@ofrnsb/whiteboard 0.0.0-stage → 0.1.0
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 +70 -2
- package/dist/boards-ykaNj5ns.d.ts +540 -0
- package/dist/chunk-ORDEALPW.js +1981 -0
- package/dist/chunk-ORDEALPW.js.map +1 -0
- package/dist/cli/index.js +2272 -0
- package/dist/core/index.d.ts +1495 -0
- package/dist/core/index.js +809 -0
- package/dist/core/index.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +3745 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +794 -0
- package/package.json +70 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/config.ts","../src/core/illustrations.ts","../src/core/board-geometry.ts","../src/core/line-icons.ts","../src/core/copy.ts","../src/core/boards.ts","../src/core/free-board.ts"],"sourcesContent":["// Limits and sizes of the board model (from simpul config/data.ts).\nexport const LEN = {\n prefix: 6, short: 12, tag: 30, id: 40, name: 60, key: 64, label: 80, title: 120, ident: 128, line: 200, host: 255,\n message: 300, note: 400, para: 500, detail: 600, text: 1000, long: 2000, doc: 4000, instructions: 12000,\n} as const;\n\nexport const BOARD = {\n note: { w: 200, h: 120 }, gap: 16, pad: 24, head: 48,\n maxNotes: 400, maxLinks: 400, maxTabs: 12, maxRows: 2000, maxCols: 40, maxText: 2000, maxInkPoints: 4000, inkWeight: { min: 1, max: 400 }, coordLimit: 100_000,\n minSize: { mark: { w: 24, h: 16 }, shape: { w: 80, h: 40 }, note: { w: 120, h: 80 } },\n frame: { default: { w: 480, h: 360 }, min: { w: 160, h: 100 } },\n gridSectionsPerRow: 3, gridNotesPerRow: 2,\n textRows: 200,\n draw: {\n pad: 24, head: 48, gapX: 16, gapY: 12, sectionGap: 40, wrapAt: 1150, stackSlack: 160, aspect: 2.2, flowGapX: 56, diagramGap: { x: 64, y: 48 }, belowExisting: 96,\n item: { stack: { w: 560, h: 56 }, grid: { w: 200, h: 88 }, row: { w: 184, h: 80 }, flow: { w: 168, h: 88 }, diagram: { w: 184, h: 72 }, timeline: { w: 200, h: 120 }, matrix: { w: 176, h: 56 } },\n heading: { w: 720, h: 44, step: 52, subH: 28, subStep: 36, titleRoom: 40, titleCharW: 22, stickerGap: 24 },\n /** An emoji card: room for the illustration above the title. */\n iconCard: { extraH: 64 },\n sticker: { w: 112, h: 112, captionH: 28 },\n /** The road: cards alternate above and below a gentle wave; `step` is the distance between milestones. */\n timeline: { step: 136, amp: 34, waveSteps: 2.4, sample: 24, lead: 56, cardGap: 56, pill: { w: 88, h: 32 }, dot: { w: 22, h: 22 }, trackPad: 24, labelH: 32 },\n matrix: { headW: 132, headH: 40, cellW: 208, cellMinH: 96, cellPad: 12, itemGap: 8, gap: 6 },\n /** A hand-composed section: its own space in board units, and the limits on what the agent may place in it. */\n free: { w: 2200, h: 920, titleH: 56, titleGap: 12, titleMinW: 320, titleCharW: 13, itemW: 220, itemH: 120, gap: 24, strokes: 24, points: 80, strokeW: { pena: { s: 3, m: 6, l: 10 }, spidol: { s: 8, m: 14, l: 22 } } },\n /**\n * The marker sketch. Letter widths are Patrick Hand's measured average advance per em (lower and upper case), with a\n * little slack for word wrap. Blocks and loose text come in four sizes; the board measures every item with these\n * same numbers before placing it, so words always fit their outline.\n */\n sketch: {\n lower: 0.36, upper: 0.43, wrapSlack: 1.12, pad: 14, gap: 18, groupPad: 26, groupTitle: 40, roundInner: 0.76,\n block: { s: { title: 19, titleLh: 23, text: 16, textLh: 20, icon: 34 }, m: { title: 24, titleLh: 28, text: 20, textLh: 25, icon: 52 }, l: { title: 32, titleLh: 37, text: 24, textLh: 30, icon: 72 }, xl: { title: 44, titleLh: 50, text: 30, textLh: 37, icon: 92 } },\n words: { s: { size: 20, lh: 25, upper: false }, m: { size: 26, lh: 31, upper: false }, l: { size: 32, lh: 37, upper: true }, xl: { size: 46, lh: 50, upper: true } },\n headline: { w: 1500, gapBelow: 10, contextW: 1500, below: 34, iconGap: 28, icon: 96 },\n pillH: 46, maxPush: 60,\n },\n /**\n * A free board: items where the agent put them, `gap` kept between any two, sticky notes `noteW` wide parked\n * `noteGap` from what they are about. Sticky notes are lettered in the board's own type: about `noteChar` wide\n * per letter at 14px, `noteLh` a line, `noteTop` for the margins.\n */\n tell: {\n widths: { s: 240, m: 300, l: 380, xl: 480 }, minTextW: 150, gap: 56, noteW: 230, noteMaxW: 330, noteGap: 16, below: 80,\n minAspect: { diamond: 0.75, triangle: 0.8, pentagon: 0.85, hexagon: 0.5, parallelogram: 0.3 },\n noteChar: 7.2, noteLh: 20, noteTop: 34, notePad: 32, maxItems: 40,\n legend: { fact: \"black: facts\", problem: \"red: what goes wrong\", action: \"green: what we do\", insight: \"purple: what it means\", person: \"blue: people and desks\", system: \"orange: systems and data\", note: \"yellow notes: what I said while drawing\", wires: \"black wires: the main flow; each layer of detail below it has its own wire colour (1 blue, 2 teal, 3 violet, 4 orange, 5 magenta, 6 olive, 7 brown, 8 slate, 9 cyan)\" },\n },\n sectionItems: 60, gridColumns: 6, gridColumnsDefault: 2, textItemH: 32, minFrameW: 280, titleCharW: 8, minFrameExtraH: 40,\n fit: { charW: 7.2, minLineW: 80, inset: 28, base: 24, lineH: 20, titleGap: 4 },\n },\n /** Sticky notes of a column or grid board (retro, brainstorm): square-ish with large text. */\n sticky: { w: 168, h: 140, top: 30, titleLh: 21, titleCharW: 8.4, byH: 16, charW: 7.2, lh: 20, pad: 32 },\n} as const;\n\nexport const COUNT = { xxs: 3, xs: 4, s: 5, sm: 6, ms: 8, m: 10, ml: 12, l: 20, xl: 30, wide: 40, xxl: 50, long: 60, huge: 100, max: 200, bulk: 500, points: 4000 } as const;\n\nexport const BOARD_ARGS = {\n ref: 40, why: 200, title: { min: 3, max: 120 }, noteText: 1_000, owner: 80, due: 40, sectionTitle: 120, sectionNotes: 60, sections: 12,\n cell: 1_000, colName: 60, options: 40, option: 80, formula: 200, itemTitle: 120, itemText: 600, gridMax: 12, subtitle: 200,\n sectionCols: 6, items: 60, linkLabel: 60, headingTitle: 200, headingSubtitle: 300, connectors: 80, beats: 16, beatItems: 40, say: 220, freeSpan: 20_000, kids: 8, answer: 320, noteIds: 200,\n columns: 40, rows: 2_000, tabs: 8, addNotes: 100, moveNotes: 400, updates: 200, addLinks: 60, addColumns: 20, addTabs: 6, editNote: 120, listed: 40,\n} as const;\nexport const LOOSE_NOTES = { perRow: 3, dx: 216, dy: 136 } as const;\nexport const SECTION_NOTE_INSET = 24;\nexport const BOARD_EDITS_KEPT = 20;\nexport const BOARD_CHATS_KEPT = 20;\nexport const BOARD_HISTORY = { whiteboardEdits: 60, opsMax: 400, opsBytes: 200_000, activityMs: 30_000, stepMs: 900, stepsTotalMs: 12_000, beat: { baseMs: 1_600, perItemMs: 320, maxMs: 4_800, sayChars: 140 }, cardsPerStep: 2, planMs: 1_400, planMax: 200 } as const;\n","// The names of the whiteboard's illustrations (Naive Icons, MIT, vendored in components/lego/boards/illustrations.ts).\n// The agent picks one per card or sticker by name; nothing else, no emoji, is ever drawn as an illustration.\n\nexport const ILLUSTRATIONS = [\n // money and documents\n \"invoice\", \"receipt\", \"banknote\", \"coin\", \"wallet\", \"credit-card\", \"bank\", \"piggy-bank\", \"safe\", \"cash-register\", \"calculator\",\n \"ledger\", \"budget\", \"tax\", \"refund\", \"loan\", \"audit\", \"currency-dollar\", \"file-text\", \"file-check\", \"file-spreadsheet\",\n \"clipboard-check\", \"rubber-stamp\", \"signature\",\n // performance and planning\n \"trending-up\", \"bar-chart\", \"line-chart\", \"pie-chart\", \"darts\", \"trophy\", \"medal\", \"rocket\", \"bulb\", \"milestone\", \"kanban\",\n \"layout-dashboard\", \"presentation\",\n // time and contact\n \"calendar\", \"calendar-check\", \"clock\", \"hourglass\", \"timer\", \"phone\", \"mail\", \"chat\", \"messages\", \"megaphone\", \"bell-ring\",\n // people\n \"user\", \"users\", \"briefcase\", \"id-card\", \"office-chair\",\n // operations and logistics\n \"truck\", \"van\", \"forklift\", \"warehouse\", \"factory\", \"store\", \"shopping-cart\", \"cargo-ship\", \"route\", \"map-pin\", \"globe\",\n \"barcode\", \"archive\", \"toolbox\",\n // control and risk\n \"alert-triangle\", \"check-circle\", \"shield-check\", \"lock\", \"courthouse\", \"hammer\", \"scale\", \"search\", \"flag\", \"stop-sign\", \"signpost\",\n // systems\n \"database\", \"server\", \"cloud\", \"settings\", \"refresh\", \"laptop\", \"exchange\",\n] as const;\n\nexport type Illustration = (typeof ILLUSTRATIONS)[number];\n\nconst NAMES = new Set<string>(ILLUSTRATIONS);\nexport const isIllustration = (x: unknown): x is Illustration => typeof x === \"string\" && NAMES.has(x);\n","// Geometry a free board shares between the server, which places what the agent drew, and the browser, which draws\n// it: the outlines of the polygon shapes and the room they leave for words, wires routed around every item, a spot\n// for a wire's label where the wire stays visible, and the nearest free spot for something that would overlap.\n//\n// Both sides route with the same function over the same items in the same order, so a wire the server kept clear of\n// later items is the wire the browser draws.\n\nexport type Box = { x: number; y: number; w: number; h: number };\n/** An item a wire may start or end at; its shape says where its outline meets its box. */\nexport type Item = Box & { shape?: string };\n\n/** Polygon outlines as points in a unit square, and the part of the square their words may use (top, right, bottom, left). */\nexport const POLYGONS = {\n diamond: { pts: [[0.5, 0], [1, 0.5], [0.5, 1], [0, 0.5]], inset: [0.24, 0.22, 0.24, 0.22] },\n triangle: { pts: [[0.5, 0], [1, 1], [0, 1]], inset: [0.46, 0.24, 0.06, 0.24] },\n pentagon: { pts: [[0.5, 0], [1, 0.38], [0.81, 1], [0.19, 1], [0, 0.38]], inset: [0.26, 0.15, 0.06, 0.15] },\n hexagon: { pts: [[0.24, 0], [0.76, 0], [1, 0.5], [0.76, 1], [0.24, 1], [0, 0.5]], inset: [0.08, 0.17, 0.08, 0.17] },\n parallelogram: { pts: [[0.16, 0], [1, 0], [0.84, 1], [0, 1]], inset: [0.06, 0.17, 0.06, 0.17] },\n} as const;\nexport type Polygon = keyof typeof POLYGONS;\nexport const isPolygon = (s: unknown): s is Polygon => typeof s === \"string\" && s in POLYGONS;\n\n/** The polygon's points at a size, as \"x,y x,y ...\" pairs. */\nexport const polygonPoints = (p: Polygon, w: number, h: number): [number, number][] =>\n POLYGONS[p].pts.map(([x, y]) => [Math.round(1 + x * (w - 2)), Math.round(1 + y * (h - 2))]);\n\n/** Padding (top, right, bottom, left in px) that keeps words inside a polygon of this size. */\nexport const polygonPad = (p: Polygon, w: number, h: number): [number, number, number, number] => {\n const [t, r, b, l] = POLYGONS[p].inset;\n return [Math.round(t * h), Math.round(r * w), Math.round(b * h), Math.round(l * w)];\n};\n\n/**\n * Lines a text takes in a width, wrapped word by word the way the browser does: a word that does not fit starts the\n * next line, a word longer than the line breaks across lines, and each written line break starts a new line.\n */\nexport function wrapLines(s: string | undefined, charW: number, width: number): number {\n if (!s) return 0;\n const max = Math.max(40, width);\n let n = 0;\n for (const part of s.split(\"\\n\")) {\n let line = 0;\n n += 1;\n for (const word of part.split(/\\s+/).filter(Boolean)) {\n const ww = word.length * charW;\n if (line && line + charW + ww > max) { n += 1; line = 0; }\n if (ww > max) { n += Math.ceil(ww / max) - 1; line = ww % max; } else line += (line ? charW : 0) + ww;\n }\n }\n return n;\n}\n\nconst hits = (a: Box, b: Box, gap = 0) => a.x < b.x + b.w + gap && b.x < a.x + a.w + gap && a.y < b.y + b.h + gap && b.y < a.y + a.h + gap;\nexport const overlaps = (a: Box, list: readonly Box[], gap = 0) => list.some((b) => hits(a, b, gap));\n\n/**\n * The nearest place for a box that keeps `gap` from everything taken, searched outwards from where it was asked for.\n * What is already on the board never moves; only the newcomer does.\n */\nexport function freeSpot(want: Box, taken: readonly Box[], gap: number, step = 24, reach = 4000): Box {\n if (!overlaps(want, taken, gap)) return want;\n for (let r = step; r <= reach; r += step) {\n // The ring at distance r (Chebyshev), nearest points first, so the move is as small as it can be.\n const ring: [number, number][] = [];\n for (let d = -r; d <= r; d += step) ring.push([d, -r], [d, r], [-r, d], [r, d]);\n ring.sort((p, q) => Math.hypot(p[0], p[1]) - Math.hypot(q[0], q[1]) || p[1] - q[1] || p[0] - q[0]);\n for (const [dx, dy] of ring) {\n const b = { ...want, x: want.x + dx, y: want.y + dy };\n if (!overlaps(b, taken, gap)) return b;\n }\n }\n return want;\n}\n\n// ---------- Wires ----------\n\n/** Grid cell and clearance in px; costs in cells: a bend, crossing a wire, running along one, and leaving by a side that faces away. */\nexport const WIRE = { cell: 16, clear: 18, margin: 360, bend: 20, cross: 6, along: 30, away: 8 } as const;\nexport type Wire = { from: string; to: string; label?: string };\nexport type Routed = { pts: number[]; label?: { x: number; y: number; w: number; h: number } };\n\n/** A label's box on a wire: its width from the letters, measured the way the board letters it. */\nexport const labelSize = (label: string, charW: number) => ({ w: Math.round(label.length * charW + 24), h: 30 });\n\ntype Side = 0 | 1 | 2 | 3; // up, right, down, left\nconst DX = [0, 1, 0, -1], DY = [-1, 0, 1, 0];\n\nclass Heap {\n private a: number[] = [];\n private k: number[] = [];\n get size() { return this.a.length; }\n // Ties break on the node number, so the same board always routes the same way.\n private less(i: number, j: number) { return this.k[i] < this.k[j] || (this.k[i] === this.k[j] && this.a[i] < this.a[j]); }\n private swap(i: number, j: number) { [this.a[i], this.a[j]] = [this.a[j], this.a[i]]; [this.k[i], this.k[j]] = [this.k[j], this.k[i]]; }\n push(v: number, key: number) {\n this.a.push(v); this.k.push(key);\n let i = this.a.length - 1;\n while (i > 0) { const p = (i - 1) >> 1; if (!this.less(i, p)) break; this.swap(i, p); i = p; }\n }\n pop(): number {\n const top = this.a[0], last = this.a.length - 1;\n this.swap(0, last); this.a.pop(); this.k.pop();\n let i = 0;\n for (;;) {\n const l = i * 2 + 1, r = l + 1;\n let m = i;\n if (l < this.a.length && this.less(l, m)) m = l;\n if (r < this.a.length && this.less(r, m)) m = r;\n if (m === i) break;\n this.swap(i, m); i = m;\n }\n return top;\n }\n}\n\n/**\n * Where a shape's outline touches its box, as fractions along each side (up, right, down, left): a wire leaves and\n * arrives only there, so its end always meets the drawn outline. A box takes a quarter, half and three quarters.\n */\nconst ALONG: Record<string, number[][]> = {\n ellipse: [[0.5], [0.5], [0.5], [0.5]], cloud: [[0.5], [0.5], [0.5], [0.5]], diamond: [[0.5], [0.5], [0.5], [0.5]],\n triangle: [[0.5], [], [0.5, 0.3, 0.7], []], pentagon: [[0.5], [0.38], [0.5, 0.3, 0.7], [0.38]],\n hexagon: [[0.5, 0.35, 0.65], [0.5], [0.5, 0.35, 0.65], [0.5]], parallelogram: [[0.58, 0.35, 0.8], [], [0.42, 0.2, 0.65], []],\n};\nconst BOX_ALONG = [[0.5, 0.25, 0.75], [0.5, 0.25, 0.75], [0.5, 0.25, 0.75], [0.5, 0.25, 0.75]];\n/** Shapes whose sides are straight all along, so a wire may leave anywhere on them. */\nconst FLAT = new Set([undefined, \"box\", \"note\", \"cylinder\", \"text\"]);\nfunction ports(b: Item, other: Item): { x: number; y: number; side: Side; off: number }[] {\n const out: { x: number; y: number; side: Side; off: number }[] = [];\n const along = ((b.shape && ALONG[b.shape]) || BOX_ALONG).map((fs) => [...fs]);\n // Two flat-sided items that overlap side by side (or one above the other) are joined by a straight wire: both get a\n // port in the middle of the stretch they share.\n if (FLAT.has(b.shape) && FLAT.has(other.shape)) {\n const y0 = Math.max(b.y, other.y), y1 = Math.min(b.y + b.h, other.y + other.h);\n if (y1 - y0 > 24) { const f = ((y0 + y1) / 2 - b.y) / b.h; along[1].unshift(f); along[3].unshift(f); }\n const x0 = Math.max(b.x, other.x), x1 = Math.min(b.x + b.w, other.x + other.w);\n if (x1 - x0 > 24) { const f = ((x0 + x1) / 2 - b.x) / b.w; along[0].unshift(f); along[2].unshift(f); }\n }\n // A side that faces away from the other item costs extra: the wire would have to turn back round the item.\n const dx = other.x + other.w / 2 - (b.x + b.w / 2), dy = other.y + other.h / 2 - (b.y + b.h / 2);\n const facing = [dy < 0, dx > 0, dy > 0, dx < 0];\n along.forEach((fs, side) => fs.forEach((f, k) => {\n const off = (k === 0 ? 0 : 2) + (facing[side] ? 0 : WIRE.away);\n if (side === 0) out.push({ x: b.x + b.w * f, y: b.y, side: 0, off });\n else if (side === 1) out.push({ x: b.x + b.w, y: b.y + b.h * f, side: 1, off });\n else if (side === 2) out.push({ x: b.x + b.w * f, y: b.y + b.h, side: 2, off });\n else out.push({ x: b.x, y: b.y + b.h * f, side: 3, off });\n }));\n return out;\n}\n\n/**\n * Wires drawn in order, each one orthogonal, around every item (never through one), leaving and entering at a side,\n * preferring few bends and keeping apart from the wires already drawn. `labelW` measures a label.\n */\nexport function routeWires(items: ReadonlyMap<string, Item>, wires: readonly Wire[], labelW: (s: string) => { w: number; h: number }): Map<number, Routed> {\n const out = new Map<number, Routed>();\n const boxes = [...items.values()];\n const usedH = new Set<string>(), usedV = new Set<string>();\n const labels: Box[] = [];\n wires.forEach((wire, i) => {\n const a = items.get(wire.from), c = items.get(wire.to);\n if (!a || !c || wire.from === wire.to) return;\n const pts = routeOne(a, c, boxes, usedH, usedV) ?? fallback(a, c);\n for (let k = 0; k + 3 < pts.length; k += 2) mark(pts[k], pts[k + 1], pts[k + 2], pts[k + 3], usedH, usedV);\n const r: Routed = { pts };\n if (wire.label) {\n const spot = labelSpot(pts, labelW(wire.label), [...boxes, ...labels]);\n r.label = spot;\n labels.push(spot);\n }\n out.set(i, r);\n });\n return out;\n}\n\nconst key = (x: number, y: number) => `${Math.round(x / WIRE.cell)},${Math.round(y / WIRE.cell)}`;\nfunction mark(x1: number, y1: number, x2: number, y2: number, usedH: Set<string>, usedV: Set<string>) {\n const n = Math.max(1, Math.round(Math.hypot(x2 - x1, y2 - y1) / WIRE.cell));\n const set = y1 === y2 ? usedH : usedV;\n for (let s = 0; s <= n; s++) set.add(key(x1 + ((x2 - x1) * s) / n, y1 + ((y2 - y1) * s) / n));\n}\n\nfunction routeOne(a: Item, c: Item, boxes: readonly Box[], usedH: Set<string>, usedV: Set<string>): number[] | null {\n for (const margin of [WIRE.margin, WIRE.margin * 3]) {\n const r = search(a, c, boxes, usedH, usedV, margin);\n if (r) return r;\n }\n return null;\n}\n\nfunction search(a: Item, c: Item, boxes: readonly Box[], usedH: Set<string>, usedV: Set<string>, margin: number): number[] | null {\n const C = WIRE.cell;\n const x0 = Math.floor((Math.min(a.x, c.x) - margin) / C) * C, y0 = Math.floor((Math.min(a.y, c.y) - margin) / C) * C;\n const x1 = Math.max(a.x + a.w, c.x + c.w) + margin, y1 = Math.max(a.y + a.h, c.y + c.h) + margin;\n const W = Math.ceil((x1 - x0) / C) + 1, H = Math.ceil((y1 - y0) / C) + 1;\n if (W * H > 400_000) return null;\n const cx = (i: number) => x0 + i * C, cy = (j: number) => y0 + j * C;\n // A cell is closed when it lies within the clearance of any item, the wire's own two ends included.\n const blocked = new Uint8Array(W * H);\n for (const b of boxes) {\n if (!hits(b, { x: x0, y: y0, w: x1 - x0, h: y1 - y0 })) continue;\n const i0 = Math.max(0, Math.ceil((b.x - WIRE.clear - x0) / C)), i1 = Math.min(W - 1, Math.floor((b.x + b.w + WIRE.clear - x0) / C));\n const j0 = Math.max(0, Math.ceil((b.y - WIRE.clear - y0) / C)), j1 = Math.min(H - 1, Math.floor((b.y + b.h + WIRE.clear - y0) / C));\n for (let j = j0; j <= j1; j++) for (let i = i0; i <= i1; i++) blocked[j * W + i] = 1;\n }\n // Leaving a box: from a port, straight out past the clearance to the first open cell.\n const exits = (b: Item, other: Item) => ports(b, other).map((p) => {\n let i = Math.round((p.x - x0) / C), j = Math.round((p.y - y0) / C);\n if (p.side === 0 || p.side === 2) i = Math.min(Math.max(i, Math.ceil((b.x + 4 - x0) / C)), Math.floor((b.x + b.w - 4 - x0) / C));\n else j = Math.min(Math.max(j, Math.ceil((b.y + 4 - y0) / C)), Math.floor((b.y + b.h - 4 - y0) / C));\n const px = p.side === 0 || p.side === 2 ? cx(i) : p.x, py = p.side === 1 || p.side === 3 ? cy(j) : p.y;\n // Out through the box's own clearance only: a port with something else right outside it is not a way out.\n const own = { x: b.x - WIRE.clear - 1, y: b.y - WIRE.clear - 1, w: b.w + WIRE.clear * 2 + 2, h: b.h + WIRE.clear * 2 + 2 };\n let steps = 0;\n while (steps === 0 || (cx(i) >= own.x && cx(i) <= own.x + own.w && cy(j) >= own.y && cy(j) <= own.y + own.h)) { i += DX[p.side]; j += DY[p.side]; steps++; }\n return { i, j, px, py, side: p.side, steps, off: p.off };\n }).filter((e) => e.i >= 0 && e.j >= 0 && e.i < W && e.j < H && !blocked[e.j * W + e.i]);\n const from = exits(a, c), to = exits(c, a);\n if (!from.length || !to.length) return null;\n const goal = new Map<number, (typeof to)[number]>();\n // Entering the target: the wire arrives moving into the side, the opposite of leaving it.\n for (const e of to) { const n = e.j * W + e.i, d = (e.side + 2) % 4; if (!goal.has(n * 4 + d)) goal.set(n * 4 + d, e); }\n const g = new Float64Array(W * H * 4).fill(Infinity), prev = new Int32Array(W * H * 4).fill(-1);\n const start = new Map<number, (typeof from)[number]>();\n const heap = new Heap();\n const hx = (i: number, j: number) => Math.min(...to.map((e) => Math.abs(e.i - i) + Math.abs(e.j - j)));\n for (const e of from) {\n const s = (e.j * W + e.i) * 4 + e.side;\n const cost = e.steps + e.off;\n if (cost < g[s]) { g[s] = cost; start.set(s, e); heap.push(s, cost + hx(e.i, e.j)); }\n }\n let end = -1;\n while (heap.size) {\n const s = heap.pop();\n if (goal.has(s)) { end = s; break; }\n const n = s >> 2, d = s & 3, i = n % W, j = (n - i) / W;\n for (let nd = 0; nd < 4; nd++) {\n if (nd === (d + 2) % 4) continue;\n const ni = i + DX[nd], nj = j + DY[nd];\n if (ni < 0 || nj < 0 || ni >= W || nj >= H || blocked[nj * W + ni]) continue;\n const k = key(cx(ni), cy(nj));\n const horiz = nd === 1 || nd === 3;\n const pen = (horiz ? usedH : usedV).has(k) ? WIRE.along : (horiz ? usedV : usedH).has(k) ? WIRE.cross : 0;\n const t = (nj * W + ni) * 4 + nd, cost = g[s] + 1 + (nd !== d ? WIRE.bend : 0) + pen;\n if (cost < g[t]) { g[t] = cost; prev[t] = s; heap.push(t, cost + hx(ni, nj)); }\n }\n }\n if (end < 0) return null;\n const cells: [number, number][] = [];\n let s = end;\n while (s >= 0) { const n = s >> 2, i = n % W; cells.push([cx(i), cy((n - i) / W)]); if (start.has(s)) break; s = prev[s]; }\n cells.reverse();\n const a0 = start.get(s)!, c0 = goal.get(end)!;\n const raw: [number, number][] = [[a0.px, a0.py], ...cells, [c0.px, c0.py]];\n return simplify(raw);\n}\n\n/** Drops the points in the middle of a straight run. */\nfunction simplify(p: [number, number][]): number[] {\n const out: [number, number][] = [];\n for (const q of p) {\n if (out.length && out[out.length - 1][0] === q[0] && out[out.length - 1][1] === q[1]) continue;\n if (out.length >= 2) {\n const [ax, ay] = out[out.length - 2], [bx, by] = out[out.length - 1];\n if ((ax === bx && bx === q[0]) || (ay === by && by === q[1])) { out[out.length - 1] = q; continue; }\n }\n out.push(q);\n }\n return out.flat();\n}\n\n/** With no way around (an item walled in), a plain elbow between the facing sides. */\nfunction fallback(a: Box, c: Box): number[] {\n const ax = a.x + a.w / 2, ay = a.y + a.h / 2, cx = c.x + c.w / 2, cy = c.y + c.h / 2;\n if (Math.abs(cx - ax) >= Math.abs(cy - ay)) {\n const x1 = cx > ax ? a.x + a.w : a.x, x2 = cx > ax ? c.x : c.x + c.w, mx = (x1 + x2) / 2;\n return [x1, ay, mx, ay, mx, cy, x2, cy];\n }\n const y1 = cy > ay ? a.y + a.h : a.y, y2 = cy > ay ? c.y : c.y + c.h, my = (y1 + y2) / 2;\n return [ax, y1, ax, my, cx, my, cx, y2];\n}\n\n/**\n * Where a wire's label goes: on the longest run with wire showing on both sides of it, clear of every item and label;\n * failing that, beside the run, so a label never hides the wire it names.\n */\nexport function labelSpot(pts: number[], size: { w: number; h: number }, avoid: readonly Box[]): Box {\n const runs: { x1: number; y1: number; x2: number; y2: number; len: number }[] = [];\n for (let k = 0; k + 3 < pts.length; k += 2) runs.push({ x1: pts[k], y1: pts[k + 1], x2: pts[k + 2], y2: pts[k + 3], len: Math.hypot(pts[k + 2] - pts[k], pts[k + 3] - pts[k + 1]) });\n const order = [...runs].sort((p, q) => q.len - p.len);\n const at = (x: number, y: number): Box => ({ x: Math.round(x - size.w / 2), y: Math.round(y - size.h / 2), w: size.w, h: size.h });\n const SHOW = 28;\n for (const r of order) {\n const horiz = r.y1 === r.y2;\n if (r.len < (horiz ? size.w : size.h) + SHOW * 2) continue;\n const b = at((r.x1 + r.x2) / 2, (r.y1 + r.y2) / 2);\n if (!overlaps(b, avoid, 4)) return b;\n }\n for (const r of order) {\n const horiz = r.y1 === r.y2, mx = (r.x1 + r.x2) / 2, my = (r.y1 + r.y2) / 2;\n const sides = horiz ? [at(mx, my - size.h / 2 - 6), at(mx, my + size.h / 2 + 6)] : [at(mx + size.w / 2 + 8, my), at(mx - size.w / 2 - 8, my)];\n for (const b of sides) if (!overlaps(b, avoid, 4)) return b;\n }\n const r = order[0];\n return r ? at((r.x1 + r.x2) / 2, (r.y1 + r.y2) / 2 - size.h) : at(pts[0], pts[1]);\n}\n\n/** A routed wire as thin boxes along its runs, so later items keep clear of it. */\nexport function wireBoxes(pts: number[], pad = 6): Box[] {\n const out: Box[] = [];\n for (let k = 0; k + 3 < pts.length; k += 2) {\n const x = Math.min(pts[k], pts[k + 2]), y = Math.min(pts[k + 1], pts[k + 3]);\n out.push({ x: x - pad, y: y - pad, w: Math.abs(pts[k + 2] - pts[k]) + pad * 2, h: Math.abs(pts[k + 3] - pts[k + 1]) + pad * 2 });\n }\n return out;\n}\n","// The line drawings a sketched board can use beside its words, by name. Vendored from Lucide (ISC) by\n// scripts/vendor/lucide-icons.mjs into src/components/lego/boards/line-icons.ts.\nexport const LINE_ICONS = [\n \"phone\", \"phone-call\", \"phone-incoming\", \"phone-missed\", \"headset\", \"message-circle\", \"message-square\", \"messages-square\", \"mail\", \"send\", \"bell\", \"megaphone\",\n \"user\", \"users\", \"user-check\", \"user-x\", \"user-plus\", \"contact\", \"crown\", \"star\", \"heart\", \"handshake\", \"briefcase\", \"building\", \"landmark\", \"store\", \"house\",\n \"credit-card\", \"wallet\", \"banknote\", \"coins\", \"piggy-bank\", \"receipt\", \"percent\", \"badge-dollar-sign\", \"hand-coins\", \"globe\", \"plane\", \"map-pin\", \"car\",\n \"database\", \"server\", \"cloud\", \"cpu\", \"bot\", \"brain\", \"sparkles\", \"wand\", \"zap\", \"plug\", \"workflow\", \"network\", \"git-branch\", \"layers\", \"boxes\", \"package\", \"truck\",\n \"search\", \"list-checks\", \"clipboard-check\", \"clipboard-list\", \"file-text\", \"files\", \"folder\", \"book-open\", \"notebook-pen\", \"pencil\", \"calculator\",\n \"chart-bar\", \"chart-line\", \"chart-pie\", \"chart-no-axes-combined\", \"trending-up\", \"trending-down\", \"target\", \"gauge\", \"activity\", \"funnel\",\n \"calendar\", \"calendar-check\", \"calendar-clock\", \"clock\", \"timer\", \"hourglass\", \"repeat\", \"refresh-cw\", \"infinity\", \"rocket\", \"flag\", \"milestone\",\n \"check\", \"circle-check\", \"x\", \"circle-x\", \"octagon-x\", \"shield\", \"shield-check\", \"lock\", \"key\", \"eye\", \"thumbs-up\", \"thumbs-down\",\n \"lightbulb\", \"info\", \"scale\", \"gavel\", \"award\", \"trophy\", \"gift\", \"ticket\", \"tag\", \"shopping-cart\", \"smartphone\", \"laptop\", \"monitor\", \"wifi\",\n \"arrow-right\", \"arrow-down\", \"arrow-up-right\", \"corner-down-right\", \"split\", \"merge\", \"plus\", \"minus\", \"equal\", \"ban\", \"hand\", \"pointer\",\n] as const;\nexport type LineIcon = (typeof LINE_ICONS)[number];\nconst NAMES = new Set<string>(LINE_ICONS);\nexport const isLineIcon = (x: unknown): x is LineIcon => typeof x === \"string\" && NAMES.has(x);\n","// Words the board model writes into a board's text (from simpul copy/server.ts).\nexport const ERR = {\n nBarisLagi: (a: unknown) => `\\n... ${a} more rows`,\n membuatPapan: \"made the board\",\n batchNotFound: \"That piece of agent work is not in this board's history.\",\n batchChangedSince: (who: string[]) => `${who.join(\", \")} changed the board after the agent did. Undo version by version from History so their changes are not lost.`,\n versionNotKept: (v: number) => `Version ${v} is no longer kept in this board's history.`,\n luarBagianN: (a: unknown) => `Outside sections\\n${a}`,\n};\nexport const WORDS = { yes: \"Yes\", no: \"No\", agent: \"Agent\", untitled: \"Untitled\", created: \"created\", you: \"You\" } as const;\n","import { isIllustration, type Illustration } from \"./illustrations.ts\";\nimport { freeSpot, wrapLines, type Box } from \"./board-geometry.ts\";\nimport { isLineIcon, type LineIcon } from \"./line-icons.ts\";\nimport { ERR, WORDS } from \"./copy.ts\";\nimport { BOARD, LEN } from \"./config.ts\";\n// Whiteboards and sheets: shared, editable work surfaces the agent makes and the team keeps working on.\n// Pure and shared by server and client: the client applies an edit at once, the server applies the same edit and\n// returns the board, so both always agree. Every change is an op; nobody sends a whole board back.\n\nexport type BoardMode = \"whiteboard\" | \"sheet\" | \"tasks\";\n/** Tints for slips and boxes; paper, ink and red are the ledger's own (ink = the highlighted element, red = what needs action). */\n/** outline = an empty frame of a box (not built yet); new = the accent edge (new in this step). Both for staged pictures. */\n/** orange, peach and sand are the warm card tones of an illustrated timeline. */\nexport const NOTE_COLORS = [\"yellow\", \"blue\", \"green\", \"pink\", \"purple\", \"gray\", \"paper\", \"ink\", \"red\", \"outline\", \"new\", \"orange\", \"peach\", \"sand\"] as const;\nexport type NoteColor = (typeof NOTE_COLORS)[number];\n/** What a board item is drawn as. Older boards have none: those are notes. */\n/**\n * track: the thick winding road a timeline runs along (its path is `points`); pill: a milestone marker on it (\"Hari 7\");\n * dot: a small numbered step between milestones; cell: one cell of a matrix (calendar, swimlane);\n * sticker: a large free-standing illustration with no card around it (a truck on the road, a bank by the title).\n */\nexport const SHAPES = [\"note\", \"box\", \"text\", \"ellipse\", \"cloud\", \"cylinder\", \"ink\", \"track\", \"pill\", \"dot\", \"cell\", \"sticker\", \"diamond\", \"triangle\", \"pentagon\", \"hexagon\", \"parallelogram\"] as const;\n/** Shapes that hold a title and words inside an outline. */\nexport const OUTLINED = new Set<Shape>([\"box\", \"ellipse\", \"cloud\", \"cylinder\", \"diamond\", \"triangle\", \"pentagon\", \"hexagon\", \"parallelogram\"]);\nexport type Shape = (typeof SHAPES)[number];\nexport const TEXT_SIZES = [\"s\", \"m\", \"l\", \"xl\"] as const;\nexport type TextSize = (typeof TEXT_SIZES)[number];\n\nexport type WbNote = {\n id: string; text: string; x: number; y: number; w: number; h: number; color: NoteColor; frame: string | null; owner?: string; due?: string; by: string;\n shape?: Shape;\n /** Bold first line of a box (\"Agent core\") above its text. */\n title?: string;\n /** The illustration drawn large at the top of a card, by name from ILLUSTRATIONS (\"truck\", \"invoice\"). */\n icon?: string;\n /** Drawn in marker: outline, words and drawing in this ink, no fill. */\n pen?: Pen;\n /** A sketched outline drawn as dashes: optional, planned, or a loose group. */\n dashed?: boolean;\n size?: TextSize;\n /** Pen strokes: x,y pairs relative to the item's top-left. */\n points?: number[];\n /** Pen pressure per point (0..1), only when the device gave real pressure; without it the stroke simulates it. */\n pressure?: number[];\n /** A pen stroke's width in board units, set from the zoom it was drawn at so it keeps its size on screen. */\n weight?: number;\n /** How a pen stroke is drawn: a clean nib (the default) or a marker. */\n brush?: (typeof BRUSHES)[number];\n};\nexport const BRUSHES = [\"pena\", \"spidol\"] as const;\nexport type WbFrame = { id: string; title: string; x: number; y: number; w: number; h: number; subtitle?: string };\n/** `auto`: the board routes the wire itself, around every item. */\nexport const ROUTES = [\"straight\", \"elbow\", \"curve\", \"auto\"] as const;\n/** `layer`: how deep in the explanation the wire runs (0 the main flow, up to 9); it sets the wire's colour. */\nexport type WbLink = { id: string; from: string; to: string; label?: string; route?: (typeof ROUTES)[number]; dashed?: boolean; arrow?: \"end\" | \"both\" | \"none\"; layer?: number };\nexport const MAX_LAYER = 9;\n\nexport const COL_TYPES = [\"text\", \"number\", \"money\", \"date\", \"select\", \"check\"] as const;\nexport type ColType = (typeof COL_TYPES)[number];\nexport type CellValue = string | number | boolean | null;\nexport type SheetCol = { id: string; name: string; type: ColType; options?: string[]; formula?: string; total?: \"sum\" | \"avg\" | \"count\" | null; width?: number };\nexport type SheetRow = { id: string; cells: Record<string, CellValue> };\nexport type SheetTab = { id: string; name: string; columns: SheetCol[]; rows: SheetRow[] };\n\n/** What changed last, so the UI can outline it (\"each new edit is outlined so you can track changes\"). */\n/** One change, with the ops that made it, so any browser can animate it or step back through the board's history. */\nexport type BoardEdit = { at: string; by: string; agent: boolean; what: string; keys: string[]; version?: number; ops?: BoardOp[];\n /** The piece of agent work this edit belongs to (see BoardActivity.batch). */\n batch?: string;\n /** Set on a batch's edits when a person keeps or undoes that piece of agent work. */\n decided?: { by: string; at: string; how: \"kept\" | \"undone\" };\n /** The agent's one-line reason for this change, read out when the history is replayed (\"Hari 21 ditambah: maks. 1 reminder per 7 hari\"). */\n why?: string;\n /** A beat of a told board: `what` is the sentence said while it was drawn, so the board shows that, not the kind of item. */\n told?: boolean };\n\n/** Where the agent is about to put something: shown as faint footprints before each item is drawn into its place. */\nexport type PlannedItem = { id: string; kind: \"frame\" | \"track\" | \"pill\" | \"dot\" | \"card\" | \"sticker\" | \"text\" | \"cell\" | \"shape\"; x: number; y: number; w: number; h: number };\n\n/** Who is working on the board right now; fresh for BOARD_ACTIVITY_MS after `at`. Teammates see the agent working live. */\nexport type BoardActivity = {\n by: string; agent: boolean; what: string; at: string; chatId?: string; keys?: string[];\n /** The agent's plan for this piece of work: every item it is about to add, set when the work starts. */\n plan?: PlannedItem[];\n /** One piece of agent work (one tool call): its edits share it, so the whole piece can be kept or undone together. */\n batch?: string;\n};\n\n/** The board as it was before the oldest edit still kept, so history can be rebuilt as base + the ops of each kept edit. */\nexport type BoardBase = { version: number; title: string; frames: WbFrame[]; notes: WbNote[]; links: WbLink[]; tabs: SheetTab[] };\n\nexport type Board = {\n id: string; ref: string; tenantId: string; unitId: string; projectId: string | null;\n title: string; mode: BoardMode;\n createdBy: string; createdAt: string; updatedAt: string; updatedBy: string; version: number;\n frames: WbFrame[]; notes: WbNote[]; links: WbLink[];\n tabs: SheetTab[];\n edits: BoardEdit[];\n /** Conversations that made, changed or read the board, newest first. Boards saved before this have none. */\n chats?: BoardChat[];\n activity?: BoardActivity;\n base?: BoardBase;\n};\n\nexport type BoardChat = { chatId: string; userId: string; at: string; what: \"created\" | \"edited\" | \"read\" };\n\nexport type BoardOp =\n | { op: \"title\"; title: string }\n | { op: \"note.add\"; note: Partial<WbNote> & { id: string; text: string; x: number; y: number } }\n | { op: \"note.update\"; id: string; patch: Partial<Omit<WbNote, \"id\" | \"by\">> }\n | { op: \"note.remove\"; id: string }\n | { op: \"frame.add\"; frame: Partial<WbFrame> & { id: string; title: string; x: number; y: number } }\n | { op: \"frame.update\"; id: string; patch: Partial<Omit<WbFrame, \"id\">> }\n /** Moves the frame and every note inside it. */\n | { op: \"frame.move\"; id: string; dx: number; dy: number }\n | { op: \"frame.remove\"; id: string; keepNotes?: boolean }\n | { op: \"link.add\"; link: WbLink }\n | { op: \"link.update\"; id: string; patch: Partial<Omit<WbLink, \"id\" | \"from\" | \"to\">> }\n | { op: \"link.remove\"; id: string }\n | { op: \"tab.add\"; tab: { id: string; name: string; columns?: SheetCol[] } }\n | { op: \"tab.rename\"; tab: string; name: string }\n | { op: \"tab.remove\"; tab: string }\n | { op: \"col.add\"; tab: string; col: SheetCol; at?: number }\n | { op: \"col.update\"; tab: string; id: string; patch: Partial<Omit<SheetCol, \"id\">> }\n | { op: \"col.remove\"; tab: string; id: string }\n | { op: \"row.add\"; tab: string; row: SheetRow; at?: number }\n | { op: \"row.remove\"; tab: string; id: string }\n | { op: \"cell.set\"; tab: string; row: string; col: string; value: CellValue }\n /** Server only (never accepted from a browser): puts back the whole content of an earlier version. */\n | { op: \"restore\"; to: BoardBase };\n\nexport const NOTE_W = BOARD.note.w;\nexport const NOTE_H = BOARD.note.h;\nconst GAP = BOARD.gap;\nconst PAD = BOARD.pad;\nconst HEAD = BOARD.head;\nexport const MAX_NOTES = BOARD.maxNotes;\nexport const MAX_ROWS = BOARD.maxRows;\nexport const MAX_COLS = BOARD.maxCols;\nconst MAX_TEXT = BOARD.maxText;\n\n/** Emoji never reach the board: illustrations are drawings, and an emoji font varies by device. */\n/**\n * A task board is a sheet seen as lanes, so any process fits it (To do/Doing/Done, Lead/Won, Admitted/Ward/Discharged):\n * its first tab, the first choice column as the lane, the first text column as the card title, every other column a\n * field on the card. Moving a card is setting its lane cell, with the same history, undo and live edits as a sheet.\n */\nexport function taskShape(b: Pick<Board, \"tabs\">) {\n const tab = b.tabs[0];\n const lane = tab?.columns.find((c) => c.type === \"select\");\n const title = tab?.columns.find((c) => c.type === \"text\" && !c.formula);\n if (!tab || !lane || !title) return null;\n return { tab, lane, title, lanes: lane.options ?? [], fields: tab.columns.filter((c) => c.id !== lane.id && c.id !== title.id) };\n}\n\n/** The ops that lay out a new task board: one tab, its title and lane columns first, then the other fields and the cards. */\nexport function taskBoardOps(o: { tab: string; title: string; lane: string; lanes: string[]; fields: Omit<SheetCol, \"id\">[]; cards: Record<string, CellValue>[] }): BoardOp[] {\n const cols: SheetCol[] = [{ id: uid(\"c\"), name: o.title, type: \"text\" }, { id: uid(\"c\"), name: o.lane, type: \"select\", options: o.lanes }, ...o.fields.map((f) => ({ ...f, id: uid(\"c\") }))];\n const tid = uid(\"t\");\n const byName = new Map(cols.map((c) => [c.name.toLowerCase(), c.id]));\n return [\n { op: \"tab.add\", tab: { id: tid, name: o.tab, columns: cols } },\n ...o.cards.map((card): BoardOp => ({ op: \"row.add\", tab: tid, row: { id: uid(\"r\"), cells: Object.fromEntries(Object.entries(card).flatMap(([k, v]) => { const id = byName.get(k.toLowerCase()); return id ? [[id, v]] : []; })) } })),\n ];\n}\n\nexport const noEmoji = (s: string) => s.replace(/[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u{FE0F}\\u{200D}]/gu, \"\").replace(/\\s{2,}/g, \" \").trim();\n\n/** A card's illustration is one of the board's drawings by name; anything else (an emoji, a word) is dropped. */\nexport function validIcon(s?: string): Illustration | LineIcon | undefined {\n const t = s?.trim().toLowerCase();\n return isIllustration(t) || isLineIcon(t) ? t : undefined;\n}\n\n/** Marker colours of a sketched item: its outline, words and drawing are all in that one ink. */\nexport const PENS = [\"black\", \"blue\", \"green\", \"red\", \"purple\", \"orange\"] as const;\nexport type Pen = (typeof PENS)[number];\n\nexport const uid = (prefix: string) => `${prefix}${Math.random().toString(36).slice(2, 8)}${Date.now().toString(36).slice(-3)}`;\nconst clampText = (s: string) => s.slice(0, MAX_TEXT);\nconst finite = (n: unknown, d = 0) => (typeof n === \"number\" && Number.isFinite(n) ? Math.max(-BOARD.coordLimit, Math.min(BOARD.coordLimit, n)) : d);\n\n/** The frame a point falls in, topmost (last drawn) first. */\nexport function frameAt(b: Pick<Board, \"frames\">, x: number, y: number): string | null {\n for (let i = b.frames.length - 1; i >= 0; i--) {\n const f = b.frames[i];\n if (x >= f.x && x <= f.x + f.w && y >= f.y && y <= f.y + f.h) return f.id;\n }\n return null;\n}\n\nfunction cellFor(col: SheetCol, v: CellValue): CellValue {\n if (v === null || v === \"\") return null;\n switch (col.type) {\n case \"number\": case \"money\": {\n const n = typeof v === \"number\" ? v : Number(String(v).replace(/\\s/g, \"\").replace(/^Rp/i, \"\").replace(/\\.(?=\\d{3}(\\D|$))/g, \"\").replace(\",\", \".\"));\n return Number.isFinite(n) ? n : null;\n }\n case \"check\": return v === true || v === 1 || (typeof v === \"string\" && [\"true\", \"ya\", \"yes\", \"1\", \"x\", \"✓\"].includes(v.trim().toLowerCase()));\n case \"date\": return /^\\d{4}-\\d{2}-\\d{2}/.test(String(v)) ? String(v).slice(0, 10) : null;\n case \"select\": return String(v).slice(0, LEN.label);\n default: return clampText(String(v));\n }\n}\n\n/** Text and pen marks can be small; slips and boxes keep room for a line of text. */\nconst MARKS: (Shape | undefined)[] = [\"text\", \"ink\", \"track\", \"pill\", \"dot\", \"cell\", \"sticker\"];\nexport function minSize(shape?: Shape): { w: number; h: number } {\n return { ...(MARKS.includes(shape) ? BOARD.minSize.mark : shape && OUTLINED.has(shape) ? BOARD.minSize.shape : BOARD.minSize.note) };\n}\n\nfunction shapeFields(n: Partial<WbNote>): Partial<WbNote> {\n const out: Partial<WbNote> = {};\n if (n.shape && SHAPES.includes(n.shape) && n.shape !== \"note\") out.shape = n.shape;\n if (n.title) out.title = noEmoji(n.title).slice(0, LEN.title);\n if (n.size && TEXT_SIZES.includes(n.size)) out.size = n.size;\n const icon = validIcon(n.icon);\n if (icon) out.icon = icon;\n if (n.pen && PENS.includes(n.pen)) out.pen = n.pen;\n if (n.dashed === true) out.dashed = true;\n if (Array.isArray(n.points) && (n.shape === \"ink\" || n.shape === \"track\")) out.points = n.points.slice(0, BOARD.maxInkPoints).map((v) => Math.round(finite(v) * 10) / 10);\n if (n.shape === \"ink\" && n.brush && BRUSHES.includes(n.brush)) out.brush = n.brush;\n if (n.shape === \"ink\" && typeof n.weight === \"number\" && Number.isFinite(n.weight)) out.weight = Math.round(Math.min(BOARD.inkWeight.max, Math.max(BOARD.inkWeight.min, n.weight)) * 10) / 10;\n if (Array.isArray(n.pressure) && n.shape === \"ink\") out.pressure = n.pressure.slice(0, BOARD.maxInkPoints / 2).map((v) => Math.round(Math.min(1, Math.max(0, finite(v))) * 100) / 100);\n return out;\n}\n\nfunction linkFields(l: Partial<WbLink>): Partial<WbLink> {\n return {\n ...(l.label ? { label: l.label.slice(0, LEN.name) } : {}),\n ...(l.route && ROUTES.includes(l.route) ? { route: l.route } : {}),\n ...(l.dashed ? { dashed: true } : {}),\n ...(l.arrow === \"both\" || l.arrow === \"none\" ? { arrow: l.arrow } : {}),\n ...(typeof l.layer === \"number\" && l.layer >= 1 ? { layer: Math.min(MAX_LAYER, Math.round(l.layer)) } : {}),\n };\n}\n\n/**\n * Applies ops to a copy of the board. Ops on things that no longer exist (someone else removed them) are skipped,\n * so two people editing at once never break the board; the later edit to the same field wins.\n */\nexport function applyOps(board: Board, ops: BoardOp[], by: string, now = new Date().toISOString()): Board {\n const b: Board = structuredClone(board);\n const tab = (id: string) => b.tabs.find((t) => t.id === id);\n for (const o of ops) {\n switch (o.op) {\n case \"title\": b.title = o.title.trim().slice(0, LEN.title) || b.title; break;\n case \"note.add\": {\n if (b.notes.length >= MAX_NOTES || b.notes.some((n) => n.id === o.note.id)) break;\n const x = finite(o.note.x), y = finite(o.note.y);\n const color = NOTE_COLORS.includes(o.note.color as NoteColor) ? (o.note.color as NoteColor) : \"yellow\";\n const min = minSize(o.note.shape);\n b.notes.push({\n id: o.note.id, text: clampText(o.note.text), x, y, w: Math.max(min.w, finite(o.note.w, NOTE_W) || NOTE_W), h: Math.max(min.h, finite(o.note.h, NOTE_H) || NOTE_H), color,\n frame: o.note.frame !== undefined ? o.note.frame : frameAt(b, x + NOTE_W / 2, y + NOTE_H / 2),\n ...(o.note.owner ? { owner: o.note.owner.slice(0, LEN.label) } : {}), ...(o.note.due ? { due: o.note.due.slice(0, LEN.id) } : {}), by,\n ...shapeFields(o.note),\n });\n break;\n }\n case \"note.update\": {\n const n = b.notes.find((x) => x.id === o.id);\n if (!n) break;\n const p = o.patch;\n if (p.text !== undefined) n.text = clampText(p.text);\n if (p.x !== undefined) n.x = finite(p.x, n.x);\n if (p.y !== undefined) n.y = finite(p.y, n.y);\n const min = minSize(p.shape ?? n.shape);\n if (p.w !== undefined) n.w = Math.max(min.w, finite(p.w, n.w));\n if (p.h !== undefined) n.h = Math.max(min.h, finite(p.h, n.h));\n Object.assign(n, shapeFields({ ...n, ...p }));\n if (p.title === \"\") delete n.title;\n if (p.color && NOTE_COLORS.includes(p.color)) n.color = p.color;\n if (p.owner !== undefined) n.owner = p.owner?.slice(0, LEN.label) || undefined;\n if (p.due !== undefined) n.due = p.due?.slice(0, LEN.id) || undefined;\n if (p.frame !== undefined) n.frame = p.frame && b.frames.some((f) => f.id === p.frame) ? p.frame : null;\n else if (p.x !== undefined || p.y !== undefined) n.frame = frameAt(b, n.x + n.w / 2, n.y + n.h / 2);\n break;\n }\n case \"note.remove\": b.notes = b.notes.filter((n) => n.id !== o.id); b.links = b.links.filter((l) => l.from !== o.id && l.to !== o.id); break;\n case \"frame.add\":\n if (b.frames.some((f) => f.id === o.frame.id)) break;\n b.frames.push({ id: o.frame.id, title: o.frame.title.slice(0, LEN.title), x: finite(o.frame.x), y: finite(o.frame.y), w: Math.max(BOARD.frame.min.w, finite(o.frame.w, BOARD.frame.default.w)), h: Math.max(BOARD.frame.min.h, finite(o.frame.h, BOARD.frame.default.h)), ...(o.frame.subtitle ? { subtitle: o.frame.subtitle.slice(0, 200) } : {}) });\n break;\n case \"frame.update\": {\n const f = b.frames.find((x) => x.id === o.id);\n if (!f) break;\n if (o.patch.title !== undefined) f.title = o.patch.title.slice(0, LEN.title);\n if (o.patch.x !== undefined) f.x = finite(o.patch.x, f.x);\n if (o.patch.y !== undefined) f.y = finite(o.patch.y, f.y);\n if (o.patch.w !== undefined) f.w = Math.max(BOARD.frame.min.w, finite(o.patch.w, f.w));\n if (o.patch.h !== undefined) f.h = Math.max(BOARD.frame.min.h, finite(o.patch.h, f.h));\n if (o.patch.subtitle !== undefined) { if (o.patch.subtitle) f.subtitle = o.patch.subtitle.slice(0, LEN.line); else delete f.subtitle; }\n break;\n }\n case \"frame.move\": {\n const f = b.frames.find((x) => x.id === o.id);\n if (!f) break;\n const dx = finite(o.dx), dy = finite(o.dy);\n f.x += dx; f.y += dy;\n for (const n of b.notes) if (n.frame === f.id) { n.x += dx; n.y += dy; }\n break;\n }\n case \"frame.remove\":\n b.frames = b.frames.filter((f) => f.id !== o.id);\n b.notes = o.keepNotes === false ? b.notes.filter((n) => n.frame !== o.id) : b.notes.map((n) => (n.frame === o.id ? { ...n, frame: null } : n));\n break;\n case \"link.add\":\n if (b.links.length < BOARD.maxLinks && !b.links.some((l) => l.id === o.link.id) && [o.link.from, o.link.to].every((id) => b.notes.some((n) => n.id === id) || b.frames.some((f) => f.id === id)))\n b.links.push({ id: o.link.id, from: o.link.from, to: o.link.to, ...linkFields(o.link) });\n break;\n case \"link.update\": {\n const l = b.links.find((x) => x.id === o.id);\n if (!l) break;\n Object.assign(l, linkFields({ ...l, ...o.patch }));\n if (o.patch.label === \"\") delete l.label;\n break;\n }\n case \"link.remove\": b.links = b.links.filter((l) => l.id !== o.id); break;\n case \"tab.add\":\n if (b.tabs.length < BOARD.maxTabs && !tab(o.tab.id)) b.tabs.push({ id: o.tab.id, name: o.tab.name.slice(0, LEN.name) || `Tab ${b.tabs.length + 1}`, columns: (o.tab.columns ?? []).slice(0, MAX_COLS), rows: [] });\n break;\n case \"tab.rename\": { const t = tab(o.tab); if (t) t.name = o.name.slice(0, LEN.name) || t.name; break; }\n case \"tab.remove\": if (b.tabs.length > 1) b.tabs = b.tabs.filter((t) => t.id !== o.tab); break;\n case \"col.add\": {\n const t = tab(o.tab);\n if (!t || t.columns.length >= MAX_COLS || t.columns.some((c) => c.id === o.col.id)) break;\n const c: SheetCol = { ...o.col, name: o.col.name.slice(0, LEN.name), type: COL_TYPES.includes(o.col.type) ? o.col.type : \"text\" };\n t.columns.splice(o.at ?? t.columns.length, 0, c);\n break;\n }\n case \"col.update\": {\n const c = tab(o.tab)?.columns.find((x) => x.id === o.id);\n if (!c) break;\n Object.assign(c, o.patch);\n if (!COL_TYPES.includes(c.type)) c.type = \"text\";\n c.name = c.name.slice(0, LEN.name);\n break;\n }\n case \"col.remove\": {\n const t = tab(o.tab);\n if (!t) break;\n t.columns = t.columns.filter((c) => c.id !== o.id);\n for (const r of t.rows) delete r.cells[o.id];\n break;\n }\n case \"row.add\": {\n const t = tab(o.tab);\n if (!t || t.rows.length >= MAX_ROWS || t.rows.some((r) => r.id === o.row.id)) break;\n const cells: Record<string, CellValue> = {};\n for (const c of t.columns) if (o.row.cells[c.id] !== undefined && !c.formula) cells[c.id] = cellFor(c, o.row.cells[c.id]);\n t.rows.splice(o.at ?? t.rows.length, 0, { id: o.row.id, cells });\n break;\n }\n case \"row.remove\": { const t = tab(o.tab); if (t) t.rows = t.rows.filter((r) => r.id !== o.id); break; }\n case \"restore\": {\n const to = structuredClone(o.to);\n b.title = to.title; b.frames = to.frames; b.notes = to.notes; b.links = to.links; b.tabs = to.tabs;\n break;\n }\n case \"cell.set\": {\n const t = tab(o.tab);\n const c = t?.columns.find((x) => x.id === o.col);\n const r = t?.rows.find((x) => x.id === o.row);\n if (c && r && !c.formula) r.cells[c.id] = cellFor(c, o.value);\n break;\n }\n }\n }\n b.version = board.version + 1;\n b.updatedAt = now;\n b.updatedBy = by;\n return b;\n}\n\n/** The keys an op touches, for outlining what the agent changed. */\nexport function opKeys(ops: BoardOp[]): string[] {\n return ops.flatMap((o) => {\n switch (o.op) {\n case \"note.add\": return [o.note.id];\n case \"note.update\": case \"note.remove\": case \"frame.update\": case \"frame.move\": case \"frame.remove\": case \"link.remove\": case \"link.update\": case \"row.remove\": return [o.id];\n case \"frame.add\": return [o.frame.id];\n case \"cell.set\": return [`${o.row}:${o.col}`];\n case \"row.add\": return [o.row.id];\n case \"col.add\": return [o.col.id];\n case \"col.update\": case \"col.remove\": return [o.id];\n default: return [];\n }\n });\n}\n\n// ---------- History: base + the ops of each kept edit rebuild any version ----------\n\n/** The content of a board, as kept in its base and carried by a restore. */\nexport const contentOf = (b: Pick<Board, \"version\" | \"title\" | \"frames\" | \"notes\" | \"links\" | \"tabs\">): BoardBase =>\n structuredClone({ version: b.version, title: b.title, frames: b.frames, notes: b.notes, links: b.links, tabs: b.tabs });\n\n/** One step of the history as the browser lists it; `replayable` is false where the ops were too big to keep. */\nexport type HistoryItem = { version: number; at: string; by: string; agent: boolean; what: string; why?: string; keys: string[]; replayable: boolean; batch?: string; decided?: BoardEdit[\"decided\"]; told?: boolean };\n\nexport function historyOf(board: Board): HistoryItem[] {\n const from = board.base?.version ?? Infinity;\n return board.edits.flatMap((e) => (e.version === undefined ? [] : [{\n version: e.version, at: e.at, by: e.by, agent: e.agent, what: e.what, ...(e.why ? { why: e.why } : {}), keys: e.keys,\n replayable: !!e.ops && e.version > from, ...(e.batch ? { batch: e.batch } : {}), ...(e.decided ? { decided: e.decided } : {}), ...(e.told ? { told: true } : {}),\n }]));\n}\n\nconst PLAN_KIND: Record<string, PlannedItem[\"kind\"]> = { note: \"card\", box: \"shape\", ellipse: \"shape\", cloud: \"shape\", cylinder: \"shape\", diamond: \"shape\", triangle: \"shape\", pentagon: \"shape\", hexagon: \"shape\", parallelogram: \"shape\", text: \"text\", track: \"track\", pill: \"pill\", dot: \"dot\", cell: \"cell\", sticker: \"sticker\" };\n\n/** Where a piece of work is about to put things: one footprint per added note or frame, in the order they will land. */\nexport function planOf(ops: BoardOp[], max = 200): PlannedItem[] {\n const out: PlannedItem[] = [];\n for (const o of ops) {\n if (out.length >= max) break;\n if (o.op === \"frame.add\") out.push({ id: o.frame.id, kind: \"frame\", x: o.frame.x, y: o.frame.y, w: o.frame.w ?? NOTE_W, h: o.frame.h ?? NOTE_H });\n else if (o.op === \"note.add\" && o.note.shape !== \"ink\") {\n const k = PLAN_KIND[o.note.shape ?? \"note\"];\n if (k) out.push({ id: o.note.id, kind: k, x: o.note.x, y: o.note.y, w: o.note.w ?? NOTE_W, h: o.note.h ?? NOTE_H });\n }\n }\n return out;\n}\n\n/** The latest piece of agent work nobody has kept or undone yet: what every viewer is asked to decide on. */\nexport type PendingBatch = { id: string; by: string; what: string; why?: string; keys: string[]; at: string };\nexport function pendingBatchOf(board: Pick<Board, \"edits\">): PendingBatch | null {\n const last = [...board.edits].reverse().find((e) => e.agent && e.batch);\n if (!last?.batch) return null;\n const mine = board.edits.filter((e) => e.batch === last.batch);\n if (mine.some((e) => e.decided)) return null;\n const first = mine[0];\n return { id: last.batch, by: first.by, what: first.what, ...(first.why ? { why: first.why } : {}), keys: [...new Set(mine.flatMap((e) => e.keys))].slice(0, 400), at: last.at };\n}\n\n/** The board as it was at `version`, rebuilt from its base; null when that version is no longer kept (or never was). */\nexport function boardAt(board: Board, version: number): Board | null {\n if (version === board.version) return board;\n const base = board.base;\n if (!base || version < base.version || version > board.version) return null;\n let b: Board = { ...structuredClone(board), ...structuredClone(base), activity: undefined };\n for (const e of board.edits) {\n if (e.version === undefined || e.version <= base.version) continue;\n if (e.version > version) break;\n if (!e.ops || e.version !== b.version + 1) return null;\n b = applyOps(b, e.ops, e.by, e.at);\n }\n return b.version === version ? b : null;\n}\n\n/** Folds an edit into the base when it is trimmed from the history, so base + the rest still rebuild the board. */\nexport function foldIntoBase(base: BoardBase, e: BoardEdit, shell: Board): BoardBase {\n if (e.version === undefined || e.version <= base.version || !e.ops) return base;\n return contentOf(applyOps({ ...shell, ...structuredClone(base) }, e.ops, e.by, e.at));\n}\n\n// ---------- Steps: the order the agent builds a board in, so it can be watched growing ----------\n\nexport type BuildStep = { kind: \"frame\" | \"road\" | \"marks\" | \"cards\" | \"changes\" | \"links\" | \"stickers\"; ops: BoardOp[] };\nconst CARD_SHAPES = new Set<string | undefined>([undefined, \"note\", ...OUTLINED]);\n\n/**\n * Splits a drawing into the steps a designer would take: heading and frames, the road, milestones, cards in reading\n * order (along the road for a timeline, top to bottom then left to right otherwise, `perStep` at a time), other changes,\n * the lines between things, then free stickers. Dependencies hold: frames before what sits in them, items before links.\n */\nexport function stepsOf(ops: BoardOp[], perStep = 6): BuildStep[] {\n const frame: BoardOp[] = [], road: BoardOp[] = [], marks: BoardOp[] = [], cards: Extract<BoardOp, { op: \"note.add\" }>[] = [], changes: BoardOp[] = [], links: BoardOp[] = [], stickers: BoardOp[] = [];\n for (const o of ops) {\n if (o.op === \"frame.add\" || o.op === \"title\") frame.push(o);\n else if (o.op === \"link.add\") links.push(o);\n else if (o.op !== \"note.add\") changes.push(o);\n else if (o.note.shape === \"text\" || o.note.shape === \"cell\") frame.push(o);\n else if (o.note.shape === \"track\") road.push(o);\n else if (o.note.shape === \"pill\" || o.note.shape === \"dot\") marks.push(o);\n else if (o.note.shape === \"sticker\") stickers.push(o);\n else if (CARD_SHAPES.has(o.note.shape)) cards.push(o);\n else changes.push(o);\n }\n const along = road.length > 0;\n cards.sort((a, b) => (along ? a.note.x - b.note.x : Math.round(a.note.y / 40) - Math.round(b.note.y / 40) || a.note.x - b.note.x));\n const steps: BuildStep[] = [];\n if (frame.length) steps.push({ kind: \"frame\", ops: frame });\n if (road.length) steps.push({ kind: \"road\", ops: road });\n if (marks.length) steps.push({ kind: \"marks\", ops: marks });\n for (let i = 0; i < cards.length; i += Math.max(1, perStep)) steps.push({ kind: \"cards\", ops: cards.slice(i, i + Math.max(1, perStep)) });\n if (changes.length) steps.push({ kind: \"changes\", ops: changes });\n if (links.length) steps.push({ kind: \"links\", ops: links });\n if (stickers.length) steps.push({ kind: \"stickers\", ops: stickers });\n return steps.length ? steps : [{ kind: \"changes\", ops }];\n}\n\n// ---------- Layout: the agent says what goes together, the board decides where it goes ----------\n\nexport type Section = { title: string; subtitle?: string; notes: { text: string; title?: string; icon?: string; owner?: string; due?: string; color?: NoteColor }[] };\nexport type LayoutKind = \"columns\" | \"timeline\" | \"grid\";\nexport type Heading = { title: string; subtitle?: string; icon?: string };\n\n/** What a section is about decides its sticky colour when the agent did not pick one: green went well, pink is a problem, blue an idea, purple a risk. */\nconst MEANING: [RegExp, NoteColor][] = [\n [/baik|berhasil|sukses|lancar|good|well|win|keep/i, \"green\"],\n [/kendala|masalah|hambatan|gagal|problem|issue|obstacle|block|challenge/i, \"pink\"],\n [/peluang|ide|usul|perbaik|opportunit|idea|improve|try/i, \"blue\"],\n [/risiko|bahaya|ancaman|risk|concern|threat/i, \"purple\"],\n];\nexport const colorFor = (title: string, fallback: NoteColor): NoteColor => MEANING.find(([re]) => re.test(title))?.[1] ?? fallback;\n\nconst DRH = BOARD.draw.heading;\n/** A big title, a one-line subtitle and an optional sticker beside the title. Returns the height used. */\nfunction headingOps(ops: BoardOp[], h: Heading, x: number, y: number, id: () => string = () => uid(\"n\")): { h: number; right: number } {\n const top = y;\n // A long title wraps; everything under it moves down by the extra lines so nothing overlaps.\n const lines = Math.max(1, Math.ceil((h.title.length * DRH.titleCharW) / DRH.w));\n ops.push({ op: \"note.add\", note: { id: id(), shape: \"text\", size: \"xl\", text: noEmoji(h.title).slice(0, LEN.line), x, y, w: DRH.w, h: DRH.h * lines, color: \"paper\", frame: null } });\n let right = x + DRH.w;\n // The subtitle stops short of the sticker beside the title, so the two never overlap.\n let subW: number = DRH.w;\n const icon = validIcon(h.icon);\n if (icon) {\n const sx = x + Math.min(DRH.w, h.title.length * DRH.titleCharW) + DRH.stickerGap;\n subW = Math.min(DRH.w, sx - x - DRH.stickerGap / 2);\n ops.push({ op: \"note.add\", note: { id: id(), shape: \"sticker\", icon, text: \"\", x: sx, y: y - BOARD.draw.sticker.h / 4, w: BOARD.draw.sticker.w, h: BOARD.draw.sticker.h, color: \"paper\", frame: null } });\n right = Math.max(right, sx + BOARD.draw.sticker.w);\n }\n y += DRH.step + (lines - 1) * DRH.h;\n if (h.subtitle) {\n ops.push({ op: \"note.add\", note: { id: id(), shape: \"text\", size: \"m\", color: \"gray\", text: noEmoji(h.subtitle).slice(0, LEN.message), x, y, w: subW, h: DRH.subH * (subW < DRH.w ? 2 : 1), frame: null } });\n y += DRH.subStep + (subW < DRH.w ? DRH.subH : 0);\n }\n return { h: y - top + DRH.titleRoom, right };\n}\n\nconst STICKY = BOARD.sticky;\n/** Ops that place sections as frames of sticky notes, starting right of anything already on the board; a heading goes on top. */\nexport function layoutOps(sections: Section[], layout: LayoutKind, origin = { x: 0, y: 0 }, palette: NoteColor[] = [\"yellow\", \"blue\", \"green\", \"pink\", \"purple\"], heading?: Heading): { ops: BoardOp[]; frameIds: string[] } {\n const ops: BoardOp[] = [];\n const frameIds: string[] = [];\n const perRow = layout === \"grid\" ? Math.min(BOARD.gridSectionsPerRow, Math.max(1, Math.ceil(Math.sqrt(sections.length)))) : sections.length;\n const inner = layout === \"grid\" ? BOARD.gridNotesPerRow : 1;\n const fw = PAD * 2 + inner * STICKY.w + (inner - 1) * GAP;\n const top = heading ? headingOps(ops, heading, origin.x, origin.y).h : 0;\n let x = origin.x, y = origin.y + top, rowH = 0;\n sections.forEach((s, i) => {\n if (i > 0 && i % perRow === 0) { x = origin.x; y += rowH + GAP * 2; rowH = 0; }\n const lines = Math.max(1, Math.ceil(s.notes.length / inner));\n const head = HEAD + (s.subtitle ? BOARD.draw.heading.subH : 0);\n // Each row of notes is as tall as its longest note's words, never shorter than a square sticky.\n const textW = STICKY.w - STICKY.pad;\n const noteH = (n: Section[\"notes\"][number]) => Math.max(STICKY.h, STICKY.top + wrapLines(n.title ? noEmoji(n.title) : \"\", STICKY.titleCharW, textW) * STICKY.titleLh + wrapLines(noEmoji(n.text), STICKY.charW, textW) * STICKY.lh + STICKY.byH);\n const noteRows: number[] = Array.from({ length: lines }, (_, r) => Math.max(...s.notes.slice(r * inner, r * inner + inner).map(noteH), STICKY.h));\n const rowY = noteRows.map((_, r) => noteRows.slice(0, r).reduce((t, v) => t + v + GAP, 0));\n const fh = head + PAD + noteRows.reduce((t, v) => t + v, 0) + (lines - 1) * GAP + PAD;\n const fid = uid(\"f\");\n frameIds.push(fid);\n ops.push({ op: \"frame.add\", frame: { id: fid, title: s.title, ...(s.subtitle ? { subtitle: s.subtitle } : {}), x, y, w: fw, h: fh } });\n const color = colorFor(s.title, palette[i % palette.length]);\n s.notes.forEach((n, k) => {\n const icon = validIcon(n.icon);\n ops.push({ op: \"note.add\", note: {\n id: uid(\"n\"), text: noEmoji(n.text), ...(n.title ? { title: noEmoji(n.title) } : {}), ...(icon ? { icon } : {}), size: \"m\",\n x: x + PAD + (k % inner) * (STICKY.w + GAP), y: y + head + rowY[Math.floor(k / inner)], w: STICKY.w, h: noteRows[Math.floor(k / inner)],\n color: n.color ?? color, frame: fid, ...(n.owner ? { owner: n.owner } : {}), ...(n.due ? { due: n.due } : {}),\n } });\n });\n if (layout === \"timeline\" && i > 0) ops.push({ op: \"link.add\", link: { id: uid(\"l\"), from: frameIds[i - 1], to: fid } });\n x += fw + GAP * 2;\n rowH = Math.max(rowH, fh);\n });\n return { ops, frameIds };\n}\n\n/** Where new sections go: to the right of everything already on the board. */\nexport function nextOrigin(b: Pick<Board, \"frames\" | \"notes\">): { x: number; y: number } {\n const right = Math.max(0, ...b.frames.map((f) => f.x + f.w), ...b.notes.map((n) => n.x + n.w));\n const top = Math.min(0, ...b.frames.map((f) => f.y), ...b.notes.map((n) => n.y));\n return b.frames.length || b.notes.length ? { x: right + GAP * 4, y: top } : { x: 0, y: 0 };\n}\n\n/** Re-flows the notes of each frame into a tidy grid and fits the frame around them, after a regroup. */\nconst STRUCTURE: (Shape | undefined)[] = [\"track\", \"pill\", \"dot\", \"cell\", \"sticker\"];\nexport function tidyOps(b: Board): BoardOp[] {\n const ops: BoardOp[] = [];\n for (const f of b.frames) {\n const notes = b.notes.filter((n) => n.frame === f.id);\n // A matrix or a drawn diagram has its own geometry: re-flowing it into a grid would break it.\n if (notes.some((n) => STRUCTURE.includes(n.shape))) continue;\n const nw = Math.max(NOTE_W, ...notes.map((n) => n.w)), nh = Math.max(NOTE_H, ...notes.map((n) => n.h));\n const head = HEAD + (f.subtitle ? BOARD.draw.heading.subH : 0);\n const inner = Math.max(1, Math.floor((f.w - PAD * 2 + GAP) / (nw + GAP)));\n notes.forEach((n, k) => ops.push({ op: \"note.update\", id: n.id, patch: { x: f.x + PAD + (k % inner) * (nw + GAP), y: f.y + head + Math.floor(k / inner) * (nh + GAP), frame: f.id } }));\n const lines = Math.max(1, Math.ceil(notes.length / inner));\n ops.push({ op: \"frame.update\", id: f.id, patch: { h: head + PAD + lines * nh + (lines - 1) * GAP + PAD } });\n }\n return ops;\n}\n\n// ---------- Formulas: {Column} references, numbers, + - * / and parentheses. Nothing is ever eval'd. ----------\n\ntype Tok = { t: \"num\"; v: number } | { t: \"ref\"; v: string } | { t: \"op\"; v: string };\n\nfunction tokens(src: string): Tok[] | null {\n const out: Tok[] = [];\n let i = 0;\n while (i < src.length) {\n const ch = src[i];\n if (/\\s/.test(ch)) { i++; continue; }\n if (ch === \"{\") { const j = src.indexOf(\"}\", i); if (j < 0) return null; out.push({ t: \"ref\", v: src.slice(i + 1, j).trim() }); i = j + 1; continue; }\n if (\"+-*/()\".includes(ch)) { out.push({ t: \"op\", v: ch }); i++; continue; }\n const m = /^\\d+(\\.\\d+)?/.exec(src.slice(i));\n if (m) { out.push({ t: \"num\", v: Number(m[0]) }); i += m[0].length; continue; }\n return null;\n }\n return out;\n}\n\n/** Column names a formula refers to, for validation. */\nexport const formulaRefs = (src: string): string[] | null => tokens(src)?.flatMap((t) => (t.t === \"ref\" ? [t.v] : [])) ?? null;\n\n/** Evaluates a formula for one row; null when a referenced cell is empty or the formula is malformed. */\nexport function evalFormula(src: string, value: (name: string) => number | null): number | null {\n const toks = tokens(src);\n if (!toks?.length) return null;\n let p = 0;\n const peek = () => toks[p];\n const expr = (): number | null => {\n let l = term();\n while (l !== null && peek()?.t === \"op\" && (peek().v === \"+\" || peek().v === \"-\")) { const op = toks[p++].v; const r = term(); if (r === null) return null; l = op === \"+\" ? l + r : l - r; }\n return l;\n };\n const term = (): number | null => {\n let l = factor();\n while (l !== null && peek()?.t === \"op\" && (peek().v === \"*\" || peek().v === \"/\")) { const op = toks[p++].v; const r = factor(); if (r === null || (op === \"/\" && r === 0)) return null; l = op === \"*\" ? l * r : l / r; }\n return l;\n };\n const factor = (): number | null => {\n const t = toks[p++];\n if (!t) return null;\n if (t.t === \"num\") return t.v;\n if (t.t === \"ref\") return value(t.v);\n if (t.v === \"-\") { const v = factor(); return v === null ? null : -v; }\n if (t.v === \"(\") { const v = expr(); if (toks[p++]?.v !== \")\") return null; return v; }\n return null;\n };\n const v = expr();\n return p === toks.length && v !== null && Number.isFinite(v) ? Math.round(v * 1e6) / 1e6 : null;\n}\n\nconst num = (v: CellValue | undefined): number | null => (typeof v === \"number\" ? v : typeof v === \"string\" && v.trim() && Number.isFinite(Number(v)) ? Number(v) : null);\n\n/** A cell as shown: stored value, or the formula's result (formulas may use other formula columns, without cycles). */\nexport function cellValue(t: SheetTab, r: SheetRow, c: SheetCol, seen = new Set<string>()): CellValue {\n if (!c.formula) return r.cells[c.id] ?? null;\n if (seen.has(c.id)) return null;\n seen.add(c.id);\n const byName = new Map(t.columns.map((x) => [x.name.toLowerCase(), x]));\n return evalFormula(c.formula, (name) => {\n const ref = byName.get(name.toLowerCase());\n return ref ? num(cellValue(t, r, ref, new Set(seen))) : null;\n });\n}\n\nexport function columnTotal(t: SheetTab, c: SheetCol): number | null {\n if (!c.total) return null;\n if (c.total === \"count\") return t.rows.filter((r) => { const v = cellValue(t, r, c); return v !== null && v !== \"\" && v !== false; }).length;\n const vals = t.rows.map((r) => num(cellValue(t, r, c))).filter((v): v is number => v !== null);\n if (!vals.length) return null;\n const sum = vals.reduce((a, b) => a + b, 0);\n return c.total === \"sum\" ? Math.round(sum * 100) / 100 : Math.round((sum / vals.length) * 100) / 100;\n}\n\n/** The sheet tab as plain rows, every formula computed: for the agent to read and for CSV export. */\nexport function tabRows(t: SheetTab): { columns: SheetCol[]; rows: CellValue[][] } {\n return { columns: t.columns, rows: t.rows.map((r) => t.columns.map((c) => cellValue(t, r, c))) };\n}\n\n/** The board as text for the agent: frames with their notes (ids kept so it can move them), or sheet tabs as rows. */\nexport function boardText(b: Board, only?: Set<string>, maxRows = BOARD.textRows): string {\n // A task board reads as lanes with their cards, so the agent can name what it moves.\n const tasks = b.mode === \"tasks\" ? taskShape(b) : null;\n if (tasks) {\n const { tab, lane, title, lanes, fields } = tasks;\n const inLane = (l: string, first: boolean) => tab.rows.filter((r) => r.cells[lane.id] === l || (first && !lanes.includes(String(r.cells[lane.id]))));\n const card = (r: SheetRow) => `- ${r.id} (#${tab.rows.indexOf(r) + 1}): ${String(r.cells[title.id] ?? \"\")}${fields.map((f) => (r.cells[f.id] === null || r.cells[f.id] === undefined || r.cells[f.id] === \"\" ? \"\" : `; ${f.name}: ${String(r.cells[f.id])}`)).join(\"\")}`;\n return `Lane field \"${lane.name}\"; lanes in order: ${lanes.join(\", \")}\\n${lanes.map((l, k) => { const cs = inLane(l, k === 0); return `Lane \"${l}\" (${cs.length})${cs.length ? `\\n${cs.slice(0, maxRows).map(card).join(\"\\n\")}` : \"\"}`; }).join(\"\\n\")}`;\n }\n if (b.mode === \"sheet\" || b.mode === \"tasks\") {\n return b.tabs.map((t) => {\n const { columns, rows } = tabRows(t);\n const head = columns.map((c) => `${c.name}${c.formula ? ` (=${c.formula})` : \"\"} [${c.type}] id=${c.id}`).join(\" | \");\n const body = rows.slice(0, maxRows).map((r, i) => `${t.rows[i].id}: ${r.map((v) => (v === null ? \"\" : String(v))).join(\" | \")}`).join(\"\\n\");\n return `Tab \"${t.name}\" id=${t.id}, ${t.rows.length} baris\\nKolom: ${head}\\n${body}${t.rows.length > maxRows ? ERR.nBarisLagi(t.rows.length - maxRows) : \"\"}`;\n }).join(\"\\n\\n\");\n }\n // The road, its dots and empty matrix cells are drawing, not content: leaving them out keeps the read short.\n const drawing = (n: WbNote) => n.shape === \"track\" || n.shape === \"dot\" || (n.shape === \"cell\" && !n.text);\n const pick = (id: string) => !only || only.has(id);\n const line = (n: WbNote) => `- ${n.id}${n.shape && n.shape !== \"note\" ? ` [${n.shape}${n.color === \"ink\" || n.color === \"red\" ? `, ${n.color}` : \"\"}]` : \"\"}: ${n.icon ? `(${n.icon}) ` : \"\"}${n.title ? `${n.title}: ` : \"\"}${n.text.replace(/\\n/g, \" \")}${n.owner ? ` (PJ ${n.owner})` : \"\"}${n.due ? ` (tenggat ${n.due})` : \"\"} [oleh ${n.by}]`;\n const parts = b.frames.filter((f) => pick(f.id) || b.notes.some((n) => n.frame === f.id && pick(n.id))).map((f) => {\n const ns = b.notes.filter((n) => n.frame === f.id && !drawing(n) && (pick(n.id) || pick(f.id)));\n return `Bagian \"${f.title}\"${f.subtitle ? ` (${f.subtitle})` : \"\"} id=${f.id}\\n${ns.map(line).join(\"\\n\") || \"(kosong)\"}`;\n });\n const loose = b.notes.filter((n) => !n.frame && !drawing(n) && pick(n.id));\n if (loose.length) parts.push(ERR.luarBagianN(loose.map(line).join(\"\\n\")));\n const name = (id: string) => b.frames.find((f) => f.id === id)?.title ?? b.notes.find((n) => n.id === id)?.text.slice(0, LEN.id) ?? id;\n const arrows = b.links.filter((l) => !only || only.has(l.from) || only.has(l.to));\n if (arrows.length) parts.push(`Panah\\n${arrows.map((l) => `- ${l.id}: ${l.from} \"${name(l.from)}\" → ${l.to} \"${name(l.to)}\"${l.label ? ` (${l.label})` : \"\"}${l.route === \"straight\" ? \" lurus\" : \"\"}${l.dashed ? \" putus-putus\" : \"\"}`).join(\"\\n\")}`);\n return parts.join(\"\\n\\n\") || \"(empty board)\";\n}\n\n// ---------- Ranges: copy and paste in the shape Excel and Google Sheets use (tab-separated rows) ----------\n\nexport type Range = { r0: number; r1: number; c0: number; c1: number };\n\n/** The range as tab-separated text: raw numbers, formulas computed, checks as Ya/Tidak. */\nexport function rangeTsv(t: SheetTab, g: Range): string {\n const out: string[] = [];\n for (let r = g.r0; r <= g.r1; r++) {\n const row = t.rows[r];\n if (!row) continue;\n out.push(t.columns.slice(g.c0, g.c1 + 1).map((c) => { const v = cellValue(t, row, c); return v === null ? \"\" : typeof v === \"boolean\" ? (v ? WORDS.yes : WORDS.no) : String(v).replace(/[\\t\\n\\r]+/g, \" \"); }).join(\"\\t\"));\n }\n return out.join(\"\\n\");\n}\n\n/**\n * Ops that paste text at the range's top-left. Rows past the end are added; formula columns and columns past the\n * last are skipped; a single value fills the whole range. Returns the pasted area so the UI can select it.\n */\nexport function pasteOps(t: SheetTab, g: Range, text: string, newId: () => string = () => uid(\"r\")): { ops: BoardOp[]; area: Range } {\n const grid = text.replace(/\\r\\n?/g, \"\\n\").replace(/\\n$/, \"\").split(\"\\n\").slice(0, MAX_ROWS).map((l) => l.split(\"\\t\"));\n const one = grid.length === 1 && grid[0].length === 1;\n const h = one ? g.r1 - g.r0 + 1 : grid.length;\n const w = Math.min(t.columns.length - g.c0, one ? g.c1 - g.c0 + 1 : Math.max(...grid.map((l) => l.length)));\n const ops: BoardOp[] = [];\n for (let i = 0; i < h; i++) {\n const cells: Record<string, CellValue> = {};\n for (let j = 0; j < w; j++) {\n const col = t.columns[g.c0 + j];\n const v = one ? grid[0][0] : grid[i]?.[j];\n if (col && !col.formula && v !== undefined) cells[col.id] = v.trim() === \"\" ? null : v;\n }\n const row = t.rows[g.r0 + i];\n if (row) for (const [col, value] of Object.entries(cells)) ops.push({ op: \"cell.set\", tab: t.id, row: row.id, col, value });\n else ops.push({ op: \"row.add\", tab: t.id, row: { id: newId(), cells } });\n }\n return { ops, area: { r0: g.r0, r1: g.r0 + h - 1, c0: g.c0, c1: g.c0 + Math.max(0, w - 1) } };\n}\n\n// ---------- Diagrams: the agent says what the parts are and how they connect; the board places them ----------\n\nexport type DrawItem = {\n key?: string; shape?: Exclude<Shape, \"ink\" | \"track\" | \"cell\">; pen?: Pen; dashed?: boolean; title?: string; text?: string; icon?: string; color?: NoteColor; size?: TextSize; owner?: string; due?: string;\n /** diagram: [column, row]. */\n at?: [number, number];\n /** timeline: the milestone label on the road (\"Hari 7\", \"Minggu 2\"). */\n when?: string;\n /** matrix: [column name or index, row name or index]. */\n cell?: [string | number, string | number];\n /** free: where this item sits in the section's own space, [x, y, width, height]. */\n box?: [number, number, number, number];\n};\n/** A line the agent draws by hand in a free section: an underline, a ring, a bracket, a curved arrow. */\nexport type DrawStroke = { points: [number, number][]; color?: Pen | \"yellow\"; width?: \"s\" | \"m\" | \"l\"; marker?: boolean };\n/** A mark made on an item the way a person marks a whiteboard: the board draws it properly round or under that item. */\nexport type DrawMark = { on: string; kind: \"ring\" | \"underline\" | \"highlight\" | \"cross\" | \"tick\"; color?: Pen | \"yellow\" };\nexport type DrawSection = {\n key?: string; title: string; subtitle?: string;\n /**\n * stack: full-width bars top to bottom; grid: tiles in columns; row: side by side; flow: side by side joined by arrows;\n * diagram: each item at [column, row]; timeline: a road with a milestone per item (`when`) and the cards alternating above and below it;\n * matrix: a table of cells (`columns` across, `rows` down, e.g. weekdays × weeks or stages × owners) with each item in its `cell`.\n * free: no recipe at all; every item sits at its own `box` and `strokes` are drawn over them, so the picture is composed for this content.\n */\n layout: \"stack\" | \"grid\" | \"row\" | \"flow\" | \"diagram\" | \"timeline\" | \"matrix\" | \"free\";\n /** free: lines drawn by hand over the items. */\n strokes?: DrawStroke[];\n /** free: rings, underlines, highlights, crosses and ticks on keyed items. */\n marks?: DrawMark[];\n /** matrix: header labels across and down. */\n across?: string[];\n down?: string[];\n columns?: number;\n /** Place beside the previous section instead of below it. */\n beside?: boolean;\n items: DrawItem[];\n};\nexport type DrawConnector = { from: string; to: string; label?: string; route?: (typeof ROUTES)[number]; dashed?: boolean; arrow?: \"end\" | \"both\" | \"none\" };\nexport type DrawSpec = { heading?: Heading; sections: DrawSection[]; connectors?: DrawConnector[] };\n\nconst DR = BOARD.draw;\nconst D_PAD = DR.pad, HEAD_H = DR.head, GAP_X = DR.gapX, GAP_Y = DR.gapY, SECTION_GAP = DR.sectionGap;\nconst ITEM = DR.item;\nconst DIAGRAM_GAP = DR.diagramGap;\n\n/** Rough height a box needs for its text at its width (15px type, about 7.5px a character). */\nfunction fitH(it: DrawItem, w: number, base: number): number {\n const chars = (it.title ? it.title.length + 2 : 0) + (it.text?.length ?? 0);\n const lines = Math.ceil((chars * DR.fit.charW) / Math.max(DR.fit.minLineW, w - DR.fit.inset));\n return Math.max(base, DR.fit.base + lines * DR.fit.lineH + (it.title && it.text ? DR.fit.titleGap : 0));\n}\n\n/**\n * Ops that draw a heading and sections below everything already on the board (a new area, as when a plan is added\n * under its open questions), plus connectors between items by key (\"section-key\" names a whole section).\n * Returns the ids given to each key so later edits can address them.\n */\nexport function drawOps(b: Pick<Board, \"frames\" | \"notes\">, spec: DrawSpec, ids: () => string = () => uid(\"n\")): { ops: BoardOp[]; keys: Record<string, string>; area: { x: number; y: number; w: number; h: number } } {\n const ops: BoardOp[] = [];\n const keys: Record<string, string> = {};\n /** Items of a matrix: connectors between them curve, the way a planner draws dependencies across a calendar. */\n const curved = new Set<string>();\n const boxes = [...b.frames, ...b.notes];\n const x0 = boxes.length ? Math.min(...boxes.map((r) => r.x)) : 0;\n let y = boxes.length ? Math.max(...boxes.map((r) => r.y + r.h)) + DR.belowExisting : 0;\n const top = y;\n let right = x0;\n if (spec.heading) {\n const hd = headingOps(ops, spec.heading, x0, y, ids);\n for (const o of ops) if (o.op === \"note.add\" && o.note.shape === \"text\") o.note.pen = \"black\";\n y += hd.h;\n right = Math.max(right, hd.right);\n }\n // Sections are packed like a page in landscape. A section sits beside the last while the row is still narrow; a\n // short one after a tall one starts a column beside it, and the next stacks under it while it fits the row's height.\n const lay = (sec: DrawSection, items: DrawItem[], fx: number, fy: number, into: BoardOp[], k: Record<string, string>, cv: Set<string>, mk: () => string) =>\n sec.layout === \"free\" ? freeOps(into, sec, items, fx, fy, mk, k) : sec.layout === \"timeline\" ? timelineOps(into, sec, items, fx, fy, mk, k) : sec.layout === \"matrix\" ? matrixOps(into, sec, items, fx, fy, mk, k, cv) : boxesOps(into, sec, items, fx, fy, mk, k);\n // Areas are set out as a grid shaped like the screen the board is seen on: as many per row as brings the whole\n // board closest to a wide page, so four pictures make two rows of two instead of one tall column.\n const lone = !!spec.heading && spec.sections.length === 1;\n const drawn = spec.sections.map((s0) => { const sec = lone ? { ...s0, title: \"\" } : s0; const items = sec.items.slice(0, DR.sectionItems); return { sec, items, size: lay(sec, items, 0, 0, [], {}, new Set(), () => \"m\") }; });\n const n = drawn.length;\n const avgW = drawn.reduce((t, d) => t + d.size.w, 0) / Math.max(1, n), avgH = drawn.reduce((t, d) => t + d.size.h, 0) / Math.max(1, n);\n const perRow = Math.max(1, Math.min(n, Math.round(Math.sqrt((n * DR.aspect * avgH) / Math.max(1, avgW)))));\n // An area the agent said goes beside the last one stays on its row; one it said goes below starts a new row.\n const rows: (typeof drawn)[] = [];\n for (const d of drawn) {\n const last = rows[rows.length - 1];\n if (last && (d.sec.beside === true || (d.sec.beside === undefined && last.length < perRow))) last.push(d); else rows.push([d]);\n }\n let rowY = y;\n for (const row of rows) {\n let fx = x0;\n for (const d of row) {\n const { w } = lay(d.sec, d.items, fx, rowY, ops, keys, curved, ids);\n right = Math.max(right, fx + w);\n fx += w + SECTION_GAP;\n }\n rowY += Math.max(...row.map((d) => d.size.h)) + SECTION_GAP;\n }\n const bottom = rowY - SECTION_GAP;\n for (const c of spec.connectors ?? []) {\n const from = keys[c.from], to = keys[c.to];\n if (!from || !to || from === to) continue;\n const route = c.route ?? (curved.has(from) || curved.has(to) ? \"curve\" : \"elbow\");\n ops.push({ op: \"link.add\", link: { id: uid(\"l\"), from, to, ...(c.label ? { label: c.label } : {}), route, ...(c.dashed ? { dashed: true } : {}), ...(c.arrow && c.arrow !== \"end\" ? { arrow: c.arrow } : {}) } });\n }\n return { ops, keys, area: { x: x0, y: top, w: right - x0, h: bottom - top } };\n}\n\nconst STK = DR.sticker;\nconst stickerH = (it: DrawItem) => STK.h + (it.text ? STK.captionH : 0);\n/** A card's height: its text, plus room for the illustration when it has one. */\nconst cardH = (it: DrawItem, w: number, base: number) => fitH(it, w, base) + (validIcon(it.icon) ? DR.iconCard.extraH : 0);\n\nfunction itemNote(it: DrawItem, id: string, shape: Shape, color: NoteColor, x: number, y: number, w: number, h: number, frame: string | null): BoardOp {\n const icon = validIcon(it.icon);\n return { op: \"note.add\", note: {\n id, shape, text: noEmoji(it.text ?? \"\").slice(0, MAX_TEXT), ...(it.title ? { title: noEmoji(it.title) } : {}), ...(icon ? { icon } : {}), ...(it.size ? { size: it.size } : {}),\n color, x, y, w, h, frame, ...(it.pen ? { pen: it.pen } : {}), ...(it.dashed ? { dashed: true } : {}), ...(it.owner ? { owner: it.owner } : {}), ...(it.due ? { due: it.due } : {}),\n } };\n}\n\n/** The original section kinds: a frame with boxes or notes stacked, in a grid, in a row, in a flow, or at diagram positions. */\n/** Points through which a hand would pass, made into one flowing line (Catmull-Rom), so three points never read as a broken scribble. */\nexport function smoothPoints(pts: readonly (readonly [number, number])[], per = 8): [number, number][] {\n if (pts.length < 3) return pts.map(([x, y]) => [x, y]);\n const out: [number, number][] = [];\n for (let i = 0; i < pts.length - 1; i++) {\n const p0 = pts[Math.max(0, i - 1)], p1 = pts[i], p2 = pts[i + 1], p3 = pts[Math.min(pts.length - 1, i + 2)];\n for (let k = 0; k < per; k++) {\n const t = k / per, t2 = t * t, t3 = t2 * t;\n out.push([0, 1].map((a) => 0.5 * (2 * p1[a] + (p2[a] - p0[a]) * t + (2 * p0[a] - 5 * p1[a] + 4 * p2[a] - p3[a]) * t2 + (3 * p1[a] - p0[a] - 3 * p2[a] + p3[a]) * t3)) as [number, number]);\n }\n }\n out.push([pts[pts.length - 1][0], pts[pts.length - 1][1]]);\n return out;\n}\n\n/** The strokes of a mark on a box, as a person would make it: a ring that overshoots where it closes, a line that is not quite straight. */\nexport function markStrokes(kind: DrawMark[\"kind\"], bx: number, by: number, bw: number, bh: number): [number, number][][] {\n const cx = bx + bw / 2, cy = by + bh / 2;\n if (kind === \"ring\") {\n const rx = bw / 2 + Math.max(14, bw * 0.09), ry = bh / 2 + Math.max(12, bh * 0.16), n = 30;\n return [Array.from({ length: n + 1 }, (_, i) => { const a = -2.0 + (i / n) * Math.PI * 2.14, k = 1 + 0.03 * Math.sin(i * 1.7) - (i / n) * 0.05; return [cx + rx * k * Math.cos(a), cy + ry * k * Math.sin(a)] as [number, number]; })];\n }\n if (kind === \"underline\") return [Array.from({ length: 9 }, (_, i) => [bx + (bw * i) / 8, by + bh + 8 + 3 * Math.sin(i * 1.3)] as [number, number])];\n if (kind === \"highlight\") return [Array.from({ length: 5 }, (_, i) => [bx - 6 + ((bw + 12) * i) / 4, cy + 2 * Math.sin(i * 2.1)] as [number, number])];\n if (kind === \"tick\") return [[[bx - 34, cy], [bx - 24, cy + 14], [bx - 4, cy - 16]]];\n return [[[bx + bw * 0.12, by + bh * 0.12], [bx + bw * 0.88, by + bh * 0.88]], [[bx + bw * 0.88, by + bh * 0.12], [bx + bw * 0.12, by + bh * 0.88]]];\n}\n\n/** A section composed by hand: a title, each item at the place the agent gave it, and its hand-drawn lines on top. It is a marker sketch: outlines and words in ink, no fills, unless an item is a coloured sticky note. */\nfunction freeOps(ops: BoardOp[], sec: DrawSection, items: DrawItem[], fx: number, fy: number, ids: () => string, keys: Record<string, string>): { w: number; h: number } {\n const F = DR.free;\n const clamp = (n: number, max: number) => Math.max(0, Math.min(max, Math.round(n)));\n let right: number = Math.min(F.w, sec.title.length * F.titleCharW), bottom: number = F.titleH;\n // The area's own title is drawn only when it says something the board's heading does not.\n if (sec.title.trim()) ops.push({ op: \"note.add\", note: { id: ids(), shape: \"text\", size: \"l\", pen: \"black\", text: noEmoji(sec.title).slice(0, LEN.title), color: \"paper\", x: fx, y: fy, w: Math.max(F.titleMinW, right), h: F.titleH - F.titleGap, frame: null } });\n let auto = 0;\n const boxes = new Map<string, [number, number, number, number]>();\n // Nothing lands on top of anything: an item that would cover one already placed moves to the nearest free spot.\n const placed: Box[] = [];\n for (const it of items) {\n // An item the agent forgot to place still shows: it joins a row under the picture.\n const [bx, by, bw, bh] = it.box ?? [auto++ * (F.itemW + F.gap), F.h, F.itemW, F.itemH];\n const shape = it.shape ?? \"box\";\n const min = minSize(shape);\n const w = Math.max(min.w, clamp(bw, F.w)), h = shape === \"sticker\" ? Math.max(min.h, clamp(bh, F.h)) : Math.max(min.h, clamp(bh, F.h), shape === \"text\" ? 0 : cardH(it, w, 0));\n const spot = freeSpot({ x: clamp(bx, F.w), y: clamp(by, F.h + F.itemH) + F.titleH, w, h }, placed, F.gap / 2);\n placed.push(spot);\n const x = spot.x, y = spot.y;\n const id = ids();\n if (it.key) { keys[it.key] = id; boxes.set(it.key, [x, y - F.titleH, w, h]); }\n // A sticky note keeps its paper colour; everything else is drawn in marker.\n const sketched = shape !== \"note\" && shape !== \"sticker\";\n ops.push(itemNote(sketched ? { ...it, pen: it.pen ?? \"black\" } : it, id, shape, it.color ?? (shape === \"note\" ? \"yellow\" : \"paper\"), fx + x, fy + y, w, h, null));\n right = Math.max(right, x + w); bottom = Math.max(bottom, y + h);\n }\n const ink = (pts: readonly (readonly [number, number])[], color: DrawStroke[\"color\"], size: \"s\" | \"m\" | \"l\", marker: boolean) => {\n if (pts.length < 2) return;\n const brush = marker ? \"spidol\" : \"pena\";\n const m = F.strokeW[brush][size] * 2;\n const x0 = Math.min(...pts.map((q) => q[0])), y0 = Math.min(...pts.map((q) => q[1])), x1 = Math.max(...pts.map((q) => q[0])), y1 = Math.max(...pts.map((q) => q[1]));\n ops.push({ op: \"note.add\", note: { id: ids(), shape: \"ink\", brush, size, text: \"\", color: (color === \"black\" || !color ? \"ink\" : color) as NoteColor, x: fx + x0 - m, y: fy + F.titleH + y0 - m, w: x1 - x0 + m * 2, h: y1 - y0 + m * 2, frame: null, points: pts.flatMap(([px, py]) => [Math.round((px - x0 + m) * 10) / 10, Math.round((py - y0 + m) * 10) / 10]) } });\n right = Math.max(right, x1 + m); bottom = Math.max(bottom, F.titleH + y1 + m);\n };\n for (const st of (sec.strokes ?? []).slice(0, F.strokes)) ink(smoothPoints(st.points.slice(0, F.points).map(([px, py]) => [clamp(px, F.w), clamp(py, F.h)] as const)), st.color, st.width ?? \"m\", !!st.marker);\n for (const mk of (sec.marks ?? []).slice(0, F.strokes)) {\n const b = boxes.get(mk.on);\n if (!b) continue;\n for (const pts of markStrokes(mk.kind, ...b)) ink(smoothPoints(pts), mk.color ?? (mk.kind === \"highlight\" ? \"yellow\" : \"red\"), mk.kind === \"highlight\" ? \"l\" : \"m\", mk.kind === \"highlight\");\n }\n return { w: right, h: bottom };\n}\n\nfunction boxesOps(ops: BoardOp[], sec: DrawSection, items: DrawItem[], fx: number, fy: number, ids: () => string, keys: Record<string, string>): { w: number; h: number } {\n const layout = sec.layout as Exclude<DrawSection[\"layout\"], \"timeline\" | \"matrix\" | \"free\">;\n const base = ITEM[layout];\n const cols = layout === \"grid\" ? Math.max(1, Math.min(DR.gridColumns, sec.columns ?? DR.gridColumnsDefault)) : layout === \"stack\" ? 1 : items.length;\n const size = (it: DrawItem): { w: number; h: number } => (it.shape === \"sticker\" ? { w: STK.w, h: stickerH(it) } : { w: base.w, h: it.shape === \"text\" ? DR.textItemH : cardH(it, base.w, base.h) });\n const placed: { it: DrawItem; x: number; y: number; w: number; h: number }[] = [];\n if (layout === \"diagram\") {\n for (const it of items) {\n const [c, r] = it.at ?? [placed.length, 0];\n const sz = size(it);\n placed.push({ it, x: D_PAD + Math.max(0, c) * (base.w + DIAGRAM_GAP.x), y: HEAD_H + Math.max(0, r) * (base.h + DIAGRAM_GAP.y), ...sz });\n }\n } else {\n const gapX = layout === \"flow\" ? DR.flowGapX : GAP_X;\n let cy = HEAD_H;\n for (let i = 0; i < items.length; i += cols) {\n const line = items.slice(i, i + cols);\n const lh = Math.max(...line.map((it) => size(it).h));\n line.forEach((it, k) => placed.push({ it, x: D_PAD + k * (base.w + gapX), y: cy, w: size(it).w, h: it.shape === \"sticker\" ? size(it).h : lh }));\n cy += lh + GAP_Y;\n }\n }\n const w = Math.max(DR.minFrameW, ...placed.map((p) => p.x + p.w + D_PAD), D_PAD * 2 + (sec.title.length * DR.titleCharW));\n const h = Math.max(HEAD_H + DR.minFrameExtraH, ...placed.map((p) => p.y + p.h + D_PAD));\n const fid = uid(\"f\");\n if (sec.key) keys[sec.key] = fid;\n ops.push({ op: \"frame.add\", frame: { id: fid, title: sec.title.slice(0, LEN.title), ...(sec.subtitle ? { subtitle: sec.subtitle } : {}), x: fx, y: fy, w, h } });\n const inSection: string[] = [];\n for (const p of placed) {\n const id = ids();\n if (p.it.key) keys[p.it.key] = id;\n inSection.push(id);\n const shape = p.it.shape ?? (layout === \"stack\" || layout === \"flow\" || layout === \"diagram\" ? \"box\" : \"note\");\n ops.push(itemNote(p.it, id, shape, p.it.color ?? (shape === \"note\" ? \"yellow\" : \"paper\"), fx + p.x, fy + p.y, p.w, p.h, fid));\n }\n if (layout === \"flow\") for (let i = 1; i < inSection.length; i++) ops.push({ op: \"link.add\", link: { id: uid(\"l\"), from: inSection[i - 1], to: inSection[i] } });\n return { w, h };\n}\n\nconst TL = DR.timeline;\nconst WARM: NoteColor[] = [\"sand\", \"peach\", \"orange\", \"yellow\"];\n/**\n * An open-canvas road (no frame): a winding `track`, a `pill` milestone per card with its `when`, a small `dot` between\n * milestones, and the cards alternating above and below, each tied to its milestone by a thin line. Stickers sit on the road.\n */\nfunction timelineOps(ops: BoardOp[], sec: DrawSection, items: DrawItem[], fx: number, fy: number, ids: () => string, keys: Record<string, string>): { w: number; h: number } {\n const base = ITEM.timeline;\n const cards = items.filter((it) => it.shape !== \"sticker\");\n let oy = 0;\n if (sec.title) {\n ops.push({ op: \"note.add\", note: { id: ids(), shape: \"text\", size: \"l\", text: sec.title.slice(0, LEN.title), x: fx, y: fy, w: Math.max(DR.minFrameW, sec.title.length * DR.titleCharW * 2), h: TL.labelH, color: \"paper\", frame: null } });\n oy = TL.labelH + GAP_Y;\n }\n const heights = new Map(cards.map((it) => [it, cardH(it, base.w, base.h)]));\n const above = cards.filter((_, k) => k % 2 === 0), below = cards.filter((_, k) => k % 2 === 1);\n const ha = Math.max(0, ...above.map((it) => heights.get(it)!));\n const hb = Math.max(0, ...below.map((it) => heights.get(it)!));\n const road = oy + ha + TL.cardGap + TL.amp; // the road's middle, measured from the section top\n const wave = (x: number) => road + TL.amp * Math.sin((2 * Math.PI * x) / (TL.step * TL.waveSteps));\n const cx = (i: number) => TL.lead + base.w / 2 + i * TL.step;\n const width = cx(Math.max(0, items.length - 1)) + base.w / 2 + TL.lead;\n // The track: its box spans the wave, its points trace the middle of the road relative to the box.\n const ty = road - TL.amp - TL.trackPad;\n const points: number[] = [];\n for (let x = 0; x <= width; x += TL.sample) points.push(Math.round(x * 10) / 10, Math.round((wave(x) - ty) * 10) / 10);\n points.push(Math.round(width * 10) / 10, Math.round((wave(width) - ty) * 10) / 10);\n const track = ids();\n if (sec.key) keys[sec.key] = track;\n ops.push({ op: \"note.add\", note: { id: track, shape: \"track\", text: \"\", points, x: fx, y: fy + ty, w: width, h: 2 * (TL.amp + TL.trackPad), color: \"sand\", frame: null } });\n let card = 0, prevPill: number | null = null;\n items.forEach((it, i) => {\n const x = cx(i), yc = wave(x);\n if (it.shape === \"sticker\") {\n const id = ids();\n if (it.key) keys[it.key] = id;\n const sh = stickerH(it);\n ops.push(itemNote(it, id, \"sticker\", \"paper\", fx + x - STK.w / 2, fy + yc - STK.h + TL.trackPad, STK.w, sh, null));\n return;\n }\n if (prevPill !== null) {\n const mx = (prevPill + x) / 2;\n ops.push({ op: \"note.add\", note: { id: ids(), shape: \"dot\", text: \"\", x: fx + mx - TL.dot.w / 2, y: fy + wave(mx) - TL.dot.h / 2, w: TL.dot.w, h: TL.dot.h, color: \"paper\", frame: null } });\n }\n prevPill = x;\n const pill = ids();\n ops.push({ op: \"note.add\", note: { id: pill, shape: \"pill\", text: (it.when ?? String(card + 1)).slice(0, LEN.label), x: fx + x - TL.pill.w / 2, y: fy + yc - TL.pill.h / 2, w: TL.pill.w, h: TL.pill.h, color: \"red\", frame: null } });\n const hgt = heights.get(it)!;\n const up = card % 2 === 0;\n const top = up ? road - TL.amp - TL.cardGap - hgt : road + TL.amp + TL.cardGap;\n const id = ids();\n if (it.key) keys[it.key] = id;\n ops.push(itemNote(it, id, it.shape ?? \"note\", it.color ?? WARM[card % WARM.length], fx + x - base.w / 2, fy + top, base.w, hgt, null));\n ops.push({ op: \"link.add\", link: { id: uid(\"l\"), from: id, to: pill, route: \"straight\", arrow: \"none\" } });\n card++;\n });\n return { w: width, h: road + TL.amp + TL.cardGap + hb };\n}\n\n/**\n * Ops that carry an existing timeline on: the road is drawn further with the same wave, and each new item gets its\n * dot, milestone and card on the side the alternation calls for, tied to its milestone. `track` names the road (by id);\n * without one, the last road on the board. Null when the board has no road to extend.\n */\nexport function extendTimelineOps(b: Pick<Board, \"notes\">, items: DrawItem[], trackId?: string, ids: () => string = () => uid(\"n\")): { ops: BoardOp[]; keys: Record<string, string> } | null {\n const roads = b.notes.filter((n) => n.shape === \"track\");\n const track = (trackId ? roads.find((n) => n.id === trackId) : null) ?? roads.at(-1);\n if (!track || !items.length) return null;\n const base = ITEM.timeline;\n const period = TL.step * TL.waveSteps;\n const road = track.y + TL.amp + TL.trackPad;\n const wave = (rel: number) => road + TL.amp * Math.sin((2 * Math.PI * rel) / period);\n const along = (n: WbNote) => n.x + n.w / 2 - track.x;\n const onRoad = b.notes.filter((n) => (n.shape === \"pill\" || n.shape === \"sticker\") && along(n) >= 0 && along(n) <= track.w + base.w && Math.abs(n.y + n.h / 2 - road) <= TL.amp + base.h);\n const index = (rel: number) => Math.round((rel - TL.lead - base.w / 2) / TL.step);\n let next = onRoad.length ? Math.max(...onRoad.map((n) => index(along(n)))) + 1 : 0;\n let cards = onRoad.filter((n) => n.shape === \"pill\").length;\n let prevPill: number | null = onRoad.filter((n) => n.shape === \"pill\").reduce<number | null>((m, n) => (m === null || along(n) > m ? along(n) : m), null);\n const cx = (i: number) => TL.lead + base.w / 2 + i * TL.step;\n const ops: BoardOp[] = [];\n const keys: Record<string, string> = {};\n for (const it of items) {\n const x = cx(next), yc = wave(x);\n next += 1;\n if (it.shape === \"sticker\") {\n const id = ids();\n if (it.key) keys[it.key] = id;\n ops.push(itemNote(it, id, \"sticker\", \"paper\", track.x + x - STK.w / 2, yc - STK.h + TL.trackPad, STK.w, stickerH(it), null));\n continue;\n }\n if (prevPill !== null) {\n const mx = (prevPill + x) / 2;\n ops.push({ op: \"note.add\", note: { id: ids(), shape: \"dot\", text: \"\", x: track.x + mx - TL.dot.w / 2, y: wave(mx) - TL.dot.h / 2, w: TL.dot.w, h: TL.dot.h, color: \"paper\", frame: null } });\n }\n prevPill = x;\n const pill = ids();\n ops.push({ op: \"note.add\", note: { id: pill, shape: \"pill\", text: (it.when ?? String(cards + 1)).slice(0, LEN.label), x: track.x + x - TL.pill.w / 2, y: yc - TL.pill.h / 2, w: TL.pill.w, h: TL.pill.h, color: \"red\", frame: null } });\n const hgt = cardH(it, base.w, base.h);\n const top = cards % 2 === 0 ? road - TL.amp - TL.cardGap - hgt : road + TL.amp + TL.cardGap;\n const id = ids();\n if (it.key) keys[it.key] = id;\n ops.push(itemNote(it, id, it.shape ?? \"note\", it.color ?? WARM[cards % WARM.length], track.x + x - base.w / 2, top, base.w, hgt, null));\n ops.push({ op: \"link.add\", link: { id: uid(\"l\"), from: id, to: pill, route: \"straight\", arrow: \"none\" } });\n cards++;\n }\n // The road reaches past the last new item, on the same wave, so it reads as one road drawn further.\n const width = cx(next - 1) + base.w / 2 + TL.lead;\n if (width > track.w) {\n const ty = track.y;\n const points: number[] = [];\n for (let x = 0; x <= width; x += TL.sample) points.push(Math.round(x * 10) / 10, Math.round((wave(x) - ty) * 10) / 10);\n points.push(Math.round(width * 10) / 10, Math.round((wave(width) - ty) * 10) / 10);\n ops.unshift({ op: \"note.update\", id: track.id, patch: { w: width, points } });\n }\n return { ops, keys };\n}\n\nconst MX = DR.matrix;\n/** Index of a matrix header by its name (any case) or its number; -1 when it names nothing. */\nconst headerIndex = (v: string | number | undefined, list: string[]) =>\n typeof v === \"number\" ? (Number.isInteger(v) && v >= 0 && v < list.length ? v : -1) : v === undefined ? -1 : list.findIndex((x) => x.toLowerCase() === v.trim().toLowerCase());\n\n/**\n * A table of cells: header pills across the top and down the left, a light `cell` for each, items stacked in their\n * cell and rows grown to the fullest cell. Weekly plans (weekdays × weeks), swimlanes (stage × owner), 2×2 matrices.\n */\nfunction matrixOps(ops: BoardOp[], sec: DrawSection, items: DrawItem[], fx: number, fy: number, ids: () => string, keys: Record<string, string>, curved: Set<string>): { w: number; h: number } {\n const named = (k: 0 | 1) => [...new Set(items.map((it) => it.cell?.[k]).filter((v): v is string => typeof v === \"string\" && !!v.trim()))];\n const across = (sec.across?.length ? sec.across : named(0)).slice(0, DR.gridColumns + 1);\n const down = (sec.down?.length ? sec.down : named(1)).slice(0, DR.sectionItems);\n const cols = Math.max(1, across.length), rows = Math.max(1, down.length);\n const iw = MX.cellW - MX.cellPad * 2;\n const inCell: DrawItem[][] = Array.from({ length: cols * rows }, () => []);\n for (const it of items) {\n const c = Math.max(0, headerIndex(it.cell?.[0], across)), r = Math.max(0, headerIndex(it.cell?.[1], down));\n inCell[r * cols + c].push(it);\n }\n const hOf = (it: DrawItem) => (it.shape === \"sticker\" ? stickerH(it) : cardH(it, iw, ITEM.matrix.h));\n const rowH = Array.from({ length: rows }, (_, r) =>\n Math.max(MX.cellMinH, ...Array.from({ length: cols }, (_, c) => {\n const list = inCell[r * cols + c];\n return MX.cellPad * 2 + list.reduce((a, it) => a + hOf(it), 0) + Math.max(0, list.length - 1) * MX.itemGap;\n })));\n const left = D_PAD + (down.length ? MX.headW + MX.gap : 0);\n const topY = HEAD_H + (across.length ? MX.headH + MX.gap : 0);\n const colX = (c: number) => left + c * (MX.cellW + MX.gap);\n const rowY: number[] = [];\n rowH.reduce((y, h, r) => { rowY[r] = y; return y + h + MX.gap; }, topY);\n const w = Math.max(DR.minFrameW, colX(cols) - MX.gap + D_PAD);\n const h = rowY[rows - 1] + rowH[rows - 1] + D_PAD;\n const fid = uid(\"f\");\n if (sec.key) keys[sec.key] = fid;\n ops.push({ op: \"frame.add\", frame: { id: fid, title: sec.title.slice(0, LEN.title), ...(sec.subtitle ? { subtitle: sec.subtitle } : {}), x: fx, y: fy, w, h } });\n across.forEach((t, c) => ops.push({ op: \"note.add\", note: { id: ids(), shape: \"pill\", text: t.slice(0, LEN.label), x: fx + colX(c), y: fy + HEAD_H, w: MX.cellW, h: MX.headH, color: \"blue\", frame: fid } }));\n down.forEach((t, r) => ops.push({ op: \"note.add\", note: { id: ids(), shape: \"pill\", text: t.slice(0, LEN.label), x: fx + D_PAD, y: fy + rowY[r] + (rowH[r] - MX.headH) / 2, w: MX.headW, h: MX.headH, color: \"blue\", frame: fid } }));\n for (let r = 0; r < rows; r++) for (let c = 0; c < cols; c++) {\n ops.push({ op: \"note.add\", note: { id: ids(), shape: \"cell\", text: \"\", x: fx + colX(c), y: fy + rowY[r], w: MX.cellW, h: rowH[r], color: \"paper\", frame: fid } });\n let cy = rowY[r] + MX.cellPad;\n for (const it of inCell[r * cols + c]) {\n const id = ids();\n if (it.key) keys[it.key] = id;\n curved.add(id);\n const ih = hOf(it);\n const shape = it.shape ?? \"note\";\n ops.push(itemNote(it, id, shape, it.color ?? \"yellow\", fx + colX(c) + MX.cellPad, fy + cy, shape === \"sticker\" ? STK.w : iw, ih, fid));\n cy += ih + MX.itemGap;\n }\n }\n return { w, h };\n}\n","// A board drawn freely, the way a person explains at a whiteboard or pins up an evidence wall: the agent decides what\n// goes where, in what shape, and what joins what, beat by beat, saying a sentence as it draws each beat.\n//\n// The board keeps the agent's picture clean without rearranging it: an item that would cover something already drawn\n// moves to the nearest free spot, sticky notes go beside what they are about, and every wire is routed around every\n// item with its label where the wire stays visible. Earlier items never move for later ones.\nimport { BOARD, LEN } from \"./config.ts\";\nimport { freeSpot, wrapLines, isPolygon, labelSize, overlaps, POLYGONS, routeWires, wireBoxes, type Box, type Item, type Polygon, type Wire } from \"./board-geometry.ts\";\nimport { MAX_LAYER, minSize, noEmoji, uid, validIcon, type Board, type BoardOp, type NoteColor, type Pen, type Shape, type TextSize, type WbLink, type WbNote } from \"./boards.ts\";\n\nconst SK = BOARD.draw.sketch, T = BOARD.draw.tell;\n\nexport const TONES = [\"fact\", \"problem\", \"action\", \"insight\", \"person\", \"system\"] as const;\nexport type Tone = (typeof TONES)[number];\n/** Shapes the agent may draw; `square` and `circle` keep equal sides, `sticky` is a yellow note, `text` bare lettering. */\nexport const FORMS = [\"rect\", \"square\", \"circle\", \"ellipse\", \"diamond\", \"triangle\", \"pentagon\", \"hexagon\", \"parallelogram\", \"cylinder\", \"cloud\", \"pill\", \"sticky\", \"text\"] as const;\nexport type Form = (typeof FORMS)[number];\nexport type FreeItem = {\n key: string; x: number; y: number; form?: Form; size?: TextSize; w?: number; h?: number;\n /** How deep in the explanation this sits: 0 the main flow, 1 its breakdown, and so on to 9. */\n layer?: number;\n title?: string; text?: string; tone?: Tone; icon?: string;\n /** The questions a reader would ask about this thing, answered on the board. */\n why?: string; who?: string; when?: string; where?: string; how?: string; howMuch?: string;\n /** What this item's figure or claim rests on that the data does not prove (a rate that holds, a price, a definition). */\n assumes?: string;\n /** A remark the agent makes about this thing, stuck beside it as a sticky note. */\n note?: string;\n};\nexport type FreeLink = { from: string; to: string; label?: string; dashed?: boolean };\nexport type FreeBeat = { say: string; items?: FreeItem[]; links?: FreeLink[] };\nexport type FreeStory = { headline: string; context?: string; icon?: string; beats: FreeBeat[] };\nexport type ToldStep = { say: string; ops: BoardOp[] };\n\nconst PEN: Record<Tone, Pen> = { fact: \"black\", problem: \"red\", action: \"green\", insight: \"purple\", person: \"blue\", system: \"orange\" };\nconst SHAPE: Record<Form, Shape> = {\n rect: \"box\", square: \"box\", circle: \"ellipse\", ellipse: \"ellipse\", diamond: \"diamond\", triangle: \"triangle\", pentagon: \"pentagon\", hexagon: \"hexagon\",\n parallelogram: \"parallelogram\", cylinder: \"cylinder\", cloud: \"cloud\", pill: \"pill\", sticky: \"note\", text: \"text\",\n};\nconst round = (n: number) => Math.round(n);\n\n/** The width of one letter of a wire's label, as the board letters it (Patrick Hand at 19px, with slack). */\nexport const LABEL_CHAR = 19 * SK.lower * SK.wrapSlack;\nexport const wireLabel = (s: string) => labelSize(s, LABEL_CHAR);\n\n/** Lines a run of hand lettering takes in a given width, wrapped word by word. */\nconst lines = (s: string | undefined, size: number, upper: boolean, w: number) => wrapLines(s, size * (upper ? SK.upper : SK.lower) * SK.wrapSlack, w);\n\n/** The height a sketched shape needs for its words at a lettering size, in a given width. */\nexport function blockHeight(title: string | undefined, text: string | undefined, icon: string | undefined, size: keyof typeof SK.block, w: number, shape: Shape = \"box\"): number {\n const t = SK.block[size];\n const poly = isPolygon(shape) ? POLYGONS[shape].inset : null;\n const roundish = shape === \"ellipse\" || shape === \"cloud\";\n const inner = poly ? w * (1 - poly[1] - poly[3]) - SK.pad * 2 : (w - SK.pad * 2) * (roundish ? SK.roundInner : 1);\n const body = (validIcon(icon) ? t.icon + 6 : 0) + lines(title, t.title, true, inner) * t.titleLh + lines(text, t.text, false, inner) * t.textLh;\n if (poly) return round((body + SK.pad * 2) / (1 - poly[0] - poly[2]));\n return round((body + SK.pad * 2) / (roundish ? SK.roundInner : 1)) + (shape === \"cylinder\" ? 28 : 0);\n}\n/** A sticky note's height for its words (it is lettered in the board's own type, not in marker). */\nexport const noteHeight = (text: string, w: number) => T.noteTop + Math.max(1, wrapLines(text, T.noteChar, w - T.notePad)) * T.noteLh;\n\n/** What a shape says: its line, then the answers to why, who, when and how, one per line. */\nfunction body(n: FreeItem): string {\n const qa: [string, string | undefined][] = [[\"Why\", n.why], [\"Who\", n.who], [\"When\", n.when], [\"Where\", n.where], [\"How\", n.how], [\"How much\", n.howMuch], [\"Assumes\", n.assumes]];\n return [n.text, ...qa.filter(([, v]) => v).map(([k, v]) => `${k}: ${v}`)].filter(Boolean).map((s) => noEmoji(s!)).join(\"\\n\").slice(0, BOARD.maxText);\n}\n\n/** Items wires keep clear of: everything but pen strokes and roads. */\nexport const obstacles = (notes: readonly WbNote[]): Map<string, Item> =>\n new Map(notes.filter((n) => n.shape !== \"ink\" && n.shape !== \"track\").map((n) => [n.id, { x: n.x, y: n.y, w: n.w, h: n.h, ...(n.shape ? { shape: n.shape } : {}) }]));\n/** Wires the board routes itself, in drawing order. */\nexport const autoWires = (links: readonly WbLink[]): WbLink[] => links.filter((l) => l.route === \"auto\");\n\n/** The size of an item for its words, in its shape; squares and circles grow until the words fit with equal sides. */\nfunction sizeOf(it: FreeItem, shape: Shape, form: Form, size: TextSize, text: string): { w: number; h: number } {\n const title = it.title ? noEmoji(it.title) : undefined;\n // A sticky stays under the width where the board letters notes larger, so its words keep the size measured here.\n if (form === \"sticky\") { const w = Math.min(T.noteMaxW, it.w ?? T.noteW); return { w, h: noteHeight([title, text].filter(Boolean).join(\"\\n\"), w) }; }\n if (form === \"pill\") {\n const t = SK.words[size], label = title ?? \"\";\n return { w: Math.max(T.minTextW, round(label.length * t.size * SK.upper * SK.wrapSlack) + 40), h: SK.pillH };\n }\n if (form === \"text\") {\n const t = SK.words[size], words = [title, text].filter(Boolean).join(\"\\n\");\n const w = it.w ?? Math.min(T.widths.xl * 2, round(Math.max(...words.split(\"\\n\").map((l) => l.length)) * t.size * (t.upper ? SK.upper : SK.lower) * SK.wrapSlack) + 8);\n return { w, h: lines(words, t.size, t.upper, w) * t.lh + 4 };\n }\n // A bar may be drawn narrow, but never narrower than its words can be read in.\n let w = Math.max(T.minTextW, it.w ?? T.widths[size]);\n if (form === \"square\" || form === \"circle\") {\n for (let i = 0; i < 16; i++) { const h = blockHeight(title, text, it.icon, size, w, shape); if (h <= w) break; w = round((w + h) / 2) + 8; }\n return { w, h: w };\n }\n const min = isPolygon(shape) ? T.minAspect[shape as Polygon] * w : 0;\n return { w, h: Math.max(round(min), it.h ?? 0, blockHeight(title, text, it.icon, size, w, shape)) };\n}\n\n/**\n * The story as board ops, one group per beat in the order told: the headline and legend first, then each beat's\n * items where the agent put them, its sticky notes, and its wires. `board` is what is already there, when adding.\n */\nexport function layFree(story: FreeStory, origin = { x: 0, y: 0 }, board?: Pick<Board, \"notes\" | \"links\">, ids: () => string = () => uid(\"n\")): { steps: ToldStep[]; skipped: string[] } {\n const steps: ToldStep[] = [];\n const skipped: string[] = [];\n const notes: WbNote[] = [...(board?.notes ?? [])];\n const links: WbLink[] = [...(board?.links ?? [])];\n // Sized as the board will store it (its minimum size applied), so what is kept clear here stays clear there.\n const add = (ops: BoardOp[], n: WbNote) => {\n const min = minSize(n.shape);\n const sized = { ...n, w: Math.max(min.w, n.w), h: Math.max(min.h, n.h) };\n ops.push({ op: \"note.add\", note: sized });\n notes.push(sized);\n };\n\n // The headline: the finding in one line, what it rests on, what the colours mean, one drawing beside it.\n const H = SK.headline, head: BoardOp[] = [];\n const title = noEmoji(story.headline).slice(0, LEN.line);\n const titleW = Math.min(H.w, round(title.length * SK.words.xl.size * SK.upper * SK.wrapSlack) + 8);\n const titleH = lines(title, SK.words.xl.size, true, titleW) * SK.words.xl.lh + 4;\n add(head, { id: ids(), shape: \"text\", size: \"xl\", pen: \"black\", text: title, color: \"paper\", x: origin.x, y: origin.y, w: titleW, h: titleH, frame: null } as WbNote);\n const icon = validIcon(story.icon);\n if (icon) add(head, { id: ids(), shape: \"sticker\", icon, text: \"\", color: \"paper\", x: origin.x + titleW + H.iconGap, y: origin.y - 8, w: H.icon, h: H.icon, frame: null } as WbNote);\n let y = origin.y + titleH + H.gapBelow;\n const items = story.beats.flatMap((b) => b.items ?? []);\n const used = new Set<Tone>(items.map((n) => n.tone ?? \"fact\"));\n const deep = items.some((n) => (n.layer ?? 0) > 0);\n const legend = [...TONES.filter((t) => used.has(t)).map((t) => T.legend[t]), T.legend.note, ...(deep ? [T.legend.wires] : [])].join(\" · \");\n for (const text of [story.context ? noEmoji(story.context).slice(0, LEN.message) : \"\", legend]) {\n if (!text) continue;\n const h = lines(text, SK.words.s.size, false, H.contextW) * SK.words.s.lh + 4;\n add(head, { id: ids(), shape: \"text\", size: \"s\", pen: \"black\", text, color: \"paper\", x: origin.x, y, w: H.contextW, h, frame: null } as WbNote);\n y += h + 6;\n }\n steps.push({ say: title, ops: head });\n const ox = origin.x, oy = y + T.below;\n\n const byKey = new Map<string, string>();\n const layerOf = new Map<string, number>();\n const derived = items.every((n) => n.layer === undefined) ? depthByWires(story.beats) : null;\n let routed = route(notes, links);\n const taken = () => [...obstacles(notes).values(), ...routed.wires, ...routed.labels];\n // A note goes above what it is about, then below, and only then to a side: the sides are where the wires of a flow\n // leave and arrive.\n const sticky = (ops: BoardOp[], text: string, near: Box) => {\n const min = minSize(undefined), h = Math.max(min.h, noteHeight(text, T.noteW)), w = Math.max(min.w, T.noteW), g = T.noteGap;\n const tries = [{ x: near.x, y: near.y - h - g, w, h }, { x: near.x, y: near.y + near.h + g, w, h }, { x: near.x + near.w + g, y: near.y, w, h }, { x: near.x - w - g, y: near.y, w, h }];\n const all = taken();\n const spot = tries.find((b) => !overlaps(b, all, 8)) ?? freeSpot(tries[0], all, 8);\n add(ops, { id: ids(), text, color: \"yellow\", x: spot.x, y: spot.y, w, h, frame: null } as WbNote);\n };\n\n for (const beat of story.beats) {\n const ops: BoardOp[] = [];\n const say = noEmoji(beat.say).slice(0, LEN.message);\n const drawn: Box[] = [];\n for (const it of (beat.items ?? []).slice(0, T.maxItems)) {\n if (byKey.has(it.key)) { skipped.push(it.key); continue; }\n const text = body(it);\n // A pill is a one-line tag: an item with more to say than its title is drawn as a box so all of it shows.\n const form: Form = it.form === \"pill\" && text ? \"rect\" : it.form ?? \"rect\", shape = SHAPE[form], size: TextSize = it.size ?? \"m\";\n const min = minSize(form === \"sticky\" ? undefined : shape), sz = sizeOf(it, shape, form, size, text);\n const w = Math.max(min.w, sz.w), h = Math.max(min.h, sz.h);\n const spot = freeSpot({ x: round(ox + it.x), y: round(oy + it.y), w, h }, taken(), T.gap);\n const id = ids();\n byKey.set(it.key, id);\n layerOf.set(it.key, Math.max(0, Math.min(MAX_LAYER, Math.round(it.layer ?? derived?.get(it.key) ?? 0))));\n const ic = validIcon(it.icon);\n const pen = it.tone ? PEN[it.tone] : \"black\";\n const titled = it.title ? noEmoji(it.title).slice(0, LEN.title) : undefined;\n const n: WbNote =\n form === \"sticky\" ? { id, text: [titled, text].filter(Boolean).join(\"\\n\"), color: \"yellow\" as NoteColor, ...spot, frame: null } as WbNote\n : form === \"text\" ? { id, shape: \"text\", size, pen, text: [titled, text].filter(Boolean).join(\"\\n\"), color: \"paper\" as NoteColor, ...spot, frame: null } as WbNote\n : form === \"pill\" ? { id, shape: \"pill\", size, pen, text: titled ?? \"\", color: \"paper\" as NoteColor, ...spot, frame: null } as WbNote\n : { id, shape, pen, size, ...(titled ? { title: titled } : {}), text, color: \"paper\" as NoteColor, ...spot, frame: null, ...(ic ? { icon: ic } : {}) } as WbNote;\n add(ops, n);\n drawn.push(spot);\n if (it.note) sticky(ops, noEmoji(it.note).slice(0, LEN.message), spot);\n }\n // What was said while drawing this beat, pinned up beside the first thing drawn in it.\n const firstLink = beat.links?.find((l) => byKey.has(l.from));\n const near = drawn[0] ?? (firstLink ? notes.find((n) => n.id === byKey.get(firstLink.from)) : undefined);\n if (near) sticky(ops, say, near);\n for (const l of beat.links ?? []) {\n const from = byKey.get(l.from), to = byKey.get(l.to);\n if (!from || !to) { skipped.push(`${l.from} -> ${l.to}`); continue; }\n // A wire is as deep as the deeper of its two ends: black along the main flow, a colour per layer below it.\n const layer = Math.max(layerOf.get(l.from) ?? 0, layerOf.get(l.to) ?? 0);\n const link: WbLink = { id: uid(\"l\"), from, to, route: \"auto\", ...(l.label ? { label: noEmoji(l.label).slice(0, LEN.label) } : {}), ...(l.dashed ? { dashed: true } : {}), ...(layer ? { layer } : {}) };\n ops.push({ op: \"link.add\", link });\n links.push(link);\n }\n routed = route(notes, links);\n steps.push({ say, ops });\n }\n return { steps, skipped };\n}\n\n/**\n * Layers read from the wiring when the agent gave none: what no wire points at is the main flow (layer 0), and each\n * wire leads one layer further in, the shortest way.\n */\nfunction depthByWires(beats: FreeBeat[]): Map<string, number> {\n const keys = beats.flatMap((b) => (b.items ?? []).map((i) => i.key));\n const links = beats.flatMap((b) => b.links ?? []);\n const into = new Set(links.map((l) => l.to));\n const depth = new Map<string, number>(keys.filter((k) => !into.has(k)).map((k) => [k, 0]));\n for (let queue = [...depth.keys()]; queue.length; ) {\n const k = queue.shift()!, d = depth.get(k)!;\n for (const l of links) if (l.from === k && !depth.has(l.to)) { depth.set(l.to, Math.min(MAX_LAYER, d + 1)); queue.push(l.to); }\n }\n return depth;\n}\n\n/** The board's own wires routed over what is drawn so far, as boxes later items keep clear of. */\nfunction route(notes: readonly WbNote[], links: readonly WbLink[]): { wires: Box[]; labels: Box[] } {\n const auto = autoWires(links);\n const r = routeWires(obstacles(notes), auto.map((l): Wire => ({ from: l.from, to: l.to, ...(l.label ? { label: l.label } : {}) })), wireLabel);\n const wires: Box[] = [], labels: Box[] = [];\n for (const x of r.values()) { wires.push(...wireBoxes(x.pts)); if (x.label) labels.push(x.label); }\n return { wires, labels };\n}\n"],"mappings":";AACO,IAAM,MAAM;AAAA,EACjB,QAAQ;AAA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