1→'use client'; 2→ 3→import { useEffect, useCallback, useRef } from 'react'; 4→import { motion, AnimatePresence } from 'framer-motion'; 5→import { 6→ Sparkles, Play, Square, Trash2, ArrowLeft, Film, 7→ Image, Mic, Loader2, Wand2, Clapperboard, Clock, 8→ ChevronLeft, ChevronRight, Pause, Volume2, VolumeX, 9→ RotateCcw, LayoutGrid, MonitorPlay 10→} from 'lucide-react'; 11→import { Button } from '@/components/ui/button'; 12→import { Textarea } from '@/components/ui/textarea'; 13→import { Slider } from '@/components/ui/slider'; 14→import { Card, CardContent } from '@/components/ui/card'; 15→import { Badge } from '@/components/ui/badge'; 16→import { Progress } from '@/components/ui/progress'; 17→import { Skeleton } from '@/components/ui/skeleton'; 18→import { useVideoStore, type VideoProject } from '@/store/video-store'; 19→import { toast } from 'sonner'; 20→ 21→const STYLES = [ 22→ { id: 'cinematic', label: 'سينمائي', icon: '🎬', desc: 'جودة سينمائية عالية' }, 23→ { id: 'anime', label: 'أنمي', icon: '🎨', desc: 'رسوم أنمي يابانية' }, 24→ { id: 'realistic', label: 'واقعي', icon: '📷', desc: 'تصوير واقعي' }, 25→ { id: 'fantasy', label: 'خيالي', icon: '🧙', desc: 'عوالم خيالية' }, 26→ { id: 'documentary', label: 'وثائقي', icon: '📹', desc: 'أسلوب وثائقي' }, 27→ { id: 'watercolor', label: 'مائي', icon: '🖌️', desc: 'رسم مائي فني' }, 28→]; 29→ 30→const EXAMPLE_PROMPTS = [ 31→ 'رحلة عبر الغابات المطيرة الاستوائية مع أصوات الطيور والشلالات', 32→ 'مدينة مستقبلية في عام 2150 مع السيارات الطائرة والأبنية الشفافة', 33→ 'قصة فتاة صغيرة تكتشف عالماً سحرياً خلف خزانة قديمة', 34→ 'غروب الشمس على شاطئ هادئ مع الأمواج والنورس الأبيض', 35→]; 36→ 37→export default function Home() { 38→ return ( 39→
40→
41→
42→ 43→
44→
46→ ); 47→} 48→ 49→/* ───────────────────── Header ───────────────────── */ 50→function Header() { 51→ const { activeView, setActiveView, projects } = useVideoStore(); 52→ 53→ return ( 54→
55→
56→ 68→ 69→ 94→
95→
96→ ); 97→} 98→ 99→/* ───────────────────── App Content Router ───────────────────── */ 100→function AppContent() { 101→ const { activeView, isGenerating } = useVideoStore(); 102→ 103→ return ( 104→ 105→ {isGenerating ? ( 106→ 113→ 114→ 115→ ) : activeView === 'player' ? ( 116→ 123→ 124→ 125→ ) : activeView === 'gallery' ? ( 126→ 133→ 134→ 135→ ) : ( 136→ 142→ 143→ 144→ )} 145→ 146→ ); 147→} 148→ 149→/* ───────────────────── Create Section ───────────────────── */ 150→function CreateSection() { 151→ const { prompt, setPrompt, selectedStyle, setSelectedStyle, sceneCount, setSceneCount, isGenerating, setIsGenerating, setGenerationProgress, setActiveView, setCurrentProject, addProject, projects, setProjects } = useVideoStore(); 152→ 153→ const handleGenerate = useCallback(async () => { 154→ if (!prompt.trim()) { 155→ toast.error('يرجى كتابة وصف للفيديو'); 156→ return; 157→ } 158→ 159→ setIsGenerating(true); 160→ setGenerationProgress({ step: 'جاري تحليل الوصف وإنشاء المشاهد...', progress: 10 }); 161→ 162→ try { 163→ const res = await fetch('/api/generate-video', { 164→ method: 'POST', 165→ headers: { 'Content-Type': 'application/json' }, 166→ body: JSON.stringify({ prompt: prompt.trim(), style: selectedStyle, sceneCount }), 167→ }); 168→ 169→ if (!res.ok) { 170→ const err = await res.json(); 171→ throw new Error(err.error || 'حدث خطأ أثناء التوليد'); 172→ } 173→ 174→ const project = await res.json(); 175→ addProject(project); 176→ setCurrentProject(project); 177→ setActiveView('player'); 178→ toast.success('تم إنشاء الفيديو بنجاح!'); 179→ } catch (err: any) { 180→ toast.error(err.message || 'حدث خطأ غير متوقع'); 181→ // Fetch updated project list 182→ try { 183→ const listRes = await fetch('/api/videos'); 184→ if (listRes.ok) { 185→ const data = await listRes.json(); 186→ setProjects(data.projects || []); 187→ } 188→ } catch { /* ignore */ } 189→ } finally { 190→ setIsGenerating(false); 191→ } 192→ }, [prompt, selectedStyle, sceneCount]); 193→ 194→ const handleExampleClick = (example: string) => { 195→ setPrompt(example); 196→ }; 197→ 198→ return ( 199→
200→ {/* Hero background */} 201→
202→ 203→
204→
205→ 206→
207→ {/* Hero Text */} 208→ 214→ 220→ 221→ مدعوم بالذكاء الاصطناعي المتقدم 222→ 223→

224→ حوّل أفكارك إلى{' '} 225→ فيديوهات مذهلة 226→

227→

228→ اكتب وصفاً لما تريده وسيقوم الذكاء الاصطناعي بإنشاء مشاهد وصور وسرد صوتي تلقائياً 229→

230→
231→ 232→ {/* Main Creation Card */} 233→ 238→ 239→ 240→ {/* Prompt Input */} 241→
242→ 246→