{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-slide-to-pay",
  "type": "registry:component",
  "title": "Pay Slide To Pay",
  "description": "A slide to confirm control. The track fills as you drag, the handle turns into a check, and Enter or the arrow keys work too.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "slide",
    "confirm",
    "payment",
    "swipe",
    "drag",
    "button"
  ],
  "docs": "https://hyperblur.dev/effects/pay-slide-to-pay",
  "files": [
    {
      "path": "registry/hyperblur/pay-slide-to-pay.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-slide-to-pay.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PaySlideToPayProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  label?: string;\n  confirmLabel?: string;\n  amount?: string;\n  onConfirm?: () => void;\n  accent?: string;\n  threshold?: number;\n  resetMs?: number;\n  disabled?: boolean;\n}\n\nconst css = `\n.hb-qf6 {\n  --hb-qf6-h: 48px;\n  --hb-qf6-pad: 4px;\n  box-sizing: border-box;\n  position: relative;\n  width: 100%;\n  height: calc(var(--hb-qf6-h) + var(--hb-qf6-pad) * 2);\n  overflow: hidden;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 14px;\n  background: #111111;\n  border: 1px solid #2a2a2a;\n  border-radius: 999px;\n  user-select: none;\n  -webkit-user-select: none;\n  transition: border-color 0.4s ease;\n}\n.hb-qf6 *, .hb-qf6 *::before, .hb-qf6 *::after { box-sizing: border-box; }\n.hb-qf6[data-state=\"done\"] { border-color: #15803d; }\n.hb-qf6[data-disabled=\"true\"] { opacity: 0.5; }\n.hb-qf6-fill {\n  position: absolute;\n  left: 0;\n  top: 0;\n  bottom: 0;\n  width: calc(var(--hb-qf6-h) + var(--hb-qf6-pad) * 2 + var(--hb-qf6-p, 0) * (100% - var(--hb-qf6-h) - var(--hb-qf6-pad) * 2));\n  background: linear-gradient(90deg, color-mix(in srgb, var(--hb-qf6-x) 35%, #111111), var(--hb-qf6-x));\n  border-radius: 999px;\n  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1), background 0.4s ease;\n}\n.hb-qf6[data-drag=\"true\"] .hb-qf6-fill, .hb-qf6[data-drag=\"true\"] .hb-qf6-handle { transition: none; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-fill { background: #15803d; }\n.hb-qf6-label {\n  position: absolute;\n  inset: 0;\n  display: grid;\n  place-items: center;\n  padding: 0 20px 0 calc(var(--hb-qf6-h) + var(--hb-qf6-pad) * 2);\n  pointer-events: none;\n}\n.hb-qf6-label > span {\n  grid-area: 1 / 1;\n  display: inline-flex;\n  align-items: center;\n  gap: 8px;\n  font-weight: 600;\n  white-space: nowrap;\n  transition: opacity 0.3s ease, transform 0.35s ease;\n}\n.hb-qf6-idle {\n  color: transparent;\n  background: linear-gradient(100deg, #8f8f8f 35%, #ffffff 50%, #8f8f8f 65%) 0 0 / 250% 100%;\n  -webkit-background-clip: text;\n  background-clip: text;\n  animation: hb-qf6-shine 3.2s linear infinite;\n}\n.hb-qf6-ok { color: #fff; opacity: 0; transform: translateY(60%); }\n.hb-qf6[data-state=\"done\"] .hb-qf6-idle { opacity: 0; transform: translateY(-60%); animation: none; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-ok { opacity: 1; transform: none; }\n.hb-qf6[data-drag=\"true\"] .hb-qf6-idle { opacity: calc(1 - var(--hb-qf6-p, 0) * 1.6); }\n.hb-qf6-amt { font-variant-numeric: tabular-nums; }\n.hb-qf6-handle {\n  position: absolute;\n  top: var(--hb-qf6-pad);\n  left: calc(var(--hb-qf6-pad) + var(--hb-qf6-p, 0) * (100% - var(--hb-qf6-h) - var(--hb-qf6-pad) * 2));\n  display: grid;\n  place-items: center;\n  width: var(--hb-qf6-h);\n  height: var(--hb-qf6-h);\n  margin: 0;\n  padding: 0;\n  color: #0a0a0a;\n  background: #ededed;\n  border: 0;\n  border-radius: 50%;\n  box-shadow: 0 4px 14px -4px rgba(0, 0, 0, 0.6);\n  cursor: grab;\n  touch-action: none;\n  transition: left 0.35s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.35s ease, color 0.35s ease;\n  animation: hb-qf6-nudge 3.6s ease-in-out infinite;\n}\n.hb-qf6[data-drag=\"true\"] .hb-qf6-handle { cursor: grabbing; animation: none; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-handle { color: #15803d; background: #fff; animation: none; cursor: default; }\n.hb-qf6-handle:focus-visible { outline: 2px solid #fff; outline-offset: 2px; box-shadow: 0 0 0 5px var(--hb-qf6-x); }\n.hb-qf6-ic { grid-area: 1 / 1; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-qf6-ic-go { animation: hb-qf6-chev 1.4s ease-in-out infinite; }\n.hb-qf6-ic-ok { opacity: 0; transform: scale(0.4) rotate(-30deg); }\n.hb-qf6-ic-ok path { stroke-dasharray: 1 1.2; stroke-dashoffset: 1; transition: stroke-dashoffset 0.4s ease 0.15s; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-ic-go { opacity: 0; transform: scale(0.4); animation: none; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-ic-ok { opacity: 1; transform: none; }\n.hb-qf6[data-state=\"done\"] .hb-qf6-ic-ok path { stroke-dashoffset: 0; }\n.hb-qf6-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-qf6-shine { from { background-position: 150% 0; } to { background-position: -100% 0; } }\n@keyframes hb-qf6-nudge {\n  0%, 62%, 100% { translate: 0 0; }\n  74% { translate: 14px 0; }\n  86% { translate: 0 0; }\n}\n@keyframes hb-qf6-chev {\n  0%, 100% { transform: translateX(-1px); }\n  50% { transform: translateX(2px); }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-qf6, .hb-qf6-fill, .hb-qf6-handle, .hb-qf6-label > span, .hb-qf6-ic, .hb-qf6-ic-ok path { transition: none; }\n  .hb-qf6-idle, .hb-qf6-handle, .hb-qf6-ic-go { animation: none; }\n}\n`;\n\nexport function PaySlideToPay({\n  label = \"Slide to pay\",\n  confirmLabel = \"Payment sent\",\n  amount,\n  onConfirm,\n  accent = \"#2f7bff\",\n  threshold = 0.9,\n  resetMs = 2600,\n  disabled = false,\n  className = \"\",\n  style,\n  ...rest\n}: PaySlideToPayProps) {\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const handleRef = React.useRef<HTMLButtonElement>(null);\n  const pRef = React.useRef(0);\n  const drag = React.useRef<{ x: number; p: number; travel: number } | null>(null);\n  const timer = React.useRef(0);\n  const latest = React.useRef(onConfirm);\n  const [done, setDone] = React.useState(false);\n\n  React.useEffect(() => {\n    latest.current = onConfirm;\n  }, [onConfirm]);\n\n  React.useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  function setP(p: number) {\n    const clamped = Math.min(1, Math.max(0, p));\n    pRef.current = clamped;\n    rootRef.current?.style.setProperty(\"--hb-qf6-p\", clamped.toFixed(4));\n    handleRef.current?.setAttribute(\"aria-valuenow\", String(Math.round(clamped * 100)));\n  }\n\n  function confirm() {\n    if (done || disabled) return;\n    setP(1);\n    setDone(true);\n    latest.current?.();\n    if (resetMs > 0) {\n      window.clearTimeout(timer.current);\n      timer.current = window.setTimeout(() => {\n        setDone(false);\n        setP(0);\n      }, resetMs);\n    }\n  }\n\n  function settle() {\n    if (pRef.current >= threshold) confirm();\n    else setP(0);\n  }\n\n  function onPointerDown(event: React.PointerEvent<HTMLButtonElement>) {\n    const root = rootRef.current;\n    if (!root || done || disabled || event.button !== 0) return;\n    const style = getComputedStyle(root);\n    const h = parseFloat(style.getPropertyValue(\"--hb-qf6-h\"));\n    const pad = parseFloat(style.getPropertyValue(\"--hb-qf6-pad\"));\n    const travel = Math.max(1, root.clientWidth - h - pad * 2);\n    drag.current = { x: event.clientX, p: pRef.current, travel };\n    event.currentTarget.setPointerCapture(event.pointerId);\n    root.dataset.drag = \"true\";\n  }\n\n  function onPointerMove(event: React.PointerEvent<HTMLButtonElement>) {\n    const d = drag.current;\n    if (!d) return;\n    setP(d.p + (event.clientX - d.x) / d.travel);\n  }\n\n  function endDrag(event: React.PointerEvent<HTMLButtonElement>) {\n    if (!drag.current) return;\n    drag.current = null;\n    if (event.currentTarget.hasPointerCapture(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);\n    if (rootRef.current) rootRef.current.dataset.drag = \"false\";\n    settle();\n  }\n\n  function onKeyDown(event: React.KeyboardEvent<HTMLButtonElement>) {\n    if (done || disabled) return;\n    if (event.key === \"Enter\") {\n      event.preventDefault();\n      confirm();\n    } else if (event.key === \"ArrowRight\" || event.key === \"ArrowUp\") {\n      event.preventDefault();\n      const next = Math.min(1, pRef.current + 0.25);\n      setP(next);\n      if (next >= 1) confirm();\n    } else if (event.key === \"ArrowLeft\" || event.key === \"ArrowDown\" || event.key === \"Escape\") {\n      event.preventDefault();\n      setP(pRef.current - 0.25);\n    }\n  }\n\n  const vars = { \"--hb-qf6-x\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div\n      ref={rootRef}\n      className={`hb-qf6 ${className}`}\n      style={vars}\n      data-state={done ? \"done\" : \"idle\"}\n      data-drag=\"false\"\n      data-disabled={disabled}\n      {...rest}\n    >\n      <style href=\"hb-pay-slide-to-pay\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qf6-fill\" aria-hidden=\"true\" />\n      <div className=\"hb-qf6-label\" aria-hidden=\"true\">\n        <span className=\"hb-qf6-idle\">\n          {label}\n          {amount && <span className=\"hb-qf6-amt\">{amount}</span>}\n        </span>\n        <span className=\"hb-qf6-ok\">{confirmLabel}</span>\n      </div>\n      <button\n        ref={handleRef}\n        type=\"button\"\n        role=\"slider\"\n        className=\"hb-qf6-handle\"\n        aria-label={`${label}${amount ? ` ${amount}` : \"\"}. Press Enter to confirm or use the arrow keys.`}\n        aria-valuemin={0}\n        aria-valuemax={100}\n        aria-valuenow={done ? 100 : 0}\n        disabled={disabled}\n        onPointerDown={onPointerDown}\n        onPointerMove={onPointerMove}\n        onPointerUp={endDrag}\n        onPointerCancel={endDrag}\n        onKeyDown={onKeyDown}\n      >\n        <svg className=\"hb-qf6-ic hb-qf6-ic-go\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n          <path d=\"M6 12h12M13 6l6 6-6 6\" />\n        </svg>\n        <svg className=\"hb-qf6-ic hb-qf6-ic-ok\" viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n          <path d=\"M5 12.5l4.6 4.6L19 7.5\" pathLength=\"1\" />\n        </svg>\n      </button>\n      <span className=\"hb-qf6-sr\" role=\"status\" aria-live=\"polite\">\n        {done ? confirmLabel : \"\"}\n      </span>\n    </div>\n  );\n}\n"
    }
  ]
}