import { jsx as m } from "../../../external/.pnpm/preact@10.28.2/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js";
import { isCapitalRegionSupported as c } from "../../internal/CapitalHeader/helpers.js";
import { UIElement as l } from "../UIElement/UIElement.js";
import { CapitalOverview as f } from "./components/CapitalOverview/CapitalOverview.js";
import d from "../../../core/ConfigContext/session/utils/sessionReady.js";
import { EMPTY_OBJECT as n } from "../../../utils/value/constants.js";
import { noop as s } from "../../../utils/common.js";
class x extends l {
  static type = "capitalOverview";
  constructor(t) {
    super(t), this.componentToRender = this.componentToRender.bind(this), this.customClassNames = "adyen-pe-capital-overview-component";
  }
  componentToRender = () => /* @__PURE__ */ m(f, { ...this.props });
  async getState() {
    const { session: t } = this.props.core;
    await d(t);
    const { getDynamicGrantOffersConfiguration: r, getGrants: a } = t.context.endpoints, p = t.context.extraConfig?.legalEntity;
    if (!c(p))
      return { state: "isInUnsupportedRegion" };
    const [o, i] = await Promise.all([
      r?.(n).catch(s),
      a?.(n).catch(s)
    ]);
    let e = "isUnqualified";
    return i && i.data?.length > 0 ? e = "hasRequestedGrants" : o && o.minAmount && (e = "isPreQualified"), { state: e };
  }
}
export {
  x as CapitalOverviewElement,
  x as default
};
