{"slug":"wallet-card","name":"Wallet Card","description":"Wallet overview card with an account switcher and search that morph open from their triggers, a cascading balance with a live change pill and privacy toggle, copy-address, and Send / Deposit / Swap / Buy actions.","category":"blocks","source_url":"https://beui.dev/r/wallet-card/raw","detail_url":"https://beui.dev/r/wallet-card","raw_url":"https://beui.dev/r/wallet-card/raw","page_url":"https://beui.dev/components/blocks/wallet-card","markdown_url":"https://beui.dev/components/blocks/wallet-card.md","published_at":"2026-07-03","updated_at":"2026-11-28","dependencies":["clsx","lucide-react","motion","react","tailwind-merge"],"internal":["../magnetic","./account-avatar","./account-switcher","./actions","./balance-delta","./base","./constants","./copy-button","./engine","./magnetic","./messages","./metallic","./search-bar","./stateful","./types","./utils","@/components/motion/action-swap","@/components/motion/button","@/components/motion/wallet-card","@/lib/audio-context","@/lib/ease","@/lib/hooks/use-dismiss","@/lib/hooks/use-hover-capable","@/lib/i18n","@/lib/layers","@/lib/sound","@/lib/sounds/engine","@/lib/sounds/press","@/lib/utils"],"install_slugs":["wallet-card"],"requires_theme":false,"props":[{"displayName":"WalletCard","props":[{"name":"labels","type":"Partial<{ notifications: string; balance: string; showBalance: string; hideBalance: string; search: string; searchPlaceholder: string; noMatches: string; noRecent: string; selectAccount: string; ... 5 more ...; copyAddress: string; }>","required":false,"defaultValue":null,"description":"Override any built-in string."},{"name":"accounts","type":"WalletAccount[]","required":true,"defaultValue":null,"description":"Accounts listed in the switcher."},{"name":"accountId","type":"string","required":false,"defaultValue":null,"description":"The active account id, for controlled use."},{"name":"defaultAccountId","type":"string","required":false,"defaultValue":null,"description":"The initial account id when uncontrolled. Defaults to the first account."},{"name":"onAccountChange","type":"((id: string) => void)","required":false,"defaultValue":null,"description":"Called with the account id when the user picks an account."},{"name":"balance","type":"number","required":true,"defaultValue":null,"description":"Balance amount, shown with 2 decimals."},{"name":"balancePrefix","type":"string","required":false,"defaultValue":"$","description":"Text placed before the balance and change amounts. Default: \"$\""},{"name":"defaultChange","type":"number","required":false,"defaultValue":null,"description":"Initial balance change shown in the pill before any live change."},{"name":"defaultBalanceHidden","type":"boolean","required":false,"defaultValue":"false","description":"Start with the balance hidden behind dots."},{"name":"onSend","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the Send action is pressed."},{"name":"onDeposit","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the Deposit action is pressed."},{"name":"onSwap","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the Swap action is pressed."},{"name":"onBuy","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the Buy action is pressed."},{"name":"searchPlaceholder","type":"string","required":false,"defaultValue":null,"description":"Placeholder for the search input. Defaults to the `searchPlaceholder` label."},{"name":"searchRecent","type":"string[]","required":false,"defaultValue":null,"description":"Recent searches shown in the expanded search panel."},{"name":"onSearchChange","type":"((value: string) => void)","required":false,"defaultValue":null,"description":"Called with the search text as the user types or picks a recent search."},{"name":"onSearchSubmit","type":"((value: string) => void)","required":false,"defaultValue":null,"description":"Called with the trimmed query on Enter, or with a picked recent search."},{"name":"hasNotifications","type":"boolean","required":false,"defaultValue":"false","description":"Show an unread pulse on the notifications bell."},{"name":"onNotifications","type":"(() => void)","required":false,"defaultValue":null,"description":"Called when the notifications bell is pressed."},{"name":"className","type":"string","required":false,"defaultValue":null,"description":"Classes merged onto the root element."}]}],"types":[{"name":"WalletAccount","file":"components/motion/wallet-card/types.ts","fields":[{"name":"id","type":"string","required":true,"description":"Unique key, used as the active account id and the generated avatar's seed."},{"name":"name","type":"string","required":true,"description":"Account name shown in the switcher."},{"name":"address","type":"string","required":true,"description":"Wallet address, shown shortened in the menu and copied in full."},{"name":"avatar","type":"ReactNode","required":false,"description":"Custom avatar. Falls back to a generated image seeded from the id."}]}],"files":[{"path":"components/motion/wallet-card/index.tsx","type":"component","content":"\"use client\";\n// beui.dev/components/blocks/wallet-card\n\nimport { Bell, Eye, EyeOff } from \"lucide-react\";\nimport { useState } from \"react\";\nimport { ActionSwapText } from \"@/components/motion/action-swap\";\nimport { Button } from \"@/components/motion/button\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\nimport { AccountSwitcher } from \"./account-switcher\";\nimport { WalletActions } from \"./actions\";\nimport { BalanceDelta } from \"./balance-delta\";\nimport { type WalletCardMessages, walletCardMessages } from \"./messages\";\nimport { SearchBar } from \"./search-bar\";\nimport type { WalletCardProps as WalletCardBaseProps } from \"./types\";\n\nexport { type WalletCardMessages, walletCardMessages } from \"./messages\";\nexport type { WalletAccount } from \"./types\";\n\nexport interface WalletCardProps extends WalletCardBaseProps {\n  /** Override any built-in string. */\n  labels?: Partial<WalletCardMessages>;\n}\n\n/**\n * Composed wallet overview card: an account switcher whose trigger morphs open\n * into a full-width panel, a search icon that morphs into a search bar, a\n * rolling balance with a transient change indicator, and Send / Deposit\n * actions. Actions and search are plain callbacks - the resulting flow is left\n * to the consumer.\n */\nexport function WalletCard({\n  accounts,\n  accountId,\n  defaultAccountId,\n  onAccountChange,\n  balance,\n  balancePrefix = \"$\",\n  defaultChange,\n  defaultBalanceHidden = false,\n  onSend,\n  onDeposit,\n  onSwap,\n  onBuy,\n  searchPlaceholder,\n  searchRecent,\n  onSearchChange,\n  onSearchSubmit,\n  hasNotifications = false,\n  onNotifications,\n  labels,\n  className,\n}: WalletCardProps) {\n  const t = useMessages(\"walletCard\", walletCardMessages, labels);\n  const accountControlled = accountId !== undefined;\n  const [internalAccountId, setInternalAccountId] = useState(\n    defaultAccountId ?? accounts[0]?.id,\n  );\n  const [balanceHidden, setBalanceHidden] = useState(defaultBalanceHidden);\n\n  const shownBalance = `${balancePrefix}${balance.toLocaleString(undefined, {\n    minimumFractionDigits: 2,\n    maximumFractionDigits: 2,\n  })}`;\n  const maskedBalance = \"*\".repeat(7);\n  const activeAccountId = accountControlled ? accountId : internalAccountId;\n  const activeAccount =\n    accounts.find((a) => a.id === activeAccountId) ?? accounts[0];\n\n  const handleAccountChange = (id: string) => {\n    if (!accountControlled) setInternalAccountId(id);\n    onAccountChange?.(id);\n  };\n\n  return (\n    <div\n      className={cn(\n        \"relative w-full max-w-xs overflow-hidden rounded-4xl border border-border p-6\",\n        className,\n      )}\n    >\n      {/* relative anchor so the switcher + search panels span the whole row */}\n      <div className=\"relative flex items-center justify-between gap-2\">\n        <AccountSwitcher\n          accounts={accounts}\n          activeAccount={activeAccount}\n          onSelect={handleAccountChange}\n          labels={labels}\n        />\n\n        <div className=\"flex shrink-0 items-center gap-1\">\n          <SearchBar\n            placeholder={searchPlaceholder}\n            recent={searchRecent}\n            onChange={onSearchChange}\n            onSubmit={onSearchSubmit}\n            labels={labels}\n          />\n          <Button\n            variant=\"ghost\"\n            size=\"icon\"\n            onClick={onNotifications}\n            aria-label={t(\"notifications\")}\n            className=\"relative\"\n          >\n            <Bell className=\"h-4 w-4\" />\n            {hasNotifications ? (\n              <span className=\"absolute top-1.5 right-1.5 flex h-2 w-2\">\n                <span className=\"absolute inline-flex h-full w-full animate-ping rounded-full bg-primary opacity-60\" />\n                <span className=\"relative inline-flex h-2 w-2 rounded-full bg-primary\" />\n              </span>\n            ) : null}\n          </Button>\n        </div>\n      </div>\n\n      <div className=\"mt-8 flex flex-col items-center text-center\">\n        <div className=\"flex items-center gap-1.5\">\n          <p className=\"text-xs text-muted-foreground\">{t(\"balance\")}</p>\n          <button\n            type=\"button\"\n            onClick={() => setBalanceHidden((h) => !h)}\n            aria-label={t(balanceHidden ? \"showBalance\" : \"hideBalance\")}\n            aria-pressed={balanceHidden}\n            className=\"text-muted-foreground outline-none transition-colors hover:text-foreground\"\n          >\n            {balanceHidden ? (\n              <EyeOff className=\"h-3.5 w-3.5\" />\n            ) : (\n              <Eye className=\"h-3.5 w-3.5\" />\n            )}\n          </button>\n        </div>\n        {/* One ActionSwapText swaps the number and the asterisk mask with a\n            per-letter cascade - same baseline, no overlap or layout shift. */}\n        <ActionSwapText\n          value={balanceHidden ? \"hidden\" : shownBalance}\n          animation=\"cascade\"\n          className=\"text-3xl font-semibold text-foreground\"\n        >\n          {balanceHidden ? maskedBalance : shownBalance}\n        </ActionSwapText>\n        {balanceHidden ? (\n          <div className=\"mt-2 flex h-7 items-center justify-center\">\n            <span className=\"translate-y-[3px] text-sm font-medium text-muted-foreground leading-none tracking-[0.3em]\">\n              *****\n            </span>\n          </div>\n        ) : (\n          <BalanceDelta\n            balance={balance}\n            initialChange={defaultChange}\n            prefix={balancePrefix}\n          />\n        )}\n      </div>\n\n      <div className=\"mt-8\">\n        <WalletActions\n          onSend={onSend}\n          onDeposit={onDeposit}\n          onSwap={onSwap}\n          onBuy={onBuy}\n          labels={labels}\n        />\n      </div>\n    </div>\n  );\n}\n"},{"path":"components/motion/wallet-card/account-switcher.tsx","type":"util","content":"\"use client\";\n\nimport { Check, ChevronDown } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { useDismiss } from \"@/lib/hooks/use-dismiss\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\nimport { AccountAvatar } from \"./account-avatar\";\nimport { HEAD, ITEM, LIST, MORPH } from \"./constants\";\nimport { CopyButton } from \"./copy-button\";\nimport { type WalletCardMessages, walletCardMessages } from \"./messages\";\nimport type { WalletAccount } from \"./types\";\nimport { truncateAddress } from \"./utils\";\n\n/**\n * Account switcher whose trigger morphs into a panel that grows rightward to\n * full width (covering the header icons) and downward at the same time, via a\n * shared layoutId. Self-contained - not the generic MorphSelect.\n */\nexport function AccountSwitcher({\n  accounts,\n  activeAccount,\n  onSelect,\n  labels,\n}: {\n  accounts: WalletAccount[];\n  activeAccount: WalletAccount | undefined;\n  onSelect: (id: string) => void;\n  labels?: Partial<WalletCardMessages>;\n}) {\n  const t = useMessages(\"walletCard\", walletCardMessages, labels);\n  const reduce = useReducedMotion() ?? false;\n  const layoutId = `${useId()}-account`;\n  const rootRef = useRef<HTMLDivElement>(null);\n  const [open, setOpen] = useState(false);\n  // Hover only arms after the morph settles - otherwise the panel expands under\n  // the cursor and flashes a phantom hover bg on whatever item it lands on.\n  const [armed, setArmed] = useState(false);\n  const close = useCallback(() => setOpen(false), []);\n\n  useDismiss(open, close, rootRef);\n\n  useEffect(() => {\n    if (!open) {\n      setArmed(false);\n      return;\n    }\n    const t = window.setTimeout(() => setArmed(true), reduce ? 0 : 280);\n    return () => window.clearTimeout(t);\n  }, [open, reduce]);\n\n  const morph = reduce ? { duration: 0 } : MORPH;\n  const sizerAccount = activeAccount ?? accounts[0];\n\n  return (\n    // static (not relative) so the absolute trigger + panel anchor to the\n    // header row and can span its full width, covering the icons.\n    <div ref={rootRef} className=\"min-w-0\">\n      {/* in-flow sizer: reserves the widest possible trigger footprint (every\n          account name stacked in one grid cell) so the header row width never\n          changes - neither when the trigger leaves the flow nor when a shorter\n          account name is selected. */}\n      <div aria-hidden className={cn(HEAD, \"pointer-events-none opacity-0\")}>\n        {sizerAccount ? <AccountAvatar account={sizerAccount} /> : null}\n        <span className=\"grid\">\n          {accounts.map((account) => (\n            <span\n              key={account.id}\n              className=\"col-start-1 row-start-1 whitespace-nowrap text-sm font-medium\"\n            >\n              {account.name}\n            </span>\n          ))}\n        </span>\n        <ChevronDown className=\"h-4 w-4\" />\n      </div>\n\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {open ? null : (\n          <motion.button\n            key=\"trigger\"\n            layoutId={layoutId}\n            type=\"button\"\n            aria-haspopup=\"listbox\"\n            aria-expanded={false}\n            onClick={() => setOpen(true)}\n            transition={morph}\n            style={{ borderRadius: 20 }}\n            className={cn(\n              HEAD,\n              // shifted left by the padding so the avatar sits flush with the\n              // card content edge (aligned with the balance + buttons below).\n              \"absolute top-0 -left-2 z-20 max-w-full outline-none transition-colors hover:bg-muted/60\",\n            )}\n          >\n            {activeAccount ? (\n              <>\n                <AccountAvatar account={activeAccount} />\n                <motion.span\n                  layout=\"position\"\n                  className=\"truncate text-sm font-medium text-foreground\"\n                >\n                  {activeAccount.name}\n                </motion.span>\n                <motion.span layout=\"position\" className=\"text-muted-foreground\">\n                  <ChevronDown className=\"h-4 w-4\" />\n                </motion.span>\n              </>\n            ) : null}\n          </motion.button>\n        )}\n      </AnimatePresence>\n\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {open ? (\n          <motion.div\n            key=\"panel\"\n            layoutId={layoutId}\n            role=\"listbox\"\n            transition={morph}\n            style={{ borderRadius: 24 }}\n            className=\"absolute top-0 -right-2 -left-2 z-30 overflow-hidden border border-border/30 bg-background backdrop-blur-md\"\n          >\n            <button\n              type=\"button\"\n              onClick={() => setOpen(false)}\n              className={cn(HEAD, \"w-full outline-none\")}\n            >\n              {activeAccount ? <AccountAvatar account={activeAccount} /> : null}\n              <motion.span\n                layout=\"position\"\n                className=\"min-w-0 flex-1 truncate text-sm font-medium text-foreground\"\n              >\n                {activeAccount?.name ?? t(\"selectAccount\")}\n              </motion.span>\n              <motion.span\n                layout=\"position\"\n                animate={{ rotate: 180 }}\n                transition={morph}\n                className=\"text-muted-foreground\"\n              >\n                <ChevronDown className=\"h-4 w-4\" />\n              </motion.span>\n            </button>\n\n            <motion.ul\n              initial=\"hidden\"\n              animate=\"show\"\n              variants={reduce ? undefined : LIST}\n              className={cn(\n                \"max-h-64 overflow-y-auto p-2\",\n                armed ? \"\" : \"pointer-events-none\",\n              )}\n            >\n              {accounts.map((account) => {\n                const selected = account.id === activeAccount?.id;\n                return (\n                  <motion.li\n                    key={account.id}\n                    variants={reduce ? undefined : ITEM}\n                    className={cn(\n                      \"flex items-center rounded-full pr-2 text-sm transition-colors\",\n                      selected\n                        ? \"bg-muted text-foreground\"\n                        : cn(\n                            \"text-muted-foreground\",\n                            armed && \"hover:bg-muted hover:text-foreground\",\n                          ),\n                    )}\n                  >\n                    <button\n                      type=\"button\"\n                      role=\"option\"\n                      aria-selected={selected}\n                      onClick={() => {\n                        onSelect(account.id);\n                        setOpen(false);\n                      }}\n                      className=\"flex min-w-0 flex-1 items-center gap-2.5 rounded-full px-2 py-2 text-left outline-none\"\n                    >\n                      <AccountAvatar account={account} />\n                      <span className=\"flex min-w-0 flex-1 flex-col\">\n                        <span className=\"truncate font-medium\">\n                          {account.name}\n                        </span>\n                        <span className=\"truncate text-xs text-muted-foreground\">\n                          {truncateAddress(account.address)}\n                        </span>\n                      </span>\n                      {selected ? (\n                        <Check className=\"h-4 w-4 shrink-0 text-foreground\" />\n                      ) : null}\n                    </button>\n                    <CopyButton value={account.address} labels={labels} />\n                  </motion.li>\n                );\n              })}\n            </motion.ul>\n          </motion.div>\n        ) : null}\n      </AnimatePresence>\n    </div>\n  );\n}\n"},{"path":"components/motion/wallet-card/actions.tsx","type":"util","content":"\"use client\";\n\nimport { ArrowDownToLine, ArrowUp, CreditCard, Repeat } from \"lucide-react\";\nimport { motion, useReducedMotion } from \"motion/react\";\nimport type { ComponentType } from \"react\";\nimport { SPRING_PRESS } from \"@/lib/ease\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { type WalletCardMessages, walletCardMessages } from \"./messages\";\n\ntype WalletAction = {\n  key: string;\n  label: string;\n  icon: ComponentType<{ className?: string }>;\n  onClick?: () => void;\n};\n\n/**\n * Row of primary wallet actions rendered icon-over-label, with a spring press.\n */\nexport function WalletActions({\n  onSend,\n  onDeposit,\n  onSwap,\n  onBuy,\n  labels,\n}: {\n  onSend?: () => void;\n  onDeposit?: () => void;\n  onSwap?: () => void;\n  onBuy?: () => void;\n  labels?: Partial<WalletCardMessages>;\n}) {\n  const reduce = useReducedMotion();\n  const t = useMessages(\"walletCard\", walletCardMessages, labels);\n\n  const actions: WalletAction[] = [\n    { key: \"send\", label: t(\"send\"), icon: ArrowUp, onClick: onSend },\n    { key: \"deposit\", label: t(\"deposit\"), icon: ArrowDownToLine, onClick: onDeposit },\n    { key: \"swap\", label: t(\"swap\"), icon: Repeat, onClick: onSwap },\n    { key: \"buy\", label: t(\"buy\"), icon: CreditCard, onClick: onBuy },\n  ];\n\n  return (\n    <div className=\"flex items-start justify-between gap-2\">\n      {actions.map(({ key, label, icon: Icon, onClick }) => (\n        <motion.button\n          key={key}\n          type=\"button\"\n          onClick={onClick}\n          whileTap={reduce ? undefined : { scale: 0.94 }}\n          transition={SPRING_PRESS}\n          className=\"flex flex-1 flex-col items-center gap-2 outline-none\"\n        >\n          <span className=\"flex h-12 w-12 items-center justify-center rounded-full bg-muted text-foreground\">\n            <Icon className=\"h-5 w-5\" />\n          </span>\n          <span className=\"text-xs font-medium text-muted-foreground\">\n            {label}\n          </span>\n        </motion.button>\n      ))}\n    </div>\n  );\n}\n"},{"path":"components/motion/wallet-card/balance-delta.tsx","type":"util","content":"\"use client\";\n\nimport { TrendingDown, TrendingUp } from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\n/**\n * A transient change indicator for the balance: a tinted pill with a trend\n * arrow that pops in whenever the balance moves and persists until it moves\n * again.\n */\nexport function BalanceDelta({\n  balance,\n  initialChange,\n  prefix = \"$\",\n}: {\n  balance: number;\n  initialChange?: number;\n  prefix?: string;\n}) {\n  const reduce = useReducedMotion();\n  const prevRef = useRef(balance);\n  const [delta, setDelta] = useState<{ id: number; amount: number } | null>(\n    initialChange ? { id: 0, amount: initialChange } : null,\n  );\n\n  // Persist the last change until the balance moves again - don't auto-hide.\n  useEffect(() => {\n    const diff = balance - prevRef.current;\n    prevRef.current = balance;\n    if (diff === 0) return;\n    setDelta({ id: Date.now(), amount: diff });\n  }, [balance]);\n\n  const up = (delta?.amount ?? 0) > 0;\n\n  return (\n    <div className=\"mt-2 flex h-7 items-center justify-center\">\n      <AnimatePresence mode=\"wait\">\n        {delta ? (\n          <motion.span\n            key={delta.id}\n            initial={{ opacity: 0, y: reduce ? 0 : 6, scale: reduce ? 1 : 0.9 }}\n            animate={{ opacity: 1, y: 0, scale: 1 }}\n            exit={{ opacity: 0, y: reduce ? 0 : -6, scale: reduce ? 1 : 0.9 }}\n            transition={{ duration: 0.2, ease: EASE_OUT }}\n            className={cn(\n              \"inline-flex items-center gap-1 rounded-full px-2.5 py-1 text-xs font-medium tabular-nums\",\n              up\n                ? \"bg-emerald-500/15 text-emerald-600 dark:text-emerald-400\"\n                : \"bg-red-500/15 text-red-600 dark:text-red-400\",\n            )}\n          >\n            {up ? (\n              <TrendingUp className=\"h-3.5 w-3.5\" />\n            ) : (\n              <TrendingDown className=\"h-3.5 w-3.5\" />\n            )}\n            {up ? \"+\" : \"-\"}\n            {prefix}\n            {Math.abs(delta.amount).toLocaleString(undefined, {\n              minimumFractionDigits: 2,\n              maximumFractionDigits: 2,\n            })}\n          </motion.span>\n        ) : null}\n      </AnimatePresence>\n    </div>\n  );\n}\n"},{"path":"components/motion/wallet-card/messages.ts","type":"util","content":"/** English defaults. Override per instance with `labels`, or app-wide with `LocaleProvider`. */\nexport const walletCardMessages = {\n  notifications: \"Notifications\",\n  balance: \"Balance\",\n  showBalance: \"Show balance\",\n  hideBalance: \"Hide balance\",\n  search: \"Search\",\n  searchPlaceholder: \"Search\",\n  noMatches: \"No matches\",\n  noRecent: \"No recent searches\",\n  selectAccount: \"Select account\",\n  send: \"Send\",\n  deposit: \"Deposit\",\n  swap: \"Swap\",\n  buy: \"Buy\",\n  copied: \"Copied\",\n  copyAddress: \"Copy address\",\n};\n\nexport type WalletCardMessages = typeof walletCardMessages;\n"},{"path":"components/motion/wallet-card/search-bar.tsx","type":"util","content":"\"use client\";\n\nimport { History, Search } from \"lucide-react\";\nimport {\n  AnimatePresence,\n  motion,\n  type Transition,\n  useReducedMotion,\n} from \"motion/react\";\nimport { useCallback, useEffect, useId, useRef, useState } from \"react\";\nimport { EASE_OUT } from \"@/lib/ease\";\nimport { useDismiss } from \"@/lib/hooks/use-dismiss\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\nimport { ITEM, LIST, MORPH } from \"./constants\";\nimport { type WalletCardMessages, walletCardMessages } from \"./messages\";\n\n/**\n * Search icon that morphs into a full-width search bar via a shared layoutId,\n * growing leftward across the header row. The recent-searches results render as\n * a SEPARATE dropdown below the bar - not part of the morphing element - so\n * filtering as you type resizes only the dropdown and never re-fires the morph\n * (which would scale-distort the input text). The in-flow slot keeps its width\n * whether open or closed so the header row (and card) never shifts.\n */\nexport function SearchBar({\n  placeholder,\n  recent = [],\n  onChange,\n  onSubmit,\n  labels,\n}: {\n  placeholder?: string;\n  recent?: string[];\n  onChange?: (value: string) => void;\n  onSubmit?: (value: string) => void;\n  labels?: Partial<WalletCardMessages>;\n}) {\n  const t = useMessages(\"walletCard\", walletCardMessages, labels);\n  const reduce = useReducedMotion() ?? false;\n  const layoutId = `${useId()}-search`;\n  const rootRef = useRef<HTMLDivElement>(null);\n  const inputRef = useRef<HTMLInputElement>(null);\n  const [open, setOpen] = useState(false);\n  const [value, setValue] = useState(\"\");\n  // Hover arms after the dropdown reveals so it doesn't flash a phantom hover.\n  const [armed, setArmed] = useState(false);\n  const close = useCallback(() => setOpen(false), []);\n\n  useDismiss(open, close, rootRef);\n\n  useEffect(() => {\n    if (open) inputRef.current?.focus();\n  }, [open]);\n\n  useEffect(() => {\n    if (!open) {\n      setArmed(false);\n      return;\n    }\n    const id = window.setTimeout(() => setArmed(true), reduce ? 0 : 260);\n    return () => window.clearTimeout(id);\n  }, [open, reduce]);\n\n  // The box keeps the bouncy morph (same feel as the account switcher)...\n  const morph: Transition = reduce ? { duration: 0 } : MORPH;\n  // ...but the leading icon + input travel across the row, so their own layout\n  // uses a critically-damped spring - they glide to place without inheriting the\n  // box's overshoot (which read as the icon jittering right-then-left).\n  const glide: Transition = reduce\n    ? { duration: 0 }\n    : { type: \"spring\", duration: 0.5, bounce: 0 };\n\n  const query = value.trim().toLowerCase();\n  const filtered = query\n    ? recent.filter((r) => r.toLowerCase().includes(query))\n    : recent;\n\n  const submit = (next: string) => {\n    onSubmit?.(next);\n    setOpen(false);\n  };\n\n  return (\n    // static so the open bar + dropdown anchor to the header row (spanning its\n    // width), while the slot below reserves the icon's footprint.\n    <div ref={rootRef} className=\"shrink-0\">\n      {/* reserve the icon's width while open (the icon has left the flow) */}\n      {open ? <div aria-hidden className=\"h-8 w-8\" /> : null}\n\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {open ? null : (\n          <motion.button\n            key=\"icon\"\n            layoutId={layoutId}\n            type=\"button\"\n            aria-label={t(\"search\")}\n            onClick={() => setOpen(true)}\n            transition={morph}\n            style={{ borderRadius: 16 }}\n            className=\"inline-flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground\"\n          >\n            <Search className=\"h-4 w-4\" />\n          </motion.button>\n        )}\n      </AnimatePresence>\n\n      {/* one connected panel: input + results grow out of the trigger. The text\n          nodes use layout=\"position\" so when the panel resizes (filtering) they\n          reposition without scaling - no re-morph distortion, still connected. */}\n      <AnimatePresence initial={false} mode=\"popLayout\">\n        {open ? (\n          <motion.div\n            key=\"panel\"\n            layoutId={layoutId}\n            transition={morph}\n            style={{ borderRadius: 24 }}\n            className=\"absolute top-0 -right-2 -left-2 z-40 overflow-hidden border border-border/30 bg-background backdrop-blur-md\"\n          >\n            <div className=\"flex h-10 items-center gap-2.5 px-4\">\n              <motion.span\n                layout=\"position\"\n                transition={glide}\n                className=\"shrink-0\"\n              >\n                <Search className=\"h-4 w-4 text-muted-foreground\" />\n              </motion.span>\n              <motion.input\n                ref={inputRef}\n                layout=\"position\"\n                initial={reduce ? false : { opacity: 0 }}\n                animate={{ opacity: 1 }}\n                transition={{\n                  opacity: { duration: 0.15, delay: 0.12, ease: EASE_OUT },\n                  layout: glide,\n                }}\n                value={value}\n                onChange={(e) => {\n                  setValue(e.target.value);\n                  onChange?.(e.target.value);\n                }}\n                onKeyDown={(e) => {\n                  if (e.key === \"Enter\" && value.trim()) submit(value.trim());\n                  if (e.key === \"Escape\") close();\n                }}\n                placeholder={placeholder ?? t(\"searchPlaceholder\")}\n                className=\"min-w-0 flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground\"\n              />\n            </div>\n\n            <div className=\"h-px bg-border/40\" />\n\n            {filtered.length > 0 ? (\n              <motion.ul\n                initial=\"hidden\"\n                animate=\"show\"\n                variants={reduce ? undefined : LIST}\n                className={cn(\n                  \"max-h-56 overflow-y-auto p-2\",\n                  armed ? \"\" : \"pointer-events-none\",\n                )}\n              >\n                {filtered.map((term) => (\n                  <motion.li\n                    key={term}\n                    layout=\"position\"\n                    variants={reduce ? undefined : ITEM}\n                  >\n                    <button\n                      type=\"button\"\n                      onClick={() => {\n                        setValue(term);\n                        onChange?.(term);\n                        submit(term);\n                      }}\n                      className={cn(\n                        \"flex h-8 w-full items-center gap-2.5 rounded-full px-2 text-left text-sm text-muted-foreground outline-none transition-colors\",\n                        armed && \"hover:bg-muted hover:text-foreground\",\n                      )}\n                    >\n                      <History className=\"h-4 w-4 shrink-0\" />\n                      <span className=\"min-w-0 flex-1 truncate\">{term}</span>\n                    </button>\n                  </motion.li>\n                ))}\n              </motion.ul>\n            ) : (\n              <motion.div\n                layout=\"position\"\n                className=\"flex flex-col items-center gap-1 px-4 py-8 text-center\"\n              >\n                <Search className=\"h-5 w-5 text-muted-foreground/60\" />\n                <p className=\"text-sm text-muted-foreground\">\n                  {t(query ? \"noMatches\" : \"noRecent\")}\n                </p>\n              </motion.div>\n            )}\n          </motion.div>\n        ) : null}\n      </AnimatePresence>\n    </div>\n  );\n}\n"},{"path":"components/motion/wallet-card/types.ts","type":"util","content":"import type { ReactNode } from \"react\";\n\nexport type WalletAccount = {\n  /** Unique key, used as the active account id and the generated avatar's seed. */\n  id: string;\n  /** Account name shown in the switcher. */\n  name: string;\n  /** Wallet address, shown shortened in the menu and copied in full. */\n  address: string;\n  /** Custom avatar. Falls back to a generated image seeded from the id. */\n  avatar?: ReactNode;\n};\n\nexport interface WalletCardProps {\n  /** Accounts listed in the switcher. */\n  accounts: WalletAccount[];\n  /** The active account id, for controlled use. */\n  accountId?: string;\n  /** The initial account id when uncontrolled. Defaults to the first account. */\n  defaultAccountId?: string;\n  /** Called with the account id when the user picks an account. */\n  onAccountChange?: (id: string) => void;\n  /** Balance amount, shown with 2 decimals. */\n  balance: number;\n  /** Text placed before the balance and change amounts. Default: \"$\" */\n  balancePrefix?: string;\n  /** Initial balance change shown in the pill before any live change. */\n  defaultChange?: number;\n  /** Start with the balance hidden behind dots. */\n  defaultBalanceHidden?: boolean;\n  /** Called when the Send action is pressed. */\n  onSend?: () => void;\n  /** Called when the Deposit action is pressed. */\n  onDeposit?: () => void;\n  /** Called when the Swap action is pressed. */\n  onSwap?: () => void;\n  /** Called when the Buy action is pressed. */\n  onBuy?: () => void;\n  /** Placeholder for the search input. Defaults to the `searchPlaceholder` label. */\n  searchPlaceholder?: string;\n  /** Recent searches shown in the expanded search panel. */\n  searchRecent?: string[];\n  /** Called with the search text as the user types or picks a recent search. */\n  onSearchChange?: (value: string) => void;\n  /** Called with the trimmed query on Enter, or with a picked recent search. */\n  onSearchSubmit?: (value: string) => void;\n  /** Show an unread pulse on the notifications bell. */\n  hasNotifications?: boolean;\n  /** Called when the notifications bell is pressed. */\n  onNotifications?: () => void;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n"},{"path":"components/motion/action-swap.tsx","type":"util","content":"\"use client\";\n\nimport { AnimatePresence, type HTMLMotionProps, motion, useReducedMotion, type Variants } from \"motion/react\";\nimport type { ReactNode } from \"react\";\nimport { useState } from \"react\";\nimport { EASE_OUT, SPRING_LAYOUT, SPRING_PRESS, SPRING_SWAP } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ActionSwapItem = {\n  /** Unique key, used as the button's value. */\n  id: string;\n  /** Text shown on the button while this item is active. Hidden when `iconOnly`. */\n  label: ReactNode;\n  /** Icon shown before the label while this item is active. */\n  icon?: ReactNode;\n  /** Accessible name while active. Falls back to a string label when `iconOnly`. */\n  ariaLabel?: string;\n};\n\nexport type ActionSwapButtonVariant = \"primary\" | \"secondary\" | \"outline\" | \"ghost\";\nexport type ActionSwapButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\nexport type ActionSwapAnimation = \"blur\" | \"roll\" | \"cascade\";\n\n/** Animations with a single-element variant set (cascade animates per letter). */\ntype CoreAnimation = \"blur\" | \"roll\";\n\nexport interface ActionSwapButtonProps extends Omit<\n  HTMLMotionProps<\"button\">,\n  \"children\" | \"onChange\"\n> {\n  /** States the button steps through, each with a label and optional icon. */\n  items: ActionSwapItem[];\n  /** The id of the shown item, for controlled use. */\n  value?: string;\n  /** The initial item id when uncontrolled. Default: the first item. */\n  defaultValue?: string;\n  /** Called with the next item's id and the item when a press advances it. */\n  onValueChange?: (value: string, item: ActionSwapItem) => void;\n  /** Visual style of the button. Default: \"secondary\" */\n  variant?: ActionSwapButtonVariant;\n  /** Button height and padding. Default: \"md\" */\n  size?: ActionSwapButtonSize;\n  /** How the label and icon swap between items. Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Show only the icon and use the label as the accessible name. Default: true for size \"icon\" */\n  iconOnly?: boolean;\n  /** Advance to the next item on each press, wrapping at the end. Default: true */\n  cycle?: boolean;\n}\n\nexport interface ActionSwapTextProps {\n  /** Key for the current text; a new value plays the swap. */\n  value: string;\n  children: ReactNode;\n  /** How the old text leaves and the new text enters. Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n\nexport interface ActionSwapIconProps {\n  /** Key for the current icon; a new value plays the swap. */\n  value: string;\n  children: ReactNode;\n  /** How the old icon leaves and the new one enters. \"cascade\" plays as \"roll\". Default: \"blur\" */\n  animation?: ActionSwapAnimation;\n  /** Classes merged onto the root element. */\n  className?: string;\n}\n\n// The arriving layer springs in, so a second press mid-swap bends it toward\n// the new target instead of restarting. The leaving layer is a little quicker,\n// still long enough to cross the arrival so the swap reads as one morph.\nconst BLUR_TRANSITION = SPRING_SWAP;\nconst BLUR_EXIT_TRANSITION = { duration: 0.16, ease: EASE_OUT } as const;\nconst ROLL_TRANSITION = SPRING_SWAP;\nconst ROLL_EXIT_TRANSITION = { duration: 0.14, ease: EASE_OUT } as const;\n// A light blur softens the crossing without smearing small glyphs.\nconst SWAP_BLUR = \"blur(2px)\";\nconst ROLL_BLUR = \"blur(3px)\";\n\n// Cascade rolls the label one letter at a time, left to right. The leaving\n// and landing strings overlap as independent layers (no shared cells), so\n// proportional glyph widths never jitter. Exits cascade at half the enter\n// stagger so the tail of the old label lingers briefly.\nconst CASCADE_STAGGER = 0.025;\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n  initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n  animate: (delay: number = 0) => ({\n    opacity: 1,\n    y: \"0%\",\n    filter: \"blur(0px)\",\n    transition: { ...SPRING_SWAP, delay },\n  }),\n  exit: (delay: number = 0) => ({\n    opacity: 0,\n    y: \"-105%\",\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n  }),\n};\n\nconst TEXT_VARIANTS: Record<CoreAnimation, Variants> = {\n  blur: {\n    initial: { opacity: 0, scale: 0.9, filter: SWAP_BLUR },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      filter: \"blur(0px)\",\n      transition: BLUR_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      scale: 0.96,\n      filter: SWAP_BLUR,\n      transition: BLUR_EXIT_TRANSITION,\n    },\n  },\n  roll: {\n    initial: { opacity: 0, y: \"90%\", filter: ROLL_BLUR },\n    animate: {\n      opacity: 1,\n      y: \"0%\",\n      filter: \"blur(0px)\",\n      transition: ROLL_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      y: \"-90%\",\n      filter: ROLL_BLUR,\n      transition: ROLL_EXIT_TRANSITION,\n    },\n  },\n};\n\nconst ICON_VARIANTS: Record<CoreAnimation, Variants> = {\n  blur: {\n    initial: { opacity: 0, scale: 0.25, filter: SWAP_BLUR },\n    animate: {\n      opacity: 1,\n      scale: 1,\n      filter: \"blur(0px)\",\n      transition: BLUR_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      scale: 0.25,\n      filter: SWAP_BLUR,\n      transition: BLUR_EXIT_TRANSITION,\n    },\n  },\n  roll: {\n    initial: { opacity: 0, y: 12, filter: ROLL_BLUR },\n    animate: {\n      opacity: 1,\n      y: 0,\n      filter: \"blur(0px)\",\n      transition: ROLL_TRANSITION,\n    },\n    exit: {\n      opacity: 0,\n      y: -12,\n      filter: ROLL_BLUR,\n      transition: ROLL_EXIT_TRANSITION,\n    },\n  },\n};\n\nconst VARIANT_CLASS: Record<ActionSwapButtonVariant, string> = {\n  primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n  secondary: \"border border-border bg-card text-foreground hover:border-border\",\n  outline: \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n  ghost: \"text-muted-foreground hover:bg-muted/60 hover:text-foreground\",\n};\n\nconst SIZE_CLASS: Record<ActionSwapButtonSize, string> = {\n  sm: \"h-8 gap-1.5 rounded-full px-3 text-xs\",\n  md: \"h-10 gap-2 rounded-full px-4 text-sm\",\n  lg: \"h-12 gap-2.5 rounded-full px-5 text-base\",\n  icon: \"h-10 w-10 rounded-full\",\n};\n\nexport function ActionSwapText({\n  value,\n  children,\n  animation = \"blur\",\n  className,\n}: ActionSwapTextProps) {\n  const reduce = useReducedMotion();\n\n  // Cascade needs a plain string to split into letters; non-string content\n  // and reduced motion fall back to the closest single-element animation.\n  const label = typeof children === \"string\" ? children : null;\n  const cascade = animation === \"cascade\" && label !== null && !reduce;\n  const coreAnimation: CoreAnimation =\n    animation === \"cascade\" ? \"roll\" : animation;\n\n  return (\n    <span\n      className={cn(\n        \"relative -my-[0.08em] inline-block max-w-full whitespace-nowrap py-[0.08em] align-bottom\",\n        className,\n      )}\n      style={{\n        clipPath: \"inset(0 -999px)\",\n        WebkitClipPath: \"inset(0 -999px)\",\n      }}\n    >\n      <span\n        aria-hidden\n        className=\"invisible inline-block whitespace-nowrap\"\n      >\n        {cascade\n          ? label.split(\"\").map((char, index) => (\n              <span\n                // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                key={index}\n                className=\"inline-block whitespace-pre\"\n              >\n                {char}\n              </span>\n            ))\n          : children}\n      </span>\n      {cascade ? (\n        <>\n          {/* Letters are decorative fragments; readers get the whole label. */}\n          <span className=\"sr-only\">{label}</span>\n          <AnimatePresence initial={false}>\n            <motion.span\n              key={`cascade-${value}`}\n              aria-hidden\n              initial=\"initial\"\n              animate=\"animate\"\n              exit=\"exit\"\n              className=\"absolute left-0 top-[0.08em] inline-block whitespace-pre\"\n            >\n              {label.split(\"\").map((char, i) => (\n                <motion.span\n                  // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity - the letter at a position is exactly what rolls.\n                  key={i}\n                  custom={i * CASCADE_STAGGER}\n                  variants={CASCADE_LETTER_VARIANTS}\n                  // Own states: a label that swaps away and straight back\n                  // re-enters mid-exit, and only owned targets are restored.\n                  initial=\"initial\"\n                  animate=\"animate\"\n                  exit=\"exit\"\n                  className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n                >\n                  {char}\n                </motion.span>\n              ))}\n            </motion.span>\n          </AnimatePresence>\n        </>\n      ) : (\n        <AnimatePresence initial={false}>\n          <motion.span\n            key={`${animation}-${value}`}\n            variants={TEXT_VARIANTS[coreAnimation]}\n            initial={reduce ? false : \"initial\"}\n            animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n            exit={reduce ? undefined : \"exit\"}\n            // Truncation lives on the layer that holds the text - the layer\n            // moves as a whole, so clipping it never eats the roll.\n            className=\"absolute left-0 top-[0.08em] inline-block max-w-full truncate will-change-[opacity,filter,transform]\"\n          >\n            {children}\n          </motion.span>\n        </AnimatePresence>\n      )}\n    </span>\n  );\n}\n\nexport function ActionSwapIcon({\n  value,\n  children,\n  animation = \"blur\",\n  className,\n}: ActionSwapIconProps) {\n  const reduce = useReducedMotion();\n  // Icons are single elements - cascade maps to its closest motion, roll.\n  const coreAnimation: CoreAnimation =\n    animation === \"cascade\" ? \"roll\" : animation;\n\n  return (\n    <span className={cn(\"relative inline-grid shrink-0 place-items-center overflow-hidden\", className)}>\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        <motion.span\n          key={`${animation}-${value}`}\n          aria-hidden\n          variants={ICON_VARIANTS[coreAnimation]}\n          initial={reduce ? false : \"initial\"}\n          animate={reduce ? { opacity: 1, filter: \"blur(0px)\", scale: 1, y: 0 } : \"animate\"}\n          exit={reduce ? undefined : \"exit\"}\n          className=\"col-start-1 row-start-1 inline-flex items-center justify-center will-change-[opacity,filter,transform]\"\n        >\n          {children}\n        </motion.span>\n      </AnimatePresence>\n    </span>\n  );\n}\n\nexport function ActionSwapButton({\n  items,\n  value,\n  defaultValue,\n  onValueChange,\n  variant = \"secondary\",\n  size = \"md\",\n  animation = \"blur\",\n  iconOnly = size === \"icon\",\n  cycle = true,\n  className,\n  disabled,\n  onClick,\n  style,\n  ...rest\n}: ActionSwapButtonProps) {\n  const reduce = useReducedMotion();\n  const [internalValue, setInternalValue] = useState(defaultValue ?? items[0]?.id);\n  const currentValue = value ?? internalValue;\n  const activeIndex = Math.max(0, items.findIndex((item) => item.id === currentValue));\n  const activeItem = items[activeIndex] ?? items[0];\n  const hasIcon = items.some((item) => item.icon);\n  const nextItem = cycle && items.length > 0 ? items[(activeIndex + 1) % items.length] : undefined;\n\n  if (!activeItem) return null;\n\n  const accessibleLabel = activeItem.ariaLabel ?? (iconOnly && typeof activeItem.label === \"string\" ? activeItem.label : undefined);\n  const layoutTransition = reduce ? { duration: 0 } : SPRING_LAYOUT;\n\n  return (\n    <motion.button\n      type=\"button\"\n      disabled={disabled}\n      // A label of a different length resizes the button: glide the width on\n      // the soft layout spring, and only when the value changes, so unrelated\n      // page reflow never animates the button.\n      layout\n      layoutDependency={activeItem.id}\n      whileTap={reduce || disabled ? undefined : { scale: 0.97 }}\n      transition={{ ...SPRING_PRESS, layout: layoutTransition }}\n      // Layout animations only correct a radius set inline.\n      style={{ borderRadius: 9999, ...style }}\n      className={cn(\n        \"inline-flex items-center justify-center overflow-hidden font-medium transition-colors\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        VARIANT_CLASS[variant],\n        SIZE_CLASS[size],\n        className,\n      )}\n      aria-label={accessibleLabel}\n      onClick={(event) => {\n        onClick?.(event);\n        if (event.defaultPrevented || disabled || !cycle || !nextItem) return;\n        if (value === undefined) setInternalValue(nextItem.id);\n        onValueChange?.(nextItem.id, nextItem);\n      }}\n      {...rest}\n    >\n      {/* Position-only layout keeps the contents from stretching with the\n          button while its width glides. */}\n      {hasIcon ? (\n        <motion.span\n          layout=\"position\"\n          layoutDependency={activeItem.id}\n          transition={layoutTransition}\n          className=\"inline-flex shrink-0\"\n        >\n          <ActionSwapIcon value={activeItem.id} animation={animation} className=\"h-4 w-4\">\n            {activeItem.icon ?? null}\n          </ActionSwapIcon>\n        </motion.span>\n      ) : null}\n      {!iconOnly ? (\n        <motion.span\n          layout=\"position\"\n          layoutDependency={activeItem.id}\n          transition={layoutTransition}\n          className=\"inline-flex min-w-0 max-w-full\"\n        >\n          <ActionSwapText value={activeItem.id} animation={animation}>\n            {activeItem.label}\n          </ActionSwapText>\n        </motion.span>\n      ) : null}\n    </motion.button>\n  );\n}\n"},{"path":"components/motion/button/index.tsx","type":"util","content":"export type {\n  ButtonLinkProps,\n  ButtonProps,\n  ButtonSize,\n  ButtonVariant,\n} from \"./base\";\nexport { Button, ButtonLink } from \"./base\";\nexport type { MagneticButtonProps } from \"./magnetic\";\nexport { MagneticButton } from \"./magnetic\";\nexport type { MetallicButtonProps } from \"./metallic\";\nexport { MetallicButton } from \"./metallic\";\nexport type {\n  ButtonState,\n  StatefulButtonMessages,\n  StatefulButtonProps,\n} from \"./stateful\";\nexport { StatefulButton, statefulButtonMessages } from \"./stateful\";\n"},{"path":"lib/i18n.tsx","type":"util","content":"\"use client\";\n\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useMemo,\n} from \"react\";\n\n/**\n * A component's messages. Plain strings with `{name}` placeholders, so a\n * dictionary stays JSON-serializable and can be passed from a server layout.\n * There are no plural forms: write messages that read correctly for any count.\n */\nexport type Messages = Record<string, string>;\n\n/** A language file: component namespace → any subset of that component's messages. */\nexport type LocaleMessages = Record<string, Partial<Messages>>;\n\ntype LocaleContextValue = {\n  locale?: string;\n  messages: LocaleMessages;\n};\n\nconst NO_MESSAGES: LocaleMessages = {};\n\nconst LocaleContext = createContext<LocaleContextValue>({ messages: NO_MESSAGES });\n\n/** Without a locale, digits stay plain so server and client render the same text. */\nexport function formatNumber(value: number, locale?: string) {\n  return locale ? new Intl.NumberFormat(locale).format(value) : String(value);\n}\n\nexport interface LocaleProviderProps {\n  /** BCP 47 tag, e.g. `de`, `pt-BR`. Drives `Intl` number formatting. */\n  locale: string;\n  /**\n   * Component namespace → translated strings. Missing keys fall back to English.\n   * Pass a stable object (a module constant, imported JSON or a memoized value):\n   * a new object each render gives every translated component a new `t`.\n   */\n  messages?: LocaleMessages;\n  children: ReactNode;\n}\n\nexport function LocaleProvider({ locale, messages = NO_MESSAGES, children }: LocaleProviderProps) {\n  const value = useMemo(() => ({ locale, messages }), [locale, messages]);\n  return <LocaleContext.Provider value={value}>{children}</LocaleContext.Provider>;\n}\n\nexport function useLocale(): { locale?: string } {\n  return { locale: useContext(LocaleContext).locale };\n}\n\n/**\n * Resolves a component's strings: `labels` prop, then the provider's\n * messages for `namespace`, then the component's English `defaults`.\n * Numbers passed as values are formatted for the provider's locale.\n */\nexport function useMessages<T extends Messages>(\n  namespace: string,\n  defaults: T,\n  labels?: Partial<T>,\n) {\n  const { locale, messages } = useContext(LocaleContext);\n  const provided = messages[namespace];\n  // Inline `labels={{ … }}` is a new object every render. Keying it by content\n  // keeps `t` one identity until a label changes, so effects and memos that\n  // depend on `t` don't re-run per render, and render-time reads never lag.\n  const labelsKey = labels ? JSON.stringify(labels) : \"\";\n  const stableLabels = useMemo(\n    () => (labelsKey ? (JSON.parse(labelsKey) as Partial<T>) : undefined),\n    [labelsKey],\n  );\n\n  return useCallback(\n    (key: keyof T & string, values?: Record<string, string | number>) => {\n      const template = stableLabels?.[key] ?? provided?.[key] ?? defaults[key];\n      if (!values) return template;\n      return template.replace(/\\{(\\w+)\\}/g, (match, name: string) => {\n        const value = values[name];\n        if (value === undefined) return match;\n        return typeof value === \"number\" ? formatNumber(value, locale) : value;\n      });\n    },\n    [defaults, stableLabels, locale, provided],\n  );\n}\n"},{"path":"lib/utils.ts","type":"util","content":"import { clsx, type ClassValue } from \"clsx\"\nimport { twMerge } from \"tailwind-merge\"\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs))\n}\n"},{"path":"components/motion/wallet-card/account-avatar.tsx","type":"util","content":"import { cn } from \"@/lib/utils\";\nimport type { WalletAccount } from \"./types\";\nimport { diceBearGlassUrl } from \"./utils\";\n\nexport function AccountAvatar({\n  account,\n  className,\n}: {\n  account: WalletAccount;\n  className?: string;\n}) {\n  if (account.avatar) return <>{account.avatar}</>;\n  return (\n    <img\n      src={diceBearGlassUrl(account.id || account.address)}\n      alt={account.name}\n      className={cn(\"h-7 w-7 shrink-0 rounded-full bg-muted\", className)}\n    />\n  );\n}\n"},{"path":"components/motion/wallet-card/constants.ts","type":"util","content":"import type { Transition, Variants } from \"motion/react\";\nimport { SPRING_MORPH } from \"@/lib/ease\";\n\n// Trigger box grows into the full-width panel and back, one shared surface.\nexport const MORPH: Transition = SPRING_MORPH;\n\nexport const LIST: Variants = {\n  hidden: {},\n  show: { transition: { staggerChildren: 0.035, delayChildren: 0.12 } },\n};\n\nexport const ITEM: Variants = {\n  hidden: { opacity: 0, y: -6, filter: \"blur(3px)\" },\n  show: { opacity: 1, y: 0, filter: \"blur(0px)\" },\n};\n\n// Shared padding for the account trigger + panel header so the avatar/name stay\n// put as the box morphs - the panel reads as the trigger itself growing open.\nexport const HEAD = \"flex items-center gap-2 px-2 py-1.5 text-left\";\n"},{"path":"components/motion/wallet-card/copy-button.tsx","type":"util","content":"\"use client\";\n\nimport { Check, Copy } from \"lucide-react\";\nimport { useEffect, useRef, useState } from \"react\";\nimport { ActionSwapIcon } from \"@/components/motion/action-swap\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { cn } from \"@/lib/utils\";\nimport { type WalletCardMessages, walletCardMessages } from \"./messages\";\n\n/**\n * Copies `value` to the clipboard and swaps the copy icon for a check via the\n * library's ActionSwapIcon. Stops click propagation so it can sit inside a\n * selectable row.\n */\nexport function CopyButton({\n  value,\n  className,\n  labels,\n}: {\n  value: string;\n  className?: string;\n  labels?: Partial<WalletCardMessages>;\n}) {\n  const t = useMessages(\"walletCard\", walletCardMessages, labels);\n  const [copied, setCopied] = useState(false);\n  const timer = useRef<number | undefined>(undefined);\n\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  const copy = async () => {\n    try {\n      await navigator.clipboard.writeText(value);\n    } catch {\n      // clipboard may be unavailable (insecure context) - swap anyway\n    }\n    setCopied(true);\n    window.clearTimeout(timer.current);\n    timer.current = window.setTimeout(() => setCopied(false), 1400);\n  };\n\n  return (\n    <button\n      type=\"button\"\n      aria-label={copied ? t(\"copied\") : t(\"copyAddress\")}\n      onClick={(e) => {\n        e.stopPropagation();\n        copy();\n      }}\n      className={cn(\n        \"inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-muted-foreground outline-none transition-colors hover:bg-muted hover:text-foreground\",\n        className,\n      )}\n    >\n      <ActionSwapIcon\n        value={copied ? \"check\" : \"copy\"}\n        animation=\"cascade\"\n        className=\"h-3.5 w-3.5\"\n      >\n        {copied ? (\n          <Check className=\"h-3.5 w-3.5 text-emerald-500\" />\n        ) : (\n          <Copy className=\"h-3.5 w-3.5\" />\n        )}\n      </ActionSwapIcon>\n    </button>\n  );\n}\n"},{"path":"components/motion/wallet-card/utils.ts","type":"util","content":"export function diceBearGlassUrl(seed: string) {\n  return `https://api.dicebear.com/9.x/glass/svg?seed=${encodeURIComponent(seed)}`;\n}\n\nexport function truncateAddress(address: string) {\n  return address.length > 12\n    ? `${address.slice(0, 6)}…${address.slice(-4)}`\n    : address;\n}\n"},{"path":"lib/hooks/use-dismiss.ts","type":"util","content":"\"use client\";\n\nimport { type RefObject, useEffect, useLayoutEffect, useRef } from \"react\";\nimport {\n  inLayerAbove,\n  inOtherLayer,\n  type Layer,\n  openLayer,\n  ownsEscape,\n} from \"@/lib/layers\";\n\n/**\n * What the dismissing gesture does to the control it landed on.\n *\n * `\"pass-through\"` is the platform norm (native popover light-dismiss): the\n * tap closes the overlay *and* activates whatever was under it. Use\n * `\"consume\"` where the open overlay sits over or beside controls that would\n * be costly to trigger by accident - the dismissal then swallows the\n * activation too, so the gesture only closes.\n */\nexport type DismissBehavior = \"pass-through\" | \"consume\";\n\n/** What closed the overlay: Escape, a pointerdown outside it, or focus leaving it. */\nexport type DismissReason = \"escape\" | \"pointer\" | \"focus\";\n\nexport interface DismissOptions {\n  /** Default `\"pass-through\"`. */\n  behavior?: DismissBehavior;\n  /** Dismiss on Escape as well. Default true. */\n  escape?: boolean;\n  /** Dismiss when focus moves outside, as a combobox does on Tab. Default false. */\n  focusOutside?: boolean;\n  /**\n   * Dismiss on a pointerdown outside. Default true. Turn it off for an overlay\n   * whose own backdrop handles presses and only needs Escape and layering.\n   */\n  outsidePress?: boolean;\n  /** Return true for an outside target that should *not* dismiss. */\n  ignore?: (target: Element) => boolean;\n}\n\n// preventDefault on pointerdown does not suppress the click that follows, so\n// consuming a gesture means swallowing that click itself. The swallower\n// deliberately outlives the effect that installed it - the dismissal it\n// belongs to has already unmounted or re-rendered by the time the click lands.\n// It releases on that click, or on the next gesture if the pointer is dragged\n// away and no click ever arrives, so it can never eat a later one. A keydown\n// releases it too: a gesture that ends with neither a click nor a cancel would\n// otherwise leave it armed, and the click Enter synthesizes on some focused\n// control is not the one this dismissal was owed.\nfunction consumeActivation(source: Event) {\n  const swallow = (event: MouseEvent) => {\n    event.preventDefault();\n    event.stopPropagation();\n    release();\n  };\n  const restart = (event: Event) => {\n    if (event !== source) release();\n  };\n  const release = () => {\n    window.removeEventListener(\"click\", swallow, true);\n    window.removeEventListener(\"pointerdown\", restart, true);\n    window.removeEventListener(\"pointercancel\", restart, true);\n    window.removeEventListener(\"keydown\", release, true);\n  };\n  window.addEventListener(\"click\", swallow, true);\n  window.addEventListener(\"pointerdown\", restart, true);\n  window.addEventListener(\"pointercancel\", restart, true);\n  window.addEventListener(\"keydown\", release, true);\n}\n\n/**\n * Close an open overlay on Escape or a pointerdown outside `ref`. Pass `null`\n * for `ref` when what counts as inside isn't one element, and say so with\n * `ignore` instead.\n *\n * The pointerdown listener is capture-phase: a bubble-phase one is blinded by\n * any handler in between that stops propagation, and an overlay cannot know\n * what it is layered over.\n *\n * Each open dismissal is a layer in `lib/layers.ts`, so only the innermost\n * open overlay answers Escape (a menu inside a drawer closes, the drawer\n * stays), and a drawer's focus trap leaves focus in a menu it portaled out.\n */\nexport function useDismiss(\n  open: boolean,\n  onDismiss: (reason: DismissReason) => void,\n  ref: RefObject<HTMLElement | SVGElement | null> | null,\n  {\n    behavior = \"pass-through\",\n    escape: dismissOnEscape = true,\n    focusOutside = false,\n    outsidePress = true,\n    ignore,\n  }: DismissOptions = {},\n) {\n  // Read through refs, so a callback rebuilt each render neither re-binds the\n  // listeners nor moves this layer to the top of the stack.\n  const dismissRef = useRef(onDismiss);\n  const ignoreRef = useRef(ignore);\n  useLayoutEffect(() => {\n    dismissRef.current = onDismiss;\n    ignoreRef.current = ignore;\n  });\n\n  useEffect(() => {\n    if (!open) return;\n    const inside = (target: Node) =>\n      Boolean(ref?.current?.contains(target)) ||\n      (target instanceof Element && Boolean(ignoreRef.current?.(target)));\n    const layer: Layer = { contains: inside, escape: dismissOnEscape };\n    const closeLayer = openLayer(layer);\n    const onKey = (event: KeyboardEvent) => {\n      if (!dismissOnEscape || event.key !== \"Escape\" || !ownsEscape(layer, event)) return;\n      event.preventDefault();\n      dismissRef.current(\"escape\");\n    };\n    const onPointer = (event: PointerEvent) => {\n      const target = event.target as Element | null;\n      if (!target || inside(target)) return;\n      // A press in an overlay opened on top of this one (a tooltip or menu\n      // portaled to the body) belongs to that overlay, not outside this one.\n      if (inLayerAbove(layer, target)) return;\n      // Outside this overlay, but inside another open one: the gesture is\n      // that overlay's to answer, and swallowing its click from behind would\n      // cost the user the control they actually aimed at.\n      if (behavior === \"consume\" && !inOtherLayer(layer, target, { traps: false })) {\n        consumeActivation(event);\n      }\n      dismissRef.current(\"pointer\");\n    };\n    const onFocus = (event: FocusEvent) => {\n      const target = event.target;\n      if (target instanceof Node && !inside(target)) dismissRef.current(\"focus\");\n    };\n    window.addEventListener(\"keydown\", onKey);\n    if (outsidePress) window.addEventListener(\"pointerdown\", onPointer, true);\n    if (focusOutside) window.addEventListener(\"focusin\", onFocus);\n    return () => {\n      closeLayer();\n      window.removeEventListener(\"keydown\", onKey);\n      window.removeEventListener(\"pointerdown\", onPointer, true);\n      window.removeEventListener(\"focusin\", onFocus);\n    };\n  }, [open, ref, behavior, dismissOnEscape, focusOutside, outsidePress]);\n}\n"},{"path":"lib/ease.ts","type":"util","content":"// Shared motion tokens. Easing curves mirror the CSS custom properties in\n// globals.css; springs are the canonical physics used across components.\n// Strong custom variants - defaults like `ease-in`/`ease-out` feel weak.\n\nexport const EASE_OUT = [0.16, 1, 0.3, 1] as const;\n/** Accelerating curve for things that fall (a dropped ball, a toppled block). Not for UI entrances. */\nexport const EASE_IN = [0.55, 0, 1, 0.45] as const;\nexport const EASE_IN_OUT = [0.77, 0, 0.175, 1] as const;\nexport const EASE_DRAWER = [0.32, 0.72, 0, 1] as const;\n\n/** CSS string form of EASE_OUT for inline style transitions. */\nexport const EASE_OUT_CSS = \"cubic-bezier(0.16, 1, 0.3, 1)\";\n\n/** Press feedback on buttons and other tappable surfaces. */\nexport const SPRING_PRESS = {\n  type: \"spring\",\n  stiffness: 500,\n  damping: 30,\n  mass: 0.6,\n} as const;\n\n/** Content swaps - label/icon slots trading places inside a control. */\nexport const SPRING_SWAP = {\n  type: \"spring\",\n  stiffness: 460,\n  damping: 30,\n  mass: 0.55,\n} as const;\n\n/** Overlay panel entrances - modals and sheets summoned by pointer. */\nexport const SPRING_PANEL = {\n  type: \"spring\",\n  stiffness: 420,\n  damping: 40,\n  mass: 0.5,\n} as const;\n\n/** Shared-layout glides - pills, indicators and panels morphing between positions. */\nexport const SPRING_LAYOUT = {\n  type: \"spring\",\n  stiffness: 360,\n  damping: 32,\n  mass: 0.6,\n} as const;\n\n/** Cursor-follow physics for decorative mouse tracking (magnetic, tilt, dock). */\nexport const SPRING_MOUSE = {\n  stiffness: 200,\n  damping: 15,\n  mass: 0.3,\n} as const;\n\n/** Dragged handles and fills (sliders) - critically damped `useSpring` config,\n * so the value follows the pointer butterily and never rebounds off an end. */\nexport const SPRING_GLIDE = {\n  stiffness: 700,\n  damping: 50,\n  mass: 0.5,\n} as const;\n\n/** Shared-surface morphs: a trigger growing into its panel and back on one\n * weighted spring, so opening and closing travel the same path. */\nexport const SPRING_MORPH = {\n  type: \"spring\",\n  duration: 0.5,\n  bounce: 0.22,\n} as const;\n"},{"path":"components/motion/button/base.tsx","type":"util","content":"\"use client\";\n\nimport {\n  AnimatePresence,\n  type HTMLMotionProps,\n  motion,\n  useReducedMotion,\n} from \"motion/react\";\nimport {\n  forwardRef,\n  type MouseEvent,\n  type PointerEvent,\n  type ReactNode,\n  useCallback,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT, SPRING_PRESS } from \"@/lib/ease\";\nimport { useSound } from \"@/lib/sound\";\nimport { pressSound } from \"@/lib/sounds/press\";\nimport { cn } from \"@/lib/utils\";\n\nexport type ButtonVariant = \"primary\" | \"secondary\" | \"ghost\" | \"outline\";\nexport type ButtonSize = \"sm\" | \"md\" | \"lg\" | \"icon\";\n\nexport interface ButtonProps extends Omit<\n  HTMLMotionProps<\"button\">,\n  \"children\"\n> {\n  /** Visual style: filled, card, ghost or outline. Default: \"primary\" */\n  variant?: ButtonVariant;\n  /** Height and padding; \"icon\" is a square icon-only button. Default: \"md\" */\n  size?: ButtonSize;\n  /** Scale while pressed. Default 0.97: subtle, so the press reads as feedback, not a squash. */\n  pressScale?: number;\n  /** Spawn a Material-style ripple from the press point. Off by default. */\n  ripple?: boolean;\n  /** Play a soft press sound. Off by default; a `SoundProvider` can mute it app-wide. */\n  sound?: boolean;\n  children?: ReactNode;\n}\n\nexport interface ButtonLinkProps extends Omit<\n  HTMLMotionProps<\"a\">,\n  \"children\"\n> {\n  /** Visual style: filled, card, ghost or outline. Default: \"primary\" */\n  variant?: ButtonVariant;\n  /** Height and padding; \"icon\" is a square icon-only link. Default: \"md\" */\n  size?: ButtonSize;\n  /** Scale while pressed. Default 0.97. */\n  pressScale?: number;\n  children?: ReactNode;\n}\n\ntype Ripple = { id: number; x: number; y: number; size: number };\n\nconst VARIANT_CLASS: Record<ButtonVariant, string> = {\n  primary: \"bg-primary text-primary-foreground hover:bg-primary/90\",\n  secondary: \"border border-border bg-card text-foreground hover:border-border\",\n  ghost: \"text-muted-foreground hover:text-foreground hover:bg-muted/60\",\n  outline:\n    \"border border-border bg-transparent text-foreground hover:bg-muted/60\",\n};\n\nconst SIZE_CLASS: Record<ButtonSize, string> = {\n  sm: \"h-8 px-3 text-xs gap-1.5 rounded-full\",\n  md: \"h-10 px-5 text-sm gap-2 rounded-full\",\n  lg: \"h-12 px-6 text-base gap-2 rounded-full\",\n  icon: \"h-8 w-8 rounded-full\",\n};\n\nexport const Button = forwardRef<HTMLButtonElement, ButtonProps>(\n  function Button(\n    {\n      variant = \"primary\",\n      size = \"md\",\n      pressScale = 0.97,\n      ripple = false,\n      sound = false,\n      className,\n      children,\n      onPointerDown,\n      onClick,\n      ...rest\n    },\n    ref,\n  ) {\n    const reduce = useReducedMotion();\n    const [ripples, setRipples] = useState<Ripple[]>([]);\n    const nextId = useRef(0);\n    const play = useSound(pressSound, { enabled: sound });\n\n    const handleClick = useCallback(\n      (event: MouseEvent<HTMLButtonElement>) => {\n        // `detail` is 0 for a click the keyboard made; a pointer press already sounded.\n        if (event.detail === 0) play();\n        onClick?.(event);\n      },\n      [play, onClick],\n    );\n\n    const handlePointerDown = useCallback(\n      (event: PointerEvent<HTMLButtonElement>) => {\n        play();\n        if (ripple && !reduce) {\n          const rect = event.currentTarget.getBoundingClientRect();\n          const size = Math.max(rect.width, rect.height) * 2;\n          const id = nextId.current++;\n          setRipples((prev) => [\n            ...prev,\n            {\n              id,\n              x: event.clientX - rect.left,\n              y: event.clientY - rect.top,\n              size,\n            },\n          ]);\n        }\n        onPointerDown?.(event);\n      },\n      [ripple, reduce, onPointerDown, play],\n    );\n\n    return (\n      // Hover changes colour only: a hover scale blurs the label, and buttons\n      // are hovered far too often for movement to earn its place.\n      <motion.button\n        ref={ref}\n        type=\"button\"\n        whileTap={reduce ? undefined : { scale: pressScale }}\n        transition={SPRING_PRESS}\n        onPointerDown={handlePointerDown}\n        onClick={handleClick}\n        className={cn(\n          \"inline-flex items-center justify-center font-medium select-none\",\n          \"transition-colors\",\n          \"disabled:pointer-events-none disabled:opacity-50\",\n          ripple && \"relative overflow-hidden\",\n          VARIANT_CLASS[variant],\n          SIZE_CLASS[size],\n          className,\n        )}\n        {...rest}\n      >\n        {ripple && !reduce ? (\n          <span className=\"pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]\">\n            <AnimatePresence>\n              {ripples.map((r) => (\n                <motion.span\n                  key={r.id}\n                  className=\"absolute rounded-full bg-current\"\n                  style={{\n                    left: r.x,\n                    top: r.y,\n                    width: r.size,\n                    height: r.size,\n                    x: \"-50%\",\n                    y: \"-50%\",\n                  }}\n                  initial={{ scale: 0.05, opacity: 0.3 }}\n                  animate={{ scale: 1, opacity: 0 }}\n                  exit={{ opacity: 0 }}\n                  transition={{ duration: 0.8, ease: EASE_OUT }}\n                  onAnimationComplete={() =>\n                    setRipples((prev) => prev.filter((x) => x.id !== r.id))\n                  }\n                />\n              ))}\n            </AnimatePresence>\n          </span>\n        ) : null}\n        {children}\n      </motion.button>\n    );\n  },\n);\n\nexport const ButtonLink = forwardRef<HTMLAnchorElement, ButtonLinkProps>(\n  function ButtonLink(\n    {\n      variant = \"primary\",\n      size = \"md\",\n      pressScale = 0.97,\n      className,\n      children,\n      ...rest\n    },\n    ref,\n  ) {\n    const reduce = useReducedMotion();\n\n    return (\n      <motion.a\n        ref={ref}\n        whileTap={reduce ? undefined : { scale: pressScale }}\n        transition={SPRING_PRESS}\n        className={cn(\n          \"inline-flex items-center justify-center font-medium select-none\",\n          \"transition-colors\",\n          VARIANT_CLASS[variant],\n          SIZE_CLASS[size],\n          className,\n        )}\n        {...rest}\n      >\n        {children}\n      </motion.a>\n    );\n  },\n);\n"},{"path":"components/motion/button/magnetic.tsx","type":"util","content":"\"use client\";\n\nimport { forwardRef } from \"react\";\nimport { Magnetic } from \"../magnetic\";\nimport { Button, type ButtonProps } from \"./base\";\n\nexport interface MagneticButtonProps extends ButtonProps {\n  /** Magnetic pull strength. Default 0.25. */\n  strength?: number;\n  /** Class applied to the magnetic wrapper. */\n  magneticClassName?: string;\n}\n\nexport const MagneticButton = forwardRef<HTMLButtonElement, MagneticButtonProps>(function MagneticButton(\n  { strength = 0.25, magneticClassName, children, ...rest },\n  ref,\n) {\n  return (\n    <Magnetic strength={strength} className={magneticClassName}>\n      <Button ref={ref} {...rest}>\n        {children}\n      </Button>\n    </Magnetic>\n  );\n});\n"},{"path":"components/motion/button/metallic.tsx","type":"util","content":"\"use client\";\n\nimport { motion, useReducedMotion } from \"motion/react\";\nimport { forwardRef, useState } from \"react\";\nimport { EASE_IN_OUT, EASE_OUT } from \"@/lib/ease\";\nimport { cn } from \"@/lib/utils\";\nimport { Button, type ButtonProps } from \"./base\";\n\nexport interface MetallicButtonProps extends Omit<\n  ButtonProps,\n  \"ripple\" | \"variant\"\n> {\n  /** Stops the traveling reflection while preserving the chrome rim. */\n  paused?: boolean;\n}\n\n// The rim and highlight drift separately so the material stays quiet and reflective.\nconst SILVER_DRIFT = {\n  duration: 8,\n  ease: EASE_IN_OUT,\n  repeat: Infinity,\n};\n\n// One quick sweep on hover. Leaving resets it instantly: both ends sit outside\n// the button, so the jump is invisible and no reverse sweep plays.\nconst CHROME_SHIMMER = {\n  duration: 0.9,\n  ease: EASE_OUT,\n};\nconst CHROME_RESET = { duration: 0 };\n\nexport const MetallicButton = forwardRef<\n  HTMLButtonElement,\n  MetallicButtonProps\n>(function MetallicButton(\n  {\n    size = \"md\",\n    paused = false,\n    className,\n    children,\n    onHoverStart,\n    onHoverEnd,\n    ...rest\n  },\n  ref,\n) {\n  const reduce = useReducedMotion();\n  const still = paused || Boolean(reduce);\n  const [hovered, setHovered] = useState(false);\n\n  return (\n    <Button\n      ref={ref}\n      variant=\"ghost\"\n      size={size}\n      onHoverStart={(event, info) => {\n        setHovered(true);\n        onHoverStart?.(event, info);\n      }}\n      onHoverEnd={(event, info) => {\n        setHovered(false);\n        onHoverEnd?.(event, info);\n      }}\n      className={cn(\n        \"group relative isolate overflow-hidden border-0 bg-transparent text-foreground\",\n        \"hover:bg-transparent hover:text-foreground\",\n        \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n        \"shadow-[0_8px_22px_rgba(0,0,0,0.16)]\",\n        size === \"icon\" && \"rounded-full\",\n        className,\n      )}\n      {...rest}\n    >\n      <motion.span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-y-0 left-[-18%] z-0 w-[136%] rounded-[inherit] bg-[linear-gradient(105deg,#111_0%,#737373_14%,#fafafa_26%,#525252_38%,#0a0a0a_50%,#a3a3a3_64%,#fff_75%,#404040_87%,#111_100%)]\"\n        animate={still ? undefined : { x: [\"0%\", \"13%\", \"0%\"] }}\n        transition={still ? undefined : SILVER_DRIFT}\n      />\n\n      <motion.span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-y-0 left-[-58%] z-[1] w-[52%] -skew-x-12 bg-[linear-gradient(90deg,transparent,rgba(255,255,255,0.5)_48%,transparent)] opacity-50 blur-[3px] mix-blend-screen\"\n        animate={still ? undefined : { x: hovered ? \"310%\" : \"0%\" }}\n        transition={still ? undefined : hovered ? CHROME_SHIMMER : CHROME_RESET}\n      />\n\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-[2px] z-[2] rounded-[inherit] bg-background transition-colors group-hover:bg-muted/40\"\n      />\n\n      <span\n        aria-hidden=\"true\"\n        className=\"pointer-events-none absolute inset-[2px] z-[3] rounded-[inherit] shadow-[inset_0_1px_0_rgba(255,255,255,0.28),inset_0_-1px_0_rgba(0,0,0,0.16)]\"\n      />\n\n      <span className=\"relative z-10 inline-flex items-center justify-center gap-2\">\n        {children}\n      </span>\n    </Button>\n  );\n});\n"},{"path":"components/motion/button/stateful.tsx","type":"util","content":"\"use client\";\n\nimport { Check, Loader2, X } from \"lucide-react\";\nimport {\n  AnimatePresence,\n  motion,\n  useReducedMotion,\n  type Variants,\n} from \"motion/react\";\nimport {\n  forwardRef,\n  type ReactNode,\n  useLayoutEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport { EASE_OUT, SPRING_SWAP } from \"@/lib/ease\";\nimport { useMessages } from \"@/lib/i18n\";\nimport { Button, type ButtonProps } from \"./base\";\n\nexport type ButtonState = \"idle\" | \"loading\" | \"success\" | \"error\";\n\n/** English defaults. Override per instance with `labels`, or app-wide with `LocaleProvider`. */\nexport const statefulButtonMessages = {\n  loading: \"Loading\",\n  success: \"Done\",\n  error: \"Try again\",\n};\n\nexport type StatefulButtonMessages = typeof statefulButtonMessages;\n\nexport interface StatefulButtonProps extends Omit<ButtonProps, \"children\"> {\n  /** Which state to show. Loading also disables the button. Default: \"idle\" */\n  state?: ButtonState;\n  children: ReactNode;\n  /** Text shown while loading. Default: \"Loading\" */\n  loadingText?: ReactNode;\n  /** Text shown on success. Default: \"Done\" */\n  successText?: ReactNode;\n  /** Text shown on error. Default: \"Try again\" */\n  errorText?: ReactNode;\n  /** Trailing icon shown only while idle. */\n  icon?: ReactNode;\n  /** Override any built-in string. */\n  labels?: Partial<StatefulButtonMessages>;\n}\n\nconst CASCADE_STAGGER = 0.025;\nconst ROLL_BLUR = \"blur(6px)\";\n\nconst CASCADE_LETTER_VARIANTS: Variants = {\n  initial: { opacity: 0, y: \"105%\", filter: ROLL_BLUR },\n  animate: (delay: number = 0) => ({\n    opacity: 1,\n    y: \"0%\",\n    filter: \"blur(0px)\",\n    transition: { ...SPRING_SWAP, delay },\n  }),\n  exit: (delay: number = 0) => ({\n    opacity: 0,\n    y: \"-105%\",\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT, delay: delay * 0.5 },\n  }),\n};\n\nconst ICON_VARIANTS: Variants = {\n  // Width collapses too, so the icon adds/removes its own space smoothly\n  // instead of popping the row width in a single frame.\n  initial: { opacity: 0, width: 0, scale: 0.7, filter: ROLL_BLUR },\n  animate: {\n    opacity: 1,\n    width: \"1.5rem\",\n    scale: 1,\n    filter: \"blur(0px)\",\n    transition: SPRING_SWAP,\n  },\n  exit: {\n    opacity: 0,\n    width: 0,\n    scale: 0.7,\n    filter: ROLL_BLUR,\n    transition: { duration: 0.16, ease: EASE_OUT },\n  },\n};\n\nfunction IconSlot({ keyId, children }: { keyId: string; children: ReactNode }) {\n  const reduce = useReducedMotion();\n  return (\n    <motion.span\n      key={keyId}\n      variants={ICON_VARIANTS}\n      initial={reduce ? { opacity: 0 } : \"initial\"}\n      animate={reduce ? { opacity: 1 } : \"animate\"}\n      exit={reduce ? { opacity: 0 } : \"exit\"}\n      transition={reduce ? { duration: 0.15 } : undefined}\n      className=\"inline-grid shrink-0 place-items-center overflow-hidden\"\n    >\n      {children}\n    </motion.span>\n  );\n}\n\nfunction TextSlot({\n  value,\n  children,\n}: {\n  value: string;\n  children: ReactNode;\n}) {\n  const reduce = useReducedMotion();\n  const measureRef = useRef<HTMLSpanElement>(null);\n  const [width, setWidth] = useState<number>();\n  const label = typeof children === \"string\" ? children : null;\n  const cascade = label !== null && !reduce;\n\n  // Measure strings with the same per-letter layout as the cascade. Measuring\n  // the whole string preserves kerning, which can make it narrower than the\n  // inline-block letters and clip the final glyph during the width animation.\n  useLayoutEffect(() => {\n    const nextWidth = measureRef.current?.offsetWidth;\n    if (!nextWidth) return;\n    setWidth((current) => (current === nextWidth ? current : nextWidth));\n  });\n\n  return (\n    <motion.span\n      initial={false}\n      animate={{ width }}\n      transition={reduce ? { duration: 0 } : SPRING_SWAP}\n      className=\"relative inline-block overflow-hidden whitespace-nowrap align-bottom\"\n    >\n      <span\n        ref={measureRef}\n        aria-hidden\n        className=\"invisible inline-block whitespace-nowrap\"\n      >\n        {cascade\n          ? label.split(\"\").map((char, index) => (\n              <span\n                // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                key={index}\n                className=\"inline-block whitespace-pre\"\n              >\n                {char}\n              </span>\n            ))\n          : children}\n      </span>\n\n      {cascade ? (\n        <>\n          <span className=\"sr-only\">{label}</span>\n          <AnimatePresence initial={false}>\n            <motion.span\n              key={`cascade-${value}`}\n              aria-hidden\n              initial=\"initial\"\n              animate=\"animate\"\n              exit=\"exit\"\n              className=\"absolute left-0 top-0 inline-block whitespace-pre\"\n            >\n              {label.split(\"\").map((char, index) => (\n                <motion.span\n                  // biome-ignore lint/suspicious/noArrayIndexKey: position is the slot identity.\n                  key={index}\n                  custom={index * CASCADE_STAGGER}\n                  variants={CASCADE_LETTER_VARIANTS}\n                  // Own states: a label that swaps away and straight back\n                  // re-enters mid-exit, and only owned targets are restored.\n                  initial=\"initial\"\n                  animate=\"animate\"\n                  exit=\"exit\"\n                  className=\"inline-block whitespace-pre will-change-[opacity,filter,transform]\"\n                >\n                  {char}\n                </motion.span>\n              ))}\n            </motion.span>\n          </AnimatePresence>\n        </>\n      ) : (\n        <AnimatePresence initial={false}>\n          <motion.span\n            key={`text-${value}`}\n            initial={reduce ? { opacity: 0 } : { opacity: 0, y: 14, filter: ROLL_BLUR }}\n            animate={reduce ? { opacity: 1 } : { opacity: 1, y: 0, filter: \"blur(0px)\" }}\n            exit={reduce ? { opacity: 0 } : { opacity: 0, y: -14, filter: ROLL_BLUR }}\n            transition={reduce ? { duration: 0.15 } : SPRING_SWAP}\n            className=\"absolute left-0 top-0 inline-block will-change-[opacity,filter,transform]\"\n          >\n            {children}\n          </motion.span>\n        </AnimatePresence>\n      )}\n    </motion.span>\n  );\n}\n\nexport const StatefulButton = forwardRef<HTMLButtonElement, StatefulButtonProps>(function StatefulButton(\n  {\n    state = \"idle\",\n    children,\n    loadingText,\n    successText,\n    errorText,\n    icon,\n    labels,\n    disabled,\n    ...rest\n  },\n  ref,\n) {\n  const t = useMessages(\"statefulButton\", statefulButtonMessages, labels);\n  const isBusy = state === \"loading\";\n  const stateText =\n    state === \"loading\"\n      ? (loadingText ?? t(\"loading\"))\n      : state === \"success\"\n        ? (successText ?? t(\"success\"))\n        : state === \"error\"\n        ? (errorText ?? t(\"error\"))\n        : children;\n  const textKey =\n    typeof stateText === \"string\" ? `${state}-${stateText}` : state;\n\n  return (\n    <Button ref={ref} disabled={disabled || isBusy} aria-busy={isBusy} {...rest}>\n      <span\n        aria-live=\"polite\"\n        className=\"relative inline-flex items-center justify-center overflow-hidden\"\n      >\n        <AnimatePresence initial={false}>\n          {state === \"loading\" ? (\n            <IconSlot keyId=\"loading-icon\">\n              <Loader2 className=\"h-4 w-4 animate-spin\" />\n            </IconSlot>\n          ) : null}\n          {state === \"success\" ? (\n            <IconSlot keyId=\"success-icon\">\n              <Check className=\"h-4 w-4\" />\n            </IconSlot>\n          ) : null}\n          {state === \"error\" ? (\n            <IconSlot keyId=\"error-icon\">\n              <X className=\"h-4 w-4\" />\n            </IconSlot>\n          ) : null}\n        </AnimatePresence>\n\n        <TextSlot value={textKey}>{stateText}</TextSlot>\n\n        <AnimatePresence initial={false}>\n          {state === \"idle\" && icon ? (\n            <IconSlot keyId=\"idle-icon\">{icon}</IconSlot>\n          ) : null}\n        </AnimatePresence>\n      </span>\n    </Button>\n  );\n});\n"},{"path":"lib/layers.ts","type":"util","content":"/**\n * Every open overlay on the page, innermost last: focus traps, modal scopes\n * and dismissable menus all register here. Overlays have no shared z-order to\n * consult, and a menu inside a drawer portals out of it, so this stack is how\n * they agree on who answers Escape and where focus may go.\n */\n\nexport interface Layer {\n  /** Whether `target` belongs to this layer (its panel, portals, trigger). */\n  contains: (target: Node) => boolean;\n  /** True for focus traps and modal scopes, which pull stray focus back. */\n  traps?: boolean;\n  /** False for a layer that ignores Escape, so the key reaches the one below. */\n  escape?: boolean;\n}\n\nconst stack: Layer[] = [];\n// The innermost layer when each Escape began, read before any handler runs,\n// so a layer that closes itself mid-event can't hand the key to the one below.\nconst escapeOwners = new WeakMap<Event, Layer | undefined>();\nlet listening = false;\n\nfunction innermostEscapeLayer() {\n  for (let index = stack.length - 1; index >= 0; index--) {\n    if (stack[index].escape !== false) return stack[index];\n  }\n  return undefined;\n}\n\nfunction recordEscapeOwner(event: KeyboardEvent) {\n  if (event.key === \"Escape\") escapeOwners.set(event, innermostEscapeLayer());\n}\n\n/** Registers an open layer. Call the returned function when it closes. */\nexport function openLayer(layer: Layer) {\n  if (!listening) {\n    document.addEventListener(\"keydown\", recordEscapeOwner, true);\n    listening = true;\n  }\n  stack.push(layer);\n  return () => {\n    const index = stack.indexOf(layer);\n    if (index !== -1) stack.splice(index, 1);\n  };\n}\n\n/** Whether this Escape is `layer`'s to answer: it was innermost when the key went down. */\nexport function ownsEscape(layer: Layer, event: KeyboardEvent) {\n  if (event.defaultPrevented) return false;\n  const owner = escapeOwners.has(event)\n    ? escapeOwners.get(event)\n    : innermostEscapeLayer();\n  return owner === layer;\n}\n\n/** Whether `target` sits in a layer opened on top of `layer`. */\nexport function inLayerAbove(layer: Layer, target: Node) {\n  const index = stack.indexOf(layer);\n  return stack.slice(index + 1).some((above) => above.contains(target));\n}\n\n/** Whether a focus trap is open on top of `layer`; stray focus is that one's to pull back. */\nexport function trapAbove(layer: Layer) {\n  const index = stack.indexOf(layer);\n  return stack.slice(index + 1).some((above) => above.traps);\n}\n\n/**\n * Whether `target` belongs to any open layer other than `layer`. Pass\n * `traps: false` to count only dismissable overlays, not the traps under them.\n */\nexport function inOtherLayer(layer: Layer, target: Node, { traps = true } = {}) {\n  return stack.some(\n    (other) => other !== layer && (traps || !other.traps) && other.contains(target),\n  );\n}\n"},{"path":"lib/sound.tsx","type":"util","content":"\"use client\";\n\nimport {\n  createContext,\n  type ReactNode,\n  useCallback,\n  useContext,\n  useEffect,\n  useLayoutEffect,\n  useMemo,\n  useRef,\n} from \"react\";\nimport {\n  registerSoundSettings,\n  retainAudioContext,\n  type SoundSettingsEntry,\n} from \"@/lib/audio-context\";\nimport type { PlayOptions, Sound } from \"@/lib/sounds/engine\";\n\nexport interface SoundSettings {\n  /** False mutes every beUI sound under the provider. */\n  enabled: boolean;\n  /** 0 to 1, scales every beUI sound. */\n  volume: number;\n}\n\nconst SoundContext = createContext<SoundSettings & { depth: number }>({\n  enabled: true,\n  volume: 1,\n  depth: 0,\n});\n\n/**\n * App-wide sound settings. `enabled={false}` mutes every beUI sound, from\n * component `sound` props and `useSound` to the games, Wheel Picker and\n * Bookshelf, and `volume` scales them all. Without a provider, sounds play at\n * full volume. A nested provider overrides the one around it.\n */\nexport function SoundProvider({\n  enabled = true,\n  volume = 1,\n  children,\n}: Partial<SoundSettings> & { children: ReactNode }) {\n  const depth = useContext(SoundContext).depth + 1;\n  const value = useMemo(() => ({ enabled, volume, depth }), [enabled, volume, depth]);\n\n  // Module-level as well (lib/audio-context.ts), so players outside React\n  // and `sound.play()` obey it too.\n  const entry = useRef<SoundSettingsEntry>({ depth, enabled, volume });\n  const registration = useRef<ReturnType<typeof registerSoundSettings> | null>(null);\n  useEffect(() => {\n    registration.current = registerSoundSettings(entry.current);\n    return () => {\n      registration.current?.release();\n      registration.current = null;\n    };\n  }, []);\n  useEffect(() => {\n    Object.assign(entry.current, { depth, enabled, volume });\n    registration.current?.update();\n  }, [depth, enabled, volume]);\n\n  return <SoundContext.Provider value={value}>{children}</SoundContext.Provider>;\n}\n\nexport function useSoundSettings(): SoundSettings {\n  return useContext(SoundContext);\n}\n\nexport interface UseSoundOptions {\n  /** False makes `play` do nothing, for a component's `sound` prop. */\n  enabled?: boolean;\n  /** 0 to 1 for this sound, on top of the provider volume. */\n  volume?: number;\n}\n\n/**\n * A stable `play()` for one sound. It does nothing while disabled or muted,\n * and keeps the shared audio context warm only while it can play.\n */\nexport function useSound(sound: Sound, { enabled = true, volume = 1 }: UseSoundOptions = {}) {\n  const settings = useSoundSettings();\n  const on = enabled && settings.enabled && settings.volume > 0 && volume > 0;\n  // Read by the stable callback, so a caller's effects don't re-run when\n  // the settings change.\n  const latest = useRef({ on, volume, sound });\n  useLayoutEffect(() => {\n    latest.current = { on, volume, sound };\n  });\n\n  useEffect(() => {\n    if (!on) return;\n    return retainAudioContext();\n  }, [on]);\n\n  return useCallback((options?: PlayOptions) => {\n    const current = latest.current;\n    if (!current.on) return;\n    current.sound.play({ ...options, volume: (options?.volume ?? 1) * current.volume });\n  }, []);\n}\n"},{"path":"lib/sounds/press.ts","type":"util","content":"import { defineSound } from \"./engine\";\n\n/** A physical button: a switch click that settles twice over a soft thump and a little casing ring. */\nexport const pressSound = defineSound({\n  name: \"Press\",\n  duration: 0.1,\n  vary: 0.03,\n  room: 0.1,\n  build: (v) => {\n    v.click({ freq: 2800, q: 1.8, decay: 0.005, gain: 0.5 });\n    v.click({ freq: 4200, q: 2.5, at: 0.011, decay: 0.003, gain: 0.16 });\n    v.strike({ freq: 150, material: \"wood\", bend: 1.5, decay: 0.07, gain: 0.75 });\n    v.strike({ freq: 1250, material: \"plastic\", decay: 0.022, gain: 0.14 });\n  },\n});\n"},{"path":"components/motion/magnetic.tsx","type":"util","content":"\"use client\";\n\nimport { motion, useMotionValue, useReducedMotion, useSpring } from \"motion/react\";\nimport { useRef, type ReactNode } from \"react\";\nimport { SPRING_MOUSE } from \"@/lib/ease\";\nimport { useHoverCapable } from \"@/lib/hooks/use-hover-capable\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface MagneticProps {\n  children: ReactNode;\n  strength?: number;\n  className?: string;\n}\n\nexport function Magnetic({ children, strength = 0.35, className }: MagneticProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const reduce = useReducedMotion();\n  const canHover = useHoverCapable();\n  // Decorative cursor-follow: skip on touch (phantom hover) and reduced motion.\n  const enabled = !reduce && canHover;\n  const x = useMotionValue(0);\n  const y = useMotionValue(0);\n  const sx = useSpring(x, SPRING_MOUSE);\n  const sy = useSpring(y, SPRING_MOUSE);\n\n  const onMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    const el = ref.current;\n    if (!el || !enabled) return;\n    const rect = el.getBoundingClientRect();\n    x.set((e.clientX - rect.left - rect.width / 2) * strength);\n    y.set((e.clientY - rect.top - rect.height / 2) * strength);\n  };\n\n  const onLeave = () => {\n    x.set(0);\n    y.set(0);\n  };\n\n  return (\n    <motion.div\n      ref={ref}\n      onMouseMove={onMove}\n      onMouseLeave={onLeave}\n      style={{ x: sx, y: sy }}\n      className={cn(\"inline-block\", className)}\n    >\n      {children}\n    </motion.div>\n  );\n}\n"},{"path":"lib/audio-context.ts","type":"util","content":"// One AudioContext for every synthesized sound on the page: the sounds\n// library (lib/sounds/), the WheelPicker tick (lib/tick-sound.ts), the casino\n// games (lib/game-sounds.ts) and Bookshelf (lib/book-sounds.ts). Browsers cap\n// concurrent contexts, and a page can show a date made of several WheelPickers\n// next to a game, so they all share this one. It is created on first use and\n// closed once every player is disposed.\n//\n// Every player connects to `audioOutput()` rather than the context's\n// destination, so the page-wide volume and mute from `SoundProvider`\n// (lib/sound.tsx) reach all of them in one place.\n\ntype AudioContextCtor = typeof AudioContext;\n\nlet context: AudioContext | null = null;\nlet master: GainNode | null = null;\nlet users = 0;\n\n/** Settings one mounted `SoundProvider` asks for. */\nexport interface SoundSettingsEntry {\n  /** Nesting depth: the deepest provider decides. */\n  depth: number;\n  enabled: boolean;\n  volume: number;\n}\n\n// Mounted providers in mount order. Module state, so `sound.play()` called\n// outside React obeys them too. The deepest provider wins; among equals, the\n// one mounted last. Effects run child first, so this can't be \"whoever ran\n// last\".\nconst providers = new Set<SoundSettingsEntry>();\nlet allowed = true;\nlet volume = 1;\n\nfunction applySettings() {\n  let chosen: SoundSettingsEntry | undefined;\n  for (const entry of providers) {\n    if (!chosen || entry.depth >= chosen.depth) chosen = entry;\n  }\n  allowed = chosen?.enabled ?? true;\n  volume = Math.min(1, Math.max(0, chosen?.volume ?? 1));\n  if (master) master.gain.value = volume;\n}\n\n/**\n * Registers a provider's settings; call `update` after changing the entry and\n * the returned release function when the provider unmounts.\n */\nexport function registerSoundSettings(entry: SoundSettingsEntry) {\n  providers.add(entry);\n  applySettings();\n  return {\n    update: applySettings,\n    release() {\n      providers.delete(entry);\n      applySettings();\n    },\n  };\n}\n\n/**\n * Registers a sound player. Call the returned function when the player is\n * disposed; the context closes after the last one.\n */\nexport function retainAudioContext() {\n  users++;\n  let released = false;\n  return () => {\n    if (released) return;\n    released = true;\n    users--;\n    if (users === 0 && context) {\n      void context.close();\n      context = null;\n      master = null;\n    }\n  };\n}\n\n/**\n * The shared context, created on first call and resumed if suspended. Null\n * during SSR, in browsers without Web Audio, and while sounds are muted or at\n * zero volume.\n */\nexport function getAudioContext(): AudioContext | null {\n  if (!allowed || volume <= 0) return null;\n  if (!context) {\n    if (typeof window === \"undefined\") return null;\n    const Ctor =\n      window.AudioContext ??\n      (window as unknown as { webkitAudioContext?: AudioContextCtor }).webkitAudioContext;\n    if (!Ctor) return null;\n    context = new Ctor();\n  }\n  // Browsers may refuse outside a user gesture. Players call this from\n  // pointer and key handlers first, so a later call finds it running.\n  if (context.state === \"suspended\") void context.resume().catch(() => undefined);\n  return context;\n}\n\n/** The node every player connects to: the page-wide volume, then the speakers. */\nexport function audioOutput(ctx: AudioContext): AudioNode {\n  if (master?.context !== ctx) {\n    master = ctx.createGain();\n    master.gain.value = volume;\n    master.connect(ctx.destination);\n  }\n  return master;\n}\n\nconst gains = new WeakMap<BaseAudioContext, Map<string, GainNode>>();\n\n/**\n * A player's own level, made once per context and routed into `audioOutput`.\n * Players keep their mix this way without rebuilding nodes on every play, and\n * a context closed and recreated gets fresh ones.\n */\nexport function playerGain(ctx: AudioContext, key: string, level: number): GainNode {\n  let byKey = gains.get(ctx);\n  if (!byKey) {\n    byKey = new Map();\n    gains.set(ctx, byKey);\n  }\n  let gain = byKey.get(key);\n  if (!gain) {\n    gain = ctx.createGain();\n    gain.gain.value = level;\n    gain.connect(audioOutput(ctx));\n    byKey.set(key, gain);\n  }\n  return gain;\n}\n"},{"path":"lib/sounds/engine.ts","type":"util","content":"import { audioOutput, getAudioContext } from \"@/lib/audio-context\";\n\n// Every beUI sound is a short recipe played with Web Audio the moment it is\n// asked for. Nothing is downloaded. Recipes are built the way a real tap\n// sounds: a contact click (a millisecond of filtered noise), a body that\n// rings at a few inharmonic partials of a material and settles in pitch, and\n// a little of a small room behind it.\n\n/** Options for one play of a sound. */\nexport interface PlayOptions {\n  /** 0 to 1, multiplied with the page-wide volume from `SoundProvider`. */\n  volume?: number;\n  /** Pitch multiplier; 1 is the designed pitch. */\n  pitch?: number;\n}\n\n/** Where a sound renders: the live context, or an offline one for drawing. */\nexport interface SoundTarget {\n  context: BaseAudioContext;\n  destination: AudioNode;\n  /** Start time on the context clock, in seconds. */\n  when: number;\n  volume: number;\n  pitch: number;\n}\n\n/** A plain oscillator with an attack, a decay and an optional glide. */\nexport interface ToneSpec {\n  type?: OscillatorType;\n  /** Start frequency in Hz. */\n  freq: number;\n  /** End frequency in Hz; glides from `freq` over `glide`. */\n  to?: number;\n  /** Glide time in seconds; defaults to the attack plus decay. */\n  glide?: number;\n  /** Starts this many times higher and settles to `freq` in about 15 ms, like a struck object. */\n  bend?: number;\n  /** Delay from the sound's start, in seconds. */\n  at?: number;\n  /** Fade-in time in seconds. */\n  attack?: number;\n  /** Time to fade to silence after the attack, in seconds. */\n  decay: number;\n  gain: number;\n}\n\n/** A burst of filtered white noise. */\nexport interface NoiseSpec {\n  filter?: BiquadFilterType;\n  /** Filter frequency in Hz. */\n  freq: number;\n  /** End filter frequency in Hz; sweeps from `freq` over the decay. */\n  to?: number;\n  q?: number;\n  /** Delay from the sound's start, in seconds. */\n  at?: number;\n  /** Fade-in time in seconds. */\n  attack?: number;\n  /** Time to fade to silence after the attack, in seconds. */\n  decay: number;\n  gain: number;\n}\n\n/** The contact of a tap: a few milliseconds of band-passed noise with an instant attack. */\nexport interface ClickSpec {\n  /** Band center in Hz: 1-2 kHz is a soft knock, 3-5 kHz a crisp click. */\n  freq: number;\n  /** Band width; higher is narrower and more tonal. */\n  q?: number;\n  /** Delay from the sound's start, in seconds. */\n  at?: number;\n  /** Time to fade to silence, in seconds. */\n  decay?: number;\n  gain: number;\n}\n\n/** How a material rings: partials as [frequency ratio, level], and how fast high ones die. */\nexport interface Material {\n  partials: readonly (readonly [ratio: number, level: number])[];\n  /** Higher partials decay in `decay / ratio ** damping`; wood is high, metal low. */\n  damping: number;\n}\n\n// Partial ratios follow the modes of small struck objects: a free bar for\n// wood and metal, a cup for glass, a tuned bar for the mallet.\nexport const MATERIALS = {\n  wood: { partials: [[1, 1], [2.76, 0.3], [5.4, 0.08]], damping: 1.3 },\n  plastic: { partials: [[1, 1], [2.43, 0.4], [4.86, 0.14]], damping: 0.9 },\n  glass: { partials: [[1, 1], [2.32, 0.42], [4.25, 0.2], [6.63, 0.08]], damping: 0.55 },\n  metal: { partials: [[1, 1], [2.76, 0.5], [5.4, 0.26], [8.93, 0.1]], damping: 0.4 },\n  mallet: { partials: [[1, 1], [3.99, 0.2], [9.14, 0.05]], damping: 0.8 },\n  bell: { partials: [[1, 1], [2.0, 0.34], [2.76, 0.2], [5.4, 0.07]], damping: 0.5 },\n} satisfies Record<string, Material>;\n\n/** A struck object: one partial per mode of its material, each with its own decay. */\nexport interface StrikeSpec {\n  /** Fundamental in Hz. */\n  freq: number;\n  /** A name from `MATERIALS` or your own partials. Default: \"plastic\". */\n  material?: keyof typeof MATERIALS | Material;\n  /** Starts this many times higher and settles in about 15 ms. Default: 1.01. */\n  bend?: number;\n  /** Delay from the sound's start, in seconds. */\n  at?: number;\n  /** Time for the fundamental to fade to silence, in seconds. */\n  decay: number;\n  gain: number;\n}\n\nexport interface Voice {\n  tone(spec: ToneSpec): void;\n  noise(spec: NoiseSpec): void;\n  click(spec: ClickSpec): void;\n  strike(spec: StrikeSpec): void;\n}\n\nexport interface Sound {\n  /** Display name, like \"Tap\". */\n  name: string;\n  /** Length in seconds; the room tail rings a little past it. */\n  duration: number;\n  /** Plays the sound now. Silent during SSR and while sounds are muted. */\n  play(options?: PlayOptions): void;\n  /** Schedules the sound on any context; `play` uses the live one. */\n  render(target: SoundTarget): void;\n}\n\nexport interface SoundRecipe {\n  /** Display name, like \"Tap\". */\n  name: string;\n  /** Length in seconds; the room tail rings a little past it. */\n  duration: number;\n  /** Random pitch spread per play (0.04 = ±4%), so repeats don't sound stamped. */\n  vary?: number;\n  /** How much of the small room the sound is played in, 0 (dry) to 1. Default: 0.12. */\n  room?: number;\n  /** Adds the sound's layers to the voice on each play. */\n  build: (voice: Voice) => void;\n}\n\n// Keeps a sum of voices well under clipping at volume 1.\nconst MASTER_GAIN = 0.16;\nconst SILENT = 0.0001;\n// Time a strike or bend takes to settle onto its pitch.\nconst SETTLE = 0.015;\n\nconst noiseBuffers = new WeakMap<BaseAudioContext, AudioBuffer>();\n\n/** One second of white noise per context, shared by every noise voice. */\nexport function noiseBuffer(context: BaseAudioContext) {\n  let buffer = noiseBuffers.get(context);\n  if (!buffer) {\n    buffer = context.createBuffer(1, context.sampleRate, context.sampleRate);\n    const data = buffer.getChannelData(0);\n    for (let i = 0; i < data.length; i++) data[i] = Math.random() * 2 - 1;\n    noiseBuffers.set(context, buffer);\n  }\n  return buffer;\n}\n\n// A small, soft room: 8 early reflections, then a diffuse tail that falls\n// 60 dB in 0.3 s and darkens as it fades, the way air and soft walls\n// absorb highs first. Generated once per context.\nconst ROOM_LENGTH = 0.3;\n// The convolver's equal-power normalization leaves the room about 15 dB\n// under the dry sound; this brings `room: 0.12` to a tail heard only as space.\nconst ROOM_GAIN = 6;\nconst roomBuffers = new WeakMap<BaseAudioContext, AudioBuffer>();\n\nfunction roomBuffer(context: BaseAudioContext) {\n  let buffer = roomBuffers.get(context);\n  if (!buffer) {\n    const rate = context.sampleRate;\n    const length = Math.ceil(ROOM_LENGTH * rate);\n    buffer = context.createBuffer(2, length, rate);\n    for (let channel = 0; channel < 2; channel++) {\n      const data = buffer.getChannelData(channel);\n      let smooth = 0;\n      for (let i = Math.floor(0.004 * rate); i < length; i++) {\n        const t = i / rate;\n        // One-pole low-pass whose cutoff closes over the tail.\n        const brightness = 0.7 * Math.exp(-t / 0.08) + 0.08;\n        smooth += brightness * (Math.random() * 2 - 1 - smooth);\n        data[i] = smooth * Math.exp(-t / 0.043);\n      }\n      for (let r = 0; r < 8; r++) {\n        const at = Math.floor((0.005 + Math.random() * 0.022) * rate);\n        data[at] += (Math.random() < 0.5 ? -1 : 1) * (0.5 - r * 0.05);\n      }\n    }\n    roomBuffers.set(context, buffer);\n  }\n  return buffer;\n}\n\n// One convolver per output node, shared by every play: building one is the\n// expensive part, sending to it is cheap.\nconst rooms = new WeakMap<AudioNode, ConvolverNode>();\n\nfunction roomFor(context: BaseAudioContext, destination: AudioNode) {\n  let room = rooms.get(destination);\n  if (!room) {\n    room = context.createConvolver();\n    room.buffer = roomBuffer(context);\n    room.connect(destination);\n    rooms.set(destination, room);\n  }\n  return room;\n}\n\n/** A linear attack to `peak`, then an exponential fall to silence. */\nfunction envelope(param: AudioParam, start: number, attack: number, decay: number, peak: number) {\n  param.setValueAtTime(0, start);\n  param.linearRampToValueAtTime(Math.max(peak, SILENT), start + attack);\n  param.exponentialRampToValueAtTime(SILENT, start + attack + decay);\n}\n\nfunction voiceFor(target: SoundTarget, output: AudioNode): Voice {\n  const { context, when, pitch } = target;\n  // Partials above this only add hiss on small speakers, or alias near Nyquist.\n  const ceiling = Math.min(12000, context.sampleRate * 0.45);\n\n  const tone: Voice[\"tone\"] = ({ type = \"sine\", freq, to, glide, bend, at = 0, attack = 0.002, decay, gain }) => {\n    const start = when + at;\n    const osc = context.createOscillator();\n    const amp = context.createGain();\n    osc.type = type;\n    const base = freq * pitch;\n    osc.frequency.setValueAtTime(base * (bend ?? 1), start);\n    if (bend !== undefined) osc.frequency.exponentialRampToValueAtTime(base, start + SETTLE);\n    if (to !== undefined) {\n      osc.frequency.exponentialRampToValueAtTime(to * pitch, start + Math.max(glide ?? attack + decay, SETTLE));\n    }\n    envelope(amp.gain, start, attack, decay, gain);\n    osc.connect(amp).connect(output);\n    osc.start(start);\n    osc.stop(start + attack + decay + 0.02);\n  };\n\n  const noise: Voice[\"noise\"] = ({ filter = \"bandpass\", freq, to, q = 1, at = 0, attack = 0.002, decay, gain }) => {\n    const start = when + at;\n    const source = context.createBufferSource();\n    const shape = context.createBiquadFilter();\n    const amp = context.createGain();\n    source.buffer = noiseBuffer(context);\n    shape.type = filter;\n    shape.Q.value = q;\n    shape.frequency.setValueAtTime(freq * pitch, start);\n    if (to !== undefined) {\n      shape.frequency.exponentialRampToValueAtTime(to * pitch, start + attack + decay);\n    }\n    envelope(amp.gain, start, attack, decay, gain);\n    source.connect(shape).connect(amp).connect(output);\n    // A random offset into the buffer keeps each burst a little different.\n    source.start(start, Math.random() * 0.5);\n    source.stop(start + attack + decay + 0.02);\n  };\n\n  return {\n    tone,\n    noise,\n    click({ freq, q = 2, at = 0, decay = 0.005, gain }) {\n      // A little spread on the band, so no two contacts are identical.\n      noise({ freq: freq * (0.94 + Math.random() * 0.12), q, at, attack: 0.0005, decay, gain });\n    },\n    strike({ freq, material = \"plastic\", bend = 1.01, at = 0, decay, gain }) {\n      const { partials, damping } = typeof material === \"string\" ? MATERIALS[material] : material;\n      for (const [ratio, level] of partials) {\n        if (freq * ratio * pitch * bend > ceiling) continue;\n        tone({\n          // Real objects are never perfectly tuned; a hair of detune per partial.\n          freq: freq * ratio * (1 + (Math.random() * 2 - 1) * 0.003),\n          bend,\n          at,\n          attack: 0.001,\n          decay: decay / ratio ** damping,\n          gain: gain * level,\n        });\n      }\n    },\n  };\n}\n\n/** Turns a recipe into a playable sound. */\nexport function defineSound({ name, duration, vary = 0, room = 0.12, build }: SoundRecipe): Sound {\n  const render = (target: SoundTarget) => {\n    const { context, destination } = target;\n    const output = context.createGain();\n    output.gain.value = MASTER_GAIN * target.volume;\n    output.connect(destination);\n    if (room > 0) {\n      const send = context.createGain();\n      send.gain.value = room * ROOM_GAIN;\n      output.connect(send).connect(roomFor(context, destination));\n    }\n    build(voiceFor(target, output));\n  };\n\n  return {\n    name,\n    duration,\n    render,\n    play({ volume = 1, pitch = 1 } = {}) {\n      const context = getAudioContext();\n      if (!context || volume <= 0) return;\n      const spread = vary ? 1 + (Math.random() * 2 - 1) * vary : 1;\n      render({\n        context,\n        // The page-wide volume is applied there.\n        destination: audioOutput(context),\n        when: context.currentTime + 0.005,\n        volume,\n        pitch: pitch * spread,\n      });\n    },\n  };\n}\n"},{"path":"lib/hooks/use-hover-capable.ts","type":"util","content":"\"use client\";\n\nimport { useEffect, useState } from \"react\";\n\n/**\n * Returns true only on devices that have a true hover (mouse / trackpad).\n * Touch devices fire phantom `:hover` on tap that sticks until tap-elsewhere\n * - gate hover-only effects (scale lifts, magnetic pulls) behind this.\n */\nexport function useHoverCapable() {\n  const [canHover, setCanHover] = useState(false);\n\n  useEffect(() => {\n    if (typeof window === \"undefined\" || !window.matchMedia) return;\n    const mq = window.matchMedia(\"(hover: hover) and (pointer: fine)\");\n    const update = () => setCanHover(mq.matches);\n    update();\n    mq.addEventListener?.(\"change\", update);\n    return () => mq.removeEventListener?.(\"change\", update);\n  }, []);\n\n  return canHover;\n}\n"},{"path":"components/previews/blocks/wallet-card.preview.tsx","type":"preview","content":"\"use client\";\n\nimport { useState } from \"react\";\nimport { WalletCard } from \"@/components/motion/wallet-card\";\nimport { Button } from \"@/components/motion/button\";\n\nconst ACCOUNTS = [\n  { id: \"main\", name: \"Main Wallet\", address: \"0x8f3Cb1a29e4D7c6F1B2a3E9d0C4b5A6f7D8e9C0b\" },\n  { id: \"trading\", name: \"Trading\", address: \"0x1a2B3c4D5e6F7a8B9c0D1e2F3a4B5c6D7e8F9a0B\" },\n  { id: \"cold\", name: \"Cold Storage\", address: \"0x9F8e7D6c5B4a3E2d1C0b9A8f7E6d5C4b3A2e1F0d\" },\n];\n\nconst RECENT_SEARCHES = [\"vitalik.eth\", \"0xA0b8…6EB4\", \"Uniswap\", \"Send to Trading\"];\n\nexport function WalletCardPreview() {\n  const [balance, setBalance] = useState(12480.32);\n\n  return (\n    <div className=\"flex w-full flex-col items-center gap-4 p-6\">\n      <WalletCard\n        accounts={ACCOUNTS}\n        balance={balance}\n        defaultChange={124.5}\n        searchRecent={RECENT_SEARCHES}\n        hasNotifications\n      />\n      <Button\n        variant=\"ghost\"\n        size=\"sm\"\n        onClick={() => setBalance((b) => b + (Math.random() > 0.5 ? 1 : -1) * (50 + Math.random() * 400))}\n      >\n        Simulate balance change\n      </Button>\n    </div>\n  );\n}\n"}]}