;
{
  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] = "9b018eaa-4558-440c-b800-48b5eb4a0174", e._sentryDebugIdIdentifier = "sentry-dbid-9b018eaa-4558-440c-b800-48b5eb4a0174");
  } catch (e) {
  }
}
;
import { c as useLegalEntity, v as useExperimentsContext, g as getLegalEntityCountry, u as useTranslation, a as addResourceBundles, L as Loader, a7 as noop, j as TaskTypes, a8 as EntityTypes, o as LegalEntityTypes, _ as __variableDynamicImportRuntimeHelper, b8 as individualOnfidoBaseMapping } from "./StoreProvider-CqQrndhS.js";
import { jsx } from "preact/jsx-runtime";
import { skipToken } from "@tanstack/preact-query";
import { useParams } from "wouter-preact";
import { u as useScenarios } from "./useScenarios-CcJjvY9u.js";
import { u as useCapabilityProblems, g as getProblemsForEntity } from "./getProblemsForEntity-C1PgQbDM.js";
import { g as getTrustedFieldsProvider, b as getTrustedFields, a as getTrustedEntityAssociations } from "./getTrustedFields-C5-mXl-l.js";
import { i as isBafinSignatoryFlow, r as removeIdVerificationProblemsForBafinSignatory } from "./bafinUtils-5hCwQF0u.js";
import { I as IndividualOnfidoDropin } from "./IndividualDropin-Dc6nJvrr.js";
function DecisionMakerDetailsPage({
  decisionMakerId: decisionMakerIdProp,
  parentCompanyId: parentCompanyIdProp,
  taskType = TaskTypes.DECISION_MAKER,
  asModal,
  hideSidebar,
  isTargetLegalEntityType,
  onSubmit,
  handleBackClick,
  handleCloseClick,
  handleHomeClick = noop
}) {
  const routeParams = useParams();
  const parentCompanyId = parentCompanyIdProp ?? routeParams.parentId;
  const decisionMakerId = decisionMakerIdProp ?? routeParams.decisionMakerId;
  const { data: decisionMakerLe } = useLegalEntity(decisionMakerId ?? skipToken);
  const { data: parentCompanyLe } = useLegalEntity(parentCompanyId ?? skipToken);
  const capabilityProblems = useCapabilityProblems();
  const { isExperimentEnabled } = useExperimentsContext();
  const { data: scenarios } = useScenarios(
    (parentCompanyLe && getLegalEntityCountry(parentCompanyLe)) ?? skipToken,
    LegalEntityTypes.INDIVIDUAL
  );
  const { i18n } = useTranslation();
  addResourceBundles(i18n, [
    { ns: "individual", importFn: (lang) => __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "../language/bg-BG.json": () => import("./bg-BG-wMYXZGDQ.js"), "../language/cs-CZ.json": () => import("./cs-CZ-bkbdzIkF.js"), "../language/da-DK.json": () => import("./da-DK-DvZ431fC.js"), "../language/de-DE.json": () => import("./de-DE-0uSzhWg5.js"), "../language/el-GR.json": () => import("./el-GR-CWWBcvDM.js"), "../language/en-US.json": () => import("./en-US-cVpRgdC8.js"), "../language/es-ES.json": () => import("./es-ES-B7dt4cn7.js"), "../language/et-EE.json": () => import("./et-EE-D_3GB-yT.js"), "../language/fi-FI.json": () => import("./fi-FI-REMsyTSr.js"), "../language/fr-FR.json": () => import("./fr-FR-CvHWmim-.js"), "../language/hr-HR.json": () => import("./hr-HR-LO3oO8yb.js"), "../language/hu-HU.json": () => import("./hu-HU-DEKBPTur.js"), "../language/it-IT.json": () => import("./it-IT-BeX7-OcD.js"), "../language/ja-JP.json": () => import("./ja-JP-B3wVYIJU.js"), "../language/lt-LT.json": () => import("./lt-LT-3niAR3rI.js"), "../language/lv-LV.json": () => import("./lv-LV-K-KFPny2.js"), "../language/nl-NL.json": () => import("./nl-NL-CM5U8ODq.js"), "../language/no-NO.json": () => import("./no-NO-BQL_M1pn.js"), "../language/pl-PL.json": () => import("./pl-PL-DC_lIAnp.js"), "../language/pt-BR.json": () => import("./pt-BR-AZ3roErF.js"), "../language/pt-PT.json": () => import("./pt-PT-DVKtHjIY.js"), "../language/ro-RO.json": () => import("./ro-RO-CHcD-PGb.js"), "../language/sk-SK.json": () => import("./sk-SK-s9Xm01UD.js"), "../language/sl-SI.json": () => import("./sl-SI-C0wSbuau.js"), "../language/sv-SE.json": () => import("./sv-SE-DtKjf4Go.js") }), `../language/${lang}.json`, 3) }
  ]);
  if (!parentCompanyLe || decisionMakerId && !decisionMakerLe) {
    return /* @__PURE__ */ jsx(Loader, {});
  }
  const country = getLegalEntityCountry(decisionMakerLe ?? parentCompanyLe);
  let problems = capabilityProblems && decisionMakerId ? getProblemsForEntity(capabilityProblems, EntityTypes.LEGAL_ENTITY, decisionMakerId) : void 0;
  if (problems && parentCompanyLe && decisionMakerLe && scenarios) {
    const associatedDecisionMakers = parentCompanyLe.entityAssociations?.filter(
      (association) => association.legalEntityId === decisionMakerLe.id
    );
    const isBafinSignatory = associatedDecisionMakers?.some(
      (association) => isBafinSignatoryFlow({ taskType, data: association, scenarios })
    );
    if (isBafinSignatory) {
      problems = removeIdVerificationProblemsForBafinSignatory(problems, decisionMakerLe);
    }
  }
  const trustedFieldsProvider = getTrustedFieldsProvider(parentCompanyLe);
  const trustedFields = decisionMakerLe ? getTrustedFields(decisionMakerLe, individualOnfidoBaseMapping) : {};
  const trustedEntityAssociation = getTrustedEntityAssociations(parentCompanyLe).find(
    (ea) => ea.reference === decisionMakerId
  );
  const trustedRoles = trustedEntityAssociation?.types ?? [];
  const isRevampedDecisionMakersTaskPageEnabled = isExperimentEnabled(
    "EnableRevampedDecisionMakersTaskPage"
  );
  const props = {
    taskType,
    taskName: TASK_NAMES[taskType],
    legalEntityResponse: decisionMakerLe,
    parentLegalEntity: parentCompanyLe,
    problems,
    country,
    asModal,
    hideSidebar,
    isTargetLegalEntityType,
    onSubmit,
    trustedFieldsProvider,
    trustedRoles,
    handleBackClick,
    handleCloseClick,
    handleHomeClick
  };
  return /* @__PURE__ */ jsx(
    IndividualOnfidoDropin,
    {
      ...props,
      asModal: isRevampedDecisionMakersTaskPageEnabled,
      trustedFields
    }
  );
}
const TASK_NAMES = {
  [TaskTypes.DECISION_MAKER]: "decisionMakerDetails",
  [TaskTypes.TRUST_MEMBER_COMPANY_OWNER]: "companyOwnerDetails",
  [TaskTypes.UNINCORPORATED_PARTNERSHIP_MEMBER_COMPANY_OWNER]: "companyOwnerDetails"
};
export {
  DecisionMakerDetailsPage
};
