import { jsx as s } from "react/jsx-runtime";
import { useState as b, useMemo as C, useCallback as u } from "react";
import { createPortal as w } from "react-dom";
import { c as i } from "./index.CfM2L_w0.js";
import { a as p } from "./index.CfQlFjZU.js";
import { n as v } from "./index.B0wX8xO7.js";
import { a as h } from "./ProgressActivity.DYLCzf8q.js";
import { a as M, g as A, d as D } from "./GridRow._ehOXG8R.js";
import { G as y } from "./GridLayouts.DSIvKCIo.js";
import { D as G } from "./dialog.CWXLj3fC.js";
const S = "creator_item-row_7-1vb", g = "creator_container_xNdtB", k = "creator_container__basic_8fAAK", O = "creator_modal_L4sFh", x = "creator_modal__basic_3sZUq", B = "creator_modal__advanced_QWutO", L = "creator_row__basic_81kUN", V = "creator_style__basic_wzakf", z = "creator_style__advanced_NSON-", I = "creator_loader_A0SzC", P = "creator_icon_3aLNB", e = { "item-row": S, container: g, container__basic: k, modal: O, modal__basic: x, modal__advanced: B, row__basic: L, style__basic: V, style__advanced: z, loader: I, icon: P };
function Y() {
  const [a, o] = b(!1), t = C(() => (r) => /* @__PURE__ */ s(
    j,
    {
      isOpen: a,
      onDismiss: () => {
        o(!1), r.onDismiss?.();
      },
      ...r
    }
  ), [a]), c = u(() => {
    o(!0);
  }, []), n = u(() => {
    o(!1);
  }, []);
  return {
    Modal: t,
    openModal: c,
    closeModal: n
  };
}
var R = /* @__PURE__ */ ((a) => (a.BASIC = "basic", a.ADVANCED = "advanced", a))(R || {});
function U({
  isOpen: a = !1,
  type: o = "basic",
  loading: t = !1,
  onClickLoader: c = () => {
  },
  onDismiss: n = () => {
  },
  children: r,
  containerClassName: l,
  modalClassName: d,
  rowClassName: _,
  ...m
}) {
  return {
    isOpen: a,
    loading: t,
    content: r,
    onClickLoader: c,
    onDismiss: n,
    dialogProps: m,
    containerClassName: i(e.container, l, {
      [e.container__basic]: o === "basic"
      /* BASIC */
    }),
    modalClassName: i(
      e.modal,
      e[`modal__${o}`],
      d
    ),
    rowClassName: i(_, {
      [e.row__basic]: o === "basic"
      /* BASIC */
    }),
    childClassName: i(e[`style__${o}`], y.colCentre),
    loaderClassName: e.loader,
    iconClassName: e.icon
  };
}
function $({
  isOpen: a,
  loading: o,
  content: t,
  onClickLoader: c,
  onDismiss: n,
  dialogProps: r,
  containerClassName: l,
  childClassName: d,
  iconClassName: _,
  loaderClassName: m,
  modalClassName: f,
  rowClassName: N
}) {
  return a ? w(
    /* @__PURE__ */ s("div", { className: l, children: /* @__PURE__ */ s(M, { className: f, "data-testId": "container", children: /* @__PURE__ */ s(
      v,
      {
        value: o,
        then: /* @__PURE__ */ s("div", { onClick: c, className: m, children: /* @__PURE__ */ s(
          h,
          {
            className: _,
            "data-testid": "loader"
          }
        ) }),
        otherwise: /* @__PURE__ */ s(A, { className: N, children: /* @__PURE__ */ s(D, { className: d, "aria-role": "Sample", children: /* @__PURE__ */ s(
          G,
          {
            ...r,
            onDismiss: n,
            slot: t,
            "data-testid": "dialog"
          }
        ) }) })
      }
    ) }) }),
    document.body
  ) : null;
}
const j = p($, U, "Modal");
export {
  R as M,
  j as a,
  Y as u
};
