{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-method-picker",
  "type": "registry:component",
  "title": "Pay Method Picker",
  "description": "A radio list of payment methods with a highlight that slides to the selection and a detail panel that expands under it.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "payment",
    "method",
    "radio",
    "picker",
    "checkout",
    "select"
  ],
  "docs": "https://hyperblur.dev/effects/pay-method-picker",
  "files": [
    {
      "path": "registry/hyperblur/pay-method-picker.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-method-picker.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport type PayMethodIcon = \"card\" | \"bank\" | \"wallet\" | \"voucher\";\n\nexport interface PayMethod {\n  id: string;\n  label: string;\n  description?: string;\n  detail?: React.ReactNode;\n  badge?: string;\n  icon?: PayMethodIcon;\n  disabled?: boolean;\n}\n\nexport interface PayMethodPickerProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\" | \"defaultValue\"> {\n  methods?: PayMethod[];\n  value?: string;\n  defaultValue?: string;\n  onChange?: (id: string) => void;\n  accent?: string;\n  label?: string;\n}\n\nconst defaultMethods: PayMethod[] = [\n  {\n    id: \"card\",\n    label: \"Credit or debit card\",\n    description: \"Instant confirmation\",\n    icon: \"card\",\n    badge: \"Popular\",\n    detail: \"Enter your card details on the next step. Nothing is charged until you confirm the order.\",\n  },\n  {\n    id: \"bank\",\n    label: \"Bank transfer\",\n    description: \"Arrives in 1 to 2 business days\",\n    icon: \"bank\",\n    detail: \"We show the account details and a payment reference after checkout. The order ships once the transfer clears.\",\n  },\n  {\n    id: \"wallet\",\n    label: \"Wallet balance\",\n    description: \"Pay from your stored balance\",\n    icon: \"wallet\",\n    detail: \"Your wallet balance is applied first. Any remainder can be paid by card.\",\n  },\n  {\n    id: \"voucher\",\n    label: \"Cash voucher\",\n    description: \"Pay at a partner store\",\n    icon: \"voucher\",\n    detail: \"Print or save the voucher and pay within 3 days at any partner store. A small cash fee may apply.\",\n  },\n];\n\nconst css = `\n.hb-qf3 {\n  box-sizing: border-box;\n  position: relative;\n  display: flex;\n  flex-direction: column;\n  gap: 8px;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 14px;\n  line-height: 1.35;\n}\n.hb-qf3 *, .hb-qf3 *::before, .hb-qf3 *::after { box-sizing: border-box; }\n.hb-qf3-hl {\n  position: absolute;\n  left: 0;\n  right: 0;\n  top: 0;\n  height: 0;\n  opacity: 0;\n  pointer-events: none;\n  background: color-mix(in srgb, var(--hb-qf3-x) 12%, #111111);\n  border: 1px solid var(--hb-qf3-x);\n  border-radius: 12px;\n  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-qf3-x) 16%, transparent), 0 10px 30px -14px var(--hb-qf3-x);\n  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1), height 0.4s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.2s ease;\n}\n.hb-qf3[data-ready=\"true\"] .hb-qf3-hl { opacity: 1; }\n.hb-qf3-item {\n  position: relative;\n  min-width: 0;\n  background: #111111;\n  border: 1px solid #262626;\n  border-radius: 12px;\n  transition: border-color 0.25s ease;\n}\n.hb-qf3-item[data-on=\"true\"] { background: transparent; border-color: transparent; }\n.hb-qf3-item:not([data-on=\"true\"]):hover { border-color: #3a3a3a; }\n.hb-qf3-row {\n  display: flex;\n  align-items: center;\n  gap: 12px;\n  width: 100%;\n  margin: 0;\n  padding: 7px 12px;\n  color: inherit;\n  font: inherit;\n  text-align: left;\n  background: none;\n  border: 0;\n  border-radius: 12px;\n  cursor: pointer;\n  -webkit-tap-highlight-color: transparent;\n}\n.hb-qf3-row:focus-visible { outline: 2px solid var(--hb-qf3-x); outline-offset: 2px; }\n.hb-qf3-row:disabled { cursor: not-allowed; opacity: 0.45; }\n.hb-qf3-ico {\n  display: grid;\n  flex: none;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  color: #a1a1a1;\n  background: #1a1a1a;\n  border-radius: 8px;\n  transition: color 0.25s ease, background-color 0.25s ease;\n}\n.hb-qf3-item[data-on=\"true\"] .hb-qf3-ico { color: #fff; background: var(--hb-qf3-x); }\n.hb-qf3-ico svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }\n.hb-qf3-txt { display: flex; min-width: 0; flex: 1; flex-direction: column; }\n.hb-qf3-name { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qf3-desc { overflow: hidden; color: #8f8f8f; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qf3-badge {\n  flex: none;\n  padding: 2px 8px;\n  color: var(--hb-qf3-soft);\n  font-size: 11px;\n  font-weight: 600;\n  background: color-mix(in srgb, var(--hb-qf3-x) 16%, transparent);\n  border-radius: 999px;\n}\n.hb-qf3-dot {\n  position: relative;\n  flex: none;\n  width: 18px;\n  height: 18px;\n  border: 1.5px solid #4a4a4a;\n  border-radius: 50%;\n  transition: border-color 0.25s ease;\n}\n.hb-qf3-dot::after {\n  content: \"\";\n  position: absolute;\n  inset: 3px;\n  background: var(--hb-qf3-x);\n  border-radius: 50%;\n  transform: scale(0);\n  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);\n}\n.hb-qf3-item[data-on=\"true\"] .hb-qf3-dot { border-color: var(--hb-qf3-x); }\n.hb-qf3-item[data-on=\"true\"] .hb-qf3-dot::after { transform: scale(1); }\n.hb-qf3-more {\n  display: grid;\n  grid-template-rows: 0fr;\n  transition: grid-template-rows 0.4s cubic-bezier(0.22, 1, 0.36, 1);\n}\n.hb-qf3-item[data-on=\"true\"] .hb-qf3-more { grid-template-rows: 1fr; }\n.hb-qf3-more > div { min-height: 0; overflow: hidden; }\n.hb-qf3-more p {\n  margin: 0;\n  padding: 0 12px 9px 52px;\n  color: #a1a1a1;\n  font-size: 12.5px;\n  opacity: 0;\n  transform: translateY(-4px);\n  transition: opacity 0.3s ease 0.08s, transform 0.3s ease 0.08s;\n}\n.hb-qf3-item[data-on=\"true\"] .hb-qf3-more p { opacity: 1; transform: none; }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qf3-hl, .hb-qf3-item, .hb-qf3-ico, .hb-qf3-dot, .hb-qf3-dot::after, .hb-qf3-more, .hb-qf3-more p { transition: none; }\n}\n`;\n\nfunction Icon({ kind }: { kind: PayMethodIcon }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n      {kind === \"card\" && (\n        <>\n          <rect x=\"3\" y=\"5.5\" width=\"18\" height=\"13\" rx=\"2.5\" />\n          <path d=\"M3 10h18M7 15h3\" />\n        </>\n      )}\n      {kind === \"bank\" && <path d=\"M3 9.5L12 4l9 5.5M5 10v7M9.5 10v7M14.5 10v7M19 10v7M3.5 20h17\" />}\n      {kind === \"wallet\" && (\n        <>\n          <path d=\"M4 7.5A2.5 2.5 0 0 1 6.5 5H18v3\" />\n          <rect x=\"3.5\" y=\"8\" width=\"17\" height=\"11\" rx=\"2.5\" />\n          <circle cx=\"16.5\" cy=\"13.5\" r=\"1\" />\n        </>\n      )}\n      {kind === \"voucher\" && (\n        <>\n          <path d=\"M4 8a2 2 0 0 0 0 4v0a2 2 0 0 0 0 4v1.5h16V16a2 2 0 0 1 0-4v0a2 2 0 0 1 0-4V6.5H4z\" />\n          <path d=\"M14 7v10\" strokeDasharray=\"1.6 2.2\" />\n        </>\n      )}\n    </svg>\n  );\n}\n\nexport function PayMethodPicker({\n  methods = defaultMethods,\n  value,\n  defaultValue,\n  onChange,\n  accent = \"#2f7bff\",\n  label = \"Payment method\",\n  className = \"\",\n  style,\n  ...rest\n}: PayMethodPickerProps) {\n  const uid = React.useId();\n  const rootRef = React.useRef<HTMLDivElement>(null);\n  const hlRef = React.useRef<HTMLDivElement>(null);\n  const rowRefs = React.useRef<(HTMLButtonElement | null)[]>([]);\n  const [inner, setInner] = React.useState(defaultValue ?? methods[0]?.id ?? \"\");\n  const current = value ?? inner;\n  const activeIndex = Math.max(0, methods.findIndex((m) => m.id === current));\n\n  const place = React.useCallback(() => {\n    const root = rootRef.current;\n    const hl = hlRef.current;\n    const item = rowRefs.current[activeIndex]?.parentElement;\n    if (!root || !hl || !item) return;\n    const first = !root.dataset.ready;\n    if (first) hl.style.transition = \"none\";\n    hl.style.transform = `translateY(${item.offsetTop}px)`;\n    hl.style.height = `${item.offsetHeight}px`;\n    if (first) {\n      void hl.offsetHeight;\n      hl.style.transition = \"\";\n      root.dataset.ready = \"true\";\n    }\n  }, [activeIndex]);\n\n  React.useLayoutEffect(() => {\n    place();\n  }, [place, methods]);\n\n  React.useEffect(() => {\n    const root = rootRef.current;\n    if (!root || typeof ResizeObserver === \"undefined\") return;\n    const ro = new ResizeObserver(() => place());\n    ro.observe(root);\n    rowRefs.current.forEach((el) => el?.parentElement && ro.observe(el.parentElement));\n    return () => ro.disconnect();\n  }, [place, methods]);\n\n  function choose(id: string) {\n    if (value === undefined) setInner(id);\n    if (id !== current) onChange?.(id);\n  }\n\n  function onKey(event: React.KeyboardEvent, index: number) {\n    const keys = [\"ArrowDown\", \"ArrowRight\", \"ArrowUp\", \"ArrowLeft\", \"Home\", \"End\"];\n    if (!keys.includes(event.key)) return;\n    event.preventDefault();\n    const step = event.key === \"ArrowDown\" || event.key === \"ArrowRight\" ? 1 : -1;\n    let next = index;\n    if (event.key === \"Home\") next = -1;\n    if (event.key === \"End\") next = methods.length;\n    const jump = event.key === \"Home\" ? 1 : event.key === \"End\" ? -1 : step;\n    for (let i = 0; i < methods.length; i += 1) {\n      next = (next + jump + methods.length) % methods.length;\n      if (!methods[next].disabled) break;\n    }\n    rowRefs.current[next]?.focus();\n    choose(methods[next].id);\n  }\n\n  const vars = {\n    \"--hb-qf3-x\": accent,\n    \"--hb-qf3-soft\": `color-mix(in srgb, ${accent} 55%, #fff)`,\n    ...style,\n  } as React.CSSProperties;\n\n  return (\n    <div\n      ref={rootRef}\n      role=\"radiogroup\"\n      aria-label={label}\n      className={`hb-qf3 ${className}`}\n      style={vars}\n      {...rest}\n    >\n      <style href=\"hb-pay-method-picker\" precedence=\"default\">{css}</style>\n      <div ref={hlRef} className=\"hb-qf3-hl\" aria-hidden=\"true\" />\n      {methods.map((m, i) => {\n        const on = i === activeIndex;\n        const detailId = `${uid}-${m.id}`;\n        return (\n          <div key={m.id} className=\"hb-qf3-item\" data-on={on} role=\"none\">\n            <button\n              ref={(el) => {\n                rowRefs.current[i] = el;\n              }}\n              type=\"button\"\n              role=\"radio\"\n              className=\"hb-qf3-row\"\n              aria-checked={on}\n              aria-describedby={m.detail ? detailId : undefined}\n              tabIndex={on ? 0 : -1}\n              disabled={m.disabled}\n              onClick={() => choose(m.id)}\n              onKeyDown={(e) => onKey(e, i)}\n            >\n              <span className=\"hb-qf3-ico\">\n                <Icon kind={m.icon ?? \"card\"} />\n              </span>\n              <span className=\"hb-qf3-txt\">\n                <span className=\"hb-qf3-name\">{m.label}</span>\n                {m.description && <span className=\"hb-qf3-desc\">{m.description}</span>}\n              </span>\n              {m.badge && <span className=\"hb-qf3-badge\">{m.badge}</span>}\n              <span className=\"hb-qf3-dot\" aria-hidden=\"true\" />\n            </button>\n            {m.detail && (\n              <div className=\"hb-qf3-more\">\n                <div>\n                  <p id={detailId}>{m.detail}</p>\n                </div>\n              </div>\n            )}\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}