import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter, Routes, Route } from "react-router";
import "./index.css";
import { AuthProvider } from "./contexts/AuthContext";
import { SupervisorQuestionsProvider } from "./contexts/SupervisorQuestionsContext";
import { GridOverlay } from "./components/GridOverlay";
import { SupervisorQuestionNotification } from "./components/SupervisorQuestionNotification";
import { PhaseConfirmationNotification } from "./components/PhaseConfirmationNotification";
import { ProtectedRoute } from "./components/ProtectedRoute";
import HomePage from "./routes/_index";
import ListenPage from "./routes/listen";
import FilesPage from "./routes/files";
import ContractsPage from "./routes/contracts";
import OrdersPage from "./routes/orders";
import MeshPage from "./routes/mesh";
import HistoryPage from "./routes/history";
import LoginPage from "./routes/login";
import SettingsPage from "./routes/settings";
import ContractFilePage from "./routes/contract-file";
import SpeakPage from "./routes/speak";
import DirectivesPage from "./routes/directives";

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <AuthProvider>
      <SupervisorQuestionsProvider>
        <BrowserRouter>
          <GridOverlay />
          <SupervisorQuestionNotification />
          <PhaseConfirmationNotification />
          <Routes>
          <Route path="/" element={<HomePage />} />
          <Route path="/login" element={<LoginPage />} />
          <Route
            path="/listen"
            element={
              <ProtectedRoute>
                <ListenPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/files"
            element={
              <ProtectedRoute>
                <FilesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/files/:id"
            element={
              <ProtectedRoute>
                <FilesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts"
            element={
              <ProtectedRoute>
                <ContractsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts/:id"
            element={
              <ProtectedRoute>
                <ContractsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/contracts/:id/files/:fileId"
            element={
              <ProtectedRoute>
                <ContractFilePage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/orders"
            element={
              <ProtectedRoute>
                <OrdersPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/orders/:id"
            element={
              <ProtectedRoute>
                <OrdersPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/mesh"
            element={
              <ProtectedRoute>
                <MeshPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/mesh/:id"
            element={
              <ProtectedRoute>
                <MeshPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/history"
            element={
              <ProtectedRoute>
                <HistoryPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/history/:id"
            element={
              <ProtectedRoute>
                <HistoryPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/settings"
            element={
              <ProtectedRoute>
                <SettingsPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/directives"
            element={
              <ProtectedRoute>
                <DirectivesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/directives/:id"
            element={
              <ProtectedRoute>
                <DirectivesPage />
              </ProtectedRoute>
            }
          />
          <Route
            path="/speak"
            element={
              <ProtectedRoute>
                <SpeakPage />
              </ProtectedRoute>
            }
          />
          </Routes>
        </BrowserRouter>
      </SupervisorQuestionsProvider>
    </AuthProvider>
  </StrictMode>
);
