import "katex/dist/katex.min.css";

import { Home } from "./pages/student/Home";
import {
  createBrowserRouter,
  Navigate,
  RouterProvider,
} from "react-router-dom";
import { ProtectedRoute } from "./components/ProtectedRoute";
import { Login } from "./pages/auth/Login";
import { Lessons } from "./pages/student/Lessons";
import { Practice } from "./pages/student/Practice";
import { Pretest } from "./pages/student/practice/Pretest";
import { Results } from "./pages/student/practice/Results";
import { Test } from "./pages/student/practice/Test";
import { Profile } from "./pages/student/Profile";
import { Rewards } from "./pages/student/Rewards";
import { StudentLayout } from "./pages/student/StudentLayout";
import { TargetedPractice } from "./pages/student/targeted-practice/page";
import { Drills } from "./pages/student/drills/page";
import { HardTestModules } from "./pages/student/hard-test-modules/page";
import { Analytics } from "./pages/student/Analytics";
import { QuestMap } from "./pages/student/QuestMap";
import ErrorPage from "./pages/ErrorPage";

function App() {
  const router = createBrowserRouter([
    {
      path: "/login",
      element: <Login />,
    },
    {
      path: "/student",
      element: <ProtectedRoute />,
      children: [
        {
          element: <StudentLayout />,
          children: [
            {
              path: "home",
              element: <Home />,
            },
            {
              path: "practice",
              element: <Practice />,
            },
            {
              path: "lessons",
              element: <Lessons />,
            },
            {
              path: "rewards",
              element: <Rewards />,
            },
            {
              path: "profile",
              element: <Profile />,
            },
            {
              path: "analytics",
              element: <Analytics />,
            },
            {
              path: "quests",
              element: <QuestMap />,
            },
            {
              path: "practice/:sheetId",
              element: <Pretest />,
            },
            {
              path: "practice/targeted-practice",
              element: <TargetedPractice />,
            },
            {
              path: "practice/drills",
              element: <Drills />,
            },
            {
              path: "practice/hard-test-modules",
              element: <HardTestModules />,
            },
          ],
        },
        {
          path: "practice/:sheetId/test",
          element: <Test />,
        },
        {
          path: "practice/:sheetId/test/results",
          element: <Results />,
        },
      ],
    },
    {
      path: "/",
      element: <Navigate to="/student/home" replace />,
    },
    {
      path: "*",
      element: <Navigate to="/student/home" replace />,
    },
  ]);

  return <RouterProvider router={router} />;
}

export default App;
