@wildwinter/app-shell 0.57.0 → 0.58.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +195 -0
- package/dist/chunk-4JQWNC6Z.js +319 -0
- package/dist/chunk-4JQWNC6Z.js.map +1 -0
- package/dist/chunk-ICYPXUNA.js +8 -0
- package/dist/chunk-ICYPXUNA.js.map +1 -0
- package/dist/{chunk-XJM733E6.js → chunk-OO6O4LEL.js} +6 -2
- package/dist/chunk-OO6O4LEL.js.map +1 -0
- package/dist/{chunk-CPNTROWD.js → chunk-OZQ2BYXH.js} +13 -4
- package/dist/chunk-OZQ2BYXH.js.map +1 -0
- package/dist/{chunk-5BKGDTYD.js → chunk-RMQNBWLZ.js} +3 -3
- package/dist/{chunk-5BKGDTYD.js.map → chunk-RMQNBWLZ.js.map} +1 -1
- package/dist/index.cjs +334 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/property-list.cjs.map +1 -1
- package/dist/property-list.js +2 -2
- package/dist/tool-window.cjs +11 -2
- package/dist/tool-window.cjs.map +1 -1
- package/dist/tool-window.d.cts +10 -4
- package/dist/tool-window.d.ts +10 -4
- package/dist/tool-window.js +1 -1
- package/dist/updater.cjs.map +1 -1
- package/dist/updater.js +1 -1
- package/dist/value-control.cjs +4 -0
- package/dist/value-control.cjs.map +1 -1
- package/dist/value-control.d.cts +4 -4
- package/dist/value-control.d.ts +4 -4
- package/dist/value-control.js +1 -1
- package/dist/value-rows.cjs +8 -1
- package/dist/value-rows.cjs.map +1 -1
- package/dist/value-rows.js +5 -2
- package/dist/value-rows.js.map +1 -1
- package/dist/view-client.cjs +172 -0
- package/dist/view-client.cjs.map +1 -0
- package/dist/view-client.d.cts +46 -0
- package/dist/view-client.d.ts +46 -0
- package/dist/view-client.js +165 -0
- package/dist/view-client.js.map +1 -0
- package/dist/view-host-web.cjs +327 -0
- package/dist/view-host-web.cjs.map +1 -0
- package/dist/view-host-web.d.cts +61 -0
- package/dist/view-host-web.d.ts +61 -0
- package/dist/view-host-web.js +4 -0
- package/dist/view-host-web.js.map +1 -0
- package/dist/view-host.cjs +532 -0
- package/dist/view-host.cjs.map +1 -0
- package/dist/view-host.d.cts +178 -0
- package/dist/view-host.d.ts +178 -0
- package/dist/view-host.js +426 -0
- package/dist/view-host.js.map +1 -0
- package/dist/view-preload.cjs +16 -0
- package/dist/view-preload.cjs.map +1 -0
- package/dist/view-preload.js +8 -0
- package/dist/view-preload.js.map +1 -0
- package/dist/view-protocol.cjs +12 -0
- package/dist/view-protocol.cjs.map +1 -0
- package/dist/view-protocol.d.cts +257 -0
- package/dist/view-protocol.d.ts +257 -0
- package/dist/view-protocol.js +3 -0
- package/dist/view-protocol.js.map +1 -0
- package/package.json +25 -4
- package/dist/chunk-CPNTROWD.js.map +0 -1
- package/dist/chunk-XJM733E6.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/tooltip.ts","../src/icons.ts","../src/dom.ts","../src/settings.ts","../src/property-names.ts","../src/property-name-field.ts","../src/value-control.ts","../src/property-list.ts"],"names":["el","tip"],"mappings":";;;AA6BA,SAAS,SAAA,CAAU,MAAmB,IAAA,EAAoB;AACxD,EAAA,IAAA,CAAK,WAAA,GAAc,EAAA;AACnB,EAAA,MAAM,EAAA,GAAK,2BAAA;AACX,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI,CAAA;AACJ,EAAA,OAAA,CAAQ,CAAA,GAAI,EAAA,CAAG,IAAA,CAAK,IAAI,OAAO,IAAA,EAAM;AACnC,IAAA,IAAI,CAAA,CAAE,KAAA,GAAQ,IAAA,EAAM,IAAA,CAAK,MAAA,CAAO,KAAK,KAAA,CAAM,IAAA,EAAM,CAAA,CAAE,KAAK,CAAC,CAAA;AACzD,IAAA,MAAM,MAAA,GAAS,QAAA,CAA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AM,IAAA,CAAK,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,OAAA,KAAa,EAAE,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,KAAA,CAAM,CAAC,IAAI,CAAC,CAAA,IAAK,QAAA,EAAU,GAAI,IAAA,CAAK,KAAA,GAAQ,EAAC,GAAI,EAAE,OAAA,EAAS,EAAA,EAAG,EAAqB,CAAA;AAClJ,IAAA,MAAA,EAAO;AAAG,IAAA,OAAA,EAAQ;AAAG,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EACvC,CAAC,CAAA;AACD,EAAA,IAAA,CAAK,MAAA,CAAO,MAAM,GAAG,CAAA;AAErB,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,MAAM,KAAA,CAAM,cAAA,EAAe;AAAA,IAC3C,gBAAA,EAAkB,MAAO,SAAA,GAAY,IAAA,GAAO,yBAAyB,IAAI,CAAA;AAAA;AAAA,IAEzE,YAAA,EAAc,MAAM,KAAA,CAAM,cAAA,OAAqB,SAAA,GAAY,IAAA,GAAO,yBAAyB,IAAI,CAAA,CAAA;AAAA,IAC/F;AAAA,GACF;AACF","file":"property-list.cjs","sourcesContent":["// ---------------------------------------------------------------------------\n// A single themed tooltip the family controls, replacing native `title`\n// rollovers: those are unstyled OS chrome and appear on the platform's slow\n// (~1s) delay, which is exactly the seam design-language section 4 (\"coherent\n// to the edges\") says not to leave showing.\n//\n// ONE floating bubble, document-DELEGATED: any element carrying a `data-tip`\n// attribute gets it, so a caller just sets `data-tip=\"...\"` anywhere and wires\n// nothing. The bubble anchors above the element (flipping below near the top\n// edge), uses our own snappy delay and the shared panel-enter motion.\n// `initTooltips()` is idempotent, so it is safe to call from more than one\n// place in an app that has several entry points.\n//\n// Lifted from Patterpad's patterpad-surface/web/tooltip.ts, which proved it,\n// with the one app-specific rule (suppressed in Writing View) generalised into\n// the `suppressed` option so the shell knows nothing about either app's modes.\n// ---------------------------------------------------------------------------\n\n// Bold markers: a producer wraps a span in these PRIVATE control chars (U+0002 STX / U+0003 ETX,\n// never present in user text) and the renderer turns it into a <strong>. Lets a data-tip bold part\n// of itself (a name, a \"VO:\" prefix) without any HTML, and each segment is still set via\n// textContent, so there is no injection risk from user content.\nconst B_OPEN = \"\\u0002\";\nconst B_CLOSE = \"\\u0003\";\n\n/** Wrap `s` so it renders bold inside a tooltip (see the marker note above). */\nexport function tipBold(s: string): string { return `${B_OPEN}${s}${B_CLOSE}`; }\n\n/** Render `text` into `host`, turning `\\u0002…\\u0003`-marked spans into <strong>; all set as text (safe). */\nfunction renderTip(host: HTMLElement, text: string): void {\n host.textContent = \"\";\n const re = /\\u0002([^\\u0003]*)\\u0003/g;\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = re.exec(text)) !== null) {\n if (m.index > last) host.append(text.slice(last, m.index));\n const strong = document.createElement(\"strong\");\n strong.textContent = m[1] ?? \"\";\n host.append(strong);\n last = m.index + m[0].length;\n }\n if (last < text.length) host.append(text.slice(last));\n}\n\nexport interface TooltipOptions {\n /** Called before every show: return true to keep the bubble down. For a mode\n * that wants no chrome at all (Patterpad's Writing View). */\n suppressed?: () => boolean;\n}\n\nlet inited = false;\nlet checked = false; // the one-shot no-host warning below has been scheduled\nlet suppressed: (() => boolean) | undefined;\nconst SHOW_DELAY = 350; // ms - snappier than the OS title delay, slow enough not to flicker on pass-through\nconst EDGE = 6; // viewport inset so the bubble never touches the window edge\nconst GAP = 7; // px between the anchor and the bubble\n\nlet tip: HTMLDivElement | null = null;\nlet timer = 0;\nlet active: HTMLElement | null = null;\n/** The subject of a rect-anchored tip (see `tipAt`), when there is one. */\nlet activeKey: string | null = null;\n\nfunction ensureEl(): HTMLDivElement {\n if (tip) return tip;\n const el = document.createElement(\"div\");\n el.className = \"tooltip\";\n el.setAttribute(\"role\", \"tooltip\");\n el.hidden = true;\n document.body.appendChild(el);\n tip = el;\n return el;\n}\n\n/** A rectangle in VIEWPORT coordinates, for anchoring a tip to something that is\n * not a DOM element: a shape on a canvas, a run of text inside one. */\nexport interface TipRect { left: number; top: number; width: number; height: number }\n\nconst rectOf = (anchor: HTMLElement | TipRect): TipRect =>\n (anchor instanceof HTMLElement ? anchor.getBoundingClientRect() : anchor);\n\n/** Anchor the (already-visible, so measurable) bubble above the anchor, flipping below near the top. */\nfunction place(anchor: HTMLElement | TipRect): void {\n const t = ensureEl();\n const r = rectOf(anchor);\n const tr = t.getBoundingClientRect();\n let top = r.top - tr.height - GAP;\n if (top < EDGE) top = r.top + r.height + GAP; // not enough room above -> below\n let left = r.left + r.width / 2 - tr.width / 2;\n left = Math.max(EDGE, Math.min(left, window.innerWidth - tr.width - EDGE));\n t.style.left = `${Math.round(left)}px`;\n t.style.top = `${Math.round(top)}px`;\n}\n\nfunction show(anchor: HTMLElement): void {\n const text = anchor.dataset[\"tip\"];\n if (!text) return;\n paint(anchor, text);\n}\n\n/** Fill, place and reveal the bubble. The one path: both the delegated\n * `data-tip` route and `tipAt` end up here, so a canvas tip and a button tip\n * are the same bubble with the same look and the same motion. */\nfunction paint(anchor: HTMLElement | TipRect, text: string): void {\n if (suppressed?.()) return;\n const t = ensureEl();\n // A modal <dialog> (settings, a confirm) renders in the browser TOP LAYER, above every normal-flow\n // element whatever its z-index. If the anchor is inside one, move the bubble into that dialog so it\n // shares the top layer; otherwise keep it on <body>. Re-parenting per show also moves it back out\n // once the modal closes.\n const host: HTMLElement = (anchor instanceof HTMLElement ? anchor.closest<HTMLElement>(\"dialog[open]\") : null)\n ?? document.body;\n if (t.parentElement !== host) host.appendChild(t);\n active = anchor instanceof HTMLElement ? anchor : null;\n renderTip(t, text);\n t.hidden = false;\n t.classList.remove(\"show\"); void t.offsetWidth; // restart the enter animation\n place(anchor); // measure + position now it has content + is visible\n t.classList.add(\"show\");\n}\n\nfunction hide(): void {\n if (timer) { window.clearTimeout(timer); timer = 0; }\n active = null;\n activeKey = null;\n if (tip) { tip.hidden = true; tip.classList.remove(\"show\"); }\n}\n\nfunction schedule(anchor: HTMLElement): void {\n if (anchor === active) return;\n if (timer) window.clearTimeout(timer);\n timer = window.setTimeout(() => show(anchor), SHOW_DELAY);\n}\n\n/**\n * Show a tip for something that has no DOM node of its own: a card on a canvas,\n * a zone, a pin. The caller says WHERE (a viewport rectangle) and WHAT, and\n * identifies the subject with `key`.\n *\n * The key is what makes this usable from a canvas. Re-calling with the same key\n * re-places the bubble WITHOUT restarting the delay, so a tip can follow its\n * shape while the camera moves; calling with a different key starts the wait\n * again, so sweeping the pointer across a dense board does not strobe.\n *\n * The bubble is ordinary DOM, so it holds its size whatever the canvas is\n * zoomed to. That is the point of it: the label it stands in for is the one\n * thing on a canvas that must not shrink with everything else.\n */\nexport function tipAt(key: string, rect: TipRect, text: string): void {\n if (key === activeKey) {\n // Already up for this subject: move it, do not re-animate it.\n if (tip && !tip.hidden) { renderTip(tip, text); place(rect); }\n return;\n }\n // A different subject: down first, then wait again. Leaving the old bubble up\n // during the wait would put one card's name over another card, which is worse\n // than no name at all - and it matches the delegated route, where leaving an\n // element hides the tip before the next one is scheduled.\n hide();\n activeKey = key;\n timer = window.setTimeout(() => { timer = 0; paint(rect, text); }, SHOW_DELAY);\n}\n\n/** Take any tip down: the pointer has left, or a gesture has started. */\nexport function hideTip(): void { hide(); }\n\n/**\n * Mount the renderer because something is about to speak the grammar.\n *\n * The themed tooltip is not a feature a host turns on; it is the renderer for a grammar the shell's own\n * components already speak, and `data-tip` with nothing listening draws NOTHING - not the themed\n * bubble, not the platform one. That silence cost Patterpad two releases of a pin with no tooltip, and\n * cost it again when a `title` was converted to `data-tip` in a window that had never mounted this.\n *\n * So `el` calls this whenever it sets a tip. Mounting a delegated listener is the same class of act as\n * `confirmDialog` appending to `document.body`, which this package has always done.\n */\nexport function ensureTooltipHost(): void { initTooltips(); }\n\n/**\n * One deferred check that an app writing `data-tip` ITSELF has a host, warning if not.\n *\n * `ensureTooltipHost` covers anything built through `el`. It cannot cover a `data-tip` written straight\n * into markup or set by hand, which is the case that leaves a whole window of dead tips with no shell\n * component involved - so that one gets a warning rather than silence. Scheduled once, after the\n * current task, so it sees a rendered document rather than an empty one.\n */\nexport function checkTooltipHost(): void {\n if (checked) return;\n checked = true;\n setTimeout(() => {\n if (inited || typeof document === \"undefined\") return;\n if (document.querySelector(\"[data-tip]\")) {\n console.warn(\"app-shell: something set `data-tip` but no tooltip host is mounted, so those rollovers will not draw. Call initTooltips() once per window.\");\n }\n }, 0);\n}\n\nconst tipAncestor = (n: EventTarget | null): HTMLElement | null =>\n (n instanceof Element ? n.closest<HTMLElement>(\"[data-tip]\") : null);\n\n/**\n * Wire the one delegated controller. Mounting happens once; OPTIONS do not.\n *\n * An explicit call is always authoritative about its options, even after something else has already\n * mounted the listener. That ordering is not hypothetical, and Storyletter caught it before it shipped:\n * once components self-mount (see `ensureTooltipHost`), a host's own\n * `initTooltips({ suppressed })` could land second and be dropped by an early return, silently taking\n * a rule like \"no tooltips in Writing View\" with it. Nothing would fail and nothing would show.\n *\n * Components therefore call this with NO arguments: they mount the renderer without claiming the\n * options, and the host keeps the last word on behaviour.\n */\nexport function initTooltips(opts: TooltipOptions = {}): void {\n if (opts.suppressed !== undefined) suppressed = opts.suppressed; // an explicit call always wins\n if (inited) return;\n inited = true;\n\n document.addEventListener(\"pointerover\", (e) => {\n const el = tipAncestor(e.target);\n if (el) schedule(el);\n });\n document.addEventListener(\"pointerout\", (e) => {\n const el = tipAncestor(e.target);\n if (!el) return;\n const to = (e as PointerEvent).relatedTarget;\n if (to instanceof Node && el.contains(to)) return; // still inside the same anchor\n hide();\n });\n // Keyboard parity: reveal on focus, dismiss on blur.\n document.addEventListener(\"focusin\", (e) => { const el = tipAncestor(e.target); if (el) schedule(el); });\n document.addEventListener(\"focusout\", () => hide());\n // It's ANCHORED (not cursor-following), so anything that moves the layout or context dismisses it.\n document.addEventListener(\"pointerdown\", () => hide(), true);\n document.addEventListener(\"scroll\", () => { if (active) hide(); }, true);\n document.addEventListener(\"keydown\", (e) => { if (e.key === \"Escape\") hide(); });\n window.addEventListener(\"blur\", () => hide());\n}\n","// ---------------------------------------------------------------------------\n// The family's icon vocabulary.\n//\n// An icon is a WORD. Two apps in one suite spelling \"close\" differently is the\n// same fault as calling one thing a scene here and a chapter there, and it is\n// harder to notice because nobody reads glyphs, they just feel wrong. This\n// module exists so that no app ever types a codepoint again: it asks for\n// `iconNode(\"close\")` and gets whatever the family has agreed that means.\n//\n// The evidence that it was needed, gathered 2026-08-09 across both apps:\n// Patterpad spelled close as a cross twelve times, Storyletter used the same\n// cross once and a multiplication sign twice, in one window, and a comment\n// bubble had just been invented from scratch with nothing to check it against.\n//\n// DRAWN, not typed (design-language.md section 4, \"Icons are drawn, and so are\n// separators\", 2026-09-16). The first cut of this table was Unicode glyphs,\n// which render from whatever symbol font the OS has, so weight, baseline and\n// optical size drifted per character and per platform. The vocabulary is now\n// one drawn set: Lucide, vendored below as inline SVG strings on one 24-unit\n// grid at one stroke weight. The words did not change; what they draw did.\n//\n// Lucide 1.46.0 (lucide-static), ISC licence.\n// https://lucide.dev / https://cdn.jsdelivr.net/npm/lucide-static@1.46.0/icons/<name>.svg\n// Fetched 2026-09-16. The chosen decision record is\n// patterkit/design/ui-review-2026-09/07c-track-c-icon-sets-notes.md.\n//\n// STROKE. The family draws icons at 14px inside its small square buttons and\n// wants a 1.5px rendered stroke against Inter at that size (Inter Regular's\n// stems are about 1.3px there). Lucide's native stroke is 2 on a 24 grid,\n// which is 2 x 14/24 = 1.17px at 14px, a shade light. So the root of every\n// stroke icon carries stroke-width=\"2.571\": 2.571 x 14/24 = 1.5. A caller\n// drawing at another size gets the proportional weight (12px: 1.29px; 16px:\n// 1.71px), which is what one drawn set means. Filled shapes (the discs) carry\n// fill=\"currentColor\" and no stroke at all.\n//\n// Every icon is `currentColor`, so it takes the colour of the button it sits\n// in, and none of the strings carries width/height: the size is the caller's\n// (`iconNode(name, size)`), so an icon can never be the wrong size somewhere\n// because a CSS rule failed to reach it.\n//\n// Adding one: it needs a MEANING, not a picture. \"A downward chevron\" is not an\n// entry; \"expand this\" is. If two callers want the same picture for two\n// meanings, that is two entries, and one of them will be wrong later.\n// ---------------------------------------------------------------------------\n//\n// Lucide licence (the icons vendored in this file):\n//\n// ISC License\n// Copyright (c) 2026 Lucide Icons and Contributors\n//\n// Permission to use, copy, modify, and/or distribute this software for any\n// purpose with or without fee is hereby granted, provided that the above\n// copyright notice and this permission notice appear in all copies.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n//\n// Portions of Lucide (among those used here: arrow-down, arrow-left,\n// arrow-right, arrow-up, check, chevron-down, chevron-left, chevron-right,\n// circle, lock, plus, search, x) derive from Feather, MIT,\n// Copyright (c) 2013-present Cole Bemis. See LICENSES.md.\n// ---------------------------------------------------------------------------\n\n/**\n * The typed glyphs the vocabulary used to draw.\n *\n * @deprecated Since the move to drawn icons (design-language.md, \"Icons are\n * drawn\"). Kept byte-for-byte so a consumer still doing\n * `textContent = icon.close` keeps working while each app moves; a new call\n * site uses `iconNode(name)` (a node to append) or `iconHtml(name)` (for an\n * innerHTML build). The names are the same in all three. Removed once both\n * apps have moved.\n */\nexport const icon = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. Patterpad's, twelve times over. */\n close: \"✕\",\n /** The overflow menu on a document or a row: \"more about this\". */\n more: \"⋯\",\n /** Collapsed disclosure, pointing at what would open. */\n collapsed: \"▸\",\n /** Expanded disclosure. */\n expanded: \"▾\",\n /** A dropdown's affordance, where it is not a real <select>. */\n dropdown: \"▾\",\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. */\n back: \"‹\",\n /** Forward / next. */\n forward: \"›\",\n /** Up one, in a list. */\n up: \"↑\",\n /** Down one. */\n down: \"↓\",\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. */\n tick: \"✓\",\n /** Somebody else holds this: the version-control lock. */\n locked: \"⊘\",\n /** Read-only on disk with no other holder: the resting state of everything\n * in a lock-based working copy that nobody has checked out yet. */\n readOnly: \"○\",\n /** YOU hold this one: checked out / opened by the current user, still yours to\n * edit. Shares its glyph with `note`, which the table permits: an entry is a\n * MEANING, and two meanings may draw the same shape. */\n checkedOut: \"✎\",\n /** Tracked, with local changes not yet committed. */\n modified: \"●\",\n /** Not in version control yet: new since the last commit. */\n untracked: \"+\",\n /** Something needs attention but is not fatal. */\n warning: \"‼\",\n /** A live thing: the running position, an active marker. */\n dot: \"●\",\n /** Play, in the sense of \"run this\". */\n play: \"▶\",\n /** Start the thing again from the top: a play session, a sweep. Named for the\n * act, not the arrow, which is the table's rule. */\n restart: \"⟲\",\n /** The three ways a collection can be shown. Named by what you get rather than\n * by the glyph, so a second app can pick the same three without copying\n * somebody's taste in symbols. */\n viewCards: \"▦\",\n viewTable: \"☰\",\n viewNode: \"◈\",\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. */\n grip: \"⠿\",\n /** Add one of whatever this list holds. */\n add: \"+\",\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: the pencil. Both apps had chosen it independently,\n * which is the happiest way for a vocabulary entry to arrive. */\n note: \"✎\",\n /** A comment thread. Speech, not a pencil: documentation states the reason,\n * comments are the conversation, and the two must never look alike. */\n comment: \"❝\",\n} as const;\n\n/**\n * Every word in the vocabulary. The 26 the glyph table had, plus the seven the\n * 2026-09 review found the apps drawing by hand with nothing to check against,\n * and the two the 2026-10 Patterpad review found the same way (`copy`,\n * `speaker`).\n */\nexport type IconName =\n | keyof typeof icon\n /** History back, the topbar's quiet arrow pair (nav-history.ts). An ARROW,\n * not a chevron: a chevron says structure, an arrow says time (the author's\n * ruling, 2026-08-28). Added beside `arrowRight` so the pair share a set. */\n | \"arrowLeft\"\n /** History forward; also the one honest \"go there\" arrow where a link used\n * to carry a typed one. */\n | \"arrowRight\"\n /** Connect to a server, a live link, a running game. */\n | \"connect\"\n /** Search. */\n | \"search\"\n /** Keep this window on top (tool-window-web.ts). */\n | \"pin\"\n /** Settings. */\n | \"settings\"\n /** Record. The icon is the DISC; painting it in the danger colour while\n * recording is the caller's job, through the button's own colour. */\n | \"record\"\n /** Copy this to the clipboard. The confirmation is `tick`, shown by the\n * caller while `copyWithFeedback` holds `.copied` on the button. */\n | \"copy\"\n /** Sound: play with audio, a table read. The act of hearing, not a volume\n * control. */\n | \"speaker\";\n\n// The two roots every drawing shares. Kept as constants so the table below is\n// the inner elements only, which is what a reader compares against lucide.dev.\nconst STROKE = '<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.571\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">';\nconst FILL = '<svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">';\nconst stroked = (inner: string): string => `${STROKE}${inner}</svg>`;\nconst filled = (inner: string): string => `${FILL}${inner}</svg>`;\n\n// The three discs are the one drawing in the table that is not Lucide's own\n// element as shipped: Lucide's `circle` is an r=10 outline that fills its box,\n// which at badge size beside a row title is a blot, so the disc is drawn at a\n// smaller radius with the fill forced (the same amount of hand-drawing as the\n// legacy noteFilled below, and the decision record's stated cost). `modified`\n// and `dot` share it, as their glyphs did; `record` is larger because a record\n// button is meant to fill more of its box.\nconst DISC = filled('<circle cx=\"12\" cy=\"12\" r=\"6\"/>');\nconst DISC_LARGE = filled('<circle cx=\"12\" cy=\"12\" r=\"9\"/>');\n\n/**\n * The drawings, by word. Each is a complete `<svg viewBox=\"0 0 24 24\" …>`\n * string with no width/height (see `iconNode` / `iconHtml`, which size it).\n * The Lucide name each derives from is on the entry, so a reviewer can put\n * the two side by side.\n */\nconst DRAWN: Record<IconName, string> = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. (x) */\n close: stroked('<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>'),\n /** The overflow menu on a document or a row: \"more about this\". (ellipsis) */\n more: stroked('<circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"19\" cy=\"12\" r=\"1\"/><circle cx=\"5\" cy=\"12\" r=\"1\"/>'),\n /** Collapsed disclosure, pointing at what would open. (chevron-right) */\n collapsed: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Expanded disclosure. (chevron-down) */\n expanded: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n /** A dropdown's affordance, where it is not a real <select>. (chevron-down) */\n dropdown: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. (chevron-left) */\n back: stroked('<path d=\"m15 18-6-6 6-6\"/>'),\n /** Forward / next. (chevron-right) */\n forward: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Up one, in a list. (arrow-up) */\n up: stroked('<path d=\"m5 12 7-7 7 7\"/><path d=\"M12 19V5\"/>'),\n /** Down one. (arrow-down) */\n down: stroked('<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>'),\n /** History back. (arrow-left) */\n arrowLeft: stroked('<path d=\"m12 19-7-7 7-7\"/><path d=\"M19 12H5\"/>'),\n /** History forward; \"go there\". (arrow-right) */\n arrowRight: stroked('<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>'),\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. (check) */\n tick: stroked('<path d=\"M20 6 9 17l-5-5\"/>'),\n /** Somebody else holds this: the version-control lock. (lock) */\n locked: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/>'),\n /** Read-only on disk with no other holder. (lock-open) An open lock rather\n * than a struck-out eye: this state is not a prohibition. Nobody holds the\n * file, saving checks it out, and it is the resting state of everything the\n * author has not touched yet under a lock-based VCS. eye-off would say \"you\n * cannot\", which is false here; the open lock says \"not held\", beside\n * `locked`, which is the shut one, so the two read as a pair. */\n readOnly: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 9.9-1\"/>'),\n /** YOU hold this one: checked out, still yours to edit. (pencil) */\n checkedOut: stroked('<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\"/><path d=\"m15 5 4 4\"/>'),\n /** Tracked, with local changes not yet committed. (a disc; see DISC) */\n modified: DISC,\n /** Not in version control yet: new since the last commit. (plus) */\n untracked: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Something needs attention but is not fatal. (triangle-alert) */\n warning: stroked('<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/>'),\n /** A live thing: the running position, an active marker. (a disc) */\n dot: DISC,\n /** Play, in the sense of \"run this\". (play) */\n play: stroked('<path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/>'),\n /** Start the thing again from the top: a play session, a sweep. (rotate-ccw) */\n restart: stroked('<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/>'),\n /** The three ways a collection can be shown, named by what you get. */\n /** Cards. (layout-grid) */\n viewCards: stroked('<rect width=\"7\" height=\"7\" x=\"3\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"14\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"3\" y=\"14\" rx=\"1\"/>'),\n /** A table. (rows-3: a ruled box, which is a table. `list` is bullets, and\n * the view is not a list.) */\n viewTable: stroked('<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M21 9H3\"/><path d=\"M21 15H3\"/>'),\n /** A node graph. (waypoints: four nodes on edges reads as a graph.\n * `git-fork` reads as version control, which this family also draws, and\n * a picture that means two things is the fault this table exists to\n * prevent.) */\n viewNode: stroked('<path d=\"m10.586 5.414-5.172 5.172\"/><path d=\"m18.586 13.414-5.172 5.172\"/><path d=\"M6 12h12\"/><circle cx=\"12\" cy=\"20\" r=\"2\"/><circle cx=\"12\" cy=\"4\" r=\"2\"/><circle cx=\"20\" cy=\"12\" r=\"2\"/><circle cx=\"4\" cy=\"12\" r=\"2\"/>'),\n /** Record: the disc, in whatever colour the button is. (a disc; see DISC_LARGE) */\n record: DISC_LARGE,\n /** Sound: play with audio. (volume-2: the cone and two waves. Patterpad's\n * hand-drawn one had a single wave, which at 14px reads as quiet rather\n * than as sound.) */\n speaker: stroked('<path d=\"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\"/><path d=\"M16 9a5 5 0 0 1 0 6\"/><path d=\"M19.364 18.364a9 9 0 0 0 0-12.728\"/>'),\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. (grip-vertical) */\n grip: stroked('<circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"5\" r=\"1\"/><circle cx=\"9\" cy=\"19\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"5\" r=\"1\"/><circle cx=\"15\" cy=\"19\" r=\"1\"/>'),\n /** Add one of whatever this list holds. (plus) */\n add: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Copy this to the clipboard. (copy: the front sheet whole, the back\n * sheet showing round two of its sides) */\n copy: stroked('<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/>'),\n /** Connect: to a server, a live link, a running game. (plug) */\n connect: stroked('<path d=\"M12 22v-5\"/><path d=\"M15 8V2\"/><path d=\"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z\"/><path d=\"M9 8V2\"/>'),\n /** Search. (search) */\n search: stroked('<path d=\"m21 21-4.34-4.34\"/><circle cx=\"11\" cy=\"11\" r=\"8\"/>'),\n /** Keep this window on top. (pin) */\n pin: stroked('<path d=\"M12 17v5\"/><path d=\"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\"/>'),\n /** Settings. (settings) */\n settings: stroked('<path d=\"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/>'),\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: a document with lines on it. (file-text) The glyph\n * table drew a pencil and shared it with `checkedOut`; the drawn set gives\n * the two meanings two shapes, and notes get the document, which is what\n * the shell's own noteFilled/noteOutline pair had always drawn. */\n note: stroked('<path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\"/><path d=\"M14 2v5a1 1 0 0 0 1 1h5\"/><path d=\"M10 9H8\"/><path d=\"M16 13H8\"/><path d=\"M16 17H8\"/>'),\n /** A comment thread. Speech, not a document: documentation states the\n * reason, comments are the conversation, and the two must never look\n * alike. (message-square) */\n comment: stroked('<path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\"/>'),\n};\n\n/**\n * The drawings as strings, by word, for a caller that builds markup itself.\n * Prefer `iconHtml(name, size)`, which sizes it; these carry no width/height.\n *\n * Two legacy entries ride along unchanged: `noteFilled` and `noteOutline`, the\n * has-notes / no-notes pair Patterpad drew on a 16-unit grid before the set\n * existed. They are sized in the markup (13px) and on their own grid, so they\n * are NOT part of the vocabulary above and `iconNode` does not know them; no\n * app uses them today. They stay until a 24-grid pair replaces them, because\n * their two-state meaning (there are notes / there are none) has no Lucide\n * shape, and re-weighting the 16-grid drawing to the family stroke merges its\n * text lines.\n */\nexport const iconSvg = {\n ...DRAWN,\n /** A document with lines: notes exist on this thing. (legacy, 16 grid) */\n noteFilled: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"currentColor\" fill-rule=\"evenodd\" aria-hidden=\"true\"><path d=\"M3.4 1.4h5.3L12.6 5.3v8.1a1.2 1.2 0 0 1-1.2 1.2H3.4a1.2 1.2 0 0 1-1.2-1.2V2.6A1.2 1.2 0 0 1 3.4 1.4ZM4.9 6.8h6.2v1.1H4.9Zm0 2.1h6.2v1.1H4.9Zm0 2.1h3.7v1.1H4.9Z\"/></svg>',\n /** The same document, empty: nothing written here yet. (legacy, 16 grid) */\n noteOutline: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.1\" stroke-linejoin=\"round\" stroke-linecap=\"round\" aria-hidden=\"true\"><path d=\"M3.4 2h4.9l3.9 3.9v7.5a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z\"/><path d=\"M8.3 2.2v3.8h3.8\"/><path d=\"M4.9 8h6.2M4.9 10h6.2M4.9 12h3.7\" stroke-width=\"0.95\"/></svg>',\n} as const;\n\nexport type IconSvgName = keyof typeof iconSvg;\n\n/** Every word, in table order, for a test or a gallery to walk. */\nexport const ICON_NAMES = Object.keys(DRAWN) as IconName[];\n\n/** The default size: 14px, the family's icon inside its small square button. */\nexport const ICON_SIZE = 14;\n\n/**\n * The drawing as markup with its size set, for a caller building innerHTML.\n * `data-icon` carries the word, so a stylesheet or a test can find it.\n */\nexport function iconHtml(name: IconName, size = ICON_SIZE): string {\n return DRAWN[name].replace(\"<svg \", `<svg width=\"${size}\" height=\"${size}\" data-icon=\"${name}\" `);\n}\n\n// One parsed template per word, filled on first use; every call clones it, so\n// the string is parsed once per window and each caller gets its own node.\nconst templates = new Map<IconName, SVGSVGElement>();\n\n/**\n * The drawing as a fresh SVG node, sized. Append it where the glyph used to be\n * set as text; it is `aria-hidden`, so the button's accessible name stays the\n * button's (`aria-label` / `data-tip`), as it always had to.\n */\nexport function iconNode(name: IconName, size = ICON_SIZE): SVGSVGElement {\n let tpl = templates.get(name);\n if (!tpl) {\n const holder = document.createElement(\"template\");\n holder.innerHTML = DRAWN[name];\n tpl = holder.content.firstElementChild as SVGSVGElement;\n tpl.setAttribute(\"data-icon\", name);\n templates.set(name, tpl);\n }\n const node = tpl.cloneNode(true) as SVGSVGElement;\n node.setAttribute(\"width\", String(size));\n node.setAttribute(\"height\", String(size));\n return node;\n}\n\n// The glyph table, reversed, so a legacy call site that still hands the shell\n// a typed character (\"✕\", \"↑\") draws the word it stood for. Where two words\n// shared a glyph the first in table order wins, which is fine: the picture was\n// the same either way. Goes when `icon` does.\nconst BY_GLYPH = new Map<string, IconName>();\nfor (const [name, glyph] of Object.entries(icon) as [IconName, string][]) {\n if (!BY_GLYPH.has(glyph)) BY_GLYPH.set(glyph, name);\n}\n\n/** The word a deprecated glyph stood for, or undefined for any other string. */\nexport function iconNameOfGlyph(glyph: string): IconName | undefined {\n return BY_GLYPH.get(glyph);\n}\n\n/** Whether a string is a word in the vocabulary. */\nexport function isIconName(s: string): s is IconName {\n return Object.prototype.hasOwnProperty.call(DRAWN, s);\n}\n","// ---------------------------------------------------------------------------\n// `el`: the tiny tag-typed element factory both apps build their imperative,\n// idempotent views with.\n//\n// A SUPERSET of the two apps' prior signatures, so neither rewrites call sites:\n// - Patterpad: el(tag, cls?, text?) (positional)\n// - Storylet Studio: el(tag, { className, text, ... }, ...kids) (options bag)\n// A string second argument is the className; an object is the props bag; string\n// children become text nodes. So `el(\"div\", \"c\", \"t\")` and\n// `el(\"div\", { className: \"c\" }, \"t\")` produce identical DOM.\n// ---------------------------------------------------------------------------\n\nimport { ensureTooltipHost, checkTooltipHost } from \"./tooltip.js\";\nimport { iconNode, iconNameOfGlyph, isIconName, type IconName } from \"./icons.js\";\n\nexport type Child = Node | string | null | undefined;\n\nexport interface ElProps {\n className?: string;\n text?: string;\n /** A NATIVE rollover. Prefer `tip`: `title` is OS chrome on the platform's own\n * slow delay, which is the seam the themed tooltip exists to close. */\n title?: string;\n /** A themed rollover (`data-tip`, picked up by the delegated controller that\n * `initTooltips()` wires). Also the accessible name, since the elements that\n * want one are usually icon buttons with no text of their own. */\n tip?: string;\n onClick?: (event: MouseEvent) => void;\n}\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n classNameOrProps?: string | ElProps,\n ...children: Child[]\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n const props: ElProps = typeof classNameOrProps === \"string\"\n ? { className: classNameOrProps }\n : classNameOrProps ?? {};\n if (props.className) node.className = props.className;\n if (props.text !== undefined && props.text !== null) node.textContent = props.text;\n if (props.title !== undefined) node.title = props.title;\n if (props.tip !== undefined) {\n node.dataset[\"tip\"] = props.tip;\n node.setAttribute(\"aria-label\", props.tip);\n // Setting a tip mounts the renderer. Without this, `data-tip` draws nothing at all in a window whose\n // host never called `initTooltips()`, which is a silent failure rather than a degraded one. No\n // options passed: the host stays authoritative about behaviour (see tooltip.ts).\n ensureTooltipHost();\n }\n if (props.onClick) node.addEventListener(\"click\", props.onClick as EventListener);\n for (const child of children) {\n if (child === null || child === undefined) continue;\n node.append(child);\n }\n checkTooltipHost(); // one-shot: warns if the APP wrote data-tip and nothing mounted a host\n return node;\n}\n\n/** A small square icon button (the move/delete controls list editors share).\n * Its rollover is the THEMED one (`data-tip`), so an app that has called\n * `initTooltips()` gets our bubble rather than the platform's.\n *\n * `name` is a word from the vocabulary (\"up\", \"close\"), drawn at 14px. A\n * typed glyph from the deprecated `icon` table (\"↑\", \"✕\") is accepted for\n * now and drawn as the word it stood for, so an app that has not moved its\n * call sites yet still gets the drawn set; any other string is set as text,\n * which is the old behaviour and on its way out. */\nexport function iconBtn(name: IconName | (string & {}), title: string, onClick: () => void, disabled = false, danger = false): HTMLButtonElement {\n const b = el(\"button\", `shell-icon${danger ? \" danger\" : \"\"}`);\n b.type = \"button\"; b.dataset[\"tip\"] = title; b.setAttribute(\"aria-label\", title);\n const word = isIconName(name) ? name : iconNameOfGlyph(name);\n if (word) b.append(iconNode(word)); else b.textContent = name;\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n}\n\n/** The sentence under a settings row: plain text, or nodes when it carries\n * markup (a `code` for a file name, a `b` for an option's name). */\nexport type FieldHint = string | Node | Array<string | Node>;\n\n/**\n * A captioned field, the family's settings row (the 2026-10 review, ruling C):\n * the caption on the left and the control inline beside it,\n * `<label class=\"shell-labelled\"><span class=\"shell-fieldcap\">…</span>control</label>`.\n *\n * The label is pointed at the field it captions, EXPLICITLY, and never at a button. A `<label>` with no\n * `for` forwards a click to its first labelable descendant, and buttons are labelable - so a caption\n * wrapped around a control containing buttons (`tagChips`, whose every chip carries a remove button)\n * turns every click on the row's dead space into a press of the FIRST button in it. That shipped:\n * patterkit/patter#44, where clicking a Game Data list value anywhere but its ✕ deleted the first value\n * in the list. Reported as \"clicking a value removes the wrong one\", which is not a wrong-index bug at\n * all - the click never reached the chip. The same rule makes a control GROUP safe to caption: a field\n * with its own Choose… or Import… button beside it (`.shell-inline`) captions the field, and the button\n * stays a button.\n *\n * When the control holds no labelable field (a chips editor with the add input removed, say), this is a\n * plain `<div>`: no caption behaviour is better than a caption that presses something.\n *\n * With a `hint`, the row and the sentence under it come back together in a `.shell-field`, the hint as\n * the field's description (`aria-describedby`) rather than inside the label, where it would become part\n * of the field's NAME and be read out every time it takes focus. Without one, the row is exactly what it\n * always was.\n */\nexport function labelled(label: string, control: HTMLElement, hint?: FieldHint): HTMLElement {\n const target = control.matches(\"input, select, textarea\")\n ? control\n : control.querySelector<HTMLElement>(\"input:not([type=button]):not([type=submit]), select, textarea\");\n const w = el(target ? \"label\" : \"div\", \"shell-labelled\");\n w.append(el(\"span\", \"shell-fieldcap\", label), control);\n if (target) {\n if (!target.id) target.id = uid();\n (w as HTMLLabelElement).htmlFor = target.id;\n }\n if (hint === undefined) return w;\n const note = el(\"p\", \"shell-fieldhint\");\n note.append(...(Array.isArray(hint) ? hint : [hint]));\n note.id = uid();\n if (target) {\n const by = target.getAttribute(\"aria-describedby\");\n target.setAttribute(\"aria-describedby\", by ? `${by} ${note.id}` : note.id);\n }\n return el(\"div\", \"shell-field\", w, note);\n}\n\nconst uid = (): string => `shell-f-${Math.random().toString(36).slice(2, 9)}`;\n\nexport interface LabelledToggleOptions {\n checked?: boolean;\n /** The sentence under the row: what turning it on does. */\n hint?: FieldHint;\n /** An option that only means something while the row above it is set (Patterpad's \"Embed source\n * language for debug\" under an IDs-only build): indented under that row with a rule, so it reads as\n * belonging to it rather than as a peer. */\n sub?: boolean;\n disabled?: boolean;\n /** Fired on every flip, with the new state. The input is handed back too, for a caller that reads it\n * on Save instead. */\n onChange?: (checked: boolean) => void;\n}\n\n/**\n * The settings toggle, `labelled`'s partner (ruling C): the caption on the left, the checkbox beside it\n * where any other row has its control, and the optional hint under the row. One shape in both apps, so\n * a switch in one app's settings looks like a switch in the other's. Clicking the caption flips it, as\n * the label is the checkbox's.\n *\n * Returns the outermost row (to append, hide, or indent) and the input (to read or listen to).\n */\nexport function labelledToggle(label: string, opts: LabelledToggleOptions = {}): { row: HTMLElement; input: HTMLInputElement } {\n const input = el(\"input\", \"shell-toggle-input\");\n input.type = \"checkbox\";\n input.checked = opts.checked ?? false;\n input.disabled = opts.disabled ?? false;\n const { onChange } = opts;\n if (onChange) input.addEventListener(\"change\", () => onChange(input.checked));\n const row = labelled(label, input, opts.hint);\n // On the caption-and-box line itself, whether or not a hint wraps it.\n (row.matches(\".shell-labelled\") ? row : row.querySelector(\".shell-labelled\"))?.classList.add(\"shell-toggle\");\n if (opts.sub) row.classList.add(\"shell-suboption\");\n return { row, input };\n}\n\n/** Swap item `i` with its neighbour `i + delta` IN PLACE (the up/down reorder list editors share);\n * a no-op when the target is out of range. Returns whether anything moved. */\nexport function moveItem<T>(arr: T[], i: number, delta: number): boolean {\n const j = i + delta;\n if (j < 0 || j >= arr.length) return false;\n [arr[i], arr[j]] = [arr[j]!, arr[i]!];\n return true;\n}\n\n/** The icon size inside a chip's remove / move buttons: the chip is set at\n * 0.76rem, so its controls draw smaller than a toolbar button's 14px. */\nconst CHIP_ICON = 10;\n\n/** A tag-style editor for a string-list field (an enum's allowed values / flags): removable chips + an\n * add input (Enter or \",\" commits; blank / duplicate ignored). Mutates `holder.values` in place (read\n * back on save). `onChange` fires after any add / remove so callers can refresh a dependent control. */\nexport function tagChips(holder: { values?: string[] }, onChange?: () => void): HTMLElement {\n const wrap = el(\"div\", \"shell-tags\");\n const input = el(\"input\", \"shell-tag-input\");\n // Sentence-cased like every other hint (the microcopy ruling, 2026-08-28):\n // lowercase fragments read as adrift, and a placeholder is a hint speaking.\n input.type = \"text\"; input.placeholder = \"Add value\"; input.spellcheck = false;\n const makeChip = (v: string): HTMLElement => {\n const chip = el(\"span\", \"shell-tag\", v);\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.values = (holder.values ?? []).filter((o) => o !== v); chip.remove(); onChange?.(); });\n chip.append(x);\n return chip;\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.values ?? []).includes(v)) { (holder.values ??= []).push(v); wrap.insertBefore(makeChip(v), input); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n for (const v of holder.values ?? []) wrap.append(makeChip(v));\n wrap.append(input);\n return wrap;\n}\n\n/** What `stageChips` tells its caller beyond \"something changed\". */\nexport interface StageChipsOptions {\n /**\n * A stage was renamed in place, `from` to `to`. Given, a rename calls this\n * INSTEAD of `onChange`: values are stored by stage name, so whoever knows\n * where those values live has to carry them, and doing it as one edit is\n * theirs to arrange. Absent, a rename is an ordinary change.\n */\n onRename?: (from: string, to: string) => void;\n /** The stages were reordered (after `onChange`): the one edit that changes\n * what every ordering gate means without changing any value. */\n onReorder?: () => void;\n}\n\n/**\n * An ORDERED chips editor for a string-list field whose order means something\n * (a quality's stages: `advance()` walks them, so 2 comes after 1): numbered\n * chips, each with move-earlier / move-later / remove, plus an add input\n * (Enter or \",\" commits; blank / duplicate ignored). A stage's name renames\n * in place when clicked (Enter or blur commits, Escape cancels; blank, the same\n * name or another stage's is ignored). Mutates `holder.stages` in place;\n * `onChange` fires after any add / move / remove, and after a rename unless\n * `opts.onRename` takes it.\n *\n * Patterpad's, lifted (ui-review-2026-09, finding 3); Storyletter had been\n * faking it with `tagChips` over a `values` holder, which loses the order\n * controls. Same class family as `tagChips` (`.shell-tags`), so it is styled by\n * settings.css already.\n */\nexport function stageChips(holder: { stages?: string[] }, onChange?: () => void, opts: StageChipsOptions = {}): HTMLElement {\n const wrap = el(\"div\", \"shell-tags shell-stages\");\n const input = el(\"input\", \"shell-tag-input\");\n input.type = \"text\"; input.placeholder = \"Add stage\"; input.spellcheck = false;\n const control = (name: IconName, tip: string, disabled: boolean, onClick: () => void): HTMLButtonElement => {\n const b = el(\"button\", \"shell-tag-x shell-tag-move\", iconNode(name, CHIP_ICON));\n b.type = \"button\"; b.dataset[\"tip\"] = tip; b.setAttribute(\"aria-label\", tip);\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n };\n // The name, editable in place. A span with a button's role rather than a\n // <button>, so the chip's own controls stay its only buttons.\n const nameLabel = (chip: HTMLElement, v: string, i: number): HTMLElement => {\n const label = el(\"span\", \"shell-tag-label\", `${i + 1}. ${v}`);\n label.setAttribute(\"role\", \"button\"); label.tabIndex = 0;\n label.dataset[\"tip\"] = `Rename ${v}`;\n const edit = (): void => {\n const field = el(\"input\", \"shell-tag-input shell-stage-rename\");\n field.type = \"text\"; field.value = v; field.spellcheck = false;\n field.setAttribute(\"aria-label\", `Rename ${v}`);\n let done = false;\n const finish = (keep: boolean): void => {\n if (done) return;\n done = true;\n const to = field.value.trim();\n const stages = holder.stages ?? [];\n if (keep && to !== \"\" && to !== v && !stages.includes(to)) {\n stages[stages.indexOf(v)] = to;\n rebuild();\n if (opts.onRename) opts.onRename(v, to); else onChange?.();\n } else {\n rebuild();\n }\n };\n field.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\") { e.preventDefault(); finish(true); }\n else if (e.key === \"Escape\") { e.preventDefault(); e.stopPropagation(); finish(false); }\n });\n field.addEventListener(\"blur\", () => finish(true));\n label.replaceWith(field);\n chip.classList.add(\"editing\");\n field.focus(); field.select();\n };\n // The chips usually sit inside a <label> for the add input (`labelled`),\n // whose activation would move focus there and close the rename at once.\n label.addEventListener(\"click\", (e) => { e.preventDefault(); edit(); });\n label.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); edit(); } });\n return label;\n };\n const moved = (): void => { rebuild(); onChange?.(); opts.onReorder?.(); };\n const rebuild = (): void => {\n for (const c of Array.from(wrap.children)) if (c !== input) c.remove();\n const stages = holder.stages ?? [];\n stages.forEach((v, i) => {\n const chip = el(\"span\", \"shell-tag\");\n chip.dataset[\"stage\"] = v;\n chip.append(\n nameLabel(chip, v, i),\n control(\"back\", `Move ${v} earlier`, i === 0, () => { if (moveItem(stages, i, -1)) moved(); }),\n control(\"forward\", `Move ${v} later`, i === stages.length - 1, () => { if (moveItem(stages, i, 1)) moved(); }),\n );\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.stages = (holder.stages ?? []).filter((o) => o !== v); rebuild(); onChange?.(); });\n chip.append(x);\n wrap.insertBefore(chip, input);\n });\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.stages ?? []).includes(v)) { (holder.stages ??= []).push(v); rebuild(); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n wrap.append(input);\n rebuild();\n return wrap;\n}\n\n// --- drag-to-reorder ---------------------------------------------------------\n// One drag at a time per window, shared across every wired list, so the\n// midpoint test knows what is being carried without a dataTransfer round trip.\nlet reorderDragId: string | null = null;\nconst clearDropMarks = (host: ParentNode): void =>\n host.querySelectorAll(\".drop-before, .drop-after\").forEach((e) => e.classList.remove(\"drop-before\", \"drop-after\"));\n\n/**\n * Make `el` a drag source and a drop target for HTML5 drag-to-reorder among\n * its siblings. While carried it wears `.dragging`; a hovered target wears\n * `.drop-before` or `.drop-after` by the midpoint test on `axis` (\"y\" for\n * rows, \"x\" for a wrapping grid); a drop calls `onMove(draggedId, before,\n * targetId)` and the caller reorders its model and re-renders.\n *\n * Storyletter's `wireCardDrag`, lifted (ui-review-2026-09, finding 30);\n * Patterpad's `wireSceneDrag` is the same idea fixed on \"y\". The marks are\n * classes only: the app draws them (Patterpad's `box-shadow: 0 -2px 0 0\n * var(--accent)` pair is the family's look).\n */\nexport function wireReorder(el: HTMLElement, id: string, axis: \"x\" | \"y\", onMove: (id: string, before: boolean, targetId: string) => void): void {\n el.draggable = true;\n el.dataset[\"reorderId\"] = id;\n const host = (): ParentNode => el.parentElement ?? el;\n el.addEventListener(\"dragstart\", (e) => {\n reorderDragId = id; el.classList.add(\"dragging\");\n if (e.dataTransfer) { e.dataTransfer.effectAllowed = \"move\"; e.dataTransfer.setData(\"text/plain\", id); }\n });\n el.addEventListener(\"dragend\", () => { reorderDragId = null; el.classList.remove(\"dragging\"); clearDropMarks(host()); });\n el.addEventListener(\"dragover\", (e) => {\n if (!reorderDragId || reorderDragId === id) return;\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = \"move\";\n const r = el.getBoundingClientRect();\n const before = axis === \"y\" ? e.clientY < r.top + r.height / 2 : e.clientX < r.left + r.width / 2;\n clearDropMarks(host());\n el.classList.add(before ? \"drop-before\" : \"drop-after\");\n });\n el.addEventListener(\"dragleave\", () => el.classList.remove(\"drop-before\", \"drop-after\"));\n el.addEventListener(\"drop\", (e) => {\n e.preventDefault();\n const before = el.classList.contains(\"drop-before\");\n clearDropMarks(host());\n if (reorderDragId && reorderDragId !== id) onMove(reorderDragId, before, id);\n });\n}\n\n// --- metadata and breadcrumbs ---------------------------------------------------\n// \"Icons are drawn, and so are separators\" (design-language.md section 4,\n// 2026-09-16): metadata is never joined with \"·\" and a breadcrumb is never a\n// string with \"›\" in it. Both apps had been building exactly those strings\n// (ui-review-2026-09, marker A); these two helpers make the same lines as DOM,\n// with the separator drawn by CSS (controls.css) or by the icon vocabulary.\n\n/**\n * A metadata line: `parts` as spans in a flex row, separated by a drawn\n * 3px disc (a `::before` on every part after the first, in controls.css),\n * so `metaLine([\"6 runs\", \"200 max steps\", \"seed 4\"])` is what\n * \"6 runs · 200 max steps · seed 4\" used to be, without the typed dot.\n * Empty, null and undefined parts are skipped, so a caller can pass an\n * optional segment without branching.\n */\nexport function metaLine(parts: (string | Node | null | undefined)[]): HTMLElement {\n const row = el(\"span\", \"shell-meta\");\n for (const part of parts) {\n if (part === null || part === undefined || part === \"\") continue;\n const seg = el(\"span\", \"shell-meta-part\");\n seg.append(part);\n row.append(seg);\n }\n return row;\n}\n\nexport interface Crumb {\n label: string;\n /** Makes the crumb a button. Ignored on the last crumb, which is where the\n * reader already is. */\n onClick?: (event: MouseEvent) => void;\n}\n\n/**\n * A breadcrumb trail: each crumb a span, or a button when it carries\n * `onClick` and is not the last, with `iconNode(\"forward\", 12)` drawn between\n * them. `breadcrumb([\"Box\", \"Deck\", \"Card\"])` is what \"Box › Deck › Card\"\n * used to be; the chevrons are the family's own drawing, not a symbol-font\n * character.\n */\nexport function breadcrumb(parts: (string | Crumb)[]): HTMLElement {\n const trail = el(\"nav\", \"shell-crumbs\");\n trail.setAttribute(\"aria-label\", \"Where this is\");\n parts.forEach((part, i) => {\n const crumb: Crumb = typeof part === \"string\" ? { label: part } : part;\n const last = i === parts.length - 1;\n if (i > 0) {\n const sep = iconNode(\"forward\", 12);\n sep.classList.add(\"shell-crumb-sep\");\n trail.append(sep);\n }\n if (crumb.onClick && !last) {\n const b = el(\"button\", { className: \"shell-crumb shell-crumb-link\", text: crumb.label, onClick: crumb.onClick });\n b.type = \"button\";\n trail.append(b);\n } else {\n const s = el(\"span\", \"shell-crumb\", crumb.label);\n if (last) s.setAttribute(\"aria-current\", \"location\");\n trail.append(s);\n }\n });\n return trail;\n}\n","// ---------------------------------------------------------------------------\n// The shared settings surface: a native <dialog> with a left-rail of grouped\n// tabs and one panel per section (mountSettingsDialog), plus the list-editing\n// core those sections lean on (expandableRow, focusNewRow, dupGuard). The app\n// supplies the sections; each holds its own state and reports the first invalid\n// control so the Save gate can block + jump. Framework here, content in the app.\n//\n// Lifted from Patterpad's Project Settings (settings-list.ts + the inlined\n// dialog logic in its renderer), with neutral class names. Styling ships as\n// settings.css.\n// ---------------------------------------------------------------------------\n\nimport { el } from \"./dom.js\";\n\n// --- list-editing core --------------------------------------------------------\n\n/** A compact list row: a single `.set-rowline` (inline controls) plus, when\n * `details` are given, a disclosure that reveals a `.set-details` panel below,\n * so a list scans like a table with secondary fields tucked away. `name` is\n * what the row declares (a property's name, a field's), stamped on it as\n * `data-name` so `revealRow` can land on it. */\nexport function expandableRow(opts: { line: HTMLElement[]; details?: HTMLElement[]; name?: string }): HTMLElement {\n const row = el(\"div\", \"set-row\");\n if (opts.name !== undefined) row.dataset.name = opts.name;\n const line = el(\"div\", \"set-rowline\");\n if (opts.details && opts.details.length) {\n const details = el(\"div\", \"set-details\"); details.hidden = true;\n for (const d of opts.details) details.append(d);\n // The triangle is drawn by CSS off `.open` (a text glyph stays hairline-thin).\n const toggle = el(\"button\", \"set-expand\"); toggle.type = \"button\";\n // `data-tip`, not `title`: this package ships a themed tooltip and nothing\n // else in it raises an OS rollover. A lone `title` here would be the one\n // place a host's chrome broke character, and on the platform's own delay.\n toggle.dataset.tip = \"More\"; toggle.setAttribute(\"aria-label\", \"More\");\n toggle.setAttribute(\"aria-expanded\", \"false\");\n toggle.addEventListener(\"click\", () => {\n const open = details.hidden;\n details.hidden = !open;\n toggle.setAttribute(\"aria-expanded\", String(open));\n toggle.classList.toggle(\"open\", open);\n });\n line.append(toggle);\n opts.line.forEach((c) => line.append(c));\n row.append(line, details);\n } else {\n opts.line.forEach((c) => line.append(c));\n row.append(line);\n }\n return row;\n}\n\n/**\n * Land on one row of a list by the `name` it was built with: open its details\n * (an enum's values sit behind the disclosure, and they are usually what the\n * jump was for), bring it to the middle of its scroller, and light it for a\n * moment (`.set-row.landed` in settings.css). \"Go to definition\" in both apps\n * used to open the page a property is declared on and stop there, with the\n * declaration below the fold and nothing marking it (Storyletter, 2026-09-14).\n *\n * Returns false when no row carries the name, so a host whose page fills in\n * asynchronously can ask again on a later frame; asking again is the host's,\n * since only the host knows what opens on its own time. The row is matched by\n * reading the stamp rather than by an attribute selector, so a name needs no\n * escaping.\n */\nexport function revealRow(within: ParentNode, name: string): boolean {\n const row = [...within.querySelectorAll<HTMLElement>(\".set-row\")].find((r) => r.dataset.name === name);\n if (!row) return false;\n const toggle = row.querySelector<HTMLButtonElement>(\".set-rowline > .set-expand\");\n if (toggle && toggle.getAttribute(\"aria-expanded\") !== \"true\") toggle.click();\n const still = typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n row.scrollIntoView({ block: \"center\", behavior: still ? \"auto\" : \"smooth\" });\n // Restarted, so landing on the same row twice lights it twice.\n row.classList.remove(\"landed\");\n void row.offsetWidth;\n row.classList.add(\"landed\");\n row.addEventListener(\"animationend\", () => row.classList.remove(\"landed\"), { once: true });\n return true;\n}\n\n/**\n * `revealRow`, retried over the next frames until the row exists or the tries\n * run out: for a page that fills in on its own time after a navigation. Both\n * apps hand-rolled this as `landOn` with the same twelve tries\n * (ui-review-2026-09, finding 29). Resolves true when it landed, false when it\n * gave up, and giving up is quiet: a name no page shows as a row is not a fault.\n */\nexport function revealRowWhenReady(within: ParentNode, name: string, tries = 12): Promise<boolean> {\n return new Promise((resolve) => {\n const attempt = (left: number): void => {\n if (revealRow(within, name)) { resolve(true); return; }\n if (left <= 0) { resolve(false); return; }\n requestAnimationFrame(() => attempt(left - 1));\n };\n attempt(tries);\n });\n}\n\n/** After a \"+ Add\" re-renders a list, bring the new (last) row into view and\n * focus its name input (`.set-name`, else the first input). */\nexport function focusNewRow(listEl: HTMLElement | null | undefined): void {\n const last = listEl?.lastElementChild;\n if (!(last instanceof HTMLElement)) return;\n last.scrollIntoView({ block: \"nearest\" });\n const name = last.querySelector<HTMLInputElement>(\"input.set-name\") ?? last.querySelector<HTMLInputElement>(\"input\");\n name?.focus();\n}\n\nexport interface DupGuard {\n /** Forget the previous render's inputs (call at the top of render). */\n reset(): void;\n /** Register a name input; `key` returns the comparison string (default the\n * input's value). Re-checks live on input. `also` = extra inputs that change the key. */\n track(input: HTMLInputElement, key?: () => string, also?: HTMLInputElement[]): void;\n /** Re-paint duplicates; true if any two non-blank keys collide. */\n check(): boolean;\n /** The first input currently flagged (after a fresh check), or null. */\n firstDuplicate(): HTMLInputElement | null;\n}\n\nconst DUP_MESSAGE = \"Another row already has this name.\";\n\n/** Case-insensitive duplicate-name detection: paints clashing inputs `.invalid`\n * and lets a Save gate block + jump via `firstDuplicate()`. */\nexport function dupGuard(): DupGuard {\n const items: Array<{ input: HTMLInputElement; key: () => string }> = [];\n const check = (): boolean => {\n const counts = new Map<string, number>();\n for (const it of items) { const k = it.key().trim().toLowerCase(); if (k) counts.set(k, (counts.get(k) ?? 0) + 1); }\n let any = false;\n for (const it of items) {\n const k = it.key().trim().toLowerCase();\n const dup = !!k && (counts.get(k) ?? 0) > 1;\n it.input.classList.toggle(\"invalid\", dup);\n // The reason rides `data-tip` (the themed rollover, and what the Save\n // gate's message channel reads), never `title`.\n if (dup) { it.input.dataset[\"tip\"] = DUP_MESSAGE; any = true; }\n else if (it.input.dataset[\"tip\"] === DUP_MESSAGE) delete it.input.dataset[\"tip\"];\n }\n return any;\n };\n return {\n reset() { items.length = 0; },\n track(input, key = () => input.value, also) {\n items.push({ input, key });\n input.addEventListener(\"input\", check);\n for (const a of also ?? []) a.addEventListener(\"input\", check);\n },\n check,\n firstDuplicate() { check(); return items.find((it) => it.input.classList.contains(\"invalid\"))?.input ?? null; },\n };\n}\n\n// --- the settings dialog ------------------------------------------------------\n\nexport interface SettingsSectionHandle {\n /** The first invalid control to jump to, blocking Save (e.g. a duplicate\n * name). Return `{ el, message }` to say WHICH fault in the error line;\n * a bare element says it through its own `data-tip` (the dup guard's, a\n * property-name field's), and the line falls back to a generic sentence\n * when it has neither. */\n firstInvalid?(): HTMLElement | { el: HTMLElement; message?: string } | null;\n}\n\nexport interface SettingsSection {\n id: string;\n label: string;\n /** Optional left-rail group heading above this tab. */\n group?: string;\n /** Build the section body into `host`; called fresh on each open so it reads\n * the current data. Return a handle (for the Save gate). */\n mount(host: HTMLElement): SettingsSectionHandle;\n /** Why this tab cannot be used right now, or null when it can. A reason\n * renders the tab dimmed and inert with the reason as its rollover\n * (Patterpad's Audio tab while the project is not voiced). Read on open\n * and on `refreshTabs()`, so a control inside the dialog can flip it. */\n disabled?: () => string | null;\n}\n\nexport interface SettingsDialogOptions {\n title: string;\n sections: SettingsSection[];\n /** Fired when Save is clicked and every section validates. The app reads its\n * own section state and persists. May be async; the dialog stays open until\n * it resolves, then closes.\n *\n * Return `false` (or a Promise of it) when the save was REFUSED, a version\n * control lock say, and the dialog stays open with the author's edits in it\n * for another try; saying why is the app's (a toast, usually). A throw, or a\n * rejected Promise, is treated the same way rather than surfacing as an\n * unhandled rejection. Anything else closes the dialog, as it always has. */\n onSave: () => void | boolean | Promise<void | boolean>;\n}\n\nexport interface SettingsDialog {\n /** Open (optionally on a given tab id). Sections re-mount from current data. */\n open(tabId?: string): void;\n /** Re-read every section's `disabled()`; a tab that has just become\n * disabled while showing hands over to the first usable one. */\n refreshTabs(): void;\n destroy(): void;\n}\n\n/** Build a settings dialog. The frame owns the modal, the tab rail, save-on-Save\n * (with a validation gate), and Cancel; the sections own their content + state. */\nexport function mountSettingsDialog(opts: SettingsDialogOptions): SettingsDialog {\n const dialog = el(\"dialog\", \"settings-dialog\");\n const form = el(\"form\", \"settings-form\"); form.method = \"dialog\";\n const tabs = el(\"nav\", \"settings-tabs\");\n const panels = el(\"div\", \"settings-panels\");\n const error = el(\"p\", \"settings-error\"); error.hidden = true;\n const cancel = el(\"button\", \"settings-cancel\", \"Cancel\"); cancel.type = \"button\"; cancel.value = \"cancel\";\n const save = el(\"button\", \"settings-save primary\", \"Save\"); save.value = \"save\";\n\n const panelFor = new Map<string, HTMLElement>();\n const tabFor = new Map<string, HTMLButtonElement>();\n const handles = new Map<string, SettingsSectionHandle>();\n let active = opts.sections[0]?.id ?? \"\";\n\n let lastGroup: string | undefined;\n for (const s of opts.sections) {\n if (s.group && s.group !== lastGroup) { tabs.append(el(\"div\", \"settings-group\", s.group)); lastGroup = s.group; }\n const tab = el(\"button\", \"settings-tab\", s.label); tab.type = \"button\"; tab.dataset[\"tab\"] = s.id;\n // A disabled tab is inert by class, not by the `disabled` attribute: a\n // disabled button swallows the pointer, and the reason has to be readable\n // on hover.\n tab.addEventListener(\"click\", () => { if (!tab.classList.contains(\"is-disabled\")) showTab(s.id); });\n tabs.append(tab); tabFor.set(s.id, tab);\n const panel = el(\"section\", \"settings-panel\"); panel.dataset[\"panel\"] = s.id; panel.hidden = true;\n panels.append(panel); panelFor.set(s.id, panel);\n }\n\n function showTab(id: string): void {\n active = id;\n for (const [sid, t] of tabFor) t.classList.toggle(\"active\", sid === id);\n for (const [sid, p] of panelFor) p.hidden = sid !== id;\n }\n\n const usable = (s: SettingsSection): boolean => !tabFor.get(s.id)?.classList.contains(\"is-disabled\");\n function refreshTabs(): void {\n for (const s of opts.sections) {\n const tab = tabFor.get(s.id)!;\n const reason = s.disabled?.() ?? null;\n tab.classList.toggle(\"is-disabled\", reason !== null);\n if (reason !== null) { tab.dataset[\"tip\"] = reason; tab.setAttribute(\"aria-disabled\", \"true\"); }\n else { delete tab.dataset[\"tip\"]; tab.removeAttribute(\"aria-disabled\"); }\n }\n if (!opts.sections.some((s) => s.id === active && usable(s))) {\n const first = opts.sections.find(usable);\n if (first) showTab(first.id);\n }\n }\n\n form.append(\n el(\"h2\", \"settings-title\", opts.title),\n el(\"div\", \"settings-body\", tabs, panels),\n el(\"div\", \"settings-actions\", error, cancel, save),\n );\n dialog.append(form);\n document.body.append(dialog);\n\n // Enter should not submit while editing a field; only the Save button does.\n form.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\" && (e.target as HTMLElement)?.tagName === \"INPUT\") e.preventDefault();\n });\n\n cancel.addEventListener(\"click\", () => dialog.close(\"cancel\"));\n save.addEventListener(\"click\", (e) => {\n e.preventDefault();\n error.hidden = true;\n for (const s of opts.sections) {\n const found = handles.get(s.id)?.firstInvalid?.();\n if (!found) continue;\n const bad = found instanceof HTMLElement ? found : found.el;\n const message = (found instanceof HTMLElement ? undefined : found.message) ?? bad.dataset[\"tip\"];\n showTab(s.id);\n bad.focus();\n // The field's own rollover says which fault it is, so the line repeats it\n // rather than inventing a summary; the generic sentence is the fallback.\n error.textContent = message || \"Fix the highlighted fields first.\";\n error.hidden = false;\n return;\n }\n // The dialog closes only on a save that went through. It used to close\n // whatever happened, so a save refused under a lock took the author's edits\n // away with it. Save is off while one is in flight, so a second click\n // cannot start a second save.\n save.disabled = true;\n void (async () => {\n let saved: unknown;\n try { saved = await opts.onSave(); } catch (err) { saved = false; console.error(\"Settings save failed:\", err); }\n save.disabled = false;\n if (saved !== false) dialog.close(\"save\");\n })();\n });\n\n return {\n open(tabId) {\n handles.clear();\n for (const s of opts.sections) {\n const panel = panelFor.get(s.id)!;\n panel.replaceChildren();\n handles.set(s.id, s.mount(panel));\n }\n error.hidden = true;\n showTab(tabId ?? active ?? opts.sections[0]?.id ?? \"\");\n refreshTabs(); // a disabled tab asked for by id hands over to the first usable one\n dialog.showModal();\n },\n refreshTabs,\n destroy() { dialog.remove(); },\n };\n}\n","// ---------------------------------------------------------------------------\n// Property names: what an author may call a value the story reads and writes.\n//\n// This belongs to the shell for the same reason gameIds do (see ids.ts): it\n// follows from the SHAPE these apps share - a project of data files, authored in\n// an editor, compiled for something else to run - rather than from any one\n// subject. Nothing here needs the words card, beat, hand or scene.\n//\n// UNLIKE gameIds, the rule is not a house style. It is dictated by the\n// expression language both families embed (`@wildwinter/expr`), and every clause\n// below is a failure observed by compiling one:\n//\n// parser.ts tokenises an identifier as /[a-zA-Z_][a-zA-Z0-9_]*/ and then\n// FOLDS it: `name: propTok.value.toLowerCase()`.\n//\n// @patter.is_night -> [\"sv\",\"patter\",\"is_night\"] reachable\n// @patter.isNight -> [\"sv\",\"patter\",\"isnight\"] folded: a declaration\n// spelled `isNight` is\n// one nothing can reach\n// @patter.is-night -> [\"bin\",\"-\",[\"sv\",\"patter\",\"is\"], NOT an error: it is\n// [\"s\",\"night\"]] SUBTRACTION. A hyphen\n// silently compiles to\n// a different meaning\n// @patter.is night -> parse error\n// @patter.9lives -> parse error (a name cannot start with a digit)\n// @patter.not -> parse error (`true false and or not` are keywords)\n//\n// The hyphen line is why this is worth a shared rule rather than a per-app\n// check: every other violation is loud, and that one quietly means something\n// else. It is also why a property name is NOT a gameId with different spelling -\n// a gameId is built out of hyphens, and here a hyphen is an operator.\n//\n// DEPENDENCY-FREE on purpose, ids.ts's reasoning verbatim: the apps' compilers,\n// CLIs and embedded runtimes need these rules far from any UI, so they keep\n// their own copies and assert parity with these in a test.\n// ---------------------------------------------------------------------------\n\n/** The five words `@wildwinter/expr` lexes as keywords, so a property may not be\n * called any of them: the reference does not resolve, it fails to parse. Kept\n * here as a copy for the same reason the rules are (no dependency), and each\n * app probes the real parser to prove the list is still true. */\nexport const RESERVED_PROPERTY_NAMES: readonly string[] = [\"true\", \"false\", \"and\", \"or\", \"not\"];\n\n/** What an editor should tell an author, in one line. */\nexport const PROPERTY_NAME_HINT =\n \"Lower case letters, digits, and underscores. It can't start with a digit. No hyphens or spaces.\";\n\n/**\n * Coerce a label into a legal property name: lower case, apostrophes dropped,\n * runs of anything else to a single underscore, no trailing underscore, an\n * underscore in front if it would otherwise start with a digit, and one behind\n * if it would otherwise be a keyword.\n *\n * A LEADING underscore is kept where the author typed one, because `_private` is\n * a legal name and a meaningful choice; only the ends that would be illegal are\n * touched.\n *\n * May return \"\", when there was nothing usable in the input. Callers treat that\n * as \"no name yet\" rather than as a name.\n */\nexport function propertyNameify(text: string): string {\n const trimmed = text.trim();\n // An underscore the author actually typed is kept; one that is only the ghost of\n // leading punctuation is not. That is the difference between `_private` and `!gold`.\n const deliberateLeading = trimmed.startsWith(\"_\");\n let out = trimmed.toLowerCase().replace(/['’]/g, \"\")\n .replace(/[^a-z0-9_]+/g, \"_\").replace(/_+/g, \"_\").replace(/^_+|_+$/g, \"\");\n if (out === \"\") return \"\";\n if (deliberateLeading || /^[0-9]/.test(out)) out = `_${out}`;\n if (RESERVED_PROPERTY_NAMES.includes(out)) out = `${out}_`;\n return out;\n}\n\n/**\n * Is this a name the expression language can actually reach? Lower case letters,\n * digits and underscores, not starting with a digit, and not a keyword.\n *\n * \"\" is NOT legal: an unnamed declaration is an unfinished row, which is a\n * different thing from an illegal one, and callers distinguish them.\n */\nexport function isValidPropertyName(name: string): boolean {\n return /^[a-z_][a-z0-9_]*$/.test(name) && !RESERVED_PROPERTY_NAMES.includes(name);\n}\n\n/**\n * The one thing that is only a case difference, e.g. `isNight` -> `isnight`.\n *\n * Worth its own question because it is the only violation that can be repaired\n * without guessing at intent: the language already folds every REFERENCE, so\n * folding the declaration to match changes nothing observable, where inventing\n * an underscore for a space is a decision about what the author meant. Loaders\n * fold this class silently and report the rest.\n */\nexport function isCaseOnlyPropertyName(name: string): boolean {\n return !isValidPropertyName(name) && isValidPropertyName(name.toLowerCase());\n}\n","// ---------------------------------------------------------------------------\n// The manners for a field that names a declared property.\n//\n// The RULE is property-names.ts, which is dependency-free because each app's\n// domain layer keeps its own copy of it. This is the other half: how a field\n// BEHAVES while somebody types a name into it, which only UI touches, so the\n// shell owns it outright.\n//\n// The manners are the gameId editor's, adopted rather than re-argued (see\n// id-editor.ts): an illegal name is marked and blocks Save, and Tab coerces it,\n// in the field, where it can be seen and undone. Nothing is rewritten as it is\n// typed. Patterpad's first pass at this folded every keystroke to lower case;\n// that is the manner the id editor had already rejected, on the grounds that an\n// app which silently renames a thing has made a decision that was not its to\n// make, and a property name is exactly that kind of thing: the author is naming\n// something their own conditions will call.\n//\n// It arrived here as two copies, one per app, written in one session and already\n// carrying the same forty lines of fault wording. Lifting them before they could\n// drift is the whole reason this file exists.\n// ---------------------------------------------------------------------------\n\nimport { isValidPropertyName, propertyNameify, RESERVED_PROPERTY_NAMES } from \"./property-names.js\";\n\n/** Re-check callbacks for bound REFERENCE fields, so a host can say \"the declarations\n * changed\" without holding a handle per row. */\nconst refSyncs = new WeakMap<HTMLInputElement, () => void>();\n\n/**\n * One line saying what is wrong with this name, or undefined when nothing is.\n *\n * Each branch names what actually HAPPENS rather than reciting the rule, because\n * the person reading it is usually somebody wondering why a condition does\n * nothing. Kept to one line: it lands in a rollover on the field, and hosts\n * repeat it in the Save error rather than inventing a summary of their own.\n */\nexport function propertyNameProblem(name: string): string | undefined {\n if (isValidPropertyName(name)) return undefined;\n const suggestion = propertyNameify(name);\n const tail = suggestion ? ` Try \"${suggestion}\", or press Tab.` : \"\";\n if (RESERVED_PROPERTY_NAMES.includes(name.toLowerCase())) {\n return `Can't be used. \"${name.toLowerCase()}\" is a keyword in expressions.${tail}`;\n }\n // The one that is not an error anywhere else: `@scope.a-b` compiles to a-minus-b.\n if (name.includes(\"-\")) return `Can't be used. A hyphen reads as subtraction in an expression.${tail}`;\n if (/^[0-9]/.test(name)) return `Can't be used. A name can't start with a digit.${tail}`;\n if (name !== name.toLowerCase()) {\n return `Can't be used. Expressions fold names, so this would look for \"${name.toLowerCase()}\".${tail}`;\n }\n return `Can't be used. Only lower case letters, digits, and underscores.${tail}`;\n}\n\n/**\n * Wire a name field: mark it live, explain the fault in its rollover, and coerce\n * on Tab. `onCommit` receives what the author typed, VERBATIM, on every input.\n *\n * `.illegal` rather than dupGuard's `.invalid`, because both can be true of one\n * field and `dupGuard.check()` owns that class: it would clear this marking every\n * time it ran, including at the moment of a blocked Save.\n *\n * An empty field is not marked. An unfinished row is a different thing from an\n * illegal one, and hosts prune blank names on save.\n */\nexport function bindPropertyName(\n input: HTMLInputElement,\n onCommit: (value: string) => void,\n opts: { hint?: string } = {},\n): void {\n const hint = opts.hint;\n const sync = (): void => {\n const v = input.value.trim();\n const problem = v === \"\" ? undefined : propertyNameProblem(v);\n input.classList.toggle(\"illegal\", !!problem);\n if (problem) input.title = problem;\n else if (input.title.startsWith(\"Can't be used\")) {\n if (hint) input.title = hint;\n else input.removeAttribute(\"title\");\n }\n };\n input.addEventListener(\"input\", () => { onCommit(input.value); sync(); });\n input.addEventListener(\"keydown\", (e) => {\n // The opt-in coercion, the id editor's gesture. Shift+Tab is left alone: it is\n // how somebody leaves a field they have not finished with.\n if (e.key !== \"Tab\" || e.shiftKey) return;\n const typed = input.value.trim();\n if (typed === \"\" || isValidPropertyName(typed)) return;\n const coerced = propertyNameify(typed);\n if (!coerced || coerced === input.value) return;\n e.preventDefault();\n input.value = coerced;\n onCommit(coerced);\n sync();\n });\n sync();\n}\n\n/**\n * The first field in `host` holding a name no expression could reach, for a Save\n * gate. Hosts hand this back beside `dupGuard.firstDuplicate()`: two faults, two\n * sets of words, one gate.\n */\nexport function firstIllegalPropertyName(host: ParentNode): HTMLInputElement | null {\n return host.querySelector<HTMLInputElement>(\"input.illegal\");\n}\n\n// ---------------------------------------------------------------------------\n// Reference fields, which are a different job from declaration fields.\n//\n// A declaration NAMES a property; a reference POINTS at one. The expression\n// parser folds every reference, so `@world.isNight` reaches `isnight` perfectly\n// well and complaining about the capital would be inventing a rule the language\n// does not have. Everything else still bites, and harder: no declaration may\n// contain a hyphen, so `is-night` in a reference can never match anything that\n// exists.\n//\n// And a reference has a fault a declaration cannot have: naming something that\n// was never declared. That is not a grammar question, so the host supplies the\n// list. The cost of getting it wrong is quiet - a coverage driver pointed at a\n// property nobody declared feeds a value nobody reads, the branches it was meant\n// to exercise stay unexercised, and the report shows them as never hit, which\n// reads as \"this content is unreachable\" rather than \"that name is a typo\".\n// ---------------------------------------------------------------------------\n\nexport interface PropertyRefOptions {\n /** The names that exist, read fresh on every check so a declaration added in the\n * same dialog clears the complaint. Compared case-insensitively, since the\n * parser folds. */\n known: () => string[];\n /** The scope token this field addresses, for the wording (\"no @world property...\"). */\n scope?: string;\n /** Shown on the field when there is nothing to complain about. */\n hint?: string;\n}\n\n/** The closest known name, when one is close enough to be worth naming. Deliberately\n * narrow: a wrong suggestion is worse than none, so it wants a shared prefix or a\n * single-character slip, not the least-bad match in the list. */\nfunction nearest(name: string, known: string[]): string | undefined {\n const n = name.toLowerCase();\n const byPrefix = known.filter((k) => k.toLowerCase().startsWith(n) || n.startsWith(k.toLowerCase()));\n if (byPrefix.length === 1) return byPrefix[0];\n let best: string | undefined;\n let bestScore = 3; // strictly better than \"three edits away\"\n for (const k of known) {\n const a = k.toLowerCase();\n if (Math.abs(a.length - n.length) > 2) continue;\n // Levenshtein, small strings, no need for a matrix beyond two rows.\n let prev = Array.from({ length: n.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i++) {\n const row = [i];\n for (let j = 1; j <= n.length; j++) {\n row[j] = Math.min(prev[j]! + 1, row[j - 1]! + 1, prev[j - 1]! + (a[i - 1] === n[j - 1] ? 0 : 1));\n }\n prev = row;\n }\n const d = prev[n.length]!;\n if (d < bestScore) { bestScore = d; best = k; }\n }\n return best;\n}\n\n/** Why this reference cannot be used, or undefined when it can. */\nexport function propertyRefProblem(name: string, opts: PropertyRefOptions): string | undefined {\n const scope = opts.scope ? `@${opts.scope}` : \"that scope\";\n // Case is NOT a fault here: the parser folds references.\n const folded = name.toLowerCase();\n if (!isValidPropertyName(folded)) {\n const suggestion = propertyNameify(name);\n const tail = suggestion ? ` Try \"${suggestion}\", or press Tab.` : \"\";\n if (RESERVED_PROPERTY_NAMES.includes(folded)) return `Can't be used. \"${folded}\" is a keyword in expressions.${tail}`;\n if (name.includes(\"-\")) return `Can't be used. A hyphen reads as subtraction in an expression.${tail}`;\n if (/^[0-9]/.test(name)) return `Can't be used. A name can't start with a digit.${tail}`;\n return `Can't be used. Only lower case letters, digits, and underscores.${tail}`;\n }\n const known = opts.known();\n if (known.some((k) => k.toLowerCase() === folded)) return undefined;\n const near = nearest(folded, known);\n if (near) return `No ${scope} property is called \"${name}\". Did you mean \"${near}\"?`;\n if (known.length === 0) return `No ${scope} properties are declared yet. Declare one above first.`;\n const shown = known.slice(0, 3).map((k) => `\"${k}\"`).join(\", \");\n const more = known.length > 3 ? `, and ${known.length - 3} more` : \"\";\n return `No ${scope} property is called \"${name}\". Pick one of ${shown}${more}.`;\n}\n\n/**\n * Wire a field that POINTS at a declared property: same manners as a declaration\n * field (mark, do not rewrite, Tab coerces), plus the declared names offered as a\n * datalist, because the rule is declare-then-reference and a picker makes that\n * painless rather than pedantic.\n *\n * Marks `.illegal` for an undeclared name too, which gates Save wherever the host\n * already asks `firstIllegalPropertyName`.\n */\nexport function bindPropertyRef(\n input: HTMLInputElement,\n onCommit: (value: string) => void,\n opts: PropertyRefOptions,\n): void {\n const list = document.createElement(\"datalist\");\n list.id = `shell-propref-${Math.random().toString(36).slice(2, 9)}`;\n input.setAttribute(\"list\", list.id);\n\n // Attached lazily, not once at bind. A datalist has to be IN the document to do anything, and it is\n // attached as a sibling of the input - so binding a field that has not been appended yet (which is\n // the ordinary order for a builder that makes its nodes and then mounts them) silently produced no\n // autocomplete at all: no error, nothing to see. This re-tries on every sync, so it heals as soon as\n // the field reaches the tree.\n const attach = (): void => {\n if (!list.isConnected && input.parentNode) input.after(list);\n };\n\n const sync = (): void => {\n attach();\n const known = opts.known();\n list.replaceChildren(...known.map((k) => { const o = document.createElement(\"option\"); o.value = k; return o; }));\n const v = input.value.trim();\n const problem = v === \"\" ? undefined : propertyRefProblem(v, opts);\n input.classList.toggle(\"illegal\", !!problem);\n if (problem) input.title = problem;\n else if (input.title.startsWith(\"Can't be used\") || input.title.startsWith(\"No \")) {\n if (opts.hint) input.title = opts.hint;\n else input.removeAttribute(\"title\");\n }\n };\n refSyncs.set(input, sync);\n\n input.addEventListener(\"input\", () => { onCommit(input.value); sync(); });\n input.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"Tab\" || e.shiftKey) return;\n const typed = input.value.trim();\n // Only a GRAMMAR fault is coercible. An undeclared name is not something Tab can\n // fix, and a legal reference in the wrong case is not a fault at all.\n if (typed === \"\" || isValidPropertyName(typed.toLowerCase())) return;\n const coerced = propertyNameify(typed);\n if (!coerced || coerced === input.value) return;\n e.preventDefault();\n input.value = coerced;\n onCommit(coerced);\n sync();\n });\n sync();\n}\n\n/**\n * Re-check every bound reference field inside `host`. Hosts call this when the\n * DECLARATIONS change, since a reference's validity depends on a list it does not\n * own: rename a property and the driver pointing at it is wrong from that moment,\n * with nothing typed into it.\n */\nexport function revalidatePropertyRefs(host: ParentNode): void {\n for (const input of host.querySelectorAll(\"input\")) refSyncs.get(input)?.();\n}\n","// ---------------------------------------------------------------------------\n// Typed value controls: how both apps show and set a value of a declared type.\n//\n// The first is the quality's. A quality is a step on a ladder, so its value is\n// shown as the LADDER, with the current rung marked, rather than a dropdown that\n// shows one name and hides where it stands (patterkit design/proposals/\n// patter-qualities.md section 4). Storyletter's Board drew it this way first;\n// it lives here so Storyletter's Fields tab, Patterpad's play panel and Game\n// Data rows, and the play inspectors all draw the same strip.\n//\n// An UNSET value (a field or game-data value the node leaves out) names what it\n// falls back to, \"default (x)\", by the family's one rule: the declaration's own\n// default, else the type's (a quality's first stage). A value that is no longer\n// a stage (a deleted one) is shown as such, so it can be put back on the ladder.\n//\n// No Electron, no app state: this module is DOM only, and is its own entry point\n// (`@wildwinter/app-shell/value-control`) so a play inspector outside the apps\n// can take it.\n// ---------------------------------------------------------------------------\n\nimport { el, tagChips } from \"./dom.js\";\n\n/** A declaration as these controls read it: a property's, a field's or a game-data field's. */\nexport interface ValueDeclLike {\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: readonly string[];\n /** quality: the ladder, in order */\n stages?: readonly string[];\n}\n\n/**\n * What an unset value of `decl` falls back to, as the words a control shows: its own default where it has\n * one, else its type's (False, 0, the first value, no flags, the first stage, empty text). The kernel's\n * `defaultFor`, in words; a host reads the same value from the bundle.\n */\nexport function fallbackText(decl: ValueDeclLike): string {\n const d = decl.default;\n if (d !== undefined && d !== null) {\n if (typeof d === \"boolean\") return d ? \"True\" : \"False\";\n if (Array.isArray(d)) return d.length === 0 ? \"none\" : d.join(\", \");\n return d === \"\" ? \"none\" : String(d);\n }\n switch (decl.type) {\n case \"boolean\": return \"False\";\n case \"number\": return \"0\";\n case \"enum\": return decl.values?.[0] ?? \"none\";\n case \"quality\": return decl.stages?.[0] ?? \"first stage\";\n case \"flags\": return \"none\";\n default: return \"empty\";\n }\n}\n\n/** The label an unset value shows: \"default (x)\", naming what it falls back to. */\nexport const defaultLabel = (decl: ValueDeclLike): string => `default (${fallbackText(decl)})`;\n\n/**\n * The quiet line under a ladder that has just been reordered: how many gates order against it. A reorder\n * changes no value, and is the one edit that changes what a gate MEANS without saying so (patter-qualities.md\n * section 2), so the editor says so. Empty when no gate orders the quality.\n */\nexport function stageGateNote(gates: number): string {\n if (gates <= 0) return \"\";\n return gates === 1\n ? \"1 gate compares against this ladder, and it now reads the new order.\"\n : `${gates} gates compare against this ladder, and each now reads the new order.`;\n}\n\nexport interface RungStripOptions {\n /** The ladder, in order. */\n stages: readonly string[];\n /** The value held, or undefined when unset: a field or game-data value the node leaves out. */\n value: string | undefined;\n /** The declaration, for what an unset value falls back to (its default, else the first stage). */\n decl?: ValueDeclLike;\n /** Pick a stage. Absent: the strip is read-only. */\n onPick?: (stage: string) => void;\n /** Clear back to unset. With it, the strip leads with \"default (x)\", which clears the value. */\n onClear?: () => void;\n /** The rollover on a rung that is not the current one (default: `Set to \"x\"`). */\n pickTip?: (stage: string) => string;\n /**\n * The document to build in, for a host outside the apps (a play inspector in a page or a frame of its\n * own). Given, rollovers are plain `title`s and the family's themed tooltips are not mounted; the host\n * styles `.seg`, `.seg-opt` and `.shell-rung` itself. Absent: the apps' document and themed rollovers.\n */\n doc?: Document;\n}\n\n/**\n * A quality's value as its ladder: one rung per stage, in order, the current one marked (`on`). Unset, the\n * rung it falls back to is marked as the fallback (`fallback`), and with `onClear` a leading \"default (x)\"\n * option is the current choice. A value that is not a stage (a deleted one) is shown after the ladder,\n * marked `stray`, until a rung is picked.\n */\nexport function rungStrip(opts: RungStripOptions): HTMLElement {\n const make = opts.doc === undefined ? el : (tag: \"span\" | \"button\", props: { className: string; text?: string; tip?: string; onClick?: () => void }) => {\n const node = opts.doc!.createElement(tag);\n node.className = props.className;\n if (props.text !== undefined) node.textContent = props.text;\n if (props.tip !== undefined) { node.title = props.tip; node.setAttribute(\"aria-label\", props.tip); }\n if (props.onClick) node.addEventListener(\"click\", props.onClick);\n if (tag === \"button\") (node as HTMLButtonElement).type = \"button\";\n return node;\n };\n const strip = make(\"span\", { className: \"seg shell-rungs\" });\n const decl: ValueDeclLike = opts.decl ?? { type: \"quality\", stages: opts.stages };\n const unset = opts.value === undefined;\n const fallback = typeof decl.default === \"string\" && opts.stages.includes(decl.default) ? decl.default : opts.stages[0];\n const readOnly = opts.onPick === undefined;\n if (opts.onClear) {\n strip.append(make(\"button\", {\n className: `seg-opt shell-rung shell-rung-default${unset ? \" on\" : \"\"}`, text: defaultLabel(decl),\n tip: unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n onClick: () => { if (!unset) opts.onClear!(); },\n }));\n }\n for (const stage of opts.stages) {\n const current = opts.value === stage;\n const falls = unset && stage === fallback;\n const rung = make(readOnly ? \"span\" : \"button\", {\n className: `seg-opt shell-rung${current ? \" on\" : \"\"}${falls ? \" fallback\" : \"\"}`, text: stage,\n tip: current ? \"The current stage\" : falls ? \"The stage it falls back to\" : readOnly ? stage : (opts.pickTip?.(stage) ?? `Set to \"${stage}\"`),\n ...(readOnly ? {} : { onClick: () => { if (!current) opts.onPick!(stage); } }),\n });\n strip.append(rung);\n }\n if (!unset && !opts.stages.includes(opts.value!)) {\n strip.append(make(\"span\", {\n className: \"seg-opt shell-rung stray on\", text: opts.value!,\n tip: `\"${opts.value}\" is not one of the stages: pick the one it belongs at now`,\n }));\n }\n return strip;\n}\n\n// ---------------------------------------------------------------------------\n// The field row: ONE control for a node's value of a declared field, driven by\n// the declared type, for the family's seven types (text, multiline, number,\n// boolean, enum, flags, quality). Storyletter's card and outcome Fields and\n// Patterpad's Game Data rows both draw it, which settles the disagreements the\n// parity review found (patterkit design/family-parity-2026-10.md item 10):\n//\n// - the declared purpose is shown, under the control, not hidden in a rollover;\n// - unset says what it falls back to, \"default (x)\", by `defaultLabel`;\n// - flags are a picker of the declared values, not comma-separated text;\n// - multiline is a text area;\n// - a value the declaration refuses (not a number, not one of the values, not\n// a stage) is said under the control, and the app may add its own message;\n// - text commits as typed, and Escape puts back what the field held when it\n// took focus (the family's field rule).\n//\n// Committing as typed means a host that redraws on every change (Patterpad's\n// inspector rebuilds its whole stack) would drop the focus at every keystroke.\n// `fieldRows()` is the answer: it hands back the SAME element for the same key\n// across a redraw, updated in place, and gives the focus (and the caret) back\n// to it once the redraw has put it in the page again.\n// ---------------------------------------------------------------------------\n\n/** A value a field row commits: a flags value is the list of names set. */\nexport type FieldValue = string | number | boolean | string[];\n\n/** A field's declaration as the row reads it: a card field's, an outcome field's or a game-data field's. */\nexport interface FieldDeclLike extends ValueDeclLike {\n name: string;\n /** What the field is for, shown under the control. */\n purpose?: string;\n /** A sentence about each value (an enum's values, the flags, a quality's stages), as an extension's manifest\n * gives them: the chosen value's is shown under the control, and each chosen flag's. */\n valueHelp?: Readonly<Record<string, string>>;\n}\n\n/**\n * The help for what `decl` holds: the chosen enum value's or stage's (the one it falls back to, when unset), or\n * each chosen flag's, \"name: sentence\" a line each. Empty when the declaration describes none of them.\n */\nexport function valueHelpText(decl: FieldDeclLike, value: unknown): string {\n const help = decl.valueHelp;\n if (help === undefined) return \"\";\n const said = (v: string): string | undefined => (Object.prototype.hasOwnProperty.call(help, v) ? help[v] : undefined);\n if (decl.type === \"enum\" || decl.type === \"quality\") {\n const held = typeof value === \"string\" && value !== \"\" ? value\n : typeof decl.default === \"string\" && decl.default !== \"\" ? decl.default\n : decl.type === \"enum\" ? decl.values?.[0] : decl.stages?.[0];\n return held === undefined ? \"\" : said(held) ?? \"\";\n }\n if (decl.type === \"flags\") {\n const held = Array.isArray(value) ? value.map(String) : Array.isArray(decl.default) ? decl.default.map(String) : [];\n return held.flatMap((v) => { const h = said(v); return h === undefined ? [] : [`${v}: ${h}`]; }).join(\"\\n\");\n }\n return \"\";\n}\n\nexport interface FieldRowOptions {\n decl: FieldDeclLike;\n /** The node's own value, typed (a flags value is a string list), or undefined where the node sets none. */\n value: unknown;\n /** Commit a value; `undefined` clears it, back to the default. Absent: the row is read-only. */\n onCommit?: (value: FieldValue | undefined) => void;\n /** Drawn but not editable, as when there is no node to write to. */\n disabled?: boolean;\n /** A message of the app's own about this value (a check the row cannot make), shown under the control. */\n problem?: string;\n /** The app's own sentence INSTEAD of the row's (a renamed stage said better than \"not one of the stages\").\n * Given, it is the whole message; `problem` is ignored. */\n replaceProblem?: string;\n /** The caption; default the field's name. */\n label?: string | Node;\n /** Added to the row and its caption, so a row sits in its app's layout. */\n className?: string;\n labelClassName?: string;\n /** The app's class for a text field or select, used instead of the shell's `.field`. */\n controlClassName?: string;\n}\n\nexport interface FieldRowHandle {\n /** The row: its caption, then the control with the purpose and any message under it. */\n readonly el: HTMLElement;\n /** Redraw for a new value, declaration or message, keeping the element. A field being typed in keeps its\n * text: what the author is typing is newer than what the app last stored. */\n update(opts: FieldRowOptions): void;\n}\n\n/** The type's fallback as a value, for a flags picker to start from when the node sets none. */\nconst fallbackFlags = (decl: ValueDeclLike): string[] => (Array.isArray(decl.default) ? decl.default.filter((v): v is string => typeof v === \"string\") : []);\n\n/** What the row says about a value the declaration refuses, or \"\" when it fits. */\nexport function fieldValueProblem(decl: ValueDeclLike, value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n switch (decl.type) {\n case \"number\":\n return typeof value === \"number\" && Number.isFinite(value) ? \"\" : \"Not a number.\";\n case \"boolean\":\n return typeof value === \"boolean\" ? \"\" : \"Not True or False.\";\n case \"enum\":\n return decl.values && !decl.values.includes(String(value)) ? `\"${String(value)}\" is not one of the values.` : \"\";\n case \"quality\":\n return decl.stages && !decl.stages.includes(String(value)) ? `\"${String(value)}\" is not one of the stages.` : \"\";\n case \"flags\": {\n if (!Array.isArray(value)) return \"Not a list of flags.\";\n const strays = decl.values ? value.filter((v) => !decl.values!.includes(String(v))) : [];\n if (strays.length === 0) return \"\";\n return strays.length === 1 ? `\"${String(strays[0])}\" is not one of the values.` : `${strays.map((s) => `\"${String(s)}\"`).join(\", \")} are not among the values.`;\n }\n default:\n return \"\";\n }\n}\n\nconst isTextual = (type: string): boolean => type !== \"boolean\" && type !== \"enum\" && type !== \"flags\" && type !== \"quality\";\n\n/** Everything that decides which control is drawn: a change here rebuilds it, anything else updates it. */\nconst controlShape = (o: FieldRowOptions): string => JSON.stringify([\n o.decl.type, o.decl.values ?? null, o.decl.stages ?? null, o.decl.default ?? null,\n o.onCommit === undefined, o.disabled === true, o.controlClassName ?? \"\",\n o.decl.type === \"quality\" && (o.decl.stages?.length ?? 0) === 0,\n]);\n\n/**\n * One declared field's value as a row: the caption, then the control the declared type calls for, with the\n * purpose and any message under it. See the section comment above for the rules it carries.\n */\nexport function fieldRow(initial: FieldRowOptions): FieldRowHandle {\n let opts = initial;\n const row = el(\"div\", `shell-fieldrow${opts.className ? ` ${opts.className}` : \"\"}`);\n const caption = el(\"span\", `shell-fieldrow-label${opts.labelClassName ? ` ${opts.labelClassName}` : \"\"}`);\n caption.id = `shell-fr-${Math.random().toString(36).slice(2, 9)}`;\n const body = el(\"div\", \"shell-fieldrow-body\");\n const purpose = el(\"p\", \"shell-fieldrow-purpose\");\n const valueHelp = el(\"p\", \"shell-fieldrow-purpose shell-fieldrow-valuehelp\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n row.append(caption, body);\n\n let shape = \"\";\n /** Redraw the control for the current value; set by whichever control is built. */\n let show: (value: unknown) => void = () => {};\n /** A local problem the control found while typing (a number that is not one yet). */\n let typing = \"\";\n\n const commit = (v: FieldValue | undefined): void => { opts.onCommit?.(v); };\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n // An app's own field class replaces the shell's `.field`, so its controls look like its other fields.\n const ctl = (base: string): string => (opts.controlClassName ? `${base.replace(/^field /, \"\")} ${opts.controlClassName}` : base);\n const labelledBy = (node: HTMLElement): void => {\n node.setAttribute(\"aria-labelledby\", caption.id);\n const described = [purpose.id, problem.id].filter(Boolean).join(\" \");\n if (described) node.setAttribute(\"aria-describedby\", described);\n };\n purpose.id = `${caption.id}-p`; problem.id = `${caption.id}-m`;\n\n const sayProblem = (): void => {\n // The chosen value's own help travels with every change of value, as the message does.\n const help = valueHelpText(opts.decl, opts.value);\n valueHelp.textContent = help;\n valueHelp.hidden = help === \"\";\n const words = opts.replaceProblem !== undefined\n ? [opts.replaceProblem].filter((w) => w !== \"\")\n : [typing || fieldValueProblem(opts.decl, opts.value), opts.problem ?? \"\"].filter((w) => w !== \"\");\n problem.textContent = words.join(\" \");\n problem.hidden = words.length === 0;\n row.classList.toggle(\"has-problem\", words.length > 0);\n row.classList.toggle(\"shell-fieldrow-textual\", isTextual(opts.decl.type));\n };\n\n const build = (): HTMLElement => {\n const decl = opts.decl;\n typing = \"\";\n if (decl.type === \"quality\" && (decl.stages?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-fieldrow-rungs\");\n show = (value) => {\n holder.replaceChildren(rungStrip({\n stages: decl.stages!, value: typeof value === \"string\" && value !== \"\" ? value : undefined, decl,\n ...(editable() ? { onPick: (stage: string) => { opts = { ...opts, value: stage }; show(stage); sayProblem(); commit(stage); }, onClear: () => { opts = { ...opts, value: undefined }; show(undefined); sayProblem(); commit(undefined); } } : {}),\n }));\n const strip = holder.firstElementChild as HTMLElement | null;\n if (strip) { strip.setAttribute(\"role\", \"group\"); labelledBy(strip); }\n };\n return holder;\n }\n if (decl.type === \"boolean\" || decl.type === \"enum\") {\n const sel = el(\"select\", ctl(\"field shell-fieldrow-select\"));\n labelledBy(sel);\n sel.disabled = !editable();\n const choices: Array<[string, string]> = decl.type === \"boolean\"\n ? [[\"true\", \"True\"], [\"false\", \"False\"]]\n : (decl.values ?? []).map((v): [string, string] => [v, v]);\n show = (value) => {\n const current = value === undefined || value === null || value === \"\" ? \"\" : String(value);\n sel.replaceChildren();\n const add = (v: string, label: string): void => { const o = el(\"option\", undefined, label); o.value = v; sel.append(o); };\n add(\"\", defaultLabel(decl));\n for (const [v, label] of choices) add(v, label);\n // A value the declaration no longer offers stays visible, so the author sees what is held.\n if (current !== \"\" && !choices.some(([v]) => v === current)) add(current, current);\n sel.value = current;\n };\n sel.addEventListener(\"change\", () => {\n const raw = sel.value;\n const v: FieldValue | undefined = raw === \"\" ? undefined : decl.type === \"boolean\" ? raw === \"true\" : raw;\n opts = { ...opts, value: v }; sayProblem(); commit(v);\n });\n return sel;\n }\n if (decl.type === \"flags\" && (decl.values?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-flags\");\n holder.setAttribute(\"role\", \"group\");\n labelledBy(holder);\n show = (value) => {\n const unset = !Array.isArray(value);\n const held = unset ? fallbackFlags(decl) : (value as unknown[]).map(String);\n holder.replaceChildren();\n const chip = (text: string, cls: string, pressed: boolean | undefined, tip: string, onClick?: () => void): void => {\n const b = el(onClick && editable() ? \"button\" : \"span\", { className: `shell-flag${cls}`, text, tip });\n b.setAttribute(\"aria-label\", `${text}: ${tip}`); // the tip alone would hide the value's name\n if (b instanceof HTMLButtonElement) { b.type = \"button\"; b.addEventListener(\"click\", onClick!); }\n if (pressed !== undefined) b.setAttribute(\"aria-pressed\", String(pressed));\n holder.append(b);\n };\n const set = (next: string[] | undefined): void => { opts = { ...opts, value: next }; show(next); sayProblem(); commit(next); };\n chip(defaultLabel(decl), ` shell-flag-default${unset ? \" on\" : \"\"}`, undefined,\n unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n unset ? undefined : () => set(undefined));\n for (const v of decl.values!) {\n const on = held.includes(v);\n chip(v, `${on ? \" on\" : \"\"}${on && unset ? \" fallback\" : \"\"}`, on, on ? `Unset ${v}` : `Set ${v}`,\n () => set(on ? held.filter((x) => x !== v) : decl.values!.filter((x) => x === v || held.includes(x)).concat(held.filter((x) => !decl.values!.includes(x)))));\n }\n // A held value the declaration does not offer: shown, struck, and a click drops it.\n for (const v of held.filter((x) => !decl.values!.includes(x))) {\n chip(v, \" stray on\", true, `\"${v}\" is not one of the values: click to drop it`, () => set(held.filter((x) => x !== v)));\n }\n };\n return holder;\n }\n if (decl.type === \"flags\") {\n // No values declared to pick from: the shell's chip editor, each name typed.\n const holder = el(\"span\", \"shell-fieldrow-chips\");\n show = (value) => {\n const box = { values: Array.isArray(value) ? (value as unknown[]).map(String) : [] };\n const chips = tagChips(box, () => {\n const next = box.values.length > 0 ? [...box.values] : undefined;\n opts = { ...opts, value: next }; sayProblem(); commit(next);\n });\n const input = chips.querySelector(\"input\");\n if (input) { labelledBy(input); input.placeholder = Array.isArray(value) ? \"Add value\" : defaultLabel(decl); input.disabled = !editable(); }\n chips.querySelectorAll(\"button\").forEach((b) => { (b as HTMLButtonElement).disabled = !editable(); });\n holder.replaceChildren(chips);\n };\n return holder;\n }\n // text, multiline, number, and any type the row does not know: typed, committed as typed.\n const multiline = decl.type === \"multiline\";\n const field = multiline ? el(\"textarea\", ctl(\"field shell-fieldrow-text\")) : el(\"input\", ctl(\"field shell-fieldrow-text\"));\n if (field instanceof HTMLInputElement) {\n field.type = \"text\";\n if (decl.type === \"number\") field.inputMode = \"decimal\";\n } else field.rows = 3;\n labelledBy(field);\n field.placeholder = defaultLabel(decl);\n field.disabled = !editable();\n const asText = (value: unknown): string =>\n value === undefined || value === null ? \"\" : Array.isArray(value) ? value.join(\", \") : String(value);\n const read = (raw: string): { value?: FieldValue; bad?: string } => {\n if (raw.trim() === \"\") return {};\n if (decl.type !== \"number\") return { value: raw };\n const n = Number(raw.trim());\n return Number.isFinite(n) ? { value: n } : { bad: \"Not a number.\" };\n };\n let atFocus = \"\";\n show = (value) => {\n // What the author is typing is newer than the stored value, so a focused field keeps its text.\n // So does one the author was in when a redraw took the row out of the page, until they leave it.\n if (field.ownerDocument.activeElement === field || keeper.restoring(field) || keeper.holds(row)) return;\n field.value = asText(value);\n };\n const take = (): void => {\n const r = read(field.value);\n typing = r.bad ?? \"\";\n if (r.bad === undefined) opts = { ...opts, value: r.value };\n sayProblem();\n if (r.bad === undefined) commit(r.value);\n };\n field.addEventListener(\"focus\", () => { if (!keeper.restoring(field)) atFocus = field.value; });\n field.addEventListener(\"input\", take);\n field.addEventListener(\"keydown\", (e) => {\n if ((e as KeyboardEvent).key !== \"Escape\" || field.value === atFocus) return;\n field.value = atFocus;\n take();\n });\n return field;\n };\n\n const draw = (next: FieldRowOptions): void => {\n const decl = next.decl;\n const label = next.label ?? decl.name;\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n caption.className = `shell-fieldrow-label${next.labelClassName ? ` ${next.labelClassName}` : \"\"}`;\n row.className = `shell-fieldrow${next.className ? ` ${next.className}` : \"\"}`;\n const nextShape = controlShape(next);\n opts = next;\n if (nextShape !== shape) {\n shape = nextShape;\n body.replaceChildren(build());\n }\n show(next.value);\n purpose.textContent = decl.purpose ?? \"\";\n if (decl.purpose) body.append(purpose); else purpose.remove();\n body.append(valueHelp, problem);\n sayProblem();\n };\n\n draw(initial);\n keeper.watch(row);\n return { el: row, update: draw };\n}\n\n// --- keeping the focus across a redraw -------------------------------------\n//\n// A host that rebuilds its view takes the row out of the page and puts it back.\n// Taking a focused element out drops its focus, which is the same thing as\n// the author losing their place mid-word. So a row remembers whether the\n// author was in it, and where the caret was, and the cache gives both back\n// once the row is in the page again (a microtask: after the host's redraw).\n\ninterface FocusMemo { field: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement; start: number | null; end: number | null }\n\nconst keeper = (() => {\n const memos = new WeakMap<HTMLElement, FocusMemo>();\n const restoringNow = new WeakSet<Element>();\n /** When each row was last handed back by the cache, to tell a move's late blur from the author's. */\n const redrawn = new WeakMap<HTMLElement, number>();\n const put = (row: HTMLElement): void => {\n const memo = memos.get(row);\n if (!memo) return;\n const doc = row.ownerDocument;\n const active = doc.activeElement;\n if (!row.isConnected || !memo.field.isConnected || !row.contains(memo.field)) return;\n if (active && active !== doc.body && !row.contains(active)) { memos.delete(row); return; }\n if (active === memo.field && memo.field.matches(\":focus\")) return;\n restoringNow.add(memo.field);\n try {\n memo.field.focus({ preventScroll: true });\n if (!(memo.field instanceof HTMLSelectElement) && memo.start !== null) memo.field.setSelectionRange(memo.start, memo.end ?? memo.start);\n } finally { restoringNow.delete(memo.field); }\n };\n return {\n watch(row: HTMLElement): void {\n const note = (e: Event): void => {\n const t = e.target;\n if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement)) return;\n const text = !(t instanceof HTMLSelectElement);\n memos.set(row, { field: t, start: text ? (t as HTMLInputElement).selectionStart : null, end: text ? (t as HTMLInputElement).selectionEnd : null });\n };\n row.addEventListener(\"focusin\", note);\n row.addEventListener(\"input\", note);\n row.addEventListener(\"keyup\", note);\n row.addEventListener(\"mouseup\", note);\n // A blur the author made (the row still in the page) forgets; one caused by the row leaving the page\n // does not, and is what the cache puts back. Chromium drops the focus of a moved element LATE: the\n // blur arrives after the redraw, the row already back in the page, so a blur to nowhere just after a\n // redraw is the move's, and the focus goes straight back.\n // Chromium may also fire that blur synchronously, as the host clears its view and before the cache\n // has handed the row back: so the decision waits for the microtask, by which time a row the redraw\n // asked for again is marked as redrawn since the blur.\n row.addEventListener(\"focusout\", (e) => {\n const at = performance.now();\n const late = (e as FocusEvent).relatedTarget === null && at - (redrawn.get(row) ?? -Infinity) < 250;\n if (late && memos.has(row)) { queueMicrotask(() => put(row)); return; }\n queueMicrotask(() => {\n if ((redrawn.get(row) ?? -Infinity) >= at) { put(row); return; }\n if (row.isConnected && !row.contains(row.ownerDocument.activeElement)) memos.delete(row);\n });\n });\n },\n /** Give the focus back to the row, if the author was in it and has not gone anywhere else since. */\n restore(row: HTMLElement): void {\n if (!memos.has(row)) return;\n redrawn.set(row, performance.now());\n // At the microtask, not now: the event that caused the redraw may still note the caret.\n queueMicrotask(() => put(row));\n },\n restoring: (field: Element): boolean => restoringNow.has(field),\n /** Forget the row's focus if the author has since gone somewhere else (before the row is redrawn). */\n settle(row: HTMLElement): void {\n const active = row.ownerDocument.activeElement;\n if (active && active !== row.ownerDocument.body && !row.contains(active)) memos.delete(row);\n },\n /** The row the author is in (before a redraw takes it out). */\n holds: (row: HTMLElement): boolean => memos.has(row),\n };\n})();\n\n/**\n * The focus keeping `fieldRows` does, for a host (or a structured row) that keeps row elements itself: call\n * `settle` before it updates a row and `restore` once the row is back in the page.\n */\nexport const fieldRowFocus = {\n settle: (row: HTMLElement): void => keeper.settle(row),\n restore: (row: HTMLElement): void => keeper.restore(row),\n};\n\nexport interface FieldRows {\n /**\n * The row for `key` (a node and a field, say `${nodeId}:${field}`): the same element as last time when\n * there was one, updated for these options, else a new one. A row the author was typing in gets its focus\n * and caret back once the redraw has put it in the page.\n */\n row(key: string, opts: FieldRowOptions): HTMLElement;\n /** Forget every row not asked for since the last sweep (call at the end of a redraw). */\n sweep(): void;\n}\n\n/** A cache of field rows for a host that redraws its whole view on every change. */\nexport function fieldRows(): FieldRows {\n const rows = new Map<string, { handle: FieldRowHandle; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had) {\n had.used = true;\n keeper.settle(had.handle.el);\n had.handle.update(opts);\n keeper.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = fieldRow(opts);\n rows.set(key, { handle, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// THE property declaration list: name, type, default, values or stages,\n// purpose, in a row per declaration, with reorder, remove, add-then-focus and\n// the duplicate / illegal-name gates. Patterpad's settings-properties.ts and\n// Storyletter's prop-list.ts were built from the same shell primitives in the\n// same order (dupGuard, bindPropertyName, a type select over the same six\n// types, defaultControl, three iconBtns on moveItem, labelled tagChips and\n// stageChips, expandableRow, focusNewRow); this is the one list, and each\n// app's extras (Shared, Temporary, Read-only, Durable) arrive through\n// `extraLine` / `extraDetails`.\n//\n// `defaultControl` was four copies (three inside Patterpad), and the two apps'\n// option labels had already parted (\"(unset)\" vs \"(none)\"). One label set now.\n//\n// Storage of the default differs by app: Patterpad's model holds a typed\n// value (true, 3), Storyletter's DTO holds the string the field showed. The\n// list mutates `decls` in place either way; `typed` picks the encoding.\n// ---------------------------------------------------------------------------\n\nimport { el } from \"./dom.js\";\nimport { iconBtn, labelled, moveItem, stageChips, tagChips } from \"./dom.js\";\nimport { dupGuard, expandableRow, focusNewRow } from \"./settings.js\";\nimport type { SettingsSectionHandle } from \"./settings.js\";\nimport { bindPropertyName, firstIllegalPropertyName } from \"./property-name-field.js\";\nimport { PROPERTY_NAME_HINT } from \"./property-names.js\";\nimport { defaultLabel, fallbackText } from \"./value-control.js\";\n\n/** The six types both apps declare. */\nexport type PropertyListType = \"number\" | \"boolean\" | \"string\" | \"enum\" | \"flags\" | \"quality\";\n\n/** The shape a row edits. Apps' DTOs carry more (shared, writable, durable);\n * those ride through untouched. */\nexport interface PropertyDeclLike {\n name: string;\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: string[];\n /** quality: the ladder, in order */\n stages?: string[];\n purpose?: string;\n}\n\n/** The type list, in the family's order, with the words the select shows. */\nexport const PROPERTY_TYPES: ReadonlyArray<readonly [PropertyListType, string]> = [\n [\"number\", \"Number\"], [\"boolean\", \"True / False\"], [\"string\", \"Text\"],\n [\"enum\", \"List\"], [\"flags\", \"Flags\"], [\"quality\", \"Quality\"],\n];\n\nexport interface DefaultControlOptions {\n /**\n * How the default is stored. `false` (default): the string the field shows\n * (Storyletter's DTO). `true`: a typed value (boolean, number, string)\n * (Patterpad's model). Either way, no default given DELETES the key: a\n * default is optional in source, and the type's holds (the family's rule,\n * ruled 2026-10-18).\n */\n typed?: boolean;\n /**\n * An enum may hold \"\" (none chosen), as a field's may: the select then\n * offers \"(none)\" beside \"default (x)\". Off for a property, whose value is\n * always one of its values.\n */\n noneChosen?: boolean;\n /** What the blank says instead of the type's default, where something else holds when none is given\n * here: a tag's starting value falls back to its group's default, say. */\n unsetLabel?: string;\n}\n\nconst option = (value: string, label: string, selected: boolean): HTMLOptionElement => {\n const o = el(\"option\", undefined, label);\n o.value = value; o.selected = selected;\n return o;\n};\n\n/** The select value that stands for an enum's \"\" (none chosen), apart from no default at all. */\nconst NONE_CHOSEN = \"\\u0000none\";\n\n/**\n * The type-appropriate control for a declaration's DEFAULT: a true / false\n * picker for a boolean, the value list for an enum, the stage list for a\n * quality, a note for flags (a set starts empty), a number or text field\n * otherwise. Leaving it blank gives no default, and the blank says what holds\n * then, \"default (x)\" (`defaultLabel`): a default is optional, and the type's\n * fills in.\n */\nexport function defaultControl(p: PropertyDeclLike, onChange?: () => void, opts: DefaultControlOptions = {}): HTMLElement {\n const typed = opts.typed === true;\n const write = (raw: string): void => {\n if (raw === \"\") delete p.default;\n else if (raw === NONE_CHOSEN) p.default = \"\";\n else if (typed && p.type === \"boolean\") p.default = raw === \"true\";\n else if (typed && p.type === \"number\") p.default = Number(raw);\n else p.default = raw;\n onChange?.();\n };\n const current = p.default === undefined || p.default === null ? \"\" : String(p.default);\n // What a blank default falls back to, said on the blank itself: the type's, not this one's.\n const unsetLabel = opts.unsetLabel ?? defaultLabel({ ...p, default: undefined });\n if (p.type === \"boolean\") {\n const sel = el(\"select\", \"field set-default\");\n sel.append(option(\"\", unsetLabel, current === \"\"), option(\"true\", \"True\", current === \"true\"), option(\"false\", \"False\", current === \"false\"));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"enum\") {\n const sel = el(\"select\", \"field set-default\");\n const none = opts.noneChosen === true && p.default === \"\";\n sel.append(option(\"\", unsetLabel, current === \"\" && !none));\n if (opts.noneChosen) sel.append(option(NONE_CHOSEN, \"(none)\", none));\n for (const v of p.values ?? []) sel.append(option(v, v, current === v));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"quality\") {\n // The default is a STAGE; blank means the first rung, and says which.\n const sel = el(\"select\", \"field set-default\");\n sel.append(option(\"\", unsetLabel, current === \"\"));\n for (const v of p.stages ?? []) sel.append(option(v, v, current === v));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"flags\") {\n // Flags hold a SET of values, so there is no single default: it starts empty.\n const s = el(\"span\", \"set-flagnote\", \"Starts empty\");\n s.dataset[\"tip\"] = \"A flags property starts with none set.\";\n return s;\n }\n const input = el(\"input\", \"field set-default\");\n input.type = p.type === \"number\" ? \"number\" : \"text\";\n input.placeholder = p.type === \"number\" ? `Default (${fallbackText({ type: \"number\" })})` : \"Default\";\n input.value = current;\n input.addEventListener(\"input\", () => write(input.value));\n return input;\n}\n\nexport interface PropertyListOptions<T extends PropertyDeclLike> extends DefaultControlOptions {\n /** Called after every mutation; a centre editor feeds its autosave here. */\n onChange?: () => void;\n /** The add button's label. Default \"+ Add property\". */\n addLabel?: string;\n /** The empty sentence. Default \"No properties yet.\" */\n emptyText?: string;\n /** The type select's entries; default `PROPERTY_TYPES`. */\n types?: ReadonlyArray<readonly [string, string]>;\n /** A fresh declaration for the add button. Default: a blank of the first type. */\n newDecl?: () => T;\n /** Controls on the row's line, between the default and the movers\n * (Storyletter's \"uses\" affordance). */\n extraLine?: (decl: T, index: number) => (HTMLElement | null)[];\n /** Fields behind the disclosure, before Values / Stages / Purpose\n * (Shared, Temporary, Read-only, Durable). */\n extraDetails?: (decl: T, index: number) => (HTMLElement | null)[];\n /** Offer the Purpose field. Default true. */\n purpose?: boolean;\n /** What a row declares, in the row's own words (\"Field name\", \"What this field is for\", \"Delete\n * field\"). Default \"property\". */\n noun?: string;\n /**\n * The rule a name follows. `\"property\"` (default): the property-name rules, bound and gated, since an\n * expression must be able to reach it. `\"free\"`: any name, only duplicates refused, for a declaration no\n * expression reads (a Patterpad game-data field's name is the host's word).\n */\n names?: \"property\" | \"free\";\n /**\n * A quality's stage was renamed in place (the declaration's own default\n * already follows it). Given, the rename is handed here INSTEAD of\n * `onChange`, so the caller can carry every value that names the stage in\n * the same edit as the declaration; absent, it is an ordinary change.\n */\n onStageRename?: (decl: T, from: string, to: string) => void;\n /** A quality's stages were reordered (after `onChange`). `note` is a quiet\n * line under the stages for the caller to fill, such as how many gates\n * compare against the ladder. */\n onStageReorder?: (decl: T, note: HTMLElement) => void;\n}\n\nexport interface PropertyListHandle extends SettingsSectionHandle {\n /** Both faults, for the Save gate: a duplicate first, then an illegal name. */\n firstInvalid(): HTMLInputElement | null;\n /** The first name that clashes with another, or null. */\n firstDuplicate(): HTMLInputElement | null;\n /** The first name no expression could reach, or null. */\n firstIllegalName(): HTMLInputElement | null;\n /** Redraw from `decls` (after an outside change). */\n render(): void;\n}\n\n/** Mount the list into `host`. Mutates `decls` in place; the caller reads\n * them back on save (pruning blank names is the caller's, since only it\n * knows its DTO). */\nexport function mountPropertyList<T extends PropertyDeclLike>(host: HTMLElement, decls: T[], opts: PropertyListOptions<T> = {}): PropertyListHandle {\n const changed = (): void => opts.onChange?.();\n const guard = dupGuard();\n const types = opts.types ?? PROPERTY_TYPES;\n const list = el(\"div\", \"set-list\");\n const keep = (parts: (HTMLElement | null)[] | undefined): HTMLElement[] =>\n (parts ?? []).filter((p): p is HTMLElement => p !== null);\n\n const noun = opts.noun ?? \"property\";\n const Noun = noun.charAt(0).toUpperCase() + noun.slice(1);\n const freeNames = opts.names === \"free\";\n\n const row = (p: T, i: number): HTMLElement => {\n const name = el(\"input\", \"field set-name\");\n name.type = \"text\"; name.placeholder = `${Noun} name`; name.value = p.name; name.spellcheck = false;\n if (freeNames) name.addEventListener(\"input\", () => { p.name = name.value; changed(); });\n else {\n name.dataset[\"tip\"] = PROPERTY_NAME_HINT;\n bindPropertyName(name, (v) => { p.name = v; changed(); }, { hint: PROPERTY_NAME_HINT });\n }\n guard.track(name);\n\n const type = el(\"select\", \"field set-type\");\n for (const [v, label] of types) type.append(option(v, label, v === p.type));\n type.addEventListener(\"change\", () => {\n p.type = type.value;\n delete p.default; // a default rarely survives a type change: the new type's holds\n if (p.type === \"enum\" || p.type === \"flags\") p.values ??= []; else delete p.values;\n if (p.type === \"quality\") p.stages ??= []; else delete p.stages;\n render(); changed();\n });\n\n // The default control is rebuilt in place when the values change, so a\n // new value becomes selectable as the default.\n let def = defaultControl(p, changed, opts);\n const refreshDefault = (): void => { const fresh = defaultControl(p, changed, opts); def.replaceWith(fresh); def = fresh; changed(); };\n\n const up = iconBtn(\"up\", \"Move up\", () => { if (moveItem(decls, i, -1)) { render(); changed(); } }, i === 0);\n const down = iconBtn(\"down\", \"Move down\", () => { if (moveItem(decls, i, 1)) { render(); changed(); } }, i === decls.length - 1);\n const del = iconBtn(\"close\", `Delete ${noun}`, () => { decls.splice(i, 1); render(); changed(); }, false, true);\n\n const details: HTMLElement[] = keep(opts.extraDetails?.(p, i));\n if (p.type === \"enum\" || p.type === \"flags\") details.push(labelled(\"Values\", tagChips(p, refreshDefault)));\n // A quality's ladder, IN ORDER: the chips carry movers because position is the meaning.\n if (p.type === \"quality\") {\n const note = el(\"p\", \"shell-stage-note\");\n const stages = stageChips(p, refreshDefault, {\n onRename: (from, to) => {\n if (p.default === from) p.default = to;\n const fresh = defaultControl(p, changed, opts); def.replaceWith(fresh); def = fresh;\n if (opts.onStageRename) opts.onStageRename(p, from, to); else changed();\n },\n onReorder: () => opts.onStageReorder?.(p, note),\n });\n details.push(labelled(\"Stages (in order)\", stages), note);\n }\n if (opts.purpose !== false) {\n const purpose = el(\"input\", \"field set-purpose\");\n purpose.type = \"text\"; purpose.placeholder = `What this ${noun} is for`; purpose.value = p.purpose ?? \"\";\n purpose.addEventListener(\"input\", () => {\n if (purpose.value.trim()) p.purpose = purpose.value; else delete p.purpose;\n changed();\n });\n details.push(labelled(\"Purpose\", purpose));\n }\n // Stamped with the declared name so \"Go to definition\" lands on the row (revealRow).\n return expandableRow({ line: [name, type, def, ...keep(opts.extraLine?.(p, i)), up, down, del], details, name: p.name });\n };\n\n const render = (): void => {\n guard.reset();\n list.replaceChildren();\n if (decls.length === 0) list.append(el(\"p\", \"empty\", opts.emptyText ?? \"No properties yet.\"));\n else decls.forEach((p, i) => list.append(row(p, i)));\n guard.check();\n };\n render();\n\n const add = el(\"button\", \"btn set-add\", opts.addLabel ?? \"+ Add property\");\n add.type = \"button\";\n add.addEventListener(\"click\", () => {\n decls.push(opts.newDecl ? opts.newDecl() : ({ name: \"\", type: types[0]?.[0] ?? \"string\", ...(opts.typed ? {} : { default: \"\" }) } as unknown as T));\n render(); changed(); focusNewRow(list);\n });\n host.append(list, add);\n\n return {\n firstDuplicate: () => guard.firstDuplicate(),\n firstIllegalName: () => (freeNames ? null : firstIllegalPropertyName(host)),\n // The Save gate takes both faults; the field's own rollover says which.\n firstInvalid: () => guard.firstDuplicate() ?? (freeNames ? null : firstIllegalPropertyName(host)),\n render,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/tooltip.ts","../src/icons.ts","../src/dom.ts","../src/settings.ts","../src/property-names.ts","../src/property-name-field.ts","../src/value-control.ts","../src/property-list.ts"],"names":["el","tip"],"mappings":";;;AA6BA,SAAS,SAAA,CAAU,MAAmB,IAAA,EAAoB;AACxD,EAAA,IAAA,CAAK,WAAA,GAAc,EAAA;AACnB,EAAA,MAAM,EAAA,GAAK,2BAAA;AACX,EAAA,IAAI,IAAA,GAAO,CAAA;AACX,EAAA,IAAI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AA,KAAA,CAAM,KAAA,EAAM;AAAA,EACd,CAAA;AACA,EAAA,MAAA,EAAO;AAEP,EAAA,MAAM,MAAM,EAAA,CAAG,QAAA,EAAU,aAAA,EAAe,IAAA,CAAK,YAAY,gBAAgB,CAAA;AACzE,EAAA,GAAA,CAAI,IAAA,GAAO,QAAA;AACX,EAAA,GAAA,CAAI,gBAAA,CAAiB,SAAS,MAAM;AAClC,IAAA,KAAA,CAAM,IAAA,CAAK,IAAA,CAAK,OAAA,GAAU,IAAA,CAAK,OAAA,KAAa,EAAE,IAAA,EAAM,EAAA,EAAI,IAAA,EAAM,KAAA,CAAM,CAAC,IAAI,CAAC,CAAA,IAAK,QAAA,EAAU,GAAI,IAAA,CAAK,KAAA,GAAQ,EAAC,GAAI,EAAE,OAAA,EAAS,EAAA,EAAG,EAAqB,CAAA;AAClJ,IAAA,MAAA,EAAO;AAAG,IAAA,OAAA,EAAQ;AAAG,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,EACvC,CAAC,CAAA;AACD,EAAA,IAAA,CAAK,MAAA,CAAO,MAAM,GAAG,CAAA;AAErB,EAAA,OAAO;AAAA,IACL,cAAA,EAAgB,MAAM,KAAA,CAAM,cAAA,EAAe;AAAA,IAC3C,gBAAA,EAAkB,MAAO,SAAA,GAAY,IAAA,GAAO,yBAAyB,IAAI,CAAA;AAAA;AAAA,IAEzE,YAAA,EAAc,MAAM,KAAA,CAAM,cAAA,OAAqB,SAAA,GAAY,IAAA,GAAO,yBAAyB,IAAI,CAAA,CAAA;AAAA,IAC/F;AAAA,GACF;AACF","file":"property-list.cjs","sourcesContent":["// ---------------------------------------------------------------------------\n// A single themed tooltip the family controls, replacing native `title`\n// rollovers: those are unstyled OS chrome and appear on the platform's slow\n// (~1s) delay, which is exactly the seam design-language section 4 (\"coherent\n// to the edges\") says not to leave showing.\n//\n// ONE floating bubble, document-DELEGATED: any element carrying a `data-tip`\n// attribute gets it, so a caller just sets `data-tip=\"...\"` anywhere and wires\n// nothing. The bubble anchors above the element (flipping below near the top\n// edge), uses our own snappy delay and the shared panel-enter motion.\n// `initTooltips()` is idempotent, so it is safe to call from more than one\n// place in an app that has several entry points.\n//\n// Lifted from Patterpad's patterpad-surface/web/tooltip.ts, which proved it,\n// with the one app-specific rule (suppressed in Writing View) generalised into\n// the `suppressed` option so the shell knows nothing about either app's modes.\n// ---------------------------------------------------------------------------\n\n// Bold markers: a producer wraps a span in these PRIVATE control chars (U+0002 STX / U+0003 ETX,\n// never present in user text) and the renderer turns it into a <strong>. Lets a data-tip bold part\n// of itself (a name, a \"VO:\" prefix) without any HTML, and each segment is still set via\n// textContent, so there is no injection risk from user content.\nconst B_OPEN = \"\\u0002\";\nconst B_CLOSE = \"\\u0003\";\n\n/** Wrap `s` so it renders bold inside a tooltip (see the marker note above). */\nexport function tipBold(s: string): string { return `${B_OPEN}${s}${B_CLOSE}`; }\n\n/** Render `text` into `host`, turning `\\u0002…\\u0003`-marked spans into <strong>; all set as text (safe). */\nfunction renderTip(host: HTMLElement, text: string): void {\n host.textContent = \"\";\n const re = /\\u0002([^\\u0003]*)\\u0003/g;\n let last = 0;\n let m: RegExpExecArray | null;\n while ((m = re.exec(text)) !== null) {\n if (m.index > last) host.append(text.slice(last, m.index));\n const strong = document.createElement(\"strong\");\n strong.textContent = m[1] ?? \"\";\n host.append(strong);\n last = m.index + m[0].length;\n }\n if (last < text.length) host.append(text.slice(last));\n}\n\nexport interface TooltipOptions {\n /** Called before every show: return true to keep the bubble down. For a mode\n * that wants no chrome at all (Patterpad's Writing View). */\n suppressed?: () => boolean;\n}\n\nlet inited = false;\nlet checked = false; // the one-shot no-host warning below has been scheduled\nlet suppressed: (() => boolean) | undefined;\nconst SHOW_DELAY = 350; // ms - snappier than the OS title delay, slow enough not to flicker on pass-through\nconst EDGE = 6; // viewport inset so the bubble never touches the window edge\nconst GAP = 7; // px between the anchor and the bubble\n\nlet tip: HTMLDivElement | null = null;\nlet timer = 0;\nlet active: HTMLElement | null = null;\n/** The subject of a rect-anchored tip (see `tipAt`), when there is one. */\nlet activeKey: string | null = null;\n\nfunction ensureEl(): HTMLDivElement {\n if (tip) return tip;\n const el = document.createElement(\"div\");\n el.className = \"tooltip\";\n el.setAttribute(\"role\", \"tooltip\");\n el.hidden = true;\n document.body.appendChild(el);\n tip = el;\n return el;\n}\n\n/** A rectangle in VIEWPORT coordinates, for anchoring a tip to something that is\n * not a DOM element: a shape on a canvas, a run of text inside one. */\nexport interface TipRect { left: number; top: number; width: number; height: number }\n\nconst rectOf = (anchor: HTMLElement | TipRect): TipRect =>\n (anchor instanceof HTMLElement ? anchor.getBoundingClientRect() : anchor);\n\n/** Anchor the (already-visible, so measurable) bubble above the anchor, flipping below near the top. */\nfunction place(anchor: HTMLElement | TipRect): void {\n const t = ensureEl();\n const r = rectOf(anchor);\n const tr = t.getBoundingClientRect();\n let top = r.top - tr.height - GAP;\n if (top < EDGE) top = r.top + r.height + GAP; // not enough room above -> below\n let left = r.left + r.width / 2 - tr.width / 2;\n left = Math.max(EDGE, Math.min(left, window.innerWidth - tr.width - EDGE));\n t.style.left = `${Math.round(left)}px`;\n t.style.top = `${Math.round(top)}px`;\n}\n\nfunction show(anchor: HTMLElement): void {\n const text = anchor.dataset[\"tip\"];\n if (!text) return;\n paint(anchor, text);\n}\n\n/** Fill, place and reveal the bubble. The one path: both the delegated\n * `data-tip` route and `tipAt` end up here, so a canvas tip and a button tip\n * are the same bubble with the same look and the same motion. */\nfunction paint(anchor: HTMLElement | TipRect, text: string): void {\n if (suppressed?.()) return;\n const t = ensureEl();\n // A modal <dialog> (settings, a confirm) renders in the browser TOP LAYER, above every normal-flow\n // element whatever its z-index. If the anchor is inside one, move the bubble into that dialog so it\n // shares the top layer; otherwise keep it on <body>. Re-parenting per show also moves it back out\n // once the modal closes.\n const host: HTMLElement = (anchor instanceof HTMLElement ? anchor.closest<HTMLElement>(\"dialog[open]\") : null)\n ?? document.body;\n if (t.parentElement !== host) host.appendChild(t);\n active = anchor instanceof HTMLElement ? anchor : null;\n renderTip(t, text);\n t.hidden = false;\n t.classList.remove(\"show\"); void t.offsetWidth; // restart the enter animation\n place(anchor); // measure + position now it has content + is visible\n t.classList.add(\"show\");\n}\n\nfunction hide(): void {\n if (timer) { window.clearTimeout(timer); timer = 0; }\n active = null;\n activeKey = null;\n if (tip) { tip.hidden = true; tip.classList.remove(\"show\"); }\n}\n\nfunction schedule(anchor: HTMLElement): void {\n if (anchor === active) return;\n if (timer) window.clearTimeout(timer);\n timer = window.setTimeout(() => show(anchor), SHOW_DELAY);\n}\n\n/**\n * Show a tip for something that has no DOM node of its own: a card on a canvas,\n * a zone, a pin. The caller says WHERE (a viewport rectangle) and WHAT, and\n * identifies the subject with `key`.\n *\n * The key is what makes this usable from a canvas. Re-calling with the same key\n * re-places the bubble WITHOUT restarting the delay, so a tip can follow its\n * shape while the camera moves; calling with a different key starts the wait\n * again, so sweeping the pointer across a dense board does not strobe.\n *\n * The bubble is ordinary DOM, so it holds its size whatever the canvas is\n * zoomed to. That is the point of it: the label it stands in for is the one\n * thing on a canvas that must not shrink with everything else.\n */\nexport function tipAt(key: string, rect: TipRect, text: string): void {\n if (key === activeKey) {\n // Already up for this subject: move it, do not re-animate it.\n if (tip && !tip.hidden) { renderTip(tip, text); place(rect); }\n return;\n }\n // A different subject: down first, then wait again. Leaving the old bubble up\n // during the wait would put one card's name over another card, which is worse\n // than no name at all - and it matches the delegated route, where leaving an\n // element hides the tip before the next one is scheduled.\n hide();\n activeKey = key;\n timer = window.setTimeout(() => { timer = 0; paint(rect, text); }, SHOW_DELAY);\n}\n\n/** Take any tip down: the pointer has left, or a gesture has started. */\nexport function hideTip(): void { hide(); }\n\n/**\n * Mount the renderer because something is about to speak the grammar.\n *\n * The themed tooltip is not a feature a host turns on; it is the renderer for a grammar the shell's own\n * components already speak, and `data-tip` with nothing listening draws NOTHING - not the themed\n * bubble, not the platform one. That silence cost Patterpad two releases of a pin with no tooltip, and\n * cost it again when a `title` was converted to `data-tip` in a window that had never mounted this.\n *\n * So `el` calls this whenever it sets a tip. Mounting a delegated listener is the same class of act as\n * `confirmDialog` appending to `document.body`, which this package has always done.\n */\nexport function ensureTooltipHost(): void { initTooltips(); }\n\n/**\n * One deferred check that an app writing `data-tip` ITSELF has a host, warning if not.\n *\n * `ensureTooltipHost` covers anything built through `el`. It cannot cover a `data-tip` written straight\n * into markup or set by hand, which is the case that leaves a whole window of dead tips with no shell\n * component involved - so that one gets a warning rather than silence. Scheduled once, after the\n * current task, so it sees a rendered document rather than an empty one.\n */\nexport function checkTooltipHost(): void {\n if (checked) return;\n checked = true;\n setTimeout(() => {\n if (inited || typeof document === \"undefined\") return;\n if (document.querySelector(\"[data-tip]\")) {\n console.warn(\"app-shell: something set `data-tip` but no tooltip host is mounted, so those rollovers will not draw. Call initTooltips() once per window.\");\n }\n }, 0);\n}\n\nconst tipAncestor = (n: EventTarget | null): HTMLElement | null =>\n (n instanceof Element ? n.closest<HTMLElement>(\"[data-tip]\") : null);\n\n/**\n * Wire the one delegated controller. Mounting happens once; OPTIONS do not.\n *\n * An explicit call is always authoritative about its options, even after something else has already\n * mounted the listener. That ordering is not hypothetical, and Storyletter caught it before it shipped:\n * once components self-mount (see `ensureTooltipHost`), a host's own\n * `initTooltips({ suppressed })` could land second and be dropped by an early return, silently taking\n * a rule like \"no tooltips in Writing View\" with it. Nothing would fail and nothing would show.\n *\n * Components therefore call this with NO arguments: they mount the renderer without claiming the\n * options, and the host keeps the last word on behaviour.\n */\nexport function initTooltips(opts: TooltipOptions = {}): void {\n if (opts.suppressed !== undefined) suppressed = opts.suppressed; // an explicit call always wins\n if (inited) return;\n inited = true;\n\n document.addEventListener(\"pointerover\", (e) => {\n const el = tipAncestor(e.target);\n if (el) schedule(el);\n });\n document.addEventListener(\"pointerout\", (e) => {\n const el = tipAncestor(e.target);\n if (!el) return;\n const to = (e as PointerEvent).relatedTarget;\n if (to instanceof Node && el.contains(to)) return; // still inside the same anchor\n hide();\n });\n // Keyboard parity: reveal on focus, dismiss on blur.\n document.addEventListener(\"focusin\", (e) => { const el = tipAncestor(e.target); if (el) schedule(el); });\n document.addEventListener(\"focusout\", () => hide());\n // It's ANCHORED (not cursor-following), so anything that moves the layout or context dismisses it.\n document.addEventListener(\"pointerdown\", () => hide(), true);\n document.addEventListener(\"scroll\", () => { if (active) hide(); }, true);\n document.addEventListener(\"keydown\", (e) => { if (e.key === \"Escape\") hide(); });\n window.addEventListener(\"blur\", () => hide());\n}\n","// ---------------------------------------------------------------------------\n// The family's icon vocabulary.\n//\n// An icon is a WORD. Two apps in one suite spelling \"close\" differently is the\n// same fault as calling one thing a scene here and a chapter there, and it is\n// harder to notice because nobody reads glyphs, they just feel wrong. This\n// module exists so that no app ever types a codepoint again: it asks for\n// `iconNode(\"close\")` and gets whatever the family has agreed that means.\n//\n// The evidence that it was needed, gathered 2026-08-09 across both apps:\n// Patterpad spelled close as a cross twelve times, Storyletter used the same\n// cross once and a multiplication sign twice, in one window, and a comment\n// bubble had just been invented from scratch with nothing to check it against.\n//\n// DRAWN, not typed (design-language.md section 4, \"Icons are drawn, and so are\n// separators\", 2026-09-16). The first cut of this table was Unicode glyphs,\n// which render from whatever symbol font the OS has, so weight, baseline and\n// optical size drifted per character and per platform. The vocabulary is now\n// one drawn set: Lucide, vendored below as inline SVG strings on one 24-unit\n// grid at one stroke weight. The words did not change; what they draw did.\n//\n// Lucide 1.46.0 (lucide-static), ISC licence.\n// https://lucide.dev / https://cdn.jsdelivr.net/npm/lucide-static@1.46.0/icons/<name>.svg\n// Fetched 2026-09-16. The chosen decision record is\n// patterkit/design/ui-review-2026-09/07c-track-c-icon-sets-notes.md.\n//\n// STROKE. The family draws icons at 14px inside its small square buttons and\n// wants a 1.5px rendered stroke against Inter at that size (Inter Regular's\n// stems are about 1.3px there). Lucide's native stroke is 2 on a 24 grid,\n// which is 2 x 14/24 = 1.17px at 14px, a shade light. So the root of every\n// stroke icon carries stroke-width=\"2.571\": 2.571 x 14/24 = 1.5. A caller\n// drawing at another size gets the proportional weight (12px: 1.29px; 16px:\n// 1.71px), which is what one drawn set means. Filled shapes (the discs) carry\n// fill=\"currentColor\" and no stroke at all.\n//\n// Every icon is `currentColor`, so it takes the colour of the button it sits\n// in, and none of the strings carries width/height: the size is the caller's\n// (`iconNode(name, size)`), so an icon can never be the wrong size somewhere\n// because a CSS rule failed to reach it.\n//\n// Adding one: it needs a MEANING, not a picture. \"A downward chevron\" is not an\n// entry; \"expand this\" is. If two callers want the same picture for two\n// meanings, that is two entries, and one of them will be wrong later.\n// ---------------------------------------------------------------------------\n//\n// Lucide licence (the icons vendored in this file):\n//\n// ISC License\n// Copyright (c) 2026 Lucide Icons and Contributors\n//\n// Permission to use, copy, modify, and/or distribute this software for any\n// purpose with or without fee is hereby granted, provided that the above\n// copyright notice and this permission notice appear in all copies.\n//\n// THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF\n// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN\n// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n//\n// Portions of Lucide (among those used here: arrow-down, arrow-left,\n// arrow-right, arrow-up, check, chevron-down, chevron-left, chevron-right,\n// circle, lock, plus, search, x) derive from Feather, MIT,\n// Copyright (c) 2013-present Cole Bemis. See LICENSES.md.\n// ---------------------------------------------------------------------------\n\n/**\n * The typed glyphs the vocabulary used to draw.\n *\n * @deprecated Since the move to drawn icons (design-language.md, \"Icons are\n * drawn\"). Kept byte-for-byte so a consumer still doing\n * `textContent = icon.close` keeps working while each app moves; a new call\n * site uses `iconNode(name)` (a node to append) or `iconHtml(name)` (for an\n * innerHTML build). The names are the same in all three. Removed once both\n * apps have moved.\n */\nexport const icon = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. Patterpad's, twelve times over. */\n close: \"✕\",\n /** The overflow menu on a document or a row: \"more about this\". */\n more: \"⋯\",\n /** Collapsed disclosure, pointing at what would open. */\n collapsed: \"▸\",\n /** Expanded disclosure. */\n expanded: \"▾\",\n /** A dropdown's affordance, where it is not a real <select>. */\n dropdown: \"▾\",\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. */\n back: \"‹\",\n /** Forward / next. */\n forward: \"›\",\n /** Up one, in a list. */\n up: \"↑\",\n /** Down one. */\n down: \"↓\",\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. */\n tick: \"✓\",\n /** Somebody else holds this: the version-control lock. */\n locked: \"⊘\",\n /** Read-only on disk with no other holder: the resting state of everything\n * in a lock-based working copy that nobody has checked out yet. */\n readOnly: \"○\",\n /** YOU hold this one: checked out / opened by the current user, still yours to\n * edit. Shares its glyph with `note`, which the table permits: an entry is a\n * MEANING, and two meanings may draw the same shape. */\n checkedOut: \"✎\",\n /** Tracked, with local changes not yet committed. */\n modified: \"●\",\n /** Not in version control yet: new since the last commit. */\n untracked: \"+\",\n /** Something needs attention but is not fatal. */\n warning: \"‼\",\n /** A live thing: the running position, an active marker. */\n dot: \"●\",\n /** Play, in the sense of \"run this\". */\n play: \"▶\",\n /** Start the thing again from the top: a play session, a sweep. Named for the\n * act, not the arrow, which is the table's rule. */\n restart: \"⟲\",\n /** The three ways a collection can be shown. Named by what you get rather than\n * by the glyph, so a second app can pick the same three without copying\n * somebody's taste in symbols. */\n viewCards: \"▦\",\n viewTable: \"☰\",\n viewNode: \"◈\",\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. */\n grip: \"⠿\",\n /** Add one of whatever this list holds. */\n add: \"+\",\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: the pencil. Both apps had chosen it independently,\n * which is the happiest way for a vocabulary entry to arrive. */\n note: \"✎\",\n /** A comment thread. Speech, not a pencil: documentation states the reason,\n * comments are the conversation, and the two must never look alike. */\n comment: \"❝\",\n} as const;\n\n/**\n * Every word in the vocabulary. The 26 the glyph table had, plus the seven the\n * 2026-09 review found the apps drawing by hand with nothing to check against,\n * and the two the 2026-10 Patterpad review found the same way (`copy`,\n * `speaker`).\n */\nexport type IconName =\n | keyof typeof icon\n /** History back, the topbar's quiet arrow pair (nav-history.ts). An ARROW,\n * not a chevron: a chevron says structure, an arrow says time (the author's\n * ruling, 2026-08-28). Added beside `arrowRight` so the pair share a set. */\n | \"arrowLeft\"\n /** History forward; also the one honest \"go there\" arrow where a link used\n * to carry a typed one. */\n | \"arrowRight\"\n /** Connect to a server, a live link, a running game. */\n | \"connect\"\n /** Search. */\n | \"search\"\n /** Keep this window on top (tool-window-web.ts). */\n | \"pin\"\n /** Settings. */\n | \"settings\"\n /** Record. The icon is the DISC; painting it in the danger colour while\n * recording is the caller's job, through the button's own colour. */\n | \"record\"\n /** Copy this to the clipboard. The confirmation is `tick`, shown by the\n * caller while `copyWithFeedback` holds `.copied` on the button. */\n | \"copy\"\n /** Sound: play with audio, a table read. The act of hearing, not a volume\n * control. */\n | \"speaker\";\n\n// The two roots every drawing shares. Kept as constants so the table below is\n// the inner elements only, which is what a reader compares against lucide.dev.\nconst STROKE = '<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.571\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\">';\nconst FILL = '<svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\">';\nconst stroked = (inner: string): string => `${STROKE}${inner}</svg>`;\nconst filled = (inner: string): string => `${FILL}${inner}</svg>`;\n\n// The three discs are the one drawing in the table that is not Lucide's own\n// element as shipped: Lucide's `circle` is an r=10 outline that fills its box,\n// which at badge size beside a row title is a blot, so the disc is drawn at a\n// smaller radius with the fill forced (the same amount of hand-drawing as the\n// legacy noteFilled below, and the decision record's stated cost). `modified`\n// and `dot` share it, as their glyphs did; `record` is larger because a record\n// button is meant to fill more of its box.\nconst DISC = filled('<circle cx=\"12\" cy=\"12\" r=\"6\"/>');\nconst DISC_LARGE = filled('<circle cx=\"12\" cy=\"12\" r=\"9\"/>');\n\n/**\n * The drawings, by word. Each is a complete `<svg viewBox=\"0 0 24 24\" …>`\n * string with no width/height (see `iconNode` / `iconHtml`, which size it).\n * The Lucide name each derives from is on the entry, so a reviewer can put\n * the two side by side.\n */\nconst DRAWN: Record<IconName, string> = {\n // --- dismissing and revealing ---------------------------------------------\n /** Close a panel, a dialog, a popover. (x) */\n close: stroked('<path d=\"M18 6 6 18\"/><path d=\"m6 6 12 12\"/>'),\n /** The overflow menu on a document or a row: \"more about this\". (ellipsis) */\n more: stroked('<circle cx=\"12\" cy=\"12\" r=\"1\"/><circle cx=\"19\" cy=\"12\" r=\"1\"/><circle cx=\"5\" cy=\"12\" r=\"1\"/>'),\n /** Collapsed disclosure, pointing at what would open. (chevron-right) */\n collapsed: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Expanded disclosure. (chevron-down) */\n expanded: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n /** A dropdown's affordance, where it is not a real <select>. (chevron-down) */\n dropdown: stroked('<path d=\"m6 9 6 6 6-6\"/>'),\n\n // --- moving through things ------------------------------------------------\n /** Back / previous, in a breadcrumb or a stepper. (chevron-left) */\n back: stroked('<path d=\"m15 18-6-6 6-6\"/>'),\n /** Forward / next. (chevron-right) */\n forward: stroked('<path d=\"m9 18 6-6-6-6\"/>'),\n /** Up one, in a list. (arrow-up) */\n up: stroked('<path d=\"m5 12 7-7 7 7\"/><path d=\"M12 19V5\"/>'),\n /** Down one. (arrow-down) */\n down: stroked('<path d=\"M12 5v14\"/><path d=\"m19 12-7 7-7-7\"/>'),\n /** History back. (arrow-left) */\n arrowLeft: stroked('<path d=\"m12 19-7-7 7-7\"/><path d=\"M19 12H5\"/>'),\n /** History forward; \"go there\". (arrow-right) */\n arrowRight: stroked('<path d=\"M5 12h14\"/><path d=\"m12 5 7 7-7 7\"/>'),\n\n // --- state ----------------------------------------------------------------\n /** Done, applied, agreed. (check) */\n tick: stroked('<path d=\"M20 6 9 17l-5-5\"/>'),\n /** Somebody else holds this: the version-control lock. (lock) */\n locked: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/>'),\n /** Read-only on disk with no other holder. (lock-open) An open lock rather\n * than a struck-out eye: this state is not a prohibition. Nobody holds the\n * file, saving checks it out, and it is the resting state of everything the\n * author has not touched yet under a lock-based VCS. eye-off would say \"you\n * cannot\", which is false here; the open lock says \"not held\", beside\n * `locked`, which is the shut one, so the two read as a pair. */\n readOnly: stroked('<rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 9.9-1\"/>'),\n /** YOU hold this one: checked out, still yours to edit. (pencil) */\n checkedOut: stroked('<path d=\"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z\"/><path d=\"m15 5 4 4\"/>'),\n /** Tracked, with local changes not yet committed. (a disc; see DISC) */\n modified: DISC,\n /** Not in version control yet: new since the last commit. (plus) */\n untracked: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Something needs attention but is not fatal. (triangle-alert) */\n warning: stroked('<path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\"/><path d=\"M12 9v4\"/><path d=\"M12 17h.01\"/>'),\n /** A live thing: the running position, an active marker. (a disc) */\n dot: DISC,\n /** Play, in the sense of \"run this\". (play) */\n play: stroked('<path d=\"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z\"/>'),\n /** Start the thing again from the top: a play session, a sweep. (rotate-ccw) */\n restart: stroked('<path d=\"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8\"/><path d=\"M3 3v5h5\"/>'),\n /** The three ways a collection can be shown, named by what you get. */\n /** Cards. (layout-grid) */\n viewCards: stroked('<rect width=\"7\" height=\"7\" x=\"3\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"3\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"14\" y=\"14\" rx=\"1\"/><rect width=\"7\" height=\"7\" x=\"3\" y=\"14\" rx=\"1\"/>'),\n /** A table. (rows-3: a ruled box, which is a table. `list` is bullets, and\n * the view is not a list.) */\n viewTable: stroked('<rect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"/><path d=\"M21 9H3\"/><path d=\"M21 15H3\"/>'),\n /** A node graph. (waypoints: four nodes on edges reads as a graph.\n * `git-fork` reads as version control, which this family also draws, and\n * a picture that means two things is the fault this table exists to\n * prevent.) */\n viewNode: stroked('<path d=\"m10.586 5.414-5.172 5.172\"/><path d=\"m18.586 13.414-5.172 5.172\"/><path d=\"M6 12h12\"/><circle cx=\"12\" cy=\"20\" r=\"2\"/><circle cx=\"12\" cy=\"4\" r=\"2\"/><circle cx=\"20\" cy=\"12\" r=\"2\"/><circle cx=\"4\" cy=\"12\" r=\"2\"/>'),\n /** Record: the disc, in whatever colour the button is. (a disc; see DISC_LARGE) */\n record: DISC_LARGE,\n /** Sound: play with audio. (volume-2: the cone and two waves. Patterpad's\n * hand-drawn one had a single wave, which at 14px reads as quiet rather\n * than as sound.) */\n speaker: stroked('<path d=\"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z\"/><path d=\"M16 9a5 5 0 0 1 0 6\"/><path d=\"M19.364 18.364a9 9 0 0 0 0-12.728\"/>'),\n\n // --- handling -------------------------------------------------------------\n /** The drag grip on a reorderable row. (grip-vertical) */\n grip: stroked('<circle cx=\"9\" cy=\"12\" r=\"1\"/><circle cx=\"9\" cy=\"5\" r=\"1\"/><circle cx=\"9\" cy=\"19\" r=\"1\"/><circle cx=\"15\" cy=\"12\" r=\"1\"/><circle cx=\"15\" cy=\"5\" r=\"1\"/><circle cx=\"15\" cy=\"19\" r=\"1\"/>'),\n /** Add one of whatever this list holds. (plus) */\n add: stroked('<path d=\"M5 12h14\"/><path d=\"M12 5v14\"/>'),\n /** Copy this to the clipboard. (copy: the front sheet whole, the back\n * sheet showing round two of its sides) */\n copy: stroked('<rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\"/><path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\"/>'),\n /** Connect: to a server, a live link, a running game. (plug) */\n connect: stroked('<path d=\"M12 22v-5\"/><path d=\"M15 8V2\"/><path d=\"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z\"/><path d=\"M9 8V2\"/>'),\n /** Search. (search) */\n search: stroked('<path d=\"m21 21-4.34-4.34\"/><circle cx=\"11\" cy=\"11\" r=\"8\"/>'),\n /** Keep this window on top. (pin) */\n pin: stroked('<path d=\"M12 17v5\"/><path d=\"M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z\"/>'),\n /** Settings. (settings) */\n settings: stroked('<path d=\"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/>'),\n\n // --- annotation -----------------------------------------------------------\n /** Documentation notes: a document with lines on it. (file-text) The glyph\n * table drew a pencil and shared it with `checkedOut`; the drawn set gives\n * the two meanings two shapes, and notes get the document, which is what\n * the shell's own noteFilled/noteOutline pair had always drawn. */\n note: stroked('<path d=\"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z\"/><path d=\"M14 2v5a1 1 0 0 0 1 1h5\"/><path d=\"M10 9H8\"/><path d=\"M16 13H8\"/><path d=\"M16 17H8\"/>'),\n /** A comment thread. Speech, not a document: documentation states the\n * reason, comments are the conversation, and the two must never look\n * alike. (message-square) */\n comment: stroked('<path d=\"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z\"/>'),\n};\n\n/**\n * The drawings as strings, by word, for a caller that builds markup itself.\n * Prefer `iconHtml(name, size)`, which sizes it; these carry no width/height.\n *\n * Two legacy entries ride along unchanged: `noteFilled` and `noteOutline`, the\n * has-notes / no-notes pair Patterpad drew on a 16-unit grid before the set\n * existed. They are sized in the markup (13px) and on their own grid, so they\n * are NOT part of the vocabulary above and `iconNode` does not know them; no\n * app uses them today. They stay until a 24-grid pair replaces them, because\n * their two-state meaning (there are notes / there are none) has no Lucide\n * shape, and re-weighting the 16-grid drawing to the family stroke merges its\n * text lines.\n */\nexport const iconSvg = {\n ...DRAWN,\n /** A document with lines: notes exist on this thing. (legacy, 16 grid) */\n noteFilled: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"currentColor\" fill-rule=\"evenodd\" aria-hidden=\"true\"><path d=\"M3.4 1.4h5.3L12.6 5.3v8.1a1.2 1.2 0 0 1-1.2 1.2H3.4a1.2 1.2 0 0 1-1.2-1.2V2.6A1.2 1.2 0 0 1 3.4 1.4ZM4.9 6.8h6.2v1.1H4.9Zm0 2.1h6.2v1.1H4.9Zm0 2.1h3.7v1.1H4.9Z\"/></svg>',\n /** The same document, empty: nothing written here yet. (legacy, 16 grid) */\n noteOutline: '<svg viewBox=\"0 0 16 16\" width=\"13\" height=\"13\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.1\" stroke-linejoin=\"round\" stroke-linecap=\"round\" aria-hidden=\"true\"><path d=\"M3.4 2h4.9l3.9 3.9v7.5a1 1 0 0 1-1 1H3.4a1 1 0 0 1-1-1V3a1 1 0 0 1 1-1Z\"/><path d=\"M8.3 2.2v3.8h3.8\"/><path d=\"M4.9 8h6.2M4.9 10h6.2M4.9 12h3.7\" stroke-width=\"0.95\"/></svg>',\n} as const;\n\nexport type IconSvgName = keyof typeof iconSvg;\n\n/** Every word, in table order, for a test or a gallery to walk. */\nexport const ICON_NAMES = Object.keys(DRAWN) as IconName[];\n\n/** The default size: 14px, the family's icon inside its small square button. */\nexport const ICON_SIZE = 14;\n\n/**\n * The drawing as markup with its size set, for a caller building innerHTML.\n * `data-icon` carries the word, so a stylesheet or a test can find it.\n */\nexport function iconHtml(name: IconName, size = ICON_SIZE): string {\n return DRAWN[name].replace(\"<svg \", `<svg width=\"${size}\" height=\"${size}\" data-icon=\"${name}\" `);\n}\n\n// One parsed template per word, filled on first use; every call clones it, so\n// the string is parsed once per window and each caller gets its own node.\nconst templates = new Map<IconName, SVGSVGElement>();\n\n/**\n * The drawing as a fresh SVG node, sized. Append it where the glyph used to be\n * set as text; it is `aria-hidden`, so the button's accessible name stays the\n * button's (`aria-label` / `data-tip`), as it always had to.\n */\nexport function iconNode(name: IconName, size = ICON_SIZE): SVGSVGElement {\n let tpl = templates.get(name);\n if (!tpl) {\n const holder = document.createElement(\"template\");\n holder.innerHTML = DRAWN[name];\n tpl = holder.content.firstElementChild as SVGSVGElement;\n tpl.setAttribute(\"data-icon\", name);\n templates.set(name, tpl);\n }\n const node = tpl.cloneNode(true) as SVGSVGElement;\n node.setAttribute(\"width\", String(size));\n node.setAttribute(\"height\", String(size));\n return node;\n}\n\n// The glyph table, reversed, so a legacy call site that still hands the shell\n// a typed character (\"✕\", \"↑\") draws the word it stood for. Where two words\n// shared a glyph the first in table order wins, which is fine: the picture was\n// the same either way. Goes when `icon` does.\nconst BY_GLYPH = new Map<string, IconName>();\nfor (const [name, glyph] of Object.entries(icon) as [IconName, string][]) {\n if (!BY_GLYPH.has(glyph)) BY_GLYPH.set(glyph, name);\n}\n\n/** The word a deprecated glyph stood for, or undefined for any other string. */\nexport function iconNameOfGlyph(glyph: string): IconName | undefined {\n return BY_GLYPH.get(glyph);\n}\n\n/** Whether a string is a word in the vocabulary. */\nexport function isIconName(s: string): s is IconName {\n return Object.prototype.hasOwnProperty.call(DRAWN, s);\n}\n","// ---------------------------------------------------------------------------\n// `el`: the tiny tag-typed element factory both apps build their imperative,\n// idempotent views with.\n//\n// A SUPERSET of the two apps' prior signatures, so neither rewrites call sites:\n// - Patterpad: el(tag, cls?, text?) (positional)\n// - Storylet Studio: el(tag, { className, text, ... }, ...kids) (options bag)\n// A string second argument is the className; an object is the props bag; string\n// children become text nodes. So `el(\"div\", \"c\", \"t\")` and\n// `el(\"div\", { className: \"c\" }, \"t\")` produce identical DOM.\n// ---------------------------------------------------------------------------\n\nimport { ensureTooltipHost, checkTooltipHost } from \"./tooltip.js\";\nimport { iconNode, iconNameOfGlyph, isIconName, type IconName } from \"./icons.js\";\n\nexport type Child = Node | string | null | undefined;\n\nexport interface ElProps {\n className?: string;\n text?: string;\n /** A NATIVE rollover. Prefer `tip`: `title` is OS chrome on the platform's own\n * slow delay, which is the seam the themed tooltip exists to close. */\n title?: string;\n /** A themed rollover (`data-tip`, picked up by the delegated controller that\n * `initTooltips()` wires). Also the accessible name, since the elements that\n * want one are usually icon buttons with no text of their own. */\n tip?: string;\n onClick?: (event: MouseEvent) => void;\n}\n\nexport function el<K extends keyof HTMLElementTagNameMap>(\n tag: K,\n classNameOrProps?: string | ElProps,\n ...children: Child[]\n): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n const props: ElProps = typeof classNameOrProps === \"string\"\n ? { className: classNameOrProps }\n : classNameOrProps ?? {};\n if (props.className) node.className = props.className;\n if (props.text !== undefined && props.text !== null) node.textContent = props.text;\n if (props.title !== undefined) node.title = props.title;\n if (props.tip !== undefined) {\n node.dataset[\"tip\"] = props.tip;\n node.setAttribute(\"aria-label\", props.tip);\n // Setting a tip mounts the renderer. Without this, `data-tip` draws nothing at all in a window whose\n // host never called `initTooltips()`, which is a silent failure rather than a degraded one. No\n // options passed: the host stays authoritative about behaviour (see tooltip.ts).\n ensureTooltipHost();\n }\n if (props.onClick) node.addEventListener(\"click\", props.onClick as EventListener);\n for (const child of children) {\n if (child === null || child === undefined) continue;\n node.append(child);\n }\n checkTooltipHost(); // one-shot: warns if the APP wrote data-tip and nothing mounted a host\n return node;\n}\n\n/** A small square icon button (the move/delete controls list editors share).\n * Its rollover is the THEMED one (`data-tip`), so an app that has called\n * `initTooltips()` gets our bubble rather than the platform's.\n *\n * `name` is a word from the vocabulary (\"up\", \"close\"), drawn at 14px. A\n * typed glyph from the deprecated `icon` table (\"↑\", \"✕\") is accepted for\n * now and drawn as the word it stood for, so an app that has not moved its\n * call sites yet still gets the drawn set; any other string is set as text,\n * which is the old behaviour and on its way out. */\nexport function iconBtn(name: IconName | (string & {}), title: string, onClick: () => void, disabled = false, danger = false): HTMLButtonElement {\n const b = el(\"button\", `shell-icon${danger ? \" danger\" : \"\"}`);\n b.type = \"button\"; b.dataset[\"tip\"] = title; b.setAttribute(\"aria-label\", title);\n const word = isIconName(name) ? name : iconNameOfGlyph(name);\n if (word) b.append(iconNode(word)); else b.textContent = name;\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n}\n\n/** The sentence under a settings row: plain text, or nodes when it carries\n * markup (a `code` for a file name, a `b` for an option's name). */\nexport type FieldHint = string | Node | Array<string | Node>;\n\n/**\n * A captioned field, the family's settings row (the 2026-10 review, ruling C):\n * the caption on the left and the control inline beside it,\n * `<label class=\"shell-labelled\"><span class=\"shell-fieldcap\">…</span>control</label>`.\n *\n * The label is pointed at the field it captions, EXPLICITLY, and never at a button. A `<label>` with no\n * `for` forwards a click to its first labelable descendant, and buttons are labelable - so a caption\n * wrapped around a control containing buttons (`tagChips`, whose every chip carries a remove button)\n * turns every click on the row's dead space into a press of the FIRST button in it. That shipped:\n * patterkit/patter#44, where clicking a Game Data list value anywhere but its ✕ deleted the first value\n * in the list. Reported as \"clicking a value removes the wrong one\", which is not a wrong-index bug at\n * all - the click never reached the chip. The same rule makes a control GROUP safe to caption: a field\n * with its own Choose… or Import… button beside it (`.shell-inline`) captions the field, and the button\n * stays a button.\n *\n * When the control holds no labelable field (a chips editor with the add input removed, say), this is a\n * plain `<div>`: no caption behaviour is better than a caption that presses something.\n *\n * With a `hint`, the row and the sentence under it come back together in a `.shell-field`, the hint as\n * the field's description (`aria-describedby`) rather than inside the label, where it would become part\n * of the field's NAME and be read out every time it takes focus. Without one, the row is exactly what it\n * always was.\n */\nexport function labelled(label: string, control: HTMLElement, hint?: FieldHint): HTMLElement {\n const target = control.matches(\"input, select, textarea\")\n ? control\n : control.querySelector<HTMLElement>(\"input:not([type=button]):not([type=submit]), select, textarea\");\n const w = el(target ? \"label\" : \"div\", \"shell-labelled\");\n w.append(el(\"span\", \"shell-fieldcap\", label), control);\n if (target) {\n if (!target.id) target.id = uid();\n (w as HTMLLabelElement).htmlFor = target.id;\n }\n if (hint === undefined) return w;\n const note = el(\"p\", \"shell-fieldhint\");\n note.append(...(Array.isArray(hint) ? hint : [hint]));\n note.id = uid();\n if (target) {\n const by = target.getAttribute(\"aria-describedby\");\n target.setAttribute(\"aria-describedby\", by ? `${by} ${note.id}` : note.id);\n }\n return el(\"div\", \"shell-field\", w, note);\n}\n\nconst uid = (): string => `shell-f-${Math.random().toString(36).slice(2, 9)}`;\n\nexport interface LabelledToggleOptions {\n checked?: boolean;\n /** The sentence under the row: what turning it on does. */\n hint?: FieldHint;\n /** An option that only means something while the row above it is set (Patterpad's \"Embed source\n * language for debug\" under an IDs-only build): indented under that row with a rule, so it reads as\n * belonging to it rather than as a peer. */\n sub?: boolean;\n disabled?: boolean;\n /** Fired on every flip, with the new state. The input is handed back too, for a caller that reads it\n * on Save instead. */\n onChange?: (checked: boolean) => void;\n}\n\n/**\n * The settings toggle, `labelled`'s partner (ruling C): the caption on the left, the checkbox beside it\n * where any other row has its control, and the optional hint under the row. One shape in both apps, so\n * a switch in one app's settings looks like a switch in the other's. Clicking the caption flips it, as\n * the label is the checkbox's.\n *\n * Returns the outermost row (to append, hide, or indent) and the input (to read or listen to).\n */\nexport function labelledToggle(label: string, opts: LabelledToggleOptions = {}): { row: HTMLElement; input: HTMLInputElement } {\n const input = el(\"input\", \"shell-toggle-input\");\n input.type = \"checkbox\";\n input.checked = opts.checked ?? false;\n input.disabled = opts.disabled ?? false;\n const { onChange } = opts;\n if (onChange) input.addEventListener(\"change\", () => onChange(input.checked));\n const row = labelled(label, input, opts.hint);\n // On the caption-and-box line itself, whether or not a hint wraps it.\n (row.matches(\".shell-labelled\") ? row : row.querySelector(\".shell-labelled\"))?.classList.add(\"shell-toggle\");\n if (opts.sub) row.classList.add(\"shell-suboption\");\n return { row, input };\n}\n\n/** Swap item `i` with its neighbour `i + delta` IN PLACE (the up/down reorder list editors share);\n * a no-op when the target is out of range. Returns whether anything moved. */\nexport function moveItem<T>(arr: T[], i: number, delta: number): boolean {\n const j = i + delta;\n if (j < 0 || j >= arr.length) return false;\n [arr[i], arr[j]] = [arr[j]!, arr[i]!];\n return true;\n}\n\n/** The icon size inside a chip's remove / move buttons: the chip is set at\n * 0.76rem, so its controls draw smaller than a toolbar button's 14px. */\nconst CHIP_ICON = 10;\n\n/** A tag-style editor for a string-list field (an enum's allowed values / flags): removable chips + an\n * add input (Enter or \",\" commits; blank / duplicate ignored). Mutates `holder.values` in place (read\n * back on save). `onChange` fires after any add / remove so callers can refresh a dependent control. */\nexport function tagChips(holder: { values?: string[] }, onChange?: () => void): HTMLElement {\n const wrap = el(\"div\", \"shell-tags\");\n const input = el(\"input\", \"shell-tag-input\");\n // Sentence-cased like every other hint (the microcopy ruling, 2026-08-28):\n // lowercase fragments read as adrift, and a placeholder is a hint speaking.\n input.type = \"text\"; input.placeholder = \"Add value\"; input.spellcheck = false;\n const makeChip = (v: string): HTMLElement => {\n const chip = el(\"span\", \"shell-tag\", v);\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.values = (holder.values ?? []).filter((o) => o !== v); chip.remove(); onChange?.(); });\n chip.append(x);\n return chip;\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.values ?? []).includes(v)) { (holder.values ??= []).push(v); wrap.insertBefore(makeChip(v), input); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n for (const v of holder.values ?? []) wrap.append(makeChip(v));\n wrap.append(input);\n return wrap;\n}\n\n/** What `stageChips` tells its caller beyond \"something changed\". */\nexport interface StageChipsOptions {\n /**\n * A stage was renamed in place, `from` to `to`. Given, a rename calls this\n * INSTEAD of `onChange`: values are stored by stage name, so whoever knows\n * where those values live has to carry them, and doing it as one edit is\n * theirs to arrange. Absent, a rename is an ordinary change.\n */\n onRename?: (from: string, to: string) => void;\n /** The stages were reordered (after `onChange`): the one edit that changes\n * what every ordering gate means without changing any value. */\n onReorder?: () => void;\n}\n\n/**\n * An ORDERED chips editor for a string-list field whose order means something\n * (a quality's stages: `advance()` walks them, so 2 comes after 1): numbered\n * chips, each with move-earlier / move-later / remove, plus an add input\n * (Enter or \",\" commits; blank / duplicate ignored). A stage's name renames\n * in place when clicked (Enter or blur commits, Escape cancels; blank, the same\n * name or another stage's is ignored). Mutates `holder.stages` in place;\n * `onChange` fires after any add / move / remove, and after a rename unless\n * `opts.onRename` takes it.\n *\n * Patterpad's, lifted (ui-review-2026-09, finding 3); Storyletter had been\n * faking it with `tagChips` over a `values` holder, which loses the order\n * controls. Same class family as `tagChips` (`.shell-tags`), so it is styled by\n * settings.css already.\n */\nexport function stageChips(holder: { stages?: string[] }, onChange?: () => void, opts: StageChipsOptions = {}): HTMLElement {\n const wrap = el(\"div\", \"shell-tags shell-stages\");\n const input = el(\"input\", \"shell-tag-input\");\n input.type = \"text\"; input.placeholder = \"Add stage\"; input.spellcheck = false;\n const control = (name: IconName, tip: string, disabled: boolean, onClick: () => void): HTMLButtonElement => {\n const b = el(\"button\", \"shell-tag-x shell-tag-move\", iconNode(name, CHIP_ICON));\n b.type = \"button\"; b.dataset[\"tip\"] = tip; b.setAttribute(\"aria-label\", tip);\n b.disabled = disabled;\n b.addEventListener(\"click\", onClick);\n return b;\n };\n // The name, editable in place. A span with a button's role rather than a\n // <button>, so the chip's own controls stay its only buttons.\n const nameLabel = (chip: HTMLElement, v: string, i: number): HTMLElement => {\n const label = el(\"span\", \"shell-tag-label\", `${i + 1}. ${v}`);\n label.setAttribute(\"role\", \"button\"); label.tabIndex = 0;\n label.dataset[\"tip\"] = `Rename ${v}`;\n const edit = (): void => {\n const field = el(\"input\", \"shell-tag-input shell-stage-rename\");\n field.type = \"text\"; field.value = v; field.spellcheck = false;\n field.setAttribute(\"aria-label\", `Rename ${v}`);\n let done = false;\n const finish = (keep: boolean): void => {\n if (done) return;\n done = true;\n const to = field.value.trim();\n const stages = holder.stages ?? [];\n if (keep && to !== \"\" && to !== v && !stages.includes(to)) {\n stages[stages.indexOf(v)] = to;\n rebuild();\n if (opts.onRename) opts.onRename(v, to); else onChange?.();\n } else {\n rebuild();\n }\n };\n field.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\") { e.preventDefault(); finish(true); }\n else if (e.key === \"Escape\") { e.preventDefault(); e.stopPropagation(); finish(false); }\n });\n field.addEventListener(\"blur\", () => finish(true));\n label.replaceWith(field);\n chip.classList.add(\"editing\");\n field.focus(); field.select();\n };\n // The chips usually sit inside a <label> for the add input (`labelled`),\n // whose activation would move focus there and close the rename at once.\n label.addEventListener(\"click\", (e) => { e.preventDefault(); edit(); });\n label.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \" \") { e.preventDefault(); edit(); } });\n return label;\n };\n const moved = (): void => { rebuild(); onChange?.(); opts.onReorder?.(); };\n const rebuild = (): void => {\n for (const c of Array.from(wrap.children)) if (c !== input) c.remove();\n const stages = holder.stages ?? [];\n stages.forEach((v, i) => {\n const chip = el(\"span\", \"shell-tag\");\n chip.dataset[\"stage\"] = v;\n chip.append(\n nameLabel(chip, v, i),\n control(\"back\", `Move ${v} earlier`, i === 0, () => { if (moveItem(stages, i, -1)) moved(); }),\n control(\"forward\", `Move ${v} later`, i === stages.length - 1, () => { if (moveItem(stages, i, 1)) moved(); }),\n );\n const x = el(\"button\", \"shell-tag-x\", iconNode(\"close\", CHIP_ICON));\n x.type = \"button\"; x.dataset[\"tip\"] = `Remove ${v}`; x.setAttribute(\"aria-label\", `Remove ${v}`);\n x.addEventListener(\"click\", () => { holder.stages = (holder.stages ?? []).filter((o) => o !== v); rebuild(); onChange?.(); });\n chip.append(x);\n wrap.insertBefore(chip, input);\n });\n };\n const commit = (): void => {\n const v = input.value.trim();\n if (v && !(holder.stages ?? []).includes(v)) { (holder.stages ??= []).push(v); rebuild(); onChange?.(); }\n input.value = \"\";\n };\n input.addEventListener(\"keydown\", (e) => { if (e.key === \"Enter\" || e.key === \",\") { e.preventDefault(); commit(); } });\n input.addEventListener(\"blur\", commit);\n wrap.append(input);\n rebuild();\n return wrap;\n}\n\n// --- drag-to-reorder ---------------------------------------------------------\n// One drag at a time per window, shared across every wired list, so the\n// midpoint test knows what is being carried without a dataTransfer round trip.\nlet reorderDragId: string | null = null;\nconst clearDropMarks = (host: ParentNode): void =>\n host.querySelectorAll(\".drop-before, .drop-after\").forEach((e) => e.classList.remove(\"drop-before\", \"drop-after\"));\n\n/**\n * Make `el` a drag source and a drop target for HTML5 drag-to-reorder among\n * its siblings. While carried it wears `.dragging`; a hovered target wears\n * `.drop-before` or `.drop-after` by the midpoint test on `axis` (\"y\" for\n * rows, \"x\" for a wrapping grid); a drop calls `onMove(draggedId, before,\n * targetId)` and the caller reorders its model and re-renders.\n *\n * Storyletter's `wireCardDrag`, lifted (ui-review-2026-09, finding 30);\n * Patterpad's `wireSceneDrag` is the same idea fixed on \"y\". The marks are\n * classes only: the app draws them (Patterpad's `box-shadow: 0 -2px 0 0\n * var(--accent)` pair is the family's look).\n */\nexport function wireReorder(el: HTMLElement, id: string, axis: \"x\" | \"y\", onMove: (id: string, before: boolean, targetId: string) => void): void {\n el.draggable = true;\n el.dataset[\"reorderId\"] = id;\n const host = (): ParentNode => el.parentElement ?? el;\n el.addEventListener(\"dragstart\", (e) => {\n reorderDragId = id; el.classList.add(\"dragging\");\n if (e.dataTransfer) { e.dataTransfer.effectAllowed = \"move\"; e.dataTransfer.setData(\"text/plain\", id); }\n });\n el.addEventListener(\"dragend\", () => { reorderDragId = null; el.classList.remove(\"dragging\"); clearDropMarks(host()); });\n el.addEventListener(\"dragover\", (e) => {\n if (!reorderDragId || reorderDragId === id) return;\n e.preventDefault();\n if (e.dataTransfer) e.dataTransfer.dropEffect = \"move\";\n const r = el.getBoundingClientRect();\n const before = axis === \"y\" ? e.clientY < r.top + r.height / 2 : e.clientX < r.left + r.width / 2;\n clearDropMarks(host());\n el.classList.add(before ? \"drop-before\" : \"drop-after\");\n });\n el.addEventListener(\"dragleave\", () => el.classList.remove(\"drop-before\", \"drop-after\"));\n el.addEventListener(\"drop\", (e) => {\n e.preventDefault();\n const before = el.classList.contains(\"drop-before\");\n clearDropMarks(host());\n if (reorderDragId && reorderDragId !== id) onMove(reorderDragId, before, id);\n });\n}\n\n// --- metadata and breadcrumbs ---------------------------------------------------\n// \"Icons are drawn, and so are separators\" (design-language.md section 4,\n// 2026-09-16): metadata is never joined with \"·\" and a breadcrumb is never a\n// string with \"›\" in it. Both apps had been building exactly those strings\n// (ui-review-2026-09, marker A); these two helpers make the same lines as DOM,\n// with the separator drawn by CSS (controls.css) or by the icon vocabulary.\n\n/**\n * A metadata line: `parts` as spans in a flex row, separated by a drawn\n * 3px disc (a `::before` on every part after the first, in controls.css),\n * so `metaLine([\"6 runs\", \"200 max steps\", \"seed 4\"])` is what\n * \"6 runs · 200 max steps · seed 4\" used to be, without the typed dot.\n * Empty, null and undefined parts are skipped, so a caller can pass an\n * optional segment without branching.\n */\nexport function metaLine(parts: (string | Node | null | undefined)[]): HTMLElement {\n const row = el(\"span\", \"shell-meta\");\n for (const part of parts) {\n if (part === null || part === undefined || part === \"\") continue;\n const seg = el(\"span\", \"shell-meta-part\");\n seg.append(part);\n row.append(seg);\n }\n return row;\n}\n\nexport interface Crumb {\n label: string;\n /** Makes the crumb a button. Ignored on the last crumb, which is where the\n * reader already is. */\n onClick?: (event: MouseEvent) => void;\n}\n\n/**\n * A breadcrumb trail: each crumb a span, or a button when it carries\n * `onClick` and is not the last, with `iconNode(\"forward\", 12)` drawn between\n * them. `breadcrumb([\"Box\", \"Deck\", \"Card\"])` is what \"Box › Deck › Card\"\n * used to be; the chevrons are the family's own drawing, not a symbol-font\n * character.\n */\nexport function breadcrumb(parts: (string | Crumb)[]): HTMLElement {\n const trail = el(\"nav\", \"shell-crumbs\");\n trail.setAttribute(\"aria-label\", \"Where this is\");\n parts.forEach((part, i) => {\n const crumb: Crumb = typeof part === \"string\" ? { label: part } : part;\n const last = i === parts.length - 1;\n if (i > 0) {\n const sep = iconNode(\"forward\", 12);\n sep.classList.add(\"shell-crumb-sep\");\n trail.append(sep);\n }\n if (crumb.onClick && !last) {\n const b = el(\"button\", { className: \"shell-crumb shell-crumb-link\", text: crumb.label, onClick: crumb.onClick });\n b.type = \"button\";\n trail.append(b);\n } else {\n const s = el(\"span\", \"shell-crumb\", crumb.label);\n if (last) s.setAttribute(\"aria-current\", \"location\");\n trail.append(s);\n }\n });\n return trail;\n}\n","// ---------------------------------------------------------------------------\n// The shared settings surface: a native <dialog> with a left-rail of grouped\n// tabs and one panel per section (mountSettingsDialog), plus the list-editing\n// core those sections lean on (expandableRow, focusNewRow, dupGuard). The app\n// supplies the sections; each holds its own state and reports the first invalid\n// control so the Save gate can block + jump. Framework here, content in the app.\n//\n// Lifted from Patterpad's Project Settings (settings-list.ts + the inlined\n// dialog logic in its renderer), with neutral class names. Styling ships as\n// settings.css.\n// ---------------------------------------------------------------------------\n\nimport { el } from \"./dom.js\";\n\n// --- list-editing core --------------------------------------------------------\n\n/** A compact list row: a single `.set-rowline` (inline controls) plus, when\n * `details` are given, a disclosure that reveals a `.set-details` panel below,\n * so a list scans like a table with secondary fields tucked away. `name` is\n * what the row declares (a property's name, a field's), stamped on it as\n * `data-name` so `revealRow` can land on it. */\nexport function expandableRow(opts: { line: HTMLElement[]; details?: HTMLElement[]; name?: string }): HTMLElement {\n const row = el(\"div\", \"set-row\");\n if (opts.name !== undefined) row.dataset.name = opts.name;\n const line = el(\"div\", \"set-rowline\");\n if (opts.details && opts.details.length) {\n const details = el(\"div\", \"set-details\"); details.hidden = true;\n for (const d of opts.details) details.append(d);\n // The triangle is drawn by CSS off `.open` (a text glyph stays hairline-thin).\n const toggle = el(\"button\", \"set-expand\"); toggle.type = \"button\";\n // `data-tip`, not `title`: this package ships a themed tooltip and nothing\n // else in it raises an OS rollover. A lone `title` here would be the one\n // place a host's chrome broke character, and on the platform's own delay.\n toggle.dataset.tip = \"More\"; toggle.setAttribute(\"aria-label\", \"More\");\n toggle.setAttribute(\"aria-expanded\", \"false\");\n toggle.addEventListener(\"click\", () => {\n const open = details.hidden;\n details.hidden = !open;\n toggle.setAttribute(\"aria-expanded\", String(open));\n toggle.classList.toggle(\"open\", open);\n });\n line.append(toggle);\n opts.line.forEach((c) => line.append(c));\n row.append(line, details);\n } else {\n opts.line.forEach((c) => line.append(c));\n row.append(line);\n }\n return row;\n}\n\n/**\n * Land on one row of a list by the `name` it was built with: open its details\n * (an enum's values sit behind the disclosure, and they are usually what the\n * jump was for), bring it to the middle of its scroller, and light it for a\n * moment (`.set-row.landed` in settings.css). \"Go to definition\" in both apps\n * used to open the page a property is declared on and stop there, with the\n * declaration below the fold and nothing marking it (Storyletter, 2026-09-14).\n *\n * Returns false when no row carries the name, so a host whose page fills in\n * asynchronously can ask again on a later frame; asking again is the host's,\n * since only the host knows what opens on its own time. The row is matched by\n * reading the stamp rather than by an attribute selector, so a name needs no\n * escaping.\n */\nexport function revealRow(within: ParentNode, name: string): boolean {\n const row = [...within.querySelectorAll<HTMLElement>(\".set-row\")].find((r) => r.dataset.name === name);\n if (!row) return false;\n const toggle = row.querySelector<HTMLButtonElement>(\".set-rowline > .set-expand\");\n if (toggle && toggle.getAttribute(\"aria-expanded\") !== \"true\") toggle.click();\n const still = typeof matchMedia === \"function\" && matchMedia(\"(prefers-reduced-motion: reduce)\").matches;\n row.scrollIntoView({ block: \"center\", behavior: still ? \"auto\" : \"smooth\" });\n // Restarted, so landing on the same row twice lights it twice.\n row.classList.remove(\"landed\");\n void row.offsetWidth;\n row.classList.add(\"landed\");\n row.addEventListener(\"animationend\", () => row.classList.remove(\"landed\"), { once: true });\n return true;\n}\n\n/**\n * `revealRow`, retried over the next frames until the row exists or the tries\n * run out: for a page that fills in on its own time after a navigation. Both\n * apps hand-rolled this as `landOn` with the same twelve tries\n * (ui-review-2026-09, finding 29). Resolves true when it landed, false when it\n * gave up, and giving up is quiet: a name no page shows as a row is not a fault.\n */\nexport function revealRowWhenReady(within: ParentNode, name: string, tries = 12): Promise<boolean> {\n return new Promise((resolve) => {\n const attempt = (left: number): void => {\n if (revealRow(within, name)) { resolve(true); return; }\n if (left <= 0) { resolve(false); return; }\n requestAnimationFrame(() => attempt(left - 1));\n };\n attempt(tries);\n });\n}\n\n/** After a \"+ Add\" re-renders a list, bring the new (last) row into view and\n * focus its name input (`.set-name`, else the first input). */\nexport function focusNewRow(listEl: HTMLElement | null | undefined): void {\n const last = listEl?.lastElementChild;\n if (!(last instanceof HTMLElement)) return;\n last.scrollIntoView({ block: \"nearest\" });\n const name = last.querySelector<HTMLInputElement>(\"input.set-name\") ?? last.querySelector<HTMLInputElement>(\"input\");\n name?.focus();\n}\n\nexport interface DupGuard {\n /** Forget the previous render's inputs (call at the top of render). */\n reset(): void;\n /** Register a name input; `key` returns the comparison string (default the\n * input's value). Re-checks live on input. `also` = extra inputs that change the key. */\n track(input: HTMLInputElement, key?: () => string, also?: HTMLInputElement[]): void;\n /** Re-paint duplicates; true if any two non-blank keys collide. */\n check(): boolean;\n /** The first input currently flagged (after a fresh check), or null. */\n firstDuplicate(): HTMLInputElement | null;\n}\n\nconst DUP_MESSAGE = \"Another row already has this name.\";\n\n/** Case-insensitive duplicate-name detection: paints clashing inputs `.invalid`\n * and lets a Save gate block + jump via `firstDuplicate()`. */\nexport function dupGuard(): DupGuard {\n const items: Array<{ input: HTMLInputElement; key: () => string }> = [];\n const check = (): boolean => {\n const counts = new Map<string, number>();\n for (const it of items) { const k = it.key().trim().toLowerCase(); if (k) counts.set(k, (counts.get(k) ?? 0) + 1); }\n let any = false;\n for (const it of items) {\n const k = it.key().trim().toLowerCase();\n const dup = !!k && (counts.get(k) ?? 0) > 1;\n it.input.classList.toggle(\"invalid\", dup);\n // The reason rides `data-tip` (the themed rollover, and what the Save\n // gate's message channel reads), never `title`.\n if (dup) { it.input.dataset[\"tip\"] = DUP_MESSAGE; any = true; }\n else if (it.input.dataset[\"tip\"] === DUP_MESSAGE) delete it.input.dataset[\"tip\"];\n }\n return any;\n };\n return {\n reset() { items.length = 0; },\n track(input, key = () => input.value, also) {\n items.push({ input, key });\n input.addEventListener(\"input\", check);\n for (const a of also ?? []) a.addEventListener(\"input\", check);\n },\n check,\n firstDuplicate() { check(); return items.find((it) => it.input.classList.contains(\"invalid\"))?.input ?? null; },\n };\n}\n\n// --- the settings dialog ------------------------------------------------------\n\nexport interface SettingsSectionHandle {\n /** The first invalid control to jump to, blocking Save (e.g. a duplicate\n * name). Return `{ el, message }` to say WHICH fault in the error line;\n * a bare element says it through its own `data-tip` (the dup guard's, a\n * property-name field's), and the line falls back to a generic sentence\n * when it has neither. */\n firstInvalid?(): HTMLElement | { el: HTMLElement; message?: string } | null;\n}\n\nexport interface SettingsSection {\n id: string;\n label: string;\n /** Optional left-rail group heading above this tab. */\n group?: string;\n /** Build the section body into `host`; called fresh on each open so it reads\n * the current data. Return a handle (for the Save gate). */\n mount(host: HTMLElement): SettingsSectionHandle;\n /** Why this tab cannot be used right now, or null when it can. A reason\n * renders the tab dimmed and inert with the reason as its rollover\n * (Patterpad's Audio tab while the project is not voiced). Read on open\n * and on `refreshTabs()`, so a control inside the dialog can flip it. */\n disabled?: () => string | null;\n}\n\nexport interface SettingsDialogOptions {\n title: string;\n sections: SettingsSection[];\n /** Fired when Save is clicked and every section validates. The app reads its\n * own section state and persists. May be async; the dialog stays open until\n * it resolves, then closes.\n *\n * Return `false` (or a Promise of it) when the save was REFUSED, a version\n * control lock say, and the dialog stays open with the author's edits in it\n * for another try; saying why is the app's (a toast, usually). A throw, or a\n * rejected Promise, is treated the same way rather than surfacing as an\n * unhandled rejection. Anything else closes the dialog, as it always has. */\n onSave: () => void | boolean | Promise<void | boolean>;\n}\n\nexport interface SettingsDialog {\n /** Open (optionally on a given tab id). Sections re-mount from current data. */\n open(tabId?: string): void;\n /** Re-read every section's `disabled()`; a tab that has just become\n * disabled while showing hands over to the first usable one. */\n refreshTabs(): void;\n destroy(): void;\n}\n\n/** Build a settings dialog. The frame owns the modal, the tab rail, save-on-Save\n * (with a validation gate), and Cancel; the sections own their content + state. */\nexport function mountSettingsDialog(opts: SettingsDialogOptions): SettingsDialog {\n const dialog = el(\"dialog\", \"settings-dialog\");\n const form = el(\"form\", \"settings-form\"); form.method = \"dialog\";\n const tabs = el(\"nav\", \"settings-tabs\");\n const panels = el(\"div\", \"settings-panels\");\n const error = el(\"p\", \"settings-error\"); error.hidden = true;\n const cancel = el(\"button\", \"settings-cancel\", \"Cancel\"); cancel.type = \"button\"; cancel.value = \"cancel\";\n const save = el(\"button\", \"settings-save primary\", \"Save\"); save.value = \"save\";\n\n const panelFor = new Map<string, HTMLElement>();\n const tabFor = new Map<string, HTMLButtonElement>();\n const handles = new Map<string, SettingsSectionHandle>();\n let active = opts.sections[0]?.id ?? \"\";\n\n let lastGroup: string | undefined;\n for (const s of opts.sections) {\n if (s.group && s.group !== lastGroup) { tabs.append(el(\"div\", \"settings-group\", s.group)); lastGroup = s.group; }\n const tab = el(\"button\", \"settings-tab\", s.label); tab.type = \"button\"; tab.dataset[\"tab\"] = s.id;\n // A disabled tab is inert by class, not by the `disabled` attribute: a\n // disabled button swallows the pointer, and the reason has to be readable\n // on hover.\n tab.addEventListener(\"click\", () => { if (!tab.classList.contains(\"is-disabled\")) showTab(s.id); });\n tabs.append(tab); tabFor.set(s.id, tab);\n const panel = el(\"section\", \"settings-panel\"); panel.dataset[\"panel\"] = s.id; panel.hidden = true;\n panels.append(panel); panelFor.set(s.id, panel);\n }\n\n function showTab(id: string): void {\n active = id;\n for (const [sid, t] of tabFor) t.classList.toggle(\"active\", sid === id);\n for (const [sid, p] of panelFor) p.hidden = sid !== id;\n }\n\n const usable = (s: SettingsSection): boolean => !tabFor.get(s.id)?.classList.contains(\"is-disabled\");\n function refreshTabs(): void {\n for (const s of opts.sections) {\n const tab = tabFor.get(s.id)!;\n const reason = s.disabled?.() ?? null;\n tab.classList.toggle(\"is-disabled\", reason !== null);\n if (reason !== null) { tab.dataset[\"tip\"] = reason; tab.setAttribute(\"aria-disabled\", \"true\"); }\n else { delete tab.dataset[\"tip\"]; tab.removeAttribute(\"aria-disabled\"); }\n }\n if (!opts.sections.some((s) => s.id === active && usable(s))) {\n const first = opts.sections.find(usable);\n if (first) showTab(first.id);\n }\n }\n\n form.append(\n el(\"h2\", \"settings-title\", opts.title),\n el(\"div\", \"settings-body\", tabs, panels),\n el(\"div\", \"settings-actions\", error, cancel, save),\n );\n dialog.append(form);\n document.body.append(dialog);\n\n // Enter should not submit while editing a field; only the Save button does.\n form.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\" && (e.target as HTMLElement)?.tagName === \"INPUT\") e.preventDefault();\n });\n\n cancel.addEventListener(\"click\", () => dialog.close(\"cancel\"));\n save.addEventListener(\"click\", (e) => {\n e.preventDefault();\n error.hidden = true;\n for (const s of opts.sections) {\n const found = handles.get(s.id)?.firstInvalid?.();\n if (!found) continue;\n const bad = found instanceof HTMLElement ? found : found.el;\n const message = (found instanceof HTMLElement ? undefined : found.message) ?? bad.dataset[\"tip\"];\n showTab(s.id);\n bad.focus();\n // The field's own rollover says which fault it is, so the line repeats it\n // rather than inventing a summary; the generic sentence is the fallback.\n error.textContent = message || \"Fix the highlighted fields first.\";\n error.hidden = false;\n return;\n }\n // The dialog closes only on a save that went through. It used to close\n // whatever happened, so a save refused under a lock took the author's edits\n // away with it. Save is off while one is in flight, so a second click\n // cannot start a second save.\n save.disabled = true;\n void (async () => {\n let saved: unknown;\n try { saved = await opts.onSave(); } catch (err) { saved = false; console.error(\"Settings save failed:\", err); }\n save.disabled = false;\n if (saved !== false) dialog.close(\"save\");\n })();\n });\n\n return {\n open(tabId) {\n handles.clear();\n for (const s of opts.sections) {\n const panel = panelFor.get(s.id)!;\n panel.replaceChildren();\n handles.set(s.id, s.mount(panel));\n }\n error.hidden = true;\n showTab(tabId ?? active ?? opts.sections[0]?.id ?? \"\");\n refreshTabs(); // a disabled tab asked for by id hands over to the first usable one\n dialog.showModal();\n },\n refreshTabs,\n destroy() { dialog.remove(); },\n };\n}\n","// ---------------------------------------------------------------------------\n// Property names: what an author may call a value the story reads and writes.\n//\n// This belongs to the shell for the same reason gameIds do (see ids.ts): it\n// follows from the SHAPE these apps share - a project of data files, authored in\n// an editor, compiled for something else to run - rather than from any one\n// subject. Nothing here needs the words card, beat, hand or scene.\n//\n// UNLIKE gameIds, the rule is not a house style. It is dictated by the\n// expression language both families embed (`@wildwinter/expr`), and every clause\n// below is a failure observed by compiling one:\n//\n// parser.ts tokenises an identifier as /[a-zA-Z_][a-zA-Z0-9_]*/ and then\n// FOLDS it: `name: propTok.value.toLowerCase()`.\n//\n// @patter.is_night -> [\"sv\",\"patter\",\"is_night\"] reachable\n// @patter.isNight -> [\"sv\",\"patter\",\"isnight\"] folded: a declaration\n// spelled `isNight` is\n// one nothing can reach\n// @patter.is-night -> [\"bin\",\"-\",[\"sv\",\"patter\",\"is\"], NOT an error: it is\n// [\"s\",\"night\"]] SUBTRACTION. A hyphen\n// silently compiles to\n// a different meaning\n// @patter.is night -> parse error\n// @patter.9lives -> parse error (a name cannot start with a digit)\n// @patter.not -> parse error (`true false and or not` are keywords)\n//\n// The hyphen line is why this is worth a shared rule rather than a per-app\n// check: every other violation is loud, and that one quietly means something\n// else. It is also why a property name is NOT a gameId with different spelling -\n// a gameId is built out of hyphens, and here a hyphen is an operator.\n//\n// DEPENDENCY-FREE on purpose, ids.ts's reasoning verbatim: the apps' compilers,\n// CLIs and embedded runtimes need these rules far from any UI, so they keep\n// their own copies and assert parity with these in a test.\n// ---------------------------------------------------------------------------\n\n/** The five words `@wildwinter/expr` lexes as keywords, so a property may not be\n * called any of them: the reference does not resolve, it fails to parse. Kept\n * here as a copy for the same reason the rules are (no dependency), and each\n * app probes the real parser to prove the list is still true. */\nexport const RESERVED_PROPERTY_NAMES: readonly string[] = [\"true\", \"false\", \"and\", \"or\", \"not\"];\n\n/** What an editor should tell an author, in one line. */\nexport const PROPERTY_NAME_HINT =\n \"Lower case letters, digits, and underscores. It can't start with a digit. No hyphens or spaces.\";\n\n/**\n * Coerce a label into a legal property name: lower case, apostrophes dropped,\n * runs of anything else to a single underscore, no trailing underscore, an\n * underscore in front if it would otherwise start with a digit, and one behind\n * if it would otherwise be a keyword.\n *\n * A LEADING underscore is kept where the author typed one, because `_private` is\n * a legal name and a meaningful choice; only the ends that would be illegal are\n * touched.\n *\n * May return \"\", when there was nothing usable in the input. Callers treat that\n * as \"no name yet\" rather than as a name.\n */\nexport function propertyNameify(text: string): string {\n const trimmed = text.trim();\n // An underscore the author actually typed is kept; one that is only the ghost of\n // leading punctuation is not. That is the difference between `_private` and `!gold`.\n const deliberateLeading = trimmed.startsWith(\"_\");\n let out = trimmed.toLowerCase().replace(/['’]/g, \"\")\n .replace(/[^a-z0-9_]+/g, \"_\").replace(/_+/g, \"_\").replace(/^_+|_+$/g, \"\");\n if (out === \"\") return \"\";\n if (deliberateLeading || /^[0-9]/.test(out)) out = `_${out}`;\n if (RESERVED_PROPERTY_NAMES.includes(out)) out = `${out}_`;\n return out;\n}\n\n/**\n * Is this a name the expression language can actually reach? Lower case letters,\n * digits and underscores, not starting with a digit, and not a keyword.\n *\n * \"\" is NOT legal: an unnamed declaration is an unfinished row, which is a\n * different thing from an illegal one, and callers distinguish them.\n */\nexport function isValidPropertyName(name: string): boolean {\n return /^[a-z_][a-z0-9_]*$/.test(name) && !RESERVED_PROPERTY_NAMES.includes(name);\n}\n\n/**\n * The one thing that is only a case difference, e.g. `isNight` -> `isnight`.\n *\n * Worth its own question because it is the only violation that can be repaired\n * without guessing at intent: the language already folds every REFERENCE, so\n * folding the declaration to match changes nothing observable, where inventing\n * an underscore for a space is a decision about what the author meant. Loaders\n * fold this class silently and report the rest.\n */\nexport function isCaseOnlyPropertyName(name: string): boolean {\n return !isValidPropertyName(name) && isValidPropertyName(name.toLowerCase());\n}\n","// ---------------------------------------------------------------------------\n// The manners for a field that names a declared property.\n//\n// The RULE is property-names.ts, which is dependency-free because each app's\n// domain layer keeps its own copy of it. This is the other half: how a field\n// BEHAVES while somebody types a name into it, which only UI touches, so the\n// shell owns it outright.\n//\n// The manners are the gameId editor's, adopted rather than re-argued (see\n// id-editor.ts): an illegal name is marked and blocks Save, and Tab coerces it,\n// in the field, where it can be seen and undone. Nothing is rewritten as it is\n// typed. Patterpad's first pass at this folded every keystroke to lower case;\n// that is the manner the id editor had already rejected, on the grounds that an\n// app which silently renames a thing has made a decision that was not its to\n// make, and a property name is exactly that kind of thing: the author is naming\n// something their own conditions will call.\n//\n// It arrived here as two copies, one per app, written in one session and already\n// carrying the same forty lines of fault wording. Lifting them before they could\n// drift is the whole reason this file exists.\n// ---------------------------------------------------------------------------\n\nimport { isValidPropertyName, propertyNameify, RESERVED_PROPERTY_NAMES } from \"./property-names.js\";\n\n/** Re-check callbacks for bound REFERENCE fields, so a host can say \"the declarations\n * changed\" without holding a handle per row. */\nconst refSyncs = new WeakMap<HTMLInputElement, () => void>();\n\n/**\n * One line saying what is wrong with this name, or undefined when nothing is.\n *\n * Each branch names what actually HAPPENS rather than reciting the rule, because\n * the person reading it is usually somebody wondering why a condition does\n * nothing. Kept to one line: it lands in a rollover on the field, and hosts\n * repeat it in the Save error rather than inventing a summary of their own.\n */\nexport function propertyNameProblem(name: string): string | undefined {\n if (isValidPropertyName(name)) return undefined;\n const suggestion = propertyNameify(name);\n const tail = suggestion ? ` Try \"${suggestion}\", or press Tab.` : \"\";\n if (RESERVED_PROPERTY_NAMES.includes(name.toLowerCase())) {\n return `Can't be used. \"${name.toLowerCase()}\" is a keyword in expressions.${tail}`;\n }\n // The one that is not an error anywhere else: `@scope.a-b` compiles to a-minus-b.\n if (name.includes(\"-\")) return `Can't be used. A hyphen reads as subtraction in an expression.${tail}`;\n if (/^[0-9]/.test(name)) return `Can't be used. A name can't start with a digit.${tail}`;\n if (name !== name.toLowerCase()) {\n return `Can't be used. Expressions fold names, so this would look for \"${name.toLowerCase()}\".${tail}`;\n }\n return `Can't be used. Only lower case letters, digits, and underscores.${tail}`;\n}\n\n/**\n * Wire a name field: mark it live, explain the fault in its rollover, and coerce\n * on Tab. `onCommit` receives what the author typed, VERBATIM, on every input.\n *\n * `.illegal` rather than dupGuard's `.invalid`, because both can be true of one\n * field and `dupGuard.check()` owns that class: it would clear this marking every\n * time it ran, including at the moment of a blocked Save.\n *\n * An empty field is not marked. An unfinished row is a different thing from an\n * illegal one, and hosts prune blank names on save.\n */\nexport function bindPropertyName(\n input: HTMLInputElement,\n onCommit: (value: string) => void,\n opts: { hint?: string } = {},\n): void {\n const hint = opts.hint;\n const sync = (): void => {\n const v = input.value.trim();\n const problem = v === \"\" ? undefined : propertyNameProblem(v);\n input.classList.toggle(\"illegal\", !!problem);\n if (problem) input.title = problem;\n else if (input.title.startsWith(\"Can't be used\")) {\n if (hint) input.title = hint;\n else input.removeAttribute(\"title\");\n }\n };\n input.addEventListener(\"input\", () => { onCommit(input.value); sync(); });\n input.addEventListener(\"keydown\", (e) => {\n // The opt-in coercion, the id editor's gesture. Shift+Tab is left alone: it is\n // how somebody leaves a field they have not finished with.\n if (e.key !== \"Tab\" || e.shiftKey) return;\n const typed = input.value.trim();\n if (typed === \"\" || isValidPropertyName(typed)) return;\n const coerced = propertyNameify(typed);\n if (!coerced || coerced === input.value) return;\n e.preventDefault();\n input.value = coerced;\n onCommit(coerced);\n sync();\n });\n sync();\n}\n\n/**\n * The first field in `host` holding a name no expression could reach, for a Save\n * gate. Hosts hand this back beside `dupGuard.firstDuplicate()`: two faults, two\n * sets of words, one gate.\n */\nexport function firstIllegalPropertyName(host: ParentNode): HTMLInputElement | null {\n return host.querySelector<HTMLInputElement>(\"input.illegal\");\n}\n\n// ---------------------------------------------------------------------------\n// Reference fields, which are a different job from declaration fields.\n//\n// A declaration NAMES a property; a reference POINTS at one. The expression\n// parser folds every reference, so `@world.isNight` reaches `isnight` perfectly\n// well and complaining about the capital would be inventing a rule the language\n// does not have. Everything else still bites, and harder: no declaration may\n// contain a hyphen, so `is-night` in a reference can never match anything that\n// exists.\n//\n// And a reference has a fault a declaration cannot have: naming something that\n// was never declared. That is not a grammar question, so the host supplies the\n// list. The cost of getting it wrong is quiet - a coverage driver pointed at a\n// property nobody declared feeds a value nobody reads, the branches it was meant\n// to exercise stay unexercised, and the report shows them as never hit, which\n// reads as \"this content is unreachable\" rather than \"that name is a typo\".\n// ---------------------------------------------------------------------------\n\nexport interface PropertyRefOptions {\n /** The names that exist, read fresh on every check so a declaration added in the\n * same dialog clears the complaint. Compared case-insensitively, since the\n * parser folds. */\n known: () => string[];\n /** The scope token this field addresses, for the wording (\"no @world property...\"). */\n scope?: string;\n /** Shown on the field when there is nothing to complain about. */\n hint?: string;\n}\n\n/** The closest known name, when one is close enough to be worth naming. Deliberately\n * narrow: a wrong suggestion is worse than none, so it wants a shared prefix or a\n * single-character slip, not the least-bad match in the list. */\nfunction nearest(name: string, known: string[]): string | undefined {\n const n = name.toLowerCase();\n const byPrefix = known.filter((k) => k.toLowerCase().startsWith(n) || n.startsWith(k.toLowerCase()));\n if (byPrefix.length === 1) return byPrefix[0];\n let best: string | undefined;\n let bestScore = 3; // strictly better than \"three edits away\"\n for (const k of known) {\n const a = k.toLowerCase();\n if (Math.abs(a.length - n.length) > 2) continue;\n // Levenshtein, small strings, no need for a matrix beyond two rows.\n let prev = Array.from({ length: n.length + 1 }, (_, i) => i);\n for (let i = 1; i <= a.length; i++) {\n const row = [i];\n for (let j = 1; j <= n.length; j++) {\n row[j] = Math.min(prev[j]! + 1, row[j - 1]! + 1, prev[j - 1]! + (a[i - 1] === n[j - 1] ? 0 : 1));\n }\n prev = row;\n }\n const d = prev[n.length]!;\n if (d < bestScore) { bestScore = d; best = k; }\n }\n return best;\n}\n\n/** Why this reference cannot be used, or undefined when it can. */\nexport function propertyRefProblem(name: string, opts: PropertyRefOptions): string | undefined {\n const scope = opts.scope ? `@${opts.scope}` : \"that scope\";\n // Case is NOT a fault here: the parser folds references.\n const folded = name.toLowerCase();\n if (!isValidPropertyName(folded)) {\n const suggestion = propertyNameify(name);\n const tail = suggestion ? ` Try \"${suggestion}\", or press Tab.` : \"\";\n if (RESERVED_PROPERTY_NAMES.includes(folded)) return `Can't be used. \"${folded}\" is a keyword in expressions.${tail}`;\n if (name.includes(\"-\")) return `Can't be used. A hyphen reads as subtraction in an expression.${tail}`;\n if (/^[0-9]/.test(name)) return `Can't be used. A name can't start with a digit.${tail}`;\n return `Can't be used. Only lower case letters, digits, and underscores.${tail}`;\n }\n const known = opts.known();\n if (known.some((k) => k.toLowerCase() === folded)) return undefined;\n const near = nearest(folded, known);\n if (near) return `No ${scope} property is called \"${name}\". Did you mean \"${near}\"?`;\n if (known.length === 0) return `No ${scope} properties are declared yet. Declare one above first.`;\n const shown = known.slice(0, 3).map((k) => `\"${k}\"`).join(\", \");\n const more = known.length > 3 ? `, and ${known.length - 3} more` : \"\";\n return `No ${scope} property is called \"${name}\". Pick one of ${shown}${more}.`;\n}\n\n/**\n * Wire a field that POINTS at a declared property: same manners as a declaration\n * field (mark, do not rewrite, Tab coerces), plus the declared names offered as a\n * datalist, because the rule is declare-then-reference and a picker makes that\n * painless rather than pedantic.\n *\n * Marks `.illegal` for an undeclared name too, which gates Save wherever the host\n * already asks `firstIllegalPropertyName`.\n */\nexport function bindPropertyRef(\n input: HTMLInputElement,\n onCommit: (value: string) => void,\n opts: PropertyRefOptions,\n): void {\n const list = document.createElement(\"datalist\");\n list.id = `shell-propref-${Math.random().toString(36).slice(2, 9)}`;\n input.setAttribute(\"list\", list.id);\n\n // Attached lazily, not once at bind. A datalist has to be IN the document to do anything, and it is\n // attached as a sibling of the input - so binding a field that has not been appended yet (which is\n // the ordinary order for a builder that makes its nodes and then mounts them) silently produced no\n // autocomplete at all: no error, nothing to see. This re-tries on every sync, so it heals as soon as\n // the field reaches the tree.\n const attach = (): void => {\n if (!list.isConnected && input.parentNode) input.after(list);\n };\n\n const sync = (): void => {\n attach();\n const known = opts.known();\n list.replaceChildren(...known.map((k) => { const o = document.createElement(\"option\"); o.value = k; return o; }));\n const v = input.value.trim();\n const problem = v === \"\" ? undefined : propertyRefProblem(v, opts);\n input.classList.toggle(\"illegal\", !!problem);\n if (problem) input.title = problem;\n else if (input.title.startsWith(\"Can't be used\") || input.title.startsWith(\"No \")) {\n if (opts.hint) input.title = opts.hint;\n else input.removeAttribute(\"title\");\n }\n };\n refSyncs.set(input, sync);\n\n input.addEventListener(\"input\", () => { onCommit(input.value); sync(); });\n input.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"Tab\" || e.shiftKey) return;\n const typed = input.value.trim();\n // Only a GRAMMAR fault is coercible. An undeclared name is not something Tab can\n // fix, and a legal reference in the wrong case is not a fault at all.\n if (typed === \"\" || isValidPropertyName(typed.toLowerCase())) return;\n const coerced = propertyNameify(typed);\n if (!coerced || coerced === input.value) return;\n e.preventDefault();\n input.value = coerced;\n onCommit(coerced);\n sync();\n });\n sync();\n}\n\n/**\n * Re-check every bound reference field inside `host`. Hosts call this when the\n * DECLARATIONS change, since a reference's validity depends on a list it does not\n * own: rename a property and the driver pointing at it is wrong from that moment,\n * with nothing typed into it.\n */\nexport function revalidatePropertyRefs(host: ParentNode): void {\n for (const input of host.querySelectorAll(\"input\")) refSyncs.get(input)?.();\n}\n","// ---------------------------------------------------------------------------\n// Typed value controls: how both apps show and set a value of a declared type.\n//\n// The first is the quality's. A quality is a step on a ladder, so its value is\n// shown as the LADDER, with the current rung marked, rather than a dropdown that\n// shows one name and hides where it stands (patterkit design/proposals/\n// patter-qualities.md section 4). Storyletter's Board drew it this way first;\n// it lives here so Storyletter's Fields tab, Patterpad's play panel and Game\n// Data rows, and the play inspectors all draw the same strip.\n//\n// An UNSET value (a field or game-data value the node leaves out) names what it\n// falls back to, \"default (x)\", by the family's one rule: the declaration's own\n// default, else the type's (a quality's first stage). A value that is no longer\n// a stage (a deleted one) is shown as such, so it can be put back on the ladder.\n//\n// No Electron, no app state: this module is DOM only, and is its own entry point\n// (`@wildwinter/app-shell/value-control`) so a play inspector outside the apps\n// can take it.\n// ---------------------------------------------------------------------------\n\nimport { el, tagChips } from \"./dom.js\";\n\n/** A declaration as these controls read it: a property's, a field's or a game-data field's. */\nexport interface ValueDeclLike {\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: readonly string[];\n /** quality: the ladder, in order */\n stages?: readonly string[];\n}\n\n/**\n * What an unset value of `decl` falls back to, as the words a control shows: its own default where it has\n * one, else its type's (False, 0, the first value, no flags, the first stage, empty text). The kernel's\n * `defaultFor`, in words; a host reads the same value from the bundle.\n */\nexport function fallbackText(decl: ValueDeclLike): string {\n const d = decl.default;\n if (d !== undefined && d !== null) {\n if (typeof d === \"boolean\") return d ? \"True\" : \"False\";\n if (Array.isArray(d)) return d.length === 0 ? \"none\" : d.join(\", \");\n return d === \"\" ? \"none\" : String(d);\n }\n switch (decl.type) {\n case \"boolean\": return \"False\";\n case \"number\": return \"0\";\n case \"enum\": return decl.values?.[0] ?? \"none\";\n case \"quality\": return decl.stages?.[0] ?? \"first stage\";\n case \"flags\": return \"none\";\n default: return \"empty\";\n }\n}\n\n/** The label an unset value shows: \"default (x)\", naming what it falls back to. */\nexport const defaultLabel = (decl: ValueDeclLike): string => `default (${fallbackText(decl)})`;\n\n/**\n * The quiet line under a ladder that has just been reordered: how many gates order against it. A reorder\n * changes no value, and is the one edit that changes what a gate MEANS without saying so (patter-qualities.md\n * section 2), so the editor says so. Empty when no gate orders the quality.\n */\nexport function stageGateNote(gates: number): string {\n if (gates <= 0) return \"\";\n return gates === 1\n ? \"1 gate compares against this ladder, and it now reads the new order.\"\n : `${gates} gates compare against this ladder, and each now reads the new order.`;\n}\n\nexport interface RungStripOptions {\n /** The ladder, in order. */\n stages: readonly string[];\n /** The value held, or undefined when unset: a field or game-data value the node leaves out. */\n value: string | undefined;\n /** The declaration, for what an unset value falls back to (its default, else the first stage). */\n decl?: ValueDeclLike;\n /** Pick a stage. Absent: the strip is read-only. */\n onPick?: (stage: string) => void;\n /** Clear back to unset. With it, the strip leads with \"default (x)\", which clears the value. */\n onClear?: () => void;\n /** The rollover on a rung that is not the current one (default: `Set to \"x\"`). */\n pickTip?: (stage: string) => string;\n /**\n * The document to build in, for a host outside the apps (a play inspector in a page or a frame of its\n * own). Given, rollovers are plain `title`s and the family's themed tooltips are not mounted; the host\n * styles `.seg`, `.seg-opt` and `.shell-rung` itself. Absent: the apps' document and themed rollovers.\n */\n doc?: Document;\n}\n\n/**\n * A quality's value as its ladder: one rung per stage, in order, the current one marked (`on`). Unset, the\n * rung it falls back to is marked as the fallback (`fallback`), and with `onClear` a leading \"default (x)\"\n * option is the current choice. A value that is not a stage (a deleted one) is shown after the ladder,\n * marked `stray`, until a rung is picked.\n */\nexport function rungStrip(opts: RungStripOptions): HTMLElement {\n const make = opts.doc === undefined ? el : (tag: \"span\" | \"button\", props: { className: string; text?: string; tip?: string; onClick?: () => void }) => {\n const node = opts.doc!.createElement(tag);\n node.className = props.className;\n if (props.text !== undefined) node.textContent = props.text;\n if (props.tip !== undefined) { node.title = props.tip; node.setAttribute(\"aria-label\", props.tip); }\n if (props.onClick) node.addEventListener(\"click\", props.onClick);\n if (tag === \"button\") (node as HTMLButtonElement).type = \"button\";\n return node;\n };\n const strip = make(\"span\", { className: \"seg shell-rungs\" });\n const decl: ValueDeclLike = opts.decl ?? { type: \"quality\", stages: opts.stages };\n const unset = opts.value === undefined;\n const fallback = typeof decl.default === \"string\" && opts.stages.includes(decl.default) ? decl.default : opts.stages[0];\n const readOnly = opts.onPick === undefined;\n if (opts.onClear) {\n strip.append(make(\"button\", {\n className: `seg-opt shell-rung shell-rung-default${unset ? \" on\" : \"\"}`, text: defaultLabel(decl),\n tip: unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n onClick: () => { if (!unset) opts.onClear!(); },\n }));\n }\n for (const stage of opts.stages) {\n const current = opts.value === stage;\n const falls = unset && stage === fallback;\n const rung = make(readOnly ? \"span\" : \"button\", {\n className: `seg-opt shell-rung${current ? \" on\" : \"\"}${falls ? \" fallback\" : \"\"}`, text: stage,\n tip: current ? \"The current stage\" : falls ? \"The stage it falls back to\" : readOnly ? stage : (opts.pickTip?.(stage) ?? `Set to \"${stage}\"`),\n ...(readOnly ? {} : { onClick: () => { if (!current) opts.onPick!(stage); } }),\n });\n strip.append(rung);\n }\n if (!unset && !opts.stages.includes(opts.value!)) {\n strip.append(make(\"span\", {\n className: \"seg-opt shell-rung stray on\", text: opts.value!,\n tip: `\"${opts.value}\" is not one of the stages: pick the one it belongs at now`,\n }));\n }\n return strip;\n}\n\n// ---------------------------------------------------------------------------\n// The field row: ONE control for a node's value of a declared field, driven by\n// the declared type, for the family's seven types (text, multiline, number,\n// boolean, enum, flags, quality). Storyletter's card and outcome Fields and\n// Patterpad's Game Data rows both draw it, which settles the disagreements the\n// parity review found (patterkit design/family-parity-2026-10.md item 10):\n//\n// - the declared purpose is shown, under the control, not hidden in a rollover;\n// - unset says what it falls back to, \"default (x)\", by `defaultLabel`;\n// - flags are a picker of the declared values, not comma-separated text;\n// - multiline is a text area;\n// - a value the declaration refuses (not a number, not one of the values, not\n// a stage) is said under the control, and the app may add its own message;\n// - text commits as typed, and Escape puts back what the field held when it\n// took focus (the family's field rule).\n//\n// Committing as typed means a host that redraws on every change (Patterpad's\n// inspector rebuilds its whole stack) would drop the focus at every keystroke.\n// `fieldRows()` is the answer: it hands back the SAME element for the same key\n// across a redraw, updated in place, and gives the focus (and the caret) back\n// to it once the redraw has put it in the page again.\n// ---------------------------------------------------------------------------\n\n/** A value a field row commits: a flags value is the list of names set. */\nexport type FieldValue = string | number | boolean | string[];\n\n/** A field's declaration as the row reads it: a card field's, an outcome field's or a game-data field's. */\nexport interface FieldDeclLike extends ValueDeclLike {\n name: string;\n /** What the field is for, shown under the control. */\n purpose?: string;\n /** A sentence about each value (an enum's values, the flags, a quality's stages, a pick's fixed words), as an\n * extension's manifest gives them: the chosen value's is shown under the control, and each chosen flag's. */\n valueHelp?: Readonly<Record<string, string>>;\n}\n\n/**\n * The help for what `decl` holds: the chosen enum value's, stage's or pick word's (the one it falls back to, when\n * unset), or each chosen flag's, \"name: sentence\" a line each. Empty when the declaration describes none of them.\n */\nexport function valueHelpText(decl: FieldDeclLike, value: unknown): string {\n const help = decl.valueHelp;\n if (help === undefined) return \"\";\n const said = (v: string): string | undefined => (Object.prototype.hasOwnProperty.call(help, v) ? help[v] : undefined);\n if (decl.type === \"enum\" || decl.type === \"quality\") {\n const held = typeof value === \"string\" && value !== \"\" ? value\n : typeof decl.default === \"string\" && decl.default !== \"\" ? decl.default\n : decl.type === \"enum\" ? decl.values?.[0] : decl.stages?.[0];\n return held === undefined ? \"\" : said(held) ?? \"\";\n }\n if (decl.type === \"flags\") {\n const held = Array.isArray(value) ? value.map(String) : Array.isArray(decl.default) ? decl.default.map(String) : [];\n return held.flatMap((v) => { const h = said(v); return h === undefined ? [] : [`${v}: ${h}`]; }).join(\"\\n\");\n }\n if (decl.type === \"pick\") {\n // A pick's help describes its fixed words only; empty is automatic, so nothing is chosen to describe.\n const held = typeof value === \"string\" && value !== \"\" ? value : typeof decl.default === \"string\" ? decl.default : \"\";\n return held === \"\" ? \"\" : said(held) ?? \"\";\n }\n return \"\";\n}\n\nexport interface FieldRowOptions {\n decl: FieldDeclLike;\n /** The node's own value, typed (a flags value is a string list), or undefined where the node sets none. */\n value: unknown;\n /** Commit a value; `undefined` clears it, back to the default. Absent: the row is read-only. */\n onCommit?: (value: FieldValue | undefined) => void;\n /** Drawn but not editable, as when there is no node to write to. */\n disabled?: boolean;\n /** A message of the app's own about this value (a check the row cannot make), shown under the control. */\n problem?: string;\n /** The app's own sentence INSTEAD of the row's (a renamed stage said better than \"not one of the stages\").\n * Given, it is the whole message; `problem` is ignored. */\n replaceProblem?: string;\n /** The caption; default the field's name. */\n label?: string | Node;\n /** Added to the row and its caption, so a row sits in its app's layout. */\n className?: string;\n labelClassName?: string;\n /** The app's class for a text field or select, used instead of the shell's `.field`. */\n controlClassName?: string;\n}\n\nexport interface FieldRowHandle {\n /** The row: its caption, then the control with the purpose and any message under it. */\n readonly el: HTMLElement;\n /** Redraw for a new value, declaration or message, keeping the element. A field being typed in keeps its\n * text: what the author is typing is newer than what the app last stored. */\n update(opts: FieldRowOptions): void;\n}\n\n/** The type's fallback as a value, for a flags picker to start from when the node sets none. */\nconst fallbackFlags = (decl: ValueDeclLike): string[] => (Array.isArray(decl.default) ? decl.default.filter((v): v is string => typeof v === \"string\") : []);\n\n/** What the row says about a value the declaration refuses, or \"\" when it fits. */\nexport function fieldValueProblem(decl: ValueDeclLike, value: unknown): string {\n if (value === undefined || value === null || value === \"\") return \"\";\n switch (decl.type) {\n case \"number\":\n return typeof value === \"number\" && Number.isFinite(value) ? \"\" : \"Not a number.\";\n case \"boolean\":\n return typeof value === \"boolean\" ? \"\" : \"Not True or False.\";\n case \"enum\":\n return decl.values && !decl.values.includes(String(value)) ? `\"${String(value)}\" is not one of the values.` : \"\";\n case \"quality\":\n return decl.stages && !decl.stages.includes(String(value)) ? `\"${String(value)}\" is not one of the stages.` : \"\";\n case \"flags\": {\n if (!Array.isArray(value)) return \"Not a list of flags.\";\n const strays = decl.values ? value.filter((v) => !decl.values!.includes(String(v))) : [];\n if (strays.length === 0) return \"\";\n return strays.length === 1 ? `\"${String(strays[0])}\" is not one of the values.` : `${strays.map((s) => `\"${String(s)}\"`).join(\", \")} are not among the values.`;\n }\n default:\n return \"\";\n }\n}\n\nconst isTextual = (type: string): boolean => type !== \"boolean\" && type !== \"enum\" && type !== \"flags\" && type !== \"quality\";\n\n/** Everything that decides which control is drawn: a change here rebuilds it, anything else updates it. */\nconst controlShape = (o: FieldRowOptions): string => JSON.stringify([\n o.decl.type, o.decl.values ?? null, o.decl.stages ?? null, o.decl.default ?? null,\n o.onCommit === undefined, o.disabled === true, o.controlClassName ?? \"\",\n o.decl.type === \"quality\" && (o.decl.stages?.length ?? 0) === 0,\n]);\n\n/**\n * One declared field's value as a row: the caption, then the control the declared type calls for, with the\n * purpose and any message under it. See the section comment above for the rules it carries.\n */\nexport function fieldRow(initial: FieldRowOptions): FieldRowHandle {\n let opts = initial;\n const row = el(\"div\", `shell-fieldrow${opts.className ? ` ${opts.className}` : \"\"}`);\n const caption = el(\"span\", `shell-fieldrow-label${opts.labelClassName ? ` ${opts.labelClassName}` : \"\"}`);\n caption.id = `shell-fr-${Math.random().toString(36).slice(2, 9)}`;\n const body = el(\"div\", \"shell-fieldrow-body\");\n const purpose = el(\"p\", \"shell-fieldrow-purpose\");\n const valueHelp = el(\"p\", \"shell-fieldrow-purpose shell-fieldrow-valuehelp\");\n const problem = el(\"p\", \"shell-fieldrow-problem\");\n problem.setAttribute(\"role\", \"status\");\n row.append(caption, body);\n\n let shape = \"\";\n /** Redraw the control for the current value; set by whichever control is built. */\n let show: (value: unknown) => void = () => {};\n /** A local problem the control found while typing (a number that is not one yet). */\n let typing = \"\";\n\n const commit = (v: FieldValue | undefined): void => { opts.onCommit?.(v); };\n const editable = (): boolean => opts.onCommit !== undefined && opts.disabled !== true;\n // An app's own field class replaces the shell's `.field`, so its controls look like its other fields.\n const ctl = (base: string): string => (opts.controlClassName ? `${base.replace(/^field /, \"\")} ${opts.controlClassName}` : base);\n const labelledBy = (node: HTMLElement): void => {\n node.setAttribute(\"aria-labelledby\", caption.id);\n const described = [purpose.id, problem.id].filter(Boolean).join(\" \");\n if (described) node.setAttribute(\"aria-describedby\", described);\n };\n purpose.id = `${caption.id}-p`; problem.id = `${caption.id}-m`;\n\n const sayProblem = (): void => {\n // The chosen value's own help travels with every change of value, as the message does.\n const help = valueHelpText(opts.decl, opts.value);\n valueHelp.textContent = help;\n valueHelp.hidden = help === \"\";\n const words = opts.replaceProblem !== undefined\n ? [opts.replaceProblem].filter((w) => w !== \"\")\n : [typing || fieldValueProblem(opts.decl, opts.value), opts.problem ?? \"\"].filter((w) => w !== \"\");\n problem.textContent = words.join(\" \");\n problem.hidden = words.length === 0;\n row.classList.toggle(\"has-problem\", words.length > 0);\n row.classList.toggle(\"shell-fieldrow-textual\", isTextual(opts.decl.type));\n };\n\n const build = (): HTMLElement => {\n const decl = opts.decl;\n typing = \"\";\n if (decl.type === \"quality\" && (decl.stages?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-fieldrow-rungs\");\n show = (value) => {\n holder.replaceChildren(rungStrip({\n stages: decl.stages!, value: typeof value === \"string\" && value !== \"\" ? value : undefined, decl,\n ...(editable() ? { onPick: (stage: string) => { opts = { ...opts, value: stage }; show(stage); sayProblem(); commit(stage); }, onClear: () => { opts = { ...opts, value: undefined }; show(undefined); sayProblem(); commit(undefined); } } : {}),\n }));\n const strip = holder.firstElementChild as HTMLElement | null;\n if (strip) { strip.setAttribute(\"role\", \"group\"); labelledBy(strip); }\n };\n return holder;\n }\n if (decl.type === \"boolean\" || decl.type === \"enum\") {\n const sel = el(\"select\", ctl(\"field shell-fieldrow-select\"));\n labelledBy(sel);\n sel.disabled = !editable();\n const choices: Array<[string, string]> = decl.type === \"boolean\"\n ? [[\"true\", \"True\"], [\"false\", \"False\"]]\n : (decl.values ?? []).map((v): [string, string] => [v, v]);\n show = (value) => {\n const current = value === undefined || value === null || value === \"\" ? \"\" : String(value);\n sel.replaceChildren();\n const add = (v: string, label: string): void => { const o = el(\"option\", undefined, label); o.value = v; sel.append(o); };\n add(\"\", defaultLabel(decl));\n for (const [v, label] of choices) add(v, label);\n // A value the declaration no longer offers stays visible, so the author sees what is held.\n if (current !== \"\" && !choices.some(([v]) => v === current)) add(current, current);\n sel.value = current;\n };\n sel.addEventListener(\"change\", () => {\n const raw = sel.value;\n const v: FieldValue | undefined = raw === \"\" ? undefined : decl.type === \"boolean\" ? raw === \"true\" : raw;\n opts = { ...opts, value: v }; sayProblem(); commit(v);\n });\n return sel;\n }\n if (decl.type === \"flags\" && (decl.values?.length ?? 0) > 0) {\n const holder = el(\"span\", \"shell-flags\");\n holder.setAttribute(\"role\", \"group\");\n labelledBy(holder);\n show = (value) => {\n const unset = !Array.isArray(value);\n const held = unset ? fallbackFlags(decl) : (value as unknown[]).map(String);\n holder.replaceChildren();\n const chip = (text: string, cls: string, pressed: boolean | undefined, tip: string, onClick?: () => void): void => {\n const b = el(onClick && editable() ? \"button\" : \"span\", { className: `shell-flag${cls}`, text, tip });\n b.setAttribute(\"aria-label\", `${text}: ${tip}`); // the tip alone would hide the value's name\n if (b instanceof HTMLButtonElement) { b.type = \"button\"; b.addEventListener(\"click\", onClick!); }\n if (pressed !== undefined) b.setAttribute(\"aria-pressed\", String(pressed));\n holder.append(b);\n };\n const set = (next: string[] | undefined): void => { opts = { ...opts, value: next }; show(next); sayProblem(); commit(next); };\n chip(defaultLabel(decl), ` shell-flag-default${unset ? \" on\" : \"\"}`, undefined,\n unset ? \"Not set here: the declared default holds\" : \"Clear the value, back to the default\",\n unset ? undefined : () => set(undefined));\n for (const v of decl.values!) {\n const on = held.includes(v);\n chip(v, `${on ? \" on\" : \"\"}${on && unset ? \" fallback\" : \"\"}`, on, on ? `Unset ${v}` : `Set ${v}`,\n () => set(on ? held.filter((x) => x !== v) : decl.values!.filter((x) => x === v || held.includes(x)).concat(held.filter((x) => !decl.values!.includes(x)))));\n }\n // A held value the declaration does not offer: shown, struck, and a click drops it.\n for (const v of held.filter((x) => !decl.values!.includes(x))) {\n chip(v, \" stray on\", true, `\"${v}\" is not one of the values: click to drop it`, () => set(held.filter((x) => x !== v)));\n }\n };\n return holder;\n }\n if (decl.type === \"flags\") {\n // No values declared to pick from: the shell's chip editor, each name typed.\n const holder = el(\"span\", \"shell-fieldrow-chips\");\n show = (value) => {\n const box = { values: Array.isArray(value) ? (value as unknown[]).map(String) : [] };\n const chips = tagChips(box, () => {\n const next = box.values.length > 0 ? [...box.values] : undefined;\n opts = { ...opts, value: next }; sayProblem(); commit(next);\n });\n const input = chips.querySelector(\"input\");\n if (input) { labelledBy(input); input.placeholder = Array.isArray(value) ? \"Add value\" : defaultLabel(decl); input.disabled = !editable(); }\n chips.querySelectorAll(\"button\").forEach((b) => { (b as HTMLButtonElement).disabled = !editable(); });\n holder.replaceChildren(chips);\n };\n return holder;\n }\n // text, multiline, number, and any type the row does not know: typed, committed as typed.\n const multiline = decl.type === \"multiline\";\n const field = multiline ? el(\"textarea\", ctl(\"field shell-fieldrow-text\")) : el(\"input\", ctl(\"field shell-fieldrow-text\"));\n if (field instanceof HTMLInputElement) {\n field.type = \"text\";\n if (decl.type === \"number\") field.inputMode = \"decimal\";\n } else field.rows = 3;\n labelledBy(field);\n field.placeholder = defaultLabel(decl);\n field.disabled = !editable();\n const asText = (value: unknown): string =>\n value === undefined || value === null ? \"\" : Array.isArray(value) ? value.join(\", \") : String(value);\n const read = (raw: string): { value?: FieldValue; bad?: string } => {\n if (raw.trim() === \"\") return {};\n if (decl.type !== \"number\") return { value: raw };\n const n = Number(raw.trim());\n return Number.isFinite(n) ? { value: n } : { bad: \"Not a number.\" };\n };\n let atFocus = \"\";\n show = (value) => {\n // What the author is typing is newer than the stored value, so a focused field keeps its text.\n // So does one the author was in when a redraw took the row out of the page, until they leave it.\n if (field.ownerDocument.activeElement === field || keeper.restoring(field) || keeper.holds(row)) return;\n field.value = asText(value);\n };\n const take = (): void => {\n const r = read(field.value);\n typing = r.bad ?? \"\";\n if (r.bad === undefined) opts = { ...opts, value: r.value };\n sayProblem();\n if (r.bad === undefined) commit(r.value);\n };\n field.addEventListener(\"focus\", () => { if (!keeper.restoring(field)) atFocus = field.value; });\n field.addEventListener(\"input\", take);\n field.addEventListener(\"keydown\", (e) => {\n if ((e as KeyboardEvent).key !== \"Escape\" || field.value === atFocus) return;\n field.value = atFocus;\n take();\n });\n return field;\n };\n\n const draw = (next: FieldRowOptions): void => {\n const decl = next.decl;\n const label = next.label ?? decl.name;\n if (typeof label === \"string\") caption.textContent = label; else caption.replaceChildren(label);\n caption.className = `shell-fieldrow-label${next.labelClassName ? ` ${next.labelClassName}` : \"\"}`;\n row.className = `shell-fieldrow${next.className ? ` ${next.className}` : \"\"}`;\n const nextShape = controlShape(next);\n opts = next;\n if (nextShape !== shape) {\n shape = nextShape;\n body.replaceChildren(build());\n }\n show(next.value);\n purpose.textContent = decl.purpose ?? \"\";\n if (decl.purpose) body.append(purpose); else purpose.remove();\n body.append(valueHelp, problem);\n sayProblem();\n };\n\n draw(initial);\n keeper.watch(row);\n return { el: row, update: draw };\n}\n\n// --- keeping the focus across a redraw -------------------------------------\n//\n// A host that rebuilds its view takes the row out of the page and puts it back.\n// Taking a focused element out drops its focus, which is the same thing as\n// the author losing their place mid-word. So a row remembers whether the\n// author was in it, and where the caret was, and the cache gives both back\n// once the row is in the page again (a microtask: after the host's redraw).\n\ninterface FocusMemo { field: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement; start: number | null; end: number | null }\n\nconst keeper = (() => {\n const memos = new WeakMap<HTMLElement, FocusMemo>();\n const restoringNow = new WeakSet<Element>();\n /** When each row was last handed back by the cache, to tell a move's late blur from the author's. */\n const redrawn = new WeakMap<HTMLElement, number>();\n const put = (row: HTMLElement): void => {\n const memo = memos.get(row);\n if (!memo) return;\n const doc = row.ownerDocument;\n const active = doc.activeElement;\n if (!row.isConnected || !memo.field.isConnected || !row.contains(memo.field)) return;\n if (active && active !== doc.body && !row.contains(active)) { memos.delete(row); return; }\n if (active === memo.field && memo.field.matches(\":focus\")) return;\n restoringNow.add(memo.field);\n try {\n memo.field.focus({ preventScroll: true });\n if (!(memo.field instanceof HTMLSelectElement) && memo.start !== null) memo.field.setSelectionRange(memo.start, memo.end ?? memo.start);\n } finally { restoringNow.delete(memo.field); }\n };\n return {\n watch(row: HTMLElement): void {\n const note = (e: Event): void => {\n const t = e.target;\n if (!(t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement)) return;\n const text = !(t instanceof HTMLSelectElement);\n memos.set(row, { field: t, start: text ? (t as HTMLInputElement).selectionStart : null, end: text ? (t as HTMLInputElement).selectionEnd : null });\n };\n row.addEventListener(\"focusin\", note);\n row.addEventListener(\"input\", note);\n row.addEventListener(\"keyup\", note);\n row.addEventListener(\"mouseup\", note);\n // A blur the author made (the row still in the page) forgets; one caused by the row leaving the page\n // does not, and is what the cache puts back. Chromium drops the focus of a moved element LATE: the\n // blur arrives after the redraw, the row already back in the page, so a blur to nowhere just after a\n // redraw is the move's, and the focus goes straight back.\n // Chromium may also fire that blur synchronously, as the host clears its view and before the cache\n // has handed the row back: so the decision waits for the microtask, by which time a row the redraw\n // asked for again is marked as redrawn since the blur.\n row.addEventListener(\"focusout\", (e) => {\n const at = performance.now();\n const late = (e as FocusEvent).relatedTarget === null && at - (redrawn.get(row) ?? -Infinity) < 250;\n if (late && memos.has(row)) { queueMicrotask(() => put(row)); return; }\n queueMicrotask(() => {\n if ((redrawn.get(row) ?? -Infinity) >= at) { put(row); return; }\n if (row.isConnected && !row.contains(row.ownerDocument.activeElement)) memos.delete(row);\n });\n });\n },\n /** Give the focus back to the row, if the author was in it and has not gone anywhere else since. */\n restore(row: HTMLElement): void {\n if (!memos.has(row)) return;\n redrawn.set(row, performance.now());\n // At the microtask, not now: the event that caused the redraw may still note the caret.\n queueMicrotask(() => put(row));\n },\n restoring: (field: Element): boolean => restoringNow.has(field),\n /** Forget the row's focus if the author has since gone somewhere else (before the row is redrawn). */\n settle(row: HTMLElement): void {\n const active = row.ownerDocument.activeElement;\n if (active && active !== row.ownerDocument.body && !row.contains(active)) memos.delete(row);\n },\n /** The row the author is in (before a redraw takes it out). */\n holds: (row: HTMLElement): boolean => memos.has(row),\n };\n})();\n\n/**\n * The focus keeping `fieldRows` does, for a host (or a structured row) that keeps row elements itself: call\n * `settle` before it updates a row and `restore` once the row is back in the page.\n */\nexport const fieldRowFocus = {\n settle: (row: HTMLElement): void => keeper.settle(row),\n restore: (row: HTMLElement): void => keeper.restore(row),\n};\n\nexport interface FieldRows {\n /**\n * The row for `key` (a node and a field, say `${nodeId}:${field}`): the same element as last time when\n * there was one, updated for these options, else a new one. A row the author was typing in gets its focus\n * and caret back once the redraw has put it in the page.\n */\n row(key: string, opts: FieldRowOptions): HTMLElement;\n /** Forget every row not asked for since the last sweep (call at the end of a redraw). */\n sweep(): void;\n}\n\n/** A cache of field rows for a host that redraws its whole view on every change. */\nexport function fieldRows(): FieldRows {\n const rows = new Map<string, { handle: FieldRowHandle; used: boolean }>();\n return {\n row(key, opts) {\n const had = rows.get(key);\n if (had) {\n had.used = true;\n keeper.settle(had.handle.el);\n had.handle.update(opts);\n keeper.restore(had.handle.el);\n return had.handle.el;\n }\n const handle = fieldRow(opts);\n rows.set(key, { handle, used: true });\n return handle.el;\n },\n sweep() {\n for (const [key, entry] of rows) { if (!entry.used) rows.delete(key); else entry.used = false; }\n },\n };\n}\n","// ---------------------------------------------------------------------------\n// THE property declaration list: name, type, default, values or stages,\n// purpose, in a row per declaration, with reorder, remove, add-then-focus and\n// the duplicate / illegal-name gates. Patterpad's settings-properties.ts and\n// Storyletter's prop-list.ts were built from the same shell primitives in the\n// same order (dupGuard, bindPropertyName, a type select over the same six\n// types, defaultControl, three iconBtns on moveItem, labelled tagChips and\n// stageChips, expandableRow, focusNewRow); this is the one list, and each\n// app's extras (Shared, Temporary, Read-only, Durable) arrive through\n// `extraLine` / `extraDetails`.\n//\n// `defaultControl` was four copies (three inside Patterpad), and the two apps'\n// option labels had already parted (\"(unset)\" vs \"(none)\"). One label set now.\n//\n// Storage of the default differs by app: Patterpad's model holds a typed\n// value (true, 3), Storyletter's DTO holds the string the field showed. The\n// list mutates `decls` in place either way; `typed` picks the encoding.\n// ---------------------------------------------------------------------------\n\nimport { el } from \"./dom.js\";\nimport { iconBtn, labelled, moveItem, stageChips, tagChips } from \"./dom.js\";\nimport { dupGuard, expandableRow, focusNewRow } from \"./settings.js\";\nimport type { SettingsSectionHandle } from \"./settings.js\";\nimport { bindPropertyName, firstIllegalPropertyName } from \"./property-name-field.js\";\nimport { PROPERTY_NAME_HINT } from \"./property-names.js\";\nimport { defaultLabel, fallbackText } from \"./value-control.js\";\n\n/** The six types both apps declare. */\nexport type PropertyListType = \"number\" | \"boolean\" | \"string\" | \"enum\" | \"flags\" | \"quality\";\n\n/** The shape a row edits. Apps' DTOs carry more (shared, writable, durable);\n * those ride through untouched. */\nexport interface PropertyDeclLike {\n name: string;\n type: string;\n default?: unknown;\n /** enum / flags */\n values?: string[];\n /** quality: the ladder, in order */\n stages?: string[];\n purpose?: string;\n}\n\n/** The type list, in the family's order, with the words the select shows. */\nexport const PROPERTY_TYPES: ReadonlyArray<readonly [PropertyListType, string]> = [\n [\"number\", \"Number\"], [\"boolean\", \"True / False\"], [\"string\", \"Text\"],\n [\"enum\", \"List\"], [\"flags\", \"Flags\"], [\"quality\", \"Quality\"],\n];\n\nexport interface DefaultControlOptions {\n /**\n * How the default is stored. `false` (default): the string the field shows\n * (Storyletter's DTO). `true`: a typed value (boolean, number, string)\n * (Patterpad's model). Either way, no default given DELETES the key: a\n * default is optional in source, and the type's holds (the family's rule,\n * ruled 2026-10-18).\n */\n typed?: boolean;\n /**\n * An enum may hold \"\" (none chosen), as a field's may: the select then\n * offers \"(none)\" beside \"default (x)\". Off for a property, whose value is\n * always one of its values.\n */\n noneChosen?: boolean;\n /** What the blank says instead of the type's default, where something else holds when none is given\n * here: a tag's starting value falls back to its group's default, say. */\n unsetLabel?: string;\n}\n\nconst option = (value: string, label: string, selected: boolean): HTMLOptionElement => {\n const o = el(\"option\", undefined, label);\n o.value = value; o.selected = selected;\n return o;\n};\n\n/** The select value that stands for an enum's \"\" (none chosen), apart from no default at all. */\nconst NONE_CHOSEN = \"\\u0000none\";\n\n/**\n * The type-appropriate control for a declaration's DEFAULT: a true / false\n * picker for a boolean, the value list for an enum, the stage list for a\n * quality, a note for flags (a set starts empty), a number or text field\n * otherwise. Leaving it blank gives no default, and the blank says what holds\n * then, \"default (x)\" (`defaultLabel`): a default is optional, and the type's\n * fills in.\n */\nexport function defaultControl(p: PropertyDeclLike, onChange?: () => void, opts: DefaultControlOptions = {}): HTMLElement {\n const typed = opts.typed === true;\n const write = (raw: string): void => {\n if (raw === \"\") delete p.default;\n else if (raw === NONE_CHOSEN) p.default = \"\";\n else if (typed && p.type === \"boolean\") p.default = raw === \"true\";\n else if (typed && p.type === \"number\") p.default = Number(raw);\n else p.default = raw;\n onChange?.();\n };\n const current = p.default === undefined || p.default === null ? \"\" : String(p.default);\n // What a blank default falls back to, said on the blank itself: the type's, not this one's.\n const unsetLabel = opts.unsetLabel ?? defaultLabel({ ...p, default: undefined });\n if (p.type === \"boolean\") {\n const sel = el(\"select\", \"field set-default\");\n sel.append(option(\"\", unsetLabel, current === \"\"), option(\"true\", \"True\", current === \"true\"), option(\"false\", \"False\", current === \"false\"));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"enum\") {\n const sel = el(\"select\", \"field set-default\");\n const none = opts.noneChosen === true && p.default === \"\";\n sel.append(option(\"\", unsetLabel, current === \"\" && !none));\n if (opts.noneChosen) sel.append(option(NONE_CHOSEN, \"(none)\", none));\n for (const v of p.values ?? []) sel.append(option(v, v, current === v));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"quality\") {\n // The default is a STAGE; blank means the first rung, and says which.\n const sel = el(\"select\", \"field set-default\");\n sel.append(option(\"\", unsetLabel, current === \"\"));\n for (const v of p.stages ?? []) sel.append(option(v, v, current === v));\n sel.addEventListener(\"change\", () => write(sel.value));\n return sel;\n }\n if (p.type === \"flags\") {\n // Flags hold a SET of values, so there is no single default: it starts empty.\n const s = el(\"span\", \"set-flagnote\", \"Starts empty\");\n s.dataset[\"tip\"] = \"A flags property starts with none set.\";\n return s;\n }\n const input = el(\"input\", \"field set-default\");\n input.type = p.type === \"number\" ? \"number\" : \"text\";\n input.placeholder = p.type === \"number\" ? `Default (${fallbackText({ type: \"number\" })})` : \"Default\";\n input.value = current;\n input.addEventListener(\"input\", () => write(input.value));\n return input;\n}\n\nexport interface PropertyListOptions<T extends PropertyDeclLike> extends DefaultControlOptions {\n /** Called after every mutation; a centre editor feeds its autosave here. */\n onChange?: () => void;\n /** The add button's label. Default \"+ Add property\". */\n addLabel?: string;\n /** The empty sentence. Default \"No properties yet.\" */\n emptyText?: string;\n /** The type select's entries; default `PROPERTY_TYPES`. */\n types?: ReadonlyArray<readonly [string, string]>;\n /** A fresh declaration for the add button. Default: a blank of the first type. */\n newDecl?: () => T;\n /** Controls on the row's line, between the default and the movers\n * (Storyletter's \"uses\" affordance). */\n extraLine?: (decl: T, index: number) => (HTMLElement | null)[];\n /** Fields behind the disclosure, before Values / Stages / Purpose\n * (Shared, Temporary, Read-only, Durable). */\n extraDetails?: (decl: T, index: number) => (HTMLElement | null)[];\n /** Offer the Purpose field. Default true. */\n purpose?: boolean;\n /** What a row declares, in the row's own words (\"Field name\", \"What this field is for\", \"Delete\n * field\"). Default \"property\". */\n noun?: string;\n /**\n * The rule a name follows. `\"property\"` (default): the property-name rules, bound and gated, since an\n * expression must be able to reach it. `\"free\"`: any name, only duplicates refused, for a declaration no\n * expression reads (a Patterpad game-data field's name is the host's word).\n */\n names?: \"property\" | \"free\";\n /**\n * A quality's stage was renamed in place (the declaration's own default\n * already follows it). Given, the rename is handed here INSTEAD of\n * `onChange`, so the caller can carry every value that names the stage in\n * the same edit as the declaration; absent, it is an ordinary change.\n */\n onStageRename?: (decl: T, from: string, to: string) => void;\n /** A quality's stages were reordered (after `onChange`). `note` is a quiet\n * line under the stages for the caller to fill, such as how many gates\n * compare against the ladder. */\n onStageReorder?: (decl: T, note: HTMLElement) => void;\n}\n\nexport interface PropertyListHandle extends SettingsSectionHandle {\n /** Both faults, for the Save gate: a duplicate first, then an illegal name. */\n firstInvalid(): HTMLInputElement | null;\n /** The first name that clashes with another, or null. */\n firstDuplicate(): HTMLInputElement | null;\n /** The first name no expression could reach, or null. */\n firstIllegalName(): HTMLInputElement | null;\n /** Redraw from `decls` (after an outside change). */\n render(): void;\n}\n\n/** Mount the list into `host`. Mutates `decls` in place; the caller reads\n * them back on save (pruning blank names is the caller's, since only it\n * knows its DTO). */\nexport function mountPropertyList<T extends PropertyDeclLike>(host: HTMLElement, decls: T[], opts: PropertyListOptions<T> = {}): PropertyListHandle {\n const changed = (): void => opts.onChange?.();\n const guard = dupGuard();\n const types = opts.types ?? PROPERTY_TYPES;\n const list = el(\"div\", \"set-list\");\n const keep = (parts: (HTMLElement | null)[] | undefined): HTMLElement[] =>\n (parts ?? []).filter((p): p is HTMLElement => p !== null);\n\n const noun = opts.noun ?? \"property\";\n const Noun = noun.charAt(0).toUpperCase() + noun.slice(1);\n const freeNames = opts.names === \"free\";\n\n const row = (p: T, i: number): HTMLElement => {\n const name = el(\"input\", \"field set-name\");\n name.type = \"text\"; name.placeholder = `${Noun} name`; name.value = p.name; name.spellcheck = false;\n if (freeNames) name.addEventListener(\"input\", () => { p.name = name.value; changed(); });\n else {\n name.dataset[\"tip\"] = PROPERTY_NAME_HINT;\n bindPropertyName(name, (v) => { p.name = v; changed(); }, { hint: PROPERTY_NAME_HINT });\n }\n guard.track(name);\n\n const type = el(\"select\", \"field set-type\");\n for (const [v, label] of types) type.append(option(v, label, v === p.type));\n type.addEventListener(\"change\", () => {\n p.type = type.value;\n delete p.default; // a default rarely survives a type change: the new type's holds\n if (p.type === \"enum\" || p.type === \"flags\") p.values ??= []; else delete p.values;\n if (p.type === \"quality\") p.stages ??= []; else delete p.stages;\n render(); changed();\n });\n\n // The default control is rebuilt in place when the values change, so a\n // new value becomes selectable as the default.\n let def = defaultControl(p, changed, opts);\n const refreshDefault = (): void => { const fresh = defaultControl(p, changed, opts); def.replaceWith(fresh); def = fresh; changed(); };\n\n const up = iconBtn(\"up\", \"Move up\", () => { if (moveItem(decls, i, -1)) { render(); changed(); } }, i === 0);\n const down = iconBtn(\"down\", \"Move down\", () => { if (moveItem(decls, i, 1)) { render(); changed(); } }, i === decls.length - 1);\n const del = iconBtn(\"close\", `Delete ${noun}`, () => { decls.splice(i, 1); render(); changed(); }, false, true);\n\n const details: HTMLElement[] = keep(opts.extraDetails?.(p, i));\n if (p.type === \"enum\" || p.type === \"flags\") details.push(labelled(\"Values\", tagChips(p, refreshDefault)));\n // A quality's ladder, IN ORDER: the chips carry movers because position is the meaning.\n if (p.type === \"quality\") {\n const note = el(\"p\", \"shell-stage-note\");\n const stages = stageChips(p, refreshDefault, {\n onRename: (from, to) => {\n if (p.default === from) p.default = to;\n const fresh = defaultControl(p, changed, opts); def.replaceWith(fresh); def = fresh;\n if (opts.onStageRename) opts.onStageRename(p, from, to); else changed();\n },\n onReorder: () => opts.onStageReorder?.(p, note),\n });\n details.push(labelled(\"Stages (in order)\", stages), note);\n }\n if (opts.purpose !== false) {\n const purpose = el(\"input\", \"field set-purpose\");\n purpose.type = \"text\"; purpose.placeholder = `What this ${noun} is for`; purpose.value = p.purpose ?? \"\";\n purpose.addEventListener(\"input\", () => {\n if (purpose.value.trim()) p.purpose = purpose.value; else delete p.purpose;\n changed();\n });\n details.push(labelled(\"Purpose\", purpose));\n }\n // Stamped with the declared name so \"Go to definition\" lands on the row (revealRow).\n return expandableRow({ line: [name, type, def, ...keep(opts.extraLine?.(p, i)), up, down, del], details, name: p.name });\n };\n\n const render = (): void => {\n guard.reset();\n list.replaceChildren();\n if (decls.length === 0) list.append(el(\"p\", \"empty\", opts.emptyText ?? \"No properties yet.\"));\n else decls.forEach((p, i) => list.append(row(p, i)));\n guard.check();\n };\n render();\n\n const add = el(\"button\", \"btn set-add\", opts.addLabel ?? \"+ Add property\");\n add.type = \"button\";\n add.addEventListener(\"click\", () => {\n decls.push(opts.newDecl ? opts.newDecl() : ({ name: \"\", type: types[0]?.[0] ?? \"string\", ...(opts.typed ? {} : { default: \"\" }) } as unknown as T));\n render(); changed(); focusNewRow(list);\n });\n host.append(list, add);\n\n return {\n firstDuplicate: () => guard.firstDuplicate(),\n firstIllegalName: () => (freeNames ? null : firstIllegalPropertyName(host)),\n // The Save gate takes both faults; the field's own rollover says which.\n firstInvalid: () => guard.firstDuplicate() ?? (freeNames ? null : firstIllegalPropertyName(host)),\n render,\n };\n}\n"]}
|