{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shooting-stars",
  "type": "registry:ui",
  "title": "Shooting Stars",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Atmospheric meteor shower background that spawns diagonal shooting stars with glowing heads and transparent gradient tails at configurable intervals.",
  "dependencies": [
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/shooting-stars.tsx",
      "content": "\"use client\";\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { Sparkles } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface ShootingStarsProps {\n  /** Average spawns per second. Default: 2.5 */\n  frequency?: number;\n  /** Trajectory angle in degrees. Default: 35 */\n  angle?: number;\n  /** Hex or RGB color for the meteor head and tail. Default: \"#FFFFFF\" */\n  color?: string;\n  /** Maximum simultaneous shooting stars. Default: 6 */\n  maxConcurrent?: number;\n  /** Optional foreground content */\n  children?: React.ReactNode;\n  className?: string;\n}\n\ninterface Meteor {\n  x: number;\n  y: number;\n  length: number;\n  speed: number;\n  life: number;\n  maxLife: number;\n}\n\nexport function ShootingStars({\n  frequency = 2.5,\n  angle = 35,\n  color = \"#FFFFFF\",\n  maxConcurrent = 6,\n  children,\n  className,\n}: ShootingStarsProps) {\n  const canvasRef = useRef<HTMLCanvasElement>(null);\n  const [burstTrigger, setBurstTrigger] = useState(0);\n\n  useEffect(() => {\n    const canvas = canvasRef.current;\n    if (!canvas) return;\n    const ctx = canvas.getContext(\"2d\");\n    if (!ctx) return;\n\n    let rafId: number;\n    let width = (canvas.width = canvas.offsetWidth || 600);\n    let height = (canvas.height = canvas.offsetHeight || 360);\n\n    const rad = (angle * Math.PI) / 180;\n    const vx = Math.cos(rad);\n    const vy = Math.sin(rad);\n\n    const meteors: Meteor[] = [];\n\n    const spawnMeteor = () => {\n      if (meteors.length >= maxConcurrent) return;\n      meteors.push({\n        x: Math.random() * width * 0.85,\n        y: Math.random() * height * 0.45,\n        length: 80 + Math.random() * 90,\n        speed: 520 + Math.random() * 340,\n        life: 0,\n        maxLife: 0.75 + Math.random() * 0.45,\n      });\n    };\n\n    // Initial spawn\n    spawnMeteor();\n\n    let last = performance.now();\n    const render = (now: number) => {\n      const dt = Math.min(0.05, (now - last) / 1000);\n      last = now;\n\n      if (Math.random() < frequency * dt) {\n        spawnMeteor();\n      }\n\n      ctx.clearRect(0, 0, width, height);\n\n      for (let i = meteors.length - 1; i >= 0; i--) {\n        const m = meteors[i];\n        m.life += dt;\n        if (m.life >= m.maxLife) {\n          meteors.splice(i, 1);\n          continue;\n        }\n\n        m.x += vx * m.speed * dt;\n        m.y += vy * m.speed * dt;\n\n        const progress = m.life / m.maxLife;\n        const alpha =\n          progress < 0.2\n            ? progress / 0.2\n            : Math.max(0, 1 - (progress - 0.2) / 0.8);\n\n        const tailX = m.x - vx * m.length;\n        const tailY = m.y - vy * m.length;\n\n        const grad = ctx.createLinearGradient(m.x, m.y, tailX, tailY);\n        grad.addColorStop(0, color);\n        grad.addColorStop(1, \"rgba(255, 255, 255, 0)\");\n\n        ctx.save();\n        ctx.globalAlpha = alpha;\n        ctx.strokeStyle = grad;\n        ctx.lineWidth = 2;\n        ctx.lineCap = \"round\";\n        ctx.beginPath();\n        ctx.moveTo(m.x, m.y);\n        ctx.lineTo(tailX, tailY);\n        ctx.stroke();\n\n        // Bright head glow\n        ctx.fillStyle = color;\n        ctx.beginPath();\n        ctx.arc(m.x, m.y, 2.2, 0, Math.PI * 2);\n        ctx.fill();\n        ctx.restore();\n      }\n\n      rafId = requestAnimationFrame(render);\n    };\n\n    rafId = requestAnimationFrame(render);\n    return () => cancelAnimationFrame(rafId);\n  }, [frequency, angle, color, maxConcurrent, burstTrigger]);\n\n  return (\n    <div\n      data-fullscreen-scroll\n      className={cn(\n        \"relative flex min-h-[360px] w-full flex-col justify-between overflow-hidden rounded-3xl border border-neutral-800 bg-[#05070F] p-6 text-white shadow-sm\",\n        className\n      )}\n    >\n      {/* Subtle Background Star Dust */}\n      <div\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 opacity-25 [background-image:radial-gradient(white_1px,transparent_1px)] [background-size:32px_32px]\"\n      />\n\n      <canvas\n        ref={canvasRef}\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-0 h-full w-full\"\n      />\n\n      <div className=\"relative z-10 flex flex-1 flex-col justify-between\">\n        {children ?? (\n          <>\n            <div className=\"flex items-center justify-between gap-2\">\n              <span className=\"inline-flex items-center gap-1.5 rounded-full border border-white/15 bg-white/10 px-3 py-1 font-mono text-[11px] font-medium text-white backdrop-blur-md\">\n                <Sparkles className=\"h-3.5 w-3.5 text-amber-200\" />\n                Shooting Stars · {angle}° Trajectory\n              </span>\n\n              <button\n                type=\"button\"\n                onClick={() => setBurstTrigger((c) => c + 1)}\n                className=\"rounded-full border border-white/15 bg-white/10 px-3 py-1 font-mono text-[11px] text-white backdrop-blur-md transition-colors hover:bg-white/20\"\n              >\n                Spawn Meteor\n              </button>\n            </div>\n\n            <div className=\"my-auto max-w-md py-8\">\n              <h3 className=\"text-2xl font-bold tracking-tight text-white sm:text-3xl\">\n                Meteor Shower Streaking\n              </h3>\n              <p className=\"mt-2 text-xs leading-relaxed text-white/75 sm:text-sm\">\n                Randomized diagonal meteors with bright heads and linear-gradient\n                tails that fade out smoothly over a 1-second lifecycle.\n              </p>\n            </div>\n\n            <div className=\"font-mono text-[11px] text-white/50\">\n              Max Concurrent: {maxConcurrent} · Frequency: {frequency}/s\n            </div>\n          </>\n        )}\n      </div>\n    </div>\n  );\n}\n\nexport default ShootingStars;\n",
      "type": "registry:ui",
      "target": "components/ui/shooting-stars.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
