try {
	let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
	n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "251f993e-a60a-4dc6-9fbf-755fad96924f", e._sentryDebugIdIdentifier = "sentry-dbid-251f993e-a60a-4dc6-9fbf-755fad96924f");
} catch (e) {}
import { o as createLogger } from "./translation-Br5wIPO-.js";
import { s as useApiContext } from "./http-CHTzpXCd.js";
import { useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";
import "preact/jsx-runtime";
import { createContext } from "preact";
//#region src/utils/testing/ignoreLocalStorage.tsx
var IgnoreLocalStorageContext = createContext(false);
var useIgnoreLocalStorage = () => useContext(IgnoreLocalStorageContext);
//#endregion
//#region src/hooks/useLocalStorage.ts
var logger = createLogger();
var useLocalStorage = (key, defaultValue, options) => {
	const { serializer, parser, syncData } = useMemo(() => ({
		serializer: JSON.stringify,
		parser: JSON.parse,
		syncData: true,
		...options
	}), [options]);
	const ignoreLocalStorage = useIgnoreLocalStorage() || typeof window === "undefined";
	const rawValueRef = useRef(null);
	const [value, setValue] = useState(() => {
		if (ignoreLocalStorage) return defaultValue;
		try {
			rawValueRef.current = window.localStorage.getItem(key);
			return rawValueRef.current ? parser(rawValueRef.current) : defaultValue;
		} catch (err) {
			logger.error(err);
			return defaultValue;
		}
	});
	useEffect(() => {
		if (ignoreLocalStorage) return;
		const updateLocalStorage = () => {
			if (value !== void 0) {
				const newValue = serializer(value);
				const oldValue = rawValueRef.current;
				rawValueRef.current = newValue;
				window.localStorage.setItem(key, newValue);
				window.dispatchEvent(new StorageEvent("storage", {
					storageArea: window.localStorage,
					url: window.location.href,
					key,
					newValue,
					oldValue
				}));
			} else {
				window.localStorage.removeItem(key);
				window.dispatchEvent(new StorageEvent("storage", {
					storageArea: window.localStorage,
					url: window.location.href,
					key
				}));
			}
		};
		try {
			updateLocalStorage();
		} catch (err) {
			logger.error(err);
		}
	}, [value, ignoreLocalStorage]);
	useEffect(() => {
		if (!syncData) return;
		const handleStorageChange = (event) => {
			if (event.key !== key || event.storageArea !== window.localStorage) return;
			try {
				if (event.newValue !== rawValueRef.current) {
					rawValueRef.current = event.newValue;
					setValue(event.newValue ? parser(event.newValue) : void 0);
				}
			} catch (err) {
				logger.error(err);
			}
		};
		if (ignoreLocalStorage) return;
		window.addEventListener("storage", handleStorageChange);
		return () => {
			window.removeEventListener("storage", handleStorageChange);
		};
	}, [
		key,
		syncData,
		ignoreLocalStorage
	]);
	return [value, setValue];
};
//#endregion
//#region src/hooks/useAccountHolder.ts
var getAccountHolderStorageKey = (legalEntityId) => `ACCOUNT_HOLDER-${legalEntityId}`;
var useAccountHolder = () => {
	const { rootLegalEntityId } = useApiContext();
	const [accountHolderFromLocalStorage, setAccountHolderIntoLocalStorage] = useLocalStorage(getAccountHolderStorageKey(rootLegalEntityId.value), void 0);
	return {
		accountHolder: accountHolderFromLocalStorage,
		setAccountHolder: setAccountHolderIntoLocalStorage
	};
};
//#endregion
export { useLocalStorage as n, useAccountHolder as t };
