/* App router + main layout */ const APP_ROUTES = ['home','about','services','service-detail','cases','case-detail','articles','article-detail','prices','platforms','contact']; const HASH_ROUTES = ['home','about','services','cases','articles','prices','platforms','contact']; function normalizedPath(path) { if (!path || path === '/') return '/'; return path.endsWith('/') ? path : `${path}/`; } function routeFromPath(path) { const current = normalizedPath(path); if (current === '/') return 'home'; if (current === '/about/') return 'about'; if (current === '/services/') return 'services'; if (current.startsWith('/services/')) return 'service-detail'; if (current === '/cases/') return 'cases'; if (current.startsWith('/cases/')) return 'case-detail'; if (current === '/articles/') return 'articles'; if (current.startsWith('/articles/')) return 'article-detail'; if (current === '/prices/') return 'prices'; if (current === '/platforms/') return 'platforms'; if (current === '/contact/') return 'contact'; return window.__INITIAL_ROUTE__ || 'home'; } function routeFromHash() { const value = window.location.hash.replace(/^#\/?/, '').replace(/\/$/, ''); return HASH_ROUTES.includes(value) ? value : ''; } function routeFromLocation() { return routeFromHash() || routeFromPath(window.location.pathname); } function canonicalPathForRoute(route) { const current = normalizedPath(window.location.pathname); if (route === 'service-detail' && current.startsWith('/services/') && current !== '/services/') return current; if (route === 'case-detail' && current.startsWith('/cases/') && current !== '/cases/') return current; if (route === 'article-detail' && current.startsWith('/articles/') && current !== '/articles/') return current; return routeHref(route); } function App() { const [route, setRoute] = React.useState(routeFromLocation); React.useEffect(() => { const onPopState = () => setRoute(routeFromLocation()); window.addEventListener('popstate', onPopState); return () => window.removeEventListener('popstate', onPopState); }, []); React.useEffect(() => { const nextPath = canonicalPathForRoute(route); if (!nextPath) return; if (window.location.pathname === nextPath && !window.location.hash) return; const method = window.location.hash ? 'replaceState' : 'pushState'; window.history[method]({ route }, '', nextPath); }, [route]); return (