import { Component, type ErrorInfo, type ReactNode } from "react"; import { BrowserRouter, Navigate, Route, Routes, useLocation } from "react-router-dom"; import { Toaster } from "sonner"; import { KeyboardShortcutProvider } from "./components/common/keyboard-shortcut-provider"; import { useAuth } from "./hooks/use-auth"; import { AutomatePage } from "./pages/automate-page"; import { ChangePasswordPage } from "./pages/change-password-page"; import { FilesPage } from "./pages/files-page"; import { FullscreenGridPage } from "./pages/fullscreen-grid-page"; import { HomePage } from "./pages/home-page"; import { LoginPage } from "./pages/login-page"; import { PrivacyPolicyPage } from "./pages/privacy-policy-page"; import { ToolPage } from "./pages/tool-page"; class ErrorBoundary extends Component< { children: ReactNode }, { hasError: boolean; error: Error | null } > { constructor(props: { children: ReactNode }) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error) { return { hasError: true, error }; } componentDidCatch(error: Error, info: ErrorInfo) { console.error("Uncaught render error:", error, info.componentStack); } render() { if (this.state.hasError) { return (

Something went wrong

{this.state.error?.message || "An unexpected error occurred."}

); } return this.props.children; } } function AuthGuard({ children }: { children: React.ReactNode }) { const { loading, authEnabled, isAuthenticated, mustChangePassword } = useAuth(); const location = useLocation(); // Don't guard the login or change-password pages if ( location.pathname === "/login" || location.pathname === "/change-password" || location.pathname === "/privacy" ) { return <>{children}; } if (loading) { return (

Loading...

); } if (authEnabled && !isAuthenticated) { return ; } // Force password change before allowing access to the app if (authEnabled && mustChangePassword) { return ; } return <>{children}; } export function App() { return ( } /> } /> } /> } /> } /> } /> {/* Redirects: old color tools consolidated into adjust-colors */} } /> } /> } /> } /> } /> } /> ); }