import { jsx as t } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import N from "../../../../internal/Tabs/Tabs.js";
import _ from "./PaymentRefundAlerts.js";
import C from "./PaymentDetailsActions.js";
import L from "./PaymentDetailsProperties.js";
import R from "./PaymentDetailsStatusBox.js";
import B from "./PaymentDetailsSummary.js";
import X from "./PaymentDetailsTimeline.js";
import { DetailsTab as m } from "../../types.js";
import { TX_DETAILS_TABS as w, TX_DATA_CLASS as x, TX_DATA_CONTAINER as U } from "../../constants.js";
import { useState as Y, useMemo as p, useEffect as j } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import O from "../../../../../core/Context/preact/useCoreContext.js";
const F = ({
  dataCustomization: i,
  extraFields: r,
  fullRefundFailed: c,
  fullRefundInProgress: v,
  refundAmounts: D,
  refundAvailable: d,
  refundCurrency: y,
  refundDisabled: S,
  refundedAmount: b,
  refundedState: l,
  refundLocked: g,
  setActiveView: h,
  transaction: e,
  transactionNavigator: E
}) => {
  const { i18n: P } = O(), [s, n] = Y(), o = p(
    () => w.filter(({ id: a }) => {
      switch (a) {
        case m.SUMMARY: {
          const { additions: u, deductions: f, originalAmount: T, amountBeforeDeductions: A, netAmount: M } = e;
          return u && u.length > 0 || f && f.length > 0 || T && T.value !== A.value || M.value !== A.value;
        }
        case m.TIMELINE:
          return e.events && e.events.length > 0;
        default:
          return !0;
      }
    }),
    [e]
  ), I = p(
    () => ({
      [m.DETAILS]: /* @__PURE__ */ t(L, { dataCustomization: i, extraFields: r, transaction: e }),
      [m.SUMMARY]: /* @__PURE__ */ t(B, { transaction: e }),
      [m.TIMELINE]: /* @__PURE__ */ t(X, { transaction: e })
    }),
    [i, r, e]
  );
  return j(() => n(o[0]?.id), [o]), /* @__PURE__ */ t("div", { className: x, children: [
    /* @__PURE__ */ t(R, { refundedState: l, transaction: e }),
    /* @__PURE__ */ t("div", { className: U, children: [
      o.length > 1 && /* @__PURE__ */ t(
        N,
        {
          "aria-label": P.get("transactions.details.viewSelect.a11y.label"),
          onChange: ({ id: a }) => n(a),
          tabs: o,
          activeTab: s
        }
      ),
      s && I[s]
    ] }),
    /* @__PURE__ */ t(
      _,
      {
        fullRefundFailed: c,
        fullRefundInProgress: v,
        refundAmounts: D,
        refundCurrency: y,
        refundedAmount: b,
        refundedState: l,
        refundLocked: g
      }
    ),
    /* @__PURE__ */ t(
      C,
      {
        extraFields: r,
        refundAvailable: d,
        refundDisabled: S,
        setActiveView: h,
        transaction: e,
        transactionNavigator: E
      }
    )
  ] });
};
export {
  F as default
};
