"use client"; import { useState, useEffect } from "react"; import { Download, Music, Film, Mic, Eye, Star, Scissors, Type, CheckCircle2, AlertCircle, Zap, Brain, LucideProps, } from "lucide-react"; type LucideIcon = React.ComponentType; const STAGES: Record = { download: { en: "Download Video", th: "ดาวน์โหลดวิดีโอ", zh: "下载视频", Icon: Download }, audio: { en: "Extract Audio", th: "แยกเสียง", zh: "提取音频", Icon: Music }, scenes: { en: "Scene Detection", th: "ตรวจจับฉาก", zh: "场景检测", Icon: Film }, transcribe:{ en: "Transcribe", th: "ถอดเสียง (Whisper)", zh: "语音转录", Icon: Mic }, vision: { en: "Vision Analysis", th: "วิเคราะห์ด้วย AI", zh: "视觉分析", Icon: Eye }, scoring: { en: "Highlight Scoring", th: "คัดเลือกไฮไลท์", zh: "精彩评分", Icon: Star }, cutting: { en: "Cut Clips", th: "ตัดคลิป", zh: "剪切片段", Icon: Scissors }, subtitles: { en: "Generate Subtitles",th: "สร้างซับไตเติ้ล", zh: "生成字幕", Icon: Type }, done: { en: "Done!", th: "เสร็จสิ้น!", zh: "完成!", Icon: CheckCircle2 }, error: { en: "Error", th: "เกิดข้อผิดพลาด", zh: "错误", Icon: AlertCircle }, }; type Lang = "en" | "th" | "zh"; interface Props { stage: string; pct: number; message: string; uiLang?: Lang; } export default function GenerationProgress({ stage, pct, message, uiLang = "en" }: Props) { const info = STAGES[stage] ?? { en: stage, th: stage, zh: stage, Icon: Film }; const Icon = info.Icon; const label = uiLang === "th" ? info.th : uiLang === "zh" ? info.zh : info.en; const isError = stage === "error"; // Fake progress: slowly animate toward 4% when real pct is 0 (pipeline just started) const [fakePct, setFakePct] = useState(0); useEffect(() => { if (pct > 0 || isError || stage === "done") { setFakePct(0); return; } const id = setInterval(() => setFakePct((p) => Math.min(p + 0.3, 4)), 400); return () => clearInterval(id); }, [pct, isError, stage]); const displayPct = Math.max(pct, Math.round(fakePct * 10) / 10); const progressLabel = uiLang === "th" ? "ความคืบหน้า" : uiLang === "zh" ? "处理进度" : "Progress"; return (
{/* AMD badge */}
AMD ROCm GPU Processing
{/* Stage icon + label */}

{label}

{message &&

{message}

}
{/* Progress bar */}
{progressLabel} {displayPct}%
= 100 ? "bg-green-500" : "bg-gradient-to-r from-violet-500 via-fuchsia-500 to-pink-500" }`} style={{ width: `${displayPct}%` }} />
{/* Stage grid */}
{Object.entries(STAGES) .filter(([k]) => k !== "error") .map(([key, val], i, arr) => { const stageKeys = arr.map(([k]) => k); const currentIdx = stageKeys.indexOf(stage); const done = i < currentIdx; const active = i === currentIdx; const StageIcon = val.Icon; const stageLabel = uiLang === "th" ? val.th : uiLang === "zh" ? val.zh : val.en; return (
{stageLabel.split(" ")[0]}
); })}
{/* Multimodal info — compact single line */} {(stage === "vision" || stage === "transcribe") && (
{uiLang === "th" ? "Multimodal AI: Whisper ROCm · Qwen2.5-VL · librosa" : uiLang === "zh" ? "多模态 AI: Whisper ROCm · Qwen2.5-VL · librosa" : "Multimodal AI: Whisper ROCm · Qwen2.5-VL · librosa"}
)}
); }