import { o as T } from "./rolldown-runtime.js";
import { i as D, t as E } from "./vendor/react.js";
import { t as h } from "./check.js";
import { t as A } from "./chevron-right.js";
import { t as i } from "./utils.js";
import { a as v, i as B, n as K, o as L, r as W, t as q } from "./_shared.js";
import { t as F } from "./use-controllable-state.js";
import { t as J } from "./create-safe-context.js";
import { t as V } from "./Separator.js";
import { a as X, c as b, d as Y, f as $, h as H, l as x, m as Q, n as U, o as Z, p as ee, r as te, s as ne, t as oe, u as C } from "./MenuSubmenuTrigger.js";
var c = /* @__PURE__ */ T(D(), 1), t = E(), [ae, y] = J("ContextMenu");
function m({ children: e, open: n, defaultOpen: o = !1, onOpenChange: a }) {
  const [r, u] = c.useState({
    x: 0,
    y: 0
  }), [d, s] = F({
    value: n,
    defaultValue: o,
    onChange: a
  });
  return /* @__PURE__ */ (0, t.jsx)(ae.Provider, {
    value: {
      open: d,
      setOpen: s,
      position: r,
      setPosition: u
    },
    children: /* @__PURE__ */ (0, t.jsx)(te, {
      "data-slot": "context-menu",
      open: d,
      onOpenChange: s,
      children: e
    })
  });
}
m.displayName = "ContextMenu.Root";
function f({ children: e, className: n, disabled: o = !1, onKeyDown: a, ...r }) {
  const { setOpen: u, setPosition: d } = y();
  return /* @__PURE__ */ (0, t.jsx)("div", {
    "data-slot": "context-menu-trigger",
    tabIndex: 0,
    onContextMenu: c.useCallback((s) => {
      o || (s.preventDefault(), d({
        x: s.clientX,
        y: s.clientY
      }), u(!0));
    }, [
      o,
      u,
      d
    ]),
    onKeyDown: c.useCallback((s) => {
      if (a?.(s), !s.defaultPrevented && !o && s.key === "F10" && s.shiftKey) {
        s.preventDefault();
        const l = s.currentTarget.getBoundingClientRect();
        d({
          x: l.left + l.width / 2,
          y: l.top + l.height / 2
        }), u(!0);
      }
    }, [
      o,
      a,
      u,
      d
    ]),
    className: n,
    ...r,
    children: e
  });
}
f.displayName = "ContextMenu.Trigger";
function M({ ...e }) {
  return /* @__PURE__ */ (0, t.jsx)(x, {
    "data-slot": "context-menu-portal",
    ...e
  });
}
M.displayName = "ContextMenu.Portal";
function g({ alignOffset: e = 0, sideOffset: n = 0, className: o, ...a }) {
  const { position: r } = y(), u = c.useMemo(() => ({ getBoundingClientRect: () => ({
    x: r.x,
    y: r.y,
    width: 0,
    height: 0,
    top: r.y,
    right: r.x,
    bottom: r.y,
    left: r.x,
    toJSON: () => ({})
  }) }), [r.x, r.y]);
  return /* @__PURE__ */ (0, t.jsx)(x, { children: /* @__PURE__ */ (0, t.jsx)(b, {
    className: "isolate z-50 outline-none",
    anchor: u,
    side: "bottom",
    align: "start",
    sideOffset: n,
    alignOffset: e,
    collisionPadding: 8,
    children: /* @__PURE__ */ (0, t.jsx)(C, {
      "data-slot": "context-menu-popup",
      className: i("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 ring-foreground/10 bg-popover text-popover-foreground min-w-32 rounded-md p-1 shadow-md ring-1 duration-100 z-50 max-h-(--available-height) origin-(--transform-origin) overflow-x-hidden overflow-y-auto outline-none data-closed:overflow-hidden motion-reduce:animate-none", o),
      ...a
    })
  }) });
}
g.displayName = "ContextMenu.Popup";
function j({ ...e }) {
  return /* @__PURE__ */ (0, t.jsx)(ee, {
    "data-slot": "context-menu-group",
    ...e
  });
}
j.displayName = "ContextMenu.Group";
function N({ className: e, inset: n, ...o }) {
  return /* @__PURE__ */ (0, t.jsx)($, {
    "data-slot": "context-menu-label",
    "data-inset": n,
    className: i("text-muted-foreground px-2 py-1.5 text-xs font-medium data-[inset]:ps-8", e),
    ...o
  });
}
N.displayName = "ContextMenu.Label";
function _({ className: e, inset: n, variant: o = "default", ...a }) {
  return /* @__PURE__ */ (0, t.jsx)(Y, {
    "data-slot": "context-menu-item",
    "data-inset": n,
    "data-variant": o,
    className: i("focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 dark:data-[variant=destructive]:focus:bg-destructive/20 data-[variant=destructive]:focus:text-destructive data-[variant=destructive]:*:[svg]:text-destructive not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2 rounded-sm px-2 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/context-menu-item relative flex cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-[color,background-color,transform] duration-150 active:scale-[0.99]", e),
    ...a
  });
}
_.displayName = "ContextMenu.Item";
function S({ ...e }) {
  return /* @__PURE__ */ (0, t.jsx)(U, {
    "data-slot": "context-menu-sub",
    ...e
  });
}
S.displayName = "ContextMenu.Sub";
function k({ className: e, inset: n, children: o, ...a }) {
  return /* @__PURE__ */ (0, t.jsxs)(oe, {
    "data-slot": "context-menu-sub-trigger",
    "data-inset": n,
    className: i("focus:bg-accent focus:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground gap-2 rounded-sm px-2 py-2 text-sm [&_svg:not([class*='size-'])]:size-4 group/ctx-sub flex cursor-default items-center outline-hidden select-none data-[inset]:ps-8 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-[color,background-color,transform] duration-150 active:scale-[0.99]", e),
    ...a,
    children: [o, /* @__PURE__ */ (0, t.jsx)(A, { className: "ms-auto rtl:rotate-180 transition-transform duration-150 group-data-open/ctx-sub:translate-x-0.5" })]
  });
}
k.displayName = "ContextMenu.SubTrigger";
function z({ className: e, ...n }) {
  return /* @__PURE__ */ (0, t.jsx)(x, { children: /* @__PURE__ */ (0, t.jsx)(b, {
    className: "isolate z-50 outline-none",
    side: "right",
    align: "start",
    sideOffset: 0,
    alignOffset: -3,
    children: /* @__PURE__ */ (0, t.jsx)(C, {
      "data-slot": "context-menu-sub-popup",
      className: i("data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 ring-foreground/10 bg-popover text-popover-foreground min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100 w-auto motion-reduce:animate-none", e),
      ...n
    })
  }) });
}
z.displayName = "ContextMenu.SubPopup";
function P({ className: e, children: n, checked: o, ...a }) {
  return /* @__PURE__ */ (0, t.jsxs)(H, {
    "data-slot": "context-menu-checkbox-item",
    className: i("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2 rounded-sm py-2 pe-8 ps-2 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors duration-150", e),
    checked: o,
    ...a,
    children: [/* @__PURE__ */ (0, t.jsx)("span", {
      className: "pointer-events-none absolute end-2 flex items-center justify-center",
      "data-slot": "context-menu-checkbox-item-indicator",
      children: /* @__PURE__ */ (0, t.jsx)(Q, {
        className: "animate-in zoom-in-75 duration-150 motion-reduce:animate-none",
        children: /* @__PURE__ */ (0, t.jsx)(h, {})
      })
    }), n]
  });
}
P.displayName = "ContextMenu.CheckboxItem";
function R({ ...e }) {
  return /* @__PURE__ */ (0, t.jsx)(ne, {
    "data-slot": "context-menu-radio-group",
    ...e
  });
}
R.displayName = "ContextMenu.RadioGroup";
function I({ className: e, children: n, ...o }) {
  return /* @__PURE__ */ (0, t.jsxs)(Z, {
    "data-slot": "context-menu-radio-item",
    className: i("focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground gap-2 rounded-sm py-2 pe-8 ps-2 text-sm [&_svg:not([class*='size-'])]:size-4 relative flex cursor-default items-center outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 transition-colors duration-150", e),
    ...o,
    children: [/* @__PURE__ */ (0, t.jsx)("span", {
      className: "pointer-events-none absolute end-2 flex items-center justify-center",
      "data-slot": "context-menu-radio-item-indicator",
      children: /* @__PURE__ */ (0, t.jsx)(X, {
        className: "animate-in zoom-in-75 duration-150 motion-reduce:animate-none",
        children: /* @__PURE__ */ (0, t.jsx)(h, {})
      })
    }), n]
  });
}
I.displayName = "ContextMenu.RadioItem";
function O({ className: e, ...n }) {
  return /* @__PURE__ */ (0, t.jsx)(V, {
    "data-slot": "context-menu-separator",
    className: i("bg-border -mx-1 my-1 h-px", e),
    ...n
  });
}
O.displayName = "ContextMenu.Separator";
function w({ className: e, ...n }) {
  return /* @__PURE__ */ (0, t.jsx)("span", {
    "data-slot": "context-menu-shortcut",
    className: i("text-muted-foreground group-focus/context-menu-item:text-accent-foreground ms-auto text-xs tracking-widest transition-colors duration-150", e),
    ...n
  });
}
w.displayName = "ContextMenu.Shortcut";
var se = Object.assign(m, {
  Root: m,
  Trigger: f,
  Portal: M,
  Popup: g,
  Group: j,
  Label: N,
  Item: _,
  Sub: S,
  SubTrigger: k,
  SubPopup: z,
  CheckboxItem: P,
  RadioGroup: R,
  RadioItem: I,
  Separator: O,
  Shortcut: w
}), p = {
  open: "boolean",
  defaultOpen: "boolean"
}, G = class extends q {
  get propDefs() {
    return p;
  }
  static get observedAttributes() {
    return Object.keys(p).map(K);
  }
  _renderReact() {
    const e = this._readAllProps(), n = this._getSlot("trigger"), o = this._getDefaultSlot();
    return c.createElement(se, {
      open: e.open,
      defaultOpen: e.defaultOpen || !1,
      onOpenChange: (a) => W(this, "open-change", a)
    }, n ? c.createElement(f, null, v(n)) : null, o ? c.createElement(g, null, v(o)) : null);
  }
};
B(G, p);
L("hf-context-menu", G);
export {
  G as ContextMenuWC,
  G as default
};

//# sourceMappingURL=hf-context-menu.js.map