import React, { useState, useEffect, Suspense } from 'react';
import { GameProvider, useGame } from './context/GameContext';
import { Monitor, Smartphone, LayoutDashboard, Loader2, RefreshCw, Lock } from 'lucide-react';
const HostView = React.lazy(() => import('./components/HostView').then(module => ({ default: module.HostView })));
const PlayerView = React.lazy(() => import('./components/PlayerView').then(module => ({ default: module.PlayerView })));
const SpectatorView = React.lazy(() => import('./components/SpectatorView').then(module => ({ default: module.SpectatorView })));
const LoginScreen: React.FC = () => {
const { login } = useGame();
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setLoading(true);
setError('');
const success = await login(password);
if (!success) {
setError('Invalid Password');
}
setLoading(false);
};
return (
);
};
const AppContent: React.FC = () => {
const { setIsHost, isSyncing, isAuthenticated } = useGame();
const [view, setView] = useState<'HOST' | 'PLAYER' | 'SPECTATOR'>('SPECTATOR');
useEffect(() => {
const handleHashChange = () => {
const hash = window.location.hash;
if (hash === '#host') {
setView('HOST');
setIsHost(true);
}
else if (hash === '#player') {
setView('PLAYER');
setIsHost(false);
}
else {
setView('SPECTATOR');
setIsHost(false);
}
};
handleHashChange();
window.addEventListener('hashchange', handleHashChange);
return () => window.removeEventListener('hashchange', handleHashChange);
}, [setIsHost]);
const navigate = (newView: 'HOST' | 'PLAYER' | 'SPECTATOR') => {
setView(newView);
window.location.hash = newView.toLowerCase();
};
const renderView = () => {
switch (view) {
case 'HOST':
return isAuthenticated ? : ;
case 'PLAYER': return ;
case 'SPECTATOR': return ;
default: return ;
}
};
return (
{/* Top Navigation Bar */}
{/* Main Content Area */}
}>
{renderView()}
);
};
const App: React.FC = () => {
return (
);
};
interface NavButtonProps {
active: boolean;
onClick: () => void;
icon: React.ReactNode;
label: string;
}
const NavButton: React.FC = ({ active, onClick, icon, label }) => (
);
export default App;