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] = "4d03d98a-0b49-4e76-a97f-3b7271374203", e._sentryDebugIdIdentifier = "sentry-dbid-4d03d98a-0b49-4e76-a97f-3b7271374203");
} catch (e) {}
import { n as httpGet, s as useApiContext } from "./http-CHTzpXCd.js";
import { c as entriesOf } from "./AnalyticsContext-C0HNdPss.js";
import { t as Scenarios } from "./get-scenarios-D432otQE.js";
import { skipToken, useQuery } from "@tanstack/preact-query";
//#region src/api/configurations/useScenarios.ts
var getScenarios = async (legalEntityId, baseUrl, legalEntityType, countryCode) => {
	return httpGet({
		baseUrl,
		path: `legalEntities/${legalEntityId}/configurations/scenarios?${new URLSearchParams({
			countryCode,
			legalEntityType
		})}`
	});
};
/**
* Based on country and capabilities the forms will be different. Since different combinations
* of country+capabilities often have the same result, we group them in scenarios.
*
* Note: this might not be the exact truth, and during the form completion
* some differences might arise, but it is true as a starting point.
*
* @param countryCode - need to be dynamic, might not match the legalEntityId's countryCode
* @param legalEntityType - needs to be dynamic, might not match the legalEntityId's legalEntityType
*/
var useScenarios = (countryCode, legalEntityType, options) => {
	const { rootLegalEntityId, baseUrl } = useApiContext();
	const result = useQuery({
		queryKey: countryCode === skipToken ? [] : [
			"scenarios",
			legalEntityType,
			countryCode
		],
		queryFn: countryCode === skipToken ? skipToken : () => getScenarios(rootLegalEntityId.value, baseUrl.value, legalEntityType, countryCode),
		...options,
		select: (response) => entriesOf(response).reduce((acc, [entityType, scenarios]) => {
			acc[entityType] = scenarios ? sortScenarios(scenarios) : void 0;
			return acc;
		}, {})
	});
	return {
		isLoading: result.isLoading,
		isError: result.isError,
		data: result.data?.[legalEntityType]
	};
};
/**
* Sorts scenarios according to their order within the {@link Scenarios} const.
*/
var sortScenarios = (scenarios) => Object.values(Scenarios).reduce((acc, potential) => scenarios.includes(potential) ? [...acc, potential] : acc, []);
//#endregion
export { useScenarios as t };
