import ReactDOM from "react-dom/client";
import App from "./App.jsx";
import "./index.css";
import { BrowserRouter as Router } from "react-router-dom";
import { ToggleContextProvider } from "./context/ToggleContext.jsx";
import { AuthContextProvider } from "./context/AuthContext.jsx";
import { UserContextProvider } from "./context/UserContext.jsx";
import { ProfImgContextProvider } from "./context/ProfImg.jsx";
import { ToastContainer } from "react-toastify";
import { SearchLoadContextProvider } from "./context/SearchLoadContext.jsx";
import { LocalizationProvider } from "@mui/x-date-pickers";
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
import { WsContextProvider } from "./context/WsContext.jsx";
import { CurrentLvlContextProvider } from "./context/CurrentLvlContext.jsx";
import { LevelContextProvider } from "./context/LevelContext.jsx";
import { FacultyContextProvider } from "./context/FacultyContext.jsx";
import { DeptContextProvider } from "./context/DeptContext.jsx";
import { PubContextProvider } from "./context/PubContext.jsx";
import { ConfContextProvider } from "./context/ConfContext.jsx";
import { FacultyIdContextProvider } from "./context/FacultyIdContext.jsx";
import { DownloadsContextProvider } from "./context/DownloadsContext.jsx";
import { RangeContextProvider } from "./context/RangeContext.jsx";
import { GoalsContextProvider } from "./context/GoalsContext.jsx";
import { ThemeProvider } from "@mui/material";
import theme from "./theme.js";
import { ThemeContextProvider } from "./context/ThemeContext.jsx";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
const queryClient = new QueryClient();
ReactDOM.createRoot(document.getElementById("root")).render(
  <LocalizationProvider dateAdapter={AdapterDayjs}>
    <AuthContextProvider>
      <ThemeContextProvider>
        <DeptContextProvider>
          <CurrentLvlContextProvider>
            <FacultyIdContextProvider>
              <SearchLoadContextProvider>
                <UserContextProvider>
                  <LevelContextProvider>
                    <WsContextProvider>
                      <ProfImgContextProvider>
                        <FacultyContextProvider>
                          <ConfContextProvider>
                            <PubContextProvider>
                              <RangeContextProvider>
                                <ToggleContextProvider>
                                  <DownloadsContextProvider>
                                    <GoalsContextProvider>
                                      <ThemeProvider theme={theme}>
                                        <Router>
                                          <QueryClientProvider
                                            client={queryClient}
                                          >
                                            <App />

                                            {import.meta.env.DEV && (
                                              <ReactQueryDevtools
                                                initialIsOpen={false}
                                              />
                                            )}
                                          </QueryClientProvider>
                                        </Router>
                                      </ThemeProvider>
                                    </GoalsContextProvider>
                                    <ToastContainer />
                                  </DownloadsContextProvider>
                                </ToggleContextProvider>
                              </RangeContextProvider>
                            </PubContextProvider>
                          </ConfContextProvider>
                        </FacultyContextProvider>
                      </ProfImgContextProvider>
                    </WsContextProvider>
                  </LevelContextProvider>
                </UserContextProvider>
              </SearchLoadContextProvider>
            </FacultyIdContextProvider>
          </CurrentLvlContextProvider>
        </DeptContextProvider>
      </ThemeContextProvider>
    </AuthContextProvider>
  </LocalizationProvider>,
);
