{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pay-wallet-balance",
  "type": "registry:component",
  "title": "Pay Wallet Balance",
  "description": "A wallet card with a counting balance, quick top-up amounts, recent activity and an eye button that blurs the figures.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "payments",
    "wallet",
    "balance",
    "top up",
    "activity",
    "privacy",
    "fintech"
  ],
  "docs": "https://hyperblur.dev/effects/pay-wallet-balance",
  "files": [
    {
      "path": "registry/hyperblur/pay-wallet-balance.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/pay-wallet-balance.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface PayWalletActivity {\n  id: string;\n  label: string;\n  time: string;\n  amount: number;\n}\n\nexport interface PayWalletBalanceProps\n  extends Omit<React.HTMLAttributes<HTMLDivElement>, \"onChange\"> {\n  balance?: number;\n  currency?: string;\n  name?: string;\n  topUps?: number[];\n  activity?: PayWalletActivity[];\n  maxActivity?: number;\n  optimistic?: boolean;\n  onTopUp?: (amount: number) => void;\n  hidden?: boolean;\n  defaultHidden?: boolean;\n  onHiddenChange?: (hidden: boolean) => void;\n  accent?: string;\n}\n\nconst defaultActivity: PayWalletActivity[] = [\n  { id: \"a1\", label: \"Corner Bakery\", time: \"Today, 8:14\", amount: -640 },\n  { id: \"a2\", label: \"Salary, Halden Labs\", time: \"Yesterday\", amount: 184000 },\n  { id: \"a3\", label: \"Metro monthly pass\", time: \"Oct 30\", amount: -7800 },\n];\n\nconst css = `\n.hb-qfc {\n  box-sizing: border-box;\n  width: 100%;\n  color: #ededed;\n  font-family: inherit;\n  font-size: 13px;\n  line-height: 1.4;\n}\n.hb-qfc *, .hb-qfc *::before, .hb-qfc *::after { box-sizing: border-box; }\n.hb-qfc-card { position: relative; padding: 12px 14px 10px; overflow: hidden; background: #111111; border: 1px solid #262626; border-radius: 14px; }\n.hb-qfc-card::before {\n  content: \"\";\n  position: absolute;\n  inset: 0 0 auto 0;\n  height: 112px;\n  pointer-events: none;\n  background:\n    radial-gradient(90% 120% at 0% 0%, color-mix(in srgb, var(--hb-qfc-x) 30%, transparent), transparent 70%),\n    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent);\n}\n.hb-qfc-top { position: relative; display: flex; align-items: center; justify-content: space-between; }\n.hb-qfc-name { display: inline-flex; align-items: center; gap: 7px; color: #b5b5b5; font-size: 12px; font-weight: 500; }\n.hb-qfc-name svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.hb-qfc-eye {\n  display: grid;\n  place-items: center;\n  width: 28px;\n  height: 28px;\n  margin: -4px -4px -4px 0;\n  padding: 0;\n  color: #a1a1a1;\n  background: none;\n  border: 0;\n  border-radius: 50%;\n  cursor: pointer;\n  transition: color 0.2s ease, background-color 0.2s ease;\n}\n.hb-qfc-eye:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }\n.hb-qfc-eye:focus-visible { outline: 2px solid var(--hb-qfc-x); outline-offset: 1px; }\n.hb-qfc-eye svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }\n.hb-qfc-eye .hb-qfc-slash { stroke-dasharray: 1 1.2; stroke-dashoffset: 1; transition: stroke-dashoffset 0.3s ease; }\n.hb-qfc[data-hidden=\"true\"] .hb-qfc-slash { stroke-dashoffset: 0; }\n.hb-qfc-bal {\n  position: relative;\n  margin: 2px 0 0;\n  font-size: 32px;\n  font-weight: 650;\n  letter-spacing: -0.03em;\n  line-height: 1.15;\n  font-variant-numeric: tabular-nums;\n  transition: filter 0.35s ease, opacity 0.35s ease;\n}\n.hb-qfc-bal small { color: #8f8f8f; font-size: 17px; font-weight: 500; letter-spacing: 0; }\n.hb-qfc[data-hidden=\"true\"] .hb-qfc-bal { opacity: 0.6; filter: blur(9px); user-select: none; -webkit-user-select: none; }\n.hb-qfc-ups { position: relative; display: flex; align-items: center; gap: 6px; margin-top: 8px; }\n.hb-qfc-ups > span { margin-right: 2px; color: #8f8f8f; font-size: 12px; }\n.hb-qfc-chip {\n  margin: 0;\n  padding: 0 11px;\n  height: 28px;\n  color: #ededed;\n  font: inherit;\n  font-size: 12.5px;\n  font-weight: 600;\n  font-variant-numeric: tabular-nums;\n  background: rgba(255, 255, 255, 0.06);\n  border: 1px solid rgba(255, 255, 255, 0.12);\n  border-radius: 999px;\n  cursor: pointer;\n  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s ease, border-color 0.2s ease;\n}\n.hb-qfc-chip:hover { background: color-mix(in srgb, var(--hb-qfc-x) 24%, transparent); border-color: var(--hb-qfc-x); }\n.hb-qfc-chip:active { transform: scale(0.94); }\n.hb-qfc-chip:focus-visible { outline: 2px solid var(--hb-qfc-x); outline-offset: 2px; }\n.hb-qfc-sec { position: relative; margin: 10px 0 2px; color: #8f8f8f; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }\n.hb-qfc-list { position: relative; display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }\n.hb-qfc-row { display: flex; align-items: center; gap: 10px; min-height: 30px; border-top: 1px solid #1f1f1f; }\n.hb-qfc-row:first-child { border-top: 0; }\n.hb-qfc-row[data-new=\"true\"] { animation: hb-qfc-in 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both; }\n.hb-qfc-av { display: grid; flex: none; place-items: center; width: 22px; height: 22px; color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 50%; }\n.hb-qfc-tx { display: flex; min-width: 0; flex: 1; align-items: baseline; gap: 8px; }\n.hb-qfc-tx b { overflow: hidden; font-size: 12.5px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }\n.hb-qfc-tx span { flex: none; color: #6f6f6f; font-size: 11.5px; }\n.hb-qfc-am { flex: none; font-size: 12.5px; font-variant-numeric: tabular-nums; transition: filter 0.35s ease, opacity 0.35s ease; }\n.hb-qfc-am[data-sign=\"plus\"] { color: #3ddc97; }\n.hb-qfc[data-hidden=\"true\"] .hb-qfc-am { opacity: 0.6; filter: blur(6px); user-select: none; -webkit-user-select: none; }\n.hb-qfc-sr { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }\n@keyframes hb-qfc-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }\n@media (prefers-reduced-motion: reduce) {\n  .hb-qfc-bal, .hb-qfc-am, .hb-qfc-chip, .hb-qfc-eye, .hb-qfc-slash { transition: none; }\n  .hb-qfc-row[data-new=\"true\"] { animation: none; }\n}\n`;\n\nconst tints = [\"#3b6dff\", \"#a05bff\", \"#14b8a6\", \"#f97316\", \"#ec4899\", \"#0ea5e9\"];\n\nfunction tintFor(text: string) {\n  let h = 0;\n  for (let i = 0; i < text.length; i += 1) h = (h * 31 + text.charCodeAt(i)) >>> 0;\n  return tints[h % tints.length];\n}\n\nfunction split(cents: number) {\n  const abs = Math.abs(Math.round(cents));\n  return {\n    whole: Math.floor(abs / 100)\n      .toString()\n      .replace(/\\B(?=(\\d{3})+(?!\\d))/g, \",\"),\n    frac: (abs % 100).toString().padStart(2, \"0\"),\n  };\n}\n\nfunction money(cents: number, currency: string) {\n  const { whole, frac } = split(cents);\n  return `${currency}${whole}.${frac}`;\n}\n\nfunction CountUp({ value }: { value: number }) {\n  const ref = React.useRef<HTMLSpanElement>(null);\n  const shown = React.useRef(0);\n\n  React.useEffect(() => {\n    const el = ref.current;\n    if (!el) return;\n    const write = (v: number) => {\n      shown.current = v;\n      const { whole, frac } = split(v);\n      el.textContent = `${whole}.${frac}`;\n    };\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      write(value);\n      return;\n    }\n    const from = shown.current;\n    const span = Math.max(500, Math.min(1400, Math.abs(value - from) / 120));\n    let raf = 0;\n    let t0 = 0;\n    const tick = (now: number) => {\n      if (!t0) t0 = now;\n      const p = Math.min(1, (now - t0) / span);\n      const eased = 1 - Math.pow(1 - p, 3);\n      write(Math.round(from + (value - from) * eased));\n      if (p < 1) raf = requestAnimationFrame(tick);\n    };\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [value]);\n\n  return <span ref={ref}>0.00</span>;\n}\n\nexport function PayWalletBalance({\n  balance = 248650,\n  currency = \"$\",\n  name = \"Main wallet\",\n  topUps = [2500, 5000, 10000],\n  activity = defaultActivity,\n  maxActivity = 3,\n  optimistic = true,\n  onTopUp,\n  hidden,\n  defaultHidden = false,\n  onHiddenChange,\n  accent = \"#2f7bff\",\n  className = \"\",\n  style,\n  ...rest\n}: PayWalletBalanceProps) {\n  const [innerHidden, setInnerHidden] = React.useState(defaultHidden);\n  const [added, setAdded] = React.useState(0);\n  const [extra, setExtra] = React.useState<PayWalletActivity[]>([]);\n  const isHidden = hidden ?? innerHidden;\n  const total = balance + added;\n  const rows = [...extra, ...activity].slice(0, Math.max(1, maxActivity));\n\n  function toggle() {\n    const next = !isHidden;\n    if (hidden === undefined) setInnerHidden(next);\n    onHiddenChange?.(next);\n  }\n\n  function topUp(amount: number) {\n    onTopUp?.(amount);\n    if (!optimistic) return;\n    setAdded((a) => a + amount);\n    setExtra((list) => [{ id: `top-${list.length}`, label: \"Top up\", time: \"Just now\", amount }, ...list].slice(0, 6));\n  }\n\n  const vars = { \"--hb-qfc-x\": accent, ...style } as React.CSSProperties;\n\n  return (\n    <div className={`hb-qfc ${className}`} style={vars} data-hidden={isHidden} {...rest}>\n      <style href=\"hb-pay-wallet-balance\" precedence=\"default\">{css}</style>\n      <div className=\"hb-qfc-card\">\n        <div className=\"hb-qfc-top\">\n          <span className=\"hb-qfc-name\">\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\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            </svg>\n            {name}\n          </span>\n          <button\n            type=\"button\"\n            className=\"hb-qfc-eye\"\n            aria-pressed={isHidden}\n            aria-label={isHidden ? \"Show balance\" : \"Hide balance\"}\n            onClick={toggle}\n          >\n            <svg viewBox=\"0 0 24 24\" aria-hidden=\"true\">\n              <path d=\"M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12z\" />\n              <circle cx=\"12\" cy=\"12\" r=\"2.8\" />\n              <path className=\"hb-qfc-slash\" d=\"M4 4l16 16\" pathLength=\"1\" />\n            </svg>\n          </button>\n        </div>\n        <p className=\"hb-qfc-bal\" aria-hidden={isHidden}>\n          <small>{currency}</small>\n          <CountUp value={total} />\n        </p>\n        <span className=\"hb-qfc-sr\" role=\"status\">\n          {isHidden ? \"Balance hidden\" : `Balance ${money(total, currency)}`}\n        </span>\n        {topUps.length > 0 && (\n          <div className=\"hb-qfc-ups\">\n            <span>Top up</span>\n            {topUps.map((amount) => (\n              <button key={amount} type=\"button\" className=\"hb-qfc-chip\" onClick={() => topUp(amount)}>\n                +{money(amount, currency).replace(/\\.00$/, \"\")}\n              </button>\n            ))}\n          </div>\n        )}\n        <p className=\"hb-qfc-sec\">Recent activity</p>\n        <ul className=\"hb-qfc-list\">\n          {rows.map((row) => (\n            <li key={row.id} className=\"hb-qfc-row\" data-new={row.id.startsWith(\"top-\")}>\n              <span className=\"hb-qfc-av\" aria-hidden=\"true\" style={{ background: tintFor(row.label) }}>\n                {row.label.charAt(0).toUpperCase()}\n              </span>\n              <span className=\"hb-qfc-tx\">\n                <b>{row.label}</b>\n                <span>{row.time}</span>\n              </span>\n              <span className=\"hb-qfc-am\" data-sign={row.amount >= 0 ? \"plus\" : \"minus\"} aria-hidden={isHidden}>\n                {row.amount >= 0 ? \"+\" : \"-\"}\n                {money(row.amount, currency)}\n              </span>\n            </li>\n          ))}\n        </ul>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}