{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "menu-context",
  "type": "registry:component",
  "title": "Context Menu",
  "description": "A right-click and long-press menu that opens at the pointer and flips at the edges. It has icons, shortcuts, a submenu, a danger item and full keyboard control.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "context menu",
    "right click",
    "long press",
    "submenu",
    "popover",
    "keyboard"
  ],
  "docs": "https://hyperblur.dev/effects/menu-context",
  "files": [
    {
      "path": "registry/hyperblur/menu-context.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/menu-context.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\n\nexport type ContextIconName =\n  | \"open\"\n  | \"copy\"\n  | \"cut\"\n  | \"paste\"\n  | \"edit\"\n  | \"share\"\n  | \"trash\"\n  | \"star\"\n  | \"link\"\n  | \"folder\"\n  | \"download\"\n  | \"mail\"\n  | \"chat\";\n\nexport interface ContextMenuItem {\n  id: string;\n  label?: string;\n  icon?: React.ReactNode | ContextIconName;\n  shortcut?: string;\n  danger?: boolean;\n  disabled?: boolean;\n  separator?: boolean;\n  items?: ContextMenuItem[];\n}\n\nexport interface MenuContextProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onSelect\"> {\n  items?: ContextMenuItem[];\n  onSelect?: (id: string) => void;\n  boundary?: \"viewport\" | \"container\";\n  longPress?: number;\n  autoDemo?: number;\n  disabled?: boolean;\n  accent?: string;\n}\n\nconst icons: Record<ContextIconName, React.ReactNode> = {\n  open: <path d=\"M9 3h4v4M13 3 7.5 8.5M11 9v3c0 .6-.4 1-1 1H4c-.6 0-1-.4-1-1V6c0-.6.4-1 1-1h3\" />,\n  copy: (\n    <>\n      <rect x=\"5.5\" y=\"5.5\" width=\"8\" height=\"8\" rx=\"1.8\" />\n      <path d=\"M10.5 5.5V4.3a1.8 1.8 0 0 0-1.8-1.8H4.3a1.8 1.8 0 0 0-1.8 1.8v4.4a1.8 1.8 0 0 0 1.8 1.8h1.2\" />\n    </>\n  ),\n  cut: (\n    <>\n      <circle cx=\"4.5\" cy=\"11.5\" r=\"1.8\" />\n      <circle cx=\"11.5\" cy=\"11.5\" r=\"1.8\" />\n      <path d=\"m5.7 10 6.3-7.5M10.3 10 4 2.5\" />\n    </>\n  ),\n  paste: (\n    <>\n      <rect x=\"3\" y=\"3\" width=\"10\" height=\"11\" rx=\"1.8\" />\n      <path d=\"M6 3V2.5h4V3M6 7.5h4M6 10.5h3\" />\n    </>\n  ),\n  edit: <path d=\"m10.5 3 2.5 2.5L6 12.5l-3 .5.5-3z\" />,\n  share: <path d=\"M8 10V2.5M5 5l3-2.5L11 5M3.5 9v3.2c0 .7.6 1.3 1.3 1.3h6.4c.7 0 1.3-.6 1.3-1.3V9\" />,\n  trash: <path d=\"M3 4.5h10M6.5 4.5V3h3v1.5M4.5 4.5l.6 8.2c0 .5.4.8.9.8h4c.5 0 .9-.3.9-.8l.6-8.2M7 7v4M9 7v4\" />,\n  star: <path d=\"m8 2.2 1.8 3.7 4 .6-2.9 2.8.7 4L8 11.4l-3.6 1.9.7-4L2.2 6.5l4-.6z\" />,\n  link: <path d=\"M6.7 9.3a2.6 2.6 0 0 0 3.7 0l2-2a2.6 2.6 0 0 0-3.7-3.7l-.7.7M9.3 6.7a2.6 2.6 0 0 0-3.7 0l-2 2a2.6 2.6 0 0 0 3.7 3.7l.7-.7\" />,\n  folder: <path d=\"M2.5 4.5c0-.6.4-1 1-1h2.7l1.3 1.5h5c.6 0 1 .4 1 1v5.5c0 .6-.4 1-1 1h-9c-.6 0-1-.4-1-1z\" />,\n  download: <path d=\"M8 2.5v8M5 7.5l3 3 3-3M3 13h10\" />,\n  mail: (\n    <>\n      <rect x=\"2.5\" y=\"3.5\" width=\"11\" height=\"9\" rx=\"1.8\" />\n      <path d=\"m3 5 5 3.8L13 5\" />\n    </>\n  ),\n  chat: <path d=\"M3 3.5h10v7H8l-3 2.5v-2.5H3z\" />,\n};\n\nconst defaultItems: ContextMenuItem[] = [\n  { id: \"open\", label: \"Open\", icon: \"open\", shortcut: \"Enter\" },\n  { id: \"rename\", label: \"Rename\", icon: \"edit\", shortcut: \"F2\" },\n  { id: \"copy\", label: \"Copy\", icon: \"copy\", shortcut: \"Cmd C\" },\n  {\n    id: \"share\",\n    label: \"Share\",\n    icon: \"share\",\n    items: [\n      { id: \"share-link\", label: \"Copy link\", icon: \"link\" },\n      { id: \"share-mail\", label: \"Email\", icon: \"mail\" },\n      { id: \"share-chat\", label: \"Send in chat\", icon: \"chat\" },\n    ],\n  },\n  { id: \"sep\", separator: true },\n  { id: \"delete\", label: \"Delete\", icon: \"trash\", shortcut: \"Del\", danger: true },\n];\n\nconst css = `\n.hb-za5 {\n  --hb-za5-c: #2f7bff;\n  box-sizing: border-box;\n  position: relative;\n  width: 100%;\n  font-family: inherit;\n  outline: none;\n  -webkit-touch-callout: none;\n}\n.hb-za5 *, .hb-za5 *::before, .hb-za5 *::after { box-sizing: border-box; }\n.hb-za5:focus-visible { outline: 2px solid var(--hb-za5-c); outline-offset: 2px; border-radius: 12px; }\n.hb-za5-area {\n  display: grid;\n  place-items: center;\n  min-height: 120px;\n  padding: 16px;\n  font-size: 13px;\n  color: #8f8f8f;\n  text-align: center;\n  background: #111111;\n  border: 1px dashed #2f2f2f;\n  border-radius: 12px;\n  user-select: none;\n  -webkit-user-select: none;\n}\n.hb-za5-area b { display: block; margin-bottom: 2px; font-size: 14px; font-weight: 600; color: #ededed; }\n.hb-za5-menu {\n  position: absolute;\n  z-index: 30;\n  width: max-content;\n  min-width: var(--hb-za5-w, 188px);\n  max-width: 280px;\n  padding: 5px;\n  color: #ededed;\n  background: rgba(20, 20, 20, 0.96);\n  border: 1px solid #2c2c2c;\n  border-radius: 12px;\n  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);\n  backdrop-filter: blur(14px);\n  -webkit-backdrop-filter: blur(14px);\n  outline: none;\n  visibility: hidden;\n  font-family: inherit;\n  font-size: 13px;\n  user-select: none;\n  -webkit-user-select: none;\n  animation: hb-za5-pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;\n}\n.hb-za5-menu *, .hb-za5-menu *::before, .hb-za5-menu *::after { box-sizing: border-box; }\n.hb-za5-menu[data-fixed=\"true\"] { position: fixed; z-index: 2147483000; }\n.hb-za5-menu[data-ghost=\"true\"] { pointer-events: none; }\n.hb-za5-row { position: relative; }\n.hb-za5-item {\n  display: flex;\n  align-items: center;\n  gap: 9px;\n  height: 28px;\n  padding: 0 8px;\n  color: #e4e4e4;\n  border-radius: 7px;\n  cursor: default;\n  outline: none;\n  white-space: nowrap;\n  transition: background 0.12s ease, color 0.12s ease;\n}\n.hb-za5-item[data-active=\"true\"], .hb-za5-item:focus-visible { background: color-mix(in srgb, var(--hb-za5-c) 85%, #000); color: #ffffff; }\n.hb-za5-item[data-danger=\"true\"] { color: #ff6b6b; }\n.hb-za5-item[data-danger=\"true\"][data-active=\"true\"], .hb-za5-item[data-danger=\"true\"]:focus-visible { background: #d93f3f; color: #ffffff; }\n.hb-za5-item[aria-disabled=\"true\"] { opacity: 0.4; }\n.hb-za5-ico { display: grid; flex: 0 0 auto; place-items: center; width: 16px; height: 16px; }\n.hb-za5-ico svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }\n.hb-za5-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }\n.hb-za5-key { flex: 0 0 auto; margin-left: 18px; font-size: 11px; letter-spacing: 0.02em; color: #7d7d7d; }\n.hb-za5-item[data-active=\"true\"] .hb-za5-key, .hb-za5-item:focus-visible .hb-za5-key { color: rgba(255, 255, 255, 0.7); }\n.hb-za5-chev { flex: 0 0 auto; width: 12px; height: 12px; margin-left: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.7; }\n.hb-za5-sep { height: 1px; margin: 5px 4px; background: #2a2a2a; }\n.hb-za5-sub {\n  position: absolute;\n  top: -6px;\n  left: calc(100% + 2px);\n  width: max-content;\n  min-width: var(--hb-za5-sw, 168px);\n  padding: 5px;\n  background: rgba(20, 20, 20, 0.98);\n  border: 1px solid #2c2c2c;\n  border-radius: 12px;\n  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);\n  transform-origin: 0 12px;\n  animation: hb-za5-sub 0.14s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;\n}\n.hb-za5-sub[data-flip=\"true\"] { left: auto; right: calc(100% + 2px); transform-origin: 100% 12px; }\n@keyframes hb-za5-pop {\n  from { opacity: 0; transform: scale(0.84); }\n  to { opacity: 1; transform: scale(1); }\n}\n@keyframes hb-za5-sub {\n  from { opacity: 0; transform: translateX(-6px) scale(0.94); }\n  to { opacity: 1; transform: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-za5-menu, .hb-za5-sub { animation: none; }\n  .hb-za5-item { transition: none; }\n}\n`;\n\nfunction Icon({ icon }: { icon: React.ReactNode | ContextIconName | undefined }) {\n  if (icon === undefined || icon === null) return <span className=\"hb-za5-ico\" aria-hidden=\"true\" />;\n  if (typeof icon === \"string\") {\n    const glyph = icons[icon as ContextIconName];\n    return (\n      <span className=\"hb-za5-ico\" aria-hidden=\"true\">\n        {glyph ? <svg viewBox=\"0 0 16 16\">{glyph}</svg> : icon}\n      </span>\n    );\n  }\n  return (\n    <span className=\"hb-za5-ico\" aria-hidden=\"true\">\n      {icon}\n    </span>\n  );\n}\n\ninterface MenuState {\n  x: number;\n  y: number;\n  ghost: boolean;\n  keyboard: boolean;\n}\n\nconst PAD = 8;\n\nfunction subscribeNothing() {\n  return () => {};\n}\n\nexport function MenuContext({\n  items,\n  onSelect,\n  boundary = \"viewport\",\n  longPress = 520,\n  autoDemo = 0,\n  disabled = false,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  children,\n  onContextMenu,\n  onPointerDown,\n  onPointerMove,\n  onPointerUp,\n  onPointerCancel,\n  onPointerEnter,\n  onPointerLeave,\n  onKeyDown,\n  ...rest\n}: MenuContextProps) {\n  const list = items && items.length ? items : defaultItems;\n  const fixed = boundary === \"viewport\";\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const menuRef = React.useRef<HTMLDivElement>(null);\n  const subRef = React.useRef<HTMLDivElement>(null);\n  const nodes = React.useRef(new Map<string, HTMLElement>());\n  const rows = React.useRef(new Map<string, HTMLElement>());\n  const press = React.useRef<{ timer: number; x: number; y: number; id: number } | null>(null);\n  const suppress = React.useRef(false);\n  const [menu, setMenu] = React.useState<MenuState | null>(null);\n  const [focusId, setFocusId] = React.useState<string | null>(null);\n  const [subOpen, setSubOpen] = React.useState<string | null>(null);\n  const [hovering, setHovering] = React.useState(false);\n  const mounted = React.useSyncExternalStore(\n    subscribeNothing,\n    () => true,\n    () => false,\n  );\n\n  const realOpen = menu !== null && !menu.ghost;\n  const subItems = list.find((i) => i.id === subOpen)?.items ?? [];\n  const inSub = focusId !== null && subItems.some((i) => i.id === focusId);\n\n  const close = React.useCallback((refocus: boolean) => {\n    setMenu(null);\n    setFocusId(null);\n    setSubOpen(null);\n    if (refocus) rootRef.current?.focus({ preventScroll: true });\n  }, []);\n\n  const openAt = React.useCallback(\n    (clientX: number, clientY: number, keyboard: boolean) => {\n      const root = rootRef.current;\n      if (!root) return;\n      let x = clientX;\n      let y = clientY;\n      if (!fixed) {\n        const rect = root.getBoundingClientRect();\n        x = clientX - rect.left - root.clientLeft;\n        y = clientY - rect.top - root.clientTop;\n      }\n      const first = list.find((i) => !i.separator && !i.disabled);\n      setSubOpen(null);\n      setFocusId(keyboard && first ? first.id : null);\n      setMenu({ x, y, ghost: false, keyboard });\n    },\n    [fixed, list],\n  );\n\n  React.useLayoutEffect(() => {\n    const el = menuRef.current;\n    const root = rootRef.current;\n    if (!menu || !el || !root) return;\n    const w = el.offsetWidth;\n    const h = el.offsetHeight;\n    const bw = fixed ? window.innerWidth : root.clientWidth;\n    const bh = fixed ? window.innerHeight : root.clientHeight;\n    let left = menu.x;\n    let top = menu.y;\n    if (left + w > bw - PAD) left = menu.x - w;\n    if (top + h > bh - PAD) top = menu.y - h;\n    left = Math.max(PAD / 2, Math.min(left, bw - w - PAD / 2));\n    top = Math.max(PAD / 2, Math.min(top, bh - h - PAD / 2));\n    el.style.left = `${left.toFixed(1)}px`;\n    el.style.top = `${top.toFixed(1)}px`;\n    el.style.transformOrigin = `${(menu.x - left).toFixed(1)}px ${(menu.y - top).toFixed(1)}px`;\n    el.style.visibility = \"visible\";\n  }, [menu, fixed]);\n\n  React.useLayoutEffect(() => {\n    const sub = subRef.current;\n    const root = rootRef.current;\n    const row = subOpen ? rows.current.get(subOpen) : null;\n    if (!sub || !row || !root) return;\n    const rowRect = row.getBoundingClientRect();\n    const limit = fixed\n      ? { right: window.innerWidth, bottom: window.innerHeight }\n      : (() => {\n          const r = root.getBoundingClientRect();\n          return { right: r.right, bottom: r.bottom };\n        })();\n    const w = sub.offsetWidth;\n    const h = sub.offsetHeight;\n    const flip = rowRect.right + 2 + w > limit.right - PAD / 2;\n    sub.dataset.flip = flip ? \"true\" : \"false\";\n    const overflow = rowRect.top - 6 + h - (limit.bottom - PAD / 2);\n    sub.style.top = overflow > 0 ? `${(-6 - overflow).toFixed(1)}px` : \"\";\n  }, [subOpen, fixed, menu]);\n\n  React.useEffect(() => {\n    if (!menu || menu.ghost) return;\n    if (focusId) nodes.current.get(focusId)?.focus({ preventScroll: true });\n    else menuRef.current?.focus({ preventScroll: true });\n  }, [menu, focusId, subOpen]);\n\n  React.useEffect(() => {\n    if (!realOpen) return;\n    function away(e: PointerEvent) {\n      if (menuRef.current && !menuRef.current.contains(e.target as Node)) close(false);\n    }\n    function dismiss() {\n      close(false);\n    }\n    document.addEventListener(\"pointerdown\", away, true);\n    window.addEventListener(\"resize\", dismiss);\n    if (fixed) window.addEventListener(\"scroll\", dismiss, true);\n    return () => {\n      document.removeEventListener(\"pointerdown\", away, true);\n      window.removeEventListener(\"resize\", dismiss);\n      if (fixed) window.removeEventListener(\"scroll\", dismiss, true);\n    };\n  }, [realOpen, fixed, close]);\n\n  React.useEffect(() => {\n    if (!autoDemo || fixed || hovering || realOpen || disabled) return;\n    const ids: number[] = [];\n    function later(fn: () => void, ms: number) {\n      ids.push(window.setTimeout(fn, ms));\n    }\n    const plain = list.filter((i) => !i.separator && !i.disabled);\n    const direct = plain.filter((i) => !i.items).slice(0, 2);\n    const parent = plain.find((i) => i.items && i.items.length);\n    const steps: { focus: string; sub: string | null }[] = direct.map((i) => ({ focus: i.id, sub: null }));\n    if (parent && parent.items) {\n      steps.push({ focus: parent.id, sub: parent.id });\n      const kids = parent.items.filter((i) => !i.separator && !i.disabled).slice(0, 2);\n      kids.forEach((k) => steps.push({ focus: k.id, sub: parent.id }));\n    }\n    function cycle() {\n      const root = rootRef.current;\n      if (!root) return;\n      setSubOpen(null);\n      setFocusId(null);\n      setMenu({ x: 14, y: root.clientHeight * 0.16, ghost: true, keyboard: false });\n      steps.forEach((s, n) => {\n        later(() => {\n          setSubOpen(s.sub);\n          setFocusId(s.focus);\n        }, 900 + n * 850);\n      });\n      later(() => {\n        setMenu(null);\n        setFocusId(null);\n        setSubOpen(null);\n        later(cycle, autoDemo);\n      }, 900 + steps.length * 850 + 700);\n    }\n    later(cycle, 900);\n    return () => {\n      ids.forEach((t) => window.clearTimeout(t));\n      setMenu((m) => (m && m.ghost ? null : m));\n      setFocusId(null);\n      setSubOpen(null);\n    };\n  }, [autoDemo, fixed, hovering, realOpen, disabled, list]);\n\n  function select(item: ContextMenuItem) {\n    if (item.disabled || item.separator) return;\n    if (item.items && item.items.length) {\n      setSubOpen(item.id);\n      setFocusId(item.items.find((i) => !i.separator && !i.disabled)?.id ?? null);\n      return;\n    }\n    onSelect?.(item.id);\n    close(true);\n  }\n\n  function onMenuKey(e: React.KeyboardEvent<HTMLDivElement>) {\n    const current = inSub ? subItems : list;\n    const focusable = current.filter((i) => !i.separator && !i.disabled);\n    const at = focusable.findIndex((i) => i.id === focusId);\n    if (e.key === \"ArrowDown\" || e.key === \"ArrowUp\") {\n      e.preventDefault();\n      if (!focusable.length) return;\n      const step = e.key === \"ArrowDown\" ? 1 : -1;\n      const next = at === -1 ? (step === 1 ? 0 : focusable.length - 1) : (at + step + focusable.length) % focusable.length;\n      setFocusId(focusable[next].id);\n      if (!inSub) setSubOpen(null);\n    } else if (e.key === \"Home\" || e.key === \"End\") {\n      e.preventDefault();\n      if (!focusable.length) return;\n      setFocusId(focusable[e.key === \"Home\" ? 0 : focusable.length - 1].id);\n    } else if (e.key === \"ArrowRight\") {\n      const item = list.find((i) => i.id === focusId);\n      if (item && item.items && item.items.length) {\n        e.preventDefault();\n        select(item);\n      }\n    } else if (e.key === \"ArrowLeft\") {\n      if (inSub && subOpen) {\n        e.preventDefault();\n        setFocusId(subOpen);\n        setSubOpen(null);\n      }\n    } else if (e.key === \"Enter\" || e.key === \" \") {\n      e.preventDefault();\n      const item = current.find((i) => i.id === focusId);\n      if (item) select(item);\n    } else if (e.key === \"Escape\") {\n      e.preventDefault();\n      e.stopPropagation();\n      if (subOpen) {\n        setFocusId(subOpen);\n        setSubOpen(null);\n      } else close(true);\n    } else if (e.key === \"Tab\") {\n      e.preventDefault();\n      close(true);\n    }\n  }\n\n  function renderItems(group: ContextMenuItem[], level: number) {\n    return group.map((item) => {\n      if (item.separator) return <div key={item.id} className=\"hb-za5-sep\" role=\"separator\" />;\n      const hasSub = Boolean(item.items && item.items.length);\n      const active = focusId === item.id;\n      return (\n        <div\n          key={item.id}\n          className=\"hb-za5-row\"\n          ref={(el) => {\n            if (el) rows.current.set(item.id, el);\n            else rows.current.delete(item.id);\n          }}\n        >\n          <div\n            ref={(el) => {\n              if (el) nodes.current.set(item.id, el);\n              else nodes.current.delete(item.id);\n            }}\n            role=\"menuitem\"\n            tabIndex={active ? 0 : -1}\n            className=\"hb-za5-item\"\n            data-active={active}\n            data-danger={item.danger ? \"true\" : undefined}\n            aria-disabled={item.disabled || undefined}\n            aria-haspopup={hasSub ? \"menu\" : undefined}\n            aria-expanded={hasSub ? subOpen === item.id : undefined}\n            onPointerEnter={() => {\n              if (item.disabled || menu?.ghost) return;\n              setFocusId(item.id);\n              if (level === 0) setSubOpen(hasSub ? item.id : null);\n            }}\n            onClick={() => select(item)}\n          >\n            <Icon icon={item.icon} />\n            <span className=\"hb-za5-label\">{item.label}</span>\n            {hasSub ? (\n              <svg className=\"hb-za5-chev\" viewBox=\"0 0 12 12\" aria-hidden=\"true\">\n                <path d=\"m4.5 2.5 3.5 3.5-3.5 3.5\" />\n              </svg>\n            ) : item.shortcut ? (\n              <span className=\"hb-za5-key\">{item.shortcut}</span>\n            ) : null}\n          </div>\n          {hasSub && subOpen === item.id ? (\n            <div ref={subRef} className=\"hb-za5-sub\" role=\"menu\" aria-label={item.label}>\n              {renderItems(item.items ?? [], 1)}\n            </div>\n          ) : null}\n        </div>\n      );\n    });\n  }\n\n  function cancelPress() {\n    const p = press.current;\n    if (p) window.clearTimeout(p.timer);\n    press.current = null;\n  }\n\n  const vars = { \"--hb-za5-c\": accent, ...style } as React.CSSProperties;\n\n  const panel = menu ? (\n    <div\n      ref={menuRef}\n      className=\"hb-za5-menu\"\n      role=\"menu\"\n      tabIndex={-1}\n      aria-orientation=\"vertical\"\n      aria-hidden={menu.ghost || undefined}\n      data-fixed={fixed}\n      data-ghost={menu.ghost}\n      style={{ left: menu.x, top: menu.y, \"--hb-za5-c\": accent } as React.CSSProperties}\n      onKeyDown={onMenuKey}\n      onContextMenu={(e) => e.preventDefault()}\n    >\n      {renderItems(list, 0)}\n    </div>\n  ) : null;\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-za5 ${className}`}\n      style={vars}\n      tabIndex={disabled ? undefined : 0}\n      aria-haspopup=\"menu\"\n      onContextMenu={(e) => {\n        onContextMenu?.(e);\n        if (e.defaultPrevented || disabled) return;\n        if (suppress.current || (e.target as HTMLElement).closest(\".hb-za5-menu\")) {\n          e.preventDefault();\n          suppress.current = false;\n          return;\n        }\n        e.preventDefault();\n        openAt(e.clientX, e.clientY, false);\n      }}\n      onPointerDown={(e) => {\n        onPointerDown?.(e);\n        if (disabled || e.pointerType === \"mouse\" || longPress <= 0) return;\n        if ((e.target as HTMLElement).closest(\".hb-za5-menu\")) return;\n        cancelPress();\n        const x = e.clientX;\n        const y = e.clientY;\n        const timer = window.setTimeout(() => {\n          press.current = null;\n          suppress.current = true;\n          openAt(x, y, false);\n        }, longPress);\n        press.current = { timer, x, y, id: e.pointerId };\n      }}\n      onPointerMove={(e) => {\n        onPointerMove?.(e);\n        const p = press.current;\n        if (p && p.id === e.pointerId && Math.hypot(e.clientX - p.x, e.clientY - p.y) > 8) cancelPress();\n      }}\n      onPointerUp={(e) => {\n        onPointerUp?.(e);\n        cancelPress();\n      }}\n      onPointerCancel={(e) => {\n        onPointerCancel?.(e);\n        cancelPress();\n      }}\n      onPointerEnter={(e) => {\n        onPointerEnter?.(e);\n        setHovering(true);\n      }}\n      onPointerLeave={(e) => {\n        onPointerLeave?.(e);\n        setHovering(false);\n      }}\n      onKeyDown={(e) => {\n        onKeyDown?.(e);\n        if (disabled || e.defaultPrevented) return;\n        if (e.key === \"ContextMenu\" || (e.key === \"F10\" && e.shiftKey)) {\n          e.preventDefault();\n          const rect = (e.target as HTMLElement).getBoundingClientRect();\n          openAt(rect.left + 20, rect.top + 20, true);\n        }\n      }}\n      {...rest}\n    >\n      <style href=\"hb-menu-context\" precedence=\"default\">{css}</style>\n      {children ?? (\n        <div className=\"hb-za5-area\">\n          <span>\n            <b>Right-click here</b>\n            or press and hold on touch\n          </span>\n        </div>\n      )}\n      {panel ? (fixed ? (mounted ? createPortal(panel, document.body) : null) : panel) : null}\n    </div>\n  );\n}\n"
    }
  ]
}