{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"tap-burst","type":"registry:ui","title":"Tap Burst","description":"Bursts of sparks radiate from every click inside the area.","dependencies":[],"registryDependencies":[],"files":[{"path":"registry/ui/tap-burst.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, type PointerEvent, type ReactNode } from \"react\";\n\nexport interface TapBurstProps {\n  children?: ReactNode;\n  sparkColor?: string;\n  sparkCount?: number;\n  /** How far sparks travel, in px. */\n  sparkRadius?: number;\n  /** Length of each spark line, in px. */\n  sparkSize?: number;\n  /** Ms per burst. */\n  duration?: number;\n  className?: string;\n}\n\ntype Spark = { x: number; y: number; angle: number; t0: number };\n\nexport function TapBurst({\n  children,\n  sparkColor = \"#ffffff\",\n  sparkCount = 8,\n  sparkRadius = 24,\n  sparkSize = 10,\n  duration = 400,\n  className,\n}: TapBurstProps) {\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const sparks = useRef<Spark[]>([]);\n  const raf = useRef(0);\n  const draw = useRef<(now: number) => void>(() => {});\n\n  useEffect(() => {\n    const canvas = canvasRef.current!;\n    const ctx = canvas.getContext(\"2d\")!;\n    const ro = new ResizeObserver(() => {\n      const dpr = Math.min(window.devicePixelRatio || 1, 2);\n      canvas.width = canvas.offsetWidth * dpr;\n      canvas.height = canvas.offsetHeight * dpr;\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0);\n    });\n    ro.observe(canvas);\n\n    draw.current = (now) => {\n      ctx.clearRect(0, 0, canvas.width, canvas.height);\n      sparks.current = sparks.current.filter((s) => now - s.t0 < duration);\n      ctx.strokeStyle = sparkColor;\n      ctx.lineWidth = 2;\n      for (const s of sparks.current) {\n        const p = (now - s.t0) / duration;\n        const eased = p * (2 - p);\n        const dist = eased * sparkRadius;\n        const len = sparkSize * (1 - eased);\n        const cos = Math.cos(s.angle);\n        const sin = Math.sin(s.angle);\n        ctx.beginPath();\n        ctx.moveTo(s.x + dist * cos, s.y + dist * sin);\n        ctx.lineTo(s.x + (dist + len) * cos, s.y + (dist + len) * sin);\n        ctx.stroke();\n      }\n      // Loop only while sparks are alive: idle costs nothing.\n      raf.current = sparks.current.length ? requestAnimationFrame(draw.current) : 0;\n    };\n\n    return () => {\n      ro.disconnect();\n      cancelAnimationFrame(raf.current);\n      raf.current = 0;\n    };\n  }, [sparkColor, sparkRadius, sparkSize, duration]);\n\n  const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {\n    const rect = canvasRef.current!.getBoundingClientRect();\n    const t0 = performance.now();\n    for (let i = 0; i < sparkCount; i++) {\n      sparks.current.push({\n        x: e.clientX - rect.left,\n        y: e.clientY - rect.top,\n        angle: (2 * Math.PI * i) / sparkCount,\n        t0,\n      });\n    }\n    if (!raf.current) raf.current = requestAnimationFrame(draw.current);\n  };\n\n  return (\n    <div className={className} style={{ position: \"relative\" }} onPointerDown={onPointerDown}>\n      {children}\n      <canvas\n        ref={canvasRef}\n        aria-hidden\n        style={{ position: \"absolute\", inset: 0, width: \"100%\", height: \"100%\", pointerEvents: \"none\" }}\n      />\n    </div>\n  );\n}\n"}]}