import { jsx as o } from "../../../../../preact@10.29.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useRef as an, useMemo as ee, useEffect as ue, useState as se } from "../../../../../preact@10.29.0/node_modules/preact/hooks/dist/hooks.module.js";
import { u as Dn } from "./useCreateLegalEntity-C5daQcez.js";
import { a as Mn, u as Bn } from "./useToastContext-C2BAjZxO.js";
import { u as wn } from "./useUpdateLegalEntity-vK1vTzAB.js";
import { az as _e, u as I, z as _n, q as je, L as W, am as on, k as Yn, V as Hn, W as Un, an as Vn, aB as rn, aA as K, O as D, ac as qn, b as zn, j as kn } from "./StoreProvider-CBB99upB.js";
import { a as xn, F as Gn, u as Pe } from "./useFormContext-CX6rQNws.js";
import { S as Kn } from "./types-CQ2p58-6.js";
import { u as Le } from "./useAssociatedLegalEntity-DXp9udzH.js";
import { g as $n, a as jn, u as Wn } from "./dropinUtils-D44Paj5u.js";
import { u as Jn } from "./useMultiForm-DRZSxmEa.js";
import { E as Zn } from "./EndStateLayout-DVisdSEd.js";
import { E as ae } from "./ErrorPanel-D4kO8XQ8.js";
import { i as Qn, p as Xn, a as ea } from "./validationError-DmAD3_AN.js";
import { c as w } from "./formUtils-BEcbGHkz.js";
import { l as G } from "./localizeDateString-D2nDwdFu.js";
import { m as na, a as aa, L as oa, I as ra, C as ia, b as De, c as We } from "./Currency-B4udmJgX.js";
import { f as ne } from "./utils-DNSfZiio.js";
import { c as Ae } from "./types-CcxS0801.js";
import { g as S } from "./getProps-Cc3J2-z9.js";
import { F as L } from "./Field-CPoHG0G-.js";
import { L as ta } from "./Link-ru5UMRxt.js";
import { R as ge } from "./RadioGroup-BuAX_NLA.js";
import { I as tn } from "./InputText-C55stM8O.js";
import { useQuery as sa } from "../../../../../@tanstack_preact-query@5.95.2_preact@10.29.0/node_modules/@tanstack/preact-query/build/modern/useQuery.js";
import { S as Ye } from "./Select-seF9rM5K.js";
import { I as sn } from "./InputDate-BVYQZZuX.js";
import { C as la } from "./Checkbox-DmYVTVOD.js";
import { A as da } from "./Address-DaePmCRZ.js";
import { g as ca, C as ma, a as ua } from "./utils-BvFIL5qs.js";
import { C as ga } from "./CountryField-C7SjQFv_.js";
import { N as ya } from "./NewSummary-D-9PYaY6.js";
import { b as pa } from "./validate-CDGLD3wC.js";
import { Fragment as $ } from "../../../../../preact@10.29.0/node_modules/preact/dist/preact.module.js";
try {
  let e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, n = new e.Error().stack;
  n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "4a429afd-e01c-41c8-97d3-b34e41b728ee", e._sentryDebugIdIdentifier = "sentry-dbid-4a429afd-e01c-41c8-97d3-b34e41b728ee");
} catch {
}
const ln = {
  legalProceedingsDate: "organization.dateOfInitiationOfLegalProceeding",
  legalInformationInsolvency: "organization.statusOfLegalProceeding",
  legalEntityIdentifier: "organization.globalLegalEntityIdentifier",
  naceCode: "organization.economicSector",
  legalForm: "organization.legalForm",
  legalName: "organization.legalName",
  "registrationAddress.city": "organization.registeredAddress.city",
  "registrationAddress.country": "organization.registeredAddress.country",
  "registrationAddress.postalCode": "organization.registeredAddress.postalCode",
  "registrationAddress.stateOrProvince": "organization.registeredAddress.stateOrProvince",
  "registrationAddress.address": "organization.registeredAddress.street",
  "registrationAddress.otherAddressInformation": "organization.registeredAddress.street2"
}, fa = {
  gender: "individual.birthData.genderCode",
  countryOfBirth: "individual.birthData.birthCountry"
}, dn = {
  legalProceedingsDate: "soleProprietorship.dateOfInitiationOfLegalProceeding",
  legalInformationInsolvency: "soleProprietorship.statusOfLegalProceeding",
  naceCode: "soleProprietorship.economicSector"
}, ha = {
  ...ln
}, Je = {
  ...dn
}, cn = {
  ..._e(ln)
}, mn = {
  ..._e(fa)
}, He = {
  ..._e(dn)
}, we = (e, n, a) => a ? ne(e, a) : ne(
  e,
  n ? He : cn
), M = {
  COMPANY_PAGE: "company",
  SOLE_PROPRIETOR_PAGE: "soleProprietor",
  PARENT_COMPANY_PAGE: "parentCompany",
  ULTIMATE_PARENT_COMPANY_PAGE: "ultimateParentCompany"
}, ye = {
  YES: "Yes",
  NO: "No"
}, pe = [
  {
    id: ye.YES,
    name: "yes"
  },
  {
    id: ye.NO,
    name: "no"
  }
], Ca = [
  {
    id: ye.YES,
    name: "yes"
  },
  {
    id: ye.NO,
    name: "noIdontKnow"
  }
], un = [
  "legalForm",
  "naceCode",
  "numberOfEmployees",
  "doesYourCompanyHaveLEI",
  "legalEntityIdentifier",
  "isCompanyOwnedByAnotherCompany",
  "isParentOwnedByAnotherCompany",
  "financialReportingDate",
  "currency",
  "balanceSheetTotal",
  "annualTurnover",
  "legalInformationInsolvency",
  "legalProceedingsDate"
], gn = [
  "gender",
  "countryOfBirth",
  "naceCode",
  "legalInformationInsolvency",
  "legalProceedingsDate"
], fe = [
  "legalName",
  "legalForm",
  "naceCode",
  "numberOfEmployees",
  "doesYourCompanyHaveLEI",
  "legalEntityIdentifier",
  "isThisAddressTheMainHeadquarters",
  "financialReportingDate",
  "currency",
  "balanceSheetTotal",
  "annualTurnover",
  "legalInformationInsolvency",
  "legalProceedingsDate",
  "registrationAddress",
  "sameAddressAsRootEntity"
], N = {
  company: {
    formId: "company",
    formName: "businessInformation",
    fields: [...un]
  },
  soleProprietor: {
    formId: "soleProprietor",
    formName: "businessInformation",
    fields: [...gn]
  },
  parentCompany: {
    formId: "parentCompany",
    formName: "parentCompanyInformation",
    fields: [...fe]
  },
  ultimateParentCompany: {
    formId: "ultimateParentCompany",
    formName: "ultimateParentCompanyInformation",
    fields: [...fe]
  }
}, E = {
  COMPANY: "company",
  SOLE_PROPRIETOR: "soleProprietor",
  PARENT_COMPANY: "parentCompany",
  ULTIMATE_PARENT_COMPANY: "ultimateParentCompany"
}, Pa = (e, n) => {
  if (!n) return;
  if (e === E.COMPANY || e === E.SOLE_PROPRIETOR)
    return n.id;
  if (!n?.entityAssociations) return;
  const a = "immediateParentCompany";
  return n.entityAssociations?.find(
    (t) => t.type === a
  )?.legalEntityId;
}, Aa = typeof navigator < "u" ? navigator.language : "en-US", Ze = (e) => e.company?.isCompanyOwnedByAnotherCompany && e.company?.isCompanyOwnedByAnotherCompany === "Yes", Ea = (e) => e.company?.isParentOwnedByAnotherCompany && e.company?.isParentOwnedByAnotherCompany === "Yes", Ia = (e) => ({
  ...e,
  numberOfEmployees: e.numberOfEmployees ? e.numberOfEmployees.toString() : void 0,
  annualTurnover: e.annualTurnover ? e.annualTurnover.toString() : void 0,
  balanceSheetTotal: e.balanceSheetTotal ? e.balanceSheetTotal.toString() : void 0
}), Fa = (e, n, a) => {
  const r = e.soleProprietor;
  if (!r || !n?.id || !a?.id)
    return null;
  const t = we(
    r,
    !0,
    mn
  ), { identificationData: g, ...s } = n.individual || {}, l = {
    id: n.id,
    individual: {
      ...s,
      ...t.individual
    }
  }, i = we(
    r,
    !0,
    He
  );
  if (!i.soleProprietorship) return null;
  i.soleProprietorship.statusOfLegalProceeding === "iDontKnow" && (i.soleProprietorship.statusOfLegalProceeding = "noLegalActionsTaken"), (i.soleProprietorship.statusOfLegalProceeding === "iDontKnow" || i.soleProprietorship.statusOfLegalProceeding === "noLegalActionsTaken") && (i.soleProprietorship.dateOfInitiationOfLegalProceeding = "");
  const m = {
    id: a.id,
    soleProprietorship: {
      ...a.soleProprietorship,
      ...i.soleProprietorship
    }
  };
  return { individualPayload: l, solePropPayload: m };
}, Me = (e, n, a) => {
  const r = n[e];
  if (!r || e === E.PARENT_COMPANY && !Ze(n) || e === E.ULTIMATE_PARENT_COMPANY && (!Ea(n) || !Ze(n)))
    return null;
  const t = we(r), g = e === E.SOLE_PROPRIETOR;
  if (g)
    throw new Error(
      "Use prepareSoleProprietorBusinessFinancingSubmitData for sole proprietor business financing"
    );
  if (g === !1) {
    if (!t.organization) return null;
    const l = t.organization.registeredAddress?.country || a?.organization?.registeredAddress?.country, i = r;
    if (i.financialReportingDate && K(l)) {
      const m = {
        currency: i.currency,
        financialReportingDate: i.financialReportingDate,
        numberOfEmployees: i.numberOfEmployees ? Number(i.numberOfEmployees) : void 0,
        balanceSheetTotal: i.balanceSheetTotal ? Number(i.balanceSheetTotal) : void 0,
        annualTurnover: i.annualTurnover ? Number(i.annualTurnover) : void 0
      }, c = aa(m);
      t.organization.financialReports = [c];
    }
    K(l) || (t.organization.financialReports = void 0), t.organization.statusOfLegalProceeding === "iDontKnow" && (t.organization.statusOfLegalProceeding = "noLegalActionsTaken"), (t.organization.statusOfLegalProceeding === "iDontKnow" || t.organization.statusOfLegalProceeding === "noLegalActionsTaken") && (t.organization.dateOfInitiationOfLegalProceeding = ""), i.sameAddressAsRootEntity && a?.organization?.registeredAddress && (t.organization.registeredAddress = {
      ...a.organization.registeredAddress
    }), i.isThisAddressTheMainHeadquarters && (t.organization.principalPlaceOfBusiness = {
      ...t.organization.registeredAddress
    }), i.doesYourCompanyHaveLEI !== "Yes" && delete t.organization.globalLegalEntityIdentifier;
  }
  const s = Pa(e, a);
  return s ? (delete t.type, t.id = s) : (delete t.id, t.type = g ? W.SOLE_PROPRIETORSHIP : W.ORGANIZATION), t;
}, Be = (e, n) => {
  if (!e || !n) return n;
  const a = { ...n };
  let r = {};
  if (e.financialReports) {
    const t = Array.isArray(e.financialReports) ? e.financialReports : [e.financialReports], g = na(
      t,
      !1
    );
    r = Ia(g), r.numberOfEmployees && (r.numberOfEmployees = r.numberOfEmployees.toString());
  }
  return {
    ...a,
    ...r,
    numberOfEmployees: r.numberOfEmployees ? r.numberOfEmployees.toString() : void 0,
    doesYourCompanyHaveLEI: e.globalLegalEntityIdentifier ? "Yes" : "No",
    isThisAddressTheMainHeadquarters: e.principalPlaceOfBusiness ? "Yes" : a.isThisAddressTheMainHeadquarters
  };
}, ba = (e, n) => !e || !n ? n : {
  ...n,
  naceCode: n.naceCode ?? e.economicSector,
  legalInformationInsolvency: n.legalInformationInsolvency ?? e.statusOfLegalProceeding,
  legalProceedingsDate: n.legalProceedingsDate ?? e.dateOfInitiationOfLegalProceeding
}, X = async (e, n, a, r, t) => {
  if (!n)
    throw new Error(`Missing details for ${e}`);
  try {
    return t ? await r({ ...n, id: t }) : await a(n);
  } catch (g) {
    const s = new Error(`Form submission failed for ${e}`);
    throw s.actualError = g, s.businessFinancingType = s, s;
  }
}, va = (e, n, a) => {
  const r = [];
  return K(e) || r.push(
    "financialReportingDate",
    "balanceSheetTotal",
    "annualTurnover",
    "currency",
    "numberOfEmployees"
  ), n.isCompanyOwnedByAnotherCompany !== "Yes" && r.push("isParentOwnedByAnotherCompany"), n.doesYourCompanyHaveLEI !== "Yes" && r.push("legalEntityIdentifier"), (!n?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(n?.legalInformationInsolvency)) && r.push("legalProceedingsDate"), a.filter((t) => !r.includes(t));
}, Ta = (e, n) => {
  const a = [];
  return (!e?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(e?.legalInformationInsolvency)) && a.push("legalProceedingsDate"), n.filter((r) => !a.includes(r));
}, Qe = (e, n, a) => {
  const r = [], t = e?.sameAddressAsRootEntity && a ? a.country : e?.registrationAddress?.country;
  return K(t) || r.push(
    "financialReportingDate",
    "balanceSheetTotal",
    "annualTurnover",
    "currency",
    "numberOfEmployees"
  ), e?.sameAddressAsRootEntity && r.push("registrationAddress"), e.doesYourCompanyHaveLEI !== "Yes" && r.push("legalEntityIdentifier"), (!e?.legalInformationInsolvency || ["noLegalActionsTaken", "iDontKnow"].includes(e?.legalInformationInsolvency)) && r.push("legalProceedingsDate"), n.filter((g) => !r.includes(g));
}, Oa = (e, n, a) => {
  let r;
  if (!n)
    return r;
  const { company: t, soleProprietor: g, parentCompany: s = {}, ultimateParentCompany: l = {} } = n;
  if (g)
    return r = {}, r.soleProprietor = Ta(
      g,
      gn
    ), delete r.company, r;
  if (t && (r = {}, r.company = va(e, t, un)), t?.isCompanyOwnedByAnotherCompany === "Yes") {
    const i = Qe(
      s,
      fe,
      a
    );
    r = {
      ...r,
      parentCompany: i
    };
  }
  if (t?.isParentOwnedByAnotherCompany === "Yes") {
    const i = Qe(
      l,
      fe,
      a
    );
    r = {
      ...r,
      ultimateParentCompany: i
    };
  }
  return r;
}, yn = (e, n) => e?.sameAddressAsRootEntity && n ? n?.country : e?.registrationAddress?.country, Ra = (e, n) => {
  if (!n) return;
  const r = {
    M: "male",
    F: "female",
    U: "preferNotToSay"
  }[n];
  return r ? e((t) => t[r]) : n;
}, le = (e, n) => {
  if (n)
    return e(n === "noLegalActionsTaken" ? (a) => a.no : (a) => a[n]);
}, Sa = (e) => {
  try {
    return new Intl.NumberFormat(e), e;
  } catch (n) {
    return console.warn(`Invalid locale '${e}' provided. Falling back to 'en-US'.`, n), "en-US";
  }
}, j = (e, n) => {
  if (!e) return;
  const a = Sa(Aa), r = Number(e).toLocaleString(a);
  return `${n} ${r}`;
}, Na = (e, n, a, r, t) => {
  const g = Vn(r) || {}, { company: s, parentCompany: l, ultimateParentCompany: i, soleProprietor: m } = g;
  if (m && (m.naceCode = m.naceCodeLabel, m.countryOfBirth = m.countryOfBirth ? a.getCountryName(m.countryOfBirth) ?? void 0 : void 0, m.legalInformationInsolvency = le(
    n,
    m.legalInformationInsolvency
  ), m.legalProceedingsDate = m.legalProceedingsDate ? G(m.legalProceedingsDate, e) : void 0, m.gender && (m.gender = Ra(n, m.gender))), s) {
    s.legalForm = s.legalFormLabel, s.naceCode = s.naceCodeLabel, s.legalEntityIdentifier = s.legalEntityIdentifier ?? "None", s.legalInformationInsolvency = le(
      n,
      s?.legalInformationInsolvency
    ), s.annualTurnover = j(s.annualTurnover, s.currency), s.balanceSheetTotal = j(s.balanceSheetTotal, s.currency);
    const { legalProceedingsDate: c, financialReportingDate: d } = s;
    s.legalProceedingsDate = c ? G(c, e) : void 0, s.financialReportingDate = d ? G(d, e) : void 0;
  }
  if (l) {
    const {
      legalName: c,
      legalFormLabel: d,
      naceCodeLabel: u,
      country: C,
      legalEntityIdentifier: F,
      legalInformationInsolvency: y,
      annualTurnover: T,
      currency: A,
      balanceSheetTotal: f,
      legalProceedingsDate: P,
      financialReportingDate: b,
      sameAddressAsRootEntity: Q,
      registrationAddress: O
    } = l;
    c && (l.legalForm = d, l.naceCode = u, l.country = C ? a.getCountryName(C) : "", O && (l.registrationAddress = {
      ...O,
      country: a.getCountryName(O?.country)
    }), l.legalEntityIdentifier = F ?? "None", l.legalInformationInsolvency = le(
      n,
      y
    ), l.annualTurnover = j(T, A), l.balanceSheetTotal = j(f, A), l.legalProceedingsDate = P ? G(P, e) : void 0, l.financialReportingDate = b ? G(b, e) : void 0, Q && (delete l.country, g.parentCompany = {
      ...l,
      registrationAddress: {
        ...t,
        country: a.getCountryName(t?.country)
      }
    }));
  }
  if (i) {
    const {
      legalName: c,
      legalFormLabel: d,
      naceCodeLabel: u,
      country: C,
      legalEntityIdentifier: F,
      legalInformationInsolvency: y,
      annualTurnover: T,
      currency: A,
      balanceSheetTotal: f,
      legalProceedingsDate: P,
      financialReportingDate: b,
      sameAddressAsRootEntity: Q,
      registrationAddress: O
    } = i;
    c && (i.legalForm = d, i.naceCode = u, i.country = C ? a.getCountryName(C) : "", O && (i.registrationAddress = {
      ...O,
      country: a.getCountryName(O?.country)
    }), i.legalEntityIdentifier = F ?? "None", i.legalInformationInsolvency = le(
      n,
      y
    ), i.annualTurnover = j(T, A), i.balanceSheetTotal = j(f, A), i.legalProceedingsDate = P ? G(P, e) : void 0, i.financialReportingDate = b ? G(b, e) : void 0, Q && (delete i.country, g.ultimateParentCompany = {
      ...i,
      registrationAddress: {
        ...t,
        country: a.getCountryName(t?.country)
      }
    }));
  }
  return g;
}, de = (e) => {
  if (e.type === W.SOLE_PROPRIETORSHIP)
    return ne(e, Je);
  if (e.type === W.INDIVIDUAL && e.entityAssociations?.find(
    (a) => a.entityType === W.SOLE_PROPRIETORSHIP && a.associatorId === e.id
  )) {
    const a = ne(
      e,
      Je
    ), r = e.individual?.birthData;
    return {
      ...a,
      gender: r?.genderCode || e.individual?.gender,
      countryOfBirth: r?.birthCountry || e.individual?.countryOfBirth
    };
  }
  return ne(e, ha);
}, La = async (e) => kn({
  baseUrl: e,
  path: "datasets/naceCodes"
}), Da = (e) => {
  const { baseUrl: n } = zn();
  return sa({
    queryKey: ["naceCodes"],
    queryFn: () => La(n.value),
    ...e
  });
};
function Ma({
  name: e = "naceCode",
  data: n,
  valid: a,
  errorMessage: r,
  label: t,
  readonly: g,
  handleChangeFor: s
}) {
  const { t: l } = I("common"), { data: i } = Da(), m = an(s);
  ue(() => {
    m.current = s;
  }, [s]);
  const c = (d) => {
    const u = {
      target: {
        name: "naceCode",
        value: d.target.value
      }
    };
    s("naceCode")(u);
  };
  return ue(() => {
    const u = {
      target: {
        name: "naceCodeLabel",
        value: i?.find((C) => C.id === n.naceCode)?.name
      }
    };
    m.current("naceCodeLabel")(u);
  }, [n.naceCode, i]), /* @__PURE__ */ o(L, { name: e, label: t, errorMessage: r, isValid: a.naceCode, children: (d) => /* @__PURE__ */ o(
    Ye,
    {
      ...d,
      name: e,
      placeholder: l((u) => u.selectOne),
      selected: n.naceCode,
      items: i ?? [],
      readonly: g && !!n,
      onChange: c
    }
  ) });
}
const Ba = "adyen-kyc-business-financing-lei-radio", wa = "adyen-kyc-business-financing-title", _a = "adyen-kyc-business-financing-body", Ya = "adyen-kyc-business-financing-exposure-financials", Ha = "adyen-kyc-business-financing-structured-address", v = {
  businessFinancingLeiRadio: Ba,
  businessFinancingTitle: wa,
  businessFinancingBody: _a,
  businessFinancingExposureFinancials: Ya,
  businessFinancingStructuredAddress: Ha
}, J = [
  "legalForm",
  "naceCode",
  "naceCodeLabel",
  "legalFormLabel",
  "doesYourCompanyHaveLEI",
  "legalEntityIdentifier"
];
function Ee(e) {
  const {
    data: n,
    valid: a,
    errors: r,
    country: t,
    handleFieldChange: g,
    fieldValidationErrors: s,
    targetPage: l,
    sectionHeading: i,
    hideSectionHeading: m,
    isSoleProprietor: c
  } = e, { t: d } = I("businessFinancing"), { t: u } = I("common"), C = w(e, u);
  if (!g)
    return;
  const F = l === M.COMPANY_PAGE;
  return /* @__PURE__ */ o($, { children: [
    !m && /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: d(i ? (y) => y[i] : (y) => y.businessInformation) }),
    !c && /* @__PURE__ */ o(
      oa,
      {
        name: "legalForm",
        countryCode: t,
        data: {
          legalForm: n?.legalForm
        },
        valid: { legalForm: a?.legalForm },
        errorMessage: C.getErrorMessage("legalForm", r, s),
        handleChangeFor: g,
        readonly: !1,
        label: d((y) => y.businessStructure)
      }
    ),
    /* @__PURE__ */ o(
      Ma,
      {
        name: "naceCode",
        data: { naceCode: n?.naceCode },
        valid: { naceCode: a?.naceCode },
        errorMessage: C.getErrorMessage("naceCode", r, s),
        handleChangeFor: g,
        readonly: !1,
        label: d((y) => y.industryAndNaceCode)
      }
    ),
    !c && /* @__PURE__ */ o($, { children: [
      /* @__PURE__ */ o(
        L,
        {
          el: "fieldset",
          name: "doesYourCompanyHaveLEI",
          label: d(
            (y) => y[F ? "doesYourCompanyHaveLEI" : "doesThisCompanyHaveLEI"]
          ),
          helper: /* @__PURE__ */ o(
            D,
            {
              el: "div",
              variant: "body",
              color: "secondary",
              className: v.businessFinancingBody,
              children: [
                d((y) => y.anLEIIsAUniqueCode),
                " ",
                /* @__PURE__ */ o(ta, { href: "https://search.gleif.org/#/search/", external: !0, inline: !0, children: d((y) => y.lookUpYourLEI) })
              ]
            }
          ),
          errorMessage: C.getErrorMessage(
            "doesYourCompanyHaveLEI",
            r,
            s
          ),
          children: (y) => /* @__PURE__ */ o(
            ge,
            {
              ...y,
              name: "doesYourCompanyHaveLEI",
              items: F ? pe : Ca,
              value: n?.doesYourCompanyHaveLEI,
              disabled: !1,
              className: v.businessFinancingLeiRadio,
              onChange: g("doesYourCompanyHaveLEI"),
              "aria-required": !0,
              "aria-invalid": !a?.doesYourCompanyHaveLEI
            }
          )
        }
      ),
      n?.doesYourCompanyHaveLEI === "Yes" && /* @__PURE__ */ o(
        L,
        {
          name: "legalEntityIdentifier",
          label: d((y) => y.legalEntityIdentifier),
          errorMessage: C.getErrorMessage(
            "legalEntityIdentifier",
            r,
            s
          ),
          isValid: a?.legalEntityIdentifier,
          helper: u((y) => y.enterNCharactersWithAMixForExample, {
            numChars: 20,
            example: "529900T8BM49AURSDO55"
          }),
          children: (y) => /* @__PURE__ */ o(
            tn,
            {
              ...y,
              name: "legalEntityIdentifier",
              value: n?.legalEntityIdentifier,
              readonly: !1,
              onInput: g("legalEntityIdentifier", "input"),
              onBlur: g("legalEntityIdentifier", "blur"),
              "aria-required": !0,
              "aria-invalid": !a?.legalEntityIdentifier,
              isValid: a?.legalEntityIdentifier
            }
          )
        }
      )
    ] })
  ] });
}
const Ua = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], Z = [
  "numberOfEmployees",
  "financialReportingDate",
  "legalEntityIdentifier",
  "currency",
  "balanceSheetTotal",
  "annualTurnover"
];
function Ue(e) {
  const { data: n, valid: a, errors: r, country: t, sectionHeading: g, handleFieldChange: s, fieldValidationErrors: l } = e, { t: i, i18n: m } = I("businessFinancing"), { t: c } = I("common"), d = w(e, c), u = ee(() => Ae[t] ?? [], [t]);
  if (!s)
    return;
  const C = n, F = r, y = a, [T] = u, A = T ?? "EUR";
  return u.length === 1 && n?.currency !== T && s("currency")(T), /* @__PURE__ */ o("section", { children: [
    /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: i(g ? (f) => f[g] : (f) => f.businessFinancials) }),
    /* @__PURE__ */ o(
      L,
      {
        name: "numberOfEmployees",
        label: i((f) => f.numberOfEmployees),
        helper: i((f) => f.theNumberOfIndividualsReceivingAWageOrSalary),
        errorMessage: d.getErrorMessage("numberOfEmployees", r, l),
        isValid: a?.numberOfEmployees,
        children: (f) => /* @__PURE__ */ o(
          ra,
          {
            ...f,
            "aria-required": !0,
            "aria-invalid": !a?.numberOfEmployees,
            name: "numberOfEmployees",
            min: "0",
            step: "1",
            value: n?.numberOfEmployees,
            onInput: s("numberOfEmployees", "input"),
            onBlur: s("numberOfEmployees", "blur")
          }
        )
      }
    ),
    u?.length > 1 && /* @__PURE__ */ o(
      ia,
      {
        country: t,
        data: d.getFieldData(C, De),
        errors: d.getFieldErrors(F, l, De),
        handleChangeFor: s,
        labels: { currency: i((f) => f.financialStatementReportingCurrency) },
        readonly: d.isReadOnly("currency"),
        valid: d.getFieldValid(y, De)
      }
    ),
    /* @__PURE__ */ o("div", { className: v.businessFinancingExposureFinancials, children: [
      /* @__PURE__ */ o(
        L,
        {
          name: "balanceSheetTotal",
          label: i((f) => f.balanceSheetTotal),
          helper: i((f) => f.theSumOfTotalLiabilities),
          errorMessage: d.getErrorMessage(
            "balanceSheetTotal",
            r,
            l
          ),
          isValid: a?.balanceSheetTotal,
          children: (f) => /* @__PURE__ */ o(
            We,
            {
              ...f,
              "aria-required": d.isRequiredField("balanceSheetTotal"),
              "aria-invalid": !a?.balanceSheetTotal,
              locale: m.language,
              currency: n?.currency ?? A,
              amount: n?.balanceSheetTotal ? Number(n?.balanceSheetTotal) : void 0,
              onAmountChanged: s("balanceSheetTotal")
            }
          )
        }
      ),
      /* @__PURE__ */ o(
        L,
        {
          name: "financialReportingDate",
          label: i((f) => f.statementReportingDate),
          helper: i((f) => f.useTheMoreRecentOfTheReportingDates),
          errorMessage: d.getErrorMessage(
            "financialReportingDate",
            r,
            l
          ),
          isValid: a?.financialReportingDate,
          children: (f) => /* @__PURE__ */ o(
            sn,
            {
              ...f,
              name: "financialReportingDate",
              value: n?.financialReportingDate,
              onInput: s("financialReportingDate", "input"),
              onBlur: s("financialReportingDate", "blur"),
              "aria-required": !0,
              "aria-invalid": !a?.financialReportingDate,
              max: Ua
            }
          )
        }
      ),
      /* @__PURE__ */ o(
        L,
        {
          name: "annualTurnover",
          label: i((f) => f.annualTurnover),
          helper: i((f) => f.theAnnualSalesRevenue),
          errorMessage: d.getErrorMessage("annualTurnover", r, l),
          isValid: a?.annualTurnover,
          children: (f) => /* @__PURE__ */ o(
            We,
            {
              ...f,
              name: "annualTurnover",
              "aria-required": d.isRequiredField("annualTurnover"),
              "aria-invalid": !a?.annualTurnover,
              locale: m.language,
              currency: n?.currency ?? A,
              amount: n?.annualTurnover ? Number(n?.annualTurnover) : void 0,
              onAmountChanged: s("annualTurnover")
            }
          )
        }
      )
    ] })
  ] });
}
const Va = (/* @__PURE__ */ new Date()).toISOString().split("T")[0], U = [
  "legalInformationInsolvency",
  "legalProceedingsDate"
];
function Ie(e) {
  const { data: n, valid: a, errors: r, fieldValidationErrors: t, handleFieldChange: g, sectionHeading: s } = e, { t: l } = I("businessFinancing"), { t: i } = I("common"), m = w(e, i);
  if (!g)
    return;
  const c = [
    { id: "noLegalActionsTaken", name: i((u) => u.no) },
    {
      id: "underJudicialAdministration",
      name: l((u) => u.yesTheCompanyIsUnderJudicialAdministration)
    },
    {
      id: "bankruptcyInsolvency",
      name: l((u) => u.yesTheCompanyIsFilingForBankruptcy)
    },
    {
      id: "otherLegalMeasures",
      name: l((u) => u.yesTheCompanyIsFacingOtherLegalMeasures)
    },
    { id: "iDontKnow", name: i((u) => u.iDontKnow) }
  ], d = n?.legalInformationInsolvency && !["noLegalActionsTaken", "iDontKnow"].includes(n?.legalInformationInsolvency);
  return /* @__PURE__ */ o($, { children: [
    /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: l(s ? (u) => u[s] : (u) => u.legalInformation) }),
    /* @__PURE__ */ o(
      L,
      {
        name: "legalInformationInsolvency",
        label: l((u) => u.legalInformationInsolvency),
        errorMessage: m.getErrorMessage(
          "legalInformationInsolvency",
          r,
          t
        ),
        isValid: a?.legalInformationInsolvency,
        children: (u) => /* @__PURE__ */ o(
          Ye,
          {
            ...u,
            onChange: g("legalInformationInsolvency", "blur"),
            name: "legalInformationInsolvency",
            placeholder: i((C) => C.selectOne),
            selected: n?.legalInformationInsolvency,
            items: c,
            "aria-required": !0,
            "aria-invalid": !a?.legalInformationInsolvency
          }
        )
      }
    ),
    d && /* @__PURE__ */ o(
      L,
      {
        name: "legalProceedingsDate",
        label: l((u) => u.legalProceedingsDate),
        errorMessage: m.getErrorMessage(
          "legalProceedingsDate",
          r,
          t
        ),
        isValid: a?.legalProceedingsDate,
        children: (u) => /* @__PURE__ */ o(
          sn,
          {
            ...u,
            name: "legalProceedingsDate",
            value: n.legalProceedingsDate,
            onInput: g("legalProceedingsDate", "input"),
            onBlur: g("legalProceedingsDate", "blur"),
            "aria-required": !0,
            "aria-invalid": !a?.legalProceedingsDate,
            max: Va
          }
        )
      }
    )
  ] });
}
const Xe = [
  "isCompanyOwnedByAnotherCompany",
  "isParentOwnedByAnotherCompany"
];
function qa(e) {
  const { data: n, valid: a, errors: r = {}, legalEntity: t, fieldValidationErrors: g, handleFieldChange: s } = e, { t: l } = I("businessFinancing"), { t: i } = I("common"), m = w(e, i);
  if (s)
    return /* @__PURE__ */ o($, { children: [
      /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: l((c) => c.ownershipStructure) }),
      /* @__PURE__ */ o(
        L,
        {
          el: "fieldset",
          name: "isCompanyOwnedByAnotherCompany",
          label: l((c) => c.isCompanyOwnedByAnotherCompany, {
            company: t?.organization ? t.organization.legalName : ""
          }),
          errorMessage: m.getErrorMessage(
            "isCompanyOwnedByAnotherCompany",
            r,
            g
          ),
          helper: /* @__PURE__ */ o(
            D,
            {
              el: "div",
              variant: "body",
              color: "secondary",
              className: v.businessFinancingBody,
              children: l((c) => c.thisMeansYouHaveAParentCompany)
            }
          ),
          children: (c) => /* @__PURE__ */ o(
            ge,
            {
              ...c,
              name: "isCompanyOwnedByAnotherCompany",
              items: pe,
              value: n?.isCompanyOwnedByAnotherCompany,
              className: v.businessFinancingLeiRadio,
              disabled: !1,
              onChange: s("isCompanyOwnedByAnotherCompany"),
              "aria-required": !0,
              "aria-invalid": !a?.isCompanyOwnedByAnotherCompany
            }
          )
        }
      ),
      n?.isCompanyOwnedByAnotherCompany === "Yes" && /* @__PURE__ */ o(
        L,
        {
          el: "fieldset",
          name: "isParentOwnedByAnotherCompany",
          label: l((c) => c.isParentOwnedByAnotherCompany),
          helper: /* @__PURE__ */ o(
            D,
            {
              el: "div",
              variant: "body",
              color: "secondary",
              className: v.businessFinancingBody,
              children: l((c) => c.thisMeansYouHaveAnUltimateParentCompany)
            }
          ),
          errorMessage: m.getErrorMessage(
            "isParentOwnedByAnotherCompany",
            r,
            g
          ),
          children: (c) => /* @__PURE__ */ o(
            ge,
            {
              ...c,
              name: "isParentOwnedByAnotherCompany",
              items: pe,
              value: n.isParentOwnedByAnotherCompany,
              className: v.businessFinancingLeiRadio,
              disabled: !1,
              onChange: s("isParentOwnedByAnotherCompany"),
              "aria-required": !0,
              "aria-invalid": !a?.isParentOwnedByAnotherCompany
            }
          )
        }
      )
    ] });
}
function za(e) {
  const { t: n } = I("businessFinancing"), { t: a } = I("common"), {
    form: { handleChangeFor: r, data: t, setValid: g }
  } = Pe(), { country: s, formVerificationErrors: l, legalEntity: i, fieldValidationErrors: m } = e, c = w(e, a), d = (A, f) => r(A, "company", f), u = S(e, Xe), C = S(e, J), F = S(e, Z), y = S(e, U);
  return (Ae[s] ?? [])?.length === 1 && g("currency", !0, "company"), /* @__PURE__ */ o("form", { className: "adyen-kyc__high-exposure-company", children: [
    /* @__PURE__ */ o(
      rn,
      {
        title: n((A) => A.additionalInformationForBusinessFinancing),
        description: n((A) => A.weNeedAFewMoreDetailsAboutYouAndYourBusiness),
        secondary: !0
      }
    ),
    /* @__PURE__ */ o(
      ae,
      {
        verificationErrors: l,
        validationErrors: m,
        formUtils: c,
        id: "ariaErrorField"
      }
    ),
    /* @__PURE__ */ o(
      Ee,
      {
        ...C,
        handleFieldChange: d,
        country: s,
        targetPage: M.COMPANY_PAGE,
        sectionHeading: "businessInformation",
        data: c.getFieldData(t?.company ?? {}, J)
      }
    ),
    K(s) && /* @__PURE__ */ o(
      Ue,
      {
        ...F,
        handleFieldChange: d,
        country: s,
        targetPage: M.COMPANY_PAGE,
        data: c.getFieldData(t?.company ?? {}, Z)
      }
    ),
    /* @__PURE__ */ o(
      Ie,
      {
        ...y,
        country: s,
        handleFieldChange: d,
        targetPage: M.COMPANY_PAGE,
        sectionHeading: "legalInformation",
        data: c.getFieldData(t?.company ?? {}, U)
      }
    ),
    /* @__PURE__ */ o(
      qa,
      {
        ...u,
        legalEntity: i,
        handleFieldChange: d,
        data: c.getFieldData(t?.company ?? {}, Xe)
      }
    )
  ] });
}
const he = [
  "legalName"
];
function pn(e) {
  const { data: n, valid: a, errors: r, fieldValidationErrors: t, handleFieldChange: g, sectionHeading: s } = e, { t: l } = I("businessFinancing"), { t: i } = I("common"), m = w(e, i);
  if (g)
    return /* @__PURE__ */ o($, { children: [
      /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: l(s ? (c) => c[s] : (c) => c.basicCompanyInformation) }),
      /* @__PURE__ */ o(
        L,
        {
          name: "legalName",
          label: l((c) => c.legalName),
          errorMessage: m.getErrorMessage("legalName", r, t),
          isValid: a?.legalName,
          helper: l((c) => c.legalNameIsUsedToIdentifyABusinessWithTheGovernment),
          helperPosition: "below",
          children: (c) => /* @__PURE__ */ o(
            tn,
            {
              ...c,
              name: "legalName",
              value: n?.legalName,
              readonly: !1,
              onInput: g("legalName", "input"),
              onBlur: g("legalName", "blur"),
              "aria-required": !0,
              "aria-invalid": !a?.legalName
            }
          )
        }
      )
    ] });
}
const ka = ["otherAddressInformation"], Ce = [
  "isThisAddressTheMainHeadquarters",
  "registrationAddress",
  "sameAddressAsRootEntity"
];
function fn(e) {
  const {
    data: n,
    valid: a,
    errors: r,
    fieldValidationErrors: t,
    shouldValidate: g,
    defaultData: s,
    handleFieldChange: l,
    formId: i,
    legalEntity: m,
    sectionHeading: c
  } = e, { t: d, i18n: u } = I("businessFinancing"), { t: C } = I("common"), F = w(e, C), y = n?.registrationAddress?.country, T = on(u.language), A = ee(() => ca(y).filter((P) => y ? ma.includes(y) ? !0 : P !== "stateOrProvince" : !0), [y]);
  if (!l)
    return;
  const f = (P) => {
    P.data.country || (P.data.country = y), l("registrationAddress")(P.data);
  };
  return /* @__PURE__ */ o($, { children: [
    /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: c ? qn(C, c) : C((P) => P.registeredAddress) }),
    /* @__PURE__ */ o(
      L,
      {
        name: "sameAddressAsRootEntity",
        errorMessage: r?.sameAddressAsRootEntity?.errorMessage,
        isValid: a?.sameAddressAsRootEntity,
        children: (P) => /* @__PURE__ */ o(
          la,
          {
            ...P,
            "aria-required": F.isRequiredField("sameAddressAsRootEntity"),
            "aria-invalid": !a?.sameAddressAsRootEntity,
            name: "sameAddressAsRootEntity",
            label: d((b) => b.sameAddressAsRootEntity, {
              rootLegalEntityName: m?.organization?.legalName ?? ""
            }),
            checked: n?.sameAddressAsRootEntity ?? !1,
            onChange: l("sameAddressAsRootEntity")
          }
        )
      }
    ),
    n?.sameAddressAsRootEntity && m?.organization?.registeredAddress ? /* @__PURE__ */ o("div", { className: v.businessFinancingStructuredAddress, children: [
      /* @__PURE__ */ o("div", { children: m.organization.registeredAddress.street }),
      /* @__PURE__ */ o("div", { children: m.organization.registeredAddress.street2 }),
      /* @__PURE__ */ o("div", { children: [
        m.organization.registeredAddress.city,
        " ",
        m.organization.registeredAddress.postalCode ? `, ${m.organization.registeredAddress.postalCode}` : ""
      ] }),
      /* @__PURE__ */ o("div", { children: m.organization.registeredAddress.stateOrProvince }),
      /* @__PURE__ */ o("div", { children: m.organization.registeredAddress.country ? T.getCountryName(m.organization.registeredAddress.country) : "" })
    ] }) : /* @__PURE__ */ o(
      da,
      {
        id: i,
        addressType: "registrationAddress",
        data: { ...s?.registrationAddress, country: y },
        labels: y ? ua(y) : void 0,
        countryCode: y,
        requiredFields: A,
        optionalFields: ka,
        onChange: f,
        shouldValidate: g
      }
    ),
    /* @__PURE__ */ o(
      L,
      {
        el: "fieldset",
        name: "isThisAddressTheMainHeadquarters",
        label: d((P) => P.areTheMainHeadquartersAtThisAddress),
        helper: d((P) => P.addressRegisteredWithGovernment),
        errorMessage: F.getErrorMessage(
          "isThisAddressTheMainHeadquarters",
          r,
          t
        ),
        children: (P) => /* @__PURE__ */ o(
          ge,
          {
            ...P,
            name: "isThisAddressTheMainHeadquarters",
            items: pe,
            value: n?.isThisAddressTheMainHeadquarters,
            className: v.businessFinancingLeiRadio,
            disabled: !1,
            onChange: l("isThisAddressTheMainHeadquarters"),
            "aria-required": !0,
            "aria-invalid": !a?.isThisAddressTheMainHeadquarters
          }
        )
      }
    )
  ] });
}
const xa = N.parentCompany.formId;
function Ga(e) {
  const { t: n } = I("businessFinancing"), { t: a } = I("common"), {
    form: { handleChangeFor: r, data: t, setValid: g }
  } = Pe(), { country: s, formVerificationErrors: l, fieldValidationErrors: i, legalEntity: m } = e, c = w(
    e,
    a
  ), d = (P, b) => r(P, "parentCompany", b);
  g("sameAddressAsRootEntity", !0, "parentCompany");
  const u = S(e, he), C = S(e, Ce), F = S(e, J), y = S(e, Z), T = S(e, U), A = yn(
    t?.parentCompany,
    m?.organization?.registeredAddress
  );
  return (Ae[A ?? s] ?? [])?.length === 1 && g("currency", !0, "parentCompany"), /* @__PURE__ */ o("form", { className: "adyen-kyc__high-exposure-parent-company", children: [
    /* @__PURE__ */ o(D, { el: "h1", variant: "title-l", className: v.businessFinancingBody, children: a((P) => P.parentCompanyInformation) }),
    /* @__PURE__ */ o(D, { el: "p", variant: "body", className: v.businessFinancingBody, children: n((P) => P.inThePreviousStepOwnedByAParentCompany) }),
    /* @__PURE__ */ o(
      ae,
      {
        verificationErrors: l,
        validationErrors: i,
        formUtils: c,
        id: "ariaErrorField"
      }
    ),
    /* @__PURE__ */ o(
      pn,
      {
        ...u,
        sectionHeading: "parentCompanyInformation",
        handleFieldChange: d,
        data: c.getFieldData(t?.parentCompany ?? {}, he)
      }
    ),
    /* @__PURE__ */ o(
      fn,
      {
        ...C,
        formId: xa,
        sectionHeading: "parentCompanyAddress",
        defaultData: t?.parentCompany,
        legalEntity: m,
        handleFieldChange: d,
        data: c.getFieldData(t?.parentCompany ?? {}, Ce)
      }
    ),
    /* @__PURE__ */ o(
      Ee,
      {
        ...F,
        hideSectionHeading: !0,
        country: A ?? s,
        targetPage: M.PARENT_COMPANY_PAGE,
        handleFieldChange: d,
        data: c.getFieldData(t?.parentCompany ?? {}, J)
      }
    ),
    K(A) && /* @__PURE__ */ o(
      Ue,
      {
        ...y,
        country: A ?? s,
        targetPage: M.PARENT_COMPANY_PAGE,
        handleFieldChange: d,
        data: c.getFieldData(t?.parentCompany ?? {}, Z)
      }
    ),
    /* @__PURE__ */ o(
      Ie,
      {
        ...T,
        country: A ?? s,
        targetPage: M.PARENT_COMPANY_PAGE,
        sectionHeading: "legalInformation",
        handleFieldChange: d,
        data: c.getFieldData(t?.parentCompany ?? {}, U)
      }
    )
  ] });
}
const en = ["gender", "countryOfBirth"];
function Ka(e) {
  const { data: n, valid: a, errors: r, handleFieldChange: t, fieldValidationErrors: g, sectionHeading: s } = e, { t: l } = I("businessFinancing"), { t: i } = I("common"), m = w(e, i);
  if (!t)
    return;
  const c = [
    { id: "M", name: l((d) => d.male) },
    { id: "F", name: l((d) => d.female) },
    { id: "U", name: l((d) => d.preferNotToSay) }
  ];
  return /* @__PURE__ */ o($, { children: [
    /* @__PURE__ */ o(D, { el: "h3", variant: "title", className: v.businessFinancingTitle, children: l(s ? (d) => d[s] : (d) => d.personalInformation) }),
    /* @__PURE__ */ o(
      ga,
      {
        data: { country: n?.countryOfBirth },
        valid: { country: a?.countryOfBirth },
        name: "countryOfBirth",
        errors: {
          country: m.getErrorMessage("countryOfBirth", r, g)
        },
        labels: { country: l((d) => d.countryOfBirth) },
        readonly: m.isReadOnly("countryOfBirth"),
        handleChangeFor: () => t("countryOfBirth", "input")
      }
    ),
    /* @__PURE__ */ o(
      L,
      {
        name: "gender",
        label: l((d) => d.gender),
        errorMessage: m.getErrorMessage("gender", r, g),
        isValid: a?.gender,
        children: (d) => /* @__PURE__ */ o(
          Ye,
          {
            ...d,
            onChange: t("gender", "blur"),
            name: "gender",
            placeholder: i((u) => u.selectOne),
            selected: n?.gender,
            items: c,
            "aria-required": !0,
            "aria-invalid": !a?.gender
          }
        )
      }
    )
  ] });
}
function $a(e) {
  const { t: n } = I("businessFinancing"), { t: a } = I("common"), {
    form: { handleChangeFor: r, data: t }
  } = Pe(), { country: g, formVerificationErrors: s, fieldValidationErrors: l } = e, i = w(e, a), m = (C, F) => r(
    C,
    "soleProprietor",
    F
  ), c = S(e, en), d = S(e, ["naceCode", "naceCodeLabel"]), u = S(e, U);
  return /* @__PURE__ */ o("form", { className: "adyen-kyc__high-exposure-company", children: [
    /* @__PURE__ */ o(
      rn,
      {
        title: n((C) => C.additionalInformationForBusinessFinancing),
        description: n((C) => C.weNeedAFewMoreDetailsAboutYouAndYourBusiness),
        secondary: !0
      }
    ),
    /* @__PURE__ */ o(
      ae,
      {
        verificationErrors: s,
        validationErrors: l,
        formUtils: i,
        id: "ariaErrorField"
      }
    ),
    /* @__PURE__ */ o(
      Ka,
      {
        ...c,
        handleFieldChange: m,
        country: g,
        targetPage: M.SOLE_PROPRIETOR_PAGE,
        sectionHeading: "personalInformation",
        data: i.getFieldData(
          t?.soleProprietor ?? {},
          en
        )
      }
    ),
    /* @__PURE__ */ o(
      Ee,
      {
        ...d,
        handleFieldChange: m,
        country: g,
        targetPage: M.SOLE_PROPRIETOR_PAGE,
        sectionHeading: "businessInformation",
        isSoleProprietor: !0,
        data: i.getFieldData(t?.soleProprietor ?? {}, [
          "naceCode",
          "naceCodeLabel"
        ])
      }
    ),
    /* @__PURE__ */ o(
      Ie,
      {
        ...u,
        country: g,
        handleFieldChange: m,
        targetPage: M.SOLE_PROPRIETOR_PAGE,
        sectionHeading: "legalInformation",
        data: i.getFieldData(t?.soleProprietor ?? {}, U)
      }
    )
  ] });
}
const ja = N.ultimateParentCompany.formId;
function Wa(e) {
  const { formVerificationErrors: n, country: a, fieldValidationErrors: r, legalEntity: t } = e, { t: g } = I("businessFinancing"), { t: s } = I("common"), l = w(
    e,
    s
  ), {
    form: { handleChangeFor: i, data: m, setValid: c }
  } = Pe(), d = (P, b) => i(P, "ultimateParentCompany", b);
  c("sameAddressAsRootEntity", !0, "ultimateParentCompany");
  const u = S(e, he), C = S(e, Ce), F = S(e, J), y = S(e, Z), T = S(e, U), A = yn(
    m?.ultimateParentCompany,
    t?.organization?.registeredAddress
  );
  return (Ae[A ?? a] ?? [])?.length === 1 && c("currency", !0, "ultimateParentCompany"), /* @__PURE__ */ o("form", { className: "adyen-kyc__high-exposure-ultimate-parent-company", children: [
    /* @__PURE__ */ o(D, { el: "h1", variant: "title-l", className: v.businessFinancingBody, children: s((P) => P.ultimateParentCompanyInformation) }),
    /* @__PURE__ */ o(D, { el: "p", variant: "body", className: v.businessFinancingBody, children: g((P) => P.inThePreviousStepOwnedByAnUltimateParentCompany) }),
    /* @__PURE__ */ o(
      ae,
      {
        verificationErrors: n,
        validationErrors: r,
        formUtils: l,
        id: "ariaErrorField"
      }
    ),
    /* @__PURE__ */ o(
      pn,
      {
        ...u,
        sectionHeading: "ultimateParentCompanyInformation",
        handleFieldChange: d,
        data: l.getFieldData(m?.ultimateParentCompany ?? {}, he)
      }
    ),
    /* @__PURE__ */ o(
      fn,
      {
        ...C,
        formId: ja,
        sectionHeading: "ultimateParentCompanyAddress",
        defaultData: m?.ultimateParentCompany,
        handleFieldChange: d,
        data: l.getFieldData(m?.ultimateParentCompany ?? {}, Ce),
        legalEntity: t
      }
    ),
    /* @__PURE__ */ o(
      Ee,
      {
        ...F,
        hideSectionHeading: !0,
        country: A ?? a,
        targetPage: M.ULTIMATE_PARENT_COMPANY_PAGE,
        handleFieldChange: d,
        data: l.getFieldData(m?.ultimateParentCompany ?? {}, J)
      }
    ),
    K(A) && /* @__PURE__ */ o(
      Ue,
      {
        ...y,
        country: A ?? a,
        targetPage: M.ULTIMATE_PARENT_COMPANY_PAGE,
        handleFieldChange: d,
        data: l.getFieldData(
          m?.ultimateParentCompany ?? {},
          Z
        )
      }
    ),
    /* @__PURE__ */ o(
      Ie,
      {
        ...T,
        country: A ?? a,
        sectionHeading: "legalInformation",
        targetPage: M.ULTIMATE_PARENT_COMPANY_PAGE,
        handleFieldChange: d,
        data: l.getFieldData(m?.ultimateParentCompany ?? {}, U)
      }
    )
  ] });
}
const Ja = [
  "naceCodeLabel",
  "legalFormLabel",
  "currency",
  "doesYourCompanyHaveLEI",
  "sameAddressAsRootEntity"
], hn = {
  legalForm: "businessStructure",
  naceCode: "industryAndNaceCode",
  balanceSheetTotal: "totalAssets",
  annualTurnover: "annualTurnover",
  legalInformationInsolvency: "legalProceedings",
  isCompanyOwnedByAnotherCompany: "hasParentCompany",
  isParentOwnedByAnotherCompany: "hasUltimateParentCompany",
  isThisAddressTheMainHeadquarters: "addressIsHeadquarters"
}, Za = (e) => Ja.includes(e), Qa = (e) => e in hn, Xa = ({
  forms: e,
  items: n,
  handleEditForm: a,
  children: r
}) => {
  const { t } = I("businessFinancing"), { t: g } = I("common"), s = (i) => {
    if (!i) return [];
    const c = Object.entries(i).map(([u, C]) => Za(u) || !C ? void 0 : {
      term: Qa(u) ? t((y) => y[hn[u]]) : g((y) => y[u]),
      details: C
    }).filter((u) => u !== void 0), d = [];
    return c.map((u) => {
      typeof u?.details == "object" ? d.push(...s(u?.details)) : d.push(u);
    }), d;
  };
  return /* @__PURE__ */ o(ya, { handleEditForm: a, sections: ((i) => i.map(({ formId: c, formName: d }) => ({
    formId: c,
    label: g((u) => u[d]),
    items: s(n[c])
  })))(e), children: r });
}, ce = (e, n) => {
  const a = n?.organization, r = n?.soleProprietorship, t = a || r;
  return t ? {
    [`${e}--economicSector`]: t?.economicSector ?? "",
    [`${e}--legalForm`]: a?.legalForm ?? "",
    [`${e}--statusOfLegalProceeding`]: t?.statusOfLegalProceeding ?? ""
  } : {};
}, nn = {
  soleProprietor: N.soleProprietor.fields,
  company: N.company.fields,
  parentCompany: N.parentCompany.fields,
  ultimateParentCompany: N.ultimateParentCompany.fields
}, eo = N.parentCompany.formId, me = N.company.formId, no = N.ultimateParentCompany.formId;
function Uo(e) {
  const {
    country: n,
    rootLegalEntity: a,
    externalOnSubmit: r,
    externalOnSubmitLabel: t,
    isStandaloneComponent: g,
    handleHomeClick: s
  } = e, { t: l } = I("businessFinancing"), { t: i, i18n: m } = I("common"), c = _n();
  an(null);
  const d = Mn(), { mutateAsync: u } = Dn(), { mutateAsync: C } = wn(), { data: F, isLoading: y } = Le(a, "immediateParentCompany"), { data: T, isLoading: A } = Le(a, "ultimateParentCompany"), { data: f, isLoading: P } = Le(
    a,
    "soleProprietorship"
  ), b = ee(() => {
    if (y || A || P)
      return;
    const h = je(a), p = {};
    return h && f ? (p.soleProprietor = de(
      a
    ), p.soleProprietor = ba(
      f.soleProprietorship,
      p.soleProprietor
    )) : a.type === W.ORGANIZATION && (p.company = de(
      a
    ), p.company = Be(
      a.organization,
      p.company
    ), p.company.isCompanyOwnedByAnotherCompany = "No", p.company.isParentOwnedByAnotherCompany = "No", F && (p.parentCompany = de(
      F
    ), p.parentCompany = Be(
      F.organization,
      p.parentCompany
    ), p.company.isCompanyOwnedByAnotherCompany = "Yes"), T && (p.ultimateParentCompany = de(
      T
    ), p.ultimateParentCompany = Be(
      T.organization,
      p.ultimateParentCompany
    ), p.company.isParentOwnedByAnotherCompany = "Yes")), p;
  }, [
    y,
    A,
    P,
    a,
    F,
    T,
    f
  ]);
  ue(() => {
    c.addTaskEvent("Landed on page", {
      actionType: "start"
    });
  }, [c]);
  const Q = on(m.language), [O, Fe] = se(), [Cn, be] = se("success"), [Pn, Ve] = se(!1), { showToast: V } = Bn(), { isSettingEnabled: An } = Yn(), ve = An(Kn.ShowBusinessFinancingFirst), En = async () => {
    if (be("loading"), !R)
      return;
    const h = je(a), p = h ? null : Me(
      E.COMPANY,
      R,
      a
    ), Y = h ? Fa(R, a, f) : null, _ = h ? null : Me(
      E.PARENT_COMPANY,
      R,
      a
    ), q = h ? null : Me(
      E.ULTIMATE_PARENT_COMPANY,
      R,
      a
    );
    if (h) {
      if (!Y || !a || !f?.id) {
        V({
          label: l((H) => H.missingCompanyDetails),
          variant: "error"
        });
        return;
      }
      try {
        await X(
          E.SOLE_PROPRIETOR,
          Y.individualPayload,
          u,
          C,
          a.id
        );
        const H = await X(
          E.SOLE_PROPRIETOR,
          Y.solePropPayload,
          u,
          C,
          f.id
        ), z = {
          ...ce("SoleProprietor", H)
        };
        c.addTaskEvent("Success", {
          actionType: "submit",
          returnValue: [E.SOLE_PROPRIETOR],
          additionalData: z
        }), await d(), ve || g ? Ve(!0) : r?.({ ...R }), Fe({});
      } catch (H) {
        V({ label: i((z) => z.failedToUpdateDetails), variant: "error" }), oe(H, E.SOLE_PROPRIETOR);
      } finally {
        be("success");
      }
    } else {
      if (!p || !a) {
        V({
          label: l((k) => k.missingCompanyDetails),
          variant: "error"
        });
        return;
      }
      let H = !1, z = !1;
      try {
        const k = [];
        if (_) {
          const B = X(
            E.PARENT_COMPANY,
            _,
            u,
            C,
            _?.id
          );
          k.push(B);
        }
        if (q) {
          const B = X(
            E.ULTIMATE_PARENT_COMPANY,
            q,
            u,
            C,
            q?.id
          );
          k.push(B);
        }
        const Oe = await Promise.allSettled(k), Re = [
          ...a.entityAssociations ? a.entityAssociations.filter(
            (B) => B.type !== "immediateParentCompany" && B.type !== "ultimateParentCompany"
          ) : []
        ], Se = [E.COMPANY];
        if (Oe.forEach((B, Ne) => {
          const x = Ne === 0 ? E.PARENT_COMPANY : E.ULTIMATE_PARENT_COMPANY;
          if (B.status === "fulfilled") {
            const $e = B.value;
            x === E.PARENT_COMPANY ? (Re.push({
              type: "immediateParentCompany",
              legalEntityId: $e.id,
              associatorId: p.id
            }), Se.push(E.PARENT_COMPANY)) : x === E.ULTIMATE_PARENT_COMPANY && (Re.push({
              type: "ultimateParentCompany",
              legalEntityId: $e.id,
              associatorId: p.id
            }), Se.push(E.ULTIMATE_PARENT_COMPANY));
          } else
            x === E.PARENT_COMPANY ? H = !0 : x === E.ULTIMATE_PARENT_COMPANY && (z = !0), oe(B.reason, x);
        }), !H && !z) {
          p.entityAssociations = [...Re];
          const B = {
            ...ce("Business", p),
            ...ce("ParentCompany", _),
            ...ce(
              "UltimateParentCompany",
              q
            )
          };
          try {
            await X(
              E.COMPANY,
              p,
              u,
              C,
              p?.id
            ), c.addTaskEvent("Success", {
              actionType: "submit",
              returnValue: Se,
              additionalData: B
            }), await d(), ve || g ? Ve(!0) : r?.({ ...R });
          } catch (Ne) {
            V({ label: i((x) => x.failedToUpdateDetails), variant: "error" }), oe(Ne, E.COMPANY);
          }
          Fe({});
        }
      } catch (k) {
        !H && !z && oe(k, E.COMPANY), V({ label: i((Oe) => Oe.failedToUpdateDetails), variant: "error" });
      } finally {
        be("success");
      }
    }
  }, oe = (h, p) => {
    const Y = p === E.SOLE_PROPRIETOR ? {
      ...mn,
      ...He
    } : cn;
    if (Qn(h.actualError)) {
      const _ = Xn(h.actualError, void 0, Y);
      Fe((q) => ({
        ...q,
        validationErrors: {
          ...q?.validationErrors,
          [p]: _?.[p] ?? {}
        }
      }));
    } else ea(h) ? V({
      label: i((_) => _.maintenanceModeMessage),
      variant: "error",
      duration: "indefinite"
    }) : V({ label: i((_) => _.failedToUpdateDetails), variant: "error" });
  }, [In, Fn] = se(void 0), qe = Jn({
    requiredFields: In,
    defaultData: b,
    rules: pa
  }), { data: R = b, isValid: ze, errors: re, valid: ke } = qe, xe = ee(() => {
    let h = {};
    if (R?.soleProprietor)
      h = { soleProprietor: { ...N.soleProprietor } };
    else {
      h = { company: { ...N.company } };
      const p = R?.company?.isCompanyOwnedByAnotherCompany === "Yes", Y = R?.company?.isParentOwnedByAnotherCompany === "Yes";
      p && (h = { ...h, parentCompany: N.parentCompany }), p && Y && (h = {
        ...h,
        ultimateParentCompany: N.ultimateParentCompany
      });
    }
    return h;
  }, [
    R?.soleProprietor,
    R?.company?.isCompanyOwnedByAnotherCompany,
    R?.company?.isParentOwnedByAnotherCompany
  ]);
  ue(() => {
    const h = Oa(
      n,
      R,
      a?.organization?.registeredAddress
    );
    Fn(h);
  }, [R, a?.organization?.registeredAddress]);
  const ie = ee(() => {
    const h = $n(
      xe,
      nn,
      {}
    );
    return jn(h, ze, O);
  }, [xe, ze, nn, O]), {
    handleNextClick: bn,
    handleBackClick: vn,
    activeForm: Te,
    gotoFormByFormIndex: Ge,
    steps: Ke,
    shouldValidate: te
  } = Wn({
    problems: O,
    forms: ie,
    onSubmit: En
  }), Tn = (h) => /* @__PURE__ */ o("div", { className: "adyen-kyc-form-wrapper", children: [
    h.formId === "soleProprietor" && /* @__PURE__ */ o(
      $a,
      {
        data: b?.soleProprietor,
        legalEntity: a,
        heading: l((p) => p.additionalInformationForBusinessFinancing),
        id: h.formId,
        country: n,
        shouldValidate: te,
        fieldValidationErrors: O?.validationErrors?.[h?.formId],
        formVerificationErrors: O?.verificationErrors?.[h?.formId],
        errors: re?.soleProprietor,
        valid: ke?.soleProprietor
      }
    ),
    h.formId === me && /* @__PURE__ */ o(
      za,
      {
        data: b?.company,
        legalEntity: a,
        heading: l((p) => p.additionalInformationForBusinessFinancing),
        id: me,
        country: n,
        shouldValidate: te,
        fieldValidationErrors: O?.validationErrors?.[h?.formId],
        formVerificationErrors: O?.verificationErrors?.[h?.formId],
        errors: re?.company,
        valid: ke?.company
      }
    ),
    h.formId === eo && /* @__PURE__ */ o(
      Ga,
      {
        data: b?.parentCompany,
        heading: i((p) => p.parentCompanyInformation),
        id: me,
        country: n,
        shouldValidate: te,
        errors: re?.parentCompany,
        legalEntity: a
      }
    ),
    h.formId === no && /* @__PURE__ */ o(
      Wa,
      {
        data: b?.ultimateParentCompany,
        heading: i((p) => p.ultimateParentCompanyInformation),
        id: me,
        country: n,
        shouldValidate: te,
        errors: re?.ultimateParentCompany,
        legalEntity: a
      }
    )
  ] });
  if (!b?.company && !b?.soleProprietor)
    return /* @__PURE__ */ o(Hn, {});
  const On = O?.validationErrors && Object.values(O.validationErrors)?.reduce(
    (h, p) => ({ ...h, ...p }),
    {}
  ), Rn = O?.verificationErrors && Object.values(O.verificationErrors)?.reduce(
    (h, p) => ({ ...h, ...p }),
    {}
  ), Sn = w({ labels: {} }, i), Nn = (h) => {
    const p = ie.findIndex((Y) => Y.formId === h);
    p >= 0 && Ge(p);
  }, Ln = Na(
    m.language,
    l,
    Q,
    R,
    a?.organization?.registeredAddress
  );
  return Pn ? /* @__PURE__ */ o(
    Zn,
    {
      title: l((h) => h.submissionReceived),
      description: l((h) => h.theInformationProvidedIsBeingReviewed),
      action: r && !ve ? /* @__PURE__ */ o(Un, { onClick: () => r?.({ ...R }), children: t || i((h) => h.finish) }) : void 0
    }
  ) : /* @__PURE__ */ o(Gn, { form: qe, children: /* @__PURE__ */ o(
    xn,
    {
      summaryComponent: /* @__PURE__ */ o(Xa, { items: Ln, handleEditForm: Nn, forms: ie, children: /* @__PURE__ */ o(
        ae,
        {
          validationErrors: On,
          verificationErrors: Rn,
          formUtils: Sn,
          id: "ariaErrorField",
          slot: "errorPanel"
        }
      ) }),
      currentStep: Ke.current,
      disableNextButton: !Te.isValid,
      forms: ie,
      activeForm: Te,
      gotoFormByFormIndex: Ge,
      handleBackClick: vn,
      handleCancelClick: s,
      handleNextClick: bn,
      loadingStatus: Cn,
      totalSteps: Ke.total,
      children: /* @__PURE__ */ o("div", { children: Tn(
        Te || (b?.soleProprietor ? N.soleProprietor : N.company)
      ) })
    }
  ) });
}
export {
  Uo as B
};
