import { jsx as r } from "react/jsx-runtime";
import { useState as a } from "react";
import y from "iframe-resizer-react";
import N from "./Dialog.js";
import u from "../../hooks/usePostMessage.js";
const O = "EVENT_FRAME_DIALOG", L = "_OPEN_DIALOG", P = "_CLOSE_DIALOG", S = (i) => {
  const { eventPrefix: o = O, className: d = "", getSourceFrame: g = () => {
  } } = i, n = `${o}${L}`, e = `${o}${P}`, [p, t] = a(!1), [c, m] = a(""), [E, D] = a({}), { sendMessageToWidget: f } = u(o, (s) => {
    if (console.log(s), s.type === n)
      t(!0), m(s.payload.src), D(s.payload.dialogProps);
    else if (s.type === e) {
      t(!1);
      const l = g();
      l && f(
        {
          type: e,
          payload: s.payload
        },
        [l]
      );
    }
  }), _ = `frame-dialog ${d}`;
  return /* @__PURE__ */ r(
    N,
    {
      ...E,
      show: p,
      bodyClassName: "padding-2 rounded min-height-200",
      body: /* @__PURE__ */ r(y, { src: c, className: "unstyled width-100pct" }),
      disableEsc: !0,
      className: _
    }
  );
};
export {
  P as CLOSE_DIALOG_EVENT,
  O as DEFAULT_PREFIX,
  L as OPEN_DIALOG_EVENT,
  S as default
};
//# sourceMappingURL=FrameDialog.js.map
