import "./service/metrics";
import "setimmediate";
import dayjs from "dayjs";
import duration from "dayjs/plugin/duration";
import relativeTime from "dayjs/plugin/relativeTime";
import utc from "dayjs/plugin/utc";
import React from "react";
import ReactDOM from "react-dom";
import { BrowserRouter } from "react-router-dom";
import { RootAppRouter } from "./App";
import { QueryErrorBoundary } from "./components/error-boundaries/QueryErrorBoundary";
import { ReloadPageErrorBoundary } from "./components/error-boundaries/ReloadPageErrorBoundary";
import { ToastContextProvider } from "./components/toasts/Toasts";
import { ConfettiContextProvider } from "./contexts/ConfettiContext";
import { setupQueryClientProvider } from "./data/setup";
import "./index.css";
import { PaymentContextProvider } from "./payment-context";
import { ThemeContextProvider } from "./theme-context";
import { UserContextProvider } from "./user-context";
import { getURLHash, isGitpodIo, isWebsiteSlug } from "./utils";
const bootApp = () => {
if (isGitpodIo()) {
if (isWebsiteSlug(window.location.pathname)) {
window.location.host = "www.gitpod.io";
return;
}
}
const hash = getURLHash();
if (/^(https:\/\/)?github\.dev\//i.test(hash)) {
window.location.hash = hash.replace(/^(https:\/\/)?github\.dev\//i, "https://github.com/");
} else if (/^([^/]+?=[^/]*?|prebuild)\/(https:\/\/)?github\.dev\//i.test(hash)) {
window.location.hash = hash.replace(
/^([^/]+?=[^/]*?|prebuild)\/(https:\/\/)?github\.dev\//i,
"$1/https://github.com/",
);
}
const GitpodQueryClientProvider = setupQueryClientProvider();
dayjs.extend(relativeTime);
dayjs.extend(utc);
dayjs.extend(duration);
ReactDOM.render(
<React.StrictMode>
<ThemeContextProvider>
<ReloadPageErrorBoundary>
<BrowserRouter>
<GitpodQueryClientProvider>
{}
<QueryErrorBoundary>
<ConfettiContextProvider>
<ToastContextProvider>
<UserContextProvider>
<PaymentContextProvider>
<RootAppRouter />
</PaymentContextProvider>
</UserContextProvider>
</ToastContextProvider>
</ConfettiContextProvider>
</QueryErrorBoundary>
</GitpodQueryClientProvider>
</BrowserRouter>
</ReloadPageErrorBoundary>
</ThemeContextProvider>
</React.StrictMode>,
document.getElementById("root"),
);
};
bootApp();