import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import "./scss/app.scss";
// import "@stripe/stripe-js";
import ErrorBoundary from "./ErrorBoundary.tsx";
import ReactGA from "react-ga4";
import { initFacebookPixel } from "./utilities/metaPixel/metaPixel.ts";
import { ThemeProvider } from "@mui/material/styles";
import theme from "./theme/theme.ts";
import CssBaseline from "@mui/material/CssBaseline";
import { RapidContextProvider } from "./rapidContextProvider/RapidContextProvider.tsx";

//
//sets up google analytics, if we are on production
if (import.meta.env.VITE_CURRENT_ENVIRONMENT == "production") {
  try {
    initFacebookPixel();
    ReactGA.initialize(import.meta.env.VITE_GOOGLE_ANALYTICS_MEASUREMENT_ID);
  } catch (error) {
    console.log({ errorIssue: error });
  }
}

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
  // <React.StrictMode>
  <ErrorBoundary>
    <ThemeProvider theme={theme}>
      <CssBaseline /> {/* Normalizes MUI baseline styles */}
      <RapidContextProvider>
        <App />
      </RapidContextProvider>
    </ThemeProvider>
  </ErrorBoundary>
  // </React.StrictMode>
);
