{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "radial-menu",
  "type": "registry:ui",
  "title": "Radial Menu",
  "description": "A menu that opens in a ring around its trigger, each item arriving on its own spring.",
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "files": [
    {
      "path": "components/prequelui/moments/shared.tsx",
      "target": "components/prequelui/moments/shared.tsx",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport { useEffect, useState } from \"react\";\nimport type { Transition } from \"motion/react\";\nimport { useHydratedReducedMotion } from \"@/lib/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nexport { cn, useHydratedReducedMotion };\n\nexport type MomentProps = {\n  className?: string;\n  preview?: boolean;\n};\n\nexport const springFast: Transition = { type: \"spring\", stiffness: 620, damping: 32 };\nexport const springSoft: Transition = { type: \"spring\", stiffness: 260, damping: 22 };\nexport const springBounce: Transition = { type: \"spring\", stiffness: 380, damping: 18 };\nexport const springHeavy: Transition = { type: \"spring\", stiffness: 200, damping: 26 };\nexport const springSnap: Transition = { type: \"spring\", stiffness: 700, damping: 38 };\n\nexport const tweenFast: Transition = { duration: 0.18, ease: [0.23, 1, 0.32, 1] };\nexport const tweenSoft: Transition = { duration: 0.32, ease: [0.23, 1, 0.32, 1] };\n\nexport const surface =\n  \"relative flex h-[150px] w-[230px] max-w-full select-none items-center justify-center text-foreground\";\n\nexport function usePreviewPulse(\n  preview: boolean | undefined,\n  duration = 900,\n  gap = 2500,\n) {\n  const [on, setOn] = useState(false);\n  const reduce = useHydratedReducedMotion();\n\n  useEffect(() => {\n    if (!preview || reduce) {\n      setOn(false);\n      return;\n    }\n    let close = 0;\n    let next = 0;\n    const run = () => {\n      setOn(true);\n      close = window.setTimeout(() => setOn(false), duration);\n      next = window.setTimeout(run, gap);\n    };\n    run();\n    return () => {\n      window.clearTimeout(close);\n      window.clearTimeout(next);\n    };\n  }, [preview, reduce, duration, gap]);\n\n  return on && !reduce;\n}\n\nexport function usePreviewStep(\n  preview: boolean | undefined,\n  steps: number,\n  interval = 1500,\n) {\n  const [step, setStep] = useState(0);\n  const reduce = useHydratedReducedMotion();\n\n  useEffect(() => {\n    if (!preview || reduce) return;\n    setStep(1);\n    const id = window.setInterval(\n      () => setStep((current) => (current + 1) % steps),\n      interval,\n    );\n    return () => window.clearInterval(id);\n  }, [preview, reduce, steps, interval]);\n\n  return reduce ? 0 : step;\n}\n\nexport function usePreviewPointer(\n  preview: boolean | undefined,\n  width = 220,\n  height = 120,\n) {\n  const [point, setPoint] = useState({ x: width / 2, y: height / 2 });\n  const reduce = useHydratedReducedMotion();\n\n  useEffect(() => {\n    if (!preview || reduce) return;\n    let frame = 0;\n    let start = 0;\n    const loop = (time: number) => {\n      if (!start) start = time;\n      const t = (time - start) / 1000;\n      const x = width / 2 + Math.cos(t * 1.4) * (width * 0.36);\n      const y = height / 2 + Math.sin(t * 2.1) * (height * 0.28);\n      setPoint({ x, y });\n      frame = requestAnimationFrame(loop);\n    };\n    frame = requestAnimationFrame(loop);\n    return () => cancelAnimationFrame(frame);\n  }, [preview, reduce, width, height]);\n\n  return [point, setPoint] as const;\n}\n\nexport function clamp(value: number, min: number, max: number) {\n  return Math.min(max, Math.max(min, value));\n}\n\n/**\n * The docs stage zooms its children (CSS `zoom`), so a pointer event reports\n * positions in zoomed pixels while the component lays itself out unscaled.\n * Normalise the event back into the component's own coordinate space.\n */\nexport function localPoint(\n  event: { clientX: number; clientY: number },\n  node: HTMLElement,\n) {\n  const rect = node.getBoundingClientRect();\n  const scaleX = node.offsetWidth ? rect.width / node.offsetWidth : 1;\n  const scaleY = node.offsetHeight ? rect.height / node.offsetHeight : 1;\n  return {\n    x: (event.clientX - rect.left) / (scaleX || 1),\n    y: (event.clientY - rect.top) / (scaleY || 1),\n  };\n}\n\nexport function naturalWidth(node: HTMLElement) {\n  return node.offsetWidth || node.getBoundingClientRect().width;\n}\n\nexport function pointerScaleX(node: HTMLElement) {\n  const rect = node.getBoundingClientRect();\n  return node.offsetWidth ? rect.width / node.offsetWidth : 1;\n}\n"
    },
    {
      "path": "components/prequelui/moments/radial-menu.tsx",
      "target": "components/prequelui/moments/radial-menu.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport { motion } from \"motion/react\";\nimport { Copy, EyeOff, Move, Pencil, Share2, Tag } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  cn,\n  springBounce,\n  surface,\n  useHydratedReducedMotion,\n  usePreviewPulse,\n  type MomentProps,\n} from \"./shared\";\n\nconst ITEMS = [\n  { label: \"Edit\", angle: -90, Icon: Pencil },\n  { label: \"Copy\", angle: -30, Icon: Copy },\n  { label: \"Share\", angle: 30, Icon: Share2 },\n  { label: \"Tag\", angle: 90, Icon: Tag },\n  { label: \"Move\", angle: 150, Icon: Move },\n  { label: \"Hide\", angle: 210, Icon: EyeOff },\n];\nconst RADIUS = 48;\n\nexport function RadialMenu({ className, preview }: MomentProps) {\n  const [open, setOpen] = useState(false);\n  const [chosen, setChosen] = useState<string | null>(null);\n  const reduce = useHydratedReducedMotion();\n  const pulse = usePreviewPulse(preview, 1400, 3000);\n  const shown = preview ? pulse : open;\n  const trigger = useRef<HTMLButtonElement | null>(null);\n  const items = useRef<(HTMLButtonElement | null)[]>([]);\n\n  useEffect(() => {\n    if (open) items.current[0]?.focus();\n  }, [open]);\n\n  const close = (returnFocus: boolean) => {\n    setOpen(false);\n    if (returnFocus) trigger.current?.focus();\n  };\n\n  const onKeyDown = (event: React.KeyboardEvent) => {\n    if (!open) return;\n    if (event.key === \"Escape\") {\n      event.preventDefault();\n      close(true);\n      return;\n    }\n    const forward = event.key === \"ArrowRight\" || event.key === \"ArrowDown\";\n    const backward = event.key === \"ArrowLeft\" || event.key === \"ArrowUp\";\n    if (!forward && !backward) return;\n    event.preventDefault();\n    const current = items.current.findIndex((node) => node === document.activeElement);\n    const next =\n      (current + (forward ? 1 : -1) + ITEMS.length) % ITEMS.length;\n    items.current[next]?.focus();\n  };\n\n  return (\n    <div className={cn(surface, \"flex-col gap-2\", className)}>\n      <div\n        className=\"relative flex size-[148px] items-center justify-center\"\n        onKeyDown={onKeyDown}\n      >\n        <div role=\"menu\" aria-label=\"Moment actions\" className=\"absolute inset-0\">\n          {ITEMS.map((item, index) => {\n            const radians = (item.angle * Math.PI) / 180;\n            const x = Math.cos(radians) * RADIUS;\n            const y = Math.sin(radians) * RADIUS;\n            return (\n              <motion.button\n                key={item.label}\n                ref={(node) => {\n                  items.current[index] = node;\n                }}\n                type=\"button\"\n                role=\"menuitem\"\n                tabIndex={shown ? 0 : -1}\n                aria-hidden={!shown}\n                aria-label={item.label}\n                onClick={() => {\n                  setChosen(item.label);\n                  close(true);\n                }}\n                animate={\n                  reduce\n                    ? {\n                        x: shown ? x : 0,\n                        y: shown ? y : 0,\n                        scale: shown ? 1 : 0.4,\n                        opacity: shown ? 1 : 0,\n                      }\n                    : {\n                        x: shown ? x : 0,\n                        y: shown ? y : 0,\n                        scale: shown ? 1 : 0,\n                        opacity: shown ? 1 : 0,\n                      }\n                }\n                transition={\n                  reduce\n                    ? { duration: 0 }\n                    : { ...springBounce, delay: shown ? index * 0.025 : 0 }\n                }\n                style={{ pointerEvents: shown ? \"auto\" : \"none\" }}\n                className=\"absolute left-1/2 top-1/2 -ml-[17px] -mt-[17px] flex size-[34px] items-center justify-center rounded-full border border-white/12 bg-[#1c1c21] text-white/70 outline-none hover:bg-white hover:text-black focus-visible:ring-2 focus-visible:ring-white/60\"\n              >\n                <item.Icon className=\"size-3.5\" aria-hidden=\"true\" />\n              </motion.button>\n            );\n          })}\n        </div>\n\n        <button\n          ref={trigger}\n          type=\"button\"\n          aria-haspopup=\"menu\"\n          aria-expanded={shown}\n          aria-label={shown ? \"Close the radial menu\" : \"Open the radial menu\"}\n          onClick={() => setOpen((value) => !value)}\n          className=\"relative z-10 flex size-[46px] items-center justify-center rounded-full bg-white text-black outline-none focus-visible:ring-2 focus-visible:ring-black/40\"\n        >\n          <motion.span\n            className=\"block h-[2px] w-4 rounded-full bg-black\"\n            animate={{ rotate: shown ? 45 : 0, y: shown ? 0 : -3 }}\n            transition={reduce ? { duration: 0 } : springBounce}\n          />\n          <motion.span\n            className=\"absolute block h-[2px] w-4 rounded-full bg-black\"\n            animate={{ rotate: shown ? -45 : 0, y: shown ? 0 : 3 }}\n            transition={reduce ? { duration: 0 } : springBounce}\n          />\n        </button>\n      </div>\n      <span\n        aria-live=\"polite\"\n        className=\"text-[13px] uppercase tracking-[0.18em] text-white/45\"\n      >\n        {chosen ?? (shown ? \"Choose\" : \"Actions\")}\n      </span>\n    </div>\n  );\n}\n"
    },
    {
      "path": "lib/use-reduced-motion.ts",
      "target": "lib/use-reduced-motion.ts",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport { useReducedMotion } from \"motion/react\";\nimport { useSyncExternalStore } from \"react\";\n\nconst subscribe = () => () => {};\n\nexport function useHydratedReducedMotion() {\n  const reduce = useReducedMotion() ?? false;\n  const mounted = useSyncExternalStore(\n    subscribe,\n    () => true,\n    () => false,\n  );\n  return mounted ? reduce : false;\n}\n"
    }
  ]
}
