import { useEffect, useState } from 'react'; interface Props { segmentsCount: number; currentSegmentIndex?: number; // Optional for streaming mode realProgress?: number; // Optional for streaming mode generatedSegments?: any[]; // Optional for streaming mode onCancel?: () => void; isStreaming?: boolean; // If true, use real progress; if false, simulate } const GENERATION_TIPS = [ "💡 AI is analyzing your reference image for character details...", "🎬 Creating detailed camera movements for cinematic quality...", "👤 Generating character descriptions with exact physical features...", "🎭 Crafting micro-expressions and natural gestures...", "🎨 Designing scene continuity for seamless video flow...", "🎯 Ensuring dialogue syncs perfectly with actions...", "✨ Adding production-quality details to each segment...", "🔍 Cross-checking consistency across all segments...", "💾 Auto-saving your prompts for recovery...", "🎪 Almost done! Finalizing segment specifications..." ]; export function SegmentGenerationProgress({ segmentsCount, onCancel }: Props) { const [progress, setProgress] = useState(0); const [currentTip, setCurrentTip] = useState(0); const [elapsedTime, setElapsedTime] = useState(0); const [estimatedTime] = useState( segmentsCount <= 2 ? 20 : segmentsCount <= 5 ? 50 : 90 ); // Progress simulation (realistic timing based on actual API performance) useEffect(() => { const interval = setInterval(() => { setProgress(prev => { // Slow start (first 30%), medium middle (30-80%), slow end (80-100%) if (prev < 30) return prev + 0.5; // Slow start if (prev < 80) return prev + 0.8; // Medium speed if (prev < 95) return prev + 0.2; // Slow down near end return prev; // Stop at 95% until actual completion }); }, 1000); return () => clearInterval(interval); }, []); // Tip rotation useEffect(() => { const interval = setInterval(() => { setCurrentTip(prev => (prev + 1) % GENERATION_TIPS.length); }, 4000); // Change tip every 4 seconds return () => clearInterval(interval); }, []); // Elapsed time counter useEffect(() => { const interval = setInterval(() => { setElapsedTime(prev => prev + 1); }, 1000); return () => clearInterval(interval); }, []); const formatTime = (seconds: number) => { const mins = Math.floor(seconds / 60); const secs = seconds % 60; return mins > 0 ? `${mins}m ${secs}s` : `${secs}s`; }; return (
{GENERATION_TIPS[currentTip]}