{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"halo-follow","type":"registry:ui","title":"Halo Follow","description":"A soft colored glow trails the cursor inside its container and swells over interactive children.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/halo-follow.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface HaloFollowProps {\n  children?: ReactNode;\n  /** Glow color. */\n  color?: string;\n  /** Glow diameter in px. */\n  size?: number;\n  /** Follow easing per frame, 0–1. Lower trails further behind. */\n  ease?: number;\n  /** Resting opacity, 0–1. */\n  intensity?: number;\n  /** Scale multiplier while over an interactive child. */\n  hoverScale?: number;\n  /** Children matching this selector make the glow swell and brighten. */\n  selector?: string;\n  className?: string;\n}\n\nexport function HaloFollow({\n  children,\n  color = \"#c6ff3d\",\n  size = 360,\n  ease = 0.12,\n  intensity = 0.35,\n  hoverScale = 1.5,\n  selector = \"a,button,[data-glow]\",\n  className,\n}: HaloFollowProps) {\n  const root = useRef<HTMLDivElement>(null);\n  const orb = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    const el = root.current!;\n    const o = orb.current!;\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const k = reduced ? 1 : ease;\n    const cur = { x: 0, y: 0, s: 0.6, a: 0 };\n    const tgt = { x: 0, y: 0, s: 0.6, a: 0 };\n    let raf = 0;\n\n    const tick = () => {\n      cur.x += (tgt.x - cur.x) * k;\n      cur.y += (tgt.y - cur.y) * k;\n      cur.s += (tgt.s - cur.s) * 0.12;\n      cur.a += (tgt.a - cur.a) * 0.12;\n      o.style.transform = `translate3d(${cur.x - size / 2}px, ${cur.y - size / 2}px, 0) scale(${cur.s})`;\n      o.style.opacity = String(cur.a);\n      const settled =\n        Math.abs(tgt.x - cur.x) + Math.abs(tgt.y - cur.y) < 0.2 &&\n        Math.abs(tgt.s - cur.s) < 0.002 &&\n        Math.abs(tgt.a - cur.a) < 0.002;\n      // The loop sleeps once the orb catches up; a still cursor costs nothing.\n      raf = settled ? 0 : requestAnimationFrame(tick);\n    };\n    const kick = () => {\n      if (!raf) raf = requestAnimationFrame(tick);\n    };\n\n    const onMove = (e: PointerEvent) => {\n      const r = el.getBoundingClientRect();\n      tgt.x = e.clientX - r.left;\n      tgt.y = e.clientY - r.top;\n      if (cur.a < 0.01) {\n        cur.x = tgt.x;\n        cur.y = tgt.y;\n      }\n      const hot = (e.target as Element | null)?.closest?.(selector);\n      const over = !!hot && el.contains(hot);\n      tgt.s = over ? hoverScale : 1;\n      tgt.a = over ? Math.min(1, intensity * 2.2) : intensity;\n      kick();\n    };\n    const onLeave = () => {\n      tgt.s = 0.6;\n      tgt.a = 0;\n      kick();\n    };\n\n    el.addEventListener(\"pointermove\", onMove, { passive: true });\n    el.addEventListener(\"pointerleave\", onLeave);\n    return () => {\n      cancelAnimationFrame(raf);\n      el.removeEventListener(\"pointermove\", onMove);\n      el.removeEventListener(\"pointerleave\", onLeave);\n    };\n  }, [size, ease, intensity, hoverScale, selector]);\n\n  return (\n    <div ref={root} className={cn(\"relative isolate overflow-hidden\", className)}>\n      <div\n        ref={orb}\n        aria-hidden\n        style={{\n          position: \"absolute\",\n          left: 0,\n          top: 0,\n          width: size,\n          height: size,\n          borderRadius: \"50%\",\n          background: `radial-gradient(circle, ${color} 0%, color-mix(in srgb, ${color} 35%, transparent) 30%, transparent 68%)`,\n          filter: \"blur(12px)\",\n          opacity: 0,\n          pointerEvents: \"none\",\n          zIndex: -1,\n          willChange: \"transform, opacity\",\n        }}\n      />\n      {children}\n    </div>\n  );\n}\n"}]}