;
{
  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] = "565e645f-a1dd-4b3b-9e1b-ebc5743849fe", e._sentryDebugIdIdentifier = "sentry-dbid-565e645f-a1dd-4b3b-9e1b-ebc5743849fe");
  } catch (e) {
  }
}
;
import { useQuery, skipToken } from "@tanstack/preact-query";
import { b as useApiContext, ac as entriesOf, ay as Scenarios, k as httpGet } from "./StoreProvider-CqQrndhS.js";
const getScenarios = async (legalEntityId, baseUrl, legalEntityType, countryCode) => {
  const scenarioParams = new URLSearchParams({
    countryCode,
    legalEntityType
  });
  return httpGet({
    baseUrl,
    path: `legalEntities/${legalEntityId}/configurations/scenarios?${scenarioParams}`
  });
};
const 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) => (
      // Sort all scenarios
      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]
  };
};
const sortScenarios = (scenarios) => Object.values(Scenarios).reduce(
  (acc, potential) => scenarios.includes(potential) ? [...acc, potential] : acc,
  []
);
export {
  useScenarios as u
};
