{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "button-shift-arm",
  "type": "registry:component",
  "title": "Button Shift Arm",
  "description": "A delete button that only fires while Shift is held. A plain click shakes it harder each time and pops a hint with a pressing keycap; holding Shift turns it into a striped red button.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "shake",
    "modifier",
    "danger",
    "keyboard",
    "confirm"
  ],
  "docs": "https://hyperblur.dev/effects/button-shift-arm",
  "files": [
    {
      "path": "registry/hyperblur/button-shift-arm.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/button-shift-arm.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface ButtonShiftArmProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"onClick\" | \"color\"> {\n  children?: React.ReactNode;\n  armedLabel?: React.ReactNode;\n  doneLabel?: React.ReactNode;\n  hint?: React.ReactNode;\n  touchFallback?: boolean;\n  accent?: string;\n  size?: \"sm\" | \"md\" | \"lg\";\n  resetAfter?: number;\n  onBlocked?: (attempts: number) => void;\n  onConfirm?: () => void;\n}\n\nconst css = `\n.hb-xd8 {\n  --hb-xd8-h: 2.75rem;\n  --hb-xd8-fs: 0.875rem;\n  --hb-xd8-amp: 3px;\n  position: relative;\n  display: inline-flex;\n  box-sizing: border-box;\n  font-family: inherit;\n  font-size: var(--hb-xd8-fs);\n}\n.hb-xd8 *, .hb-xd8 *::before, .hb-xd8 *::after { box-sizing: border-box; }\n.hb-xd8[data-size=\"sm\"] { --hb-xd8-h: 2.25rem; --hb-xd8-fs: 0.8125rem; }\n.hb-xd8[data-size=\"lg\"] { --hb-xd8-h: 3.25rem; --hb-xd8-fs: 1rem; }\n.hb-xd8-btn {\n  position: relative;\n  flex: 1 1 auto;\n  display: grid;\n  place-items: center;\n  height: var(--hb-xd8-h);\n  margin: 0;\n  padding: 0 1.25em;\n  overflow: hidden;\n  font: inherit;\n  font-weight: 600;\n  white-space: nowrap;\n  color: color-mix(in srgb, var(--hb-xd8-c) 50%, #fff);\n  background: linear-gradient(180deg, #1b1b1b, #131313);\n  border: 1px solid #2c2c2c;\n  border-radius: 10px;\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 1px 2px rgba(0,0,0,0.5);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: color 0.2s ease, border-color 0.25s ease, box-shadow 0.3s ease, transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);\n}\n.hb-xd8-btn::before {\n  content: \"\";\n  position: absolute;\n  inset: 0;\n  background:\n    repeating-linear-gradient(-45deg, rgba(0,0,0,0.16) 0 6px, transparent 6px 12px),\n    linear-gradient(180deg, color-mix(in srgb, var(--hb-xd8-c) 92%, #fff), color-mix(in srgb, var(--hb-xd8-c) 82%, #000));\n  background-size: 17px 17px, 100% 100%;\n  opacity: 0;\n  transition: opacity 0.2s ease;\n}\n.hb-xd8-btn:focus-visible { outline: 2px solid var(--hb-xd8-c); outline-offset: 3px; }\n.hb-xd8-btn:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-xd8[data-armed=\"true\"] .hb-xd8-btn {\n  color: #fff;\n  border-color: color-mix(in srgb, var(--hb-xd8-c) 70%, #000);\n  box-shadow: inset 0 1px 0 rgba(255,255,255,0.3), 0 0 0 4px color-mix(in srgb, var(--hb-xd8-c) 18%, transparent), 0 10px 24px -10px var(--hb-xd8-c);\n  transform: scale(1.03);\n}\n.hb-xd8[data-armed=\"true\"] .hb-xd8-btn::before { opacity: 1; animation: hb-xd8-march 0.7s linear infinite; }\n.hb-xd8[data-phase=\"done\"] .hb-xd8-btn { color: #a1a1a1; cursor: default; }\n.hb-xd8[data-shake=\"1\"] .hb-xd8-btn { animation: hb-xd8-shake-a 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); border-color: color-mix(in srgb, var(--hb-xd8-c) 60%, #2c2c2c); }\n.hb-xd8[data-shake=\"2\"] .hb-xd8-btn { animation: hb-xd8-shake-b 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97); border-color: color-mix(in srgb, var(--hb-xd8-c) 60%, #2c2c2c); }\n.hb-xd8-lbl {\n  position: relative;\n  grid-area: 1 / 1;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.5em;\n  transition: opacity 0.18s ease, transform 0.3s cubic-bezier(0.3, 1.4, 0.5, 1);\n}\n.hb-xd8-lbl[data-on=\"false\"] { opacity: 0; transform: translateY(70%); }\n.hb-xd8-lbl[data-on=\"false\"].hb-xd8-up { transform: translateY(-70%); }\n.hb-xd8-tip {\n  position: absolute;\n  left: 50%;\n  bottom: calc(100% + 10px);\n  z-index: 3;\n  display: inline-flex;\n  align-items: center;\n  gap: 6px;\n  padding: 6px 9px;\n  font-size: 0.75rem;\n  font-weight: 500;\n  color: #ededed;\n  white-space: nowrap;\n  background: #1f1f1f;\n  border: 1px solid #333;\n  border-radius: 8px;\n  box-shadow: 0 10px 24px -8px rgba(0,0,0,0.9);\n  opacity: 0;\n  transform: translate(-50%, 6px) scale(0.95);\n  transform-origin: 50% 100%;\n  pointer-events: none;\n  transition: opacity 0.18s ease, transform 0.35s cubic-bezier(0.3, 1.5, 0.5, 1);\n}\n.hb-xd8-tip::after {\n  content: \"\";\n  position: absolute;\n  left: 50%;\n  top: 100%;\n  width: 8px;\n  height: 8px;\n  margin: -4px 0 0 -4px;\n  background: #1f1f1f;\n  border-right: 1px solid #333;\n  border-bottom: 1px solid #333;\n  transform: rotate(45deg);\n}\n.hb-xd8[data-tip=\"true\"] .hb-xd8-tip { opacity: 1; transform: translate(-50%, 0) scale(1); }\n.hb-xd8-key {\n  display: inline-flex;\n  align-items: center;\n  gap: 3px;\n  padding: 1px 6px;\n  font-family: var(--font-mono), ui-monospace, monospace;\n  font-size: 0.68rem;\n  color: #fff;\n  background: linear-gradient(180deg, #3a3a3a, #2a2a2a);\n  border: 1px solid #444;\n  border-bottom-width: 2px;\n  border-radius: 5px;\n}\n.hb-xd8[data-tip=\"true\"] .hb-xd8-key { animation: hb-xd8-press 1s ease-in-out 0.2s infinite; }\n.hb-xd8-strikes { display: inline-flex; gap: 3px; margin-left: 2px; }\n.hb-xd8-strikes i { display: block; width: 4px; height: 4px; border-radius: 50%; background: #3a3a3a; font-style: normal; }\n.hb-xd8-strikes i[data-on=\"true\"] { background: var(--hb-xd8-c); box-shadow: 0 0 6px var(--hb-xd8-c); }\n.hb-xd8-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-xd8-march { to { background-position: 17px 0, 0 0; } }\n@keyframes hb-xd8-shake-a {\n  15% { transform: translateX(calc(var(--hb-xd8-amp) * -1)) rotate(-1deg); }\n  30% { transform: translateX(var(--hb-xd8-amp)) rotate(1deg); }\n  45% { transform: translateX(calc(var(--hb-xd8-amp) * -0.7)); }\n  60% { transform: translateX(calc(var(--hb-xd8-amp) * 0.5)); }\n  75% { transform: translateX(calc(var(--hb-xd8-amp) * -0.25)); }\n}\n@keyframes hb-xd8-shake-b {\n  15% { transform: translateX(calc(var(--hb-xd8-amp) * -1)) rotate(-1deg); }\n  30% { transform: translateX(var(--hb-xd8-amp)) rotate(1deg); }\n  45% { transform: translateX(calc(var(--hb-xd8-amp) * -0.7)); }\n  60% { transform: translateX(calc(var(--hb-xd8-amp) * 0.5)); }\n  75% { transform: translateX(calc(var(--hb-xd8-amp) * -0.25)); }\n}\n@keyframes hb-xd8-press {\n  0%, 60%, 100% { transform: translateY(0); border-bottom-width: 2px; }\n  30% { transform: translateY(1px); border-bottom-width: 1px; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-xd8-btn, .hb-xd8-btn::before, .hb-xd8-lbl, .hb-xd8-tip { transition: none; }\n  .hb-xd8[data-armed=\"true\"] .hb-xd8-btn { transform: none; }\n  .hb-xd8[data-armed=\"true\"] .hb-xd8-btn::before, .hb-xd8[data-shake] .hb-xd8-btn, .hb-xd8[data-tip=\"true\"] .hb-xd8-key { animation: none; }\n}\n`;\n\nexport function ButtonShiftArm({\n  children = \"Delete branch\",\n  armedLabel = \"Delete forever\",\n  doneLabel = \"Branch deleted\",\n  hint = \"to delete\",\n  touchFallback = true,\n  accent = \"#ef4444\",\n  size = \"md\",\n  resetAfter = 2400,\n  onBlocked,\n  onConfirm,\n  disabled = false,\n  type = \"button\",\n  className = \"\",\n  style,\n  onPointerEnter,\n  onPointerLeave,\n  onPointerDown,\n  onFocus,\n  onBlur,\n  ...rest\n}: ButtonShiftArmProps) {\n  const [shift, setShift] = React.useState(false);\n  const [near, setNear] = React.useState(false);\n  const [strikes, setStrikes] = React.useState(0);\n  const [tip, setTip] = React.useState(false);\n  const [phase, setPhase] = React.useState<\"idle\" | \"done\">(\"idle\");\n  const pointer = React.useRef(\"mouse\");\n  const latest = React.useRef({ onBlocked, onConfirm });\n\n  React.useEffect(() => {\n    latest.current = { onBlocked, onConfirm };\n  }, [onBlocked, onConfirm]);\n\n  React.useEffect(() => {\n    const down = (e: KeyboardEvent) => {\n      if (e.key === \"Shift\") setShift(true);\n    };\n    const up = (e: KeyboardEvent) => {\n      if (e.key === \"Shift\") setShift(false);\n    };\n    const reset = () => setShift(false);\n    window.addEventListener(\"keydown\", down);\n    window.addEventListener(\"keyup\", up);\n    window.addEventListener(\"blur\", reset);\n    return () => {\n      window.removeEventListener(\"keydown\", down);\n      window.removeEventListener(\"keyup\", up);\n      window.removeEventListener(\"blur\", reset);\n    };\n  }, []);\n\n  React.useEffect(() => {\n    if (!tip) return;\n    const t = window.setTimeout(() => setTip(false), 2400);\n    return () => window.clearTimeout(t);\n  }, [tip, strikes]);\n\n  React.useEffect(() => {\n    if (phase !== \"done\" || resetAfter <= 0) return;\n    const t = window.setTimeout(() => {\n      setPhase(\"idle\");\n      setStrikes(0);\n    }, resetAfter);\n    return () => window.clearTimeout(t);\n  }, [phase, resetAfter]);\n\n  const armed = phase === \"idle\" && shift && near && !disabled;\n  const shake = strikes === 0 || tip === false ? \"0\" : strikes % 2 ? \"1\" : \"2\";\n  const shown = Math.min(3, strikes);\n\n  return (\n    <span\n      className={`hb-xd8 ${className}`.trim()}\n      data-size={size}\n      data-phase={phase}\n      data-armed={armed}\n      data-tip={tip && phase === \"idle\"}\n      data-shake={shake}\n      style={{ \"--hb-xd8-c\": accent, \"--hb-xd8-amp\": `${(2 + Math.min(3, strikes) * 1.5).toFixed(1)}px`, ...style } as React.CSSProperties}\n    >\n      <style href=\"hb-button-shift-arm\" precedence=\"default\">{css}</style>\n      <span className=\"hb-xd8-tip\" aria-hidden=\"true\">\n        Hold <span className=\"hb-xd8-key\">⇧ Shift</span> {hint}\n        <span className=\"hb-xd8-strikes\">\n          {[0, 1, 2].map((i) => (\n            <i key={i} data-on={i < shown} />\n          ))}\n        </span>\n      </span>\n      <button\n        type={type}\n        className=\"hb-xd8-btn\"\n        disabled={disabled}\n        aria-disabled={phase === \"done\" || undefined}\n        aria-keyshortcuts=\"Shift+Enter\"\n        onPointerEnter={(e) => {\n          onPointerEnter?.(e);\n          setNear(true);\n        }}\n        onPointerLeave={(e) => {\n          onPointerLeave?.(e);\n          setNear(false);\n        }}\n        onPointerDown={(e) => {\n          onPointerDown?.(e);\n          pointer.current = e.pointerType;\n        }}\n        onFocus={(e) => {\n          onFocus?.(e);\n          setNear(true);\n        }}\n        onBlur={(e) => {\n          onBlur?.(e);\n          setNear(false);\n        }}\n        onClick={(e) => {\n          if (phase !== \"idle\") return;\n          const touchOk = touchFallback && pointer.current === \"touch\" && tip;\n          if (e.shiftKey || touchOk) {\n            setTip(false);\n            setPhase(\"done\");\n            latest.current.onConfirm?.();\n            return;\n          }\n          const n = strikes + 1;\n          setStrikes(n);\n          setTip(true);\n          latest.current.onBlocked?.(n);\n        }}\n        {...rest}\n      >\n        <span className=\"hb-xd8-lbl hb-xd8-up\" data-on={phase === \"idle\" && !armed} aria-hidden={phase !== \"idle\" || armed}>\n          <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <circle cx=\"6\" cy=\"6\" r=\"2.5\" />\n            <circle cx=\"6\" cy=\"18\" r=\"2.5\" />\n            <circle cx=\"18\" cy=\"8\" r=\"2.5\" />\n            <path d=\"M6 8.5v7M18 10.5c0 4-6 3-11 5.5\" />\n          </svg>\n          {children}\n        </span>\n        <span className=\"hb-xd8-lbl\" data-on={armed} aria-hidden={!armed}>\n          <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path d=\"M12 3l9.5 17h-19z\" />\n            <path d=\"M12 10v4.5M12 17.5v.01\" />\n          </svg>\n          {armedLabel}\n        </span>\n        <span className=\"hb-xd8-lbl\" data-on={phase === \"done\"} aria-hidden={phase !== \"done\"}>\n          <svg viewBox=\"0 0 24 24\" width=\"1em\" height=\"1em\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.4\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\"><path d=\"M5 12.5l4.5 4.5L19 7.5\" /></svg>\n          {doneLabel}\n        </span>\n      </button>\n      <span className=\"hb-xd8-sr\" role=\"status\" aria-live=\"polite\">\n        {phase === \"done\" ? doneLabel : tip ? \"Hold Shift and press again to delete\" : \"\"}\n      </span>\n    </span>\n  );\n}\n"
    }
  ]
}