import {StrictMode} from 'react';
import {createRoot} from 'react-dom/client';
import App, {type PageRoute} from './App.tsx';
import './index.css';

const rootEl = document.getElementById('root')!;
const datasetPage = rootEl.dataset.page as PageRoute | undefined;

function detectPageFromPath(): PageRoute {
  const path = window.location.pathname.toLowerCase();
  if (path.includes('about')) return 'about';
  if (path.includes('rooms')) return 'rooms';
  if (path.includes('gallery')) return 'gallery';
  if (path.includes('contact')) return 'contact';
  if (path.includes('privacy-policy')) return 'privacy-policy';
  if (path.includes('terms')) return 'terms';
  return 'home';
}

const activePage: PageRoute = datasetPage || detectPageFromPath();

createRoot(rootEl).render(
  <StrictMode>
    <App page={activePage} />
  </StrictMode>
);
