import { StrictMode } from 'react';
import { createRoot } from 'react-dom/client';
import 'animal-island-ui/style';

import { ConsoleAuthGate } from './auth/console-auth.js';
import { AppShell } from './app-shell.js';
import { useBrowserPathname } from './navigation/use-browser-pathname.js';
import './styles.css';

const root = document.querySelector<HTMLElement>('#root');
if (!root) throw new Error('Missing application root');

function BrowserApp() {
  const pathname = useBrowserPathname();
  return (
    <ConsoleAuthGate>
      <AppShell pathname={pathname} />
    </ConsoleAuthGate>
  );
}

createRoot(root).render(
  <StrictMode>
    <BrowserApp />
  </StrictMode>,
);
