import { jsx as i } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useCallback as h, useMemo as b } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import C from "../../../../internal/Tabs/Tabs.js";
import T from "../../../../../hooks/useTimezoneAwareDateFormatting.js";
import { TypographyVariant as A } from "../../../../internal/Typography/types.js";
import k from "../../../../internal/Typography/Typography.js";
import { PaymentLinkActivity as _ } from "../PaymentLinkActivity/PaymentLinkActivity.js";
/* empty css                     */
import L from "../../../../internal/CopyText/CopyText.js";
import { BACKEND_REDACTED_DATA_MARKER as I, FRONTEND_REDACTED_DATA_MARKER as u } from "../../../../constants.js";
import D from "../../../../internal/Link/Link.js";
import E from "../../../../../core/Context/preact/useCoreContext.js";
import { DATE_FORMAT_PAYMENT_LINK_DETAILS_TABS as v } from "../../../../../constants/dateFormats.js";
import f from "../../../../internal/StructuredList/StructuredList.js";
import { Fragment as c } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/dist/preact.module.js";
const r = {
  root: "adyen-pe-payment-link-tabs",
  list: "adyen-pe-payment-link-tabs__list",
  listHeading: "adyen-pe-payment-link-tabs__list-heading",
  listLabel: "adyen-pe-payment-link-tabs__list-label",
  listValue: "adyen-pe-payment-link-tabs__list-value"
}, z = ({ paymentLink: e }) => {
  const { i18n: t } = E(), { dateFormat: m } = T(), a = h((s) => Object.values(s).some((y) => y === I), []), o = b(() => {
    const s = e.linkInformation.linkType, y = {
      linkInformation: [
        {
          key: "payByLink.details.fields.paymentLinkId",
          value: e.linkInformation.paymentLinkId,
          config: { isCopyable: !0, linkUrl: e.linkInformation.paymentLink }
        },
        {
          key: "payByLink.details.fields.store",
          value: e.linkInformation.storeCode
        },
        {
          key: "payByLink.details.fields.merchantReference",
          value: e.linkInformation.merchantReference
        },
        {
          key: "payByLink.details.fields.createdOn",
          value: m(e.linkInformation.creationDate, v)
        },
        {
          key: "payByLink.details.fields.expiresOn",
          value: m(e.linkInformation.expirationDate, v)
        },
        {
          key: "payByLink.details.fields.linkType",
          value: t.has(`payByLink.common.linkType.${s}`) ? t.get(`payByLink.common.linkType.${s}`) : s
        },
        {
          key: "payByLink.details.fields.description",
          value: e.linkInformation.description
        }
      ],
      shopperInformation: [
        {
          key: "payByLink.details.fields.shopper.reference",
          value: e.shopperInformation?.shopperReference
        },
        {
          key: "payByLink.details.fields.shopper.fullName",
          value: [e.shopperInformation?.shopperName?.firstName, e.shopperInformation?.shopperName?.lastName].filter(Boolean).join(" "),
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shopper.email",
          value: e.shopperInformation?.shopperEmail,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shopper.phone",
          value: e.shopperInformation?.telephoneNumber,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shopper.country",
          value: e.shopperInformation?.shopperCountry
        },
        ...e.shopperInformation?.shippingAddress && a(e.shopperInformation?.shippingAddress) ? [
          {
            key: "payByLink.details.fields.shippingAddress.title",
            value: u
          }
        ] : [],
        ...e.shopperInformation?.billingAddress && a(e.shopperInformation?.billingAddress) ? [
          {
            key: "payByLink.details.fields.billingAddress.title",
            value: u
          }
        ] : []
      ],
      shippingAddress: !e.shopperInformation?.shippingAddress || a(e.shopperInformation?.shippingAddress) ? [] : [
        {
          key: "payByLink.details.fields.shippingAddress.street",
          value: e.shopperInformation?.shippingAddress?.street,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shippingAddress.houseNumberOrName",
          value: e.shopperInformation?.shippingAddress?.houseNumberOrName,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shippingAddress.country",
          value: e.shopperInformation?.shippingAddress?.country
        },
        {
          key: "payByLink.details.fields.shippingAddress.city",
          value: e.shopperInformation?.shippingAddress?.city,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.shippingAddress.postalCode",
          value: e.shopperInformation?.shippingAddress?.postalCode,
          config: { isCopyable: !0 }
        }
      ],
      billingAddress: !e.shopperInformation?.billingAddress || a(e.shopperInformation?.billingAddress) ? [] : [
        {
          key: "payByLink.details.fields.billingAddress.street",
          value: e.shopperInformation?.billingAddress?.street,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.billingAddress.houseNumberOrName",
          value: e.shopperInformation?.billingAddress?.houseNumberOrName,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.billingAddress.country",
          value: e.shopperInformation?.billingAddress?.country
        },
        {
          key: "payByLink.details.fields.billingAddress.city",
          value: e.shopperInformation?.billingAddress?.city,
          config: { isCopyable: !0 }
        },
        {
          key: "payByLink.details.fields.billingAddress.postalCode",
          value: e.shopperInformation?.billingAddress?.postalCode,
          config: { isCopyable: !0 }
        }
      ]
    };
    return Object.fromEntries(
      Object.entries(y).map(([g, p]) => [
        g,
        p.filter((l) => l.value != null && l.value !== "" && l.value !== void 0)
      ])
    );
  }, [e, m, t, a]), n = h((s) => /* @__PURE__ */ i("div", { className: r.listLabel, children: s }), []), d = h((s, y, g, p) => {
    let l;
    if (s && s.toString().includes(I))
      l = u;
    else if (p?.isCopyable && s && s !== "") {
      const N = p?.linkUrl ? /* @__PURE__ */ i(D, { href: p.linkUrl, target: "_blank", children: s.toString() }) : void 0;
      l = /* @__PURE__ */ i(L, { textToCopy: s.toString(), visibleText: N, type: "Default" });
    } else
      l = s;
    return /* @__PURE__ */ i("div", { className: r.listValue, children: l });
  }, []), B = b(
    () => [
      {
        id: "linkInformation",
        label: "payByLink.details.tabs.linkInformation",
        content: /* @__PURE__ */ i(
          f,
          {
            classNames: r.list,
            items: o.linkInformation,
            align: "start",
            layout: "4-8",
            renderLabel: n,
            renderValue: d
          }
        )
      },
      {
        id: "shopperInformation",
        label: "payByLink.details.tabs.shopperInformation",
        content: /* @__PURE__ */ i(c, { children: [
          /* @__PURE__ */ i(
            f,
            {
              classNames: r.list,
              items: o.shopperInformation,
              align: "start",
              layout: "4-8",
              renderLabel: n,
              renderValue: d
            }
          ),
          o.shippingAddress.length > 0 && /* @__PURE__ */ i(c, { children: [
            /* @__PURE__ */ i(k, { variant: A.CAPTION, stronger: !0, className: r.listHeading, children: t.get("payByLink.details.fields.shippingAddress.title") }),
            /* @__PURE__ */ i(
              f,
              {
                classNames: r.list,
                items: o.shippingAddress,
                align: "start",
                layout: "4-8",
                renderLabel: n,
                renderValue: d
              }
            )
          ] }),
          o.billingAddress.length > 0 && /* @__PURE__ */ i(c, { children: [
            /* @__PURE__ */ i(k, { variant: A.CAPTION, stronger: !0, className: r.listHeading, children: t.get("payByLink.details.fields.billingAddress.title") }),
            /* @__PURE__ */ i(
              f,
              {
                classNames: r.list,
                items: o.billingAddress,
                align: "start",
                layout: "4-8",
                renderLabel: n,
                renderValue: d
              }
            )
          ] })
        ] })
      },
      {
        id: "activity",
        label: "payByLink.details.tabs.activity",
        content: /* @__PURE__ */ i(_, { activities: e.paymentLinkActivities ?? [] })
      }
    ],
    [o, n, d, t, e.paymentLinkActivities]
  );
  return /* @__PURE__ */ i("div", { className: r.root, children: /* @__PURE__ */ i(C, { tabs: B }) });
};
export {
  z as PaymentLinkTabs
};
