import { createRoot } from "react-dom/client";
import "./index.css";
import { Router } from "./pages/router";
import "react-toastify/dist/ReactToastify.css";

import { URQL as URQLContext } from "./contexts/URQL";
import ProjectContext from "./contexts/ProjectContext";
import UserContext from "./contexts/UserContext";
import AppStateContext from "./contexts/AppContext";
import AuthContext from "./contexts/AuthContext";

const root = createRoot(document.querySelector("#root"));

if (process.env.DEBUG) {
  localStorage.debug = process.env.DEBUG;
}

root.render(
  <AuthContext>
    <URQLContext>
      <AppStateContext>
        <UserContext>
          <ProjectContext>
            <Router />
          </ProjectContext>
        </UserContext>
      </AppStateContext>
    </URQLContext>
  </AuthContext>,
);
