import { jsx as s } from "../../../../../preact@10.29.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { lazy as P } from "../../../../../preact@10.29.0/node_modules/preact/compat/dist/compat.module.js";
import { u as K, z as b, aB as M, ax as I, C as U, ac as R } from "./StoreProvider-CBB99upB.js";
import { I as q } from "./unincorporated-partnership-QawJyhxx.js";
import { L as k } from "./List-BAzyC6sw.js";
import { S as G } from "./StructuredList-EKVbq_i3.js";
import { useEffect as J } from "../../../../../preact@10.29.0/node_modules/preact/hooks/dist/hooks.module.js";
import { E as Q } from "./ErrorPanel-D4kO8XQ8.js";
import { t as W } from "./trackNavigation-db_h46BT.js";
import { c as X } from "./formUtils-BEcbGHkz.js";
import { g as Y } from "./roleMetadata-C8VLzyMj.js";
import { i as Z } from "./summaryItem-CAQCQSkt.js";
try {
  let y = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {}, d = new y.Error().stack;
  d && (y._sentryDebugIds = y._sentryDebugIds || {}, y._sentryDebugIds[d] = "75f15944-3e6f-43a5-915a-dc2c06165a2e", y._sentryDebugIdIdentifier = "sentry-dbid-75f15944-3e6f-43a5-915a-dc2c06165a2e");
} catch {
}
const $ = () => {
  const y = b();
  J(() => {
    y.addPageEvent("Landed on page", {
      actionType: "navigate"
    });
  }, []);
}, D = "adyen-kyc-summary", ee = "adyen-kyc-summary-content", se = "adyen-kyc-summary-list", te = "adyen-kyc-summary-list-header", re = "adyen-kyc-summary-list-header-title", ne = "adyen-kyc-summary-list-item", ae = "adyen-kyc-summary-list-item-key", ie = "adyen-kyc-summary-list-item-value", me = "adyen-kyc-summary-content-legal-caption", oe = "adyen-kyc-summary-content-list", ce = "adyen-kyc-summary-content-logo", c = {
  summary: D,
  summaryContent: ee,
  summaryList: se,
  summaryListHeader: te,
  summaryListHeaderTitle: re,
  summaryListItem: ne,
  summaryListItemKey: ae,
  summaryListItemValue: ie,
  summaryContentLegalCaption: me,
  summaryContentList: oe,
  summaryContentLogo: ce
}, ue = P(() => import("./onfido-logo-BSkKPH10.js")), ye = {
  formId: "summary",
  formName: "summary"
};
function be({
  data: y,
  forms: d,
  gotoForm: x,
  labels: p,
  problems: f,
  omitted: L = {},
  showFormHeader: N = !0,
  showSectionHeader: g = !0,
  showLegalCaption: T = !1,
  showTaxExemptedLegalCaption: j = !1,
  useStructuredList: S = !1
}) {
  const { t: a } = K("common"), O = b();
  $();
  const V = (e) => {
    const r = d.findIndex((n) => n.formId === e);
    r >= 0 && x(r);
  }, _ = f?.validationErrors && Object.values(f.validationErrors)?.reduce(
    (e, r) => ({ ...e, ...r }),
    {}
  ), A = f?.verificationErrors && Object.values(f.verificationErrors)?.reduce(
    (e, r) => ({ ...e, ...r }),
    {}
  ), H = X({ labels: p }, a), v = (e, r) => /* @__PURE__ */ s("header", { className: c.summaryListHeader, children: [
    /* @__PURE__ */ s("h2", { className: c.summaryListHeaderTitle, children: e }),
    !L.summaryEditButton?.includes(r) && /* @__PURE__ */ s(
      U,
      {
        variant: "tertiary",
        icon: "edit",
        onClick: () => {
          W({
            userEvents: O,
            actionType: "edit",
            toForm: e,
            label: "Pencil icon"
          }), V(r);
        },
        ariaLabel: a((n) => n.editForm, { formName: e })
      }
    )
  ] }), E = (e, r = {}, n, t, i) => {
    const m = Object.entries(e).map(([o, u]) => ({
      term: a((l) => l[r[o] || o]),
      details: u
    }));
    return i ? /* @__PURE__ */ s(k, { variant: "grouped-secondary", children: [
      g && v(n, t),
      /* @__PURE__ */ s(G, { items: m })
    ] }) : /* @__PURE__ */ s(k, { variant: "grouped-secondary", children: [
      g && v(n, t),
      /* @__PURE__ */ s("dl", { className: c.summaryList, children: Array.isArray(e) ? e.map((o) => B(o)) : C(e, r) })
    ] });
  }, w = (e, r) => {
    const n = [];
    return d.forEach(({ formId: t, formName: i }) => {
      const m = e[t];
      if (!m || Object.values(m).every((l) => I(l)) || t === ye.formId || L.forms?.includes(t)) return;
      const u = m.hasInnerForms ? z(p?.[t], t, m) : E(
        m,
        p?.[t],
        a(
          (l) => l[typeof p?.[t] == "string" ? p[t] : i]
        ),
        t,
        r
      );
      n.push(u);
    }), n;
  }, z = (e, r, n = {}) => {
    if (!n) return [];
    const t = [];
    return Object.entries(n).forEach(([i, m]) => {
      const o = a(
        (u) => u[e?.[i] || i]
      );
      if (typeof m == "object" && m !== null) {
        if (Object.values(m).every((u) => I(u)))
          return;
        t.push(E(m, e, o, r));
      }
    }), t;
  }, h = (e, r) => /* @__PURE__ */ s("div", { className: c.summaryListItem, children: [
    /* @__PURE__ */ s("dt", { className: c.summaryListItemKey, children: e }),
    /* @__PURE__ */ s("dd", { className: c.summaryListItemValue, children: r })
  ] }), B = (e) => /* @__PURE__ */ s("ul", { className: c.summaryContentList, children: /* @__PURE__ */ s("li", { children: e }) }), C = (e = {}, r = {}) => {
    if (!e) return [];
    if (e?.idVerificationMethod === "instantVerification")
      return [
        h(
          a((t) => t.verificationMethod),
          /* @__PURE__ */ s(q, { lazyLoadedImage: ue, className: c.summaryContentLogo })
        )
      ];
    const n = [];
    return Object.entries(e).forEach(([t, i]) => {
      if (L.keys?.includes(t) || !i) return;
      const m = a((o) => o[r[t] || t]);
      if (t === "role" && Array.isArray(i)) {
        const o = i.length > 1 ? a((l) => l.roles) : m, u = i.map((l) => a((F) => F[Y(l)])).join(", ");
        n.push(h(o, u));
      } else if (Z(i)) {
        const { summaryLabel: o, summaryValue: u } = i;
        n.push(h(R(a, o) ?? "", u));
      } else typeof i == "object" ? n.push(C(i, r)) : ["string", "number"].includes(typeof i) && n.push(h(m, i));
    }), n;
  };
  return /* @__PURE__ */ s("div", { role: "region", className: c.summary, children: [
    N && /* @__PURE__ */ s(M, { title: a((e) => e.summary), description: a((e) => e.summaryDescription) }),
    /* @__PURE__ */ s("div", { className: c.summaryContent, children: [
      /* @__PURE__ */ s(
        Q,
        {
          validationErrors: _,
          verificationErrors: A,
          formUtils: H,
          id: "ariaErrorField"
        }
      ),
      w(y, S),
      T && /* @__PURE__ */ s("div", { className: c.summaryContentLegalCaption, children: a((e) => e.summaryLegalCaption) }),
      j && /* @__PURE__ */ s("div", { className: c.summaryContentLegalCaption, children: [
        /* @__PURE__ */ s("p", { children: a((e) => e.summaryTaxExemptionLegalCaptionTitle) }),
        /* @__PURE__ */ s("ul", { children: [
          /* @__PURE__ */ s("li", { children: a((e) => e.summaryTaxExemptionLegalCaption_1) }),
          /* @__PURE__ */ s("li", { children: a((e) => e.summaryTaxExemptionLegalCaption_2) }),
          /* @__PURE__ */ s("li", { children: a((e) => e.summaryTaxExemptionLegalCaption_3) })
        ] })
      ] })
    ] })
  ] });
}
export {
  be as S,
  c as a,
  ye as s,
  $ as u
};
