import { jsx as t } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useState as C, useCallback as u, useEffect as g } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import { popoverUtil as S } from "../../../../internal/Popover/utils/popoverUtil.js";
import { DisputeDetailsContainer as h } from "../../../DisputeManagement/components/DisputeDetailsContainer/DisputeDetailsContainer.js";
import A from "../../../../../core/Context/preact/useCoreContext.js";
import D from "../../../../internal/Modal/Modal.js";
const E = ({
  children: c,
  selectedDetail: e,
  resetDetails: n,
  dataCustomization: p,
  onContactSupport: f,
  refreshDisputesList: a,
  setModalVisible: o
}) => {
  const { i18n: l } = A(), [i, r] = C(!1), s = !!e, d = u(() => {
    i && (r(!1), a("CHARGEBACKS")), o(!1), n();
  }, [i, a, n, o]), m = u(() => {
    r(!0);
  }, []);
  return g(() => {
    s && (o(!0), S.closeAll());
  }, [s, o]), /* @__PURE__ */ t("div", { children: [
    c,
    e && /* @__PURE__ */ t(
      D,
      {
        isOpen: s,
        "aria-label": l.get("disputes.management.common.title"),
        onClose: d,
        isDismissible: !0,
        headerWithBorder: !1,
        size: e.modalSize || "large",
        children: /* @__PURE__ */ t(
          h,
          {
            id: e.selection.data,
            dataCustomization: p,
            onDisputeAccept: m,
            onDisputeDefend: m,
            onContactSupport: f,
            onDismiss: n,
            hideTitle: !0
          }
        )
      }
    )
  ] });
};
export {
  E as DisputeManagementModal
};
