{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "block-orders",
  "type": "registry:block",
  "title": "Orders",
  "description": "The order history on a raised page: search, a status filter, a date range and a sort over a table that pages, each row opening its order, with a refund dialog from the row’s menu that changes its status.",
  "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/date-range-picker.json",
    "https://wideset.co/r/divider.json",
    "https://wideset.co/r/dropdown-menu.json",
    "https://wideset.co/r/filter-button.json",
    "https://wideset.co/r/form-field.json",
    "https://wideset.co/r/icon-button.json",
    "https://wideset.co/r/illustration.json",
    "https://wideset.co/r/list-item.json",
    "https://wideset.co/r/modal.json",
    "https://wideset.co/r/pagination.json",
    "https://wideset.co/r/select.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/toast.json",
    "https://wideset.co/r/utils.json"
  ],
  "files": [
    {
      "path": "src/blocks/orders/brand-mark.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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/orders/data.ts",
      "type": "registry:file",
      "target": "blocks/wideset/orders/data.ts",
      "content": "import {\n  type RemixiconComponentType,\n  RiBankCardLine,\n  RiContactsBook3Line,\n  RiHandCoinLine,\n  RiHome5Line,\n  RiInbox2Line,\n  RiKey2Line,\n  RiLineChartLine,\n  RiPieChart2Line,\n  RiPlugLine,\n  RiQuestionLine,\n  RiSettings3Line,\n  RiShoppingBag3Fill,\n  RiShoppingBag3Line,\n  RiTeamLine,\n} from '@remixicon/react';\n\n/*\n  What Lumen Studio's customers bought through it in the four weeks to 10 November 2026: meeting\n  room hardware, onboarding and licences. Lumen Studio Ltd is a UK business, so its UK customers\n  pay 20% VAT and the others none. Money is kept in whole cents and every total is worked out\n  from the order's lines.\n*/\n\n/** The product is Orbit; the workspace selling through 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\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: 'orders', label: 'Orders', icon: RiShoppingBag3Line, activeIcon: RiShoppingBag3Fill },\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: '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 day the sample is seen from, so the calendar agrees with the rows. */\nexport const TODAY = '2026-11-10';\n\nexport type CustomerId =\n  'atlas' | 'cobalt' | 'halcyon' | 'juniper' | 'kestrel' | 'marlow' | 'northwind' | 'tidewater';\n\n/** Who buys: the initials on their avatar, the card each one pays with, and the VAT charged. */\nexport const CUSTOMERS: Record<\n  CustomerId,\n  { name: string; initials: string; card: string; vatRate: number }\n> = {\n  atlas: { name: 'Atlas Robotics', initials: 'AR', card: 'Amex ending 3007', vatRate: 0 },\n  cobalt: { name: 'Cobalt Security', initials: 'CS', card: 'Visa ending 9034', vatRate: 0 },\n  halcyon: { name: 'Halcyon Freight', initials: 'HF', card: 'Visa ending 2190', vatRate: 0 },\n  juniper: { name: 'Juniper Legal', initials: 'JL', card: 'Mastercard ending 2264', vatRate: 0.2 },\n  kestrel: { name: 'Kestrel Analytics', initials: 'KA', card: 'Visa ending 1881', vatRate: 0 },\n  marlow: { name: 'Marlow & Finch', initials: 'MF', card: 'Visa ending 6411', vatRate: 0.2 },\n  northwind: {\n    name: 'Northwind Health',\n    initials: 'NH',\n    card: 'Mastercard ending 5510',\n    vatRate: 0,\n  },\n  tidewater: {\n    name: 'Tidewater Energy',\n    initials: 'TE',\n    card: 'Mastercard ending 7718',\n    vatRate: 0.2,\n  },\n};\n\nexport type ItemId =\n  'camera' | 'display' | 'hub' | 'licence' | 'onboarding' | 'sensor' | 'support' | 'training';\n\n/** What Lumen Studio sells. Prices in cents; hardware ships, services and licences do not. */\nexport const ITEMS: Record<ItemId, { name: string; price: number; ships: boolean }> = {\n  camera: { name: 'Lumen Cam 4K', price: 34900, ships: true },\n  display: { name: 'Lumen Display 27', price: 89900, ships: true },\n  hub: { name: 'Lumen Hub', price: 64900, ships: true },\n  licence: { name: 'Lumen Suite licence, 1 year', price: 28800, ships: false },\n  onboarding: { name: 'Onboarding package, Team', price: 240000, ships: false },\n  sensor: { name: 'Room sensor, pack of 5', price: 19500, ships: true },\n  support: { name: 'Priority support, 1 year', price: 180000, ships: false },\n  training: { name: 'Admin training, half day', price: 90000, ships: false },\n};\n\n/** One parcel rate, charged once on any order with hardware in it. */\nconst SHIPPING = 3800;\n\nexport type Status =\n  | 'cancelled'\n  | 'delivered'\n  | 'partially-refunded'\n  | 'payment-failed'\n  | 'processing'\n  | 'refunded'\n  | 'shipped';\n\n/**\n * The status carries its meaning in colour: Processing is under way (info); Shipped and Delivered\n * mean the order went out as it should (positive); a failed payment needs someone (negative).\n * Refunded and Cancelled are how an order ended, with the money already where it belongs, so\n * there is nothing to signal and they stay neutral.\n */\nexport const STATUS: Record<\n  Status,\n  { label: string; color: 'info' | 'negative' | 'neutral' | 'positive' }\n> = {\n  processing: { label: 'Processing', color: 'info' },\n  shipped: { label: 'Shipped', color: 'positive' },\n  delivered: { label: 'Delivered', color: 'positive' },\n  'partially-refunded': { label: 'Partially refunded', color: 'neutral' },\n  refunded: { label: 'Refunded', color: 'neutral' },\n  cancelled: { label: 'Cancelled', color: 'neutral' },\n  'payment-failed': { label: 'Payment failed', color: 'negative' },\n};\n\nexport const statusOptions = Object.entries(STATUS).map(([value, { label }]) => ({ value, label }));\n\nexport type Order = {\n  /** The order number, shown as \"#6178\". */\n  id: string;\n  /** The calendar day it was placed. */\n  placed: string;\n  customer: CustomerId;\n  status: Status;\n  /** What was bought: an item and how many. */\n  lines: [item: ItemId, quantity: number][];\n  /** What went back to the customer so far, in cents. */\n  refunded: number;\n};\n\nconst order = (\n  id: string,\n  placed: string,\n  customer: CustomerId,\n  status: Status,\n  ...lines: Order['lines']\n): Order => ({ id, placed, customer, status, lines, refunded: 0 });\n\n/** What the order comes to: its lines, the parcel if there is one, and the customer's VAT. */\nexport function totalOf({ customer, lines }: Pick<Order, 'customer' | 'lines'>) {\n  const subtotal = lines.reduce((sum, [item, quantity]) => sum + ITEMS[item].price * quantity, 0);\n  const shipping = lines.some(([item]) => ITEMS[item].ships) ? SHIPPING : 0;\n  return Math.round((subtotal + shipping) * (1 + CUSTOMERS[customer].vatRate));\n}\n\n/** What the customer's card was charged: nothing when the payment failed or never ran. */\nexport const paidFor = (o: Order) =>\n  o.status === 'payment-failed' || o.status === 'cancelled' ? 0 : totalOf(o);\n\n/** What can still go back to the customer. */\nexport const refundableFor = (o: Order) => paidFor(o) - o.refunded;\n\nconst refunded = (o: Order, amount = totalOf(o)): Order => ({ ...o, refunded: amount });\n\n/** Newest first. */\nexport const ORDERS: Order[] = [\n  order('6187', '2026-11-10', 'atlas', 'processing', ['licence', 12]),\n  order('6186', '2026-11-10', 'northwind', 'payment-failed', ['display', 3], ['hub', 3]),\n  order('6185', '2026-11-10', 'halcyon', 'processing', ['sensor', 4], ['hub', 1]),\n  order('6184', '2026-11-09', 'cobalt', 'processing', ['support', 1], ['licence', 25]),\n  order(\n    '6183',\n    '2026-11-09',\n    'tidewater',\n    'processing',\n    ['hub', 6],\n    ['camera', 6],\n    ['training', 1],\n  ),\n  order('6182', '2026-11-09', 'kestrel', 'shipped', ['display', 2]),\n  order('6181', '2026-11-06', 'juniper', 'shipped', ['hub', 1], ['camera', 1]),\n  order('6180', '2026-11-06', 'halcyon', 'delivered', ['licence', 40]),\n  order('6179', '2026-11-06', 'atlas', 'shipped', ['sensor', 10], ['hub', 4], ['display', 4]),\n  order('6178', '2026-11-05', 'marlow', 'shipped', ['hub', 2], ['camera', 2], ['onboarding', 1]),\n  order('6177', '2026-11-05', 'cobalt', 'cancelled', ['training', 2]),\n  order('6176', '2026-11-04', 'kestrel', 'delivered', ['onboarding', 1], ['training', 1]),\n  order('6175', '2026-11-04', 'tidewater', 'delivered', ['licence', 60], ['support', 1]),\n  refunded(order('6174', '2026-11-03', 'halcyon', 'refunded', ['display', 1])),\n  order('6173', '2026-11-03', 'juniper', 'delivered', ['licence', 18]),\n  order('6172', '2026-11-02', 'northwind', 'delivered', ['camera', 4], ['sensor', 2]),\n  order('6171', '2026-10-30', 'atlas', 'delivered', ['training', 1]),\n  refunded(\n    order('6170', '2026-10-30', 'cobalt', 'partially-refunded', ['hub', 5], ['camera', 5]),\n    34900,\n  ),\n  order('6169', '2026-10-29', 'marlow', 'delivered', ['licence', 24]),\n  order('6168', '2026-10-28', 'kestrel', 'delivered', ['hub', 2], ['sensor', 2]),\n  order('6167', '2026-10-28', 'halcyon', 'delivered', ['support', 1]),\n  order('6166', '2026-10-27', 'tidewater', 'cancelled', ['display', 8], ['hub', 8]),\n  order('6165', '2026-10-26', 'northwind', 'delivered', ['onboarding', 1], ['licence', 30]),\n  order('6164', '2026-10-23', 'juniper', 'delivered', ['display', 1], ['camera', 1]),\n  order('6163', '2026-10-22', 'atlas', 'delivered', ['hub', 3], ['camera', 3], ['sensor', 6]),\n  order('6162', '2026-10-22', 'cobalt', 'delivered', ['licence', 15]),\n  refunded(order('6161', '2026-10-21', 'kestrel', 'refunded', ['training', 1])),\n  order('6160', '2026-10-20', 'halcyon', 'delivered', ['hub', 2], ['display', 2]),\n  order('6159', '2026-10-19', 'marlow', 'delivered', ['training', 2]),\n  order('6158', '2026-10-16', 'tidewater', 'delivered', ['sensor', 12]),\n  order('6157', '2026-10-15', 'northwind', 'delivered', ['licence', 45], ['support', 1]),\n  order('6156', '2026-10-15', 'atlas', 'delivered', ['display', 6]),\n  order('6155', '2026-10-14', 'juniper', 'delivered', ['onboarding', 1]),\n  order('6154', '2026-10-13', 'cobalt', 'delivered', ['camera', 2]),\n  order('6153', '2026-10-13', 'kestrel', 'delivered', ['licence', 20]),\n  order('6152', '2026-10-12', 'halcyon', 'delivered', ['sensor', 3], ['camera', 1]),\n];\n\nexport type SortKey = 'placed' | 'total';\nexport type Sort = { key: SortKey; direction: 'asc' | 'desc' };\n\n/** The sort as one value for the select: the column and its direction. */\nexport const sortOptions = [\n  { value: 'placed-desc', label: 'Newest first' },\n  { value: 'placed-asc', label: 'Oldest first' },\n  { value: 'total-desc', label: 'Highest total' },\n  { value: 'total-asc', label: 'Lowest total' },\n];\n"
    },
    {
      "path": "src/blocks/orders/empty-state.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/empty-state.tsx",
      "content": "'use client';\n\n// TODO(custom): empty state (drawing, title, line, actions); Wideset has no EmptyState.\nimport { Illustration } from '@/components/ui/wideset/illustration/Illustration';\nimport { type IllustrationName } from '@/components/ui/wideset/illustration/Illustration.types';\nimport type { ReactNode } from 'react';\n\n/*\n  The prototype for a Wideset EmptyState: one design for every region with nothing to show, copied\n  byte for byte into each block that needs one. A first run (nothing here yet) takes a drawing and\n  the ways in; a state the user caused (no search results) takes no drawing and the one way back.\n*/\n\ntype EmptyStateProps = {\n  /** A drawing, only for a first run: nothing has been added yet. */\n  illustration?: IllustrationName;\n  /** What is missing, in a few words: \"No customers yet\". */\n  title: ReactNode;\n  /** One sentence: what will appear here, or why nothing does. */\n  description: ReactNode;\n  /** One or two `size=\"sm\"` buttons: the ways in, or the way back. */\n  children?: ReactNode;\n};\n\n/** What a region shows with nothing in it: centred in the region, the text read first. */\nexport function EmptyState({ illustration, title, description, children }: EmptyStateProps) {\n  return (\n    <div className=\"gap-ws-12 flex flex-col items-center text-center\">\n      {illustration && <Illustration illustration={illustration} size=\"sm\" />}\n      {/* Announced when it replaces the rows, as after a search. */}\n      <div role=\"status\" className=\"gap-ws-3 flex max-w-[26rem] flex-col\">\n        <h2 className=\"typography-label-strong-md text-ws-static-strong\">{title}</h2>\n        <p className=\"typography-body-md text-ws-static-base\">{description}</p>\n      </div>\n      {children && <div className=\"gap-ws-5 flex flex-wrap justify-center\">{children}</div>}\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/export-csv.ts",
      "type": "registry:file",
      "target": "blocks/wideset/orders/export-csv.ts",
      "content": "import { CUSTOMERS, ITEMS, type Order, STATUS, totalOf } from './data';\n\n/**\n * The orders as a CSV file, the way a spreadsheet opens it: one row an order, every cell quoted\n * because item names hold commas, the total in dollars.\n */\nexport function exportCsv(orders: Order[]) {\n  const lines = [\n    ['Order', 'Customer', 'Date', 'Items', 'Status', 'Total (USD)'],\n    ...orders.map((order) => [\n      `#${order.id}`,\n      CUSTOMERS[order.customer].name,\n      order.placed,\n      order.lines.map(([item, quantity]) => `${quantity} x ${ITEMS[item].name}`).join('; '),\n      STATUS[order.status].label,\n      (totalOf(order) / 100).toFixed(2),\n    ]),\n  ];\n  const csv = lines.map((line) => line.map((cell) => `\"${cell}\"`).join(',')).join('\\n');\n  const link = document.createElement('a');\n  link.href = URL.createObjectURL(new Blob([csv], { type: 'text/csv' }));\n  link.download = 'orders.csv';\n  link.click();\n  URL.revokeObjectURL(link.href);\n}\n"
    },
    {
      "path": "src/blocks/orders/filters.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/filters.tsx",
      "content": "'use client';\n\nimport { RiSearchLine } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { DateRangePicker } from '@/components/ui/wideset/daterangepicker/DateRangePicker';\nimport { type DateRangeValue } from '@/components/ui/wideset/daterangepicker/DateRangePicker.types';\nimport { FilterButton } from '@/components/ui/wideset/filter-button/FilterButton';\nimport { Select } from '@/components/ui/wideset/select/Select';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\n\nimport { sortOptions, statusOptions, TODAY } from './data';\n\nexport type FilterValues = {\n  query: string;\n  statuses: string[];\n  /** The days the orders were placed in; left out, every day. */\n  range?: DateRangeValue;\n};\n\n/** The sample's own today as a local Date, for the calendar: drop it to follow the clock. */\nconst [year, month, day] = TODAY.split('-').map(Number);\nconst SAMPLE_TODAY = new Date(year, month - 1, day);\n\n/**\n * The toolbar over the table: search, the status, the days, and the sort at the far end. The\n * date range keeps its own state and reports a finished range; `resetKey` changes when the\n * filters are cleared from outside, which empties it.\n */\nexport function Filters({\n  values,\n  onChange,\n  sort,\n  onSortChange,\n  resetKey,\n  onClear,\n}: {\n  values: FilterValues;\n  onChange: (values: FilterValues) => void;\n  /** The sort as the select holds it: `placed-desc`. */\n  sort: string;\n  onSortChange: (sort: string) => void;\n  resetKey: number;\n  /** Clears every filter; left out while nothing narrows the list. */\n  onClear?: () => void;\n}) {\n  const set = (next: Partial<FilterValues>) => onChange({ ...values, ...next });\n\n  return (\n    <div className=\"gap-ws-5 flex flex-wrap items-center\">\n      <TextInput\n        size=\"sm\"\n        className=\"w-[18rem] max-w-full\"\n        value={values.query}\n        onChange={(event) => set({ query: event.target.value })}\n      >\n        <TextInput.Prefix inner>\n          <TextInput.Icon icon={RiSearchLine} />\n        </TextInput.Prefix>\n        <TextInput.Input\n          type=\"search\"\n          placeholder=\"Search by number or customer\"\n          aria-label=\"Search orders\"\n        />\n        <TextInput.Suffix inner>\n          <TextInput.ClearButton />\n        </TextInput.Suffix>\n      </TextInput>\n      <FilterButton\n        label=\"Status\"\n        placeholder=\"Status\"\n        options={statusOptions}\n        value={values.statuses}\n        onChange={(statuses) => set({ statuses })}\n        clearFilterAriaLabel=\"Clear status filter\"\n      />\n      <DateRangePicker\n        key={resetKey}\n        size=\"sm\"\n        aria-label=\"Order date\"\n        placeholder=\"Order date\"\n        className=\"w-[14.5rem]\"\n        dateFormat=\"MMM d, yyyy\"\n        weekStartsOn={1}\n        today={SAMPLE_TODAY}\n        defaultMonth={SAMPLE_TODAY}\n        disabledDates={{ after: SAMPLE_TODAY }}\n        onSelect={(range) => range?.from && range.to && set({ range })}\n      />\n      {onClear && (\n        <Button size=\"sm\" variant=\"secondary\" preset=\"ghost\" onClick={onClear}>\n          Clear filters\n        </Button>\n      )}\n      <Select\n        size=\"sm\"\n        preset=\"border\"\n        aria-label=\"Sort orders\"\n        options={sortOptions}\n        value={sort}\n        onValueChange={onSortChange}\n        className=\"ml-auto w-auto\"\n      />\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/format.ts",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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 decimal = new Intl.NumberFormat(LOCALE, {\n  minimumFractionDigits: 2,\n  maximumFractionDigits: 2,\n});\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});\n\n/** Money is kept in whole cents: 532080 → $5,320.80. */\nexport const formatUsd = (cents: number) => usd.format(cents / 100);\n/** The same without the sign, for a field that shows `$` beside it: 532080 → 5,320.80. */\nexport const formatAmount = (cents: number) => decimal.format(cents / 100);\n/** What was typed into such a field, in cents: `5,320.8` → 532080. Not a number: NaN. */\nexport const parseAmount = (text: string) =>\n  text.trim() ? Math.round(Number(text.replace(/,/g, '')) * 100) : NaN;\n/** Nov 5, 2026. */\nexport const formatDate = (iso: string) => date.format(new Date(iso));\n"
    },
    {
      "path": "src/blocks/orders/index.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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 { 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, useState } from 'react';\n\nimport {\n  CUSTOMERS,\n  type Order,\n  ORDERS,\n  paidFor,\n  refundableFor,\n  type Sort,\n  type SortKey,\n  totalOf,\n} from './data';\nimport { exportCsv } from './export-csv';\nimport { Filters, type FilterValues } from './filters';\nimport { formatUsd } from './format';\nimport { OrdersTable } from './orders-table';\nimport { PageHeader } from './page-header';\nimport { RefundDialog } from './refund-dialog';\nimport { OrdersSidebar } from './sidebar';\nimport { TableFooter } from './table-footer';\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]';\nconst PAGE_SIZE = 12;\nconst NO_FILTERS: FilterValues = { query: '', statuses: [] };\nconst OPPOSITE = { asc: 'desc', desc: 'asc' } as const;\n\n// Order numbers rise with time, so the number is the date order and settles equal totals.\nconst compare =\n  ({ key, direction }: Sort) =>\n  (a: Order, b: Order) => {\n    const order = (key === 'total' ? totalOf(a) - totalOf(b) : 0) || a.id.localeCompare(b.id);\n    return direction === 'asc' ? order : -order;\n  };\n\n/** The page inside the card: under the toasts, so a refund can report itself. */\nfunction OrdersPage() {\n  const { showToast } = useToast();\n  const [orders, setOrders] = useState(ORDERS);\n  const [filters, setFilters] = useState(NO_FILTERS);\n  // Counts the times the filters were cleared: the date range empties itself when it changes.\n  const [cleared, setCleared] = useState(0);\n  const [sort, setSort] = useState<Sort>({ key: 'placed', direction: 'desc' });\n  const [page, setPage] = useState(1);\n  // The order stays while the dialog closes, so its words do not vanish under the fade.\n  const [refund, setRefund] = useState<{ order: Order; open: boolean }>();\n\n  const query = filters.query.trim().toLowerCase().replace(/^#/, '');\n  const { from, to } = filters.range ?? {};\n  const matching = orders\n    .filter(\n      (order) =>\n        (order.id.includes(query) ||\n          CUSTOMERS[order.customer].name.toLowerCase().includes(query)) &&\n        (filters.statuses.length === 0 || filters.statuses.includes(order.status)) &&\n        (!from || !to || (order.placed >= from && order.placed <= to)),\n    )\n    .sort(compare(sort));\n  const rows = matching.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);\n  const narrowed = query !== '' || filters.statuses.length > 0 || filters.range !== undefined;\n\n  // Anything that changes the rows goes back to the first page.\n  const filter = (values: FilterValues) => {\n    setFilters(values);\n    setPage(1);\n  };\n  const clearFilters = () => {\n    filter(NO_FILTERS);\n    setCleared(cleared + 1);\n  };\n  const sortBy = (next: Sort) => {\n    setSort(next);\n    setPage(1);\n  };\n\n  function applyRefund(order: Order, amount: number) {\n    const refunded = order.refunded + amount;\n    const status = refunded === paidFor(order) ? 'refunded' : 'partially-refunded';\n    setOrders((all) => all.map((o) => (o.id === order.id ? { ...o, refunded, status } : o)));\n    setRefund({ order, open: false });\n    showToast({\n      content: `${formatUsd(amount)} refunded to ${CUSTOMERS[order.customer].name}`,\n      status: 'success',\n    });\n  }\n\n  return (\n    <div className={cn(COLUMN, 'gap-ws-12 pt-ws-14 pb-ws-16 flex flex-col')}>\n      <PageHeader onExport={() => exportCsv(matching)} />\n\n      <section aria-label=\"Orders\" className=\"gap-ws-9 flex flex-col\">\n        <Filters\n          values={filters}\n          onChange={filter}\n          sort={`${sort.key}-${sort.direction}`}\n          onSortChange={(value) => {\n            const [key, direction] = value.split('-') as [SortKey, Sort['direction']];\n            sortBy({ key, direction });\n          }}\n          resetKey={cleared}\n          // With no rows left, the empty state holds the way back.\n          onClear={narrowed && rows.length > 0 ? clearFilters : undefined}\n        />\n        <OrdersTable\n          rows={rows}\n          sort={sort}\n          // A second click on the sorted column turns it round.\n          onSort={(key) =>\n            sortBy({ key, direction: sort.key === key ? OPPOSITE[sort.direction] : 'desc' })\n          }\n          onRefund={(order) => setRefund({ order, open: true })}\n          onClearFilters={clearFilters}\n        />\n        <TableFooter\n          page={page}\n          pageSize={PAGE_SIZE}\n          total={matching.length}\n          onPageChange={setPage}\n        />\n      </section>\n\n      {refund && (\n        <RefundDialog\n          open={refund.open}\n          onOpenChange={(open) => setRefund({ ...refund, open })}\n          order={{\n            number: `#${refund.order.id}`,\n            customer: CUSTOMERS[refund.order.customer].name,\n            paid: paidFor(refund.order),\n            refundable: refundableFor(refund.order),\n            card: CUSTOMERS[refund.order.customer].card,\n          }}\n          onConfirm={(amount) => applyRefund(refund.order, amount)}\n        />\n      )}\n    </div>\n  );\n}\n\n/**\n * Orders (Inset direction): the order history on the raised page beside the workspace sidebar.\n * Search, a status filter, a date range and the sort narrow one table that pages; a row opens\n * its order, and its menu refunds it in a small dialog that changes the row and says so in a\n * toast. The history is read, not acted on, so the page has no filled button: Export is\n * secondary.\n */\nexport default function Orders() {\n  const sidebarId = useId();\n  const [collapsed, setCollapsed] = useState(false);\n\n  return (\n    <ToastProvider>\n      <AppShell className=\"ws-block-utility\" direction=\"inset\">\n        <OrdersSidebar 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>Orders</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            <OrdersPage />\n          </div>\n        </AppShell.Main>\n      </AppShell>\n    </ToastProvider>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/orders-table.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/orders-table.tsx",
      "content": "'use client';\n\n// TODO(custom): whole-row link done with a stretched <a>; Table has no row link.\nimport { Avatar } from '@/components/ui/wideset/avatar/Avatar';\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { StatusBadge } from '@/components/ui/wideset/status-badge/StatusBadge';\nimport { Table } from '@/components/ui/wideset/table/Table';\n\nimport {\n  CUSTOMERS,\n  ITEMS,\n  type Order,\n  refundableFor,\n  type Sort,\n  type SortKey,\n  STATUS,\n  totalOf,\n} from './data';\nimport { EmptyState } from './empty-state';\nimport { formatDate, formatUsd } from './format';\nimport { RowMenu } from './row-menu';\n\nconst COLUMN_COUNT = 7;\n\n/**\n * One page of orders, a line each: number, who bought (behind the company's initials), when,\n * what, where it stands and what it came to. A row opens its order from anywhere on it; the ⋯ at\n * its end is its own target. The date and the total sort from their headers, the same sort the\n * toolbar's select holds.\n */\nexport function OrdersTable({\n  rows,\n  sort,\n  onSort,\n  onRefund,\n  onClearFilters,\n}: {\n  rows: Order[];\n  sort: Sort;\n  onSort: (key: SortKey) => void;\n  onRefund: (order: Order) => void;\n  onClearFilters: () => void;\n}) {\n  const sortable = (key: SortKey) => ({\n    sortable: true,\n    sortDirection: sort.key === key ? sort.direction : null,\n    onSort: () => onSort(key),\n  });\n\n  return (\n    // Narrower than its columns, the table scrolls sideways inside its own area.\n    <div className=\"ws-scrollbar overflow-x-auto\">\n      <Table size=\"md\" interactive={rows.length > 0} className=\"min-w-[60rem] table-fixed\">\n        <Table.Head>\n          <Table.Row>\n            <Table.Header className=\"w-[7rem]\">Order</Table.Header>\n            <Table.Header className=\"w-[13rem]\">Customer</Table.Header>\n            <Table.Header className=\"w-[8.5rem]\" {...sortable('placed')}>\n              Date\n            </Table.Header>\n            <Table.Header>Items</Table.Header>\n            <Table.Header className=\"w-[10rem]\">Status</Table.Header>\n            <Table.Header align=\"right\" className=\"w-[9rem]\" {...sortable('total')}>\n              Total\n            </Table.Header>\n            <Table.Header className=\"w-[3.5rem]\">\n              <span className=\"sr-only\">Actions</span>\n            </Table.Header>\n          </Table.Row>\n        </Table.Head>\n        <Table.Body>\n          {rows.length === 0 ? (\n            <Table.Row>\n              <Table.Cell colSpan={COLUMN_COUNT}>\n                <div className=\"py-ws-20\">\n                  <EmptyState\n                    title=\"No orders match\"\n                    description=\"Try another number or customer, or clear the filters.\"\n                  >\n                    <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={onClearFilters}>\n                      Clear filters\n                    </Button>\n                  </EmptyState>\n                </div>\n              </Table.Cell>\n            </Table.Row>\n          ) : (\n            rows.map((order) => {\n              const status = STATUS[order.status];\n              const customer = CUSTOMERS[order.customer];\n              const [[first], ...more] = order.lines;\n              return (\n                // The number's link stretches over the whole row: one target, the hover on every\n                // cell.\n                <Table.Row key={order.id} className=\"relative\">\n                  <Table.Cell>\n                    <a\n                      href={`#order-${order.id}`}\n                      className=\"text-ws-static-strong focus-visible:wds-focus-visible outline-ws-dynamic-primary-strong-default after:inset-ws-0 tabular-nums after:absolute\"\n                    >\n                      #{order.id}\n                    </a>\n                  </Table.Cell>\n                  <Table.Cell>\n                    {/* The company's initials on a square: a face for the name, not a second\n                        label, so it is hidden from screen readers. */}\n                    <div className=\"gap-ws-7 flex items-center\">\n                      <Avatar shape=\"square\" initials={customer.initials} aria-hidden=\"true\" />\n                      <span className=\"truncate\">{customer.name}</span>\n                    </div>\n                  </Table.Cell>\n                  <Table.Cell className=\"tabular-nums\">\n                    <time dateTime={order.placed}>{formatDate(order.placed)}</time>\n                  </Table.Cell>\n                  <Table.Cell truncate>\n                    {ITEMS[first].name}\n                    {more.length > 0 && (\n                      <span className=\"text-ws-static-subtle\"> +{more.length} more</span>\n                    )}\n                  </Table.Cell>\n                  <Table.Cell>\n                    <StatusBadge color={status.color}>{status.label}</StatusBadge>\n                  </Table.Cell>\n                  <Table.Cell align=\"right\" className=\"tabular-nums\">\n                    {formatUsd(totalOf(order))}\n                  </Table.Cell>\n                  {/* Above the row's link, so the menu is reached and not the order. */}\n                  <Table.Cell align=\"right\" className=\"relative\">\n                    <RowMenu\n                      order={`#${order.id}`}\n                      href={`#order-${order.id}`}\n                      onRefund={refundableFor(order) > 0 ? () => onRefund(order) : undefined}\n                    />\n                  </Table.Cell>\n                </Table.Row>\n              );\n            })\n          )}\n        </Table.Body>\n      </Table>\n    </div>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/page-header.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/page-header.tsx",
      "content": "'use client';\n\n// TODO(custom): page header (title, a line of description, the actions on the right); no PageHeader in Wideset.\nimport { RiDownload2Line } from '@remixicon/react';\nimport { Button } from '@/components/ui/wideset/button/Button';\n\nimport { workspace } from './data';\n\n/**\n * The page's title, one line saying what the list holds, and its one action. Export is a\n * secondary button: a history is read, so the page has no filled button at all.\n */\nexport function PageHeader({ onExport }: { onExport: () => void }) {\n  return (\n    <header className=\"gap-ws-12 flex flex-wrap items-center justify-between\">\n      <div className=\"gap-ws-2 flex min-w-0 flex-col\">\n        <h1 className=\"typography-title-md text-ws-static-strong\">Orders</h1>\n        <p className=\"typography-body-md text-ws-static-subtle\">\n          Hardware, onboarding and licences customers bought through {workspace.name}.\n        </p>\n      </div>\n      <Button size=\"sm\" variant=\"secondary\" preset=\"border\" onClick={onExport}>\n        <Button.Icon icon={RiDownload2Line} />\n        Export\n      </Button>\n    </header>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/people.assets.ts",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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/4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JiWHOFOWJbrKo1LqFiXvYhtJwvjKU44qRdFdTW/Td1ukW5yUx/wBQS0W3XDhG5G7gnwzv/FNk6whCisNYyeOKSRNFzb7cWIMKMt+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/orders/person-avatar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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/orders/refund-dialog.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/refund-dialog.tsx",
      "content": "'use client';\n\nimport { Button } from '@/components/ui/wideset/button/Button';\nimport { FormField } from '@/components/ui/wideset/form-field/FormField';\nimport { Modal } from '@/components/ui/wideset/modal/Modal';\nimport { Select } from '@/components/ui/wideset/select/Select';\nimport { TextInput } from '@/components/ui/wideset/text-input/TextInput';\nimport { useEffect, useId, useRef, useState } from 'react';\n\nimport { formatAmount, formatUsd, parseAmount } from './format';\n\nconst REASONS = [\n  { value: 'requested', label: 'Requested by the customer' },\n  { value: 'duplicate', label: 'Duplicate order' },\n  { value: 'faulty', label: 'Damaged or faulty item' },\n  { value: 'not-delivered', label: 'Not delivered' },\n  { value: 'mistake', label: 'Ordered by mistake' },\n  { value: 'other', label: 'Other' },\n];\n\n/** What the dialog needs to know about the order it refunds. Money in cents. */\nexport type RefundTarget = {\n  /** The order's number, as shown: \"#6178\". */\n  number: string;\n  customer: string;\n  /** What the card was charged. */\n  paid: number;\n  /** What is left of the payment: what was paid less what went back already. */\n  refundable: number;\n  /** The card the money goes back to: \"Visa ending 6411\". */\n  card: string;\n};\n\ntype RefundFormProps = {\n  id: string;\n  order: RefundTarget;\n  pending: boolean;\n  onRefund: (amount: number, reason: string) => void;\n};\n\n/**\n * The dialog's content. It mounts with the dialog, so every opening starts from the full amount\n * and no reason. Errors wait for the first try at refunding, then follow what is typed.\n */\nfunction RefundForm({ id, order, pending, onRefund }: RefundFormProps) {\n  const [text, setText] = useState(formatAmount(order.refundable));\n  const [reason, setReason] = useState('');\n  const [tried, setTried] = useState(false);\n\n  const amount = parseAmount(text);\n  const max = formatUsd(order.refundable);\n  const amountError = !(amount > 0)\n    ? 'Enter an amount above $0.00.'\n    : amount > order.refundable\n      ? `Enter ${max} or less.`\n      : undefined;\n  const reasonError = reason ? undefined : 'Choose a reason.';\n  const rest = order.refundable - amount;\n\n  function refund() {\n    setTried(true);\n    if (amountError) document.getElementById(`${id}-amount`)?.focus();\n    else if (reasonError) document.getElementById(`${id}-reason`)?.focus();\n    else onRefund(amount, reason);\n  }\n\n  return (\n    <>\n      <Modal.Header>\n        <Modal.Title>Refund order {order.number}</Modal.Title>\n        <Modal.Description>\n          {order.customer} paid {formatUsd(order.paid)} with {order.card}.\n          {order.paid > order.refundable &&\n            ` ${formatUsd(order.paid - order.refundable)} of it has gone back already.`}\n        </Modal.Description>\n      </Modal.Header>\n      <Modal.Body className=\"gap-ws-11 flex flex-col\">\n        <div className=\"gap-ws-9 grid grid-cols-2 items-start\">\n          <FormField\n            label=\"Amount\"\n            htmlFor={`${id}-amount`}\n            helperText={`Up to ${max}.`}\n            errorText={tried ? amountError : undefined}\n          >\n            <TextInput\n              id={`${id}-amount`}\n              name=\"amount\"\n              required\n              inputMode=\"decimal\"\n              autoComplete=\"off\"\n              placeholder=\"0.00\"\n              variant={tried && amountError ? 'danger' : 'primary'}\n              value={text}\n              onChange={(event) => setText(event.target.value.replace(/[^\\d.,]/g, ''))}\n              // Leaving the field settles what was typed into an amount: 1200 → 1,200.00.\n              onBlur={() => amount > 0 && setText(formatAmount(amount))}\n            >\n              <TextInput.Prefix>$</TextInput.Prefix>\n              <TextInput.Input className=\"tabular-nums\" />\n            </TextInput>\n          </FormField>\n          <FormField\n            label=\"Reason\"\n            htmlFor={`${id}-reason`}\n            errorText={tried ? reasonError : undefined}\n          >\n            <Select\n              id={`${id}-reason`}\n              name=\"reason\"\n              className=\"w-full\"\n              required\n              options={REASONS}\n              placeholder=\"Choose a reason\"\n              variant={tried && reasonError ? 'danger' : 'primary'}\n              value={reason}\n              onValueChange={setReason}\n            />\n          </FormField>\n        </div>\n        {/* What confirming does, in words, following the amount as it is typed. */}\n        <p className=\"typography-body-md text-ws-static-subtle tabular-nums\">\n          {amountError\n            ? `A refund goes back to the ${order.card} within 5 to 10 business days.`\n            : `${formatUsd(amount)} goes back to the ${order.card} within 5 to 10 business days. The order is marked ${\n                rest === 0 ? 'Refunded' : `Partially refunded and ${formatUsd(rest)} stays paid`\n              }.`}{' '}\n          {order.customer} gets a confirmation by email. A refund cannot be undone.\n        </p>\n      </Modal.Body>\n      <Modal.Footer>\n        <Modal.Close asChild>\n          <Button variant=\"secondary\" preset=\"border\" disabled={pending}>\n            Cancel\n          </Button>\n        </Modal.Close>\n        <Button onClick={refund} disabled={pending}>\n          {pending ? 'Refunding…' : amountError ? 'Refund' : `Refund ${formatUsd(amount)}`}\n        </Button>\n      </Modal.Footer>\n    </>\n  );\n}\n\ntype RefundDialogProps = {\n  open: boolean;\n  onOpenChange: (open: boolean) => void;\n  order: RefundTarget;\n  /** Called once the refund went through, with the amount in cents and the reason's value. */\n  onConfirm: (amount: number, reason: string) => void;\n};\n\n/**\n * Refunding an order: the amount, full unless changed and never above what is left of the\n * payment, the reason, and what confirming does. Money leaves on a click, never on Enter in a\n * field: the fields are not a form, and the button names the amount it sends back.\n */\nexport function RefundDialog({ open, onOpenChange, order, onConfirm }: RefundDialogProps) {\n  const id = useId();\n  const [pending, setPending] = useState(false);\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 dialog open.\n  function refund(amount: number, reason: string) {\n    setPending(true);\n    timer.current = window.setTimeout(() => {\n      setPending(false);\n      onConfirm(amount, reason);\n    }, 800);\n  }\n\n  return (\n    <Modal open={open} onOpenChange={(next) => !pending && onOpenChange(next)}>\n      <Modal.Content className=\"ws-block-utility\"\n        persistent={pending}\n        onOpenAutoFocus={(event) => {\n          event.preventDefault();\n          document.getElementById(`${id}-amount`)?.focus();\n        }}\n      >\n        <RefundForm id={id} order={order} pending={pending} onRefund={refund} />\n      </Modal.Content>\n    </Modal>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/row-menu.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/row-menu.tsx",
      "content": "'use client';\n\nimport { RiMoreFill } from '@remixicon/react';\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';\n\ntype RowMenuProps = {\n  /** The order's number, as shown: \"#6178\". */\n  order: string;\n  /** The order's page. */\n  href: string;\n  /** Opens the refund dialog; left out when nothing is left to refund, which disables the item. */\n  onRefund?: () => void;\n};\n\nconst Label = ({ children }: { children: string }) => (\n  <ListItem.Content>\n    <ListItem.Label>{children}</ListItem.Label>\n  </ListItem.Content>\n);\n\n/**\n * A row's own actions, behind the ⋯ at its end. Refund stays in the list when it cannot be used,\n * disabled, so the menu is the same on every row.\n */\nexport function RowMenu({ order, href, onRefund }: RowMenuProps) {\n  return (\n    <DropdownMenu>\n      <DropdownMenu.Trigger asChild>\n        <IconButton\n          icon={RiMoreFill}\n          size=\"xs\"\n          variant=\"secondary\"\n          preset=\"ghost\"\n          aria-label={`Actions for order ${order}`}\n        />\n      </DropdownMenu.Trigger>\n      <DropdownMenu.Content className=\"ws-block-utility\" align=\"end\">\n        <DropdownMenu.Item onSelect={() => window.location.assign(href)}>\n          <Label>View order</Label>\n        </DropdownMenu.Item>\n        <DropdownMenu.Item>\n          <Label>Download invoice</Label>\n        </DropdownMenu.Item>\n        <DropdownMenu.Separator />\n        <DropdownMenu.Item disabled={!onRefund} onSelect={onRefund}>\n          <Label>Refund</Label>\n        </DropdownMenu.Item>\n      </DropdownMenu.Content>\n    </DropdownMenu>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/sidebar.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/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 OrdersSidebar(props: Pick<SidebarProps, 'id' | 'collapsed' | 'onCollapsedChange'>) {\n  const [active, setActive] = useState('orders');\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                  alt={account.name}\n                  title={account.name}\n                />\n              </div>\n            </Sidebar.Collapsed>\n          </div>\n        </div>\n      </Sidebar.Footer>\n    </Sidebar>\n  );\n}\n"
    },
    {
      "path": "src/blocks/orders/table-footer.tsx",
      "type": "registry:file",
      "target": "blocks/wideset/orders/table-footer.tsx",
      "content": "'use client';\n\n// TODO(custom): range label \"1–12 of 36 orders\" beside Pagination; Pagination has no range label.\nimport { Pagination } from '@/components/ui/wideset/pagination/Pagination';\n\n/**\n * Under the table: which rows are showing, and the pages when there is more than one. With no\n * rows it says nothing: the empty state in the table's place announces that.\n */\nexport function TableFooter({\n  page,\n  pageSize,\n  total,\n  onPageChange,\n}: {\n  page: number;\n  pageSize: number;\n  total: number;\n  onPageChange: (page: number) => void;\n}) {\n  const pagesCount = Math.max(1, Math.ceil(total / pageSize));\n  const first = (page - 1) * pageSize + 1;\n  const last = Math.min(total, page * pageSize);\n\n  return (\n    <div className=\"gap-ws-9 min-h-ws-forms-sm flex flex-wrap items-center justify-between\">\n      {total > 0 && (\n        <p role=\"status\" className=\"typography-body-md text-ws-static-subtle tabular-nums\">\n          {first}–{last} of {total} orders\n        </p>\n      )}\n      {pagesCount > 1 && (\n        <Pagination\n          pagesCount={pagesCount}\n          activePage={page}\n          onChangeActivePage={onPageChange}\n          navigationAriaLabel=\"Order pages\"\n        />\n      )}\n    </div>\n  );\n}\n"
    }
  ],
  "meta": {
    "version": "1.1.0",
    "commit": "a734f9f0"
  }
}
