{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "signal-glitch-title",
  "title": "Signal Glitch Title",
  "description": "A title that loses signal for a moment: colour channels split and slices of the word jump sideways in short bursts, then it snaps back clean.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/new-york/signal-glitch-title/signal-glitch-title.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface SignalGlitchTitleProps extends Omit<\n  React.HTMLAttributes<HTMLHeadingElement>,\n  \"children\"\n> {\n  text?: string;\n  as?: \"h1\" | \"h2\" | \"h3\" | \"p\";\n  /** Milliseconds between bursts. 0 leaves only the pointer to set one off. */\n  interval?: number;\n  /** How far the slices jump, in em. */\n  intensity?: number;\n  /** The two split channels. */\n  channels?: [string, string];\n}\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nconst CHANNELS: [string, string] = [\"#4EA7FC\", \"#EB5757\"];\nconst STEPS = 9;\n\nexport function SignalGlitchTitle({\n  text = \"SIGNAL LOST\",\n  as: Tag = \"h2\",\n  interval = 3000,\n  intensity = 0.06,\n  channels = CHANNELS,\n  className,\n  style,\n  onPointerEnter,\n  ...props\n}: SignalGlitchTitleProps) {\n  const reduce = useReducedMotion();\n  const rootRef = React.useRef<HTMLHeadingElement>(null);\n  const layerRefs = React.useRef<(HTMLSpanElement | null)[]>([]);\n  const burst = React.useRef<() => void>(() => {});\n\n  // A burst is a handful of frames: a random slice of each channel jumps sideways, then everything snaps back.\n  React.useEffect(() => {\n    let timer = 0;\n    let step = 0;\n    let running = false;\n    const clear = () => {\n      layerRefs.current.forEach((el) => {\n        if (!el) return;\n        el.style.opacity = \"0\";\n        el.style.transform = \"none\";\n      });\n    };\n    const tick = () => {\n      if (step >= STEPS) {\n        clear();\n        running = false;\n        return;\n      }\n      step += 1;\n      layerRefs.current.forEach((el, i) => {\n        if (!el) return;\n        const top = Math.random() * 80;\n        const height = 6 + Math.random() * 30;\n        const shift = (Math.random() - 0.5) * 2 * intensity * (i ? -1 : 1);\n        el.style.opacity = \"0.9\";\n        el.style.clipPath = `inset(${top.toFixed(1)}% 0 ${Math.max(0, 100 - top - height).toFixed(1)}% 0)`;\n        el.style.transform = `translateX(${shift.toFixed(3)}em)`;\n      });\n      timer = window.setTimeout(tick, 45);\n    };\n    burst.current = () => {\n      if (reduce || running) return;\n      running = true;\n      step = 0;\n      tick();\n    };\n    const every =\n      interval > 0 && !reduce\n        ? window.setInterval(() => burst.current(), interval)\n        : 0;\n    return () => {\n      window.clearInterval(every);\n      window.clearTimeout(timer);\n      clear();\n    };\n  }, [reduce, interval, intensity]);\n\n  return (\n    <Tag\n      ref={rootRef}\n      className={`relative ${className ?? \"\"}`}\n      style={style}\n      onPointerEnter={(e: React.PointerEvent<HTMLHeadingElement>) => {\n        onPointerEnter?.(e);\n        burst.current();\n      }}\n      {...props}\n    >\n      {text}\n      {channels.map((color, i) => (\n        <span\n          key={color}\n          ref={(el) => {\n            layerRefs.current[i] = el;\n          }}\n          aria-hidden=\"true\"\n          className=\"pointer-events-none absolute inset-0 block\"\n          style={{ color, opacity: 0, mixBlendMode: \"screen\" }}\n        >\n          {text}\n        </span>\n      ))}\n    </Tag>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}