{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "canvas",
  "title": "Canvas",
  "author": "superzero11 <https://github.com/superzero11/uiset>",
  "description": "A node editor on UI SDK's canvas behaviors: pan and zoom, drag nodes or move them with Alt and arrows, spatial focus, Shift-drag box selection, wires drawn by pointer or with C and arrows, a minimap, zoom controls, a toolbar, an inspector, undo, and agent actions.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.5",
    "@ui-sdk/react@0.1.0-beta.5"
  ],
  "registryDependencies": [
    "https://uiset.dev/r/uiset.json",
    "https://uiset.dev/r/button.json",
    "https://uiset.dev/r/field.json",
    "https://uiset.dev/r/menu.json",
    "https://uiset.dev/r/toolbar.json"
  ],
  "files": [
    {
      "path": "registry/uiset/ui/canvas.tsx",
      "content": "\"use client\"\n\nimport { ariaKeyshortcuts, createUndoStack, type Viewport } from \"@ui-sdk/core\"\nimport { usePart, usePrimitive, type PartProps } from \"@ui-sdk/react/primitive\"\nimport { Fragment, useEffect, useId, useRef, useState, type CSSProperties, type ReactNode } from \"react\"\nimport { flushSync } from \"react-dom\"\nimport { Button } from \"./button\"\nimport { Field, FieldLabel, Input } from \"./field\"\nimport { Menu, MenuContent, MenuItem, MenuTrigger } from \"./menu\"\nimport { Toolbar, ToolbarButton, ToolbarSeparator } from \"./toolbar\"\nimport { Icon } from \"./shell/icons\"\nimport {\n  canvasPrimitive,\n  createCanvasController,\n  type CanvasController,\n  type CanvasEdge,\n  type CanvasNodeKind,\n} from \"./canvas/canvas\"\nimport { boundsOf, describeWires, nodeRect, parsePort, portKey, type CanvasNodeShape, type CanvasPort, type Point } from \"./canvas/geometry\"\nimport \"./shell/shell.css\"\nimport \"./chart/tokens.css\"\nimport \"./canvas/canvas.css\"\nimport { returnFocus } from \"./uiset/focus\"\n\ntype CanvasNode = CanvasNodeShape & {\n  x: number\n  y: number\n  /** One of `kinds`, shown above the title. */\n  kind?: string\n  /** A chart slot, 1 to 8, for the header's accent. */\n  color?: number\n  /** Anything your app keeps on a node, like a prompt or a model name. */\n  data?: Record<string, unknown>\n}\n\ntype CanvasChange = { reason: string; type: \"move\" | \"add\" | \"remove\" | \"edit\" }\n\ntype CanvasProps = {\n  /** The canvas's name, for people and agents. */\n  label: string\n  nodes?: CanvasNode[]\n  defaultNodes?: CanvasNode[]\n  onNodesChange?: (nodes: CanvasNode[], details: CanvasChange) => void\n  edges?: CanvasEdge[]\n  defaultEdges?: CanvasEdge[]\n  onEdgesChange?: (edges: CanvasEdge[], details: { reason: string }) => void\n  selected?: string[]\n  defaultSelected?: string[]\n  onSelectedChange?: (selected: string[]) => void\n  defaultViewport?: Viewport\n  /** Frames every node when the canvas first shows, instead of `defaultViewport`. */\n  fitView?: boolean\n  /** The kinds of node there are, for the Add menu and agents. */\n  kinds?: CanvasNodeKind[]\n  /** Makes the node \"Add\" or an agent asks for; return null to refuse. */\n  onAddNode?: (kind: string, at: Point, title?: string) => CanvasNode | null\n  /** Enter or a double-click on a node. */\n  onNodeOpen?: (node: CanvasNode) => void\n  /** Whether a wire may join these ports (\"node:out:port\" to \"node:in:port\"). */\n  canConnect?: (from: string, to: string) => boolean\n  locked?: (node: CanvasNode) => boolean\n  /** What a node shows under its ports. */\n  renderNode?: (node: CanvasNode) => ReactNode\n  /** Snapping grid and Alt+arrow step, in canvas units. */\n  grid?: number\n  /** The zoom buttons in the corner. */\n  controls?: boolean\n  minimap?: boolean\n  onUndo?: () => void\n  onRedo?: () => void\n  /** Lets a toolbar, an inspector or your code drive the canvas: `createCanvasController()`. */\n  controller?: CanvasController\n  className?: string\n}\n\nconst series = (color?: number) => `var(--chart-${Math.min(8, Math.max(1, Math.round(color ?? 1)))})`\n\nfunction useControllable<T>(value: T | undefined, initial: T) {\n  const [own, setOwn] = useState(initial)\n  return [value ?? own, (next: T) => value === undefined && setOwn(next)] as const\n}\n\nfunction NodesPart(props: PartProps<\"div\">) {\n  return usePart(canvasPrimitive, \"nodes\", {}, props, \"div\")\n}\nfunction NodePart({ value, ...props }: { value: string } & PartProps<\"div\">) {\n  return usePart(canvasPrimitive, \"node\", { value }, props, \"div\")\n}\nfunction PortPart({ value, ...props }: { value: string } & PartProps<\"span\">) {\n  return usePart(canvasPrimitive, \"port\", { value }, props, \"span\")\n}\nfunction WirePart({ value, ...props }: { value: string } & PartProps<\"path\">) {\n  return usePart(canvasPrimitive, \"wire\", { value }, props, \"path\")\n}\nfunction UnwirePart({ value, ...props }: { value: string } & PartProps<\"g\">) {\n  return usePart(canvasPrimitive, \"unwire\", { value }, props, \"g\")\n}\nfunction DraftPart(props: PartProps<\"path\">) {\n  return usePart(canvasPrimitive, \"draft\", {}, props, \"path\")\n}\nfunction GridPart(props: PartProps<\"div\">) {\n  return usePart(canvasPrimitive, \"grid\", {}, props, \"div\")\n}\nfunction WorldPart(props: PartProps<\"div\">) {\n  return usePart(canvasPrimitive, \"world\", {}, props, \"div\")\n}\nfunction ZoomPart(props: PartProps<\"button\">) {\n  return usePart(canvasPrimitive, \"zoom\", {}, props, \"button\")\n}\nfunction LassoPart(props: PartProps<\"div\">) {\n  return usePart(canvasPrimitive, \"lasso\", {}, props, \"div\")\n}\n\nfunction PortRow({ node, index }: { node: CanvasNode; index: number }) {\n  const input: CanvasPort | undefined = node.inputs?.[index]\n  const output: CanvasPort | undefined = node.outputs?.[index]\n  return (\n    <span className=\"canvas-node-row\">\n      <span className=\"canvas-node-in\">\n        {input && <PortPart value={portKey(node.id, \"in\", input.id)} className=\"canvas-port\" />}\n        <span className=\"canvas-port-label\">{input?.label}</span>\n      </span>\n      <span className=\"canvas-node-out\">\n        <span className=\"canvas-port-label\">{output?.label}</span>\n        {output && <PortPart value={portKey(node.id, \"out\", output.id)} className=\"canvas-port\" />}\n      </span>\n    </span>\n  )\n}\n\n/**\n * A node editor. Drag empty space to pan, scroll or pinch to zoom, Shift-drag to select a\n * box of nodes. Tab reaches the nodes once; arrows go to the nearest node that way, Alt\n * with arrows moves it, Space selects, C starts a wire, Delete removes, Enter opens.\n */\nfunction Canvas({\n  label,\n  nodes,\n  defaultNodes = [],\n  onNodesChange,\n  edges,\n  defaultEdges = [],\n  onEdgesChange,\n  selected,\n  defaultSelected,\n  onSelectedChange,\n  defaultViewport,\n  fitView = false,\n  kinds,\n  onAddNode,\n  onNodeOpen,\n  canConnect,\n  locked,\n  renderNode,\n  grid = 8,\n  controls = true,\n  minimap = true,\n  onUndo,\n  onRedo,\n  controller,\n  className,\n}: CanvasProps) {\n  const baseId = useId()\n  const helpId = `${baseId}-help`\n  const [allNodes, setOwnNodes] = useControllable(nodes, defaultNodes)\n  const [allEdges, setOwnEdges] = useControllable(edges, defaultEdges)\n  const setNodes = (next: CanvasNode[], details: CanvasChange) => {\n    setOwnNodes(next)\n    onNodesChange?.(next, details)\n  }\n  const setEdges = (next: CanvasEdge[], details: { reason: string }) => {\n    setOwnEdges(next)\n    onEdgesChange?.(next, details)\n  }\n  const positions = Object.fromEntries(allNodes.map((n) => [n.id, { x: n.x, y: n.y }]))\n  const byId = new Map(allNodes.map((n) => [n.id, n]))\n\n  const handle = usePrimitive(canvasPrimitive, {\n    nodes: allNodes,\n    positions,\n    onPositionsChange: (next, details) =>\n      setNodes(\n        allNodes.map((n) => (next[n.id] && (next[n.id]!.x !== n.x || next[n.id]!.y !== n.y) ? { ...n, ...next[n.id]! } : n)),\n        { reason: details.reason, type: \"move\" },\n      ),\n    edges: allEdges,\n    onEdgesChange: (next, details) => setEdges(next, { reason: details.reason }),\n    selected,\n    defaultSelected,\n    onSelectedChange: onSelectedChange ? (next) => onSelectedChange(next) : undefined,\n    defaultViewport,\n    grid,\n    kinds,\n    canConnect,\n    locked: locked ? (id) => !!byId.get(id) && locked(byId.get(id)!) : undefined,\n    onOpen: onNodeOpen ? (id) => byId.get(id) && onNodeOpen(byId.get(id)!) : undefined,\n    // A canvas whose nodes nobody can change doesn't remove them.\n    onRemove: nodes === undefined || onNodesChange ? (ids) => {\n      const gone = new Set(ids)\n      setNodes(\n        allNodes.filter((n) => !gone.has(n.id)),\n        { reason: \"imperative\", type: \"remove\" },\n      )\n      setEdges(\n        allEdges.filter((e) => !gone.has(parsePort(e.from).node) && !gone.has(parsePort(e.to).node)),\n        { reason: \"imperative\" },\n      )\n    } : undefined,\n    onAdd: onAddNode\n      ? (kind, at, title) => {\n          const node = onAddNode(kind, at, title)\n          if (!node) return undefined\n          // Rendered before this returns: whoever asked for the node, an agent's next step\n          // say, can use it by name at once. A render scheduled for later has lost that\n          // race in Firefox (\"No node …\").\n          flushSync(() => setNodes([...allNodes, node], { reason: \"imperative\", type: \"add\" }))\n          return node.id\n        }\n      : undefined,\n    onUndo,\n    onRedo,\n    controller,\n  })\n\n  // Frame the nodes once the frame has a size to fit them in.\n  const fitted = useRef(false)\n  useEffect(() => {\n    if (!fitView || fitted.current) return\n    const el = handle.api.viewport.visible()\n    if (el.right - el.left <= 0) return\n    fitted.current = true\n    handle.api.fitView()\n  })\n\n  return usePart(\n    handle,\n    \"root\",\n    {},\n    {\n      \"aria-label\": label,\n      \"aria-describedby\": helpId,\n      className: [\"canvas\", className].filter(Boolean).join(\" \"),\n      children: (\n        <>\n          <p id={helpId} hidden>\n            Arrow keys go to the nearest node that way. Alt with arrows moves it, Space selects it,\n            C starts a wire (arrows choose an input, Enter connects, Escape stops), Delete removes,\n            Enter opens. Plus and minus zoom; 0 resets.\n          </p>\n          <GridPart className=\"canvas-grid\" />\n          <WorldPart className=\"canvas-world\">\n            <svg className=\"canvas-wires\" aria-hidden=\"true\" width=\"1\" height=\"1\">\n              {allEdges.map((edge) => (\n                <WirePart key={edge.id} value={edge.id} className=\"canvas-wire\" />\n              ))}\n              <DraftPart className=\"canvas-wire\" data-draft=\"\" />\n              {allEdges.map((edge) => (\n                <UnwirePart key={edge.id} value={edge.id} className=\"canvas-unwire\">\n                  <title>Disconnect</title>\n                  <circle r=\"9\" />\n                  <path d=\"M -3.5 -3.5 L 3.5 3.5 M 3.5 -3.5 L -3.5 3.5\" />\n                </UnwirePart>\n              ))}\n            </svg>\n            <NodesPart className=\"canvas-nodes\" aria-label={`${label} nodes`}>\n              {allNodes.map((node, index) => {\n                const rows = Math.max(node.inputs?.length ?? 0, node.outputs?.length ?? 0)\n                // Ids from data may hold spaces; these don't.\n                const partId = `${baseId}-n${index}`\n                const wires = describeWires(node, allNodes, allEdges)\n                const kind = kinds?.find((k) => k.id === node.kind)?.label\n                const body = renderNode?.(node)\n                return (\n                  <NodePart\n                    key={node.id}\n                    value={node.id}\n                    className=\"canvas-node\"\n                    // Named by what it shows, in the order it shows it: title, then kind.\n                    aria-labelledby={kind ? `${partId}-title ${partId}-kind` : `${partId}-title`}\n                    aria-describedby={[body ? `${partId}-body` : \"\", wires ? `${partId}-wires` : \"\"].filter(Boolean).join(\" \") || undefined}\n                    data-locked={locked?.(node) ? \"\" : undefined}\n                  >\n                    <span\n                      className=\"canvas-node-card\"\n                      style={{ inlineSize: `${node.width ?? 208}px`, \"--series\": series(node.color) } as CSSProperties}\n                    >\n                      <span className=\"canvas-node-header\">\n                        <span id={`${partId}-title`} className=\"canvas-node-title\">\n                          {node.title}\n                        </span>\n                        {kind && (\n                          <span id={`${partId}-kind`} className=\"canvas-node-kind\">\n                            {kind}\n                          </span>\n                        )}\n                      </span>\n                      {Array.from({ length: rows }, (_, i) => (\n                        <PortRow key={i} node={node} index={i} />\n                      ))}\n                      <span className=\"canvas-node-foot\" />\n                      {body ? (\n                        <span id={`${partId}-body`} className=\"canvas-node-body\">\n                          {body}\n                        </span>\n                      ) : null}\n                    </span>\n                    {wires && (\n                      <span id={`${partId}-wires`} hidden>\n                        {wires}\n                      </span>\n                    )}\n                  </NodePart>\n                )\n              })}\n            </NodesPart>\n          </WorldPart>\n          <LassoPart className=\"canvas-lasso\" />\n          {controls && (\n            <div className=\"canvas-controls\" role=\"group\" aria-label=\"Zoom\" data-canvas-control=\"\">\n              <Button variant=\"ghost\" aria-label=\"Zoom out\" onClick={() => handle.api.zoomOut()}>\n                <Icon name=\"minus\" />\n              </Button>\n              <ZoomPart className=\"canvas-zoom\" type=\"button\" onClick={() => handle.api.resetZoom()} />\n              <Button variant=\"ghost\" aria-label=\"Zoom in\" onClick={() => handle.api.zoomIn()}>\n                <Icon name=\"plus\" />\n              </Button>\n              <Button variant=\"ghost\" aria-label=\"Fit to view\" onClick={() => handle.api.fitView()}>\n                <Icon name=\"fit\" />\n              </Button>\n            </div>\n          )}\n          {minimap && <Minimap nodes={allNodes} onCenter={(point) => handle.api.centerOn(point)} />}\n        </>\n      ),\n    } as never,\n    \"div\",\n  )\n}\n\nfunction ViewboxPart(props: PartProps<\"rect\">) {\n  return usePart(canvasPrimitive, \"viewbox\", {}, props, \"rect\")\n}\nfunction MinimapPart(props: PartProps<\"svg\">) {\n  return usePart(canvasPrimitive, \"minimap\", {}, props, \"svg\")\n}\n\n/** A map of every node with the part in view; press or drag on it to look elsewhere. */\nfunction Minimap({\n  nodes,\n  onCenter,\n}: {\n  nodes: CanvasNode[]\n  onCenter: (point: Point) => void\n}) {\n  const svg = useRef<SVGSVGElement>(null)\n  // The map's frame follows the view, so a drag keeps the frame it started with: otherwise\n  // each move would re-map the next and the view would run away.\n  const frame = useRef<DOMMatrix | null>(null)\n  const toCanvas = (event: React.PointerEvent) => {\n    const matrix = frame.current\n    if (!matrix) return\n    const point = new DOMPoint(event.clientX, event.clientY).matrixTransform(matrix)\n    onCenter({ x: point.x, y: point.y })\n  }\n  return (\n    <div className=\"canvas-minimap\" aria-hidden=\"true\" data-canvas-control=\"\">\n      <MinimapPart\n        ref={svg}\n        preserveAspectRatio=\"xMidYMid meet\"\n        onPointerDown={(event: React.PointerEvent<SVGSVGElement>) => {\n          event.currentTarget.setPointerCapture(event.pointerId)\n          frame.current = svg.current?.getScreenCTM()?.inverse() ?? null\n          toCanvas(event)\n        }}\n        onPointerMove={(event: React.PointerEvent<SVGSVGElement>) => {\n          if (event.buttons) toCanvas(event)\n        }}\n        onPointerUp={() => (frame.current = null)}\n        onPointerCancel={() => (frame.current = null)}\n      >\n        {nodes.map((node) => {\n          const r = nodeRect(node, node)\n          return (\n            <rect\n              key={node.id}\n              className=\"canvas-minimap-node\"\n              x={r.left}\n              y={r.top}\n              width={r.right - r.left}\n              height={r.bottom - r.top}\n              rx=\"6\"\n              style={{ \"--series\": series(node.color) } as CSSProperties}\n            />\n          )\n        })}\n        <ViewboxPart className=\"canvas-minimap-view\" />\n      </MinimapPart>\n    </div>\n  )\n}\n\n/**\n * Add, remove, undo and fit, for a canvas, on UI SDK's Toolbar: one tab stop, arrows\n * between tools, and disabled tools still reachable, so focus never drops when one turns off.\n */\nfunction CanvasToolbar({\n  label = \"Canvas tools\",\n  canvas,\n  kinds,\n  selectedCount = 0,\n  onUndo,\n  onRedo,\n  canUndo = false,\n  canRedo = false,\n  children,\n}: {\n  /**\n   * The toolbar's own name. Keep the canvas's name out of it: agents find components by\n   * names that contain what they ask for, so \"Workflow tools\" would also answer \"Workflow\".\n   */\n  label?: string\n  canvas: CanvasController\n  /** Shows an Add menu with these kinds. */\n  kinds?: CanvasNodeKind[]\n  selectedCount?: number\n  onUndo?: () => void\n  onRedo?: () => void\n  canUndo?: boolean\n  canRedo?: boolean\n  children?: ReactNode\n}) {\n  // The menu hands focus back to its button as it closes; the new node takes it after.\n  const add = (kind: string) => {\n    let id: string | true | undefined\n    try {\n      id = canvas.addNode(kind)\n    } catch {\n      return\n    }\n    if (typeof id === \"string\") requestAnimationFrame(() => requestAnimationFrame(() => canvas.focusNode(id as string)))\n  }\n  return (\n    <Toolbar className=\"canvas-toolbar\" aria-label={label}>\n      {kinds?.length ? (\n        <Menu onAction={(value: unknown) => add(String(value))}>\n          <ToolbarButton render={<MenuTrigger data-variant=\"outline\" />}>\n            <Icon name=\"plus\" />\n            Add node\n          </ToolbarButton>\n          <MenuContent>\n            {kinds.map((kind) => (\n              <MenuItem key={kind.id} value={kind.id}>\n                {kind.label}\n              </MenuItem>\n            ))}\n          </MenuContent>\n        </Menu>\n      ) : null}\n      <ToolbarButton\n        data-variant=\"ghost\"\n        disabled={!selectedCount}\n        data-agent-confirm=\"Removes the selected nodes and their wires\"\n        onClick={() => canvas.removeSelected()}\n      >\n        <Icon name=\"trash\" />\n        {selectedCount > 1 ? `Remove ${selectedCount} nodes` : \"Remove node\"}\n      </ToolbarButton>\n      {(onUndo || onRedo) && <ToolbarSeparator />}\n      {onUndo && (\n        <ToolbarButton data-variant=\"ghost\" disabled={!canUndo} onClick={onUndo} aria-keyshortcuts={ariaKeyshortcuts(\"mod+z\")}>\n          Undo\n        </ToolbarButton>\n      )}\n      {onRedo && (\n        <ToolbarButton data-variant=\"ghost\" disabled={!canRedo} onClick={onRedo} aria-keyshortcuts={ariaKeyshortcuts(\"mod+shift+z\")}>\n          Redo\n        </ToolbarButton>\n      )}\n      <ToolbarSeparator />\n      <ToolbarButton data-variant=\"ghost\" onClick={() => canvas.fitView()}>\n        Fit view\n      </ToolbarButton>\n      {children}\n    </Toolbar>\n  )\n}\n\n/** The selected node's details: its title, its wires (each can be removed) and your fields. */\nfunction CanvasInspector({\n  node,\n  nodes,\n  edges,\n  canvas,\n  onRename,\n  children,\n  empty = \"Select a node to see its details.\",\n}: {\n  node: CanvasNode | null\n  nodes: CanvasNode[]\n  edges: CanvasEdge[]\n  canvas: CanvasController\n  onRename?: (node: CanvasNode, title: string) => void\n  /** Your fields for the node, like its prompt or model. */\n  children?: (node: CanvasNode) => ReactNode\n  empty?: string\n}) {\n  const titleId = useId()\n  if (!node)\n    return (\n      <aside className=\"canvas-inspector\" aria-labelledby={titleId}>\n        <h3 id={titleId} className=\"canvas-inspector-title\">\n          Details\n        </h3>\n        <p className=\"canvas-inspector-empty\">{empty}</p>\n      </aside>\n    )\n  const name = (key: string) => {\n    const { node: id, side, port } = parsePort(key)\n    const other = nodes.find((n) => n.id === id)\n    const list = side === \"in\" ? other?.inputs : other?.outputs\n    return `${other?.title ?? id} · ${list?.find((p) => p.id === port)?.label ?? port}`\n  }\n  const wires = edges.filter((e) => parsePort(e.from).node === node.id || parsePort(e.to).node === node.id)\n  // A removed wire's button goes; focus moves to the next one, or back to the node.\n  const disconnect = (index: number) => {\n    const wire = wires[index]!\n    const next = wires[index + 1] ?? wires[index - 1]\n    canvas.disconnect(wire.id)\n    returnFocus(() =>\n      next\n        ? (document.querySelector<HTMLElement>(`[data-canvas-wire=\"${CSS.escape(next.id)}\"]`) ?? undefined)\n        : canvas.nodeElement(node.id),\n    )\n  }\n  return (\n    // Keyed by node, so every field here, yours included, starts over for each node.\n    <Fragment key={node.id}>\n    <aside className=\"canvas-inspector\" aria-labelledby={titleId}>\n      <h3 id={titleId} className=\"canvas-inspector-title\">\n        {node.title}\n      </h3>\n      {onRename && (\n        <form\n          className=\"canvas-inspector-form\"\n          aria-label={`Rename ${node.title}`}\n          onSubmit={(event) => {\n            event.preventDefault()\n            const text = String(new FormData(event.currentTarget).get(\"node-title\") ?? \"\").trim()\n            if (text) onRename(node, text)\n          }}\n        >\n          <Field name=\"node-title\">\n            <FieldLabel>Title</FieldLabel>\n            <Input required defaultValue={node.title} autoComplete=\"off\" />\n          </Field>\n          <Button type=\"submit\" variant=\"outline\">\n            Rename\n          </Button>\n        </form>\n      )}\n      {children?.(node)}\n      <h4 className=\"canvas-inspector-heading\">Wires</h4>\n      {wires.length ? (\n        <ul className=\"canvas-inspector-wires\">\n          {wires.map((wire, index) => (\n            <li key={wire.id}>\n              <span>\n                {name(wire.from)} → {name(wire.to)}\n              </span>\n              <Button\n                variant=\"ghost\"\n                data-canvas-wire={wire.id}\n                onClick={() => disconnect(index)}\n                aria-label={`Disconnect ${name(wire.from)} from ${name(wire.to)}`}\n              >\n                Disconnect\n              </Button>\n            </li>\n          ))}\n        </ul>\n      ) : (\n        <p className=\"canvas-inspector-empty\">No wires yet. Focus the node and press C to start one.</p>\n      )}\n    </aside>\n    </Fragment>\n  )\n}\n\n/**\n * Nodes and edges with undo and redo. Pass `nodes`, `edges` and the change handlers to\n * `Canvas`, and `undo`, `redo`, `canUndo`, `canRedo` to it and its toolbar.\n */\nfunction useCanvasHistory(initial: { nodes: CanvasNode[]; edges: CanvasEdge[] }) {\n  type Snapshot = { nodes: CanvasNode[]; edges: CanvasEdge[] }\n  const [present, setPresent] = useState<Snapshot>(initial)\n  const [stack] = useState(() => createUndoStack<Snapshot>(initial))\n  const current = useRef(present)\n  const same = (a: Snapshot, b: Snapshot) =>\n    a.nodes.length === b.nodes.length &&\n    a.nodes.every((n, i) => n === b.nodes[i]) &&\n    a.edges.map((e) => e.id).join(\"|\") === b.edges.map((e) => e.id).join(\"|\")\n  // A change that changes nothing (a rename to the same title, a pruned selection) isn't a step.\n  const commit = (next: Snapshot) => {\n    if (same(next, current.current)) return\n    current.current = next\n    stack.record(next)\n    setPresent(next)\n  }\n  const restore = (next: Snapshot | undefined) => {\n    if (!next) return\n    current.current = next\n    setPresent(next)\n  }\n  const ids = (edges: CanvasEdge[]) => edges.map((e) => e.id).join(\"|\")\n  return {\n    nodes: present.nodes,\n    edges: present.edges,\n    onNodesChange: (nodes: CanvasNode[]) => {\n      // Removing nodes takes their wires in the same step, so one undo brings both back.\n      const kept = new Set(nodes.map((n) => n.id))\n      const edges = current.current.edges.filter((e) => kept.has(parsePort(e.from).node) && kept.has(parsePort(e.to).node))\n      commit({ nodes, edges })\n    },\n    onEdgesChange: (edges: CanvasEdge[]) => {\n      if (ids(edges) === ids(current.current.edges)) return\n      commit({ ...current.current, edges })\n    },\n    /** For changes outside the canvas, like a rename in the inspector. */\n    setNodes: (update: (nodes: CanvasNode[]) => CanvasNode[]) => {\n      const nodes = update(current.current.nodes)\n      // Equal nodes count as the same, so an edit that changes nothing records nothing.\n      const kept = nodes.map((n, i) => {\n        const was = current.current.nodes[i]\n        return was && JSON.stringify(was) === JSON.stringify(n) ? was : n\n      })\n      commit({ ...current.current, nodes: kept })\n    },\n    undo: () => restore(stack.undo()),\n    redo: () => restore(stack.redo()),\n    canUndo: stack.canUndo(),\n    canRedo: stack.canRedo(),\n  }\n}\n\n/** The box around every node, in canvas units. */\nconst canvasBounds = (nodes: CanvasNode[]) => boundsOf(nodes.map((n) => nodeRect(n, n)))\n\nexport { Canvas, CanvasInspector, CanvasToolbar, canvasBounds, createCanvasController, useCanvasHistory }\nexport type { CanvasChange, CanvasController, CanvasEdge, CanvasNode, CanvasNodeKind, CanvasPort, CanvasProps }\n",
      "type": "registry:ui",
      "target": "@ui/canvas.tsx"
    },
    {
      "path": "registry/uiset/ui/canvas/canvas.ts",
      "content": "import {\n  announce,\n  createChange,\n  createConnect,\n  createController,\n  createFocusRecovery,\n  createLasso,\n  createMove,\n  createRovingFocus,\n  createSelection,\n  createViewport,\n  css,\n  definePrimitive,\n  isFocusFromKeyboard,\n  live,\n  matchesShortcut,\n  selects,\n  spatialMove,\n  type ChangeDetails,\n  type ConnectDraft,\n  type LassoDraft,\n  type MoveDraft,\n  type MovePoint,\n  type Viewport,\n} from \"@ui-sdk/core\"\nimport { returnFocus } from \"../uiset/focus\"\nimport {\n  boundsOf,\n  nodeRect,\n  parsePort,\n  portKey,\n  portPoint,\n  wireMiddle,\n  wirePath,\n  type CanvasNodeShape,\n  type Point,\n} from \"./geometry\"\n\n// A node editor's behavior, composed from UI SDK: createViewport pans and zooms,\n// createMove drags nodes (Alt with arrows by keyboard), createSelection and createLasso\n// choose them, spatialMove sends focus to the nearest node in an arrow's direction, and\n// createConnect draws wires between ports, by pointer or with C then arrows.\n\ntype CanvasEdge = { id: string; from: string; to: string }\ntype CanvasPositions = Record<string, MovePoint>\ntype CanvasNodeKind = { id: string; label: string }\n\n/** What code outside the canvas can do: a toolbar, an inspector, or your own buttons. */\ntype CanvasControllerApi = {\n  fitView(): boolean\n  zoomIn(): boolean\n  zoomOut(): boolean\n  resetZoom(): boolean\n  /** The selected nodes' ids. */\n  selectedNodes(): string[]\n  /** Asks to remove the selected nodes (through `onRemove`), and moves focus to what's left. */\n  removeSelected(): boolean\n  /** Adds a node of a kind, in view, through `onAdd`; returns its id. */\n  addNode(kind: string, title?: string): string | true\n  /** Focuses a node, bringing it into view. */\n  focusNode(id: string): void\n  /** Removes one wire. */\n  disconnect(edge: string): boolean\n  /** A node's element, if it's on the canvas. */\n  nodeElement(id: string): HTMLElement | undefined\n}\n\n/** Connects a toolbar, an inspector or your code to a canvas. Create it once and pass it to both. */\nconst createCanvasController = () => createController<CanvasControllerApi>()\ntype CanvasController = ReturnType<typeof createCanvasController>\n\ntype CanvasOptions = {\n  /** Each node's title and ports. Positions live in `positions`. */\n  nodes: CanvasNodeShape[]\n  positions?: CanvasPositions\n  defaultPositions?: CanvasPositions\n  onPositionsChange?: (positions: CanvasPositions, details: ChangeDetails<string>) => void\n  edges?: CanvasEdge[]\n  defaultEdges?: CanvasEdge[]\n  onEdgesChange?: (edges: CanvasEdge[], details: ChangeDetails<string>) => void\n  selected?: string[]\n  defaultSelected?: string[]\n  onSelectedChange?: (selected: string[], details: ChangeDetails<string>) => void\n  viewport?: Viewport\n  defaultViewport?: Viewport\n  onViewportChange?: (viewport: Viewport, details: ChangeDetails<string>) => void\n  /** The grid nodes snap to, in canvas units, and how far Alt with an arrow nudges. */\n  grid?: number\n  minZoom?: number\n  maxZoom?: number\n  /** Whether a wire may join these ports, on top of output-to-input between two nodes. */\n  canConnect?: (from: string, to: string) => boolean\n  /** Nodes that can't be moved. */\n  locked?: (id: string) => boolean\n  /** Enter or a double-click on a node. */\n  onOpen?: (id: string) => void\n  /** Removes nodes; without it, Delete does nothing. The wires on them go too. */\n  onRemove?: (ids: string[]) => void\n  /** Adds a node of a kind at a point; returns its id. Without it, agents can't add nodes. */\n  onAdd?: (kind: string, at: Point, title?: string) => string | void\n  /** The kinds of node there are, for agents. */\n  kinds?: CanvasNodeKind[]\n  onUndo?: () => void\n  onRedo?: () => void\n  controller?: CanvasController\n}\n\nconst edgeId = (from: string, to: string) => `${from}->${to}`\n\n/** @internal Left out of @uiset/web's declarations: its type names UI SDK internals. */\nconst canvasPrimitive = definePrimitive({\n  name: \"canvas\",\n  options: {\n    nodes: \"value\",\n    positions: \"value\",\n    defaultPositions: \"value\",\n    onPositionsChange: \"callback\",\n    edges: \"value\",\n    defaultEdges: \"value\",\n    onEdgesChange: \"callback\",\n    selected: \"value\",\n    defaultSelected: \"value\",\n    onSelectedChange: \"callback\",\n    viewport: \"value\",\n    defaultViewport: \"value\",\n    onViewportChange: \"callback\",\n    grid: \"number\",\n    minZoom: \"number\",\n    maxZoom: \"number\",\n    canConnect: \"value\",\n    locked: \"value\",\n    onOpen: \"callback\",\n    onRemove: \"callback\",\n    onAdd: \"action\",\n    kinds: \"value\",\n    onUndo: \"callback\",\n    onRedo: \"callback\",\n    controller: \"value\",\n  },\n  controlled: [\"positions\", \"edges\", \"selected\", \"viewport\"],\n  live: [\"viewport\", \"moving\", \"lasso\", \"connecting\"],\n  state: (options: CanvasOptions) => ({\n    positions: options.positions ?? options.defaultPositions ?? ({} as CanvasPositions),\n    edges: options.edges ?? options.defaultEdges ?? ([] as CanvasEdge[]),\n    selected: options.selected ?? options.defaultSelected ?? ([] as string[]),\n    viewport: options.viewport ?? options.defaultViewport ?? { x: 0, y: 0, zoom: 1 },\n    moving: null as MoveDraft | null,\n    lasso: null as LassoDraft | null,\n    connecting: null as ConnectDraft | null,\n    focused: null as string | null,\n  }),\n  sync: (options) => ({\n    ...(options.positions === undefined ? {} : { positions: options.positions }),\n    ...(options.edges === undefined ? {} : { edges: options.edges }),\n    ...(options.selected === undefined ? {} : { selected: options.selected }),\n    ...(options.viewport === undefined ? {} : { viewport: options.viewport }),\n  }),\n  api: (context) => {\n    const opts = () => context.options()\n    const change = createChange(context)\n    const get = () => context.store.get()\n    const nodeOf = (id: string) => opts().nodes.find((n) => n.id === id)\n    const title = (id: string) => nodeOf(id)?.title ?? id\n    const portLabel = (key: string) => {\n      const { node, side, port } = parsePort(key)\n      const spec = nodeOf(node)\n      const list = side === \"in\" ? spec?.inputs : spec?.outputs\n      return `${title(node)} ${list?.find((p) => p.id === port)?.label ?? port}`\n    }\n\n    const viewport = createViewport(context, {\n      key: \"viewport\",\n      surface: () => context.element(\"root\") ?? null,\n      set: (value, details) => change(\"viewport\", value, details),\n      minZoom: () => opts().minZoom ?? 0.25,\n      maxZoom: () => opts().maxZoom ?? 2,\n    })\n\n    const selection = createSelection(context, {\n      key: \"selected\",\n      set: (value, details) => change(\"selected\", value, details),\n      order: () => opts().nodes.map((n) => n.id),\n      multiple: () => true,\n    })\n\n    const move = createMove(context, {\n      key: \"positions\",\n      draft: \"moving\",\n      set: (value, details) => change(\"positions\", value, details),\n      step: () => opts().grid ?? 8,\n      scale: () => get().viewport.zoom,\n      group: (key) => (get().selected.includes(key) ? get().selected : [key]),\n      disabled: (key) => opts().locked?.(key) ?? false,\n      label: title,\n    })\n\n    const lasso = createLasso(context, {\n      slot: \"node\",\n      draft: \"lasso\",\n      selected: () => get().selected,\n      set: (keys, details) => change(\"selected\", keys, details),\n      message: (count) => `${count} ${count === 1 ? \"node\" : \"nodes\"} selected`,\n    })\n\n    const roving = createRovingFocus(context, { slot: \"node\", key: \"focused\", move: spatialMove() })\n\n    // A node that goes (an undo, an agent, new props) leaves the selection too, after the\n    // render that removed it, so the toolbar never offers to remove a node that's gone.\n    const exists = (id: string) => opts().nodes.some((n) => n.id === id)\n    context.onOptions(() => {\n      for (const [id, at] of Object.entries(get().positions)) lastSeen.set(id, at)\n      queueMicrotask(() => {\n        const selected = get().selected\n        if (selected.some((id) => !exists(id)))\n          change(\"selected\", selected.filter(exists), { reason: \"imperative\" })\n      })\n    })\n\n    // A focused node that goes, however it went (an undo, an agent), hands focus to the node\n    // now nearest where it was, or to the canvas.\n    const lastSeen = new Map<string, Point>()\n    const recovery = createFocusRecovery<{ value: string }>({\n      fallback: (lost) => {\n        const was = lastSeen.get(lost.key)\n        const items = roving.items()\n        if (!was || !items.length) return items[0]?.el ?? context.element(\"root\") ?? undefined\n        const distance = (key: string) => {\n          const at = get().positions[key]\n          return at ? (at.x - was.x) ** 2 + (at.y - was.y) ** 2 : Infinity\n        }\n        return [...items].sort((a, b) => distance(a.key) - distance(b.key))[0]!.el\n      },\n    })\n\n    const canJoin = (from: string, to: string) => {\n      const a = parsePort(from)\n      const b = parsePort(to)\n      if (a.side !== \"out\" || b.side !== \"in\" || a.node === b.node) return false\n      if (get().edges.some((e) => e.from === from && e.to === to)) return false\n      return opts().canConnect?.(from, to) ?? true\n    }\n    // An input takes one wire: a new one replaces it.\n    const join = (from: string, to: string, details: { reason: string; event?: Event }) =>\n      change(\n        \"edges\",\n        [...get().edges.filter((e) => e.to !== to), { id: edgeId(from, to), from, to }],\n        details,\n      )\n\n    const wiring = createConnect(context, {\n      slot: \"port\",\n      draft: \"connecting\",\n      canConnect: canJoin,\n      point: (x, y) => viewport.toCanvas(x, y),\n      connect: (from, to, details) => join(from, to, details),\n      label: portLabel,\n    })\n\n    /** A node's place as drawn: its position, plus a drag under way. */\n    const placeOf = (state: ReturnType<typeof get>, id: string): Point | undefined => {\n      const at = state.positions[id]\n      if (!at) return undefined\n      const draft = state.moving\n      return draft?.keys.includes(id) ? { x: at.x + draft.dx, y: at.y + draft.dy } : at\n    }\n    const portAt = (state: ReturnType<typeof get>, key: string) => {\n      const { node, side, port } = parsePort(key)\n      const spec = nodeOf(node)\n      const at = placeOf(state, node)\n      return spec && at ? portPoint(spec, at, side, port) : undefined\n    }\n    const ends = (state: ReturnType<typeof get>, id: string) => {\n      const edge = state.edges.find((e) => e.id === id)\n      const from = edge && portAt(state, edge.from)\n      const to = edge && portAt(state, edge.to)\n      return from && to ? { from, to } : undefined\n    }\n\n    const rects = () =>\n      opts()\n        .nodes.map((n) => (get().positions[n.id] ? nodeRect(n, get().positions[n.id]!) : undefined))\n        .filter((r) => r !== undefined)\n    const fitView = () => {\n      const all = boundsOf(rects())\n      return all ? viewport.fit(all, { padding: 48, maxZoom: 1 }, { reason: \"imperative\" }) : false\n    }\n\n    const nodeElement = (id: string) => context.element(\"node\", id) ?? undefined\n    // After nodes go, focus the one nearest where they were; else the canvas itself.\n    const nearestTo = (ids: string[]) => {\n      const gone = new Set(ids)\n      const from = boundsOf(\n        ids.map((id) => (nodeOf(id) && get().positions[id] ? nodeRect(nodeOf(id)!, get().positions[id]!) : undefined)).filter((r) => r !== undefined),\n      )\n      const centerX = from ? (from.left + from.right) / 2 : 0\n      const centerY = from ? (from.top + from.bottom) / 2 : 0\n      let best: string | undefined\n      let distance = Infinity\n      for (const node of opts().nodes) {\n        const at = get().positions[node.id]\n        if (gone.has(node.id) || !at) continue\n        const d = (at.x - centerX) ** 2 + (at.y - centerY) ** 2\n        if (d < distance) [best, distance] = [node.id, d]\n      }\n      return best\n    }\n    const remove = (wanted: string[]) => {\n      const onRemove = opts().onRemove\n      const ids = wanted.filter(exists)\n      if (!onRemove || !ids.length) return false\n      const next = nearestTo(ids)\n      onRemove(ids)\n      change(\"selected\", get().selected.filter((id) => !ids.includes(id)), { reason: \"imperative\" })\n      announce(`Removed ${ids.length === 1 ? title(ids[0]!) : `${ids.length} nodes`}.`)\n      returnFocus(() => (next && nodeElement(next)) || (context.element(\"root\") ?? undefined))\n      return true\n    }\n\n    const findNode = (name: string) => {\n      const byId = opts().nodes.find((n) => n.id === name)\n      if (byId) return byId\n      const matches = opts().nodes.filter((n) => n.title.toLowerCase() === String(name).toLowerCase())\n      if (!matches.length) throw new Error(`No node \"${name}\". Nodes: ${opts().nodes.map((n) => n.title).join(\", \")}.`)\n      if (matches.length > 1)\n        throw new Error(`\"${name}\" names ${matches.length} nodes (ids ${matches.map((n) => n.id).join(\", \")}). Give the id.`)\n      return matches[0]!\n    }\n    const findPort = (node: CanvasNodeShape, side: \"in\" | \"out\", name?: string) => {\n      const list = (side === \"in\" ? node.inputs : node.outputs) ?? []\n      if (!list.length) throw new Error(`${node.title} has no ${side === \"in\" ? \"inputs\" : \"outputs\"}.`)\n      if (name === undefined) return list[0]!\n      const port = list.find((p) => p.id === name || p.label.toLowerCase() === String(name).toLowerCase())\n      if (!port)\n        throw new Error(`${node.title} has no ${side === \"in\" ? \"input\" : \"output\"} \"${name}\". It has: ${list.map((p) => p.label).join(\", \")}.`)\n      return port\n    }\n\n    /** What a node is joined to, in words, for its description and for agents. */\n    const wiresOf = (id: string) => {\n      const into = get()\n        .edges.filter((e) => parsePort(e.to).node === id)\n        .map((e) => `${portLabel(e.to).slice(title(id).length + 1)} from ${portLabel(e.from)}`)\n      const out = get()\n        .edges.filter((e) => parsePort(e.from).node === id)\n        .map((e) => `${portLabel(e.from).slice(title(id).length + 1)} to ${portLabel(e.to)}`)\n      return [into.length ? `Inputs: ${into.join(\"; \")}.` : \"\", out.length ? `Outputs: ${out.join(\"; \")}.` : \"\"]\n        .filter(Boolean)\n        .join(\" \")\n    }\n\n    // C starts a wire from the node's first output; C again tries its next one.\n    const startWire = (id: string) => {\n      const outs = nodeOf(id)?.outputs ?? []\n      if (!outs.length) {\n        announce(`${title(id)} has no outputs to connect.`)\n        return\n      }\n      const current = get().connecting?.from\n      const index = current ? outs.findIndex((p) => portKey(id, \"out\", p.id) === current) : -1\n      if (current) wiring.cancel()\n      wiring.start(portKey(id, \"out\", outs[(index + 1) % outs.length]!.id))\n    }\n\n    const zoomStep = 1.25\n\n    return {\n      viewport,\n      selection,\n      move,\n      lasso,\n      wiring,\n      roving,\n      recovery,\n      placeOf,\n      portAt,\n      title,\n      wiresOf,\n      startWire,\n      nodeElement,\n      remove,\n      /** A wire's path as drawn, following a drag under way. */\n      wire: (state: ReturnType<typeof get>, id: string) => {\n        const at = ends(state, id)\n        return at ? wirePath(at.from, at.to) : \"\"\n      },\n      /** Where a wire's remove button sits. */\n      wireMiddle: (state: ReturnType<typeof get>, id: string) => {\n        const at = ends(state, id)\n        return at ? wireMiddle(at.from, at.to) : undefined\n      },\n      /** The wire being drawn, from its port to the pointer or the chosen port. */\n      draftWire: (state: ReturnType<typeof get>) => {\n        const draft = state.connecting\n        if (!draft) return \"\"\n        const from = portAt(state, draft.from)\n        const to = draft.to ? portAt(state, draft.to) : { x: draft.x, y: draft.y }\n        return from && to ? wirePath(from, to) : \"\"\n      },\n      open: (id: string) => opts().onOpen?.(id),\n      fitView,\n      zoomIn: () => viewport.zoomBy(zoomStep, undefined, { reason: \"imperative\" }),\n      zoomOut: () => viewport.zoomBy(1 / zoomStep, undefined, { reason: \"imperative\" }),\n      resetZoom: () => viewport.zoomTo(1, undefined, { reason: \"imperative\" }),\n      selectedNodes: () => get().selected.filter(exists),\n      clearSelection: (reason: \"escape-key\" | \"outside-press\" | \"imperative\", event?: Event) =>\n        change(\"selected\", [], { reason, event }),\n      removeSelected: () => remove(get().selected),\n      focusNode: (id: string) => {\n        roving.focus(id)\n        const el = nodeElement(id)\n        if (el) viewport.reveal(viewport.rectOf(el), { padding: 32 }, { reason: \"imperative\" })\n      },\n      /** Pans so a canvas point sits in the middle of the frame, keeping the zoom. */\n      centerOn: (point: Point) => {\n        const el = context.element(\"root\")\n        if (!el) return false\n        const { zoom } = get().viewport\n        return viewport.setViewport(\n          { x: el.clientWidth / 2 - point.x * zoom, y: el.clientHeight / 2 - point.y * zoom, zoom },\n          { reason: \"imperative\" },\n        )\n      },\n      /** The minimap's frame: every node and the view, with room around them. */\n      overview: () => {\n        const view = viewport.visible()\n        const all = boundsOf([...rects(), view])!\n        const pad = Math.max(all.right - all.left, all.bottom - all.top) * 0.05\n        return `${all.left - pad} ${all.top - pad} ${all.right - all.left + pad * 2} ${all.bottom - all.top + pad * 2}`\n      },\n      view: () => viewport.visible(),\n      /** The port a keyboard wire started from, if one is under way. */\n      keyboardWire: () => (get().connecting?.keyboard ? get().connecting!.from : undefined),\n      undo: () => opts().onUndo?.(),\n      redo: () => opts().onRedo?.(),\n\n      // For agents and controllers, by the names people see.\n      /** Adds a node of a kind (by its id or label), in view unless x and y are given. */\n      addNode(kind: string, nodeTitle?: string, x?: number, y?: number): string {\n        const add = opts().onAdd\n        if (!add) throw new Error(\"This canvas doesn't add nodes.\")\n        const kinds = opts().kinds\n        const found = kinds?.find((k) => k.id === kind || k.label.toLowerCase() === String(kind).toLowerCase())\n        if (kinds && !found) throw new Error(`No kind \"${kind}\". Kinds: ${kinds.map((k) => k.label).join(\", \")}.`)\n        if ((x === undefined) !== (y === undefined)) throw new Error(\"Give both x and y, or neither to place it in view.\")\n        const view = viewport.visible()\n        let at =\n          x !== undefined && y !== undefined\n            ? { x: Number(x), y: Number(y) }\n            : { x: Math.round((view.left + view.right) / 2 - 104), y: Math.round((view.top + view.bottom) / 2 - 40) }\n        if (!Number.isFinite(at.x) || !Number.isFinite(at.y)) throw new Error(\"Give x and y as numbers.\")\n        // Several placed in view step down and across, so none hides another.\n        if (x === undefined)\n          while (Object.values(get().positions).some((p) => Math.abs(p.x - at.x) < 8 && Math.abs(p.y - at.y) < 8))\n            at = { x: at.x + 24, y: at.y + 24 }\n        const id = add(found?.id ?? kind, at, nodeTitle)\n        if (typeof id !== \"string\") throw new Error(\"The canvas didn't add that node.\")\n        announce(`Added ${nodeTitle ?? found?.label ?? kind}.`)\n        return id\n      },\n      /** Moves a node to a point, in canvas units. */\n      moveNode(node: string, x: number, y: number) {\n        const found = findNode(node)\n        if (opts().locked?.(found.id)) throw new Error(`${found.title} is locked.`)\n        if (!Number.isFinite(Number(x)) || !Number.isFinite(Number(y))) throw new Error(\"Give x and y as numbers.\")\n        return move.moveTo(found.id, { x: Number(x), y: Number(y) }, { reason: \"imperative\" })\n      },\n      /** Wires one node's output to another's input, by titles and, if they have several, port names. */\n      connect(fromNode: string, toNode: string, fromPort?: string, toPort?: string) {\n        const a = findNode(fromNode)\n        const b = findNode(toNode)\n        const from = portKey(a.id, \"out\", findPort(a, \"out\", fromPort).id)\n        const to = portKey(b.id, \"in\", findPort(b, \"in\", toPort).id)\n        if (!canJoin(from, to))\n          throw new Error(`${portLabel(from)} can't connect to ${portLabel(to)}: it's the same node, already wired, or not allowed.`)\n        return join(from, to, { reason: \"imperative\" })\n      },\n      /** Removes the wire between two nodes (or the one wire id). */\n      disconnect(fromNodeOrEdge: string, toNode?: string) {\n        const edges = get().edges\n        const found =\n          toNode === undefined\n            ? edges.filter((e) => e.id === fromNodeOrEdge)\n            : edges.filter(\n                (e) => parsePort(e.from).node === findNode(fromNodeOrEdge).id && parsePort(e.to).node === findNode(toNode).id,\n              )\n        if (!found.length) throw new Error(`No wire from ${fromNodeOrEdge}${toNode ? ` to ${toNode}` : \"\"}.`)\n        const gone = new Set(found.map((e) => e.id))\n        change(\"edges\", edges.filter((e) => !gone.has(e.id)), { reason: \"imperative\" })\n        announce(`Disconnected ${found.map((e) => `${portLabel(e.from)} from ${portLabel(e.to)}`).join(\", \")}.`)\n        return true\n      },\n      /** Selects nodes by title or id, replacing the selection. */\n      select(...nodes: string[]) {\n        const ids = [...new Set(nodes.map((n) => findNode(n).id))]\n        return change(\"selected\", ids, { reason: \"imperative\" })\n      },\n      openNode(node: string) {\n        const open = opts().onOpen\n        if (!open) throw new Error(\"This canvas doesn't open nodes.\")\n        open(findNode(node).id)\n        return true\n      },\n      /** Every node for agents: id, then title, place and wires. */\n      items: () =>\n        opts().nodes.map((n) => {\n          const at = get().positions[n.id]\n          const wires = wiresOf(n.id)\n          return {\n            value: n.id,\n            label: `${n.title} (at ${Math.round(at?.x ?? 0)}, ${Math.round(at?.y ?? 0)}${wires ? `; ${wires}` : \"\"})`,\n          }\n        }),\n    }\n  },\n  slots: (slot) => ({\n    // The frame: it clips, takes the gestures, and holds zoom keys for the whole canvas.\n    root: slot({\n      role: \"group\",\n      // Pans and zooms are live: nothing here reads them, so they render nothing.\n      selects: selects({ selected: () => [], focused: () => [] }),\n      attrs: (state) => ({\n        \"aria-roledescription\": \"canvas\",\n        // With no nodes to land on, the frame itself is the tab stop.\n        tabindex: Object.keys(state.positions).length ? \"-1\" : \"0\",\n        style: css({ position: \"relative\", overflow: \"clip\", \"touch-action\": \"none\", \"user-select\": \"none\" }),\n      }),\n      on: {\n        wheel: (event, { api }) => api.viewport.wheel(event as WheelEvent),\n        pointerdown: (event, { el, api }) => {\n          const e = event as PointerEvent\n          const target = e.target as Element\n          // Only empty space: the frame, the grid, the world, or the wire layer.\n          // A wire started by keyboard ends when the pointer takes over.\n          if (api.wiring.active() && api.keyboardWire()) api.wiring.cancel()\n          if (!el || target.closest(\"[data-canvas-node], [data-canvas-control], [data-canvas-unwire]\")) return\n          if (e.shiftKey) api.lasso.pointerdown(e, el)\n          else {\n            if (api.selectedNodes().length) api.clearSelection(\"outside-press\", e)\n            api.viewport.pointerdown(e)\n          }\n        },\n        keydown: (event, { api }) => {\n          const e = event as KeyboardEvent\n          if (e.defaultPrevented) return\n          if (matchesShortcut(e, \"mod+shift+z\") || matchesShortcut(e, \"mod+y\")) {\n            e.preventDefault()\n            api.redo()\n            return\n          }\n          if (matchesShortcut(e, \"mod+z\")) {\n            e.preventDefault()\n            api.undo()\n            return\n          }\n          api.viewport.keydown(e)\n        },\n      },\n    }),\n    // A dot grid that pans and scales with the world, drawn without rendering anything.\n    grid: slot({\n      attrs: () => ({ \"aria-hidden\": \"true\" }),\n      live: live((state) => {\n        const { x, y, zoom } = state.viewport\n        const size = 24 * zoom\n        return { style: `background-size:${size}px ${size}px;background-position:${x}px ${y}px` }\n      }),\n    }),\n    // The zoom is also a variable, so rings and edges can keep their size on screen.\n    world: slot({\n      attrs: () => ({ style: css({ position: \"absolute\", left: \"0\", top: \"0\", \"transform-origin\": \"0 0\" }) }),\n      live: live((state, { api }) => ({ style: `${api.viewport.style(state)};--canvas-zoom:${state.viewport.zoom}` })),\n    }),\n    // The zoom readout updates live, so zooming renders no React at all.\n    zoom: slot({\n      attrs: () => ({ \"data-canvas-zoom\": \"\" }),\n      live: live((state) => {\n        const percent = Math.round(state.viewport.zoom * 100)\n        return { \"data-zoom\": `${percent}%`, \"aria-label\": `Zoom ${percent}%, reset to 100%` }\n      }),\n    }),\n    nodes: slot({\n      role: \"listbox\",\n      keys: { none: \"Nodes handle their own keys; the canvas is one tab stop.\" },\n      attrs: () => ({ \"aria-multiselectable\": \"true\" }),\n    }),\n    node: slot<{ value: string }>({\n      props: { value: \"string\" },\n      role: \"option\",\n      focus: \"roving\",\n      keys: [\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\", \"Home\", \"End\", \" \", \"Enter\", \"Escape\", \"Delete\", \"Backspace\", \"c\"],\n      // A press chooses the node on pointerdown, before a drag can start; keys are below.\n      press: () => {},\n      // Focus and selection reach only the nodes they touch; a move, every node.\n      selects: selects({ focused: ({ key }) => [key, null], selected: ({ key }) => [key], edges: () => [] }),\n      attrs: (state, part) => {\n        const at = state.positions[part.key]\n        return {\n          tabindex: part.api.roving.tabIndex(state, part),\n          \"aria-roledescription\": \"node\",\n          \"aria-selected\": String(state.selected.includes(part.key)),\n          \"data-canvas-node\": \"\",\n          style: css({ position: \"absolute\", left: `${at?.x ?? 0}px`, top: `${at?.y ?? 0}px`, \"touch-action\": \"none\" }),\n        }\n      },\n      live: live((state, { api, key }) => ({\n        style: api.move.style(state, key),\n        \"data-dragging\": api.move.dragging(state, key) ? \"\" : undefined,\n        \"data-lassoed\": api.lasso.touches(state, key) ? \"\" : undefined,\n        \"data-wiring\": state.connecting?.from.startsWith(`${key}:`) ? \"\" : undefined,\n      })),\n      on: {\n        keydown: (event, { api, key, el }) => {\n          const e = event as KeyboardEvent\n          // A wire under way takes the keys: arrows choose an input, Enter joins, Escape stops.\n          if (api.wiring.active()) {\n            if (e.code === \"KeyC\" && !e.altKey && !e.ctrlKey && !e.metaKey && !e.shiftKey) {\n              e.preventDefault()\n              api.startWire(key)\n              return\n            }\n            // The behavior takes arrows, Enter and Escape, and cancels on Tab without\n            // stopping it, so focus moves on.\n            api.wiring.keydown(e)\n            return\n          }\n          if (matchesShortcut(e, \"mod+a\")) {\n            e.preventDefault()\n            api.selection.toggleAll({ reason: \"list-navigation\", event: e })\n            return\n          }\n          if (api.move.keydown(e, key)) {\n            e.preventDefault()\n            return\n          }\n          const plain = !e.altKey && !e.ctrlKey && !e.metaKey\n          // By the key's place, so C works on any keyboard layout.\n          if (plain && e.code === \"KeyC\" && !e.shiftKey) {\n            e.preventDefault()\n            api.startWire(key)\n            return\n          }\n          if (plain && e.key === \" \") {\n            e.preventDefault()\n            api.selection.toggle(key, { reason: \"item-press\", event: e })\n            return\n          }\n          if (plain && e.key === \"Enter\") {\n            e.preventDefault()\n            api.open(key)\n            return\n          }\n          if (plain && (e.key === \"Delete\" || e.key === \"Backspace\")) {\n            e.preventDefault()\n            const selected = api.selectedNodes()\n            api.remove(selected.includes(key) ? selected : [key])\n            return\n          }\n          if (plain && e.key === \"Escape\" && api.selectedNodes().length) {\n            e.preventDefault()\n            api.clearSelection(\"escape-key\", e)\n            return\n          }\n          if (el && !e.altKey) api.roving.keydown(e, el)\n        },\n        pointerdown: (event, { api, key, el }) => {\n          const e = event as PointerEvent\n          if ((e.target as Element).closest(\"[data-canvas-port]\")) return\n          // Choose on press, so a drag moves what's chosen; keep a selection the node is in.\n          if (e.shiftKey || e.metaKey || e.ctrlKey) api.selection.toggle(key, { reason: \"item-press\", event: e })\n          else if (!api.selection.isSelected(key)) api.selection.choose(key, { reason: \"item-press\", event: e })\n          if (el) api.move.pointerdown(e, key, el)\n        },\n        dblclick: (_event, { api, key }) => api.open(key),\n        // Keyboard focus brings a node into view; a press leaves the view where it is, so a\n        // drag starts under the pointer.\n        focus: (_event, { el, api }) => {\n          if (el && isFocusFromKeyboard()) api.viewport.reveal(api.viewport.rectOf(el), { padding: 32 }, { reason: \"focus-in\" })\n        },\n        // A keyboard wire belongs to the node it started on.\n        blur: (event, { api, key, el }) => {\n          const next = (event as FocusEvent).relatedTarget as Node | null\n          if (api.wiring.active() && api.keyboardWire()?.startsWith(`${key}:`) && !(next && el?.contains(next)))\n            api.wiring.cancel()\n        },\n      },\n      bind: (el, part) => {\n        const cleanups = [part.api.roving.bind(el, part), part.api.recovery.bind(el, part)]\n        return () => cleanups.forEach((cleanup) => cleanup())\n      },\n    }),\n    // Ports are pointer targets; keyboard wiring goes through the node (C, arrows, Enter).\n    port: slot<{ value: string }>({\n      props: { value: \"string\" },\n      selects: selects({ selected: () => [], focused: () => [] }),\n      attrs: (_state, { key }) => ({ \"aria-hidden\": \"true\", \"data-canvas-port\": parsePort(key).side }),\n      live: live((state, { api, key }) => ({ \"data-connect\": api.wiring.role(state, key) })),\n      on: {\n        pointerdown: (event, { el, api, key }) => {\n          if (el && parsePort(key).side === \"out\") {\n            event.stopPropagation()\n            api.wiring.pointerdown(event as PointerEvent, key, el)\n          }\n        },\n      },\n    }),\n    wire: slot<{ value: string }>({\n      props: { value: \"string\" },\n      selects: selects({ selected: () => [], focused: () => [] }),\n      live: live((state, { api, key }) => ({ d: api.wire(state, key) })),\n    }),\n    unwire: slot<{ value: string }>({\n      props: { value: \"string\" },\n      selects: selects({ selected: () => [], focused: () => [] }),\n      attrs: () => ({ \"data-canvas-unwire\": \"\" }),\n      live: live((state, { api, key }) => {\n        const at = api.wireMiddle(state, key)\n        return { transform: at ? `translate(${at.x} ${at.y})` : \"translate(-9999 -9999)\" }\n      }),\n      on: {\n        pointerdown: (event) => event.stopPropagation(),\n        click: (_event, { api, key }) => api.disconnect(key),\n      },\n    }),\n    draft: slot({\n      live: live((state, { api }) => ({ d: api.draftWire(state) })),\n    }),\n    lasso: slot({\n      attrs: () => ({ \"aria-hidden\": \"true\" }),\n      live: live((state, { api }) => ({ style: api.lasso.style(state) })),\n    }),\n    // The minimap follows pans and zooms live: its frame and the box that is in view.\n    minimap: slot({\n      live: live((state, { api }) => {\n        void state.viewport\n        return { viewBox: api.overview() }\n      }),\n    }),\n    viewbox: slot({\n      live: live((state, { api }) => {\n        void state.viewport\n        const view = api.view()\n        return {\n          x: String(view.left),\n          y: String(view.top),\n          width: String(Math.max(0, view.right - view.left)),\n          height: String(Math.max(0, view.bottom - view.top)),\n        }\n      }),\n    }),\n  }),\n  agent: {\n    actions: [\"addNode\", \"moveNode\", \"connect\", \"disconnect\", \"select\", \"openNode\", \"fitView\"],\n    items: (api) => api.items(),\n  },\n})\n\nexport { canvasPrimitive, createCanvasController, edgeId }\nexport type { CanvasController, CanvasControllerApi, CanvasEdge, CanvasNodeKind, CanvasOptions, CanvasPositions }\n",
      "type": "registry:file",
      "target": "@ui/canvas/canvas.ts"
    },
    {
      "path": "registry/uiset/ui/canvas/geometry.ts",
      "content": "// Where things sit on a canvas, in canvas units (CSS pixels at 100%). Nodes have a header,\n// then one row per port: input i on the left edge and output i on the right of row i, so\n// wires attach without measuring the page. canvas.css draws the same sizes.\n\ntype CanvasPort = { id: string; label: string }\n\ntype CanvasNodeShape = {\n  id: string\n  title: string\n  inputs?: CanvasPort[]\n  outputs?: CanvasPort[]\n  /** Canvas units. Defaults to `NODE_WIDTH`. */\n  width?: number\n}\n\ntype Point = { x: number; y: number }\ntype Rect = { left: number; top: number; right: number; bottom: number }\n\nconst NODE_WIDTH = 208\nconst HEADER = 36\nconst ROW = 28\nconst FOOT = 8\n\n/** A port's key: node, side and port, like \"model:out:text\". */\nconst portKey = (node: string, side: \"in\" | \"out\", port: string) => `${node}:${side}:${port}`\n\n/** Splits a port key. Node and port ids may not hold \":\" themselves. */\nfunction parsePort(key: string) {\n  const [node = \"\", side = \"\", port = \"\"] = key.split(\":\")\n  return { node, side: side as \"in\" | \"out\", port }\n}\n\nfunction nodeHeight(node: CanvasNodeShape) {\n  const rows = Math.max(node.inputs?.length ?? 0, node.outputs?.length ?? 0)\n  return HEADER + rows * ROW + FOOT\n}\n\nfunction nodeRect(node: CanvasNodeShape, at: Point): Rect {\n  return { left: at.x, top: at.y, right: at.x + (node.width ?? NODE_WIDTH), bottom: at.y + nodeHeight(node) }\n}\n\n/** Where a port's dot sits, or undefined if the node has no such port. */\nfunction portPoint(node: CanvasNodeShape, at: Point, side: \"in\" | \"out\", port: string): Point | undefined {\n  const list = side === \"in\" ? node.inputs : node.outputs\n  const index = list?.findIndex((p) => p.id === port) ?? -1\n  if (index < 0) return undefined\n  return {\n    x: side === \"in\" ? at.x : at.x + (node.width ?? NODE_WIDTH),\n    y: at.y + HEADER + ROW * (index + 0.5),\n  }\n}\n\n/** A wire from an output to an input: a curve that leaves rightward and arrives from the left. */\nfunction wirePath(from: Point, to: Point) {\n  const reach = Math.max(40, Math.abs(to.x - from.x) / 2)\n  const r = (n: number) => Math.round(n * 10) / 10\n  return `M ${r(from.x)} ${r(from.y)} C ${r(from.x + reach)} ${r(from.y)}, ${r(to.x - reach)} ${r(to.y)}, ${r(to.x)} ${r(to.y)}`\n}\n\n/** The point halfway along a wire, for its remove button. */\nfunction wireMiddle(from: Point, to: Point): Point {\n  const reach = Math.max(40, Math.abs(to.x - from.x) / 2)\n  // A cubic Bézier at t = 0.5.\n  return {\n    x: (from.x + 3 * (from.x + reach) + 3 * (to.x - reach) + to.x) / 8,\n    y: (from.y + 3 * from.y + 3 * to.y + to.y) / 8,\n  }\n}\n\n/** The box holding every rect, or null for none. */\nfunction boundsOf(rects: Rect[]): Rect | null {\n  if (!rects.length) return null\n  return rects.reduce((all, r) => ({\n    left: Math.min(all.left, r.left),\n    top: Math.min(all.top, r.top),\n    right: Math.max(all.right, r.right),\n    bottom: Math.max(all.bottom, r.bottom),\n  }))\n}\n\n/** What a node is wired to, in words: its description for screen readers (React and web). */\nfunction describeWires(node: CanvasNodeShape, nodes: readonly CanvasNodeShape[], edges: readonly { from: string; to: string }[]) {\n  const name = (key: string) => {\n    const { node: id, side, port } = parsePort(key)\n    const other = nodes.find((n) => n.id === id)\n    const list = side === \"in\" ? other?.inputs : other?.outputs\n    return { node: other?.title ?? id, port: list?.find((p) => p.id === port)?.label ?? port }\n  }\n  const into = edges\n    .filter((e) => parsePort(e.to).node === node.id)\n    .map((e) => `${name(e.to).port} from ${name(e.from).node} ${name(e.from).port}`)\n  const out = edges\n    .filter((e) => parsePort(e.from).node === node.id)\n    .map((e) => `${name(e.from).port} to ${name(e.to).node} ${name(e.to).port}`)\n  return [into.length && `Inputs: ${into.join(\"; \")}.`, out.length && `Outputs: ${out.join(\"; \")}.`]\n    .filter(Boolean)\n    .join(\" \")\n}\n\nexport { boundsOf, describeWires, FOOT, HEADER, NODE_WIDTH, nodeHeight, nodeRect, parsePort, portKey, portPoint, ROW, wireMiddle, wirePath }\nexport type { CanvasNodeShape, CanvasPort, Point, Rect }\n",
      "type": "registry:file",
      "target": "@ui/canvas/geometry.ts"
    },
    {
      "path": "registry/uiset/ui/canvas/canvas.css",
      "content": "@layer ui-sdk, uiset.tokens, uiset.base, uiset.skin;\n\n/*\n * A node editor. Sizes inside nodes are in px on purpose: they are canvas units, scaled by\n * the zoom, and geometry.ts places wires on them (header 36, rows 28, foot 8).\n */\n@layer uiset.base {\n  .canvas {\n    --canvas-surface: color-mix(in oklch, var(--ui-muted) 45%, var(--ui-background));\n    --canvas-dot: color-mix(in oklch, var(--ui-foreground) 22%, transparent);\n    /* Node and wire edges mix halfway to the text color, so they clear 3:1 on the surface. */\n    --canvas-edge: color-mix(in oklch, var(--ui-foreground) 50%, var(--ui-background));\n    --canvas-wire: color-mix(in oklch, var(--ui-foreground) 55%, var(--canvas-surface));\n    /* The accent, pulled toward the text color so it clears 3:1 on the surface in every skin. */\n    --canvas-accent: color-mix(in oklch, var(--ui-primary) 70%, var(--ui-foreground));\n    block-size: var(--canvas-height, 32rem);\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 6px);\n    background: var(--canvas-surface);\n    color: var(--ui-foreground);\n    outline: none;\n\n    &:focus-visible {\n      outline: 2px solid var(--ui-ring-border);\n      outline-offset: 2px;\n    }\n  }\n\n  .canvas-grid {\n    position: absolute;\n    inset: 0;\n    background-image: radial-gradient(circle, var(--canvas-dot) 1px, transparent 1.4px);\n    pointer-events: none;\n  }\n\n  /* Physical: wires run left to right in every language, like the ports. */\n  .canvas-wires {\n    position: absolute;\n    top: 0;\n    left: 0;\n    overflow: visible;\n    pointer-events: none;\n  }\n\n  .canvas-wire {\n    fill: none;\n    stroke: var(--canvas-wire);\n    stroke-width: 2;\n    stroke-linecap: round;\n\n    &[data-draft] {\n      stroke: var(--canvas-accent);\n      stroke-dasharray: 6 5;\n    }\n  }\n\n  .canvas-unwire {\n    cursor: pointer;\n    pointer-events: auto;\n    transition: opacity var(--uiset-fast, 0.12s) ease;\n\n    /* Out of the way until the canvas is in use; focus shows them for the keyboard (B26). */\n    .canvas:not(:hover, :focus-within) & {\n      opacity: 0;\n    }\n\n    circle {\n      fill: var(--ui-background);\n      stroke: var(--canvas-edge);\n      stroke-width: 1;\n    }\n\n    path {\n      fill: none;\n      stroke: var(--ui-muted-foreground);\n      stroke-width: 1.5;\n      stroke-linecap: round;\n    }\n\n    &:hover circle {\n      fill: color-mix(in oklch, var(--tone-danger) 14%, var(--ui-background));\n      stroke: var(--tone-danger);\n    }\n\n    &:hover path {\n      stroke: var(--tone-danger);\n    }\n  }\n\n  .canvas-nodes {\n    display: contents;\n  }\n\n  .canvas-node {\n    display: block;\n    border-radius: 10px;\n    outline: none;\n    cursor: grab;\n\n    &[data-dragging] {\n      z-index: 2;\n      cursor: grabbing;\n    }\n\n    &[data-locked] {\n      cursor: default;\n    }\n  }\n\n  .canvas-node-card {\n    display: grid;\n    box-sizing: border-box;\n    overflow: visible;\n    border: 1px solid var(--canvas-edge);\n    border-radius: 10px;\n    background: var(--ui-background);\n    box-shadow: 0 1px 2px color-mix(in oklch, var(--ui-foreground) 10%, transparent);\n    font-size: 12px;\n    line-height: 16px;\n\n    /* Selection: an accent edge that keeps its width on screen at any zoom. */\n    .canvas-node[aria-selected=\"true\"] & {\n      border-color: var(--canvas-accent);\n      box-shadow:\n        0 0 0 calc(1.5px / var(--canvas-zoom, 1)) var(--canvas-accent),\n        0 4px 12px color-mix(in oklch, var(--ui-foreground) 12%, transparent);\n    }\n\n    .canvas-node[data-lassoed] & {\n      border-style: dashed;\n      border-color: var(--canvas-accent);\n    }\n\n    .canvas-node[data-dragging] & {\n      box-shadow: var(--ui-shadow);\n    }\n  }\n\n  .canvas-node-header {\n    display: flex;\n    align-items: baseline;\n    gap: 6px;\n    box-sizing: border-box;\n    block-size: 35px;\n    padding: 9px 10px 0;\n    overflow: hidden;\n    border-block-end: 1px solid var(--ui-border);\n    border-start-start-radius: 9px;\n    border-start-end-radius: 9px;\n    background: linear-gradient(to right, var(--series) 0 3px, transparent 3px);\n    white-space: nowrap;\n  }\n\n  .canvas-node-kind {\n    flex: none;\n    margin-inline-start: auto;\n    color: var(--ui-muted-foreground);\n    font-size: 11px;\n    font-weight: 500;\n  }\n\n  .canvas-node-title {\n    min-inline-size: 0;\n    overflow: hidden;\n    font-size: 13px;\n    font-weight: 600;\n    text-overflow: ellipsis;\n  }\n\n  /* The focus ring keeps its width on screen at any zoom. */\n  [data-uiset] .canvas .canvas-node:focus-visible {\n    outline-width: calc(2px / var(--canvas-zoom, 1));\n    outline-offset: calc(3px / var(--canvas-zoom, 1));\n  }\n\n  .canvas-node-row {\n    direction: ltr;\n    display: grid;\n    grid-template-columns: 1fr 1fr;\n    align-items: center;\n    block-size: 28px;\n    padding-inline: 12px;\n    color: var(--ui-muted-foreground);\n  }\n\n  .canvas-node-in,\n  .canvas-node-out {\n    position: relative;\n    min-inline-size: 0;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n\n  /* The cells let their port dots hang outside; their labels truncate inside. */\n  .canvas-node-in {\n    overflow: visible;\n  }\n\n  .canvas-node-out {\n    overflow: visible;\n    text-align: end;\n  }\n\n  .canvas-port-label {\n    display: block;\n    overflow: hidden;\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n\n  /* A port sits on the card's edge, centered on its row. */\n  .canvas-port {\n    position: absolute;\n    inset-block-start: 50%;\n    inline-size: 12px;\n    block-size: 12px;\n    box-sizing: border-box;\n    border: 2px solid var(--canvas-edge);\n    border-radius: 50%;\n    background: var(--ui-background);\n    translate: 0 -50%;\n    cursor: crosshair;\n\n    /* A bigger target than the dot. */\n    &::before {\n      content: \"\";\n      position: absolute;\n      inset: -8px;\n      border-radius: 50%;\n    }\n\n    /* Physical sides: wires run left to right in every language, like geometry.ts. */\n    &[data-canvas-port=\"in\"] {\n      left: -19px;\n    }\n\n    &[data-canvas-port=\"out\"] {\n      right: -19px;\n    }\n\n    &[data-connect=\"source\"],\n    &[data-connect=\"target\"] {\n      border-color: var(--canvas-accent);\n      background: var(--canvas-accent);\n    }\n\n    &[data-connect=\"candidate\"] {\n      border-color: var(--canvas-accent);\n      border-style: dashed;\n    }\n\n    &[data-connect=\"target\"] {\n      box-shadow: 0 0 0 4px color-mix(in oklch, var(--canvas-accent) 30%, transparent);\n    }\n  }\n\n  .canvas-node-foot {\n    block-size: 7px;\n  }\n\n  .canvas-node-body {\n    display: block;\n    padding: 8px 10px 10px;\n    border-block-start: 1px solid var(--ui-border);\n    color: var(--ui-muted-foreground);\n    overflow-wrap: anywhere;\n  }\n\n  .canvas-lasso {\n    position: absolute;\n    border: 1px dashed var(--canvas-accent);\n    background: color-mix(in oklch, var(--ui-primary) 8%, transparent);\n    pointer-events: none;\n  }\n\n  .canvas-controls {\n    position: absolute;\n    inset-block-end: 12px;\n    inset-inline-start: 12px;\n    display: flex;\n    align-items: center;\n    gap: 2px;\n    padding: 3px;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 4px);\n    background: var(--ui-background);\n    box-shadow: 0 1px 2px color-mix(in oklch, var(--ui-foreground) 10%, transparent);\n\n    [data-slot=\"button\"] {\n      min-inline-size: 2rem;\n      block-size: 2rem;\n      padding-inline: 0.375rem;\n    }\n  }\n\n  /* The readout is drawn from live state; its name says the same in words. */\n  .canvas-zoom {\n    display: inline-grid;\n    place-items: center;\n    min-inline-size: 3.25rem;\n    block-size: 2rem;\n    padding: 0;\n    border: 0;\n    border-radius: var(--ui-radius);\n    background: transparent;\n    color: var(--ui-foreground);\n    font: inherit;\n    font-size: 0.8125rem;\n    font-variant-numeric: tabular-nums;\n    cursor: pointer;\n\n    /* ::before, since on touch screens UI SDK turns a button's ::after into its hit area. */\n    &::before {\n      content: attr(data-zoom);\n    }\n\n    &:hover {\n      background: var(--ui-muted);\n    }\n  }\n\n  .canvas-minimap {\n    position: absolute;\n    inset-block-end: 12px;\n    inset-inline-end: 12px;\n    inline-size: 168px;\n    block-size: 112px;\n    overflow: hidden;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 4px);\n    background: var(--ui-background);\n    cursor: pointer;\n\n    svg {\n      display: block;\n      inline-size: 100%;\n      block-size: 100%;\n    }\n\n    @media (max-width: 40rem) {\n      display: none;\n    }\n  }\n\n  .canvas-minimap-node {\n    fill: color-mix(in oklch, var(--series) 75%, var(--ui-foreground));\n  }\n\n  .canvas-minimap-view {\n    fill: color-mix(in oklch, var(--ui-primary) 10%, transparent);\n    stroke: var(--ui-primary);\n    stroke-width: 2;\n    vector-effect: non-scaling-stroke;\n  }\n\n  .canvas-toolbar {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 0.375rem;\n  }\n\n  /* The web inspector groups its fields and wires; the groups join this grid's spacing. */\n  :is(.canvas-inspector-fields, .canvas-inspector-wire-list) {\n    display: contents;\n  }\n\n  .canvas-inspector {\n    display: grid;\n    align-content: start;\n    gap: 0.75rem;\n    font-size: var(--ui-font-size);\n    padding: 1rem;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 6px);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n  }\n\n  .canvas-inspector-title {\n    margin: 0;\n    font-size: 1rem;\n    font-weight: 650;\n    overflow-wrap: anywhere;\n  }\n\n  .canvas-inspector-heading {\n    margin: 0.25rem 0 0;\n    color: var(--ui-muted-foreground);\n    font-size: 0.8125rem;\n    font-weight: 600;\n  }\n\n  .canvas-inspector-form {\n    display: grid;\n    grid-template-columns: 1fr auto;\n    align-items: end;\n    gap: 0.5rem;\n  }\n\n  .canvas-inspector-wires {\n    display: grid;\n    gap: 0.25rem;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n\n    li {\n      display: flex;\n      flex-wrap: wrap;\n      align-items: center;\n      justify-content: space-between;\n      gap: 0.25rem 0.5rem;\n      font-size: 0.875rem;\n    }\n  }\n\n  .canvas-inspector-empty {\n    margin: 0;\n    color: var(--ui-muted-foreground);\n    font-size: 0.875rem;\n  }\n\n  @media (forced-colors: active) {\n    .canvas-wire {\n      stroke: CanvasText;\n    }\n\n    .canvas-wire[data-draft],\n    .canvas-node[aria-selected=\"true\"] .canvas-node-card {\n      border-color: Highlight;\n      stroke: Highlight;\n    }\n\n    .canvas-port {\n      border-color: CanvasText;\n    }\n\n    .canvas-port[data-connect=\"source\"],\n    .canvas-port[data-connect=\"target\"] {\n      background: Highlight;\n    }\n\n    .canvas-port[data-connect=\"candidate\"] {\n      border-color: Highlight;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/canvas/canvas.css"
    },
    {
      "path": "registry/uiset/ui/chart/tokens.css",
      "content": "@layer ui-sdk, uiset.tokens, uiset.base, uiset.skin;\n\n/*\n  Chart colors, validated per surface with the dataviz six-checks script (docs/charts.md):\n  categorical slots in a fixed order (never cycled, never by rank), one-hue sequential\n  steps, a diverging pair with a gray midpoint, and quiet chrome. Text never uses these;\n  it stays in --ui-foreground and --ui-muted-foreground.\n*/\n\n@layer uiset.tokens {\n  :where([data-uiset]) {\n    --chart-1: light-dark(oklch(0.575 0.163 255.5), oklch(0.622 0.161 255.1));\n    --chart-2: light-dark(oklch(0.671 0.175 40.6), oklch(0.622 0.173 40.1));\n    --chart-3: light-dark(oklch(0.669 0.141 162.1), oklch(0.621 0.128 163.1));\n    --chart-4: light-dark(oklch(0.764 0.161 75.1), oklch(0.67 0.143 73.2));\n    --chart-5: light-dark(oklch(0.716 0.141 357.4), oklch(0.622 0.171 0.8));\n    --chart-6: light-dark(oklch(0.529 0.18 142.5), oklch(0.529 0.18 142.5));\n    --chart-7: light-dark(oklch(0.527 0.197 283.4), oklch(0.67 0.145 286.8));\n    --chart-8: light-dark(oklch(0.623 0.191 24.9), oklch(0.669 0.159 22.3));\n    /* \"Other\" and de-emphasized series: a gray that never reads as a slot. */\n    --chart-other: color-mix(in oklch, var(--ui-muted-foreground) 70%, var(--ui-background));\n\n    /* Sequential, one hue: step 1 is \"little\", step 7 is \"most\". Dark mode runs the same\n       ramp from the surface up, so \"most\" is always the loudest. */\n    --chart-seq-1: light-dark(oklch(0.905 0.041 252.8), oklch(0.338 0.103 256.9));\n    --chart-seq-2: light-dark(oklch(0.812 0.079 253.4), oklch(0.433 0.128 256.5));\n    --chart-seq-3: light-dark(oklch(0.717 0.118 253.6), oklch(0.527 0.15 255.9));\n    --chart-seq-4: light-dark(oklch(0.622 0.161 255.1), oklch(0.622 0.161 255.1));\n    --chart-seq-5: light-dark(oklch(0.527 0.15 255.9), oklch(0.717 0.118 253.6));\n    --chart-seq-6: light-dark(oklch(0.433 0.128 256.5), oklch(0.812 0.079 253.4));\n    --chart-seq-7: light-dark(oklch(0.338 0.103 256.9), oklch(0.905 0.041 252.8));\n\n    /* Diverging: two poles that read as opposite, a gray middle that reads as nothing. */\n    --chart-neg: var(--chart-8);\n    --chart-mid: light-dark(oklch(0.951 0.004 95), oklch(0.34 0.005 106.7));\n    --chart-pos: var(--chart-1);\n\n    /* Chrome: hairlines one step off the surface, solid, never dashed. */\n    --chart-grid: color-mix(in oklch, var(--ui-foreground) 9%, var(--ui-background));\n    --chart-axis: color-mix(in oklch, var(--ui-foreground) 24%, var(--ui-background));\n    --chart-surface: var(--ui-background);\n    --chart-crosshair: color-mix(in oklch, var(--ui-foreground) 45%, var(--ui-background));\n    --chart-area-opacity: 0.1;\n  }\n}\n\n@layer uiset.skin {\n  /* Blueprint paper is mid blue (L 0.36): its set sits above the usual dark band so every\n     slot keeps 3:1 on the paper. Adjacent pairs: CVD ΔE 14.6, normal 18.7. The first six\n     (a segmented bar's most parts) also clear every pair: CVD 9.3, normal 17.3. */\n  [data-uiset][data-skin=\"blueprint\"] {\n    --chart-1: oklch(0.74 0.11 279.9);\n    --chart-2: oklch(0.86 0.14 159.9);\n    --chart-3: oklch(0.739 0.17 49.8);\n    --chart-4: oklch(0.7 0.2 351);\n    --chart-5: oklch(0.89 0.18 96);\n    --chart-6: oklch(0.89 0.1 327);\n    --chart-7: oklch(0.859 0.14 130.1);\n    --chart-8: oklch(0.789 0.117 242.6);\n    --chart-seq-1: color-mix(in oklab, var(--blueprint-line) 14%, var(--blueprint-paper));\n    --chart-seq-2: color-mix(in oklab, var(--blueprint-line) 28%, var(--blueprint-paper));\n    --chart-seq-3: color-mix(in oklab, var(--blueprint-line) 42%, var(--blueprint-paper));\n    --chart-seq-4: color-mix(in oklab, var(--blueprint-line) 56%, var(--blueprint-paper));\n    --chart-seq-5: color-mix(in oklab, var(--blueprint-line) 70%, var(--blueprint-paper));\n    --chart-seq-6: color-mix(in oklab, var(--blueprint-line) 85%, var(--blueprint-paper));\n    --chart-seq-7: var(--blueprint-line);\n    --chart-neg: var(--chart-3);\n    --chart-pos: var(--chart-2);\n    --chart-mid: color-mix(in oklab, var(--blueprint-line) 20%, var(--blueprint-paper));\n    --chart-grid: var(--blueprint-faint);\n    --chart-axis: color-mix(in oklab, var(--blueprint-line) 55%, var(--blueprint-paper));\n    --chart-crosshair: var(--blueprint-line);\n    --chart-area-opacity: 0.16;\n  }\n\n  /* Studio keeps the validated dark set and lights its sequential ramp like a lamp.\n     Ramps mix in OKLab: OKLCH would swing the hue from amber through pink to the panel. */\n  [data-uiset][data-skin=\"studio\"] {\n    --chart-seq-1: color-mix(in oklab, var(--studio-lamp) 14%, var(--studio-panel));\n    --chart-seq-2: color-mix(in oklab, var(--studio-lamp) 28%, var(--studio-panel));\n    --chart-seq-3: color-mix(in oklab, var(--studio-lamp) 42%, var(--studio-panel));\n    --chart-seq-4: color-mix(in oklab, var(--studio-lamp) 56%, var(--studio-panel));\n    --chart-seq-5: color-mix(in oklab, var(--studio-lamp) 70%, var(--studio-panel));\n    --chart-seq-6: color-mix(in oklab, var(--studio-lamp) 85%, var(--studio-panel));\n    --chart-seq-7: var(--studio-lamp);\n    --chart-crosshair: var(--studio-lamp);\n  }\n  /* Phosphor: the tube's own green first, then the other phosphors (blue, P3 amber, P22\n     red, P4 white, lavender, cyan, pink), each 3:1 or more on the tube. Adjacent pairs:\n     CVD ΔE ≥ 9.5, normal ≥ 17; the first six clear every pair (CVD 9.4, normal 19.6). */\n  [data-uiset][data-skin=\"phosphor\"] {\n    --chart-1: oklch(0.88 0.17 148);\n    --chart-2: oklch(0.72 0.2 250);\n    --chart-3: oklch(0.84 0.17 75);\n    --chart-4: oklch(0.68 0.17 28);\n    --chart-5: oklch(0.96 0.02 150);\n    --chart-6: oklch(0.84 0.11 300);\n    --chart-7: oklch(0.92 0.11 195);\n    --chart-8: oklch(0.76 0.14 355);\n    --chart-seq-1: color-mix(in oklab, var(--phosphor-glow) 14%, var(--phosphor-tube));\n    --chart-seq-2: color-mix(in oklab, var(--phosphor-glow) 28%, var(--phosphor-tube));\n    --chart-seq-3: color-mix(in oklab, var(--phosphor-glow) 42%, var(--phosphor-tube));\n    --chart-seq-4: color-mix(in oklab, var(--phosphor-glow) 56%, var(--phosphor-tube));\n    --chart-seq-5: color-mix(in oklab, var(--phosphor-glow) 70%, var(--phosphor-tube));\n    --chart-seq-6: color-mix(in oklab, var(--phosphor-glow) 85%, var(--phosphor-tube));\n    --chart-seq-7: var(--phosphor-glow);\n    --chart-neg: var(--chart-4);\n    --chart-pos: var(--chart-2);\n    --chart-mid: color-mix(in oklab, var(--phosphor-dim) 30%, var(--phosphor-tube));\n    --chart-grid: oklch(0.75 0.11 150 / 0.2);\n    --chart-axis: color-mix(in oklab, var(--phosphor-dim) 70%, var(--phosphor-tube));\n    --chart-crosshair: var(--phosphor-glow);\n    --chart-area-opacity: 0.14;\n  }\n\n  /* Ink: data is the one place with color, a muted print-like set, like color e-paper:\n     ink first, then blue, orange, sage, dark red, purple, teal, mustard, each 3:1 or more\n     on the screen. Adjacent pairs: CVD ΔE ≥ 9.8, normal ≥ 16; the first six clear every\n     pair (CVD 9.8, normal 16.5). Sequential steps are ink on the screen. */\n  [data-uiset][data-skin=\"ink\"] {\n    --chart-1: oklch(0.2 0 0);\n    --chart-2: oklch(0.5 0.12 250);\n    --chart-3: oklch(0.58 0.15 55);\n    --chart-4: oklch(0.58 0.06 150);\n    --chart-5: oklch(0.42 0.15 25);\n    --chart-6: oklch(0.38 0.15 300);\n    --chart-7: oklch(0.58 0.09 195);\n    --chart-8: oklch(0.58 0.12 95);\n    --chart-seq-1: color-mix(in oklab, var(--ink-ink) 14%, var(--ink-screen));\n    --chart-seq-2: color-mix(in oklab, var(--ink-ink) 28%, var(--ink-screen));\n    --chart-seq-3: color-mix(in oklab, var(--ink-ink) 42%, var(--ink-screen));\n    --chart-seq-4: color-mix(in oklab, var(--ink-ink) 56%, var(--ink-screen));\n    --chart-seq-5: color-mix(in oklab, var(--ink-ink) 70%, var(--ink-screen));\n    --chart-seq-6: color-mix(in oklab, var(--ink-ink) 85%, var(--ink-screen));\n    --chart-seq-7: var(--ink-ink);\n    --chart-neg: var(--chart-5);\n    --chart-pos: var(--chart-2);\n    --chart-mid: var(--ink-tint);\n    --chart-grid: oklch(0.82 0 0);\n    --chart-axis: oklch(0.55 0 0);\n    --chart-crosshair: var(--ink-ink);\n    --chart-area-opacity: 0.12;\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/chart/tokens.css"
    },
    {
      "path": "registry/uiset/ui/shell/shell.css",
      "content": "@layer ui-sdk, uiset.tokens, uiset.base, uiset.skin;\n\n@layer uiset.base {\n  :where([data-uiset]) {\n    /* Status colors: text and edges hold 4.5:1 / 3:1 on --ui-background in each scheme. */\n    /* Dark values also clear 4.5:1 on the mid-dark Blueprint and Studio panels. */\n    --tone-info: light-dark(oklch(0.48 0.15 255), oklch(0.86 0.08 240));\n    --tone-success: light-dark(oklch(0.47 0.12 150), oklch(0.87 0.11 150));\n    --tone-warning: light-dark(oklch(0.5 0.12 70), oklch(0.89 0.11 85));\n    --tone-danger: light-dark(oklch(0.46 0.19 27), oklch(0.86 0.08 25));\n    --tone-neutral: var(--ui-muted-foreground);\n  }\n\n  .uiset-visually-hidden {\n    position: absolute;\n    width: 1px;\n    height: 1px;\n    overflow: hidden;\n    clip-path: inset(50%);\n    white-space: nowrap;\n  }\n\n  .uiset-icon {\n    width: 1rem;\n    height: 1rem;\n    flex-shrink: 0;\n    fill: none;\n    stroke: currentColor;\n    stroke-width: 1.75;\n    stroke-linecap: round;\n    stroke-linejoin: round;\n  }\n\n  /* App shell */\n\n  .app-shell {\n    --sidebar-width: 15rem;\n    display: grid;\n    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);\n    min-height: var(--app-shell-height, 100dvh);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n\n    &[data-narrow] {\n      grid-template-columns: minmax(0, 1fr);\n    }\n  }\n\n  [data-sidebar=\"collapsed\"] .app-shell:not([data-narrow]) {\n    --sidebar-width: 3.75rem;\n  }\n\n  .app-sidebar,\n  .app-drawer {\n    display: flex;\n    flex-direction: column;\n    gap: 0.75rem;\n    min-width: 0;\n    padding: 0.75rem;\n    border-inline-end: 1px solid var(--ui-border);\n    background: color-mix(in oklab, var(--ui-muted) 55%, var(--ui-background));\n    overflow: hidden;\n  }\n\n  .app-sidebar-top {\n    display: flex;\n    align-items: center;\n    justify-content: space-between;\n    gap: 0.5rem;\n    min-height: 2.25rem;\n  }\n\n  .app-brand {\n    min-width: 0;\n    margin: 0;\n    overflow: hidden;\n    font-weight: 600;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  [data-sidebar=\"collapsed\"] .app-sidebar .app-brand {\n    display: none;\n  }\n\n  .app-sidebar-toggle,\n  .app-menu-button {\n    flex-shrink: 0;\n    width: 2.25rem;\n    height: 2.25rem;\n    padding: 0;\n  }\n\n  .app-main {\n    display: flex;\n    flex-direction: column;\n    min-width: 0;\n  }\n\n  /* Its padding counts in its height, with or without a page's box-sizing reset. */\n  .app-header {\n    box-sizing: border-box;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 0.75rem;\n    min-height: 3.25rem;\n    padding: 0.5rem 1rem;\n    border-bottom: 1px solid var(--ui-border);\n  }\n\n  /* The padding is a variable, so a full-bleed page (an inbox) can cancel it exactly. */\n  .app-content {\n    --app-shell-pad: clamp(1rem, 3vw, 2rem);\n    flex: 1;\n    min-width: 0;\n    padding: var(--app-shell-pad);\n  }\n\n  .sidebar-nav {\n    display: grid;\n    gap: 1rem;\n  }\n\n  .sidebar-group {\n    display: grid;\n    gap: 0.25rem;\n\n    ul {\n      display: grid;\n      gap: 2px;\n      margin: 0;\n      padding: 0;\n      list-style: none;\n    }\n  }\n\n  .sidebar-group-title {\n    margin: 0;\n    padding-inline: 0.5rem;\n    font-size: 0.75rem;\n    font-weight: 600;\n    color: var(--ui-muted-foreground);\n  }\n\n  /* Collapsed to icons: group titles leave the layout (a hidden title used to keep its\n     width and push the icons off center), and a rule separates the groups instead. */\n  [data-sidebar=\"collapsed\"] .app-sidebar {\n    .sidebar-group-title {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      overflow: hidden;\n      clip-path: inset(50%);\n      white-space: nowrap;\n    }\n\n    .sidebar-nav {\n      gap: 0.5rem;\n    }\n\n    .sidebar-group + .sidebar-group {\n      padding-block-start: 0.5rem;\n      border-block-start: 1px solid var(--ui-border);\n    }\n  }\n\n  /* A tooltip trigger, so UI SDK's stylesheet would draw it as a button: reset that. */\n  .sidebar-link {\n    display: flex;\n    align-items: center;\n    justify-content: flex-start;\n    gap: 0.625rem;\n    width: 100%;\n    height: auto;\n    min-height: 2.25rem;\n    padding: 0.375rem 0.5rem;\n    border: 0;\n    border-radius: var(--ui-radius);\n    background: transparent;\n    color: var(--ui-foreground);\n    font-weight: 400;\n    text-decoration: none;\n\n    &:hover {\n      background: var(--ui-muted);\n    }\n\n    &[aria-current=\"page\"] {\n      position: relative;\n      background: var(--ui-muted);\n      font-weight: 600;\n\n      /* A short bar, inset from the corners (an inset shadow bent around them). */\n      &::before {\n        content: \"\";\n        position: absolute;\n        inset-block: 0.5rem;\n        inset-inline-start: 0;\n        inline-size: 3px;\n        border-radius: 999px;\n        background: var(--ui-primary);\n      }\n    }\n\n    &:focus-visible {\n      outline: 2px solid var(--ui-ring-border);\n      outline-offset: -2px;\n    }\n  }\n\n  .sidebar-icon {\n    display: inline-grid;\n    place-items: center;\n    width: 1.25rem;\n    flex-shrink: 0;\n  }\n\n  .sidebar-label {\n    flex: 1;\n    min-width: 0;\n    overflow: hidden;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  .sidebar-badge {\n    font-size: 0.75rem;\n  }\n\n  /* Each link is a square icon button, centered in the rail under the toggle; the current\n     page shows by its fill and an accent icon (a side bar on a square reads as a glitch). */\n  [data-sidebar=\"collapsed\"] .app-sidebar {\n    .sidebar-link {\n      justify-content: center;\n      inline-size: 2.25rem;\n      min-block-size: 2.25rem;\n      margin-inline: auto;\n      padding: 0;\n\n      &[aria-current=\"page\"] {\n        color: color-mix(in oklch, var(--ui-primary) 55%, var(--ui-foreground));\n\n        &::before {\n          display: none;\n        }\n      }\n    }\n\n    .sidebar-label,\n    .sidebar-badge {\n      position: absolute;\n      width: 1px;\n      height: 1px;\n      overflow: hidden;\n      clip-path: inset(50%);\n    }\n  }\n\n  /* The tooltip repeats the visible label, so it only shows when labels are hidden. */\n  [data-sidebar=\"expanded\"] .sidebar-tooltip,\n  .app-drawer .sidebar-tooltip {\n    display: none;\n  }\n\n  /* Page structure */\n\n  .breadcrumbs ol {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: center;\n    gap: 0.25rem;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n    font-size: 0.875rem;\n  }\n\n  .breadcrumbs li {\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    color: var(--ui-muted-foreground);\n\n    a {\n      color: inherit;\n      text-underline-offset: 0.2em;\n    }\n\n    [aria-current=\"page\"] {\n      color: var(--ui-foreground);\n      font-weight: 500;\n    }\n  }\n\n  .breadcrumbs-separator {\n    width: 0.875rem;\n    height: 0.875rem;\n  }\n\n  .page-header {\n    display: grid;\n    gap: 0.75rem;\n    margin-bottom: 1.5rem;\n  }\n\n  .page-header-row {\n    display: flex;\n    flex-wrap: wrap;\n    align-items: flex-end;\n    justify-content: space-between;\n    gap: 1rem;\n  }\n\n  .page-header-title {\n    margin: 0;\n    font-size: clamp(1.5rem, 3vw, 1.875rem);\n    line-height: 1.15;\n    text-wrap: balance;\n  }\n\n  .page-header-description {\n    max-width: 42rem;\n    margin: 0.375rem 0 0;\n    color: var(--ui-muted-foreground);\n  }\n\n  .page-header-actions {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n  }\n\n  .card {\n    display: grid;\n    gap: 1rem;\n    min-width: 0;\n    padding: 1.25rem;\n    border: 1px solid var(--ui-border);\n    border-radius: calc(var(--ui-radius) + 6px);\n    background: var(--ui-background);\n  }\n\n  .card-header {\n    display: grid;\n    gap: 0.25rem;\n  }\n\n  .card-title {\n    margin: 0;\n    font-size: 1rem;\n    font-weight: 600;\n  }\n\n  .card-description {\n    margin: 0;\n    color: var(--ui-muted-foreground);\n    font-size: 0.875rem;\n  }\n\n  .card-footer {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n    padding-top: 1rem;\n    border-top: 1px solid var(--ui-border);\n  }\n\n  /* Data display */\n\n  .badge {\n    --badge-color: var(--tone-neutral);\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    padding: 0.0625rem 0.5rem;\n    border: 1px solid color-mix(in oklab, var(--badge-color) 55%, transparent);\n    border-radius: min(999px, calc(var(--ui-radius) * 999));\n    background: color-mix(in oklab, var(--badge-color) 10%, var(--ui-background));\n    color: var(--badge-color);\n    font-size: 0.75rem;\n    font-weight: 600;\n    line-height: 1.5;\n    white-space: nowrap;\n\n    &[data-tone=\"info\"] {\n      --badge-color: var(--tone-info);\n    }\n\n    &[data-tone=\"success\"] {\n      --badge-color: var(--tone-success);\n    }\n\n    &[data-tone=\"warning\"] {\n      --badge-color: var(--tone-warning);\n    }\n\n    &[data-tone=\"danger\"] {\n      --badge-color: var(--tone-danger);\n    }\n  }\n\n  .count-badge {\n    position: relative;\n    display: inline-flex;\n    vertical-align: middle;\n  }\n\n  /* The solid button's colors: every skin already holds 4.5:1 between them. */\n  .count-badge-count {\n    position: absolute;\n    inset-block-start: 0;\n    inset-inline-end: 0;\n    translate: 40% -40%;\n    display: inline-flex;\n    align-items: center;\n    justify-content: center;\n    box-sizing: border-box;\n    min-width: 1.125rem;\n    height: 1.125rem;\n    padding-inline: 0.3125rem;\n    border-radius: min(999px, calc(var(--ui-radius) * 999));\n    background: var(--uiset-solid-bg);\n    color: var(--uiset-solid-fg);\n    box-shadow: 0 0 0 2px var(--ui-background);\n    font-size: 0.6875rem;\n    font-weight: 600;\n    font-variant-numeric: tabular-nums;\n    line-height: 1;\n    white-space: nowrap;\n    pointer-events: none;\n\n    &:dir(rtl) {\n      translate: -40% -40%;\n    }\n\n    &[data-dot] {\n      min-width: 0.625rem;\n      width: 0.625rem;\n      height: 0.625rem;\n      padding: 0;\n      translate: 20% -20%;\n\n      &:dir(rtl) {\n        translate: -20% -20%;\n      }\n    }\n  }\n\n  /* Each avatar overlaps the one before it, with a ring of the page color between them. */\n  .avatar-group {\n    display: inline-flex;\n    align-items: center;\n    vertical-align: middle;\n\n    & > * {\n      box-shadow: 0 0 0 2px var(--ui-background);\n    }\n\n    /* A small overlap: more would cover the next avatar's initials. */\n    & > * + * {\n      margin-inline-start: calc(var(--ui-spacing) * -1);\n    }\n  }\n\n  .avatar-group-more {\n    font-variant-numeric: tabular-nums;\n  }\n\n  /* Content sits at the top, so figures in a row line up whether or not one has a trend. */\n  .stat {\n    display: grid;\n    align-content: start;\n    gap: 0.25rem;\n\n    p {\n      margin: 0;\n    }\n  }\n\n  .stat-label {\n    font-size: 0.875rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .stat-trend {\n    max-inline-size: 100%;\n  }\n\n  /* A standalone figure keeps proportional digits; tabular ones look loose this big. */\n  .stat-value {\n    font-size: 1.75rem;\n    font-weight: 650;\n    line-height: 1.15;\n  }\n\n  .stat-change {\n    display: inline-flex;\n    align-items: center;\n    gap: 0.25rem;\n    font-size: 0.875rem;\n    font-weight: 600;\n\n    &[data-good] {\n      color: var(--tone-success);\n    }\n\n    &[data-bad] {\n      color: var(--tone-danger);\n    }\n  }\n\n  .stat-period,\n  .stat-description {\n    color: var(--ui-muted-foreground);\n    font-weight: 400;\n  }\n\n  .stat-description {\n    font-size: 0.8125rem;\n  }\n\n  .empty-state {\n    display: grid;\n    justify-items: center;\n    gap: 0.5rem;\n    padding: 2.5rem 1rem;\n    text-align: center;\n  }\n\n  .empty-state-icon {\n    width: 2rem;\n    height: 2rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .empty-state-title {\n    margin: 0.25rem 0 0;\n    font-size: 1.0625rem;\n  }\n\n  .empty-state-description {\n    max-width: 28rem;\n    margin: 0;\n    color: var(--ui-muted-foreground);\n  }\n\n  .empty-state-actions {\n    display: flex;\n    flex-wrap: wrap;\n    justify-content: center;\n    gap: 0.5rem;\n    margin-top: 0.5rem;\n  }\n\n  .skeleton {\n    display: block;\n    width: 100%;\n    border-radius: var(--ui-radius);\n    background: linear-gradient(\n        90deg,\n        var(--ui-muted) 0 35%,\n        color-mix(in oklab, var(--ui-muted), var(--ui-foreground) 8%) 50%,\n        var(--ui-muted) 65% 100%\n      )\n      0 0 / 300% 100%;\n    animation: skeleton-wave 1.6s ease-in-out infinite;\n  }\n\n  .skeleton-text {\n    display: grid;\n    gap: 0.5rem;\n\n    .skeleton {\n      height: 0.75rem;\n    }\n  }\n\n  @keyframes skeleton-wave {\n    from {\n      background-position: 100% 0;\n    }\n    to {\n      background-position: 0 0;\n    }\n  }\n\n  .description-list {\n    display: grid;\n    margin: 0;\n\n    &[data-layout=\"columns\"] .description-item {\n      display: grid;\n      grid-template-columns: minmax(8rem, 1fr) 2fr;\n      gap: 1rem;\n    }\n\n    dt {\n      color: var(--ui-muted-foreground);\n    }\n\n    dd {\n      margin: 0;\n      min-width: 0;\n      overflow-wrap: anywhere;\n    }\n  }\n\n  .description-item {\n    padding-block: 0.625rem;\n    border-bottom: 1px solid var(--ui-border);\n\n    &:last-child {\n      border-bottom: 0;\n    }\n  }\n\n  .item-list {\n    display: grid;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n  }\n\n  .item {\n    display: flex;\n    align-items: center;\n    gap: 0.75rem;\n    min-height: 3rem;\n    padding-block: 0.625rem;\n    border-bottom: 1px solid var(--ui-border);\n\n    &:last-child {\n      border-bottom: 0;\n    }\n  }\n\n  .item-text {\n    display: grid;\n    flex: 1;\n    min-width: 0;\n  }\n\n  .item-title {\n    overflow: hidden;\n    color: var(--ui-foreground);\n    font-weight: 500;\n    white-space: nowrap;\n    text-overflow: ellipsis;\n  }\n\n  a.item-title {\n    text-decoration: none;\n\n    &:hover {\n      text-decoration: underline;\n    }\n  }\n\n  .item-description,\n  .item-meta {\n    color: var(--ui-muted-foreground);\n    font-size: 0.8125rem;\n  }\n\n  .item-actions {\n    display: flex;\n    gap: 0.25rem;\n  }\n\n  .alert {\n    --alert-color: var(--tone-info);\n    display: grid;\n    grid-template-columns: auto minmax(0, 1fr) auto;\n    gap: 0.75rem;\n    align-items: start;\n    padding: 0.875rem 1rem;\n    position: relative;\n    overflow: hidden;\n    padding-inline-start: calc(1rem + 3px);\n    border: 1px solid color-mix(in oklab, var(--alert-color) 45%, var(--ui-border));\n    border-radius: calc(var(--ui-radius) + 4px);\n    background: color-mix(in oklab, var(--alert-color) 7%, var(--ui-background));\n\n    /* The accent is a straight bar the corners clip; a thick border would taper into them. */\n    &::before {\n      content: \"\";\n      position: absolute;\n      inset-block: 0;\n      inset-inline-start: 0;\n      inline-size: 4px;\n      background: var(--alert-color);\n    }\n\n    &[data-tone=\"success\"] {\n      --alert-color: var(--tone-success);\n    }\n\n    &[data-tone=\"warning\"] {\n      --alert-color: var(--tone-warning);\n    }\n\n    &[data-tone=\"danger\"] {\n      --alert-color: var(--tone-danger);\n    }\n  }\n\n  .alert-icon {\n    width: 1.25rem;\n    height: 1.25rem;\n    color: var(--alert-color);\n  }\n\n  .alert-body {\n    display: grid;\n    gap: 0.25rem;\n  }\n\n  .alert-title {\n    margin: 0;\n    font-weight: 600;\n  }\n\n  .alert-text {\n    color: var(--ui-foreground);\n  }\n\n  .alert-actions {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.5rem;\n    margin-top: 0.375rem;\n  }\n\n  .alert-dismiss {\n    width: 2rem;\n    height: 2rem;\n    padding: 0;\n  }\n\n  /* Sized in its own em so a key sits inside a line of text, not below it. */\n  .kbd {\n    display: inline-flex;\n    align-items: center;\n    min-width: 1.75em;\n    height: 1.75em;\n    justify-content: center;\n    padding-inline: 0.4em;\n    vertical-align: 0.125em;\n    line-height: 1;\n    border: 1px solid var(--ui-input);\n    border-bottom-width: 2px;\n    border-radius: calc(var(--ui-radius) / 2 + 2px);\n    background: var(--ui-background);\n    color: var(--ui-foreground);\n    font-family: var(--ui-font-mono);\n    font-size: 0.75rem;\n  }\n\n  .spinner {\n    display: inline-block;\n    flex-shrink: 0;\n    border: 2px solid color-mix(in oklab, var(--ui-foreground) 18%, transparent);\n    border-top-color: var(--ui-primary);\n    border-radius: 50%;\n    animation: spinner-turn 0.8s linear infinite;\n  }\n\n  @keyframes spinner-turn {\n    to {\n      rotate: 1turn;\n    }\n  }\n\n  .stepper {\n    container-type: inline-size;\n  }\n\n  .stepper ol {\n    display: flex;\n    flex-wrap: wrap;\n    gap: 0.25rem 1rem;\n    margin: 0;\n    padding: 0;\n    list-style: none;\n  }\n\n  /* Marks line up across steps, whether a step has a description or not. */\n  .stepper-step {\n    align-items: flex-start;\n    gap: 0.625rem;\n    height: auto;\n    min-height: 2.75rem;\n    padding: 0.375rem 0.625rem 0.375rem 0.375rem;\n    text-align: start;\n  }\n\n  @container (max-width: 30rem) {\n    .stepper ol {\n      flex-direction: column;\n      flex-wrap: nowrap;\n    }\n  }\n\n  .stepper-mark {\n    box-sizing: border-box;\n    display: inline-grid;\n    place-items: center;\n    width: 1.75rem;\n    height: 1.75rem;\n    flex-shrink: 0;\n    border: 2px solid var(--ui-input);\n    border-radius: 50%;\n    font-size: 0.8125rem;\n    font-weight: 600;\n    font-variant-numeric: tabular-nums;\n  }\n\n  .stepper li[data-state=\"current\"] .stepper-mark {\n    border-color: var(--ui-primary);\n    color: var(--ui-primary);\n  }\n\n  .stepper li[data-state=\"complete\"] .stepper-mark {\n    border-color: var(--ui-primary);\n    background: var(--ui-primary);\n    color: var(--ui-primary-foreground);\n  }\n\n  /* The label's first line centers on the mark, whatever the page's line height. */\n  .stepper-text {\n    display: grid;\n    padding-block-start: max(0px, calc((1.75rem - 1lh) / 2));\n  }\n\n  .stepper-label {\n    font-weight: 600;\n  }\n\n  .stepper-description {\n    font-size: 0.75rem;\n    color: var(--ui-muted-foreground);\n  }\n\n  .search-field {\n    position: relative;\n    display: flex;\n    /* A row even as a UI SDK field (which stacks its parts), so the icon centers. */\n    flex-direction: row;\n    align-items: center;\n    width: 100%;\n\n    [data-slot=\"input\"] {\n      width: 100%;\n      padding-inline: 2.125rem 3rem;\n    }\n  }\n\n  .search-field-icon {\n    position: absolute;\n    inset-inline-start: 0.625rem;\n    color: var(--ui-muted-foreground);\n    pointer-events: none;\n  }\n\n  .search-field-clear {\n    position: absolute;\n    inset-inline-end: 0.25rem;\n    width: 1.75rem;\n    height: 1.75rem;\n    padding: 0;\n  }\n\n  /* The browser's own clear button would duplicate ours. */\n  .search-field input[type=\"search\"]::-webkit-search-cancel-button {\n    display: none;\n  }\n\n  .search-field-hint {\n    position: absolute;\n    inset-inline-end: 0.5rem;\n    pointer-events: none;\n  }\n\n  .copy-button {\n    gap: 0.375rem;\n  }\n\n  @media (prefers-reduced-motion: reduce) {\n    .skeleton,\n    .spinner {\n      animation-duration: 0s;\n    }\n\n    .spinner {\n      border-top-color: var(--ui-muted-foreground);\n    }\n  }\n\n  @media (forced-colors: active) {\n    .badge,\n    .alert,\n    .kbd {\n      border-color: CanvasText;\n    }\n\n    /* Shadows don't draw here, so the rings become real edges. */\n    .avatar-group > *,\n    .count-badge-count {\n      outline: 1px solid CanvasText;\n    }\n\n    .count-badge-count {\n      background: Canvas;\n      color: CanvasText;\n    }\n\n    .sidebar-link[aria-current=\"page\"] {\n      outline: 2px solid Highlight;\n    }\n\n    .stepper li[data-state=\"complete\"] .stepper-mark {\n      background: Highlight;\n      color: HighlightText;\n    }\n  }\n}\n",
      "type": "registry:file",
      "target": "@ui/shell/shell.css"
    },
    {
      "path": "registry/uiset/ui/shell/icons.tsx",
      "content": "import { iconPaths, type IconName } from \"./icon-paths\"\n\nfunction Icon({ name, className }: { name: IconName; className?: string }) {\n  return (\n    <svg\n      viewBox=\"0 0 24 24\"\n      aria-hidden=\"true\"\n      focusable=\"false\"\n      className={[\"uiset-icon\", className].filter(Boolean).join(\" \")}\n    >\n      <path d={iconPaths[name]} />\n    </svg>\n  )\n}\n\nexport { Icon }\nexport type { IconName }\n",
      "type": "registry:file",
      "target": "@ui/shell/icons.tsx"
    },
    {
      "path": "registry/uiset/ui/shell/icon-paths.ts",
      "content": "// UISet's icons as SVG path data on a 24×24 grid, stroked: framework-free, so the React\n// Icon and the web elements draw the same shapes.\nconst iconPaths = {\n  // Text editing (the rich text editor's toolbar).\n  bold: \"M7 5h6a3.5 3.5 0 0 1 0 7H7zM7 12h7a3.5 3.5 0 0 1 0 7H7z\",\n  italic: \"M10 5h8M6 19h8M14 5l-4 14\",\n  underline: \"M7 5v6a5 5 0 0 0 10 0V5M5 20h14\",\n  strike: \"M5 12h14M16 7a4 4 0 0 0-3.5-2h-1A3.5 3.5 0 0 0 8 8.5c0 1.4.8 2.4 2.5 3M8 17a4 4 0 0 0 3.5 2h1a3.5 3.5 0 0 0 3.5-3.5c0-.6-.1-1.1-.4-1.5\",\n  \"code-inline\": \"M9 8l-4 4 4 4M15 8l4 4-4 4\",\n  link: \"M10 14a4 4 0 0 0 5.7 0l3-3a4 4 0 0 0-5.7-5.7l-1 1M14 10a4 4 0 0 0-5.7 0l-3 3a4 4 0 0 0 5.7 5.7l1-1\",\n  \"list-bullet\": \"M9 6h11M9 12h11M9 18h11M4.5 6v.01M4.5 12v.01M4.5 18v.01\",\n  \"list-ordered\": \"M10 6h10M10 12h10M10 18h10M4 4.5l1.5-.5v4.5M4 15a1.3 1.3 0 0 1 2.4.6c0 .8-2.4 1.7-2.4 2.9h2.6\",\n  \"list-check\": \"M11 6h9M11 12h9M11 18h9M3.5 6l1.5 1.5L8 4.5M3.5 12l1.5 1.5 3-3M3.5 18l1.5 1.5 3-3\",\n  quote: \"M6 7h4v4c0 3-1.3 5-4 6M14 7h4v4c0 3-1.3 5-4 6\",\n  undo: \"M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3\",\n  redo: \"M15 14l5-5-5-5M20 9H10a6 6 0 0 0 0 12h3\",\n  image: \"M4 5h16v14H4zM4 16l5-5 4 4 3-3 4 4M15 9.5v.01\",\n  \"code-block\": \"M4 5h16v14H4zM9.5 10l-2 2 2 2M14.5 10l2 2-2 2\",\n  rule: \"M4 12h16M8 8h8M8 16h8\",\n  menu: \"M4 7h16M4 12h16M4 17h16\",\n  sidebar: \"M4 5h16v14H4zM9 5v14\",\n  chevron: \"M9 6l6 6-6 6\",\n  search: \"M11 18a7 7 0 1 1 0-14 7 7 0 0 1 0 14zM20 20l-4-4\",\n  close: \"M6 6l12 12M18 6L6 18\",\n  copy: \"M8 8h11v11H8zM5 16V5h11\",\n  check: \"M5 12.5l4.5 4.5L19 7.5\",\n  info: \"M12 11v6M12 7.5v.01M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18z\",\n  success: \"M8 12.5l2.5 2.5L16 9.5M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18z\",\n  warning:\n    \"M12 9v4M12 16.5v.01M10.3 4.2L2.6 18a2 2 0 0 0 1.7 3h15.4a2 2 0 0 0 1.7-3L13.7 4.2a2 2 0 0 0-3.4 0z\",\n  danger: \"M15 9l-6 6M9 9l6 6M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18z\",\n  up: \"M7 14l5-5 5 5\",\n  down: \"M7 10l5 5 5-5\",\n  inbox: \"M4 13l2.5-7h11l2.5 7v6H4zM4 13h5l1 2h4l1-2h5\",\n  more: \"M4.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M10.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0M16.8 12a1.2 1.2 0 1 0 2.4 0a1.2 1.2 0 1 0-2.4 0\",\n  columns: \"M4 5h16v14H4zM10 5v14M15 5v14\",\n  download: \"M12 4v11M7 10l5 5 5-5M5 20h14\",\n  upload: \"M12 15V4M7 9l5-5 5 5M5 20h14\",\n  retry: \"M20 12a8 8 0 1 1-8-8c2.2 0 4.3.9 5.9 2.4L20 8.5M20 4v4.5h-4.5\",\n  filter: \"M4 6h16M7 12h10M10 18h4\",\n  home: \"M4 11l8-7 8 7M6 9.5V20h12V9.5M10 20v-5h4v5\",\n  users: \"M9 11a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7zM3 20c0-3.3 2.7-6 6-6s6 2.7 6 6M16 4.5a3.5 3.5 0 0 1 0 6.5M21 20c0-2.6-1.6-4.8-4-5.6\",\n  orders: \"M6 4h12l1 16H5zM9 8a3 3 0 0 0 6 0\",\n  reports: \"M5 20V10M12 20V4M19 20v-7\",\n  settings: \"M12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6zM19.4 13.5l1.6 1.2-2 3.4-1.9-.7a7 7 0 0 1-2 1.2l-.3 2h-4l-.3-2a7 7 0 0 1-2-1.2l-1.9.7-2-3.4 1.6-1.2a7 7 0 0 1 0-3l-1.6-1.2 2-3.4 1.9.7a7 7 0 0 1 2-1.2l.3-2h4l.3 2a7 7 0 0 1 2 1.2l1.9-.7 2 3.4-1.6 1.2a7 7 0 0 1 0 3z\",\n  mail: \"M4 6h16v12H4zM4 7l8 6 8-6\",\n  star: \"M12 4l2.5 5.2 5.5.8-4 3.9.9 5.6L12 16.8 7.1 19.5l.9-5.6-4-3.9 5.5-.8z\",\n  archive: \"M4 5h16v4H4zM6 9v10h12V9M10 13h4\",\n  trash: \"M5 7h14M10 7V5h4v2M7 7l1 13h8l1-13\",\n  plus: \"M12 5v14M5 12h14\",\n  minus: \"M5 12h14\",\n  fit: \"M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5\",\n  folder: \"M3.5 6.5a1.5 1.5 0 0 1 1.5-1.5h4l2 2h8a1.5 1.5 0 0 1 1.5 1.5v9a1.5 1.5 0 0 1-1.5 1.5H5a1.5 1.5 0 0 1-1.5-1.5z\",\n  file: \"M6 3.5h8l4 4v13H6zM14 3.5v4h4\",\n  branch: \"M6 4v16M18 8a2 2 0 1 0 0-4 2 2 0 0 0 0 4zM18 8c0 5-6 5-12 8\",\n  grip: \"M9 6.5v.01M15 6.5v.01M9 12v.01M15 12v.01M9 17.5v.01M15 17.5v.01\",\n  edit: \"M5 19h4L19 9l-4-4L5 15zM14 6l4 4\",\n  send: \"M4 12l16-8-6 16-2-7z\",\n  card: \"M3 6h18v12H3zM3 10h18M7 15h4\",\n  shield: \"M12 3l7 3v5c0 4.5-3 8.5-7 10-4-1.5-7-5.5-7-10V6z\",\n  bell: \"M6 16V11a6 6 0 0 1 12 0v5l2 2H4zM10 20a2 2 0 0 0 4 0\",\n}\n\ntype IconName = keyof typeof iconPaths\n\n/** An icon as an SVG element, for code without React. */\nfunction iconElement(name: IconName, className?: string) {\n  const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\")\n  svg.setAttribute(\"viewBox\", \"0 0 24 24\")\n  svg.setAttribute(\"aria-hidden\", \"true\")\n  svg.setAttribute(\"focusable\", \"false\")\n  svg.setAttribute(\"class\", [\"uiset-icon\", className].filter(Boolean).join(\" \"))\n  const path = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\")\n  path.setAttribute(\"d\", iconPaths[name])\n  svg.append(path)\n  return svg\n}\n\nexport { iconElement, iconPaths }\nexport type { IconName }\n",
      "type": "registry:file",
      "target": "@ui/shell/icon-paths.ts"
    }
  ],
  "type": "registry:ui"
}