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] = "8174a6ae-b34e-467f-9b3a-6d96dc3f0b12", e._sentryDebugIdIdentifier = "sentry-dbid-8174a6ae-b34e-467f-9b3a-6d96dc3f0b12");
} catch (e) {}
import { o as createLogger, r as useTranslation } from "./translation-Br5wIPO-.js";
import { n as datasetUtilities, t as datasetIdentifier } from "./datasetUtil-BZmNUckr.js";
import { useEffect, useState } from "preact/hooks";
//#region src/datasets/generators/loadCountries.ts
var logger$1 = createLogger();
var countriesImports = /* @__PURE__ */ Object.assign({
	"../countries/de-DE.json": () => import("./de-DE-CKOOKYoC.js"),
	"../countries/el-GR.json": () => import("./el-GR-DfW8zYK4.js"),
	"../countries/en-US.json": () => import("./en-US-CuX4Fzoo.js"),
	"../countries/es-ES.json": () => import("./es-ES-Bwhnseeu.js"),
	"../countries/fr-FR.json": () => import("./fr-FR-Duc4nlp1.js"),
	"../countries/it-IT.json": () => import("./it-IT-3PSb6tzc.js"),
	"../countries/ja-JP.json": () => import("./ja-JP-wmwnTtNd.js"),
	"../countries/nl-NL.json": () => import("./nl-NL-BLie9b-e.js"),
	"../countries/pt-PT.json": () => import("./pt-PT-Czy2_X1t.js"),
	"../countries/sv-SE.json": () => import("./sv-SE-CBNLo-2r.js")
});
var loadCountriesDataset = async (locale) => {
	const importForLocale = countriesImports[`../countries/${locale}.json`];
	if (!importForLocale) {
		logger$1.warn(`No countries dataset for ${locale}, falling back to en-US`);
		return (await import("./en-US-CuX4Fzoo.js")).default;
	}
	return (await importForLocale()).default;
};
//#endregion
//#region src/datasets/generators/loadStatesDataset.ts
var logger = createLogger();
var statesImports = /* @__PURE__ */ Object.assign({
	"../states/AU/en-US.json": () => import("./en-US-RmklpZAK.js"),
	"../states/BR/en-US.json": () => import("./en-US-CUsu9qhV.js"),
	"../states/BR/pt-BR.json": () => import("./pt-BR-CTxtcXRe.js"),
	"../states/CA/en-US.json": () => import("./en-US-NaoNaTO0.js"),
	"../states/JP/en-US.json": () => import("./en-US-DrAjiabh.js"),
	"../states/JP/ja-JP.json": () => import("./ja-JP-C7tIgG_I.js"),
	"../states/NZ/en-US.json": () => import("./en-US-C0SrG99u.js"),
	"../states/US/en-US.json": () => import("./en-US-CO9Ct3Xx.js")
});
var loadStatesDataset = async (country, locale) => {
	const importForLocale = statesImports[`../states/${country}/${locale}.json`];
	if (!importForLocale) {
		logger.warn(`No ${country} states dataset for ${locale}, falling back to en-US`);
		const fallbackImport = statesImports[`../states/${country}/en-US.json`];
		return (await fallbackImport()).default;
	}
	return (await importForLocale()).default;
};
//#endregion
//#region src/core/services/agnostic/get-dataset.ts
var loadDataset = async (identifier, locale) => {
	if (identifier === datasetIdentifier.country) return loadCountriesDataset(locale);
	if (identifier.startsWith("states")) return loadStatesDataset(identifier.slice(identifier.indexOf("/") + 1), locale);
	throw new Error(`Unknown dataset: ${identifier}`);
};
var getDataset = async (identifier, locale) => {
	const datasetUtils = datasetUtilities(locale);
	const dataset = datasetUtils.getDataset(identifier);
	if (dataset) return new Promise((resolve) => {
		resolve(dataset);
	});
	return loadDataset(identifier, locale).then((datasetResponse) => {
		datasetUtils.setDataset(identifier, datasetResponse);
		return datasetResponse;
	});
};
//#endregion
//#region src/hooks/useDataset.ts
function useDataset(datasetIdentifier, skip) {
	const { i18n } = useTranslation();
	const [dataset, setDataset] = useState([]);
	const [loaded, setLoaded] = useState(false);
	useEffect(() => {
		if (skip) return;
		getDataset(datasetIdentifier, i18n.language).then((response) => {
			setDataset(response && response.length ? response : []);
		}).catch(() => {
			setDataset([]);
		}).finally(() => {
			setLoaded(true);
		});
	}, [
		datasetIdentifier,
		i18n.language,
		skip
	]);
	return {
		dataset,
		loaded
	};
}
//#endregion
export { useDataset as t };
