{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "click",
  "type": "registry:ui",
  "title": "Click",
  "description": "A ring, ripple, crosshair or burst played at the click point.",
  "dependencies": [
    "motion"
  ],
  "files": [
    {
      "path": "components/prequelui/motion.tsx",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport {\n  MotionConfig,\n  useInView as useMotionInView,\n  type Transition,\n} from \"motion/react\";\nimport { useHydratedReducedMotion } from \"@/lib/use-reduced-motion\";\nimport { cn } from \"@/lib/utils\";\n\nconst TempoContext = React.createContext(1);\n\nexport function PrequelMotionProvider({\n  tempo = 1,\n  children,\n}: {\n  tempo?: number;\n  children: React.ReactNode;\n}) {\n  const value = React.useMemo(() => Math.max(0.4, tempo), [tempo]);\n  return (\n    <TempoContext.Provider value={value}>\n      <MotionConfig reducedMotion=\"user\">{children}</MotionConfig>\n    </TempoContext.Provider>\n  );\n}\n\nexport function useTempo() {\n  return React.useContext(TempoContext);\n}\n\nconst TIME_KEYS = [\n  \"duration\",\n  \"visualDuration\",\n  \"delay\",\n  \"repeatDelay\",\n  \"delayChildren\",\n] as const;\n\nfunction scaleValue(transition: Transition, tempo: number): Transition {\n  if (tempo === 1 || !transition || typeof transition !== \"object\") {\n    return transition;\n  }\n  const next: Record<string, unknown> = {};\n  for (const [key, value] of Object.entries(transition)) {\n    if (typeof value === \"number\" && (TIME_KEYS as readonly string[]).includes(key)) {\n      next[key] = value * tempo;\n    } else if (typeof value === \"number\" && key === \"stiffness\") {\n      next[key] = value / (tempo * tempo);\n    } else if (typeof value === \"number\" && key === \"damping\") {\n      next[key] = value / tempo;\n    } else if (value && typeof value === \"object\" && !Array.isArray(value)) {\n      next[key] = scaleValue(value as Transition, tempo);\n    } else {\n      next[key] = value;\n    }\n  }\n  return next as Transition;\n}\n\nexport function useTempoTransition(transition: Transition) {\n  const tempo = useTempo();\n  return React.useMemo(\n    () => scaleValue(transition, tempo),\n    [tempo, JSON.stringify(transition)],\n  );\n}\n\nexport function useReduceMotion() {\n  return useHydratedReducedMotion();\n}\n\nexport function usePageVisible() {\n  const [visible, setVisible] = React.useState(true);\n  React.useEffect(() => {\n    const update = () => setVisible(!document.hidden);\n    update();\n    document.addEventListener(\"visibilitychange\", update);\n    return () => document.removeEventListener(\"visibilitychange\", update);\n  }, []);\n  return visible;\n}\n\nexport function useMounted() {\n  return React.useSyncExternalStore(\n    () => () => {},\n    () => true,\n    () => false,\n  );\n}\n\nexport function useSeen(\n  ref: React.RefObject<Element | null>,\n  enabled = true,\n  once = true,\n) {\n  const inView = useMotionInView(ref, { once, amount: 0.35 });\n  return enabled ? inView : true;\n}\n\ntype SlotProps = React.HTMLAttributes<HTMLElement> & {\n  children?: React.ReactNode;\n  ref?: React.Ref<HTMLElement>;\n};\n\nexport function Slot({ children, ...props }: SlotProps) {\n  if (!React.isValidElement<Record<string, unknown>>(children)) {\n    return null;\n  }\n  const child = children as React.ReactElement<Record<string, unknown>>;\n  const childProps = child.props;\n  return React.cloneElement(child, {\n    ...props,\n    ...childProps,\n    className: cn(\n      String(props.className ?? \"\"),\n      String(childProps.className ?? \"\"),\n    ),\n    style: {\n      ...((props.style as React.CSSProperties) ?? {}),\n      ...((childProps.style as React.CSSProperties) ?? {}),\n    },\n  } as Record<string, unknown>);\n}\n\nexport function srOnlyStyle(): React.CSSProperties {\n  return {\n    position: \"absolute\",\n    width: 1,\n    height: 1,\n    padding: 0,\n    margin: -1,\n    overflow: \"hidden\",\n    clip: \"rect(0, 0, 0, 0)\",\n    whiteSpace: \"nowrap\",\n    borderWidth: 0,\n  };\n}\n\nlet segmenter: Intl.Segmenter | null | undefined;\n\nexport function splitGraphemes(text: string): string[] {\n  if (segmenter === undefined) {\n    segmenter =\n      typeof Intl !== \"undefined\" && typeof Intl.Segmenter === \"function\"\n        ? new Intl.Segmenter(undefined, { granularity: \"grapheme\" })\n        : null;\n  }\n  if (!segmenter) return Array.from(text);\n  return Array.from(segmenter.segment(text), (entry) => entry.segment);\n}\n\nexport const easeOut = [0.23, 1, 0.32, 1] as const;\nexport const easeSoft = [0.215, 0.61, 0.355, 1] as const;\nexport const easeInOut = [0.77, 0, 0.175, 1] as const;\nexport const easeEnter = [0.25, 0.1, 0.35, 1] as const;\nexport const easeLeave = [0, 0, 0.58, 1] as const;\nexport const easeResize = [0.4, 0, 0.1, 1] as const;\nexport const easeAway = [0.33, 0.17, 0.67, 0.5] as const;\n\nexport const pressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const selectionSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n};\n\nexport const highlightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 40,\n};\n\nexport const popSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 29,\n};\n\nexport const tooltipSpring: Transition = {\n  type: \"spring\",\n  stiffness: 400,\n  damping: 31,\n};\n\nexport const dialogSpring: Transition = {\n  type: \"spring\",\n  stiffness: 150,\n  damping: 25,\n};\n\nexport const toastSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 24,\n};\n\nexport const heightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n  bounce: 0,\n  restDelta: 0.01,\n};\n\nexport const progressSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 35,\n  restDelta: 0.01,\n  restSpeed: 0.1,\n};\n\nexport const scrollSpring: Transition = {\n  type: \"spring\",\n  stiffness: 250,\n  damping: 40,\n  bounce: 0,\n};\n\nexport const avatarSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 17,\n};\n\nexport const pinnedSpring: Transition = {\n  type: \"spring\",\n  stiffness: 320,\n  damping: 25,\n  mass: 0.8,\n};\n\nexport const thumbSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 25,\n};\n\nexport const checkSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 24,\n};\n\nexport const cursorEntry: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 30,\n  restSpeed: 10,\n};\n\nexport const cursorExit: Transition = {\n  type: \"spring\",\n  stiffness: 550,\n  damping: 46.9,\n  restSpeed: 10,\n};\n\nexport const cursorLabel: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 50,\n  bounce: 0,\n};\n\nexport const swapTween: Transition = {\n  duration: 0.15,\n  ease: easeOut,\n};\n\nexport const overlayTween: Transition = {\n  duration: 0.4,\n  ease: easeSoft,\n};\n\nexport const disclosureTween: Transition = {\n  duration: 0.35,\n  ease: easeSoft,\n};\n\nexport const menuTween: Transition = {\n  duration: 0.22,\n  ease: easeSoft,\n};\n\nexport const panelOutTween: Transition = {\n  duration: 0.15,\n  ease: easeLeave,\n};\n\nexport const panelInTween: Transition = {\n  duration: 0.3,\n  ease: easeEnter,\n};\n\nexport const panelHeightTween: Transition = {\n  duration: 0.45,\n  ease: easeResize,\n};\n\nexport const exitTween: Transition = {\n  duration: 0.2,\n  ease: easeAway,\n};\n\nexport const faceSpring: Transition = {\n  type: \"spring\",\n  stiffness: 280,\n  damping: 20,\n};\n\nexport const blurIcon = \"blur(2px)\";\n\nexport function flipTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate =\n    side === \"top\"\n      ? \"rotateX(-20deg)\"\n      : side === \"bottom\"\n        ? \"rotateX(20deg)\"\n        : side === \"left\"\n          ? \"rotateY(20deg)\"\n          : \"rotateY(-20deg)\";\n  return `perspective(500px) ${rotate} scale(0.8)`;\n}\n\nexport function uprightTransform(side: \"top\" | \"bottom\" | \"left\" | \"right\") {\n  const rotate = side === \"left\" || side === \"right\" ? \"rotateY(0deg)\" : \"rotateX(0deg)\";\n  return `perspective(500px) ${rotate} scale(1)`;\n}\n",
      "target": "components/prequelui/motion.tsx"
    },
    {
      "path": "components/prequelui/effects/shared.ts",
      "type": "registry:lib",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { useInView, type Transition } from \"motion/react\";\n\nexport const entranceSpring: Transition = {\n  type: \"spring\",\n  stiffness: 200,\n  damping: 20,\n};\n\nexport const heightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 300,\n  damping: 30,\n  bounce: 0,\n  restDelta: 0.01,\n};\n\nexport const highlightSpring: Transition = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 40,\n};\n\nexport const fadeTween: Transition = {\n  duration: 0.2,\n  ease: [0.23, 1, 0.32, 1],\n};\n\nexport const softEase = [0.23, 1, 0.32, 1] as const;\n\nexport type SlideDirection = \"up\" | \"down\" | \"left\" | \"right\";\n\nconst HOVER_QUERY = \"(hover: hover) and (pointer: fine)\";\nconst COARSE_QUERY = \"(pointer: coarse)\";\n\nfunction useMediaQuery(query: string) {\n  const [matches, setMatches] = React.useState(false);\n\n  React.useEffect(() => {\n    const mql = window.matchMedia(query);\n    const update = () => setMatches(mql.matches);\n    update();\n    mql.addEventListener(\"change\", update);\n    return () => mql.removeEventListener(\"change\", update);\n  }, [query]);\n\n  return matches;\n}\n\nexport function useCanHover() {\n  return useMediaQuery(HOVER_QUERY);\n}\n\nexport function useCoarsePointer() {\n  return useMediaQuery(COARSE_QUERY);\n}\n\nexport function useMounted() {\n  const [mounted, setMounted] = React.useState(false);\n  React.useEffect(() => setMounted(true), []);\n  return mounted;\n}\n\nexport function useInViewEffect(\n  ref: React.RefObject<Element | null>,\n  enabled: boolean,\n  once: boolean,\n  margin: string,\n) {\n  const inView = useInView(ref, {\n    once,\n    amount: 0.35,\n    margin: margin as `${number}px`,\n  });\n  return enabled ? inView : true;\n}\n\nexport function clamp(value: number, min: number, max: number) {\n  return Math.min(max, Math.max(min, value));\n}\n\nexport function mergeRefs<T>(\n  ...refs: Array<React.Ref<T> | undefined>\n): React.RefCallback<T> {\n  return (node) => {\n    for (const ref of refs) {\n      if (!ref) continue;\n      if (typeof ref === \"function\") ref(node);\n      else (ref as React.MutableRefObject<T | null>).current = node;\n    }\n  };\n}\n",
      "target": "components/prequelui/effects/shared.ts"
    },
    {
      "path": "components/prequelui/effects/click.tsx",
      "type": "registry:ui",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { AnimatePresence, motion, type Transition } from \"motion/react\";\nimport { useReduceMotion } from \"../motion\";\nimport { useMounted } from \"./shared\";\n\nexport type ClickVariant = \"ripple\" | \"ring\" | \"crosshair\" | \"burst\" | \"particles\";\n\ntype ClickItem = {\n  id: number;\n  x: number;\n  y: number;\n  variant: ClickVariant;\n  color: string;\n  size: number;\n  duration: number;\n};\n\nexport type ClickProps = {\n  children?: React.ReactNode;\n  variant?: ClickVariant;\n  color?: string;\n  size?: number;\n  duration?: number;\n  disabled?: boolean;\n  scope?: React.RefObject<HTMLElement | null>;\n};\n\nexport function Click({\n  children,\n  variant = \"ring\",\n  color = \"currentColor\",\n  size = 100,\n  duration = 400,\n  disabled = false,\n  scope,\n}: ClickProps) {\n  const [items, setItems] = React.useState<ClickItem[]>([]);\n  const nextId = React.useRef(0);\n  const timers = React.useRef(new Set<number>());\n  const mounted = useMounted();\n  const reduce = useReduceMotion();\n\n  React.useEffect(() => {\n    if (disabled || reduce) return;\n    const target: HTMLElement | Document = scope?.current ?? document;\n    const isDocument = target instanceof Document;\n\n    const onPointerUp = (event: PointerEvent) => {\n      if (!isDocument) {\n        const rect = (target as HTMLElement).getBoundingClientRect();\n        if (\n          event.clientX < rect.left ||\n          event.clientX > rect.right ||\n          event.clientY < rect.top ||\n          event.clientY > rect.bottom\n        ) {\n          return;\n        }\n      }\n\n      const id = nextId.current++;\n      setItems((current) => [\n        ...current,\n        {\n          id,\n          x: event.clientX,\n          y: event.clientY,\n          variant,\n          color,\n          size,\n          duration,\n        },\n      ]);\n\n      const timer = window.setTimeout(() => {\n        timers.current.delete(timer);\n        setItems((current) => current.filter((item) => item.id !== id));\n      }, duration + 320);\n      timers.current.add(timer);\n    };\n\n    target.addEventListener(\"pointerup\", onPointerUp as EventListener, {\n      passive: true,\n    });\n    return () =>\n      target.removeEventListener(\"pointerup\", onPointerUp as EventListener);\n  }, [color, disabled, duration, reduce, scope, size, variant]);\n\n  React.useEffect(() => {\n    const pending = timers.current;\n    return () => pending.forEach((timer) => window.clearTimeout(timer));\n  }, []);\n\n  return (\n    <>\n      <span data-slot=\"click\" style={{ display: \"contents\" }}>\n        {children}\n      </span>\n      {mounted\n        ? createPortal(\n            <div\n              aria-hidden=\"true\"\n              style={{\n                position: \"fixed\",\n                inset: 0,\n                pointerEvents: \"none\",\n                zIndex: 9999,\n              }}\n            >\n              <AnimatePresence initial={false}>\n                {items.map((item) => (\n                  <ClickEffect key={item.id} item={item} />\n                ))}\n              </AnimatePresence>\n            </div>,\n            document.body,\n          )\n        : null}\n    </>\n  );\n}\n\nconst easeOut: Transition = { duration: 0.4, ease: \"easeOut\" };\n\nfunction ClickEffect({ item }: { item: ClickItem }) {\n  if (item.variant === \"ripple\") return <Ripple item={item} />;\n  if (item.variant === \"ring\") return <Ring item={item} />;\n  if (item.variant === \"crosshair\") return <Crosshair item={item} />;\n  if (item.variant === \"burst\") return <Burst item={item} />;\n  return <Particles item={item} />;\n}\n\nfunction Ripple({ item }: { item: ClickItem }) {\n  return (\n    <motion.span\n      initial={{ opacity: 0.9, scale: 0.2 }}\n      animate={{ opacity: 0, scale: 1 }}\n      exit={{ opacity: 0 }}\n      transition={{ ...easeOut, duration: item.duration / 1000 }}\n      style={{\n        position: \"fixed\",\n        left: item.x - item.size / 2,\n        top: item.y - item.size / 2,\n        width: item.size,\n        height: item.size,\n        borderRadius: 9999,\n        background: item.color,\n        boxShadow: `inset 0 0 0 2px ${item.color}`,\n      }}\n    />\n  );\n}\n\nfunction Ring({ item }: { item: ClickItem }) {\n  const radiusEnd = Math.max(item.size / 1.5, 50);\n  const radiusStart = Math.max(radiusEnd * 0.2, 12);\n  const strokeStart = Math.max(radiusEnd * 0.05, 2.5);\n  const duration = item.duration / 1000;\n\n  return (\n    <motion.svg\n      style={{\n        position: \"fixed\",\n        left: item.x - radiusEnd / 2,\n        top: item.y - radiusEnd / 2,\n        width: radiusEnd,\n        height: radiusEnd,\n        overflow: \"visible\",\n      }}\n      viewBox={`0 0 ${radiusEnd} ${radiusEnd}`}\n    >\n      <motion.circle\n        cx={radiusEnd / 2}\n        cy={radiusEnd / 2}\n        fill=\"none\"\n        stroke={item.color}\n        strokeLinecap=\"round\"\n        initial={{ r: radiusStart, strokeWidth: strokeStart }}\n        animate={{ r: radiusEnd, strokeWidth: 0 }}\n        transition={{ duration, ease: \"easeOut\" }}\n      />\n    </motion.svg>\n  );\n}\n\nfunction Crosshair({ item }: { item: ClickItem }) {\n  const duration = item.duration / 1000;\n  const distance = Math.max(item.size * 0.65, 56);\n  const gap = Math.max(item.size * 0.05, 3);\n  const lengthStart = Math.max(item.size * 0.26, 16);\n  const lengthEnd = Math.max(lengthStart * 0.55, 6);\n  const strokeWidth = Math.max(item.size * 0.065, 2);\n  const half = distance + gap + lengthStart;\n  const box = half * 2;\n  const center = half;\n  const directions = [\n    [1, 0],\n    [-1, 0],\n    [0, -1],\n    [0, 1],\n  ] as const;\n\n  return (\n    <motion.svg\n      style={{\n        position: \"fixed\",\n        left: item.x - half,\n        top: item.y - half,\n        width: box,\n        height: box,\n        overflow: \"visible\",\n        rotate: -25,\n      }}\n      viewBox={`0 0 ${box} ${box}`}\n    >\n      {directions.map(([dx, dy], index) => (\n        <motion.line\n          key={index}\n          x1={center + dx * gap}\n          y1={center + dy * gap}\n          x2={center + dx * (gap + lengthStart)}\n          y2={center + dy * (gap + lengthStart)}\n          stroke={item.color}\n          strokeWidth={strokeWidth}\n          strokeLinecap=\"round\"\n          initial={{ pathLength: 1, scale: 1 }}\n          animate={{\n            x1: center + dx * distance,\n            y1: center + dy * distance,\n            x2: center + dx * (distance + lengthEnd),\n            y2: center + dy * (distance + lengthEnd),\n            pathLength: 0,\n            scale: 0,\n          }}\n          transition={{ duration, ease: [0, 0, 0.7, 1] }}\n        />\n      ))}\n    </motion.svg>\n  );\n}\n\nfunction Burst({ item }: { item: ClickItem }) {\n  const duration = item.duration / 1000;\n  const start = Math.max(item.size * 0.4, 36);\n  const end = Math.max(item.size * 0.65, 56);\n  const lengthStart = Math.max(item.size * 0.2, 14);\n  const lengthEnd = Math.max(lengthStart * 0.5, 6);\n  const strokeWidth = Math.max(item.size * 0.05, 1.5);\n  const half = end + lengthStart;\n  const box = half * 2;\n  const center = half;\n  const count = 8;\n\n  return (\n    <motion.svg\n      style={{\n        position: \"fixed\",\n        left: item.x - half,\n        top: item.y - half,\n        width: box,\n        height: box,\n        overflow: \"visible\",\n      }}\n      viewBox={`0 0 ${box} ${box}`}\n    >\n      {Array.from({ length: count }).map((_, index) => {\n        const angle = (index / count) * Math.PI * 2;\n        const ux = Math.cos(angle);\n        const uy = Math.sin(angle);\n        const x0 = center + ux * start;\n        const y0 = center + uy * start;\n        const x1 = center + ux * end;\n        const y1 = center + uy * end;\n\n        return (\n          <motion.line\n            key={index}\n            stroke={item.color}\n            strokeWidth={strokeWidth}\n            strokeLinecap=\"round\"\n            initial={{\n              x1: x0 - (ux * lengthStart) / 2,\n              y1: y0 - (uy * lengthStart) / 2,\n              x2: x0 + (ux * lengthStart) / 2,\n              y2: y0 + (uy * lengthStart) / 2,\n              opacity: 1,\n            }}\n            animate={{\n              x1: x1 - (ux * lengthEnd) / 2,\n              y1: y1 - (uy * lengthEnd) / 2,\n              x2: x1 + (ux * lengthEnd) / 2,\n              y2: y1 + (uy * lengthEnd) / 2,\n              opacity: [1, 1, 0],\n            }}\n            transition={{ duration, ease: \"easeInOut\" }}\n          />\n        );\n      })}\n    </motion.svg>\n  );\n}\n\nfunction Particles({ item }: { item: ClickItem }) {\n  const duration = item.duration / 1000;\n  const count = 8;\n  const radius = item.size * 0.35;\n  const dot = Math.max(item.size * 0.025, 2.5);\n  const half = radius + dot * 2;\n  const box = half * 2;\n\n  return (\n    <div\n      style={{\n        position: \"fixed\",\n        left: item.x - half,\n        top: item.y - half,\n        width: box,\n        height: box,\n        overflow: \"visible\",\n      }}\n    >\n      {Array.from({ length: count }).map((_, index) => {\n        const angle = (index / count) * Math.PI * 2;\n        return (\n          <motion.span\n            key={index}\n            style={{\n              position: \"absolute\",\n              left: \"50%\",\n              top: \"50%\",\n              width: dot,\n              height: dot,\n              marginLeft: -dot / 2,\n              marginTop: -dot / 2,\n              borderRadius: 9999,\n              background: item.color,\n            }}\n            initial={{ x: 0, y: 0, scale: 0, opacity: 0 }}\n            animate={{\n              x: Math.cos(angle) * radius,\n              y: Math.sin(angle) * radius,\n              scale: [0, 1, 0],\n              opacity: [0, 1, 0],\n            }}\n            transition={{\n              duration,\n              delay: index * duration * 0.06,\n              ease: \"easeOut\",\n            }}\n          />\n        );\n      })}\n    </div>\n  );\n}\n",
      "target": "components/prequelui/effects/click.tsx"
    }
  ]
}
