{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sticker",
  "title": "Sticker",
  "description": "A die-cut sticker you can peel off and stick somewhere else, in a matte, gloss or holographic finish. Drag from any edge and the flap folds back over itself with its liner backing, crease shading and a shadow underneath. Let go early and it falls flat; peel past a threshold and it comes off in your hand, tilting as you carry it, and slaps down where you drop it. The gloss follows the mouse, the border is traced from the artwork's real shape, the nearest corner curls up on hover, and the keyboard can lift and move it.",
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/new-york/blocks/sticker/sticker.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Pt = { x: number; y: number }\ntype Spring = readonly [stiffness: number, damping: number]\n\n/** Silhouette grid cell, in px. */\nconst CELL = 2\n/** How far the hidden layers reach past the sticker, for its border and shadows, in px. */\nconst PAD = 40\n/** How much a lifted sticker grows. */\nconst LIFT_SCALE = 0.05\nconst DIAGONALS: Pt[] = [\n  { x: -Math.SQRT1_2, y: -Math.SQRT1_2 },\n  { x: Math.SQRT1_2, y: -Math.SQRT1_2 },\n  { x: Math.SQRT1_2, y: Math.SQRT1_2 },\n  { x: -Math.SQRT1_2, y: Math.SQRT1_2 },\n]\n/** Critically damped where a fold must never swing past flat, bouncy where it should land with a slap. */\nconst SPRINGS = {\n  hover: [300, 35],\n  back: [520, 46],\n  unfold: [380, 39],\n  follow: [900, 56],\n  lift: [320, 30],\n  slap: [700, 22],\n  tilt: [240, 20],\n  light: [170, 22],\n} satisfies Record<string, Spring>\n\n/** The sticker touched last sits on top, like the real thing. */\nlet topLayer = 10\n\nconst add = (a: Pt, b: Pt): Pt => ({ x: a.x + b.x, y: a.y + b.y })\nconst sub = (a: Pt, b: Pt): Pt => ({ x: a.x - b.x, y: a.y - b.y })\nconst mul = (a: Pt, k: number): Pt => ({ x: a.x * k, y: a.y * k })\nconst dot = (a: Pt, b: Pt) => a.x * b.x + a.y * b.y\nconst len = (a: Pt) => Math.hypot(a.x, a.y)\nconst unit = (a: Pt): Pt => {\n  const n = len(a)\n  return n ? { x: a.x / n, y: a.y / n } : { x: 0, y: 1 }\n}\nconst clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v))\n\n/** Keeps the half of a polygon on one side of the line through `m` with normal `u`. */\nfunction clipHalf(pts: Pt[], m: Pt, u: Pt, sign: 1 | -1) {\n  const out: Pt[] = []\n  const side = (p: Pt) => sign * ((p.x - m.x) * u.x + (p.y - m.y) * u.y)\n  for (let i = 0; i < pts.length; i++) {\n    const a = pts[i]\n    const b = pts[(i + 1) % pts.length]\n    const fa = side(a)\n    const fb = side(b)\n    if (fa >= 0) out.push(a)\n    if (fa >= 0 !== fb >= 0) {\n      const t = fa / (fa - fb)\n      out.push({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t })\n    }\n  }\n  return out\n}\n\nfunction polygon(pts: Pt[], off: number) {\n  if (pts.length < 3) return \"polygon(0 0, 0 0, 0 0)\"\n  return `polygon(${pts.map((p) => `${(p.x + off).toFixed(2)}px ${(p.y + off).toFixed(2)}px`).join(\", \")})`\n}\n\n/* ------------------------------------------------------------------ */\n/* Silhouette: where the sticker actually is, so peels start at its    */\n/* real edge instead of the empty corners of its box.                 */\n/* ------------------------------------------------------------------ */\n\ninterface Shape {\n  /** Offset of the grid from the sticker's top-left, in px. */\n  pad: number\n  cols: number\n  rows: number\n  mask: Uint8Array\n  total: number\n  center: Pt\n  /** The sticker's furthest points along each diagonal, where hover peels start. */\n  corners: Pt[]\n}\n\ntype Op =\n  | { kind: \"box\"; x: number; y: number; w: number; h: number; r: number }\n  | { kind: \"img\"; el: HTMLImageElement; fit: string; x: number; y: number; w: number; h: number }\n  | { kind: \"svg\"; url: string; x: number; y: number; w: number; h: number }\n\nconst SVG_PROPS = [\n  \"fill\",\n  \"fill-opacity\",\n  \"fill-rule\",\n  \"stroke\",\n  \"stroke-width\",\n  \"stroke-opacity\",\n  \"stroke-linecap\",\n  \"stroke-linejoin\",\n  \"opacity\",\n  \"display\",\n  \"visibility\",\n]\n\n/** An inline SVG as a standalone image, with its CSS-driven paint baked in. */\nfunction svgUrl(svg: SVGSVGElement) {\n  const clone = svg.cloneNode(true) as SVGSVGElement\n  const from = [svg, ...svg.querySelectorAll(\"*\")]\n  const to = [clone, ...clone.querySelectorAll(\"*\")]\n  from.forEach((node, i) => {\n    const cs = getComputedStyle(node)\n    const target = to[i] as SVGElement\n    for (const p of SVG_PROPS) target.style.setProperty(p, cs.getPropertyValue(p))\n  })\n  clone.setAttribute(\"xmlns\", \"http://www.w3.org/2000/svg\")\n  clone.setAttribute(\"width\", String(svg.clientWidth))\n  clone.setAttribute(\"height\", String(svg.clientHeight))\n  return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(new XMLSerializer().serializeToString(clone))}`\n}\n\nconst CLEAR = /^transparent$|rgba\\(.*,\\s*0\\)$|\\/\\s*0\\)$/\n\n/** Lists what paints inside the sticker: images, inline SVGs, backgrounds and text. Call untransformed. */\nfunction measure(front: HTMLElement, k: number) {\n  const origin = front.getBoundingClientRect()\n  const box = (r: DOMRect) => ({\n    x: (r.left - origin.left) / k,\n    y: (r.top - origin.top) / k,\n    w: r.width / k,\n    h: r.height / k,\n  })\n  const ops: Op[] = []\n  const walk = (el: Element) => {\n    if (el instanceof SVGSVGElement) {\n      ops.push({ kind: \"svg\", url: svgUrl(el), ...box(el.getBoundingClientRect()) })\n      return\n    }\n    if (!(el instanceof HTMLElement)) return\n    const cs = getComputedStyle(el)\n    if (cs.display === \"none\" || cs.visibility === \"hidden\" || cs.opacity === \"0\") return\n    if (el instanceof HTMLImageElement) {\n      ops.push({ kind: \"img\", el, fit: cs.objectFit, ...box(el.getBoundingClientRect()) })\n      return\n    }\n    if (cs.backgroundImage !== \"none\" || !CLEAR.test(cs.backgroundColor)) {\n      ops.push({ kind: \"box\", r: Number.parseFloat(cs.borderTopLeftRadius) || 0, ...box(el.getBoundingClientRect()) })\n    }\n    for (const node of el.childNodes) {\n      if (node.nodeType === Node.TEXT_NODE && node.textContent?.trim()) {\n        const range = document.createRange()\n        range.selectNodeContents(node)\n        for (const r of range.getClientRects()) ops.push({ kind: \"box\", r: 0, ...box(r) })\n      } else if (node instanceof Element) walk(node)\n    }\n  }\n  for (const child of front.children) walk(child)\n  return ops\n}\n\nfunction fitBox(el: HTMLImageElement, fit: string, x: number, y: number, w: number, h: number) {\n  const nw = el.naturalWidth\n  const nh = el.naturalHeight\n  if (fit === \"fill\" || !nw || !nh) return { x, y, w, h }\n  let k = 1\n  if (fit === \"contain\") k = Math.min(w / nw, h / nh)\n  else if (fit === \"cover\") k = Math.max(w / nw, h / nh)\n  else if (fit === \"scale-down\") k = Math.min(1, w / nw, h / nh)\n  return { x: x + (w - nw * k) / 2, y: y + (h - nh * k) / 2, w: nw * k, h: nh * k }\n}\n\nasync function rasterize(ops: Op[], cols: number, rows: number, pad: number): Promise<Uint8Array | null> {\n  if (!ops.length) return null\n  const canvas = document.createElement(\"canvas\")\n  canvas.width = cols\n  canvas.height = rows\n  const ctx = canvas.getContext(\"2d\", { willReadFrequently: true })\n  if (!ctx) return null\n  ctx.setTransform(1 / CELL, 0, 0, 1 / CELL, pad / CELL, pad / CELL)\n  const rect = (op: Op, r = 0) => {\n    ctx.beginPath()\n    ctx.roundRect(op.x, op.y, op.w, op.h, Math.min(r, op.w / 2, op.h / 2))\n    ctx.fill()\n  }\n  for (const op of ops) {\n    if (op.kind === \"box\") rect(op, op.r)\n    else if (op.kind === \"img\") {\n      await op.el.decode().catch(() => {})\n      if (!op.el.naturalWidth) {\n        rect(op)\n        continue\n      }\n      const f = fitBox(op.el, op.fit, op.x, op.y, op.w, op.h)\n      ctx.save()\n      ctx.beginPath()\n      ctx.rect(op.x, op.y, op.w, op.h)\n      ctx.clip()\n      ctx.drawImage(op.el, f.x, f.y, f.w, f.h)\n      ctx.restore()\n    } else {\n      const img = new Image()\n      img.src = op.url\n      try {\n        await img.decode()\n        ctx.drawImage(img, op.x, op.y, op.w, op.h)\n      } catch {\n        rect(op)\n      }\n    }\n  }\n  let data: Uint8ClampedArray\n  try {\n    data = ctx.getImageData(0, 0, cols, rows).data\n  } catch {\n    // A cross-origin image tainted the canvas: fall back to the boxes things sit in.\n    return rasterize(\n      ops.map((op) => (op.kind === \"box\" ? op : { kind: \"box\", r: 0, x: op.x, y: op.y, w: op.w, h: op.h })),\n      cols,\n      rows,\n      pad\n    )\n  }\n  const solid = new Uint8Array(cols * rows)\n  for (let i = 0; i < solid.length; i++) solid[i] = data[i * 4 + 3] > 64 ? 1 : 0\n  return solid\n}\n\nfunction boxSolid(cols: number, rows: number, pad: number, w: number, h: number) {\n  const solid = new Uint8Array(cols * rows)\n  for (let row = 0; row < rows; row++) {\n    for (let col = 0; col < cols; col++) {\n      const x = (col + 0.5) * CELL - pad\n      const y = (row + 0.5) * CELL - pad\n      if (x >= 0 && x <= w && y >= 0 && y <= h) solid[row * cols + col] = 1\n    }\n  }\n  return solid\n}\n\n/** Grows the painted cells by the die-cut border, then finds the centre and the corners. */\nfunction shapeFrom(solid: Uint8Array, cols: number, rows: number, pad: number, grow: number): Shape | null {\n  const r = Math.round(grow / CELL)\n  let mask = solid\n  if (r > 0) {\n    mask = new Uint8Array(cols * rows)\n    const kernel: number[] = []\n    for (let dy = -r; dy <= r; dy++) for (let dx = -r; dx <= r; dx++) if (dx * dx + dy * dy <= r * r + r) kernel.push(dx, dy)\n    for (let row = 0; row < rows; row++) {\n      for (let col = 0; col < cols; col++) {\n        if (!solid[row * cols + col]) continue\n        for (let i = 0; i < kernel.length; i += 2) {\n          const c = col + kernel[i]\n          const w = row + kernel[i + 1]\n          if (c >= 0 && c < cols && w >= 0 && w < rows) mask[w * cols + c] = 1\n        }\n      }\n    }\n  }\n  let total = 0\n  let sx = 0\n  let sy = 0\n  const best = DIAGONALS.map(() => ({ score: -Infinity, at: { x: 0, y: 0 } }))\n  for (let row = 0; row < rows; row++) {\n    for (let col = 0; col < cols; col++) {\n      if (!mask[row * cols + col]) continue\n      const p = { x: (col + 0.5) * CELL - pad, y: (row + 0.5) * CELL - pad }\n      total++\n      sx += p.x\n      sy += p.y\n      DIAGONALS.forEach((d, i) => {\n        const score = dot(p, d)\n        if (score > best[i].score) best[i] = { score, at: p }\n      })\n    }\n  }\n  if (!total) return null\n  return { pad, cols, rows, mask, total, center: { x: sx / total, y: sy / total }, corners: best.map((b) => b.at) }\n}\n\n/* ------------------------------------------------------------------ */\n/* Engine: everything per frame lives here, outside React.             */\n/* ------------------------------------------------------------------ */\n\ninterface Options {\n  border: number\n  threshold: number\n  movable: boolean\n  bounded: boolean\n  hoverPeel: boolean\n  rotate: number\n  haptics: boolean\n  onPeel: () => void\n  onStick: (offset: Pt) => void\n  announce: (message: string) => void\n}\n\ninterface Els {\n  root: HTMLDivElement\n  mover: HTMLDivElement\n  front: HTMLDivElement\n  liftShadow: HTMLDivElement\n  flapShadow: HTMLDivElement\n  back: HTMLDivElement\n  shade: HTMLDivElement\n  /** The gloss over the artwork and the lights that draw it. Absent on a matte sticker. */\n  sheen: () => HTMLDivElement | null\n  lights: () => SVGFEPointLightElement[]\n}\n\nfunction createSticker(el: Els, offset: Pt, get: () => Options) {\n  const reduced = () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n\n  const s = {\n    w: 0,\n    h: 0,\n    shape: null as Shape | null,\n    build: 0,\n    alive: true,\n    mode: \"idle\" as \"idle\" | \"peel\" | \"carry\",\n    /** Lifted from the keyboard. */\n    held: false,\n    heldFrom: { x: 0, y: 0 },\n    pointer: null as number | null,\n    rect: null as DOMRect | null,\n    bounds: null as { x0: number; x1: number; y0: number; y1: number } | null,\n    down: { x: 0, y: 0 },\n    downRoot: { x: 0, y: 0 },\n    v0: { x: 0, y: 0 },\n    /** Where the peel starts, on the sticker's edge. */\n    anchor: null as Pt | null,\n    /** Unit vector from the anchor into the sticker. */\n    inward: { x: 0, y: 1 },\n    /** The fold: from the anchor to where the anchor has been folded over to. */\n    v: { x: 0, y: 0 },\n    vv: { x: 0, y: 0 },\n    vt: { x: 0, y: 0 },\n    vSpring: SPRINGS.back as Spring,\n    want: -1,\n    wantAmount: 0,\n    corner: -1,\n    T: { ...offset },\n    TV: { x: 0, y: 0 },\n    Tt: { ...offset },\n    T0: { ...offset },\n    lift: 0,\n    liftV: 0,\n    liftT: 0,\n    liftSpring: SPRINGS.lift as Spring,\n    tilt: 0,\n    tiltV: 0,\n    tiltT: 0,\n    last: { x: 0, t: 0 },\n    /** Where the gloss sits, in the sticker's own space. It trails the pointer on a spring. */\n    light: { x: 0, y: 0 },\n    lightV: { x: 0, y: 0 },\n    lightT: { x: 0, y: 0 },\n    lightKey: \"\",\n    raf: 0,\n    prev: 0,\n  }\n\n  /** Where the gloss rests when nothing is moving it: up and to the left, like light from a window. */\n  const restLight = (): Pt => ({ x: s.w * 0.28, y: s.h * 0.16 })\n\n  function inside(p: Pt) {\n    const sh = s.shape\n    if (!sh) {\n      const b = get().border\n      return p.x >= -b && p.x <= s.w + b && p.y >= -b && p.y <= s.h + b\n    }\n    const col = Math.floor((p.x + sh.pad) / CELL)\n    const row = Math.floor((p.y + sh.pad) / CELL)\n    return col >= 0 && col < sh.cols && row >= 0 && row < sh.rows && sh.mask[row * sh.cols + col] === 1\n  }\n\n  const center = () => s.shape?.center ?? { x: s.w / 2, y: s.h / 2 }\n\n  /** Walks from `p` along `dir` to the sticker's edge. */\n  function edgeFrom(p: Pt, dir: Pt) {\n    let q = p\n    for (let t = 1, n = s.w + s.h + PAD; t < n; t++) {\n      const next = add(p, mul(dir, t))\n      if (!inside(next)) break\n      q = next\n    }\n    return q\n  }\n\n  /** Share of the sticker on the lifted side of the fold. */\n  function progress(m: Pt, u: Pt) {\n    const sh = s.shape\n    if (!sh) return 0\n    let lifted = 0\n    for (let row = 0; row < sh.rows; row++) {\n      const y = (row + 0.5) * CELL - sh.pad - m.y\n      for (let col = 0; col < sh.cols; col++) {\n        if (!sh.mask[row * sh.cols + col]) continue\n        if (((col + 0.5) * CELL - sh.pad - m.x) * u.x + y * u.y < 0) lifted++\n      }\n    }\n    return lifted / sh.total\n  }\n\n  const rootRect = () => s.rect ?? el.root.getBoundingClientRect()\n  const ratio = (r: DOMRect) => (s.w ? r.width / s.w : 1) || 1\n\n  /** A pointer position in the sticker's own, unrotated space. */\n  function local(cx: number, cy: number): Pt {\n    const r = rootRect()\n    const k = ratio(r)\n    const dx = (cx - (r.left + (s.w / 2 + s.T.x) * k)) / k\n    const dy = (cy - (r.top + (s.h / 2 + s.T.y) * k)) / k\n    const a = (-(get().rotate + s.tilt) * Math.PI) / 180\n    const sc = 1 + LIFT_SCALE * s.lift\n    return {\n      x: (dx * Math.cos(a) - dy * Math.sin(a)) / sc + s.w / 2,\n      y: (dx * Math.sin(a) + dy * Math.cos(a)) / sc + s.h / 2,\n    }\n  }\n\n  function rootPt(cx: number, cy: number): Pt {\n    const r = rootRect()\n    const k = ratio(r)\n    return { x: (cx - r.left) / k, y: (cy - r.top) / k }\n  }\n\n  /** Keeps the sticker's centre inside its parent. */\n  function measureBounds() {\n    const parent = el.root.parentElement\n    if (!get().bounded || !parent) return null\n    const r = rootRect()\n    const k = ratio(r)\n    const p = parent.getBoundingClientRect()\n    return {\n      x0: (p.left - r.left) / k - s.w / 2,\n      x1: (p.right - r.left) / k - s.w / 2,\n      y0: (p.top - r.top) / k - s.h / 2,\n      y1: (p.bottom - r.top) / k - s.h / 2,\n    }\n  }\n\n  /** Past the edge the sticker follows with growing resistance, then springs back in on release. */\n  function rubber(v: number, lo: number, hi: number) {\n    const give = (d: number) => 48 * (1 - Math.exp(-d / 96))\n    if (v < lo) return lo - give(lo - v)\n    if (v > hi) return hi + give(v - hi)\n    return v\n  }\n\n  function inBounds(t: Pt, soft: boolean): Pt {\n    const b = s.bounds\n    if (!b) return t\n    if (soft) return { x: rubber(t.x, b.x0, b.x1), y: rubber(t.y, b.y0, b.y1) }\n    return { x: clamp(t.x, b.x0, Math.max(b.x0, b.x1)), y: clamp(t.y, b.y0, Math.max(b.y0, b.y1)) }\n  }\n\n  function raise() {\n    el.root.style.zIndex = String(++topLayer)\n  }\n\n  function setState(state: \"peeling\" | \"held\" | null) {\n    if (state) el.mover.dataset.state = state\n    else delete el.mover.dataset.state\n  }\n\n  const hide = (node: HTMLElement) => {\n    node.style.visibility = \"hidden\"\n  }\n\n  function render() {\n    const { rotate } = get()\n    el.mover.style.transform = `translate(${s.T.x.toFixed(2)}px, ${s.T.y.toFixed(2)}px) rotate(${(rotate + s.tilt).toFixed(2)}deg) scale(${(1 + LIFT_SCALE * s.lift).toFixed(4)})`\n    const up = Math.max(0, s.lift)\n    el.liftShadow.style.opacity = (up * 0.32).toFixed(3)\n    el.liftShadow.style.transform = `translate(0, ${(2 + up * 12).toFixed(2)}px)`\n    el.liftShadow.style.visibility = up > 0.002 ? \"visible\" : \"hidden\"\n\n    // The gloss: one light for a clear laminate, a ring of coloured ones for foil. The ring turns\n    // as the light crosses the sticker, so the colours trade places the way foil does.\n    const lights = el.lights()\n    if (lights.length) {\n      const ring = lights.length > 1 ? Math.min(s.w, s.h) * 0.34 : 0\n      const turn = (s.light.x / Math.max(1, s.w)) * Math.PI\n      const key = `${s.light.x.toFixed(1)},${s.light.y.toFixed(1)},${s.w},${s.h},${lights.length}`\n      if (key !== s.lightKey) {\n        s.lightKey = key\n        const z = (Math.max(s.w, s.h) * 0.55).toFixed(1)\n        lights.forEach((light, i) => {\n          const a = turn + (i * Math.PI * 2) / lights.length\n          light.setAttribute(\"x\", (s.light.x + PAD + Math.cos(a) * ring).toFixed(1))\n          light.setAttribute(\"y\", (s.light.y + PAD + Math.sin(a) * ring).toFixed(1))\n          light.setAttribute(\"z\", z)\n        })\n      }\n    }\n    const sheen = el.sheen()\n\n    const n = len(s.v)\n    if (!s.anchor || n < 0.4 || dot(s.v, s.inward) <= 0) {\n      el.front.style.clipPath = \"\"\n      if (sheen) sheen.style.clipPath = \"\"\n      hide(el.back)\n      hide(el.shade)\n      hide(el.flapShadow)\n      return\n    }\n    const u = mul(s.v, 1 / n)\n    const m = add(s.anchor, mul(s.v, 0.5))\n    const box = [\n      { x: -PAD, y: -PAD },\n      { x: s.w + PAD, y: -PAD },\n      { x: s.w + PAD, y: s.h + PAD },\n      { x: -PAD, y: s.h + PAD },\n    ]\n    const flat = clipHalf(box, m, u, 1)\n    el.front.style.clipPath = polygon(flat, 0)\n    if (sheen) sheen.style.clipPath = polygon(flat, PAD)\n    const lifted = polygon(clipHalf(box, m, u, -1), PAD)\n\n    // Reflection across the fold. It fixes the fold line and lands the anchor on its folded spot.\n    const d = 2 * dot(m, u)\n    const b = -2 * u.x * u.y\n    const mirror = `matrix(${1 - 2 * u.x * u.x}, ${b}, ${b}, ${1 - 2 * u.y * u.y}, ${d * u.x}, ${d * u.y})`\n    const fade = Math.min(1, n / 14)\n\n    for (const node of [el.back, el.shade, el.flapShadow]) {\n      node.style.visibility = \"visible\"\n      node.style.clipPath = lifted\n    }\n    el.back.style.transform = mirror\n    el.shade.style.transform = mirror\n    el.flapShadow.style.transform = `translate(${(u.x * 1.5).toFixed(2)}px, ${(u.y * 1.5 + 1.5).toFixed(2)}px) ${mirror}`\n    el.flapShadow.style.opacity = (fade * 0.42).toFixed(3)\n\n    // Crease shading on the back of the flap, darkest at the fold, laid out in the layer's box.\n    const W = s.w + PAD * 2\n    const H = s.h + PAD * 2\n    const dir = { x: -u.x, y: -u.y }\n    const L = Math.abs(W * dir.x) + Math.abs(H * dir.y)\n    const start = { x: W / 2 - (dir.x * L) / 2, y: H / 2 - (dir.y * L) / 2 }\n    const p0 = (m.x + PAD - start.x) * dir.x + (m.y + PAD - start.y) * dir.y\n    const deg = (Math.atan2(dir.x, -dir.y) * 180) / Math.PI\n    const reach = Math.max(10, n * 0.4)\n    const mask = `linear-gradient(${deg.toFixed(2)}deg, #000 ${p0.toFixed(1)}px, rgb(0 0 0 / 0.45) ${(p0 + 2.5).toFixed(1)}px, transparent ${(p0 + reach).toFixed(1)}px)`\n    el.shade.style.setProperty(\"mask-image\", mask)\n    el.shade.style.setProperty(\"-webkit-mask-image\", mask)\n    el.shade.style.opacity = (fade * 0.34).toFixed(3)\n  }\n\n  function curlVector() {\n    const size = clamp(Math.min(s.w, s.h) * 0.2, 10, 30)\n    return mul(s.inward, size * s.wantAmount)\n  }\n\n  /** Moves the hover peel between corners, flattening the old one before lifting the next. */\n  function reconcileHover() {\n    if (s.want !== s.corner) {\n      if (len(s.v) < 0.6) {\n        s.corner = s.want\n        s.v = { x: 0, y: 0 }\n        s.vv = { x: 0, y: 0 }\n        const at = s.corner >= 0 ? s.shape?.corners[s.corner] : undefined\n        s.anchor = at ?? null\n        if (at) s.inward = unit(sub(center(), at))\n      } else s.vt = { x: 0, y: 0 }\n      s.vSpring = SPRINGS.hover\n    }\n    if (s.want === s.corner && s.corner >= 0) {\n      s.vt = curlVector()\n      s.vSpring = SPRINGS.hover\n    }\n  }\n\n  function integrate(x: number, vel: number, target: number, [k, c]: Spring, dt: number) {\n    const a = -k * (x - target) - c * vel\n    vel += a * dt\n    return [x + vel * dt, vel] as const\n  }\n\n  function frame(now: number) {\n    s.raf = 0\n    const elapsed = Math.min(1 / 30, s.prev ? (now - s.prev) / 1000 : 1 / 60)\n    s.prev = now\n    const snap = reduced()\n    if (s.mode === \"idle\" && !s.held) reconcileHover()\n    // Carried, the gloss slides against the direction of travel, as it does on a card tipped in the hand.\n    if (s.mode === \"carry\") {\n      const rest = restLight()\n      s.lightT = {\n        x: clamp(rest.x - s.TV.x * 0.05, -s.w * 0.4, s.w * 1.4),\n        y: clamp(rest.y - s.TV.y * 0.05, -s.h * 0.4, s.h * 1.4),\n      }\n    }\n\n    const steps = Math.max(1, Math.ceil(elapsed / (1 / 120)))\n    const dt = elapsed / steps\n    for (let i = 0; i < steps; i++) {\n      if (s.mode !== \"peel\") {\n        ;[s.v.x, s.vv.x] = integrate(s.v.x, s.vv.x, s.vt.x, s.vSpring, dt)\n        ;[s.v.y, s.vv.y] = integrate(s.v.y, s.vv.y, s.vt.y, s.vSpring, dt)\n      }\n      ;[s.T.x, s.TV.x] = integrate(s.T.x, s.TV.x, s.Tt.x, SPRINGS.follow, dt)\n      ;[s.T.y, s.TV.y] = integrate(s.T.y, s.TV.y, s.Tt.y, SPRINGS.follow, dt)\n      ;[s.lift, s.liftV] = integrate(s.lift, s.liftV, s.liftT, s.liftSpring, dt)\n      ;[s.tilt, s.tiltV] = integrate(s.tilt, s.tiltV, s.tiltT, SPRINGS.tilt, dt)\n      ;[s.light.x, s.lightV.x] = integrate(s.light.x, s.lightV.x, s.lightT.x, SPRINGS.light, dt)\n      ;[s.light.y, s.lightV.y] = integrate(s.light.y, s.lightV.y, s.lightT.y, SPRINGS.light, dt)\n    }\n    // A fold springing flat must never swing through to the other side.\n    if (s.anchor && s.mode !== \"peel\" && dot(s.v, s.inward) <= 0) {\n      s.v = { x: 0, y: 0 }\n      s.vv = { x: 0, y: 0 }\n    }\n    s.tiltT *= Math.exp(-elapsed * 8)\n    if (snap) {\n      if (s.mode !== \"peel\") s.v = { ...s.vt }\n      s.T = { ...s.Tt }\n      s.lift = s.liftT\n      s.tilt = 0\n      s.tiltT = 0\n      s.lightT = restLight()\n      s.light = { ...s.lightT }\n      s.lightV = { x: 0, y: 0 }\n    }\n    render()\n\n    const busy =\n      len(sub(s.v, s.vt)) > 0.02 ||\n      len(s.vv) > 0.02 ||\n      len(sub(s.T, s.Tt)) > 0.02 ||\n      len(s.TV) > 0.02 ||\n      Math.abs(s.lift - s.liftT) > 0.001 ||\n      Math.abs(s.liftV) > 0.001 ||\n      Math.abs(s.tilt) > 0.01 ||\n      Math.abs(s.tiltV) > 0.01 ||\n      len(sub(s.light, s.lightT)) > 0.3 ||\n      len(s.lightV) > 0.5 ||\n      s.want !== s.corner\n    if (busy) kick()\n    else {\n      s.prev = 0\n      if (s.mode === \"idle\" && s.corner < 0 && len(s.v) < 0.05) s.anchor = null\n    }\n  }\n\n  function kick() {\n    if (!s.raf && s.alive) s.raf = requestAnimationFrame(frame)\n  }\n\n  function buzz() {\n    if (get().haptics) navigator.vibrate?.(10)\n  }\n\n  function peelOff(e: PointerEvent) {\n    s.mode = \"carry\"\n    setState(\"held\")\n    s.vt = { x: 0, y: 0 }\n    s.vSpring = SPRINGS.unfold\n    s.liftT = 1\n    s.liftSpring = SPRINGS.lift\n    const r = rootPt(e.clientX, e.clientY)\n    s.Tt = inBounds(add(s.T0, sub(r, s.downRoot)), true)\n    s.last = { x: r.x, t: performance.now() }\n    buzz()\n    get().onPeel()\n    kick()\n  }\n\n  function stick() {\n    s.mode = \"idle\"\n    s.held = false\n    setState(null)\n    s.Tt = inBounds(s.Tt, false)\n    s.liftT = 0\n    s.liftSpring = SPRINGS.slap\n    s.tiltT = 0\n    buzz()\n    s.lightT = restLight()\n    get().onStick({ ...s.Tt })\n    kick()\n  }\n\n  async function rebuild() {\n    const id = ++s.build\n    if (!s.w || !s.h) return\n    const { border } = get()\n    const pad = Math.ceil(border) + 2\n    const cols = Math.ceil((s.w + pad * 2) / CELL)\n    const rows = Math.ceil((s.h + pad * 2) / CELL)\n    const fallback = () => shapeFrom(boxSolid(cols, rows, pad, s.w, s.h), cols, rows, pad, border)\n    if (!s.shape) s.shape = fallback()\n    // Measure untransformed, so a rotated sticker reads its own layout.\n    const saved = el.mover.style.transform\n    el.mover.style.transform = \"none\"\n    let ops: Op[]\n    try {\n      ops = measure(el.front, ratio(el.front.getBoundingClientRect()))\n    } finally {\n      el.mover.style.transform = saved\n    }\n    const solid = await rasterize(ops, cols, rows, pad)\n    if (id !== s.build || !s.alive) return\n    s.shape = (solid && shapeFrom(solid, cols, rows, pad, border)) || fallback()\n  }\n\n  return {\n    resize() {\n      const w = el.front.offsetWidth\n      const h = el.front.offsetHeight\n      if (w === s.w && h === s.h) return\n      s.w = w\n      s.h = h\n      s.shape = null\n      s.lightT = restLight()\n      s.light = { ...s.lightT }\n      s.lightV = { x: 0, y: 0 }\n      void rebuild()\n      render()\n    },\n    rebuild,\n    sync() {\n      render()\n    },\n    down(e: PointerEvent, target: HTMLElement) {\n      if (s.pointer !== null || s.held) return\n      if (e.pointerType === \"mouse\" && e.button !== 0) return\n      s.rect = el.root.getBoundingClientRect()\n      const p = local(e.clientX, e.clientY)\n      if (!inside(p)) {\n        s.rect = null\n        return\n      }\n      s.pointer = e.pointerId\n      target.setPointerCapture(e.pointerId)\n      raise()\n      s.mode = \"peel\"\n      setState(\"peeling\")\n      s.down = p\n      s.downRoot = rootPt(e.clientX, e.clientY)\n      s.T0 = { ...s.Tt }\n      s.bounds = measureBounds()\n      // Pressing on a corner that's already curling carries on from that curl.\n      if (s.corner >= 0 && s.anchor && len(s.v) > 0.5) s.v0 = { ...s.v }\n      else {\n        s.v0 = { x: 0, y: 0 }\n        s.v = { x: 0, y: 0 }\n        s.anchor = null\n      }\n      s.vv = { x: 0, y: 0 }\n      s.corner = -1\n      s.want = -1\n      render()\n    },\n    move(e: PointerEvent) {\n      if (s.pointer === null) {\n        if (e.pointerType !== \"mouse\" || reduced() || s.mode !== \"idle\" || s.held) return\n        const p = local(e.clientX, e.clientY)\n        // The gloss follows the mouse across the sticker.\n        s.lightT = p\n        if (!get().hoverPeel || !s.shape) {\n          kick()\n          return\n        }\n        const zone = Math.min(s.w, s.h) * 0.32 + get().border\n        let best = -1\n        let gap = zone\n        s.shape.corners.forEach((c, i) => {\n          const d = len(sub(p, c))\n          if (d < gap) {\n            best = i\n            gap = d\n          }\n        })\n        s.want = best\n        s.wantAmount = best < 0 ? 0 : clamp(1.2 - gap / zone, 0.45, 1)\n        kick()\n        return\n      }\n      if (e.pointerId !== s.pointer) return\n\n      if (s.mode === \"peel\") {\n        const p = local(e.clientX, e.clientY)\n        const drag = sub(p, s.down)\n        let v = add(s.v0, drag)\n        if (!s.anchor) {\n          if (len(drag) < 3) return\n          const c = center()\n          const rel = sub(s.down, c)\n          // Peel from the edge nearest the press. From the middle, peel from the side being dragged away from.\n          const dir = len(rel) > Math.min(s.w, s.h) * 0.12 ? unit(rel) : unit(mul(drag, -1))\n          s.anchor = edgeFrom(s.down, dir)\n          const into = sub(c, s.anchor)\n          s.inward = len(into) > 1 ? unit(into) : mul(dir, -1)\n        }\n        // Dragging outward still peels, folding the edge back over the sticker.\n        const into = dot(v, s.inward)\n        if (into < 0) v = sub(v, mul(s.inward, 2 * into))\n        s.v = v\n        s.vt = { x: 0, y: 0 }\n        const n = len(v)\n        if (n > 0.4 && get().movable) {\n          const u = mul(v, 1 / n)\n          if (progress(add(s.anchor, mul(v, 0.5)), u) >= get().threshold) {\n            peelOff(e)\n            return\n          }\n        }\n        render()\n        return\n      }\n\n      if (s.mode === \"carry\") {\n        const r = rootPt(e.clientX, e.clientY)\n        const now = performance.now()\n        const speed = (r.x - s.last.x) / Math.max(1, now - s.last.t)\n        s.last = { x: r.x, t: now }\n        if (!reduced()) s.tiltT = clamp(s.tiltT * 0.5 + speed * 5, -10, 10)\n        s.Tt = inBounds(add(s.T0, sub(r, s.downRoot)), true)\n        kick()\n      }\n    },\n    up(e: PointerEvent) {\n      if (e.pointerId !== s.pointer) return\n      s.pointer = null\n      s.rect = null\n      if (s.mode === \"peel\") {\n        // Let go early: the flap falls back flat.\n        s.mode = \"idle\"\n        setState(null)\n        s.vt = { x: 0, y: 0 }\n        s.vSpring = SPRINGS.back\n        kick()\n      } else if (s.mode === \"carry\") stick()\n    },\n    leave() {\n      s.want = -1\n      if (s.mode === \"idle\") s.lightT = restLight()\n      kick()\n    },\n    key(e: KeyboardEvent) {\n      const lifting = e.key === \"Enter\" || e.key === \" \"\n      if (lifting) {\n        if (e.repeat || s.pointer !== null) return true\n        if (!s.held) {\n          s.held = true\n          s.want = -1\n          s.heldFrom = { ...s.Tt }\n          s.bounds = measureBounds()\n          s.liftT = 1\n          s.liftSpring = SPRINGS.lift\n          raise()\n          setState(\"held\")\n          get().onPeel()\n          get().announce(\"Peeled off. Arrow keys move it, Enter sticks it down, Escape puts it back.\")\n        } else {\n          stick()\n          get().announce(\"Stuck down.\")\n        }\n        kick()\n        return true\n      }\n      if (!s.held) return false\n      if (e.key === \"Escape\") {\n        s.Tt = { ...s.heldFrom }\n        stick()\n        get().announce(\"Put back.\")\n        return true\n      }\n      const step = e.shiftKey ? 40 : 10\n      const moves: Record<string, Pt> = {\n        ArrowLeft: { x: -step, y: 0 },\n        ArrowRight: { x: step, y: 0 },\n        ArrowUp: { x: 0, y: -step },\n        ArrowDown: { x: 0, y: step },\n      }\n      const by = moves[e.key]\n      if (!by) return false\n      s.Tt = inBounds(add(s.Tt, by), false)\n      kick()\n      return true\n    },\n    blur() {\n      if (s.held) stick()\n    },\n    destroy() {\n      s.alive = false\n      cancelAnimationFrame(s.raf)\n    },\n  }\n}\n\ntype Engine = ReturnType<typeof createSticker>\n\n/* ------------------------------------------------------------------ */\n\n/** A copy of the sticker behind or over the real one: inert, hidden from assistive tech, padded for overspill. */\nfunction Layer({\n  ref,\n  children,\n  filter,\n  shown = false,\n}: {\n  ref: React.Ref<HTMLDivElement>\n  children: React.ReactNode\n  filter: string\n  /** Most layers only appear mid-peel, switched on by the engine. The gloss is always there. */\n  shown?: boolean\n}) {\n  return (\n    <div\n      ref={ref}\n      aria-hidden\n      inert\n      className=\"pointer-events-none absolute\"\n      style={{ inset: -PAD, transformOrigin: `${PAD}px ${PAD}px`, filter, visibility: shown ? undefined : \"hidden\" }}\n    >\n      <div className=\"absolute grid\" style={{ inset: PAD }}>\n        {children}\n      </div>\n    </div>\n  )\n}\n\n/** Grows the sticker's alpha by the border, rounded rather than boxy, into `grown`. */\nfunction Grow({ border }: { border: number }) {\n  if (border <= 0) {\n    return (\n      <feComponentTransfer in=\"SourceAlpha\" result=\"grown\">\n        <feFuncA type=\"identity\" />\n      </feComponentTransfer>\n    )\n  }\n  return (\n    <>\n      <feMorphology in=\"SourceAlpha\" operator=\"dilate\" radius={border * 0.5} result=\"dilated\" />\n      <feGaussianBlur in=\"dilated\" stdDeviation={border * 0.35} result=\"soft\" />\n      <feComponentTransfer in=\"soft\" result=\"grown\">\n        <feFuncA type=\"linear\" slope={8} intercept={-0.6} />\n      </feComponentTransfer>\n    </>\n  )\n}\n\nexport type StickerFinish = \"matte\" | \"gloss\" | \"holo\"\n\n/** The lights behind each finish. One white light is a laminate; three coloured ones are foil. */\nconst FINISH_LIGHTS: Record<StickerFinish, string[]> = {\n  matte: [],\n  gloss: [\"#ffffff\"],\n  holo: [\"#7df3ff\", \"#ff9be0\", \"#fff59a\"],\n}\n\nexport interface StickerProps extends Omit<React.ComponentProps<\"div\">, \"children\"> {\n  /** The sticker's artwork: an image, an inline SVG, or any element. Its painted shape becomes the die cut. */\n  children: React.ReactNode\n  /** Width of the die-cut border, in px. `0` for none. */\n  border?: number\n  /** Colour of the die-cut border. */\n  borderColor?: string\n  /** Colour of the sticker's back, seen on the peeled flap. */\n  backColor?: string\n  /**\n   * The surface. \"gloss\" is a clear laminate with a highlight that follows the mouse and slides as\n   * the sticker is carried; \"holo\" is foil, with coloured light that shifts as it moves; \"matte\" has\n   * no shine. Default \"gloss\".\n   */\n  finish?: StickerFinish\n  /** Print a faint ruled grid on the back, like the liner a sticker peels from. Default true. */\n  liner?: boolean\n  /** Tilt, in degrees. */\n  rotate?: number\n  /** Share of the sticker, 0 to 1, that has to be peeled before it comes off in your hand. */\n  threshold?: number\n  /** Let the sticker come off and be stuck down somewhere else. When `false` it only peels and falls back. */\n  movable?: boolean\n  /** Keep a moved sticker's centre inside its parent. */\n  bounded?: boolean\n  /** Curl the nearest corner up as the mouse comes close. */\n  hoverPeel?: boolean\n  /** Where the sticker starts, relative to its place in the layout, in px. */\n  defaultOffset?: { x: number; y: number }\n  /** Called when the sticker comes off, by peeling or the keyboard. */\n  onPeel?: () => void\n  /** Called when the sticker is stuck down, with its offset from its place in the layout. */\n  onStick?: (offset: { x: number; y: number }) => void\n  /** Accessible name. Defaults to \"Sticker\". */\n  label?: string\n  /** Buzz the device as the sticker comes off and goes down, where the Vibration API exists. */\n  haptics?: boolean\n}\n\nexport function Sticker({\n  children,\n  border = 6,\n  borderColor = \"#ffffff\",\n  backColor = \"#eceae4\",\n  finish = \"gloss\",\n  liner = true,\n  rotate = 0,\n  threshold = 0.4,\n  movable = true,\n  bounded = true,\n  hoverPeel = true,\n  defaultOffset,\n  onPeel,\n  onStick,\n  label = \"Sticker\",\n  haptics = true,\n  className,\n  style,\n  ...props\n}: StickerProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null)\n  const moverRef = React.useRef<HTMLDivElement>(null)\n  const frontRef = React.useRef<HTMLDivElement>(null)\n  const liftShadowRef = React.useRef<HTMLDivElement>(null)\n  const flapShadowRef = React.useRef<HTMLDivElement>(null)\n  const backRef = React.useRef<HTMLDivElement>(null)\n  const shadeRef = React.useRef<HTMLDivElement>(null)\n  const sheenRef = React.useRef<HTMLDivElement>(null)\n  const lightsRef = React.useRef<(SVGFEPointLightElement | null)[]>([])\n  const engineRef = React.useRef<Engine | null>(null)\n  const [message, setMessage] = React.useState(\"\")\n\n  const uid = `sticker-${React.useId().replace(/[^a-zA-Z0-9_-]/g, \"\")}`\n  const hintId = `${uid}-hint`\n  const ids = { cut: `${uid}-cut`, back: `${uid}-back`, ink: `${uid}-ink`, sheen: `${uid}-sheen` }\n  const lights = FINISH_LIGHTS[finish]\n  const start = React.useRef(defaultOffset ?? { x: 0, y: 0 }).current\n\n  const options = React.useRef<Options>(null!)\n  options.current = {\n    border,\n    threshold,\n    movable,\n    bounded,\n    hoverPeel,\n    rotate,\n    haptics,\n    onPeel: () => onPeel?.(),\n    onStick: (offset) => onStick?.(offset),\n    announce: setMessage,\n  }\n\n  React.useEffect(() => {\n    const engine = createSticker(\n      {\n        root: rootRef.current!,\n        mover: moverRef.current!,\n        front: frontRef.current!,\n        liftShadow: liftShadowRef.current!,\n        flapShadow: flapShadowRef.current!,\n        back: backRef.current!,\n        shade: shadeRef.current!,\n        sheen: () => sheenRef.current,\n        lights: () => lightsRef.current.filter((light) => light !== null),\n      },\n      start,\n      () => options.current\n    )\n    engineRef.current = engine\n    engine.resize()\n    const front = frontRef.current!\n    const ro = new ResizeObserver(() => engine.resize())\n    ro.observe(front)\n    // Re-read the silhouette when the artwork changes or an image finishes loading.\n    let queued = 0\n    const refresh = () => {\n      cancelAnimationFrame(queued)\n      queued = requestAnimationFrame(() => void engine.rebuild())\n    }\n    // The engine writes the front's own clip-path every frame, so only changes inside it count.\n    const mo = new MutationObserver((records) => {\n      if (records.some((r) => r.target !== front)) refresh()\n    })\n    mo.observe(front, { subtree: true, childList: true, attributes: true, characterData: true })\n    front.addEventListener(\"load\", refresh, true)\n    return () => {\n      ro.disconnect()\n      mo.disconnect()\n      front.removeEventListener(\"load\", refresh, true)\n      cancelAnimationFrame(queued)\n      engine.destroy()\n      engineRef.current = null\n    }\n  }, [start])\n\n  React.useEffect(() => {\n    void engineRef.current?.rebuild()\n  }, [border])\n\n  React.useEffect(() => {\n    engineRef.current?.sync()\n  }, [rotate, finish])\n\n  return (\n    <div\n      ref={rootRef}\n      className={cn(\"pointer-events-none relative inline-block align-top\", className)}\n      style={style}\n      {...props}\n    >\n      <svg aria-hidden width=\"0\" height=\"0\" className=\"absolute\">\n        <defs>\n          <filter id={ids.cut} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\" colorInterpolationFilters=\"sRGB\">\n            <Grow border={border} />\n            <feFlood floodColor={borderColor} />\n            <feComposite in2=\"grown\" operator=\"in\" result=\"paper\" />\n            <feGaussianBlur in=\"grown\" stdDeviation=\"0.8\" />\n            <feOffset dy=\"0.8\" result=\"tightBlur\" />\n            <feFlood floodColor=\"#000\" floodOpacity=\"0.24\" />\n            <feComposite in2=\"tightBlur\" operator=\"in\" result=\"tight\" />\n            <feGaussianBlur in=\"grown\" stdDeviation=\"3\" />\n            <feOffset dy=\"2.5\" result=\"softBlur\" />\n            <feFlood floodColor=\"#000\" floodOpacity=\"0.12\" />\n            <feComposite in2=\"softBlur\" operator=\"in\" result=\"soft\" />\n            {/* Thickness: a hairline round the cut, and a darker lip along the bottom edge. */}\n            <feMorphology in=\"grown\" operator=\"dilate\" radius=\"0.6\" result=\"fat\" />\n            <feComposite in=\"fat\" in2=\"grown\" operator=\"out\" result=\"ring\" />\n            <feFlood floodColor=\"#000\" floodOpacity=\"0.1\" />\n            <feComposite in2=\"ring\" operator=\"in\" result=\"outline\" />\n            <feOffset in=\"grown\" dy=\"-1.1\" result=\"raised\" />\n            <feComposite in=\"grown\" in2=\"raised\" operator=\"out\" result=\"lip\" />\n            <feFlood floodColor=\"#000\" floodOpacity=\"0.14\" />\n            <feComposite in2=\"lip\" operator=\"in\" result=\"edge\" />\n            <feMerge>\n              <feMergeNode in=\"soft\" />\n              <feMergeNode in=\"tight\" />\n              <feMergeNode in=\"outline\" />\n              <feMergeNode in=\"paper\" />\n              <feMergeNode in=\"SourceGraphic\" />\n              <feMergeNode in=\"edge\" />\n            </feMerge>\n          </filter>\n          <filter id={ids.back} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\" colorInterpolationFilters=\"sRGB\">\n            <Grow border={border} />\n            <feFlood floodColor={backColor} />\n            <feComposite in2=\"grown\" operator=\"in\" result=\"paper\" />\n            {liner && (\n              <>\n                {/* One 9px cell with a line down its left and along its top, tiled into a grid. */}\n                <feFlood x=\"0\" y=\"0\" width=\"1\" height=\"9\" floodColor=\"#000\" floodOpacity=\"0.07\" result=\"down\" />\n                <feFlood x=\"0\" y=\"0\" width=\"9\" height=\"1\" floodColor=\"#000\" floodOpacity=\"0.07\" result=\"across\" />\n                <feMerge x=\"0\" y=\"0\" width=\"9\" height=\"9\" result=\"cell\">\n                  <feMergeNode in=\"down\" />\n                  <feMergeNode in=\"across\" />\n                </feMerge>\n                <feTile in=\"cell\" result=\"grid\" />\n                <feComposite in=\"grid\" in2=\"grown\" operator=\"in\" result=\"lines\" />\n                <feMerge>\n                  <feMergeNode in=\"paper\" />\n                  <feMergeNode in=\"lines\" />\n                </feMerge>\n              </>\n            )}\n          </filter>\n          {lights.length > 0 && (\n            <filter id={ids.sheen} x=\"0\" y=\"0\" width=\"100%\" height=\"100%\" colorInterpolationFilters=\"sRGB\">\n              <Grow border={border} />\n              {/* The softened edge is the only slope on the surface, so it catches a rim of light. */}\n              <feGaussianBlur in=\"grown\" stdDeviation=\"1.4\" result=\"bump\" />\n              {lights.map((color, i) => (\n                <feSpecularLighting\n                  key={color}\n                  in=\"bump\"\n                  surfaceScale={2.5}\n                  specularConstant={lights.length > 1 ? 0.38 : 0.42}\n                  specularExponent={lights.length > 1 ? 24 : 55}\n                  lightingColor={color}\n                  result={`glint${i}`}\n                >\n                  <fePointLight\n                    ref={(node) => {\n                      lightsRef.current[i] = node\n                    }}\n                    x={PAD + 20}\n                    y={PAD + 12}\n                    z={60}\n                  />\n                </feSpecularLighting>\n              ))}\n              <feMerge result=\"glints\">\n                {lights.map((color, i) => (\n                  <feMergeNode key={color} in={`glint${i}`} />\n                ))}\n              </feMerge>\n              <feComposite in=\"glints\" in2=\"grown\" operator=\"in\" />\n            </filter>\n          )}\n          <filter id={ids.ink} x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\" colorInterpolationFilters=\"sRGB\">\n            <Grow border={border} />\n            <feFlood floodColor=\"#000\" />\n            <feComposite in2=\"grown\" operator=\"in\" />\n          </filter>\n        </defs>\n      </svg>\n\n      <div\n        ref={moverRef}\n        role={movable ? \"button\" : undefined}\n        tabIndex={movable ? 0 : undefined}\n        aria-label={movable ? label : undefined}\n        aria-roledescription={movable ? \"sticker\" : undefined}\n        aria-describedby={movable ? hintId : undefined}\n        className={cn(\n          \"pointer-events-auto relative touch-none rounded-md outline-none select-none [-webkit-tap-highlight-color:transparent]\",\n          \"cursor-grab data-state:cursor-grabbing\",\n          \"focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-ring\"\n        )}\n        style={{ transform: `translate(${start.x}px, ${start.y}px) rotate(${rotate}deg)` }}\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        onPointerLeave={() => engineRef.current?.leave()}\n        onDragStart={(e) => e.preventDefault()}\n        onKeyDown={(e) => {\n          if (!movable) return\n          if (engineRef.current?.key(e.nativeEvent)) e.preventDefault()\n        }}\n        onBlur={() => engineRef.current?.blur()}\n      >\n        <Layer ref={liftShadowRef} filter={`url(#${ids.ink}) blur(9px)`}>\n          {children}\n        </Layer>\n        <div ref={frontRef} className=\"relative grid\" style={{ filter: `url(#${ids.cut})` }}>\n          {children}\n        </div>\n        {lights.length > 0 && (\n          <Layer ref={sheenRef} filter={`url(#${ids.sheen})`} shown>\n            {children}\n          </Layer>\n        )}\n        <Layer ref={flapShadowRef} filter={`url(#${ids.ink}) blur(3px)`}>\n          {children}\n        </Layer>\n        <Layer ref={backRef} filter={`url(#${ids.back})`}>\n          {children}\n        </Layer>\n        <Layer ref={shadeRef} filter={`url(#${ids.ink})`}>\n          {children}\n        </Layer>\n      </div>\n\n      {movable && (\n        <span id={hintId} className=\"sr-only\">\n          Drag to peel it off and stick it somewhere else, or press Enter to lift it and use the arrow keys.\n        </span>\n      )}\n      <span aria-live=\"polite\" className=\"sr-only\">\n        {message}\n      </span>\n    </div>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "look": "modern",
    "addedAt": "2026-11-24"
  },
  "type": "registry:component"
}