{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "loadout",
  "title": "Loadout",
  "description": "Gear slots, a weapon's sheet with its stats, and what's in the pack.",
  "dependencies": [
    "lucide-react@1.73.0"
  ],
  "registryDependencies": [
    "https://www.cyberspec.dev/r/cyber.json",
    "https://www.cyberspec.dev/r/alert-dialog.json",
    "https://www.cyberspec.dev/r/badge.json",
    "https://www.cyberspec.dev/r/button.json",
    "https://www.cyberspec.dev/r/dialog.json",
    "https://www.cyberspec.dev/r/item-slot.json",
    "https://www.cyberspec.dev/r/meter.json",
    "https://www.cyberspec.dev/r/micro.json",
    "https://www.cyberspec.dev/r/panel.json",
    "https://www.cyberspec.dev/r/readout.json",
    "https://www.cyberspec.dev/r/screen.json",
    "https://www.cyberspec.dev/r/segmented-control.json",
    "https://www.cyberspec.dev/r/tabs.json",
    "https://www.cyberspec.dev/r/toaster.json"
  ],
  "files": [
    {
      "path": "registry/cyber/blocks/loadout/figure.tsx",
      "content": "\"use client\"\n\nimport { Corners, Micro, Ruler } from \"@/registry/cyber/ui/micro\"\nimport type { SlotKind } from \"@/registry/cyber/blocks/loadout/gear\"\n\n// The runner, as a wireframe on a measuring stage. It's decoration: the\n// part of the body the selected slot belongs to lights in the signal color,\n// which only repeats what the pressed slot and the sheet already say.\n//\n// Each shape names the regions it belongs to in `data-part`; the stylesheet\n// lights the ones matching the stage's `data-region`.\nfunction Figure({ region }: { region: SlotKind | null }) {\n  return (\n    <div data-loadout-figure=\"\" data-region={region ?? undefined} aria-hidden>\n      <Corners size={9} />\n      <Ruler vertical data-loadout-figure-rule=\"\" />\n      <Micro data-loadout-figure-code=\"\">Subj S.Quinn // Scan 04</Micro>\n      <svg viewBox=\"0 0 200 448\" focusable=\"false\">\n        {/* Stage: a ground plane and a center line. */}\n        <path data-part=\"stage\" d=\"M100 6v436M36 430 100 416 164 430 100 444Z M60 430 100 421 140 430 100 439Z\" />\n\n        <g data-part=\"head outfit\">\n          <path d=\"M100 20 119 31V57L100 68 81 57V31Z\" />\n          <path d=\"M81 40H119M88 40 100 52 112 40M92 68 90 80H110L108 68\" />\n        </g>\n        {/* The deck's port, behind the ear, and its lead down the neck. */}\n        <g data-part=\"deck\">\n          <path d=\"M125 44 131 38 137 44 131 50ZM131 50V72L118 84\" />\n        </g>\n\n        <g data-part=\"chest outfit\">\n          <path d=\"M62 84H138L146 100 132 190H68L54 100Z\" />\n          <path d=\"M62 84 100 120 138 84M100 120V190M72 150H128M70 168H130\" />\n          <path d=\"M54 100 62 114 50 172 38 170ZM146 100 138 114 150 172 162 170Z\" />\n        </g>\n        <g data-part=\"chest weapon outfit\">\n          <path d=\"M38 176 50 178 44 238 32 236ZM162 176 150 178 156 238 168 236Z\" />\n        </g>\n        <g data-part=\"weapon\">\n          <path d=\"M32 242 44 244 40 262 30 258ZM168 242 156 244 160 262 170 258Z\" />\n        </g>\n\n        <g data-part=\"legs outfit\">\n          <path d=\"M68 196H132L138 226 100 240 62 226Z\" />\n          <path d=\"M62 232 96 244 90 320H68ZM138 232 104 244 110 320H132Z\" />\n          <path d=\"M68 326H90L86 400H72ZM132 326H110L114 400H128Z\" />\n          <path d=\"M70 406H88L92 424H62ZM130 406H112L108 424H138Z\" />\n          <path d=\"M72 280H91M128 280H109M73 360H88M127 360H112\" />\n        </g>\n        {/* Quick-access pouches on the belt. */}\n        <g data-part=\"quick\">\n          <path d=\"M52 200H62V216H52ZM138 200H148V216H138Z\" />\n        </g>\n      </svg>\n      <Micro data-loadout-figure-foot=\"\">Frame 09 // Reflex 07 // Nerve 13</Micro>\n    </div>\n  )\n}\n\nexport { Figure }\n",
      "type": "registry:component",
      "target": "@components/blocks/loadout/figure.tsx"
    },
    {
      "path": "registry/cyber/blocks/loadout/gear.ts",
      "content": "import type { ItemRarity } from \"@/registry/cyber/ui/item-slot\"\n\n// What Sable Quinn owns, and where on a runner each piece can go. Every\n// item, maker and number here is written for this kit.\n\ntype SlotKind = \"weapon\" | \"head\" | \"chest\" | \"legs\" | \"outfit\" | \"deck\" | \"quick\"\ntype PackGroup = \"weapon\" | \"wear\" | \"tech\"\n\ntype Slot = { id: string; name: string; kind: SlotKind }\n\ntype Item = {\n  id: string\n  name: string\n  maker: string\n  type: string\n  kind: SlotKind\n  rarity: ItemRarity\n  /** The one large figure on its sheet. */\n  output: { label: string; value: number; unit?: string; precision?: number }\n  /** Two or three gauges, each out of 100. */\n  stats: { label: string; value: number }[]\n  /** Sockets: the name of what's fitted, or null for a free one. */\n  mods: (string | null)[]\n  /** Counts toward the Armor readout while fitted. */\n  armor?: number\n  /** Kilograms, for the whole stack. */\n  weight: number\n  price: number\n  count?: number\n  isNew?: boolean\n  serial: string\n  note: string\n  /** A silhouette on a 48 unit square, filled with the even-odd rule. */\n  art: string\n}\n\nconst slots: Slot[] = [\n  { id: \"primary\", name: \"Primary weapon\", kind: \"weapon\" },\n  { id: \"secondary\", name: \"Secondary weapon\", kind: \"weapon\" },\n  { id: \"sidearm\", name: \"Sidearm\", kind: \"weapon\" },\n  { id: \"headgear\", name: \"Headgear\", kind: \"head\" },\n  { id: \"face\", name: \"Face\", kind: \"head\" },\n  { id: \"inner\", name: \"Inner layer\", kind: \"chest\" },\n  { id: \"outer\", name: \"Outer layer\", kind: \"chest\" },\n  { id: \"legwear\", name: \"Legwear\", kind: \"legs\" },\n  { id: \"footwear\", name: \"Footwear\", kind: \"legs\" },\n  { id: \"outfit\", name: \"Outfit\", kind: \"outfit\" },\n  { id: \"deck\", name: \"Deck\", kind: \"deck\" },\n  { id: \"quick-1\", name: \"Quick slot 1\", kind: \"quick\" },\n  { id: \"quick-2\", name: \"Quick slot 2\", kind: \"quick\" },\n]\n\nconst groupOf: Record<SlotKind, PackGroup> = {\n  weapon: \"weapon\",\n  head: \"wear\",\n  chest: \"wear\",\n  legs: \"wear\",\n  outfit: \"wear\",\n  deck: \"tech\",\n  quick: \"tech\",\n}\n\nconst items: Item[] = [\n  {\n    id: \"kr9\",\n    name: \"Kestrel KR-9 carbine\",\n    maker: \"Kestrel Arms\",\n    type: \"Carbine\",\n    kind: \"weapon\",\n    rarity: \"rare\",\n    output: { label: \"Output\", value: 412.8, unit: \"dps\", precision: 1 },\n    stats: [\n      { label: \"Handling\", value: 72 },\n      { label: \"Range\", value: 64 },\n      { label: \"Quiet\", value: 58 },\n    ],\n    mods: [\"Lumen smart-link\", \"Baffle suppressor\", null],\n    weight: 3.6,\n    price: 4200,\n    serial: \"KA-KR9 // LOT 22 // NODE 3F:A2\",\n    note: \"A short carbine that forgives a bad stance. Smart-linked, it leads a moving target by itself.\",\n    art: \"M2 20h8v9H5l-3-3zM10 19h20v8H10zM14 16h12v2H14zM30 21h14v3H30zM44 20h2v5h-2zM20 27h6l-1 10h-6zM12 27h5l-2 8h-4zM13 21.5h8v2h-8z\",\n  },\n  {\n    id: \"hush\",\n    name: \"Onyx Hush arc blade\",\n    maker: \"Onyx Dynamics\",\n    type: \"Arc blade\",\n    kind: \"weapon\",\n    rarity: \"epic\",\n    output: { label: \"Output\", value: 506, unit: \"dps\", precision: 1 },\n    stats: [\n      { label: \"Handling\", value: 88 },\n      { label: \"Range\", value: 9 },\n      { label: \"Quiet\", value: 96 },\n    ],\n    mods: [\"Capacitor edge\", null],\n    weight: 1.8,\n    price: 9800,\n    serial: \"OD-HSH // REV 4 // PROTOCOL 7741-C\",\n    note: \"The edge only carries a charge on the swing. Nothing hums while it's sheathed, which is the point.\",\n    art: \"M44 4l-1 6-23 22-4-4zM12 26l10 10-2 2-10-10zM13 33l2 2-8 8-2-2zM3 41l4 4-2 2-4-4z\",\n  },\n  {\n    id: \"sparrow\",\n    name: \"Kestrel Sparrow sidearm\",\n    maker: \"Kestrel Arms\",\n    type: \"Sidearm\",\n    kind: \"weapon\",\n    rarity: \"common\",\n    output: { label: \"Output\", value: 188.4, unit: \"dps\", precision: 1 },\n    stats: [\n      { label: \"Handling\", value: 81 },\n      { label: \"Range\", value: 31 },\n      { label: \"Quiet\", value: 40 },\n    ],\n    mods: [null],\n    weight: 1.1,\n    price: 950,\n    serial: \"KA-SPW // LOT 07\",\n    note: \"Issued by the crate to dock security. Plain, light, and it has never once jammed.\",\n    art: \"M6 16h34v8H6zM40 18h4v4h-4zM8 13h3v3H8zM36 13h3v3h-3zM9 24h11l-2 16H8zM21 24h8v6h-8v-1.5h6.5v-3H21zM10 18.5h20v1.5H10z\",\n  },\n  {\n    id: \"lumen\",\n    name: \"Onyx Lumen optics\",\n    maker: \"Onyx Dynamics\",\n    type: \"Optics\",\n    kind: \"head\",\n    rarity: \"legend\",\n    output: { label: \"Threat range\", value: 140, unit: \"m\" },\n    stats: [\n      { label: \"Low light\", value: 94 },\n      { label: \"Thermal\", value: 86 },\n      { label: \"Battery\", value: 61 },\n    ],\n    mods: [\"Threat overlay\", \"Smart-link bridge\"],\n    armor: 12,\n    weight: 0.3,\n    price: 15000,\n    serial: \"OD-LMN // REV 3 // CS-07\",\n    note: \"Thermal and low light on one lens, with an overlay that marks anything holding a weapon.\",\n    art: \"M4 18h40v8l-5 7H28l-3-4h-2l-3 4H9l-5-7zM9 21v4l2 4h6l3-4v-4zM28 21v4l3 4h6l2-4v-4zM40 12h2v6h-2z\",\n  },\n  {\n    id: \"halo\",\n    name: \"Vanta Halo rebreather\",\n    maker: \"Vanta Systems\",\n    type: \"Mask\",\n    kind: \"head\",\n    rarity: \"rare\",\n    output: { label: \"Filtration\", value: 96, unit: \"%\" },\n    stats: [\n      { label: \"Seal\", value: 90 },\n      { label: \"Voice mask\", value: 55 },\n    ],\n    mods: [null],\n    armor: 18,\n    weight: 0.7,\n    price: 2600,\n    isNew: true,\n    serial: \"VS-HLO // LOT 31 // NEW STOCK\",\n    note: \"For the Stacks' lower levels, where the air has a color. It flattens a voice, too.\",\n    art: \"M14 10h20l4 8v10l-6 10H16l-6-10V18zM15 16v5h18v-5zM20 27v1.5h8V27zM20 31v1.5h8V31zM4 26h5v10H4zM39 26h5v10h-5z\",\n  },\n  {\n    id: \"wraith\",\n    name: \"Wraith mesh jacket\",\n    maker: \"Static Saints cut\",\n    type: \"Jacket\",\n    kind: \"chest\",\n    rarity: \"epic\",\n    output: { label: \"Armor\", value: 148 },\n    stats: [\n      { label: \"Mobility\", value: 77 },\n      { label: \"Insulation\", value: 52 },\n      { label: \"Low profile\", value: 83 },\n    ],\n    mods: [\"Ceramic weave\", null],\n    armor: 148,\n    weight: 2.2,\n    price: 7400,\n    serial: \"WR-MSH // REV 2 // NODE 1C:09\",\n    note: \"The mesh stiffens where it's struck and nowhere else. Scanners read it as an ordinary coat.\",\n    art: \"M16 6l8 6 8-6 10 5 4 16-6 2-3-8v21H11V21l-3 8-6-2 4-16zM23.3 13v29h1.4V13zM15 31v2h5v-2zM28 31v2h5v-2z\",\n  },\n  {\n    id: \"union-vest\",\n    name: \"Lowtide Union work vest\",\n    maker: \"Lowtide Union\",\n    type: \"Vest\",\n    kind: \"chest\",\n    rarity: \"common\",\n    output: { label: \"Armor\", value: 60 },\n    stats: [\n      { label: \"Mobility\", value: 90 },\n      { label: \"Insulation\", value: 34 },\n      { label: \"Low profile\", value: 95 },\n    ],\n    mods: [],\n    armor: 60,\n    weight: 1.4,\n    price: 300,\n    serial: \"LU-VST // DOCK ISSUE\",\n    note: \"Every loader on the Lowtide docks wears one, so nobody looks twice at it.\",\n    art: \"M14 6h6l4 6 4-6h6v10l4 4v22H10V20l4-4zM14 26v6h8v-6zM26 26v6h8v-6zM23.3 14v8h1.4v-8z\",\n  },\n  {\n    id: \"greaves\",\n    name: \"Cinder Row runner greaves\",\n    maker: \"Cinder Row forge\",\n    type: \"Greaves\",\n    kind: \"legs\",\n    rarity: \"rare\",\n    output: { label: \"Armor\", value: 84 },\n    stats: [\n      { label: \"Mobility\", value: 69 },\n      { label: \"Grip\", value: 88 },\n    ],\n    mods: [\"Shock soles\"],\n    armor: 84,\n    weight: 1.9,\n    price: 3100,\n    serial: \"CR-GRV // LOT 14\",\n    note: \"Plated to the knee and soled for wet rooftops. They take the drop so the ankles don't.\",\n    art: \"M6 6h10v22l8 4v8H6zM26 6h10v22l8 4v8H26zM8 12v1.5h6V12zM28 12v1.5h6V12zM8 18v1.5h6V18zM28 18v1.5h6V18z\",\n  },\n  {\n    id: \"harness\",\n    name: \"Solace trauma harness\",\n    maker: \"Solace Mutual\",\n    type: \"Outfit\",\n    kind: \"outfit\",\n    rarity: \"rare\",\n    output: { label: \"Armor\", value: 40 },\n    stats: [\n      { label: \"Mobility\", value: 62 },\n      { label: \"Vitals uplink\", value: 97 },\n    ],\n    mods: [\"Medevac beacon\", null],\n    armor: 40,\n    weight: 2.8,\n    price: 5200,\n    serial: \"SM-TRH // POLICY 7741-C\",\n    note: \"Reads the wearer's vitals and calls a medevac before they can ask for one. The premium is steep.\",\n    art: \"M20 4h8v5l8 3 5 16-4 2-4-9v9l1 14h-7l-2-12h-2l-2 12h-7l1-14v-9l-4 9-4-2 5-16 8-3zM22.5 13v3h-3v3h3v3h3v-3h3v-3h-3v-3z\",\n  },\n  {\n    id: \"mk2\",\n    name: \"Vanta Mk.II deck\",\n    maker: \"Vanta Systems\",\n    type: \"Deck\",\n    kind: \"deck\",\n    rarity: \"epic\",\n    output: { label: \"Memory\", value: 12, unit: \"RAM\" },\n    stats: [\n      { label: \"Buffer\", value: 70 },\n      { label: \"Cooling\", value: 48 },\n      { label: \"Trace cover\", value: 81 },\n    ],\n    mods: [\"Ghostwrite\", \"Null Ping\", null],\n    weight: 0.9,\n    price: 11200,\n    serial: \"VS-MK2 // REV 0.1 // LINK STABLE\",\n    note: \"Three daemon sockets and a buffer deep enough to hold a door open while the next one loads.\",\n    art: \"M5 14h38v20l-4 4H5zM9 18v10h18V18zM30 18v3h4v-3zM36 18v3h4v-3zM30 23v3h4v-3zM36 23v3h4v-3zM9 31v2h10v-2zM38 8h2v6h-2z\",\n  },\n  {\n    id: \"booster\",\n    name: \"Meridian reflex booster\",\n    maker: \"Meridian Biotech\",\n    type: \"Injector\",\n    kind: \"quick\",\n    rarity: \"common\",\n    output: { label: \"Duration\", value: 12, unit: \"s\" },\n    stats: [\n      { label: \"Potency\", value: 66 },\n      { label: \"Onset\", value: 92 },\n    ],\n    mods: [],\n    weight: 0.6,\n    price: 1800,\n    count: 20,\n    serial: \"MB-RX // BATCH 0412\",\n    note: \"Twelve seconds in which everyone else is slow. The headache afterwards is not covered.\",\n    art: \"M8 20h24v8H8zM32 23h12v2H32zM2 22h6v4H2zM0 19h2v10H0zM12 22v4h12v-4zM30 17h2v14h-2z\",\n  },\n  {\n    id: \"patch-kit\",\n    name: \"Solace patch kit\",\n    maker: \"Solace Mutual\",\n    type: \"Field kit\",\n    kind: \"quick\",\n    rarity: \"common\",\n    output: { label: \"Restores\", value: 40, unit: \"%\" },\n    stats: [\n      { label: \"Potency\", value: 48 },\n      { label: \"Onset\", value: 60 },\n    ],\n    mods: [],\n    weight: 0.4,\n    price: 720,\n    count: 6,\n    serial: \"SM-PK // BATCH 0098\",\n    note: \"Sealant, clotting foam and a stimulant, in the order they're needed.\",\n    art: \"M8 14h32v24H8zM18 8h12v6h-2.5v-3.5h-7V14H18zM22 20v4h-4v4h4v4h4v-4h4v-4h-4v-4z\",\n  },\n]\n\nconst itemById = Object.fromEntries(items.map((item) => [item.id, item])) as Record<string, Item>\nconst slotById = Object.fromEntries(slots.map((slot) => [slot.id, slot])) as Record<string, Slot>\n\n// What's on the runner as the screen opens. Everything else is in the pack.\nconst startFitted: Record<string, string | null> = {\n  primary: \"kr9\",\n  secondary: \"hush\",\n  sidearm: null,\n  headgear: \"lumen\",\n  face: null,\n  inner: null,\n  outer: \"wraith\",\n  legwear: \"greaves\",\n  footwear: null,\n  outfit: null,\n  deck: \"mk2\",\n  \"quick-1\": \"booster\",\n  \"quick-2\": null,\n}\n\n// Money the way the Sprawl writes it: \"¤ 15 240\".\nfunction credits(amount: number) {\n  return `¤ ${Math.round(amount)\n    .toString()\n    .replace(/\\B(?=(\\d{3})+(?!\\d))/g, \" \")}`\n}\n\nconst kilos = (weight: number) => `${weight.toFixed(1)} kg`\n\nexport { credits, groupOf, itemById, items, kilos, slotById, slots, startFitted }\nexport type { Item, PackGroup, Slot, SlotKind }\n",
      "type": "registry:component",
      "target": "@components/blocks/loadout/gear.ts"
    },
    {
      "path": "registry/cyber/blocks/loadout/loadout.css",
      "content": "@layer ui-sdk, cyber.tokens, cyber.base, cyber.ui, cyber.blocks, cyber.fx, cyber.a11y;\n\n@layer cyber.blocks {\n  [data-skin=\"cyber\"] [data-loadout-screen] {\n    container: loadout / inline-size;\n  }\n\n  [data-skin=\"cyber\"] [data-kit=\"loadout\"] {\n    display: grid;\n    grid-template-columns: minmax(0, 1fr) clamp(285px, 27%, 360px);\n    gap: 24px clamp(16px, 2cqi, 30px);\n    align-items: start;\n    min-width: 0;\n\n    & > [data-kit=\"tabs\"] { container: inventory / inline-size; }\n  }\n\n  /* A region's name, the way the body's sections are headed. */\n  [data-skin=\"cyber\"] [data-loadout-heading] {\n    font-size: var(--cy-text-lg);\n    font-weight: 600;\n    line-height: 1.2;\n    letter-spacing: var(--cy-track);\n    text-transform: uppercase;\n    color: var(--cy-ink);\n  }\n\n  /* ── Fitted inventory ──────────────────────────────────────────────── */\n\n  [data-skin=\"cyber\"] [data-loadout-fitted] {\n    display: grid;\n    grid-template-columns: minmax(180px, 1fr) minmax(105px, .8fr) minmax(260px, 1.25fr);\n    grid-template-rows: auto 1fr;\n    grid-template-areas: \"weapons figure gear\" \"vitals figure gear\";\n    gap: 16px clamp(12px, 2cqi, 24px);\n    align-items: start;\n    padding-block-start: 10px;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-weapons] {\n    grid-area: weapons;\n    display: grid;\n    grid-template-columns: minmax(0, 1fr);\n    gap: 10px;\n    min-width: 0;\n\n    & ul {\n      display: grid;\n      gap: 10px;\n      margin: 0;\n      padding: 0;\n      list-style: none;\n    }\n\n    & li {\n      display: grid;\n      grid-template-columns: auto minmax(0, 1fr);\n      align-items: center;\n      gap: 12px;\n    }\n  }\n\n  /* What a tile holds, printed beside it. */\n  [data-skin=\"cyber\"] [data-loadout-caption] {\n    cursor: pointer;\n    display: grid;\n    gap: 2px;\n    min-width: 0;\n\n    & [data-kit=\"label\"] {\n      line-height: 1.2;\n      text-wrap: balance;\n    }\n\n    & [data-kit=\"hint\"] {\n      font-size: var(--cy-text-xs);\n    }\n\n    & [data-loadout-figure-of] {\n      margin-block-start: 2px;\n      font-size: var(--cy-text-md);\n    }\n  }\n\n  /* The stage the wireframe stands on: brackets on its corners, a rule\n     down its leading edge, print at its head and foot. */\n  [data-skin=\"cyber\"] [data-loadout-figure] {\n    grid-area: figure;\n    min-width: 0;\n    position: relative;\n    display: grid;\n    justify-items: center;\n    gap: 6px;\n    padding: 12px 12px 10px 20px;\n    color: var(--cy-line-ctl);\n\n    & > svg {\n      display: block;\n      width: 100%;\n      max-width: 190px;\n      height: auto;\n      fill: none;\n      stroke: currentColor;\n      stroke-width: 1;\n      stroke-linejoin: miter;\n    }\n\n    & [data-part] {\n      fill: color-mix(in srgb, var(--cy-accent) 7%, transparent);\n      transition:\n        stroke var(--cy-t) linear,\n        fill var(--cy-t) linear;\n    }\n\n    & [data-part=\"stage\"] {\n      fill: none;\n      stroke: var(--cy-line-deco);\n    }\n\n    /* The region the selection belongs to. */\n    &[data-region=\"weapon\"] [data-part~=\"weapon\"],\n    &[data-region=\"head\"] [data-part~=\"head\"],\n    &[data-region=\"chest\"] [data-part~=\"chest\"],\n    &[data-region=\"legs\"] [data-part~=\"legs\"],\n    &[data-region=\"outfit\"] [data-part~=\"outfit\"],\n    &[data-region=\"deck\"] [data-part~=\"deck\"],\n    &[data-region=\"quick\"] [data-part~=\"quick\"] {\n      stroke: var(--cy-signal);\n      fill: var(--cy-signal-fill);\n    }\n\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-figure-rule] {\n    position: absolute;\n    inset-block: 14px;\n    inset-inline-start: 4px;\n    height: auto;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-figure] [data-micro] {\n    justify-self: start;\n    max-width: 100%;\n    overflow: hidden;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-vitals] {\n    grid-area: vitals;\n    display: grid;\n    grid-template-columns: minmax(0, 1fr);\n    gap: 12px;\n    padding-block-start: 12px;\n    border-block-start: 1px solid var(--cy-line-deco);\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-gear] {\n    display: grid;\n    grid-area: gear;\n    grid-template-columns: repeat(2, minmax(0, 1fr));\n    gap: 18px clamp(12px, 2cqi, 24px);\n    min-width: 0;\n\n    & section {\n      display: grid;\n      align-content: start;\n      gap: 8px;\n      min-width: 0;\n    }\n\n    & [data-loadout-heading] {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n    }\n\n    & [data-loadout-heading]::after {\n      content: \"\";\n      flex: 1;\n      border-block-start: 1px solid var(--cy-line-deco);\n    }\n\n    & [data-kit=\"hint\"] {\n      font-size: var(--cy-text-xs);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-slots] {\n    display: grid;\n    grid-template-columns: repeat(2, minmax(0, 72px));\n    gap: 6px;\n\n    & > div {\n      display: grid;\n      gap: 4px;\n      align-content: start;\n    }\n\n    & [data-kit=\"item-slot\"] {\n      width: 100%;\n      height: auto;\n      aspect-ratio: 1;\n    }\n\n    & label {\n      font-family: var(--cy-font);\n      font-size: var(--cy-text-xs);\n      font-weight: 600;\n      line-height: 1.2;\n      letter-spacing: .04em;\n      color: var(--cy-ink-mute);\n      cursor: pointer;\n    }\n  }\n\n  @container inventory (max-width: 680px) {\n    [data-skin=\"cyber\"] [data-loadout-fitted] {\n      grid-template-columns: minmax(0, 1fr) minmax(0, .55fr);\n      grid-template-areas: \"weapons figure\" \"vitals vitals\" \"gear gear\";\n    }\n\n    [data-skin=\"cyber\"] [data-loadout-figure] {\n      align-self: stretch;\n      align-content: center;\n      padding: 8px 4px 8px 12px;\n\n      & > svg { width: auto; height: clamp(150px, 44cqi, 240px); max-width: 100%; }\n    }\n\n    [data-skin=\"cyber\"] [data-loadout-weapons] [data-kit=\"item-slot\"] {\n      --slot-size: clamp(50px, 15cqi, 76px);\n    }\n\n    [data-skin=\"cyber\"] [data-loadout-vitals] {\n      grid-template-columns: minmax(60px, .7fr) minmax(0, 2fr);\n      align-items: end;\n      gap: 20px;\n      padding-block: 12px;\n      border-block-end: 1px solid var(--cy-line-deco);\n    }\n\n    [data-skin=\"cyber\"] [data-loadout-gear] {\n      grid-template-columns: repeat(3, minmax(0, 1fr));\n    }\n  }\n\n  @container inventory (max-width: 440px) {\n    [data-skin=\"cyber\"] [data-loadout-fitted] { grid-template-columns: minmax(0, 1fr) 26%; }\n    [data-skin=\"cyber\"] [data-loadout-weapons] li { gap: 8px; }\n    [data-skin=\"cyber\"] [data-loadout-weapons] > [data-micro],\n    [data-skin=\"cyber\"] [data-loadout-figure] [data-micro] { display: none; }\n    [data-skin=\"cyber\"] [data-loadout-gear] { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n  }\n\n  /* ── Pack ──────────────────────────────────────────────────────────── */\n\n  [data-skin=\"cyber\"] [data-loadout-pack] {\n    display: grid;\n    gap: 14px;\n    padding-block-start: 10px;\n    min-width: 0;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-pack-head] {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: end;\n    justify-content: space-between;\n    gap: 10px 20px;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-pack-grid] {\n    display: grid;\n    grid-template-columns: repeat(auto-fill, minmax(min(100%, 236px), 1fr));\n    gap: 12px 24px;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n\n    & li {\n      display: grid;\n      grid-template-columns: auto minmax(0, 1fr);\n      align-items: center;\n      gap: 12px;\n      padding-block-end: 12px;\n      border-block-end: 1px solid var(--cy-line-deco);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-none] {\n    padding: 28px 0;\n    color: var(--cy-ink-mute);\n  }\n\n  /* ── The sheet ─────────────────────────────────────────────────────── */\n\n  [data-skin=\"cyber\"] [data-loadout-detail] {\n    display: grid;\n    min-width: 0;\n    gap: 6px;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-back] { display: none; }\n\n  [data-skin=\"cyber\"] [data-loadout-sheet] {\n    --panel-spine: 8px;\n    min-width: 0;\n\n    & [data-kit=\"panel-footer\"] {\n      display: grid;\n      grid-template-columns: repeat(3, minmax(0, 1fr));\n      gap: 6px;\n      padding-block: 10px;\n\n      & > button { min-width: 0; padding-inline: 6px; }\n      & > button:only-child { grid-column: 1 / -1; }\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-output] {\n    display: flex;\n    gap: 6px 12px;\n    flex-wrap: wrap;\n    align-items: center;\n    justify-content: space-between;\n\n    & [data-kit=\"readout\"] { --readout-size: clamp(34px, 4cqi, 50px); }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-swatch] {\n    display: grid;\n    place-items: center;\n    width: 54px;\n    aspect-ratio: 1;\n    color: var(--cy-ink);\n    background: repeating-linear-gradient(135deg, transparent 0 5px, color-mix(in srgb, currentColor 9%, transparent) 5px 6px);\n    border: 1px solid color-mix(in srgb, currentColor 45%, transparent);\n\n    &[data-rarity=\"rare\"] { color: var(--cy-rare); }\n    &[data-rarity=\"epic\"] { color: var(--cy-epic); }\n    &[data-rarity=\"legend\"] { color: var(--cy-flag); }\n    & svg { width: 80%; fill: currentColor; }\n  }\n\n  @container loadout (max-width: 760px) {\n    [data-skin=\"cyber\"] [data-kit=\"loadout\"] { grid-template-columns: minmax(0, 1fr); }\n    [data-skin=\"cyber\"] [data-loadout-back] { display: inline-flex; justify-self: start; }\n\n    [data-skin=\"cyber\"] [data-kit=\"screen-status\"] {\n      display: grid;\n      grid-template-columns: repeat(4, minmax(0, 1fr));\n      align-items: end;\n      gap: 12px;\n    }\n\n    [data-skin=\"cyber\"] :is([data-kit=\"screen-status-lead\"], [data-kit=\"screen-status-aside\"]) {\n      display: contents;\n    }\n  }\n\n  @container loadout (max-width: 460px) {\n    [data-skin=\"cyber\"] [data-kit=\"screen-status\"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }\n    [data-skin=\"cyber\"] [data-loadout-pack-head] > [data-kit=\"field\"] { width: 100%; }\n    [data-skin=\"cyber\"] [data-loadout-pack-head] [data-kit=\"segmented-control\"] { width: 100%; }\n    [data-skin=\"cyber\"] [data-loadout-pack-head] [data-kit=\"segmented-control-item\"] { padding-inline: 4px; min-height: 44px; }\n  }\n\n  /* It tears in each time the selection changes (the element is keyed by\n     what's selected). */\n  [data-skin=\"cyber\"] [data-loadout-sheet-body] {\n    display: grid;\n    gap: 14px;\n    min-width: 0;\n    animation: var(--cy-fx-in) 240ms var(--cy-ease-snap) backwards;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-line] {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 6px 8px;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-meters] {\n    display: grid;\n    gap: 10px;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-mods] {\n    display: grid;\n    gap: 6px;\n\n    & h3 {\n      display: flex;\n      align-items: baseline;\n      gap: 8px;\n    }\n\n    & ol {\n      display: grid;\n      gap: 4px;\n      margin: 0;\n      padding: 0;\n      list-style: none;\n    }\n\n    & li {\n      display: flex;\n      align-items: center;\n      gap: 8px;\n      font-size: var(--cy-text-sm);\n      color: var(--cy-ink-mute);\n\n      &[data-fitted] {\n        color: var(--cy-ink-hi);\n      }\n    }\n  }\n\n  /* A socket: solid when something's fitted in it, hollow when it's free. */\n  [data-skin=\"cyber\"] [data-loadout-socket] {\n    flex: none;\n    width: 9px;\n    height: 9px;\n    border: 1px solid var(--cy-signal-dim);\n\n    [data-fitted] > & {\n      border-color: var(--cy-signal);\n      background: var(--cy-signal);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-note] {\n    font-size: var(--cy-text-sm);\n    color: var(--cy-ink-hi);\n    text-wrap: pretty;\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-facts] {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 8px 24px;\n    margin: 0;\n    padding-block-start: 10px;\n    border-block-start: 1px solid var(--cy-line-deco);\n\n    & dt {\n      font-size: var(--cy-text-xs);\n      font-weight: 600;\n      letter-spacing: var(--cy-track);\n      text-transform: uppercase;\n      color: var(--cy-ink);\n    }\n\n    & dd {\n      margin: 0;\n      font-family: var(--cy-mono);\n      font-size: var(--cy-text-md);\n      color: var(--cy-signal);\n      white-space: nowrap;\n    }\n  }\n\n  /* The panel sets a list with dashes; this only lays each row out. */\n  [data-skin=\"cyber\"] [data-loadout-fits] {\n    margin: 0;\n    font-size: var(--cy-text-sm);\n    color: var(--cy-ink-hi);\n\n    & li {\n      display: flex;\n      flex-wrap: wrap;\n      align-items: baseline;\n      justify-content: space-between;\n      gap: 2px 12px;\n    }\n  }\n\n  /* ── The viewer ────────────────────────────────────────────────────── */\n\n  /* The item on a plate of registration marks, with its serial as a code\n     strip down the trailing side. */\n  [data-skin=\"cyber\"] [data-loadout-viewer] {\n    --viewer-ink: var(--cy-accent);\n\n    display: grid;\n    grid-template-columns: minmax(0, 1fr) auto;\n    gap: 8px;\n    min-width: 0;\n\n    &[data-rarity=\"rare\"] {\n      --viewer-ink: var(--cy-rare);\n    }\n    &[data-rarity=\"epic\"] {\n      --viewer-ink: var(--cy-epic);\n    }\n    &[data-rarity=\"legend\"] {\n      --viewer-ink: var(--cy-flag);\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-viewer-plate] {\n    position: relative;\n    display: grid;\n    grid-template-rows: auto minmax(0, 1fr) auto;\n    justify-items: center;\n    gap: 4px;\n    min-height: 230px;\n    padding: 8px 28px;\n    border: 1px solid var(--cy-line-deco);\n    background-color: var(--cy-void);\n\n    & > [data-loadout-viewer-marks] {\n      position: absolute;\n      inset: 0;\n      width: 100%;\n      height: 100%;\n      fill: none;\n      stroke: var(--cy-line-deco);\n      stroke-width: 1;\n    }\n\n    & > [data-loadout-viewer-art] {\n      position: relative;\n      align-self: center;\n      display: block;\n      width: min(72%, 230px);\n      height: auto;\n      fill: color-mix(in srgb, var(--viewer-ink) 16%, transparent);\n      stroke: var(--viewer-ink);\n      stroke-width: 1.25;\n      stroke-linejoin: miter;\n      filter: drop-shadow(0 0 calc(10px * var(--cy-fx)) color-mix(in srgb, var(--viewer-ink) 45%, transparent));\n    }\n\n    & > [data-micro] {\n      position: relative;\n      justify-self: start;\n      max-width: 100%;\n      padding-inline: 4px;\n      overflow: hidden;\n      text-overflow: ellipsis;\n      /* Print sits on the plate, not on the marks behind it. */\n      background: var(--cy-void);\n      opacity: 1;\n    }\n  }\n\n  [data-skin=\"cyber\"] [data-loadout-viewer-strip] {\n    display: flex;\n    align-items: stretch;\n    gap: 4px;\n    max-height: 250px;\n    overflow: hidden;\n    color: var(--cy-line-ctl);\n  }\n}\n",
      "type": "registry:file",
      "target": "@components/blocks/loadout/loadout.css"
    },
    {
      "path": "registry/cyber/blocks/loadout/loadout.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\nimport { ArrowUp } from \"lucide-react\"\nimport { Figure } from \"@/registry/cyber/blocks/loadout/figure\"\nimport {\n  credits,\n  groupOf,\n  itemById,\n  items,\n  kilos,\n  slotById,\n  slots,\n  startFitted,\n  type Item,\n  type PackGroup,\n  type Slot,\n} from \"@/registry/cyber/blocks/loadout/gear\"\nimport { AlertDialog } from \"@/registry/cyber/ui/alert-dialog\"\nimport { Badge, type BadgeTone } from \"@/registry/cyber/ui/badge\"\nimport { Button } from \"@/registry/cyber/ui/button\"\nimport { Dialog } from \"@/registry/cyber/ui/dialog\"\nimport { ItemSlot, type ItemRarity } from \"@/registry/cyber/ui/item-slot\"\nimport { Meter } from \"@/registry/cyber/ui/meter\"\nimport { Barcode, Corners, Micro } from \"@/registry/cyber/ui/micro\"\nimport { Panel } from \"@/registry/cyber/ui/panel\"\nimport { Readout } from \"@/registry/cyber/ui/readout\"\nimport { Screen } from \"@/registry/cyber/ui/screen\"\nimport { SegmentedControl } from \"@/registry/cyber/ui/segmented-control\"\nimport { Tabs } from \"@/registry/cyber/ui/tabs\"\nimport { notify } from \"@/registry/cyber/ui/toaster\"\nimport \"@/registry/cyber/blocks/loadout/loadout.css\"\n\n// What a runner is carrying. The Fitted view is the body: weapons down one\n// side, a wireframe of the runner, and gear slots by region. The Pack view\n// is everything stowed, with a filter. Whatever is selected in either fills\n// the sheet beside them, and the sheet's keys fit it, stow it, open it in a\n// viewer or sell it.\n//\n// Only fitted gear counts against carry weight, so fitting and stowing move\n// the readout in the status strip; a sale moves the credits.\n\nconst carryLimit = 16\nconst heavyAt = 14.5\n\ntype View = \"fitted\" | \"pack\"\ntype Filter = \"all\" | PackGroup\n// An item, wherever it is, or a slot with nothing in it.\ntype Selection = { item: string } | { slot: string } | null\n\nconst rarityBadge: Record<ItemRarity, { tone: BadgeTone; word: string }> = {\n  common: { tone: \"mute\", word: \"Common\" },\n  rare: { tone: \"rare\", word: \"Rare\" },\n  epic: { tone: \"epic\", word: \"Epic\" },\n  legend: { tone: \"flag\", word: \"Legendary\" },\n}\n\nconst regions: { title: string; slots: string[] }[] = [\n  { title: \"Head\", slots: [\"headgear\", \"face\"] },\n  { title: \"Chest\", slots: [\"inner\", \"outer\"] },\n  { title: \"Legs\", slots: [\"legwear\", \"footwear\"] },\n  { title: \"Outfit\", slots: [\"outfit\"] },\n  { title: \"Deck\", slots: [\"deck\"] },\n  { title: \"Quick access\", slots: [\"quick-1\", \"quick-2\"] },\n]\n\nconst weaponSlots = slots.filter((slot) => slot.kind === \"weapon\")\n\nconst filters: { value: Filter; label: string }[] = [\n  { value: \"all\", label: \"All\" },\n  { value: \"weapon\", label: \"Weapons\" },\n  { value: \"wear\", label: \"Wear\" },\n  { value: \"tech\", label: \"Tech\" },\n]\n\nconst figureOf = (item: Item) => `${item.output.value.toFixed(item.output.precision ?? 0)}${item.output.unit ? ` ${item.output.unit}` : \"\"}`\n\nfunction Art({ d }: { d: string }) {\n  return (\n    <svg viewBox=\"0 0 48 48\" focusable=\"false\">\n      <path fillRule=\"evenodd\" d={d} />\n    </svg>\n  )\n}\n\n// The item on its plate: the same silhouette as the slot's, large, on\n// registration marks, with its serial as a code strip down the side.\nfunction Viewer({ item }: { item: Item }) {\n  const marks = React.useId()\n  return (\n    <div data-loadout-viewer=\"\" data-rarity={item.rarity} aria-hidden>\n      <div data-loadout-viewer-plate=\"\">\n        {/* A field of small crosses, one every 40px. */}\n        <svg data-loadout-viewer-marks=\"\" focusable=\"false\">\n          <defs>\n            <pattern id={marks} width=\"40\" height=\"40\" patternUnits=\"userSpaceOnUse\">\n              <path d=\"M16.5 20h7M20 16.5v7\" />\n            </pattern>\n          </defs>\n          <rect width=\"100%\" height=\"100%\" fill={`url(#${marks})`} />\n        </svg>\n        <Corners variant=\"cross\" size={9} inset={12} />\n        <Micro data-loadout-viewer-head=\"\">\n          {item.maker} // {item.type}\n        </Micro>\n        <svg data-loadout-viewer-art=\"\" viewBox=\"0 0 48 48\" focusable=\"false\">\n          <path fillRule=\"evenodd\" d={item.art} vectorEffect=\"non-scaling-stroke\" />\n        </svg>\n        <Micro data-loadout-viewer-foot=\"\">Registered to S. Quinn // fit or disable by holder only</Micro>\n      </div>\n      <div data-loadout-viewer-strip=\"\">\n        <Micro vertical>{item.serial}</Micro>\n        <Barcode value={item.serial} vertical size={16} />\n      </div>\n    </div>\n  )\n}\n\nexport default function Loadout() {\n  const [fitted, setFitted] = React.useState(startFitted)\n  const [owned, setOwned] = React.useState(() => items.map((item) => item.id))\n  const [balance, setBalance] = React.useState(15240)\n  const [selection, setSelection] = React.useState<Selection>({ item: \"kr9\" })\n  // The empty slot last chosen: the next thing fitted lands there if it can.\n  const [target, setTarget] = React.useState<string | null>(null)\n  const [view, setView] = React.useState<View>(\"fitted\")\n  const [filter, setFilter] = React.useState<Filter>(\"all\")\n  const [seen, setSeen] = React.useState<readonly string[]>([])\n  // The sale being confirmed. It outlives the sale itself, so the question\n  // doesn't change under the dialog while it closes.\n  const [selling, setSelling] = React.useState<Item | null>(null)\n  const [confirming, setConfirming] = React.useState(false)\n\n  const root = React.useRef<HTMLDivElement>(null)\n  const sheetRef = React.useRef<HTMLElement>(null)\n  const back = React.useRef<HTMLButtonElement>(null)\n  const lastSlot = React.useRef<HTMLElement | null>(null)\n  const rackId = React.useId()\n  const primary = React.useRef<HTMLButtonElement>(null)\n  const rescue = React.useRef(false)\n\n  const slotOf = (id: string) => slots.find((slot) => fitted[slot.id] === id) ?? null\n  const pack = owned.filter((id) => !slotOf(id)).map((id) => itemById[id])\n  const worn = slots.flatMap((slot) => (fitted[slot.id] ? [itemById[fitted[slot.id]!]] : []))\n  const load = Math.round(worn.reduce((sum, item) => sum + item.weight, 0) * 10) / 10\n  const armor = worn.reduce((sum, item) => sum + (item.armor ?? 0), 0)\n\n  const item = selection && \"item\" in selection ? itemById[selection.item] : null\n  const emptySlot = selection && \"slot\" in selection ? slotById[selection.slot] : null\n  const home = item ? slotOf(item.id) : null\n  const region = item?.kind ?? emptySlot?.kind ?? null\n  const isNew = (candidate: Item) => Boolean(candidate.isNew) && !seen.includes(candidate.id)\n\n  // A tile that's about to leave the page (a pack item being fitted) may be\n  // the focused one. Note that focus was here, and hand it to the sheet's\n  // first key if it ends up nowhere.\n  const holdFocus = () => {\n    rescue.current = Boolean(root.current?.contains(document.activeElement))\n  }\n  React.useEffect(() => {\n    if (!rescue.current) return\n    rescue.current = false\n    if (!document.activeElement || document.activeElement === document.body) primary.current?.focus()\n  })\n\n  const focusInventory = (button: HTMLElement | null) => {\n    const destination = button?.getClientRects().length ? button : root.current?.querySelector<HTMLElement>('[role=\"tab\"][aria-selected=\"true\"]')\n    destination?.focus({ preventScroll: true })\n    destination?.scrollIntoView({ block: \"center\" })\n  }\n\n  const select = (next: Selection, button: HTMLElement) => {\n    lastSlot.current = button\n    setSelection(next)\n    if (next && \"slot\" in next) setTarget(next.slot)\n    if (next && \"item\" in next && itemById[next.item].isNew) setSeen((ids) => (ids.includes(next.item) ? ids : [...ids, next.item]))\n    // When the sheet sits below the inventory, bring its new heading into\n    // view. A wide rack keeps focus on the tile for continued browsing.\n    if (back.current?.getClientRects().length) {\n      requestAnimationFrame(() => {\n        sheetRef.current?.focus({ preventScroll: true })\n        back.current?.scrollIntoView({ block: \"start\" })\n      })\n    }\n  }\n\n  // Where an item would go: the empty slot that was asked for, else the\n  // first free slot of its kind, else the first slot of its kind, whose\n  // item is sent back to the pack.\n  const landing = (candidate: Item): Slot => {\n    const fits = slots.filter((slot) => slot.kind === candidate.kind)\n    const asked = target ? slotById[target] : null\n    if (asked && asked.kind === candidate.kind && !fitted[asked.id]) return asked\n    return fits.find((slot) => !fitted[slot.id]) ?? fits[0]\n  }\n\n  const equip = (candidate: Item) => {\n    const slot = landing(candidate)\n    const displaced = fitted[slot.id] ? itemById[fitted[slot.id]!] : null\n    const next = Math.round((load + candidate.weight - (displaced?.weight ?? 0)) * 10) / 10\n    if (next > carryLimit) {\n      notify(\"Over the carry limit\", {\n        tone: \"warning\",\n        description: `${candidate.name} would bring the load to ${kilos(next)} of ${carryLimit}. Stow something first.`,\n      })\n      return\n    }\n    holdFocus()\n    setFitted({ ...fitted, [slot.id]: candidate.id })\n    setTarget(null)\n    notify(`${candidate.name} fitted`, {\n      tone: \"success\",\n      description: displaced ? `${slot.name}. ${displaced.name} went back to the pack.` : `${slot.name}. Load ${kilos(next)}.`,\n    })\n  }\n\n  const unequip = (candidate: Item, from: Slot) => {\n    holdFocus()\n    setFitted({ ...fitted, [from.id]: null })\n    notify(`${candidate.name} stowed`, { description: `${from.name} is open. Load ${kilos(Math.round((load - candidate.weight) * 10) / 10)}.` })\n  }\n\n  const toggle = () => {\n    if (!item) return\n    if (home) unequip(item, home)\n    else equip(item)\n  }\n\n  const choosePack = (group: Filter) => {\n    const available = pack.filter((candidate) => group === \"all\" || groupOf[candidate.kind] === group)\n    const next = available.find((candidate) => candidate.id === item?.id)\n      ?? available.find((candidate) => candidate.kind === emptySlot?.kind)\n      ?? available[0]\n    setFilter(group)\n    setSelection(next ? { item: next.id } : null)\n  }\n\n  const changeView = (next: View) => {\n    setView(next)\n    if (next === \"pack\") choosePack(filter)\n    else if (!home && !emptySlot) setSelection(worn.length ? { item: worn[0].id } : { slot: slots[0].id })\n  }\n\n  const browse = (group: Filter) => {\n    setView(\"pack\")\n    choosePack(group)\n    requestAnimationFrame(() => focusInventory(null))\n  }\n\n  const sell = (sold: Item) => {\n    const rest = pack.filter((other) => other.id !== sold.id)\n    setOwned(owned.filter((id) => id !== sold.id))\n    setBalance(balance + sold.price)\n    // The next thing in the pack takes the sheet, so its keys stay where\n    // focus returns to.\n    const next = rest.find((other) => filter === \"all\" || groupOf[other.kind] === filter)\n    setSelection(next ? { item: next.id } : null)\n    notify(`${sold.name} sold`, { tone: \"success\", description: `Ren Aoki paid ${credits(sold.price)}. Balance ${credits(balance + sold.price)}.` })\n    if (!next)\n      setTimeout(() => {\n        if (!document.activeElement || document.activeElement === document.body) primary.current?.focus()\n      }, 320)\n  }\n\n  // E fits or stows the selection, as the foot of the screen says. Not while\n  // typing, not as part of a shortcut, and not from inside a dialog.\n  const toggleRef = React.useRef(toggle)\n  React.useEffect(() => {\n    toggleRef.current = toggle\n  })\n  React.useEffect(() => {\n    const onKey = (event: KeyboardEvent) => {\n      if (event.defaultPrevented || event.key.toLowerCase() !== \"e\" || event.metaKey || event.ctrlKey || event.altKey || event.repeat) return\n      const from = event.target as Element | null\n      if (from !== document.body && !root.current?.contains(from)) return\n      if (from?.closest?.('input, textarea, select, [contenteditable=\"\"], [contenteditable=\"true\"], dialog, [role=\"dialog\"], [role=\"alertdialog\"]'))\n        return\n      toggleRef.current()\n    }\n    document.addEventListener(\"keydown\", onKey)\n    return () => document.removeEventListener(\"keydown\", onKey)\n  }, [])\n\n  // One slot on the body: the item fitted there, or the open slot.\n  const slotTile = (slot: Slot, size: \"md\" | \"lg\" = \"md\") => {\n    const held = fitted[slot.id] ? itemById[fitted[slot.id]!] : null\n    return (\n      <ItemSlot\n        id={`${rackId}-${slot.id}`}\n        label={held ? held.name : slot.name}\n        rarity={held?.rarity}\n        mods={held?.mods.length ? held.mods.map((mod) => mod !== null) : undefined}\n        count={held?.count}\n        equipped={Boolean(held)}\n        selected={held ? item?.id === held.id : emptySlot?.id === slot.id}\n        size={size}\n        onClick={(event) => select(held ? { item: held.id } : { slot: slot.id }, event.currentTarget)}\n      >\n        {held && <Art d={held.art} />}\n      </ItemSlot>\n    )\n  }\n\n  const deck = fitted.deck ? itemById[fitted.deck] : null\n\n  const fittedView = (\n    <div data-loadout-fitted=\"\">\n      <section data-loadout-weapons=\"\" aria-labelledby=\"loadout-weapons\">\n        <h2 id=\"loadout-weapons\" data-loadout-heading=\"\">\n          Weapons\n        </h2>\n        <ul>\n          {weaponSlots.map((slot) => {\n            const held = fitted[slot.id] ? itemById[fitted[slot.id]!] : null\n            return (\n              <li key={slot.id}>\n                {slotTile(slot, \"lg\")}\n                <label data-loadout-caption=\"\" htmlFor={`${rackId}-${slot.id}`}>\n                  <span data-kit=\"label\">{held ? held.name : slot.name}</span>\n                  <span data-kit=\"hint\">{held ? `${slot.name} // ${held.type}` : \"Open slot\"}</span>\n                  {held && (\n                    <span data-kit=\"value\" data-loadout-figure-of=\"\">\n                      {figureOf(held)}\n                    </span>\n                  )}\n                </label>\n              </li>\n            )\n          })}\n        </ul>\n        <Micro>CS-L0 // Rack 03 // Link stable</Micro>\n      </section>\n\n      <Figure region={region} />\n\n      <div data-loadout-vitals=\"\">\n        <Readout label=\"Armor\" value={armor} size=\"sm\" />\n        <Meter label=\"Load\" value={load} max={carryLimit} high={heavyAt} highLabel=\"Heavy\" segments={16} />\n      </div>\n\n      <div data-loadout-gear=\"\">\n        {regions.map((group) => {\n          const id = `loadout-${group.slots[0]}`\n          return (\n            <section key={group.title} aria-labelledby={id}>\n              <h2 id={id} data-loadout-heading=\"\">\n                {group.title}\n              </h2>\n              <div data-loadout-slots=\"\">\n                {group.slots.map((slotId) => (\n                  <div key={slotId}>\n                    {slotTile(slotById[slotId])}\n                    {group.slots.length > 1 && <label htmlFor={`${rackId}-${slotId}`}>{slotById[slotId].name}</label>}\n                  </div>\n                ))}\n              </div>\n              {group.title === \"Deck\" && (\n                <span data-kit=\"hint\">\n                  {deck ? `${deck.mods.filter(Boolean).length} of ${deck.mods.length} daemons loaded` : \"No deck jacked in\"}\n                </span>\n              )}\n            </section>\n          )\n        })}\n      </div>\n    </div>\n  )\n\n  const shown = pack.filter((candidate) => filter === \"all\" || groupOf[candidate.kind] === filter)\n  const packWeight = pack.reduce((sum, candidate) => sum + candidate.weight, 0)\n\n  const packView = (\n    <div data-loadout-pack=\"\">\n      <div data-loadout-pack-head=\"\">\n        <SegmentedControl<Filter> label=\"Pack filter\" value={filter} onValueChange={(next) => next && choosePack(next)} options={filters} />\n        <p data-kit=\"value\" role=\"status\">\n          {shown.length} of {pack.length} shown // {kilos(packWeight)} stowed\n        </p>\n      </div>\n      <p data-kit=\"hint\">Stowed gear rides in the drop pack. Only what's fitted counts against carry weight.</p>\n      {shown.length ? (\n        <ul data-loadout-pack-grid=\"\">\n          {shown.map((candidate) => (\n            <li key={candidate.id}>\n              <ItemSlot\n                id={`${rackId}-pack-${candidate.id}`}\n                label={candidate.name}\n                rarity={candidate.rarity}\n                mods={candidate.mods.length ? candidate.mods.map((mod) => mod !== null) : undefined}\n                count={candidate.count}\n                isNew={isNew(candidate)}\n                selected={item?.id === candidate.id}\n                onClick={(event) => select({ item: candidate.id }, event.currentTarget)}\n              >\n                <Art d={candidate.art} />\n              </ItemSlot>\n              <label data-loadout-caption=\"\" htmlFor={`${rackId}-pack-${candidate.id}`}>\n                <span data-kit=\"label\">{candidate.name}</span>\n                <span data-kit=\"hint\">\n                  {candidate.type} // {kilos(candidate.weight)}\n                </span>\n                <span data-kit=\"value\">{credits(candidate.price)}</span>\n              </label>\n            </li>\n          ))}\n        </ul>\n      ) : (\n        <p data-loadout-none=\"\">{pack.length ? \"Nothing stowed in this category.\" : \"The pack is empty.\"}</p>\n      )}\n    </div>\n  )\n\n  // What the selected item is measured against: the item of its kind that's\n  // fitted now, when both report the same figure.\n  const rival = item && !home ? worn.find((other) => other.kind === item.kind && other.output.label === item.output.label) : null\n  const candidates = emptySlot ? pack.filter((candidate) => candidate.kind === emptySlot.kind) : []\n  const sheetKey = item ? item.id : emptySlot ? `slot:${emptySlot.id}` : \"none\"\n\n  const sheet = (\n    <Panel\n      ref={sheetRef}\n      tabIndex={-1}\n      data-loadout-sheet=\"\"\n      level={2}\n      title={item ? item.name : emptySlot ? emptySlot.name : \"No selection\"}\n      code={item ? item.serial : \"CS-L0 // SLOT OPEN // NO SIGNAL\"}\n      actions={item ? <Badge tone={rarityBadge[item.rarity].tone}>{rarityBadge[item.rarity].word}</Badge> : emptySlot ? <Badge tone=\"mute\">Open</Badge> : undefined}\n      footer={\n        <>\n          <Button\n            ref={primary}\n            tone=\"primary\"\n            onClick={() => (item ? toggle() : browse(emptySlot ? groupOf[emptySlot.kind] : \"all\"))}\n          >\n            {item ? (home ? \"Unequip\" : \"Equip\") : \"Browse pack\"}\n          </Button>\n          {item && (\n            <Dialog trigger=\"Inspect\" title={item.name} description={`${item.type}, ${item.maker}. ${item.note}`} confirm=\"Close viewer\" cancel={null} code={item.serial}>\n              <Viewer item={item} />\n            </Dialog>\n          )}\n          {item && (\n            <Button\n              disabled={Boolean(home)}\n              onClick={() => {\n                setSelling(item)\n                setConfirming(true)\n              }}\n            >\n              Sell\n            </Button>\n          )}\n        </>\n      }\n    >\n      {/* Keyed by what's selected, so the sheet tears in each time it changes.\n          The keys below stay put, and keep focus. */}\n      <div key={sheetKey} data-loadout-sheet-body=\"\">\n        {item ? (\n          <>\n            <p data-loadout-line=\"\">\n              <span data-kit=\"hint\">\n                {item.type} // {item.maker}\n              </span>\n              {home ? (\n                <Badge tone=\"signal\" status>\n                  Fitted: {home.name}\n                </Badge>\n              ) : (\n                <Badge tone=\"mute\" status>\n                  Stowed\n                </Badge>\n              )}\n              {isNew(item) && <Badge tone=\"flag\">New</Badge>}\n            </p>\n            <div data-loadout-output=\"\">\n              <Readout\n                size=\"lg\"\n                label={item.output.label}\n                value={item.output.value}\n                unit={item.output.unit}\n                precision={item.output.precision}\n                delta={rival ? item.output.value - rival.output.value : undefined}\n              />\n              <span data-loadout-swatch=\"\" data-rarity={item.rarity} aria-hidden>\n                <Art d={item.art} />\n              </span>\n            </div>\n            {rival && <p data-kit=\"hint\">Against the {rival.name}, fitted now.</p>}\n            <div data-loadout-meters=\"\">\n              {item.stats.map((stat) => (\n                <Meter key={stat.label} label={stat.label} value={stat.value} />\n              ))}\n            </div>\n            <div data-loadout-mods=\"\">\n              <h3 data-kit=\"label\">\n                Mods{\" \"}\n                {item.mods.length > 0 && (\n                  <span data-kit=\"value\">\n                    {item.mods.filter(Boolean).length}/{item.mods.length}\n                  </span>\n                )}\n              </h3>\n              {item.mods.length ? (\n                // Sockets are numbered, so the list is ordered.\n                <ol>\n                  {item.mods.map((mod, index) => (\n                    <li key={index} data-fitted={mod ? \"\" : undefined}>\n                      <span data-loadout-socket=\"\" aria-hidden />\n                      {mod ?? \"Empty socket\"}\n                    </li>\n                  ))}\n                </ol>\n              ) : (\n                <p data-kit=\"hint\">No sockets on this one.</p>\n              )}\n            </div>\n            <p data-loadout-note=\"\">{item.note}</p>\n            <dl data-loadout-facts=\"\">\n              <div>\n                <dt>Weight</dt>\n                <dd>{kilos(item.weight)}</dd>\n              </div>\n              <div>\n                <dt>Price</dt>\n                <dd>{credits(item.price)}</dd>\n              </div>\n              {item.count != null && (\n                <div>\n                  <dt>Stack</dt>\n                  <dd>{item.count}</dd>\n                </div>\n              )}\n            </dl>\n          </>\n        ) : emptySlot ? (\n          <>\n            <p data-loadout-note=\"\">Nothing is fitted here.</p>\n            {candidates.length ? (\n              <>\n                <p data-kit=\"hint\">\n                  {candidates.length} stowed {candidates.length === 1 ? \"item fits\" : \"items fit\"} this slot:\n                </p>\n                <ul data-loadout-fits=\"\">\n                  {candidates.map((candidate) => (\n                    <li key={candidate.id}>\n                      {candidate.name} <span data-kit=\"value\">{figureOf(candidate)}</span>\n                    </li>\n                  ))}\n                </ul>\n              </>\n            ) : (\n              <p data-kit=\"hint\">Nothing in the pack fits this slot.</p>\n            )}\n          </>\n        ) : (\n          <p data-loadout-note=\"\">Choose a slot or a stowed item to read its sheet.</p>\n        )}\n      </div>\n    </Panel>\n  )\n\n  return (\n    <Screen\n      data-loadout-screen=\"\"\n      label=\"Loadout\"\n      code=\"CS-L0 // LOADOUT // SABLE QUINN // PROTOCOL 7741-C\"\n      status={\n        <>\n          <Readout label=\"Level\" value={34} size=\"sm\" />\n          <Readout label=\"Rep\" value={27} size=\"sm\" tone=\"ok\" />\n        </>\n      }\n      aside={\n        <>\n          <Readout label=\"Carry weight\" value={load} precision={1} unit={`/ ${carryLimit} kg`} size=\"sm\" tone={load >= heavyAt ? \"flag\" : \"signal\"} />\n          <Readout label=\"Credits\" prefix=\"¤\" value={balance} size=\"sm\" tone=\"flag\" />\n        </>\n      }\n      hints={[\n        { keys: \"⇥\", label: \"Next slot\" },\n        { keys: \"↵\", label: \"Select\" },\n        { keys: \"E\", label: \"Fit or stow\", onPress: toggle, disabled: !item },\n      ]}\n    >\n      <div data-kit=\"loadout\" ref={root}>\n        <Tabs\n          label=\"Loadout views\"\n          value={view}\n          onValueChange={(next) => next && changeView(next as View)}\n          tabs={[\n            { value: \"fitted\", label: \"Fitted\", content: fittedView },\n            { value: \"pack\", label: \"Pack\", flag: pack.some(isNew) ? \"New\" : undefined, content: packView },\n          ]}\n        />\n        <div data-loadout-detail=\"\">\n          <Button ref={back} data-loadout-back=\"\" tone=\"ghost\" onClick={() => focusInventory(lastSlot.current)}>\n            <ArrowUp aria-hidden /> Back to {view === \"fitted\" ? \"fitted gear\" : \"pack\"}\n          </Button>\n          {sheet}\n        </div>\n      </div>\n      <AlertDialog\n        open={confirming}\n        onOpenChange={(open) => setConfirming(open)}\n        title={selling ? `Sell the ${selling.name}?` : \"Sell this item?\"}\n        description={selling ? `Ren Aoki pays ${credits(selling.price)} for it. A sold item doesn't come back.` : undefined}\n        confirm={selling ? `Sell for ${credits(selling.price)}` : \"Sell\"}\n        cancel=\"Keep it\"\n        agentConfirm={\n          selling ? `Sells the ${selling.name} to the broker for ${credits(selling.price)} and removes it from the pack. This can't be undone.` : undefined\n        }\n        code=\"BROKER LINK // R.AOKI // ANSWER REQUIRED\"\n        onConfirm={() => {\n          if (selling) sell(selling)\n        }}\n      />\n    </Screen>\n  )\n}\n",
      "type": "registry:component",
      "target": "@components/blocks/loadout/loadout.tsx"
    }
  ],
  "categories": [
    "screen"
  ],
  "type": "registry:block"
}
