docPages top-level constant

List<DocPage> const docPages

The reference's pages by section: what ui_docs serves (docs/reference/<id>.md).

Implementation

const List<DocPage> docPages = [
  DocPage(
    id: 'layout',
    title: 'Responsive layout',
    summary: 'Sizes, rows, columns, stacks, scrolling and screen sizes beyond the base: every layout field, which sizing modes each parent allows, media rules and breakpoints, and the web layouts agents ask for (a page gutter, cards that wrap, a row turning into a column, a sticky header).',
    when: 'Sizes, rows, columns, stacks, scrolling and screen sizes beyond the base: every layout field, which sizing\nmodes each parent allows, media rules and breakpoints, and the web layouts agents ask for (a page gutter, cards that\nwrap, a row turning into a column, a sticky header).',
    example: 'The text hugs its content, the red box fills the column\'s width, and in the row the green and blue boxes share the\nfree space 1 : 2 (`flex`) beside a fixed gray box.\n\n```json\n{\n  "schema": 3,\n  "roots": ["sizing"],\n  "nodes": {\n    "sizing": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 400, "height": 400},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["hugText", "fillBox", "bar"],\n      "layout": {"width": {"fill": 400}, "height": {"fill": 400}, "padding": 10},\n      "props": {"crossAxisAlignment": "start", "spacing": 8}\n    },\n    "hugText": {\n      "type": "text",\n      "layout": {"width": {"hug": 80}, "height": {"hug": 20}},\n      "props": {"text": "As wide as its text", "style": {"fontSize": 16, "color": "#FF000000"}}\n    },\n    "fillBox": {\n      "type": "box",\n      "layout": {"width": {"fill": 380}, "height": 24},\n      "decoration": {"fills": [{"color": "#FFEF4444"}]}\n    },\n    "bar": {\n      "type": "row",\n      "children": ["one", "two", "fixed"],\n      "layout": {"width": {"fill": 380}, "height": 40},\n      "props": {"spacing": 10}\n    },\n    "one": {\n      "type": "box",\n      "layout": {"width": {"fill": 100}, "height": {"fill": 40}},\n      "decoration": {"fills": [{"color": "#FF22C55E"}]}\n    },\n    "two": {\n      "type": "box",\n      "layout": {"width": {"fill": 200}, "height": {"fill": 40}, "flex": 2},\n      "decoration": {"fills": [{"color": "#FF3B82F6"}]}\n    },\n    "fixed": {"type": "box", "layout": {"width": 60, "height": 20}, "decoration": {"fills": [{"color": "#FF9CA3AF"}]}}\n  }\n}\n```',
    pitfalls: '- `fill` takes all the room it is given: cap it with `constraints.maxWidth`. Where its parent gives no room on that\n  axis (it hugs it, or scrolls), a fill is its design number (`fill_fallback`, naming the parent).\n- `x`/`y` mean nothing under a row or column, `flex`/`align` nothing under a stack.\n- A stack that hugs its children grows to hold them, so there a negative offset is 0. A\n  negative margin does not overlap a neighbor: translate with `motion`.\n- A media patch replaces a size of another mode: `{"hug": 200}` over `{"fill": 292}` is `{"hug": 200}`. A field\n  both patched and bound shows the binding: bind in the rule instead.\n- `squeezeChildren` (default true) shrinks children that do not fit (CSS flex shrink); false is Flutter\'s\n  overflow (`layout_overflow`).\n- A `spacer` takes free space only in a row or column with room.\n- Without `basis`, children of a wrapping row keep their own size.\n- `\${screen.width}` prints `390.0`; `\${= screen.width}` prints `390`.',
    words: 10517,
    items: ['canvas', 'row', 'column', 'flex', 'stack', 'box', 'spacer', 'divider', 'verticalDivider', 'variance', 'sticky', 'floating', 'measure', 'scroll', 'scrollEnd', 'enterViewport', 'exitViewport', 'scrollTo'],
    sections: [
      DocSection('layout-layout-fields', 'Layout fields', 'A node\'s `"layout"`: its size, spacing and placement in its parent. `width` and `height` are an\n[AxisSize](values.md#type-AxisSize): a number (fixed) or `{"fill" | "hug" | "flexible" | "fixed": number}`; `x` and `y` an\n[AxisPosition](values.md#type-AxisPosition).\n\n| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `width` | [AxisSize](values.md#type-AxisSize) | `0` |  | The node\'s width: a number (fixed), `{"hug": n}` (its content), `{"fill": n}` (the room its parent gives) or `{"flexible": n}` (up to n). n is the design size. Without one the node is 0 wide. |\n| `height` | [AxisSize](values.md#type-AxisSize) | `0` |  | The node\'s height: a number (fixed), `{"hug": n}`, `{"fill": n}` or `{"flexible": n}`, as `width`. Without one the node is 0 high. |\n| `constraints` | [BoxConstraints](values.md#type-BoxConstraints) | `{}` |  |  |\n| `margin` | [EdgeInsets](values.md#type-EdgeInsets) | `0` |  | Space around the node, outside its box. |\n| `padding` | [EdgeInsets](values.md#type-EdgeInsets) | `0` |  | Space between the node\'s box and its content (Flutter\'s `Padding`). A text\'s padding sits around its lines, as `Padding(child: Text(...))`: a hugging text grows by it. |\n| `aspectRatio` | double | unset | ≥ 0 | Width / height the node keeps when its parent resizes it. |\n| `widthFactor` | double | unset | ≥ 0 | A share of the room the parent gives across (Flutter\'s `FractionallySizedBox.widthFactor`): a progress bar\'s fill is `0.6` of its track. Unset: sized by `width`. Bind it (`\${= item.pct / 100}`) for a bar that follows data. |\n| `heightFactor` | double | unset | ≥ 0 | A share of the room the parent gives down (Flutter\'s `FractionallySizedBox.heightFactor`). Unset: sized by `height`. |\n| `flex` | int | `1` | ≥ 0 | Under a row/column: share of the free space (`Expanded.flex`). |\n| `squeezable` | bool | `false` |  | Under a row/column: a hugging child that may shrink (`Flexible`). |\n| `x` | [AxisPosition](values.md#type-AxisPosition) | `{"start":0}` |  | Under a freeform parent (`Positioned` / `Align`). |\n| `y` | [AxisPosition](values.md#type-AxisPosition) | `{"start":0}` |  | Position under a freeform parent. |\n| `align` | [Alignment](values.md#type-Alignment) | unset |  | Under a row/column: alignment in its slot (`Align`). |\n| `order` | int | `0` |  | CSS `order`: under a row, column or flex, children are laid out and painted by ascending order (equal orders as listed). Patch it per screen size (`media`) to reorder at a width. |\n| `basis` | double | unset | ≥ 0 | CSS `flex-basis`, under a wrapping row, column or flex: the main size the child counts when lines are broken; a child that fills the main axis (`{"fill": n}`) then grows by its `flex` share of the room left on its line (`flex: 1 1 280px`). Cards with `basis: 280` sit three across at 900 px, two at 600, one at 390, with no breakpoints. |\n| `columnSpan` | int | `1` | ≥ 1 | CSS `grid-column: span n`, under a gridView: how many columns the item covers (at most the grid\'s columns). Bind it per item (`\${= index == 0 ? 2 : 1}`: a lead story across two) and patch it per screen size (`media`). |\n\n(Continues: layout.md#layout-layout-fields.)'),
      DocSection('layout-which-sizing-modes-each-parent-allows', 'Which sizing modes each parent allows', 'From the parents\' own rules; "fill (with `basis`)": a child of a wrapping row may fill its line\'s share when it sets\n`layout.basis`.\n\n| Parent | Width may be | Height may be |\n|---|---|---|\n| `row` | fixed, fill, flexible, hug | fixed, fill, hug |\n| `column` | fixed, fill, hug | fixed, fill, flexible, hug |\n| `row` with {"wrap":true} | fixed, fill (with `basis`), hug | fixed, fill, hug |\n| `column` with {"scrollable":true} | fixed, fill, hug | fixed, hug |\n| `row` with {"scrollable":true,"scrollDirection":"horizontal"} | fixed, hug | fixed, fill, hug |\n| `stack` | fixed, fill, hug | fixed, fill, hug |\n| `canvas` | fixed, fill, hug | fixed, fill, hug |\n| `listView` | fill | fixed, hug |\n| `listView` with {"itemExtent":80} | fill | fill |\n| `gridView` | fill | fill |\n| `pageView` | fill | fill |\n\nWhy a mode is not allowed, as the declarations say it:\n\n- Flexible only applies in a row or column, along its main axis.\n- A wrapping row lays its children out in runs: they keep their own size along it, unless they set layout.basis (CSS flex-basis): then a filling child grows to share its line. Add the width it starts from and wraps at ("layout": {"width": {"fill": 300}, "basis": 240}), or give it a fixed or hug size.\n- The column scrolls: its content has no end to fill to (with "fillViewport": true a filling child shares the viewport while the content fits it).\n- The row scrolls: its content has no end to fill to (with "fillViewport": true a filling child shares the viewport while the content fits it).\n- Items in a list always fill across it.\n- A list is unbounded along its scroll axis: items cannot fill it. Set an item extent.\n- The list gives every item its item extent: they fill it.\n- Grid cells size their children: they fill them.\n- Pages size their children: they fill them.'),
      DocSection('layout-media-rules', 'Media rules', 'A node\'s `media` (and the theme\'s) is a list of rules, each a CSS media query over the node:\n\n| Key | Meaning |\n|---|---|\n| `minWidth` | CSS `min-width`: a width in px (inclusive), or a breakpoint name (from its min width). |\n| `maxWidth` | CSS `max-width`: a width in px (inclusive), or a breakpoint name (up to the next breakpoint\'s min width, exclusive). |\n| `orientation` | CSS `orientation`. |\n| `patch` | A JSON merge patch over the node (maps merge, `null` removes, anything else replaces): `props`, `layout`, `decoration`, `visible`, `opacity`, `motion` (a transform that moves what is painted, not the layout: `Transform.translate`), and `bind`: bindings that hold at these sizes only (`"bind": {"visible": "\${= !open}"}`), or `null` to drop one of the node\'s own here, so its patched value shows. |'),
      DocSection('layout-breakpoints', 'Breakpoints', 'The project\'s breakpoints name size classes by minimum width. Unless a document\'s `breakpoints` key says otherwise\nthey are:\n\n| id | name | minWidth | design width × height |\n|---|---|---|---|\n| `mobile` | Mobile | 0 | 390 × 844 |\n| `tablet` | Tablet | 600 | 834 × 1112 |\n| `desktop` | Desktop | 1024 | 1440 × 900 |\n\nA breakpoint\'s fields:\n\n| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `id` | String | `""` |  | Stable id. |\n| `name` | String | `""` |  | Name. |\n| `minWidth` | double | `0` | ≥ 0 | From this width (inclusive). |\n| `width` | double | `0` | ≥ 0 | Design width of its canvases. |\n| `height` | double | `0` | ≥ 0 | Design height of its canvases. |'),
      DocSection('layout-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-scroll"></a>`scroll` | The node (a scrolling row, column, list, grid or canvas) scrolled (`\${result.offset}`, `\${result.max}`, `\${result.fraction}` 0–1, `\${result.index}` the item at the start of the view (the last at the end), `\${result.count}` the items, `\${result.overscroll}` how far it is pulled past an end: below 0 past the start, above 0 past the end, 0 within). Store what a carousel\'s arrows, dots or progress bar show. How near the end it is, to load more: `\${result.max - result.offset}` (under 600: fetch the next page); a list\'s `pagination` loads its next page by itself (`thresholdPixels`). |\n| <a id="trigger-scrollEnd"></a>`scrollEnd` | The node stopped scrolling; `\${result}` as for `scroll`. |\n| <a id="trigger-enterViewport"></a>`enterViewport` | At least `Trigger.visibleFraction` of the node became visible (and stayed so for `Trigger.visibleMs`), or it fell below that after being visible. With `Trigger.onceKey` (`\${item.id}`), an impression: once per item per app session. |\n| <a id="trigger-exitViewport"></a>`exitViewport` |  |'),
      DocSection('layout-responsive-design', 'Responsive design', 'Responsive layout works as on the web: flexbox and grid lay content out so it fits any width, and media queries\nchange what must change at a width. Use these, in this order:\n\n1. **Intrinsic layout, no breakpoints.** A wrapping row whose children set `layout.basis` and fill the main axis:\n   lines break by the basis and the children on each line grow to share it. For repeated data, a `gridView` with\n   `minCrossAxisExtent` makes as many equal columns as fit. A share of the parent (CSS `width: 60%`) is\n   `layout.widthFactor: 0.6`.\n2. **Media rules** for what must change at a width: direction, order, visibility, type size, padding. A rule\'s\n   `patch` is merged over the node (objects merge, `null` removes a key), except that a value with several forms is\n   **replaced**, as CSS replaces a declaration: `{"width": {"hug": 200}}` over `{"fill": 292}` is `{"hug": 200}`.\n   Rules apply in order, a later one winning (the cascade).\n3. **Bindings on `\${screen}`** for values computed from the size: `"bind": {"layout.width": "\${= min(screen.width -\n   32, 760)}"}`. `\${screen}` has `width`, `height`, `breakpoint`, `is.<name>`, `atLeast.<name>`\n   (`\${= screen.atLeast.tablet ? 3 : 1}`). Nothing can check such a formula\'s result: prefer media rules.\n4. **A canvas per breakpoint**, only for screens that are genuinely different designs (below).\n\nPrecedence: the node\'s own values, then its media rules, then an active interaction state\'s patch, then its\nbindings, then conditions; a binding of a field the active state patches yields to the patch (which may bind).\n\nThis page uses the four web patterns: a header whose links collapse to a menu icon below desktop, a 3 → 2 → 1 card\ngrid from data (`minCrossAxisExtent`), a text-and-photo section that stacks with the photo first on phones (`basis`\nin a wrapping row, the photo\'s `order` patched), and a title whose size steps up with the width, inside a content\ncolumn capped at 1200:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home"],\n  "nodes": {\n    "home": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 1440, "height": 900},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["header", "content"],\n      "layout": {"width": {"fill": 1440}, "height": {"fill": 900}},\n      "props": {"scrollable": true}\n    },\n    "header": {\n      "type": "row",\n      "children": ["logo", "nav", "menu"],\n      "layout": {"width": {"fill": 1440}, "height": 64, "padding": [16, 0, 16, 0]},\n      "props": {"mainAxisAlignment": "spaceBetween"},\n      "decoration": {"fills": [{"color": "#FF111827"}]},\n      "media": [{"minWidth": "desktop", "patch": {"layout": {"padding": [32, 0, 32, 0]}}}]\n    },\n    "logo": {\n      "type": "text",\n      "layout": {"width": {"hug": 80}, "height": {"hug": 24}},\n      "props": {"text": "Relay", "style": {"fontSize": 20, "fontWeight": 700, "color": "#FFFFFFFF"}}\n    },\n    "nav": {\n      "type": "row",\n      "children": ["nav-1", "nav-2", "nav-3"],\n      "visible": false,\n      "layout": {"width": {"hug": 300}, "height": {"hug": 20}},\n      "props": {"spacing": 32},\n\n(Continues: layout.md#layout-responsive-design.)'),
      DocSection('layout-a-capped-band', 'A capped band', 'A full-width band with capped, centered content (CSS `max-width: 1200px; margin: 0 auto` inside a colored band):\nthe band fills the width and holds the background; its one child fills with `constraints.maxWidth`, centered by the\nband\'s `crossAxisAlignment` (`center`, the default). Under `crossAxisAlignment: stretch` a cap holds too, as CSS\n`max-width` does: the child sits at the start, or where its `layout.align` puts it (`[0, 0]` centers it). Below, a\ncomparison table built from one row template and one cell template:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home"],\n  "nodes": {\n    "home": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 1440, "height": 900},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["band"],\n      "props": {"scrollable": true},\n      "layout": {"width": {"fill": 1440}, "height": {"fill": 900}}\n    },\n    "band": {\n      "type": "column",\n      "children": ["rail"],\n      "layout": {"width": {"fill": 1440}, "height": {"hug": 200}, "padding": [24, 48, 24, 48]},\n      "decoration": {"fills": [{"color": "#FF1F2937"}]}\n    },\n    "rail": {\n      "type": "column",\n      "children": ["title", "table"],\n      "props": {"spacing": 16, "crossAxisAlignment": "stretch"},\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 160}, "constraints": {"maxWidth": 1200}}\n    },\n    "title": {\n      "type": "text",\n      "props": {"text": "Compare plans", "style": {"fontSize": 28, "fontWeight": 700, "color": "#FFFFFFFF"}},\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 34}}\n    },\n    "table": {\n      "type": "listView",\n      "children": ["tr"],\n      "bind": {"data": "\${rows}"},\n      "props": {"physics": "never"},\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 120}}\n    },\n    "tr": {\n      "type": "row",\n      "children": ["label", "cells"],\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 44}},\n      "decoration": {"strokes": [{"color": "#FF374151"}], "strokeSides": "bottom"}\n    },\n    "label": {\n      "type": "text",\n      "bind": {"props.text": "\${item.label}"},\n      "props": {"text": "", "style": {"fontSize": 14, "color": "#FFD1D5DB"}},\n      "layout": {"width": {"fill": 180}, "height": {"hug": 20}, "flex": 2}\n    },\n    "cells": {\n      "type": "gridView",\n      "children": ["cell"],\n      "bind": {"data": "\${item.values}", "props.crossAxisCount": "\${= length(item.values)}"},\n      "props": {"physics": "never", "crossAxisCount": 3, "shrinkWrapRows": true},\n      "layout": {"width": {"fill": 600}, "height": {"hug": 44}, "flex": 3}\n    },\n    "cell": {\n      "type": "text",\n      "bind": {"props.text": "\${item}"},\n      "props": {"text": "", "textAlign": "center", "style": {"fontSize": 14, "color": "#FFFFFFFF"}},\n      "layout": {"width": {"fill": 200}, "height": {"hug": 20}, "margin": [0, 12, 0, 12]}\n    }\n  },\n  "variables": {\n    "home": [\n      {\n        "name": "rows",\n        "type": "list",\n        "value": [\n          {"label": "Seats", "values": ["5", "25", "Unlimited"]},\n          {"label": "SSO", "values": ["–", "Yes", "Yes"]},\n\n(Continues: layout.md#layout-a-capped-band.)'),
      DocSection('layout-page-gutter', 'Page gutter', 'The most common layout defect is sections that start at different x (one band padded 24, the next 32, a third\ncapped). Give every section the same two layers, and they line up at every width:\n\n- the **band** (the section) fills the page width, holds its background, and has the page **gutter** as its side\n  padding: the same three values in every band, by the same media rules (16 on phones, 32 from 600, 64 from 1024);\n- its one **rail** child fills the band with `"constraints": {"maxWidth": 1200}`, centered (the band\'s default\n  `crossAxisAlignment`); the section\'s content goes inside the rail.\n\nAt 390 every rail starts at 16, at 834 at 32, at 1440 at 120 ((1440 − 1200) / 2: the cap, not the gutter). Never pad\nthe rail or a section\'s first child to move content: change the gutter in every band at once. A part meant to run\nto the edge (a photo strip) is a band with no rail ([overlap and bleed](#layout-overlap-and-bleed)).\n\nA hero is a band like the others: give it and its copy a **hug** height with a minimum (`"height": {"hug": 560},\n"constraints": {"minHeight": 480}`), never a fixed one. A headline whose size steps up by a media rule takes more\nlines in a narrower column, and a fixed height then overflows by the extra lines at tablet or desktop.\n\n```json\n{\n  "schema": 3,\n  "roots": ["home"],\n  "nodes": {\n    "home": {"type": "canvas", "slots": {"body": "page"}, "layout": {"width": 1440, "height": 900},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}},\n    "page": {"type": "column", "children": ["hero", "features"], "props": {"scrollable": true},\n      "layout": {"width": {"fill": 1440}, "height": {"fill": 900}}},\n    "hero": {"type": "column", "children": ["heroRail"],\n      "layout": {"width": {"fill": 1440}, "height": {"hug": 200}, "padding": [16, 48, 16, 48]},\n      "decoration": {"fills": [{"color": "#FF0F172A"}]},\n      "media": [{"minWidth": 600, "patch": {"layout": {"padding": [32, 64, 32, 64]}}},\n                {"minWidth": 1024, "patch": {"layout": {"padding": [64, 96, 64, 96]}}}]},\n    "heroRail": {"type": "column", "children": ["heroTitle"],\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 60}, "constraints": {"maxWidth": 1200}}},\n    "heroTitle": {"type": "text", "layout": {"width": {"fill": 1200}, "height": {"hug": 40}},\n      "props": {"text": "Every section starts on one line", "style": {"fontSize": 32, "fontWeight": 700, "color": "#FFFFFFFF"}}},\n    "features": {"type": "column", "children": ["featuresRail"],\n      "layout": {"width": {"fill": 1440}, "height": {"hug": 200}, "padding": [16, 48, 16, 48]},\n      "media": [{"minWidth": 600, "patch": {"layout": {"padding": [32, 64, 32, 64]}}},\n                {"minWidth": 1024, "patch": {"layout": {"padding": [64, 96, 64, 96]}}}]},\n    "featuresRail": {"type": "row", "children": ["f1"],\n      "layout": {"width": {"fill": 1200}, "height": {"hug": 120}, "constraints": {"maxWidth": 1200}},\n      "props": {"wrap": true, "spacing": 24, "runSpacing": 24}},\n    "f1": {"type": "text", "layout": {"width": {"fill": 400}, "height": {"hug": 48}, "basis": 300},\n\n(Continues: layout.md#layout-page-gutter.)'),
      DocSection('layout-an-editorial-page-at-three-sizes', 'An editorial page at three sizes', 'A phone, a tablet and a desktop are three layouts, not one stretched: **use the width**. On a tablet, split the page\ninto the content and a rail; on a desktop, give the content columns and let a lead item span them. A page that is\none column at 1440 px wide, or whose content stops short of the width it was given, wastes the screen.\n\nThe front page below is one document. On a phone it is one column: stories, then the "Most read" rail. From 834 px\nthe `split` flex turns horizontal (its `direction` patched): the stories fill and the rail is 280 wide and `sticky`,\npinned 24 px below the top as the page scrolls. The stories are a `gridView` whose `crossAxisCount` is 1, 2 from\n834 px and 3 from 1200 px; the lead story spans two columns (`"bind": {"layout.columnSpan": "\${= index == 0 ? 2 :\n1}"}`), which is the whole row at two columns and the full width at one, because a span is never wider than the\ngrid. The masthead is a full-width colored band whose content is capped at 1200 and centered\n([a capped band](#layout-a-capped-band)), as is the split.\n\n```json\n{\n  "schema": 3,\n  "roots": ["front"],\n  "nodes": {\n    "front": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFAF7F2"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["masthead", "main"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}},\n      "props": {"scrollable": true}\n    },\n    "masthead": {\n      "type": "column",\n      "children": ["mastheadInner"],\n      "layout": {"width": {"fill": 390}, "height": {"hug": 72}, "padding": [20, 20, 20, 20]},\n      "decoration": {"fills": [{"color": "#FF1F2A44"}]}\n    },\n    "mastheadInner": {\n      "type": "row",\n      "children": ["title", "edition"],\n      "layout": {"width": {"fill": 350}, "height": {"hug": 32}, "constraints": {"maxWidth": 1200}},\n      "props": {"mainAxisAlignment": "spaceBetween"}\n    },\n    "title": {\n      "type": "text",\n      "layout": {"width": {"hug": 140}, "height": {"hug": 32}},\n      "props": {"text": "The Long Tide", "style": {"fontSize": 24, "fontWeight": 700, "color": "#FFFAF7F2"}}\n    },\n    "edition": {\n      "type": "text",\n      "layout": {"width": {"hug": 120}, "height": {"hug": 18}},\n      "props": {"text": "Saturday edition", "style": {"fontSize": 13, "color": "#FFCBD5E1"}},\n      "media": [{"maxWidth": 599, "patch": {"visible": false}}]\n    },\n    "main": {\n      "type": "column",\n      "children": ["split"],\n      "layout": {"width": {"fill": 390}, "height": {"hug": 1200}, "padding": [20, 24, 20, 40]}\n    },\n    "split": {\n      "type": "flex",\n      "children": ["river", "rail"],\n      "layout": {"width": {"fill": 350}, "height": {"hug": 1200}, "constraints": {"maxWidth": 1200}},\n      "props": {"direction": "vertical", "spacing": 32, "crossAxisAlignment": "start"},\n      "media": [{"minWidth": 834, "patch": {"props": {"direction": "horizontal"}}}]\n    },\n    "river": {\n      "type": "gridView",\n      "children": ["story"],\n      "layout": {"width": {"fill": 350}, "height": {"hug": 900}},\n      "props": {\n        "crossAxisCount": 1,\n        "shrinkWrapRows": true,\n\n(Continues: layout.md#layout-an-editorial-page-at-three-sizes.)'),
      DocSection('layout-grid-spans-a-timetable', 'Grid spans; a timetable', 'A `gridView` item spans and is placed as in CSS grid, through its own `layout` (the template\'s, bound per item from\nits data, and patched per size like any field):\n\n| `layout` | CSS | |\n|---|---|---|\n| `columnSpan`, `rowSpan` | `grid-column: span n`, `grid-row: span n` | cells covered across and down (a span is at most the grid\'s columns) |\n| `columnStart`, `rowStart` | `grid-column-start`, `grid-row-start` | the first column and row, 1 the first; unset: the next free cell |\n\nItems with both starts are placed first, then those with only a row, then the rest in order, each in the next cells\nwhere it fits (CSS\'s auto-placement); `"fillGaps": true` on the grid is CSS `grid-auto-flow: dense`, the rest taking\nthe first cells they fit from the top (a hole a span left). **Explicit placement stays put when the data is\nfiltered**: a session keeps its track\'s column and its slot\'s row, so filtering leaves those cells empty. For a\nfiltered view that closes up, bind the starts only while showing everything (`"layout.columnStart": "\${= track ==\n\'all\' ? item.track : null}"`): a null start is auto-placement. Rows are `mainAxisExtent` long (a time slot), or with `shrinkWrapRows` as long\nas their tallest item. A time-by-track timetable binds each session\'s track and slot to `columnStart` and\n`rowStart`, its length to `rowSpan`, and a session for every track to `columnSpan`; on a phone the bindings are only\nin a `minWidth` rule\'s patch, so the sessions fall back to one column in time order (a list), each naming its room:\n\n```json\n{\n  "schema": 3,\n  "roots": ["schedule"],\n  "nodes": {\n    "schedule": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["heading", "tracks", "grid"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 20},\n      "props": {"spacing": 12, "crossAxisAlignment": "start", "scrollable": true}\n    },\n    "heading": {\n      "type": "text",\n      "layout": {"width": {"fill": 350}, "height": {"hug": 30}},\n      "props": {"text": "Saturday, 9:00 to 12:00", "style": {"fontSize": 22, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "tracks": {\n      "type": "row",\n      "children": ["track1", "track2", "track3"],\n      "layout": {"width": {"fill": 350}, "height": {"hug": 20}},\n      "props": {"spacing": 12},\n      "visible": false,\n      "media": [{"minWidth": 600, "patch": {"visible": true}}]\n    },\n    "track1": {\n      "type": "text",\n      "layout": {"width": {"fill": 100}, "height": {"hug": 20}},\n      "props": {"text": "Main hall", "style": {"fontSize": 13, "fontWeight": 700, "color": "#FF6B7280"}}\n    },\n    "track2": {\n      "type": "text",\n      "layout": {"width": {"fill": 100}, "height": {"hug": 20}},\n      "props": {"text": "Studio", "style": {"fontSize": 13, "fontWeight": 700, "color": "#FF6B7280"}}\n    },\n    "track3": {\n      "type": "text",\n      "layout": {"width": {"fill": 100}, "height": {"hug": 20}},\n      "props": {"text": "Workshop room", "style": {"fontSize": 13, "fontWeight": 700, "color": "#FF6B7280"}}\n    },\n\n(Continues: layout.md#layout-grid-spans-a-timetable.)'),
      DocSection('layout-cards-that-wrap', 'Cards that wrap', 'Three plan cards three across at desktop, two at tablet, one on phones, with no breakpoint: a wrapping `row`\n(`"wrap": true`, `spacing`, `runSpacing`) whose cards are `"width": {"fill": 300}, "basis": 280`. With\n`crossAxisAlignment: stretch` the cards of each line are as tall as its tallest (CSS `align-items: stretch`: equal\nheights). From data, use a `gridView` with `minCrossAxisExtent` and `shrinkWrapRows` instead\n([equal-height cards](lists.md#lists-equal-height-cards)).'),
      DocSection('layout-a-row-that-becomes-a-column', 'A row that becomes a column', 'A `flex` node with `"direction": "horizontal"` and a rule patching `"direction": "vertical"` below a width. Its\nchildren stay the same nodes, keeping their state. Another order at a width: each child\'s `layout.order`, patched in\nthe child\'s own rule (`{"maxWidth": "mobile", "patch": {"layout": {"order": -1}}}` puts it first). Hidden at a\nwidth: `{"maxWidth": "tablet", "patch": {"visible": false}}`; a hidden node takes no room.\n\n```json\n"split": {"type": "flex", "children": ["copy", "photo"], "props": {"direction": "horizontal", "spacing": 32},\n          "layout": {"width": {"fill": 1200}, "height": {"hug": 400}},\n          "media": [{"maxWidth": 599, "patch": {"props": {"direction": "vertical"}}}]}\n```'),
      DocSection('layout-a-media-rule-and-a-binding-on-one-field', 'A media rule and a binding on one field', 'Shown on phones only, and there only while a panel is closed: a patch may set `bind`, bindings that hold at its\nsizes only. Write the node for the other sizes and bind in the rule: `"visible": false, "media": [{"maxWidth": 599,\n"patch": {"bind": {"visible": "\${= !filtersOpen}"}}}]`. The breakpoint stays in the media rule. To show a patched\nvalue where the node binds the field at other sizes, drop the binding in the rule: `"patch": {"visible": true,\n"bind": {"visible": null}}`.'),
      DocSection('layout-overlap-and-bleed', 'Overlap and bleed', '**Overlapping a neighbor** (CSS `margin-top: -36px`, `transform: translateY(-36px)`): Flutter\'s answer is\n`Transform.translate`: `"motion": {"translateY": -36}` moves what the node paints, not its layout, so the next node\ndoes not move up; a node later in its parent paints over the ones before it. A media rule may patch it. A card\noverlapping the bottom of a hero band: the card after the hero with `translateY: -36`, and 36 px of `margin` below it\nif the next section should keep its distance. The render command reports a node translated past its parent\'s box as\n`layout_overflow` (a warning naming the parent): expected for this pattern, and the only diagnostic it leaves. To\noverlap by an amount that depends on the content, or with no warning, use a `stack`.\n\n**Bleeding past the gutter** (a table or photo running to the screen\'s edge while the text keeps its padding): put\nthe padding on the children, not on the band, or let the one child that bleeds translate out of it (`"motion":\n{"translateX": 18}` with a width 18 larger), and keep the band\'s `"decoration": {"clip": "none"}` (the default). A\nphoto frame that overhangs its photo: a `stack` with a fixed or fill size holding the frame at a negative `x`/`y`.'),
      DocSection('layout-scrolling', 'Scrolling', 'A screen scrolls only if something in it scrolls. Make the canvas\'s body column scroll: `"props": {"scrollable":\ntrue}` with `{"fill": n}` width and height. Without it, content past the bottom of the screen is cut off\n(`offscreen`). Inside a scrolling column, a child cannot `fill` the scrolling axis. Rows scroll sideways with\n`"scrollable": true, "scrollDirection": "horizontal"`. `scrollTo` reveals a node (`"node"`: an id, or an expression\ngiving one; `"axis": "horizontal"` moves only sideways scroll views), or one item of a list (`"item"`: its key or\nindex): `{"type": "scrollTo", "node": "faq", "durationMs": 400}` from a sub-navigation link (the key is `node`, not\n`target`). Under a fixed or sticky header, `"offset": 88` (the header\'s height and a margin) lands the node that far\nbelow the top instead of under the header. A heading on another page: navigate with a param (`"params": {"anchor":\n"installation"}`) and scroll in that page\'s `load` reaction (`{"type": "scrollTo", "node": "\${route.anchor}",\n"offset": 88, "when": {"left": "\${route.anchor}", "op": "isNotEmpty"}}`). A scrolling node\'s `scroll` reaction gives its position (`\${result.offset}`, `\${result.fraction}`, the item\nat the start `\${result.index}`): store it for a header that condenses or a progress bar. Arrows, dots and snapping:\n[a carousel](lists.md#lists-a-carousel-pages-and-pagination).\n\n```json\n{\n  "schema": 3,\n  "roots": ["article"],\n  "nodes": {\n    "article": {\n      "type": "canvas",\n      "slots": {"body": "scroller"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "scroller": {\n      "type": "column",\n      "children": ["header", "p1", "p2", "p3"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n      "props": {"scrollable": true, "spacing": 16, "crossAxisAlignment": "start"}\n    },\n    "header": {\n      "type": "box",\n      "layout": {"width": {"fill": 342}, "height": 400},\n      "decoration": {"fills": [{"color": "#FFDBEAFE"}], "radius": 16}\n    },\n    "p1": {\n      "type": "box",\n      "layout": {"width": {"fill": 342}, "height": 300},\n      "decoration": {"fills": [{"color": "#FFFDE68A"}], "radius": 16}\n    },\n    "p2": {\n      "type": "box",\n      "layout": {"width": {"fill": 342}, "height": 300},\n      "decoration": {"fills": [{"color": "#FFBBF7D0"}], "radius": 16}\n    },\n    "p3": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}},\n      "props": {"text": "The end of the page.", "style": {"fontSize": 16, "color": "#FF111827"}}\n    }\n  }\n}\n```'),
      DocSection('layout-scroll-progress', 'Scroll progress', 'A reading-progress bar on an article or a long page: a `scroll` reaction on the page\'s scrolling column writes\n`\${result.fraction}` (0 at the top, 1 at the end) to a variable, and a `progressBar` (or a box\'s width factor) is\nbound to it. Put the bar outside the scrolling column (a `stack` over it, or the canvas\'s `appBar`) so it stays in\nview:\n\n```json\n"actions": [{"trigger": {"type": "scroll"},\n             "actions": [{"type": "setVariable", "variable": "readFraction", "value": "\${result.fraction}"}]}]\n```\n\nand on the bar `"bind": {"props.value": "\${readFraction}"}`. Per section instead of per page: `viewProgress` on the\nsection ([view progress](animation.md#animation-reveal-on-scroll-view-progress-sticky-effects)).'),
      DocSection('layout-a-sticky-header-or-column', 'A sticky header or column', 'A header that stays at the top while the page scrolls under it: the scrolling column\'s first child with\n`"sticky": {"offset": 0}` (CSS `position: sticky`); it is drawn above the content and is pushed on by the end of\nits parent. `\${sticky.stuck}` is true while it is pinned (bind a shadow or a smaller height to it). A `--full-page`\ncapture draws it once, in its place in the page, as a reader sees it at the top; to see it pinned, capture a window\nscrolled down (`--scroll <scrolling column id>=1200` without `--full-page`). A header fixed to the window instead (it never\nscrolls, and a full-page capture draws it once, at the top): a `stack` filling the canvas body, the scrolling column\nfirst (with a top spacer of the header\'s height) and the header after it at `"y": 0`.\n\nA comparison table with a **sticky first column** on phones is two parts side by side: a fixed column of row\nlabels, and a row of plan columns that scrolls sideways (made to scroll only on phones by a media rule on its\n`scrollable`); give each table row the same height in both. From data: [a table from one template](lists.md#lists-a-table-from-one-template).'),
      DocSection('layout-rtl', 'RTL', '`textDirection` (`"ltr"` | `"rtl"`, Flutter\'s `Directionality`) on a node lays it and everything under it out in that\ndirection; a node without one inherits the nearest above it (none: left to right). Bind it to mirror a screen for\nArabic or Hebrew from one place: `"bind": {"textDirection": "\${= uiLang == \'ar\' ? \'rtl\' : \'ltr\'}"}` on the canvas\nbody. Under right to left:\n\n- rows and wrapping rows run from the right; a column\'s `start` / `end` cross alignment is the right / left edge;\n- a text\'s `start` / `end` alignment (the default is `start`) is the right / left edge, and its lines lay out right to\n  left; `left` and `right` stay where they are;\n- padding and margin written `{"start": 16, "top": 8, "end": 4, "bottom": 8}` put the start on the right; the list\n  form `[left, top, right, bottom]` stays absolute;\n- a stack mirrors each child\'s `x` (its distance from the left becomes its distance from the right);\n- directional icons (`arrow_back`, `chevron_right`, `send`, `undo`... the Material icons Flutter declares with\n  `matchTextDirection`) mirror; other icons do not.\n\nA part that must keep its own direction inside a mirrored screen (a phrase in another script, a code) sets its own\n`textDirection`: `"bind": {"textDirection": "\${= langRtl ? \'rtl\' : \'ltr\'}"}`.'),
      DocSection('layout-a-canvas-per-breakpoint', 'A canvas per breakpoint', 'Canvases with the same `props.screen` are one screen; each sets `props.breakpoint` to the breakpoint it is for. At\na given width the screen shows the canvas whose breakpoint\'s `minWidth` is the highest at or below the width, else\nits narrowest. Each canvas has its own nodes; share state with `page_variables`. A `variance` node does the same for\none part of a screen. Older documents use this:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home-mobile", "home-desktop"],\n  "nodes": {\n    "home-mobile": {\n      "type": "canvas",\n      "name": "Home",\n      "props": {"screen": "home", "breakpoint": "mobile"},\n      "slots": {"body": "m-page"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "m-page": {\n      "type": "column",\n      "children": ["m-title", "m-size"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n      "props": {"crossAxisAlignment": "start", "spacing": 8}\n    },\n    "m-title": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 32}},\n      "props": {"text": "Stacked for phones", "style": {"fontSize": 24, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "m-size": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}},\n      "props": {\n        "text": "\${screen.breakpoint}: \${screen.width} px wide",\n        "style": {"fontSize": 14, "color": "#FF6B7280"}\n      }\n    },\n    "home-desktop": {\n      "type": "canvas",\n      "name": "Home",\n      "props": {"screen": "home", "breakpoint": "desktop"},\n      "slots": {"body": "d-page"},\n      "layout": {"width": 1440, "height": 900},\n      "decoration": {"fills": [{"color": "#FFF3F4F6"}]}\n    },\n    "d-page": {\n      "type": "row",\n      "children": ["d-title", "d-size"],\n      "layout": {"width": {"fill": 1440}, "height": {"hug": 120}, "padding": 48},\n      "props": {"mainAxisAlignment": "spaceBetween"}\n    },\n    "d-title": {\n      "type": "text",\n      "layout": {"width": {"hug": 400}, "height": {"hug": 48}},\n      "props": {"text": "Side by side on desktops", "style": {"fontSize": 40, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "d-size": {\n      "type": "text",\n      "layout": {"width": {"hug": 200}, "height": {"hug": 20}},\n      "props": {\n        "text": "\${screen.breakpoint}: \${screen.width} px wide",\n        "style": {"fontSize": 14, "color": "#FF6B7280"}\n      }\n    }\n  }\n}\n```\n\n```json\n{\n  "schema": 3,\n  "roots": ["page"],\n  "nodes": {\n    "page": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["features"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24}\n    },\n    "features": {\n      "type": "variance",\n      "children": ["stacked", "sideBySide"],\n      "layout": {"width": {"fill": 342}, "height": {"hug": 200}},\n      "props": {\n        "variants": [\n          {"id": "narrow", "name": "Narrow", "breakpoint": "mobile", "children": ["stacked"]},\n\n(Continues: layout.md#layout-a-canvas-per-breakpoint.)'),
    ],
  ),
  DocPage(
    id: 'theme',
    title: 'Theme and text',
    summary: 'A site\'s palette and type scale, declared once and named everywhere; dark mode and a type scale that changes with the screen size; and the `text` node in depth (runs, links, superscripts, fonts, text direction).',
    when: 'A site\'s palette and type scale, declared once and named everywhere; dark mode and a type scale that changes with\nthe screen size; and the `text` node in depth (runs, links, superscripts, fonts, text direction).',
    example: 'A site manifest (`site.json`) with a theme: a palette and a type scale. The page next to it names them.\n\n```json\n{\n  "schema": 3,\n  "pages": ["home.json"],\n  "theme": {\n    "primary": "ember",\n    "onPrimary": "paper",\n    "colors": {"ink": "#FF1B1B1B", "ember": "#FFE4572E", "paper": "#FFF6F1E9"},\n    "textStyles": {\n      "body": {"fontSize": 16, "height": 1.5, "color": "ink"},\n      "title": {"from": "body", "fontSize": 32, "fontWeight": 700, "height": 1.2},\n      "eyebrow": {"from": "body", "fontSize": 12, "letterSpacing": 2, "color": "ember"}\n    },\n    "media": [{"minWidth": 1024, "patch": {"textStyles": {"title": {"fontSize": 56}}}}]\n  }\n}\n```\n\nA page using it (a fragment of `home.json`\'s `nodes`):\n\n```json\n"eyebrow": {"type": "text", "props": {"text": "OUR MENU", "style": "eyebrow"}, "layout": {"width": {"fill": 342}, "height": {"hug": 18}}},\n"title":   {"type": "text", "props": {"text": "Fire, smoke and season", "style": "title"}, "layout": {"width": {"fill": 342}, "height": {"hug": 40}}},\n"note":    {"type": "text", "props": {"text": "Cooked over oak.", "style": {"from": "body", "color": "ember"}}, "layout": {"width": {"fill": 342}, "height": {"hug": 24}}},\n"rule":    {"type": "box", "layout": {"width": 120, "height": 4}, "decoration": {"fills": [{"color": "ember"}]}}\n```',
    pitfalls: '- A text without a color is white (`text_no_color` when rendered): set it in the style or the named style.\n- A name the theme does not have names nothing: write one the theme has. Without a `site.json`, put the page in a folder with one: `{"schema": 3, "pages": ["home.json"],\n  "theme": {...}}`.\n- A theme color\'s name is not read from a formula: bind `\${theme.colors.ember}`.\n- Run offsets count characters, `\\n` as one.',
    words: 3239,
    items: ['text', 'textDirection', 'defaultTextStyle', 'linkTap', 'setThemeMode'],
    sections: [
      DocSection('theme-theme-keys', 'Theme keys', 'The theme (`site.json`\'s `theme`, or the app\'s theme at run time):\n\n| Key | Meaning |\n|---|---|\n| `colors` | Every named color of the project by key (`themeKey` of its name: "Brand Blue" is `brandBlue`), read as `\${theme.colors.brandBlue}`. |\n| `textStyles` | Every named text style by key, read as `\${theme.text.title.fontSize}` and named by a text\'s style (`"style": "title"`, or `{"from": "title", ...}` to change some of its fields). A style may itself start `from` another and name `colors`; `textStyle` gives it resolved. |\n| `dark` | The colors for dark mode: the tokens and `colors` that differ from the light ones (its other fields are not used). |\n| `media` | The theme by screen size, as CSS media queries over custom properties: each rule\'s `patch` is a theme\'s JSON (`{"textStyles": {"display": {"fontSize": 40}}, "colors": {...}}`) merged over this one while the screen meets its conditions (`atScreen`). A type scale that changes at a breakpoint is written once here, not on every text. |\n| `primary` | Primary buttons and info toasts. |\n| `onPrimary` | Text on `primary`. |\n| `surface` | Dialog backgrounds. |\n| `onSurface` | Text on `surface`. |\n| `error` | Destructive buttons and error toasts. |\n| `success` | Success toasts. |\n| `warning` | Warning toasts. |\n| `fontFamily` | Font family of body text and buttons. |\n| `titleFontFamily` | Font family of titles. |\n| `radius` | Corner radius of dialogs. |\n| `buttonRadius` | Corner radius of buttons. |\n| `spacing` | The spacing scale: gaps and paddings by name (`{"1": 4, "2": 8, "3": 12}` or `{"sm": 8, "md": 16}`), read as `\${theme.spacing.md}`. Flutter has no spacing token; a design system names its steps here. |\n| `radii` | Corner radii by name (`{"control": 7, "panel": 8, "dialog": 12}`; Flutter\'s `Radius.circular`), read as `\${theme.radii.panel}`. |\n| `sizes` | Other lengths by name: a control scale\'s heights (`{"compact": 28, "large": 44}`), icon sizes, a panel\'s width; read as `\${theme.sizes.compact}`. |\n| `shadows` | Shadows by name (Flutter\'s `BoxShadow` lists, as `kElevationToShadow` gives one per elevation): each a list of drop shadows as `decoration.effects` takes them, read as `\${theme.shadows.level3}`. `dark` may give other shadows for dark mode. |\n| `durations` | Durations in milliseconds by name (Flutter\'s `Durations`: `short2`, `medium1`...; a design system\'s own names), read as `\${theme.durations.medium}`. |\n| `curves` | Easing curves by name (Flutter\'s `Curves`: `easeOut`, `easeInOut`...), read as `\${theme.curves.standard}`. |'),
      DocSection('theme-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-linkTap"></a>`linkTap` | A link in a text was tapped: a run of its `runs` with a `link` (`TextRun.link`). `\${result.link}` is the run\'s link, `\${result.text}` its characters, `\${result.start}` and `\${result.end}` where they are in the text. Without this reaction the tap opens the link (a web page, `mailto:`, `tel:`, an app link), as `openLink` does; with it, its actions run instead (a run whose link names something of the app\'s own: `link="restart"`). |'),
      DocSection('theme-named-colors-and-styles', 'Named colors and styles', '- **Colors**: `colors` maps a name to `"#AARRGGBB"` (or to another color\'s name: `"accent": "ember"`). Wherever a\n  color is accepted, write its name. The roles `primary`, `onPrimary`, `surface`, `onSurface`, `error`, `success`,\n  `warning` (keys of the theme) are names too.\n- **Text styles**: `textStyles` maps a name to a TextStyle. A style may start `from` another and name colors. A\n  text names its style in one field, `"style": "title"`; to change some fields of it, `"style": {"from": "title",\n  "color": "ember"}` (`textTheme.titleLarge.merge(...)`: the fields written win). Runs, a button\'s `textStyle` and\n  an input\'s styles take the same two forms.\n- Changing a color or style in the theme changes every node that names it, and only those.\n- In a binding a name is not read: bind the value, `"\${theme.colors.ember}"` or `"\${theme.text.title}"`; inside\n  a formula, `\${= done ? theme.colors.sage : theme.colors.mist}`.'),
      DocSection('theme-what-controls-take-from-the-theme', 'What controls take from the theme', 'A control\'s colors, fonts and shapes that its props leave unset come from the theme: `primary` fills filled buttons\n(labeled in `onPrimary`) and draws checks, thumbs, focus rings and text-button labels where it reads on `surface`\n(else `onSurface` does); `fontFamily` is every control label\'s font (`titleFontFamily` titles\'); `buttonRadius`\nshapes every kind of button and chip, `radius` dialogs, menus, pickers and fields. Without a theme, controls are\nneutral: ink on paper (near-black on white; near-white on near-black in dark mode) and the greys between, in no font\nof their own, and plain in shape: buttons and chips of a 6 px radius (not a stadium), fields and dropdowns outlined\nwith their label as the placeholder (no underline, no floating label), date and time pickers plain fields, a\nswitch with one thumb size, tabs with a square underline, dialogs and menus of an 8 px radius with a hairline\nborder. Gauges, charts, barcodes, signature pads, tab bars and pagination take their unset colors from the theme\ntoo: values and lines `primary`, tracks and grids `outlineVariant`, ticks and axes `outline`, labels\n`onSurfaceVariant`, needles, cursors and tooltips `onSurface`. Nothing comes from Material\'s defaults (no purple,\nripples, elevation or stadium shapes) or from the host app\'s theme.'),
      DocSection('theme-spacing-radii-sizes-shadows-and-motion', 'Spacing, radii, sizes, shadows and motion', 'The theme names its scales as it names colors: `"spacing": {"1": 4, "2": 8, "3": 12}`, `"radii": {"control": 7,\n"panel": 8}`, `"sizes": {"compact": 28, "large": 44}`, `"shadows": {"level3": [{"type": "dropShadow", ...}]}` (with\n`dark` shadows of their own), `"durations": {"fast": 150}` (milliseconds) and `"curves": {"standard": "easeInOut"}`.\nA node reads a step in a binding, `"bind": {"layout.padding": "\${theme.spacing.3}", "decoration.radius":\n"\${theme.radii.panel}", "decoration.effects": "\${theme.shadows.level3}"}`; a name the theme does not have\nnames nothing. A [design system](design-systems.md#page-design-systems) brings a whole set of them. The theme\'s `radius` and\n`buttonRadius` shape the controls (dialogs and fields, buttons and chips); without them controls take small radii\nof their own (6 and 8).'),
      DocSection('theme-a-type-scale-that-changes-with-the-screen-size', 'A type scale that changes with the screen size', 'The theme\'s `media` rules patch the theme as a node\'s rules patch a node: `{"minWidth": 1024, "patch":\n{"textStyles": {"title": {"fontSize": 56}}}}` makes every text using `title` grow at desktop width, written once. A\nnode\'s own media rule may switch its style (`"patch": {"props": {"style": "caption"}}`, which replaces the style)\nor change some fields (`{"style": {"fontSize": 20}}`, merged over the named style).'),
      DocSection('theme-what-the-notation-s-page-words-read', 'What the notation\'s page words read', 'A theme may name what the notation\'s words draw in, beside its roles: a text style `<look>Page` beside `<look>`\n(`heading1Page`, `leadPage`, `bodyPage`) is what a text of that look takes on a website\'s page (under `Page`),\nits size, line height and spacing; `colors.card` is the ground of a card and `colors.selectedRow` the fill of a\nchosen row (the accent\'s tint without it); a band of a page takes a picture as its ground (`Section image="…"`,\nunder a scrim). [Design systems](design-systems.md#page-design-systems) says how a site\'s roles reach them.'),
      DocSection('theme-dark-mode', 'Dark mode', '`"dark": {"colors": {"ink": "#FFEEEEEE"}}` gives the colors (and roles: `surface`, `primary`...) that differ in\ndark mode; everything naming `ink` follows the mode: fills, strokes, named text styles (a style whose `color` is\n`"ink"`), and the controls, which take the theme\'s roles. A style with a literal color (`"#FF111111"`) does not\nchange: name the color.\n\nWhich mode shows is the theme\'s `mode` (Flutter\'s `ThemeMode`, as `MaterialApp.themeMode`): `system` (the default:\nthe device\'s setting), `light` or `dark`. A site that is dark by design says `"mode": "dark"` in its theme and\nopens dark everywhere: in an app, in a session\'s view, in a render and in the editor, whatever the device\'s\nsetting. A site\'s own switch is one action:\n\n```json\n{"type": "setThemeMode", "mode": "\${= theme.isDark ? \'light\' : \'dark\'}"}\n```\n\n`mode` is an expression giving `system`, `light` or `dark`. Every screen of the site redraws at once, the next page\nopens in the same mode, and with `persist` (the default) the choice is kept in the site\'s local storage, so a\nreload starts in it; `"persist": false` keeps it for this visit only. `\${theme.mode}` reads the mode chosen and\n`\${theme.isDark}` (also `\${screen.isDark}`) whether the screen is dark; bind a switch\'s value to\n`\${theme.isDark}` to show it. A theme without `dark` stays as designed in dark mode (its colors and controls light),\nwhile `\${theme.isDark}` still says dark (`\${theme.hasDark}` is false), so a page may choose its own colors.\n\nThe render command captures either: `--theme light` or `--theme dark` (the PNG names end `-light`, `-dark`), and a\n`--tap` on the switch afterwards captures the other.'),
      DocSection('theme-text', 'Text', 'A `text` node has `props.text` and `props.style`. What a text looks like when the style leaves something out: no\n`color`, white; no `fontSize`, 12; no `fontWeight`, 400; no `fontFamily`, the platform\'s default (Roboto on Android\nand the web); no `height`, the nearest `defaultTextStyle`\'s (a node key, Flutter\'s `DefaultTextStyle`, for its\nwhole subtree), else the font\'s own line height. Sizing: one line `{"hug": n}` × `{"hug": n}`; a paragraph `{"fill": n}` wide × `{"hug": n}` high. A\nfixed height shorter than the lines clips them (`text_clipped`).\n\n`runs` style parts of the text: `[{"start": 0, "end": 5, "style": {"fontWeight": 700}}]` (character offsets, end\nexclusive, `\\n` counting as one), merged over `style`; a run may carry a `"link"` URL. Offsets count the text as\nwritten, an expression keeping its run; a run that starts or ends inside a `\${...}` counts the text as shown instead,\nso a drop cap on a bound paragraph (`"text": "\${= story.lead}"`) is `{"start": 0, "end": 1}`. A literal `\$` right before an\nexpression is text: `"\$\${price}"` shows `\$47`. There is no escape for a literal `\${`: compute it.'),
      DocSection('theme-superscripts-and-a-raised-currency-sign', 'Superscripts and a raised currency sign', 'A raised or lowered character (a price\'s "\$", a footnote mark): a run with `"fontFeatures": ["sups"]` (or `"subs"`)\nwhen the font has those OpenType features; otherwise a smaller `fontSize` in a row of texts aligned\n`crossAxisAlignment: start` (or `baseline`) for the exact shift.'),
      DocSection('theme-fonts', 'Fonts', '`style.fontFamily` names a family (`"Inter"`), with `fontWeight` and `fontStyle` choosing the file. A site declares\nthe families it ships in `site.json`, in the shape of a Flutter pubspec\'s `fonts:` section, the files beside it:\n\n```json\n{\n  "schema": 3,\n  "pages": ["home.json"],\n  "fonts": [\n    {"family": "Fraunces", "fonts": [\n      {"asset": "fonts/fraunces-latin-400-normal.woff"},\n      {"asset": "fonts/fraunces-latin-700-normal.woff", "weight": 700},\n      {"asset": "fonts/fraunces-latin-400-italic.woff", "style": "italic"}\n    ]}\n  ],\n  "theme": {"fontFamily": "Fraunces", "textStyles": {"body": {"fontFamily": "Fraunces", "fontSize": 17}}}\n}\n```\n\n- `family` is the name text styles use, whatever the file calls itself; each file has a `weight` (100–900, default\n  400) and a `style` (`normal` or `italic`).\n- A **variable font** (one file with a `wght` axis, `RobotoSlab[wght].ttf`) is declared **once**, without a weight:\n  it draws every weight of its axis (Flutter sets the axis from `fontWeight`), and the render command counts each\n  of them as declared. Listing the same file again per weight is not needed.\n- Files are `.ttf`, `.otf` or `.woff` (an npm `@fontsource/<family>` package\'s `files/` folder has a `.woff` beside\n  each `.woff2`). WOFF2 is not read; a declared file that is not there is `font_missing`.\n- The render command loads them with no flag, before the page shows; a published site loads them from its files.\n- A family a text style names that no file provides is `font_fallback`, naming the nodes that use it: declare it,\n  or pass `--fonts <dir>` (`--fonts system` for the system\'s fonts). A family nobody declared is fetched by name\n  from Google Fonts in an app.\n\nCharacters the font has no glyph for draw as empty boxes (`missing_glyph`): use an `icon`.'),
    ],
  ),
  DocPage(
    id: 'decoration',
    title: 'Decoration, images, icons and drawing',
    summary: 'What a node\'s box paints beyond the base: gradients, pixel patterns and grain, borders on some sides, shadows and blurs, scrims over children, images, icons, SVG-like paths and custom drawing.',
    when: 'What a node\'s box paints beyond the base: gradients, pixel patterns and grain, borders on some sides, shadows and\nblurs, scrims over children, images, icons, SVG-like paths and custom drawing.',
    example: 'A card with a solid fill, a border, rounded corners and a shadow, and a gradient band:\n\n```json\n{\n  "schema": 3,\n  "roots": ["deco"],\n  "nodes": {\n    "deco": {\n      "type": "canvas",\n      "slots": {"body": "row"},\n      "layout": {"width": 520, "height": 200},\n      "decoration": {"fills": [{"color": "#FFF9FAFB"}]}\n    },\n    "row": {\n      "type": "row",\n      "children": ["card", "gradient", "outlined"],\n      "layout": {"width": {"fill": 520}, "height": {"fill": 200}, "padding": 24},\n      "props": {"spacing": 24, "mainAxisAlignment": "center"}\n    },\n    "card": {\n      "type": "box",\n      "layout": {"width": 140, "height": 120},\n      "decoration": {\n        "fills": [{"color": "#FFFFFFFF"}],\n        "radius": 12,\n        "effects": [{"type": "dropShadow", "color": "#33000000", "offset": [0, 4], "blurRadius": 16}]\n      }\n    },\n    "gradient": {\n      "type": "box",\n      "layout": {"width": 140, "height": 120},\n      "decoration": {\n        "fills": [\n          {\n            "type": "radial",\n            "stops": [{"position": 0, "color": "#FFFDE68A"}, {"position": 1, "color": "#FFF97316"}]\n          }\n        ],\n        "radius": [24, 4, 24, 4]\n      }\n    },\n    "outlined": {\n      "type": "box",\n      "layout": {"width": 140, "height": 120},\n      "decoration": {"strokes": [{"color": "#FF2563EB"}], "strokeWidth": 2, "dashPattern": [6, 4], "radius": 12}\n    }\n  }\n}\n```',
    pitfalls: '- An effect needs its `type`; without it the effect is dropped.\n- Colors are `"#AARRGGBB"`, `"#RRGGBB"` or a theme name; `"#FFF"`, `rgb()` and CSS names are not read.\n- A `path` node without a `viewBox` is drawn in its box\'s own pixels from the top left and is not clipped to the\n  box (as Flutter\'s `CustomPaint`): give it a `viewBox` to scale it, or clip an ancestor (`path_overflow`).\n- Decoration on a type that draws no box (a `text`, a `listView`) is ignored: wrap it.\n- `clip` is needed for children to follow rounded corners.\n- A child\'s fill covers its parent\'s inside border: pad the parent, stroke outside, or move the border to the child.',
    words: 4582,
    items: ['icon', 'path', 'customPaint', 'imageLoading', 'imageLoaded', 'imageError'],
    sections: [
      DocSection('decoration-decoration-fields', 'Decoration fields', 'A node\'s `"decoration"`: what its box paints. Types without a box decoration keep only blur effects. Fills paint\nbottom to top under the node\'s content; `foregroundFills` paint over it, children included. Every color may be a\ntheme color\'s name.\n\n| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `fills` | List<[Paint](decoration.md#type-Paint)> | `[]` |  | Paints for the box, bottom to top: a color, a gradient, an image or noise. |\n| `strokes` | List<[Paint](decoration.md#type-Paint)> | `[]` |  | Paints for the border, drawn `strokeWidth` wide. |\n| `strokeWidth` | double | `1` | ≥ 0 | The border\'s width in pixels. Without `strokes` it draws nothing. |\n| `strokeAlign` | [StrokeAlign](values.md#enum-StrokeAlign) | `"inside"` | `inside`, `center`, `outside` |  |\n| `strokeSides` | [StrokeSides](values.md#enum-StrokeSides) | `"all"` |  | Which sides the border is drawn on: `all`, `top`, `bottom`, `left`, `right`, `topBottom`, `leftRight`... |\n| `strokeCap` | [StrokeCap](values.md#enum-StrokeCap) | `"butt"` | `butt`, `round`, `square` |  |\n| `dashPattern` | List<double> | `[]` |  | Dash and gap lengths, alternating; empty is a solid stroke. |\n| `radius` | [BorderRadius](values.md#type-BorderRadius) | `0` |  |  |\n| `effects` | List<[Effect](decoration.md#type-Effect)> | `[]` |  | Shadows and blurs: each `{"type": "dropShadow" \\| "innerShadow" \\| "layerBlur" \\| "backgroundBlur", ...}`. |\n| `clip` | [Clip](values.md#enum-Clip) | `"none"` | `none`, `hardEdge`, `antiAlias`, `antiAliasWithSaveLayer` | Clips the content to the box (rounded by `radius`). |\n| `blendMode` | [BlendMode](values.md#enum-BlendMode) | `"srcOver"` |  |  |\n| `foregroundFills` | List<[Paint](decoration.md#type-Paint)> | `[]` |  | Fills painted over the content. |\n| `shape` | [DecorationShape](values.md#enum-DecorationShape) | `"rectangle"` | `rectangle`, `circle` | A rectangle (rounded by `radius`) or a circle. |\n| `clipPath` | String | unset |  | The node cut to a path, as CSS `clip-path` and Flutter\'s `ClipPath`, whatever the node is (a box, a text, an icon, a picture, a control): SVG path data in `clipViewBox`\'s units mapped by `clipFit`; with neither, the box\'s unit square, 0 to 1 across and down whatever its size, so one curve fits every width. What it paints and its children are cut, its border is drawn along the path (inside) and its shadow takes its shape; a pointer outside it passes through. A header whose foot is a wave: `clipPath="M0 0 H1 V0.8 C0.75 1 0.25 0.6 0 0.85 Z"`. |\n| `clipViewBox` | [Rect](values.md#type-Rect) | unset |  | The units `clipPath` is written in, `[width, height]` or `[minX, minY, width, height]`, as a `customPaint`\'s `viewBox`, mapped onto the box by `clipFit`. Unset: the unit square, or with `clipFit=none` the box\'s pixels. |\n| `clipFit` | [BoxFit](values.md#enum-BoxFit) | `"fill"` | `fill`, `contain`, `cover`, `fitWidth`, `fitHeight`, `none`, `scaleDown` | How `clipViewBox` maps onto the box, as a `customPaint`\'s `fit`: `fill` stretches it, `contain` keeps its aspect, `none` keeps its units pixels (without a view box: the box\'s own pixels from its top left). |\n\n(Continues: decoration.md#decoration-decoration-fields.)'),
      DocSection('decoration-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-imageLoading"></a>`imageLoading` | A node\'s image fill started loading, became ready, or failed. `\${result.url}` identifies the image and `\${result.status}` is `loading`, `loaded`, or `error`. Cached images can report loaded immediately without a loading event. |\n| <a id="trigger-imageLoaded"></a>`imageLoaded` |  |\n| <a id="trigger-imageError"></a>`imageError` |  |'),
      DocSection('decoration-gradients', 'Gradients', 'As Flutter\'s `LinearGradient`, a linear gradient runs from `"begin"` to `"end"` (alignments; default left to\nright; `[0, -1]` to `[0, 1]` is top to bottom). As `RadialGradient`, a radial one has a `"center"` and a `"radius"`\n(a share of the box\'s shortest side); past the last stop it keeps that stop\'s color, so end a glow on a transparent\nstop. `transform` is the general form. A paint without `type` is an image if it has `image`, a linear gradient if it\nhas `stops`, else a solid color.'),
      DocSection('decoration-a-pattern-in-pixels-a-background-grid-grain', 'A pattern in pixels, a background grid, grain', '**A pattern in pixels** (CSS `repeating-linear-gradient(to bottom, #E5E7EB 0 1px, transparent 1px 80px)`): a\nlinear gradient with `"length": 80` (px from `begin` toward `end`) and `"tileMode": "repeated"`; a background grid is\ntwo of them, one `topCenter` → `bottomCenter`, one `centerLeft` → `centerRight`.\n\n```json\n"fills": [\n  {"type": "linear", "begin": "topCenter", "end": "bottomCenter", "length": 80, "tileMode": "repeated",\n   "stops": [{"position": 0, "color": "#14FFFFFF"}, {"position": 0.0125, "color": "#14FFFFFF"}, {"position": 0.0125, "color": "#00FFFFFF"}, {"position": 1, "color": "#00FFFFFF"}]},\n  {"type": "linear", "begin": "centerLeft", "end": "centerRight", "length": 80, "tileMode": "repeated",\n   "stops": [{"position": 0, "color": "#14FFFFFF"}, {"position": 0.0125, "color": "#14FFFFFF"}, {"position": 0.0125, "color": "#00FFFFFF"}, {"position": 1, "color": "#00FFFFFF"}]}\n]\n```\n\n**Grain**: `{"type": "noise", "noise": {"baseFrequency": 0.8, "numOctaves": 3, "seed": 1}, "color": "#FF000000",\n"opacity": 0.08}`, SVG\'s `feTurbulence` as a paint (a seamless tile repeated over the box; `blendMode` as CSS\n`mix-blend-mode`).'),
      DocSection('decoration-borders-rules-and-shadows', 'Borders, rules and shadows', 'A node\'s border is painted with its own box, **under its children**: a child with a fill covers an `inside` border\n(the default). Give the parent padding of the border\'s width, set `"strokeAlign": "outside"`, or put the border (or\nthe rule) on the filled child. `strokes` with `strokeWidth` (default 1), `strokeAlign` (`inside`, `center`, `outside`), `strokeSides` (`all`,\n`bottom`, `topBottom`...) and `dashPattern` (`[6, 4]`). A rule under a text: the text inside a `row` or `column`\nwith `"strokes": [{"color": ...}], "strokeSides": "bottom"`, or a `box` 1 high. `strokeWidth` without `strokes`\ndraws nothing. Effects: `dropShadow`, `innerShadow`, `layerBlur`, `backgroundBlur` (frosted glass), each with\n`color`, `offset`, `blurRadius`, `spreadRadius`.'),
      DocSection('decoration-a-scrim-over-a-photo', 'A scrim over a photo', '`foregroundFills` paint over the node **and its children**, as Flutter\'s `foregroundDecoration`: a scrim there\ndarkens a caption inside the node too. For a caption over a photo, paint the photo in `fills` and put the darkening\ngradient on a child `box` before the caption (a stack: photo box, gradient box, caption text), or on the photo\nbox\'s `foregroundFills` when the caption is a sibling painted after it.'),
      DocSection('decoration-images', 'Images', 'Images are image fills: `{"type": "image", "image": {"url": "...", "fit": "cover"}}` in `decoration.fills` of a box\n(give the box the image\'s size or an `aspectRatio`), placed as Flutter\'s `DecorationImage` places them: `fit` is a\n`BoxFit` (`cover`, `contain`, `fill`, `fitWidth`, `fitHeight`, `none`, `scaleDown`) and `alignment` an `Alignment`\n(`[0, -0.3]` keeps a face in a cropped photo). The `url` is one of:\n\n- **a file beside the site**, by its path relative to `site.json`\'s folder (`"images/hero.jpg"`, as a Flutter app\n  names an asset): PNG, JPEG, WebP, GIF, BMP or SVG. The render command reads it from the folder; a published site\n  from its files. A path that names no file is `image_failed`, naming it. Use this for photos and illustrations.\n- `https://...`: loaded by the app; the render command does not fetch it (`image_network`).\n- `data:image/...` (an SVG may be written inline as `data:image/svg+xml;utf8,<svg ...>`, URL-encoded).\n\nFills stack, first at the bottom: a photo with a gradient scrim over it, so text reads on it, is two fills:\n\n```json\n{\n  "schema": 3,\n  "roots": ["story"],\n  "nodes": {\n    "story": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 320},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["card"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 320}, "padding": 24}\n    },\n    "card": {\n      "type": "column",\n      "children": ["kicker", "headline"],\n      "layout": {"width": {"fill": 342}, "height": 240, "padding": 20},\n      "props": {"mainAxisAlignment": "end", "crossAxisAlignment": "start", "spacing": 6},\n      "decoration": {\n        "radius": 16,\n        "clip": "antiAlias",\n        "fills": [\n          {"type": "image", "image": {"url": "assets/photo.png", "fit": "cover", "alignment": [0, -0.3]}},\n          {\n            "type": "linear",\n            "begin": [0, -1],\n            "end": [0, 1],\n            "stops": [{"color": "#00000000", "position": 0.35}, {"color": "#CC000000", "position": 1}]\n          }\n        ]\n      }\n    },\n    "kicker": {\n      "type": "text",\n      "layout": {"width": {"fill": 302}, "height": {"hug": 16}},\n      "props": {\n        "text": "TRAVEL",\n        "style": {"fontSize": 12, "fontWeight": 700, "letterSpacing": 2, "color": "#FFFDE68A"}\n      }\n    },\n    "headline": {\n      "type": "text",\n      "layout": {"width": {"fill": 302}, "height": {"hug": 56}},\n      "props": {\n        "text": "A week on the salt marsh, by boat and on foot",\n        "style": {"fontSize": 20, "fontWeight": 700, "height": 1.3, "color": "#FFFFFFFF"}\n      }\n    }\n  }\n}\n```'),
      DocSection('decoration-illustration', 'Illustration', 'Three ways to draw art without a photo, each scaled to its box:\n\n- **An SVG file** (`images/hills.svg`) as an image fill: drawn as vectors at any size, `fit` and `alignment` as\n  for a photo. For a single shape or mark, a `path` node with SVG path data and a `viewBox`.\n\n```json\n{\n  "schema": 3,\n  "roots": ["hero"],\n  "nodes": {\n    "hero": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 340},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["art", "badge"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 340}, "padding": 24},\n      "props": {"spacing": 12}\n    },\n    "art": {\n      "type": "box",\n      "layout": {"width": {"fill": 342}, "height": 214},\n      "decoration": {\n        "radius": 12,\n        "clip": "antiAlias",\n        "fills": [{"type": "image", "image": {"url": "assets/hills.svg", "fit": "cover"}}]\n      }\n    },\n    "badge": {\n      "type": "path",\n      "layout": {"width": 48, "height": 48},\n      "props": {\n        "data": "M12 2 L15 9 L22 9 L16.5 13.5 L18.5 21 L12 16.5 L5.5 21 L7.5 13.5 L2 9 L9 9 Z",\n        "viewBox": [24, 24]\n      },\n      "decoration": {"fills": [{"color": "#FFF4B740"}]}\n    }\n  }\n}\n```\n\n- **`customPaint`**: draw lists in a view box, Flutter\'s `Canvas` calls as data (`rect`, `circle`, `path` with SVG\n  data, `line`, `repeat` over a count with `\${index}`), over the node\'s own fill and border and\n  under its children (`painter`), or over them (`foregroundPainter`). Values may be expressions, so a drawing can follow data. It is not\n  clipped by the box\'s `radius`: round a parent with `clip` for that.\n\n```json\n{\n  "schema": 3,\n  "roots": ["hero"],\n  "nodes": {\n    "hero": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 260},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["scene"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 260}, "padding": 24}\n    },\n    "scene": {\n      "type": "box",\n      "layout": {"width": {"fill": 342}, "height": 212},\n      "customPaint": {\n        "viewBox": [320, 200],\n        "fit": "cover",\n        "painter": [\n          {"op": "rect", "rect": [0, 0, 320, 200], "paint": "#FFE8F1F8"},\n          {"op": "circle", "c": [236, 62], "radius": 28, "paint": "#FFF4B740"},\n          {\n            "op": "repeat",\n            "count": 3,\n            "ops": [\n              {\n                "op": "circle",\n                "c": ["\${= 60 + index * 34}", "\${= 48 + index * 6}"],\n                "radius": 3,\n                "paint": "#FF5D6D7E"\n              }\n            ]\n          },\n          {\n            "op": "path",\n            "d": "M0 150 C60 100 120 110 170 140 C220 170 270 120 320 130 L320 200 L0 200 Z",\n            "paint": "#FF7FB685"\n          },\n          {\n            "op": "path",\n            "d": "M0 170 C80 140 160 160 220 175 C260 185 290 170 320 165 L320 200 L0 200 Z",\n            "paint": "#FF3E7C59"\n          },\n          {\n            "op": "line",\n            "p1": [40, 196],\n\n(Continues: decoration.md#decoration-illustration.)'),
      DocSection('decoration-icons', 'Icons', 'An `icon` node with `props.icon` set to a Material icon name (`"check_circle"`, `"menu"`, `"north_east"`; any name\nat fonts.google.com/icons; `_outlined`, `_rounded`, `_sharp` pick the style), `props.color` and `props.size` (the\nglyph\'s size, centered in the node\'s box; without it the glyph fills the box). A text field\'s\n`decoration.prefixIcon` is `{"icon": "search", "size": 18}`. A name the renderer does not know draws nothing\n(`icon_not_drawn`).'),
      DocSection('decoration-small-marks-and-shapes', 'Small marks and shapes', 'A mark the font lacks (✦, ✳): an `icon` (`"auto_awesome"`, `"star"`), or a `path` node with SVG path data and a\n`viewBox` so it scales to its box: the one decorated shape (fills, strokes and shadows from its `decoration`). Custom\ndrawing beyond one path (several shapes, a line through points, shapes in different colors, text on a canvas): the\n`customPaint` behavior\'s draw lists, behind or over the node\'s content. A line through points is a `path` op with\n`points` (a formula of `\${size.width}` for a share of the box), or with `commands` (Flutter\'s `Path` calls:\n`moveTo`, `lineTo`, `quadraticBezierTo`, `cubicTo`, `close`) for curves; shapes in different colors are one `path`\nop per color.'),
    ],
  ),
  DocPage(
    id: 'forms',
    title: 'Buttons, forms and inputs',
    summary: 'Buttons, text fields, checkboxes, switches, radios, sliders, dropdowns, segmented buttons, date and time pickers, chips and signatures: every control\'s props, **how to style each one (in one place, below)**, two-way binding to a variable, validation and error states, focus and the keyboard.',
    when: 'Buttons, text fields, checkboxes, switches, radios, sliders, dropdowns, segmented buttons, date and time pickers,\nchips and signatures: every control\'s props, **how to style each one (in one place, below)**, two-way binding to a\nvariable, validation and error states, focus and the keyboard.',
    example: 'An email field stored in a variable on every change, an error shown after a failed send, and a thank-you after a\ngood one:\n\n```json\n{\n  "schema": 3,\n  "roots": ["contact"],\n  "nodes": {\n    "contact": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 500},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["email", "emailError", "send", "thanks"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 500}, "padding": 24},\n      "props": {"spacing": 8, "crossAxisAlignment": "start"}\n    },\n    "email": {\n      "type": "textField",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 28}},\n      "props": {"decoration": {"labelText": "Email", "hintText": "you@example.com"}, "keyboardType": "emailAddress"},\n      "actions": [\n        {\n          "trigger": {"type": "changed"},\n          "actions": [{"type": "setVariable", "variable": "email", "value": "\${result}"}]\n        }\n      ]\n    },\n    "emailError": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 18}},\n      "props": {"text": "Enter a valid email address.", "style": {"fontSize": 13, "color": "#FFDC2626"}},\n      "bind": {"visible": "\${= tried && !contains(email, \'@\')}"}\n    },\n    "send": {\n      "type": "elevatedButton",\n      "layout": {"width": {"hug": 120}, "height": 44},\n      "props": {"label": "Send"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {"type": "setVariable", "variable": "tried", "value": "true"},\n            {\n              "type": "if",\n              "condition": {"left": "\${= contains(email, \'@\')}", "op": "isTrue"},\n              "then": [{"type": "setVariable", "variable": "sent", "value": "true"}]\n            }\n          ]\n        }\n      ]\n    },\n    "thanks": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}},\n      "props": {"text": "Thanks! We\'ll reply within a day.", "style": {"fontSize": 15, "color": "#FF16A34A"}},\n      "bind": {"visible": "\${sent}"}\n    }\n  },\n  "variables": {\n    "contact": [\n      {"name": "email", "type": "text", "value": ""},\n      {"name": "tried", "type": "boolean", "value": false},\n      {"name": "sent", "type": "boolean", "value": false}\n    ]\n  }\n}\n```',
    pitfalls: '- A button\'s text is `label`, not `text`; its colors are in `style`, not `decoration`.\n- An input does nothing with its value until a `changed` reaction stores it, or its value prop is bound.\n- `\${result}` in a `changed` chain is the new value until an action that gives a value replaces it; `setVariable`\n  does not.\n- Every action key is written flat in the action; a misspelled one is dropped.\n- A `validator` reads the field\'s text as `value`, not the variable the field is bound to; it goes in `props`, not\n  `bind`.\n- With `autovalidateMode` `disabled` (the default) a validator shows nothing until its form is validated: give the\n  form, or the field, a mode, or run `validate` on send.',
    words: 14168,
    items: ['filledButton', 'elevatedButton', 'outlinedButton', 'textButton', 'iconButton', 'floatingActionButton', 'textField', 'checkbox', 'switch', 'radio', 'slider', 'splitter', 'calendar', 'dropdown', 'segmentedButton', 'datePicker', 'timePicker', 'dateTimeInput', 'signature', 'chip', 'actionChip', 'choiceChip', 'filterChip', 'inputChip', 'form', 'radioGroup', 'changed', 'changeEnd', 'changeStart', 'submitted', 'deleted', 'editingComplete', 'focusGained', 'focusLost', 'keyDown', 'keyUp', 'editText', 'focus', 'validate'],
    sections: [
      DocSection('forms-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-changed"></a>`changed` | An input\'s value changed (typed text, a toggled checkbox, a slider step, a picked item). `\${result}` is the new value (a text field\'s: its text, word and selection). |\n| <a id="trigger-changeEnd"></a>`changeEnd` | A slider was let go, with its final value. |\n| <a id="trigger-changeStart"></a>`changeStart` | A slider was taken (a drag or a press on it began, or a key moves it), with its value before the change (Flutter\'s `onChangeStart`). |\n| <a id="trigger-submitted"></a>`submitted` | A text field was submitted from the keyboard. |\n| <a id="trigger-deleted"></a>`deleted` | An input chip\'s delete icon was tapped, or Delete or Backspace pressed on it (Flutter\'s `onDeleted`). |\n| <a id="trigger-editingComplete"></a>`editingComplete` | A text field lost focus after editing. |\n| <a id="trigger-focusGained"></a>`focusGained` | A text field gained or lost focus. |\n| <a id="trigger-focusLost"></a>`focusLost` |  |\n| <a id="trigger-keyDown"></a>`keyDown` | A key went down (or up) while the screen shows; `Trigger.key` limits it to one key or combination, `Trigger.when` to while a formula holds. `\${result.key}`, `\${result.shift}`, `\${result.alt}`, `\${result.meta}`. |\n| <a id="trigger-keyUp"></a>`keyUp` |  |'),
      DocSection('forms-styling-the-controls-in-one-place', 'Styling the controls, in one place', '| Control | Its look | Where |\n|---|---|---|\n| `textField` | label, hint, helper and error texts and their styles; border (`"border": {"type": "outline", "borderSide": {"color": ..., "width": 1}, "borderRadius": 8}`), `enabledBorder`, `focusedBorder`, `errorBorder`, `focusedErrorBorder`; `fillColor` + `filled`; `contentPadding`; `prefixIcon` / `suffixIcon`, `prefixText` / `suffixText` | `props.decoration` ([InputDecoration](#type-InputDecoration), [InputBorder](#type-InputBorder), [InputIcon](#type-InputIcon)) |\n| `textField` | the typed text\'s style (`style`), alignment, the caret (`cursorColor`, `showCursor`), the focus ring (`focusRingColor`, `focusRingWidth`) | `props` ([textField](#node-textField)) |\n| buttons | `backgroundColor`, `foregroundColor`, `textStyle` (the label\'s size and weight), `shape` (`{"type": "roundedRectangle", "borderRadius": 10}`), `side` (border), `padding`, `elevation` | `props.style` ([ButtonStyle](#type-ButtonStyle)) |\n| `checkbox` | `activeColor`, `checkColor`, `fillColor`, `side` / `activeSide` (the box\'s border), `borderRadius`, `compact` | `props` ([checkbox](#node-checkbox)) |\n| `switch` | `activeTrackColor`, `inactiveTrackColor`, `activeThumbColor`, `inactiveThumbColor`, `fillTrack`, `thumbInset`, `trackOutlineWidth`, `trackRadius` | `props` ([switch](#node-switch)) |\n| `radio`, `slider`, `dropdown`, `segmentedButton` | their colors, track and thumb shapes | `props` ([radio](#node-radio), [slider](#node-slider), [dropdown](#node-dropdown), [segmentedButton](#node-segmentedButton)) |\n| a labeled row | a `row` holding the control (with `"ignorePointer": true` and its value bound) and a text, with the row\'s `click` reaction | [a labeled checkbox](#forms-a-labeled-checkbox-or-switch) |\n\nEvery color there may be a theme color\'s name; every text style may name a theme style. An outlined or filled\nfield that sets no `contentPadding` (nor a `layout.padding`) takes Flutter\'s default, 12 px at the sides, which\nkeeps its text and label off the border; set `contentPadding` for another.'),
      DocSection('forms-a-text-field-bound-to-a-variable-two-way', 'A text field bound to a variable (two-way)', 'Bind its `props.initialValue` to the variable: `"bind": {"props.initialValue": "\${query}"}`. Typing sets the\nvariable (its `changed` reaction also runs), and setting the variable elsewhere (a clear button, a stepper,\n`--set`) changes the text, keeping the caret, as a `TextEditingController` held in state. The other inputs show\ntheir bound value prop (`"bind": {"props.value": "\${agree}"}` for a checkbox, switch, slider or dropdown,\n`props.selected` for a segmented button, `props.groupValue` for radios) and report a change through `changed`:\nstore `\${result}` in the same variable and the control follows it.'),
      DocSection('forms-validation-and-an-error-state', 'Validation and an error state', 'As Flutter\'s `TextFormField` and `Form`:\n\n- A field\'s `validator` is Flutter\'s `validator: (value) => ...`: an expression that reads the typed text as\n  `value` and gives the error to show under the field, or `\'\'` when it is valid:\n  `"validator": "\${= trim(value) == \'\' ? \'Enter your name.\' : \'\'}"` (in `props`, not `bind`: it runs on the text\n  each time the field checks itself).\n- `autovalidateMode` says when a field checks itself (Flutter\'s `AutovalidateMode`): `disabled` (default: only\n  when its form is validated), `onUnfocus` (when the focus leaves it: validate on blur), `onUserInteraction` (as\n  it is typed in, once it has been), `onUserInteractionIfError` (as it is typed in, while it shows an error: the\n  error clears as soon as it is fixed), `always`. An error stays until the field checks itself again.\n- A node with `"form": {"autovalidateMode": ...}` is Flutter\'s `Form` around the fields inside it: the mode applies\n  to all of them, and its nodes read `\${form.valid}` (every field passes now) and `\${form.errors}` (the errors the\n  fields show, top to bottom: `{field, label, message}`) for a summary.\n- `{"type": "validate", "node": "<form>"}` is `FormState.validate()`: every field of the form shows its error,\n  the first invalid one takes the focus, and `\${result}` is whether all are valid, for an `if` that submits.\n\nAn error can also come from anywhere else: bind `props.decoration.errorText` (an empty text shows none); the\nvalidator\'s error, when it shows one, wins. Give a field that may show an error a hug height (`{"hug": 56}`): it\ngrows by the error line, and the form with it; a fixed height keeps the field that tall. `inputFormatter` applies\n`{"type": "regex", "pattern": ..., "allow": true}`, `{"type": "email"}` (no spaces) or `{"type": "phone"}` (digits, `+`, spaces, `()`, `-`, `.`); another type is said as the page is expanded. A form submitted to a service: `submitForm`\n([data](data.md#page-data)).\n\nA contact form validated on blur and on send, with a summary of the errors above it, a radio group and a thank-you\nthat replaces the form:\n\n```json\n{\n  "schema": 3,\n  "roots": ["contact"],\n  "nodes": {\n    "contact": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 760},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["contactForm", "thanks"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 760}, "padding": 24},\n      "props": {"crossAxisAlignment": "start", "scrollable": true}\n    },\n    "contactForm": {\n      "type": "column",\n      "children": ["summary", "name", "email", "budgetLabel", "budget", "message", "send"],\n      "layout": {"width": {"fill": 342}, "height": {"hug": 560}},\n      "props": {"spacing": 14, "crossAxisAlignment": "start"},\n      "form": {"autovalidateMode": "onUnfocus"},\n      "bind": {"visible": "\${= !sent}"}\n    },\n    "summary": {\n      "type": "column",\n      "children": ["summaryTitle", "summaryList"],\n      "layout": {"width": {"fill": 342}, "height": {"hug": 60}, "padding": 12},\n\n(Continues: forms.md#forms-validation-and-an-error-state.)'),
      DocSection('forms-submitting-without-a-backend', 'Submitting without a backend', 'A site with no service to send to still has a whole submit flow: validate, show a sending state, keep the entry,\nconfirm, and tell the app that hosts the page. Here a `status` variable (`idle`, `sending`, `error`, `sent`) drives\nwhat shows; the `delay` stands in for the request; `setStorage` keeps every submission on the device (`insert` into\nthe list `\${storage.submissions}`); `emitEvent` hands it to the host app (`codelessly.events`, the same bus a\nreal backend hook listens on); and the confirmation says plainly that nothing was sent. The success text is honest\nabout it, so the page is a real offline form, not a mock-up.\n\n```json\n{\n  "schema": 3,\n  "roots": ["signup"],\n  "nodes": {\n    "signup": {"type": "canvas", "slots": {"body": "col"}, "layout": {"width": 390, "height": 420},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}},\n    "col": {"type": "column", "children": ["form", "sending", "failed", "sent"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 420}, "padding": 24}, "props": {"spacing": 12}},\n    "form": {"type": "column", "children": ["email", "send"], "form": true,\n      "layout": {"width": {"fill": 342}, "height": {"hug": 120}}, "props": {"spacing": 12},\n      "bind": {"visible": "\${= status == \'idle\' || status == \'error\'}"}},\n    "email": {"type": "textField", "layout": {"width": {"fill": 342}, "height": {"hug": 56}},\n      "props": {"decoration": {"labelText": "Email"}, "keyboardType": "emailAddress",\n        "validator": "\${= matches(value, \'^[^@ ]+@[^@ ]+[.][^@ ]+\$\') ? \'\' : \'Enter an email like name@example.com.\'}"},\n      "bind": {"props.initialValue": "\${email}"},\n      "actions": [{"trigger": {"type": "changed"}, "actions": [{"type": "setVariable", "variable": "email", "value": "\${result}"}]}]},\n    "send": {"type": "filledButton", "layout": {"width": {"fill": 342}, "height": 48}, "props": {"label": "Subscribe"},\n      "actions": [{"trigger": {"type": "click"}, "actions": [\n        {"type": "validate", "node": "form"},\n        {"type": "if", "condition": {"left": "\${result}", "op": "isTrue"}, "then": [\n          {"type": "setVariable", "variable": "status", "value": "sending"},\n          {"type": "delay", "ms": 900},\n          {"type": "if", "condition": {"left": "\${failNext}", "op": "isTrue"},\n            "then": [{"type": "setVariable", "variable": "status", "value": "error"}],\n            "else": [\n              {"type": "setStorage", "key": "submissions", "op": "insert", "valueType": "list",\n                "value": "\${= {\'email\': email, \'at\': now()}}"},\n              {"type": "emitEvent", "event": "signupSubmitted", "props": {"email": "\${email}"}},\n              {"type": "setVariable", "variable": "status", "value": "sent"}]}]}]}]},\n    "sending": {"type": "row", "children": ["spinner", "sendingText"], "props": {"spacing": 10},\n      "layout": {"width": {"fill": 342}, "height": 32}, "bind": {"visible": "\${= status == \'sending\'}"}},\n    "spinner": {"type": "circularProgressIndicator", "layout": {"width": 24, "height": 24}},\n    "sendingText": {"type": "text", "layout": {"width": {"fill": 300}, "height": {"hug": 20}},\n\n(Continues: forms.md#forms-submitting-without-a-backend.)'),
      DocSection('forms-loading-and-error-states-without-a-backend', 'Loading and error states without a backend', 'The `status` variable above is the whole loading and error design: one value, a node per state bound to it\n(`"visible": "\${= status == \'sending\'}"`, a spinner and a line; `\'error\'`, a message over the form, which stays so\nthe visitor can retry). `failNext` makes the next submit fail, so the error state is exercised by the page itself:\na "simulate a failure" switch in a demo, or the render command\'s `--set failNext=true --type email=a@b.co --tap\nsend`. Capture a state mid-flight with `--set \'status="sending"\'` (the command settles past a short `delay`). For a\nlist that loads, the same pattern drives its `loading` and `error` slots from a `status` a `load` reaction sets\nafter a `delay`.'),
      DocSection('forms-a-radio-group', 'A radio group', 'Flutter\'s `RadioGroup`: give the node around the radios `"radioGroup": {"groupValue": ...}`, bind its\n`radioGroup.groupValue` to the variable that keeps the choice, and store `\${result}` in its `changed` reaction. Each\n`radio` inside sets only its `value`: it is on when that is the group\'s value, and choosing it runs the group\'s\n`changed` (and its own). See `budget` in the form above.'),
      DocSection('forms-a-stepper-around-a-field', 'A stepper around a field', 'Two icon buttons that `setVariable` with `"op": "add"` / `"subtract"` on a number, and a field bound two-way to the\nsame variable. Keep the last valid value in a second variable when the typed text may be invalid.'),
      DocSection('forms-a-clear-button-in-the-field', 'A clear button in the field', 'Its `decoration.suffixIcon` with a tap reaction (`actions` is a list of reactions, as a node\'s), shown only while\nthere is text by binding the icon:\n\n```json\n"search": {"type": "textField", "layout": {"width": {"fill": 280}, "height": {"hug": 28}},\n  "bind": {"props.initialValue": "\${query}", "props.decoration.suffixIcon.icon": "\${= query == \'\' ? \'\' : \'close\'}"},\n  "props": {"decoration": {"hintText": "Search dishes", "prefixIcon": {"icon": "search", "size": 18}, "suffixIcon": {"icon": "close", "size": 18,\n    "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "setVariable", "variable": "query", "value": ""}]}]}}}}\n```'),
      DocSection('forms-a-labeled-checkbox-or-switch', 'A labeled checkbox or switch', 'The whole row toggles: the control ignores the pointer and shows the variable; the row\'s reaction toggles it. A tap\non a control inside a tappable row otherwise runs the control\'s own reaction only (the innermost wins).\n\n```json\n"agreeRow": {"type": "row", "children": ["agreeBox", "agreeText"], "props": {"spacing": 8},\n  "layout": {"width": {"hug": 240}, "height": 40},\n  "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "setVariable", "variable": "agree", "op": "toggle"}]}]},\n"agreeBox": {"type": "checkbox", "ignorePointer": true, "layout": {"width": 24, "height": 24}, "bind": {"props.value": "\${agree}"}},\n"agreeText": {"type": "text", "props": {"text": "I agree", "style": {"fontSize": 15, "color": "#FF111827"}},\n  "layout": {"width": {"hug": 60}, "height": {"hug": 20}}}\n```'),
      DocSection('forms-buttons', 'Buttons', 'Buttons (`filledButton`, `elevatedButton`, `outlinedButton`, `textButton`, `iconButton`) take `label`, `icon` and\n`style`. With no layout they hug: 28 high, padded, the label 12 px unless `style.textStyle.fontSize` says otherwise.\n`"loading": true` (bound to a variable an action sets while it runs) shows a spinner in place of the icon and ignores\ntaps. For full control of a button\'s look (two lines, an icon after the label), use a `row` with a decoration, padding, text\nchildren, a `click` reaction and [hover and pressed states](interaction.md#interaction-hover-press-and-other-states).'),
      DocSection('forms-add-and-remove-items-a-list-editor', 'Add and remove items (a list editor)', 'Add: `setVariable` on the list with `"op": "add"` (appends; a list value appends each item) and\n`"value": "\${= object(\'name\', draft, \'done\', false)}"`, then clear the draft; guard it with the action\'s `when` (or\nan `if`) on the draft not being empty. Remove: in the item template, `"op": "removeAt"` with `"index": "\${index}"`.\nChange one item: `"op": "update"` with `index`, or a formula (`\${= updateWhere(habits, \'id\', item.id, h => set(h,\n\'done\', !h.done))}`). Give items an id (`newId(\'habit\')`) when they can be reordered or removed.'),
      DocSection('forms-focus-and-the-keyboard', 'Focus and the keyboard', '`focus` moves the focus to a field (or away), `editText` changes its text or selection. `submitted` fires on the\nkeyboard\'s done key; `textInputAction` picks the key. A canvas\'s `keyDown` reaction (`{"trigger": {"type":\n"keyDown", "key": "ArrowRight"}, ...}`) runs while no text field has the focus: arrow keys between tabs, Escape to\nclose. The render command types with `--type <id>=<text>` (it replaces the text) and presses keys with `--key`\n(after `--unfocus`).'),
    ],
  ),
  DocPage(
    id: 'lists',
    title: 'Lists, grids, tables and repeated data',
    summary: 'Anything repeated from data: lists and grids from one item template, nested lists (`item`, `index`, `parent`), equal-height card grids, tables, carousels (`pageView`), list tiles, pagination, pull to refresh, swipe actions and reordering.',
    when: 'Anything repeated from data: lists and grids from one item template, nested lists (`item`, `index`, `parent`),\nequal-height card grids, tables, carousels (`pageView`), list tiles, pagination, pull to refresh, swipe actions and\nreordering.',
    example: 'A `listView` repeats its first child once per item of its `data` binding; inside, `\${item}` is the item and\n`\${index}` its position:\n\n```json\n{\n  "schema": 3,\n  "roots": ["faq"],\n  "nodes": {\n    "faq": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 600},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["heading", "items"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 600}, "padding": 24},\n      "props": {"spacing": 12, "crossAxisAlignment": "start", "scrollable": true}\n    },\n    "heading": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 30}},\n      "props": {"text": "Questions", "style": {"fontSize": 24, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "items": {\n      "type": "listView",\n      "children": ["item"],\n      "layout": {"width": {"fill": 342}, "height": {"hug": 300}},\n      "props": {"scrollable": false, "spacing": 8},\n      "bind": {"data": "\${questions}"}\n    },\n    "item": {\n      "type": "column",\n      "children": ["q", "a"],\n      "layout": {"width": {"fill": 342}, "height": {"hug": 60}, "padding": 12},\n      "props": {"crossAxisAlignment": "start", "spacing": 4},\n      "decoration": {"fills": [{"color": "#FFF3F4F6"}], "radius": 8},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "setVariable", "variable": "open", "value": "\${= open == index ? -1 : index}"}]\n        }\n      ]\n    },\n    "q": {\n      "type": "text",\n      "layout": {"width": {"fill": 318}, "height": {"hug": 20}},\n      "props": {"text": "\${item.q}", "style": {"fontSize": 16, "fontWeight": 600, "color": "#FF111827"}}\n    },\n    "a": {\n      "type": "text",\n      "layout": {"width": {"fill": 318}, "height": {"hug": 20}},\n      "props": {"text": "\${item.a}", "style": {"fontSize": 14, "height": 1.4, "color": "#FF4B5563"}},\n      "bind": {"visible": "\${= open == index}"}\n    }\n  },\n  "variables": {\n    "faq": [\n      {"name": "open", "type": "integer", "value": -1},\n      {\n        "name": "questions",\n        "type": "list",\n        "value": [\n          {"q": "Can I cancel any time?", "a": "Yes. Your plan stays active until the end of the period."},\n          {"q": "Do you offer refunds?", "a": "Within 14 days of purchase, no questions asked."},\n          {"q": "Is there a free trial?", "a": "Every plan starts with 30 days free."}\n        ]\n      }\n    ]\n  }\n}\n```',
    pitfalls: '- Only the first child is the template; other children are ignored.\n- A list function\'s condition reads the item through a lambda (`r => r.status == x`); written without one it is\n  computed once and the list comes out empty.\n- `item` and `index` are the innermost list\'s; the outer one is `parent`.\n- A list inside a scrolling page needs `"scrollable": false` (or `"physics": "never"`, which a `gridView` needs:\n  it has no `scrollable`), or it takes its design height and scrolls inside itself.\n- A wrapping `listView` runs along its `scrollDirection`: with the default `vertical` it flows top to bottom into\n  columns.\n- Decoration on a `listView` or `gridView` is ignored: put the list inside a column that has\n  it.\n- A `fill` height inside a hugging grid item is its design number (`fill_fallback`).\n- A slot inside a list of a component shows what the call passes in every item, built in the caller\'s scope: it\n  reads the caller\'s variables, not the item.',
    words: 8389,
    items: ['listView', 'gridView', 'pageView', 'tableView', 'listTile', 'pagination', 'reorderHandle', 'reorder', 'refresh', 'swipeAction', 'rowTap', 'sort', 'paginate'],
    sections: [
      DocSection('lists-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-reorder"></a>`reorder` | A data list row was dragged to a new place by this node, its reorder handle (`\${result.from}`, `\${result.to}`). A list with a `reorder` fires it too, with `\${result.item}`, `\${result.fromList}`, `\${result.toList}`. |\n| <a id="trigger-refresh"></a>`refresh` | A list or grid was pulled past its start to refresh (its `pullToRefresh`, or its pagination\'s); its pagination reloads its first page too. A list with this reaction can always be pulled. |\n| <a id="trigger-swipeAction"></a>`swipeAction` | A swipe action of a list item ran (the list\'s `swipeActions`): `\${result.action}`, `\${result.label}`, `\${result.item}`, `\${result.index}`. |\n| <a id="trigger-rowTap"></a>`rowTap` | A table view\'s body row was tapped: `\${result.row}` (the row\'s data), `\${result.rowIndex}`, `\${result.column}` (the tapped column\'s key), `\${result.columnIndex}`. |\n| <a id="trigger-sort"></a>`sort` | A table header was activated by pointer or keyboard: `\${result.column}` is its key, `\${result.columnIndex}` its index, and `\${result.ascending}` the new direction. |'),
      DocSection('lists-one-template-from-data', 'One template from data', 'A `listView` (or `gridView`, `pageView`) repeats its **first child** once per item of its `data` binding:\n`"bind": {"data": "\${questions}"}`. Inside the repeated child, `\${item}` is the item (`\${item.title}`) and\n`\${index}` its position from 0. A list in a scrolling page sets `"scrollable": false` so it lays out every item at\nits full height; `spacing` separates items. Items fill the list\'s width. The item template can carry reactions: a\nclick on an item runs with that item\'s `item` and `index`. When the item is more than about five nodes, or appears\nelsewhere too, make it one call of a [component](components.md#page-components) (`"bind": {"props.plan": "\${item}"}`).'),
      DocSection('lists-a-grid-of-cards', 'A grid of cards', 'For cards in columns from one list inside a scrolling page, use a `gridView` with `minCrossAxisExtent` (CSS\n`repeat(auto-fit, minmax(280px, 1fr))`: as many equal columns as fit), `"shrinkWrapRows": true` and\n`"physics": "never"` (it lays out every item and the page scrolls). A fixed number of columns: `crossAxisCount`. A\n`listView` with `"wrap": true` lays its items out at their own sizes in runs along its `scrollDirection`: set\n`"scrollDirection": "horizontal"` for chips or nav links side by side. In wrap mode the gap between items is\n`wrapSpacing` and between runs `runSpacing`; `spacing` does not apply.'),
      DocSection('lists-equal-height-cards', 'Equal-height cards', 'In a `gridView` with `"shrinkWrapRows": true` (CSS grid\'s auto rows) each row is as tall as its tallest item, and\nevery item is stretched to it, whether it hugs or fills its height. Make the item the card (the box with the\ndecoration): a card *inside* a hugging item column keeps its own height, and a card that fills the item\'s height\nthere takes its design number (`fill_fallback`). A banner above one card goes inside the card, with a top margin on\nthe others to line them up. A card\'s button pinned to its bottom: a `spacer` (or a `fill` height child) between the\ncontent and the button inside the stretched card. `shrinkWrapRows` wins over `mainAxisExtent`; for\nrows at least n tall, give the item `"constraints": {"minHeight": n}`.'),
      DocSection('lists-nested-lists', 'Nested lists', 'A list inside a list\'s item repeats per item of its own `data`, usually a field of the outer item. Inside the inner\ntemplate `item` and `index` are the innermost list\'s; `parent` is the item around it (`\${parent.item}`,\n`\${parent.index}`, and its fields directly: `\${parent.name}`). Two levels:\n\n```json\n"sections": {"type": "listView", "children": ["section"], "bind": {"data": "\${= groupBy(dishes, \'section\')}"},\n             "props": {"scrollable": false, "spacing": 24}, "layout": {"width": {"fill": 600}, "height": {"hug": 400}}},\n"section":  {"type": "column", "children": ["sectionTitle", "dishList"], "props": {"crossAxisAlignment": "start"},\n             "layout": {"width": {"fill": 600}, "height": {"hug": 200}}},\n"sectionTitle": {"type": "text", "props": {"text": "\${item.key} (\${item.count})", "style": {"fontSize": 20, "color": "#FF111827"}},\n             "layout": {"width": {"hug": 200}, "height": {"hug": 24}}},\n"dishList": {"type": "listView", "children": ["dish"], "bind": {"data": "\${item.items}"}, "props": {"scrollable": false},\n             "layout": {"width": {"fill": 600}, "height": {"hug": 120}}},\n"dish":     {"type": "text", "props": {"text": "\${parent.key} \${parent.index}: \${item.name} (#\${index})", "style": {"color": "#FF374151"}},\n             "layout": {"width": {"fill": 600}, "height": {"hug": 20}}}\n```\n\nA third level reads the second\'s item as `parent`; to reach further out, carry the value down in the data.'),
      DocSection('lists-a-table-from-one-template', 'A table from one template', 'A `listView` of rows bound to the records, each row a label and a `gridView` of cells bound to `\${item.values}` with\n`crossAxisCount` the number of columns: one cell node for every column (the example in\n[a capped band](layout.md#layout-a-capped-band)). Four columns written by hand, or four lists side by side, are the same\ntable written four times. For a column that stays while the others scroll sideways, keep the label column a\n`listView` of its own beside one horizontally scrolling block of the cell grids, rows the same height in both. A\n`tableView` is a data table with columns declared once (sorting, row taps).'),
      DocSection('lists-a-data-table-tableview', 'A data table (tableView)', 'The rows are **bound data** (`"bind": {"data": "\${years}"}`, a list of records), never a `props.data`; the columns\nare `props.columns`, each a record field (`key`), its header (`label`) and its width. The `cell` slot is one template\nfor every cell, reading `\${item.value}` (also `\${item.row}`, the whole record, and `\${item.column}`); `columnHeader`\nreads `\${item.label}`. `fillWidth` shares a wide screen\'s extra width between the columns:\n\n```json\n{\n  "schema": 3,\n  "roots": ["impact"],\n  "nodes": {\n    "impact": {"type": "canvas", "slots": {"body": "table"}, "layout": {"width": 390, "height": 260},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}},\n    "table": {"type": "tableView", "slots": {"cell": "cell", "columnHeader": "head"},\n      "layout": {"width": {"fill": 390}, "height": {"fill": 260}},\n      "props": {"rowHeight": 40, "headerHeight": 40, "pinHeaderColumn": false, "fillWidth": true,\n        "columns": [{"key": "year", "label": "Year", "width": 80}, {"key": "trees", "label": "Trees", "width": 100},\n                    {"key": "survival", "label": "Survival", "width": 100}]},\n      "bind": {"data": "\${years}"}},\n    "head": {"type": "text", "layout": {"width": {"fill": 100}, "height": {"fill": 40}, "padding": [12, 10, 12, 10]},\n      "props": {"text": "\${item.label}", "style": {"fontSize": 13, "fontWeight": 700, "color": "#FF334155"}}},\n    "cell": {"type": "text", "layout": {"width": {"fill": 100}, "height": {"fill": 40}, "padding": [12, 10, 12, 10]},\n      "props": {"text": "\${item.value}", "style": {"fontSize": 14, "color": "#FF0F172A"}}}\n  },\n  "variables": {\n    "impact": [\n      {"name": "years", "type": "list", "value": [\n        {"year": "2023", "trees": "3,120", "survival": "94%"},\n        {"year": "2024", "trees": "4,480", "survival": "91%"},\n        {"year": "2025", "trees": "4,880", "survival": "87%"}]}\n    ]\n  }\n}\n```'),
      DocSection('lists-filter-sort-and-page-a-list', 'Filter, sort and page a list', 'Search, a status filter, sortable columns and pages are computed variables over the records, chained: `shown`\nfilters and sorts them, `paged` is one page of it, and the list binds `\${paged}`.\n\n- Inside `filter`, `sortBy`, `map` and `count` an item\'s field is read through the item, a lambda\'s parameter:\n  `filter(invoices, r => r.status == x)`. Written without it (`filter(invoices, status == x)`) the condition is\n  computed once, outside the list, and matches no item: the list is empty.\n- "All" and an empty search match everything inside the lambda: `statusFilter == \'All\' || r.status ==\n  statusFilter`; `contains(lower(r.cust), lower(search))` is true while `search` is empty.\n- `sortBy(list, key, \'desc\')`: the key is a field name (a variable holding one works) or a lambda; the direction\n  is `\'asc\'` or `\'desc\'`, not 1 or -1.\n- Page after filtering and sorting; set `page` back to 0 when the search or filter changes. Counts read `shown`.\n\n```json\n{"schema": 3, "roots": ["home"],\n "nodes": {\n  "home": {"type": "canvas", "slots": {"body": "col"}, "layout": {"width": 390, "height": 360}, "decoration": {"fills": [{"color": "#FFFFFFFF"}]}},\n  "col": {"type": "column", "children": ["tools", "head", "list", "pager"], "props": {"spacing": 8}, "layout": {"width": {"fill": 390}, "height": {"hug": 320}, "padding": 16}},\n  "tools": {"type": "row", "children": ["search", "pick"], "props": {"spacing": 8}, "layout": {"width": {"fill": 358}, "height": {"hug": 48}}},\n  "search": {"type": "textField", "props": {"decoration": {"hintText": "Search customer"}}, "bind": {"props.initialValue": "\${search}"}, "layout": {"width": {"fill": 220}, "height": {"hug": 28}},\n    "actions": [{"trigger": {"type": "changed"}, "actions": [{"type": "setVariable", "variable": "search", "value": "\${result}"}, {"type": "setVariable", "variable": "page", "value": "0"}]}]},\n  "pick": {"type": "dropdown", "props": {"items": ["All", "Paid", "Overdue"], "isExpanded": true}, "bind": {"props.value": "\${statusFilter}"}, "layout": {"width": 130, "height": {"hug": 28}},\n    "actions": [{"trigger": {"type": "changed"}, "actions": [{"type": "setVariable", "variable": "statusFilter", "value": "\${result}"}, {"type": "setVariable", "variable": "page", "value": "0"}]}]},\n  "head": {"type": "row", "children": ["hCust", "hAmt"], "layout": {"width": {"fill": 358}, "height": {"hug": 20}}},\n  "hCust": {"type": "text", "props": {"text": "Customer", "style": {"fontSize": 13, "color": "#FF6B7280"}}, "bind": {"props.text": "Customer\${= sortKey == \'cust\' ? (desc ? \' ↓\' : \' ↑\') : \'\'}"}, "layout": {"width": {"fill": 270}, "height": {"hug": 18}},\n    "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "setVariable", "variable": "desc", "value": "\${= sortKey == \'cust\' && !desc}"}, {"type": "setVariable", "variable": "sortKey", "value": "cust"}]}]},\n  "hAmt": {"type": "text", "props": {"text": "Amount", "style": {"fontSize": 13, "color": "#FF6B7280"}}, "bind": {"props.text": "Amount\${= sortKey == \'amt\' ? (desc ? \' ↓\' : \' ↑\') : \'\'}"}, "layout": {"width": {"hug": 80}, "height": {"hug": 18}},\n\n(Continues: lists.md#lists-filter-sort-and-page-a-list.)'),
      DocSection('lists-a-weekly-grid', 'A weekly grid', 'Seven columns of days from data: a `gridView` with `"crossAxisCount": 7` bound to the days (`\${= range(7)}`, or a\ncomputed list of `{day, done}` records), each cell a box whose fill is bound to the item. Rows of habits × days: a\n`listView` of habits whose item holds a label and that 7-column grid bound to `\${item.days}`; in a cell, `\${parent}`\nis the habit and `\${index}` the day. A grid sizes its cells: set the cell height with `mainAxisExtent` and give\nthe cell `fill` on both axes.\n\nA tap on a day flips it in the habit\'s record (`setAt` and `set` build the new list); the label counts the checks:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home"],\n  "nodes": {\n    "home": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 400},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["habitList"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 400}, "padding": 24}\n    },\n    "habitList": {\n      "type": "listView",\n      "children": ["habit"],\n      "bind": {"data": "\${habits}"},\n      "props": {"scrollable": false, "spacing": 12},\n      "layout": {"width": {"fill": 342}, "height": {"hug": 200}}\n    },\n    "habit": {\n      "type": "column",\n      "children": ["name", "week"],\n      "props": {"crossAxisAlignment": "start", "spacing": 6},\n      "layout": {"width": {"fill": 342}, "height": {"hug": 70}}\n    },\n    "name": {\n      "type": "text",\n      "props": {"text": "\${item.name}: \${= count(item.days, d => d)}", "style": {"fontSize": 15, "color": "#FF111827"}},\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}}\n    },\n    "week": {\n      "type": "gridView",\n      "children": ["day"],\n      "bind": {"data": "\${item.days}"},\n      "props": {"crossAxisCount": 7, "mainAxisExtent": 40, "crossAxisSpacing": 6, "physics": "never"},\n      "layout": {"width": {"fill": 342}, "height": {"hug": 40}}\n    },\n    "day": {\n      "type": "box",\n      "layout": {"width": {"fill": 40}, "height": {"fill": 40}},\n      "decoration": {"fills": [{"color": "#FFE5E7EB"}], "radius": 20},\n      "bind": {"decoration.fills[0].color": "\${= item ? \'#FF16A34A\' : \'#FFE5E7EB\'}"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {\n              "type": "setVariable",\n              "variable": "habits",\n              "value": "\${= setAt(habits, parent.index, set(parent.item, \'days\', setAt(parent.item.days, index, !item)))}"\n            }\n          ]\n        }\n      ]\n    }\n  },\n  "variables": {\n    "home": [\n      {\n        "name": "habits",\n        "type": "list",\n        "value": [\n          {"name": "Water", "days": [true, true, false, false, false, false, false]},\n          {"name": "Read", "days": [false, true, false, false, false, false, false]}\n        ]\n      }\n    ]\n  }\n}\n```'),
      DocSection('lists-a-carousel-pages-and-pagination', 'A carousel, pages and pagination', 'A `pageView` shows one item (or child) per page and swipes between them (`viewportFraction` below 1 shows the\nneighbors\' edges; `initialPage`). Long lists that load in pages: the list\'s `pagination` settings, with a\n`pagination` control or the `paginate` action to move between pages.\n\nA rail of cards with arrows, dots and a progress bar is a horizontal `listView` (or scrolling `row`):\n\n- `"itemSnapping": true` makes a drag or fling come to rest with a card at the start of the view (CSS\n  `scroll-snap-align: start`; Flutter\'s `PageView.pageSnapping`, for items).\n- Its `scroll` reaction gives `\${result.index}` (the card at the start; the last at the end), `\${result.count}`,\n  `\${result.offset}` and `\${result.fraction}` (0–1): store them in variables the controls bind.\n- An arrow is `{"type": "scrollTo", "node": "<item template>", "item": "\${= current + 1}"}`: `item` is the key or\n  the index of the card to bring to the start (`alignment` 0; 0.5 centers it). A dot scrolls to its own `\${index}`.\n  For a scrolling `row` of fixed children, name the child: `"node": "card\${= current + 1}"`.\n\nThe same pattern moves a horizontal timeline from its year buttons, or a featured-routes carousel from its dots:\n\n```json\n{\n  "schema": 3,\n  "roots": ["shop"],\n  "nodes": {\n    "shop": {\n      "type": "canvas",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 520},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["header", "rail", "footer"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 520}, "padding": [20, 24, 20, 24]},\n      "props": {"spacing": 16, "crossAxisAlignment": "start"}\n    },\n    "header": {\n      "type": "row",\n      "children": ["heading", "arrows"],\n      "layout": {"width": {"fill": 350}, "height": {"hug": 40}},\n      "props": {"mainAxisAlignment": "spaceBetween"}\n    },\n    "heading": {\n      "type": "text",\n      "layout": {"width": {"hug": 160}, "height": {"hug": 28}},\n      "props": {"text": "New arrivals", "style": {"fontSize": 22, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "arrows": {\n      "type": "row",\n      "children": ["prev", "next"],\n      "layout": {"width": {"hug": 96}, "height": 40},\n      "props": {"spacing": 8}\n    },\n    "prev": {\n      "type": "iconButton",\n      "layout": {"width": 40, "height": 40},\n      "props": {"icon": "chevron_left"},\n      "bind": {"props.enabled": "\${= current > 0}"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {\n              "type": "scrollTo",\n              "node": "card",\n              "item": "\${= current - 1}",\n              "axis": "horizontal",\n              "durationMs": 300\n            }\n          ]\n        }\n      ]\n    },\n    "next": {\n      "type": "iconButton",\n      "layout": {"width": 40, "height": 40},\n      "props": {"icon": "chevron_right"},\n      "bind": {"props.enabled": "\${= current < length(products) - 1}"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {\n              "type": "scrollTo",\n              "node": "card",\n\n(Continues: lists.md#lists-a-carousel-pages-and-pagination.)'),
    ],
  ),
  DocPage(
    id: 'navigation',
    title: 'Screens, navigation, modals and toasts',
    summary: 'Several screens and moving between them, a page\'s URL path, passing values to a screen, dialogs, bottom sheets and popovers, confirmations and toasts, app bars, navigation bars, tabs and disclosure (accordions).',
    when: 'Several screens and moving between them, a page\'s URL path, passing values to a screen, dialogs, bottom sheets\nand popovers, confirmations and toasts, app bars, navigation bars, tabs and disclosure (accordions).',
    example: 'Two screens: a list that opens a detail screen with a parameter, a modal, and a toast:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home", "about", "signup"],\n  "nodes": {\n    "home": {\n      "type": "canvas",\n      "name": "Home",\n      "slots": {"body": "homeCol"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "homeCol": {\n      "type": "column",\n      "children": ["toAbout", "openSignup", "toast"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n      "props": {"spacing": 12, "crossAxisAlignment": "start"}\n    },\n    "toAbout": {\n      "type": "textButton",\n      "layout": {"width": 160, "height": 40},\n      "props": {"label": "About us"},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "navigate", "to": "about"}]}]\n    },\n    "openSignup": {\n      "type": "textButton",\n      "layout": {"width": 160, "height": 40},\n      "props": {"label": "Sign up"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "openModal", "to": "signup", "presentation": "dialog"}]\n        }\n      ]\n    },\n    "toast": {\n      "type": "textButton",\n      "layout": {"width": 160, "height": 40},\n      "props": {"label": "Show a toast"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "showToast", "message": "Saved", "style": "success"}]\n        }\n      ]\n    },\n    "about": {\n      "type": "canvas",\n      "name": "About",\n      "path": "about",\n      "slots": {"body": "aboutCol"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFF9FAFB"}]}\n    },\n    "aboutCol": {\n      "type": "column",\n      "children": ["aboutTitle", "back"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n      "props": {"spacing": 12, "crossAxisAlignment": "start"}\n    },\n    "aboutTitle": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 30}},\n      "props": {"text": "About", "style": {"fontSize": 24, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "back": {\n      "type": "textButton",\n      "layout": {"width": 120, "height": 40},\n      "props": {"label": "Back"},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "navigate", "mode": "pop"}]}]\n    },\n    "signup": {\n      "type": "canvas",\n      "name": "Sign up",\n      "slots": {"body": "signupCol"},\n      "layout": {"width": 320, "height": 200},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}], "radius": 16}\n    },\n    "signupCol": {\n      "type": "column",\n      "children": ["signupTitle", "close"],\n      "layout": {"width": {"fill": 320}, "height": {"fill": 200}, "padding": 24},\n      "props": {"spacing": 16}\n    },\n    "signupTitle": {\n      "type": "text",\n      "layout": {"width": {"hug": 200}, "height": {"hug": 26}},\n      "props": {"text": "Join the waitlist", "style": {"fontSize": 20, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "close": {\n      "type": "filledButton",\n      "layout": {"width": 120, "height": 40},\n      "props": {"label": "Close"},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "closeModal"}]}]\n    }\n  }\n}\n```',
    pitfalls: '- `to` names a canvas id; a screen that is not a root cannot be shown.\n- A modal shows its canvas at its design size: give the modal canvas the dialog\'s size, not the screen\'s.\n- `\${route.<param>}` exists only on the screen navigated to with `params`.\n- A canvas\'s `path` is a top-level key of the canvas node, not a prop.\n- Menus hidden behind `hovered` never open on touch screens, and never by keyboard: open them with a click.\n- A `"barrierDismissible": false` modal with no `closeModal` inside cannot be left.',
    words: 5053,
    items: ['appBar', 'navigationBar', 'bottomNavigationBar', 'tabs', 'tabBar', 'accordion', 'expansionTile', 'modal', 'load', 'backPressed', 'navigate', 'openModal', 'closeModal', 'showToast', 'announce', 'confirm', 'openLink'],
    sections: [
      DocSection('navigation-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-load"></a>`load` | A screen appeared (set on its canvas). |\n| <a id="trigger-backPressed"></a>`backPressed` | On a screen (its canvas): the user tried to leave it (the system or browser back button, a back gesture, Escape on a dialog) while the canvas\'s `blockBack` holds (`props.blockBack`, usually bound: `\${= dirty}`). The screen stays and these actions run instead, e.g. a "Discard changes?" confirm that leaves with a navigate pop, which the block doesn\'t stop. While `blockBack` is false, back leaves as usual and this doesn\'t fire. |'),
      DocSection('navigation-screens', 'Screens', 'Each canvas in `roots` is a screen, unless canvases are grouped: canvases with the same `props.screen` are one\nscreen, one canvas per breakpoint ([a canvas per breakpoint](layout.md#layout-a-canvas-per-breakpoint)). A canvas is the\n`Scaffold` of its screen: put the page content in its `body` slot, usually a column filling it. Its\n`decoration.fills` is the page background; its `layout` is its design size (on a device the canvas takes the\nscreen\'s size).\n\nA site\'s pages may be separate documents (one file per page, checked and rendered together); `navigate` then names a\ncanvas id of another document. Give a canvas a `"path"` (`"pricing"`, a top-level key of the canvas node, not a\nprop) for its URL; without one it gets a path from its name. The first screen of the first document is the entry\nscreen.'),
      DocSection('navigation-going-to-a-screen-and-back', 'Going to a screen and back', '`{"type": "navigate", "to": "<canvas id>"}` pushes the screen; `"mode": "pop"` goes back; `"replace"` and `"reset"`\nreplace the history. For a screen with a canvas per breakpoint, name any of them. `to` may be built by a binding\n(`"to": "\${item.to}"` in a list of search results, each record naming its page\'s canvas id): it is the screen it names\nwhen the action runs. `"params": {"id": "\${item.id}"}`\npasses values the destination reads as `\${route.id}`. A link to the screen\'s path with a query string passes the same\n(`trip?id=coast`), and so does the render command\'s `--navigate trip?id=coast`. A screen opened without the param\nreads it as empty: give the page a default (`coalesce(find(trips, \'id\', route.id), first(trips))`).\n`transition` picks the animation (`fade`, `slideUp`...).'),
      DocSection('navigation-modals-and-toasts', 'Modals and toasts', '`{"type": "openModal", "to": "<canvas id>"}` shows another canvas over the screen, at its design size\n(`presentation`: `dialog`, `bottomSheet`, `fullScreen`, a popover anchored to a node...). Inside it,\n`{"type": "closeModal"}` closes it, and its value becomes the opener\'s `\${result}`. The modal canvas is a root like\nany screen; give it the size of the dialog. `{"type": "showToast", "message": "Saved", "style": "success"}` shows a\nshort message; `confirm` asks yes or no and runs `actions` or `cancelActions`.\n\nA bottom sheet with `snapHeights` (`[0.5, 1]`, shares of the window\'s height) rests at one of them and is dragged\nbetween them. `"stopVariable": "sheetStop"` keeps the stop it rests at in that variable, both ways: the sheet writes\nit as it opens and when it is moved to another stop, and setting the variable moves the open sheet to the nearest\nstop. A sheet opened while the variable holds one of its stops opens there, else at the lowest; the variable is `0`\nwhile the sheet is closed. `\${screen.url}` is the address of the page as shown (a browser\'s URL; in an app the\nlocation a link opens the screen with, or empty).'),
      DocSection('navigation-overlays-and-the-keyboard', 'Overlays and the keyboard', 'Every modal (`dialog`, `bottomSheet`, `sideSheet`, `popover`, `fullScreen`, `adaptive`) and the built-in\n`confirm` behaves as a dialog should, with nothing to write:\n\n- **The focus moves into it** as it opens. Opened from the keyboard (Enter or Space on the node that opens it), its\n  first focusable has the focus, with the ring: in a `focusGroup` (a menu) the item whose `selected` is bound true,\n  else the first. Opened by a pointer or a touch, the overlay itself holds the focus: nothing is ringed and no\n  on-screen keyboard opens, until a key is pressed (Tab goes to its first stop; in a menu an arrow starts at the\n  first item, End at the last).\n- **Tab and Shift+Tab stay inside** the top overlay; what is under it takes no key.\n- **Escape closes the top overlay**, as a press outside it does. `"barrierDismissible": false` on the action turns\n  both off (close it with a `closeModal`). A canvas whose `blockBack` holds stays open and runs its `backPressed`\n  reactions instead (ask "discard changes?" there).\n- **Closing gives the focus back** to the node that opened it: with the ring when the keyboard opened or closed the\n  overlay, else silently (the next Tab starts there). Overlays opened from overlays unwind: a menu item that opens\n  a dialog gets the focus back when the dialog closes, and when the menu is already gone, the menu\'s button does.\n- **It is named** for assistive technology as it opens: the modal canvas\'s `"props": {"semanticLabel": "Join the\n  waitlist"}`, else for a popover the label of the node that opened it (a menu is called what its button is), else\n  the first text it shows (a dialog\'s title).\n\nA popover that opens while a text field is being typed in (suggestions under a search field) leaves the focus in\nthe field. A menu\'s items are nodes with a click reaction inside a node with `focusGroup`\n([interaction](interaction.md#page-interaction)): Up and Down move through them, Home and End jump, a letter finds one, Enter and\nSpace choose.'),
      DocSection('navigation-a-mobile-menu-drawer', 'A mobile menu (drawer)', 'A menu button that toggles a `menuOpen` variable, and the menu a node bound `"visible": "\${menuOpen}"`. As an\noverlay over the page: the canvas body is a `stack` filling it, the page\'s scrolling column first and the menu\npanel last (fill width, placed at `"y": 64`), hidden unless open; or open it as a modal (`"presentation":\n"fullScreen"` or a sheet). A link in the menu closes it (`setVariable menuOpen false`) and navigates. The render\ncommand captures the open state with `--tap menuButton`; an overlay sized to the window is drawn in the first\nwindow of a `--full-page` capture.'),
      DocSection('navigation-tabs-and-an-accordion-faq', 'Tabs and an accordion (FAQ)', 'Tabs from a variable: a row of tab labels whose `selected` binds to `\${= tab == \'lunch\'}` with a click that sets\n`tab`, and the panels bound `visible` on `tab` (the `tabs` and `tabBar` node types do the same with Material\'s\nlook). An FAQ where several items may be open: a list variable of open indices; an item\'s click sets\n`\${= contains(open, index) ? without(open, index) : append(open, index)}`, its answer is visible while\n`\${= contains(open, index)}`, and its icon turns (`motion.rotate`) with a transition.'),
      DocSection('navigation-app-bars-and-navigation-bars', 'App bars and navigation bars', 'A canvas\'s `appBar` slot spans the top at its own height and `bottomNavigationBar` the bottom; the body sits\nbetween, and `floatingActionButton` sits 16 px from the right above the bottom bar. `navigationBar` and\n`bottomNavigationBar` take destinations (icon, label) and report the chosen index through `changed`.'),
    ],
  ),
  DocPage(
    id: 'state',
    title: 'State and logic',
    summary: 'Variables and where they live, computed and function variables, expressions and every binding path with the value it expects, conditions, the formula functions (grouped: text, numbers, money, lists, objects, dates, colors), the actions that change state, and sandboxed scripts.',
    when: 'Variables and where they live, computed and function variables, expressions and every binding path with the value\nit expects, conditions, the formula functions (grouped: text, numbers, money, lists, objects, dates, colors), the\nactions that change state, and sandboxed scripts.',
    example: 'A counter: a variable, two buttons that change it, and a text and a color bound to it.\n\n```json\n{\n  "schema": 3,\n  "roots": ["counter"],\n  "nodes": {\n    "counter": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 400},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["label", "total", "add"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 400}, "padding": 24},\n      "props": {"spacing": 12, "mainAxisAlignment": "center"}\n    },\n    "label": {\n      "type": "text",\n      "layout": {"width": {"hug": 120}, "height": {"hug": 24}},\n      "props": {"text": "Clicked \${count} times", "style": {"fontSize": 18, "color": "#FF111827"}}\n    },\n    "total": {\n      "type": "text",\n      "layout": {"width": {"hug": 120}, "height": {"hug": 20}},\n      "props": {"text": "", "style": {"fontSize": 14, "color": "#FF6B7280"}},\n      "bind": {"props.text": "\${= \'Total: \' + money(count * price, \'\$\')}"}\n    },\n    "add": {\n      "type": "box",\n      "layout": {"width": 160, "height": 44},\n      "decoration": {"fills": [{"color": "#FF2563EB"}], "radius": 8},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "setVariable", "variable": "count", "op": "add", "value": "1"}]\n        }\n      ]\n    }\n  },\n  "variables": {\n    "counter": [{"name": "count", "type": "integer", "value": 0}, {"name": "price", "type": "decimal", "value": 2.5}]\n  }\n}\n```',
    pitfalls: '- `\${false}` reads a variable called `false`: a literal is `\${= false}`.\n- Values in `props`, `layout` and `decoration` are literal: `"opacity": "\${x}"` is an error; bind it.\n- A backslash in a formula is written twice in JSON: `"\${= matches(code, \'^\\\\d{4}\$\')}"`.\n- A component never reads its caller\'s variables: pass them as parameters.\n- Per-breakpoint canvases have separate variables: shared state lives in `page_variables`.\n- A function variable named like a formula function is never called (the built-in wins).\n- Formula syntax errors and unknown names in formulas are reported by the render command (the SDK parses them).\n- A misspelled binding path sets nothing.',
    words: 6913,
    items: ['valueChanged', 'actionError', 'setVariable', 'setValue', 'setVariant', 'callFunction', 'if', 'forEach', 'delay', 'runScript', 'retryFailed'],
    sections: [
      DocSection('state-variables', 'Variables', 'Declare them in the document\'s `variables`, under a canvas id (that canvas only) or under `"page_variables"` (every\ncanvas of the document, kept while the user moves between them). A site\'s `site.json` adds project variables, read\nby bare name in every page and component. A variable\'s keys:\n\n| Key | Example | Meaning |\n|---|---|---|\n| `id` | `"v1"` |  |\n| `name` | `"count"` | Unique in its scope; what expressions read (`\${name}`). |\n| `type` | `"integer"` |  |\n| `value` | `3` | The default value, as `type` holds it (see `VariableType.coerce`); null when unset. |\n| `formula` | `"a + 1"` | The expression (what goes in `\${= ...}`) that computes the value of a computed variable; empty for a plain one. A computed variable is read-only: it changes when what its formula reads changes. |\n| `parameters` | `["a"]` | A computed variable with parameters is a function: formulas call it by name (`clamp01(x)`), and its `formula` reads the arguments by these names. |\n| `options` | `["a"]` | The options of a `VariableType.choice` variable. |\n| `persist` | `true` | Whether the app keeps the value on the device: it starts from the value it had last time (not `value`) and every change is saved. A draft, a list the user builds up. A computed variable can\'t persist (`persists`). |\n\nTypes:\n\n| Value | Meaning |\n|---|---|\n| `integer` | A whole number (`int`). |\n| `text` | Text (`String`). |\n| `decimal` | A number with decimals (`double`). |\n| `boolean` | `true` or `false`. |\n| `color` | A color, `#AARRGGBB`. |\n| `list` | A JSON list. |\n| `map` | A JSON object. |\n| `image` | An image URL. |\n| `choice` | One of `Variable.options`, stored as the option\'s value. |'),
      DocSection('state-expressions', 'Expressions', '`\${name}` or `\${path}` reads a value: `\${count}`, `\${user.name}`, `\${items[0].price}`, `\${pal[item.kind]}`.\n`\${= formula}` computes one: arithmetic (`+ - * / %`), comparisons (`== != < <= > >=`), `&&`, `||`, `!`,\n`cond ? a : b`, `a ?? b` (`b` when `a` is null; `coalesce` also passes over empty text), literals (`\'text\'`, `3.5`, `true`, `null`, lists `[1, 2]`), and lambdas for list functions\n(`x => x.price`). A text that is exactly one expression gives its value with its type; inside other text a number is\nprinted without trailing zeros. Names an expression may start with, besides the variables: `data`, `route`, `storage`, `screen`, `device`, `theme`, `item`, `index`, `parent`, `result`, `loop`, `auth`, `drag`, `perf`, `track`, `dismiss`, `pan`, `transform`, `flip`, `tilt`, `view`, `sticky`, `script`, `speech`, `pageOffset`, `form`. The\nnames a node gives the nodes inside it are read there only: `item`, `index`, `parent` in a list\'s item; `pageOffset`\nin a `pageView`\'s page (its distance from the current page, for parallax; not the page\'s scroll); `form` inside a\n`form`; `track`, `sticky`, `view` and the like inside their node. A page\'s or a list\'s scroll position is its `scroll`\nreaction\'s `\${result.offset}` (and `index`, `fraction`), stored in a variable that anything may bind.'),
      DocSection('state-binding-paths', 'Binding paths', 'What each path of `bind` expects. A formula gives the value as the field is written in JSON: a number, `true` /\n`false`, a name for an enum, a list or an object for the fields written that way. A value of another shape is not\nread and the field keeps its value. Values are read loosely: `"12"` is a number, `1` and `"true"` are true.\n\n| Path | Type | A formula gives |\n|---|---|---|\n| `visible` | `bool` | `true` or `false` |\n| `opacity` | `double` | a number |\n| `selected` | `bool` | `true` or `false` |\n| `disabled` | `bool` | `true` or `false` |\n| `data` | `List` | a list |\n| `layout.width` | `AxisSize` | a number (fixed) or {"fill"\\|"flexible"\\|"hug"\\|"fixed": number} |\n| `layout.height` | `AxisSize` | a number (fixed) or {"fill"\\|"flexible"\\|"hug"\\|"fixed": number} |\n| `layout.constraints` | `BoxConstraints` | {"minWidth", "maxWidth", "minHeight", "maxHeight"} (each optional, numbers >= 0) |\n| `layout.margin` | `EdgeInsets` | a number (all sides), [horizontal, vertical] or [left, top, right, bottom] |\n| `layout.padding` | `EdgeInsets` | a number (all sides), [horizontal, vertical] or [left, top, right, bottom] |\n| `layout.aspectRatio` | `double` | a number |\n| `layout.widthFactor` | `double` | a number |\n| `layout.heightFactor` | `double` | a number |\n| `layout.flex` | `int` | a whole number |\n| `layout.squeezable` | `bool` | `true` or `false` |\n| `layout.x` | `AxisPosition` | a number (distance from the start) or {"start": d}, {"end": d}, {"start": a, "end": b}, {"align": -1..1}, {"relative": d} |\n| `layout.y` | `AxisPosition` | a number (distance from the start) or {"start": d}, {"end": d}, {"start": a, "end": b}, {"align": -1..1}, {"relative": d} |\n| `layout.align` | `Alignment` | [x, y] from -1 to 1, or a name: topLeft, topCenter, topRight, centerLeft, center, centerRight, bottomLeft, bottomCenter, bottomRight |\n| `layout.order` | `int` | a whole number |\n| `layout.basis` | `double` | a number |\n| `layout.columnSpan` | `int` | a whole number |\n| `layout.rowSpan` | `int` | a whole number |\n| `layout.columnStart` | `int` | a whole number |\n| `layout.rowStart` | `int` | a whole number |\n| `decoration.fills` | `List<Paint>` | a list of Paint objects |\n| `decoration.strokes` | `List<Paint>` | a list of Paint objects |\n| `decoration.strokeWidth` | `double` | a number |\n| `decoration.strokeAlign` | `StrokeAlign` | one of its names ([StrokeAlign](values.md#enum-StrokeAlign)) |\n| `decoration.strokeSides` | `StrokeSides` | one of its names ([StrokeSides](values.md#enum-StrokeSides)) |\n| `decoration.strokeCap` | `StrokeCap` | one of its names ([StrokeCap](values.md#enum-StrokeCap)) |\n| `decoration.dashPattern` | `List<double>` | a list of double objects |\n| `decoration.radius` | `BorderRadius` | a number (every corner), [x, y] (every corner elliptical) or [topLeft, topRight, bottomRight, bottomLeft] (each a number or [x, y]) |\n| `decoration.effects` | `List<Effect>` | a list of Effect objects |\n| `decoration.clip` | `Clip` | one of its names ([Clip](values.md#enum-Clip)) |\n| `decoration.blendMode` | `BlendMode` | one of its names ([BlendMode](values.md#enum-BlendMode)) |\n| `decoration.foregroundFills` | `List<Paint>` | a list of Paint objects |\n\n(Continues: state.md#state-binding-paths.)'),
      DocSection('state-conditions', 'Conditions', 'An if / else-if / else rule. Its first branch whose test holds and that sets a property gives the property its value; when none does, the property keeps its binding\'s or its own value. JSON:\n\n```json\n{"id": "c1", "name": "Low stock", "branches": [\n  {"when": {"left": "\${stock}", "op": "lessThan", "right": "5"},\n   "set": [{"node": "badge", "path": "visible", "value": true}]},\n  {"set": [{"node": "badge", "path": "visible", "value": false}]}]}\n\n```\n\n- Branch: One branch: when `when` holds (always, for an `else`: null), the properties in `sets` take their values.\n- Set entry: Sets property `path` (a binding path, DESIGN.md §5.1) of node `node` to `value`: a JSON value, where a string is an expression read like a binding\'s (`\${= qty * 2}`, `#FF0000`, `Hello \${name}`).\n- Comparison: `left op right` (the right side only for ops that `ConditionOp.takesRight`).\n- Junction: All of `parts` (`and`) or any of them (`or`). Every part is evaluated. JSON: `{"and": [...]}` / `{"or": [...]}`.\n- Operand: One side of a `Comparison`: an expression text whose `\${...}` are read (`\${count}`, `\${= a + b}`, `3`, `done`), or, when `raw`, a literal taken as written. Both are then parsed loosely (`3` is a number, `true` a bool, `[1, 2]` a list). JSON: the text, or `{"raw": text}`.\n\n| op | Reads right | Meaning |\n|---|---|---|\n| `equalsTo` | yes |  |\n| `notEqualsTo` | yes |  |\n| `greaterThan` | yes |  |\n| `lessThan` | yes |  |\n| `greaterThanOrEqualTo` | yes |  |\n| `lessThanOrEqualTo` | yes |  |\n| `isEmpty` | no | Null, or an empty text, list or map. |\n| `isNotEmpty` | no |  |\n| `contains` | yes | A list holds the right operand, a text contains it, a map has it as a key. |\n| `isOdd` | no |  |\n| `isEven` | no |  |\n| `isNull` | no | Null, or the text `null`. |\n| `isTrue` | no |  |\n| `isFalse` | no |  |'),
      DocSection('state-scripts', 'Scripts', 'A document\'s sandboxed JavaScript (`scripts`), run by `runScript` or called from a formula (`script.name(...)`).\n\n| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `id` | String | `""` |  |  |\n| `name` | String | `""` |  | A JavaScript identifier: script.<name>(...). |\n| `description` | String | `""` |  |  |\n| `params` | Object | unset |  | [{"name", "description", "defaultValue"}]. |\n| `source` | String | `""` |  | JavaScript. |\n| `version` | int | `1` |  | Goes up each time the script is saved. |\n| `capabilities` | List<String> | `[]` |  | What it may do: variables.read, variables.write, nodes.read, navigation, api, cloud, actions, clock. |\n| `timeoutMs` | int | `1000` | ≥ 1 |  |\n| `memoryLimitMb` | int | `32` | ≥ 1 | Enforced on devices; on the web only `timeoutMs` applies. |\n| `pageId` | String | unset |  | Null: a project script. |\n| `tests` | Object | unset |  | Sample runs: [{"name", "args", "vars", "nodes", "expect", "expectError"}]. |'),
      DocSection('state-formula-functions', 'Formula functions', 'The functions a formula (`\${= ...}`) can call, from the SDK\'s formula engine, grouped.\n\nTime zones are **UTC offsets**, not IANA names: `now(\'-06:00\')`, `formatDate(now(\'+01:00\'), \'HH:mm\')`. The formula\nengine has no time zone database, so `now(\'America/Chicago\')` is not a zone and daylight saving time is not applied.\nFor a place that changes its clocks, pick the offset by date in the formula (Chicago, US rules: `now(month(now()) > 3\n&& month(now()) < 11 ? \'-05:00\' : \'-06:00\')`, exact except in the weeks of March and November when the clocks\nchange), or have the host app pass the offset in (a variable it sets).\n\n#### Text\n\n| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-left"></a>`left` | `left(text, count)` | `left("MX4821", 2) → MX` |\n| <a id="fn-right"></a>`right` | `right(text, count)` | `right("1FUJGLDR5MX4821", 6) → MX4821` |\n| <a id="fn-upper"></a>`upper` | `upper(text)` | `upper("hi") → HI` |\n| <a id="fn-lower"></a>`lower` | `lower(text)` | `lower("Hi") → hi` |\n| <a id="fn-trim"></a>`trim` | `trim(text)` | `trim("  hi ") → hi` |\n| <a id="fn-contains"></a>`contains` | `contains(text or list, value)` | `contains(lower(title), lower(search)) → true` |\n| <a id="fn-startsWith"></a>`startsWith` | `startsWith(text, prefix)` | `startsWith("Buy milk", "Buy") → true` |\n| <a id="fn-endsWith"></a>`endsWith` | `endsWith(text, suffix)` | `endsWith("photo.png", ".png") → true` |\n| <a id="fn-padLeft"></a>`padLeft` | `padLeft(value, width, char)` | `padLeft(4, 2) → 04 (numbers pad with 0, text with spaces)` |\n| `padLeft` | `padLeft(text, width, char?)` | `padLeft(42, 5, "0") → 00042` |\n| <a id="fn-padRight"></a>`padRight` | `padRight(value, width, char)` | `padRight("A", 3, ".") → A..` |\n| `padRight` | `padRight(text, width, char?)` | `padRight("ab", 4, ".") → ab..` |\n| <a id="fn-substring"></a>`substring` | `substring(text, start, end)` | `substring("Vinyl", 0, 3) → Vin` |\n| `substring` | `substring(text, start, end?)` | `substring("EX-102", 3) → 102` |\n| <a id="fn-replace"></a>`replace` | `replace(text, from, to)` | `replace("a-b-c", "-", " ") → a b c` |\n| `replace` | `replace(text, from, to)` | `replace("1,402", ",", "") → 1402` |\n| <a id="fn-regexReplace"></a>`regexReplace` | `regexReplace(text, pattern, to)` | `regexReplace("WILLOW PHARMACY 044", " [0-9]+\$", "") → WILLOW PHARMACY; \$1 in to inserts a group` |\n| <a id="fn-titleCase"></a>`titleCase` | `titleCase(text)` | `titleCase("SQ *KESTREL FLOWERS") → Sq *Kestrel Flowers` |\n| <a id="fn-split"></a>`split` | `split(text, separator)` | `split("rock, jazz", ", ") → [rock, jazz]` |\n| `split` | `split(text, separator?)` | `split("2481") → [2, 4, 8, 1]` |\n| <a id="fn-matches"></a>`matches` | `matches(text, pattern)` | `matches(code, "^\\d{4}\$") → true; JavaScript patterns, with (?i) (?s) (?m) at the start: matches(url, "(?i)^https?://")` |\n| <a id="fn-regexMatches"></a>`regexMatches` | `regexMatches(text, pattern)` | `regexMatches("call 555-0100 or 555-0199", "\\d{3}-\\d{4}") → [{start: 5, end: 13, text: 555-0100, groups: []}, …]; the runs of a text: map(regexMatches(t, "#\\w+"), m => {start: m.start, end: m.end, link: m.text})` |\n\n(Continues: state.md#state-formula-functions.)'),
      DocSection('state-text', 'Text', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-left"></a>`left` | `left(text, count)` | `left("MX4821", 2) → MX` |\n| <a id="fn-right"></a>`right` | `right(text, count)` | `right("1FUJGLDR5MX4821", 6) → MX4821` |\n| <a id="fn-upper"></a>`upper` | `upper(text)` | `upper("hi") → HI` |\n| <a id="fn-lower"></a>`lower` | `lower(text)` | `lower("Hi") → hi` |\n| <a id="fn-trim"></a>`trim` | `trim(text)` | `trim("  hi ") → hi` |\n| <a id="fn-contains"></a>`contains` | `contains(text or list, value)` | `contains(lower(title), lower(search)) → true` |\n| <a id="fn-startsWith"></a>`startsWith` | `startsWith(text, prefix)` | `startsWith("Buy milk", "Buy") → true` |\n| <a id="fn-endsWith"></a>`endsWith` | `endsWith(text, suffix)` | `endsWith("photo.png", ".png") → true` |\n| <a id="fn-padLeft"></a>`padLeft` | `padLeft(value, width, char)` | `padLeft(4, 2) → 04 (numbers pad with 0, text with spaces)` |\n| `padLeft` | `padLeft(text, width, char?)` | `padLeft(42, 5, "0") → 00042` |\n| <a id="fn-padRight"></a>`padRight` | `padRight(value, width, char)` | `padRight("A", 3, ".") → A..` |\n| `padRight` | `padRight(text, width, char?)` | `padRight("ab", 4, ".") → ab..` |\n| <a id="fn-substring"></a>`substring` | `substring(text, start, end)` | `substring("Vinyl", 0, 3) → Vin` |\n| `substring` | `substring(text, start, end?)` | `substring("EX-102", 3) → 102` |\n| <a id="fn-replace"></a>`replace` | `replace(text, from, to)` | `replace("a-b-c", "-", " ") → a b c` |\n| `replace` | `replace(text, from, to)` | `replace("1,402", ",", "") → 1402` |\n| <a id="fn-regexReplace"></a>`regexReplace` | `regexReplace(text, pattern, to)` | `regexReplace("WILLOW PHARMACY 044", " [0-9]+\$", "") → WILLOW PHARMACY; \$1 in to inserts a group` |\n| <a id="fn-titleCase"></a>`titleCase` | `titleCase(text)` | `titleCase("SQ *KESTREL FLOWERS") → Sq *Kestrel Flowers` |\n| <a id="fn-split"></a>`split` | `split(text, separator)` | `split("rock, jazz", ", ") → [rock, jazz]` |\n| `split` | `split(text, separator?)` | `split("2481") → [2, 4, 8, 1]` |\n| <a id="fn-matches"></a>`matches` | `matches(text, pattern)` | `matches(code, "^\\d{4}\$") → true; JavaScript patterns, with (?i) (?s) (?m) at the start: matches(url, "(?i)^https?://")` |\n| <a id="fn-regexMatches"></a>`regexMatches` | `regexMatches(text, pattern)` | `regexMatches("call 555-0100 or 555-0199", "\\d{3}-\\d{4}") → [{start: 5, end: 13, text: 555-0100, groups: []}, …]; the runs of a text: map(regexMatches(t, "#\\w+"), m => {start: m.start, end: m.end, link: m.text})` |\n| <a id="fn-slug"></a>`slug` | `slug(text)` | `slug("Kind of Blue!") → kind-of-blue` |\n| <a id="fn-charCode"></a>`charCode` | `charCode(text, index)` | `charCode("MX", 1) → 88` |\n| <a id="fn-fromCharCode"></a>`fromCharCode` | `fromCharCode(code, …) or fromCharCode(list)` | `fromCharCode(65 + seat) → B` |\n| <a id="fn-codeUnits"></a>`codeUnits` | `codeUnits(text)` | `sum(codeUnits(tag)) % 8 → a stable color index for tag` |\n| <a id="fn-join"></a>`join` | `join(list, separator, field or item => value)` | `join(tags, " · ")` |\n| <a id="fn-pad"></a>`pad` | `pad(value, width, fill)` | `pad(5, 2) → 05` |\n| <a id="fn-text"></a>`text` | `text(value)` | `text(42) → "42"` |\n\n(Continues: state.md#state-text.)'),
      DocSection('state-numbers-and-math', 'Numbers and math', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-round"></a>`round` | `round(value, decimals)` | `round(4.567, 1) → 4.6` |\n| <a id="fn-floor"></a>`floor` | `floor(value)` | `floor(4.7) → 4` |\n| <a id="fn-ceil"></a>`ceil` | `ceil(value)` | `ceil(4.2) → 5` |\n| <a id="fn-abs"></a>`abs` | `abs(value)` | `abs(-3) → 3` |\n| <a id="fn-min"></a>`min` | `min(a, b, …) or min(list)` | `min(3, 7) → 3` |\n| <a id="fn-max"></a>`max` | `max(a, b, …) or max(list)` | `max(3, 7) → 7` |\n| <a id="fn-sqrt"></a>`sqrt` | `sqrt(value)` | `sqrt(16) → 4` |\n| <a id="fn-pow"></a>`pow` | `pow(base, exponent)` | `pow(2, 10) → 1024` |\n| <a id="fn-exp"></a>`exp` | `exp(value)` | `exp(1) → 2.71828… (zoom by exp(-delta / 500))` |\n| <a id="fn-ln"></a>`ln` | `ln(value)` | `ln(exp(2)) → 2` |\n| <a id="fn-log"></a>`log` | `log(value, base?)` | `log(1000) → 3, log(8, 2) → 3` |\n| <a id="fn-sign"></a>`sign` | `sign(value)` | `sign(-4) → -1` |\n| <a id="fn-hypot"></a>`hypot` | `hypot(x, y)` | `hypot(3, 4) → 5` |\n| <a id="fn-sin"></a>`sin` | `sin(radians)` | `sin(pi() / 2) → 1` |\n| <a id="fn-cos"></a>`cos` | `cos(radians)` | `cos(0) → 1` |\n| <a id="fn-tan"></a>`tan` | `tan(radians)` | `tan(0) → 0` |\n| <a id="fn-asin"></a>`asin` | `asin(value)` | `asin(1) → 1.5708` |\n| <a id="fn-acos"></a>`acos` | `acos(value)` | `acos(1) → 0` |\n| <a id="fn-atan"></a>`atan` | `atan(value)` | `atan(1) → 0.7854` |\n| <a id="fn-atan2"></a>`atan2` | `atan2(y, x)` | `atan2(1, 1) → 0.7854` |\n| <a id="fn-pi"></a>`pi` | `pi or pi()` | `pi → 3.14159…` |\n| <a id="fn-radians"></a>`radians` | `radians(degrees)` | `radians(180) → 3.14159…` |\n| <a id="fn-degrees"></a>`degrees` | `degrees(radians)` | `degrees(pi()) → 180` |\n| <a id="fn-clamp"></a>`clamp` | `clamp(value, min, max)` | `clamp(12, 0, 10) → 10` |\n| <a id="fn-distance"></a>`distance` | `distance(lat1, lng1, lat2, lng2, \'km\' or \'mi\')` | `distance(a.lat, a.lng, b.lat, b.lng, \'mi\') → 362.4` |\n| <a id="fn-number"></a>`number` | `number(value)` | `number("42") → 42` |\n| <a id="fn-random"></a>`random` | `random() · random(n) · random(a, b)` | `random(1, 6) → a whole number from 1 to 6` |\n| <a id="fn-fill"></a>`fill` | `fill(template, map or list)` | `fill("{i} of {n}", {i: 1, n: 10}) → 1 of 10` |\n| <a id="fn-fixed"></a>`fixed` | `fixed(value, decimals)` | `fixed(4.5, 2) → 4.50` |\n| <a id="fn-feetInches"></a>`feetInches` | `feetInches(feet)` | `feetInches(6.67) → 6′ 8″` |\n| <a id="fn-thousands"></a>`thousands` | `thousands(value, decimals)` | `thousands(1094) → 1,094` |\n| <a id="fn-seconds"></a>`seconds` | `seconds("m:ss" or "h:mm:ss")` | `seconds("3:45") → 225` |\n| <a id="fn-duration"></a>`duration` | `duration(seconds)` | `duration(225) → 3:45` |'),
      DocSection('state-money-and-number-formatting', 'Money and number formatting', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-money"></a>`money` | `money(value, symbol, decimals) or money(value, decimals); a currency code as the symbol is that currency\'s symbol` | `money(price) → \$1,234.50; money(9, "USD") → \$9.00` |\n| <a id="fn-currency"></a>`currency` | `currency(value, code, options?)` | `currency(-1234.5, "EUR") → −1.234,50 €; currency(42, "USD", "signed") → +\$42.00` |\n| <a id="fn-parseAmount"></a>`parseAmount` | `parseAmount(text, code)` | `parseAmount("1.234,50", "EUR") → 1234.5` |\n| <a id="fn-formatAmount"></a>`formatAmount` | `formatAmount(text, code)` | `formatAmount("12345.6", "USD") → 12,345.6` |\n| <a id="fn-currencySymbol"></a>`currencySymbol` | `currencySymbol(code)` | `currencySymbol("GBP") → £` |\n| <a id="fn-currencyDecimals"></a>`currencyDecimals` | `currencyDecimals(code)` | `currencyDecimals("JPY") → 0` |\n| <a id="fn-formatNumber"></a>`formatNumber` | `formatNumber(value, digits?, locale?)` | `formatNumber(2481.64, 1) → 2,481.6 · formatNumber(1234.5, 1, "ar_EG") → ١٬٢٣٤٫٥` |\n| <a id="fn-formatCurrency"></a>`formatCurrency` | `formatCurrency(value, currencyCode, locale?, decimals?)` | `formatCurrency(1234.5, "EUR", "fr_FR") → 1 234,50 € · formatCurrency(1500, "JPY", "ja_JP") → ¥1,500` |\n| <a id="fn-formatPercent"></a>`formatPercent` | `formatPercent(value, locale?, decimals?)` | `formatPercent(0.42) → 42% · formatPercent(0.42, "fr_FR") → 42 %` |'),
      DocSection('state-lists', 'Lists', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-sum"></a>`sum` | `sum(list, field or item => value)` | `sum(cart, i => i.price * i.qty) → 24` |\n| <a id="fn-count"></a>`count` | `count(list, item => condition) or count(list, field, value)` | `count(tasks, t => !t.done) → 2` |\n| <a id="fn-length"></a>`length` | `length(text or list)` | `length(cart) → 3` |\n| <a id="fn-filter"></a>`filter` | `filter(list, item => condition) or filter(list, field, value)` | `filter(tasks, t => contains(lower(t.title), lower(search)))` |\n| <a id="fn-where"></a>`where` | `where(list, field, value) or where(list, item => condition)` | `where(tasks, "done", false)` |\n| <a id="fn-find"></a>`find` | `find(list, item => condition) or find(list, field, value)` | `find(users, u => u.id == userId)` |\n| <a id="fn-any"></a>`any` | `any(list, item => condition) or any(list, field, value)` | `any(tasks, t => t.due < today()) → true` |\n| <a id="fn-all"></a>`all` | `all(list, item => condition) or all(list, field, value)` | `all(tasks, "done") → false` |\n| <a id="fn-map"></a>`map` | `map(list, field or item => value or (item, index) => value)` | `map(cart, i => i.price * i.qty) → [8, 16]` |\n| <a id="fn-sortBy"></a>`sortBy` | `sortBy(list, field or item => key, "desc", more keys…)` | `sortBy(records, r => r.artist, r => r.year, "desc") (missing keys last)` |\n| <a id="fn-sortByDesc"></a>`sortByDesc` | `sortByDesc(list, field or item => key, more keys…)` | `sortByDesc(records, "year")` |\n| <a id="fn-findIndex"></a>`findIndex` | `findIndex(list, item => condition) or findIndex(list, field, value)` | `findIndex(records, r => r.id == selectedId) → 2 (-1 when none)` |\n| `findIndex` | `findIndex(list, item => condition) or findIndex(list, field, value)` | `findIndex(tasks, "id", id) → 2 (-1 when missing)` |\n| <a id="fn-fuzzy"></a>`fuzzy` | `fuzzy(list, query, item => text, tolerance, "keep")` | `fuzzy(episodes, q, e => e.title) (best first; fuzzy(people, q, p => p.name, 3, "keep"): 3 letters off per word, in list order)` |\n| <a id="fn-fuzzyScore"></a>`fuzzyScore` | `fuzzyScore(text, query, tolerance)` | `fuzzyScore(title, q) → 100` |\n| <a id="fn-matchRanges"></a>`matchRanges` | `matchRanges(text, query, tolerance)` | `matchRanges(title, q) → [[0, 5]]` |\n| <a id="fn-matchRuns"></a>`matchRuns` | `matchRuns(text, query, tolerance)` | `matchRuns(title, q) → text runs` |\n| <a id="fn-matchReason"></a>`matchReason` | `matchReason(text, query, tolerance)` | `matchReason(title, q) → Exact phrase` |\n| <a id="fn-groupBy"></a>`groupBy` | `groupBy(list, field or item => key) → [{key, items, count}]` | `groupBy(txns, "date") → one entry per day, in order of first appearance` |\n| <a id="fn-unique"></a>`unique` | `unique(list, field or item => key)` | `unique(tags) or unique(tasks, "category")` |\n| <a id="fn-without"></a>`without` | `without(list, other or item) or without(map, keys)` | `without(held, 64) or without(task, ["draft", "tmp"])` |\n| <a id="fn-concat"></a>`concat` | `concat(list or item, ...)` | `concat([record.art], sleeves) or list1 + list2` |\n| `concat` | `concat(list, list2, ...)` | `concat(range(2), [9]) → [0, 1, 9]` |\n\n(Continues: state.md#state-lists.)'),
      DocSection('state-objects', 'Objects', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-object"></a>`object` | `object(key, value, key, value, …)` | `object(\'nights\', 2, \'cg\', id) → {nights: 2, cg: id}` |\n| <a id="fn-obj"></a>`obj` | `obj(key, value, key2, value2, ...)` | `obj("id", "ex1", "hours", 12) → {id: ex1, hours: 12}` |\n| <a id="fn-merge"></a>`merge` | `merge(map, map, …)` | `merge(stop, object(\'nights\', 3)) → stop with 3 nights` |\n| <a id="fn-set"></a>`set` | `set(map, key, value, …) or set(list, index, value)` | `set(rig, \'length\', 36) → rig, 36 ft long` |\n| <a id="fn-keys"></a>`keys` | `keys(map)` | `keys(rig) → [name, length, …]` |\n| <a id="fn-values"></a>`values` | `values(map)` | `values(totals) → [3, 5]` |\n| <a id="fn-get"></a>`get` | `get(map or list, key)` | `get(lineNames, item.line) → \'Weld\'` |\n| <a id="fn-unset"></a>`unset` | `unset(map, key)` | `unset(task, "draft")` |\n| <a id="fn-with"></a>`with` | `with(map, key, value, …)` | `with(item, \'x\', item.x + 1) → item with x changed` |\n| <a id="fn-newId"></a>`newId` | `newId(prefix)` | `newId("task") → task_k3x9f2` |'),
      DocSection('state-dates-and-time', 'Dates and time', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-now"></a>`now` | `now(utcOffset?)` | `now() → 2026-10-21T14:30:00.000, now("-07:00") at UTC−7` |\n| <a id="fn-nowMs"></a>`nowMs` | `nowMs()` | `nowMs() → 1793356053036, milliseconds since 1970 (time taps: 60000 / (nowMs() - lastTap) is a tempo)` |\n| <a id="fn-today"></a>`today` | `today(utcOffset?)` | `today() → 2026-10-21T00:00:00.000` |\n| <a id="fn-wallTime"></a>`wallTime` | `wallTime(dateWithOffset)` | `wallTime("2026-10-22T07:25:17-07:00") → 2026-10-22T07:25:17.000` |\n| <a id="fn-parseDate"></a>`parseDate` | `parseDate(text or millis)` | `parseDate("10/21/2026") or parseDate("Oct 21, 2026") → 2026-10-21; null when not a real date` |\n| <a id="fn-formatDate"></a>`formatDate` | `formatDate(date, pattern or style, locale?)` | `formatDate(now(), "EEE, MMM d · h:mm a") → Wed, Oct 21 · 2:30 PM · formatDate(today(), "full", "fr_FR") → jeudi 30 octobre 2026` |\n| <a id="fn-addSeconds"></a>`addSeconds` | `addSeconds(date, seconds)` | `addSeconds(start, 90)` |\n| <a id="fn-diffSeconds"></a>`diffSeconds` | `diffSeconds(from, to)` | `diffSeconds(startedAt, now()) → 240` |\n| <a id="fn-formatDuration"></a>`formatDuration` | `formatDuration(seconds, pattern)` | `formatDuration(6480, \'h:mm:ss\') → 1:48:00 · \'mm:ss\' → 108:00 · \'compact\' → 1h 48m` |\n| <a id="fn-addMinutes"></a>`addMinutes` | `addMinutes(date, minutes)` | `addMinutes(start, 90)` |\n| <a id="fn-addHours"></a>`addHours` | `addHours(date, hours)` | `addHours(now(), 2)` |\n| <a id="fn-addDays"></a>`addDays` | `addDays(date, days)` | `addDays(today(), 7)` |\n| <a id="fn-addMonths"></a>`addMonths` | `addMonths(date, months)` | `addMonths("2026-01-31", 1) → 2026-02-28T00:00:00.000` |\n| <a id="fn-diffMinutes"></a>`diffMinutes` | `diffMinutes(from, to)` | `diffMinutes(start, end) → 45` |\n| <a id="fn-diffHours"></a>`diffHours` | `diffHours(from, to)` | `diffHours(start, end) → 3` |\n| <a id="fn-diffDays"></a>`diffDays` | `diffDays(from, to)` | `diffDays(today(), dueDate) → 5` |\n| <a id="fn-timeAgo"></a>`timeAgo` | `timeAgo(date, style?, locale?, labels?)` | `timeAgo(sentAt) → now · 5m · 3h · Yesterday · 3d · Mar 4 · timeAgo(sentAt, "long") → 5 minutes ago (alias formatRelative)` |\n| <a id="fn-formatRelative"></a>`formatRelative` | `formatRelative(date, style?, locale?, labels?)` | `formatRelative(sentAt) → 3h (the same as timeAgo)` |\n| <a id="fn-isToday"></a>`isToday` | `isToday(date)` | `isToday(sentAt) → true` |\n| <a id="fn-isPast"></a>`isPast` | `isPast(date)` | `isPast(expiresAt) → true once it has passed (checked every minute)` |\n| <a id="fn-isFuture"></a>`isFuture` | `isFuture(date)` | `isFuture(startsAt) → true until it comes (checked every minute)` |\n| <a id="fn-isSameDay"></a>`isSameDay` | `isSameDay(a, b)` | `isSameDay(a.sentAt, b.sentAt) → false` |\n| <a id="fn-isBefore"></a>`isBefore` | `isBefore(a, b)` | `isBefore(expiresAt, now()) → true` |\n| <a id="fn-isAfter"></a>`isAfter` | `isAfter(a, b)` | `isAfter(startsAt, now()) → false` |\n| <a id="fn-year"></a>`year` | `year(date)` | `year("2026-10-21") → 2026` |\n| <a id="fn-month"></a>`month` | `month(date)` | `month("2026-10-21") → 10` |\n\n(Continues: state.md#state-dates-and-time.)'),
      DocSection('state-colors', 'Colors', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-luminance"></a>`luminance` | `luminance(color)` | `luminance("#FFFFFF") → 1` |\n| <a id="fn-mix"></a>`mix` | `mix(color1, color2, amount)` | `mix(\'#FFFFFF\', \'#000000\', 0.25) → #BFBFBF` |\n| `mix` | `mix(colorA, colorB, t)` | `mix(\'#000000\', \'#FFFFFF\', 0.5) → #FF808080` |\n| <a id="fn-alpha"></a>`alpha` | `alpha(color, opacity)` | `alpha(\'#FF4D4F\', 0.12) → #1FFF4D4F` |\n| <a id="fn-lerpColor"></a>`lerpColor` | `lerpColor(colorA, colorB, t), same as mix` | `lerpColor(\'#FF4D4F\', \'#1677FF\', 0.25) → #FFC5587B` |'),
      DocSection('state-logic', 'Logic', '| Function | Signature | Example |\n|---|---|---|\n| <a id="fn-if"></a>`if` | `if(condition, then, else)` | `if(qty > 1, "items", "item")` |\n| <a id="fn-coalesce"></a>`coalesce` | `coalesce(value, fallback, ...)` | `coalesce(route.date, today())` |'),
      DocSection('state-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-valueChanged"></a>`valueChanged` | Variable `Trigger.variable` changed while the screen shows. |\n| <a id="trigger-actionError"></a>`actionError` | On the current canvas: a failed action chain or cloud subscription. `\${result.error}` is `{type, message, action, nodeId}` (no stack or raw service objects). A failure in this reaction reports to the host without recursively firing another actionError reaction. |'),
      DocSection('state-computed-and-function-variables', 'Computed and function variables', 'A variable with a `formula` (what goes in `\${= ...}`) is read-only and follows what it reads; with `parameters` it\nis a function any formula calls by name. Declare them in `page_variables` to share them with every canvas of the\ndocument:\n\n```json\n"variables": {"page_variables": [\n  {"name": "query", "type": "text", "value": ""},\n  {"name": "dishes", "type": "list", "value": [{"name": "Lamb", "vegan": false}, {"name": "Squash", "vegan": true}]},\n  {"name": "shown", "type": "list", "formula": "filter(dishes, d => contains(lower(d.name), lower(query)))"},\n  {"name": "shownCount", "type": "integer", "formula": "length(shown)"},\n  {"name": "usd", "type": "text", "parameters": ["n"], "formula": "\'\$\' + round(n)"}\n]}\n```\n\n`\${shown}` feeds a list, `\${shownCount}` a label, `\${= usd(price * 12)}` any text: write a filter or a rule once,\nnot in every binding. A function variable\'s name must not be a formula function\'s (the built-in one wins).'),
      DocSection('state-a-streak-and-other-counts-from-data', 'A streak and other counts from data', 'Derive, do not store: a computed variable over the records. Habits done today: `count(habits, h => h.done)`.\nTotals: `sum(map(cart, i => i.price * i.qty))`. Dates: `formatDate(today(), \'EEE d\')`, `addDays(today(), -i)`,\n`weekday(date)` (Monday is 1). Function variables may call each other. A streak (checked days in a row ending at\nday `end` of a list of booleans): the days up to `end`, reversed, and the index of the first unchecked one.\n\n```json\n"variables": {"page_variables": [\n  {"name": "todayIdx", "type": "integer", "formula": "weekday(today()) - 1"},\n  {"name": "gapAt", "type": "integer", "parameters": ["days", "end"], "formula": "findIndex(reverse(take(days, end + 1)), d => !d)"},\n  {"name": "streak", "type": "integer", "parameters": ["days", "end"], "formula": "gapAt(days, end) < 0 ? end + 1 : gapAt(days, end)"}\n]}\n```\n\n`\${= streak(item.days, todayIdx)}` in a habit\'s row; `\${= streak(item.days, todayIdx - 1)}` when today is not\nchecked yet. For anything with a real loop, a script.'),
      DocSection('state-changing-state-from-a-reaction', 'Changing state from a reaction', '`setVariable` with `op`: `set` (default), `toggle`, `add` (a number adds; a list appends; a map merges),\n`subtract`, `insert` / `removeAt` / `update` at `index`, `remove`. `value` is an expression. A chain that branches:\n`if` with a `condition` (a predicate: `{"left": "\${count}", "op": "greaterThan", "right": "5"}`, `{"left":\n"\${name}", "op": "isEmpty"}`; every op is in [Conditions](#state-conditions)) and `then` / `else` chains. Every\naction also takes `when`, the same kind of predicate object (run only while it holds); a trigger\'s `when` is a\nformula string instead (`"when": "!item.future"`). `forEach` runs a chain per item; `delay` waits.\n\n```json\n{"type": "if", "condition": {"left": "\${= contains(saved, trip.id)}", "op": "isTrue"},\n "then": [{"type": "setVariable", "variable": "saved", "op": "remove", "value": "\${trip.id}"}],\n "else": [{"type": "setVariable", "variable": "saved", "op": "add", "value": "\${trip.id}"}]}\n```\n\nOne line of a list, from its own row of a list template (a cart\'s quantity stepper): `update` at the row\'s `index`\nwith the row\'s record changed. `value` is one expression giving the new record (`set` changes one field), not an\nobject written out:\n\n```json\n{"type": "setVariable", "variable": "cart", "op": "update", "index": "\${index}", "value": "\${= set(item, \'qty\', item.qty + 1)}"}\n```\n\nThe condition is an object, never a formula string: a formula goes in `left` with `"op": "isTrue"`.'),
      DocSection('state-setting-several-nodes-with-a-condition', 'Setting several nodes with a condition', 'A condition sets node fields while a test holds: an ordered list of branches (if, else if, ..., else) under a canvas\nid in the document\'s `conditions`. For one field the first branch that holds and sets it wins; a condition wins\nover the node\'s binding. A binding with a formula is often simpler; conditions suit setting several nodes at once.\n\n```json\n{\n  "schema": 3,\n  "roots": ["plans"],\n  "nodes": {\n    "plans": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 300},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["toggle", "price", "note"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 300}, "padding": 24},\n      "props": {"spacing": 12, "crossAxisAlignment": "start"}\n    },\n    "toggle": {\n      "type": "row",\n      "children": ["toggleLabel"],\n      "layout": {"width": {"hug": 120}, "height": {"hug": 36}, "padding": [14, 8, 14, 8]},\n      "decoration": {"strokes": [{"color": "#FF2563EB"}], "radius": 18},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "setVariable", "variable": "annual", "op": "toggle"}]\n        }\n      ]\n    },\n    "toggleLabel": {\n      "type": "text",\n      "layout": {"width": {"hug": 80}, "height": {"hug": 20}},\n      "props": {"text": "Monthly", "style": {"fontSize": 14, "color": "#FF2563EB"}},\n      "bind": {"props.text": "\${= annual ? \'Annual billing\' : \'Monthly billing\'}"}\n    },\n    "price": {\n      "type": "text",\n      "layout": {"width": {"hug": 80}, "height": {"hug": 40}},\n      "props": {"text": "\$12 / month", "style": {"fontSize": 32, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "note": {\n      "type": "text",\n      "layout": {"width": {"hug": 80}, "height": {"hug": 20}},\n      "props": {"text": "Save 20% with annual billing", "style": {"fontSize": 14, "color": "#FF16A34A"}}\n    }\n  },\n  "variables": {"plans": [{"name": "annual", "type": "boolean", "value": false}]},\n  "conditions": {\n    "plans": [\n      {\n        "id": "billing",\n        "branches": [\n          {\n            "when": {"left": "\${annual}", "op": "isTrue"},\n            "set": [\n              {"node": "price", "path": "props.text", "value": "\$120 / year"},\n              {"node": "note", "path": "visible", "value": false}\n            ]\n          },\n          {"set": [{"node": "price", "path": "props.text", "value": "\$12 / month"}]}\n        ]\n      }\n    ]\n  }\n}\n```'),
      DocSection('state-when-to-use-a-script', 'When to use a script', 'For multi-step state changes (a puzzle\'s checks, a game step, a streak over dates), a script reads and sets\nvariables with `vars.get(name)` and `vars.set(name, value)` (capabilities `variables.read`, `variables.write`);\nthe UI updates through what binds to them. A script cannot draw or touch nodes. A reaction runs it (`{"type":\n"runScript", "script": "place", "arguments": {"cell": "\${index}"}}`); a formula calls a pure one\n(`\${= script.isSolved(board)}`).'),
    ],
  ),
  DocPage(
    id: 'interaction',
    title: 'Interaction: reactions, states and gestures',
    summary: 'What a node does when it is tapped, hovered, pressed, dragged or swiped: reactions and every trigger, hover and pressed styles (`states`), ink ripples, tooltips, letting taps through, drag and drop, values set by dragging (`track`), swipe to dismiss, pan, pinch and rotate, keys, the clipboard and haptics.',
    when: 'What a node does when it is tapped, hovered, pressed, dragged or swiped: reactions and every trigger, hover and\npressed styles (`states`), ink ripples, tooltips, letting taps through, drag and drop, values set by dragging\n(`track`), swipe to dismiss, pan, pinch and rotate, keys, the clipboard and haptics.',
    example: 'A button-like row that changes color while hovered and pressed, and while selected:\n\n```json\n{\n  "schema": 3,\n  "roots": ["buttons"],\n  "nodes": {\n    "buttons": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 200},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["cta"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 200}},\n      "props": {"mainAxisAlignment": "center"}\n    },\n    "cta": {\n      "type": "row",\n      "children": ["ctaLabel"],\n      "layout": {"width": {"hug": 160}, "height": {"hug": 44}, "padding": [20, 12, 20, 12]},\n      "decoration": {"fills": [{"color": "#FF2563EB"}], "radius": 10},\n      "states": {\n        "hovered": {\n          "cta": {"decoration": {"fills": [{"color": "#FF1D4ED8"}]}},\n          "ctaLabel": {"props": {"text": "Let\'s go"}}\n        },\n        "pressed": {"cta": {"opacity": 0.8}}\n      },\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "openLink", "url": "https://example.com"}]}]\n    },\n    "ctaLabel": {\n      "type": "text",\n      "layout": {"width": {"hug": 100}, "height": {"hug": 20}},\n      "props": {"text": "Get started", "style": {"fontSize": 16, "fontWeight": 600, "color": "#FFFFFFFF"}}\n    }\n  }\n}\n```',
    pitfalls: '- `hovered` never happens on touch screens.\n- The innermost tappable node takes the tap; `ignorePointer` lets it through.\n- A state patch names node ids inside the node; patching a node outside it does nothing.\n- An interaction state\'s patch loses to a binding of the same field (bindings come after states).\n- A misspelled trigger never fires; a key a trigger does not take is ignored.\n- `tap_no_reaction` (render command): a `--tap` step hit a node with no reaction.\n- Only a `click` reaction makes a node reachable by keyboard: an action that exists only on `hover`,\n  `longPress` or `doubleTap` has no key.\n- A focus ring that looks cut off: the node sits flush in a parent that clips. Give the parent padding (the ring\n  is 1.5 px outside the node), or style `states.focused` instead.',
    words: 6518,
    items: ['states', 'inkWell', 'tooltip', 'ignorePointer', 'focusable', 'focusGroup', 'draggable', 'dropTarget', 'track', 'dismissible', 'pan', 'transformGesture', 'click', 'doubleTap', 'longPress', 'hold', 'secondaryClick', 'pointerDown', 'pointerUp', 'hover', 'cursorEnter', 'cursorExit', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', 'drag', 'dragEnd', 'wheel', 'pinch', 'dragStart', 'dragCancel', 'dragCompleted', 'drop', 'dragEnter', 'dragExit', 'dropRejected', 'controlTrack', 'controlDismissible', 'controlTransform', 'copyToClipboard', 'haptic'],
    sections: [
      DocSection('interaction-trigger-fields', 'Trigger fields', 'A trigger is `{"type": "<type>", ...these}`, or just the type as a string (`"click"`).\n\n| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `type` | [TriggerType](values.md#enum-TriggerType) | `"click"` |  |  |\n| `debounceMs` | int | `0` |  | Waits this long after the last trigger before running, so a burst (typing in a search field) runs once. 0 runs every time. |\n| `variable` | String | `""` |  | `TriggerType.valueChanged`: the variable watched. |\n| `intervalMs` | int | `1000` |  | Timer: ms between ticks (a number or an expression). |\n| `key` | String | `""` |  | Key triggers: the key or combination (`KeyCombo`); empty: any key. |\n| `when` | String | `""` |  | A formula; the reaction runs only while it\'s true (key triggers take the key only then; a timer or a frame ticker runs only then). Empty: always. |\n| `holdMs` | int | `1200` |  | hold, and longPress when set (else the platform\'s 500 ms): how long the press is held (ms). |\n| `visibleFraction` | double | `0.15` |  | Viewport triggers: the visible share (0–1) that counts as in view. |\n| `repeat` | bool | `false` |  | keyDown: also while the key repeats. |\n| `visibleMs` | int | `0` | ≥ 0 | Viewport: how long it stays in view before firing (ms). |\n| `onceKey` | String | `""` |  | Runs once per key (an expression, such as \${item.id}) per app session. |\n| `event` | String | `""` |  | event: the key of the component event it handles (one of the component\'s widget.events). |\n| `commitMs` | int | `0` | ≥ 0 | longPress and hold: from this many ms the press is the node\'s (letting go, moving or a scroll no longer cancels it; it still fires at holdMs). 0: none. |\n| `haptic` | [HapticKind](values.md#enum-HapticKind) | unset | `selection`, `light`, `medium`, `heavy`, `vibrate` | A pointer trigger\'s buzz as the gesture becomes sure: at commitMs when set, else as it fires. |\n| `focused` | bool | `false` |  | keyDown and keyUp: only while the node, or a control inside it, has the keyboard focus (a control of one\'s own: a wheel\'s arrows), not whatever has the focus. |'),
      DocSection('interaction-fields-every-action-has', 'Fields every action has', '| Key | Type | Default | Allowed | Description |\n|---|---|---|---|---|\n| `enabled` | bool | `true` |  | False skips the action. |\n| `nonBlocking` | bool | `false` |  | The chain doesn\'t wait for it, and its failure doesn\'t stop the chain. |\n| `when` | Object | unset |  | Runs only when it holds. |\n\nFields holding nested action chains (a list of actions): `then`, `else`, `actions`, `onSuccess`, `onError`, `cancelActions`.'),
      DocSection('interaction-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-click"></a>`click` | A tap (a click with a mouse). `\${result}` holds where it landed (`x`, `y` in the node, `globalX`, `globalY`) and the modifier keys held (`meta`, `shift`, `alt`). |\n| <a id="trigger-doubleTap"></a>`doubleTap` | Two taps in quick succession. A node with double tap reactions waits out the double tap timeout before its single taps run. |\n| <a id="trigger-longPress"></a>`longPress` | A long press: the platform\'s (500 ms), or held for `Trigger.holdMs` when it is set; `Trigger.commitMs` and `Trigger.haptic` as for hold. |\n| <a id="trigger-hold"></a>`hold` | A press held for `Trigger.holdMs`; letting go early cancels it (before `Trigger.commitMs`, when set). |\n| <a id="trigger-secondaryClick"></a>`secondaryClick` | A right click, or a two-finger tap on a trackpad (`\${result.x}`, `\${result.y}`: where, on screen). |\n| <a id="trigger-pointerDown"></a>`pointerDown` | A pointer went down on the node. |\n| <a id="trigger-pointerUp"></a>`pointerUp` | A pointer went up on the node, or was cancelled (taken away by the system or a scroll): `\${result.cancelled}` says which (`onPointerUp={result.cancelled ? close : pick}`), `\${result.x}`, `\${result.y}` where, in the node. |\n| <a id="trigger-hover"></a>`hover` | The mouse cursor moved over the node (fires when it enters, too). |\n| <a id="trigger-cursorEnter"></a>`cursorEnter` | The mouse cursor entered the node (once). |\n| <a id="trigger-cursorExit"></a>`cursorExit` | The mouse cursor left the node (once). |\n| <a id="trigger-swipeLeft"></a>`swipeLeft` | A swipe (a fling) to the left, right, up or down. |\n| <a id="trigger-swipeRight"></a>`swipeRight` |  |\n| <a id="trigger-swipeUp"></a>`swipeUp` |  |\n| <a id="trigger-swipeDown"></a>`swipeDown` |  |\n| <a id="trigger-drag"></a>`drag` | The node is dragged (every move); `dragEnd` when it\'s let go (`\${result.vx}`, `\${result.vy}`: its speed; `\${result.cancelled}`: the drag was taken away, not let go). |\n| <a id="trigger-dragEnd"></a>`dragEnd` |  |\n| <a id="trigger-wheel"></a>`wheel` | Wheel or trackpad scroll over the node (`\${result.deltaX}`, `\${result.deltaY}`, and where: `\${result.x}`, `\${result.y}` in the node). |\n| <a id="trigger-pinch"></a>`pinch` | A pinch on the node: two fingers on a touch screen, or a trackpad (ctrl + wheel on the web). Each step fires it with `\${result.scale}`, the scale of that step (multiply a zoom by it), and the point it is about, `\${result.x}`, `\${result.y}` in the node (between the fingers; the pointer on a trackpad): zoom about it by keeping that point still. |\n\n(Continues: interaction.md#interaction-triggers.)'),
      DocSection('interaction-reactions', 'Reactions', 'A node\'s `actions` is a list of **reactions**: a trigger and the chain of actions it runs, in order.\n\n- In a chain `\${result}` starts as the trigger\'s event (where a click landed; a text field\'s text; a checkbox\'s\n  value) and is replaced only by an action that gives a value (`callApi`, `openModal`\'s closing value, `runScript`,\n  `callFunction`, a cloud read); `setVariable`, `navigate`, `showToast`, `scrollTo` leave it as it was.\n- A tap on a control (a checkbox, a switch, a button, a text field) inside a node with a `click` reaction runs the\n  control\'s reaction only, as Flutter\'s gesture arena gives the tap to the innermost recognizer. To toggle from the\n  whole row with one handler, give the control `"ignorePointer": true` and bind its value.\n- Screen triggers (`load`, `valueChanged`, `timer`, `frame`, `keyDown`) go on the canvas.\n- Every action also takes `enabled`, `nonBlocking` and `when` (run only while a predicate holds:\n  `{"left": "\${count}", "op": "greaterThan", "right": "5"}`; the ops are in [Conditions](state.md#state-conditions)). A\n  trigger\'s own `when` is a formula string.\n- Write each action\'s fields flat in the action object; a misspelled key is dropped.'),
      DocSection('interaction-hover-press-and-other-states', 'Hover, press and other states', '`states` on a node changes it and its descendants while it is `hovered`, `pressed`, `focused`, `selected`,\n`disabled` or `dragged`. Each state maps node ids (the node itself or nodes inside it) to a **patch**: partial node\nJSON merged over that node (objects merge, other values replace, `null` removes). `selected` and `disabled` follow\nbindings: `"bind": {"selected": "\${= tab == \'pricing\'}"}` puts the node in its `selected` state, as Flutter\'s\n`statesController` puts a button in `WidgetState.selected`. Buttons draw it themselves (a tinted fill, the primary\ncolor as ink: tabs and toggles made of buttons need nothing more); on other nodes only a `states.selected` patch\nshows it, so a bound `selected` with none changes nothing. A chip\'s own selection is its prop,\n`props.selected`. A selected outlined button in a look of its own (a filter or a delivery option):\n\n```json\n"bind": {"selected": "\${= category == \'linen\'}"},\n"states": {"selected": {"linen": {"props": {"style": {"backgroundColor": "ink", "foregroundColor": "paper"}}}}}\n```\n\n`hovered` needs a\nmouse: on touch screens it never happens, so do not hide anything behind it. Animate the change with\n`transitions` ([animation](animation.md#page-animation)).'),
      DocSection('interaction-a-segmented-toggle-monthly-annual', 'A segmented toggle (monthly / annual)', 'Two labels in a row with a fill; each label\'s `selected` binds to the variable (`\${= annual}` and\n`\${= !annual}`), its `states.selected` patches its fill and text color, and its click sets the variable. A\n`switch` bound two-way to the same variable works as well.'),
      DocSection('interaction-drag-and-drop', 'Drag and drop', '`draggable` (`{"group": "card", "data": "\${item.id}"}`) lets the node be picked up; a `dropTarget` that `accepts`\nthe group takes it, and its `drop` reaction reads the data as `\${result.data}` (`\${result}` is the whole drag: `data`,\n`group`, `source`, `over`, `count`): `{"type": "setVariable", "variable": "cards", "value": "\${= map(cards, c => c.id == result.data ? {id: c.id, title: c.title, col: \'done\'} : c)}"}`. Reordering a list: the list\'s `reorder`\nsettings with a `reorderHandle` in the item, and the `reorder` trigger.'),
      DocSection('interaction-values-set-by-dragging-swiping-pinching', 'Values set by dragging, swiping, pinching', '`track` sets a variable as the pointer moves along a line, arc or path (a custom slider, a dial). `dismissible`\nswipes a node away (a list item; the `swipeAction` trigger). `pan` makes a node follow the pointer;\n`transformGesture` pinches, pans and rotates with fling physics. The `drag` trigger reports `\${result.dx}`,\n`\${result.dy}` per move and `dragEnd` the velocity, for game controls.'),
      DocSection('interaction-copy-to-the-clipboard', 'Copy to the clipboard', '`{"type": "copyToClipboard", "text": "\${address}"}` (the key is `text`), then the chain goes on: a toast or a\n"Copied" state after it. The render command copies in memory and lists what was copied in its report.'),
      DocSection('interaction-keys', 'Keys', 'A canvas\'s `keyDown` reaction (`{"trigger": {"type": "keyDown", "key": "ArrowRight"}, ...}`) runs while no text\nfield has the focus: arrow keys between tabs are two reactions that set the tab variable\n(`\${= (tabIndex + 1) % 4}`), Escape closing a menu is one. A combination with Ctrl/Cmd or Alt (`"key": "Mod+K"`)\nalso runs while a field has the focus; a plain letter stays with the field. In the notation it is a line of its\nown, `key mod+k onPress={open search}`, and `Text "Search" shortcut="mod+k"` shows the combination as the\nplatform writes it (Ctrl K, ⌘K).'),
      DocSection('interaction-the-keyboard-tab-enter-space-and-the-focus-ring', 'The keyboard: Tab, Enter, Space and the focus ring', 'Nothing to write: a node with a `click` reaction is a **Tab stop**, like the controls. Tab and Shift+Tab move the\nfocus through the page in reading order (rows from the top, left to right in a row; a node around other stops comes\nbefore them), Enter and Space run the focused node\'s click, and the node shows the theme\'s focus ring (the\n`focusBorder` color, just outside its box, with its corner radius) while the focus is on it **from the keyboard**:\na pointer or a touch never shows the ring. While it shows, the node is in its `focused` state, so a\n`states.focused` patch styles it further (a menu row\'s fill). A screen reader gets one focusable button named by the\nnode\'s text, or by its `tooltip` when it has none (an icon).\n\nWhat is **not** a stop:\n\n- a node with no `click` reaction: `hover`, `longPress`, drags and the other triggers alone do not make one;\n- `"focusable": false` on the node: the document\'s opt-out, for a row whose only action a button inside it repeats;\n- a node that is `disabled` (a bound `disabled`), has `ignorePointer`, or sits inside a node that has: the labeled\n  checkbox row (`ignorePointer` on the checkbox) is one stop, the row;\n- a node that is not shown (`visible: false`, opacity 0), or whose every click reaction has a `when` that does not\n  hold now (it joins the order when one does);\n- a node that is itself a control: a text field or a button with a click reaction is one stop, the control.\n\nA node with a click **around** other stops (a card with a button in it) stays a stop: its own action must stay\nreachable. If that doubles what the button does, give the card `"focusable": false`.'),
      DocSection('interaction-one-tab-stop-for-a-group-focusgroup', 'One Tab stop for a group: focusGroup', 'A menu, a tab list, a toolbar or a list of options is one stop, and the arrow keys move inside it. Put\n`focusGroup` on the node around the items:\n\n```json\n"menu": {"type": "column", "focusGroup": {"typeAhead": true}, "children": ["open", "rename", "delete"]}\n```\n\nTab enters the group at the item focused last (else the one whose `selected` is bound true, else the first) and\nleaves to the next stop outside it. The arrows of `axis` (`vertical`: Up and Down; `horizontal`: Left and Right,\nswapped under `textDirection: rtl`; `both`) move through the items that can take the focus, in reading order;\n`wrap` (default true) goes from the last to the first; Home and End jump to the ends; with `typeAhead` a typed\nletter jumps to the next item whose text starts with it (the same letter again goes on to the next). Enter and\nSpace press the focused item as anywhere. The items are whatever takes the focus inside: nodes with a click\nreaction and controls; a control\'s own keys come first (a slider in a toolbar keeps its arrows).'),
    ],
  ),
  DocPage(
    id: 'animation',
    title: 'Animation and motion',
    summary: 'Anything that moves: a change that animates (implicit transitions), keyframe animations and presets, moving, scaling and turning a node without changing layout (`motion`), shared-element flights (`hero`), reveal on scroll, shimmer, typewriter text, particles, flip cards and tilt, and the timer and frame triggers for clocks and games.',
    when: 'Anything that moves: a change that animates (implicit transitions), keyframe animations and presets, moving,\nscaling and turning a node without changing layout (`motion`), shared-element flights (`hero`), reveal on\nscroll, shimmer, typewriter text, particles, flip cards and tilt, and the timer and frame triggers for clocks and\ngames.',
    example: 'A habit check-off: tapping the circle toggles `done`; its fill and scale change through bindings, and\n`transitions` animate the change (a small overshoot), while the label fades.\n\n```json\n{\n  "schema": 3,\n  "roots": ["habit"],\n  "nodes": {\n    "habit": {\n      "type": "canvas",\n      "slots": {"body": "row"},\n      "layout": {"width": 390, "height": 120},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "row": {\n      "type": "row",\n      "children": ["check", "label"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 120}, "padding": 24},\n      "props": {"spacing": 12}\n    },\n    "check": {\n      "type": "box",\n      "layout": {"width": 32, "height": 32},\n      "decoration": {"fills": [{"color": "#FFE5E7EB"}], "radius": 16},\n      "bind": {\n        "decoration.fills[0].color": "\${= done ? \'#FF16A34A\' : \'#FFE5E7EB\'}",\n        "motion.scale": "\${= done ? 1.15 : 1}"\n      },\n      "transitions": [\n        {"property": "motion", "duration": 250, "curve": "easeOutBack"},\n        {"property": "decoration", "duration": 200}\n      ],\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "setVariable", "variable": "done", "op": "toggle"}]\n        }\n      ]\n    },\n    "label": {\n      "type": "text",\n      "layout": {"width": {"fill": 280}, "height": {"hug": 22}},\n      "props": {"text": "Drink water", "style": {"fontSize": 17, "color": "#FF111827"}},\n      "bind": {"opacity": "\${= done ? 0.5 : 1}"},\n      "transitions": [{"property": "opacity", "duration": 200}]\n    }\n  },\n  "variables": {"habit": [{"name": "done", "type": "boolean", "value": false}]}\n}\n```',
    pitfalls: '- `motion` (its scale and rotate too) does not change layout: neighbors do not move. To make room, animate a\n  layout field.\n- A transition animates changes only; a value that never changes needs an animation that autoplays.\n- An animation\'s `id` is what `animate` names; without `autoplay` it waits.\n- Animations run in a running app. The render command settles about a second after each step, so a short\n  animation is over when it captures (a counting variable is waited for until it arrives, up to 20 s); to check\n  one mid-flight, lengthen its duration in a copy.',
    words: 4981,
    items: ['motion', 'animations', 'transitions', 'shimmer', 'reveal', 'typewriter', 'particles', 'flip', 'tilt', 'hero', 'viewProgress', 'timer', 'frame', 'animate'],
    sections: [
      DocSection('animation-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-timer"></a>`timer` | Every `Trigger.intervalMs` while the screen shows (`Timer.periodic`) and `Trigger.when` holds; `\${result.tick}` counts. |\n| <a id="trigger-frame"></a>`frame` | Every frame while the node is on stage and `Trigger.when` holds (a `Ticker`): `\${result.dt}` (ms since the tick this chain last got), `\${result.elapsed}` (ms since it started), `\${result.frame}`. A frame that comes while the chain still runs is skipped; its time goes to the next `dt`. A design canvas never ticks. |'),
      DocSection('animation-animate-a-change-transitions', 'Animate a change (transitions)', '`transitions` is Flutter\'s implicit animation: when the value at a path changes (a binding, a condition, a state\npatch), the node tweens from what it shows to the new value. One entry per path or prefix: `{"property": "motion",\n"duration": 250, "curve": "easeOutBack"}`, `"opacity"`, `"decoration"`, `"layout.height"`; `"*"` for every path.\nThis is the simplest way to animate a check-off, a selected card or an opening panel.'),
      DocSection('animation-move-scale-or-turn-without-changing-layout-motion', 'Move, scale or turn without changing layout (motion)', '`motion` is a transform painted over the node\'s layout (Flutter\'s `Transform`): `translateX`/`translateY` in pixels,\n`scale`, `rotate` in degrees, 3D `rotateX`/`rotateY` with `perspective`, about `alignment` (the center by default).\nIt is the one way to scale or turn a node: there is no node `scale` and no `layout.rotation` (a turned node keeps\nits unturned box in the layout, as `Transform.rotate` does; Flutter\'s `RotatedBox` has no counterpart). Nothing else\nmoves. Bind a field (`"motion.rotate": "\${= open ? 180 : 0}"`) and add a transition to animate it; a transition on\n`motion.scale` times the scale apart from the rest of the motion (`AnimatedScale` beside `AnimatedSlide`).'),
      DocSection('animation-play-an-animation-animations-and-presets', 'Play an animation (animations and presets)', '`animations` holds a node\'s controllers: each runs 0 → 1 over `duration` (or a `spring`), after `delay`, once or\n`repeat`ed, and drives `tracks` of keyframes on its paths. A `preset` names a ready-made one (fade in, slide up,\npulse...) with its `params`. `autoplay` false waits for the `animate` action (`forward`, `reverse`, `stop`...) or a\nchange of `playKey`. A screen-wide animation sits on the canvas.'),
      DocSection('animation-reveal-on-scroll-view-progress-sticky-effects', 'Reveal on scroll, view progress, sticky effects', 'An entrance when a node scrolls into view (CSS scroll-reveal) is an **animation with `visibleFraction`**: it waits\nuntil that share of the node is in view, then plays.\n\n```json\n"animations": [{"id": "enter", "duration": 600, "curve": "easeOut", "visibleFraction": 0.3,\n                "tracks": [{"path": "opacity", "from": 0, "to": 1}, {"path": "motion.translateY", "from": 24, "to": 0}]}]\n```\n\nThe `reveal` behavior is not an entrance, despite its name: it **scrolls** the node into view (a chat\'s newest\nline). `viewProgress` gives `\${view.progress}` (0–1 through the viewport) to bind to, for effects that follow the\nscroll; the `enterViewport` and `exitViewport` triggers run actions. A page\'s reading progress:\n[scroll progress](layout.md#layout-scroll-progress).'),
      DocSection('animation-shared-elements-hero', 'Shared elements (hero)', '`hero` is Flutter\'s `Hero`: a tag (`"hero": "avatar-\${item.id}"`) flies the node from its place on the screen a\nnavigation leaves to the node with the same tag on the screen it opens; `flightShuttle` picks what flies (`morph`,\n`containerTransform`...). With `"flies": "inPlace"` it flies when it appears instead, from where the node with its\ntag was a moment ago on screen (a picked emoji flying from its picker to its chip, a card dropped into a column):\n`{"hero": {"tag": "react", "flies": "inPlace", "flight": {"duration": 720, "lift": 110}}}`, on a spring without a\n`flight`.'),
      DocSection('animation-count-up-a-number', 'Count up a number', 'A figure that counts up when the page opens is a number variable the `animate` action plays\n(`AnimationController.animateTo`), shown through a formula that formats it: `thousands` (or `formatNumber`) puts\nin the thousands separators (`12,480`), which `round` alone does not.\n\n```json\n"variables": {"home": [{"name": "trees", "type": "decimal", "value": 0}, {"name": "people", "type": "decimal", "value": 0}]},\n"actions": [{"trigger": {"type": "load"}, "actions": [\n  {"type": "animate", "variable": "trees", "command": "animateTo", "target": "12480", "duration": "1300", "curve": "easeOutCubic", "nonBlocking": true},\n  {"type": "animate", "variable": "people", "command": "animateTo", "target": "3680", "duration": "1000", "curve": "easeOutCubic", "nonBlocking": true}]}]\n```\n\nwith `"text": "\${= thousands(trees)} trees planted"`. A chain waits for each `animate` to end before the next, so\nseveral in one `load` count **one after another**; `"nonBlocking": true` on each runs them **together** (or give\neach its own `load` reaction). The render command captures once every counting variable has arrived.'),
      DocSection('animation-clocks-and-game-loops', 'Clocks and game loops', 'A canvas\'s `timer` trigger (`"intervalMs": 1000`, `"when"`: a formula that must hold) runs every interval\n(`\${result.tick}` counts); `frame` runs every frame while `when` holds (`\${result.dt}` ms since the last), for\nphysics and game loops. Keep the state in variables and the work in a script when it has several steps.\n\nA clock written by a timer (`"value": "\${= now()}"`) changes in every capture. To check a countdown\'s states, pin\nthe time with the render command\'s `--now 2026-11-13T09:00:00Z` (`now()` returns it, so the timer writes it); a\n`--set clock=...` also holds against the timer for the capture. No test-only variable is needed.'),
    ],
  ),
  DocPage(
    id: 'components',
    title: 'Components and sections',
    summary: 'Splitting a page into parts, each a file: a component used in several places with different values (a card, a chip, a row), a section used once (a header, a hero, an FAQ), their parameters (every kind, `variable` included), slots and events, the site manifest, and when to use a component, a list template or a section.',
    when: 'Splitting a page into parts, each a file: a component used in several places with different values (a card, a\nchip, a row), a section used once (a header, a hero, an FAQ), their parameters (every kind, `variable` included),\nslots and events, the site manifest, and when to use a component, a list template or a section.',
    example: 'A definition (`components/Chip.json`; the file is named after the type):\n\n```json\n{"schema": 3, "id": "Chip", "roots": ["chip"],\n "widget": {"type": "Chip", "doc": "A label with a remove button.", "children": "list", "slots": ["leading"],\n   "props": [\n     {"key": "label", "type": {"kind": "string", "flutter": "String"}, "default": "Chip", "required": true},\n     {"key": "selected", "type": {"kind": "variable", "of": {"kind": "boolean", "flutter": "bool"}}, "default": ""}],\n   "events": [{"key": "onRemove", "payload": {"kind": "string", "flutter": "String"}}]},\n "variables": {"chip": [{"name": "hovered", "type": "boolean", "value": false}]},\n "previews": [{"name": "Selected", "size": [240, 48], "props": {"label": "Design", "selected": true}}],\n "nodes": {\n  "chip": {"type": "row", "children": ["lead", "text", "extra", "remove"], "props": {"spacing": 6},\n           "layout": {"width": {"hug": 120}, "height": 36, "padding": [12, 0, 8, 0]},\n           "decoration": {"fills": [{"color": "#FFE8EAF6"}], "radius": 18},\n           "bind": {"decoration.fills[0].color": "\${= props.selected ? \'#FF3F51B5\' : \'#FFE8EAF6\'}"},\n           "actions": [{"trigger": {"type": "click"},\n                        "actions": [{"type": "setVariable", "variable": "props.selected", "op": "toggle"}]}]},\n  "lead": {"type": "slot", "props": {"name": "leading"}},\n  "text": {"type": "text", "props": {"text": "\${props.label}", "style": {"fontSize": 14, "color": "#FF1A237E"}},\n           "layout": {"width": {"hug": 60}, "height": {"hug": 20}},\n           "bind": {"props.style.color": "\${= props.selected ? \'#FFFFFFFF\' : \'#FF1A237E\'}"}},\n  "extra": {"type": "slot"},\n  "remove": {"type": "icon", "props": {"icon": "close", "color": "#FF5C6BC0"},\n             "layout": {"width": 20, "height": 20},\n             "actions": [{"trigger": {"type": "click"},\n                          "actions": [{"type": "componentEvent", "event": "onRemove", "value": "\${props.label}"}]}]}\n }}\n```\n\nAnd calls to it, in a page\'s `nodes` (the page declares `tag` and `removed`):\n\n```json\n"nodes": {\n  "design": {"type": "Chip", "props": {"label": "Design", "selected": "tag"},\n             "slots": {"leading": "dot"}, "layout": {"width": {"hug": 120}, "height": 36},\n             "actions": [{"trigger": {"type": "event", "event": "onRemove"},\n                          "actions": [{"type": "setVariable", "variable": "removed", "value": "\${result}"}]}]},\n  "dot": {"type": "box", "layout": {"width": 8, "height": 8}, "decoration": {"fills": [{"color": "#FF4CAF50"}], "radius": 4}},\n  "tags": {"type": "listView", "children": ["tagChip"], "bind": {"data": "\${tags}"},\n           "props": {"scrollDirection": "horizontal", "spacing": 8}, "layout": {"width": {"fill": 360}, "height": 36}},\n  "tagChip": {"type": "Chip", "bind": {"props.label": "\${item.name}"}, "layout": {"width": {"hug": 120}, "height": {"fill": 36}}}\n}\n```',
    pitfalls: '- A definition never reads its caller\'s variables: pass values as parameters, shared state as a `variable`\n  parameter.\n- A slot inside a list of the definition shows what the call passes once per item, built in the caller\'s scope:\n  it reads the caller\'s variables, not the item. To show the item, make it a parameter of a component the list\n  calls.\n- A call has no `decoration` and no `layout.padding`: style the definition\'s root.\n- The file is named after the type.\n- The same subtree of three or more nodes written several times over: make it a component or a list template.',
    words: 3820,
    items: ['slot', 'external', 'placeholder', 'singlePlaceholder', 'event', 'componentEvent'],
    sections: [
      DocSection('components-parameter-kinds', 'Parameter kinds', 'Declared in `widget.props` as the catalog declares any prop: `key`, `type` (`kind` and the\nFlutter type; `min`, `max`, enum `values`, list `item`), `default`, `doc`, and `"required": true` for one a call\nmust set. The kinds: `boolean` (`bool`), `integer` (`int`), `number` (`double`), `string` (`String`),\n`enumeration` (with `values`), `value` (a value type: `{"kind": "value", "flutter": "Color"}`, also `EdgeInsets`,\n`Alignment`, `IconData`...), `list` (with `item`), `object` (a model: `TextStyle`, `Paint`), `json` (any data: a\nrecord, `{"kind": "json", "flutter": "Map<String, dynamic>"}`) and `variable` (with `of`, below). Inside, read them as `\${props.<key>}`. A call sets them as any node\'s props: a literal in `props`, an\nexpression in `bind` (`"props.label": "\${item.name}"`). A call takes what the declaration has: its keys, with\ntheir types and bounds, every required one, and only the children and slots the component takes.'),
      DocSection('components-the-site-manifest', 'The site manifest', 'A directory with a `site.json` is a site: its pages, its components and its project variables, read by\nbare name in every page and component (do not give a page or component variable the same name).\n\n```json\n{"schema": 3, "pages": ["pages/home.json"], "components": ["components/Chip.json"],\n "variables": [{"name": "tags", "type": "list", "value": [{"name": "Design"}, {"name": "Code"}]}]}\n```\n\nWithout `components`, the files under `components/` are the site\'s components.\n\n`variables` is that list, or an object by name. A variable that names no `type` has its value\'s: `[]` is a list,\n`{}` a map, `3` an integer, `2.5` a decimal, `true` a boolean, anything else text.\n\n```json\n{"schema": 3, "pages": ["pages/home.json"],\n "variables": {"cart": [], "plan": "pro", "draft": {"value": "", "persist": true}}}\n```\n\nBy name, an object with `value` (or `formula`) and only a variable\'s keys (`type`, `value`, `persist`...) is the\nvariable\'s record; any other object is a map the variable holds. A record that cannot be read is\nnot declared.'),
      DocSection('components-render-codes', 'Render codes', 'The render command reports `component_missing` (a call rendered without its definition: an empty box of its size).'),
      DocSection('components-triggers', 'Triggers', 'Written as `"trigger": {"type": "<trigger>", ...}` in a reaction ([trigger fields](interaction.md#interaction-trigger-fields)).\n\n| Trigger | When it fires |\n|---|---|\n| <a id="trigger-event"></a>`event` | On a component call: the component fired its event `Trigger.event` (a `componentEvent` action inside its definition); `\${result}` is the event\'s payload. Flutter: the callback passed to a widget\'s `onChanged`-style parameter. The handler runs in the caller\'s scope. |'),
      DocSection('components-components-are-flutter-widget-classes', 'Components are Flutter widget classes', 'A page can be split into parts, each in a file of its own: a **component** is a document with one root (not a\ncanvas) and a `widget` declaration, and a page (or another component) **calls** it with one node whose `type` is\nthe component\'s type. A **section** is a component used once. The declaration is the widget\'s constructor; a\ncall is `PlanCard(price: 47, ...)`.\n\n| Here | Flutter |\n|---|---|\n| a component document | a `StatelessWidget` / `StatefulWidget` class, in its own file |\n| `widget.props` (parameters) | the constructor\'s named parameters, with types and defaults |\n| a call `{"type": "PlanCard", "props": {...}}` | `PlanCard(...)` in a parent\'s `build` |\n| `\${props.price}` in the definition | `widget.price` |\n| the definition\'s own `variables` (one set per instance) | the `State`\'s fields |\n| a `slot` node, the call\'s `children` / `slots` | `child`, `children`, `Widget title` parameters, placed in `build` |\n| `widget.events`, `componentEvent`, the call\'s `event` reaction | a `ValueChanged<T>` / `VoidCallback` parameter (`onChanged`) |\n| a `variable` parameter | a `ValueNotifier<T>` passed in |\n| `site.json` | the app\'s `lib/`: its pages and its globals |'),
      DocSection('components-a-complete-multi-page-site', 'A complete multi-page site', 'A site of two pages, a modal, a header and a footer shared by reference, written in the order that avoids\n`unknown_screen` errors: **the manifest first, every page listed**, then the components, then the pages (a listed\npage not written yet is one `page_not_written` warning, not an error). The trip\npage reads its route parameter (`\${route.id}`, from `navigate.params` or a link `trip?id=coast`); the saved list is\nrestored from storage when the home page loads; the packing list is kept per trip under a key built from the route.\n\n`site.json`:\n\n```json\n{\n  "schema": 3,\n  "pages": ["pages/home.json", "pages/trip.json"],\n  "components": ["components/Header.json", "components/Footer.json"],\n  "theme": {\n    "colors": {\n      "ink": "#FF1B1B1B",\n      "paper": "#FFFAF7F2",\n      "accent": "#FF2F6B4F",\n      "muted": "#FF6B7280",\n      "line": "#FFE5E1D8"\n    },\n    "textStyles": {\n      "body": {"fontSize": 15, "height": 1.4, "color": "ink"},\n      "title": {"from": "body", "fontSize": 28, "fontWeight": 700, "height": 1.2},\n      "link": {"from": "body", "fontWeight": 600, "color": "accent"}\n    }\n  },\n  "variables": [\n    {\n      "name": "trips",\n      "type": "list",\n      "value": [\n        {\n          "id": "alps",\n          "name": "The Alpine Arc",\n          "days": 7,\n          "packing": ["Rail pass", "Rain shell", "Walking boots"]\n        },\n        {"id": "coast", "name": "Coast to Coast", "days": 5, "packing": ["Swimwear", "Sun hat"]}\n      ]\n    },\n    {"name": "saved", "type": "list", "value": []}\n  ]\n}\n```\n\n`components/Header.json` (its About link opens the modal `about`, a canvas of `pages/home.json`; canvas ids are\nsite-wide, so any page or component may open it):\n\n```json\n{\n  "schema": 3,\n  "id": "Header",\n  "roots": ["bar"],\n  "widget": {\n    "type": "Header",\n    "doc": "The site\'s top bar: the name (home) and an About link (a modal).",\n    "props": [{"key": "savedCount", "type": {"kind": "integer", "flutter": "int"}, "default": 0}]\n  },\n  "nodes": {\n    "bar": {\n      "type": "row",\n      "children": ["brand", "count", "about"],\n      "props": {"spacing": 16},\n      "layout": {"width": {"fill": 390}, "height": 56, "padding": [20, 0, 20, 0]},\n      "decoration": {"fills": [{"color": "paper"}], "strokes": [{"color": "line"}], "strokeSides": "bottom"}\n    },\n    "brand": {\n      "type": "text",\n      "layout": {"width": {"hug": 120}, "height": {"hug": 22}},\n      "props": {"text": "Waymark", "style": {"from": "body", "fontWeight": 700}},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "navigate", "to": "home"}]}]\n    },\n    "count": {\n      "type": "text",\n      "layout": {"width": {"fill": 120}, "height": {"hug": 22}},\n      "props": {"text": "\${props.savedCount} saved", "style": {"from": "body", "color": "muted"}, "textAlign": "right"}\n    },\n    "about": {\n      "type": "text",\n      "layout": {"width": {"hug": 120}, "height": {"hug": 22}},\n      "props": {"text": "About", "style": "link"},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "openModal", "to": "about", "presentation": "dialog"}]\n        }\n      ]\n    }\n  }\n}\n```\n\n`components/Footer.json`:\n\n\n(Continues: components.md#components-a-complete-multi-page-site.)'),
      DocSection('components-when-to-make-what', 'When to make what', '* **List template**: one shape repeated from data in one parent. When the item is more than about five nodes, or\n  appears elsewhere too, make the template one call node (`"bind": {"props.plan": "\${item}"}`).\n* **Component**: the same structure in two or more places with different values (buttons, cards, chips, rows),\n  or a part others will reuse. Data comes in as parameters. Four near-identical columns of a table, or three plan\n  cards, are one component (or one list template) called four or three times, not four copies.\n* **Section**: a top-level band of a page (header, hero, plans, FAQ, footer), in its own file when it is more\n  than about 15 nodes or someone will edit it alone, even if it is used once. Parameters only for what it shares\n  with its page (`variable` parameters for state both change).'),
      DocSection('components-what-a-definition-reads', 'What a definition reads', 'Its parameters (`props`), its own variables (one set per instance: two chips are\nhovered apart), the project\'s variables (`site.json`, below) and the runtime\'s scopes (`screen`, `route`,\n`theme`, `auth`...); inside its own lists, `item` and `index`. **Never the caller\'s variables**: the same chip works\non any page. What a section needs from its page comes in as a parameter.'),
      DocSection('components-computed-values-inside-a-definition', 'Computed values inside a definition', 'A definition\'s own variables may be computed from its parameters: `{"name": "over", "type": "boolean", "formula":\n"props.seats > props.limit"}` under the root\'s id in its `variables`, then `\${over}` in any of its nodes. One rule,\nread by five nodes, written once.'),
      DocSection('components-shared-state-variable-parameters', 'Shared state: variable parameters', 'share state with the caller: `{"kind": "variable", "of": {"kind": "boolean"}}`. The\ncall passes the *name* of one of its variables (`"selected": "tag"`); inside, `\${props.selected}` reads it live and\n`setVariable "props.selected"` writes it. A header and a menu both taking `"menuOpen": "menuOpen"` open and close\nthe page\'s one menu.'),
      DocSection('components-slots', 'Slots', 'A `slot` node in the definition is replaced by what the call passes: the call\'s `children` for the\nslot named `children` (the default name; declare `"children": "list"`), or the call\'s `slots[name]` for a named\nslot (declare it in `widget.slots`). With nothing passed, the slot shows its own children. What is passed belongs\nto the caller: it is stored in the page and reads the page\'s variables.\n\nInside the definition, `\${slots.<name>}` is true while the call fills that slot, and `\${slots.children}` while\nit passes children. Hide what only frames a slot when the slot is empty: a footer with a rule and padding takes\n`"bind": {"visible": "\${slots.actions}"}`, so a call without actions has no empty strip.'),
      DocSection('components-events', 'Events', 'Declared in `widget.events`; fired inside with `{"type": "componentEvent", "event": "onRemove",\n"value": ...}`; handled by the call\'s reaction `{"trigger": {"type": "event", "event": "onRemove"}}`, which runs in\nthe caller\'s scope with the value as `\${result}`. An event nobody handles does nothing.'),
      DocSection('components-size-and-place', 'Size and place', 'The call and the definition\'s root are one box: the call\'s `layout` sizes and places it\n(width, height, flex, margin, x/y, align, constraints); the root keeps its padding, decoration and contents. A call\nhas no `decoration` and no `layout.padding`. The root\'s own size is the design size its previews and new calls\nuse. `visible` hides the instance when either the call or the root is hidden. The root\'s own placement (its\n`margin`, `flex`, `align`, `x`/`y`, bound or patched) is not read: place the instance from the call (a margin that\ndepends on a parameter is bound on the call, `"bind": {"layout.margin": "\${= item.popular ? [0, 0, 0, 0] : [0, 28,\n0, 0]}"}`).'),
      DocSection('components-ids-and-paths', 'Ids and paths', 'A definition\'s ids are its own (`text`, `remove`); a page may use the same ids, and\ndiagnostics name a node of an instance by its path, so the two never mix. An action inside a definition that names\na node (`scrollTo`, `animate`, `focus`) acts on that node of its own instance: two cards each scroll their own\nlist. Tools name a\nnode inside an instance by its **path**: the call ids from the page down, then the node\'s id\n(`design/remove`, `plans/card1/cta`); `#n` picks the n-th copy a list repeats (`tagChip#2/text`).'),
      DocSection('components-rendering-one-part', 'Rendering one part', '`tool/render/render.sh site --out out --component Chip` renders the component alone, once\nper preview at its size; `--props \'{"label": "Long label"}\'` renders one parameter set at each size, and\n`--slots fixture.json` (`{"children": [ids], "slots": {"leading": id}, "nodes": {...}}`) passes slot content.\nSteps take paths: `--tap design/remove`.\n\n`--components-all` renders every component of the site that way in one run (`<Type>-<preview>@<w>x<h>.png`):\nthe quickest look at every part a page can call.'),
      DocSection('components-per-instance', 'Per instance', 'Everything a definition keeps is kept per instance, as a Flutter `State` is: its variables, its\ninteraction states, the values a `setValue` (or `setVariant`) sets on its nodes (set inside an instance, they change\nthat instance\'s node only). A variable with `"persist": true` is kept per instance path\n(`codelessly.component.<Type>.<path>.<name>` in the app\'s storage). When an instance leaves the screen (a list\nitem scrolled away, data that shrank), what it kept goes with it, as a `State` is disposed; shown again, it starts\nafresh (a persisted variable from its stored value).'),
      DocSection('components-published-components', 'Published components', 'A published site carries its components beside its pages (each at\n`publish/{project}/components/{Type}`, with a version and a digest; a bundle holds them in its `components` map),\nand an app loads the ones a screen calls with the screen, caches them, and follows a republished one: every\ninstance updates where it is, without reloading the pages that call it. Nothing to write in the app: a\n`CodelesslyWidget` showing a published site with components just works. A call whose component can\'t be loaded\nis an empty box of its size until it arrives (`component_missing` in the app\'s error log).'),
    ],
  ),
  DocPage(
    id: 'design-systems',
    title: 'Design systems',
    summary: 'Giving every screen one look that is not the renderer\'s default and not the host app\'s: a set of components (buttons, fields, selects, cards, dialogs...) drawn from core nodes, the tokens they are styled with, and the two documents an author reads first, the principles and the patterns.',
    when: 'Giving every screen one look that is not the renderer\'s default and not the host app\'s: a set of components (buttons,\nfields, selects, cards, dialogs...) drawn from core nodes, the tokens they are styled with, and the two documents an\nauthor reads first, the principles and the patterns. Use one for a site (`site.json` names it) or for a generated UI\n(the app gives it to the session); write one when several projects should share a look.',
    example: 'A design system is a folder with a manifest, `design_system.json`:\n\n```json\n{"id": "acme", "name": "Acme", "version": "1.0.0", "description": "Flat, hairline-bordered, dense.",\n "design": "DESIGN.md", "patterns": "PATTERNS.md",\n "theme": {"primary": "#FF2563EB", "onPrimary": "#FFFFFFFF", "surface": "#FFFFFFFF", "onSurface": "#FF111827",\n   "colors": {"border": "#FFE5E7EB"}, "dark": {"surface": "#FF141414", "onSurface": "#FFFFFFFF", "colors": {"border": "#FF383838"}},\n   "textStyles": {"body": {"fontSize": 13, "height": 1.5, "color": "onSurface"}},\n   "spacing": {"2": 8, "3": 12, "4": 16}, "radii": {"control": 7, "panel": 8}, "sizes": {"compact": 28}},\n "components": ["components/Button.json", "components/Card.json"],\n "replaces": ["filledButton", "outlinedButton", "textButton"]}\n```\n\nA site made with it names the folder; its pages call the components by type:\n\n```json\n{"schema": 3, "pages": ["home.json"], "designSystem": "../design_systems/acme",\n "theme": {"primary": "#FF7C3AED"}}\n```',
    pitfalls: '- A call has no `decoration`: style the definition, or add a parameter (`variant`, `size`).\n- A color written in full (`"#FF2563EB"`) does not follow dark mode: name it.\n- A scale step is read through a binding, not written where a number goes (`"padding": "md"` is not a number).\n- `replaces` hides base controls from the prompt only; documents that use them still render.',
    words: 1032,
    items: [],
    sections: [
      DocSection('design-systems-the-manifest', 'The manifest', '| Key | Meaning |\n|---|---|\n| `id` | Its id: what a site names when it is published, the prefix of its components\' publish paths. |\n| `name`, `version`, `description` | Shown to authors; the description is the prompt\'s first line about it. |\n| `design` | DESIGN.md: the principles (look, roles of the tokens, do and don\'t). Its `## In brief` section is what a prompt quotes. |\n| `patterns` | PATTERNS.md: forms, lists, cards, empty, loading and error states, density. Its `## In brief` is quoted too. |\n| `theme` | The tokens: a theme as `site.json` takes one, with its named scales (`spacing`, `radii`, `sizes`, `shadows`, `durations`, `curves`) and `dark`. |\n| `components` | Its component definitions, in the order its list shows them ([components](components.md#page-components)). |\n| `fonts` | The families it ships, files relative to the manifest (a pubspec\'s `fonts:`). |\n| `replaces` | The base node types its components stand in for: a prompt lists the components instead. They stay valid. |\n| `examples` | Example documents: a gallery of every component, sample screens. |\n\nA published design system is one bundle, `{"manifest": {...}, "design": "...", "patterns": "...", "components":\n{"Button": {...}}}`, read with `DesignSystem.fromJson`; a folder is read with `DesignSystem.load`.'),
      DocSection('design-systems-what-a-site-gets-from-it', 'What a site gets from it', '- **Theme.** The tokens are the site\'s base theme; the site\'s `theme` is merged over them key by key (a color, a\n  style, a scale step). Named colors and text styles, light and dark, work as in [the theme](theme.md#page-theme).\n- **The site\'s roles, everywhere.** A site that gives `primary`, `surface` or `onSurface` and nothing else gets the\n  design system in them: every color made from the accent follows `primary` (with what is drawn on it dark where the\n  accent is light, and text in the accent kept readable on the ground); every neutral (a color on the line from the\n  design system\'s ground to its ink: a card, a chrome, a band, a field, a hairline, a second ink) keeps its place\n  between the site\'s `surface` and `onSurface`, and an ink that read on the design system\'s ground reads on the\n  site\'s. A `surface` as dark as the design system\'s dark ground, given as the light one, starts from the dark side\'s\n  colors, roles and shadows. Colors named `on…`, scrims and hues are not tones of the ground and stay. `"mode":\n  "dark"` opens the site on the dark side.\n- **A page\'s type.** A text style named `<look>Page` beside `<look>` (`heading1Page`, `leadPage`, `bodyPage`) is what\n  a text of that look takes on a website\'s page in the notation (under `Page`), so one design system serves an app\'s\n  window and a landing page. What a site says of `<look>` it says of `<look>Page` too.\n- **Scales.** `\${theme.spacing.3}`, `\${theme.radii.panel}`, `\${theme.sizes.compact}`, `\${theme.shadows.level3}` and\n  `\${theme.durations.fast}` are read in bindings: `"bind": {"layout.padding": "\${theme.spacing.3}",\n  "decoration.radius": "\${theme.radii.panel}"}`. A name the theme does not have names nothing.\n- **Components.** Called by type as the site\'s own (`{"type": "Button", "props": {"label": "Save"}}`); a site\n  component of the same type wins.\n- **Nothing from the app.** The app the site runs in lends no color, font or shape; without a design system the\n  controls are neutral (ink on paper, small radii).'),
      DocSection('design-systems-writing-one', 'Writing one', '1. Write the tokens first: roles (`primary`, `surface`, `onSurface`, `error`...), named colors with their `dark`\n   values, text styles that name colors, and the scales.\n2. Draw each component from core nodes (`row`, `column`, `box`, `text`, `icon`): fills, strokes and radii by\n   token name, hover and press as interaction `states`, sizes and variants as parameters bound with formulas.\n   Wrap a core control only for what only it does (text editing, a native menu), and style every part of it.\n3. Give every component a one-sentence `doc` (its purpose) and a first preview (its minimal call).\n4. Render a gallery of every component, light and dark: `--components-all --theme dark`.'),
      DocSection('design-systems-in-a-generated-ui', 'In a generated UI', 'The app gives the session the design system: its catalog then has the components, and the prompt is generated from\nit (`runtimeStarter(designSystem: ds)`): the principles in brief, the tokens by name, each component with its\nparameters and a call, the patterns in brief, and no rows for the base controls it replaces. `ui_docs "design"`,\n`"patterns"` and a component\'s name give the rest.'),
    ],
  ),
  DocPage(
    id: 'charts',
    title: 'Charts, gauges and indicators',
    summary: 'Showing numbers as pictures: progress bars and rings, activity spinners, badges, gauges, bar, line and series charts, scatter plots and barcodes.',
    when: 'Showing numbers as pictures: progress bars and rings, activity spinners, badges, gauges, bar, line and series\ncharts, scatter plots and barcodes.',
    example: 'A goal\'s progress as a bar bound to a variable, and a week as a bar chart:\n\n```json\n{\n  "schema": 3,\n  "roots": ["stats"],\n  "nodes": {\n    "stats": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 300},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["goal", "bar", "week"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 300}, "padding": 24},\n      "props": {"crossAxisAlignment": "start", "spacing": 12}\n    },\n    "goal": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}},\n      "props": {"text": "\${done} of 7 days", "style": {"fontSize": 15, "color": "#FF111827"}}\n    },\n    "bar": {\n      "type": "progressBar",\n      "layout": {"width": {"fill": 342}, "height": 10},\n      "props": {"max": 7, "color": "#FF16A34A", "backgroundColor": "#FFE5E7EB", "borderRadius": 5},\n      "bind": {"props.value": "\${done}"}\n    },\n    "week": {\n      "type": "barChart",\n      "layout": {"width": {"fill": 342}, "height": 160},\n      "props": {\n        "values": [1, 1, 0, 1, 1, 0, 0],\n        "labels": ["M", "T", "W", "T", "F", "S", "S"],\n        "color": "#FF16A34A",\n        "labelFontFamily": "Roboto"\n      }\n    }\n  },\n  "variables": {"stats": [{"name": "done", "type": "integer", "value": 4}]}\n}\n```',
    pitfalls: '- Chart colors default to a dark theme\'s; set `color`, `gridColor` and the label colors on a light page.\n- A `barChart`\'s labels default to JetBrains Mono: set `labelFontFamily` to a font you have (`font_fallback`).\n- A chart\'s size is its node\'s layout: give it a fixed height.\n- `value` above `max` is clamped.',
    words: 8234,
    items: ['progressBar', 'circularProgressIndicator', 'activityIndicator', 'badge', 'radialGauge', 'gaugeMeter', 'chart', 'barChart', 'lineChart', 'plotChart', 'graph', 'barcode'],
    sections: [
      DocSection('charts-progress-from-state', 'Progress from state', 'Bind the value (`"bind": {"props.value": "\${done}"}`) with `max` the goal; `"animate": true` eases changes. A ring:\n`progressBar` with `"shape": "arc"` (`arcSweepAngle` 360 for a full circle) or `circularProgressIndicator`.'),
      DocSection('charts-charts-from-data', 'Charts from data', '`barChart` and `lineChart` take plain lists (`values`, `labels`); bind them to computed variables\n(`\${= map(week, d => d.count)}`). `chart` draws series over data rows (`data`, `series`, `labelField`) as bars,\nlines, areas, a timeline or a donut, with a selected index; `plotChart` plots x/y series with markers, ranges and\nreference lines.'),
    ],
  ),
  DocPage(
    id: 'data',
    title: 'Data: APIs, cloud data, storage and form submission',
    summary: 'The `data` feature library: calling HTTP APIs, reading and writing the project\'s cloud documents and files, storing values on the device, and submitting forms.',
    when: 'The `data` feature library: calling HTTP APIs, reading and writing the project\'s cloud documents and files,\nstoring values on the device, and submitting forms. Not in the agent trust profile at run time (a host enables it).',
    example: 'A value saved on the device and read back as `\${storage.theme}`:\n\n```json\n{\n  "schema": 3,\n  "roots": ["prefs"],\n  "nodes": {\n    "prefs": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 200},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["saved", "save"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 200}, "padding": 24},\n      "props": {"crossAxisAlignment": "start", "spacing": 12}\n    },\n    "saved": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 20}},\n      "props": {"text": "Saved theme: \${storage.theme}", "style": {"fontSize": 15, "color": "#FF111827"}}\n    },\n    "save": {\n      "type": "filledButton",\n      "layout": {"width": 160, "height": 44},\n      "props": {"label": "Use dark", "style": {"backgroundColor": "#FF111827", "foregroundColor": "#FFFFFFFF"}},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {"type": "setStorage", "key": "theme", "value": "dark"},\n            {"type": "showToast", "message": "Saved", "style": "success"}\n          ]\n        }\n      ]\n    }\n  }\n}\n```',
    pitfalls: '- These actions are not in the agent trust profile: a runtime model may document them but not use them unless the\n  host allows the `data` catalog.\n- An API\'s URL and secrets live in the publish model, never in the document.\n- `\${result}` is the response only inside `onSuccess`.',
    words: 2311,
    items: ['callApi', 'setStorage', 'cloudDocuments', 'loadCloudData', 'reloadCloudData', 'cloudFiles', 'cloudData', 'cloudBatch', 'submitForm'],
    sections: [
      DocSection('data-call-an-api-and-show-the-result', 'Call an API and show the result', '`callApi` names an API of the publish model (`services.apis`: method, URL, headers, body with `\${input}`\nplaceholders) and passes `params`; its result is `\${result}` in `onSuccess` (store it with `setVariable`), the\nerror in `onError`. Show a loading state with a variable set before the call and cleared in both chains.'),
      DocSection('data-cloud-documents', 'Cloud documents', '`cloudData` creates, updates, deletes, reads, queries or aggregates documents of a collection (`whereFilters`,\n`orderByFilters`, `limit`); its result goes in `resultVariable`. A list bound to a cloud query loads its pages\nthrough the list\'s `pagination`.'),
      DocSection('data-storage-on-the-device', 'Storage on the device', '`setStorage` writes `\${storage.<key>}` (a key may be a path into a stored map or list; `op` as `setVariable`\'s:\n`set`, `add` appends to a list, `insert` puts at an `index`, `remove` takes a value out). A variable with\n`"persist": true` is kept on the device too.\n\n- **Restore on load**: a canvas `load` reaction copies storage into a variable, `{"type": "setVariable",\n  "variable": "saved", "value": "\${= coalesce(storage.saved, [])}"}`; write it back after each change with\n  `{"type": "setStorage", "key": "saved", "valueType": "list", "value": "\${saved}"}`.\n- **A key per page or item** (a checklist per route): the key is an expression, `"key": "packed.\${route.id}"` with\n  `"op": "add"`, `"valueType": "list"`, `"value": "\${item}"`; read it with `\${= coalesce(get(storage.packed,\n  route.id), [])}`. A persisted variable is one value for every route.\n- The render command keeps storage in memory for one run: steps and `--navigate` see what earlier steps wrote; each\n  size and each run starts empty.\n\nA whole site using both: [a complete site](components.md#components-a-complete-multi-page-site).'),
      DocSection('data-submit-a-form', 'Submit a form', '`submitForm` validates the answers and stores them (`service: local`), or sends them to a destination the project\ndeclares; `onSuccess` and `onError` run after. See `docs/submit_form.md` in the package.'),
    ],
  ),
  DocPage(
    id: 'auth',
    title: 'Auth: signing users in',
    summary: 'The `auth` feature library: signing app users in, up and out, and managing their account, with `\${auth}` to show who is signed in.',
    when: 'The `auth` feature library: signing app users in, up and out, and managing their account, with `\${auth}` to show\nwho is signed in.',
    example: 'A sign-in form whose error appears in a text:\n\n```json\n{\n  "schema": 3,\n  "roots": ["signIn"],\n  "nodes": {\n    "signIn": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 320},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["email", "password", "error", "go"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 320}, "padding": 24},\n      "props": {"spacing": 12}\n    },\n    "email": {\n      "type": "textField",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 28}},\n      "props": {"decoration": {"labelText": "Email"}, "keyboardType": "emailAddress"},\n      "bind": {"props.initialValue": "\${email}"}\n    },\n    "password": {\n      "type": "textField",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 28}},\n      "props": {"decoration": {"labelText": "Password"}, "obscureText": true},\n      "bind": {"props.initialValue": "\${password}"}\n    },\n    "error": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 18}},\n      "props": {"text": "\${authError}", "style": {"fontSize": 13, "color": "#FFDC2626"}},\n      "bind": {"visible": "\${= authError != \'\'}"}\n    },\n    "go": {\n      "type": "filledButton",\n      "layout": {"width": {"fill": 342}, "height": 48},\n      "props": {"label": "Sign in", "style": {"backgroundColor": "#FF2563EB", "foregroundColor": "#FFFFFFFF"}},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [\n            {\n              "type": "auth",\n              "operation": "signIn",\n              "email": "\${email}",\n              "password": "\${password}",\n              "errorVariable": "authError"\n            },\n            {"type": "navigate", "to": "signIn", "mode": "pop"}\n          ]\n        }\n      ]\n    }\n  },\n  "variables": {\n    "signIn": [\n      {"name": "email", "type": "text", "value": ""},\n      {"name": "password", "type": "text", "value": ""},\n      {"name": "authError", "type": "text", "value": ""}\n    ]\n  }\n}\n```',
    pitfalls: '- Not in the agent trust profile at run time.\n- Keep the password in a variable only as long as the form needs it.',
    words: 470,
    items: ['auth'],
    sections: [
      DocSection('auth-show-the-signed-in-user', 'Show the signed-in user', '`\${auth.isSignedIn}`, `\${auth.email}`, `\${auth.displayName}`, `\${auth.initial}`, `\${auth.role}` bind like any value: a header shows "Sign in" or\nthe user\'s name by `visible` bindings on `\${auth.isSignedIn}`.'),
      DocSection('auth-errors', 'Errors', 'A failure\'s message goes in `errorVariable` and stops the chain: actions after `auth` run only on success.'),
    ],
  ),
  DocPage(
    id: 'commerce',
    title: 'Commerce: paywalls',
    summary: 'The `commerce` feature library: a paywall screen\'s interactions (buy, restore, select a product, close, open a legal link).',
    when: 'The `commerce` feature library: a paywall screen\'s interactions (buy, restore, select a product, close, open a\nlegal link).',
    example: '```json\n{\n  "schema": 3,\n  "roots": ["upgrade"],\n  "nodes": {\n    "upgrade": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 200},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["buy", "restore"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 200}, "padding": 24},\n      "props": {"spacing": 12}\n    },\n    "buy": {\n      "type": "filledButton",\n      "layout": {"width": {"fill": 342}, "height": 48},\n      "props": {"label": "Start free trial", "style": {"backgroundColor": "#FF2563EB", "foregroundColor": "#FFFFFFFF"}},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "paywall", "operation": "purchase"}]}]\n    },\n    "restore": {\n      "type": "textButton",\n      "layout": {"width": {"fill": 342}, "height": 40},\n      "props": {"label": "Restore purchases"},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "paywall", "operation": "restore"}]}]\n    }\n  }\n}\n```',
    pitfalls: '- Not in the agent trust profile at run time.\n- Prices shown must come from the store\'s products, not from text you write.',
    words: 439,
    items: ['paywall'],
    sections: [
      DocSection('commerce-a-paywall-screen', 'A paywall screen', 'The products and offers come from the project\'s paywall placement; the screen is an ordinary canvas whose buttons\nrun `paywall` operations (`selectProduct`, then `purchase`; `restore`; `closePaywall`; `openLegalLink`).'),
    ],
  ),
  DocPage(
    id: 'media',
    title: 'Media: video, audio, web views, speech and sound',
    summary: 'The `media` feature library: video players, embedded videos, an audio player, web views, reading text aloud, playing sounds, printing, capturing a screenshot, downloading a file, picking a file, sharing and preloading images.',
    when: 'The `media` feature library: video players, embedded videos, an audio player, web views, reading text aloud,\nplaying sounds, printing, capturing a screenshot, downloading a file, picking a file, sharing and preloading images.',
    example: '```json\n{\n  "schema": 3,\n  "roots": ["watch"],\n  "nodes": {\n    "watch": {\n      "type": "canvas",\n      "slots": {"body": "col"},\n      "layout": {"width": 390, "height": 320},\n      "decoration": {"fills": [{"color": "#FF000000"}]}\n    },\n    "col": {\n      "type": "column",\n      "children": ["clip", "read"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 320}},\n      "props": {"spacing": 12}\n    },\n    "clip": {\n      "type": "video",\n      "layout": {"width": {"fill": 390}, "height": 220},\n      "props": {"url": "https://example.com/intro.mp4", "showControls": true, "fit": "cover"}\n    },\n    "read": {\n      "type": "textButton",\n      "layout": {"width": 200, "height": 40},\n      "props": {"label": "Read aloud", "style": {"foregroundColor": "#FFFFFFFF"}},\n      "actions": [{"trigger": {"type": "click"}, "actions": [{"type": "speak", "text": "Welcome to the tour."}]}]\n    }\n  }\n}\n```',
    pitfalls: '- Not in the agent trust profile at run time.\n- The render command does not play media: a video draws its poster or nothing.',
    words: 2550,
    items: ['video', 'embeddedVideo', 'audioPlayer', 'webView', 'print', 'preloadImages', 'speak', 'playSound', 'captureScreenshot', 'downloadFile', 'pickFile', 'share'],
    sections: [
      DocSection('media-control-a-player-from-state', 'Control a player from state', 'Bind `props.playing` and `props.positionSeconds` to variables to play, pause and seek from buttons; the player\'s\n`changed` trigger reports `ready`, `error`, the duration and the position.'),
      DocSection('media-save-a-file', 'Save a file', '`{"type": "downloadFile", "fileName": "trip.txt", "text": "\${brief}", "mimeType": "text/plain"}` offers the text as\na file (the browser\'s download, a save dialog elsewhere); `\${result.saved}` says whether it was saved. The keys are\n`fileName` and `text` (not `filename`, `content`). The render command saves it under `<out>/downloads/` and lists it.'),
      DocSection('media-pick-a-file-without-uploading-it', 'Pick a file without uploading it', '`{"type": "pickFile", "accept": "image/*,.pdf"}` opens the device\'s file chooser; `\${result}` is the picked file\'s\nrecord, `{"name", "size", "type", "data"}` (`data` a `data:` URL: an image\'s `url`, or a `cloudFiles` action\'s\n`source` when it is uploaded after all). `"multiple": true` gives a list of records; `"content": "text"` gives\n`text` in place of `data`, `"none"` neither. Picking nothing stops the chain. The render command picks the files its\n`--pick-file <path>` names.'),
      DocSection('media-share', 'Share', '`{"type": "share", "title": "\${story.title}", "url": "\${screen.url}"}` opens the device\'s share panel;\n`\${result.shared}` says whether it took it. Where there is no share panel the URL (or, without one, the text) is\ncopied to the clipboard and `\${result.copied}` is true: show a toast then.'),
      DocSection('media-read-along-text', 'Read-along text', '`speak` with `readAlong` times the words for a highlight bound to the spoken word.'),
    ],
  ),
  DocPage(
    id: 'engage',
    title: 'Engage: app events and automations',
    summary: 'The `engage` feature library: firing app events that the project\'s automations listen for (a popup after a lesson, a review prompt after the third order), and the `\${usage}` counters they read.',
    when: 'The `engage` feature library: firing app events that the project\'s automations listen for (a popup after a\nlesson, a review prompt after the third order), and the `\${usage}` counters they read.',
    example: '```json\n{\n  "schema": 3,\n  "roots": ["done"],\n  "nodes": {\n    "done": {\n      "type": "canvas",\n      "slots": {"body": "finish"},\n      "layout": {"width": 390, "height": 120},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "finish": {\n      "type": "filledButton",\n      "layout": {"width": 200, "height": 48},\n      "props": {"label": "Finish lesson", "style": {"backgroundColor": "#FF2563EB", "foregroundColor": "#FFFFFFFF"}},\n      "actions": [\n        {\n          "trigger": {"type": "click"},\n          "actions": [{"type": "emitEvent", "event": "lessonFinished", "props": {"lesson": "intro"}}]\n        }\n      ]\n    }\n  }\n}\n```',
    pitfalls: '- Not in the agent trust profile at run time.\n- An event no automation listens for does nothing.',
    words: 311,
    items: ['emitEvent'],
    sections: [
      DocSection('engage-fire-an-event', 'Fire an event', '`{"type": "emitEvent", "event": "lessonFinished", "props": {"lesson": "intro"}}`: every automation of the project\nlistening for `lessonFinished` runs, reading `\${event.props.lesson}` and `\${usage.events.lessonFinished.count}`.\nAutomations live in the publish model, not in the document.'),
    ],
  ),
  DocPage(
    id: 'publish',
    title: 'Publish, managed components and plugins',
    summary: 'What happens to documents after they are written: a published app\'s model (its layouts, components, theme and identity), page paths and titles, components published by reference, managed component releases and hosted plugins.',
    when: 'What happens to documents after they are written: a published app\'s model (its layouts, components, theme and\nidentity), page paths and titles, components published by reference, managed component releases and hosted\nplugins. Read it when you set a canvas\'s URL path or title, or ship components others reuse; the documents\nthemselves do not change.',
    example: 'A page whose canvas has a URL path and a name (its default title):\n\n```json\n{\n  "schema": 3,\n  "id": "pricing",\n  "roots": ["pricing"],\n  "nodes": {\n    "pricing": {\n      "type": "canvas",\n      "name": "Pricing",\n      "path": "pricing",\n      "slots": {"body": "title"},\n      "layout": {"width": 390, "height": 200},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "title": {\n      "type": "text",\n      "layout": {"width": {"fill": 390}, "height": {"hug": 34}, "margin": 24},\n      "props": {"text": "Pricing", "style": {"fontSize": 28, "fontWeight": 700, "color": "#FF111827"}}\n    }\n  }\n}\n```',
    pitfalls: '- The publish model is written by the editor and the publish tools, not by hand in a page document.\n- A component\'s file must be named after its type.',
    words: 681,
    items: [],
    sections: [
      DocSection('publish-the-publish-model-s-parts', 'The publish model\'s parts', '| Class | What it is |\n|---|---|\n| `PublishModel` | A published project: its layouts (by id, loaded on their own), entry screen, fonts, theme and APIs. |\n| `PublishLayout` |  |\n| `PublishComponent` | One published component definition (`publish/{p}/components/{id}`): its `document` (a component document: one root, a `widget` declaration) with its version and digest. |\n| `PublishComponentInfo` | What a publish model knows of one published component without loading it: its version and digest (a cached copy with another digest is stale), when it was published and the fonts its text uses (loaded with the screens that call it). |\n| `AppIdentity` | A published app\'s identity (the publish model\'s `appIdentity`). JSON: the identity\'s own (see the file comment), with every key this version doesn\'t model kept in `extra`. |\n| `PageIdentity` | One page\'s (or screen\'s) title and description override, keyed in `AppIdentity.pages` by an editor page id, or a canvas or layout id. |\n| `StyleSheet` | A project\'s style sheet (`style_sheets/{projectId}`), in its own format, version `schema` (not the document schema, `kSchemaVersion`). |\n| `NamedTextStyle` | A named text style. |\n| `CanvasBreakpoint` | Which project breakpoint a canvas of a layout is the design for (DESIGN.md §5.3). A layout with several canvases (one screen, one canvas per breakpoint) shows the one whose switch point is the highest at or below the width it\'s shown at (see `CanvasBreakpointsForWidth.forWidth`). |\n| `PluginRef` | What a project uses of a hosted plugin: the channel it follows, an optional major pin, and the version (and its digest) the editor built and previewed with. JSON: `{"id": "codelessly.charts", "channel": "stable", "pin": 2, "version": 14, "semver": "2.3.1", "digest": "9f2c…"}`. |\n| `Automation` | One automation of a project. Its `when` and its actions read the app\'s values (variables, `auth`, `storage`, `data`), `\${event}` (`name`, `props`) and `\${usage}`, the per-user counters the runtime keeps on the device:<br><br>- `usage.launches`, `usage.sessions`, `usage.firstSeen`, `usage.lastSeen` (ms since epoch), `usage.isFirstLaunch`, `usage.isFirstSession`;<br><br>- `usage.events.<name>.count` and `.last`: every app event fired;<br><br>- `usage.automations.<id>.count`, `.last` and `.session` (runs this session).<br><br>`maxRuns`, `maxPerSession` and `everyDays` limit how often it runs ("once", "once per session", "at most every 7 days"). |'),
      DocSection('publish-a-page-s-url-and-title', 'A page\'s URL and title', 'A canvas\'s `"path"` is its URL (`/pricing`); without one it gets a path from its name. The app identity\'s title\ntemplate (`\${page.title} · \${app.name}`) makes each page\'s title; a page can override its title and description.'),
      DocSection('publish-components-by-reference', 'Components by reference', 'A published site carries its components beside its pages; an app loads the ones a screen calls with the screen,\ncaches them, and follows a republished one: every instance updates where it is. Nothing to write in the\ndocuments ([published components](components.md#components-published-components)).'),
    ],
  ),
  DocPage(
    id: 'edit-ops',
    title: 'Edit ops and streaming',
    summary: 'Building and changing a document with edit operations: what a model sends in a `ui_apply` tool call, what an app\'s `UiSession` applies while the model streams, the retry protocol for rejected ops, the tools\' schemas and the trust profiles that limit what a model may use.',
    when: 'Building and changing a document with edit operations: what a model sends in a `ui_apply` tool call, what an app\'s\n`UiSession` applies while the model streams, the retry protocol for rejected ops, the tools\' schemas and the trust\nprofiles that limit what a model may use.',
    example: 'The ops that build the base\'s smallest document, top-down, as a model streams them:\n\n```json\n{\n  "ops": [\n    {"op": "roots", "roots": ["home"]},\n    {\n      "op": "set",\n      "id": "home",\n      "node": {\n        "type": "canvas",\n        "name": "Home",\n        "slots": {"body": "page"},\n        "layout": {"width": 390, "height": 844},\n        "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n      }\n    },\n    {\n      "op": "set",\n      "id": "page",\n      "node": {\n        "type": "column",\n        "children": ["title", "body"],\n        "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n        "props": {"crossAxisAlignment": "start", "spacing": 12}\n      }\n    },\n    {\n      "op": "set",\n      "id": "title",\n      "node": {\n        "type": "text",\n        "layout": {"width": {"fill": 342}, "height": {"hug": 34}},\n        "props": {"text": "Hello", "style": {"fontWeight": 700, "fontSize": 28, "color": "#FF111827"}}\n      }\n    },\n    {\n      "op": "set",\n      "id": "body",\n      "node": {\n        "type": "text",\n        "layout": {"width": {"fill": 342}, "height": {"hug": 40}},\n        "props": {\n          "text": "A column with two texts, filling the screen\'s width.",\n          "style": {"fontSize": 15, "color": "#FF4B5563", "height": 1.4}\n        }\n      }\n    }\n  ]\n}\n```',
    pitfalls: '* A `patch` is an RFC 7396 merge patch on one node, shaped like the node: objects merge, lists and values replace,\n  `null` deletes a key. It never changes `children`, `slots` or `type` (`structural_key_in_patch`): child lists\n  change only through `set` (with `parent`), `move` and `remove`.\n* A `set` of an id that exists replaces the node (the result says which ids it created). Replacing a node that had\n  children it no longer lists is `would_orphan`: keep them, move or remove them first, or patch instead.\n* Each op is checked on its own, against what it touched: its structure (one parent, no cycle, no canvas as a child,\n  a parent that takes children there), the trust profile, and the nodes\' fields (`catalogCheck`: types, keys and\n  values against the catalog\'s declarations, on the nodes the op created or changed, their parents and children). A rejected op changes nothing; the others\n  apply (with `"atomic": true`, all or none).\n* A batch may carry `"baseRev"`, the revision the author read: a patch of a field, or a set of a node, that another\n  author changed since is `stale_rev`, with the current value. Every applied batch has inverse ops: applied\n  atomically, they restore the document (undo).',
    words: 3591,
    items: [],
    sections: [
      DocSection('edit-ops-the-ops', 'The ops', 'A document is built and changed with six **edit operations**, each addressed by node id: what an agent sends in a\n`ui_apply` tool call, what `codelessly apply` takes, and what an app\'s `UiSession` applies while a model streams\n(`applyOps`, `decodeOps`, `OpStreamDecoder` in `package:codelessly_api/core.dart`). Generation is just the first\nbatch of ops; every change after it is a few more.\n\n| Op | Fields | Means | Example |\n|---|---|---|---|\n| `set` | `id`, `node`, `nodes`, `parent`, `index`, `slot`, `placeholders` | Create node `id` (or replace it: the result says which), optionally placed under `parent` at `index` (default: last) or in `slot`. `node` is the node as the document holds it under "nodes": its `children` may list ids that arrive in later ops (pending until then). `nodes` sets several nodes at once (id → node), in order. `placeholders` gives a size (a layout fragment) to show for a pending child until it arrives. | `{"op":"set","id":"faqTitle","parent":"faqSec","index":0,"node":{"type":"text","layout":{"width":{"hug":120},"height":{"hug":28}},"props":{"text":"Questions","style":{"fontSize":22,"fontWeight":700,"color":"#FF111827"}}}}` |\n| `patch` | `id` (required), `patch` (required) | Merge `patch` into node `id` (RFC 7396): objects merge, arrays and scalars replace, null deletes a key. Shaped like the node (`{"props": {"text": "Book a demo"}}`). It cannot change `children`, `slots` or `type`. | `{"op":"patch","id":"heroTitle","patch":{"props":{"text":"Book a demo","style":{"color":"#FF0F766E"}}}}` |\n| `move` | `id` (required), `parent` (required), `index`, `slot` | Move node `id` (with its subtree) under `parent` at `index` (default: last), or into `slot`. Reorder: move within the same parent. | `{"op":"move","id":"faqSec","parent":"page","index":2}` |\n| `remove` | `ids` (required) | Remove the nodes `ids` and everything under them; their parents stop listing them. | `{"op":"remove","ids":["promoBanner"]}` |\n| `vars` | `scope` (required), `set`, `remove` | Variables of `scope` (a canvas id, or "page_variables"): `set` maps a name to its new value, or to a full variable object (`{"type": "boolean", "value": false}`) to declare it; `remove` lists names to remove. Bindings that read them update at once. | `{"op":"vars","scope":"pricing","set":{"annual":true}}` |\n| `roots` | `roots` (required) | Set the document\'s canvases, in order. A root may name a canvas that arrives in a later op. | `{"op":"roots","roots":["home"]}` |\n| `scripts` | `set`, `remove` | The document\'s scripts (sandboxed JavaScript, where allowed): `set` maps a name to {"source", "params", "capabilities", "timeoutMs"}; `remove` lists names. A reaction runs one ({"type": "runScript", "script": name}), a formula calls it (script.name(...)). | `{"op":"scripts","set":{"clamp":{"params":["v"],"source":"return Math.max(0, Math.min(9, v));"}}}` |'),
      DocSection('edit-ops-codes-of-the-edit-layer', 'Codes of the edit layer', '| Code | Rejects the op | Meaning |\n|---|---|---|\n| `invalid_op` | yes | An op that is not an object, or names no known "op" (set, patch, move, remove, vars, roots, scripts). |\n| `missing_field` | yes | An op without a field it needs ("id", "node", "patch", "parent", "ids", "scope", "roots"). |\n| `wrong_type` | yes | A field of an op with the wrong JSON type (an id that is not text, a node that is not an object). |\n| `unknown_id` | yes | A patch, move or remove of a node the document does not have, or a set or move under a parent it does not have. |\n| `structural_key_in_patch` | yes | A patch that changes "children" or "slots" (or "type"): child lists change only through set, move and remove; a type through set. |\n| `stale_rev` | yes | The op changes a field another author changed after the batch\'s "baseRev": re-read the node (ui_read) and decide. |\n| `would_orphan` | yes | A set that replaces a node and drops children it had: they would be left under no parent. Keep them in "children", move or remove them first, or use patch. |\n| `multiple_parents` | yes | The op would list a node under a second parent (or twice in one): a node has one parent. Use move to change its parent. |\n| `cycle` | yes | The op would put a node inside its own subtree. |\n| `canvas_as_child` | yes | The op would place a canvas under a parent: canvases are only roots. |\n| `invalid_parent` | yes | A set or move under a parent that takes no children there: a type without children, or a slot the type does not have. |\n| `dangling_child` | yes | At the end of the stream, a child or slot id that names no node (it was pending and never arrived). |\n| `unreachable_node` | no (a warning) | At the end of the stream, a node no root reaches (nothing lists it as a child or slot). |\n| `pending_child` | no (a warning) | A child or slot id the op lists that has not arrived yet: accepted while streaming, an error (dangling_child) if it never comes. |\n| `capability_not_allowed` | yes | The op uses a node type, action, script, link, image host or navigation target the session\'s trust profile does not allow. |\n| `limit_exceeded` | yes | The op would exceed a limit of the trust profile (nodes, depth, text length, ops per call). |\n| `truncated_op` | yes | The stream ended inside an op: what arrived of it was not applied. |\n| `invalid_json` | yes | The tool input is not JSON where an op was expected. |\n| `invalid_variable` | yes | A vars op that declares a variable without a name, or sets one with a value its type cannot hold. |\n| `unknown_variable` | no (a warning) | A vars op that sets (or removes) a variable the scope does not declare: declare it with a full variable object. |\n| `malformed_input` | no (a warning) | The tool input\'s JSON was not well formed at a character offset (a stray or missing brace or bracket, a trailing or missing comma, an op that began before the previous one closed): the decoder repaired it and read the ops around it. Write balanced JSON: one closing brace per opening brace. |\n| `misplaced_field` | no (a warning) | A node field ("bind", "props", "actions"...) written on a set op instead of inside its "node": it was moved into the node. |\n\n(Continues: edit-ops.md#edit-ops-codes-of-the-edit-layer.)'),
      DocSection('edit-ops-the-tools', 'The tools', '`outline(document)` is one row per node, `[id, type, label, depth, {what is bound, states, triggers}]`, a sixth to\na seventh of the document\'s size (the two m05 pages: 6.7 KB for 147 nodes against 47.6 KB, 8.3 KB for 196 nodes\nagainst 55.4 KB). `readUi` answers the `ui_read` tool: the outline, or whole nodes by id.\n\nThe two tools (`uiTools(catalog)`), their input schemas generated from the op declarations and the catalog\'s\nnode types (the agent profile over the core: [ui_tools.json](ui_tools.json)):\n\n```json\n[\n  {\n    "name": "ui_apply",\n    "description": "Build or change the UI. The UI is one document: a flat map of nodes by id, each a Flutter-like widget (type, layout, decoration, props, children). Ops apply in order: set (create or replace a node, optionally placing it under a parent), patch (RFC 7396 merge patch on one node; null deletes a key), move, remove, vars (set or declare variables) and roots (the screens). Ids are the addresses: choose short readable ids. A node may list children that arrive in later ops. When building, write top-down: the roots op and the canvas first, then each container before its children, section by section, so the UI paints as it streams. To change an existing UI, send only the small ops the change needs (patch a prop instead of re-sending a node). The result lists the ops that were rejected with a code, a path and a suggestion: fix and resend only those.",\n    "input_schema": "(see ui_tools.json)"\n  },\n  {\n    "name": "ui_read",\n    "description": "Read the current UI before changing it: the outline (one row per node: id, type, label, depth, what is bound), or full nodes by id. Read the outline first; ask for full nodes only for the ones you will change.",\n    "input_schema": "(see ui_tools.json)"\n  }\n]\n```\n\nA schema that enumerates every node type and key is the wrong shape for a runtime tool: it costs tokens on every\ncall and still cannot say what a prop holds. `uiTools(catalog, compact: true)` gives the op envelope strictly (op\nnames, field names and kinds from the declarations; [ui_tools.compact.json](ui_tools.compact.json)) and leaves the\nnode\'s contents to the system prompt: the **base** in its runtime form, `runtimeStarter(catalog:, profile:, kind:)`\n([RUNTIME_STARTER.md](RUNTIME_STARTER.md)). It is the same document as [STARTER.md](STARTER.md), assembled by\n`baseDocument` from the same generated segments, with the runtime envelope (answering rules, the ops, two examples\nthat apply cleanly) in place of the file envelope (the render command, sites as files), and its tables restricted\nto what the trust profile allows. `ui_read {"types": [...]}` describes any other allowed type on demand\n(`describeTypes`), and the per-op check does the rest.\n\nThe base ends with the index of the third tool, `ui_docs {"topic": ...}` (`uiTools(catalog, compact: true, docs:\ntrue)`). `docsTopic` answers with these pages: a page\'s *When to use*, minimal example and pitfalls, and the list of\nits sections; any section by its anchor (`ui_docs "forms-validation-and-an-error-state"`); any node type, action\ntype, trigger or behavior by name, generated from the declarations. A link `forms.md#x` in the files is\n\n(Continues: edit-ops.md#edit-ops-the-tools.)'),
      DocSection('edit-ops-the-trust-profile', 'The trust profile', '`TrustProfile` is what an edited document may use: node types and action types (a restricted catalog,\n`profile.restrict(catalog)`), scripts, link and image hosts, navigation, and limits (nodes, depth, text length, ops\nper call). `TrustProfile.agent`, the default for agent-written UI, allows the core\'s node types and its local\nactions (variables, values, in-document navigation, modals, toasts, scrolling, animation, `componentEvent`): no\nscripts, no links, no host functions, no feature library\'s types. A violation is `capability_not_allowed` or\n`limit_exceeded`, with the op and the path.\n\n`componentEvent` in a document that is not a component (an agent\'s UI) is the event to the document\'s host: the\nsession delivers it to the app, which sends it to the model.'),
      DocSection('edit-ops-a-follow-up-edit', 'A follow-up edit', 'Then a follow-up instruction ("add a button under the title, drop the body text, make the title say Welcome") is\na few ops, not a new document:\n\n```json\n{"ops": [\n  {"op": "set", "id": "cta", "parent": "page", "index": 1,\n   "node": {"type": "row", "children": ["ctaText"], "layout": {"width": {"hug": 140}, "height": 44, "padding": [16, 0, 16, 0]},\n            "decoration": {"fills": [{"color": "#FF2563EB"}], "radius": 10}}},\n  {"op": "set", "id": "ctaText", "node": {"type": "text", "layout": {"width": {"hug": 100}, "height": {"hug": 20}},\n            "props": {"text": "Get started", "style": {"fontSize": 15, "fontWeight": 600, "color": "#FFFFFFFF"}}}},\n  {"op": "remove", "ids": ["body"]},\n  {"op": "patch", "id": "title", "patch": {"props": {"text": "Welcome"}}},\n  {"op": "vars", "scope": "home", "set": {"taps": {"type": "integer", "value": 0}}},\n  {"op": "patch", "id": "cta", "patch": {"actions": [{"trigger": {"type": "click"},\n            "actions": [{"type": "setVariable", "variable": "taps", "op": "add", "value": 1}]}]}},\n  {"op": "move", "id": "cta", "parent": "page", "index": 0}\n]}\n```\n\nA batch with a mistake: the second op misspells `fills`. It is rejected with a code, the path and a suggestion; the\nfirst applies:\n\n```json\n{\n  "ops": [\n    {"op": "patch", "id": "title", "patch": {"props": {"text": "Welcome back"}}},\n    {"op": "patch", "id": "title", "patch": {"decoration": {"fill": [{"color": "#FFF1F5F9"}]}}}\n  ]\n}\n```\n\nThe result (`EditResult.toModelJson()`, the tool result):\n\n```json\n{\n  "rev": 1,\n  "applied": [0],\n  "ids": {"patched": ["title"]},\n  "rejected": [\n    {\n      "op": 1,\n      "code": "unknown_decoration_key",\n      "path": "/nodes/title/decoration/fill",\n      "message": "decoration has no \\"fill\\": a fill is a list of paints: \\"decoration\\": {\\"fills\\": [{\\"color\\": \\"#FF2563EB\\"}]}.",\n      "nodeId": "title",\n      "expected": [\n        "fills",\n        "strokes",\n        "strokeWidth",\n        "strokeAlign",\n        "strokeSides",\n        "strokeCap",\n        "dashPattern",\n        "radius",\n        "effects",\n        "clip",\n        "blendMode",\n        "foregroundFills",\n        "shape",\n        "clipPath",\n        "clipViewBox",\n        "clipFit",\n        "clipCuts"\n      ],\n      "suggestion": "fills"\n    }\n  ],\n  "warnings": [],\n  "document": {"roots": ["home"], "nodes": 4},\n  "next": "The UI exists as described (rev 1): fix it by patching it, in one ui_apply call. Resend only the rejected ops, corrected, with the same ids; patch fields of nodes that exist. Never start over: no new roots, no new canvas, no re-sending nodes that applied."\n}\n```'),
      DocSection('edit-ops-streaming', 'Streaming', 'LLM APIs deliver a tool call\'s input as text deltas cut anywhere. `OpStreamDecoder` yields each op the moment its\nclosing brace arrives (inside a `set` with `nodes`, each node as its own brace closes), whatever the cuts; a stream\ncut mid-op keeps every complete op and reports the tail (`truncated_op`).\n\n**Malformed input.** With eager (fine-grained) tool input streaming a provider does not promise valid JSON, and\nmodels do not always write it: a recorded live generation closed one brace too many three times in 24 ops. The\ndecoder works around op boundaries, not the enclosing JSON: it keeps a repaired copy of the text (a closer that\ncloses nothing is dropped, a missing one is inferred, trailing commas are removed, missing commas inserted), reads an\nop object (`{"op": ...}`) at any depth outside another op (after an `ops` array closed early, in a wrapper of\nanother name, after text), and when an op begins before the previous one closed, closes that one where the next\nbegan and reads what it can of it. Each repair is one `malformed_input` warning with the character offset; the ops\naround it apply. A node field written beside `"node"` (what an early closing brace produces) is moved into the node\n(`misplaced_field`). A single stray or missing brace, bracket or comma loses at most the op it is in\n(`test/edit_stream_recovery_test.dart` checks this property on 2,000 random edits, and that every chunking yields the\nsame ops). `OpStreamEnd.repairs` and `.recovered` count the repairs and the ops read after the first one.\n\nWhile a document streams in, it is incomplete by nature:\n\n* **Order.** Root first, then top-down: the `roots` op, the canvas, its container, then each section complete before\n  the next. Nothing breaks if a model does otherwise.\n* **Forward references.** A child id listed before its node arrives is **pending**, not an error; a reference to a\n  node, screen or variable that has not arrived yet (a state that patches it, a navigation to it) is a warning while\n  the stream runs (`applyOps(..., incomplete: true)`). When the stream ends, `endOfStream` reports every id still\n  dangling (`dangling_child`), so the model can send it.\n* **Rendering** (the SDK\'s `UiSession`): nothing paints until a root canvas has content; a pending child takes no\n  room (or the size a `set`\'s `placeholders` gave it); a container none of whose children has arrived waits for\n  its first, so no empty shells flash; text and values are never shown half-written (an op applies only whole).'),
      DocSection('edit-ops-the-retry-protocol', 'The retry protocol', 'After a stream, the tool result (`EditResult.toModelJson()`) says exactly what the document holds and what to do:\n`rev`, the ops that applied (by index, and the ids they set, patched, moved and removed), every rejected op with its\ncode, path, what was expected and a suggestion, warnings (at most 20), the pending ids, the document\'s roots and node\ncount, and, when anything was rejected or is pending, `next`: fix it by patching the document as it is (same ids),\nnever start over. A host sends it back and lets the model answer with one more `ui_apply`, a capped number of\ntimes (the chat example: 2), stopping when nothing is rejected or pending. `applyOps(..., protectRoots: true)`\nanswers a batch that would replace the existing roots or create a new canvas with `start_over` (a live retry did\nexactly that instead of fixing three ops). The diagnostics models hit carry the fix as JSON (`explainDiagnostic`): a\nsize written as a layout key (`"height": {"hug": 46}`), children on a type that takes none (the types that do, and a\nrow with a fill for a tag or button), a button\'s `text` (its `label`). `uiLints(document)` adds what no declaration\ncatches: `empty_button` (a tappable box that shows nothing) and `low_contrast` (text in its background\'s color); a\nrenderer adds `missing_glyph` and `no_size` (the SDK\'s `UiSession.renderDiagnostics`).'),
    ],
  ),
  DocPage(
    id: 'render',
    title: 'The render command: checking your work',
    summary: 'Checking a document or a site before trusting it: screenshots at each size, the states after taps, typing and scrolling, and a diagnostic for every problem with a code, a JSON pointer and what to do.',
    when: 'Checking a document or a site before trusting it: screenshots at each size, the states after\ntaps, typing and scrolling, and a diagnostic for every problem with a code, a JSON pointer and what to do. The\ncommand lives in the SDK repository (`tool/render/render.sh`; its README has every option).',
    example: 'The smallest document, and the command that checks it at three sizes:\n\n```json\n{\n  "schema": 3,\n  "roots": ["home"],\n  "nodes": {\n    "home": {\n      "type": "canvas",\n      "name": "Home",\n      "slots": {"body": "page"},\n      "layout": {"width": 390, "height": 844},\n      "decoration": {"fills": [{"color": "#FFFFFFFF"}]}\n    },\n    "page": {\n      "type": "column",\n      "children": ["title", "body"],\n      "layout": {"width": {"fill": 390}, "height": {"fill": 844}, "padding": 24},\n      "props": {"crossAxisAlignment": "start", "spacing": 12}\n    },\n    "title": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 34}},\n      "props": {"text": "Hello", "style": {"fontSize": 28, "fontWeight": 700, "color": "#FF111827"}}\n    },\n    "body": {\n      "type": "text",\n      "layout": {"width": {"fill": 342}, "height": {"hug": 40}},\n      "props": {\n        "text": "A column with two texts, filling the screen\'s width.",\n        "style": {"fontSize": 15, "height": 1.4, "color": "#FF4B5563"}\n      }\n    }\n  }\n}\n```\n\n```sh\ntool/render/render.sh home.json --out shots/ --sizes 390x844,834x1112,1440x900 --full-page\n```',
    pitfalls: '- Every diagnostic is about the page as it renders at that size: its media rules applied, what scrolls there, what\n  an ancestor clips away.\n- The command does not fetch network images or fonts: put the files beside `site.json` and name them by their\n  relative path.\n- A `--tap` scrolls the target into view; a `--full-page` capture still starts at the top.\n- Runs on one SDK checkout take turns (each waits for the one before): start several, and they finish one after\n  another.',
    words: 2186,
    items: [],
    sections: [
      DocSection('render-what-it-does', 'What it does', 'Decoding is lenient: a misspelled key, a value of the wrong shape or an unknown enum value is silently ignored or\nreplaced by its default. Never trust a document that has not been checked. The command\nrenders each screen with the SDK at each size, writes `shots/<screen>@<w>x<h>.png` and\n`shots/diagnostics.json`, and prints one line per problem with a code, the JSON pointer of the value\n(`/nodes/hero-title/props/style/fontSize`) or the node, and what to do. It exits 1 when there are errors.'),
      DocSection('render-steps-before-the-capture', 'Steps before the capture', 'In order: `--tap <id>` (`<id>#<n>` for the n-th copy of a list item; a node out of view or under an overlay is\nscrolled to the middle first, and a tap that would land on another node is reported, not made), `--hover <id>`,\n`--focus <id>` (any node that takes the keyboard focus: a field, a button, a row or handle with a tap or key\nreaction; the next `--key` goes to it), `--unfocus`, `--type <id>=<text>` (a newline in the text is typed: a\nmulti-line field gets every line), `--key <key>`, `--set <variable>=<json>`, `--stage <variable>=<json>`,\n`--scroll <id or screen>=<px>` (or `=<x>,<y>`; its `scroll` and `scrollEnd` reactions run, as a user\'s scroll runs them; a page that does not scroll is a `scroll_nothing` warning), `--drag <id>=<dx>,<dy>` (or `=<other id>`: onto a node; `,press=<ms>` rests the finger first, so a hold reaction fires before the same pointer moves), `--double-tap <id>`, `--wheel <id>=<dy>`\n(a mouse wheel over the node; `=ctrl+<dy>` with Control held), `--pinch <id>=<scale>` (two fingers spread to that\nmany times as far apart), `--long-press <id>` (`=<ms>` held that long; `=<ms>,hold` not lifted), `--navigate <screen>`,\n`--wait <ms>`, `--frames <ms>,...`. A step\nmay name a node by its `name` too. In a site, steps name nodes inside components by path (`--tap plans/card1/cta`)\nand a node in a list\'s copy as `<template>#<n>/<node>` (`evCard#0/evReserve`, the same as `evReserve#0`); with no\n`#<n>` a step reaches the first copy in view; `#<n>` counts the copies shown, not those an `if` hides. A node\ninside a component is also found by the end of its path (`joinSeason/action`, `action`) when one node on screen\nhas it; with several, the error lists their paths. A node written inside a defined word (a site\'s\n`components/*.txt`, a dictionary word: expanded in place, `IconButton#editorBack` in `EditorBar` becomes\n`editorBack_editorBar1`) is reached by the id written there (`--tap editorBack`, `dayCell#22`) when one is on\nscreen; with several calls the error names each as `<call>/<id>` (`editorBar2/editorBack`), which reaches one. A tab, a segment or a navigation destination is tapped by its\nposition (`--tap tabs@2`, the third, from zero) or, where it has one no node shares, by its own id or value\n(`--tap stay` for the tab `{"id": "stay"}`). A control\'s parts have names: `quantity@decrement`,\n`quantity@increment` on a NumberInput, `level@thumb` (`@thumb-end` on a range) on a Slider,\n`region@option:Alaska` on a Select (opened first), `stay@2026-11-23` for a calendar\'s day, `password@suffix` (or\n`@prefix`) for a text field\'s icon with reactions, pressed in the field so it keeps the focus; `--dump-layout`\nlists each control\'s `parts`. A toast\'s button is `toastAction` or its label (`--tap Undo`), its close\n`toastClose`; a confirm\'s are `confirmOk` and `confirmCancel`. A step names a node, never a point (`150,345`). A\nnode covered wherever it shows is an error naming what covers it, which child to put after which when both are in\none node (the last child is drawn on top and takes the press), and the copies of a list item nothing covers. A component\'s root may be named after its call (`nav/tabs`). Ids are\n\n(Continues: render.md#render-steps-before-the-capture.)'),
      DocSection('render-render-codes', 'Render codes', 'The render step reports what rendering shows: `render_exception` (naming the node), `action_error`,\n`interaction_failed`, `step_skipped`, `tap_no_reaction`, `layout_overflow`, `offscreen`, `text_clipped`, `text_truncated`,\n`text_no_color`, `missing_glyph`, `icon_not_drawn`, `icon_smaller_than_size` (an icon\'s `size` larger than its box),\n`zero_size` (a node that paints, laid out 0 wide or 0 high, with the cause), `control_heights_differ` (controls in one\nRow drawn at different heights: each named with its height, written or hugged), `expression_not_evaluated`, `path_overflow`, `font_fallback`,\n`font_missing` (one report for the site, before any screen: each declared face whose file is not there, where it\nwas looked for and what it is drawn with instead), `fill_fallback`, `image_failed`, `image_network`, `empty_screen`, `invalid_json`,\n`component_missing`, `set_overwritten`, `theme_name_unknown` (a color or a `theme.<name>` the theme does not have),\n`paints_outside` (a child drawn past its Stack over what follows it), `formula_failed` (a formula that could not be worked out when the screen ran:\nthe node that reads it, the formula and why), `formula_runaway` (functions that call each other without end), `screen_timeout`\n(a screen over `--screen-timeout`, 120 s: the run goes on to the next), `site_now`, `page_not_written`, `placeholder_word` (a word that stood in when the site\'s\nnotation was expanded, read from the vocabulary record `notation.sh expand` saves beside it). Links to a screen that is missing are one\n`unknown_screen` per screen, with how many links name it; a page `site.json` lists whose file is not written yet is\none `page_not_written` warning per file instead (its links are checked once it is written). Formulas are\nparsed by the SDK\'s own parser there, so formula syntax errors and unknown names in formulas are reported only by\nthe render command.'),
      DocSection('render-a-loop-that-converges', 'A loop that converges', 'Render after each section, read the diagnostics, then look at the PNGs next to the target: a diagnostic\ncannot tell you that a page is ugly. Fix by the JSON pointer each line gives. Capture each state with its own\n`--label` so the files do not overwrite each other.'),
      DocSection('render-capturing-states', 'Capturing states', 'The annual price: `--tap billingSwitch --label annual`. An open menu at phone width: `--sizes 390x844 --tap\nmenuButton --label menu`. An error state: `--type seats=0 --unfocus --label error`. A value set directly:\n`--set annual=true`. A detail page with its parameter: `--navigate speaker?id=ada --full-page`. A reordered list or\na slider: `--drag handle#0=0,120`, `--drag volume=80,0`. A countdown before the event: `--now\n2026-11-13T09:00:00Z`. A pending row 120 ms after Send: `--tap send --frames 120`. Many states at once: `tool/codelessly\nstates <states.json>` renders a manifest\'s states on one warm renderer (it starts the render server for the run when\nnone is up and stops it after; each state still starts from a fresh app; its first line and each state\'s line say\nwarm or cold; `--cold` starts Flutter for each state).'),
      DocSection('render-what-a-run-keeps', 'What a run keeps', 'Storage, variables and the clipboard live in memory for one run: steps and `--navigate` see what earlier steps\nwrote, and each size starts afresh, as does each run (nothing persists between runs, so a "restored on reload"\nstate is captured by writing it first: `--tap save --navigate home`). `downloadFile` saves its file under\n`<out>/downloads/<capture>/` and `copyToClipboard` copies in memory; both are listed in the output and in the\ndiagnostics file (`downloads`, `clipboard`). `openLink` opens nothing. `pickFile` picks the files `--pick-file\n<path>` names (repeatable; without it nothing is picked and the chain ends there), and `share`, with no share\npanel, copies its link.'),
      DocSection('render-comparing-with-a-reference', 'Comparing with a reference', '`--compare <dir>` picks, for each capture, the PNG of the same size whose name is the screen and the state exactly\n(`section--saved--390x844.png` for `--label saved`, never `section--saved-empty`); with no `--label`, `default` or\nno state. When the reference names a page otherwise, map it: `--compare-map home=index`.'),
    ],
  ),
  DocPage(
    id: 'values',
    title: 'Value types, models and enums',
    summary: '',
    when: 'Looking up how one value is written: a value type (a color, an alignment, insets), a model no feature page shows\n(its fields) or an enum (its names). Link to one with `values.md#type-<Name>` or `values.md#enum-<Name>`. Models\nthat belong to a feature are on that feature\'s page (TextStyle on the theme page, InputDecoration on the forms\npage...); the [A–Z](index.md#index-a-z) finds any of them.',
    example: 'Value types are written in a compact form of their own; models are objects; enums are names:\n\n```json\n{"color": "#FF2563EB", "padding": [16, 8, 16, 8], "alignment": [0, -1], "fit": "cover"}\n```',
    pitfalls: '- Padding and margin are a number or four numbers; a list of two is not read.\n- An enum value is case sensitive.',
    words: 17188,
    items: [],
    sections: [
      DocSection('values-value-types', 'Value types', ''),
      DocSection('values-models', 'Models', 'Objects with declared fields. Keys not listed are not read.'),
      DocSection('values-enums', 'Enums', 'Written as the value\'s name, a JSON string (`"center"`).'),
      DocSection('values-colors-and-alignments', 'Colors and alignments', 'A color is `"#AARRGGBB"`, `"#RRGGBB"` or a theme color\'s name. An alignment is `[x, y]` from -1 to 1 or a name\n(`"topCenter"`, `"centerRight"`).'),
    ],
  ),
];