import { storeInitialTenant } from "../utilities/storage/UnitySessionStorage.mjs";
import { ThemeProvider } from "../utilities/theme/theme.mjs";
import { storeInitialPath } from "../utilities/redirect/LocalRedirectUrlStorage.mjs";
import { AuthProvider } from "../utilities/auth/AuthProvider.mjs";
import { initializeUnityI18n } from "../utilities/i18n/initializeI18n.mjs";
import { QueryProvider } from "./QueryProvider.mjs";
import { c } from "react-compiler-runtime";
import React, { useEffect } from "react";
import { SnackbarProvider } from "notistack";
import { BrowserRouter } from "react-router-dom";
//#region src/providers/UdpAppProvider.tsx
/**
* Bundles the core UDP providers (theme, snackbar, auth) and ensures the shared
* i18n instance is initialised exactly once. Intended to be rendered beneath a
* react-router <Router /> so the auth provider has access to history.
*/
const UdpAppProvider = (t0) => {
	const $ = c(12);
	const { children, snackbarProps, authProps, i18nOptions, devTools } = t0;
	let t1;
	let t2;
	if ($[0] !== i18nOptions) {
		t1 = () => {
			initializeUnityI18n(i18nOptions);
		};
		t2 = [i18nOptions];
		$[0] = i18nOptions;
		$[1] = t1;
		$[2] = t2;
	} else {
		t1 = $[1];
		t2 = $[2];
	}
	useEffect(t1, t2);
	storeInitialPath();
	storeInitialTenant();
	const t3 = devTools?.query;
	let t4;
	if ($[3] !== children || $[4] !== snackbarProps) {
		t4 = /* @__PURE__ */ React.createElement(BrowserRouter, null, /* @__PURE__ */ React.createElement(SnackbarProvider, {
			maxSnack: 3,
			...snackbarProps
		}, children));
		$[3] = children;
		$[4] = snackbarProps;
		$[5] = t4;
	} else t4 = $[5];
	let t5;
	if ($[6] !== authProps || $[7] !== t4) {
		t5 = /* @__PURE__ */ React.createElement(AuthProvider, authProps, t4);
		$[6] = authProps;
		$[7] = t4;
		$[8] = t5;
	} else t5 = $[8];
	let t6;
	if ($[9] !== t3 || $[10] !== t5) {
		t6 = /* @__PURE__ */ React.createElement(ThemeProvider, null, /* @__PURE__ */ React.createElement(QueryProvider, { showDevTools: t3 }, t5));
		$[9] = t3;
		$[10] = t5;
		$[11] = t6;
	} else t6 = $[11];
	return t6;
};
//#endregion
export { UdpAppProvider };

//# sourceMappingURL=UdpAppProvider.mjs.map