{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-referrals",
  "type": "registry:block",
  "title": "Referrals",
  "description": "A referral programme on a raised page: the deal in one line, the link to copy and an invite by e-mail, the credit earned and available beside progress to the next reward, the people invited with their status, and redeeming credit against the next invoice in a confirm dialog.",
  "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/form-field.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/progress-bar.json",
    "https://wideset.co/r/sidebar.json",
    "https://wideset.co/r/status-badge.json",
    "https://wideset.co/r/status-modal.json",
    "https://wideset.co/r/table.json",
    "https://wideset.co/r/text-input.json",
    "https://wideset.co/r/toast.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/referrals/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/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/referrals/credit-summary.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/credit-summary.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { cn } from '@/lib/wideset/utils';\nimport { forwardRef } from 'react';\n\nimport { programme } from './data';\nimport { formatDay, formatTeams, formatUsd } from './format';\nimport { KeyFigure } from './key-figure';\nimport { RewardProgress } from './reward-progress';\n\n/** A figure after the first: a line on its left, then the 16px a table cell is padded by, so the\n    figures stand on the columns of the table under them. */\nconst DIVIDED = 'border-ws-static-subtle pl-ws-9 border-l';\n\ntype CreditSummaryProps = {\n  /** Credit earned so far, bonuses included. */\n  earned: number;\n  /** Credit that has gone against an invoice, this page's redemption included. */\n  redeemed: number;\n  /** Credit redeemed on this page: it comes off the next invoice. */\n  applied: number;\n  /** The day the next invoice is issued. */\n  invoiceDate: string;\n  /** Subscribed teams counted towards the next bonus. */\n  towardsBonus: number;\n  onRedeem: () => void;\n  className?: string;\n};\n\n/**\n * How the programme is going, as one row of figures split by lines: the money on the left half\n * (what was earned, what is left to spend), the progress to the next bonus on the right half,\n * under the two halves of the share row. Only the progress has a bar. Redeeming is the available\n * credit's own action, a secondary button on its line; once the credit is spent the button goes\n * and the line under the figure says where the money went. The row can take focus, for the\n * moment the button that held it is gone.\n */\nexport const CreditSummary = forwardRef<HTMLElement, CreditSummaryProps>(function CreditSummary(\n  { earned, redeemed, applied, invoiceDate, towardsBonus, onRedeem, className },\n  ref,\n) {\n  const available = earned - redeemed;\n  const toGo = programme.bonus.every - towardsBonus;\n\n  return (\n    <section\n      ref={ref}\n      tabIndex={-1}\n      aria-label=\"Credit\"\n      className={cn('grid grid-cols-4 outline-none', className)}\n    >\n      <KeyFigure\n        label=\"Credit earned\"\n        value={formatUsd(earned)}\n        note={`${formatUsd(redeemed)} redeemed so far`}\n        className=\"pr-ws-9\"\n      />\n      <KeyFigure\n        label=\"Credit available\"\n        value={formatUsd(available)}\n        note={\n          applied\n            ? `${formatUsd(applied)} off the ${formatDay(invoiceDate)} invoice`\n            : 'Not yet applied to an invoice'\n        }\n        action={\n          available > 0 && (\n            <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={onRedeem}>\n              Redeem\n            </Button>\n          )\n        }\n        className={cn(DIVIDED, 'pr-ws-9')}\n      />\n      <RewardProgress\n        label=\"Next reward\"\n        value={towardsBonus}\n        target={programme.bonus.every}\n        unit=\"teams subscribed\"\n        note={`${formatTeams(toGo)} to go for a ${formatUsd(programme.bonus.amount)} bonus`}\n        className={cn(DIVIDED, 'col-span-2')}\n      />\n    </section>\n  );\n});\n"
    },
    {
      "path": "src/blocks/referrals/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBankCardLine,\n  RiContactsBook3Line,\n  RiGiftFill,\n  RiGiftLine,\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/*\n  Orbit's referral programme, as Lumen Studio sees it on 10 November 2026. A team that subscribes\n  through Lumen Studio's link earns it $200 of credit, and every fifth team adds a $500 bonus.\n  Three teams have subscribed ($600 earned), $200 of that already came off November's invoice, so\n  $400 is left to redeem against December's: Growth, 40 seats at $39 = $1,560.00. Every figure on\n  the page is worked out below from these values.\n*/\n\n/** The product is Orbit; the workspace referring others to 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: a new invitation is dated with 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 },\n  { id: 'referrals', label: 'Referrals', icon: RiGiftLine, activeIcon: RiGiftFill },\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\n/** The deal: what a referral earns, and the bonus every few of them add. */\nexport const programme = {\n  link: 'https://orbit.so/r/lumen-studio',\n  /** Credit for each referred team, once it subscribes. */\n  reward: 200,\n  /** The bonus, and how many subscribed teams it takes to earn one. */\n  bonus: { amount: 500, every: 5 },\n};\n\n/** Where a referred team stands. Only `subscribed` earns the reward. */\nexport type ReferralStatus = 'invited' | 'signed-up' | 'subscribed';\n\nexport type Referral = {\n  /** The address the invitation went to: it is all the page knows about the person. */\n  email: string;\n  /** The day the invitation was sent. */\n  invited: string;\n  status: ReferralStatus;\n};\n\n/** Everyone invited so far, newest first. */\nexport const referrals: Referral[] = [\n  { email: 'owen@tallgrasslabs.co', invited: '2026-11-06', status: 'invited' },\n  { email: 'rosa@pinecrest.studio', invited: '2026-11-03', status: 'invited' },\n  { email: 'kenji@harborlane.co', invited: '2026-10-27', status: 'signed-up' },\n  { email: 'amara@fernhill.agency', invited: '2026-10-08', status: 'subscribed' },\n  { email: 'felix@quarryworks.io', invited: '2026-09-16', status: 'subscribed' },\n  { email: 'sofia@larkspur.design', invited: '2026-08-21', status: 'subscribed' },\n];\n\n/** Credit that already came off an invoice, before today. */\nexport const redeemedBefore = 200;\n\n/** The invoice the credit goes against next: December's seats, before any credit. */\nexport const nextInvoice = { date: '2026-12-01', description: 'Growth, 40 seats', amount: 1_560 };\n\n/** What a referral has earned: the reward once the team subscribed, nothing before. */\nexport const rewardOf = (referral: Referral) =>\n  referral.status === 'subscribed' ? programme.reward : 0;\n\n/** Where the credit stands for a list of referrals: what it earned and how far the bonus is. */\nexport function creditOf(list: Referral[]) {\n  const subscribed = list.filter((referral) => referral.status === 'subscribed').length;\n  const bonuses = Math.floor(subscribed / programme.bonus.every);\n  return {\n    subscribed,\n    earned: subscribed * programme.reward + bonuses * programme.bonus.amount,\n    /** Subscribed teams counted towards the next bonus, and how many it takes. */\n    towardsBonus: subscribed % programme.bonus.every,\n  };\n}\n"
    },
    {
      "path": "src/blocks/referrals/field-with-action.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/field-with-action.tsx",
      "content": "'use client';\n\n// TODO(custom): a field with its button beside it under one label; FormField wires the helper and error text to a single control only, and TextInput's own button sits inside the field as ghost text.\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { type TextInputProps } from '@/components/ui/wideset/text-input/TextInput.types';\nimport type { ReactNode } from 'react';\n\ntype FieldWithActionProps = Omit<TextInputProps, 'size' | 'children'> & {\n  /** The button that acts on the field's value. */\n  action: ReactNode;\n};\n\n/**\n * A text field and the button that acts on it, on one row. It is the one child `FormField` sees,\n * so the `aria-describedby` and `aria-invalid` the form field hands down land on the input and\n * not on the row around it.\n */\nexport function FieldWithAction({ action, ...input }: FieldWithActionProps) {\n  return (\n    <div className=\"gap-ws-5 flex\">\n      <TextInput size=\"sm\" className=\"min-w-0 flex-1\" {...input} />\n      {action}\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/format.ts",
      "content": "// One locale and currency for the whole screen; swap them for the workspace's.\nconst LOCALE = 'en-US';\n\nconst usd = new Intl.NumberFormat(LOCALE, { style: 'currency', currency: 'USD' });\n// Dates are calendar days (`2026-11-10`), 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 day = new Intl.DateTimeFormat(LOCALE, { day: 'numeric', month: 'short', timeZone: 'UTC' });\nconst plural = new Intl.PluralRules(LOCALE);\n\nexport const formatUsd = (value: number) => usd.format(value);\nexport const formatDate = (iso: string) => date.format(new Date(iso));\n/** A day without its year, where the year is plain from the page: `Dec 1`. */\nexport const formatDay = (iso: string) => day.format(new Date(iso));\n/** `1 team`, `3 teams`. */\nexport const formatTeams = (count: number) =>\n  `${count} ${plural.select(count) === 'one' ? 'team' : 'teams'}`;\n"
    },
    {
      "path": "src/blocks/referrals/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/index.tsx",
      "content": "'use client';\n\nimport '@/styles/wideset-blocks.css';\n\nimport { RiSideBarLine } from '@remixicon/react';\nimport { AppShell } from '@/components/ui/wideset/app-shell/AppShell';\nimport { Breadcrumbs } from '@/components/ui/wideset/breadcrumbs/Breadcrumbs';\nimport { Card } from '@/components/ui/wideset/card/Card';\nimport { cn } from '@/lib/wideset/utils';\nimport { IconButton } from '@/components/ui/wideset/button/IconButton';\nimport { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';\nimport { useId, useRef, useState } from 'react';\n\nimport { CreditSummary } from './credit-summary';\nimport {\n  account,\n  creditOf,\n  nextInvoice,\n  programme,\n  redeemedBefore,\n  type Referral,\n  referrals,\n  today,\n} from './data';\nimport { formatDate, formatUsd } from './format';\nimport { InviteByEmail } from './invite-by-email';\nimport { PageHeader } from './page-header';\nimport { RedeemDialog } from './redeem-dialog';\nimport { ReferralsTable } from './referrals-table';\nimport { Section } from './section';\nimport { ShareLink } from './share-link';\nimport { ReferralsSidebar } from './sidebar';\n\n/** One column of the page: the header and the body share its edges. */\nconst COLUMN = 'px-ws-14 mx-auto w-full max-w-[80rem]';\n/** A band under another: a line and space above it. Only sharing, the page's job, has a box. */\nconst LINE = 'border-ws-static-subtle pt-ws-12 border-t';\n\n/**\n * The page, in the order it is used: the deal in one line, the two ways to share in a card (the\n * page's main action, so the one thing boxed), how the credit stands, then who was invited. It holds the invitations and the credit redeemed here, so sending\n * an invite adds a row and redeeming moves the figures.\n */\nfunction ReferralsPage() {\n  const { showToast } = useToast();\n  const [invited, setInvited] = useState<Referral[]>(referrals);\n  const [applied, setApplied] = useState(0);\n  const [redeeming, setRedeeming] = useState(false);\n  const summary = useRef<HTMLElement>(null);\n  const shareId = useId();\n\n  const credit = creditOf(invited);\n  const redeemed = redeemedBefore + applied;\n  // Credit never takes an invoice below zero: what is left over stays available.\n  const redeemable = Math.min(credit.earned - redeemed, nextInvoice.amount);\n\n  const invite = (email: string) => {\n    setInvited([{ email, invited: today, status: 'invited' }, ...invited]);\n    showToast({ status: 'success', content: `Invitation sent to ${email}` });\n  };\n\n  const redeem = () => {\n    setApplied(applied + redeemable);\n    setRedeeming(false);\n    showToast({\n      status: 'success',\n      content: `${formatUsd(redeemable)} comes off your ${formatDate(nextInvoice.date)} invoice`,\n    });\n  };\n\n  return (\n    <div className={cn(COLUMN, 'gap-ws-12 pt-ws-14 pb-ws-16 flex flex-col')}>\n      <PageHeader />\n\n      {/* The page's main action in the page's one card: the two ways to share. */}\n      <Card role=\"region\" aria-labelledby={shareId}>\n        <Card.Header>\n          <h2 id={shareId} className=\"typography-label-strong-md text-ws-static-strong\">\n            Share your link\n          </h2>\n        </Card.Header>\n        {/* Card.Content keeps 10px free on the right for a scrollbar: the padding gives it back.\n            The 32px gap puts the second field on the line of the figures' right half below. */}\n        <Card.Content contentClassName=\"pr-ws-6\">\n          <div className=\"gap-ws-14 grid grid-cols-2 items-start\">\n            <ShareLink link={programme.link} quiet={redeeming} />\n            <InviteByEmail\n              taken={[account.email, ...invited.map((referral) => referral.email)]}\n              onInvite={invite}\n            />\n          </div>\n        </Card.Content>\n      </Card>\n\n      <CreditSummary\n        ref={summary}\n        earned={credit.earned}\n        redeemed={redeemed}\n        applied={applied}\n        invoiceDate={nextInvoice.date}\n        towardsBonus={credit.towardsBonus}\n        onRedeem={() => setRedeeming(true)}\n        // The card's border closes the band above: no line of its own, the space does it.\n        className=\"pt-ws-9\"\n      />\n\n      <Section title=\"Invitations\" className={LINE}>\n        <ReferralsTable referrals={invited} />\n      </Section>\n\n      <RedeemDialog\n        open={redeeming}\n        onOpenChange={setRedeeming}\n        amount={redeemable}\n        invoice={nextInvoice}\n        onConfirm={redeem}\n        // Redeeming removes the button that opened the dialog: the figures take the focus.\n        onCloseAutoFocus={(event) => {\n          if (!applied) return;\n          event.preventDefault();\n          summary.current?.focus();\n        }}\n      />\n    </div>\n  );\n}\n\n/**\n * Referrals (Inset direction): Orbit's referral programme as a settings page on the raised card\n * beside the workspace sidebar. No hero and no illustration: the link and its Copy button lead, in\n * the page's one card; the credit is three plain figures with one bar, and the people invited are\n * a short table, both on the white under lines.\n */\nexport default function Referrals() {\n  const sidebarId = useId();\n  const [collapsed, setCollapsed] = useState(false);\n\n  return (\n    <ToastProvider>\n      <AppShell className=\"ws-block-utility\" direction=\"inset\">\n        <ReferralsSidebar id={sidebarId} collapsed={collapsed} onCollapsedChange={setCollapsed} />\n        <AppShell.Main>\n          <div className=\"h-ws-18 border-ws-static-base flex shrink-0 items-center border-b\">\n            {/* The bar belongs to the surround: it runs edge to edge. The sidebar's toggle is\n                pulled left so its glyph, not its box, sits 20px from the edge; the crumbs follow\n                it. */}\n            <div className=\"gap-ws-5 px-ws-11 flex w-full items-center\">\n              <IconButton\n                icon={RiSideBarLine}\n                variant=\"secondary\"\n                preset=\"ghost\"\n                size=\"sm\"\n                iconClassName=\"text-ws-static-subtle size-ws-9\"\n                aria-label={collapsed ? 'Expand sidebar' : 'Collapse sidebar'}\n                aria-expanded={!collapsed}\n                aria-controls={sidebarId}\n                onClick={() => setCollapsed(!collapsed)}\n                className=\"-ml-ws-5\"\n              />\n              <Breadcrumbs separator=\"arrow\">\n                <Breadcrumbs.Item asChild>\n                  <a href=\"#settings\">Settings</a>\n                </Breadcrumbs.Item>\n                <Breadcrumbs.Item>Referrals</Breadcrumbs.Item>\n              </Breadcrumbs>\n            </div>\n          </div>\n\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            <ReferralsPage />\n          </div>\n        </AppShell.Main>\n      </AppShell>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/invite-by-email.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/invite-by-email.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { type FormEvent, useId, useState } from 'react';\n\nimport { FieldWithAction } from './field-with-action';\n\nconst EMAIL = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\ntype InviteByEmailProps = {\n  /** Addresses that cannot be invited: the ones already invited and the sender's own. */\n  taken: string[];\n  onInvite: (email: string) => void;\n  className?: string;\n};\n\n/**\n * Inviting one person by e-mail: a field and its button, so Enter sends too. The address is\n * checked on submit, never while it is typed; what is wrong is said under the field, which keeps\n * the value to be corrected and takes the focus back.\n */\nexport function InviteByEmail({ taken, onInvite, className }: InviteByEmailProps) {\n  const id = useId();\n  const [email, setEmail] = useState('');\n  const [error, setError] = useState<string>();\n\n  const send = (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault();\n    const typed = email.trim().toLowerCase();\n    const problem = !typed\n      ? 'Enter an e-mail address.'\n      : !EMAIL.test(typed)\n        ? 'Enter an e-mail address like name@company.com.'\n        : taken.includes(typed)\n          ? `${typed} has already been invited.`\n          : undefined;\n    setError(problem);\n    if (problem) return document.getElementById(id)?.focus();\n    onInvite(typed);\n    setEmail('');\n  };\n\n  return (\n    <form noValidate onSubmit={send} className={className}>\n      <FormField\n        label=\"Invite by e-mail\"\n        htmlFor={id}\n        helperText=\"We send your link with a short note in your name.\"\n        errorText={error}\n      >\n        <FieldWithAction\n          id={id}\n          name=\"email\"\n          type=\"email\"\n          autoComplete=\"off\"\n          placeholder=\"name@company.com\"\n          variant={error ? 'danger' : 'primary'}\n          value={email}\n          onChange={(event) => {\n            setEmail(event.target.value);\n            setError(undefined);\n          }}\n          action={\n            <Button\n              type=\"submit\"\n              size=\"sm\"\n              variant=\"secondary\"\n              preset=\"border\"\n              className=\"shrink-0\"\n            >\n              Send\n            </Button>\n          }\n        />\n      </FormField>\n    </form>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/key-figure.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/key-figure.tsx",
      "content": "'use client';\n\n// TODO(custom): key figure (label, figure, a line under it, an action beside the figure); no stat or KpiCard component in Wideset.\nimport { cn } from '@/lib/wideset/utils';\nimport type { ReactNode } from 'react';\n\nexport type KeyFigureProps = {\n  label: string;\n  /** The figure, formatted: `$600.00`. */\n  value: string;\n  /** What the figure is made of, or what happens to it next: one line. */\n  note: string;\n  /** The one thing to do with the figure, on its line. */\n  action?: ReactNode;\n  className?: string;\n};\n\n/**\n * A key figure: what it measures, the number, and one line that explains it. No bar and no\n * badge: an amount of credit is not a judgement. What can be done with the figure sits on the\n * figure's own line, so it reads as that figure's action and not the page's.\n */\nexport function KeyFigure({ label, value, note, action, className }: KeyFigureProps) {\n  return (\n    <div className={cn('gap-ws-5 flex min-w-0 flex-col', className)}>\n      <div className=\"gap-ws-3 flex flex-col\">\n        <p className=\"typography-label-sm text-ws-static-subtle\">{label}</p>\n        <div className=\"gap-ws-9 flex items-center justify-between\">\n          <p className=\"typography-title-md text-ws-static-strong tabular-nums\">{value}</p>\n          {action}\n        </div>\n      </div>\n      <p className=\"typography-label-sm text-ws-static-subtle tabular-nums\">{note}</p>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/page-header.tsx",
      "content": "'use client';\n\n// TODO(custom): page header (title and a line of description); no PageHeader in Wideset.\nimport { product, programme } from './data';\nimport { formatUsd } from './format';\n\n/**\n * The page's title and the deal in one line: what a referral earns and when. The page has no\n * action of its own up here: sharing, its main job, starts right under the header.\n */\nexport function PageHeader() {\n  return (\n    <header className=\"gap-ws-2 flex min-w-0 flex-col\">\n      <h1 className=\"typography-title-md text-ws-static-strong\">Referrals</h1>\n      <p className=\"typography-body-md text-ws-static-subtle tabular-nums\">\n        Earn {formatUsd(programme.reward)} in credit for each team that subscribes to {product.name}{' '}\n        through your link.\n      </p>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/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/4gHYSUNDX1BST0ZJTEUAAQEAAAHIAAAAAAQwAABtbnRyUkdCIFhZWiAH4AABAAEAAAAAA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7cWIMKMt+U+oJQ2kck/wBB6+FO0KoGAoiRZ6dTvuo/aajiSmJrCH4zzbzCxlLjagpKvsRSkVI9NdPGNOaVtdmwlS4rQSpYGMq5Kj7qJNHSNGPhO+O4Ck+Ch3Vsmi2Ia27QW9Tar4T/ABI0mjBxR0q3SoKsPtFIH+ocik4NBII5zbp1UqrxIcj0jzpzT72oJvZoO1hvBdX5DyHqatJmzxrSlLcZlKGsDuHP80RoW3CFp+Orbhb+XVHzz3fjFP7mFpQT5lJrQpUwq56zz/WNRe5rtTB8KnAHzELaQ5jP80oTltQUPeiktlh1SPDvFGnuowmPIjqrppadUuLlMuKgXFf7nWk5Ss+akeP3GDVbS+id8TJQf8FKbTxuS4U59iKvTOPPNe7RYP7iKRr6fQrHiYYPpH7fU7igOFWyPWUOr4fZ90dQqZNjQmU+DSS4r27h75qxNJ9NrBoZClwGC7NcG1cp47nFDyz4D0GKmaipYwSTRak/UPSrULGjQOUG/nK3GoV7gYdtvIbRKIyFHcoZJNKEMJSg4AAr2PqA8AK6+5sVHb/5F01E4ln2pp9gpWgHcOePCqlvlt/Spqmx/lq5TVzSXgqYIoOCEb1HyA/9NVxrVjfHafA+rG/2JoVZAVmto141vcKM+FtjP//Z',\n};\n"
    },
    {
      "path": "src/blocks/referrals/person-avatar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/person-avatar.tsx",
      "content": "'use client';\n\nimport type { AvatarProps } from '@/components/ui/wideset/avatar/Avatar.types';\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\n\nimport { PHOTOS } from './people.assets';\n\ntype PersonAvatarProps = Pick<\n  AvatarProps,\n  'size' | 'shape' | 'status' | 'color' | 'className' | 'title' | 'aria-hidden' | 'aria-label'\n> & {\n  /** The person's full name: the key their photo is filed under. */\n  name: string;\n  initials: string;\n  /** Leave empty beside the person's name; pass the name where the avatar stands alone. */\n  alt?: string;\n};\n\n/**\n * A person's avatar: their photo when the sample people have one, otherwise their initials in\n * their colour. A real product mixes the two, so every place the block draws a person asks here\n * and the choice is made once. The initials stay as the fallback if the image fails to load.\n */\nexport function PersonAvatar({ name, initials, color, alt = '', ...props }: PersonAvatarProps) {\n  const photo = PHOTOS[name];\n  return photo ? (\n    <Avatar src={photo} alt={alt} initials={initials} {...props} />\n  ) : (\n    <Avatar initials={initials} color={color} {...props} />\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/redeem-dialog.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/redeem-dialog.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { StatusModal } from '@/components/ui/wideset/status-modal/StatusModal';\n\nimport { formatDate, formatUsd } from './format';\n\ntype RedeemDialogProps = {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  /** The credit that will be redeemed. */\n  amount: number;\n  /** The invoice it goes against: what it is for, when it is issued and what it comes to. */\n  invoice: { description: string; date: string; amount: number };\n  onConfirm: () => void;\n  /** Runs as the dialog hands focus back; prevent it to send focus somewhere else. */\n  onCloseAutoFocus?: (event: Event) => void;\n};\n\n/**\n * The one question before credit is spent: how much, against which invoice, and what is left to\n * pay. It is asked because applied credit cannot be taken back. A neutral status modal: nothing\n * is at risk, so no warning colour; Cancel and Esc leave the credit where it is.\n */\nexport function RedeemDialog({\n  open,\n  onOpenChange,\n  amount,\n  invoice,\n  onConfirm,\n  onCloseAutoFocus,\n}: RedeemDialogProps) {\n  return (\n    <StatusModal open={open} onOpenChange={onOpenChange}>\n      <StatusModal.Content className=\"ws-block-utility\" onCloseAutoFocus={onCloseAutoFocus}>\n        <StatusModal.Title>Redeem {formatUsd(amount)} of credit?</StatusModal.Title>\n        <StatusModal.Body>\n          It goes against your next invoice: {invoice.description}, issued on{' '}\n          {formatDate(invoice.date)}. You pay {formatUsd(invoice.amount - amount)} instead of{' '}\n          {formatUsd(invoice.amount)}. Credit cannot be moved back once it is applied.\n        </StatusModal.Body>\n        <StatusModal.Footer>\n          <StatusModal.Close asChild>\n            <Button variant=\"secondary\" preset=\"border\">\n              Cancel\n            </Button>\n          </StatusModal.Close>\n          <Button onClick={onConfirm}>{`Redeem ${formatUsd(amount)}`}</Button>\n        </StatusModal.Footer>\n      </StatusModal.Content>\n    </StatusModal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/referrals-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/referrals-table.tsx",
      "content": "'use client';\n\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { type StatusBadgeProps } from '@/components/ui/wideset/status-badge/StatusBadge.types';\nimport { Table } from '@/components/ui/wideset/table/Table';\n\nimport { type Referral, type ReferralStatus, rewardOf } from './data';\nimport { formatDate, formatUsd } from './format';\n\n/**\n * Each step of a referral carries its meaning: an invitation is waiting on the other side\n * (notice), a team signed up is on its way (info), a subscribed team is done and earned the\n * credit (positive).\n */\nconst STATUS: Record<ReferralStatus, { label: string; color: StatusBadgeProps['color'] }> = {\n  invited: { label: 'Invited', color: 'notice' },\n  'signed-up': { label: 'Signed up', color: 'info' },\n  subscribed: { label: 'Subscribed', color: 'positive' },\n};\n\n/**\n * Who was invited, newest first: the address, the day, how far they got and what it earned. The\n * reward is an amount, so it is right-aligned in tabular figures; a referral that has earned\n * nothing yet shows a dash, not $0.00.\n */\nexport function ReferralsTable({ referrals }: { referrals: Referral[] }) {\n  return (\n    <Table className=\"table-fixed\">\n      <Table.Head>\n        <Table.Row>\n          {/* Half, then a quarter: the columns stand under the figures above the table. */}\n          <Table.Header flushMargin className=\"w-[50%]\">\n            E-mail\n          </Table.Header>\n          <Table.Header className=\"w-[25%]\">Sent</Table.Header>\n          <Table.Header>Status</Table.Header>\n          <Table.Header align=\"right\" flushMargin className=\"w-[6rem]\">\n            Reward\n          </Table.Header>\n        </Table.Row>\n      </Table.Head>\n      <Table.Body>\n        {referrals.map((referral) => {\n          const reward = rewardOf(referral);\n          return (\n            <Table.Row key={referral.email}>\n              <Table.Cell flushMargin truncate className=\"text-ws-static-strong\">\n                {referral.email}\n              </Table.Cell>\n              <Table.Cell className=\"tabular-nums\">{formatDate(referral.invited)}</Table.Cell>\n              <Table.Cell>\n                <StatusBadge size=\"sm\" color={STATUS[referral.status].color}>\n                  {STATUS[referral.status].label}\n                </StatusBadge>\n              </Table.Cell>\n              <Table.Cell align=\"right\" flushMargin className=\"tabular-nums\">\n                {reward ? (\n                  formatUsd(reward)\n                ) : (\n                  <span className=\"text-ws-static-subtle\">\n                    <span aria-hidden=\"true\">–</span>\n                    <span className=\"sr-only\">Nothing yet</span>\n                  </span>\n                )}\n              </Table.Cell>\n            </Table.Row>\n          );\n        })}\n      </Table.Body>\n    </Table>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/reward-progress.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/reward-progress.tsx",
      "content": "'use client';\n\n// TODO(custom): goal meter (a count against a target, one bar, what is left); ProgressBar's own label shows only a percentage.\nimport { cn } from '@/lib/wideset/utils';\nimport { ProgressBar } from '@/components/ui/wideset/progress-bar/ProgressBar';\nimport { useId } from 'react';\n\ntype RewardProgressProps = {\n  label: string;\n  /** How far it has got, and how far it has to go: `3` of `5`. */\n  value: number;\n  target: number;\n  /** What is counted, after the target: `teams subscribed`. */\n  unit: string;\n  /** What is left and what it earns: one line. */\n  note: string;\n  className?: string;\n};\n\n/**\n * Progress to the next reward, drawn like the key figures beside it: the count against its\n * target, then one bar, then what is left in words. It is the only bar in the row, so the eye\n * lands on the one figure that is still moving.\n */\nexport function RewardProgress({\n  label,\n  value,\n  target,\n  unit,\n  note,\n  className,\n}: RewardProgressProps) {\n  const labelId = useId();\n\n  return (\n    <div className={cn('gap-ws-5 flex min-w-0 flex-col', className)}>\n      <div className=\"gap-ws-3 flex flex-col\">\n        <p id={labelId} className=\"typography-label-sm text-ws-static-subtle\">\n          {label}\n        </p>\n        <p className=\"gap-ws-5 flex items-baseline tabular-nums\">\n          <span className=\"typography-title-md text-ws-static-strong\">{value}</span>\n          <span className=\"typography-body-md text-ws-static-subtle\">\n            of {target} {unit}\n          </span>\n        </p>\n      </div>\n      <ProgressBar\n        value={Math.min(value, target)}\n        max={target}\n        aria-labelledby={labelId}\n        aria-valuetext={`${value} of ${target} ${unit}`}\n      />\n      <p className=\"typography-label-sm text-ws-static-subtle tabular-nums\">{note}</p>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/section.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/section.tsx",
      "content": "'use client';\n\n// TODO(custom): section title above its content; Wideset has no Section or PageSection.\nimport { cn } from '@/lib/wideset/utils';\nimport { type ReactNode, useId } from 'react';\n\n/** One part of the page: a 16px title, then what it holds. The title names the region. */\nexport function Section({\n  title,\n  className,\n  children,\n}: {\n  title: string;\n  className?: string;\n  children: ReactNode;\n}) {\n  const id = useId();\n\n  return (\n    <section aria-labelledby={id} className={cn('gap-ws-7 flex flex-col', className)}>\n      <h2 id={id} className=\"typography-label-strong-md text-ws-static-strong\">\n        {title}\n      </h2>\n      {children}\n    </section>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/share-link.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/share-link.tsx",
      "content": "'use client';\n\nimport { RiCheckLine, RiFileCopyLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { useEffect, useId, useState } from 'react';\n\nimport { FieldWithAction } from './field-with-action';\n\n/** How long the button says the link was copied. */\nconst COPIED_FOR = 2000;\n\n/**\n * The referral link, read-only, beside the page's one filled button: copying it is the quickest\n * way to share. The button answers in place, saying \"Copied\" for a moment, so nothing else on the\n * page moves; a status line says the same to a screen reader. While a dialog holds the filled\n * button, Copy steps back to a bordered one (`quiet`), so the screen keeps one.\n */\nexport function ShareLink({\n  link,\n  quiet,\n  className,\n}: {\n  link: string;\n  quiet?: boolean;\n  className?: string;\n}) {\n  const id = useId();\n  const [copied, setCopied] = useState(false);\n\n  useEffect(() => {\n    if (!copied) return;\n    const timer = setTimeout(() => setCopied(false), COPIED_FOR);\n    return () => clearTimeout(timer);\n  }, [copied]);\n\n  const copy = () => {\n    // The clipboard is missing on an insecure origin: the link can still be selected by hand.\n    navigator.clipboard\n      ?.writeText(link)\n      .then(() => setCopied(true))\n      .catch(() => {});\n  };\n\n  return (\n    <FormField\n      className={className}\n      label=\"Your referral link\"\n      htmlFor={id}\n      helperText=\"A team that signs up through it counts as yours.\"\n    >\n      <FieldWithAction\n        id={id}\n        readOnly\n        value={link}\n        onFocus={(event) => event.target.select()}\n        action={\n          <>\n            {/* The width holds both labels, so the field beside the button does not jump. */}\n            <Button\n              size=\"sm\"\n              variant={quiet ? 'secondary' : 'primary'}\n              preset={quiet ? 'border' : 'filled'}\n              className=\"w-[5.75rem] shrink-0\"\n              onClick={copy}\n            >\n              <Button.Icon icon={copied ? RiCheckLine : RiFileCopyLine} />\n              {copied ? 'Copied' : 'Copy'}\n            </Button>\n            <span role=\"status\" className=\"sr-only\">\n              {copied && 'Link copied'}\n            </span>\n          </>\n        }\n      />\n    </FormField>\n  );\n}\n"
    },
    {
      "path": "src/blocks/referrals/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/referrals/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 { 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 { type SidebarProps } from '@/components/ui/wideset/sidebar/Sidebar.types';\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 { PersonAvatar } from './person-avatar';\n\n/**\n * The workspace sidebar: switcher, search, the app's pages, settings and the signed-in account.\n * Its toggle sits in the page bar, so the screen holds `collapsed` and passes it down; collapsed,\n * it keeps the mark, the page icons and the avatar.\n */\nexport function ReferralsSidebar(\n  props: Pick<SidebarProps, 'id' | 'collapsed' | 'onCollapsedChange'>,\n) {\n  const [active, setActive] = useState('referrals');\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  const nav = (\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  );\n\n  return (\n    <Sidebar {...props}>\n      <Sidebar.Header>\n        <Sidebar.Expanded>\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.Expanded>\n        <Sidebar.Collapsed>\n          <div className=\"pt-ws-3 pb-ws-7 flex justify-center\">\n            <BrandMark className=\"size-ws-15\" />\n          </div>\n        </Sidebar.Collapsed>\n      </Sidebar.Header>\n\n      {/* A section draws only the slot for the state it is in, so the pages go in both. */}\n      <Sidebar.Section scrollable>{nav}</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            <Sidebar.Expanded>\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                    <PersonAvatar name={account.name} initials={account.initials} color=\"orange\" />\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            </Sidebar.Expanded>\n            <Sidebar.Collapsed>\n              <div className=\"flex justify-center\">\n                <PersonAvatar\n                  name={account.name}\n                  initials={account.initials}\n                  color=\"orange\"\n                  title={account.name}\n                  alt={account.name}\n                />\n              </div>\n            </Sidebar.Collapsed>\n          </div>\n        </div>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
