import { jsx as l } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { memo as h } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { RefundedState as u } from "../../types.js";
import { useMemo as y } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { TX_REFUND_STATUSES_CONTAINER as _ } from "../../constants.js";
import { AlertTypeOption as T, AlertVariantOption as N } from "../../../../internal/Alert/types.js";
import { Alert as P } from "../../../../internal/Alert/Alert.js";
import { TypographyVariant as v, TypographyElement as I } from "../../../../internal/Typography/types.js";
import A from "../../../../internal/Typography/Typography.js";
import F from "../../../../../core/Context/preact/useCoreContext.js";
const L = {
  type: T.HIGHLIGHT,
  variant: N.TIP
}, V = h(
  ({
    fullRefundFailed: p,
    fullRefundInProgress: c,
    refundAmounts: r,
    refundCurrency: m,
    refundedAmount: a,
    refundedState: d,
    refundLocked: g
  }) => {
    const { i18n: t } = F(), i = y(() => {
      const o = new Intl.ListFormat(t.locale, { type: "conjunction" });
      return (s) => o.format(s.map((e) => t.amount(e, m)));
    }, [t, m]), f = y(() => {
      const o = [], s = ({ description: e, ...n }) => {
        o.push(
          /* @__PURE__ */ l(P, { ...L, ...n, children: /* @__PURE__ */ l(A, { className: "adyen-pe-alert__description", el: I.DIV, variant: v.BODY, wide: !0, children: e }) })
        );
      };
      if (d === u.FULL)
        s({ description: t.get("transactions.details.refund.alerts.refundedFull") });
      else {
        if (a > 0) {
          const e = { amount: i([a]) };
          s({ description: t.get("transactions.details.refund.alerts.refundedAmount", { values: e }) });
        }
        if (g)
          s({ description: t.get("transactions.details.refund.alerts.inProgressBlocked") });
        else {
          if (r.in_progress && r.in_progress.length > 0)
            if (c)
              s({ description: t.get("transactions.details.refund.alerts.inProgress") });
            else {
              const e = { amount: i(r.in_progress) };
              s({ description: t.get("transactions.details.refund.alerts.inProgressAmount", { values: e }) });
            }
          if (r.failed && r.failed.length > 0) {
            const e = T.WARNING;
            if (p)
              s({ type: e, description: t.get("transactions.details.refund.alerts.notPossible") });
            else {
              const n = { amount: i(r.failed) };
              s({ type: e, description: t.get("transactions.details.refund.alerts.notPossibleAmount", { values: n }) });
            }
          }
        }
      }
      return o;
    }, [p, c, i, t, r, g, a, d]);
    return f.length > 0 ? /* @__PURE__ */ l("div", { className: _, children: f }) : null;
  }
);
export {
  V as default
};
