{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ascii-decode-text",
  "title": "ASCII Decode Text",
  "description": "A headline that first appears as ASCII art of its own letter shapes, then a decode front sweeps across and condenses the art into real, crisp, selectable type. After decoding, a pointer lens re-encodes the text under it and heals behind.",
  "dependencies": [
    "@rexa-developer/tiks",
    "web-haptics"
  ],
  "files": [
    {
      "path": "src/registry/components/ascii-decode-text/ascii-decode-text.tsx",
      "content": "\"use client\";\n\nimport { useTiks } from \"@rexa-developer/tiks/react\";\nimport {\n\ttype ComponentProps,\n\ttype PointerEvent,\n\ttype Ref,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseLayoutEffect,\n\tuseRef,\n\tuseState,\n\tuseSyncExternalStore,\n} from \"react\";\nimport { useWebHaptics } from \"web-haptics/react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst DEFAULT_RAMP = \" .:-=+*#%@\";\nconst REDUCED_MOTION_QUERY = \"(prefers-reduced-motion: reduce)\";\n\n/** Width of the soft edge on the text reveal, in px. */\nconst EDGE_PX = 14;\n/** Ms each cell takes to fade once the front reaches it. */\nconst CELL_FADE_MS = 70;\n/** Ms a cell flickers through neighbouring ramp characters before it resolves. */\nconst FLICKER_MS = 140;\n/** Ms each flicker character holds. */\nconst FLICKER_STEP_MS = 70;\n/** Spread of the per-cell decode time, in ms. */\nconst JITTER_MS = 70;\n/** Ms of flicker on the first cells before the front starts moving. */\nconst LEAD_MS = 100;\n/** A re-encode runs at this fraction of `duration`. */\nconst ENCODE_SPEED = 0.6;\n/** Cross-fade length under reduced motion, in ms. */\nconst FADE_MS = 240;\n/** Ms the lens takes to open where the pointer arrives. */\nconst LENS_IN_MS = 140;\n/** Ms the lens takes to heal behind the pointer. */\nconst HEAL_MS = 300;\n/** Most trail points kept for the healing lens. */\nconst MAX_TRAIL = 16;\n/** Inner part of the lens, as a fraction of its radius, that is fully encoded. */\nconst LENS_CORE = 0.7;\n/** Touch moves this far, mostly sideways, before the lens starts. */\nconst TOUCH_SLOP_PX = 6;\n/** Minimum ms between type ticks, and the most ticks per decode. */\nconst TICK_THROTTLE_MS = 35;\nconst MAX_TICKS = 24;\n/** Canvas backing store limit, in device px per CSS px. */\nconst MAX_BACKING_SCALE = 2;\n/** Raster samples per cell height when measuring glyph coverage. */\nconst SAMPLES_PER_CELL = 8;\n/**\n * Smallest cell height in CSS px, so small text stays legible as ASCII\n * rather than stipple. It never drops below 4 cells per cap height.\n */\nconst MIN_CELL_PX = 3.5;\n/** Monospace cell width as a fraction of its height. */\nconst CELL_ASPECT = 0.62;\n/**\n * Art glyph size as a fraction of the cell height, so the characters fill\n * their rows and the letters read as solid shapes, not stripes.\n */\nconst GLYPH_SCALE = 1.05;\n/** At most this fraction of empty cells get a dust character. */\nconst DUST_FRACTION = 0.06;\nconst DUST_ALPHA = 0.25;\n\n// A very soft, high, short tick, like a key on a quiet keyboard.\nconst TYPE_SOUND = {\n\tname: \"ascii-decode-text-type\",\n\tbaseFreq: 1900,\n\tnoiseColor: \"white\",\n\toscType: \"triangle\",\n\tfilterFreq: 4800,\n\tfilterQ: 2,\n\tattack: 0.001,\n\tdecay: 0.35,\n\tbrightness: 5200,\n} as const;\n\n/** Ink opacity at the lightest and the densest cell. */\nconst tones = {\n\tdefault: [0.72, 1],\n\tmuted: [0.5, 0.6],\n} as const;\n\n/**\n * Light glyphs on a dark ground read heavier and glare, so dark themes get\n * a lighter weight and slightly less ink rather than a straight inversion.\n */\nconst inks = {\n\tlight: { weight: 500, scale: 1 },\n\tdark: { weight: 400, scale: 0.9 },\n} as const;\n\n/** Display type: leading opens up and tracking tightens as the size grows. */\nconst sizes = {\n\tsm: \"text-2xl leading-[1.2] tracking-[-0.02em]\",\n\tmd: \"text-4xl leading-[1.1] tracking-[-0.025em]\",\n\tlg: \"text-4xl leading-[1.1] tracking-[-0.025em] sm:text-5xl sm:leading-[1.05] sm:tracking-[-0.03em]\",\n\txl: \"text-5xl leading-[1.05] tracking-[-0.03em] sm:text-6xl sm:tracking-[-0.035em]\",\n} as const;\n\nexport type AsciiDecodeTextTrigger = \"mount\" | \"view\" | \"hover\" | \"manual\";\nexport type AsciiDecodeTextDirection = \"ltr\" | \"rtl\" | \"center\" | \"random\";\ntype Phase = \"encoded\" | \"decoding\" | \"decoded\" | \"encoding\";\n\nfunction clamp(value: number, min: number, max: number) {\n\treturn Math.min(Math.max(value, min), max);\n}\n\n/** A stable 0-1 hash of two integers, so jitter and flicker are the same on every replay. */\nfunction hash(a: number, b: number) {\n\tlet h = Math.imul(a ^ 0x9e3779b9, 0x85ebca6b) ^ Math.imul(b, 0xc2b2ae35);\n\th = Math.imul(h ^ (h >>> 15), 0x2c1b3c6d);\n\th = Math.imul(h ^ (h >>> 12), 0x297a2d39);\n\treturn ((h ^ (h >>> 15)) >>> 0) / 4294967296;\n}\n\nfunction smoothstep(t: number) {\n\tconst x = clamp(t, 0, 1);\n\treturn x * x * (3 - 2 * x);\n}\n\n/** The sweep's ease: a calm start and a soft landing, with no overshoot. */\nfunction easeInOutSine(t: number) {\n\treturn (1 - Math.cos(Math.PI * clamp(t, 0, 1))) / 2;\n}\n\n/** The inverse of `easeInOutSine`: when the front reaches progress `p`. */\nfunction easeInOutSineInverse(p: number) {\n\treturn Math.acos(1 - 2 * clamp(p, 0, 1)) / Math.PI;\n}\n\nfunction easeOutCubic(t: number) {\n\treturn 1 - (1 - clamp(t, 0, 1)) ** 3;\n}\n\n/** Whether a CSS colour is light, i.e. the text sits on a dark theme. */\nfunction isLightColor(color: string) {\n\tconst ctx = document.createElement(\"canvas\").getContext(\"2d\", {\n\t\twillReadFrequently: true,\n\t});\n\tif (!ctx) return false;\n\tctx.fillStyle = color;\n\tctx.fillRect(0, 0, 1, 1);\n\tconst [r = 0, g = 0, b = 0] = ctx.getImageData(0, 0, 1, 1).data;\n\treturn 0.2126 * r + 0.7152 * g + 0.0722 * b > 140;\n}\n\nfunction subscribeToReducedMotion(onStoreChange: () => void) {\n\tconst mediaQuery = window.matchMedia(REDUCED_MOTION_QUERY);\n\tmediaQuery.addEventListener(\"change\", onStoreChange);\n\treturn () => mediaQuery.removeEventListener(\"change\", onStoreChange);\n}\n\nfunction usePrefersReducedMotion() {\n\treturn useSyncExternalStore(\n\t\tsubscribeToReducedMotion,\n\t\t() => window.matchMedia(REDUCED_MOTION_QUERY).matches,\n\t\t() => false,\n\t);\n}\n\nfunction applyTextTransform(text: string, transform: string) {\n\tif (transform === \"uppercase\") return text.toLocaleUpperCase();\n\tif (transform === \"lowercase\") return text.toLocaleLowerCase();\n\tif (transform === \"capitalize\") {\n\t\treturn text.replace(/(^|\\s)(\\S)/g, (_, space, char) =>\n\t\t\t`${space}${char}`.toLocaleUpperCase(),\n\t\t);\n\t}\n\treturn text;\n}\n\nfunction pxValue(value: string) {\n\tconst number = Number.parseFloat(value);\n\treturn Number.isFinite(number) ? number : 0;\n}\n\ninterface Line {\n\t/** The line's text in logical order, without the spaces at the wrap. */\n\ttext: string;\n\tleft: number;\n\tright: number;\n\ttop: number;\n\theight: number;\n\t/** Horizontal centre of each letter, for the type ticks. */\n\tletters: number[];\n}\n\ninterface PendingLine extends Line {\n\tnode: Text;\n\tstart: number;\n\tend: number;\n}\n\n/** Graphemes with their offsets, so emoji and combining marks stay whole. */\nfunction segmentText(data: string) {\n\tif (typeof Intl !== \"undefined\" && \"Segmenter\" in Intl) {\n\t\tconst segmenter = new Intl.Segmenter(undefined, {\n\t\t\tgranularity: \"grapheme\",\n\t\t});\n\t\treturn Array.from(segmenter.segment(data), (part) => ({\n\t\t\tindex: part.index,\n\t\t\tvalue: part.segment,\n\t\t}));\n\t}\n\tconst parts: { index: number; value: string }[] = [];\n\tlet index = 0;\n\tfor (const value of data) {\n\t\tparts.push({ index, value });\n\t\tindex += value.length;\n\t}\n\treturn parts;\n}\n\n/**\n * Reads the line boxes of the rendered text, in the root's layout px. Each\n * grapheme is measured with a Range, so wrapping, bidi, and letter-spacing\n * come from the browser rather than a re-layout.\n */\nfunction measureLines(\n\ttextElement: HTMLElement,\n\ttoLocal: (x: number, y: number) => { x: number; y: number },\n\tzoom: number,\n) {\n\tconst lines: Line[] = [];\n\tconst range = document.createRange();\n\tconst walker = document.createTreeWalker(textElement, NodeFilter.SHOW_TEXT);\n\tlet pending = null as PendingLine | null;\n\tconst flush = (line: PendingLine | null) => {\n\t\tif (line && line.right > line.left) {\n\t\t\tlines.push({\n\t\t\t\ttext: line.node.data.slice(line.start, line.end),\n\t\t\t\tleft: line.left,\n\t\t\t\tright: line.right,\n\t\t\t\ttop: line.top,\n\t\t\t\theight: line.height,\n\t\t\t\tletters: line.letters,\n\t\t\t});\n\t\t}\n\t};\n\tfor (let node = walker.nextNode(); node; node = walker.nextNode()) {\n\t\tconst text = node as Text;\n\t\tfor (const segment of segmentText(text.data)) {\n\t\t\tif (/^\\s+$/.test(segment.value)) continue;\n\t\t\trange.setStart(text, segment.index);\n\t\t\trange.setEnd(text, segment.index + segment.value.length);\n\t\t\tlet rect: DOMRect | null = null;\n\t\t\tfor (const candidate of range.getClientRects()) {\n\t\t\t\tif (!rect || candidate.width > rect.width) rect = candidate;\n\t\t\t}\n\t\t\tif (!rect || rect.height === 0) continue;\n\t\t\tconst corner = toLocal(rect.left, rect.top);\n\t\t\tconst width = rect.width / zoom;\n\t\t\tconst height = rect.height / zoom;\n\t\t\tconst end = segment.index + segment.value.length;\n\t\t\tconst line: PendingLine | null = pending;\n\t\t\tif (\n\t\t\t\tline &&\n\t\t\t\tline.node === text &&\n\t\t\t\tMath.abs(corner.y - line.top) <= line.height * 0.5\n\t\t\t) {\n\t\t\t\tline.left = Math.min(line.left, corner.x);\n\t\t\t\tline.right = Math.max(line.right, corner.x + width);\n\t\t\t\tline.end = end;\n\t\t\t\tline.letters.push(corner.x + width / 2);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tflush(line);\n\t\t\tpending = {\n\t\t\t\ttext: \"\",\n\t\t\t\tleft: corner.x,\n\t\t\t\tright: corner.x + width,\n\t\t\t\ttop: corner.y,\n\t\t\t\theight,\n\t\t\t\tletters: [corner.x + width / 2],\n\t\t\t\tnode: text,\n\t\t\t\tstart: segment.index,\n\t\t\t\tend,\n\t\t\t};\n\t\t}\n\t}\n\tflush(pending);\n\trange.detach();\n\treturn lines;\n}\n\ninterface Grid {\n\t/** Canvas box in the root's layout px, and its backing scale. */\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n\tscale: number;\n\t/** Cell size in backing px. */\n\tcellWidth: number;\n\tcellHeight: number;\n\t/** The text element's offset in the root, for mask coordinates. */\n\ttextLeft: number;\n\ttextTop: number;\n\ttextWidth: number;\n\tcount: number;\n\tcol: Uint16Array;\n\trow: Uint16Array;\n\tglyph: Uint8Array;\n\tink: Float32Array;\n\t/** Distance from where the front starts, in px. */\n\tdistance: Float32Array;\n\tjitter: Float32Array;\n\tseed: Float32Array;\n\t/** The front's full travel, in px. */\n\tspan: number;\n\t/** Front distance sampled across the text box every `MASK_STEP` px. */\n\tmaskDistance: Float32Array;\n\t/** Front distance of each letter, sorted, for the type ticks. */\n\tletters: Float32Array;\n\t/** Line boxes of the real text, for the lens cursor. */\n\tlines: Line[];\n\tatlas: HTMLCanvasElement;\n\tcolor: string;\n\t/** Ink for the current text colour: lighter on dark themes. */\n\ttint: (typeof inks)[keyof typeof inks];\n\tglyphs: string[];\n\tmonoFamily: string;\n\tfontSize: number;\n}\n\nconst MASK_STEP = 3;\n\ninterface EngineOptions {\n\ttext: string;\n\tdirection: AsciiDecodeTextDirection;\n\tduration: number;\n\tdensity: number;\n\tramp: string;\n\ttone: keyof typeof tones;\n\tdust: boolean;\n\tlens: boolean;\n\tlensRadius?: number;\n\ttrigger: AsciiDecodeTextTrigger;\n\treducedMotion: boolean;\n\tsound: boolean;\n\thaptics: boolean;\n}\n\ninterface EngineCallbacks {\n\tonPhase: (phase: Phase) => void;\n\tonDecoded: () => void;\n\tonTick: () => void;\n\tonHaptic: () => void;\n}\n\ninterface Animation {\n\tkind: \"decode\" | \"encode\";\n\tfade: boolean;\n\tstart: number | null;\n\ttotal: number;\n\tlead: number;\n\tsweep: number;\n\tnext: \"decode\" | null;\n\tnextLetter: number;\n\tticks: number;\n\tlastTickAt: number;\n}\n\ninterface TrailPoint {\n\tx: number;\n\ty: number;\n\t/** Radius when the point was left behind, and when that was. */\n\tr: number;\n\tt: number;\n}\n\ninterface LensHead {\n\tx: number;\n\ty: number;\n\t/** When the lens opened, so it grows in rather than popping. */\n\tsince: number;\n}\n\nfunction createCanvas(width: number, height: number) {\n\tconst canvas = document.createElement(\"canvas\");\n\tcanvas.width = Math.max(1, width);\n\tcanvas.height = Math.max(1, height);\n\treturn canvas;\n}\n\n/**\n * Owns the canvas, the text mask, and the frame loop. The component creates\n * one per mount and passes it new options on every render.\n */\nclass DecodeEngine {\n\tprivate root: HTMLElement;\n\tprivate textElement: HTMLElement;\n\tprivate canvas: HTMLCanvasElement;\n\tprivate options: EngineOptions;\n\tprivate callbacks: EngineCallbacks;\n\tphase: Phase;\n\tprivate grid: Grid | null = null;\n\tprivate dirty = true;\n\tprivate animation: Animation | null = null;\n\tprivate trail: TrailPoint[] = [];\n\tprivate head: LensHead | null = null;\n\t/** Last mouse or pen position over the root, so the lens can open on decode. */\n\tprivate hover: { x: number; y: number } | null = null;\n\tprivate cursorHidden = false;\n\tprivate touch: { id: number; x: number; y: number; active: boolean } | null =\n\t\tnull;\n\tprivate frame = 0;\n\tprivate resizeFrame = 0;\n\tprivate visible = true;\n\tprivate viewed = false;\n\tprivate destroyed = false;\n\tprivate painted = false;\n\tprivate pendingDecode = false;\n\tprivate fontsReady = false;\n\tprivate cleanups: (() => void)[] = [];\n\n\tconstructor(\n\t\troot: HTMLElement,\n\t\ttextElement: HTMLElement,\n\t\tcanvas: HTMLCanvasElement,\n\t\toptions: EngineOptions,\n\t\tcallbacks: EngineCallbacks,\n\t\tphase: Phase,\n\t) {\n\t\tthis.root = root;\n\t\tthis.textElement = textElement;\n\t\tthis.canvas = canvas;\n\t\tthis.options = options;\n\t\tthis.callbacks = callbacks;\n\t\tthis.phase = phase;\n\t\tif (phase === \"encoded\") this.setMask(\"linear-gradient(#0000, #0000)\");\n\n\t\tconst resize = new ResizeObserver(() => {\n\t\t\tif (this.resizeFrame) return;\n\t\t\tthis.resizeFrame = requestAnimationFrame(() => {\n\t\t\t\tthis.resizeFrame = 0;\n\t\t\t\tthis.invalidate();\n\t\t\t});\n\t\t});\n\t\tresize.observe(root);\n\t\tconst intersection = new IntersectionObserver(\n\t\t\t([entry]) => {\n\t\t\t\tif (!entry) return;\n\t\t\t\tthis.visible = entry.isIntersecting;\n\t\t\t\tif (entry.intersectionRatio >= 0.4) this.onView();\n\t\t\t},\n\t\t\t{ threshold: [0, 0.4] },\n\t\t);\n\t\tintersection.observe(root);\n\t\t// The art is painted in the text colour, so repaint on a theme switch.\n\t\tconst theme = new MutationObserver(() => this.onThemeChange());\n\t\ttheme.observe(document.documentElement, {\n\t\t\tattributes: true,\n\t\t\tattributeFilter: [\"class\", \"style\", \"data-theme\"],\n\t\t});\n\t\tconst onFonts = () => this.invalidate();\n\t\tdocument.fonts?.addEventListener(\"loadingdone\", onFonts);\n\t\tthis.cleanups.push(\n\t\t\t() => resize.disconnect(),\n\t\t\t() => intersection.disconnect(),\n\t\t\t() => theme.disconnect(),\n\t\t\t() => document.fonts?.removeEventListener(\"loadingdone\", onFonts),\n\t\t);\n\n\t\tconst ready = () => {\n\t\t\tif (this.destroyed) return;\n\t\t\tthis.fontsReady = true;\n\t\t\tthis.invalidate();\n\t\t\tif (this.options.trigger === \"mount\" || this.pendingDecode) {\n\t\t\t\tthis.pendingDecode = false;\n\t\t\t\tthis.decode();\n\t\t\t}\n\t\t};\n\t\tif (!document.fonts || document.fonts.status === \"loaded\") ready();\n\t\telse void document.fonts.ready.then(ready);\n\t\tif (this.phase === \"encoded\") this.paintStatic();\n\t}\n\n\tdestroy() {\n\t\tthis.destroyed = true;\n\t\tthis.setCursorHidden(false);\n\t\tcancelAnimationFrame(this.frame);\n\t\tcancelAnimationFrame(this.resizeFrame);\n\t\tfor (const cleanup of this.cleanups) cleanup();\n\t}\n\n\tsetOptions(options: EngineOptions) {\n\t\tconst previous = this.options;\n\t\tthis.options = options;\n\t\tif (\n\t\t\tprevious.text !== options.text ||\n\t\t\tprevious.density !== options.density ||\n\t\t\tprevious.ramp !== options.ramp ||\n\t\t\tprevious.tone !== options.tone ||\n\t\t\tprevious.dust !== options.dust ||\n\t\t\tprevious.direction !== options.direction\n\t\t) {\n\t\t\tthis.invalidate();\n\t\t}\n\t\tif (!this.lensEnabled() && (this.head || this.trail.length)) {\n\t\t\tthis.head = null;\n\t\t\tthis.trail = [];\n\t\t\tthis.setCursorHidden(false);\n\t\t\tthis.paintLens(performance.now());\n\t\t}\n\t}\n\n\t// ── State ────────────────────────────────────────────────────────────\n\n\tprivate setPhase(phase: Phase) {\n\t\tif (this.phase === phase) return;\n\t\tthis.phase = phase;\n\t\tthis.root.dataset.state = phase;\n\t\tthis.callbacks.onPhase(phase);\n\t}\n\n\tprivate onView() {\n\t\tif (this.viewed || this.options.trigger !== \"view\") return;\n\t\tthis.viewed = true;\n\t\tif (this.phase === \"encoded\") this.decode();\n\t}\n\n\tdecode() {\n\t\tif (!this.fontsReady) {\n\t\t\tthis.pendingDecode = true;\n\t\t\treturn;\n\t\t}\n\t\tif (this.phase === \"decoded\" || this.phase === \"decoding\") return;\n\t\tthis.start(\"decode\", null);\n\t}\n\n\tencode(next: \"decode\" | null = null) {\n\t\tthis.pendingDecode = false;\n\t\tif (this.phase === \"encoded\") {\n\t\t\tif (next) this.decode();\n\t\t\treturn;\n\t\t}\n\t\tif (this.phase === \"encoding\") {\n\t\t\tif (this.animation) this.animation.next = next;\n\t\t\treturn;\n\t\t}\n\t\tthis.start(\"encode\", next);\n\t}\n\n\t/** Re-encodes quickly, then decodes again. */\n\treplay() {\n\t\tif (this.phase === \"encoded\") this.decode();\n\t\telse this.encode(\"decode\");\n\t}\n\n\tprivate start(kind: \"decode\" | \"encode\", next: \"decode\" | null) {\n\t\tthis.head = null;\n\t\tthis.trail = [];\n\t\tthis.setCursorHidden(false);\n\t\tconst grid = this.ensureGrid();\n\t\tconst fade = this.options.reducedMotion;\n\t\tif (!grid) {\n\t\t\t// Nothing to draw (no size yet): land on the end state.\n\t\t\tif (kind === \"decode\") this.finishDecoded(true);\n\t\t\telse this.finishEncoded();\n\t\t\treturn;\n\t\t}\n\t\tthis.refreshColor(grid);\n\t\tconst duration = clamp(this.options.duration, 200, 10000);\n\t\tlet total = FADE_MS;\n\t\tlet lead = 0;\n\t\tlet sweep = FADE_MS;\n\t\tif (!fade && kind === \"decode\") {\n\t\t\ttotal = duration;\n\t\t\tlead = LEAD_MS;\n\t\t\tsweep = Math.max(duration - LEAD_MS - CELL_FADE_MS - JITTER_MS / 2, 150);\n\t\t} else if (!fade) {\n\t\t\ttotal = Math.round(duration * ENCODE_SPEED);\n\t\t\tsweep = Math.max(total - CELL_FADE_MS - FLICKER_MS - JITTER_MS / 2, 120);\n\t\t}\n\t\tthis.animation = {\n\t\t\tkind,\n\t\t\tfade,\n\t\t\tstart: null,\n\t\t\ttotal,\n\t\t\tlead,\n\t\t\tsweep,\n\t\t\tnext,\n\t\t\tnextLetter: 0,\n\t\t\tticks: 0,\n\t\t\tlastTickAt: Number.NEGATIVE_INFINITY,\n\t\t};\n\t\tthis.setPhase(kind === \"decode\" ? \"decoding\" : \"encoding\");\n\t\tthis.wake();\n\t}\n\n\tprivate finishDecoded(notify: boolean) {\n\t\tthis.animation = null;\n\t\tthis.setMask(null);\n\t\tthis.clearCanvas();\n\t\tthis.setPhase(\"decoded\");\n\t\tif (notify) this.callbacks.onDecoded();\n\t\t// The pointer is already resting on the text: open the lens under it.\n\t\tif (this.hover && this.lensReady()) {\n\t\t\tthis.moveLens(this.hover.x, this.hover.y, true);\n\t\t}\n\t}\n\n\tprivate finishEncoded() {\n\t\tconst next = this.animation?.next ?? null;\n\t\tthis.animation = null;\n\t\tthis.setMask(\"linear-gradient(#0000, #0000)\");\n\t\tthis.setPhase(\"encoded\");\n\t\tthis.paintStatic();\n\t\tif (next) this.decode();\n\t}\n\n\t// ── Frame loop ───────────────────────────────────────────────────────\n\n\tprivate wake() {\n\t\tif (this.frame || this.destroyed) return;\n\t\tthis.frame = requestAnimationFrame((now) => this.tick(now));\n\t}\n\n\tprivate tick(now: number) {\n\t\tthis.frame = 0;\n\t\tconst animation = this.animation;\n\t\tif (animation) {\n\t\t\tif (animation.start === null) animation.start = now;\n\t\t\tconst elapsed = now - animation.start;\n\t\t\t// Offscreen or in a hidden tab, skip straight to the end.\n\t\t\tif (!this.visible || document.hidden || elapsed >= animation.total) {\n\t\t\t\tif (animation.kind === \"decode\") this.finishDecoded(true);\n\t\t\t\telse this.finishEncoded();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.paintAnimation(animation, elapsed, now);\n\t\t\tthis.wake();\n\t\t\treturn;\n\t\t}\n\t\tif (this.head || this.trail.length) {\n\t\t\tthis.paintLens(now);\n\t\t\tconst opening = this.head && now - this.head.since < LENS_IN_MS;\n\t\t\tif (this.trail.length || opening) this.wake();\n\t\t}\n\t}\n\n\t// ── Rasterising ──────────────────────────────────────────────────────\n\n\t/** Marks the art stale and repaints it if it is on screen. */\n\tprivate invalidate() {\n\t\tthis.dirty = true;\n\t\tif (this.destroyed) return;\n\t\tif (this.phase === \"encoded\") this.paintStatic();\n\t\telse if (this.animation || this.head || this.trail.length) {\n\t\t\tthis.ensureGrid();\n\t\t\tthis.wake();\n\t\t}\n\t}\n\n\tprivate onThemeChange() {\n\t\tconst grid = this.grid;\n\t\tif (!grid || this.dirty) return;\n\t\tconst color = getComputedStyle(this.root).color;\n\t\tif (color === grid.color) return;\n\t\tthis.refreshColor(grid);\n\t\tif (this.phase === \"encoded\") this.paintStatic();\n\t}\n\n\tprivate refreshColor(grid: Grid) {\n\t\tconst color = getComputedStyle(this.root).color;\n\t\tif (color === grid.color) return;\n\t\tgrid.color = color;\n\t\tgrid.tint = isLightColor(color) ? inks.dark : inks.light;\n\t\tgrid.atlas = this.buildAtlas(grid);\n\t}\n\n\tprivate ensureGrid() {\n\t\tif (this.dirty || !this.grid) {\n\t\t\tthis.grid = this.rasterise();\n\t\t\tthis.dirty = false;\n\t\t}\n\t\treturn this.grid;\n\t}\n\n\tprivate toLocalFactory() {\n\t\tconst rect = this.root.getBoundingClientRect();\n\t\tconst zoom = this.root.offsetWidth ? rect.width / this.root.offsetWidth : 1;\n\t\tconst toLocal = (x: number, y: number) => ({\n\t\t\tx: (x - rect.left) / (zoom || 1),\n\t\t\ty: (y - rect.top) / (zoom || 1),\n\t\t});\n\t\treturn { rect, zoom: zoom || 1, toLocal };\n\t}\n\n\tprivate buildAtlas(grid: Grid) {\n\t\tconst atlas = createCanvas(\n\t\t\tgrid.cellWidth * grid.glyphs.length,\n\t\t\tgrid.cellHeight,\n\t\t);\n\t\tconst ctx = atlas.getContext(\"2d\");\n\t\tif (!ctx) return atlas;\n\t\tctx.font = this.atlasFont(grid);\n\t\tctx.textAlign = \"center\";\n\t\tctx.textBaseline = \"alphabetic\";\n\t\tctx.fillStyle = grid.color;\n\t\t// Centre the cap height in the cell, on whole pixels, so every row of\n\t\t// characters shares one optical middle and stays crisp.\n\t\tconst cap =\n\t\t\tctx.measureText(\"H\").actualBoundingBoxAscent || grid.cellHeight * 0.7;\n\t\tconst baseline = Math.round((grid.cellHeight + cap) / 2);\n\t\tconst middle = Math.round(grid.cellWidth / 2);\n\t\tgrid.glyphs.forEach((glyph, index) => {\n\t\t\tctx.fillText(glyph, index * grid.cellWidth + middle, baseline);\n\t\t});\n\t\treturn atlas;\n\t}\n\n\tprivate atlasFont(grid: Grid) {\n\t\tconst size = Math.round(grid.cellHeight * GLYPH_SCALE);\n\t\treturn `${grid.tint.weight} ${size}px ${grid.monoFamily}`;\n\t}\n\n\t/**\n\t * Draws the real text into an offscreen canvas at its measured line\n\t * boxes, then maps the ink in each cell to a ramp character.\n\t */\n\tprivate rasterise(): Grid | null {\n\t\tconst { root, textElement, options } = this;\n\t\tconst width = root.offsetWidth;\n\t\tconst height = root.offsetHeight;\n\t\tif (!width || !height) return null;\n\t\tconst style = getComputedStyle(textElement);\n\t\tconst { rect, zoom, toLocal } = this.toLocalFactory();\n\t\tconst lines = measureLines(textElement, toLocal, zoom);\n\t\tif (!lines.length) return null;\n\n\t\tconst fontSize = pxValue(style.fontSize);\n\t\tconst font = `${style.fontStyle} ${style.fontWeight} ${style.fontSize} ${style.fontFamily}`;\n\t\tconst measure = createCanvas(1, 1).getContext(\"2d\");\n\t\tif (!measure) return null;\n\t\tmeasure.font = font;\n\t\tconst capHeight =\n\t\t\tmeasure.measureText(\"H\").actualBoundingBoxAscent || fontSize * 0.7;\n\n\t\tconst deviceScale = window.devicePixelRatio * zoom;\n\t\tconst scale = clamp(deviceScale, 1, MAX_BACKING_SCALE);\n\t\tconst density = clamp(options.density, 4, 12);\n\t\tconst cellCss = Math.max(\n\t\t\tcapHeight / density,\n\t\t\tMath.min(MIN_CELL_PX, capHeight / 4),\n\t\t);\n\t\tconst cellHeight = Math.max(3, Math.round(cellCss * scale));\n\t\tconst cellWidth = Math.max(2, Math.round(cellHeight * CELL_ASPECT));\n\n\t\t// Bleed a little above and below for accents and descenders, and\n\t\t// line the canvas up with whole device pixels.\n\t\tconst bleed = Math.round(fontSize * 0.2);\n\t\tconst fractionX = (rect.left * window.devicePixelRatio) % 1;\n\t\tconst fractionY = (rect.top * window.devicePixelRatio) % 1;\n\t\tconst left = -fractionX / deviceScale;\n\t\tconst top = -bleed - fractionY / deviceScale;\n\t\tconst columns = Math.ceil((width * scale) / cellWidth);\n\t\tconst rows = Math.ceil(((height + bleed * 2) * scale) / cellHeight);\n\t\tconst canvasWidth = (columns * cellWidth) / scale;\n\t\tconst canvasHeight = (rows * cellHeight) / scale;\n\n\t\t// Coverage raster: SAMPLES_PER_CELL samples down each cell.\n\t\tconst sampleScale = SAMPLES_PER_CELL / (cellHeight / scale);\n\t\tconst rasterWidth = Math.ceil(canvasWidth * sampleScale);\n\t\tconst rasterHeight = Math.ceil(canvasHeight * sampleScale);\n\t\tconst raster = createCanvas(rasterWidth, rasterHeight);\n\t\tconst ctx = raster.getContext(\"2d\", { willReadFrequently: true });\n\t\tif (!ctx) return null;\n\t\tctx.font = font;\n\t\tctx.fillStyle = \"#fff\";\n\t\tctx.textBaseline = \"alphabetic\";\n\t\tctx.textAlign = \"left\";\n\t\tctx.direction = style.direction === \"rtl\" ? \"rtl\" : \"ltr\";\n\t\tctx.letterSpacing = `${pxValue(style.letterSpacing)}px`;\n\t\tctx.wordSpacing = `${pxValue(style.wordSpacing)}px`;\n\t\tctx.fontKerning = style.fontKerning === \"none\" ? \"none\" : \"normal\";\n\t\tconst metrics = ctx.measureText(\"Hg\");\n\t\tconst ascent = metrics.fontBoundingBoxAscent || fontSize * 0.9;\n\t\tconst descent = metrics.fontBoundingBoxDescent || fontSize * 0.25;\n\t\tfor (const line of lines) {\n\t\t\tconst text = applyTextTransform(line.text, style.textTransform);\n\t\t\tconst measured = ctx.measureText(text).width;\n\t\t\tconst target = line.right - line.left;\n\t\t\tconst fit = measured > 0 ? clamp(target / measured, 0.9, 1.1) : 1;\n\t\t\tconst baseline =\n\t\t\t\tline.top + (line.height - (ascent + descent)) / 2 + ascent;\n\t\t\tctx.setTransform(\n\t\t\t\tsampleScale * fit,\n\t\t\t\t0,\n\t\t\t\t0,\n\t\t\t\tsampleScale,\n\t\t\t\t(line.left - left) * sampleScale,\n\t\t\t\t(baseline - top) * sampleScale,\n\t\t\t);\n\t\t\tctx.fillText(text, 0, 0);\n\t\t}\n\t\tconst pixels = ctx.getImageData(0, 0, rasterWidth, rasterHeight).data;\n\n\t\tconst cellCount = columns * rows;\n\t\tconst sums = new Float32Array(cellCount);\n\t\tconst counts = new Uint16Array(cellCount);\n\t\tconst columnOf = new Uint16Array(rasterWidth);\n\t\tconst cellCssWidth = cellWidth / scale;\n\t\tconst cellCssHeight = cellHeight / scale;\n\t\tfor (let x = 0; x < rasterWidth; x++) {\n\t\t\tcolumnOf[x] = Math.min(\n\t\t\t\tcolumns - 1,\n\t\t\t\tMath.floor(x / sampleScale / cellCssWidth),\n\t\t\t);\n\t\t}\n\t\tfor (let y = 0; y < rasterHeight; y++) {\n\t\t\tconst rowIndex = Math.min(\n\t\t\t\trows - 1,\n\t\t\t\tMath.floor(y / sampleScale / cellCssHeight),\n\t\t\t);\n\t\t\tconst rowOffset = rowIndex * columns;\n\t\t\tconst pixelRow = y * rasterWidth * 4;\n\t\t\tfor (let x = 0; x < rasterWidth; x++) {\n\t\t\t\tconst cell = rowOffset + columnOf[x];\n\t\t\t\tsums[cell] += pixels[pixelRow + x * 4 + 3];\n\t\t\t\tcounts[cell]++;\n\t\t\t}\n\t\t}\n\n\t\t// Front distance for any x, per direction. \"ltr\" means from the start\n\t\t// of the line, so it runs from the right in RTL text.\n\t\tconst inkLeft = Math.min(...lines.map((line) => line.left));\n\t\tconst inkRight = Math.max(...lines.map((line) => line.right));\n\t\tconst inkWidth = Math.max(inkRight - inkLeft, 1);\n\t\tconst rtl = style.direction === \"rtl\";\n\t\tconst direction =\n\t\t\trtl && options.direction === \"ltr\"\n\t\t\t\t? \"rtl\"\n\t\t\t\t: rtl && options.direction === \"rtl\"\n\t\t\t\t\t? \"ltr\"\n\t\t\t\t\t: options.direction;\n\t\tconst noiseStep = Math.max(fontSize * 1.4, 24);\n\t\tconst span =\n\t\t\tdirection === \"center\"\n\t\t\t\t? inkWidth / 2\n\t\t\t\t: direction === \"random\"\n\t\t\t\t\t? inkWidth * 0.5\n\t\t\t\t\t: inkWidth;\n\t\tconst distanceAt = (x: number) => {\n\t\t\tif (direction === \"rtl\") return inkRight - x;\n\t\t\tif (direction === \"center\") return Math.abs(x - (inkLeft + inkRight) / 2);\n\t\t\tif (direction === \"random\") {\n\t\t\t\tconst t = Math.max(x - inkLeft, 0) / noiseStep;\n\t\t\t\tconst index = Math.floor(t);\n\t\t\t\tconst a = hash(index, 7919);\n\t\t\t\tconst b = hash(index + 1, 7919);\n\t\t\t\treturn (a + (b - a) * smoothstep(t - index)) * span;\n\t\t\t}\n\t\t\treturn x - inkLeft;\n\t\t};\n\n\t\tconst glyphs = Array.from(options.ramp || DEFAULT_RAMP);\n\t\tconst levels = glyphs.length - 1;\n\t\tconst [minAlpha, maxAlpha] = tones[options.tone] ?? tones.default;\n\t\tconst lineBands = lines.map((line) => [line.top, line.top + line.height]);\n\t\tconst col: number[] = [];\n\t\tconst row: number[] = [];\n\t\tconst glyph: number[] = [];\n\t\tconst ink: number[] = [];\n\t\tfor (let r = 0; r < rows; r++) {\n\t\t\tconst cy = top + (r + 0.5) * cellCssHeight;\n\t\t\tconst inLine = lineBands.some(([a, b]) => cy >= a && cy <= b);\n\t\t\tfor (let c = 0; c < columns; c++) {\n\t\t\t\tconst cell = r * columns + c;\n\t\t\t\tconst coverage = counts[cell] ? sums[cell] / (counts[cell] * 255) : 0;\n\t\t\t\t// Faint anti-aliased edges drop out, so the letter shapes stay sharp.\n\t\t\t\tconst level = clamp((coverage - 0.08) / 0.8, 0, 1);\n\t\t\t\tconst index = Math.round(level * levels);\n\t\t\t\tif (coverage > 0.14 && index > 0 && glyphs[index] !== \" \") {\n\t\t\t\t\tcol.push(c);\n\t\t\t\t\trow.push(r);\n\t\t\t\t\tglyph.push(index);\n\t\t\t\t\tink.push(minAlpha + (maxAlpha - minAlpha) * level);\n\t\t\t\t} else if (\n\t\t\t\t\toptions.dust &&\n\t\t\t\t\tcoverage === 0 &&\n\t\t\t\t\tinLine &&\n\t\t\t\t\thash(c, r + 4099) < DUST_FRACTION\n\t\t\t\t) {\n\t\t\t\t\tcol.push(c);\n\t\t\t\t\trow.push(r);\n\t\t\t\t\tglyph.push(Math.min(levels, hash(r, c) < 0.6 ? 1 : 2));\n\t\t\t\t\tink.push(DUST_ALPHA);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tconst count = col.length;\n\t\tconst distance = new Float32Array(count);\n\t\tconst jitter = new Float32Array(count);\n\t\tconst seed = new Float32Array(count);\n\t\tfor (let index = 0; index < count; index++) {\n\t\t\tconst cx = left + (col[index] + 0.5) * cellCssWidth;\n\t\t\tdistance[index] = distanceAt(cx);\n\t\t\tjitter[index] = (hash(col[index], row[index]) - 0.5) * JITTER_MS;\n\t\t\tseed[index] = hash(row[index] + 31, col[index] + 17);\n\t\t}\n\n\t\tconst textRect = textElement.getBoundingClientRect();\n\t\tconst textOrigin = toLocal(textRect.left, textRect.top);\n\t\tconst textWidth = textRect.width / zoom;\n\t\tconst maskDistance = new Float32Array(Math.ceil(textWidth / MASK_STEP) + 1);\n\t\tfor (let index = 0; index < maskDistance.length; index++) {\n\t\t\tmaskDistance[index] = distanceAt(textOrigin.x + index * MASK_STEP);\n\t\t}\n\t\tconst letters = Float32Array.from(\n\t\t\tlines.flatMap((line) => line.letters.map(distanceAt)),\n\t\t).sort();\n\n\t\tthis.canvas.width = columns * cellWidth;\n\t\tthis.canvas.height = rows * cellHeight;\n\t\tObject.assign(this.canvas.style, {\n\t\t\tleft: `${left}px`,\n\t\t\ttop: `${top}px`,\n\t\t\twidth: `${canvasWidth}px`,\n\t\t\theight: `${canvasHeight}px`,\n\t\t});\n\t\tthis.painted = true;\n\n\t\tconst monoFamily =\n\t\t\tgetComputedStyle(this.canvas).fontFamily || \"ui-monospace, monospace\";\n\t\tconst grid: Grid = {\n\t\t\tleft,\n\t\t\ttop,\n\t\t\twidth: canvasWidth,\n\t\t\theight: canvasHeight,\n\t\t\tscale,\n\t\t\tcellWidth,\n\t\t\tcellHeight,\n\t\t\ttextLeft: textOrigin.x,\n\t\t\ttextTop: textOrigin.y,\n\t\t\ttextWidth,\n\t\t\tcount,\n\t\t\tcol: Uint16Array.from(col),\n\t\t\trow: Uint16Array.from(row),\n\t\t\tglyph: Uint8Array.from(glyph),\n\t\t\tink: Float32Array.from(ink),\n\t\t\tdistance,\n\t\t\tjitter,\n\t\t\tseed,\n\t\t\tspan,\n\t\t\tmaskDistance,\n\t\t\tletters,\n\t\t\tlines,\n\t\t\tatlas: createCanvas(1, 1),\n\t\t\tcolor: getComputedStyle(root).color,\n\t\t\ttint: inks.light,\n\t\t\tglyphs,\n\t\t\tmonoFamily,\n\t\t\tfontSize,\n\t\t};\n\t\tgrid.tint = isLightColor(grid.color) ? inks.dark : inks.light;\n\t\tgrid.atlas = this.buildAtlas(grid);\n\t\t// The mono font may not be in use anywhere else yet; redraw once it is.\n\t\tconst monoFont = this.atlasFont({\n\t\t\t...grid,\n\t\t\tmonoFamily: monoFamily.split(\",\")[0] ?? monoFamily,\n\t\t});\n\t\tif (document.fonts && !document.fonts.check(monoFont)) {\n\t\t\tdocument.fonts\n\t\t\t\t.load(monoFont)\n\t\t\t\t.then(() => {\n\t\t\t\t\tif (this.grid !== grid || this.destroyed) return;\n\t\t\t\t\tgrid.atlas = this.buildAtlas(grid);\n\t\t\t\t\tif (this.phase === \"encoded\") this.paintStatic();\n\t\t\t\t})\n\t\t\t\t.catch(() => {});\n\t\t}\n\t\treturn grid;\n\t}\n\n\t// ── Painting ─────────────────────────────────────────────────────────\n\n\tprivate context() {\n\t\tconst ctx = this.canvas.getContext(\"2d\");\n\t\tif (ctx) {\n\t\t\tctx.setTransform(1, 0, 0, 1, 0, 0);\n\t\t\tctx.globalAlpha = 1;\n\t\t}\n\t\treturn ctx;\n\t}\n\n\tprivate clearCanvas() {\n\t\tif (!this.painted) return;\n\t\tthis.painted = false;\n\t\tthis.context()?.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\t}\n\n\tprivate setMask(mask: string | null) {\n\t\tif (mask) this.textElement.style.setProperty(\"--ascii-decode-mask\", mask);\n\t\telse this.textElement.style.removeProperty(\"--ascii-decode-mask\");\n\t}\n\n\tprivate drawCell(\n\t\tctx: CanvasRenderingContext2D,\n\t\tgrid: Grid,\n\t\tindex: number,\n\t\tglyph: number,\n\t\talpha: number,\n\t) {\n\t\tctx.globalAlpha = alpha * grid.tint.scale;\n\t\tctx.drawImage(\n\t\t\tgrid.atlas,\n\t\t\tglyph * grid.cellWidth,\n\t\t\t0,\n\t\t\tgrid.cellWidth,\n\t\t\tgrid.cellHeight,\n\t\t\tgrid.col[index] * grid.cellWidth,\n\t\t\tgrid.row[index] * grid.cellHeight,\n\t\t\tgrid.cellWidth,\n\t\t\tgrid.cellHeight,\n\t\t);\n\t}\n\n\t/** A neighbouring ramp character that changes every `FLICKER_STEP_MS`. */\n\tprivate flicker(grid: Grid, index: number, time: number) {\n\t\tconst step = Math.floor(time / FLICKER_STEP_MS + grid.seed[index] * 7);\n\t\tconst offset = Math.floor(hash(index, step) * 3) - 1;\n\t\treturn clamp(grid.glyph[index] + offset, 1, grid.glyphs.length - 1);\n\t}\n\n\t/** The resting art: every cell at its density character. */\n\tprivate paintStatic() {\n\t\tconst grid = this.ensureGrid();\n\t\tconst ctx = this.context();\n\t\tif (!grid || !ctx) return;\n\t\tthis.refreshColor(grid);\n\t\tctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\t\tfor (let index = 0; index < grid.count; index++) {\n\t\t\tthis.drawCell(ctx, grid, index, grid.glyph[index], grid.ink[index]);\n\t\t}\n\t\tthis.painted = true;\n\t}\n\n\tprivate paintAnimation(animation: Animation, elapsed: number, now: number) {\n\t\tconst grid = this.ensureGrid();\n\t\tconst ctx = this.context();\n\t\tif (!grid || !ctx) return;\n\t\tctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\t\tthis.painted = true;\n\t\tconst decoding = animation.kind === \"decode\";\n\n\t\tif (animation.fade) {\n\t\t\t// Reduced motion: no sweep and no flicker. The outgoing layer fades\n\t\t\t// first and the incoming one follows, so the two never sit on top of\n\t\t\t// each other at half strength.\n\t\t\tconst progress = clamp(elapsed / animation.total, 0, 1);\n\t\t\tconst out = 1 - smoothstep(progress / 0.6);\n\t\t\tconst into = smoothstep((progress - 0.4) / 0.6);\n\t\t\tconst artAlpha = decoding ? out : into;\n\t\t\tconst textAlpha = decoding ? into : out;\n\t\t\tfor (let index = 0; index < grid.count; index++) {\n\t\t\t\tthis.drawCell(\n\t\t\t\t\tctx,\n\t\t\t\t\tgrid,\n\t\t\t\t\tindex,\n\t\t\t\t\tgrid.glyph[index],\n\t\t\t\t\tgrid.ink[index] * artAlpha,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst alpha = textAlpha.toFixed(3);\n\t\t\tthis.setMask(\n\t\t\t\t`linear-gradient(rgb(0 0 0 / ${alpha}), rgb(0 0 0 / ${alpha}))`,\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\n\t\t// The front eases in and out; each cell resolves when the eased front\n\t\t// reaches it, so the art and the text mask stay in step.\n\t\tconst t = elapsed - animation.lead;\n\t\tconst travel = grid.span + EDGE_PX;\n\t\tconst front = easeInOutSine(t / animation.sweep) * travel - EDGE_PX / 2;\n\t\tfor (let index = 0; index < grid.count; index++) {\n\t\t\tconst reach = (grid.distance[index] + EDGE_PX / 2) / travel;\n\t\t\tconst at =\n\t\t\t\teaseInOutSineInverse(reach) * animation.sweep -\n\t\t\t\tCELL_FADE_MS / 2 +\n\t\t\t\tgrid.jitter[index];\n\t\t\tconst local = t - at;\n\t\t\tlet glyph = grid.glyph[index];\n\t\t\tlet alpha = grid.ink[index];\n\t\t\tif (decoding) {\n\t\t\t\tif (local >= CELL_FADE_MS) continue;\n\t\t\t\tif (local >= -FLICKER_MS) glyph = this.flicker(grid, index, t);\n\t\t\t\tif (local > 0) alpha *= 1 - local / CELL_FADE_MS;\n\t\t\t} else {\n\t\t\t\tif (local <= 0) continue;\n\t\t\t\tif (local < CELL_FADE_MS + FLICKER_MS) {\n\t\t\t\t\tglyph = this.flicker(grid, index, t);\n\t\t\t\t}\n\t\t\t\tif (local < CELL_FADE_MS) alpha *= local / CELL_FADE_MS;\n\t\t\t}\n\t\t\tthis.drawCell(ctx, grid, index, glyph, alpha);\n\t\t}\n\t\tthis.setMask(this.frontMask(grid, front, !decoding));\n\n\t\tif (decoding) this.playTicks(animation, grid, front, now);\n\t}\n\n\t/**\n\t * A left-to-right gradient that is opaque wherever the front has passed,\n\t * softened with a box blur so every edge is `EDGE_PX` wide.\n\t */\n\tprivate frontMask(grid: Grid, front: number, invert: boolean) {\n\t\tconst samples = grid.maskDistance;\n\t\tconst count = samples.length;\n\t\tconst prefix = new Float32Array(count + 1);\n\t\tfor (let index = 0; index < count; index++) {\n\t\t\tprefix[index + 1] = prefix[index] + (front >= samples[index] ? 1 : 0);\n\t\t}\n\t\tconst radius = Math.round(EDGE_PX / 2 / MASK_STEP);\n\t\tconst alphas = new Float32Array(count);\n\t\tlet sum = 0;\n\t\tfor (let index = 0; index < count; index++) {\n\t\t\tconst from = Math.max(0, index - radius);\n\t\t\tconst to = Math.min(count, index + radius + 1);\n\t\t\tconst value = (prefix[to] - prefix[from]) / (to - from);\n\t\t\talphas[index] = invert ? 1 - value : value;\n\t\t\tsum += alphas[index];\n\t\t}\n\t\tif (sum >= count - 1e-3) return null;\n\t\tif (sum <= 1e-3) return \"linear-gradient(#0000, #0000)\";\n\t\tconst stops: string[] = [];\n\t\tfor (let index = 0; index < count; index++) {\n\t\t\tconst value = alphas[index];\n\t\t\tconst previous = alphas[index - 1];\n\t\t\tconst next = alphas[index + 1];\n\t\t\tif (\n\t\t\t\tindex === 0 ||\n\t\t\t\tindex === count - 1 ||\n\t\t\t\tvalue !== previous ||\n\t\t\t\tvalue !== next\n\t\t\t) {\n\t\t\t\tstops.push(`rgb(0 0 0 / ${value.toFixed(3)}) ${index * MASK_STEP}px`);\n\t\t\t}\n\t\t}\n\t\treturn `linear-gradient(to right, ${stops.join(\", \")})`;\n\t}\n\n\tprivate playTicks(\n\t\tanimation: Animation,\n\t\tgrid: Grid,\n\t\tfront: number,\n\t\tnow: number,\n\t) {\n\t\tlet crossed = false;\n\t\twhile (\n\t\t\tanimation.nextLetter < grid.letters.length &&\n\t\t\tgrid.letters[animation.nextLetter] <= front\n\t\t) {\n\t\t\tanimation.nextLetter++;\n\t\t\tcrossed = true;\n\t\t}\n\t\tif (\n\t\t\t!crossed ||\n\t\t\t!this.options.sound ||\n\t\t\tanimation.ticks >= MAX_TICKS ||\n\t\t\tnow - animation.lastTickAt < TICK_THROTTLE_MS ||\n\t\t\tdocument.hidden\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\t// Never on page load: only once the page has had a user gesture.\n\t\tconst activation = (\n\t\t\tnavigator as Navigator & { userActivation?: { hasBeenActive: boolean } }\n\t\t).userActivation;\n\t\tif (activation && !activation.hasBeenActive) return;\n\t\tanimation.ticks++;\n\t\tanimation.lastTickAt = now;\n\t\tthis.callbacks.onTick();\n\t}\n\n\t// ── Lens ─────────────────────────────────────────────────────────────\n\n\tprivate lensEnabled() {\n\t\tconst { lens, trigger, reducedMotion } = this.options;\n\t\treturn lens && trigger !== \"hover\" && !reducedMotion;\n\t}\n\n\tprivate lensRadius(grid: Grid) {\n\t\treturn this.options.lensRadius ?? clamp(grid.fontSize * 0.6, 24, 64);\n\t}\n\n\tprivate paintLens(now: number) {\n\t\tthis.trail = this.trail.filter((point) => now - point.t < HEAL_MS);\n\t\tif (this.trail.length > MAX_TRAIL) {\n\t\t\tthis.trail.splice(0, this.trail.length - MAX_TRAIL);\n\t\t}\n\t\tconst grid = this.grid;\n\t\tconst ctx = this.context();\n\t\t// The lens opens with an ease-out and heals with an ease-in-out, so it\n\t\t// arrives quickly and settles back into the type without a snap.\n\t\tconst circles = this.trail.map((point) => ({\n\t\t\tx: point.x,\n\t\t\ty: point.y,\n\t\t\tr: point.r * (1 - smoothstep((now - point.t) / HEAL_MS)),\n\t\t}));\n\t\tif (this.head && grid) {\n\t\t\tcircles.push({\n\t\t\t\tx: this.head.x,\n\t\t\t\ty: this.head.y,\n\t\t\t\tr: this.headRadius(grid, now),\n\t\t\t});\n\t\t}\n\t\tconst visible = circles.filter((circle) => circle.r >= 0.5);\n\t\tif (!grid || !ctx || !visible.length) {\n\t\t\tthis.setMask(null);\n\t\t\tthis.clearCanvas();\n\t\t\treturn;\n\t\t}\n\n\t\tctx.clearRect(0, 0, this.canvas.width, this.canvas.height);\n\t\tthis.painted = true;\n\t\tlet minX = Number.POSITIVE_INFINITY;\n\t\tlet maxX = Number.NEGATIVE_INFINITY;\n\t\tlet minY = Number.POSITIVE_INFINITY;\n\t\tlet maxY = Number.NEGATIVE_INFINITY;\n\t\tfor (const circle of visible) {\n\t\t\tminX = Math.min(minX, circle.x - circle.r);\n\t\t\tmaxX = Math.max(maxX, circle.x + circle.r);\n\t\t\tminY = Math.min(minY, circle.y - circle.r);\n\t\t\tmaxY = Math.max(maxY, circle.y + circle.r);\n\t\t}\n\t\tconst cellWidth = grid.cellWidth / grid.scale;\n\t\tconst cellHeight = grid.cellHeight / grid.scale;\n\t\tfor (let index = 0; index < grid.count; index++) {\n\t\t\tconst x = grid.left + (grid.col[index] + 0.5) * cellWidth;\n\t\t\tconst y = grid.top + (grid.row[index] + 0.5) * cellHeight;\n\t\t\tif (x < minX || x > maxX || y < minY || y > maxY) continue;\n\t\t\t// The text mask multiplies the holes, so the art is its complement.\n\t\t\tlet clear = 1;\n\t\t\tfor (const circle of visible) {\n\t\t\t\tconst reach = Math.hypot(x - circle.x, y - circle.y);\n\t\t\t\tconst inner = circle.r * LENS_CORE;\n\t\t\t\tconst open =\n\t\t\t\t\treach <= inner\n\t\t\t\t\t\t? 1\n\t\t\t\t\t\t: 1 - clamp((reach - inner) / (circle.r - inner), 0, 1);\n\t\t\t\tclear *= 1 - open;\n\t\t\t}\n\t\t\tconst strength = 1 - clear;\n\t\t\tif (strength <= 0.01) continue;\n\t\t\t// Cells on the soft rim shimmer between neighbouring characters.\n\t\t\tconst glyph =\n\t\t\t\tstrength < 0.85 ? this.flicker(grid, index, now) : grid.glyph[index];\n\t\t\tthis.drawCell(ctx, grid, index, glyph, grid.ink[index] * strength);\n\t\t}\n\t\tthis.setMask(\n\t\t\tvisible\n\t\t\t\t.map(\n\t\t\t\t\t(circle) =>\n\t\t\t\t\t\t`radial-gradient(circle ${circle.r.toFixed(1)}px at ${(circle.x - grid.textLeft).toFixed(1)}px ${(circle.y - grid.textTop).toFixed(1)}px, #0000 ${(circle.r * LENS_CORE).toFixed(1)}px, #000 ${circle.r.toFixed(1)}px)`,\n\t\t\t\t)\n\t\t\t\t.join(\", \"),\n\t\t);\n\t}\n\n\tprivate headRadius(grid: Grid, now: number) {\n\t\tconst opened = this.head ? (now - this.head.since) / LENS_IN_MS : 1;\n\t\treturn this.lensRadius(grid) * easeOutCubic(opened);\n\t}\n\n\t/**\n\t * Moves the lens. A mouse or pen hides the cursor while the lens sits on\n\t * the text, because the lens is the cursor there; over the blank parts of\n\t * the box the cursor comes back.\n\t */\n\tprivate moveLens(clientX: number, clientY: number, pointer: boolean) {\n\t\tconst grid = this.ensureGrid();\n\t\tif (!grid) return;\n\t\tconst { toLocal } = this.toLocalFactory();\n\t\tconst point = toLocal(clientX, clientY);\n\t\tconst now = performance.now();\n\t\tconst head = this.head;\n\t\tconst radius = this.lensRadius(grid);\n\t\tif (\n\t\t\thead &&\n\t\t\tMath.hypot(point.x - head.x, point.y - head.y) >= radius * 0.3\n\t\t) {\n\t\t\tthis.trail.push({\n\t\t\t\tx: head.x,\n\t\t\t\ty: head.y,\n\t\t\t\tr: this.headRadius(grid, now),\n\t\t\t\tt: now,\n\t\t\t});\n\t\t}\n\t\tthis.head = { x: point.x, y: point.y, since: head?.since ?? now };\n\t\tconst reach = radius * 0.35;\n\t\tthis.setCursorHidden(\n\t\t\tpointer &&\n\t\t\t\tgrid.lines.some(\n\t\t\t\t\t(line) =>\n\t\t\t\t\t\tpoint.x >= line.left - reach &&\n\t\t\t\t\t\tpoint.x <= line.right + reach &&\n\t\t\t\t\t\tpoint.y >= line.top - reach &&\n\t\t\t\t\t\tpoint.y <= line.top + line.height + reach,\n\t\t\t\t),\n\t\t);\n\t\tthis.wake();\n\t}\n\n\tprivate releaseLens() {\n\t\tthis.setCursorHidden(false);\n\t\tconst grid = this.grid;\n\t\tif (!this.head || !grid) return;\n\t\tconst now = performance.now();\n\t\tthis.trail.push({\n\t\t\tx: this.head.x,\n\t\t\ty: this.head.y,\n\t\t\tr: this.headRadius(grid, now),\n\t\t\tt: now,\n\t\t});\n\t\tthis.head = null;\n\t\tthis.wake();\n\t}\n\n\tprivate setCursorHidden(hidden: boolean) {\n\t\tif (this.cursorHidden === hidden) return;\n\t\tthis.cursorHidden = hidden;\n\t\tif (hidden) this.root.dataset.lens = \"\";\n\t\telse delete this.root.dataset.lens;\n\t}\n\n\tprivate lensReady() {\n\t\treturn this.lensEnabled() && this.phase === \"decoded\" && !this.animation;\n\t}\n\n\tpointerDown(event: PointerEvent<HTMLElement>) {\n\t\tif (event.pointerType === \"touch\") {\n\t\t\tthis.touch = {\n\t\t\t\tid: event.pointerId,\n\t\t\t\tx: event.clientX,\n\t\t\t\ty: event.clientY,\n\t\t\t\tactive: false,\n\t\t\t};\n\t\t} else if (event.pointerType === \"mouse\") {\n\t\t\t// A press starts a text selection; keep the text clear for it, and\n\t\t\t// bring the cursor back so the selection has a caret to follow.\n\t\t\tthis.releaseLens();\n\t\t}\n\t}\n\n\tpointerMove(event: PointerEvent<HTMLElement>) {\n\t\tif (event.pointerType !== \"touch\") {\n\t\t\tthis.hover = { x: event.clientX, y: event.clientY };\n\t\t}\n\t\tif (!this.lensReady()) return;\n\t\tif (event.pointerType === \"touch\") {\n\t\t\tconst touch = this.touch;\n\t\t\tif (!touch || touch.id !== event.pointerId) return;\n\t\t\tif (!touch.active) {\n\t\t\t\tconst dx = event.clientX - touch.x;\n\t\t\t\tconst dy = event.clientY - touch.y;\n\t\t\t\tif (Math.hypot(dx, dy) < TOUCH_SLOP_PX) return;\n\t\t\t\t// A vertical swipe is a page scroll, not a lens drag.\n\t\t\t\tif (Math.abs(dx) <= Math.abs(dy)) {\n\t\t\t\t\tthis.touch = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttouch.active = true;\n\t\t\t\tif (this.options.haptics && !document.hidden) {\n\t\t\t\t\tthis.callbacks.onHaptic();\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (event.pointerType === \"mouse\" && event.buttons !== 0) {\n\t\t\treturn;\n\t\t}\n\t\tthis.moveLens(event.clientX, event.clientY, event.pointerType !== \"touch\");\n\t}\n\n\tpointerEnd(event: PointerEvent<HTMLElement>) {\n\t\tif (event.pointerType === \"touch\") {\n\t\t\tif (this.touch?.id !== event.pointerId) return;\n\t\t\tthis.touch = null;\n\t\t}\n\t\tthis.releaseLens();\n\t}\n\n\tpointerLeave(event: PointerEvent<HTMLElement>) {\n\t\tif (event.pointerType === \"touch\") return;\n\t\tthis.hover = null;\n\t\tthis.releaseLens();\n\t}\n}\n\nexport interface AsciiDecodeTextHandle {\n\t/** Re-encodes the text to ASCII art, then decodes it again. */\n\treplay: () => void;\n\t/** Sweeps the text back into ASCII art and holds it there. */\n\tencode: () => void;\n\t/** Decodes the ASCII art into the text. */\n\tdecode: () => void;\n}\n\nexport interface AsciiDecodeTextProps\n\textends Omit<ComponentProps<\"h2\">, \"children\" | \"ref\"> {\n\t/** The headline. Plain text only: the art is drawn from this string. */\n\tchildren: string;\n\t/** The element to render. */\n\tas?: \"h1\" | \"h2\" | \"h3\" | \"p\" | \"span\";\n\t/** Type scale of the headline. Overridable with `className`. */\n\tsize?: keyof typeof sizes;\n\t/**\n\t * What starts the decode: on mount, once 40% of it is in view, on hover or\n\t * focus (which re-encodes first), or only through `decoded` and the ref.\n\t */\n\ttrigger?: AsciiDecodeTextTrigger;\n\t/** Controlled state for `trigger=\"manual\"`: `true` decodes, `false` re-encodes. */\n\tdecoded?: boolean;\n\t/** Called each time a decode finishes. */\n\tonDecoded?: () => void;\n\t/** Where the front starts. `\"ltr\"` means the start of the line, so it runs from the right in RTL text. */\n\tdirection?: AsciiDecodeTextDirection;\n\t/** Length of the decode sweep, in ms. A re-encode takes 60% of it. */\n\tduration?: number;\n\t/**\n\t * ASCII cells per cap height, from 4 to 12. Small text uses larger cells,\n\t * down to 4 per cap height, so the characters stay legible.\n\t */\n\tdensity?: number;\n\t/** Characters from empty to full ink. */\n\tramp?: string;\n\t/** Ink colour of the art: the text colour, or a quieter 60% of it. */\n\ttone?: keyof typeof tones;\n\t/** Sprinkles faint dust characters around the letters while encoded. */\n\tdust?: boolean;\n\t/**\n\t * Re-encodes the text under the pointer, or under a sideways touch drag,\n\t * after decoding. While it sits on the text it replaces the mouse cursor.\n\t * Defaults to `true`; always off with `trigger=\"hover\"` and reduced motion.\n\t */\n\tlens?: boolean;\n\t/** Lens radius in px. Defaults to 0.6em, clamped to 24-64 px. */\n\tlensRadius?: number;\n\t/** A very soft type tick as the front crosses each letter. */\n\tsound?: boolean;\n\t/** A light haptic when a touch lens starts. */\n\thaptics?: boolean;\n\t/** Set to `false` for a plain cross-fade, as with reduced motion. */\n\tanimated?: boolean;\n\t/** Exposes `replay()`, `encode()`, and `decode()`. */\n\tref?: Ref<AsciiDecodeTextHandle>;\n}\n\nexport function AsciiDecodeText({\n\tchildren,\n\tas: Component = \"h2\",\n\tsize = \"md\",\n\ttrigger = \"view\",\n\tdecoded,\n\tonDecoded,\n\tdirection = \"ltr\",\n\tduration = 1100,\n\tdensity = 7,\n\tramp = DEFAULT_RAMP,\n\ttone = \"default\",\n\tdust = false,\n\tlens,\n\tlensRadius,\n\tsound = false,\n\thaptics = true,\n\tanimated = true,\n\tclassName,\n\tref,\n\tonPointerDown,\n\tonPointerMove,\n\tonPointerUp,\n\tonPointerCancel,\n\tonPointerLeave,\n\tonPointerEnter,\n\tonFocus,\n\t...props\n}: AsciiDecodeTextProps) {\n\tconst [phase, setPhase] = useState<Phase>(() =>\n\t\ttrigger === \"manual\" && decoded ? \"decoded\" : \"encoded\",\n\t);\n\tconst prefersReducedMotion = usePrefersReducedMotion();\n\tconst reducedMotion = prefersReducedMotion || !animated;\n\tconst lensOn = (lens ?? trigger !== \"hover\") && trigger !== \"hover\";\n\n\tconst { trigger: haptic } = useWebHaptics();\n\tconst { click: playType } = useTiks({\n\t\ttheme: TYPE_SOUND,\n\t\tvolume: 0.35,\n\t\trespectReducedMotion: false,\n\t});\n\n\tconst rootRef = useRef<HTMLElement>(null);\n\tconst textRef = useRef<HTMLSpanElement>(null);\n\tconst canvasRef = useRef<HTMLCanvasElement>(null);\n\tconst engineRef = useRef<DecodeEngine | null>(null);\n\n\tconst options: EngineOptions = {\n\t\ttext: children,\n\t\tdirection,\n\t\tduration,\n\t\tdensity,\n\t\tramp,\n\t\ttone,\n\t\tdust,\n\t\tlens: lensOn,\n\t\tlensRadius,\n\t\ttrigger,\n\t\treducedMotion,\n\t\tsound,\n\t\thaptics,\n\t};\n\tconst latest = useRef({ options, onDecoded, playType, haptic });\n\tuseLayoutEffect(() => {\n\t\tlatest.current = { options, onDecoded, playType, haptic };\n\t\tengineRef.current?.setOptions(options);\n\t});\n\n\tuseLayoutEffect(() => {\n\t\tconst root = rootRef.current;\n\t\tconst text = textRef.current;\n\t\tconst canvas = canvasRef.current;\n\t\tif (!root || !text || !canvas) return;\n\t\tconst engine = new DecodeEngine(\n\t\t\troot,\n\t\t\ttext,\n\t\t\tcanvas,\n\t\t\tlatest.current.options,\n\t\t\t{\n\t\t\t\tonPhase: setPhase,\n\t\t\t\tonDecoded: () => latest.current.onDecoded?.(),\n\t\t\t\tonTick: () => latest.current.playType(),\n\t\t\t\tonHaptic: () => void latest.current.haptic(\"light\"),\n\t\t\t},\n\t\t\troot.dataset.state === \"decoded\" ? \"decoded\" : \"encoded\",\n\t\t);\n\t\tengineRef.current = engine;\n\t\treturn () => {\n\t\t\tengine.destroy();\n\t\t\tengineRef.current = null;\n\t\t};\n\t}, []);\n\n\t// Controlled mode: follow `decoded` after the first render.\n\tconst decodedRef = useRef(decoded);\n\tuseEffect(() => {\n\t\tif (decodedRef.current === decoded) return;\n\t\tdecodedRef.current = decoded;\n\t\tif (trigger !== \"manual\" || decoded === undefined) return;\n\t\tif (decoded) engineRef.current?.decode();\n\t\telse engineRef.current?.encode();\n\t}, [decoded, trigger]);\n\n\tuseImperativeHandle(ref, () => ({\n\t\treplay: () => engineRef.current?.replay(),\n\t\tencode: () => engineRef.current?.encode(),\n\t\tdecode: () => engineRef.current?.decode(),\n\t}));\n\n\tconst startHover = () => {\n\t\tif (trigger === \"hover\") engineRef.current?.replay();\n\t};\n\n\treturn (\n\t\t<Component\n\t\t\tref={rootRef as Ref<HTMLHeadingElement>}\n\t\t\tdata-slot=\"ascii-decode-text\"\n\t\t\tdata-state={phase}\n\t\t\tdata-trigger={trigger}\n\t\t\tdata-direction={direction}\n\t\t\tclassName={cn(\n\t\t\t\t// The last cell column can overhang the box by a fraction; clip it so\n\t\t\t\t// the art never widens the page.\n\t\t\t\t\"relative max-w-full overflow-x-clip text-balance break-words font-semibold\",\n\t\t\t\t\"data-[state=encoded]:[--ascii-decode-mask:linear-gradient(#0000,#0000)]\",\n\t\t\t\t// The lens is the cursor while it sits on the text (set by the engine\n\t\t\t\t// for mouse and pen only).\n\t\t\t\t\"data-[lens]:cursor-none\",\n\t\t\t\t\"rounded-sm outline-none [-webkit-tap-highlight-color:transparent] focus-visible:outline-2 focus-visible:outline-ring/60 focus-visible:outline-offset-4\",\n\t\t\t\t// A new formatting context, so the text's negative margins below\n\t\t\t\t// never collapse through the root.\n\t\t\t\tComponent === \"span\" ? \"inline-block\" : \"flow-root\",\n\t\t\t\tlensOn && !reducedMotion && \"touch-pan-y\",\n\t\t\t\tsizes[size],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\tonPointerDown={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerDown?.(event);\n\t\t\t\tengineRef.current?.pointerDown(event);\n\t\t\t\t// A tap is the touch equivalent of hovering.\n\t\t\t\tif (event.pointerType === \"touch\") startHover();\n\t\t\t}}\n\t\t\tonPointerMove={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerMove?.(event);\n\t\t\t\tengineRef.current?.pointerMove(event);\n\t\t\t}}\n\t\t\tonPointerUp={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerUp?.(event);\n\t\t\t\tengineRef.current?.pointerEnd(event);\n\t\t\t}}\n\t\t\tonPointerCancel={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerCancel?.(event);\n\t\t\t\tengineRef.current?.pointerEnd(event);\n\t\t\t}}\n\t\t\tonPointerLeave={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerLeave?.(event);\n\t\t\t\tengineRef.current?.pointerLeave(event);\n\t\t\t}}\n\t\t\tonPointerEnter={(event: PointerEvent<HTMLHeadingElement>) => {\n\t\t\t\tonPointerEnter?.(event);\n\t\t\t\tif (event.pointerType !== \"touch\") startHover();\n\t\t\t}}\n\t\t\tonFocus={(event) => {\n\t\t\t\tonFocus?.(event);\n\t\t\t\tstartHover();\n\t\t\t}}\n\t\t\t{...props}\n\t\t>\n\t\t\t<span\n\t\t\t\tref={textRef}\n\t\t\t\tdata-slot=\"ascii-decode-text-text\"\n\t\t\t\t// The padding, cancelled by the margin, grows the mask area so\n\t\t\t\t// descenders and accents past the line box aren't clipped.\n\t\t\t\tclassName=\"-my-[0.25em] block py-[0.25em] [mask-composite:intersect] [mask-image:var(--ascii-decode-mask)]\"\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t\t{/* biome-ignore lint/a11y/noAriaHiddenOnFocusable: a canvas without tabIndex is not focusable. */}\n\t\t\t<canvas\n\t\t\t\tref={canvasRef}\n\t\t\t\taria-hidden=\"true\"\n\t\t\t\tdata-slot=\"ascii-decode-text-canvas\"\n\t\t\t\t// Unsized until the first raster, so it never adds a 300x150 box.\n\t\t\t\tclassName=\"pointer-events-none absolute top-0 left-0 size-0 select-none font-mono\"\n\t\t\t/>\n\t\t</Component>\n\t);\n}\n\nexport default AsciiDecodeText;\n",
      "type": "registry:component",
      "target": "@components/ascii-decode-text.tsx"
    }
  ],
  "meta": {
    "createdAt": "2026-11-14",
    "image": "https://cdn.tentui.com/images/components/ascii-decode-text?v=2",
    "video": "https://cdn.tentui.com/videos/components/ascii-decode-text?v=2"
  },
  "docs": "https://tentui.com/components/ascii-decode-text",
  "categories": [
    "typography"
  ],
  "type": "registry:component"
}