{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "blob-cursor",
  "type": "registry:component",
  "title": "Blob Cursor",
  "description": "A soft gooey blob that trails the cursor with lag, merging three circles through an SVG goo filter.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "hover",
    "cursor",
    "blob",
    "goo",
    "pointer",
    "follow"
  ],
  "docs": "https://hyperblur.dev/effects/blob-cursor",
  "files": [
    {
      "path": "registry/hyperblur/blob-cursor.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/blob-cursor.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface BlobCursorProps extends React.HTMLAttributes<HTMLDivElement> {\n  color?: string;\n  size?: number;\n  lag?: number;\n  blend?: \"screen\" | \"normal\" | \"difference\";\n  global?: boolean;\n}\n\nconst css = `\n.hb-bcur { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }\n.hb-bcur[data-global=\"true\"] { position: fixed; }\n.hb-bcur-svg { position: absolute; width: 0; height: 0; overflow: hidden; }\n.hb-bcur-b {\n  position: absolute; left: 0; top: 0;\n  width: var(--hb-w); height: var(--hb-w);\n  opacity: 0; transition: opacity .25s ease;\n  mix-blend-mode: var(--hb-bm);\n  will-change: transform;\n}\n.hb-bcur[data-on=\"true\"] .hb-bcur-b { opacity: 1; }\n.hb-bcur-c {\n  position: absolute; left: 0; top: 0;\n  border-radius: 50%; background: var(--hb-c);\n  will-change: transform;\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-bcur { display: none; }\n}\n`;\n\nexport function BlobCursor({\n  color = \"#2f7bff\",\n  size = 48,\n  lag = 0.15,\n  blend = \"screen\",\n  global = false,\n  className = \"\",\n  style,\n  ...rest\n}: BlobCursorProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const boxRef = React.useRef<HTMLDivElement>(null);\n  const uid = React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\");\n  const fid = `hb-bcur-${uid}`;\n  const s = Math.max(4, size);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    const box = boxRef.current;\n    const host = el?.parentElement;\n    if (!el || !box || !host) return;\n\n    const circles = Array.from(box.children) as HTMLElement[];\n    const radii = [s * 0.5, s * 0.35, s * 0.22];\n    const rates = [1, 0.6, 0.38];\n    const half = s * 3;\n    const limit = half - s * 0.8;\n    const base = Math.min(1, Math.max(0.01, lag));\n    const px = [0, 0, 0];\n    const py = [0, 0, 0];\n    const motion = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n    const moveTarget: EventTarget = global ? window : host;\n    const leaveTarget: EventTarget = global ? document.documentElement : host;\n    let tx = 0;\n    let ty = 0;\n    let raf = 0;\n    let prev = 0;\n    let placed = false;\n\n    const clamp = (v: number) => Math.max(-limit, Math.min(limit, v));\n\n    const paint = () => {\n      const lx = px[0];\n      const ly = py[0];\n      const k = 1 + Math.min(0.35, Math.hypot(tx - lx, ty - ly) / (s * 8));\n      box.style.transform = `translate3d(${(lx - half).toFixed(1)}px, ${(ly - half).toFixed(1)}px, 0)`;\n      for (let i = 0; i < circles.length; i++) {\n        const ox = clamp(px[i] - lx);\n        const oy = clamp(py[i] - ly);\n        circles[i].style.transform = `translate3d(${(half + ox - radii[i]).toFixed(1)}px, ${(half + oy - radii[i]).toFixed(1)}px, 0) scale(${k.toFixed(3)})`;\n      }\n    };\n\n    const step = (now: number) => {\n      const f = Math.min(0.05, Math.max(0, (now - prev) / 1000)) * 60;\n      prev = now;\n      let fx = tx;\n      let fy = ty;\n      let moving = false;\n      for (let i = 0; i < 3; i++) {\n        const rate = Math.min(1, base * rates[i]);\n        const k = rate >= 1 ? 1 : 1 - Math.pow(1 - rate, f);\n        px[i] += (fx - px[i]) * k;\n        py[i] += (fy - py[i]) * k;\n        if (Math.abs(fx - px[i]) + Math.abs(fy - py[i]) > 0.05) moving = true;\n        fx = px[i];\n        fy = py[i];\n      }\n      paint();\n      raf = moving ? requestAnimationFrame(step) : 0;\n    };\n\n    const move = (ev: Event) => {\n      const e = ev as PointerEvent;\n      if (e.pointerType === \"touch\" || motion.matches) return;\n      const r = el.getBoundingClientRect();\n      tx = e.clientX - r.left;\n      ty = e.clientY - r.top;\n      if (!placed) {\n        placed = true;\n        px.fill(tx);\n        py.fill(ty);\n        paint();\n        el.dataset.on = \"true\";\n      }\n      if (!raf) {\n        prev = performance.now();\n        raf = requestAnimationFrame(step);\n      }\n    };\n\n    const leave = () => {\n      placed = false;\n      el.dataset.on = \"false\";\n      if (raf) {\n        cancelAnimationFrame(raf);\n        raf = 0;\n      }\n    };\n\n    moveTarget.addEventListener(\"pointermove\", move, { passive: true });\n    leaveTarget.addEventListener(\"pointerleave\", leave);\n\n    return () => {\n      if (raf) cancelAnimationFrame(raf);\n      moveTarget.removeEventListener(\"pointermove\", move);\n      leaveTarget.removeEventListener(\"pointerleave\", leave);\n    };\n  }, [s, lag, global]);\n\n  const vars = {\n    \"--hb-c\": color,\n    \"--hb-bm\": blend,\n    \"--hb-w\": `${s * 6}px`,\n    ...style,\n  } as React.CSSProperties;\n\n  const diameters = [s, s * 0.7, s * 0.44];\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-bcur ${className}`}\n      style={vars}\n      data-global={global ? \"true\" : \"false\"}\n      aria-hidden=\"true\"\n      {...rest}\n    >\n      <style href=\"hb-blob-cursor\" precedence=\"default\">{css}</style>\n      <svg className=\"hb-bcur-svg\" width=\"0\" height=\"0\" focusable=\"false\">\n        <defs>\n          <filter id={fid} colorInterpolationFilters=\"sRGB\">\n            <feGaussianBlur in=\"SourceGraphic\" stdDeviation={s * 0.12} result=\"blur\" />\n            <feColorMatrix\n              in=\"blur\"\n              mode=\"matrix\"\n              values=\"1 0 0 0 0  0 1 0 0 0  0 0 1 0 0  0 0 0 18 -8\"\n            />\n          </filter>\n        </defs>\n      </svg>\n      <div ref={boxRef} className=\"hb-bcur-b\" style={{ filter: `url(#${fid})` }}>\n        {diameters.map((d, i) => (\n          <span key={i} className=\"hb-bcur-c\" style={{ width: d, height: d }} />\n        ))}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}