{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"goo-chaser","type":"registry:ui","title":"Goo Chaser","description":"A trail of gooey blobs that stretch, merge and split as they chase the pointer.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/goo-chaser.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useId, useRef, type ReactNode } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface GooChaserProps {\n  children?: ReactNode;\n  color?: string;\n  /** Number of trailing blobs. */\n  count?: number;\n  /** Diameter of the lead blob in px. */\n  size?: number;\n  /** 0 = blobs move together, 1 = long lazy tail. */\n  lag?: number;\n  /** Blur radius of the goo filter; higher melts blobs together from further away. */\n  goo?: number;\n  blendMode?: \"difference\" | \"normal\" | \"screen\" | \"exclusion\";\n  /** Hide the native cursor inside the container. */\n  hideCursor?: boolean;\n  className?: string;\n}\n\nexport function GooChaser({\n  children,\n  color = \"#c6ff3d\",\n  count = 4,\n  size = 96,\n  lag = 0.5,\n  goo = 14,\n  blendMode = \"difference\",\n  hideCursor = true,\n  className,\n}: GooChaserProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const blobs = useRef<(HTMLDivElement | null)[]>([]);\n  const filterId = \"blob-goo-\" + useId().replace(/[^\\w-]/g, \"\");\n\n  useEffect(() => {\n    const root = rootRef.current!;\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const target = { x: root.offsetWidth / 2, y: root.offsetHeight / 2 };\n    const pos = Array.from({ length: count }, () => ({ ...target }));\n    let raf = 0;\n    let last = 0;\n    let visible = true;\n\n    const loop = (now: number) => {\n      const dt = Math.min((now - (last || now)) / 16.67, 3);\n      last = now;\n      const t = now / 1000;\n      pos.forEach((p, i) => {\n        const k = reduced ? 1 : 1 - Math.pow(1 - 0.38 / (1 + i * lag * 2.2), dt);\n        p.x += (target.x - p.x) * k;\n        p.y += (target.y - p.y) * k;\n        // A slow orbit keeps the goo breathing while the pointer rests.\n        const wob = reduced || i === 0 ? 0 : size * (0.22 + i * 0.06);\n        const s = size * Math.max(0.3, 1 - i * 0.17);\n        const x = p.x + Math.cos(t * 1.3 + i * 2.1) * wob - s / 2;\n        const y = p.y + Math.sin(t * 1.7 + i * 1.3) * wob - s / 2;\n        const el = blobs.current[i];\n        if (el) el.style.transform = `translate3d(${x}px, ${y}px, 0)`;\n      });\n      raf = visible ? requestAnimationFrame(loop) : 0;\n    };\n\n    const onMove = (e: PointerEvent) => {\n      const r = root.getBoundingClientRect();\n      target.x = e.clientX - r.left;\n      target.y = e.clientY - r.top;\n    };\n\n    const io = new IntersectionObserver(([entry]) => {\n      visible = entry.isIntersecting;\n      if (visible && !raf) raf = requestAnimationFrame(loop);\n    });\n    io.observe(root);\n    root.addEventListener(\"pointermove\", onMove, { passive: true });\n    return () => {\n      cancelAnimationFrame(raf);\n      io.disconnect();\n      root.removeEventListener(\"pointermove\", onMove);\n    };\n  }, [count, size, lag]);\n\n  return (\n    <div\n      ref={rootRef}\n      className={cn(\"relative overflow-hidden\", className)}\n      data-blob-cursor-hide={hideCursor ? \"\" : undefined}\n    >\n      <style href=\"goo-chaser\" precedence=\"default\">\n        {`[data-blob-cursor-hide],[data-blob-cursor-hide] *{cursor:none!important}`}\n      </style>\n      <svg aria-hidden width=\"0\" height=\"0\" style={{ position: \"absolute\" }}>\n        <filter id={filterId}>\n          <feGaussianBlur in=\"SourceGraphic\" stdDeviation={goo} result=\"blur\" />\n          <feColorMatrix in=\"blur\" values={`1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 ${goo * 1.6} -${goo * 0.7}`} />\n        </filter>\n      </svg>\n      {children}\n      <div\n        aria-hidden\n        style={{ position: \"absolute\", inset: 0, pointerEvents: \"none\", filter: `url(#${filterId})`, mixBlendMode: blendMode }}\n      >\n        {Array.from({ length: count }, (_, i) => {\n          const s = size * Math.max(0.3, 1 - i * 0.17);\n          return (\n            <div\n              key={i}\n              ref={(el) => {\n                blobs.current[i] = el;\n              }}\n              style={{\n                position: \"absolute\",\n                left: 0,\n                top: 0,\n                width: s,\n                height: s,\n                borderRadius: \"50%\",\n                background: color,\n                willChange: \"transform\",\n              }}\n            >\n              <div\n                style={{\n                  position: \"absolute\",\n                  left: \"22%\",\n                  top: \"20%\",\n                  width: \"26%\",\n                  height: \"26%\",\n                  borderRadius: \"50%\",\n                  background: \"rgba(255,255,255,.75)\",\n                }}\n              />\n            </div>\n          );\n        })}\n      </div>\n    </div>\n  );\n}\n"}]}