import { OverrideCSS as n, EDITOR_PREVIEWER_ID as d } from "./accelbyte-widgets78.mjs";
import { SSRHelper as l } from "./accelbyte-widgets242.mjs";
import i from "classnames";
import o, { Component as m } from "react";
import c from "react-dom";
import { X as p } from "react-feather";
import s from "./accelbyte-widgets444.mjs";
function u(t) {
  if (l.isSSR())
    return null;
  const e = t ? "editorDialogWrapper" : "dialogWrapper";
  let r = document.getElementById(e);
  return r || (r = document.createElement("div"), r.id = e, t ? h(r) : document.body.appendChild(r)), r;
}
function h(t) {
  const e = document.getElementById(d);
  e && e.appendChild(t);
}
const N = (t) => /* @__PURE__ */ o.createElement("div", { className: i(s.dialogBody, t.className) }, t.children), R = (t) => /* @__PURE__ */ o.createElement("div", { className: i(s.dialogFooter, t.className) }, t.children);
class O extends m {
  constructor(e) {
    super(e), this.modalRoot = u(this.props.isPreviewMode), this.modalContainer = l.isSSR() ? null : document.createElement("div");
  }
  componentDidMount() {
    !this.modalRoot || !this.modalContainer || this.modalRoot.appendChild(this.modalContainer);
  }
  componentWillUnmount() {
    !this.modalRoot || !this.modalContainer || this.modalRoot.removeChild(this.modalContainer);
  }
  renderDialog() {
    const { title: e = "", className: r = "", onClose: a = null } = this.props;
    return /* @__PURE__ */ o.createElement("section", { className: i("dialog", r, n.BODY_FONT) }, e && /* @__PURE__ */ o.createElement("div", { className: "dialogHeader" }, /* @__PURE__ */ o.createElement("h2", { className: i("titleContainer", n.TITLE_FONT) }, e), !!a && /* @__PURE__ */ o.createElement("div", { className: "closeButtonContainer", style: { color: "rgb(var(--od-rgba-secondary)" } }, /* @__PURE__ */ o.createElement(
      "button",
      {
        onClick: () => {
          a && a();
        }
      },
      /* @__PURE__ */ o.createElement(p, null)
    ))), this.props.children);
  }
  renderDialogOverlay() {
    const { isOpen: e } = this.props;
    if (e)
      return /* @__PURE__ */ o.createElement("div", { className: "dialogOverlay editorDialogOverlay" }, this.renderDialog());
  }
  render() {
    var e;
    return this.props.isPreviewMode && ((e = this.props.className) != null && e.includes("paymentStatusDialog")) ? this.renderDialogOverlay() : this.modalContainer ? c.createPortal(this.renderDialogOverlay(), this.modalContainer) : /* @__PURE__ */ o.createElement("div", null);
  }
}
export {
  O as Dialog,
  N as DialogBody,
  R as DialogFooter,
  u as getDialogContainer
};
