import { j as m } from "./jsx-runtime-tc70JA_2.js";
import { b, u as C, B as E } from "./Animated-CO--9HPM.js";
import { createPortal as j } from "react-dom";
import "@synnaxlabs/x";
import { C as o } from "./css-D90kZTM8.js";
import { a as M } from "./Box-Bi280MYh.js";
const D = (l = "root") => document.getElementById(l) ?? document.body, h = ({
  style: l,
  background: d = 0,
  className: g,
  bordered: c = !0,
  rounded: u = 1,
  passthrough: a = !1,
  children: y,
  ...p
}) => {
  const {
    ref: x,
    targetCorner: i,
    dialogCorner: n,
    style: s,
    modalPosition: f
  } = b("Dialog.Dialog"), { visible: r, variant: t } = C();
  if (!r && !a) return null;
  const B = r && (Object.keys(s).length > 0 || t === "modal");
  let e = /* @__PURE__ */ m.jsx(
    M,
    {
      pack: !0,
      ref: x,
      y: !0,
      background: d,
      className: o(
        o.BE("dialog", "dialog"),
        o.loc(i.x),
        o.loc(i.y),
        o.BEM("dialog", "dialog", n.x),
        o.BEM("dialog", "dialog", n.y),
        o.visible(B),
        a && o.BM("dialog", "passthrough"),
        o.M(t),
        t === "modal" && o.BM("dialog", "modal", "position", f.toString()),
        g
      ),
      rounded: u,
      role: "dialog",
      empty: !0,
      bordered: c,
      align: "stretch",
      style: { ...s, ...l },
      ...p,
      children: y
    }
  );
  return t === "modal" && (e = /* @__PURE__ */ m.jsx(E, { empty: !0, align: "center", visible: r, children: e })), a ? e : j(e, D());
};
export {
  h as D
};
