import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { BrowserRouter, Outlet, Route, Routes } from "react-router";
import { AppShell } from "@/components/layout/app-shell";
import { AuthGuard } from "@/components/layout/auth-guard";
import { RoleRouter } from "@/components/layout/role-router";
import { NotFound } from "@/pages/not-found";
import { AllLeadsPage } from "@/pages/all-leads";
import { CallDeskPage } from "@/pages/call-desk";
import { CallHistoryPage } from "@/pages/call-history";
import { CampaignDetailPage } from "@/pages/campaign-detail";
import { CampaignsPage } from "@/pages/campaigns";
import { FollowUpsPage } from "@/pages/follow-ups-page";
import { LoginPage } from "@/pages/login";
import { OutreachPage } from "@/pages/outreach";
import { Patient360Page } from "@/pages/patient-360";
import { ReportsPage } from "@/pages/reports";
import { PatientsPage } from "@/pages/patients";
import { TeamDashboardPage } from "@/pages/team-dashboard";
import { IntegrationsPage } from "@/pages/integrations";
import { AgentDetailPage } from "@/pages/agent-detail";
import { SettingsPage } from "@/pages/settings";
import { MyPerformancePage } from "@/pages/my-performance";
import { AuthProvider } from "@/providers/auth-provider";
import { DataProvider } from "@/providers/data-provider";
import { RouteProvider } from "@/providers/router-provider";
import { ThemeProvider } from "@/providers/theme-provider";
import { Toaster } from "@/components/application/notifications/toaster";
import "@/styles/globals.css";

createRoot(document.getElementById("root")!).render(
    <StrictMode>
        <ThemeProvider>
            <AuthProvider>
                <DataProvider>
                    <BrowserRouter>
                        <RouteProvider>
                    <Routes>
                        <Route path="/login" element={<LoginPage />} />
                        <Route element={<AuthGuard />}>
                            <Route
                                element={
                                    <AppShell>
                                        <Outlet />
                                    </AppShell>
                                }
                            >
                                <Route path="/" element={<RoleRouter />} />
                                <Route path="/leads" element={<AllLeadsPage />} />
                                <Route path="/campaigns" element={<CampaignsPage />} />
                                <Route path="/campaigns/:id" element={<CampaignDetailPage />} />
                                <Route path="/outreach" element={<OutreachPage />} />
                                <Route path="/follow-ups" element={<FollowUpsPage />} />
                                <Route path="/call-history" element={<CallHistoryPage />} />
                                <Route path="/my-performance" element={<MyPerformancePage />} />
                                <Route path="/call-desk" element={<CallDeskPage />} />
                                <Route path="/patients" element={<PatientsPage />} />
                                <Route path="/team-dashboard" element={<TeamDashboardPage />} />
                                <Route path="/reports" element={<ReportsPage />} />
                                <Route path="/integrations" element={<IntegrationsPage />} />
                                <Route path="/settings" element={<SettingsPage />} />
                                <Route path="/agent/:id" element={<AgentDetailPage />} />
                                <Route path="/patient/:id" element={<Patient360Page />} />
                                <Route path="*" element={<NotFound />} />
                            </Route>
                        </Route>
                    </Routes>
                        </RouteProvider>
                    </BrowserRouter>
                </DataProvider>
            </AuthProvider>
        </ThemeProvider>
        <Toaster />
    </StrictMode>,
);
