{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "leaf-tabs",
  "type": "registry:ui",
  "title": "Leaf Tabs",
  "description": "Tabs shaped like leaves: the active one lifts from its stem and the panel changes underneath.",
  "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/leaf-tabs.tsx",
      "target": "components/prequelui/moments/leaf-tabs.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport { Flower2, Leaf, Snowflake, Sun } from \"lucide-react\";\nimport { motion } from \"motion/react\";\nimport { useId, useRef, useState } from \"react\";\nimport {\n  cn,\n  springSoft,\n  surface,\n  useHydratedReducedMotion,\n  usePreviewStep,\n  type MomentProps,\n} from \"./shared\";\n\nconst TABS = [\n  { label: \"Spring\", copy: \"A soft curve that settles.\", Icon: Flower2 },\n  { label: \"Summer\", copy: \"Short, warm and direct.\", Icon: Sun },\n  { label: \"Autumn\", copy: \"A slower, falling rhythm.\", Icon: Leaf },\n  { label: \"Winter\", copy: \"Still, quiet and exact.\", Icon: Snowflake },\n];\n\nconst SLOT = 44;\n\nexport function LeafTabs({ className, preview }: MomentProps) {\n  const [active, setActive] = useState(0);\n  const baseId = useId();\n  const tabRefs = useRef<Array<HTMLButtonElement | null>>([]);\n  const reduce = useHydratedReducedMotion();\n  const step = usePreviewStep(preview, TABS.length, 1500);\n  const index = preview ? step : active;\n\n  const select = (next: number) => {\n    setActive(next);\n    tabRefs.current[next]?.focus();\n  };\n\n  const key = (event: React.KeyboardEvent) => {\n    if (event.key === \"ArrowRight\") {\n      event.preventDefault();\n      select((active + 1) % TABS.length);\n    }\n    if (event.key === \"ArrowLeft\") {\n      event.preventDefault();\n      select((active - 1 + TABS.length) % TABS.length);\n    }\n    if (event.key === \"Home\") {\n      event.preventDefault();\n      select(0);\n    }\n    if (event.key === \"End\") {\n      event.preventDefault();\n      select(TABS.length - 1);\n    }\n  };\n\n  return (\n    <div className={cn(surface, \"flex-col gap-0\", className)}>\n      <div\n        role=\"tablist\"\n        aria-label=\"Leaf tabs\"\n        onKeyDown={key}\n        className=\"flex items-end gap-1\"\n      >\n        {TABS.map((tab, tabIndex) => {\n          const selected = index === tabIndex;\n          return (\n            <motion.button\n              key={tab.label}\n              ref={(node) => {\n                tabRefs.current[tabIndex] = node;\n              }}\n              type=\"button\"\n              role=\"tab\"\n              id={`${baseId}-tab-${tabIndex}`}\n              aria-label={tab.label}\n              aria-selected={selected}\n              aria-controls={`${baseId}-panel`}\n              tabIndex={selected ? 0 : -1}\n              onClick={() => setActive(tabIndex)}\n              animate={\n                reduce\n                  ? { y: selected ? -4 : 0, rotate: 0, scale: 1 }\n                  : { y: selected ? -9 : 0, rotate: selected ? -5 : 0, scale: selected ? 1.03 : 1 }\n              }\n              transition={reduce ? { duration: 0 } : springSoft}\n              style={{ transformOrigin: \"bottom left\", width: SLOT }}\n              className={cn(\n                \"flex h-8 items-center justify-center rounded-tl-[18px] rounded-tr-[18px] rounded-b-[7px] border border-b-0 outline-none transition-colors focus-visible:ring-2 focus-visible:ring-white/60\",\n                selected\n                  ? \"border-white/20 bg-white text-black shadow-[0_-6px_16px_rgba(0,0,0,.25)]\"\n                  : \"border-white/10 bg-white/8 text-white/45 hover:bg-white/12\",\n              )}\n            >\n              <tab.Icon className=\"size-3.5\" strokeWidth={1.8} aria-hidden=\"true\" />\n            </motion.button>\n          );\n        })}\n      </div>\n      <div\n        id={`${baseId}-panel`}\n        role=\"tabpanel\"\n        aria-labelledby={`${baseId}-tab-${index}`}\n        className=\"flex h-[58px] w-[188px] flex-col justify-center rounded-xl rounded-tl-none border border-white/10 bg-white/8 px-3\"\n      >\n        <motion.span\n          key={TABS[index].label}\n          initial={reduce ? false : { opacity: 0, x: 4 }}\n          animate={{ opacity: 1, x: 0 }}\n          transition={{ duration: reduce ? 0 : 0.18 }}\n          className=\"text-[13px] font-medium\"\n        >\n          {TABS[index].label}\n        </motion.span>\n        <motion.span\n          key={`${TABS[index].label}-copy`}\n          initial={reduce ? false : { opacity: 0, x: 4 }}\n          animate={{ opacity: 1, x: 0 }}\n          transition={{ duration: reduce ? 0 : 0.22, delay: reduce ? 0 : 0.03 }}\n          className=\"mt-0.5 text-[13px] text-white/45\"\n        >\n          {TABS[index].copy}\n        </motion.span>\n      </div>\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"
    }
  ]
}
