{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "decode-text",
  "type": "registry:ui",
  "title": "Decode Text",
  "description": "DecodeText — micro-labels resolve from glyph noise into their text.",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "decorative",
    "effect"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json",
    "https://ds.interlace.tools/r/use-reduced-motion.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/effects/decode-text.tsx",
      "target": "components/ui/effects/decode-text.tsx",
      "type": "registry:ui",
      "content": "'use client';\n\nimport * as React from 'react';\n\n// @interlace/decode-text v2.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/decode-text\n// What changed since: https://ds.interlace.tools/c/decode-text#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\nimport { cn } from '@/lib/utils';\nimport { useReducedMotion } from '@/hooks/use-reduced-motion';\n\n/**\n * DecodeText — micro-labels resolve from glyph noise into their text.\n *\n * ## RFC (R3)\n *\n * The label-scale member of the Interlace signature kit (border →\n * InterlaceWeave, data → TimelineMap). A terminal-decode on monospace\n * micro-labels is native to a lint/security brand — the aesthetic of\n * tooling output, not borrowed flair. Travel signal (R2): HIGH — card\n * category chips, cover hooks, section eyebrows, stat labels.\n *\n * ## Honesty contract\n *\n * Static markup ALWAYS carries the final text — crawlers, reader mode,\n * and JS-off visitors never see noise (the same SSR-honesty rule as\n * CountUp). The decode runs client-side only, once, when triggered;\n * `prefers-reduced-motion` skips it entirely.\n *\n * ## API parity (R17)\n *\n * `trigger` is an enum (R8: more than two plausible values) mirroring\n * common in-view/interaction reveal APIs: `\"visible\"`\n * (IntersectionObserver, once — the grid-entrance feel) or `\"hover\"`\n * (self pointer-enter, re-armable). Duration is capped short (600ms) —\n * a label, not a scene.\n *\n * Motion driver is rAF, so the gate is `useReducedMotion` (the CSS clamp\n * in page/preflight.css cannot reach JS-driven motion).\n */\nexport interface DecodeTextProps\n  extends Omit<React.ComponentPropsWithoutRef<'span'>, 'children'> {\n  /** Stable selector for E2E tests; consumer provides — no default (R5). */\n  'data-testid': string;\n  /** The final text. Plain string only — the decode is per-character. */\n  children: string;\n  /**\n   * What starts the decode.\n   * @default \"visible\"\n   */\n  trigger?: 'visible' | 'hover';\n}\n\nconst GLYPHS = '!<>-_\\\\/[]{}=+*^?#01';\nconst DURATION_MS = 600;\n\nexport function DecodeText({\n  'data-testid': testId,\n  children,\n  trigger = 'visible',\n  className,\n  ...rest\n}: DecodeTextProps) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  const playing = React.useRef(false);\n  const reduceMotion = useReducedMotion();\n\n  // Re-arm when the text changes: React updates the DOM text itself, but\n  // without this a post-decode `children` change would leave `playing`\n  // latched and a later hover-trigger play() dead. (For `visible` the\n  // observer has already disconnected, so old text never re-decodes.)\n  React.useEffect(() => {\n    playing.current = false;\n  }, [children]);\n\n  const play = React.useCallback(() => {\n    const el = ref.current;\n    if (!el || playing.current || reduceMotion) return;\n    playing.current = true;\n    const start = performance.now();\n    const step = (now: number) => {\n      const t = Math.min((now - start) / DURATION_MS, 1);\n      const resolved = Math.floor(t * children.length);\n      let out = children.slice(0, resolved);\n      for (let i = resolved; i < children.length; i++) {\n        out +=\n          children[i] === ' '\n            ? ' '\n            : GLYPHS[(i * 7 + Math.floor(now / 50)) % GLYPHS.length];\n      }\n      el.textContent = out;\n      if (t < 1) {\n        requestAnimationFrame(step);\n      } else {\n        el.textContent = children;\n        if (trigger === 'hover') playing.current = false;\n      }\n    };\n    requestAnimationFrame(step);\n  }, [children, trigger, reduceMotion]);\n\n  React.useEffect(() => {\n    if (trigger !== 'visible' || !ref.current) return;\n    const observer = new IntersectionObserver(\n      ([entry]) => {\n        if (entry.isIntersecting) {\n          play();\n          observer.disconnect();\n        }\n      },\n      { threshold: 0.5 },\n    );\n    observer.observe(ref.current);\n    return () => observer.disconnect();\n  }, [trigger, play]);\n\n  return (\n    <span\n      ref={ref}\n      data-slot=\"decode-text\"\n      data-testid={testId}\n      onMouseEnter={trigger === 'hover' ? play : undefined}\n      className={cn('inline-block', className)}\n      {...rest}\n    >\n      {/* Always the FINAL text: what crawlers and JS-off visitors keep.\n          The decode rewrites textContent client-side only. */}\n      {children}\n    </span>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "effect",
    "client": true,
    "minViewport": null,
    "loading": false,
    "version": "2.0.0",
    "since": null
  },
  "docs": "## @interlace/decode-text\n\nInstalled to `components/ui/effects/decode-text.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/effects/decode-text';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/decode-text\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
