import { jsx as n } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { memo as p } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/compat/dist/compat.module.js";
import { useMemo as i } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { TX_TIMELINE_VALUE as C, TX_TIMELINE_LABEL as D } from "../../constants.js";
import { getTransactionTimelineTxType as _, getTransactionTimelineTxStatus as g } from "../../../../utils/translation/getters.js";
import { TimelineDateFormat as v } from "../../../../internal/Timeline/types.js";
import { TypographyVariant as T, TypographyElement as d } from "../../../../internal/Typography/types.js";
import { TimelineItem as M } from "../../../../internal/Timeline/components/TimelineItem.js";
import f from "../../../../internal/Typography/Typography.js";
import N from "../../../../internal/Timeline/Timeline.js";
import w from "../../../../../core/Context/preact/useCoreContext.js";
import x from "../../../../internal/StructuredList/StructuredList.js";
import P from "../../../../../utils/random/uniqueId.js";
const c = ({ transaction: t }) => {
  const m = t.createdAt, r = t.events, a = t.balanceAccount?.timeZone, o = i(
    () => ({
      format: v.FULL_DATE_EXACT_TIME_WITHOUT_SECONDS,
      date: new Date(m),
      timezone: a
    }),
    [m, a]
  ), s = i(() => {
    const e = /* @__PURE__ */ new WeakMap();
    return r?.forEach((l) => e.set(l, P())), e;
  }, [r]);
  return r ? /* @__PURE__ */ n(N, { showMore: { limit: 2, placement: "before-last" }, children: r.map((e) => /* @__PURE__ */ n(c.Item, { event: e, defaultTimestamp: o }, s.get(e))) }) : null;
}, V = (t) => /* @__PURE__ */ n(f, { el: d.DIV, variant: T.CAPTION, className: D, children: t }), S = (t) => /* @__PURE__ */ n(f, { el: d.DIV, variant: T.CAPTION, className: C, children: t });
c.Item = p(({ defaultTimestamp: t, event: m }) => {
  const { amount: r, createdAt: a, status: o, type: s } = m, { i18n: e } = w(), l = i(() => ({ ...t, date: new Date(a) }), [t, a]), y = i(() => _(e, s), [e, s]), I = i(() => {
    const { currency: u, value: E } = r, h = `${e.amount(E, u, { hideCurrency: !0 })} ${u}`, A = g(e, o);
    return [
      { key: "transactions.details.timeline.fields.amount", value: h },
      { key: "transactions.details.timeline.fields.status", value: A }
    ];
  }, [e, r, o]), L = o.toLowerCase().includes("refund") ? "Refund" : o.toLowerCase().includes("auth") ? "Capture" : y;
  return /* @__PURE__ */ n(M, { title: L, timestamp: l, children: /* @__PURE__ */ n(
    x,
    {
      align: "start",
      layout: "3-9",
      items: I,
      renderLabel: V,
      renderValue: S
    }
  ) });
});
const K = p(c);
export {
  K as default
};
