import { StrictMode } from "react"
import { createRoot } from "react-dom/client"

import "./index.css"
import App from "./App.tsx"
import { ThemeProvider } from "@/components/theme-provider.tsx"
import { LegalPage, type LegalPageKind } from "@/LegalPage.tsx"

const legalPages: Record<string, LegalPageKind> = {
  "/imprint": "imprint",
  "/terms": "terms",
  "/privacy": "privacy",
}

const pathname = window.location.pathname.replace(/\/$/, "") || "/"
const legalPage = legalPages[pathname]

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <ThemeProvider defaultTheme="light" storageKey="snap-daily-theme">
      {legalPage ? <LegalPage kind={legalPage} /> : <App />}
    </ThemeProvider>
  </StrictMode>
)
