import { useState, useEffect, Suspense } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Badge } from '@/components/ui/badge'; import { Mic, Volume2, Brain, Globe, Zap, Users, Sparkles, Sun, Moon, ArrowDown, Music } from 'lucide-react'; import VoiceEnrollment from '@/components/forms/VoiceEnrollment'; import SpeechSynthesis from '@/components/forms/SpeechSynthesis'; import { SongGeneration } from '@/components/forms/SongGeneration'; import ParticleField from '@/components/three/ParticleField'; import FloatingElements from '@/components/three/FloatingElements'; import ErrorBoundary from '@/components/common/ErrorBoundary'; import { useToast } from '@/hooks/use-toast'; import Spline from '@splinetool/react-spline'; interface Voice { id: string; name: string; audioUrl?: string; createdAt: string; } const Index = () => { const [enrolledVoices, setEnrolledVoices] = useState([]); const [language, setLanguage] = useState<'english' | 'hindi'>('english'); const { toast } = useToast(); const [theme, setTheme] = useState<'dark' | 'light'>('dark'); useEffect(() => { const saved = (localStorage.getItem('theme') as 'dark' | 'light' | null); const initial = saved ?? 'dark'; setTheme(initial); document.documentElement.classList.toggle('light', initial === 'light'); }, []); const toggleTheme = () => { const next = theme === 'dark' ? 'light' : 'dark'; setTheme(next); document.documentElement.classList.toggle('light', next === 'light'); localStorage.setItem('theme', next); }; const handleVoiceEnrollment = (voiceData: Voice) => { setEnrolledVoices(prev => [...prev, voiceData]); }; const handleSynthesisComplete = (audioUrl: string) => { console.log('Synthesis completed:', audioUrl); }; // Demo info - no backend required to test const showDemoInfo = () => { toast({ title: "Demo ready", description: "This demo runs fully in your browser. Use Voice Enrollment to add a sample voice and Speech Synthesis to generate audio.", duration: 5000 }); const enrollTab = document.querySelector('[value="enroll"]') as HTMLElement | null; enrollTab?.click(); enrollTab?.scrollIntoView({ behavior: 'smooth', block: 'center' }); }; return (
{/* Light theme site-wide gradient background overlay */}
{/* Theme Toggle - Moved to bottom right corner */}
{/* 3D Hero Section */}
Loading 3D Experience...
}>
{ try { // Align the camera to face the user and center the scene const cam = spline.findObjectByName?.('Personal Camera') || spline.findObjectByName?.('Camera') || spline.findObjectByName?.('Main Camera') || spline.findObjectByName?.('camera') || spline.findObjectByName?.('Perspective Camera'); if (cam) { // Shift view left: move camera to the right along X, keep Y/Z and rotation intact cam.position.x = (cam.position?.x ?? 0) + 300; } } catch (e) { console.warn('Spline camera adjust failed:', e); } // Keep default zoom level for the intended view if (spline.setZoom) spline.setZoom(1); }} />