{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"diff","title":"Diff review","description":"Code an agent wants to change, reviewed hunk by hunk. Lines stream in, verdicts stamp down, and unified slides into split.","type":"registry:component","author":"Detent","dependencies":["motion"],"registryDependencies":["https://detentui.com/r/theme.json"],"files":[{"path":"components/detent/components/diff/DiffReview.tsx","target":"components/detent/components/diff/DiffReview.tsx","type":"registry:component","content":"'use client'\n\nimport { useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react'\nimport type { KeyboardEvent, ReactNode, Ref } from 'react'\nimport { AnimatePresence, motion } from 'motion/react'\nimport { ArrowUpRight, Check, Close } from '@/components/detent/icons'\nimport { stackTop, useSize, useStack } from '@/components/detent/lib/hooks'\nimport { ease, spring, dur, press } from '@/components/detent/lib/motion'\nimport { Button } from '@/components/detent/ui/Button'\nimport { Kbd } from '@/components/detent/ui/Kbd'\nimport { Morph } from '@/components/detent/ui/Morph'\nimport { RollingText } from '@/components/detent/ui/RollingText'\nimport { FileGlyph } from '@/components/detent/ui/FileGlyph'\nimport { Spinner } from '@/components/detent/ui/Spinner'\n\nexport type DiffLine = ['ctx' | 'add' | 'del', string]\nexport type Hunk = { id: string; scope: string; o: number; n: number; lines: DiffLine[] }\nexport type Verdict = 'pending' | 'accepted' | 'rejected'\nexport type DiffView = 'unified' | 'split'\nexport type DiffHandle = { next(): void; prev(): void; accept(): void; reject(): void; toggleView(): void; apply(): void }\n\nconst RH = 20\nconst HEAD = 32\n\nexport function DiffReview({\n  title,\n  file,\n  hunks,\n  shown,\n  size = { w: 720, h: 600 },\n  onApply,\n  ref,\n}: {\n  title: string\n  file: string\n  hunks: Hunk[]\n  onApply?: (verdicts: Record<string, Verdict>) => void\n  size?: { w: number; h: number }\n  shown?: number\n  ref?: Ref<DiffHandle>\n}) {\n  const total = hunks.reduce((n, h) => n + h.lines.length, 0)\n  const written = Math.min(shown ?? total, total)\n  const ready = written >= total\n  const [view, setView] = useState<DiffView>('unified')\n  const [verdicts, setVerdicts] = useState<Record<string, Verdict>>({})\n  const [focus, setFocus] = useState(0)\n  const [applied, setApplied] = useState(false)\n  const root = useRef<HTMLDivElement>(null)\n  const scroller = useRef<HTMLDivElement>(null)\n  const stack = useRef<HTMLDivElement>(null)\n  useStack(stack, 10)\n  const { w: seen } = useSize(root)\n  const width = seen || size.w\n  const roomy = width >= 560\n  const split = view === 'split' && roomy\n  const body = width - 24\n\n  const verdict = (h: Hunk) => verdicts[h.id] ?? 'pending'\n  const pending = hunks.filter((h) => verdict(h) === 'pending')\n  const resolved = ready && !pending.length\n\n  const visible = hunks.map((h, i) => Math.max(0, Math.min(h.lines.length, written - hunks.slice(0, i).reduce((t, x) => t + x.lines.length, 0))))\n  const writing = ready ? -1 : visible.findIndex((n, i) => n < hunks[i].lines.length)\n\n  let adds = 0\n  let dels = 0\n  hunks.forEach((h, i) => {\n    if (verdict(h) === 'rejected') return\n    h.lines.slice(0, visible[i]).forEach(([k]) => (k === 'add' ? adds++ : k === 'del' ? dels++ : 0))\n  })\n\n  const decide = (v: Verdict) => {\n    if (!ready || applied) return\n    const h = hunks[focus]\n    if (!h || verdict(h) !== 'pending') return\n    setVerdicts((m) => ({ ...m, [h.id]: v }))\n    const order = [...hunks.slice(focus + 1), ...hunks.slice(0, focus)]\n    const nextUp = order.find((x) => x.id !== h.id && verdict(x) === 'pending')\n    if (nextUp) setFocus(hunks.indexOf(nextUp))\n  }\n  const undo = (i = focus) => !applied && setVerdicts((m) => ({ ...m, [hunks[i].id]: 'pending' }))\n  const all = (v: Verdict) => {\n    if (!ready || applied) return\n    setVerdicts((m) => Object.fromEntries(hunks.map((h) => [h.id, m[h.id] && m[h.id] !== 'pending' ? m[h.id] : v])))\n  }\n  const apply = () => {\n    if (!resolved || applied) return\n    setApplied(true)\n    onApply?.(Object.fromEntries(hunks.map((h) => [h.id, verdict(h)])))\n  }\n  const move = (d: number) => setFocus((f) => Math.max(0, Math.min(hunks.length - 1, f + d)))\n  const toggleView = () => setView((v) => (v === 'unified' ? 'split' : 'unified'))\n\n  useImperativeHandle(ref, () => ({ next: () => move(1), prev: () => move(-1), accept: () => decide('accepted'), reject: () => decide('rejected'), toggleView, apply }))\n\n  const onKey = (e: KeyboardEvent) => {\n    if (e.metaKey || e.ctrlKey || e.altKey) return\n    const run: Record<string, () => void> = { j: () => move(1), k: () => move(-1), a: () => decide('accepted'), r: () => decide('rejected'), u: () => undo(), s: toggleView, enter: apply }\n    const f = run[e.key.toLowerCase()]\n    if (f) {\n      e.preventDefault()\n      f()\n    }\n  }\n\n  useEffect(() => {\n    const box = scroller.current\n    const el = box?.querySelector<HTMLElement>(`[data-hunk=\"${focus}\"]`)\n    if (!box || !el || !ready || !stack.current) return\n    const at = stack.current.offsetTop + stackTop(el)\n    const top = at - 12\n    const bottom = at + el.offsetHeight + 12\n    if (top < box.scrollTop) box.scrollTo({ top, behavior: 'smooth' })\n    else if (bottom > box.scrollTop + box.clientHeight) box.scrollTo({ top: Math.min(top, bottom - box.clientHeight), behavior: 'smooth' })\n  }, [focus, ready, view])\n\n  const status = !ready ? 'Writing changes' : applied ? `Applied to ${file.split('/').pop()}` : resolved ? `${hunks.filter((h) => verdict(h) === 'accepted').length} accepted · ${hunks.filter((h) => verdict(h) === 'rejected').length} rejected` : `${pending.length} of ${hunks.length} left to review`\n\n  const kept = hunks.filter((h) => verdict(h) === 'accepted').length\n\n  return (\n    <div ref={root} tabIndex={0} onKeyDown={onKey} aria-label={`Review changes to ${file}`} className=\"@container ring-focus flex flex-col overflow-hidden rounded-card bg-surface shadow-float\" style={{ width: size.w, maxWidth: '100%', height: size.h }}>\n      <header className=\"flex h-14 shrink-0 items-center gap-3 pl-4 pr-3 shadow-[inset_0_-1px_0_var(--line)]\">\n        <FileGlyph name={file} size={30} />\n        <div className=\"min-w-0 flex-1\">\n          <p className=\"truncate text-callout font-medium text-ink\">{title}</p>\n          <p className=\"flex items-center gap-2.5 font-mono text-caption leading-4 text-ink-3\">\n            <span className=\"truncate\">\n              {file.slice(0, file.lastIndexOf('/') + 1)}\n              <span className=\"text-ink-2\">{file.split('/').pop()}</span>\n            </span>\n            <span className=\"flex shrink-0 items-center gap-2\">\n              <span className=\"flex gap-1.5 tabular-nums\">\n                <span className=\"flex\" style={{ color: SIGN.add }}>\n                  +<RollingText text={String(adds)} />\n                </span>\n                <span className=\"flex\" style={{ color: SIGN.del }}>\n                  −<RollingText text={String(dels)} />\n                </span>\n              </span>\n              <Ticks adds={adds} dels={dels} />\n            </span>\n          </p>\n        </div>\n        {roomy && <Segmented value={view} onChange={setView} />}\n      </header>\n\n      <div ref={scroller} className=\"relative min-h-0 flex-1 overflow-y-auto p-3\" style={{ scrollbarWidth: 'none', maskImage: 'linear-gradient(to bottom, transparent, #000 10px, #000 calc(100% - 10px), transparent)' }}>\n        <div ref={stack} className=\"relative flex flex-col gap-2.5\">\n          <AnimatePresence initial={false}>\n            {hunks.map(\n              (h, i) =>\n                visible[i] > 0 && (\n                  <HunkView\n                    key={h.id}\n                    index={i}\n                    h={h}\n                    shown={visible[i]}\n                    verdict={verdict(h)}\n                    split={split}\n                    body={body}\n                    focused={ready && focus === i && !applied}\n                    writing={writing === i}\n                    canDecide={ready && !applied}\n                    onPick={() => {\n                      setFocus(i)\n                      root.current?.focus({ preventScroll: true })\n                    }}\n                    onDecide={(v) => {\n                      setFocus(i)\n                      if (v === 'pending') undo(i)\n                      else if (verdict(h) === 'pending') setVerdicts((m) => ({ ...m, [h.id]: v }))\n                    }}\n                  />\n                ),\n            )}\n            {ready && (\n              <motion.p key=\"end\" className=\"flex h-8 items-center justify-center gap-2 text-caption text-ink-3\" initial={{ opacity: 0 }} animate={{ opacity: 1 }} transition={{ duration: 0.3, delay: 0.2, ease: ease.out }}>\n                <span className=\"h-px w-6 bg-[var(--line)]\" />\n                No other changes in {file.split('/').pop()}\n                <span className=\"h-px w-6 bg-[var(--line)]\" />\n              </motion.p>\n            )}\n          </AnimatePresence>\n        </div>\n      </div>\n\n      <footer className=\"flex h-14 shrink-0 items-center gap-3 pl-4 pr-3 shadow-[inset_0_1px_0_var(--line)]\">\n        <span className=\"flex shrink-0 items-center gap-[3px] @max-[420px]:hidden\" aria-hidden>\n          {hunks.map((h, i) => {\n            const v = verdict(h)\n            const here = ready && focus === i && !applied\n            return (\n              <motion.span\n                key={h.id}\n                className=\"block h-[3px] w-4 rounded-full\"\n                initial={false}\n                animate={{\n                  backgroundColor: here ? 'var(--dt-accent)' : v === 'accepted' ? 'var(--ok)' : v === 'rejected' ? 'var(--danger)' : i < (writing < 0 ? hunks.length : writing + 1) ? 'color-mix(in oklch, var(--ink) 28%, transparent)' : 'color-mix(in oklch, var(--ink) 10%, transparent)',\n                  scaleY: here ? 1.6 : 1,\n                }}\n                transition={spring.smooth}\n              />\n            )\n          })}\n        </span>\n        <span className=\"relative h-5 min-w-0 flex-1\">\n          <AnimatePresence initial={false}>\n            <motion.span key={status} className=\"absolute inset-0 flex items-center gap-2 truncate text-footnote text-ink-3\" initial={{ opacity: 0, y: 6 }} animate={{ opacity: 1, y: 0 }} exit={{ opacity: 0, y: -6 }} transition={{ duration: 0.22, ease: ease.out }}>\n              {!ready && <Spinner size={12} className=\"text-ink-3\" />}\n              {applied && <Check size={14} strokeWidth={2.6} className=\"text-ok\" />}\n              <Status text={status} />\n            </motion.span>\n          </AnimatePresence>\n        </span>\n        <Morph\n          view={applied ? 'applied' : resolved ? 'apply' : 'review'}\n          justify=\"end\"\n          radius={10}\n          views={{\n            review: (\n              <span className=\"flex gap-1.5\">\n                <Button size=\"sm\" variant=\"ghost\" disabled={!ready} onClick={() => all('rejected')}>\n                  Reject<span className=\"@max-[420px]:hidden\"> all</span>\n                </Button>\n                <Button size=\"sm\" variant=\"primary\" disabled={!ready} onClick={() => all('accepted')}>\n                  Accept<span className=\"@max-[420px]:hidden\"> all</span>\n                </Button>\n              </span>\n            ),\n            apply: (\n              <Button size=\"sm\" variant=\"primary\" onClick={apply}>\n                {kept ? `Apply ${kept} ${kept === 1 ? 'change' : 'changes'}` : 'Discard all'}\n                <Kbd onInk>↵</Kbd>\n              </Button>\n            ),\n            applied: (\n              <Button size=\"sm\" variant=\"secondary\">\n                Open<span className=\"@max-[420px]:hidden\"> {file.split('/').pop()}</span>\n                <ArrowUpRight size={13} className=\"text-ink-3\" />\n              </Button>\n            ),\n          }}\n        />\n      </footer>\n    </div>\n  )\n}\n\ntype Num = { k: DiffLine[0]; text: string; o: number; n: number; i: number }\ntype Row = { l: Num; num: number; y: number; side: 'full' | 'left' | 'right'; tone: 'ctx' | 'add' | 'del'; gone: boolean; hl?: [number, number] }\ntype Fill = { key: string; y: number; side: 'left' | 'right' }\n\nconst TOKEN = /\\s+|\\w+|'[^']*'?|[^\\w\\s]/g\nconst lex = (s: string) => s.match(TOKEN) ?? []\n\nfunction changed(a: string, b: string): [[number, number], [number, number]] | null {\n  const x = lex(a)\n  const y = lex(b)\n  let p = 0\n  while (p < x.length && p < y.length && x[p] === y[p]) p++\n  let s = 0\n  while (s < x.length - p && s < y.length - p && x[x.length - 1 - s] === y[y.length - 1 - s]) s++\n  const ink = (t: string[]) => t.join('').replace(/\\s/g, '').length || 1\n  if (ink(x.slice(p, x.length - s)) / ink(x) > 0.7 || ink(y.slice(p, y.length - s)) / ink(y) > 0.7) return null\n  return [\n    [p, x.length - s],\n    [p, y.length - s],\n  ]\n}\n\nfunction place(lines: Num[], verdict: Verdict, split: boolean, hid: string) {\n  const rows: Row[] = []\n  const fills: Fill[] = []\n  let y = 0\n  for (let i = 0; i < lines.length;) {\n    const l = lines[i]\n    if (verdict !== 'pending' || l.k === 'ctx') {\n      const gone = (verdict === 'accepted' && l.k === 'del') || (verdict === 'rejected' && l.k === 'add')\n      const num = verdict === 'rejected' || (verdict === 'pending' && l.k === 'del') ? l.o : l.n\n      rows.push({ l, num, y, side: 'full', tone: verdict === 'pending' ? l.k : 'ctx', gone })\n      if (!gone) y++\n      i++\n      continue\n    }\n    const start = i\n    const out: Num[] = []\n    const inn: Num[] = []\n    while (i < lines.length && lines[i].k === 'del') out.push(lines[i++])\n    while (i < lines.length && lines[i].k === 'add') inn.push(lines[i++])\n    const marks = out.map((d, k) => (inn[k] ? changed(d.text, inn[k].text) : null))\n    out.forEach((l, k) => rows.push({ l, num: l.o, y: y + k, side: split ? 'left' : 'full', tone: 'del', gone: false, hl: marks[k]?.[0] }))\n    inn.forEach((l, k) => rows.push({ l, num: l.n, y: split ? y + k : y + out.length + k, side: split ? 'right' : 'full', tone: 'add', gone: false, hl: marks[k]?.[1] }))\n    if (split) {\n      for (let k = Math.min(out.length, inn.length); k < Math.max(out.length, inn.length); k++) fills.push({ key: `${hid}-${start}-${k}`, y: y + k, side: out.length < inn.length ? 'left' : 'right' })\n      y += Math.max(out.length, inn.length)\n    } else y += out.length + inn.length\n  }\n  return { rows, fills, height: y }\n}\n\nfunction HunkView({\n  h,\n  index,\n  shown,\n  verdict,\n  split,\n  body,\n  focused,\n  writing,\n  canDecide,\n  onPick,\n  onDecide,\n}: {\n  h: Hunk\n  index: number\n  shown: number\n  verdict: Verdict\n  split: boolean\n  body: number\n  focused: boolean\n  writing: boolean\n  canDecide: boolean\n  onPick: () => void\n  onDecide: (v: Verdict) => void\n}) {\n  const numbered = useMemo(() => {\n    let o = h.o\n    let n = h.n\n    return h.lines.map(([k, text], i): Num => ({ k, text, i, o: k === 'add' ? 0 : o++, n: k === 'del' ? 0 : n++ }))\n  }, [h])\n  const { rows, fills, height } = place(numbered.slice(0, shown), verdict, split, h.id)\n  const nc = h.lines.filter(([k]) => k !== 'del').length\n  const widest = h.lines.reduce((m, [, t]) => Math.max(m, t.length), 0)\n\n  return (\n    <motion.section\n      data-hunk={index}\n      onPointerDown={onPick}\n      className=\"relative shrink-0 overflow-hidden rounded-[12px] transition-shadow ease-detent duration-200\"\n      style={{ boxShadow: focused ? '0 0 0 1.5px var(--dt-accent)' : '0 0 0 1px var(--line)' }}\n      initial={{ opacity: 0, height: HEAD }}\n      animate={{ opacity: 1, height: HEAD + height * RH }}\n      transition={{ height: spring.smooth, opacity: { duration: 0.2, ease: ease.out } }}\n    >\n      <div className=\"relative z-10 flex items-center gap-2 pl-3 pr-1.5 shadow-[inset_0_-1px_0_var(--line)]\" style={{ height: HEAD, background: 'color-mix(in oklch, var(--ink) 2.5%, var(--surface))' }}>\n        <span className=\"flex min-w-0 items-center gap-1.5 truncate font-mono text-[11.5px] text-ink\">\n          <span aria-hidden className=\"italic text-ink-3\">\n            ƒ\n          </span>\n          <span className=\"truncate\">{h.scope}</span>\n        </span>\n        <span className=\"shrink-0 text-caption text-ink-3 @max-[520px]:hidden\">\n          Lines {h.n}–{h.n + Math.max(0, nc - 1)}\n        </span>\n        <span className=\"flex-1\" />\n        <Verdicts verdict={verdict} writing={writing} canDecide={canDecide} focused={focused} onDecide={onDecide} />\n      </div>\n\n      <div className=\"relative overflow-x-auto [scrollbar-width:none]\" style={{ height: height * RH }}>\n        <div className=\"relative h-full font-mono text-caption\" style={{ minWidth: split ? undefined : `calc(${widest}ch + 4.5rem)` }}>\n        {rows.map((r) => (\n          <RowView key={r.l.i} r={r} split={split} body={body} />\n        ))}\n        <AnimatePresence>\n          {fills.map((f) => (\n            <motion.span\n              key={f.key}\n              className=\"absolute top-0 h-5 w-1/2\"\n              style={{ left: f.side === 'right' ? '50%' : 0, y: f.y * RH, background: 'color-mix(in oklch, var(--ink) 3%, transparent)' }}\n              initial={{ opacity: 0 }}\n              animate={{ opacity: 1, transition: { duration: 0.25, delay: 0.15, ease: ease.out } }}\n              exit={{ opacity: 0, transition: { duration: dur.exit, ease: ease.out } }}\n            />\n          ))}\n        </AnimatePresence>\n        <motion.span aria-hidden className=\"absolute inset-y-0 left-1/2 z-[2] w-px bg-line\" initial={false} animate={{ opacity: split ? 1 : 0 }} transition={{ duration: 0.2, ease: ease.out }} />\n        </div>\n      </div>\n    </motion.section>\n  )\n}\n\nconst wash = (c: string, light: number, dark: number) => `light-dark(color-mix(in oklch, var(${c}) ${light}%, transparent), color-mix(in oklch, var(${c}) ${dark}%, transparent))`\nconst TINT = { ctx: 'transparent', add: wash('--ok', 7, 10), del: wash('--danger', 6.5, 10) }\nconst MARK = { add: wash('--ok', 22, 30), del: wash('--danger', 19, 28) }\nconst SIGN = { add: 'color-mix(in oklch, var(--ok) 85%, var(--ink))', del: 'color-mix(in oklch, var(--danger) 85%, var(--ink))' }\n\nfunction RowView({ r, split, body }: { r: Row; split: boolean; body: number }) {\n  const full = r.side === 'full'\n  const at = { y: r.y * RH, x: r.side === 'right' ? body / 2 : 0, width: full ? '100%' : '50%' }\n  const num = r.num\n  return (\n    <motion.div\n      className=\"absolute left-0 top-0 h-5 font-mono text-caption leading-5 transition-[background-color] ease-detent duration-500\"\n      style={{ background: TINT[r.tone], zIndex: r.gone ? 0 : 1, pointerEvents: r.gone ? 'none' : undefined }}\n      initial={{ opacity: 0, ...at }}\n      animate={{ opacity: r.gone ? 0 : 1, ...at }}\n      transition={{ default: spring.smooth, opacity: { duration: r.gone ? 0.14 : 0.3, ease: ease.out } }}\n    >\n      <motion.div className=\"absolute inset-y-0 left-0 overflow-hidden\" initial={false} animate={{ width: full && split ? '50%' : '100%' }} transition={spring.smooth}>\n        <Seg num={full && split && r.l.k === 'ctx' ? r.l.o : num} tone={r.tone} text={r.l.text} hl={r.hl} />\n      </motion.div>\n      {full && (\n        <motion.div className=\"absolute inset-y-0 left-1/2 w-1/2 overflow-hidden\" initial={false} animate={{ opacity: split ? 1 : 0 }} transition={{ duration: 0.2, delay: split ? 0.12 : 0, ease: ease.out }}>\n          <Seg num={num} tone={r.tone} text={r.l.text} />\n        </motion.div>\n      )}\n    </motion.div>\n  )\n}\n\nconst KW = new Set(['export', 'const', 'let', 'function', 'return', 'if', 'else', 'await', 'async', 'import', 'from', 'type', 'new', 'true', 'false', 'null'])\n\nfunction Seg({ num, tone, text, hl }: { num: number; tone: Row['tone']; text: string; hl?: [number, number] }) {\n  const toks = lex(text)\n  return (\n    <div className=\"relative flex h-full whitespace-pre\">\n      {tone !== 'ctx' && <span aria-hidden className=\"absolute inset-y-0 left-0 w-[2px]\" style={{ background: SIGN[tone] }} />}\n      <span className=\"tnum w-11 shrink-0 select-none pr-3 text-right\" style={{ color: tone === 'ctx' ? 'color-mix(in oklch, var(--ink) 32%, transparent)' : `color-mix(in oklch, ${SIGN[tone]} 70%, var(--ink-3))` }}>\n        {num || ''}\n      </span>\n      <span className=\"w-4 shrink-0 select-none\" style={{ color: tone === 'ctx' ? undefined : SIGN[tone] }}>\n        {tone === 'add' ? '+' : tone === 'del' ? '−' : ''}\n      </span>\n      <span className=\"min-w-0 overflow-hidden pr-3 text-ink-2\">\n        {toks.map((t, i) => {\n          const on = hl && tone !== 'ctx' && i >= hl[0] && i < hl[1]\n          return (\n            <span\n              key={i}\n              className=\"transition-[background-color] ease-detent duration-500\"\n              style={{\n                ...syntax(t, toks[i + 1]),\n                background: on ? MARK[tone as 'add' | 'del'] : undefined,\n                borderRadius: on ? `${i === hl![0] ? 3 : 0}px ${i === hl![1] - 1 ? 3 : 0}px ${i === hl![1] - 1 ? 3 : 0}px ${i === hl![0] ? 3 : 0}px` : undefined,\n              }}\n            >\n              {t}\n            </span>\n          )\n        })}\n      </span>\n    </div>\n  )\n}\n\nfunction syntax(t: string, next?: string) {\n  if (/^\\s/.test(t)) return undefined\n  if (KW.has(t)) return { color: 'var(--ink)', fontWeight: 500 }\n  if (/^['\\d]/.test(t)) return { color: 'var(--ink)' }\n  if (/^\\w/.test(t)) return next === '(' ? { color: 'var(--ink)' } : undefined\n  return { color: 'color-mix(in oklch, var(--ink) 40%, transparent)' }\n}\n\nconst TICKS = 22\n\nfunction Ticks({ adds, dels }: { adds: number; dels: number }) {\n  const total = adds + dels\n  const k = total > TICKS ? TICKS / total : 1\n  const a = Math.round(adds * k)\n  const d = Math.min(TICKS - a, Math.max(dels ? 1 : 0, Math.round(dels * k)))\n  return (\n    <span className=\"flex h-2.5 items-end gap-[2px]\" aria-hidden>\n      {Array.from({ length: TICKS }, (_, i) => (\n        <span key={i} className=\"block w-[1.5px] rounded-full transition-[background-color,height] ease-detent duration-300\" style={{ height: i < a + d ? 10 : 6, background: i < a ? SIGN.add : i < a + d ? SIGN.del : 'color-mix(in oklch, var(--ink) 14%, transparent)' }} />\n      ))}\n    </span>\n  )\n}\n\nfunction Status({ text }: { text: string }) {\n  const m = text.match(/^(\\d+ of \\d+|\\d+ accepted · \\d+ rejected)(.*)$/)\n  return m ? (\n    <span>\n      <span className=\"text-ink\">{m[1]}</span>\n      {m[2].replace(/ to review$/, '')}\n      {m[2].endsWith(' to review') && <span className=\"@max-[320px]:hidden\"> to review</span>}\n    </span>\n  ) : (\n    <span className=\"text-ink-2\">{text}</span>\n  )\n}\n\nfunction Verdicts({ verdict, writing, canDecide, focused, onDecide }: { verdict: Verdict; writing: boolean; canDecide: boolean; focused: boolean; onDecide: (v: Verdict) => void }) {\n  const state = writing ? 'writing' : verdict !== 'pending' ? verdict : canDecide ? 'ask' : 'wait'\n  return (\n    <span className=\"relative flex h-6 w-[172px] @max-[420px]:w-[132px] shrink-0 items-center justify-end\">\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {state === 'writing' && (\n          <motion.span key=\"writing\" className=\"flex items-center gap-1.5 pr-1.5 text-caption text-ink-3\" {...fade}>\n            <Spinner size={11} />\n            Writing\n          </motion.span>\n        )}\n        {state === 'ask' && (\n          <motion.span key=\"ask\" className=\"flex items-center gap-1\" {...fade}>\n            <Small onClick={() => onDecide('rejected')} hint=\"R\" focused={focused}>\n              <Close size={12} />\n              Reject\n            </Small>\n            <Small onClick={() => onDecide('accepted')} hint=\"A\" focused={focused} strong>\n              <Check size={12} strokeWidth={2.6} />\n              Accept\n            </Small>\n          </motion.span>\n        )}\n        {(state === 'accepted' || state === 'rejected') && (\n          <motion.span key={state} className=\"flex items-center gap-1\" {...fade}>\n            <button type=\"button\" onPointerDown={(e) => e.stopPropagation()} onClick={() => onDecide('pending')} className=\"ring-focus relative h-6 rounded-[7px] px-1.5 text-caption text-ink-3 transition-colors ease-detent duration-150 hover:bg-surface-2 hover:text-ink [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-x-1 [@media(pointer:coarse)]:after:-inset-y-2 [@media(pointer:coarse)]:after:content-['']\">\n              Undo\n            </button>\n            <Mark ok={state === 'accepted'} />\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </span>\n  )\n}\n\nconst fade = {\n  initial: { opacity: 0 },\n  animate: { opacity: 1 },\n  exit: { opacity: 0 },\n  transition: { duration: 0.18, ease: ease.out },\n}\n\nfunction Mark({ ok }: { ok: boolean }) {\n  const c = ok ? 'var(--ok)' : 'var(--danger)'\n  return (\n    <motion.span className=\"chip mr-0.5 rounded-full px-2 text-caption font-medium leading-5\" style={{ color: c, ['--chip' as string]: c }} initial={{ opacity: 0, y: 4 }} animate={{ opacity: 1, y: 0 }} transition={{ duration: 0.22, ease: ease.out }}>\n      {ok ? 'Accepted' : 'Rejected'}\n    </motion.span>\n  )\n}\n\nfunction Small({ onClick, hint, focused, strong, children }: { onClick: () => void; hint: string; focused: boolean; strong?: boolean; children: ReactNode }) {\n  return (\n    <motion.button\n      type=\"button\"\n      whileTap={press}\n      onPointerDown={(e) => e.stopPropagation()}\n      onClick={onClick}\n      className={`ring-focus relative flex h-6 items-center gap-1 rounded-[7px] pl-1.5 pr-1 text-caption font-medium pointer-coarse:pr-1.5 @max-[420px]:pr-1.5 [@media(pointer:coarse)]:after:absolute [@media(pointer:coarse)]:after:-inset-x-1 [@media(pointer:coarse)]:after:-inset-y-2 [@media(pointer:coarse)]:after:content-[''] transition-[background-color,color,box-shadow] ease-detent duration-150 ${\n        strong && focused ? 'bg-ink text-surface hover:opacity-90' : strong ? 'bg-surface text-ink shadow-[0_0_0_1px_var(--line-strong)] hover:bg-surface-2' : 'text-ink-2 hover:bg-surface-2 hover:text-ink'\n      }`}\n    >\n      {children}\n      <span\n        className={`ml-0.5 flex h-[18px] min-w-[18px] items-center justify-center rounded-[5px] px-1 font-mono pointer-coarse:hidden @max-[420px]:hidden text-[10.5px] leading-none transition-opacity ease-detent duration-200 ${strong && focused ? 'bg-[color-mix(in_oklch,var(--surface)_18%,transparent)] text-surface' : 'bg-surface-2 text-ink-3'}`}\n        style={{ opacity: focused ? 1 : 0.45 }}\n      >\n        {hint}\n      </span>\n    </motion.button>\n  )\n}\n\nfunction Segmented({ value, onChange }: { value: DiffView; onChange: (v: DiffView) => void }) {\n  const id = useId()\n  return (\n    <span role=\"radiogroup\" aria-label=\"Diff layout\" className=\"flex h-8 shrink-0 rounded-[10px] bg-surface-2 p-[3px]\">\n      {(['unified', 'split'] as const).map((v) => (\n        <button\n          key={v}\n          type=\"button\"\n          role=\"radio\"\n          aria-checked={value === v}\n          onClick={() => onChange(v)}\n          className={`ring-focus relative flex w-[66px] items-center justify-center rounded-[7px] text-caption font-medium capitalize transition-colors ease-detent duration-150 ${value === v ? 'text-ink' : 'text-ink-3 hover:text-ink-2'}`}\n        >\n          {value === v && <motion.span layoutId={id} className=\"absolute inset-0 rounded-[7px] bg-plate shadow-raised\" transition={spring.snappy} />}\n          <span className=\"relative\">{v}</span>\n        </button>\n      ))}\n    </span>\n  )\n}\n"},{"path":"components/detent/icons/index.tsx","target":"components/detent/icons/index.tsx","type":"registry:component","content":"import type { SVGProps } from 'react'\n\ntype P = SVGProps<SVGSVGElement> & { size?: number }\n\nfunction Svg({ size = 20, children, ...rest }: P) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden {...rest}>\n      {children}\n    </svg>\n  )\n}\n\nexport const Close = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M7 7l10 10M17 7 7 17\" />\n  </Svg>\n)\n\nexport const Check = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 12.5l4.5 4.5L19 7.5\" />\n  </Svg>\n)\n\nexport const Plus = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 5v14M5 12h14\" />\n  </Svg>\n)\n\nexport const Bin = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"4\" y=\"4.5\" width=\"16\" height=\"3.6\" rx=\"1.8\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M9.5 4.5V3.8a1.3 1.3 0 0 1 1.3-1.3h2.4a1.3 1.3 0 0 1 1.3 1.3v.7\" />\n    <path d=\"M6 10.5l.8 8.4A2.2 2.2 0 0 0 9 21h6a2.2 2.2 0 0 0 2.2-2.1l.8-8.4\" />\n    <path d=\"M10.3 13v4.5M13.7 13v4.5\" />\n  </Svg>\n)\n\nexport const Undo = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M9 9h6.5a4.5 4.5 0 0 1 0 9H10\" />\n    <path d=\"M9.6 4.6 4.6 9l5 4.4z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Pause = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n    <rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Upload = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M4 14.5v2.3A3.2 3.2 0 0 0 7.2 20h9.6a3.2 3.2 0 0 0 3.2-3.2v-2.3\" />\n    <path d=\"M12 15V7\" />\n    <path d=\"M12 3.2 7.6 8.2h8.8z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const FilePage = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M13.5 3H8a3 3 0 0 0-3 3v12a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3V8.5\" />\n    <path d=\"M13.5 3v3.5a2 2 0 0 0 2 2H19z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Picture = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"4\" />\n    <path d=\"M3.8 16.5 9 11.6a1.5 1.5 0 0 1 2.1 0l3.2 3 1.6-1.5a1.5 1.5 0 0 1 2.1 0l2.2 2.1V16a3.5 3.5 0 0 1-3.5 3.5H8A4 4 0 0 1 3.8 16.5z\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"15.5\" cy=\"8.8\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Film = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"4\" />\n    <path d=\"M10.2 9.2v5.6a.7.7 0 0 0 1 .6l4.4-2.8a.7.7 0 0 0 0-1.2l-4.4-2.8a.7.7 0 0 0-1 .6z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Bubble = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 4c4.7 0 8.5 3.1 8.5 7s-3.8 7-8.5 7c-1 0-2-.1-2.9-.4L5 19.5l1.1-3.6C4.6 14.6 3.5 12.9 3.5 11c0-3.9 3.8-7 8.5-7z\" />\n    <circle cx=\"8.6\" cy=\"11\" r=\"1.15\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"12\" cy=\"11\" r=\"1.15\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"15.4\" cy=\"11\" r=\"1.15\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Card = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3\" y=\"5.5\" width=\"18\" height=\"13\" rx=\"3.5\" />\n    <rect x=\"3\" y=\"8.6\" width=\"18\" height=\"3\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M7 15h3\" />\n  </Svg>\n)\n\nexport const Bell = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M6 15.5V11a6 6 0 1 1 12 0v4.5l1.5 2H4.5z\" />\n    <path d=\"M9.6 19.5a2.6 2.6 0 0 0 4.8 0z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Ship = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 20h14\" />\n    <path d=\"M12 16V9\" />\n    <path d=\"M12 3.5 7 9.2h10z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Mention = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"3.4\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M15.4 12v1.4a2.6 2.6 0 0 0 5.1.7A8.5 8.5 0 1 0 16 19.5\" />\n  </Svg>\n)\n\nexport const Calendar = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"5\" width=\"17\" height=\"15.5\" rx=\"4\" />\n    <path d=\"M3.5 9A4 4 0 0 1 7.5 5h9a4 4 0 0 1 4 4v1H3.5z\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M8 3v3M16 3v3\" />\n  </Svg>\n)\n\nexport const ChevronDown = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M6.5 9.5 12 15l5.5-5.5\" />\n  </Svg>\n)\n\nexport const ArrowUpRight = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M8 16 16 8\" />\n    <path d=\"M9.5 6.8h7.7v7.7z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Sun = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"4.2\" fill=\"currentColor\" stroke=\"none\" />\n    {[0, 45, 90, 135, 180, 225, 270, 315].map((a) => {\n      const r = (a * Math.PI) / 180\n      return <circle key={a} cx={12 + Math.cos(r) * 8.4} cy={12 + Math.sin(r) * 8.4} r=\"1.1\" fill=\"currentColor\" stroke=\"none\" />\n    })}\n  </Svg>\n)\n\nexport const Moon = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M19.5 14.6A8 8 0 0 1 9.4 4.5a8 8 0 1 0 10.1 10.1z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Expand = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M14 4h6v6M10 20H4v-6\" />\n    <path d=\"M20 4l-6 6M4 20l6-6\" />\n  </Svg>\n)\n\nexport const Inspect = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M4 9V6.5A2.5 2.5 0 0 1 6.5 4H9M15 4h2.5A2.5 2.5 0 0 1 20 6.5V9M4 15v2.5A2.5 2.5 0 0 0 6.5 20H9\" />\n    <path d=\"M13.2 13.2l7.3 2.5-3.1 1.3-1.3 3.1z\" fill=\"currentColor\" strokeWidth={1.5} />\n  </Svg>\n)\n\nexport const Folder = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M3.5 9.5V17a3 3 0 0 0 3 3h11a3 3 0 0 0 3-3v-6.5a3 3 0 0 0-3-3h-6\" />\n    <path d=\"M3.5 7A2.5 2.5 0 0 1 6 4.5h3.2a2 2 0 0 1 1.6.8l1.5 2.2H3.5z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Copy = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"4\" y=\"4\" width=\"11\" height=\"11\" rx=\"3\" fill=\"currentColor\" stroke=\"none\" />\n    <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"3\" fill=\"var(--icon-cutout, white)\" />\n  </Svg>\n)\n\nexport const Cookie = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M20.6 12.6a8.6 8.6 0 1 1-9.2-9.2 3 3 0 0 0 3.6 3.6 3 3 0 0 0 5.6 5.6z\" />\n    <circle cx=\"9.2\" cy=\"10.4\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"14.5\" cy=\"15.3\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"8.8\" cy=\"15.6\" r=\"0.9\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Clock = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"8.5\" />\n    <path d=\"M12 7.2v5.2l3.4 2.1\" strokeWidth={2.4} />\n  </Svg>\n)\n\nexport const ArrowLeft = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M19 12H7\" />\n    <path d=\"M10.5 6.5 4.5 12l6 5.5z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Mail = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"3.5\" />\n    <path d=\"M4.4 7.6A3.5 3.5 0 0 1 7 5.5h10a3.5 3.5 0 0 1 2.6 2.1L12 13z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const ArrowUp = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 20v-9\" />\n    <path d=\"M12 3.8 6.6 10.2h10.8z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Stop = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"6.5\" y=\"6.5\" width=\"11\" height=\"11\" rx=\"3\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Bolt = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M13.2 3.2 5.8 13h5.6l-.6 7.8 7.4-9.8h-5.6z\" fill=\"currentColor\" strokeWidth={1.6} />\n  </Svg>\n)\n\nexport const Orbit = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M18.06 8.5A7 7 0 1 1 15.5 5.94\" />\n    <circle cx=\"16.95\" cy=\"7.05\" r=\"2.1\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Search = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"10.5\" cy=\"10.5\" r=\"6.2\" />\n    <path d=\"M14.9 17.1a1.55 1.55 0 0 1 2.2-2.2l3 3a1.55 1.55 0 0 1-2.2 2.2z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Minus = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 12h14\" />\n  </Svg>\n)\n\nexport const Chevrons = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M8 9.5 12 5.5l4 4M8 14.5l4 4 4-4\" />\n  </Svg>\n)\n\nexport const Pencil = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M14.5 5.5 18.5 9.5 9 19H5v-4z\" />\n    <path d=\"M16.2 3.8a2 2 0 0 1 2.8 0l1.2 1.2a2 2 0 0 1 0 2.8l-1.4 1.4-4-4z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const ArrowRight = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 12h12\" />\n    <path d=\"M13.5 6.5 19.5 12l-6 5.5z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Cup = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 8h11v6a5 5 0 0 1-5 5h-1a5 5 0 0 1-5-5z\" />\n    <path d=\"M16 10h1.5a2.5 2.5 0 0 1 0 5H16\" />\n    <path d=\"M5 8h11v3H5z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Bag = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5.5 8h13l-1 11.2a2 2 0 0 1-2 1.8h-7a2 2 0 0 1-2-1.8z\" />\n    <path d=\"M9 11V7a3 3 0 0 1 6 0v4\" />\n    <path d=\"M5.6 8h12.8l-.25 3H5.85z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Note = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3\" y=\"6\" width=\"18\" height=\"12\" rx=\"3\" />\n    <circle cx=\"12\" cy=\"12\" r=\"2.6\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Plane = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M20.5 3.5 3.5 10.6l6.3 2.9 2.9 6.3z\" />\n    <path d=\"M20.5 3.5 9.8 13.5l2.9 6.3z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Building = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 21V6a2 2 0 0 1 2-2h7a2 2 0 0 1 2 2v15M16 10h2a2 2 0 0 1 2 2v9M3 21h18\" />\n    <rect x=\"8.5\" y=\"15.5\" width=\"4\" height=\"5.5\" rx=\"1\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const FolderOpen = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M3.5 16.5V7A2.5 2.5 0 0 1 6 4.5h3.2a2 2 0 0 1 1.6.8l1.5 2.2H17a2.5 2.5 0 0 1 2.5 2.5v1\" />\n    <path d=\"M3.5 7A2.5 2.5 0 0 1 6 4.5h3.2a2 2 0 0 1 1.6.8l1.5 2.2H3.5z\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M5.6 11.5h15a1 1 0 0 1 .96 1.27l-1.55 5.6A2.2 2.2 0 0 1 17.9 20H6.1a2.6 2.6 0 0 1-2.6-2.6v-3.8a2.1 2.1 0 0 1 2.1-2.1z\" />\n  </Svg>\n)\n\nexport const Code = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M8 7.5 3.5 12 8 16.5M16 7.5l4.5 4.5-4.5 4.5\" />\n    <path d=\"M13.2 4.6a1 1 0 0 1 1.9.6l-4.3 14.2a1 1 0 0 1-1.9-.6z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Wrench = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M15.4 3.6a4.6 4.6 0 0 0-4.3 6.1l-6.6 6.6a2.2 2.2 0 1 0 3.1 3.1l6.6-6.6a4.6 4.6 0 0 0 6.1-4.3l-2.9 2.9-2.6-.6-.6-2.6z\" />\n    <circle cx=\"6\" cy=\"17.9\" r=\"1.1\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Prompt = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M5 7.5 9.5 12 5 16.5\" />\n    <rect x=\"11.5\" y=\"15\" width=\"8\" height=\"2.4\" rx=\"1.2\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Node = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"8\" />\n    <circle cx=\"12\" cy=\"12\" r=\"3.2\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Refresh = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M19.2 13.2A7.4 7.4 0 1 1 16.8 6\" />\n    <path d=\"M19.6 3.4v6.2h-6.2z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Thumb = ({ down, ...p }: P & { down?: boolean }) => (\n  <Svg {...p} style={{ transform: down ? 'scale(1, -1)' : undefined, ...p.style }}>\n    <path d=\"M8 10.5 11.5 4a1.7 1.7 0 0 1 3.1 1.2l-.7 4h5a2 2 0 0 1 2 2.4l-1.2 6.3A2 2 0 0 1 17.7 19.5H8\" />\n    <rect x=\"3\" y=\"10.5\" width=\"5\" height=\"9\" rx=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Chart = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M3.5 17.5 8.5 12l3.5 3.5 5-6\" />\n    <circle cx=\"19.2\" cy=\"7\" r=\"2.6\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M3.5 20.5h17\" />\n  </Svg>\n)\n\nexport const Table = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"4.5\" width=\"17\" height=\"15\" rx=\"3.5\" />\n    <path d=\"M3.5 8a3.5 3.5 0 0 1 3.5-3.5h10A3.5 3.5 0 0 1 20.5 8v1.5h-17z\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M10 9.5v10M3.5 14.5h17\" />\n  </Svg>\n)\n\nexport const Play = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M8 5.8v12.4l9.6-6.2z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Grip = (p: P) => (\n  <Svg {...p} strokeWidth={3.2}>\n    <path d=\"M9 6.5h.01M15 6.5h.01M9 12h.01M15 12h.01M9 17.5h.01M15 17.5h.01\" />\n  </Svg>\n)\n\nexport const Mic = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"9\" y=\"3\" width=\"6\" height=\"11.5\" rx=\"3\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M5.5 11.5a6.5 6.5 0 0 0 13 0M12 18v3\" />\n  </Svg>\n)\n\nexport const Speaker = ({ muted, ...p }: P & { muted?: boolean }) => (\n  <Svg {...p}>\n    <path d=\"M4 9.5h3.2L12 5.5v13l-4.8-4H4z\" fill=\"currentColor\" />\n    {muted ? <path d=\"M16 9.5l4.5 5M20.5 9.5l-4.5 5\" /> : <path d=\"M15.5 9a4.2 4.2 0 0 1 0 6M18.2 6.5a8 8 0 0 1 0 11\" />}\n  </Svg>\n)\n\nexport const ChevronRight = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M10 6.5l5.5 5.5-5.5 5.5\" />\n  </Svg>\n)\n\nexport const Layers = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M8 4.5h9.5A2.5 2.5 0 0 1 20 7v9.5\" />\n    <rect x=\"4\" y=\"8\" width=\"12\" height=\"12\" rx=\"2.5\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Link = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M10.5 13.5a3.5 3.5 0 0 0 5 0l3-3a3.5 3.5 0 0 0-5-5l-.8.8\" />\n    <path d=\"M13.5 10.5a3.5 3.5 0 0 0-5 0l-3 3a3.5 3.5 0 0 0 5 5l.8-.8\" />\n    <circle cx=\"12\" cy=\"12\" r=\"1.4\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const More = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"6\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n    <circle cx=\"18\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Eye = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z\" />\n    <circle cx=\"12\" cy=\"12\" r=\"3\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const EyeOff = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M6.6 7.2C4 8.9 2.5 12 2.5 12S6 18.5 12 18.5c1.9 0 3.5-.6 4.9-1.5M10 5.7c.6-.1 1.3-.2 2-.2 6 0 9.5 6.5 9.5 6.5s-.8 1.5-2.3 3.1\" />\n    <path d=\"M4 4l16 16\" strokeWidth={2.4} />\n  </Svg>\n)\n\nexport const Alert = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"9\" />\n    <path d=\"M12 7.5v5.5\" />\n    <circle cx=\"12\" cy=\"16.4\" r=\"1.25\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Spark = (p: P) => (\n  <Svg {...p}>\n    <circle cx=\"12\" cy=\"12\" r=\"9\" />\n    <path d=\"M12.8 6.5 8.6 12.6h3.1l-.6 4.9 4.3-6.2h-3.1z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Cube = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 3.2 19.6 7.4v9.2L12 20.8l-7.6-4.2V7.4z\" />\n    <path d=\"M12 3.2 19.6 7.4 12 11.6 4.4 7.4z\" fill=\"currentColor\" stroke=\"none\" />\n    <path d=\"M12 11.6v9.2\" />\n  </Svg>\n)\n\nexport const Plug = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M6.5 9.5h11v2.5a5.5 5.5 0 0 1-11 0z\" />\n    <path d=\"M12 17.5V21\" />\n    <rect x=\"8.2\" y=\"3\" width=\"2.2\" height=\"6\" rx=\"1.1\" fill=\"currentColor\" stroke=\"none\" />\n    <rect x=\"13.6\" y=\"3\" width=\"2.2\" height=\"6\" rx=\"1.1\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Fork = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M4 12h6\" />\n    <path d=\"M10 12c3 0 4-5.5 8.5-5.5M10 12c3 0 4 5.5 8.5 5.5\" />\n    <path d=\"M16.5 4.5l2.2 2-2.2 2M16.5 15.5l2.2 2-2.2 2\" />\n    <circle cx=\"10\" cy=\"12\" r=\"2.2\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Shield = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 3 19 5.8v5.4c0 4.4-3 7.9-7 9.8-4-1.9-7-5.4-7-9.8V5.8z\" />\n    <path d=\"m8.6 11.8 2.4 2.4 4.6-4.8\" strokeWidth={2.4} />\n  </Svg>\n)\n\nexport const Send = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M20.5 3.5 3.5 10.3l6.6 2.9 2.9 6.6z\" />\n    <path d=\"M20.5 3.5 10.1 13.2l2.9 6.6z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Redo = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M15 9H8.5a4.5 4.5 0 0 0 0 9H14\" />\n    <path d=\"M14.4 4.6 19.4 9l-5 4.4z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const Captions = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"3.5\" />\n    <path d=\"M7.6 11.2h4.2a1.2 1.2 0 0 1 0 2.4H7.6a1.2 1.2 0 0 1 0-2.4zM7.6 14.6h8.8a1.2 1.2 0 0 1 0 2.4H7.6a1.2 1.2 0 0 1 0-2.4z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Sliders = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M4 8h16M4 16h16\" />\n    <path d=\"M9 5.2a2.8 2.8 0 1 1 0 5.6 2.8 2.8 0 0 1 0-5.6zM15 13.2a2.8 2.8 0 1 1 0 5.6 2.8 2.8 0 0 1 0-5.6z\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Pip = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"3.5\" y=\"5.5\" width=\"17\" height=\"13\" rx=\"3.5\" />\n    <rect x=\"11.5\" y=\"11\" width=\"6.5\" height=\"5\" rx=\"1.4\" fill=\"currentColor\" stroke=\"none\" />\n  </Svg>\n)\n\nexport const Shrink = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M10 4v6H4M14 20v-6h6\" />\n    <path d=\"M4 4l6 6M20 20l-6-6\" />\n  </Svg>\n)\n\nexport const RotateLeft = (p: P) => (\n  <Svg {...p}>\n    <rect x=\"9\" y=\"9.5\" width=\"11\" height=\"10.5\" rx=\"2.4\" />\n    <path d=\"M12.5 5.5H9a5 5 0 0 0-5 5v2\" />\n    <path d=\"M12.2 2.6 15.6 5.5l-3.4 2.9z\" fill=\"currentColor\" />\n  </Svg>\n)\n\nexport const FlipH = (p: P) => (\n  <Svg {...p}>\n    <path d=\"M12 3.5v17\" strokeDasharray=\"2 2.6\" />\n    <path d=\"M9 7.5 3.5 17H9z\" />\n    <path d=\"M15 7.5 20.5 17H15z\" fill=\"currentColor\" />\n  </Svg>\n)\n"},{"path":"components/detent/lib/hooks.ts","target":"components/detent/lib/hooks.ts","type":"registry:component","content":"'use client'\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react'\nimport type { RefObject } from 'react'\n\nexport function useFrame(cb: (dt: number, t: number) => void, active = true) {\n  const ref = useRef(cb)\n  useLayoutEffect(() => {\n    ref.current = cb\n  })\n  useEffect(() => {\n    if (!active) return\n    let raf = 0\n    let last = performance.now()\n    const loop = (t: number) => {\n      const dt = Math.min(48, t - last)\n      last = t\n      ref.current(dt, t)\n      raf = requestAnimationFrame(loop)\n    }\n    raf = requestAnimationFrame(loop)\n    return () => cancelAnimationFrame(raf)\n  }, [active])\n}\n\nexport function useSize(ref: RefObject<HTMLElement | null>) {\n  const [size, setSize] = useState({ w: 0, h: 0 })\n  useLayoutEffect(() => {\n    const el = ref.current\n    if (!el) return\n    const measure = () => setSize({ w: el.clientWidth, h: el.clientHeight })\n    measure()\n    const ro = new ResizeObserver(measure)\n    ro.observe(el)\n    return () => ro.disconnect()\n  }, [ref])\n  return size\n}\n\nconst stacked = new WeakMap<Element, number>()\nexport const stackTop = (el: Element) => stacked.get(el) ?? 0\nconst stacks = new WeakMap<Element, () => void>()\n\nexport function useStack(ref: RefObject<HTMLElement | null>, gap = 0, onPlace?: () => void) {\n  const follow = useRef(onPlace)\n  useLayoutEffect(() => {\n    follow.current = onPlace\n  })\n  const place = useCallback(() => {\n    const box = ref.current\n    if (!box) return\n    const cs = getComputedStyle(box)\n    if (cs.position === 'static') box.style.position = 'relative'\n    const [top, right, bottom, left] = ['top', 'right', 'bottom', 'left'].map((k) => parseFloat(cs.getPropertyValue(`padding-${k}`)))\n    const edges = top + bottom + parseFloat(cs.borderTopWidth) + parseFloat(cs.borderBottomWidth)\n    let y = 0\n    for (const el of Array.from(box.children) as HTMLElement[]) {\n      Object.assign(el.style, { position: 'absolute', top: `${top}px`, left: `${left}px`, right: `${right}px`, translate: `0 ${y}px` })\n      const s = getComputedStyle(el)\n      const mt = parseFloat(s.marginTop) || 0\n      stacked.set(el, top + y + mt)\n      y += mt + parseFloat(s.height) + (parseFloat(s.marginBottom) || 0) + gap\n    }\n    const was = box.style.height\n    box.style.height = `${Math.max(0, y - gap) + (cs.boxSizing === 'border-box' ? edges : 0)}px`\n    if (box.style.height === was) return\n    follow.current?.()\n    for (let el = box.parentElement; el; el = el.parentElement) {\n      const outer = stacks.get(el)\n      if (outer) return outer()\n    }\n  }, [ref, gap])\n  useLayoutEffect(place)\n  useLayoutEffect(() => {\n    const box = ref.current\n    if (!box) return\n    stacks.set(box, place)\n    const ro = new ResizeObserver(place)\n    const watch = () => {\n      ro.disconnect()\n      for (const el of Array.from(box.children)) ro.observe(el)\n    }\n    const mo = new MutationObserver(() => {\n      watch()\n      place()\n    })\n    watch()\n    mo.observe(box, { childList: true })\n    return () => {\n      stacks.delete(box)\n      ro.disconnect()\n      mo.disconnect()\n    }\n  }, [ref, place])\n}\n\nexport const layoutPx = (v: string) => Math.round(parseFloat(v) * 64) / 64\n\nexport function useRow(ref: RefObject<HTMLElement | null>, onPlace?: () => void) {\n  const follow = useRef(onPlace)\n  useLayoutEffect(() => {\n    follow.current = onPlace\n  })\n  const place = useCallback(() => {\n    const box = ref.current\n    if (!box) return\n    if (getComputedStyle(box).position === 'static') box.style.position = 'relative'\n    const kids = Array.from(box.children) as HTMLElement[]\n    for (const el of kids) Object.assign(el.style, { position: 'absolute', left: '0px', whiteSpace: 'nowrap' })\n    const sizes = kids.map((el) => {\n      const cs = getComputedStyle(el)\n      return { w: layoutPx(cs.width), h: layoutPx(cs.height), before: layoutPx(cs.marginLeft), after: layoutPx(cs.marginRight) }\n    })\n    const tall = Math.max(0, ...sizes.map((s) => s.h))\n    let x = 0\n    kids.forEach((el, i) => {\n      el.style.translate = `${x}px`\n      x += sizes[i].before + sizes[i].w + sizes[i].after\n    })\n    box.style.height = `${tall}px`\n    const was = box.style.width\n    box.style.width = `${x}px`\n    if (box.style.width !== was) follow.current?.()\n  }, [ref])\n  useLayoutEffect(place)\n  useLayoutEffect(() => {\n    const box = ref.current\n    if (!box) return\n    const ro = new ResizeObserver(place)\n    const watch = () => {\n      ro.disconnect()\n      for (const el of Array.from(box.children)) ro.observe(el)\n    }\n    const mo = new MutationObserver(() => {\n      watch()\n      place()\n    })\n    watch()\n    mo.observe(box, { childList: true })\n    return () => {\n      ro.disconnect()\n      mo.disconnect()\n    }\n  }, [ref, place])\n}\n\nconst readTheme = () => (document.documentElement.dataset.theme === 'dark' ? 'dark' : 'light')\nconst watchTheme = (on: () => void) => {\n  const mo = new MutationObserver(on)\n  mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] })\n  return () => mo.disconnect()\n}\nexport function useTheme() {\n  return useSyncExternalStore<'light' | 'dark'>(watchTheme, readTheme, () => 'light')\n}\n\nexport function fitCanvas(canvas: HTMLCanvasElement, w: number, h: number) {\n  const dpr = Math.min(2, window.devicePixelRatio || 1)\n  canvas.width = Math.round(w * dpr)\n  canvas.height = Math.round(h * dpr)\n  const ctx = canvas.getContext('2d')!\n  ctx.setTransform(dpr, 0, 0, dpr, 0, 0)\n  return ctx\n}\n\nexport const mod = (n: number, m: number) => ((n % m) + m) % m\nexport const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v))\nexport const smoothstep = (a: number, b: number, x: number) => {\n  const t = clamp((x - a) / (b - a), 0, 1)\n  return t * t * (3 - 2 * t)\n}\n"},{"path":"components/detent/lib/motion.ts","target":"components/detent/lib/motion.ts","type":"registry:component","content":"export const ease = {\n  out: [0.2, 0.9, 0.25, 1] as const,\n  inOut: [0.6, 0, 0.3, 1] as const,\n}\n\nexport const dur = {\n  exit: 0.12,\n  hover: 0.15,\n  enter: 0.2,\n  swap: 0.24,\n  panel: 0.34,\n}\n\nexport const spring = {\n  snappy: { type: 'spring', stiffness: 560, damping: 42, mass: 0.6 } as const,\n  smooth: { type: 'spring', bounce: 0, duration: 0.36 } as const,\n  soft: { type: 'spring', bounce: 0.12, duration: 0.5 } as const,\n  release: { type: 'spring', stiffness: 320, damping: 32 } as const,\n  move: { type: 'spring', stiffness: 420, damping: 38 } as const,\n  data: { type: 'spring', stiffness: 170, damping: 26 } as const,\n  pop: { type: 'spring', bounce: 0.3, duration: 0.4 } as const,\n}\n\nexport const appear = {\n  initial: { opacity: 0, scale: 0.96 },\n  animate: { opacity: 1, scale: 1, transition: { duration: dur.swap, ease: ease.out } },\n  exit: { opacity: 0, scale: 0.97, transition: { duration: dur.exit, ease: ease.out } },\n}\n\nexport const slide = {\n  enter: (dir: number) => ({ x: dir * 24, opacity: 0 }),\n  center: { x: 0, opacity: 1 },\n  exit: (dir: number) => ({ x: dir * -24, opacity: 0 }),\n}\n\nexport const press = { scale: 0.97 }\n\nexport const staggerFor = (count: number) => Math.min(0.04, 0.2 / Math.max(1, count))\n"},{"path":"components/detent/ui/Button.tsx","target":"components/detent/ui/Button.tsx","type":"registry:component","content":"'use client'\n\nimport type { ComponentProps, ReactNode } from 'react'\nimport { AnimatePresence, motion } from 'motion/react'\nimport { ease, press } from '@/components/detent/lib/motion'\nimport { Spinner } from '@/components/detent/ui/Spinner'\nimport { tap } from '@/components/detent/lib/feel'\n\nexport type Variant = 'primary' | 'secondary' | 'ghost' | 'danger'\nexport type Size = 'sm' | 'md' | 'lg'\n\nconst SIZE: Record<Size, string> = {\n  sm: 'h-8 pointer-coarse:h-9 gap-1.5 rounded-[9px] px-3 text-footnote',\n  md: 'h-9 gap-2 rounded-control px-3.5 text-callout',\n  lg: 'h-11 gap-2 rounded-row px-5 text-body',\n}\nconst ICON: Record<Size, string> = { sm: 'size-8 pointer-coarse:size-9 rounded-[9px]', md: 'size-9 rounded-control', lg: 'size-11 rounded-row' }\n\nconst VARIANT: Record<Variant, string> = {\n  primary: 'bg-ink text-surface shadow-[inset_0_1px_0_rgb(255_255_255/0.14),0_1px_2px_rgb(0_0_0/0.16)] hover:bg-[color-mix(in_oklch,var(--ink),var(--surface)_14%)]',\n  secondary: 'bg-surface text-ink shadow-raised hover:shadow-[var(--elev-raised-hover)]',\n  ghost: 'text-ink-2 hover:bg-surface-2 hover:text-ink active:bg-surface-3',\n  danger: 'chip text-danger [--chip-wash:11%] [--chip:var(--danger)] hover:[--chip-wash:17%]',\n}\n\nexport const buttonClass = (variant: Variant = 'secondary', size: Size = 'md', icon = false) =>\n  `sink ring-focus relative inline-flex shrink-0 select-none items-center justify-center font-medium transition-[background-color,color,box-shadow] ease-detent duration-150 disabled:pointer-events-none disabled:opacity-45 ${icon ? ICON[size] : SIZE[size]} ${VARIANT[variant]}`\n\nexport function Button({\n  variant = 'secondary',\n  size = 'md',\n  icon,\n  loading = false,\n  done,\n  children,\n  className = '',\n  onPointerDown,\n  ...rest\n}: Omit<ComponentProps<typeof motion.button>, 'children'> & {\n  variant?: Variant\n  size?: Size\n  icon?: boolean\n  loading?: boolean\n  done?: ReactNode\n  children?: ReactNode\n}) {\n  const hidden = loading || !!done\n  return (\n    <motion.button\n      type=\"button\"\n      whileTap={rest.disabled || loading ? undefined : press}\n      aria-busy={loading || undefined}\n      onPointerDown={(e) => {\n        if (!rest.disabled && !loading) tap()\n        onPointerDown?.(e)\n      }}\n      className={`${buttonClass(variant, size, icon)} ${className}`}\n      {...rest}\n    >\n      <motion.span\n        className=\"inline-flex items-center gap-[inherit]\"\n        initial={false}\n        animate={{ opacity: hidden ? 0 : 1, y: done && !loading ? -6 : 0 }}\n        transition={{ duration: 0.16, ease: ease.out }}\n      >\n        {children}\n      </motion.span>\n      <AnimatePresence>\n        {loading && (\n          <motion.span\n            className=\"absolute inset-0 flex items-center justify-center\"\n            initial={{ opacity: 0 }}\n            animate={{ opacity: 1 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.16, ease: ease.out }}\n          >\n            <Spinner size={size === 'lg' ? 18 : 16} />\n          </motion.span>\n        )}\n        {done && !loading && (\n          <motion.span\n            key=\"done\"\n            className=\"absolute inset-0 flex items-center justify-center gap-[inherit]\"\n            initial={{ opacity: 0, y: 6 }}\n            animate={{ opacity: 1, y: 0 }}\n            exit={{ opacity: 0 }}\n            transition={{ duration: 0.2, ease: ease.out }}\n          >\n            {done}\n          </motion.span>\n        )}\n      </AnimatePresence>\n    </motion.button>\n  )\n}\n"},{"path":"components/detent/ui/Kbd.tsx","target":"components/detent/ui/Kbd.tsx","type":"registry:component","content":"'use client'\n\nfunction Return() {\n  return (\n    <svg width={12} height={12} viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.25} strokeLinecap=\"round\" strokeLinejoin=\"round\" role=\"img\" aria-label=\"Return\">\n      <path d=\"M18.5 5.5V11a3 3 0 0 1-3 3H5.5M10 9.5 5.5 14l4.5 4.5\" />\n    </svg>\n  )\n}\n\nexport function keyLabel(text: string) {\n  return text\n    .split(/(↵)/)\n    .filter(Boolean)\n    .map((part, i) => (part === '↵' ? <Return key={i} /> : part))\n}\n\nexport function Kbd({ children, onInk = false }: { children: string; onInk?: boolean }) {\n  return (\n    <kbd\n      className={`inline-flex pointer-coarse:hidden h-5 min-w-5 items-center justify-center gap-px rounded-chip px-1 font-sans text-caption font-medium leading-none ${\n        onInk ? 'bg-[color-mix(in_oklch,var(--surface)_16%,transparent)] text-[color-mix(in_oklch,var(--surface)_72%,transparent)]' : 'bg-surface-2 text-ink-2'\n      }`}\n    >\n      {keyLabel(children)}\n    </kbd>\n  )\n}\n"},{"path":"components/detent/ui/Morph.tsx","target":"components/detent/ui/Morph.tsx","type":"registry:component","content":"'use client'\n\nimport { useLayoutEffect, useRef, useState } from 'react'\nimport type { CSSProperties, ReactNode, Ref } from 'react'\nimport { AnimatePresence, animate, motion, useMotionValue, useTransform } from 'motion/react'\nimport type { MotionValue, Transition } from 'motion/react'\nimport { ease, spring } from '@/components/detent/lib/motion'\n\ntype Anchor = 'top' | 'bottom' | 'center'\ntype Justify = 'start' | 'center' | 'end'\n\nexport function Morph({\n  view,\n  views,\n  radius = 20,\n  anchor = 'top',\n  justify = 'center',\n  transition = spring.smooth,\n  className = '',\n  style,\n  onPointerEnter,\n  onPointerLeave,\n}: {\n  view: string\n  views: Record<string, ReactNode>\n  radius?: number | Record<string, number>\n  anchor?: Anchor\n  justify?: Justify\n  transition?: Transition\n  className?: string\n  style?: CSSProperties\n  onPointerEnter?: () => void\n  onPointerLeave?: () => void\n}) {\n  const [sizes, setSizes] = useState<Record<string, { w: number; h: number }>>({})\n  const probes = useRef<Record<string, HTMLDivElement | null>>({})\n  const w = useMotionValue(0)\n  const h = useMotionValue(0)\n  const r = useMotionValue(typeof radius === 'number' ? radius : (radius[view] ?? 20))\n  const placed = useRef(false)\n  const surface = useRef<HTMLDivElement>(null)\n\n  useLayoutEffect(() => {\n    const read = () => {\n      const next: Record<string, { w: number; h: number }> = {}\n      for (const [k, el] of Object.entries(probes.current)) if (el) next[k] = { w: el.offsetWidth, h: el.offsetHeight }\n      setSizes((prev) => (JSON.stringify(prev) === JSON.stringify(next) ? prev : next))\n    }\n    read()\n    const ro = new ResizeObserver(read)\n    Object.values(probes.current).forEach((el) => el && ro.observe(el))\n    return () => ro.disconnect()\n  })\n\n  const size = sizes[view]\n  const targetR = typeof radius === 'number' ? radius : (radius[view] ?? 20)\n\n  useLayoutEffect(() => {\n    if (!size) return\n    if (!placed.current) {\n      placed.current = true\n      w.set(size.w)\n      h.set(size.h)\n      r.set(targetR)\n      const el = surface.current\n      if (el) {\n        el.style.width = `${size.w}px`\n        el.style.height = `${size.h}px`\n      }\n      return\n    }\n    const a = animate(w, size.w, transition)\n    const b = animate(h, size.h, transition)\n    const c = animate(r, targetR, transition)\n    return () => {\n      a.stop()\n      b.stop()\n      c.stop()\n    }\n  }, [size?.w, size?.h, targetR, transition, w, h, r, size])\n\n  const align = anchor === 'top' ? 'items-start' : anchor === 'bottom' ? 'items-end' : 'items-center'\n  const along = justify === 'start' ? 'justify-start' : justify === 'end' ? 'justify-end' : 'justify-center'\n  const fx = justify === 'start' ? 0 : justify === 'end' ? 1 : 0.5\n  const fy = anchor === 'top' ? 0 : anchor === 'bottom' ? 1 : 0.5\n\n  return (\n    <>\n      <motion.div\n        ref={surface}\n        className={`relative overflow-hidden ${className}`}\n        style={{ ...style, ...(size ? { width: w, height: h } : { width: 'max-content' }), borderRadius: r }}\n        onPointerEnter={onPointerEnter}\n        onPointerLeave={onPointerLeave}\n      >\n        <div className={`${size ? 'absolute inset-0' : ''} flex ${along} ${align}`}>\n          <AnimatePresence initial={false} mode=\"popLayout\">\n            <Pane key={view} w={w} h={h} size={size} fx={fx} fy={fy}>\n              {views[view]}\n            </Pane>\n          </AnimatePresence>\n        </div>\n      </motion.div>\n\n      <div aria-hidden className=\"pointer-events-none invisible absolute left-0 top-0 -z-50 size-0 overflow-clip\" {...{ inert: true }}>\n        {Object.entries(views).map(([k, v]) => (\n          <div\n            key={k}\n            ref={(el) => {\n              probes.current[k] = el\n            }}\n            className=\"absolute left-0 top-0 w-max\"\n          >\n            {v}\n          </div>\n        ))}\n      </div>\n    </>\n  )\n}\n\nfunction Pane({ w, h, size, fx, fy, ref, children }: { w: MotionValue<number>; h: MotionValue<number>; size?: { w: number; h: number }; fx: number; fy: number; ref?: Ref<HTMLDivElement>; children: ReactNode }) {\n  const x = useTransform(w, (v) => (size ? (v - size.w) * fx : 0))\n  const y = useTransform(h, (v) => (size ? (v - size.h) * fy : 0))\n  return (\n    <motion.div\n      ref={ref}\n      className={`w-max shrink-0 ${size ? 'absolute left-0 top-0' : ''}`}\n      style={{ x, y }}\n      initial={{ opacity: 0, scale: 0.96 }}\n      animate={{ opacity: 1, scale: 1, transition: { duration: 0.22, delay: 0.1, ease: ease.out } }}\n      exit={{ opacity: 0, scale: 0.98, transition: { duration: 0.1, ease: ease.out } }}\n    >\n      {children}\n    </motion.div>\n  )\n}\n"},{"path":"components/detent/ui/RollingText.tsx","target":"components/detent/ui/RollingText.tsx","type":"registry:component","content":"'use client'\n\nimport { useLayoutEffect, useRef, useState } from 'react'\nimport { animate, motion, useMotionValue } from 'motion/react'\n\nconst roll = { type: 'spring', stiffness: 380, damping: 34, mass: 0.8 } as const\n\nexport function RollingText({ text, className = '', proportional = false, still = false }: { text: string; className?: string; proportional?: boolean; still?: boolean }) {\n  const chars = [...text]\n  const probe = useRef<HTMLSpanElement>(null)\n  const [widths, setWidths] = useState<number[] | null>(null)\n\n  useLayoutEffect(() => {\n    if (!proportional || !probe.current) return\n    const read = () => {\n      const box = probe.current!\n      const z = box.offsetWidth ? box.getBoundingClientRect().width / box.offsetWidth : 1\n      const em = parseFloat(getComputedStyle(box).fontSize) || 16\n      setWidths([...box.children].map((c) => (c as HTMLElement).getBoundingClientRect().width / z / em))\n    }\n    read()\n    document.fonts?.ready.then(read)\n  }, [proportional])\n\n  return (\n    <span className={`relative inline-flex ${proportional ? '' : 'tnum'} ${className}`} style={{ lineHeight: '1.25em', height: '1.25em' }}>\n      <span className=\"sr-only\">{text}</span>\n      {proportional && (\n        <span aria-hidden className=\"pointer-events-none absolute left-0 top-0 size-0 overflow-hidden\">\n          <span ref={probe} className=\"invisible flex w-max whitespace-pre\">\n            {Array.from({ length: 10 }, (_, n) => (\n              <span key={n}>{n}</span>\n            ))}\n          </span>\n        </span>\n      )}\n      {chars.map((c, i) => {\n        const key = chars.length - i\n        return /\\d/.test(c) ? (\n          <Digit key={key} d={+c} width={proportional && widths ? widths[+c] : undefined} still={still} />\n        ) : (\n          <span key={`${key}${c}`} aria-hidden className=\"whitespace-pre\">\n            {c}\n          </span>\n        )\n      })}\n    </span>\n  )\n}\n\nfunction Digit({ d, width, still }: { d: number; width?: number; still: boolean }) {\n  const w = useMotionValue<string>(width === undefined ? '1ch' : `${width}em`)\n  const had = useRef(width !== undefined)\n  useLayoutEffect(() => {\n    if (width === undefined) return\n    if (!had.current) {\n      had.current = true\n      w.set(`${width}em`)\n      return\n    }\n    const ctl = animate(w, `${width}em`, roll)\n    return () => ctl.stop()\n  }, [width, w])\n\n  return (\n    <motion.span aria-hidden className=\"relative inline-block overflow-hidden\" style={{ height: '1.25em', width: w }}>\n      <motion.span className=\"absolute inset-x-0 top-0 flex flex-col items-center\" initial={false} animate={{ y: `${-d * 10}%` }} transition={still ? { duration: 0 } : roll}>\n        {Array.from({ length: 10 }, (_, n) => (\n          <span key={n} className=\"block\" style={{ height: '1.25em' }}>\n            {n}\n          </span>\n        ))}\n      </motion.span>\n    </motion.span>\n  )\n}\n"},{"path":"components/detent/ui/FileGlyph.tsx","target":"components/detent/ui/FileGlyph.tsx","type":"registry:component","content":"'use client'\n\nconst KIND: [RegExp, string][] = [\n  [/^pdf$/, 'light-dark(oklch(0.57 0.17 18), oklch(0.74 0.14 18))'],\n  [/^(fig|sketch|xd)$/, 'light-dark(oklch(0.55 0.2 300), oklch(0.74 0.15 300))'],\n  [/^(mp4|mov|webm)$/, 'light-dark(oklch(0.55 0.19 268), oklch(0.74 0.13 268))'],\n  [/^(png|jpe?g|gif|webp|svg)$/, 'light-dark(oklch(0.56 0.13 160), oklch(0.76 0.12 160))'],\n  [/^(ts|tsx|js|jsx|json)$/, 'light-dark(oklch(0.56 0.14 238), oklch(0.76 0.11 238))'],\n  [/^(csv|xlsx?)$/, 'light-dark(oklch(0.56 0.13 150), oklch(0.76 0.12 150))'],\n  [/^(zip|tar|gz)$/, 'light-dark(oklch(0.6 0.13 70), oklch(0.8 0.12 75))'],\n]\n\nexport const fileTint = (name: string) => {\n  const ext = (name.includes('.') ? name.split('.').pop()! : '').toLowerCase()\n  return KIND.find(([re]) => re.test(ext))?.[1] ?? null\n}\n\nexport function FileGlyph({ name, size = 34, preview, className = '' }: { name: string; size?: number; preview?: string; className?: string }) {\n  const ext = (name.includes('.') ? name.split('.').pop()! : '').slice(0, 4).toUpperCase()\n  const tint = fileTint(name)\n  const width = Math.round(size * (28 / 34))\n  if (preview)\n    return (\n      <span\n        aria-hidden\n        className={`block shrink-0 rounded-[6px] ${className}`}\n        style={{ width, height: size, background: preview, boxShadow: 'inset 0 0 0 1px rgb(0 0 0 / 0.08)' }}\n      />\n    )\n  return (\n    <svg aria-hidden width={width} height={size} viewBox=\"0 0 28 34\" fill=\"none\" className={`shrink-0 ${className}`}>\n      <path d=\"M5 .5h12.4c.8 0 1.5.3 2.1.9l7.1 7.1c.6.6.9 1.3.9 2.1V29a4.5 4.5 0 0 1-4.5 4.5H5A4.5 4.5 0 0 1 .5 29V5A4.5 4.5 0 0 1 5 .5Z\" fill=\"var(--surface)\" stroke=\"var(--line-strong)\" />\n      <path\n        d=\"M17.5.8V6A3.5 3.5 0 0 0 21 9.5h6.2Z\"\n        strokeLinejoin=\"round\"\n        style={{ fill: tint ? `color-mix(in oklch, ${tint} 22%, var(--surface))` : 'var(--surface-2)', stroke: tint ? `color-mix(in oklch, ${tint} 55%, var(--line-strong))` : 'var(--line-strong)' }}\n      />\n      {ext && (\n        <text x=\"14\" y=\"27.5\" textAnchor=\"middle\" fontSize=\"6.4\" fontWeight=\"650\" letterSpacing=\"0.3\" style={{ fontFamily: 'var(--font-sans)', fill: tint ?? 'var(--ink-3)' }}>\n          {ext}\n        </text>\n      )}\n    </svg>\n  )\n}\n"},{"path":"components/detent/ui/Spinner.tsx","target":"components/detent/ui/Spinner.tsx","type":"registry:component","content":"'use client'\n\nexport function Spinner({ size = 16, className = '' }: { size?: number; className?: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 16 16\" fill=\"none\" aria-hidden className={`motion-safe:animate-spin ${className}`} style={{ animationDuration: '0.7s' }}>\n      <circle cx=\"8\" cy=\"8\" r=\"6.25\" stroke=\"currentColor\" strokeOpacity=\"0.22\" strokeWidth=\"1.75\" />\n      <path d=\"M14.25 8A6.25 6.25 0 0 0 8 1.75\" stroke=\"currentColor\" strokeWidth=\"1.75\" strokeLinecap=\"round\" />\n    </svg>\n  )\n}\n"},{"path":"components/detent/lib/feel.ts","target":"components/detent/lib/feel.ts","type":"registry:component","content":"export const tap = () => {\n  if (typeof window !== 'undefined') window.dispatchEvent(new Event('detent:tap'))\n}\n\nlet keyed = true\nif (typeof window !== 'undefined') {\n  window.addEventListener('keydown', () => void (keyed = true), true)\n  window.addEventListener('pointerdown', () => void (keyed = false), true)\n}\nexport const byKey = () => keyed\n"}]}