{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"hud-type","type":"registry:ui","title":"HUD Type","description":"HUD-style lettering that flickers on inside bracket frames, with a scan line, live readouts and a blinking caret.","dependencies":[],"registryDependencies":["utils"],"files":[{"path":"registry/ui/hud-type.tsx","type":"registry:ui","content":"\"use client\";\n\nimport { useEffect, useRef, useState, type CSSProperties } from \"react\";\nimport { cn } from \"@/lib/utils\";\n\nconst css = `\n@keyframes tech-text-flicker{0%{opacity:0}8%{opacity:1}12%{opacity:.1}22%{opacity:.9}28%{opacity:.2}44%,100%{opacity:1}}\n@keyframes tech-text-glow{from{color:var(--tech);text-shadow:0 0 .35em var(--tech)}}\n@keyframes tech-text-corner{from{opacity:0;transform:translate(var(--dx),var(--dy))}}\n@keyframes tech-text-scan{0%{top:0;opacity:0}15%{opacity:.9}100%{top:100%;opacity:0}}\n@keyframes tech-text-blink{50%{opacity:0}}\n@keyframes tech-text-in{from{opacity:0;transform:translateY(.3em)}}\n@media (prefers-reduced-motion: reduce){[data-tech-text] *{animation:none!important}}`;\n\nexport interface HudTypeProps {\n  text: string;\n  /** Small readout above the frame. */\n  label?: string;\n  /** Small readout below the frame; a live percentage is appended. */\n  sublabel?: string;\n  /** Accent for brackets, labels, caret and the flicker glow. */\n  color?: string;\n  /** Ms between characters flickering on. */\n  speed?: number;\n  /** Show a blinking block caret after the text. */\n  caret?: boolean;\n  /** Replay the boot sequence on hover. */\n  replayOnHover?: boolean;\n  className?: string;\n}\n\n// Deterministic 0-1 jitter so SSR and client agree.\nconst jitter = (i: number) => ((i * 9301 + 49297) % 233280) / 233280;\n\nconst corners: CSSProperties[] = [\n  { top: 0, left: 0, borderTopWidth: 2, borderLeftWidth: 2, \"--dx\": \"-.3em\", \"--dy\": \"-.3em\" } as CSSProperties,\n  { top: 0, right: 0, borderTopWidth: 2, borderRightWidth: 2, \"--dx\": \".3em\", \"--dy\": \"-.3em\" } as CSSProperties,\n  { bottom: 0, left: 0, borderBottomWidth: 2, borderLeftWidth: 2, \"--dx\": \"-.3em\", \"--dy\": \".3em\" } as CSSProperties,\n  { bottom: 0, right: 0, borderBottomWidth: 2, borderRightWidth: 2, \"--dx\": \".3em\", \"--dy\": \".3em\" } as CSSProperties,\n];\n\nexport function HudType({\n  text,\n  label = \"SYS.07 // UPLINK\",\n  sublabel = \"SIGNAL LOCK\",\n  color = \"#a3e635\",\n  speed = 45,\n  caret = true,\n  replayOnHover = true,\n  className,\n}: HudTypeProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const readout = useRef<HTMLSpanElement>(null);\n  const [run, setRun] = useState(0);\n  const chars = Array.from(text);\n  const total = 300 + chars.length * speed + speed * 2 + 450;\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const io = new IntersectionObserver(([entry]) => {\n      if (entry.isIntersecting) {\n        setRun((r) => r || 1);\n        io.disconnect();\n      }\n    });\n    io.observe(el);\n    return () => io.disconnect();\n  }, []);\n\n  // Percentage readout counts up with the boot sequence (DOM write, no re-render).\n  useEffect(() => {\n    const out = readout.current;\n    if (!out || !run) return;\n    const still = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    const t0 = performance.now();\n    let raf = 0;\n    const tick = (now: number) => {\n      const p = still ? 1 : Math.min(1, (now - t0) / total);\n      out.textContent = `${String(Math.round(p * 100)).padStart(3, \"0\")}%`;\n      if (p < 1) raf = requestAnimationFrame(tick);\n    };\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [run, total]);\n\n  const hud = \"absolute whitespace-nowrap font-mono uppercase leading-none tracking-[0.2em]\";\n  const hudStyle: CSSProperties = { fontSize: \"max(10px, 0.16em)\", color: \"var(--tech)\", fontWeight: 500 };\n\n  return (\n    <div\n      ref={ref}\n      data-tech-text=\"\"\n      className={cn(\"relative inline-block px-[0.55em] py-[0.4em]\", className)}\n      style={{ \"--tech\": color, visibility: run ? \"visible\" : \"hidden\" } as CSSProperties}\n      onMouseEnter={replayOnHover ? () => setRun((r) => r + 1) : undefined}\n    >\n      <style href=\"hud-type\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"sr-only\">{text}</span>\n      <div key={run} aria-hidden>\n        <div\n          className=\"pointer-events-none absolute inset-0\"\n          style={{\n            background:\n              \"repeating-linear-gradient(0deg, color-mix(in oklab, var(--tech) 7%, transparent) 0 1px, transparent 1px 4px), color-mix(in oklab, var(--tech) 5%, transparent)\",\n            animation: \"tech-text-in .5s ease-out both\",\n          }}\n        />\n        {corners.map((s, i) => (\n          <span\n            key={i}\n            className=\"absolute size-[0.32em] min-h-3 min-w-3\"\n            style={{\n              ...s,\n              borderColor: \"var(--tech)\",\n              borderStyle: \"solid\",\n              filter: \"drop-shadow(0 0 4px var(--tech))\",\n              animation: `tech-text-corner .6s cubic-bezier(.2,.8,.2,1) ${i * 60}ms both`,\n            }}\n          />\n        ))}\n        <span\n          className=\"pointer-events-none absolute inset-x-0 h-px\"\n          style={{ background: \"var(--tech)\", boxShadow: \"0 0 8px var(--tech)\", animation: `tech-text-scan ${total}ms ease-in-out both` }}\n        />\n        <span className={cn(hud, \"bottom-full left-0 mb-[0.5em] flex items-center gap-[0.6em]\")} style={{ ...hudStyle, animation: \"tech-text-in .5s .2s ease-out both\" }}>\n          <span className=\"inline-block size-[0.6em] rounded-full\" style={{ background: \"var(--tech)\", animation: \"tech-text-blink 1.2s steps(1) infinite\" }} />\n          {label}\n        </span>\n        <span className={cn(hud, \"right-0 top-full mt-[0.5em]\")} style={{ ...hudStyle, opacity: 0.8, animation: \"tech-text-in .5s .35s ease-out both\" }}>\n          {sublabel} · <span ref={readout}>000%</span>\n        </span>\n        <span className=\"relative whitespace-pre\">\n          {chars.map((c, i) => {\n            const d = 300 + i * speed + jitter(i) * speed * 3;\n            return (\n              <span\n                key={i}\n                style={{ animation: `tech-text-flicker 480ms linear ${d}ms both, tech-text-glow 900ms ease-out ${d}ms both` }}\n              >\n                {c}\n              </span>\n            );\n          })}\n          {caret && (\n            <span\n              className=\"ml-[0.08em] inline-block h-[0.8em] w-[0.5em] align-[-0.05em]\"\n              style={{ background: \"var(--tech)\", boxShadow: \"0 0 10px var(--tech)\", animation: \"tech-text-blink 1s steps(1) infinite\" }}\n            />\n          )}\n        </span>\n      </div>\n    </div>\n  );\n}\n"}]}