{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bell-toggle",
  "type": "registry:ui",
  "title": "Bell Toggle",
  "description": "A bell that rocks on its crown when toggled, with one short ring and a quiet mute badge.",
  "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/bell-toggle.tsx",
      "target": "components/prequelui/moments/bell-toggle.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport { AnimatePresence, motion } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  cn,\n  surface,\n  useHydratedReducedMotion,\n  usePreviewPulse,\n  type MomentProps,\n} from \"./shared\";\n\nexport function BellToggle({ className, preview }: MomentProps) {\n  const [muted, setMuted] = useState(false);\n  const [swing, setSwing] = useState(0);\n  const first = useRef(true);\n  const reduce = useHydratedReducedMotion();\n  const pulse = usePreviewPulse(preview, 1000, 2600);\n  const shown = preview ? pulse : muted;\n\n  useEffect(() => {\n    if (first.current) {\n      first.current = false;\n      return;\n    }\n    if (!reduce) setSwing((value) => value + 1);\n  }, [shown, reduce]);\n\n  return (\n    <div className={cn(surface, \"flex-col gap-3\", className)}>\n      <button\n        type=\"button\"\n        role=\"switch\"\n        aria-checked={shown}\n        aria-label=\"Mute the bell\"\n        onClick={() => setMuted((value) => !value)}\n        className=\"relative flex h-[86px] w-[98px] items-center justify-center rounded-2xl outline-none focus-visible:ring-2 focus-visible:ring-white/50\"\n      >\n        <AnimatePresence>\n          {!shown ? (\n            <motion.span\n              key={`wave-${swing}`}\n              aria-hidden=\"true\"\n              className=\"absolute left-1/2 top-1/2 size-14 -translate-x-1/2 -translate-y-1/2 rounded-full border border-white/40\"\n              initial={{ scale: 0.7, opacity: 0.5 }}\n              animate={reduce || swing === 0 ? { scale: 1, opacity: 0 } : { scale: 1.7, opacity: 0 }}\n              exit={{ opacity: 0 }}\n              transition={{ duration: reduce ? 0 : 0.8, ease: \"easeOut\" }}\n            />\n          ) : null}\n        </AnimatePresence>\n        <motion.span\n          key={`bell-${swing}`}\n          className=\"relative z-10\"\n          style={{ transformOrigin: \"50% 12%\" }}\n          animate={\n            reduce || swing === 0\n              ? { rotate: 0 }\n              : { rotate: [0, 18, -15, 9, -5, 0] }\n          }\n          transition={{ duration: reduce ? 0 : 0.75, ease: [0.22, 1, 0.36, 1] }}\n        >\n          <svg width=\"38\" height=\"42\" viewBox=\"0 0 38 42\" aria-hidden=\"true\">\n            <path\n              d=\"M19 3c-7 0-11 5-11 12v7l-4 6h30l-4-6v-7c0-7-4-12-11-12Z\"\n              fill={shown ? \"rgba(255,255,255,.22)\" : \"white\"}\n              stroke=\"white\"\n              strokeWidth=\"1.5\"\n              strokeLinejoin=\"round\"\n            />\n            <circle cx=\"19\" cy=\"34\" r=\"3\" fill={shown ? \"rgba(255,255,255,.4)\" : \"white\"} />\n            {shown ? (\n              <path\n                d=\"M10 8 L28 30\"\n                stroke=\"rgba(255,255,255,.75)\"\n                strokeWidth=\"2\"\n                strokeLinecap=\"round\"\n              />\n            ) : null}\n          </svg>\n        </motion.span>\n        <AnimatePresence>\n          {shown ? (\n            <motion.span\n              aria-hidden=\"true\"\n              initial={reduce ? { opacity: 0 } : { scale: 0.4, opacity: 0 }}\n              animate={{ scale: 1, opacity: 1 }}\n              exit={reduce ? { opacity: 0 } : { scale: 0.4, opacity: 0 }}\n              transition={reduce ? { duration: 0 } : { type: \"spring\", stiffness: 520, damping: 24 }}\n              className=\"absolute right-0 top-0 flex size-4 items-center justify-center rounded-full bg-white text-[13px] font-bold leading-none text-black\"\n            >\n              ×\n            </motion.span>\n          ) : null}\n        </AnimatePresence>\n      </button>\n      <span className=\"text-[13px] uppercase tracking-[0.18em] text-white/45\">\n        {shown ? \"Muted\" : \"Ringing\"}\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"
    }
  ]
}
