import { jsx as s, jsxs as C, Fragment as S } from "react/jsx-runtime";
import * as r from "react";
import { useRef as j, useState as K, useEffect as J, forwardRef as H, useCallback as He, startTransition as Ve } from "react";
import { h as Y, r as We, p as Fe, b as Q, g as q, T as $e, J as Ue, t as Z, V as Xe, n as je } from "./use-editor.CHZsl_Yo.js";
import "./index.Bxix3KXR.js";
import { a as Ke, o as Je, b as Ye, c as Qe, s as qe, d as Ze, u as et, F as tt, e as nt } from "./floating-ui.react.VzclYQox.js";
import { c as ot, B as rt } from "./use-section-style.Cg6VYj5D.js";
import { r as X, F as at, ai as st } from "./_commonjsHelpers.BCwc0xb5.js";
import { m as it } from "./menubar-styles.DM8mXdFr.js";
import { u as V } from "./schema-resolver.C4i_G2fr.js";
import { _ as T } from "./twind.BLUk_ZzT.js";
import { P as ct } from "./dnd.esm.ByOls-Fs.js";
import "@sinclair/typebox";
import { H as lt, I as ee, a as ut } from "./theme.BjGhr3iS.js";
import { g as dt, c as pt, P as mt, b as B, a as ft, y as v, h as W } from "./index.DaRbhbpm.js";
import { c as te, R as ht, A as xt, P as Ct, C as gt, G as Mt, L as vt, I as bt, S as wt, a as Pt, b as Nt, d as It, e as St, f as yt, g as Et, h as Rt, i as Bt, n as _, j as ne, k as kt, l as _t, p as Tt } from "./base-menu.props.BqcMYHjx.js";
import { a as At, l as Ot, t as oe } from "./index.B15rbXRU.js";
import { v as re } from "./radius.prop.B549yVS5.js";
import { c as k } from "./index.BsxM-ToU.js";
var F = "ContextMenu", [Dt, Vn] = pt(F, [
  te
]), g = te(), [zt, ae] = Dt(F), se = (e) => {
  const { __scopeContextMenu: t, children: n, onOpenChange: a, dir: o, modal: i = !0 } = e, [c, l] = r.useState(!1), m = g(t), f = dt(a), d = r.useCallback(
    (h) => {
      l(h), f(h);
    },
    [f]
  );
  return /* @__PURE__ */ s(
    zt,
    {
      scope: t,
      open: c,
      onOpenChange: d,
      modal: i,
      children: /* @__PURE__ */ s(
        ht,
        {
          ...m,
          dir: o,
          open: c,
          onOpenChange: d,
          modal: i,
          children: n
        }
      )
    }
  );
};
se.displayName = F;
var ie = "ContextMenuTrigger", ce = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, disabled: a = !1, ...o } = e, i = ae(ie, n), c = g(n), l = r.useRef({ x: 0, y: 0 }), m = r.useRef({
      getBoundingClientRect: () => DOMRect.fromRect({ width: 0, height: 0, ...l.current })
    }), f = r.useRef(0), d = r.useCallback(
      () => window.clearTimeout(f.current),
      []
    ), h = (u) => {
      l.current = { x: u.clientX, y: u.clientY }, i.onOpenChange(!0);
    };
    return r.useEffect(() => d, [d]), r.useEffect(() => void (a && d()), [a, d]), /* @__PURE__ */ C(S, { children: [
      /* @__PURE__ */ s(xt, { ...c, virtualRef: m }),
      /* @__PURE__ */ s(
        mt.span,
        {
          "data-state": i.open ? "open" : "closed",
          "data-disabled": a ? "" : void 0,
          ...o,
          ref: t,
          style: { WebkitTouchCallout: "none", ...e.style },
          onContextMenu: a ? e.onContextMenu : B(e.onContextMenu, (u) => {
            d(), h(u), u.preventDefault();
          }),
          onPointerDown: a ? e.onPointerDown : B(
            e.onPointerDown,
            A((u) => {
              d(), f.current = window.setTimeout(() => h(u), 700);
            })
          ),
          onPointerMove: a ? e.onPointerMove : B(e.onPointerMove, A(d)),
          onPointerCancel: a ? e.onPointerCancel : B(e.onPointerCancel, A(d)),
          onPointerUp: a ? e.onPointerUp : B(e.onPointerUp, A(d))
        }
      )
    ] });
  }
);
ce.displayName = ie;
var Gt = "ContextMenuPortal", le = (e) => {
  const { __scopeContextMenu: t, ...n } = e, a = g(t);
  return /* @__PURE__ */ s(Ct, { ...a, ...n });
};
le.displayName = Gt;
var ue = "ContextMenuContent", de = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = ae(ue, n), i = g(n), c = r.useRef(!1);
    return /* @__PURE__ */ s(
      gt,
      {
        ...i,
        ...a,
        ref: t,
        side: "right",
        sideOffset: 2,
        align: "start",
        onCloseAutoFocus: (l) => {
          var m;
          (m = e.onCloseAutoFocus) == null || m.call(e, l), !l.defaultPrevented && c.current && l.preventDefault(), c.current = !1;
        },
        onInteractOutside: (l) => {
          var m;
          (m = e.onInteractOutside) == null || m.call(e, l), !l.defaultPrevented && !o.modal && (c.current = !0);
        },
        style: {
          ...e.style,
          "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
          "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
          "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
          "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
          "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
        }
      }
    );
  }
);
de.displayName = ue;
var Lt = "ContextMenuGroup", pe = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = g(n);
    return /* @__PURE__ */ s(Mt, { ...o, ...a, ref: t });
  }
);
pe.displayName = Lt;
var Ht = "ContextMenuLabel", me = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = g(n);
    return /* @__PURE__ */ s(vt, { ...o, ...a, ref: t });
  }
);
me.displayName = Ht;
var Vt = "ContextMenuItem", fe = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = g(n);
    return /* @__PURE__ */ s(bt, { ...o, ...a, ref: t });
  }
);
fe.displayName = Vt;
var Wt = "ContextMenuCheckboxItem", he = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(St, { ...o, ...a, ref: t });
});
he.displayName = Wt;
var Ft = "ContextMenuRadioGroup", xe = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(Et, { ...o, ...a, ref: t });
});
xe.displayName = Ft;
var $t = "ContextMenuRadioItem", Ce = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(Rt, { ...o, ...a, ref: t });
});
Ce.displayName = $t;
var Ut = "ContextMenuItemIndicator", ge = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(yt, { ...o, ...a, ref: t });
});
ge.displayName = Ut;
var Xt = "ContextMenuSeparator", Me = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(wt, { ...o, ...a, ref: t });
});
Me.displayName = Xt;
var jt = "ContextMenuArrow", Kt = r.forwardRef(
  (e, t) => {
    const { __scopeContextMenu: n, ...a } = e, o = g(n);
    return /* @__PURE__ */ s(Bt, { ...o, ...a, ref: t });
  }
);
Kt.displayName = jt;
var Jt = "ContextMenuSub", ve = (e) => {
  const { __scopeContextMenu: t, children: n, onOpenChange: a, open: o, defaultOpen: i } = e, c = g(t), [l, m] = ft({
    prop: o,
    defaultProp: i,
    onChange: a
  });
  return /* @__PURE__ */ s(Pt, { ...c, open: l, onOpenChange: m, children: n });
};
ve.displayName = Jt;
var Yt = "ContextMenuSubTrigger", be = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(Nt, { ...o, ...a, ref: t });
});
be.displayName = Yt;
var Qt = "ContextMenuSubContent", we = r.forwardRef((e, t) => {
  const { __scopeContextMenu: n, ...a } = e, o = g(n);
  return /* @__PURE__ */ s(
    It,
    {
      ...o,
      ...a,
      ref: t,
      style: {
        ...e.style,
        "--radix-context-menu-content-transform-origin": "var(--radix-popper-transform-origin)",
        "--radix-context-menu-content-available-width": "var(--radix-popper-available-width)",
        "--radix-context-menu-content-available-height": "var(--radix-popper-available-height)",
        "--radix-context-menu-trigger-width": "var(--radix-popper-anchor-width)",
        "--radix-context-menu-trigger-height": "var(--radix-popper-anchor-height)"
      }
    }
  );
});
we.displayName = Qt;
function A(e) {
  return (t) => t.pointerType !== "mouse" ? e(t) : void 0;
}
var qt = se, Zt = ce, Pe = le, en = de, tn = pe, nn = me, on = fe, rn = he, an = xe, sn = Ce, Ne = ge, cn = Me, ln = ve, un = be, dn = we;
const Ie = (e) => r.createElement(qt, { ...e });
Ie.displayName = "ContextMenu.Root";
const Se = r.forwardRef(({ children: e, ...t }, n) => r.createElement(Zt, { ...t, ref: n, asChild: !0 }, At(e)));
Se.displayName = "ContextMenu.Trigger";
const ye = r.createContext({}), Ee = r.forwardRef((e, t) => {
  const n = lt(), { size: a = _.size.default, variant: o = _.variant.default, highContrast: i = _.highContrast.default } = e, { className: c, children: l, color: m, container: f, forceMount: d, ...h } = re(e, _), u = m || n.accentColor;
  return r.createElement(Pe, { container: f, forceMount: d }, r.createElement(ee, { asChild: !0 }, r.createElement(en, { "data-accent-color": u, alignOffset: -Number(a) * 4, collisionPadding: 10, ...h, asChild: !1, ref: t, className: v("rt-PopperContent", "rt-BaseMenuContent", "rt-ContextMenuContent", c) }, r.createElement(ne, { type: "auto" }, r.createElement("div", { className: v("rt-BaseMenuViewport", "rt-ContextMenuViewport") }, r.createElement(ye.Provider, { value: r.useMemo(() => ({ size: a, variant: o, color: u, highContrast: i }), [a, o, u, i]) }, l))))));
});
Ee.displayName = "ContextMenu.Content";
const Re = r.forwardRef(({ className: e, ...t }, n) => r.createElement(nn, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuLabel", "rt-ContextMenuLabel", e) }));
Re.displayName = "ContextMenu.Label";
const P = r.forwardRef((e, t) => {
  const { className: n, children: a, color: o = kt.color.default, shortcut: i, ...c } = e;
  return r.createElement(on, { "data-accent-color": o, ...c, ref: t, className: v("rt-reset", "rt-BaseMenuItem", "rt-ContextMenuItem", n) }, r.createElement(W, null, a), i && r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, i));
});
P.displayName = "ContextMenu.Item";
const pn = r.forwardRef(({ className: e, ...t }, n) => r.createElement(tn, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuGroup", "rt-ContextMenuGroup", e) }));
pn.displayName = "ContextMenu.Group";
const mn = r.forwardRef(({ className: e, ...t }, n) => r.createElement(an, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuRadioGroup", "rt-ContextMenuRadioGroup", e) }));
mn.displayName = "ContextMenu.RadioGroup";
const fn = r.forwardRef((e, t) => {
  const { children: n, className: a, color: o = Tt.color.default, ...i } = e;
  return r.createElement(sn, { ...i, asChild: !1, ref: t, "data-accent-color": o, className: v("rt-BaseMenuItem", "rt-BaseMenuRadioItem", "rt-ContextMenuItem", "rt-ContextMenuRadioItem", a) }, r.createElement(W, null, n), r.createElement(Ne, { className: "rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator" }, r.createElement(oe, { className: "rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon" })));
});
fn.displayName = "ContextMenu.RadioItem";
const O = r.forwardRef((e, t) => {
  const { children: n, className: a, shortcut: o, color: i = _t.color.default, ...c } = e;
  return r.createElement(rn, { ...c, asChild: !1, ref: t, "data-accent-color": i, className: v("rt-BaseMenuItem", "rt-BaseMenuCheckboxItem", "rt-ContextMenuItem", "rt-ContextMenuCheckboxItem", a) }, r.createElement(W, null, n), r.createElement(Ne, { className: "rt-BaseMenuItemIndicator rt-ContextMenuItemIndicator" }, r.createElement(oe, { className: "rt-BaseMenuItemIndicatorIcon rt-ContextMenuItemIndicatorIcon" })), o && r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, o));
});
O.displayName = "ContextMenu.CheckboxItem";
const D = (e) => r.createElement(ln, { ...e });
D.displayName = "ContextMenu.Sub";
const z = r.forwardRef((e, t) => {
  const { className: n, children: a, ...o } = e;
  return r.createElement(un, { ...o, asChild: !1, ref: t, className: v("rt-BaseMenuItem", "rt-BaseMenuSubTrigger", "rt-ContextMenuItem", "rt-ContextMenuSubTrigger", n) }, a, r.createElement("div", { className: "rt-BaseMenuShortcut rt-ContextMenuShortcut" }, r.createElement(Ot, { className: "rt-BaseMenuSubTriggerIcon rt-ContextMenuSubTriggerIcon" })));
});
z.displayName = "ContextMenu.SubTrigger";
const G = r.forwardRef((e, t) => {
  const { size: n, variant: a, color: o, highContrast: i } = r.useContext(ye), { className: c, children: l, container: m, forceMount: f, ...d } = re({ size: n, variant: a, color: o, highContrast: i, ...e }, _);
  return r.createElement(Pe, { container: m, forceMount: f }, r.createElement(ee, { asChild: !0 }, r.createElement(dn, { "data-accent-color": o, alignOffset: -Number(n) * 4, sideOffset: 1, collisionPadding: 10, ...d, asChild: !1, ref: t, className: v("rt-PopperContent", "rt-BaseMenuContent", "rt-BaseMenuSubContent", "rt-ContextMenuContent", "rt-ContextMenuSubContent", c) }, r.createElement(ne, { type: "auto" }, r.createElement("div", { className: v("rt-BaseMenuViewport", "rt-ContextMenuViewport") }, l)))));
});
G.displayName = "ContextMenu.SubContent";
const L = r.forwardRef(({ className: e, ...t }, n) => r.createElement(cn, { ...t, asChild: !1, ref: n, className: v("rt-BaseMenuSeparator", "rt-ContextMenuSeparator", e) }));
L.displayName = "ContextMenu.Separator";
function I({
  direction: e,
  show: t,
  manifest: n
}) {
  return /* @__PURE__ */ s(
    "button",
    {
      type: "button",
      className: T(
        "resizable-handle absolute focus:outline-none",
        "overflow-visible z-[9998]",
        `resizable-handle-${e}`,
        {
          "-bottom-[2px] left-0 right-0 h-[6px] cursor-row-resize": e === "s",
          "-top-[2px] left-0 right-0 h-[6px] cursor-row-resize": e === "n",
          "top-0 -left-[2px] bottom-0 w-[6px] cursor-col-resize": e === "w",
          "top-0 -right-[2px] bottom-0 w-[6px] cursor-col-resize": e === "e",
          // sw and nw
          "-bottom-[2px] -left-[2px] w-[6px] h-[6px] cursor-nesw-resize": e === "sw",
          "-top-[2px] -left-[2px] w-[6px] h-[6px] cursor-nwse-resize": e === "nw",
          // se and ne
          "-bottom-[2px] -right-[2px] w-[6px] h-[6px] cursor-nwse-resize": e === "se",
          "-top-[2px] -right-[2px] w-[6px] h-[6px] cursor-nesw-resize": e === "ne"
        }
      ),
      children: /* @__PURE__ */ s(
        "div",
        {
          className: T(
            "opacity-0 z-[9999] group-hover/brick:opacity-100 transition-opacity absolute w-[10px] h-[10px] bg-white border-2 rounded-full shadow-md resizable-handle-dot",
            n.isContainer ? "border-orange-500" : "border-upstart-500",
            t && "opacity-100",
            {
              "top-1/2 -translate-y-1/2 -left-[5px]": e === "w",
              "top-1/2 -translate-y-1/2 -right-[5px]": e === "e",
              "left-1/2 -translate-x-1/2 -top-[5px]": e === "n",
              "left-1/2 -translate-x-1/2 -bottom-[5px]": e === "s",
              // sw and nw
              "-bottom-[5px] -left-[5px]": e === "sw",
              "-top-[5px] -left-[5px]": e === "nw",
              // se and ne
              "-bottom-[5px] -right-[5px]": e === "se",
              "-top-[5px] -right-[5px]": e === "ne"
            }
          )
        }
      )
    }
  );
}
function hn(e, t, n) {
  const { maxHeight: a, maxWidth: o, minHeight: i, minWidth: c } = t;
  return {
    canGrowVertical: !0,
    canGrowHorizontal: !0,
    canShrinkVertical: !0,
    canShrinkHorizontal: !0
  };
}
function xn(e = {}) {
  const { tolerance: t = 0, deepCheck: n = !1 } = e, a = j(null), [o, i] = K(!1);
  return J(() => {
    const c = a.current;
    if (!c) return;
    const l = (f) => {
      const d = c.getBoundingClientRect(), { clientX: h, clientY: u } = f;
      if (!(h >= d.left - t && h <= d.right + t && u >= d.top - t && u <= d.bottom + t)) {
        i(!1);
        return;
      }
      if (n) {
        const b = document.elementFromPoint(h, u), E = b === c || c.contains(b);
        i(E);
      } else
        i(!0);
    }, m = () => {
      i(!1);
    };
    return document.addEventListener("mousemove", l), c.addEventListener("mouseleave", m), () => {
      document.removeEventListener("mousemove", l), c.removeEventListener("mouseleave", m);
    };
  }, [t, n]), { ref: a, isHovered: o };
}
function Cn(e, t, n) {
  if (!(n != null && n.isDropAnimating) || !n.dropAnimation)
    return t;
  const { draggingOver: a } = n, { moveTo: o } = n.dropAnimation;
  if (console.log("getDropAnimationStyle", {
    snapshot: n,
    style: t
  }), a === e) {
    const i = `translate(${o.x}px, 0px)`;
    return {
      ...t,
      transform: `${i}`
    };
  }
  return {
    ...t
  };
}
function gn(e) {
  return ["bottom", "top"];
}
const Wn = H(
  ({ brick: e, children: t, isContainerChild: n, index: a }, o) => {
    const i = j(!1), c = Y(), l = We(), { panelPosition: m } = Fe(), f = Q(), { getParentBrick: d } = q(), h = $e(e.id), u = V(e.type), p = d(e.id), [b, E] = K(!1), Be = gn(), ke = Ue(), {
      refs: R,
      floatingStyles: _e,
      update: $,
      context: Te
    } = Ke({
      open: b,
      onOpenChange: E,
      whileElementsMounted: nt,
      transform: !0,
      middleware: [
        Je(u.isContainer ? { mainAxis: 8, crossAxis: 0 } : { mainAxis: 6, crossAxis: 0 }),
        Ye({
          allowedPlacements: Be
        })
      ]
    }), Ae = Qe(Te, {
      handleClose: qe(),
      delay: {
        open: 50,
        close: 200
      }
    }), { getReferenceProps: Oe, getFloatingProps: De } = Ze([Ae]);
    J(() => {
      if (R.reference.current) {
        const x = () => {
          i.current = !0;
        }, w = () => {
          i.current = !1;
        }, y = () => {
          $(), setTimeout(() => {
            i.current = !1;
          }, 200);
        }, M = R.reference.current;
        return M.addEventListener("mousedown", w), M.addEventListener("mouseup", y), M.addEventListener("mousemove", x), () => {
          M.removeEventListener("mousedown", w), M.removeEventListener("mouseup", y), M.removeEventListener("mousemove", x);
        };
      }
    }, [R.reference, $]);
    const ze = He(
      (x) => {
        const w = x.target, y = x.currentTarget;
        if (i.current || !y.matches("[data-brick]") || x.defaultPrevented && !w.closest('[data-prevented-by-editor="true"]')) {
          console.log(
            "EditableBrickWrapper: Click ignored due to mouse movement or default prevented",
            w
          );
          return;
        }
        let M = e, U = "brick";
        x.shiftKey ? p && (M = p) : (x.ctrlKey || x.metaKey) && h && (U = "section", M = h), f.hidePanel(), (m === "left" && x.clientX < window.innerWidth * 0.25 || m === "right" && x.clientX > window.innerWidth * 0.75) && f.togglePanelPosition(), Ve(() => {
          U === "section" ? f.setSelectedSectionId(M.id) : f.setSelectedBrickId(M.id), f.setPanel("inspector");
        }), i.current = !1, x.stopPropagation();
      },
      [m]
    ), { ref: Ge, isHovered: N } = xn({ tolerance: 6, deepCheck: !0 }), Le = ot({
      brick: e,
      editable: !0,
      selected: c === e.id,
      isContainerChild: n
    });
    return /* @__PURE__ */ s(
      ct,
      {
        draggableId: e.id,
        index: a,
        isDragDisabled: !u.movable || n || l === "mobile",
        children: (x, w) => {
          var M;
          const y = et([x.innerRef, R.setReference, o, Ge]);
          return hn(e, X[e.type]), /* @__PURE__ */ s(wn, { brick: e, isContainerChild: n, children: /* @__PURE__ */ C(
            "div",
            {
              ref: y,
              ...x.draggableProps,
              ...x.dragHandleProps,
              ...Oe(),
              id: e.id,
              "data-brick": !0,
              "data-brick-id": e.id,
              "data-brick-type": e.type,
              "data-element-kind": u.kind,
              "data-last-touched": e.props.lastTouched ?? "0",
              "data-container-child": n,
              "data-draggable-for-brick-id": e.id,
              "data-brick-width": e.props.width,
              "data-brick-height": e.props.height,
              "data-brick-max-width": JSON.stringify(u.maxWidth),
              "data-brick-min-width": JSON.stringify(u.minWidth),
              style: Cn(h == null ? void 0 : h.id, x.draggableProps.style, w),
              className: T(
                Le,
                w.isDragging ? "opacity-90 !z-[9999] shadow-xl overflow-hidden !cursor-grabbing" : "hover:cursor-auto"
              ),
              onClick: ze,
              children: [
                /* @__PURE__ */ s(rt, { brick: e, selectedBrickId: c, editable: !0 }),
                !u.isContainer && /* @__PURE__ */ s(Mn, { brick: e }),
                /* @__PURE__ */ s(tt, { children: /* @__PURE__ */ s(
                  vn,
                  {
                    ref: R.setFloating,
                    brick: e,
                    isContainerChild: n,
                    style: _e,
                    show: b,
                    ...De()
                  }
                ) }),
                ((M = X[e.type]) == null ? void 0 : M.resizable) && !n && !ke && !w.isDragging && /* @__PURE__ */ C(S, { children: [
                  /* @__PURE__ */ C(S, { children: [
                    /* @__PURE__ */ s(I, { direction: "s", show: N, manifest: u }),
                    /* @__PURE__ */ s(I, { direction: "n", show: N, manifest: u })
                  ] }),
                  l === "desktop" && /* @__PURE__ */ C(S, { children: [
                    /* @__PURE__ */ s(I, { direction: "w", show: N, manifest: u }),
                    /* @__PURE__ */ s(I, { direction: "e", show: N, manifest: u })
                  ] }),
                  l === "desktop" && /* @__PURE__ */ C(S, { children: [
                    /* @__PURE__ */ s(I, { direction: "se", show: N, manifest: u }),
                    /* @__PURE__ */ s(I, { direction: "sw", show: N, manifest: u }),
                    /* @__PURE__ */ s(I, { direction: "ne", show: N, manifest: u }),
                    /* @__PURE__ */ s(I, { direction: "nw", show: N, manifest: u })
                  ] })
                ] })
              ]
            }
          ) });
        }
      },
      e.id
    );
  }
);
function Mn({ brick: e }) {
  return Z() ? /* @__PURE__ */ s("div", { className: "absolute hidden group-hover/brick:block bottom-1 right-1 text-xs text-black/40", children: e.id }) : null;
}
const vn = H(
  ({ brick: e, style: t, isContainerChild: n, show: a, ...o }, i) => {
    const c = Y(), l = V(e.type), m = Xe(), f = a && l.isContainer && !c || a && !l.isContainer && !n || c === e.id;
    return !f || m ? null : /* @__PURE__ */ s(
      "div",
      {
        ref: i,
        "data-ui": !0,
        "data-ui-menu-bars-container": !0,
        role: "navigation",
        className: T(
          "z-[99999] isolate text-base items-center gap-1",
          "transition-opacity duration-150 border rounded-lg",
          f ? "opacity-100 flex" : "opacity-0 hidden",
          l.isContainer ? "border-orange-300" : "border-transparent"
        ),
        style: t,
        ...o,
        children: /* @__PURE__ */ s(bn, { brick: e })
      }
    );
  }
);
function bn({ brick: e }) {
  return /* @__PURE__ */ s(
    "div",
    {
      id: `text-editor-menu-${e.id}`,
      className: T("contents", it, "!empty:hidden")
    }
  );
}
const wn = H(
  ({ brick: e, isContainerChild: t, children: n }, a) => {
    var h, u;
    const o = q(), i = Q(), c = Z(), l = V(e.type), m = o.canMoveToWithinParent(e.id, "previous"), f = o.canMoveToWithinParent(e.id, "next"), d = o.getParentBrick(e.id);
    return /* @__PURE__ */ C(
      Ie,
      {
        modal: !1,
        onOpenChange: (p) => {
          i.setContextMenuVisible(p);
        },
        children: [
          /* @__PURE__ */ s(Se, { disabled: c, ref: a, children: n }),
          /* @__PURE__ */ s(ut, { children: /* @__PURE__ */ C(Ee, { className: "nodrag", size: "2", children: [
            /* @__PURE__ */ C(Re, { className: "!text-sm", children: [
              l.name,
              " (",
              l.kind,
              ")"
            ] }),
            l.duplicatable && /* @__PURE__ */ s(
              P,
              {
                shortcut: "⌘D",
                onClick: (p) => {
                  p.stopPropagation(), o.duplicateBrick(e.id);
                },
                children: "Duplicate"
              }
            ),
            m && /* @__PURE__ */ s(
              P,
              {
                shortcut: t ? "⌘↑" : "⌘←",
                onClick: (p) => {
                  p.stopPropagation(), o.moveBrickWithin(e.id, "previous");
                },
                children: t ? "Move up" : "Move left"
              }
            ),
            f && /* @__PURE__ */ s(
              P,
              {
                shortcut: t ? "⌘↓" : "⌘→",
                onClick: (p) => {
                  p.stopPropagation(), o.moveBrickWithin(e.id, "next");
                },
                children: t ? "Move down" : "Move right"
              }
            ),
            /* @__PURE__ */ C(D, { children: [
              /* @__PURE__ */ s(z, { children: "Visible on" }),
              /* @__PURE__ */ C(G, { children: [
                /* @__PURE__ */ s(
                  O,
                  {
                    checked: !((h = e.props.hidden) != null && h.mobile),
                    onClick: (p) => p.stopPropagation(),
                    onCheckedChange: () => o.toggleBrickVisibilityPerBreakpoint(e.id, "mobile"),
                    children: "Mobile"
                  }
                ),
                /* @__PURE__ */ s(
                  O,
                  {
                    checked: !((u = e.props.hidden) != null && u.desktop),
                    onClick: (p) => p.stopPropagation(),
                    onCheckedChange: () => o.toggleBrickVisibilityPerBreakpoint(e.id, "desktop"),
                    children: "Desktop"
                  }
                )
              ] })
            ] }),
            !t && /* @__PURE__ */ C(D, { children: [
              /* @__PURE__ */ s(z, { children: "Vertical Position" }),
              /* @__PURE__ */ s(G, { children: Object.entries(at(st.alignSelf)).map(([p, b]) => /* @__PURE__ */ s(
                O,
                {
                  checked: e.props.alignSelf === b.const,
                  onClick: (E) => E.stopPropagation(),
                  onCheckedChange: () => o.updateBrickProps(e.id, {
                    alignSelf: b.const
                  }),
                  children: b.title
                },
                p
              )) })
            ] }),
            d && /* @__PURE__ */ C(S, { children: [
              /* @__PURE__ */ s(L, {}),
              /* @__PURE__ */ C(D, { children: [
                /* @__PURE__ */ s(z, { children: "Parent container" }),
                /* @__PURE__ */ C(G, { children: [
                  /* @__PURE__ */ s(
                    P,
                    {
                      onClick: (p) => {
                        p.stopPropagation(), o.duplicateBrick(d.id);
                      },
                      children: "Duplicate container"
                    }
                  ),
                  /* @__PURE__ */ s(
                    P,
                    {
                      onClick: (p) => {
                        p.stopPropagation(), i.setSelectedBrickId(d.id), i.setPanel("inspector");
                      },
                      children: "Edit container"
                    }
                  ),
                  /* @__PURE__ */ s(L, {}),
                  /* @__PURE__ */ s(
                    P,
                    {
                      shortcut: "⌫",
                      color: "red",
                      onClick: (p) => {
                        p.stopPropagation(), o.deleteBrick(d.id), i.deselectBrick(d.id), i.hidePanel("inspector");
                      },
                      children: "Delete container"
                    }
                  )
                ] })
              ] }),
              /* @__PURE__ */ s(
                P,
                {
                  onClick: (p) => {
                    p.stopPropagation(), o.detachBrickFromContainer(e.id);
                  },
                  children: "Detach from parent"
                }
              )
            ] }),
            l.deletable && /* @__PURE__ */ C(S, { children: [
              /* @__PURE__ */ s(L, {}),
              /* @__PURE__ */ s(
                P,
                {
                  shortcut: "⌫",
                  color: "red",
                  onClick: (p) => {
                    p.stopPropagation(), o.deleteBrick(e.id), i.deselectBrick(e.id), i.hidePanel("inspector");
                  },
                  children: "Delete"
                }
              )
            ] })
          ] }) })
        ]
      }
    );
  }
);
function Fn() {
  const e = je(), t = k("(max-width: 768px)"), n = k("(min-width: 769px) and (max-width: 1024px)"), a = k("(min-width: 1025px)"), o = k("(min-width: 1420px)"), i = k("(min-width: 1200px)");
  return {
    isMobile: t,
    isTablet: n,
    isDesktop: a,
    canUseDnd: !e && i || e && o
  };
}
export {
  Wn as E,
  pn as N,
  P as R,
  Re as S,
  L as W,
  Se as g,
  Ie as h,
  Fn as u,
  Ee as y
};
//# sourceMappingURL=use-device-info.DDmUrtYw.js.map
