{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "shortcuts-cheat-sheet",
  "title": "Shortcuts Cheat Sheet",
  "description": "A keyboard-shortcut cheat sheet whose keycaps press themselves: matching keydowns depress the cap and are swallowed before the app behind it can react.",
  "dependencies": [],
  "files": [
    {
      "path": "registry/core/shortcuts-cheat-sheet/component.tsx",
      "content": "\"use client\";\n\nimport { useCallback, useEffect, useId, useMemo, useRef, useState } from \"react\";\n\n// A keyboard-shortcut cheat sheet that owns the keyboard while it is up.\n// Shortcuts render as physical keycaps; every real keydown that matches a\n// listed combo depresses that specific cap and flashes it in --ns-accent, and the\n// event is swallowed (preventDefault + stopPropagation in the capture phase)\n// so the app's own handler behind the overlay does not also fire. You can\n// rehearse a shortcut and watch its keys press themselves — clicking a row\n// plays the same press, one step at a time for sequences like \"G then P\".\n//\n// Everything modal comes from the native <dialog> opened with showModal():\n// focus trap, background inertness, top-layer stacking, ::backdrop and\n// Escape-to-close are the platform's, not a hand-rolled trap.\n//\n// The part that actually decides whether this works is normalization, and it\n// is deliberately not a string compare. A chord is a set of required modifier\n// flags plus one canonical base key. Matching runs two passes: an exact pass\n// where every modifier flag must agree, then a lenient pass that ignores Shift\n// for single printable characters — \"?\" arrives as {key:\"?\", shiftKey:true} on\n// US layouts, so a naive exact compare against the token \"?\" never fires,\n// while a blanket \"ignore shift\" would make Mod+Shift+Z indistinguishable from\n// Mod+Z. Exact-first gives both. \"Mod\" folds to metaKey on Apple and ctrlKey\n// elsewhere and never to both, so a plain Ctrl press on a Mac does not match a\n// Mod shortcut. Letters and digits additionally accept e.code (KeyK / Digit1)\n// when the chord carries a modifier, which is what rescues non-Latin layouts\n// where e.key is a Cyrillic or Greek character.\n\nconst MODIFIER_KEYS = new Set([\"Shift\", \"Control\", \"Alt\", \"Meta\", \"CapsLock\", \"OS\"]);\nconst SEQUENCE_WINDOW_MS = 1200; // how long \"G\" waits for its \"P\"\nconst STEP_GAP_MS = 60; // pause between rehearsed steps\n\n/** One chord: the modifier flags it requires plus its single base key. */\nexport type QuickKeyChord = {\n  /** Display tokens, in the order they were authored. */\n  tokens: string[];\n  /** Canonical base key: \"K\", \"?\", \"ESC\", \"ENTER\", \"↑\", \"SPACE\"… */\n  base: string;\n  ctrl: boolean;\n  meta: boolean;\n  shift: boolean;\n  alt: boolean;\n};\n\nexport type QuickKeyShortcut = {\n  /**\n   * Tokens: \"Mod\" | \"Ctrl\" | \"Meta\" | \"Shift\" | \"Alt\" plus one key per chord\n   * (\"K\", \"?\", \"Enter\", \"Esc\", \"↑\", \"Space\"). A literal \"then\" token starts a\n   * new chord, so [\"G\", \"then\", \"P\"] is a two-step sequence.\n   */\n  keys: string[];\n  label: string;\n};\n\nexport type QuickKeySection = { title: string; items: QuickKeyShortcut[] };\n\nexport interface QuickKeyProps {\n  /** Grouped shortcut list. Rendered in order; sections flow into `columns`. */\n  sections: QuickKeySection[];\n  /** Controlled open state. Omit to run uncontrolled from `defaultOpen`. */\n  open?: boolean;\n  /** Uncontrolled initial state. Ignored when `open` is passed. */\n  defaultOpen?: boolean;\n  /** Fired for every close the platform can originate: Escape, backdrop, the close button. */\n  onOpenChange?: (open: boolean) => void;\n  /** heading above the sections */\n  title?: string;\n  /** number of columns the sections flow into */\n  columns?: 1 | 2;\n  /** Match real keydowns and flash the matching caps. Default true. */\n  liveEcho?: boolean;\n  /** How long a cap stays depressed, ms. Default 180. */\n  echoDuration?: number;\n  /** extra classes merged onto the rendered root element */\n  className?: string;\n}\n\n/* ---------------------------------------------------------------- parsing */\n\nconst NAMED_BASE: Record<string, string> = {\n  esc: \"ESC\",\n  escape: \"ESC\",\n  enter: \"ENTER\",\n  return: \"ENTER\",\n  tab: \"TAB\",\n  space: \"SPACE\",\n  spacebar: \"SPACE\",\n  backspace: \"BACKSPACE\",\n  delete: \"DELETE\",\n  del: \"DELETE\",\n  up: \"↑\",\n  down: \"↓\",\n  left: \"←\",\n  right: \"→\",\n  arrowup: \"↑\",\n  arrowdown: \"↓\",\n  arrowleft: \"←\",\n  arrowright: \"→\",\n};\n\n/** Fold an author token or an `event.key` onto one canonical spelling. */\nexport function canonicalBase(raw: string): string {\n  if (raw === \" \") return \"SPACE\";\n  if (raw.length === 1) return raw.toUpperCase();\n  return NAMED_BASE[raw.toLowerCase()] ?? raw.toUpperCase();\n}\n\n/** Split `keys` on \"then\" and parse each chord. `isApple` decides what Mod folds to. */\nexport function parseShortcut(keys: string[], isApple: boolean): QuickKeyChord[] {\n  const steps: string[][] = [[]];\n  for (const token of keys) {\n    if (/^(then|>)$/i.test(token)) steps.push([]);\n    else steps[steps.length - 1].push(token);\n  }\n  return steps\n    .filter((tokens) => tokens.length > 0)\n    .map((tokens) => {\n      const chord: QuickKeyChord = { tokens, base: \"\", ctrl: false, meta: false, shift: false, alt: false };\n      for (const token of tokens) {\n        switch (token.toLowerCase()) {\n          case \"mod\":\n            if (isApple) chord.meta = true;\n            else chord.ctrl = true;\n            break;\n          case \"ctrl\":\n          case \"control\":\n          case \"⌃\":\n            chord.ctrl = true;\n            break;\n          case \"meta\":\n          case \"cmd\":\n          case \"command\":\n          case \"⌘\":\n            chord.meta = true;\n            break;\n          case \"shift\":\n          case \"⇧\":\n            chord.shift = true;\n            break;\n          case \"alt\":\n          case \"opt\":\n          case \"option\":\n          case \"⌥\":\n            chord.alt = true;\n            break;\n          default:\n            chord.base = canonicalBase(token);\n        }\n      }\n      return chord;\n    });\n}\n\n/** The subset of KeyboardEvent matching reads — so it can be exercised with a literal. */\nexport type QuickKeyEvent = {\n  key: string;\n  code?: string;\n  ctrlKey: boolean;\n  metaKey: boolean;\n  shiftKey: boolean;\n  altKey: boolean;\n};\n\nfunction baseMatches(chord: QuickKeyChord, e: QuickKeyEvent): boolean {\n  if (canonicalBase(e.key) === chord.base) return true;\n  // Physical-position fallback. Only for letters/digits, and only when the\n  // chord carries a modifier — otherwise a Cyrillic layout typing \"к\" would\n  // fire a bare \"K\" shortcut the user never asked for.\n  if (!e.code || chord.base.length !== 1) return false;\n  if (!chord.ctrl && !chord.meta && !chord.alt) return false;\n  if (chord.base >= \"A\" && chord.base <= \"Z\") return e.code === `Key${chord.base}`;\n  if (chord.base >= \"0\" && chord.base <= \"9\") return e.code === `Digit${chord.base}`;\n  return false;\n}\n\n/**\n * `lenientShift` runs the second pass: Shift is treated as already baked into\n * the printed character. Only legal for a single-character base on an event\n * that actually held Shift, so it can never widen a named-key or chord match.\n */\nexport function chordMatchesEvent(chord: QuickKeyChord, e: QuickKeyEvent, lenientShift = false): boolean {\n  if (!chord.base) return false;\n  if (e.ctrlKey !== chord.ctrl || e.metaKey !== chord.meta || e.altKey !== chord.alt) return false;\n  if (lenientShift) {\n    if (chord.shift || !e.shiftKey || chord.base.length !== 1) return false;\n  } else if (e.shiftKey !== chord.shift) {\n    return false;\n  }\n  return baseMatches(chord, e);\n}\n\n// Dev-only tripwire. Normalization is the one part of this component that can\n// break silently — a wrong fold still screenshots perfectly, it just never\n// fires. These are the four cases that go wrong in practice. `warn`, not\n// `error`, so a failure is loud in the console without tripping a screenshot\n// gate that only watches for errors.\nif (process.env.NODE_ENV !== \"production\") {\n  const ev = (key: string, mods: Partial<QuickKeyEvent> = {}): QuickKeyEvent => ({\n    key,\n    ctrlKey: false,\n    metaKey: false,\n    shiftKey: false,\n    altKey: false,\n    ...mods,\n  });\n  const macModK = parseShortcut([\"Mod\", \"K\"], true)[0];\n  const modZ = parseShortcut([\"Mod\", \"Z\"], false)[0];\n  const modShiftZ = parseShortcut([\"Mod\", \"Shift\", \"Z\"], false)[0];\n  const question = parseShortcut([\"?\"], false)[0];\n  const checks: [string, boolean][] = [\n    [\"Mod folds to Meta on Apple\", chordMatchesEvent(macModK, ev(\"k\", { metaKey: true }))],\n    [\"Mod does not match bare Ctrl on Apple\", !chordMatchesEvent(macModK, ev(\"k\", { ctrlKey: true }))],\n    [\"? matches Shift+/ only on the lenient pass\", !chordMatchesEvent(question, ev(\"?\", { shiftKey: true })) && chordMatchesEvent(question, ev(\"?\", { shiftKey: true }), true)],\n    [\"Mod+Shift+Z does not collapse into Mod+Z\", chordMatchesEvent(modShiftZ, ev(\"Z\", { ctrlKey: true, shiftKey: true })) && !chordMatchesEvent(modZ, ev(\"Z\", { ctrlKey: true, shiftKey: true }))],\n    [\"non-Latin layout falls back to e.code\", chordMatchesEvent(macModK, ev(\"к\", { code: \"KeyK\", metaKey: true }))],\n  ];\n  for (const [name, ok] of checks) {\n    if (!ok) console.warn(`[shortcuts-cheat-sheet] key normalization check failed: ${name}`);\n  }\n}\n\n/* --------------------------------------------------------------- display */\n\nfunction displayToken(token: string, isApple: boolean): string {\n  switch (token.toLowerCase()) {\n    case \"mod\":\n      return isApple ? \"⌘\" : \"Ctrl\";\n    case \"meta\":\n    case \"cmd\":\n    case \"command\":\n      return isApple ? \"⌘\" : \"Win\";\n    case \"ctrl\":\n    case \"control\":\n      return isApple ? \"⌃\" : \"Ctrl\";\n    case \"shift\":\n      return isApple ? \"⇧\" : \"Shift\";\n    case \"alt\":\n    case \"opt\":\n    case \"option\":\n      return isApple ? \"⌥\" : \"Alt\";\n    case \"space\":\n      return \"Space\";\n    default:\n      return token;\n  }\n}\n\nconst SPOKEN: Record<string, string> = {\n  \"⌘\": \"Command\",\n  \"⇧\": \"Shift\",\n  \"⌥\": \"Option\",\n  \"⌃\": \"Control\",\n  \"↑\": \"Up arrow\",\n  \"↓\": \"Down arrow\",\n  \"←\": \"Left arrow\",\n  \"→\": \"Right arrow\",\n  \"?\": \"Question mark\",\n  \"/\": \"Slash\",\n  \",\": \"Comma\",\n  \".\": \"Period\",\n};\n\n/** \"Command plus K\", so a screen reader never has to read ⌘ as an unknown glyph. */\nfunction spokenKeys(chords: QuickKeyChord[], isApple: boolean): string {\n  return chords\n    .map((chord) =>\n      chord.tokens\n        .map((token) => {\n          const shown = displayToken(token, isApple);\n          return SPOKEN[shown] ?? shown;\n        })\n        .join(\" plus \")\n    )\n    .join(\", then \");\n}\n\n/* ------------------------------------------------------------- component */\n\nexport function QuickKey({\n  sections,\n  open,\n  defaultOpen = false,\n  onOpenChange,\n  title = \"Keyboard Shortcuts\",\n  columns = 2,\n  liveEcho = true,\n  echoDuration = 180,\n  className = \"\",\n}: QuickKeyProps) {\n  const dialogRef = useRef<HTMLDialogElement>(null);\n  const closingRef = useRef(0);\n  const flashTimers = useRef<number[]>([]);\n  const pendingRef = useRef<{ row: string; step: number } | null>(null);\n  const pendingTimer = useRef(0);\n  const titleId = useId();\n\n  const [uncontrolled, setUncontrolled] = useState(defaultOpen);\n  const isOpen = open ?? uncontrolled;\n  const [flash, setFlash] = useState<string | null>(null);\n\n  // Resolved after mount so the server and the first client render agree; SSR\n  // ships the \"Ctrl\" spelling and Apple machines correct it in one commit.\n  const [isApple, setIsApple] = useState(false);\n  useEffect(() => {\n    const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n    const platform = nav.userAgentData?.platform || navigator.platform || navigator.userAgent || \"\";\n    setIsApple(/mac|iphone|ipad|ipod/i.test(platform));\n  }, []);\n\n  const rows = useMemo(\n    () =>\n      sections.map((section, s) => ({\n        ...section,\n        items: section.items.map((item, i) => ({\n          ...item,\n          rowKey: `${s}-${i}`,\n          chords: parseShortcut(item.keys, isApple),\n        })),\n      })),\n    [sections, isApple]\n  );\n\n  const flatRows = useMemo(() => rows.flatMap((section) => section.items), [rows]);\n\n  const clearFlashTimers = useCallback(() => {\n    flashTimers.current.forEach(clearTimeout);\n    flashTimers.current = [];\n  }, []);\n\n  const requestClose = useCallback(() => {\n    onOpenChange?.(false);\n    if (open === undefined) setUncontrolled(false);\n  }, [onOpenChange, open]);\n\n  /** Depress one step's caps for `echoDuration`. */\n  const flashStep = useCallback(\n    (rowKey: string, step: number) => {\n      clearFlashTimers();\n      setFlash(`${rowKey}:${step}`);\n      flashTimers.current.push(window.setTimeout(() => setFlash(null), Math.max(40, echoDuration)));\n    },\n    [clearFlashTimers, echoDuration]\n  );\n\n  /** Click a row: play every step in order, so a sequence reads as a sequence. */\n  const rehearse = useCallback(\n    (rowKey: string, stepCount: number) => {\n      clearFlashTimers();\n      const beat = Math.max(40, echoDuration) + STEP_GAP_MS;\n      setFlash(`${rowKey}:0`);\n      for (let step = 1; step < stepCount; step += 1) {\n        flashTimers.current.push(\n          window.setTimeout(() => setFlash(`${rowKey}:${step}`), step * beat)\n        );\n      }\n      flashTimers.current.push(window.setTimeout(() => setFlash(null), stepCount * beat));\n    },\n    [clearFlashTimers, echoDuration]\n  );\n\n  // Open/close the platform dialog from state.\n  useEffect(() => {\n    const dlg = dialogRef.current;\n    if (!dlg) return;\n    if (isOpen) {\n      clearTimeout(closingRef.current);\n      dlg.removeAttribute(\"data-closing\");\n      if (!dlg.open) dlg.showModal();\n      return;\n    }\n    if (!dlg.open || dlg.hasAttribute(\"data-closing\")) return;\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n    if (reduced) {\n      dlg.close();\n      return;\n    }\n    // timer-driven, not transitionend-driven: a backgrounded tab must not be\n    // able to strand an open dialog\n    dlg.setAttribute(\"data-closing\", \"\");\n    closingRef.current = window.setTimeout(() => {\n      dlg.removeAttribute(\"data-closing\");\n      dlg.close();\n    }, 150);\n  }, [isOpen]);\n\n  // Escape fires `cancel`; `close` catches anything that closed the dialog\n  // without going through the prop (form method=dialog, browser UI).\n  useEffect(() => {\n    const dlg = dialogRef.current;\n    if (!dlg) return;\n    const onCancel = (e: Event) => {\n      e.preventDefault();\n      requestClose();\n    };\n    const onClose = () => {\n      if (isOpen) requestClose();\n    };\n    const onClick = (e: MouseEvent) => {\n      if (e.target === dlg) requestClose();\n    };\n    dlg.addEventListener(\"cancel\", onCancel);\n    dlg.addEventListener(\"close\", onClose);\n    dlg.addEventListener(\"click\", onClick);\n    return () => {\n      dlg.removeEventListener(\"cancel\", onCancel);\n      dlg.removeEventListener(\"close\", onClose);\n      dlg.removeEventListener(\"click\", onClick);\n    };\n  }, [isOpen, requestClose]);\n\n  // The keyboard-ownership listener. Capture phase on window, installed only\n  // while open, so nothing behind the overlay ever sees a listed combo.\n  useEffect(() => {\n    if (!isOpen || !liveEcho) return;\n    const onKeyDown = (e: KeyboardEvent) => {\n      if (MODIFIER_KEYS.has(e.key)) return;\n      // Escape and Tab stay the platform's: Escape closes via `cancel`, Tab\n      // walks the dialog's native focus trap.\n      if (e.key === \"Escape\" || e.key === \"Tab\") {\n        pendingRef.current = null;\n        return;\n      }\n      // Enter/Space on a focused control activates it. Swallowing those would\n      // make the panel's own buttons unreachable by keyboard the moment a\n      // sheet happens to list Enter as a shortcut.\n      if ((e.key === \"Enter\" || e.key === \" \") && (e.target as HTMLElement | null)?.closest?.(\"button\")) {\n        return;\n      }\n\n      const pending = pendingRef.current;\n      if (pending) {\n        const row = flatRows.find((r) => r.rowKey === pending.row);\n        const chord = row?.chords[pending.step];\n        if (row && chord && (chordMatchesEvent(chord, e) || chordMatchesEvent(chord, e, true))) {\n          e.preventDefault();\n          e.stopPropagation();\n          flashStep(row.rowKey, pending.step);\n          clearTimeout(pendingTimer.current);\n          pendingRef.current =\n            pending.step + 1 < row.chords.length ? { row: row.rowKey, step: pending.step + 1 } : null;\n          if (pendingRef.current) {\n            pendingTimer.current = window.setTimeout(() => {\n              pendingRef.current = null;\n            }, SEQUENCE_WINDOW_MS);\n          }\n          return;\n        }\n        pendingRef.current = null;\n        clearTimeout(pendingTimer.current);\n      }\n\n      // exact pass first, lenient (Shift folded into the character) second\n      const hit =\n        flatRows.find((r) => r.chords[0] && chordMatchesEvent(r.chords[0], e)) ??\n        flatRows.find((r) => r.chords[0] && chordMatchesEvent(r.chords[0], e, true));\n      if (!hit) return;\n\n      e.preventDefault();\n      e.stopPropagation();\n      flashStep(hit.rowKey, 0);\n      if (hit.chords.length > 1) {\n        pendingRef.current = { row: hit.rowKey, step: 1 };\n        clearTimeout(pendingTimer.current);\n        pendingTimer.current = window.setTimeout(() => {\n          pendingRef.current = null;\n        }, SEQUENCE_WINDOW_MS);\n      }\n    };\n    window.addEventListener(\"keydown\", onKeyDown, { capture: true });\n    return () => window.removeEventListener(\"keydown\", onKeyDown, { capture: true });\n  }, [isOpen, liveEcho, flatRows, flashStep]);\n\n  // Closing must not leave a half-played rehearsal to resume on reopen.\n  useEffect(() => {\n    if (isOpen) return;\n    clearFlashTimers();\n    clearTimeout(pendingTimer.current);\n    pendingRef.current = null;\n    setFlash(null);\n  }, [isOpen, clearFlashTimers]);\n\n  useEffect(\n    () => () => {\n      flashTimers.current.forEach(clearTimeout);\n      flashTimers.current = [];\n      clearTimeout(pendingTimer.current);\n      clearTimeout(closingRef.current);\n    },\n    []\n  );\n\n  return (\n    <dialog\n      ref={dialogRef}\n      aria-labelledby={titleId}\n      className={`ns-qk m-auto w-[min(40rem,calc(100vw-2rem))] overflow-visible p-0 ${className}`}\n    >\n      {/* showModal() focuses the first focusable descendant unless something\n          claims it. Left alone that pre-selects the first shortcut row and\n          paints a focus ring on it at rest — take it here so focus lands in\n          the panel, the title is announced, and Tab starts at the top. */}\n      <div autoFocus tabIndex={-1} className=\"ns-qk-panel\">\n        <header className=\"flex items-baseline justify-between gap-4 px-6 pb-4 pt-5\">\n          <h2 id={titleId} className=\"text-base font-semibold tracking-tight text-foreground\">\n            {title}\n          </h2>\n          <p className=\"shrink-0 text-xs text-ns-muted\">Press a shortcut to try it</p>\n        </header>\n\n        <div\n          className={`grid gap-x-8 gap-y-6 px-6 pb-2 ${columns === 2 ? \"sm:grid-cols-2\" : \"grid-cols-1\"}`}\n        >\n          {rows.map((section, s) => (\n            <section key={`${section.title}-${s}`} aria-labelledby={`${titleId}-s${s}`}>\n              <h3\n                id={`${titleId}-s${s}`}\n                className=\"mb-2 px-2 text-[11px] font-medium uppercase tracking-[0.06em] text-ns-muted\"\n              >\n                {section.title}\n              </h3>\n              <ul className=\"flex flex-col gap-0.5\">\n                {section.items.map((item) => (\n                  <li key={item.rowKey}>\n                    <button\n                      type=\"button\"\n                      data-rehearse\n                      onClick={() => rehearse(item.rowKey, item.chords.length)}\n                      aria-label={`${item.label}: ${spokenKeys(item.chords, isApple)}`}\n                      className=\"ns-qk-row\"\n                    >\n                      <span aria-hidden className=\"min-w-0 truncate text-[13px] text-foreground\">\n                        {item.label}\n                      </span>\n                      <span aria-hidden className=\"flex shrink-0 items-center gap-1\">\n                        {item.chords.map((chord, step) => (\n                          <span key={step} className=\"flex items-center gap-1\">\n                            {step > 0 && <span className=\"ns-qk-then\">then</span>}\n                            {chord.tokens.map((token, t) => (\n                              <kbd\n                                key={t}\n                                className=\"ns-qk-cap\"\n                                data-pressed={flash === `${item.rowKey}:${step}` ? \"\" : undefined}\n                              >\n                                {displayToken(token, isApple)}\n                              </kbd>\n                            ))}\n                          </span>\n                        ))}\n                      </span>\n                    </button>\n                  </li>\n                ))}\n              </ul>\n            </section>\n          ))}\n        </div>\n\n        <footer className=\"mt-2 flex items-center justify-between gap-4 border-t border-border px-6 py-3\">\n          <p className=\"flex items-center gap-2 text-xs text-ns-muted\">\n            <kbd className=\"ns-qk-cap\" aria-hidden>\n              Esc\n            </kbd>\n            to close\n          </p>\n          <button type=\"button\" onClick={requestClose} className=\"ns-qk-close\">\n            Close\n          </button>\n        </footer>\n      </div>\n\n      {/* ::backdrop inherits custom properties from its originating element,\n          so the scrim stays token-derived in both themes. */}\n      <style>{`\n        .ns-qk {\n          border: 1px solid var(--border);\n          border-radius: 16px;\n          background: var(--surface);\n          color: var(--foreground);\n          box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.45);\n          animation: ns-qk-panel-in 220ms cubic-bezier(0.22, 1, 0.36, 1) both;\n        }\n        .ns-qk[data-closing] { animation: ns-qk-panel-out 150ms ease-in both; }\n        .ns-qk::backdrop {\n          background: color-mix(in oklab, var(--background) 72%, transparent);\n          backdrop-filter: blur(2px);\n          animation: ns-qk-scrim-in 120ms linear both;\n        }\n        .ns-qk[data-closing]::backdrop { animation: ns-qk-scrim-out 150ms linear both; }\n        .ns-qk-panel { outline: none; }\n\n        @keyframes ns-qk-panel-in {\n          from { opacity: 0; transform: translateY(8px) scale(0.98); }\n          to { opacity: 1; transform: none; }\n        }\n        @keyframes ns-qk-panel-out {\n          from { opacity: 1; transform: none; }\n          to { opacity: 0; transform: translateY(4px) scale(0.99); }\n        }\n        @keyframes ns-qk-scrim-in { from { opacity: 0 } to { opacity: 1 } }\n        @keyframes ns-qk-scrim-out { from { opacity: 1 } to { opacity: 0 } }\n\n        .ns-qk-row {\n          display: flex;\n          width: 100%;\n          align-items: center;\n          justify-content: space-between;\n          gap: 16px;\n          padding: 5px 8px;\n          border: 1px solid transparent;\n          border-radius: 6px;\n          background: transparent;\n          text-align: left;\n          transition: background-color 140ms ease-out, border-color 140ms ease-out;\n        }\n        .ns-qk-row:hover {\n          background: color-mix(in oklab, var(--foreground) 6%, transparent);\n          border-color: var(--border);\n        }\n        .ns-qk-row:active {\n          background: color-mix(in oklab, var(--ns-accent) 12%, transparent);\n          border-color: color-mix(in oklab, var(--ns-accent) 45%, var(--border));\n        }\n        .ns-qk-row:focus-visible {\n          outline: 2px solid var(--ns-accent);\n          outline-offset: 2px;\n        }\n\n        .ns-qk-then {\n          font-size: 11px;\n          color: var(--ns-muted);\n          padding: 0 2px;\n        }\n\n        .ns-qk-cap {\n          display: inline-flex;\n          align-items: center;\n          justify-content: center;\n          min-width: 26px;\n          height: 26px;\n          padding: 0 7px;\n          border: 1px solid var(--border);\n          border-radius: 6px;\n          /* the panel is --surface, so caps sit on --background to read as a\n             separate physical object in both themes */\n          background: var(--background);\n          box-shadow: 0 2px 0 var(--border);\n          color: var(--foreground);\n          font: 500 12px/1 var(--font-mono, ui-monospace, monospace);\n          white-space: nowrap;\n          /* release: slow settle back up */\n          transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1),\n            box-shadow 140ms cubic-bezier(0.22, 1, 0.36, 1),\n            background-color 200ms ease-out, border-color 200ms ease-out, color 200ms ease-out;\n        }\n        .ns-qk-cap[data-pressed] {\n          transform: translateY(2px);\n          box-shadow: 0 0 0 var(--border);\n          border-color: var(--ns-accent);\n          background: color-mix(in oklab, var(--ns-accent) 14%, var(--surface));\n          color: var(--ns-accent);\n          /* press-in: immediate */\n          transition: transform 60ms linear, box-shadow 60ms linear,\n            background-color 60ms linear, border-color 60ms linear, color 60ms linear;\n        }\n\n        .ns-qk-close {\n          border: 1px solid var(--border);\n          border-radius: 6px;\n          background: var(--background);\n          color: var(--foreground);\n          font-size: 12px;\n          padding: 4px 12px;\n          transition: background-color 140ms ease-out, border-color 140ms ease-out;\n        }\n        .ns-qk-close:hover {\n          border-color: var(--ns-accent);\n          background: color-mix(in oklab, var(--ns-accent) 10%, var(--background));\n        }\n        .ns-qk-close:focus-visible { outline: 2px solid var(--ns-accent); outline-offset: 2px; }\n\n        @media (prefers-reduced-motion: reduce) {\n          /* opacity only, one frame; the flash drops travel and becomes a pure\n             colour change — still a real pixel change, so headless\n             hover/keydown verification keeps working */\n          .ns-qk, .ns-qk[data-closing] {\n            animation-duration: 1ms;\n            animation-timing-function: linear;\n          }\n          @keyframes ns-qk-panel-in { from { opacity: 0 } to { opacity: 1 } }\n          @keyframes ns-qk-panel-out { from { opacity: 1 } to { opacity: 0 } }\n          .ns-qk-cap, .ns-qk-cap[data-pressed] {\n            transform: none;\n            box-shadow: 0 2px 0 var(--border);\n            transition: background-color 200ms ease-out, border-color 200ms ease-out,\n              color 200ms ease-out;\n          }\n        }\n      `}</style>\n    </dialog>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/ui/shortcuts-cheat-sheet.tsx"
    }
  ],
  "cssVars": {
    "theme": {
      "color-ns-muted": "var(--ns-muted)",
      "color-ns-accent": "var(--ns-accent)",
      "color-surface": "var(--surface)"
    },
    "light": {
      "ns-muted": "#4d4d4d",
      "ns-accent": "#006bff",
      "surface": "#fafafa"
    },
    "dark": {
      "ns-muted": "#8f8f8f",
      "surface": "#171717"
    }
  },
  "meta": {
    "collection": "core",
    "tags": [
      "shortcuts",
      "overlay",
      "dialog",
      "keyboard",
      "accessibility"
    ],
    "instruction": "A grouped keyboard-shortcut cheat sheet rendered as physical CSS keycaps (bottom-heavy 0 2px 0 shadow, caps on --background so they read as separate objects against the --surface panel in both themes). Built on the native <dialog> opened with showModal(), so the focus trap, background inertness, top-layer stacking, ::backdrop and Escape-to-close come from the platform rather than a hand-rolled trap; the panel enters with a 220ms translate+scale and closes on a timer rather than transitionend so a backgrounded tab can never strand it open. While open it owns the keyboard: one capture-phase keydown listener on window, installed only while open, matches every real keypress against the listed combos, depresses that specific cap in --ns-accent for echoDuration ms, and calls preventDefault + stopPropagation so the app's own handler behind the overlay does not also fire — pressing Mod+K over the sheet cannot reach the search box underneath. Matching is not a string compare: each chord is a set of required modifier flags plus one canonical base key, and matching runs an exact pass (every flag must agree) followed by a lenient pass that folds Shift into single printable characters, so \"?\" (which arrives as {key:\"?\", shiftKey:true} on US layouts) fires while Mod+Shift+Z stays distinct from Mod+Z. \"Mod\" folds to metaKey on Apple and ctrlKey elsewhere and never to both, resolved once after mount so SSR output stays stable, and letters/digits fall back to e.code when the chord carries a modifier, which rescues non-Latin layouts. Multi-step sequences are authored with a \"then\" token (\"G then P\") and matched with a 1.2s window. Every row is also a button: clicking it rehearses the shortcut, playing each step's caps in order. Rows carry a spoken aria-label (\"Search: Command plus K\") so the glyphs never reach a screen reader, sections are labelled regions, and the flash is decorative and announces nothing. prefers-reduced-motion drops the entrance travel and the keycap's transform, leaving a pure colour change that is still a real pixel change."
  },
  "type": "registry:ui"
}