{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-button",
  "type": "registry:component",
  "title": "Pay Button",
  "description": "A payment button that moves from idle to processing to success, with a spinner, a drawn check and a pop.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "buttons",
    "button",
    "payment",
    "checkout",
    "loading",
    "success",
    "state"
  ],
  "docs": "https://hyperblur.dev/effects/pay-button",
  "files": [
    {
      "path": "registry/hyperblur/pay-button.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-button.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PayButtonProps\n  extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, \"color\" | \"children\"> {\n  amount: string;\n  label?: string;\n  successLabel?: string;\n  processingMs?: number;\n  resetMs?: number;\n  color?: string;\n  onPaid?: () => void;\n  disabled?: boolean;\n  rounded?: number;\n  size?: \"sm\" | \"md\" | \"lg\";\n  brand?: \"none\" | \"visa\" | \"mastercard\" | \"pix\";\n}\n\ntype PayState = \"idle\" | \"processing\" | \"success\";\n\nconst css = `\n.hb-pb {\n  position: relative;\n  display: inline-grid;\n  place-items: center;\n  overflow: hidden;\n  margin: 0;\n  padding: 0.85em 1.6em;\n  font-family: inherit;\n  font-size: 15px;\n  font-weight: 600;\n  line-height: 1.2;\n  font-variant-numeric: tabular-nums;\n  color: #fff;\n  background-color: var(--hb-c);\n  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 60%);\n  border: 0;\n  border-radius: var(--hb-r);\n  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.28) inset, 0 12px 26px -12px color-mix(in srgb, var(--hb-c) 85%, transparent);\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n  transition: background-color 0.4s ease, box-shadow 0.4s ease, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-pb[data-size=\"sm\"] { font-size: 13px; padding: 0.7em 1.3em; }\n.hb-pb[data-size=\"lg\"] { font-size: 17px; padding: 0.95em 1.9em; }\n.hb-pb[data-state=\"success\"] {\n  background-color: #15803d;\n  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.25) inset, 0 12px 26px -12px rgba(21, 128, 61, 0.9);\n}\n.hb-pb[data-state=\"idle\"]:not(:disabled):hover { transform: translateY(-1px); }\n.hb-pb[data-state=\"idle\"]:not(:disabled):active { transform: scale(0.97); }\n.hb-pb[data-state=\"processing\"] { cursor: progress; }\n.hb-pb:focus-visible { outline: 2px solid var(--hb-c); outline-offset: 3px; }\n.hb-pb:disabled { opacity: 0.45; cursor: not-allowed; }\n.hb-pb-v {\n  grid-area: 1 / 1;\n  display: inline-flex;\n  align-items: center;\n  gap: 0.55em;\n  white-space: nowrap;\n  opacity: 0;\n  visibility: hidden;\n  transform: translateY(40%);\n  transition: opacity 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.3, 0.64, 1), visibility 0s linear 0.35s;\n}\n.hb-pb[data-state=\"idle\"] .hb-pb-i,\n.hb-pb[data-state=\"processing\"] .hb-pb-p,\n.hb-pb[data-state=\"success\"] .hb-pb-s {\n  opacity: 1;\n  visibility: visible;\n  transform: none;\n  transition-delay: 0.05s, 0.05s, 0s;\n}\n.hb-pb-ic {\n  width: 1.25em;\n  height: 1.25em;\n  flex: none;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 1.8;\n  stroke-linecap: round;\n  stroke-linejoin: round;\n}\n.hb-pb-amt { font-weight: 700; }\n.hb-pb-brand {\n  display: inline-flex;\n  align-items: center;\n  height: 1.3em;\n  margin-left: 0.2em;\n  padding-left: 0.7em;\n  border-left: 1px solid rgba(255, 255, 255, 0.35);\n  opacity: 0.85;\n}\n.hb-pb-bm { height: 0.95em; width: auto; fill: currentColor; }\n.hb-pb-spin {\n  width: 1.25em;\n  height: 1.25em;\n  flex: none;\n  fill: none;\n  stroke: currentColor;\n  stroke-width: 2.4;\n  stroke-linecap: round;\n  animation: hb-pb-rot 0.8s linear infinite;\n}\n.hb-pb-spin circle:first-child { opacity: 0.28; }\n.hb-pb-ck path {\n  stroke-dasharray: 1;\n  stroke-dashoffset: 0;\n}\n.hb-pb[data-state=\"success\"] .hb-pb-s { animation: hb-pb-pop 0.55s cubic-bezier(0.34, 1.56, 0.64, 1); }\n.hb-pb[data-state=\"success\"] .hb-pb-ck path { animation: hb-pb-draw 0.4s ease-out 0.12s both; }\n.hb-pb-sr {\n  position: absolute;\n  width: 1px;\n  height: 1px;\n  margin: -1px;\n  padding: 0;\n  overflow: hidden;\n  clip-path: inset(50%);\n  white-space: nowrap;\n  border: 0;\n}\n@keyframes hb-pb-rot {\n  to { transform: rotate(360deg); }\n}\n@keyframes hb-pb-pop {\n  0% { transform: scale(0.6); }\n  60% { transform: scale(1.12); }\n  100% { transform: scale(1); }\n}\n@keyframes hb-pb-draw {\n  from { stroke-dashoffset: 1; }\n  to { stroke-dashoffset: 0; }\n}\n@keyframes hb-pb-pulse {\n  50% { opacity: 0.35; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-pb, .hb-pb-v { transition-duration: 0.01s; }\n  .hb-pb-v { transform: none; }\n  .hb-pb-spin { animation: hb-pb-pulse 1.2s ease-in-out infinite; }\n  .hb-pb[data-state=\"success\"] .hb-pb-s, .hb-pb[data-state=\"success\"] .hb-pb-ck path { animation: none; }\n  .hb-pb[data-state=\"idle\"]:not(:disabled):hover, .hb-pb[data-state=\"idle\"]:not(:disabled):active { transform: none; }\n}\n`;\n\nfunction BrandMark({ brand }: { brand: \"visa\" | \"mastercard\" | \"pix\" }) {\n  if (brand === \"visa\") {\n    return (\n      <svg className=\"hb-pb-bm\" viewBox=\"0 0 12 14\" aria-hidden=\"true\" focusable=\"false\">\n        <path d=\"M6.6 0.5H10L5.4 13.5H2z\" />\n      </svg>\n    );\n  }\n  if (brand === \"mastercard\") {\n    return (\n      <svg className=\"hb-pb-bm\" viewBox=\"0 0 22 14\" aria-hidden=\"true\" focusable=\"false\">\n        <circle cx=\"7\" cy=\"7\" r=\"6\" fillOpacity=\"0.6\" />\n        <circle cx=\"15\" cy=\"7\" r=\"6\" fillOpacity=\"0.6\" />\n      </svg>\n    );\n  }\n  return (\n    <svg className=\"hb-pb-bm\" viewBox=\"0 0 14 14\" aria-hidden=\"true\" focusable=\"false\">\n      <path fillRule=\"evenodd\" d=\"M7 0.5L13.5 7 7 13.5 0.5 7zM7 4L10 7 7 10 4 7z\" />\n    </svg>\n  );\n}\n\nexport function PayButton({\n  amount,\n  label = \"Pay\",\n  successLabel = \"Paid\",\n  processingMs = 1400,\n  resetMs = 2400,\n  color = \"#2f7bff\",\n  onPaid,\n  disabled = false,\n  rounded = 9999,\n  size = \"md\",\n  brand = \"none\",\n  type = \"button\",\n  className = \"\",\n  style,\n  onClick,\n  ...rest\n}: PayButtonProps) {\n  const [state, setState] = React.useState<PayState>(\"idle\");\n  const timers = React.useRef<number[]>([]);\n  const latest = React.useRef(onPaid);\n\n  React.useEffect(() => {\n    latest.current = onPaid;\n  }, [onPaid]);\n\n  React.useEffect(() => {\n    const list = timers.current;\n    return () => {\n      list.forEach((t) => window.clearTimeout(t));\n    };\n  }, []);\n\n  function handleClick(e: React.MouseEvent<HTMLButtonElement>) {\n    onClick?.(e);\n    if (e.defaultPrevented || disabled || state !== \"idle\") return;\n    setState(\"processing\");\n    timers.current.push(\n      window.setTimeout(() => {\n        setState(\"success\");\n        latest.current?.();\n        if (resetMs > 0) {\n          timers.current.push(window.setTimeout(() => setState(\"idle\"), resetMs));\n        }\n      }, Math.max(0, processingMs)),\n    );\n  }\n\n  const vars = {\n    \"--hb-c\": color,\n    \"--hb-r\": `${rounded}px`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <>\n      <style href=\"hb-pay-button\" precedence=\"default\">{css}</style>\n      <button\n        type={type}\n        className={`hb-pb ${className}`}\n        style={vars}\n        data-size={size}\n        data-state={state}\n        disabled={disabled}\n        aria-busy={state === \"processing\"}\n        onClick={handleClick}\n        {...rest}\n      >\n        <span className=\"hb-pb-v hb-pb-i\">\n          <svg className=\"hb-pb-ic\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n            <rect x=\"2.5\" y=\"5\" width=\"19\" height=\"14\" rx=\"3\" />\n            <path d=\"M2.5 10h19M6.5 15h3\" />\n          </svg>\n          <span>\n            {label} <span className=\"hb-pb-amt\">{amount}</span>\n          </span>\n          {brand !== \"none\" ? (\n            <span className=\"hb-pb-brand\" aria-hidden=\"true\">\n              <BrandMark brand={brand} />\n            </span>\n          ) : null}\n        </span>\n        <span className=\"hb-pb-v hb-pb-p\">\n          <svg className=\"hb-pb-spin\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n            <circle cx=\"12\" cy=\"12\" r=\"9\" />\n            <path d=\"M12 3a9 9 0 0 1 9 9\" />\n          </svg>\n          <span>Processing</span>\n        </span>\n        <span className=\"hb-pb-v hb-pb-s\">\n          <svg className=\"hb-pb-ic hb-pb-ck\" viewBox=\"0 0 24 24\" aria-hidden=\"true\" focusable=\"false\">\n            <path d=\"M5 12.5l4.5 4.5L19 7.5\" pathLength={1} />\n          </svg>\n          <span>{successLabel}</span>\n        </span>\n      </button>\n      <span className=\"hb-pb-sr\" role=\"status\" aria-live=\"polite\">\n        {state === \"success\" ? successLabel : \"\"}\n      </span>\n    </>\n  );\n}\n"
    }
  ]
}