{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-billing",
  "type": "registry:block",
  "title": "Billing",
  "description": "A workspace’s plan and usage on a raised page: usage against limits, the payment method, a failed payment to retry and the invoices.",
  "dependencies": [
    "@remixicon/react@^4.9.0"
  ],
  "registryDependencies": [
    "https://wideset.co/r/app-shell.json",
    "https://wideset.co/r/avatar.json",
    "https://wideset.co/r/block-styles.json",
    "https://wideset.co/r/breadcrumbs.json",
    "https://wideset.co/r/button.json",
    "https://wideset.co/r/card.json",
    "https://wideset.co/r/divider.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/inline-alert.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/modal.json",
    "https://wideset.co/r/progress-bar.json",
    "https://wideset.co/r/segmented-control.json",
    "https://wideset.co/r/sidebar.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/table.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/tile.json",
    "https://wideset.co/r/toast.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/billing/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/brand-mark.tsx",
      "content": "'use client';\n\nimport { cn } from '@/lib/wideset/utils';\n\nconst TILE =\n  'M0 16C0 8.45753 0 4.68629 2.34315 2.34315C4.68629 0 8.45753 0 16 0C23.5425 0 27.3137 0 29.6569 2.34315C32 4.68629 32 8.45753 32 16C32 23.5425 32 27.3137 29.6569 29.6569C27.3137 32 23.5425 32 16 32C8.45753 32 4.68629 32 2.34315 29.6569C0 27.3137 0 23.5425 0 16Z';\n\n/**\n * Orbit's mark: a planet and its ring on the inverse tile, so it inverts in dark mode. It takes\n * the size of its place (32px in a sidebar, 36px in a larger switcher). Decorative beside the\n * product's name; give it a `label` when it stands alone.\n */\nexport function BrandMark({ className, label }: { className?: string; label?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 32 32\"\n      role={label ? 'img' : undefined}\n      aria-label={label}\n      aria-hidden={label ? undefined : true}\n      className={cn('size-ws-14 shrink-0', className)}\n    >\n      <path d={TILE} className=\"fill-(--ws-static-fill-inverse-background)\" />\n      <ellipse\n        cx=\"16\"\n        cy=\"16\"\n        rx=\"10.5\"\n        ry=\"4\"\n        transform=\"rotate(-28 16 16)\"\n        strokeWidth=\"1.75\"\n        className=\"fill-none stroke-(--ws-static-text-inverse-strong)\"\n      />\n      <circle cx=\"16\" cy=\"16\" r=\"4.75\" className=\"fill-(--ws-static-text-inverse-strong)\" />\n    </svg>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/cancel-plan-modal.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/cancel-plan-modal.tsx",
      "content": "'use client';\n\nimport { RiCloseLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Modal } from '@/components/ui/wideset/modal/Modal';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { freePlan, type Plan, usage, workspace } from './data';\nimport { formatCount, formatDate, formatGb } from './format';\n\ntype CancelPlanModalProps = {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  plan: Plan;\n  /** The last day of the paid period. */\n  periodEnd: string;\n  /** The day the workspace drops to Free. */\n  renews: string;\n  onConfirm: () => void;\n};\n\n/**\n * Cancelling the plan: what stays until when, then what the workspace loses on Free, measured\n * against what it uses today. The safe button keeps the plan; the red one names the action.\n */\nexport function CancelPlanModal({\n  open,\n  onOpenChange,\n  plan,\n  periodEnd,\n  renews,\n  onConfirm,\n}: CancelPlanModalProps) {\n  const [pending, setPending] = useState(false);\n\n  const losses = [\n    `${usage.seats - freePlan.seats} of ${usage.seats} people lose access. Free includes ${freePlan.seats} seats.`,\n    `Contacts over ${formatCount(freePlan.contacts)} become read-only. You have ${formatCount(usage.contacts)}.`,\n    `The API stops answering. It took ${formatCount(usage.apiCalls)} calls this month.`,\n    `Files over ${formatGb(freePlan.storageGb)} become read-only. You store ${formatGb(usage.storageGb)}.`,\n  ];\n\n  // Cleared on unmount, so the stand-in request never lands on a closed screen.\n  const timer = useRef<number>(undefined);\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  // A timeout stands in for the request; a real screen awaits it and shows an InlineAlert in the\n  // body if it fails, keeping the modal open.\n  function confirm() {\n    setPending(true);\n    timer.current = window.setTimeout(() => {\n      setPending(false);\n      onConfirm();\n    }, 800);\n  }\n\n  return (\n    <Modal open={open} onOpenChange={(next) => !pending && onOpenChange(next)}>\n      <Modal.Content className=\"ws-block-utility\" persistent={pending}>\n        <Modal.Header>\n          <Modal.Title>Cancel the {plan.name} plan?</Modal.Title>\n          <Modal.Description>\n            {plan.name} stays on until {formatDate(periodEnd)}. Then {workspace.name} moves to the\n            Free plan and is not charged again.\n          </Modal.Description>\n        </Modal.Header>\n        <Modal.Body>\n          <div className=\"gap-ws-5 flex flex-col\">\n            <h3 className=\"typography-label-strong-md text-ws-static-strong\">\n              On {formatDate(renews)}\n            </h3>\n            <ul className=\"gap-ws-5 flex flex-col\">\n              {losses.map((loss) => (\n                <li\n                  key={loss}\n                  className=\"gap-ws-5 typography-body-md text-ws-static-base flex items-start\"\n                >\n                  <RiCloseLine\n                    aria-hidden=\"true\"\n                    className=\"size-ws-9 mt-ws-1 text-ws-static-subtle shrink-0\"\n                  />\n                  {loss}\n                </li>\n              ))}\n            </ul>\n          </div>\n        </Modal.Body>\n        <Modal.Footer>\n          <Modal.Close asChild>\n            <Button size=\"sm\" variant=\"secondary\" preset=\"border\" disabled={pending}>\n              Keep {plan.name}\n            </Button>\n          </Modal.Close>\n          <Button size=\"sm\" variant=\"danger\" onClick={confirm} disabled={pending}>\n            {pending ? 'Cancelling…' : 'Cancel plan'}\n          </Button>\n        </Modal.Footer>\n      </Modal.Content>\n    </Modal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/change-plan-modal.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/change-plan-modal.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Modal } from '@/components/ui/wideset/modal/Modal';\nimport { SegmentedControl } from '@/components/ui/wideset/segmented-control/SegmentedControl';\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { Tile } from '@/components/ui/wideset/tile/Tile';\nimport { useState } from 'react';\n\nimport { type Interval, periodPrice, type PlanId, plans, usage, workspace } from './data';\nimport { formatCompact, formatCount, formatGb, formatUsdWhole } from './format';\n\ntype Choice = { planId: PlanId; interval: Interval };\n\ntype ChangePlanModalProps = {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  current: Choice;\n  seats: number;\n  onConfirm: (choice: Choice) => void;\n};\n\nconst INTERVALS: { value: Interval; label: string }[] = [\n  { value: 'monthly', label: 'Monthly' },\n  { value: 'yearly', label: 'Yearly' },\n];\n\n/** The choice itself; it lives inside the modal so it starts from the current plan on every open. */\nfunction ChangePlanForm({\n  current,\n  seats,\n  onConfirm,\n}: Omit<ChangePlanModalProps, 'open' | 'onOpenChange'>) {\n  const [choice, setChoice] = useState(current);\n  const unchanged = choice.planId === current.planId && choice.interval === current.interval;\n  const chosen = plans.find((plan) => plan.id === choice.planId)!;\n  const action = unchanged\n    ? 'Change plan'\n    : choice.planId === current.planId\n      ? `Switch to ${choice.interval} billing`\n      : choice.interval === current.interval\n        ? `Switch to ${chosen.name}`\n        : `Switch to ${chosen.name}, billed ${choice.interval}`;\n\n  return (\n    <>\n      <Modal.Header>\n        <Modal.Title>Change plan</Modal.Title>\n        <Modal.Description>\n          Prices for {workspace.name}’s {seats} seats. The change applies today; the rest of this\n          period is prorated.\n        </Modal.Description>\n      </Modal.Header>\n      <Modal.Body>\n        <div className=\"gap-ws-11 flex flex-col\">\n          <div className=\"gap-ws-5 flex items-center\">\n            <SegmentedControl\n              size=\"sm\"\n              aria-label=\"Billing\"\n              value={choice.interval}\n              onValueChange={(interval) =>\n                interval && setChoice({ ...choice, interval: interval as Interval })\n              }\n            >\n              {INTERVALS.map(({ value, label }) => (\n                <SegmentedControl.Item key={value} value={value}>\n                  {label}\n                </SegmentedControl.Item>\n              ))}\n            </SegmentedControl>\n            <span className=\"typography-body-md text-ws-static-subtle\">\n              Yearly billing saves up to 18%.\n            </span>\n          </div>\n          <Tile.RadioGroup\n            aria-label=\"Plan\"\n            value={choice.planId}\n            onValueChange={(planId) => setChoice({ ...choice, planId: planId as PlanId })}\n          >\n            {plans.map((plan) => {\n              const tooSmall = usage.contacts > plan.limits.contacts;\n              return (\n                <Tile.Radio\n                  key={plan.id}\n                  value={plan.id}\n                  disabled={tooSmall}\n                  title={plan.name}\n                  description={\n                    tooSmall\n                      ? `Up to ${formatCount(plan.limits.contacts)} contacts; you have ${formatCount(usage.contacts)}.`\n                      : `${formatCompact(plan.limits.contacts)} contacts, ${formatCompact(plan.limits.apiCalls)} API calls a month, ${formatGb(plan.limits.storageGb)}`\n                  }\n                >\n                  {plan.id === current.planId && <StatusBadge size=\"sm\">Current</StatusBadge>}\n                  <div className=\"flex shrink-0 flex-col items-end\">\n                    <span className=\"typography-label-strong-sm text-ws-static-strong tabular-nums\">\n                      {formatUsdWhole(periodPrice(plan, choice.interval, seats))}\n                    </span>\n                    <span className=\"typography-caption-md text-ws-static-subtle tabular-nums\">\n                      {choice.interval === 'yearly'\n                        ? `a year, ${formatUsdWhole(plan.seatPrice.yearly)} a seat a month`\n                        : `a month, ${formatUsdWhole(plan.seatPrice.monthly)} a seat`}\n                    </span>\n                  </div>\n                </Tile.Radio>\n              );\n            })}\n          </Tile.RadioGroup>\n        </div>\n      </Modal.Body>\n      <Modal.Footer>\n        <Modal.Close asChild>\n          <Button size=\"sm\" variant=\"secondary\" preset=\"border\">\n            Cancel\n          </Button>\n        </Modal.Close>\n        <Button size=\"sm\" disabled={unchanged} onClick={() => onConfirm(choice)}>\n          {action}\n        </Button>\n      </Modal.Footer>\n    </>\n  );\n}\n\n/** Picking another plan or billing interval: every plan priced for the workspace's seats. */\nexport function ChangePlanModal({ open, onOpenChange, ...props }: ChangePlanModalProps) {\n  return (\n    <Modal open={open} onOpenChange={onOpenChange}>\n      <Modal.Content className=\"ws-block-utility\">\n        <ChangePlanForm {...props} />\n      </Modal.Content>\n    </Modal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/billing/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBankCardFill,\n  RiBankCardLine,\n  RiContactsBook3Line,\n  RiHandCoinLine,\n  RiHome5Line,\n  RiInbox2Line,\n  RiKey2Line,\n  RiLineChartLine,\n  RiPieChart2Line,\n  RiPlugLine,\n  RiQuestionLine,\n  RiSettings3Line,\n  RiTeamLine,\n} from '@remixicon/react';\n\n/** The product is Orbit; the workspace paying for it is Lumen Studio. */\nexport const product = { name: 'Orbit' };\nexport const workspace = { name: 'Lumen Studio', initials: 'LS' };\nexport const account = { name: 'Maya Okafor', email: 'maya@lumenstudio.co', initials: 'MO' };\n\n/** The day the screen shows; every date below is relative to it. */\nexport const today = '2026-11-10';\n\nexport type NavLink = {\n  id: string;\n  label: string;\n  icon: RemixiconComponentType;\n  /** The icon while the page is open (a line icon swaps for its fill). */\n  activeIcon?: RemixiconComponentType;\n};\n\nexport const mainLinks: NavLink[] = [\n  { id: 'home', label: 'Home', icon: RiHome5Line },\n  { id: 'inbox', label: 'Inbox', icon: RiInbox2Line },\n  { id: 'customers', label: 'Customers', icon: RiContactsBook3Line },\n  { id: 'deals', label: 'Deals', icon: RiHandCoinLine },\n  { id: 'revenue', label: 'Revenue', icon: RiLineChartLine },\n  { id: 'reports', label: 'Reports', icon: RiPieChart2Line },\n];\n\nexport const settingsLinks: NavLink[] = [\n  { id: 'general', label: 'General', icon: RiSettings3Line },\n  { id: 'members', label: 'Members', icon: RiTeamLine },\n  { id: 'billing', label: 'Billing', icon: RiBankCardLine, activeIcon: RiBankCardFill },\n  { id: 'integrations', label: 'Integrations', icon: RiPlugLine },\n  { id: 'api-keys', label: 'API keys', icon: RiKey2Line },\n];\n\nexport const helpLink: NavLink = { id: 'help', label: 'Help and support', icon: RiQuestionLine };\n\nexport type Interval = 'monthly' | 'yearly';\nexport type PlanId = 'starter' | 'growth' | 'scale';\n\nexport type Plan = {\n  id: PlanId;\n  name: string;\n  /** Price per seat per month, by how often it is billed. */\n  seatPrice: Record<Interval, number>;\n  limits: { contacts: number; apiCalls: number; storageGb: number };\n};\n\nexport const plans: Plan[] = [\n  {\n    id: 'starter',\n    name: 'Starter',\n    seatPrice: { monthly: 19, yearly: 15 },\n    limits: { contacts: 10_000, apiCalls: 100_000, storageGb: 20 },\n  },\n  {\n    id: 'growth',\n    name: 'Growth',\n    seatPrice: { monthly: 39, yearly: 32 },\n    limits: { contacts: 50_000, apiCalls: 1_000_000, storageGb: 100 },\n  },\n  {\n    id: 'scale',\n    name: 'Scale',\n    seatPrice: { monthly: 69, yearly: 57 },\n    limits: { contacts: 250_000, apiCalls: 5_000_000, storageGb: 1_000 },\n  },\n];\n\n/** What the workspace pays for today. Seats are bought on top of any plan. */\nexport const subscription = {\n  planId: 'growth' as PlanId,\n  interval: 'monthly' as Interval,\n  seats: 40,\n  periodStart: '2026-11-01',\n  periodEnd: '2026-11-30',\n  renews: '2026-12-01',\n};\n\n/** What a cancelled workspace falls back to. */\nexport const freePlan = { seats: 3, contacts: 1_000, storageGb: 5 };\n\n/** This period's usage, measured against the plan's limits and the seats bought. */\nexport const usage = { seats: 38, contacts: 41_280, apiCalls: 612_400, storageGb: 63.4 };\n\n/** A meter is flagged from this share of its limit. */\nexport const NEAR_LIMIT = 0.9;\n\nexport const card = {\n  brand: 'Mastercard',\n  last4: '8812',\n  expires: '2026-12',\n  /** The first charge the card will not cover. */\n  firstChargeAfterExpiry: '2027-01-01',\n};\n\nexport const billingDetails = {\n  email: 'finance@lumenstudio.co',\n  company: 'Lumen Studio Ltd',\n  address: ['21 Hoxton Square', 'London N1 6NN', 'United Kingdom'],\n  vat: 'GB 318 4471 26',\n};\n\nexport type InvoiceStatus = 'paid' | 'failed';\n\nexport type Invoice = {\n  id: string;\n  date: string;\n  description: string;\n  amount: number;\n  status: InvoiceStatus;\n};\n\n/** Newest first. Seats cost $39 a month on Growth; 4 seats added on 14 Oct are prorated. */\nexport const invoices: Invoice[] = [\n  {\n    id: 'ORB-2026-0118',\n    date: '2026-11-01',\n    description: 'Growth, 40 seats',\n    amount: 1_560,\n    status: 'failed',\n  },\n  {\n    id: 'ORB-2026-0104',\n    date: '2026-10-14',\n    description: '4 seats added, Oct 14–31',\n    amount: 90.58,\n    status: 'paid',\n  },\n  {\n    id: 'ORB-2026-0097',\n    date: '2026-10-01',\n    description: 'Growth, 36 seats',\n    amount: 1_404,\n    status: 'paid',\n  },\n  {\n    id: 'ORB-2026-0081',\n    date: '2026-09-01',\n    description: 'Growth, 36 seats',\n    amount: 1_404,\n    status: 'paid',\n  },\n  {\n    id: 'ORB-2026-0066',\n    date: '2026-08-01',\n    description: 'Growth, 36 seats',\n    amount: 1_404,\n    status: 'paid',\n  },\n  {\n    id: 'ORB-2026-0052',\n    date: '2026-07-01',\n    description: 'Growth, 34 seats',\n    amount: 1_326,\n    status: 'paid',\n  },\n];\n\n/** The charge that failed, and the day the workspace pauses if it stays unpaid. */\nexport const failedPayment = { invoiceId: 'ORB-2026-0118', pausesOn: '2026-11-21' };\n\nexport const planById = (id: PlanId) => plans.find((plan) => plan.id === id)!;\n\n/** What one billing period costs: the seat price times the seats, times 12 when billed yearly. */\nexport const periodPrice = (plan: Plan, interval: Interval, seats: number) =>\n  plan.seatPrice[interval] * seats * (interval === 'yearly' ? 12 : 1);\n"
    },
    {
      "path": "src/blocks/billing/failed-payment-alert.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/failed-payment-alert.tsx",
      "content": "'use client';\n\nimport { InlineAlert } from '@/components/ui/wideset/inline-alert/InlineAlert';\n\nimport { card, workspace } from './data';\nimport { formatDayMonth, formatUsd } from './format';\n\ntype FailedPaymentAlertProps = {\n  amount: number;\n  failedOn: string;\n  /** The day the workspace pauses if the charge stays unpaid. */\n  pausesOn: string;\n  retrying: boolean;\n  onRetry: () => void;\n};\n\n/**\n * A charge the bank declined: what failed, what happens if nothing is done, and the two ways to\n * fix it. Persistent: it goes away only when the payment goes through.\n */\nexport function FailedPaymentAlert({\n  amount,\n  failedOn,\n  pausesOn,\n  retrying,\n  onRetry,\n}: FailedPaymentAlertProps) {\n  return (\n    <InlineAlert\n      status=\"error\"\n      persistent\n      title={`Payment of ${formatUsd(amount)} failed`}\n      message={`Your bank declined ${card.brand} ending ${card.last4} on ${formatDayMonth(failedOn)}. Pay by ${formatDayMonth(pausesOn)} to keep ${workspace.name} active.`}\n    >\n      <InlineAlert.Action>Update card</InlineAlert.Action>\n      <InlineAlert.Action onClick={onRetry} disabled={retrying}>\n        {retrying ? 'Retrying…' : 'Retry payment'}\n      </InlineAlert.Action>\n    </InlineAlert>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/billing/format.ts",
      "content": "// One locale for the whole screen; swap it for the user's.\nconst LOCALE = 'en-US';\n\nconst usd = new Intl.NumberFormat(LOCALE, { style: 'currency', currency: 'USD' });\nconst usdWhole = new Intl.NumberFormat(LOCALE, {\n  style: 'currency',\n  currency: 'USD',\n  maximumFractionDigits: 0,\n});\nconst count = new Intl.NumberFormat(LOCALE);\nconst compact = new Intl.NumberFormat(LOCALE, { notation: 'compact', maximumFractionDigits: 1 });\nconst decimal = new Intl.NumberFormat(LOCALE, { maximumFractionDigits: 1 });\n// Dates are calendar days (`2026-11-01`), parsed as UTC midnight: format them in UTC too.\nconst date = new Intl.DateTimeFormat(LOCALE, {\n  day: 'numeric',\n  month: 'short',\n  year: 'numeric',\n  timeZone: 'UTC',\n});\nconst dayMonth = new Intl.DateTimeFormat(LOCALE, {\n  day: 'numeric',\n  month: 'short',\n  timeZone: 'UTC',\n});\nconst monthYear = new Intl.DateTimeFormat(LOCALE, {\n  month: '2-digit',\n  year: 'numeric',\n  timeZone: 'UTC',\n});\n\nexport const formatUsd = (value: number) => usd.format(value);\nexport const formatUsdWhole = (value: number) => usdWhole.format(value);\nexport const formatCount = (value: number) => count.format(value);\n/** 612,400 → 612.4K: for limits too long to read at a glance. */\nexport const formatCompact = (value: number) => compact.format(value);\nexport const formatGb = (value: number) =>\n  value >= 1_000 ? `${decimal.format(value / 1_000)} TB` : `${decimal.format(value)} GB`;\nexport const formatDate = (iso: string) => date.format(new Date(iso));\nexport const formatDayMonth = (iso: string) => dayMonth.format(new Date(iso));\n/** A card's expiry, `2026-12` → 12/2026. */\nexport const formatExpiry = (yearMonth: string) => monthYear.format(new Date(`${yearMonth}-01`));\n/** 1–30 Nov 2026. */\nexport const formatPeriod = (from: string, to: string) =>\n  date.formatRange(new Date(from), new Date(to));\n"
    },
    {
      "path": "src/blocks/billing/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';\nimport { useEffect, useRef, useState } from 'react';\n\nimport { CancelPlanModal } from './cancel-plan-modal';\nimport { ChangePlanModal } from './change-plan-modal';\nimport {\n  card,\n  failedPayment,\n  type Interval,\n  invoices,\n  planById,\n  type PlanId,\n  subscription,\n  workspace,\n} from './data';\nimport { FailedPaymentAlert } from './failed-payment-alert';\nimport { formatDate, formatUsd } from './format';\nimport { InvoicesTable } from './invoices-table';\nimport { PageHeader } from './page-header';\nimport { PaymentMethod } from './payment-method';\nimport { PlanCard } from './plan-card';\nimport { BillingSidebar } from './sidebar';\n\nfunction BillingPage() {\n  const { showToast } = useToast();\n  const [current, setCurrent] = useState<{ planId: PlanId; interval: Interval }>({\n    planId: subscription.planId,\n    interval: subscription.interval,\n  });\n  const [cancelled, setCancelled] = useState(false);\n  const [paid, setPaid] = useState(false);\n  const [retrying, setRetrying] = useState(false);\n  const [dialog, setDialog] = useState<'change' | 'cancel' | null>(null);\n\n  const plan = planById(current.planId);\n  const failed = invoices.find((invoice) => invoice.id === failedPayment.invoiceId)!;\n  const rows = paid\n    ? invoices.map((invoice) =>\n        invoice.id === failed.id ? { ...invoice, status: 'paid' as const } : invoice,\n      )\n    : invoices;\n  const closeDialog = (open: boolean) => !open && setDialog(null);\n\n  // Cleared on unmount, so the stand-in request never lands on a closed screen.\n  const timer = useRef<number>(undefined);\n  useEffect(() => () => window.clearTimeout(timer.current), []);\n\n  // A timeout stands in for the charge; a real screen awaits it and keeps the alert, with the\n  // bank's reason, if it is declined again.\n  function retry() {\n    setRetrying(true);\n    timer.current = window.setTimeout(() => {\n      setRetrying(false);\n      setPaid(true);\n      showToast({ content: `Payment of ${formatUsd(failed.amount)} received`, status: 'success' });\n    }, 1200);\n  }\n\n  return (\n    <div className=\"p-ws-12 gap-ws-12 mx-auto flex w-full max-w-[80rem] flex-col\">\n      <PageHeader\n        summary={`${workspace.name} is on ${plan.name} with ${subscription.seats} seats, billed ${current.interval} to ${card.brand} ending ${card.last4}.`}\n      />\n\n      {!paid && (\n        <FailedPaymentAlert\n          amount={failed.amount}\n          failedOn={failed.date}\n          pausesOn={failedPayment.pausesOn}\n          retrying={retrying}\n          onRetry={retry}\n        />\n      )}\n\n      <div className=\"gap-ws-12 grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_22rem]\">\n        <PlanCard\n          plan={plan}\n          interval={current.interval}\n          seats={subscription.seats}\n          periodStart={subscription.periodStart}\n          periodEnd={subscription.periodEnd}\n          renews={subscription.renews}\n          cancelled={cancelled}\n          onChangePlan={() => setDialog('change')}\n          onCancel={() => setDialog('cancel')}\n          onResume={() => {\n            setCancelled(false);\n            showToast({\n              content: `${plan.name} resumed. It renews on ${formatDate(subscription.renews)}.`,\n            });\n          }}\n        />\n        <PaymentMethod />\n      </div>\n\n      <InvoicesTable invoices={rows} />\n\n      <ChangePlanModal\n        open={dialog === 'change'}\n        onOpenChange={closeDialog}\n        current={current}\n        seats={subscription.seats}\n        onConfirm={(choice) => {\n          setCurrent(choice);\n          setCancelled(false);\n          setDialog(null);\n          showToast({\n            content: `Switched to ${planById(choice.planId).name}, billed ${choice.interval}`,\n            status: 'success',\n          });\n        }}\n      />\n      <CancelPlanModal\n        open={dialog === 'cancel'}\n        onOpenChange={closeDialog}\n        plan={plan}\n        periodEnd={subscription.periodEnd}\n        renews={subscription.renews}\n        onConfirm={() => {\n          setCancelled(true);\n          setDialog(null);\n          showToast({\n            content: `${plan.name} cancelled. It stays on until ${formatDate(subscription.periodEnd)}.`,\n          });\n        }}\n      />\n    </div>\n  );\n}\n\n/** Billing (Inset direction): a workspace's plan, usage, payment method and invoices. */\nexport default function Billing() {\n  return (\n    <ToastProvider>\n      <AppShell className=\"ws-block-utility\" direction=\"inset\">\n        <BillingSidebar />\n        <AppShell.Main>\n          {/* The page scrolls inside the card, so the card's corners stay put. */}\n          <div className=\"ws-scrollbar min-h-0 flex-1 overflow-y-auto\">\n            <BillingPage />\n          </div>\n        </AppShell.Main>\n      </AppShell>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/invoices-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/invoices-table.tsx",
      "content": "'use client';\n\nimport { RiDownload2Line } from '@remixicon/react';\nimport { Card } from '@/components/ui/wideset/card/Card';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { Table } from '@/components/ui/wideset/table/Table';\n\nimport { billingDetails, type Invoice } from './data';\nimport { formatDate, formatUsd } from './format';\n\n/** Every invoice, newest first, its status in the colour of its meaning: paid, or failed. */\nexport function InvoicesTable({ invoices }: { invoices: Invoice[] }) {\n  return (\n    <Card>\n      <Card.Header>\n        <div className=\"gap-ws-3 flex flex-col\">\n          <h2 className=\"typography-subtitle-xs text-ws-static-strong\">Invoices</h2>\n          <p className=\"typography-body-md text-ws-static-subtle\">\n            Sent to {billingDetails.email} when they are issued.\n          </p>\n        </div>\n      </Card.Header>\n      {/* Straight in the card, so the row lines run from edge to edge; the outer columns take the\n          card's 20px inset, so the first lines up with the card title. The last row drops its\n          line: the card's border closes the table. */}\n      <Table className=\"w-full whitespace-nowrap\">\n        <Table.Head>\n          <Table.Row>\n            <Table.Header className=\"pl-ws-11\">Invoice</Table.Header>\n            <Table.Header>Date</Table.Header>\n            <Table.Header className=\"w-full\">Description</Table.Header>\n            <Table.Header align=\"right\">Amount</Table.Header>\n            <Table.Header>Status</Table.Header>\n            <Table.Header align=\"right\" className=\"pr-ws-11\">\n              <span className=\"sr-only\">Download</span>\n            </Table.Header>\n          </Table.Row>\n        </Table.Head>\n        <Table.Body className=\"[&>tr:last-child>td]:border-b-0\">\n          {invoices.map((invoice) => (\n            <Table.Row key={invoice.id}>\n              <Table.Cell className=\"text-ws-static-strong pl-ws-11 tabular-nums\">\n                {invoice.id}\n              </Table.Cell>\n              <Table.Cell className=\"tabular-nums\">{formatDate(invoice.date)}</Table.Cell>\n              <Table.Cell>{invoice.description}</Table.Cell>\n              <Table.Cell align=\"right\" className=\"tabular-nums\">\n                {formatUsd(invoice.amount)}\n              </Table.Cell>\n              <Table.Cell>\n                {invoice.status === 'failed' ? (\n                  <StatusBadge color=\"negative\" size=\"sm\">\n                    Failed\n                  </StatusBadge>\n                ) : (\n                  <StatusBadge color=\"positive\" size=\"sm\">\n                    Paid\n                  </StatusBadge>\n                )}\n              </Table.Cell>\n              <Table.Cell align=\"right\" className=\"pr-ws-11\">\n                <IconButton\n                  icon={RiDownload2Line}\n                  variant=\"secondary\"\n                  preset=\"ghost\"\n                  size=\"xs\"\n                  aria-label={`Download ${invoice.id}`}\n                />\n              </Table.Cell>\n            </Table.Row>\n          ))}\n        </Table.Body>\n      </Table>\n    </Card>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/key-value.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/key-value.tsx",
      "content": "'use client';\n\n// TODO(custom): key-value pair (label above value); no DescriptionList in Wideset.\nimport type { ReactNode } from 'react';\n\n/** A fact: its label above its value. Render inside a `dl`. */\nexport function KeyValue({ label, children }: { label: string; children: ReactNode }) {\n  return (\n    <div className=\"gap-ws-3 flex min-w-0 flex-col\">\n      <dt className=\"typography-label-sm text-ws-static-subtle\">{label}</dt>\n      <dd className=\"typography-body-md text-ws-static-base tabular-nums\">{children}</dd>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/page-header.tsx",
      "content": "'use client';\n\n// TODO(custom): Breadcrumbs pulled left (-ml-ws-5) to line up with the title; Breadcrumbs has no flush option.\nimport { Breadcrumbs } from '@/components/ui/wideset/breadcrumbs/Breadcrumbs';\nimport type { ReactNode } from 'react';\n\n/** Where the page sits (Settings › Billing), its title and one line on the workspace's state. */\nexport function PageHeader({ summary }: { summary: ReactNode }) {\n  return (\n    <header className=\"gap-ws-5 flex flex-col\">\n      {/* The crumbs are padded pills: pull them back so their text starts on the title's edge. */}\n      <Breadcrumbs separator=\"arrow\" className=\"-ml-ws-5\">\n        <Breadcrumbs.Item asChild>\n          <a href=\"#settings\">Settings</a>\n        </Breadcrumbs.Item>\n        <Breadcrumbs.Item>Billing</Breadcrumbs.Item>\n      </Breadcrumbs>\n      <div className=\"gap-ws-3 flex flex-col\">\n        <h1 className=\"typography-title-md text-ws-static-strong\">Billing</h1>\n        <p className=\"typography-body-md text-ws-static-base\">{summary}</p>\n      </div>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/payment-method.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/payment-method.tsx",
      "content": "'use client';\n\n// TODO(custom): card-brand chip composed by hand.\nimport { RiErrorWarningLine, RiMastercardLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Card } from '@/components/ui/wideset/card/Card';\n\nimport { billingDetails, card, today } from './data';\nimport { formatDate, formatExpiry } from './format';\nimport { KeyValue } from './key-value';\n\n/** Months from today's month to the card's expiry month: 0 = expires this month. */\nconst monthsLeft = (yearMonth: string) => {\n  const [year, month] = yearMonth.split('-').map(Number);\n  const [nowYear, nowMonth] = today.split('-').map(Number);\n  return (year - nowYear) * 12 + (month - nowMonth);\n};\n\n/**\n * How the workspace pays: the card (brand, last four, expiry) and where invoices go. Within two\n * months of expiring, a line says which charge the card will miss.\n */\nexport function PaymentMethod() {\n  const left = monthsLeft(card.expires);\n\n  return (\n    <Card>\n      <Card.Header>\n        <div className=\"gap-ws-9 flex items-center justify-between\">\n          <h2 className=\"typography-subtitle-xs text-ws-static-strong\">Payment method</h2>\n          <Card.Action>\n            <Button size=\"sm\" variant=\"secondary\" preset=\"border\">\n              Update card\n            </Button>\n          </Card.Action>\n        </div>\n      </Card.Header>\n      <Card.Content>\n        <div className=\"gap-ws-12 flex flex-col\">\n          <div className=\"gap-ws-5 flex flex-col\">\n            <div className=\"gap-ws-5 flex items-center\">\n              {/* The brand as a Remix icon on a card-shaped chip; no logo artwork. */}\n              <span className=\"border-ws-static-base rounded-ws-control-md h-ws-14 w-ws-18 flex shrink-0 items-center justify-center border\">\n                <RiMastercardLine aria-hidden=\"true\" className=\"size-ws-11 text-ws-static-strong\" />\n              </span>\n              <div className=\"flex min-w-0 flex-col\">\n                <span className=\"typography-label-strong-sm text-ws-static-strong\">\n                  {card.brand} ending {card.last4}\n                </span>\n                <span className=\"typography-caption-md text-ws-static-subtle tabular-nums\">\n                  Expires {formatExpiry(card.expires)}\n                </span>\n              </div>\n            </div>\n            {left <= 1 && (\n              <p className=\"typography-caption-md text-ws-semantic-notice gap-ws-3 flex items-start\">\n                <RiErrorWarningLine aria-hidden=\"true\" className=\"size-ws-8 shrink-0\" />\n                <span>\n                  {left === 0 ? 'Expires this month.' : 'Expires next month.'} Update it before the\n                  charge on {formatDate(card.firstChargeAfterExpiry)}.\n                </span>\n              </p>\n            )}\n          </div>\n          <dl className=\"gap-ws-11 flex flex-col\">\n            <KeyValue label=\"Invoices go to\">{billingDetails.email}</KeyValue>\n            <KeyValue label=\"Billing address\">\n              {[billingDetails.company, ...billingDetails.address].map((line) => (\n                <span key={line} className=\"block\">\n                  {line}\n                </span>\n              ))}\n            </KeyValue>\n          </dl>\n        </div>\n      </Card.Content>\n    </Card>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/billing/people.assets.ts",
      "content": "// Portraits of the sample people as small JPEG data URLs (a block ships only .ts and .tsx).\n// Exported from the Wideset Core Figma file by people.cjs: do not edit by hand.\n\n/** A person’s photo by name. People who are not here show their initials. */\nexport const PHOTOS: Record<string, string | undefined> = {\n  'Maya Okafor':\n    'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAACRyWFlaAAABFAAAABRnWFlaAAABKAAAABRiWFlaAAABPAAAABR3dHB0AAABUAAAABRyVFJDAAABZAAAAChnVFJDAAABZAAAAChiVFJDAAABZAAAAChjcHJ0AAABjAAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAAgAAAAcAHMAUgBHAEJYWVogAAAAAAAAb6IAADj1AAADkFhZWiAAAAAAAABimQAAt4UAABjaWFlaIAAAAAAAACSgAAAPhAAAts9YWVogAAAAAAAA9tYAAQAAAADTLXBhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABtbHVjAAAAAAAAAAEAAAAMZW5VUwAAACAAAAAcAEcAbwBvAGcAbABlACAASQBuAGMALgAgADIAMAAxADb/2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PqA8AK6+5sVHb/5F01E4ln2pp9gpWgHcOePCqlvlt/Spqmx/lq5TVzSXgqYIoOCEb1HyA/9NVxrVjfHafA+rG/2JoVZAVmto141vcKM+FtjP//Z',\n};\n"
    },
    {
      "path": "src/blocks/billing/plan-card.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/plan-card.tsx",
      "content": "'use client';\n\n// TODO(custom): own h2 instead of Card.Title (20px on this branch).\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { Card } from '@/components/ui/wideset/card/Card';\n\nimport { type Interval, periodPrice, type Plan } from './data';\nimport { formatDate, formatUsd } from './format';\nimport { PlanUsage } from './plan-usage';\n\ntype PlanCardProps = {\n  plan: Plan;\n  interval: Interval;\n  seats: number;\n  periodStart: string;\n  periodEnd: string;\n  renews: string;\n  /** Set once the plan is cancelled: it then ends at the close of this period. */\n  cancelled: boolean;\n  onChangePlan: () => void;\n  onCancel: () => void;\n  onResume: () => void;\n};\n\n/**\n * The plan: its name and what to do with it in the header; what it costs per billing period, how\n * it is billed and when it renews under the price, and this period's usage against its limits.\n * The price is the page's key figure.\n */\nexport function PlanCard({\n  plan,\n  interval,\n  seats,\n  periodStart,\n  periodEnd,\n  renews,\n  cancelled,\n  onChangePlan,\n  onCancel,\n  onResume,\n}: PlanCardProps) {\n  const yearly = interval === 'yearly';\n\n  return (\n    <Card>\n      <Card.Header>\n        <div className=\"gap-ws-9 flex flex-wrap items-center justify-between\">\n          <h2 className=\"typography-subtitle-xs text-ws-static-strong min-w-0 flex-1\">\n            {plan.name} plan\n          </h2>\n          <Card.Action className=\"gap-ws-5\">\n            {cancelled ? (\n              <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={onResume}>\n                Resume plan\n              </Button>\n            ) : (\n              <Button size=\"sm\" variant=\"secondary\" preset=\"ghost\" onClick={onCancel}>\n                Cancel plan\n              </Button>\n            )}\n            <Button size=\"sm\" onClick={onChangePlan}>\n              Change plan\n            </Button>\n          </Card.Action>\n        </div>\n      </Card.Header>\n      <Card.Content>\n        <div className=\"gap-ws-16 flex flex-col\">\n          <div className=\"gap-ws-3 flex flex-col\">\n            <p className=\"gap-ws-5 flex items-baseline\">\n              <span className=\"typography-title-md text-ws-static-strong tabular-nums\">\n                {formatUsd(periodPrice(plan, interval, seats))}\n              </span>\n              <span className=\"typography-body-md text-ws-static-subtle\">\n                {yearly ? 'per year' : 'per month'}\n              </span>\n            </p>\n            {/* How it is billed reads with what it costs, not as the card's subtitle. */}\n            <p className=\"typography-body-md text-ws-static-base tabular-nums\">\n              {seats} seats × {formatUsd(plan.seatPrice[interval])}\n              {yearly ? ' a month, billed yearly' : ', billed monthly'},{' '}\n              {cancelled ? `ends on ${formatDate(periodEnd)}` : `renews on ${formatDate(renews)}`}\n            </p>\n          </div>\n          <PlanUsage plan={plan} seats={seats} periodStart={periodStart} periodEnd={periodEnd} />\n        </div>\n      </Card.Content>\n    </Card>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/plan-usage.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/plan-usage.tsx",
      "content": "'use client';\n\nimport { type Plan, usage } from './data';\nimport { formatCompact, formatCount, formatGb, formatPeriod } from './format';\nimport { UsageMeter } from './usage-meter';\n\ntype PlanUsageProps = {\n  plan: Plan;\n  seats: number;\n  periodStart: string;\n  periodEnd: string;\n};\n\n/** This period's usage against the plan's limits: four meters in one row. */\nexport function PlanUsage({ plan, seats, periodStart, periodEnd }: PlanUsageProps) {\n  const { contacts, apiCalls, storageGb } = plan.limits;\n  const seatsLeft = seats - usage.seats;\n\n  return (\n    <section aria-labelledby=\"billing-usage-title\" className=\"gap-ws-11 flex flex-col\">\n      <div className=\"gap-ws-5 flex items-baseline\">\n        <h3 id=\"billing-usage-title\" className=\"typography-label-strong-md text-ws-static-strong\">\n          Usage\n        </h3>\n        <span className=\"typography-body-md text-ws-static-subtle\">\n          {formatPeriod(periodStart, periodEnd)}\n        </span>\n      </div>\n      <div className=\"gap-x-ws-12 gap-y-ws-11 grid grid-cols-[repeat(auto-fit,minmax(9rem,1fr))]\">\n        <UsageMeter\n          label=\"Seats\"\n          used={usage.seats}\n          limit={seats}\n          usedText={formatCount(usage.seats)}\n          limitText={formatCount(seats)}\n          note={`${seatsLeft} ${seatsLeft === 1 ? 'seat' : 'seats'} left`}\n        />\n        <UsageMeter\n          label=\"Contacts\"\n          used={usage.contacts}\n          limit={contacts}\n          usedText={formatCompact(usage.contacts)}\n          limitText={formatCompact(contacts)}\n          note={`${formatCount(contacts - usage.contacts)} left`}\n        />\n        <UsageMeter\n          label=\"API calls\"\n          used={usage.apiCalls}\n          limit={apiCalls}\n          usedText={formatCompact(usage.apiCalls)}\n          limitText={formatCompact(apiCalls)}\n          note={`${formatCompact(apiCalls - usage.apiCalls)} left this month`}\n        />\n        <UsageMeter\n          label=\"Storage\"\n          used={usage.storageGb}\n          limit={storageGb}\n          usedText={formatGb(usage.storageGb)}\n          limitText={formatGb(storageGb)}\n          note={`${formatGb(storageGb - usage.storageGb)} left`}\n        />\n      </div>\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/sidebar.tsx",
      "content": "'use client';\n\n// TODO(custom): workspace switcher and account menu are composed by hand.\nimport {\n  RiAddLine,\n  RiArrowDownSLine,\n  RiLogoutBoxRLine,\n  RiSearchLine,\n  RiSettingsLine,\n} from '@remixicon/react';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { Divider } from '@/components/ui/wideset/divider/Divider';\nimport { DropdownMenu } from '@/components/ui/wideset/dropdown/DropdownMenu';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ListItem } from '@/components/ui/wideset/list-item/ListItem';\nimport { Sidebar } from '@/components/ui/wideset/sidebar/Sidebar';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useState } from 'react';\n\nimport { BrandMark } from './brand-mark';\nimport {\n  account,\n  helpLink,\n  mainLinks,\n  type NavLink,\n  product,\n  settingsLinks,\n  workspace,\n} from './data';\nimport { PHOTOS } from './people.assets';\n\n/** The workspace sidebar: switcher, search, the app's pages, settings and the signed-in account. */\nexport function BillingSidebar() {\n  const [active, setActive] = useState('billing');\n  const photo = PHOTOS[account.name];\n\n  const link = ({ id, label, icon, activeIcon }: NavLink) => (\n    <Sidebar.Item\n      key={id}\n      href={`#${id}`}\n      icon={active === id ? (activeIcon ?? icon) : icon}\n      label={label}\n      active={active === id}\n      onClick={() => setActive(id)}\n    />\n  );\n\n  return (\n    <Sidebar>\n      <Sidebar.Header>\n        <div className=\"gap-ws-9 flex flex-col\">\n          <div className=\"gap-ws-7 pt-ws-3 pb-ws-7 flex items-center\">\n            <BrandMark className=\"size-ws-15\" />\n            <div className=\"flex min-w-0 flex-1 flex-col\">\n              <span className=\"typography-label-strong-sm text-ws-static-strong truncate\">\n                {workspace.name}\n              </span>\n              <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                {product.name}\n              </span>\n            </div>\n            <DropdownMenu>\n              <DropdownMenu.Trigger asChild>\n                <IconButton\n                  icon={RiArrowDownSLine}\n                  variant=\"secondary\"\n                  preset=\"ghost\"\n                  size=\"xs\"\n                  aria-label=\"Switch workspace\"\n                  className=\"mr-ws-3\"\n                />\n              </DropdownMenu.Trigger>\n              <DropdownMenu.Content className=\"ws-block-utility\" align=\"end\">\n                <DropdownMenu.Item data-state=\"checked\">\n                  <ListItem.Content>\n                    <ListItem.Label>{workspace.name}</ListItem.Label>\n                  </ListItem.Content>\n                </DropdownMenu.Item>\n                <DropdownMenu.Separator />\n                <DropdownMenu.Item>\n                  <ListItem.Prefix>\n                    <RiAddLine className=\"size-ws-9\" />\n                  </ListItem.Prefix>\n                  <ListItem.Content>\n                    <ListItem.Label>New workspace</ListItem.Label>\n                  </ListItem.Content>\n                </DropdownMenu.Item>\n              </DropdownMenu.Content>\n            </DropdownMenu>\n          </div>\n          <TextInput size=\"sm\">\n            <TextInput.Prefix inner>\n              <TextInput.Icon icon={RiSearchLine} />\n            </TextInput.Prefix>\n            <TextInput.Input type=\"search\" placeholder=\"Search\" aria-label=\"Search\" />\n          </TextInput>\n        </div>\n      </Sidebar.Header>\n\n      <Sidebar.Section scrollable>\n        <Sidebar.Expanded>\n          <nav aria-label=\"Workspace\" className=\"gap-ws-9 flex flex-col\">\n            <div className=\"flex flex-col\">{mainLinks.map(link)}</div>\n            <Divider weight=\"thin\" />\n            <div role=\"group\" aria-labelledby=\"sidebar-settings\" className=\"gap-ws-2 flex flex-col\">\n              <Sidebar.SectionHeader id=\"sidebar-settings\">Settings</Sidebar.SectionHeader>\n              {settingsLinks.map(link)}\n            </div>\n          </nav>\n        </Sidebar.Expanded>\n      </Sidebar.Section>\n\n      <Sidebar.Footer>\n        <div className=\"gap-ws-9 flex flex-col\">\n          <div className=\"flex flex-col\">{link(helpLink)}</div>\n          {/* On the grey ground the line keeps the nav's inset: run edge to edge, it would stop\n              short of the page and read as broken. */}\n          <div className=\"border-ws-static-base pt-ws-5 border-t\">\n            <DropdownMenu>\n              <DropdownMenu.Trigger asChild>\n                <button\n                  type=\"button\"\n                  className=\"gap-ws-5 px-ws-5 py-ws-3 rounded-ws-control-lg hover:bg-ws-dynamic-tertiary-alpha-strong-default focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default flex w-full items-center text-left\"\n                >\n                  {photo ? (\n                    <Avatar src={photo} alt=\"\" initials={account.initials} />\n                  ) : (\n                    <Avatar initials={account.initials} color=\"orange\" />\n                  )}\n                  <span className=\"flex min-w-0 flex-1 flex-col\">\n                    <span className=\"typography-label-strong-sm text-ws-static-base truncate\">\n                      {account.name}\n                    </span>\n                    <span className=\"typography-caption-md text-ws-static-subtle truncate\">\n                      {account.email}\n                    </span>\n                  </span>\n                  <RiArrowDownSLine\n                    aria-hidden=\"true\"\n                    className=\"size-ws-9 text-ws-static-strong\"\n                  />\n                </button>\n              </DropdownMenu.Trigger>\n              <DropdownMenu.Content side=\"top\" align=\"start\" className=\"ws-block-utility w-[14rem]\">\n                <DropdownMenu.Item>\n                  <ListItem.Prefix>\n                    <RiSettingsLine className=\"size-ws-9\" />\n                  </ListItem.Prefix>\n                  <ListItem.Content>\n                    <ListItem.Label>Account settings</ListItem.Label>\n                  </ListItem.Content>\n                </DropdownMenu.Item>\n                <DropdownMenu.Separator />\n                <DropdownMenu.Item variant=\"danger\">\n                  <ListItem.Prefix>\n                    <RiLogoutBoxRLine className=\"size-ws-9\" />\n                  </ListItem.Prefix>\n                  <ListItem.Content>\n                    <ListItem.Label>Log out</ListItem.Label>\n                  </ListItem.Content>\n                </DropdownMenu.Item>\n              </DropdownMenu.Content>\n            </DropdownMenu>\n          </div>\n        </div>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    },
    {
      "path": "src/blocks/billing/usage-meter.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/billing/usage-meter.tsx",
      "content": "'use client';\n\n// TODO(custom): usage meter (value / limit, bar, note); ProgressBar neutral/warning arrive with #58.\nimport { RiErrorWarningLine } from '@remixicon/react';\nimport { cn } from '@/lib/wideset/utils';\nimport { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';\n\nimport { NEAR_LIMIT } from './data';\n\ntype UsageMeterProps = {\n  label: string;\n  used: number;\n  limit: number;\n  /** The amount as read: `38`, `41.3K`, `63.4`. */\n  usedText: string;\n  /** The limit as read, with its unit: `40`, `50K`, `100 GB`. */\n  limitText: string;\n  /** One line under the bar: what is left, or when it resets. */\n  note: string;\n};\n\n/**\n * Usage against a limit: the amount large, the limit beside it, a bar, one line of context. Close\n * to the limit (90%), the line turns to a warning; the colour sits on that line, not the whole\n * meter.\n */\nexport function UsageMeter({ label, used, limit, usedText, limitText, note }: UsageMeterProps) {\n  const near = used / limit >= NEAR_LIMIT;\n\n  return (\n    <div className=\"gap-ws-5 flex min-w-0 flex-col\">\n      <div className=\"gap-ws-3 flex flex-col\">\n        <span className=\"typography-label-sm text-ws-static-subtle\">{label}</span>\n        <p className=\"gap-ws-3 flex items-baseline tabular-nums\">\n          <span className=\"typography-subtitle-sm text-ws-static-strong\">{usedText}</span>\n          <span className=\"typography-body-md text-ws-static-subtle\">/ {limitText}</span>\n        </p>\n      </div>\n      {/* The bar takes the brand colour until ProgressBar has `neutral` and `warning` variants;\n          then: variant={near ? 'warning' : 'neutral'}. */}\n      <ProgressBar value={used} max={limit} aria-label={`${label}: ${usedText} of ${limitText}`} />\n      <p\n        className={cn(\n          'typography-caption-md gap-ws-3 flex items-center',\n          near ? 'text-ws-semantic-notice' : 'text-ws-static-subtle',\n        )}\n      >\n        {near && <RiErrorWarningLine aria-hidden=\"true\" className=\"size-ws-8 shrink-0\" />}\n        {note}\n      </p>\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
