var m = Object.defineProperty;
var l = (t, o, r) => o in t ? m(t, o, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[o] = r;
var i = (t, o, r) => l(t, typeof o != "symbol" ? o + "" : o, r);
import { jsx as e, jsxs as c } from "react/jsx-runtime";
import { p4 as p, alignItemsCenter as u, gap2 as h, justifyContentCenter as f, dFlexColumn as y } from "./index-general.module.js";
import { classNames as g } from "./index-classNames.js";
import { Accordion as x } from "./index-Accordion.js";
import { Button as C, ButtonTypes as E } from "./index-Button.js";
import { IconSize as S } from "./index-Icon.js";
import { ErrorModal as B } from "./index-ErrorModal.js";
import { Text as s, FontWeights as a, TextTypes as I } from "./index-Text.js";
import { Component as w } from "react";
class z extends w {
  constructor(r) {
    super(r);
    i(this, "state", {
      error: "",
      errorInfo: "",
      hasError: !1
    });
  }
  static getDerivedStateFromError(r) {
    return {
      hasError: !0,
      error: r
    };
  }
  componentDidCatch(r, n) {
    this.props.onError(r, n), this.setState({
      errorInfo: n
    });
  }
  render() {
    const {
      hasError: r,
      errorInfo: n
    } = this.state, {
      isModal: d
    } = this.props;
    return r ? d ? e(B, {
      close: () => location.reload(),
      source: "ErrorBoundry"
    }) : e("div", {
      className: "card my-5",
      children: c("div", {
        className: g(y, f, h, u, p),
        children: [e(s, {
          type: I.heading2,
          fontWeight: a.bold,
          children: "Aw, snap!"
        }), e(s, {
          children: "An error occurred while processing your request"
        }), e(C, {
          type: E.secondary,
          onClick: () => {
            window.location.reload();
          },
          children: "Reload page"
        }), e(x, {
          variant: "outlined",
          summaryCustomStyle: {
            justifyContent: "space-between",
            paddingLeft: "12px"
          },
          baseCustomStyle: {
            borderBottom: "1px solid var(--n200)",
            marginBottom: "1px",
            maxWidth: "100%"
          },
          detailsCustomStyle: {
            marginLeft: "12px",
            marginBottom: "16px"
          },
          accordionId: "FrequentlyAskedQuestionsAccordion",
          disableGutters: !0,
          iconSize: S.small,
          summaryChildren: e(s, {
            testId: "question",
            fontWeight: a.medium,
            children: "Error info:"
          }),
          detailsChildren: e(s, {
            testId: "answer",
            children: n && n.componentStack.toString()
          })
        })]
      })
    }) : this.props.children;
  }
}
export {
  z as ErrorBoundary
};
