import './App.css' import { lazy, Suspense } from 'react' import type { ReactNode } from 'react' import { BrowserRouter, Routes, Route, useLocation } from 'react-router' import { ThemeProvider } from '@/hooks/useTheme' import { Layout } from '@/components/layout/Layout' import { LanguageProvider } from '@/hooks/useLanguage' import { I18nProvider } from '@/i18n/provider' import { HomePage } from '@/pages/HomePage' // HomePage stays eager: it is the landing route and owns the LCP, so its code must // already be in the entry chunk. The other six split out and load on navigation. const AboutPage = lazy(() => import('@/pages/AboutPage').then((m) => ({ default: m.AboutPage }))) const ExperiencePage = lazy(() => import('@/pages/ExperiencePage').then((m) => ({ default: m.ExperiencePage }))) const ProjectsListPage = lazy(() => import('@/pages/ProjectsListPage').then((m) => ({ default: m.ProjectsListPage }))) const ProjectDetailPage = lazy(() => import('@/pages/ProjectDetailPage').then((m) => ({ default: m.ProjectDetailPage }))) const PhilosophyPage = lazy(() => import('@/pages/PhilosophyPage').then((m) => ({ default: m.PhilosophyPage }))) const ContactPage = lazy(() => import('@/pages/ContactPage').then((m) => ({ default: m.ContactPage }))) // Edit mode is lazy too: visitors never download the draft store, the panel // or the save pipeline (spec-v4 ยง7 P3.4). The gate only mounts the shell when // `?edit` is present; the shell then authenticates or strips the query again. const EditModeShell = lazy(() => import('@/components/layout/EditModeShell')) function MaybeEditMode({ children }: { children: ReactNode }) { const location = useLocation() const editing = new URLSearchParams(location.search).has('edit') if (!editing) return <>{children} return ( {children} ) } function App() { return ( {/* I18nProvider sits below LanguageProvider: it resolves the language through useLanguage and hands every consumer the UI/CONTENT of it. */} {/* A null fallback keeps the shell (nav, footer) painted without reserving a box that would shift the page when the route chunk lands. */} } /> } /> } /> } /> } /> } /> } /> ) } export default App