{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scratch-card",
  "title": "Scratch Card",
  "description": "A scratch-off card over any content. Drag to scrape away brushed foil with a ragged edge and leftover specks, while flakes tumble off and fall. Past a threshold the rest fades away. Silver, gold, copper or any hex, an optional pressed-in label, progress callbacks, and Enter to reveal from the keyboard.",
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/new-york/blocks/scratch-card/scratch-card.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Pt = { x: number; y: number }\ntype Palette = { light: string; mid: string; dark: string }\n\nconst FOILS = {\n  silver: { light: \"#f2f4f3\", mid: \"#bcc4c2\", dark: \"#7c8684\" },\n  gold: { light: \"#fbefc6\", mid: \"#d2ad5e\", dark: \"#8f6c28\" },\n  copper: { light: \"#f6d6c6\", mid: \"#c68a6f\", dark: \"#80503b\" },\n} satisfies Record<string, Palette>\n\nexport type ScratchCardFoil = keyof typeof FOILS\n\n/** The named foils as hex, for building your own picker. */\nexport const scratchCardFoils = {\n  silver: FOILS.silver.mid,\n  gold: FOILS.gold.mid,\n  copper: FOILS.copper.mid,\n} as const\n\n/** Grid cell for measuring how much foil is gone, in px. */\nconst CELL = 6\n/** How far flakes may fly past the card, in px: sides, top, bottom. */\nconst SPILL = { x: 32, top: 24, bottom: 96 }\nconst MAX_FLAKES = 140\nconst GRAVITY = 1500\nconst EASE_OUT = \"cubic-bezier(0.23, 1, 0.32, 1)\"\n\nfunction mulberry32(seed: number) {\n  let a = seed >>> 0\n  return () => {\n    a = (a + 0x6d2b79f5) >>> 0\n    let t = a\n    t = Math.imul(t ^ (t >>> 15), t | 1)\n    t ^= t + Math.imul(t ^ (t >>> 7), t | 61)\n    return ((t ^ (t >>> 14)) >>> 0) / 4294967296\n  }\n}\n\nfunction parseHex(hex: string) {\n  const h = hex.trim().replace(/^#/, \"\")\n  const full = h.length === 3 ? h.split(\"\").map((c) => c + c).join(\"\") : h\n  if (!/^[0-9a-f]{6}$/i.test(full)) return null\n  const n = Number.parseInt(full, 16)\n  return [(n >> 16) & 255, (n >> 8) & 255, n & 255] as const\n}\n\nfunction mix(hex: string, to: number, t: number) {\n  const rgb = parseHex(hex)!\n  return `rgb(${rgb.map((c) => Math.round(c + (to - c) * t)).join(\" \")})`\n}\n\nfunction paletteOf(foil: string): Palette {\n  if (foil in FOILS) return FOILS[foil as ScratchCardFoil]\n  if (!parseHex(foil)) return FOILS.silver\n  return { light: mix(foil, 255, 0.6), mid: foil, dark: mix(foil, 0, 0.38) }\n}\n\n/** Brushed metal: a banded sheen, hairline brushing, grain, and an optional pressed-in label. */\nfunction paintFoil(ctx: CanvasRenderingContext2D, w: number, h: number, pal: Palette, seed: number, label: string, font: string) {\n  const rnd = mulberry32(seed)\n  ctx.globalCompositeOperation = \"source-over\"\n  ctx.globalAlpha = 1\n  ctx.clearRect(0, 0, w, h)\n\n  const g = ctx.createLinearGradient(0, 0, w, h * 0.6)\n  g.addColorStop(0, pal.mid)\n  g.addColorStop(0.22, pal.light)\n  g.addColorStop(0.42, pal.mid)\n  g.addColorStop(0.58, pal.dark)\n  g.addColorStop(0.78, pal.light)\n  g.addColorStop(1, pal.mid)\n  ctx.fillStyle = pal.mid\n  ctx.fillRect(0, 0, w, h)\n  ctx.globalAlpha = 0.55\n  ctx.fillStyle = g\n  ctx.fillRect(0, 0, w, h)\n\n  // Brushing: faint horizontal hairlines.\n  ctx.lineWidth = 0.6\n  for (let i = 0, n = Math.ceil(h * 2.4); i < n; i++) {\n    const y = rnd() * h\n    const x = rnd() * w * 0.8 - w * 0.1\n    ctx.globalAlpha = 0.025 + rnd() * 0.045\n    ctx.strokeStyle = rnd() < 0.5 ? \"#fff\" : \"#000\"\n    ctx.beginPath()\n    ctx.moveTo(x, y)\n    ctx.lineTo(x + w * (0.08 + rnd() * 0.3), y)\n    ctx.stroke()\n  }\n\n  // Grain.\n  for (let i = 0, n = Math.floor((w * h) / 10); i < n; i++) {\n    ctx.globalAlpha = 0.05 + rnd() * 0.12\n    ctx.fillStyle = rnd() < 0.5 ? \"#fff\" : \"#000\"\n    ctx.fillRect(rnd() * w, rnd() * h, 1, 1)\n  }\n\n  // Lit top edge, shaded bottom edge.\n  ctx.globalAlpha = 0.6\n  ctx.fillStyle = \"#fff\"\n  ctx.fillRect(0, 0, w, 1)\n  ctx.globalAlpha = 0.25\n  ctx.fillStyle = \"#000\"\n  ctx.fillRect(0, h - 1, w, 1)\n\n  if (label) {\n    const size = Math.max(9, Math.min(15, h * 0.16))\n    ctx.font = `600 ${size}px ${font}`\n    ctx.textAlign = \"center\"\n    ctx.textBaseline = \"middle\"\n    if (\"letterSpacing\" in ctx) ctx.letterSpacing = `${(size * 0.22).toFixed(1)}px`\n    const text = label.toUpperCase()\n    ctx.globalAlpha = 0.7\n    ctx.fillStyle = pal.light\n    ctx.fillText(text, w / 2, h / 2 + 1)\n    ctx.globalAlpha = 0.45\n    ctx.fillStyle = pal.dark\n    ctx.fillText(text, w / 2, h / 2)\n  }\n  ctx.globalAlpha = 1\n}\n\ninterface Options {\n  brush: number\n  threshold: number\n  seed: number\n  pal: Palette\n  label: string\n  flakes: boolean\n  onStart: () => void\n  onProgress: (p: number) => void\n  onComplete: () => void\n}\n\ninterface Stroke {\n  brush: number\n  /** Points normalised to the card, so a resize can replay them. */\n  pts: Pt[]\n}\n\ninterface Flake {\n  x: number\n  y: number\n  vx: number\n  vy: number\n  r: number\n  vr: number\n  flip: number\n  vflip: number\n  size: number\n  color: string\n  age: number\n  life: number\n}\n\n/** Everything per frame lives here, outside React. */\nfunction createScratch(host: HTMLElement, canvas: HTMLCanvasElement, dust: HTMLCanvasElement, get: () => Options) {\n  const ctx = canvas.getContext(\"2d\")!\n  const dctx = dust.getContext(\"2d\")!\n  const reduced = () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n  const s = {\n    w: 0,\n    h: 0,\n    rect: null as DOMRect | null,\n    strokes: [] as Stroke[],\n    stroke: null as Stroke | null,\n    pointer: null as number | null,\n    last: null as Pt | null,\n    cols: 0,\n    rows: 0,\n    grid: new Uint8Array(0),\n    cleared: 0,\n    reported: -1,\n    seg: 0,\n    started: false,\n    done: false,\n    flakes: [] as Flake[],\n    raf: 0,\n    prev: 0,\n  }\n\n  function markGrid(a: Pt, b: Pt, r: number) {\n    const reach = r * 0.85\n    const c0 = Math.max(0, Math.floor((Math.min(a.x, b.x) - r) / CELL))\n    const c1 = Math.min(s.cols - 1, Math.floor((Math.max(a.x, b.x) + r) / CELL))\n    const r0 = Math.max(0, Math.floor((Math.min(a.y, b.y) - r) / CELL))\n    const r1 = Math.min(s.rows - 1, Math.floor((Math.max(a.y, b.y) + r) / CELL))\n    const dx = b.x - a.x\n    const dy = b.y - a.y\n    const len2 = dx * dx + dy * dy\n    for (let row = r0; row <= r1; row++) {\n      for (let col = c0; col <= c1; col++) {\n        const i = row * s.cols + col\n        if (s.grid[i]) continue\n        const px = (col + 0.5) * CELL\n        const py = (row + 0.5) * CELL\n        const t = len2 ? Math.max(0, Math.min(1, ((px - a.x) * dx + (py - a.y) * dy) / len2)) : 0\n        if (Math.hypot(px - (a.x + dx * t), py - (a.y + dy * t)) <= reach) {\n          s.grid[i] = 1\n          s.cleared++\n        }\n      }\n    }\n  }\n\n  /** Scrapes from a to b: a round stroke, bites out of its rim, and a few specks of foil left behind. */\n  function scrape(a: Pt, b: Pt, brush: number) {\n    const { seed, pal } = get()\n    const rnd = mulberry32(seed * 977 + s.seg++)\n    const r = brush / 2\n    const dx = b.x - a.x\n    const dy = b.y - a.y\n    const len = Math.hypot(dx, dy)\n\n    ctx.globalCompositeOperation = \"destination-out\"\n    ctx.globalAlpha = 1\n    ctx.fillStyle = \"#000\"\n    ctx.strokeStyle = \"#000\"\n    if (len < 0.5) {\n      ctx.beginPath()\n      ctx.arc(a.x, a.y, r, 0, Math.PI * 2)\n      ctx.fill()\n    } else {\n      ctx.lineWidth = brush\n      ctx.lineCap = \"round\"\n      ctx.beginPath()\n      ctx.moveTo(a.x, a.y)\n      ctx.lineTo(b.x, b.y)\n      ctx.stroke()\n    }\n\n    // Ragged rim: small bites just outside the stroke, and around its head.\n    const nx = len ? -dy / len : 0\n    const ny = len ? dx / len : 1\n    const bites = 2 + Math.floor(len / 2.4)\n    ctx.beginPath()\n    for (let i = 0; i < bites; i++) {\n      const t = rnd()\n      const side = rnd() < 0.5 ? -1 : 1\n      const off = r + rnd() * 2.8 - 0.8\n      const x = a.x + dx * t + nx * side * off\n      const y = a.y + dy * t + ny * side * off\n      const br = 0.5 + rnd() * 1.7\n      ctx.moveTo(x + br, y)\n      ctx.arc(x, y, br, 0, Math.PI * 2)\n    }\n    for (let i = 0; i < 3; i++) {\n      const ang = rnd() * Math.PI * 2\n      const x = b.x + Math.cos(ang) * (r + rnd() * 1.5)\n      const y = b.y + Math.sin(ang) * (r + rnd() * 1.5)\n      const br = 0.6 + rnd() * 1.4\n      ctx.moveTo(x + br, y)\n      ctx.arc(x, y, br, 0, Math.PI * 2)\n    }\n    ctx.fill()\n\n    // Residue: real foil never comes off clean.\n    ctx.globalCompositeOperation = \"source-over\"\n    ctx.fillStyle = pal.dark\n    for (let i = 0, n = Math.floor(len / 10) + (rnd() < 0.3 ? 1 : 0); i < n; i++) {\n      const t = rnd()\n      const off = (rnd() * 2 - 1) * r * 0.8\n      ctx.globalAlpha = 0.35 + rnd() * 0.35\n      const sz = 0.6 + rnd() * 1\n      ctx.fillRect(a.x + dx * t + nx * off, a.y + dy * t + ny * off, sz, sz)\n    }\n    ctx.globalAlpha = 1\n\n    markGrid(a, b, r)\n  }\n\n  function spawnFlakes(a: Pt, b: Pt, brush: number) {\n    if (!get().flakes || reduced()) return\n    const { pal } = get()\n    const dx = b.x - a.x\n    const dy = b.y - a.y\n    const len = Math.hypot(dx, dy)\n    if (!len) return\n    const n = Math.min(4, Math.floor(len / 7) + (Math.random() < 0.45 ? 1 : 0))\n    const colors = [pal.light, pal.mid, pal.mid, pal.dark]\n    for (let i = 0; i < n; i++) {\n      const t = Math.random()\n      const side = Math.random() < 0.5 ? -1 : 1\n      const off = (brush / 2) * (0.4 + Math.random() * 0.6) * side\n      s.flakes.push({\n        x: a.x + dx * t + (-dy / len) * off + SPILL.x,\n        y: a.y + dy * t + (dx / len) * off + SPILL.top,\n        vx: (dx / len) * (40 + Math.random() * 90) + (Math.random() - 0.5) * 120,\n        vy: -60 - Math.random() * 140,\n        r: Math.random() * Math.PI,\n        vr: (Math.random() - 0.5) * 14,\n        flip: Math.random() * Math.PI,\n        vflip: 8 + Math.random() * 14,\n        size: 1.6 + Math.random() * 2.6,\n        color: colors[Math.floor(Math.random() * colors.length)],\n        age: 0,\n        life: 0.5 + Math.random() * 0.45,\n      })\n    }\n    if (s.flakes.length > MAX_FLAKES) s.flakes.splice(0, s.flakes.length - MAX_FLAKES)\n    kick()\n  }\n\n  function frame(now: number) {\n    s.raf = 0\n    const dt = Math.min(0.05, (now - (s.prev || now)) / 1000)\n    s.prev = now\n    dctx.clearRect(0, 0, s.w + SPILL.x * 2, s.h + SPILL.top + SPILL.bottom)\n    s.flakes = s.flakes.filter((f) => (f.age += dt) < f.life)\n    for (const f of s.flakes) {\n      f.vy += GRAVITY * dt\n      f.vx *= 1 - 1.5 * dt\n      f.x += f.vx * dt\n      f.y += f.vy * dt\n      f.r += f.vr * dt\n      f.flip += f.vflip * dt\n      const k = f.age / f.life\n      dctx.globalAlpha = k < 0.6 ? 1 : 1 - (k - 0.6) / 0.4\n      dctx.fillStyle = f.color\n      dctx.save()\n      dctx.translate(f.x, f.y)\n      dctx.rotate(f.r)\n      // Tumbling: squash one axis as the flake turns edge-on.\n      dctx.scale(1, Math.max(0.15, Math.abs(Math.cos(f.flip))))\n      dctx.fillRect(-f.size / 2, -f.size * 0.35, f.size, f.size * 0.7)\n      dctx.restore()\n    }\n    dctx.globalAlpha = 1\n    if (s.flakes.length) kick()\n    else s.prev = 0\n  }\n\n  function kick() {\n    if (!s.raf) s.raf = requestAnimationFrame(frame)\n  }\n\n  function report() {\n    const total = s.cols * s.rows\n    if (!total) return\n    const p = s.cleared / total\n    if (Math.abs(p - s.reported) >= 0.01 || p === 1) {\n      s.reported = p\n      get().onProgress(p)\n    }\n    if (!s.done && p >= get().threshold) {\n      s.done = true\n      s.pointer = null\n      s.stroke = null\n      get().onComplete()\n    }\n  }\n\n  function local(e: PointerEvent): Pt {\n    const rect = s.rect ?? host.getBoundingClientRect()\n    // Measured against layout size, so a scaled parent still maps cleanly.\n    return {\n      x: ((e.clientX - rect.left) / rect.width) * s.w,\n      y: ((e.clientY - rect.top) / rect.height) * s.h,\n    }\n  }\n\n  function repaint() {\n    if (!s.w || !s.h) return\n    const { pal, seed, label } = get()\n    paintFoil(ctx, s.w, s.h, pal, seed, label, getComputedStyle(host).fontFamily || \"sans-serif\")\n    s.cols = Math.ceil(s.w / CELL)\n    s.rows = Math.ceil(s.h / CELL)\n    s.grid = new Uint8Array(s.cols * s.rows)\n    s.cleared = 0\n    s.seg = 0\n    for (const st of s.strokes) {\n      const pts = st.pts.map((p) => ({ x: p.x * s.w, y: p.y * s.h }))\n      scrape(pts[0], pts[0], st.brush)\n      for (let i = 1; i < pts.length; i++) scrape(pts[i - 1], pts[i], st.brush)\n    }\n  }\n\n  return {\n    resize() {\n      const w = host.clientWidth\n      const h = host.clientHeight\n      if (!w || !h) return false\n      const dpr = Math.min(window.devicePixelRatio || 1, 2)\n      s.w = w\n      s.h = h\n      canvas.width = Math.round(w * dpr)\n      canvas.height = Math.round(h * dpr)\n      ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n      dust.width = Math.round((w + SPILL.x * 2) * dpr)\n      dust.height = Math.round((h + SPILL.top + SPILL.bottom) * dpr)\n      dctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n      repaint()\n      return true\n    },\n    repaint,\n    down(e: PointerEvent, target: HTMLElement) {\n      if (s.done || s.pointer !== null) return\n      if (e.pointerType === \"mouse\" && e.button !== 0) return\n      s.pointer = e.pointerId\n      target.setPointerCapture(e.pointerId)\n      s.rect = host.getBoundingClientRect()\n      const p = local(e)\n      const { brush } = get()\n      s.stroke = { brush, pts: [{ x: p.x / s.w, y: p.y / s.h }] }\n      s.strokes.push(s.stroke)\n      s.last = p\n      if (!s.started) {\n        s.started = true\n        get().onStart()\n      }\n      scrape(p, p, brush)\n      report()\n    },\n    move(e: PointerEvent) {\n      if (e.pointerId !== s.pointer || !s.stroke || !s.last) return\n      const events = e.getCoalescedEvents?.() ?? []\n      for (const ev of events.length ? events : [e]) {\n        const p = local(ev)\n        if (Math.hypot(p.x - s.last.x, p.y - s.last.y) < 1.5) continue\n        scrape(s.last, p, s.stroke.brush)\n        spawnFlakes(s.last, p, s.stroke.brush)\n        s.stroke.pts.push({ x: p.x / s.w, y: p.y / s.h })\n        s.last = p\n      }\n      report()\n    },\n    up(e: PointerEvent) {\n      if (e.pointerId !== s.pointer) return\n      s.pointer = null\n      s.stroke = null\n      s.last = null\n      s.rect = null\n    },\n    /** Marks the card revealed without scratching, e.g. from the keyboard or a controlled prop. */\n    finish() {\n      s.done = true\n      s.pointer = null\n      s.stroke = null\n    },\n    reset() {\n      if (!s.done && !s.strokes.length) return\n      s.done = false\n      s.started = false\n      s.strokes = []\n      s.flakes = []\n      s.reported = -1\n      repaint()\n      get().onProgress(0)\n    },\n    destroy() {\n      cancelAnimationFrame(s.raf)\n    },\n  }\n}\n\ntype Engine = ReturnType<typeof createScratch>\n\nexport interface ScratchCardProps extends Omit<React.ComponentProps<\"div\">, \"children\" | \"onProgress\"> {\n  /** What sits under the foil. */\n  children: React.ReactNode\n  /** A named foil or any `#rrggbb` hex. */\n  foil?: ScratchCardFoil | (string & {})\n  /** Width of the scratch, in px. */\n  brushSize?: number\n  /** Share of foil, 0 to 1, that has to be scratched before the rest falls away. */\n  threshold?: number\n  /** Controlled revealed state. Set it back to `false` to lay fresh foil. */\n  revealed?: boolean\n  defaultRevealed?: boolean\n  onRevealedChange?: (revealed: boolean) => void\n  /** Called once when the card is revealed by scratching or the keyboard. */\n  onReveal?: () => void\n  /** Called as the foil comes off, with the scratched share from 0 to 1. */\n  onProgress?: (progress: number) => void\n  /** Text pressed into the foil. */\n  foilLabel?: string\n  /** Accessible name of the foil. */\n  label?: string\n  /** Instructions read by screen readers. */\n  hint?: string\n  /** Announced once revealed. */\n  revealedLabel?: string\n  /** Shed flakes of foil while scratching. */\n  flakes?: boolean\n  /** Buzz the device on reveal where the Vibration API exists. */\n  haptics?: boolean\n  /** Seed for the foil's grain and the scratch's ragged edge. */\n  seed?: number\n}\n\nexport function ScratchCard({\n  children,\n  foil = \"silver\",\n  brushSize = 28,\n  threshold = 0.6,\n  revealed: revealedProp,\n  defaultRevealed = false,\n  onRevealedChange,\n  onReveal,\n  onProgress,\n  foilLabel = \"\",\n  label = \"Scratch to reveal\",\n  hint = \"Drag across the foil to scratch it off, or press Enter to reveal\",\n  revealedLabel = \"Revealed\",\n  flakes = true,\n  haptics = true,\n  seed = 3,\n  className,\n  style,\n  ...props\n}: ScratchCardProps) {\n  const hostRef = React.useRef<HTMLDivElement>(null)\n  const foilRef = React.useRef<HTMLDivElement>(null)\n  const canvasRef = React.useRef<HTMLCanvasElement>(null)\n  const dustRef = React.useRef<HTMLCanvasElement>(null)\n  const prizeRef = React.useRef<HTMLDivElement>(null)\n  const engineRef = React.useRef<Engine | null>(null)\n  const hintId = React.useId()\n\n  const [inner, setInner] = React.useState(defaultRevealed)\n  const revealed = revealedProp ?? inner\n  const [painted, setPainted] = React.useState(false)\n  const [touched, setTouched] = React.useState(false)\n  const pal = paletteOf(foil)\n\n  const handFocus = React.useRef(false)\n\n  const reveal = () => {\n    if (revealed) return\n    handFocus.current = document.activeElement === foilRef.current\n    if (revealedProp === undefined) setInner(true)\n    onRevealedChange?.(true)\n    onReveal?.()\n    if (haptics) navigator.vibrate?.(12)\n  }\n\n  const options = React.useRef<Options>(null!)\n  options.current = {\n    brush: brushSize,\n    threshold,\n    seed,\n    pal,\n    label: foilLabel,\n    flakes,\n    onStart: () => setTouched(true),\n    onProgress: (p) => onProgress?.(p),\n    onComplete: reveal,\n  }\n\n  React.useEffect(() => {\n    const host = hostRef.current!\n    const engine = createScratch(host, canvasRef.current!, dustRef.current!, () => options.current)\n    engineRef.current = engine\n    if (engine.resize()) setPainted(true)\n    const ro = new ResizeObserver(() => {\n      if (engine.resize()) setPainted(true)\n    })\n    ro.observe(host)\n    return () => {\n      ro.disconnect()\n      engine.destroy()\n      engineRef.current = null\n    }\n  }, [])\n\n  React.useEffect(() => {\n    const engine = engineRef.current\n    if (!engine) return\n    if (revealed) {\n      engine.finish()\n      // The foil goes invisible, so hand focus to what was under it.\n      if (handFocus.current) prizeRef.current?.focus({ preventScroll: true })\n      handFocus.current = false\n    } else {\n      engine.reset()\n      setTouched(false)\n    }\n  }, [revealed])\n\n  React.useEffect(() => {\n    engineRef.current?.repaint()\n  }, [pal.light, pal.mid, pal.dark, seed, foilLabel])\n\n  const r = brushSize / 2\n  const ring = Math.min(r, 30)\n  const cursor = `url(\"data:image/svg+xml,${encodeURIComponent(\n    `<svg xmlns='http://www.w3.org/2000/svg' width='${ring * 2 + 4}' height='${ring * 2 + 4}'>` +\n      `<circle cx='${ring + 2}' cy='${ring + 2}' r='${ring}' fill='none' stroke='black' stroke-opacity='.45' stroke-width='3'/>` +\n      `<circle cx='${ring + 2}' cy='${ring + 2}' r='${ring}' fill='none' stroke='white' stroke-width='1.25'/>` +\n      `</svg>`\n  )}\") ${ring + 2} ${ring + 2}, crosshair`\n\n  return (\n    <div\n      ref={hostRef}\n      data-revealed={revealed || undefined}\n      className={cn(\"relative isolate\", className)}\n      style={style}\n      {...props}\n    >\n      <div\n        ref={prizeRef}\n        tabIndex={-1}\n        inert={!revealed}\n        aria-hidden={!revealed}\n        className=\"size-full rounded-[inherit] outline-none\"\n      >\n        {children}\n      </div>\n\n      <div\n        ref={foilRef}\n        role=\"button\"\n        tabIndex={revealed ? -1 : 0}\n        aria-label={label}\n        aria-describedby={hintId}\n        aria-hidden={revealed || undefined}\n        className={cn(\n          \"group/scratch absolute inset-0 touch-none overflow-hidden rounded-[inherit] outline-none select-none\",\n          \"focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background\",\n          \"transition-[opacity,visibility]\",\n          revealed && \"pointer-events-none invisible opacity-0\"\n        )}\n        style={{\n          cursor,\n          transitionDuration: revealed ? \"420ms\" : \"200ms\",\n          transitionTimingFunction: EASE_OUT,\n        }}\n        onPointerDown={(e) => engineRef.current?.down(e.nativeEvent, e.currentTarget)}\n        onPointerMove={(e) => engineRef.current?.move(e.nativeEvent)}\n        onPointerUp={(e) => engineRef.current?.up(e.nativeEvent)}\n        onPointerCancel={(e) => engineRef.current?.up(e.nativeEvent)}\n        onLostPointerCapture={(e) => engineRef.current?.up(e.nativeEvent)}\n        onKeyDown={(e) => {\n          if (e.repeat || (e.key !== \"Enter\" && e.key !== \" \")) return\n          e.preventDefault()\n          engineRef.current?.finish()\n          reveal()\n        }}\n      >\n        <canvas ref={canvasRef} aria-hidden className=\"absolute inset-0 size-full\" />\n        {/* Solid foil until the canvas has painted, so the prize never flashes on load. */}\n        {!painted && <div aria-hidden className=\"absolute inset-0\" style={{ background: pal.mid }} />}\n        {/* A single sheen across untouched foil on hover, inviting the first scratch. */}\n        {!touched && (\n          <div aria-hidden className=\"pointer-events-none absolute inset-0 overflow-hidden motion-reduce:hidden\">\n            <div className=\"absolute inset-y-0 -left-1/2 w-1/2 -skew-x-12 bg-gradient-to-r from-transparent via-white/50 to-transparent transition-none group-hover/scratch:translate-x-[320%] group-hover/scratch:transition-transform group-hover/scratch:duration-[900ms] group-hover/scratch:ease-[cubic-bezier(0.23,1,0.32,1)]\" />\n          </div>\n        )}\n      </div>\n\n      <canvas\n        ref={dustRef}\n        aria-hidden\n        className=\"pointer-events-none absolute z-10\"\n        style={{\n          left: -SPILL.x,\n          top: -SPILL.top,\n          width: `calc(100% + ${SPILL.x * 2}px)`,\n          height: `calc(100% + ${SPILL.top + SPILL.bottom}px)`,\n        }}\n      />\n\n      <span id={hintId} className=\"sr-only\">\n        {hint}\n      </span>\n      <span aria-live=\"polite\" className=\"sr-only\">\n        {revealed ? revealedLabel : \"\"}\n      </span>\n    </div>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "addedAt": "2026-11-24",
    "look": "classic"
  },
  "type": "registry:component"
}