import { useEffect, useState } from "react"; import { Wand2, PenLine, Globe, Settings2, BrainCircuit, Check } from "lucide-react"; type Stage = { icon: any; label: string; description: string; }; const STAGES: Stage[] = [ { icon: Wand2, label: "Setting the scene", description: "Crafting a believable situation around your topic.", }, { icon: PenLine, label: "Writing the dialogue", description: "Generating natural turn-by-turn conversation.", }, { icon: Globe, label: "Adding translations", description: "Aligning each line with your native language.", }, { icon: Settings2, label: "Polishing details", description: "Tuning vocabulary to your level and style.", }, ]; const STAGE_DURATIONS_MS = [2800, 4200, 5500, 7000]; export function GeneratingDialogueProgress({ scenario }: { scenario: string }) { const [stageIndex, setStageIndex] = useState(0); const [progress, setProgress] = useState(4); useEffect(() => { const timers: ReturnType[] = []; let elapsed = 0; STAGE_DURATIONS_MS.forEach((duration, i) => { elapsed += duration; if (i < STAGES.length - 1) { timers.push(setTimeout(() => setStageIndex(i + 1), elapsed)); } }); return () => timers.forEach(clearTimeout); }, []); useEffect(() => { const id = setInterval(() => { setProgress((prev) => { if (prev >= 92) return prev; const delta = prev < 60 ? 1.5 : prev < 80 ? 0.7 : 0.25; return Math.min(92, prev + delta); }); }, 250); return () => clearInterval(id); }, []); return (
Generating dialogue

{scenario}

{STAGES[stageIndex].label} {Math.round(progress)}%
    {STAGES.map((stage, index) => { const isDone = index < stageIndex; const isActive = index === stageIndex; const Icon = stage.icon; return (
  • {isDone ? : }
    {stage.label} {isActive && ( )}
    {stage.description}
  • ); })}

Hang tight — generating a custom dialogue can take up to 30 seconds.

); }