{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "micro-slide-unlock",
  "type": "registry:component",
  "title": "Slide to Unlock",
  "description": "A lock-screen slider with shimmering text and a padlock whose shackle lifts as you drag. Short drags spring back; past the end it unlocks, opens the shackle and floods the track.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "micro",
    "slider",
    "unlock",
    "drag",
    "gesture",
    "lock",
    "micro"
  ],
  "docs": "https://hyperblur.dev/effects/micro-slide-unlock",
  "files": [
    {
      "path": "registry/hyperblur/micro-slide-unlock.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/micro-slide-unlock.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface MicroSlideUnlockProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"children\"> {\n  label?: string;\n  unlockedLabel?: string;\n  accent?: string;\n  resetAfter?: number;\n  idle?: boolean;\n  disabled?: boolean;\n  onUnlock?: () => void;\n}\n\nconst css = `\n.hb-wf2 {\n  --hb-wf2-c: #2f7bff;\n  --hb-wf2-p: 0;\n  position: relative;\n  width: 100%;\n  max-width: 320px;\n  height: 56px;\n  padding: 5px;\n  box-sizing: border-box;\n  border-radius: 999px;\n  background: linear-gradient(180deg, #0c0c0c 0%, #151515 100%);\n  border: 1px solid #262626;\n  box-shadow: inset 0 2px 6px rgba(0,0,0,0.65), 0 1px 0 rgba(255,255,255,0.04);\n  user-select: none;\n  -webkit-user-select: none;\n  touch-action: pan-y;\n  overflow: hidden;\n  font-family: inherit;\n  transition: border-color 0.4s ease, background 0.5s ease;\n}\n.hb-wf2 *, .hb-wf2 *::before, .hb-wf2 *::after { box-sizing: border-box; }\n.hb-wf2[data-disabled=\"true\"] { opacity: 0.45; }\n.hb-wf2-fill {\n  position: absolute;\n  left: 0;\n  top: 0;\n  bottom: 0;\n  border-radius: 999px;\n  background: linear-gradient(90deg, color-mix(in srgb, var(--hb-wf2-c) 6%, transparent), color-mix(in srgb, var(--hb-wf2-c) 32%, transparent));\n  pointer-events: none;\n}\n.hb-wf2-txt {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  gap: 6px;\n  padding-left: 46px;\n  font-size: 14px;\n  font-weight: 500;\n  letter-spacing: 0.01em;\n  pointer-events: none;\n  opacity: calc(1 - var(--hb-wf2-p) * 1.7);\n}\n.hb-wf2-sh {\n  color: transparent;\n  background: linear-gradient(100deg, #5c5c5c 0%, #5c5c5c 40%, #f2f2f2 50%, #5c5c5c 60%, #5c5c5c 100%);\n  background-size: 250% 100%;\n  -webkit-background-clip: text;\n  background-clip: text;\n  animation: hb-wf2-shine 2.6s cubic-bezier(0.45, 0, 0.3, 1) infinite;\n}\n.hb-wf2-chev { display: inline-flex; color: #4a4a4a; }\n.hb-wf2-chev svg { width: 14px; height: 14px; animation: hb-wf2-chev 1.6s ease-in-out infinite; }\n.hb-wf2-chev svg + svg { margin-left: -8px; animation-delay: 0.15s; }\n@keyframes hb-wf2-shine { 0% { background-position: 120% 0; } 100% { background-position: -20% 0; } }\n@keyframes hb-wf2-chev { 0%, 100% { opacity: 0.25; transform: translateX(0); } 50% { opacity: 1; transform: translateX(2px); } }\n.hb-wf2-done {\n  position: absolute;\n  inset: 0;\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  gap: 8px;\n  font-size: 14px;\n  font-weight: 600;\n  color: #fff;\n  opacity: 0;\n  transform: translateY(6px);\n  transition: opacity 0.3s ease 0.12s, transform 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) 0.12s;\n  pointer-events: none;\n}\n.hb-wf2[data-done=\"true\"] { border-color: color-mix(in srgb, var(--hb-wf2-c) 60%, #262626); background: linear-gradient(180deg, color-mix(in srgb, var(--hb-wf2-c) 70%, #000), var(--hb-wf2-c)); }\n.hb-wf2[data-done=\"true\"] .hb-wf2-done { opacity: 1; transform: none; }\n.hb-wf2[data-done=\"true\"] .hb-wf2-fill { opacity: 0; }\n.hb-wf2-rail {\n  position: absolute;\n  left: 5px;\n  top: 5px;\n  width: 44px;\n  height: 44px;\n  transition: transform 0.55s cubic-bezier(0.25, 1.45, 0.4, 1);\n  will-change: transform;\n}\n.hb-wf2[data-drag=\"true\"] .hb-wf2-rail { transition: none; }\n.hb-wf2-k {\n  display: grid;\n  place-items: center;\n  width: 44px;\n  height: 44px;\n  padding: 0;\n  margin: 0;\n  border: 0;\n  border-radius: 999px;\n  background: radial-gradient(circle at 50% 28%, #ffffff 0%, #e6e6e6 55%, #cfcfcf 100%);\n  color: #161616;\n  box-shadow: 0 4px 10px rgba(0,0,0,0.55), inset 0 -2px 3px rgba(0,0,0,0.15), inset 0 1px 0 #fff;\n  cursor: grab;\n  touch-action: none;\n  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.2s ease;\n}\n.hb-wf2-k:focus-visible { outline: 2px solid var(--hb-wf2-c); outline-offset: 3px; }\n.hb-wf2[data-drag=\"true\"] .hb-wf2-k { cursor: grabbing; transform: scale(1.06); box-shadow: 0 8px 18px rgba(0,0,0,0.6), 0 0 0 6px color-mix(in srgb, var(--hb-wf2-c) 18%, transparent); }\n.hb-wf2[data-idle=\"true\"] .hb-wf2-k { animation: hb-wf2-nudge 3.4s cubic-bezier(0.4, 0, 0.2, 1) infinite 1s; }\n@keyframes hb-wf2-nudge {\n  0%, 62%, 100% { transform: translateX(0); }\n  72% { transform: translateX(22px); }\n  80% { transform: translateX(-3px); }\n  86% { transform: translateX(6px); }\n  92% { transform: translateX(0); }\n}\n.hb-wf2-k svg { width: 20px; height: 20px; overflow: visible; }\n.hb-wf2-shk { transition: transform 0.3s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: 8px 11px; }\n.hb-wf2[data-done=\"true\"] .hb-wf2-k { color: var(--hb-wf2-c); }\n@media (prefers-reduced-motion: reduce) {\n  .hb-wf2, .hb-wf2-rail, .hb-wf2-k, .hb-wf2-done, .hb-wf2-shk { transition: none; }\n  .hb-wf2-sh, .hb-wf2-chev svg, .hb-wf2[data-idle=\"true\"] .hb-wf2-k { animation: none; }\n  .hb-wf2-sh { color: #9a9a9a; background: none; }\n}\n`;\n\nexport function MicroSlideUnlock({\n  label = \"slide to unlock\",\n  unlockedLabel = \"Unlocked\",\n  accent = \"#2f7bff\",\n  resetAfter = 1800,\n  idle = true,\n  disabled = false,\n  onUnlock,\n  className = \"\",\n  style,\n  ...rest\n}: MicroSlideUnlockProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const drag = React.useRef({ on: false, startX: 0, base: 0 });\n  const [x, setX] = React.useState(0);\n  const [max, setMax] = React.useState(240);\n  const [dragging, setDragging] = React.useState(false);\n  const [done, setDone] = React.useState(false);\n  const [touched, setTouched] = React.useState(false);\n\n  React.useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const ro = new ResizeObserver(() => setMax(Math.max(40, el.clientWidth - 10 - 44)));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  React.useEffect(() => {\n    if (!done || resetAfter <= 0) return;\n    const t = window.setTimeout(() => {\n      setDone(false);\n      setX(0);\n    }, resetAfter);\n    return () => window.clearTimeout(t);\n  }, [done, resetAfter]);\n\n  const unlock = () => {\n    setX(max);\n    setDone(true);\n    onUnlock?.();\n  };\n\n  const p = done ? 1 : Math.max(0, Math.min(1, x / max));\n  const pos = done ? max : x;\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-wf2 ${className}`}\n      data-drag={dragging}\n      data-done={done}\n      data-disabled={disabled}\n      data-idle={idle && !touched && !dragging && !done && !disabled}\n      style={{ ...style, [\"--hb-wf2-c\" as string]: accent, [\"--hb-wf2-p\" as string]: p.toFixed(3) }}\n      {...rest}\n    >\n      <style href=\"hb-micro-slide-unlock\" precedence=\"default\">\n        {css}\n      </style>\n      <span className=\"hb-wf2-fill\" style={{ width: `${(pos + 54).toFixed(1)}px` }} />\n      <span className=\"hb-wf2-txt\" aria-hidden=\"true\">\n        <span className=\"hb-wf2-sh\">{label}</span>\n        <span className=\"hb-wf2-chev\">\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M6 3l5 5-5 5\" />\n          </svg>\n          <svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n            <path d=\"M6 3l5 5-5 5\" />\n          </svg>\n        </span>\n      </span>\n      <span className=\"hb-wf2-done\" aria-live=\"polite\">\n        {done ? (\n          <>\n            <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2.2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n              <path d=\"M3.5 8.5l3 3 6-7\" />\n            </svg>\n            {unlockedLabel}\n          </>\n        ) : null}\n      </span>\n      <span className=\"hb-wf2-rail\" style={{ transform: `translate3d(${pos.toFixed(1)}px,0,0)` }}>\n        <button\n          type=\"button\"\n          role=\"slider\"\n          aria-label={label}\n          aria-valuemin={0}\n          aria-valuemax={100}\n          aria-valuenow={Math.round(p * 100)}\n          aria-valuetext={done ? unlockedLabel : `${Math.round(p * 100)}%`}\n          disabled={disabled}\n          className=\"hb-wf2-k\"\n          onPointerDown={(e) => {\n            if (disabled || done) return;\n            e.currentTarget.setPointerCapture(e.pointerId);\n            drag.current = { on: true, startX: e.clientX, base: x };\n            setDragging(true);\n            setTouched(true);\n          }}\n          onPointerMove={(e) => {\n            if (!drag.current.on) return;\n            const raw = drag.current.base + e.clientX - drag.current.startX;\n            const over = raw > max ? max + (raw - max) * 0.15 : raw < 0 ? raw * 0.15 : raw;\n            setX(Math.min(max + 8, Math.max(-8, over)));\n          }}\n          onPointerUp={() => {\n            if (!drag.current.on) return;\n            drag.current.on = false;\n            setDragging(false);\n            if (x >= max * 0.88) unlock();\n            else setX(0);\n          }}\n          onPointerCancel={() => {\n            drag.current.on = false;\n            setDragging(false);\n            setX(0);\n          }}\n          onKeyDown={(e) => {\n            if (disabled || done) return;\n            setTouched(true);\n            if (e.key === \"ArrowRight\") {\n              e.preventDefault();\n              const n = Math.min(max, x + max * 0.25);\n              if (n >= max) unlock();\n              else setX(n);\n            } else if (e.key === \"ArrowLeft\") {\n              e.preventDefault();\n              setX(Math.max(0, x - max * 0.25));\n            } else if (e.key === \"End\" || e.key === \"Enter\") {\n              e.preventDefault();\n              unlock();\n            } else if (e.key === \"Home\" || e.key === \"Escape\") {\n              setX(0);\n            }\n          }}\n        >\n          <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n            <path\n              className=\"hb-wf2-shk\"\n              d=\"M8 11V8a4 4 0 0 1 8 0v3\"\n              style={{\n                transform: done\n                  ? \"translate(0px,-3.5px) rotate(-22deg)\"\n                  : `translate(0px,${(-p * 2.5).toFixed(2)}px)`,\n              }}\n            />\n            <rect x=\"5\" y=\"11\" width=\"14\" height=\"10\" rx=\"2.5\" fill=\"currentColor\" stroke=\"none\" />\n            <circle cx=\"12\" cy=\"16\" r=\"1.4\" fill=\"#ffffff\" stroke=\"none\" />\n          </svg>\n        </button>\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}