// App entrypoint: wires the TanStack Query cache (api/queryClient.ts), RTL
// (emotion CacheProvider + stylis-plugin-rtl) and the MUI theme (theme.ts)
// around the whole app. `dir="rtl"` is also set on
// <html> in index.html so the initial paint (before React mounts) is
// correct too.
import { StrictMode } from "react";
import { createRoot } from "react-dom/client";
import { CacheProvider } from "@emotion/react";
import { CssBaseline, ThemeProvider } from "@mui/material";
import { QueryClientProvider } from "@tanstack/react-query";
import { App } from "./App";
import { queryClient } from "./api/queryClient";
import { theme } from "./theme/theme";
import { rtlCache } from "./theme/rtlCache";
import "./index.css";

createRoot(document.getElementById("root")!).render(
  <StrictMode>
    <QueryClientProvider client={queryClient}>
      <CacheProvider value={rtlCache}>
        <ThemeProvider theme={theme}>
          <CssBaseline />
          <App />
        </ThemeProvider>
      </CacheProvider>
    </QueryClientProvider>
  </StrictMode>,
);
