import { jsx as e } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { useCallback as u, useRef as _, useEffect as y } from "../../../../../external/.pnpm/preact@10.28.2/node_modules/preact/hooks/dist/hooks.module.js";
import l from "../../../../internal/Button/Button.js";
import { ButtonVariant as f } from "../../../../internal/Button/types.js";
import { TypographyVariant as t } from "../../../../internal/Typography/types.js";
import { SuccessIcon as v } from "../../../../internal/SuccessIcon/SuccessIcon.js";
import i from "../../../../internal/Typography/Typography.js";
import { useDisputeFlow as C } from "../../context/dispute/context.js";
/* empty css                       */
import N from "../../../../../core/Context/preact/useCoreContext.js";
import { Icon as k } from "../../../../internal/Icon/Icon.js";
import { isFunction as B } from "../../../../../utils/value/is.js";
const x = ({ onDisputeDefend: a }) => {
  const { i18n: s } = N(), { clearFiles: r, clearStates: c, dispute: d, setFlowState: n, defendResponse: o } = C(), g = u(() => {
    c(), n("details");
  }, [c, n]), h = u(() => {
    r(), n("uploadDefenseFilesView");
  }, [r, n]), m = _(!1);
  return y(() => {
    if (!m.current && o === "success" && B(a)) {
      const p = d?.dispute.pspReference;
      p && (m.current = !0, a({ id: p }));
    }
  }, [o, d, a]), /* @__PURE__ */ e("div", { className: "adyen-pe-defend-dispute__response", children: o === "success" ? /* @__PURE__ */ e("div", { className: "adyen-pe-defend-dispute__success", children: [
    /* @__PURE__ */ e(v, { className: "adyen-pe-defend-dispute__success-icon" }),
    /* @__PURE__ */ e(i, { variant: t.TITLE, children: s.get("disputes.management.defend.common.evidenceSubmitted") }),
    /* @__PURE__ */ e(i, { variant: t.BODY, className: "adyen-pe-defend-dispute__success-description", children: s.get("disputes.management.defend.chargeback.submitSuccessInfo") }),
    /* @__PURE__ */ e("div", { className: "adyen-pe-defend-dispute__success-buttons", children: /* @__PURE__ */ e(l, { variant: f.SECONDARY, onClick: g, children: s.get("disputes.management.common.actions.showDetails") }) })
  ] }) : /* @__PURE__ */ e("div", { className: "adyen-pe-defend-dispute__error", children: [
    /* @__PURE__ */ e(k, { name: "cross-circle-fill", className: "adyen-pe-defend-dispute__error-icon" }),
    /* @__PURE__ */ e(i, { variant: t.TITLE, medium: !0, children: s.get("disputes.management.defend.common.errors.somethingWentWrong") }),
    /* @__PURE__ */ e(i, { variant: t.BODY, children: s.get("disputes.management.defend.common.errors.defenseFailed") }),
    /* @__PURE__ */ e(l, { variant: f.SECONDARY, onClick: h, children: s.get("disputes.management.common.actions.goBack") })
  ] }) });
};
export {
  x as DefendDisputeResponse
};
