@ofrnsb/whiteboard 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3745 @@
1
+ import {
2
+ BOARD,
3
+ ILLUSTRATIONS,
4
+ OUTLINED,
5
+ applyOps,
6
+ autoWires,
7
+ frameAt,
8
+ isIllustration,
9
+ isLineIcon,
10
+ isPolygon,
11
+ minSize,
12
+ obstacles,
13
+ polygonPad,
14
+ polygonPoints,
15
+ routeWires,
16
+ uid,
17
+ wireLabel,
18
+ wrapLines
19
+ } from "./chunk-ORDEALPW.js";
20
+
21
+ // src/react/config.ts
22
+ var SECOND_MS = 1e3;
23
+ var BOARD2 = {
24
+ /** The sidebar reloads its board list this long after the last saved edit. */
25
+ listReloadMs: 800,
26
+ pollMs: 4 * SECOND_MS,
27
+ fastMs: SECOND_MS,
28
+ agentWindowMs: 20 * SECOND_MS,
29
+ minZoom: 0.1,
30
+ maxZoom: 2.5,
31
+ rule: 32,
32
+ presenceMs: 6 * SECOND_MS,
33
+ presenceSlackMs: 50,
34
+ agentRecentMs: 30 * SECOND_MS,
35
+ startView: { x: 24, y: 24, z: 0.8 },
36
+ homeView: { x: 24, y: 24, z: 1 },
37
+ startSize: { w: 800, h: 560 },
38
+ /** Room kept under the content on fit for the change bar and the toolbar floating over the board. */
39
+ fitBottom: 176,
40
+ /** Extra room the history strip and its narration caption take under the board while open. */
41
+ historyRoom: 150,
42
+ fitTop: 24,
43
+ widthPad: 40,
44
+ newItem: { note: { w: 200, h: 120 }, text: { w: 260, h: 40 }, shape: { w: 160, h: 72 } },
45
+ newFrame: { w: 480, h: 320 },
46
+ frameMinSize: { w: 160, h: 100 },
47
+ nudge: 8,
48
+ zoomStep: 1.25,
49
+ wheelZoom: 0.01,
50
+ /** View glide: exponential approach time constant, the longest frame step it trusts, and what counts as a wheel notch. */
51
+ glideTauMs: 90,
52
+ glideFrameCapMs: 64,
53
+ wheelNotch: 40,
54
+ wheelLinePx: 16,
55
+ labelAria: 80,
56
+ noteMax: 1e3,
57
+ changeMax: 600,
58
+ linkLabelMax: 60,
59
+ fitPad: 48,
60
+ frameMin: 40,
61
+ sheetOverscan: 8,
62
+ sheetRowH: 44,
63
+ sheetViewH: 480,
64
+ sheetPopW: 300,
65
+ sheetPopGap: 4,
66
+ sheetSkelRows: 6,
67
+ selectMax: 40,
68
+ askMax: 400,
69
+ boostMs: 90 * SECOND_MS,
70
+ /** Stickers: emoji size against the item, room kept for a caption, and the size a placed one starts at. */
71
+ stickerScale: 0.82,
72
+ stickerCaption: 26,
73
+ newSticker: 104,
74
+ /** The board's words stay readable at this zoom. Opening a board, the agent finishing one and full screen never go
75
+ * below it (past it they start at the top-left, where a told board puts its finding), and while the agent draws the
76
+ * camera follows its cursor at this zoom or closer instead of pulling out to frame a large beat. */
77
+ readZoom: 0.8,
78
+ /** While the agent writes, each item is shown so its smallest words are at least this many px on screen, and whole
79
+ * when it fits at that size or closer: a big headline is seen whole from further out, a card's small print up close. */
80
+ readPx: 11,
81
+ /** Full screen is the overview: the whole board, shrunk as far as this zoom before it starts at the top-left. */
82
+ overviewZoom: 0.25,
83
+ /** A card drawn large reads large: from these sizes (board units) its words and picture scale up. */
84
+ big: { h: 110, l: 340, xl: 520 },
85
+ /** Pen ink (perfect-freehand): diameter per width, and how the stroke thins, smooths and trails the pointer. */
86
+ ink: { thinning: 0.55, smoothing: 0.55, streamline: 0.45, taper: 6, minStep: 2 },
87
+ /** Pen widths in board units, per tool and size. */
88
+ brush: { width: { pena: { s: 3, m: 6, l: 10 }, spidol: { s: 8, m: 14, l: 22 } } },
89
+ /** Arrows (perfect-arrows): how far a curved one bows and how much it stretches over short gaps; padding off the boxes. */
90
+ arrow: { curveBow: 0.2, curveStretch: 0.5, padStart: 2, padEnd: 4, head: 9, headWidth: 0.55 },
91
+ /** The ink look (roughjs): careful hand inking, not a scribble; multi-stroke only on shapes and sections. */
92
+ rough: { roughness: 0.75, bowing: 0.5, cellRoughness: 0.55, linkRoughness: 0.6, cacheMax: 3e3 },
93
+ /** Agent edits ringed in stamp ink (rough-notation): how many at once, the draw time and how long they stay. */
94
+ notation: { max: 12, drawMs: 720, holdMs: 4200, pad: 6, stroke: 2, stamp: "#22457a" },
95
+ /** The board's look per browser: "ink" (hand-inked outlines) or "neat" (clean vectors). */
96
+ styleKey: (boardId) => `sp:wb-style:${boardId}`,
97
+ /** Someone working on the board counts as live this long after their last step (the server's activity window). */
98
+ activityFreshMs: 30 * SECOND_MS,
99
+ /**
100
+ * Choreography at the designed (Tenang) tempo: each step gets 450-900ms and a whole build about 16s at most; the
101
+ * cursor flies 500-900ms, lands `leadMs` before its item, and holds on it `holdMs` before moving on; entrances settle
102
+ * within `enterMs`. Every value is scaled by the viewer's tempo.
103
+ */
104
+ /** A sticky note shows as many 20px lines as fit its height after its padding (`chrome`) and title line; never fewer than `min`. */
105
+ noteLines: { min: 3, lh: 20, chrome: 28, title: 24 },
106
+ choreo: { totalMs: 16e3, minMs: 450, maxMs: 900, enterMs: 1200, maxSteps: 160, leadMs: 220, holdMs: 450, flightMinMs: 750, flightMaxMs: 1300 },
107
+ /** Tempo per browser: Tenang (the design), Normal and Cepat scale every client duration by `factor`. */
108
+ tempo: { key: "sp:wb-tempo", default: "tenang", factor: { tenang: 1, normal: 0.6, cepat: 0.35 } },
109
+ /**
110
+ * Entrance times at Tenang: titles type at `typeCps` characters a second; the road draws at a constant speed over
111
+ * `roadMs`; a link draws over `linkMs` and its head appears as it finishes; the stamp's ink ring spreads over `ringMs`.
112
+ * A wire and a heading wait `handMs` for the agent's hand to reach where they start.
113
+ A body line types at `bodyCps` (sped up so a long body takes at most `bodyMaxMs`); the pen hops to the next line in `lineHopMs`. */
114
+ enter: { handMs: 180, typeCps: 28, bodyCps: 75, bodyMaxMs: 3200, lineHopMs: 90, typeMinMs: 450, roadMs: 2100, linkMs: 900, stickerMs: 700, ringMs: 800, headingMs: 1600, frameMs: 1e3, cellMs: 500, dotMs: 520, fadeMs: 420, artMs: 700, footMs: 600 },
115
+ /** A board the agent made counts as new (its build plays once on open) for this long after it was created. */
116
+ buildFreshMs: 10 * 60 * SECOND_MS,
117
+ /** Where this browser remembers which boards already played their build this session. */
118
+ playedKey: "sp:wb-built",
119
+ /** "Putar ulang": the pause after each version, and how fast the narration types (ms a character). */
120
+ replay: { holdMs: 1600, typeMs: 36 },
121
+ /** Springs in duration-and-bounce form: the cursor's flight, cards popping in, milestones stamping in. */
122
+ springs: { cursor: { visualDuration: 0.75, bounce: 0 }, card: { visualDuration: 0.7, bounce: 0.12 }, stamp: { visualDuration: 0.6, bounce: 0.3 } },
123
+ /** The cursor's flight bows sideways by this share of its length, and dips this many px as it "presses" an item down. */
124
+ cursorArc: 0.08,
125
+ cursorPressPx: 2,
126
+ /** Camera: long flights along the zoom path take this long; the agent leaves the camera alone this long after any input. */
127
+ flight: { minMs: 900, maxMs: 1800 },
128
+ userWinsMs: 2 * SECOND_MS,
129
+ /** A told board: the camera frames each beat as it is drawn, at most this close, with this much of the board around it. */
130
+ tell: { zoom: 0.95, margin: 120, aspect: 0.5, startMs: 400 },
131
+ /** A follow keeps the target inside the view inset by this share. */
132
+ followInset: 0.15,
133
+ /** Footprints: their stagger as they fade in. A moved item's onion-skin ghost fades over `onionMs`. */
134
+ footStepMs: 70,
135
+ onionMs: 1200,
136
+ /** Sounds (off by default): where the choice is kept, the thud's length and the least time between two. */
137
+ sound: { key: "sp:wb-sound", thudMs: 70, thudGapMs: 220 }
138
+ };
139
+ var INPUT_MAX = { reason: 300, unitName: 80, projectName: 80, projectGoal: 400, frameName: 120, tabName: 60, boardTitle: 120 };
140
+
141
+ // src/react/copy.ts
142
+ var BOARD_COPY = {
143
+ loadFailed: "Could not load the board",
144
+ unsaved: "Changes not saved yet",
145
+ unsavedWhy: (why) => `Changes not saved yet: ${why}`,
146
+ you: "You"
147
+ };
148
+ var WB = {
149
+ colors: { paper: "Paper", ink: "Ink", red: "Red", yellow: "Yellow", blue: "Blue", green: "Green", pink: "Pink", gray: "Gray", purple: "Purple", outline: "Outline", new: "New", orange: "Orange", peach: "Peach", sand: "Sand" },
150
+ shapes: { box: "Box", ellipse: "Ellipse", cloud: "Cloud", cylinder: "Cylinder", diamond: "Diamond", triangle: "Triangle", pentagon: "Pentagon", hexagon: "Hexagon", parallelogram: "Parallelogram" },
151
+ sizes: { s: "Small", m: "Medium", l: "Large", xl: "Heading" },
152
+ tools: { select: "Select", pan: "Pan", text: "Text", frame: "Section", note: "Note", pen: "Pen", shape: "Shape", link: "Arrow" },
153
+ inkAria: "Pen stroke",
154
+ itemAria: (kind, label) => `${kind}: ${label}`,
155
+ note: "Note",
156
+ text: "Text",
157
+ shape: "Shape",
158
+ titleAndBody: "Title on the first line, details on the next",
159
+ body: "Details",
160
+ title: "Title",
161
+ emptyNote: "Empty note",
162
+ owner: (who) => `Owner ${who}`,
163
+ due: (when) => `Due ${when}`,
164
+ resize: "Drag to resize",
165
+ frameHead: "Drag to move the section, double-click to rename",
166
+ frameName: "Section name",
167
+ untitled: "Untitled",
168
+ resizeFrame: "Drag to resize the section",
169
+ newFrame: "New section",
170
+ askSelected: (ref, ids, q) => `On board ${ref}, selected notes ${ids}: ${q}`,
171
+ askBoard: (ref, q) => `On board ${ref}: ${q}`,
172
+ toDocAsk: (ref) => `Turn board ${ref} into short meeting notes.`,
173
+ changedBy: (who) => `Changed by ${who}`,
174
+ saving: "Saving\u2026",
175
+ close: "Close",
176
+ fullscreen: "Full screen",
177
+ more: "More",
178
+ toDoc: "Turn into a document",
179
+ reload: "Reload",
180
+ loadFailed: "Could not load the board.",
181
+ retry: "Try again",
182
+ loading: "Loading board",
183
+ canvasAria: "Board canvas",
184
+ wireHint: "Drag to another item to connect",
185
+ agentDrawing: "The agent is drawing\u2026",
186
+ empty: "The board is empty. Pick a tool below, double-click to add a note, or ask the agent to draw it.",
187
+ zoom: (pct) => `Zoom ${pct}%`,
188
+ zoomIn: "Zoom in",
189
+ zoomOut: "Zoom out",
190
+ fit: "Fit to screen",
191
+ selected: (n) => `${n} selected`,
192
+ color: "Color",
193
+ colorOf: (name) => `Color ${name}`,
194
+ textSize: "Text size",
195
+ remove: "Delete",
196
+ askPick: "Ask the agent about this selection",
197
+ ask: "Ask",
198
+ linkSelected: "Selected arrow",
199
+ routeTo: { elbow: "Make elbow", curve: "Make curved", straight: "Make straight", auto: "Route around" },
200
+ stickerTool: "Sticker",
201
+ penMenu: "Pen options",
202
+ penColors: { ink: "Ink", blue: "Stamp blue", red: "Red" },
203
+ penSizes: { s: "Thin", m: "Medium", l: "Thick" },
204
+ penBrushes: { pena: "Pen", spidol: "Marker" },
205
+ penBrushGroup: "Tool",
206
+ tempoLabel: "Tempo",
207
+ tempos: { tenang: "Calm", normal: "Normal", cepat: "Fast" },
208
+ penColorGroup: "Ink color",
209
+ penSizeGroup: "Thickness",
210
+ styleLabel: "Style",
211
+ styles: { ink: "Ink", neat: "Neat" },
212
+ styleOf: (name) => `Style: ${name}`,
213
+ stickerMenu: "Choose a sticker",
214
+ stickerOf: (name) => `Place the ${name.replace(/-/g, " ")} illustration`,
215
+ toElbow: "Make elbow",
216
+ toStraight: "Make straight",
217
+ dashed: "Dashed",
218
+ ends: (n) => `Ends: ${n}`,
219
+ endsOne: "one",
220
+ endsTwo: "two",
221
+ endsNone: "none",
222
+ linkLabel: "Arrow label",
223
+ describeChange: "Describe a change for the agent\u2026",
224
+ describeChangeAria: "Describe a change for the agent",
225
+ send: "Send",
226
+ toolbar: "Board tools",
227
+ askAgent: "Ask agent",
228
+ // The agent working live, the choreography and the time machine
229
+ agent: "Agent",
230
+ agentWorking: (what) => `Agent \xB7 ${what}`,
231
+ agentBuilding: "building the board",
232
+ /** What the agent's cursor says while each kind of item lands. */
233
+ stepLabel: { frame: "laying out a section", heading: "writing the title", track: "drawing the road", pill: "placing milestones", dot: "placing milestones", cell: "setting up the calendar", card: "placing cards", note: "placing cards", sticker: "placing illustrations", link: "connecting steps", change: "tidying up", remove: "removing" },
234
+ personWorking: (who, what) => `${who} \xB7 ${what}`,
235
+ skip: "Skip",
236
+ /** The agent's piece of work, waiting to be kept or undone. */
237
+ batchOf: (what) => `Agent: ${what}`,
238
+ keep: "Keep",
239
+ undo: "Undo",
240
+ kept: "Kept",
241
+ undoing: "Undoing\u2026",
242
+ keepAria: (what) => `Keep the agent's change: ${what}`,
243
+ undoAria: (what) => `Undo the agent's change: ${what}`,
244
+ batchHint: "Enter keeps, Esc undoes",
245
+ /** The marker at the view's edge pointing to the agent working off screen; clicking it flies there. */
246
+ edgeOf: (what) => `Agent \xB7 ${what}`,
247
+ edgeAria: (what) => `The agent is ${what} off screen. Show it`,
248
+ planned: "agent's plan",
249
+ soundLabel: "Sound",
250
+ soundOn: "Sound on",
251
+ soundOff: "Sound off",
252
+ skipAria: "Skip the animation, show the final result",
253
+ history: "History",
254
+ historyAria: "Board history",
255
+ historyEmpty: "This board has no history yet.",
256
+ historyLoading: "Loading history\u2026",
257
+ historyRange: "Slide to see versions",
258
+ versionTick: (v, who, when, what) => `Version ${v} \xB7 ${who} \xB7 ${when} \xB7 ${what}`,
259
+ viewing: (v) => `Viewing version ${v}`,
260
+ latest: "Back to latest",
261
+ restoreThis: "Restore this version",
262
+ restoring: "Restoring\u2026",
263
+ replay: "Replay",
264
+ replayAria: "Replay how this board was built",
265
+ pause: "Pause",
266
+ resume: "Resume",
267
+ speed: (x) => `${x}\xD7`,
268
+ speedAria: "Replay speed",
269
+ readOnly: "View only: go back to latest to change the board",
270
+ versionMissing: "This version could not be loaded."
271
+ };
272
+
273
+ // src/react/Whiteboard.tsx
274
+ import { memo as memo2, useCallback as useCallback2, useEffect as useEffect3, useMemo, useReducer, useRef as useRef3, useState as useState3 } from "react";
275
+
276
+ // src/react/format.ts
277
+ function ago(iso, now = Date.now()) {
278
+ const ts = Date.parse(iso);
279
+ if (!Number.isFinite(ts)) return "";
280
+ const s = Math.max(0, Math.round((now - ts) / 1e3));
281
+ if (s < 60) return "just now";
282
+ if (s < 3600) return `${Math.floor(s / 60)} min ago`;
283
+ if (s < 86400) return `${Math.floor(s / 3600)} h ago`;
284
+ if (s < 86400 * 7) return `${Math.floor(s / 86400)} d ago`;
285
+ return new Date(ts).toLocaleString(void 0, { day: "numeric", month: "short", year: "numeric" });
286
+ }
287
+
288
+ // src/react/icons.tsx
289
+ import { jsx } from "react/jsx-runtime";
290
+ var svg = (size, className, d) => /* @__PURE__ */ jsx("svg", { width: size ?? 16, height: size ?? 16, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", className, "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d }) });
291
+ var IChat = ({ size, className }) => svg(size, className, "M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12Z");
292
+ var IClose = ({ size, className }) => svg(size, className, "M6 6l12 12M18 6 6 18");
293
+ var IDoc = ({ size, className }) => svg(size, className, "M7 3h7l5 5v13H7zM14 3v5h5M10 13h6M10 17h6");
294
+ var IPanel = ({ size, className }) => svg(size, className, "M4 5h16v14H4zM15 5v14");
295
+ var IRefresh = ({ size, className }) => svg(size, className, "M20 11a8 8 0 1 0-2.3 5.7M20 4v7h-7");
296
+ var ITrash = ({ size, className }) => svg(size, className, "M4 7h16M10 11v6M14 11v6M6 7l1 13h10l1-13M9 7V4h6v3");
297
+
298
+ // src/react/line-icons.ts
299
+ var LINE_ICON_SVG = {
300
+ "phone": '<path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />',
301
+ "phone-call": '<path d="M13 2a9 9 0 0 1 9 9" /> <path d="M13 6a5 5 0 0 1 5 5" /> <path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />',
302
+ "phone-incoming": '<path d="M16 2v6h6" /> <path d="m22 2-6 6" /> <path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />',
303
+ "phone-missed": '<path d="m16 2 6 6" /> <path d="m22 2-6 6" /> <path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" />',
304
+ "headset": '<path d="M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z" /> <path d="M21 16v2a4 4 0 0 1-4 4h-5" />',
305
+ "message-circle": '<path d="M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" />',
306
+ "message-square": '<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" />',
307
+ "messages-square": '<path d="M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z" /> <path d="M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1" />',
308
+ "mail": '<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" /> <rect x="2" y="4" width="20" height="16" rx="2" />',
309
+ "send": '<path d="M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" /> <path d="m21.854 2.147-10.94 10.939" />',
310
+ "bell": '<path d="M10.268 21a2 2 0 0 0 3.464 0" /> <path d="M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326" />',
311
+ "megaphone": '<path d="M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z" /> <path d="M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14" /> <path d="M8 6v8" />',
312
+ "user": '<path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2" /> <circle cx="12" cy="7" r="4" />',
313
+ "users": '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <path d="M16 3.128a4 4 0 0 1 0 7.744" /> <path d="M22 21v-2a4 4 0 0 0-3-3.87" /> <circle cx="9" cy="7" r="4" />',
314
+ "user-check": '<path d="m16 11 2 2 4-4" /> <path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <circle cx="9" cy="7" r="4" />',
315
+ "user-x": '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <circle cx="9" cy="7" r="4" /> <line x1="17" x2="22" y1="8" y2="13" /> <line x1="22" x2="17" y1="8" y2="13" />',
316
+ "user-plus": '<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" /> <circle cx="9" cy="7" r="4" /> <line x1="19" x2="19" y1="8" y2="14" /> <line x1="22" x2="16" y1="11" y2="11" />',
317
+ "contact": '<path d="M16 2v2" /> <path d="M7 21v-2a2 2 0 012-2h6a2 2 0 012 2v2" /> <path d="M8 2v2" /> <circle cx="12" cy="10" r="3" /> <rect x="3" y="3" width="18" height="18" rx="2" />',
318
+ "crown": '<path d="M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z" /> <path d="M5 21h14" />',
319
+ "star": '<path d="M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z" />',
320
+ "heart": '<path d="M2 9.5a5.5 5.5 0 0 1 9.591-3.676.56.56 0 0 0 .818 0A5.49 5.49 0 0 1 22 9.5c0 2.29-1.5 4-3 5.5l-5.492 5.313a2 2 0 0 1-3 .019L5 15c-1.5-1.5-3-3.2-3-5.5" />',
321
+ "handshake": '<path d="m11 17 2 2a1 1 0 1 0 3-3" /> <path d="m14 14 2.5 2.5a1 1 0 1 0 3-3l-3.88-3.88a3 3 0 0 0-4.24 0l-.88.88a1 1 0 1 1-3-3l2.81-2.81a5.79 5.79 0 0 1 7.06-.87l.47.28a2 2 0 0 0 1.42.25L21 4" /> <path d="m21 3 1 11h-2" /> <path d="M3 3 2 14l6.5 6.5a1 1 0 1 0 3-3" /> <path d="M3 4h8" />',
322
+ "briefcase": '<path d="M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16" /> <rect width="20" height="14" x="2" y="6" rx="2" />',
323
+ "building": '<path d="M12 10h.01" /> <path d="M12 14h.01" /> <path d="M12 6h.01" /> <path d="M16 10h.01" /> <path d="M16 14h.01" /> <path d="M16 6h.01" /> <path d="M8 10h.01" /> <path d="M8 14h.01" /> <path d="M8 6h.01" /> <path d="M9 22v-3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3" /> <rect x="4" y="2" width="16" height="20" rx="2" />',
324
+ "landmark": '<path d="M10 18v-7" /> <path d="M11.119 2.205a2 2 0 0 1 1.762 0l7.84 3.846A.5.5 0 0 1 20.5 7h-17a.5.5 0 0 1-.22-.949z" /> <path d="M14 18v-7" /> <path d="M18 18v-7" /> <path d="M3 22h18" /> <path d="M6 18v-7" />',
325
+ "store": '<path d="M15 21v-5a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v5" /> <path d="M17.774 10.31a1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.451 0 1.12 1.12 0 0 0-1.548 0 2.5 2.5 0 0 1-3.452 0 1.12 1.12 0 0 0-1.549 0 2.5 2.5 0 0 1-3.77-3.248l2.889-4.184A2 2 0 0 1 7 2h10a2 2 0 0 1 1.653.873l2.895 4.192a2.5 2.5 0 0 1-3.774 3.244" /> <path d="M4 10.95V19a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8.05" />',
326
+ "house": '<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" /> <path d="M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />',
327
+ "credit-card": '<rect width="20" height="14" x="2" y="5" rx="2" /> <line x1="2" x2="22" y1="10" y2="10" /> <path d="M6 14h2" />',
328
+ "wallet": '<path d="M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1" /> <path d="M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4" />',
329
+ "banknote": '<rect width="20" height="12" x="2" y="6" rx="2" /> <circle cx="12" cy="12" r="2" /> <path d="M6 12h.01M18 12h.01" />',
330
+ "coins": '<path d="M13.744 17.736a6 6 0 1 1-7.48-7.48" /> <path d="M15 6h1v4" /> <path d="m6.134 14.768.866-.5 2 3.464" /> <circle cx="16" cy="8" r="6" />',
331
+ "piggy-bank": '<path d="M11 17h3v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a3.16 3.16 0 0 0 2-2h1a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-1a5 5 0 0 0-2-4V3a4 4 0 0 0-3.2 1.6l-.3.4H11a6 6 0 0 0-6 6v1a5 5 0 0 0 2 4v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1z" /> <path d="M16 10h.01" /> <path d="M2 8v1a2 2 0 0 0 2 2h1" />',
332
+ "receipt": '<path d="M12 17V7" /> <path d="M16 8h-6a2 2 0 0 0 0 4h4a2 2 0 0 1 0 4H8" /> <path d="M4 3a1 1 0 0 1 1-1 1.3 1.3 0 0 1 .7.2l.933.6a1.3 1.3 0 0 0 1.4 0l.934-.6a1.3 1.3 0 0 1 1.4 0l.933.6a1.3 1.3 0 0 0 1.4 0l.933-.6a1.3 1.3 0 0 1 1.4 0l.934.6a1.3 1.3 0 0 0 1.4 0l.933-.6A1.3 1.3 0 0 1 19 2a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1 1.3 1.3 0 0 1-.7-.2l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.934.6a1.3 1.3 0 0 1-1.4 0l-.933-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-1.4 0l-.934-.6a1.3 1.3 0 0 0-1.4 0l-.933.6a1.3 1.3 0 0 1-.7.2 1 1 0 0 1-1-1z" />',
333
+ "percent": '<line x1="19" x2="5" y1="5" y2="19" /> <circle cx="6.5" cy="6.5" r="2.5" /> <circle cx="17.5" cy="17.5" r="2.5" />',
334
+ "badge-dollar-sign": '<path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" /> <path d="M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8" /> <path d="M12 18V6" />',
335
+ "hand-coins": '<path d="M11 15h2a2 2 0 1 0 0-4h-3c-.6 0-1.1.2-1.4.6L3 17" /> <path d="m7 21 1.6-1.4c.3-.4.8-.6 1.4-.6h4c1.1 0 2.1-.4 2.8-1.2l4.6-4.4a2 2 0 0 0-2.75-2.91l-4.2 3.9" /> <path d="m2 16 6 6" /> <circle cx="16" cy="9" r="2.9" /> <circle cx="6" cy="5" r="3" />',
336
+ "globe": '<circle cx="12" cy="12" r="10" /> <path d="M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20" /> <path d="M2 12h20" />',
337
+ "plane": '<path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z" />',
338
+ "map-pin": '<path d="M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0" /> <circle cx="12" cy="10" r="3" />',
339
+ "car": '<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2" /> <circle cx="7" cy="17" r="2" /> <path d="M9 17h6" /> <circle cx="17" cy="17" r="2" />',
340
+ "database": '<ellipse cx="12" cy="5" rx="9" ry="3" /> <path d="M3 5V19A9 3 0 0 0 21 19V5" /> <path d="M3 12A9 3 0 0 0 21 12" />',
341
+ "server": '<rect width="20" height="8" x="2" y="2" rx="2" ry="2" /> <rect width="20" height="8" x="2" y="14" rx="2" ry="2" /> <line x1="6" x2="6.01" y1="6" y2="6" /> <line x1="6" x2="6.01" y1="18" y2="18" />',
342
+ "cloud": '<path d="M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z" />',
343
+ "cpu": '<path d="M12 20v2" /> <path d="M12 2v2" /> <path d="M17 20v2" /> <path d="M17 2v2" /> <path d="M2 12h2" /> <path d="M2 17h2" /> <path d="M2 7h2" /> <path d="M20 12h2" /> <path d="M20 17h2" /> <path d="M20 7h2" /> <path d="M7 20v2" /> <path d="M7 2v2" /> <rect x="4" y="4" width="16" height="16" rx="2" /> <rect x="8" y="8" width="8" height="8" rx="1" />',
344
+ "bot": '<path d="M12 8V4H8" /> <rect width="16" height="12" x="4" y="8" rx="2" /> <path d="M2 14h2" /> <path d="M20 14h2" /> <path d="M15 13v2" /> <path d="M9 13v2" />',
345
+ "brain": '<path d="M12 18V5" /> <path d="M15 13a4.17 4.17 0 01-3-4 4.17 4.17 0 01-3 4" /> <path d="M17.707 6.294A3 3 0 1012 5a3 3 0 10-5.707 1.294" /> <path d="M17.996 5.125a4 4 0 012.526 5.77" /> <path d="M18 18a4 4 0 002-7.465" /> <path d="M19.967 17.482a4 4 0 11-7.967.517 4 4 0 11-7.967-.517" /> <path d="M6 18a4 4 0 01-2-7.465" /> <path d="M6.004 5.125a4 4 0 00-2.526 5.77" />',
346
+ "sparkles": '<path d="M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" /> <path d="M20 2v4" /> <path d="M22 4h-4" /> <circle cx="4" cy="20" r="2" />',
347
+ "wand": '<path d="M15 4V2" /> <path d="M15 16v-2" /> <path d="M8 9h2" /> <path d="M20 9h2" /> <path d="M17.8 11.8 19 13" /> <path d="M15 9h.01" /> <path d="M17.8 6.2 19 5" /> <path d="m3 21 9-9" /> <path d="M12.2 6.2 11 5" />',
348
+ "zap": '<path d="M15.914 4a1.5 1.5 0 00-2.474-1.561l-9 9A1.5 1.5 0 005.5 14h4.002a.5.5 0 01.471.666L8.086 20a1.5 1.5 0 002.475 1.56l9-9A1.5 1.5 0 0018.5 10h-3.997a.5.5 0 01-.472-.667z" />',
349
+ "plug": '<path d="M12 22v-5" /> <path d="M15 8V2" /> <path d="M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z" /> <path d="M9 8V2" />',
350
+ "workflow": '<rect width="8" height="8" x="3" y="3" rx="2" /> <path d="M7 11v4a2 2 0 0 0 2 2h4" /> <rect width="8" height="8" x="13" y="13" rx="2" />',
351
+ "network": '<rect x="16" y="16" width="6" height="6" rx="1" /> <rect x="2" y="16" width="6" height="6" rx="1" /> <rect x="9" y="2" width="6" height="6" rx="1" /> <path d="M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3" /> <path d="M12 12V8" />',
352
+ "git-branch": '<path d="M15 6a9 9 0 0 0-9 9V3" /> <circle cx="18" cy="6" r="3" /> <circle cx="6" cy="18" r="3" />',
353
+ "layers": '<path d="M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z" /> <path d="M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12" /> <path d="M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17" />',
354
+ "boxes": '<path d="M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z" /> <path d="m7 16.5-4.74-2.85" /> <path d="m7 16.5 5-3" /> <path d="M7 16.5v5.17" /> <path d="M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z" /> <path d="m17 16.5-5-3" /> <path d="m17 16.5 4.74-2.85" /> <path d="M17 16.5v5.17" /> <path d="M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z" /> <path d="M12 8 7.26 5.15" /> <path d="m12 8 4.74-2.85" /> <path d="M12 13.5V8" />',
355
+ "package": '<path d="M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z" /> <path d="M12 22V12" /> <polyline points="3.29 7 12 12 20.71 7" /> <path d="m7.5 4.27 9 5.15" />',
356
+ "truck": '<path d="M14 18V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v11a1 1 0 0 0 1 1h2" /> <path d="M15 18H9" /> <path d="M19 18h2a1 1 0 0 0 1-1v-3.65a1 1 0 0 0-.22-.624l-3.48-4.35A1 1 0 0 0 17.52 8H14" /> <circle cx="17" cy="18" r="2" /> <circle cx="7" cy="18" r="2" />',
357
+ "search": '<path d="m21 21-4.34-4.34" /> <circle cx="11" cy="11" r="8" />',
358
+ "list-checks": '<path d="M13 5h8" /> <path d="M13 12h8" /> <path d="M13 19h8" /> <path d="m3 17 2 2 4-4" /> <path d="m3 7 2 2 4-4" />',
359
+ "clipboard-check": '<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /> <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /> <path d="m9 14 2 2 4-4" />',
360
+ "clipboard-list": '<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /> <path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /> <path d="M12 11h4" /> <path d="M12 16h4" /> <path d="M8 11h.01" /> <path d="M8 16h.01" />',
361
+ "file-text": '<path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z" /> <path d="M14 2v5a1 1 0 0 0 1 1h5" /> <path d="M10 9H8" /> <path d="M16 13H8" /> <path d="M16 17H8" />',
362
+ "files": '<path d="M15 2h-4a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8" /> <path d="M16.706 2.706A2.4 2.4 0 0 0 15 2v5a1 1 0 0 0 1 1h5a2.4 2.4 0 0 0-.706-1.706z" /> <path d="M5 7a2 2 0 0 0-2 2v11a2 2 0 0 0 2 2h8a2 2 0 0 0 1.732-1" />',
363
+ "folder": '<path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z" />',
364
+ "book-open": '<path d="M12 5v16" /> <path d="M20.001 19A2 2 0 0022 17V5a2 2 0 00-1.999-2L16 3.002A5 5 0 0012 5a5 5 0 00-4-2H4a2 2 0 00-2 2v12a2 2 0 001.999 2H8a5 5 0 014 2 5 5 0 014-2z" />',
365
+ "notebook-pen": '<path d="M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4" /> <path d="M2 6h4" /> <path d="M2 10h4" /> <path d="M2 14h4" /> <path d="M2 18h4" /> <path d="M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z" />',
366
+ "pencil": '<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /> <path d="m15 5 4 4" />',
367
+ "calculator": '<rect width="16" height="20" x="4" y="2" rx="2" /> <line x1="8" x2="16" y1="6" y2="6" /> <line x1="16" x2="16" y1="14" y2="18" /> <path d="M16 10h.01" /> <path d="M12 10h.01" /> <path d="M8 10h.01" /> <path d="M12 14h.01" /> <path d="M8 14h.01" /> <path d="M12 18h.01" /> <path d="M8 18h.01" />',
368
+ "chart-bar": '<path d="M3 3v16a2 2 0 0 0 2 2h16" /> <path d="M7 16h8" /> <path d="M7 11h12" /> <path d="M7 6h3" />',
369
+ "chart-line": '<path d="M3 3v16a2 2 0 0 0 2 2h16" /> <path d="m19 9-5 5-4-4-3 3" />',
370
+ "chart-pie": '<path d="M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z" /> <path d="M21.21 15.89A10 10 0 1 1 8 2.83" />',
371
+ "chart-no-axes-combined": '<path d="M12 16v5" /> <path d="M16 14.639V21" /> <path d="M20 10.656V21" /> <path d="m22 3-8.646 8.646a.5.5 0 0 1-.708 0L9.354 8.354a.5.5 0 0 0-.707 0L2 15" /> <path d="M4 18.463V21" /> <path d="M8 14.656V21" />',
372
+ "trending-up": '<path d="M16 7h6v6" /> <path d="m22 7-8.5 8.5-5-5L2 17" />',
373
+ "trending-down": '<path d="M16 17h6v-6" /> <path d="m22 17-8.5-8.5-5 5L2 7" />',
374
+ "target": '<circle cx="12" cy="12" r="10" /> <circle cx="12" cy="12" r="6" /> <circle cx="12" cy="12" r="2" />',
375
+ "gauge": '<path d="m12 14 4-4" /> <path d="M3.34 19a10 10 0 1 1 17.32 0" />',
376
+ "activity": '<path d="M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2" />',
377
+ "funnel": '<path d="M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z" />',
378
+ "calendar": '<path d="M8 2v3" /> <path d="M16 2v3" /> <rect x="3" y="3" width="18" height="18" rx="2" /> <path d="M3 9h18" />',
379
+ "calendar-check": '<path d="M8 2v3" /> <path d="M16 2v3" /> <rect x="3" y="3" width="18" height="18" rx="2" /> <path d="M3 9h18" /> <path d="m9 15 2 2 4-4" />',
380
+ "calendar-clock": '<path d="M16 14v2.2l1.6 1" /> <path d="M16 2v3" /> <path d="M21 7.338V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h2.338" /> <path d="M3 9h5.859" /> <path d="M8 2v3" /> <circle cx="16" cy="16" r="6" />',
381
+ "clock": '<circle cx="12" cy="12" r="10" /> <path d="M12 6v6l4 2" />',
382
+ "timer": '<line x1="10" x2="14" y1="2" y2="2" /> <line x1="12" x2="15" y1="14" y2="11" /> <circle cx="12" cy="14" r="8" />',
383
+ "hourglass": '<path d="M5 22h14" /> <path d="M5 2h14" /> <path d="M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22" /> <path d="M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2" />',
384
+ "repeat": '<path d="m17 2 4 4-4 4" /> <path d="M3 11v-1a4 4 0 0 1 4-4h14" /> <path d="m7 22-4-4 4-4" /> <path d="M21 13v1a4 4 0 0 1-4 4H3" />',
385
+ "refresh-cw": '<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" /> <path d="M21 3v5h-5" /> <path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" /> <path d="M8 16H3v5" />',
386
+ "infinity": '<path d="M6 16c5 0 7-8 12-8a4 4 0 0 1 0 8c-5 0-7-8-12-8a4 4 0 1 0 0 8" />',
387
+ "rocket": '<path d="M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5" /> <path d="M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09" /> <path d="M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z" /> <path d="M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05" />',
388
+ "flag": '<path d="M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528" />',
389
+ "milestone": '<path d="M12 13v8" /> <path d="M12 3v3" /> <path d="M18.172 6a2 2 0 0 1 1.414.586l2.06 2.06a1.207 1.207 0 0 1 0 1.708l-2.06 2.06a2 2 0 0 1-1.414.586H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1z" />',
390
+ "check": '<path d="M20 6 9 17l-5-5" />',
391
+ "circle-check": '<circle cx="12" cy="12" r="10" /> <path d="m16 9-5.5 5.5L8 12" />',
392
+ "x": '<path d="M18 6 6 18" /> <path d="m6 6 12 12" />',
393
+ "circle-x": '<circle cx="12" cy="12" r="10" /> <path d="m15 9-6 6" /> <path d="m9 9 6 6" />',
394
+ "octagon-x": '<path d="m15 9-6 6" /> <path d="M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z" /> <path d="m9 9 6 6" />',
395
+ "shield": '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" />',
396
+ "shield-check": '<path d="M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z" /> <path d="m9 12 2 2 4-4" />',
397
+ "lock": '<rect width="18" height="11" x="3" y="11" rx="2" ry="2" /> <path d="M7 11V7a5 5 0 0 1 10 0v4" />',
398
+ "key": '<path d="m2 21 9.6-9.6" /> <path d="m7.5 15.5 2.3 2.3a1 1 0 0 1 0 1.4l-2.1 2.1a1 1 0 0 1-1.4 0L4 19" /> <circle cx="15.5" cy="7.5" r="5.5" />',
399
+ "eye": '<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /> <circle cx="12" cy="12" r="3" />',
400
+ "thumbs-up": '<path d="M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z" /> <path d="M7 10v12" />',
401
+ "thumbs-down": '<path d="M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z" /> <path d="M17 14V2" />',
402
+ "lightbulb": '<path d="M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" /> <path d="M9 18h6" /> <path d="M10 22h4" />',
403
+ "info": '<circle cx="12" cy="12" r="10" /> <path d="M12 16v-4" /> <path d="M12 8h.01" />',
404
+ "scale": '<path d="M12 3v18" /> <path d="m19 8 3 8a5 5 0 0 1-6 0zV7" /> <path d="M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1" /> <path d="m5 8 3 8a5 5 0 0 1-6 0zV7" /> <path d="M7 21h10" />',
405
+ "gavel": '<path d="m14 13-8.381 8.38a1 1 0 0 1-3.001-3l8.384-8.381" /> <path d="m16 16 6-6" /> <path d="m21.5 10.5-8-8" /> <path d="m8 8 6-6" /> <path d="m8.5 7.5 8 8" />',
406
+ "award": '<path d="m15.477 12.89 1.515 8.526a.5.5 0 0 1-.81.47l-3.58-2.687a1 1 0 0 0-1.197 0l-3.586 2.686a.5.5 0 0 1-.81-.469l1.514-8.526" /> <circle cx="12" cy="8" r="6" />',
407
+ "trophy": '<path d="M10 14.66V17a1 1 0 0 1-1 1 2 2 0 0 0-2 2v2" /> <path d="M14 14.66V17a1 1 0 0 0 1 1 2 2 0 0 1 2 2v2" /> <path d="M17.916 10H19.5A2.5 2.5 0 0 0 22 7.5V5a1 1 0 0 0-1-1h-3" /> <path d="M4 22h16" /> <path d="M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z" /> <path d="M6.084 10H4.5A2.5 2.5 0 0 1 2 7.5V5a1 1 0 0 1 1-1h3" />',
408
+ "gift": '<path d="M12 7v14" /> <path d="M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8" /> <path d="M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5" /> <rect x="3" y="7" width="18" height="4" rx="1" />',
409
+ "ticket": '<path d="M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z" /> <path d="M13 5v2" /> <path d="M13 17v2" /> <path d="M13 11v2" />',
410
+ "tag": '<path d="M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z" /> <circle cx="7.5" cy="7.5" r=".5" fill="currentColor" />',
411
+ "shopping-cart": '<path d="m2.05 2.05 1.099-.028a1 1 0 0 1 1.008.815l2.69 14.347A1 1 0 0 0 7.83 18H18" /> <path d="M4.563 5h16.435a1 1 0 0 1 .981 1.204l-1.026 6.226A2 2 0 0 1 18.962 14H6.25" /> <circle cx="18" cy="20" r="2" /> <circle cx="8" cy="20" r="2" />',
412
+ "smartphone": '<rect width="14" height="20" x="5" y="2" rx="2" ry="2" /> <path d="M12 18h.01" />',
413
+ "laptop": '<path d="M18 5a2 2 0 0 1 2 2v8.526a2 2 0 0 0 .212.897l1.068 2.127a1 1 0 0 1-.9 1.45H3.62a1 1 0 0 1-.9-1.45l1.068-2.127A2 2 0 0 0 4 15.526V7a2 2 0 0 1 2-2z" /> <path d="M20.054 15.987H3.946" />',
414
+ "monitor": '<rect width="20" height="14" x="2" y="3" rx="2" /> <line x1="8" x2="16" y1="21" y2="21" /> <line x1="12" x2="12" y1="17" y2="21" />',
415
+ "wifi": '<path d="M12 20h.01" /> <path d="M2 8.82a15 15 0 0 1 20 0" /> <path d="M5 12.859a10 10 0 0 1 14 0" /> <path d="M8.5 16.429a5 5 0 0 1 7 0" />',
416
+ "arrow-right": '<path d="M5 12h14" /> <path d="m12 5 7 7-7 7" />',
417
+ "arrow-down": '<path d="M12 5v14" /> <path d="m19 12-7 7-7-7" />',
418
+ "arrow-up-right": '<path d="M7 7h10v10" /> <path d="M7 17 17 7" />',
419
+ "corner-down-right": '<path d="m15 10 5 5-5 5" /> <path d="M4 4v7a4 4 0 0 0 4 4h12" />',
420
+ "split": '<path d="M16 3h5v5" /> <path d="M8 3H3v5" /> <path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3" /> <path d="m15 9 6-6" />',
421
+ "merge": '<path d="m8 6 4-4 4 4" /> <path d="M12 2v10.3a4 4 0 0 1-1.172 2.872L4 22" /> <path d="m20 22-5-5" />',
422
+ "plus": '<path d="M5 12h14" /> <path d="M12 5v14" />',
423
+ "minus": '<path d="M5 12h14" />',
424
+ "equal": '<line x1="5" x2="19" y1="9" y2="9" /> <line x1="5" x2="19" y1="15" y2="15" />',
425
+ "ban": '<circle cx="12" cy="12" r="10" /> <path d="M4.929 4.929 19.07 19.071" />',
426
+ "hand": '<path d="M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2" /> <path d="M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2" /> <path d="M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8" /> <path d="M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" />',
427
+ "pointer": '<path d="M22 14a8 8 0 0 1-8 8" /> <path d="M18 11v-1a2 2 0 0 0-2-2a2 2 0 0 0-2 2" /> <path d="M14 10V9a2 2 0 0 0-2-2a2 2 0 0 0-2 2v1" /> <path d="M10 9.5V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v10" /> <path d="M18 11a2 2 0 1 1 4 0v3a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15" />'
428
+ };
429
+
430
+ // src/react/illustrations.ts
431
+ var ILLUSTRATION_SVG = {
432
+ "invoice": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M11 5 L30 5 L37 12 L37 42 L11 42 Z" fill="#FFFFFF"/> <path d="M30 5 L30 12 L37 12" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <path d="M16 18 L32 18 M16 24 L32 24 M16 30 L26 30" stroke="#264653" stroke-width="2.5" fill="none"/> <circle cx="31" cy="36" r="4" fill="#E76F51"/> </svg>',
433
+ "receipt": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 6 L36 6 L36 38 L32 41 L28 38 L24 41 L20 38 L16 41 L12 38 Z" fill="#FAEDCD"/> <path d="M17 14 L31 14 M17 20 L31 20 M17 26 L26 26" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M18 32 L30 32" stroke="#E76F51" stroke-width="3" fill="none"/> </svg>',
434
+ "banknote": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="13" width="36" height="22" rx="3" fill="#588157"/> <circle cx="24" cy="24" r="6" fill="#E9C46A" stroke="none"/> <path d="M24 19 L24 24 L28 28" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M11 19 L11 29 M37 19 L37 29" stroke="#FAEDCD" stroke-width="2.5" fill="none"/> </svg>',
435
+ "coin": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="16" fill="#E9C46A"/> <circle cx="24" cy="24" r="9.5" fill="#FAEDCD" stroke="none"/> <path d="M19 17 L24 23 L29 17 M24 23 L24 31 M19 27 L29 27" stroke="#8B5E3C" stroke-width="2.5" fill="none"/> </svg>',
436
+ "wallet": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="12" y="8" width="20" height="12" rx="3" fill="#FAEDCD"/> <rect x="6" y="16" width="36" height="22" rx="4" fill="#8B5E3C"/> <rect x="29" y="23" width="13" height="8" rx="3" fill="#E9C46A"/> </svg>',
437
+ "credit-card": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="5" y="12" width="38" height="26" rx="4" fill="#2A9D8F"/> <rect x="5" y="18" width="38" height="6" fill="#264653"/> <rect x="11" y="28" width="9" height="6" rx="1.5" fill="#E9C46A"/> <path d="M24 32.5 L 33 32.5" stroke="#FFFFFF" stroke-width="2.5"/> </svg>',
438
+ "bank": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M8 18 L24 8 L40 18 Z" fill="#E9C46A"/> <path d="M10 20 L38 20 L38 38 L10 38 Z" fill="#FAEDCD"/> <path d="M15 24 L15 34 M21 24 L21 34 M27 24 L27 34 M33 24 L33 34" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M7 40 L41 40" stroke="#2A2A2A" stroke-width="4" fill="none"/> </svg>',
439
+ "piggy-bank": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <ellipse cx="23" cy="27" rx="14" ry="10" fill="#F4A6A4"/> <path d="M14 18 L13 10 L21 15 Z" fill="#F4A6A4"/> <ellipse cx="35" cy="27" rx="4" ry="3" fill="#F4A6A4"/> <circle cx="34" cy="26" r="1" fill="#264653" stroke="none"/> <circle cx="36.5" cy="26" r="1" fill="#264653" stroke="none"/> <path d="M20 18 L28 18" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M13 36 L13 41 M21 37 L21 41 M28 37 L28 41" stroke="#F4A6A4" stroke-width="3.5" fill="none"/> <path d="M9 23 C5 22 5 18 8 17" stroke="#F4A6A4" stroke-width="2.5" fill="none"/> <circle cx="30" cy="23" r="1.6" fill="#2A2A2A" stroke="none"/> </svg>',
440
+ "safe": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="7" width="34" height="34" rx="4" fill="#264653"/> <rect x="12" y="12" width="24" height="24" rx="3" fill="#FAEDCD" stroke="none"/> <circle cx="23" cy="24" r="6" fill="#E76F51"/> <path d="M23 18 L23 24 L27 28" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <path d="M33 20 L38 20 M33 28 L38 28" stroke="#E9C46A" stroke-width="2.5" fill="none"/> </svg>',
441
+ "cash-register": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="12" y="8" width="20" height="10" rx="2" fill="#E9C46A"/> <path d="M9 18 H35 L37 32 H7 Z" fill="#264653"/> <path d="M13 24 H31" stroke="#FAEDCD" stroke-width="2"/> <path d="M14 29 H30" stroke="#FAEDCD" stroke-width="2"/> <rect x="7" y="34" width="32" height="7" rx="2" fill="#E76F51"/> </svg>',
442
+ "calculator": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="13" y="6" width="22" height="36" rx="4" fill="#E76F51"/> <rect x="17" y="10" width="14" height="8" rx="2" fill="#FAEDCD"/> <circle cx="20" cy="25" r="1.6" fill="#2A2A2A" stroke="none"/> <circle cx="28" cy="25" r="1.6" fill="#2A2A2A" stroke="none"/> <circle cx="20" cy="31" r="1.6" fill="#2A2A2A" stroke="none"/> <circle cx="28" cy="31" r="1.6" fill="#2A2A2A" stroke="none"/> <circle cx="20" cy="37" r="1.6" fill="#2A2A2A" stroke="none"/> <circle cx="28" cy="37" r="1.6" fill="#2A2A2A" stroke="none"/> </svg>',
443
+ "ledger": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="6" width="34" height="36" rx="3" fill="#264653"/> <path d="M16 6 L16 42" stroke="#FAEDCD" stroke-width="3" fill="none"/> <path d="M21 14 L35 14 M21 21 L35 21 M21 28 L32 28 M21 35 L28 35" stroke="#FAEDCD" stroke-width="2.5" fill="none"/> <path d="M10 12 L13 12 M10 20 L13 20 M10 28 L13 28 M10 36 L13 36" stroke="#E9C46A" stroke-width="2.5" fill="none"/> </svg>',
444
+ "budget": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="9" width="34" height="30" rx="3" fill="#FAEDCD"/> <path d="M7 17 L41 17" stroke="#264653" stroke-width="2.5" fill="none"/> <ellipse cx="24" cy="26" rx="9" ry="3" fill="#E9C46A" stroke="none"/> <ellipse cx="24" cy="31" rx="9" ry="3" fill="#E9C46A" stroke="none"/> <ellipse cx="24" cy="36" rx="9" ry="3" fill="#E9C46A" stroke="none"/> </svg>',
445
+ "tax": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="9" y="5" width="30" height="38" rx="3" fill="#FFFFFF"/> <path d="M15 14 L33 14 M15 20 L33 20 M15 26 L28 26" stroke="#264653" stroke-width="2.5" fill="none"/> <circle cx="20" cy="32" r="3" fill="#E76F51" stroke="none"/> <circle cx="30" cy="38" r="3" fill="#E76F51" stroke="none"/> <path d="M32 31 L18 40" stroke="#E76F51" stroke-width="3" fill="none"/> </svg>',
446
+ "refund": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="8" fill="#E9C46A" stroke="none"/> <path d="M36 24 A12 12 0 1 0 22 35.5" stroke="#2A9D8F" stroke-width="3.5" fill="none"/> <path d="M16 31 L22 37 L28 33" stroke="#2A9D8F" stroke-width="3" fill="none"/> </svg>',
447
+ "loan": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="18" r="10" fill="#E9C46A"/> <path d="M24 13 L24 23 M21 17 L27 17" stroke="#8B5E3C" stroke-width="2.5" fill="none"/> <path d="M24 31 L24 41 M18 35 L24 41 L30 35" stroke="#E76F51" stroke-width="3.5" fill="none"/> </svg>',
448
+ "audit": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="5" width="24" height="30" rx="3" fill="#FFFFFF"/> <path d="M13 13 L27 13 M13 20 L27 20 M13 27 L22 27" stroke="#264653" stroke-width="2.5" fill="none"/> <circle cx="30" cy="30" r="7" fill="#E9C46A"/> <path d="M35 35 L41 41" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> </svg>',
449
+ "currency-dollar": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="16" fill="#E9C46A"/> <path d="M30 16 C28 13 20 13 19 18 C18 24 30 24 29 30 C28 35 20 35 18 32" stroke="#264653" stroke-width="3" fill="none"/> <path d="M24 11 L24 37" stroke="#264653" stroke-width="2.5" fill="none"/> </svg>',
450
+ "file-text": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 6 L12 42 L36 42 L36 18 L24 6 Z" fill="#FAEDCD"/> <path d="M24 6 L24 18 L36 18" fill="#F4A6A4"/> <path d="M17 25 L31 25" stroke="#2A2A2A" stroke-width="2" fill="none"/> <path d="M17 31 L31 31" stroke="#2A2A2A" stroke-width="2" fill="none"/> <path d="M17 37 L26 37" stroke="#2A2A2A" stroke-width="2" fill="none"/> </svg>',
451
+ "file-check": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 6 L12 42 L36 42 L36 18 L24 6 Z" fill="#FAEDCD"/> <path d="M24 6 L24 18 L36 18" fill="#F4A6A4"/> <path d="M17 29 L22 34 L31 24" stroke="#588157" stroke-width="4" fill="none"/> </svg>',
452
+ "file-spreadsheet": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 7 L28 7 L38 17 L38 41 L12 41 Z" fill="#FAEDCD"/> <path d="M28 7 L28 17 L38 17" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <rect x="16" y="22" width="16" height="12" rx="1" fill="#588157" stroke="none"/> <path d="M16 28 L32 28 M21 22 L21 34 M27 22 L27 34" stroke="#FAEDCD" stroke-width="1.8" fill="none"/> </svg>',
453
+ "clipboard-check": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="10" y="10" width="28" height="32" rx="4" fill="#FAEDCD"/> <rect x="18" y="6" width="12" height="8" rx="3" fill="#E9C46A"/> <path d="M17 27 L22 32 L31 21" stroke="#588157" stroke-width="4" fill="none"/> </svg>',
454
+ "rubber-stamp": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="9" y="26" width="30" height="10" rx="2" fill="#E76F51"/> <path d="M16 26 L18 18 L30 18 L32 26 Z" fill="#264653"/> <path d="M20 18 C20 12 28 12 28 18" fill="#264653"/> <path d="M15 33 L33 33" stroke="#FAEDCD" stroke-width="2.5" fill="none"/> </svg>',
455
+ "signature": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M7 34 C11 27 14 30 13 34 C12 38 16 38 18 34 C21 28 24 22 28 25 C31 27 29 33 27 34 C31 34 34 30 37 30" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M10 41 C18 40 30 41 38 40" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <path d="M36 30 C37 27 40 24 41 23 C43 25 42 28 40 31 C39 32 37 31 36 30 Z" fill="#264653" stroke="none"/> <path d="M39 29 L41 25" stroke="#FAEDCD" stroke-width="1.5" fill="none"/> </svg>',
456
+ "trending-up": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M8 34 L17 24 L24 29 L32 19" stroke="#2A9D8F" stroke-width="4.5" fill="none"/> <path d="M 36.88 14.12 L 33.30 22.90 L 28.10 17.70 Z" fill="#E76F51"/> </svg>',
457
+ "bar-chart": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="26" width="8" height="14" rx="2" fill="#2A9D8F"/> <rect x="19" y="16" width="8" height="24" rx="2" fill="#E9C46A"/> <rect x="31" y="8" width="8" height="32" rx="2" fill="#E76F51"/> </svg>',
458
+ "line-chart": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M7 40 L41 40 M7 9 L7 40" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M11 32 L20 22 L28 27 L38 13" stroke="#E76F51" stroke-width="3.5" fill="none"/> <circle cx="20" cy="22" r="2.5" fill="#E9C46A" stroke="none"/> <circle cx="28" cy="27" r="2.5" fill="#E9C46A" stroke="none"/> <circle cx="38" cy="13" r="2.5" fill="#E9C46A" stroke="none"/> </svg>',
459
+ "pie-chart": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="16" fill="#2A9D8F"/> <path d="M24 24 L24 8 A 16 16 0 0 1 39.31 16 Z" fill="#E76F51"/> </svg>',
460
+ "darts": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="16" fill="#264653"/> <circle cx="24" cy="24" r="10" fill="#FAEDCD" stroke="none"/> <circle cx="24" cy="24" r="4" fill="#E76F51" stroke="none"/> <path d="M24 24 L40 8" stroke-width="3"/> <path d="M40 8 L34 9 M40 8 L39 14" stroke-width="2" fill="none"/> </svg>',
461
+ "trophy": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M14 12 C 6 12 6 22 14 22" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M34 12 C 42 12 42 22 34 22" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M14 7 L 34 7 L 34 17 C 34 25 29 29 24 29 C 19 29 14 25 14 17 Z" fill="#E9C46A"/> <path d="M24 29 L 24 37" stroke="#2A2A2A" stroke-width="3"/> <rect x="15" y="37" width="18" height="4.5" rx="2" fill="#8B5E3C"/> <path d="M24 8.1 L 26.16 13.08 L 31.47 13.41 L 27.32 17.23 L 28.98 22.7 L 24 19.72 L 19.02 22.7 L 20.68 17.23 L 16.53 13.41 L 21.84 13.08 Z" fill="#2A2A2A" stroke="none"/> <path d="M24 11.09 L 25.27 14.03 L 28.41 14.22 L 25.96 16.48 L 26.94 19.71 L 24 17.95 L 21.06 19.71 L 22.04 16.48 L 19.59 14.22 L 22.73 14.03 Z" fill="#E76F51" stroke="none"/> </svg>',
462
+ "medal": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M15 5 L22 17 L12 17 Z" fill="#E76F51"/> <path d="M33 5 L26 17 L36 17 Z" fill="#E76F51"/> <circle cx="24" cy="30" r="10" fill="#E9C46A"/> <path d="M24 24 L26.4 29 L32 29.6 L27.8 33.4 L29 39 L24 36 L19 39 L20.2 33.4 L16 29.6 L21.6 29 Z" fill="#E76F51" stroke="none"/> </svg>',
463
+ "rocket": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M18 32 L24 42.5 L30 32 Z" fill="#E76F51"/> <path d="M24 6 C 16 6 14 16 14 25 L 14 34 L 34 34 L 34 25 C 34 16 32 6 24 6 Z" fill="#FAEDCD"/> <path d="M14 28 L8 34 L8 40 L14 36 Z" fill="#E76F51"/> <path d="M34 28 L40 34 L40 40 L34 36 Z" fill="#E76F51"/> <circle cx="24" cy="20" r="5" fill="#2A9D8F"/> </svg>',
464
+ "bulb": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M24 6 C 14 6 10 16 14 24 L14 30 L34 30 L34 24 C 38 16 34 6 24 6 Z" fill="#E9C46A"/> <rect x="16" y="30" width="16" height="6" fill="#264653"/> <rect x="18" y="36" width="12" height="4" fill="#264653"/> <circle cx="20" cy="18" r="1.5" fill="#2A2A2A"/> <circle cx="28" cy="18" r="1.5" fill="#2A2A2A"/> </svg>',
465
+ "milestone": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M24 6 L24 42" stroke="#264653" stroke-width="3" fill="none"/> <path d="M9 12 L33 12 L39 18 L33 24 L9 24 Z" fill="#E76F51"/> <path d="M14 18 L28 18" stroke="#FAEDCD" stroke-width="2.5" fill="none"/> </svg>',
466
+ "kanban": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="8" width="10" height="32" rx="2" fill="#FAEDCD"/> <rect x="19" y="8" width="10" height="22" rx="2" fill="#E9C46A"/> <rect x="31" y="8" width="10" height="27" rx="2" fill="#2A9D8F"/> </svg>',
467
+ "layout-dashboard": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="7" width="15" height="15" rx="3" fill="#E76F51"/> <rect x="26" y="7" width="15" height="10" rx="3" fill="#E9C46A"/> <rect x="7" y="26" width="15" height="15" rx="3" fill="#2A9D8F"/> <rect x="26" y="21" width="15" height="20" rx="3" fill="#264653"/> </svg>',
468
+ "presentation": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="8" width="36" height="24" rx="3" fill="#264653"/> <rect x="9.5" y="11.5" width="29" height="17" rx="1.5" fill="#FAEDCD" stroke="none"/> <path d="M14 24 L20 17 L25 22 L32 15" stroke="#E76F51" stroke-width="2.5" fill="none"/> <path d="M24 32 L24 40" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> <path d="M17 40 L31 40" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> </svg>',
469
+ "calendar": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="12" width="32" height="28" rx="4" fill="#FAEDCD"/> <path d="M8 20 L40 20" stroke="#2A2A2A" stroke-width="3"/> <rect x="8" y="12" width="32" height="8" fill="#E76F51"/> <path d="M16 8 L16 16" stroke="#2A2A2A" stroke-width="3"/> <path d="M32 8 L32 16" stroke="#2A2A2A" stroke-width="3"/> <circle cx="18" cy="28" r="1.5" fill="#2A2A2A"/> <circle cx="24" cy="28" r="1.5" fill="#2A2A2A"/> <circle cx="30" cy="28" r="1.5" fill="#2A2A2A"/> </svg>',
470
+ "calendar-check": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="10" width="32" height="30" rx="4" fill="#FAEDCD"/> <path d="M8 17 L40 17" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M15 7 L15 12 M33 7 L33 12" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M15 26 L20 31 L31 22" stroke="#2A9D8F" stroke-width="2.5" fill="none"/> </svg>',
471
+ "clock": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="18" fill="#2A9D8F"/> <path d="M24 24 L24 13" stroke="#FFFFFF" stroke-width="3"/> <path d="M24 24 L33 28" stroke="#FFFFFF" stroke-width="3"/> <circle cx="24" cy="24" r="2" fill="#2A2A2A"/> </svg>',
472
+ "hourglass": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 8 L36 8 L25 24 L36 40 L12 40 L23 24 Z" fill="#FAEDCD"/> <path d="M16.5 12 L31.5 12 L25 22 Z" fill="#E9C46A" stroke="none"/> <path d="M17 36 L31 36 L25 28 Z" fill="#E9C46A" stroke="none"/> <path d="M11 8 L37 8" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> <path d="M11 40 L37 40" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> </svg>',
473
+ "timer": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="26" r="14" fill="#E9C46A"/> <rect x="19" y="6" width="10" height="6" rx="2" fill="#E76F51"/> <path d="M24 26 L24 18" stroke="#FFFFFF" stroke-width="3" fill="none"/> <path d="M24 26 L30 30" stroke="#FFFFFF" stroke-width="3" fill="none"/> <path d="M17 26 L19 26 M29 26 L31 26" stroke="#8B5E3C" stroke-width="2" fill="none"/> </svg>',
474
+ "phone": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M10 8 L18 8 L22 18 L16 22 C 18 28 20 30 26 32 L30 26 L40 30 L40 38 C 40 40 38 42 36 42 C 22 42 6 26 6 12 C 6 10 8 8 10 8 Z" fill="#588157"/> </svg>',
475
+ "mail": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="12" width="36" height="24" rx="3" fill="#F4A6A4"/> <path d="M6 14 L24 28 L42 14" stroke="#2A2A2A"/> <circle cx="20" cy="22" r="1.5" fill="#2A2A2A"/> <circle cx="28" cy="22" r="1.5" fill="#2A2A2A"/> </svg>',
476
+ "chat": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M8 10 L40 10 L40 32 L26 32 L20 40 L20 32 L8 32 Z" fill="#E9C46A"/> <circle cx="16" cy="21" r="1.8" fill="#2A2A2A"/> <circle cx="24" cy="21" r="1.8" fill="#2A2A2A"/> <circle cx="32" cy="21" r="1.8" fill="#2A2A2A"/> </svg>',
477
+ "messages": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 14 L30 14 L30 30 L20 30 L16 36 L16 30 L6 30 Z" fill="#E76F51"/> <path d="M18 8 L42 8 L42 26 L34 26 L30 32 L30 26 L18 26 Z" fill="#FAEDCD"/> <circle cx="25" cy="17" r="1.8" fill="#2A2A2A" stroke="none"/> <circle cx="32" cy="17" r="1.8" fill="#2A2A2A" stroke="none"/> <circle cx="39" cy="17" r="1.8" fill="#2A2A2A" stroke="none"/> </svg>',
478
+ "megaphone": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M7 20 L24 11 L24 37 L7 28 Z" fill="#E76F51"/> <rect x="24" y="9" width="8" height="30" rx="3" fill="#F4A6A4"/> <path d="M12 29 L15 41 L21 41 L18 31 Z" fill="#E9C46A"/> <path d="M36 16 L40 20" stroke="#2A9D8F" stroke-width="3.5" fill="none"/> <path d="M36 28 L40 24" stroke="#2A9D8F" stroke-width="3.5" fill="none"/> </svg>',
479
+ "bell-ring": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M12 33 C 12 14 36 14 36 33 Z" fill="#E9C46A"/> <path d="M10 33 L38 33" stroke="#2A2A2A" stroke-width="3"/> <path d="M20 37 C 20 41 28 41 28 37" fill="#E76F51"/> <path d="M6 15 L10 19" stroke="#E76F51" stroke-width="3.5" fill="none"/> <path d="M42 15 L38 19" stroke="#E76F51" stroke-width="3.5" fill="none"/> </svg>',
480
+ "user": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="16" r="8.5" fill="#E76F51"/> <path d="M7 43 C 7 33 14 29 24 29 C 34 29 41 33 41 43" fill="#2A9D8F"/> </svg>',
481
+ "users": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="15" cy="14" r="6" fill="#264653"/> <path d="M5 34 C 5 26 9 23 15 23 C 19 23 22 24 24 26 L 24 40 L 8 40 Z" fill="#264653"/> <circle cx="29" cy="18" r="7.5" fill="#E76F51"/> <path d="M14 42 C 14 33 21 30 29 30 C 37 30 43 33 43 42 Z" fill="#2A9D8F"/> </svg>',
482
+ "briefcase": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="16" width="36" height="24" rx="4" fill="#264653"/> <path d="M18 16 L18 12 A 3 3 0 0 1 21 9 L27 9 A 3 3 0 0 1 30 12 L30 16" fill="none" stroke="#2A2A2A" stroke-width="3.5"/> <rect x="19" y="24" width="10" height="7" rx="2" fill="#E9C46A" stroke="none"/> </svg>',
483
+ "id-card": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="11" width="32" height="26" rx="4" fill="#FAEDCD"/> <circle cx="17" cy="20" r="4" fill="#264653"/> <path d="M11 29 C13 26 16 25 17 25 C19 25 22 26 23 29" fill="#264653" stroke="#264653" stroke-width="1"/> <path d="M28 18 L36 18 M28 23 L36 23 M28 28 L33 28" stroke="#2A2A2A" stroke-width="2" fill="none"/> <path d="M8 37 L40 37" stroke="#2A9D8F" stroke-width="3" fill="none"/> </svg>',
484
+ "office-chair": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="13" y="7" width="22" height="17" rx="4" fill="#264653"/> <rect x="9" y="24" width="30" height="6" rx="3" fill="#E76F51"/> <path d="M24 30 L24 37 M15 37 L33 37" stroke="#2A2A2A" stroke-width="3" fill="none"/> <circle cx="12" cy="39" r="2.5" fill="#2A2A2A"/> <circle cx="36" cy="39" r="2.5" fill="#2A2A2A"/> </svg>',
485
+ "truck": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 13 L28 13 L28 32 L6 32 Z" fill="#E76F51"/><path d="M28 19 L35 19 L41 27 L41 32 L28 32 Z" fill="#FAEDCD"/><circle cx="14" cy="36" r="4.5" fill="#2A2A2A"/><circle cx="34" cy="36" r="4.5" fill="#2A2A2A"/><circle cx="14" cy="36" r="1.5" fill="#FAEDCD" stroke="none"/><circle cx="34" cy="36" r="1.5" fill="#FAEDCD" stroke="none"/> </svg>',
486
+ "van": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 18 L24 18 L34 26 L41 26 L41 34 L6 34 Z" fill="#FAEDCD"/> <path d="M24 18 L24 26 L34 26" stroke="#264653" stroke-width="2" fill="none"/> <circle cx="14" cy="36" r="4" fill="#264653"/> <circle cx="34" cy="36" r="4" fill="#264653"/> </svg>',
487
+ "forklift": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="10" y="22" width="14" height="12" rx="2" fill="#E9C46A"/> <circle cx="14" cy="35" r="4" fill="#264653"/> <circle cx="24" cy="35" r="4" fill="#264653"/> <path d="M32 10 L32 36 M32 30 L40 30 M32 36 L40 36" stroke="#2A2A2A" stroke-width="3.5" fill="none"/> <path d="M24 24 L32 24" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> </svg>',
488
+ "warehouse": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 20 L24 8 L42 20" fill="#E76F51"/> <rect x="6" y="20" width="36" height="22" fill="#E9C46A"/> <rect x="18" y="30" width="12" height="12" fill="#264653" stroke="none"/> <rect x="10" y="24" width="5" height="5" fill="#FAEDCD" stroke="none"/> <rect x="33" y="24" width="5" height="5" fill="#FAEDCD" stroke="none"/> </svg>',
489
+ "factory": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 40 L6 24 L16 18 L16 24 L26 18 L26 24 L36 18 L36 40 Z" fill="#264653"/> <rect x="32" y="8" width="8" height="12" fill="#E76F51"/> <rect x="10" y="28" width="6" height="5" fill="#FAEDCD" stroke="none"/> <rect x="19" y="28" width="6" height="5" fill="#FAEDCD" stroke="none"/> <rect x="28" y="28" width="6" height="5" fill="#FAEDCD" stroke="none"/> <rect x="10" y="35" width="6" height="5" fill="#FAEDCD" stroke="none"/> <rect x="28" y="35" width="6" height="5" fill="#FAEDCD" stroke="none"/> </svg>',
490
+ "store": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 12 L42 12 L38 20 L10 20 Z" fill="#E76F51"/> <rect x="8" y="20" width="32" height="22" rx="2" fill="#FAEDCD"/> <path d="M6 12 Q 9 17 12 12 Q 15 17 18 12 Q 21 17 24 12 Q 27 17 30 12 Q 33 17 36 12 Q 39 17 42 12" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <rect x="20" y="28" width="9" height="14" fill="#2A9D8F" stroke="none"/> <rect x="12" y="25" width="5" height="6" fill="#E9C46A" stroke="none"/> </svg>',
491
+ "shopping-cart": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="20" y="10" width="7" height="10" rx="1.5" fill="#E9C46A"/> <rect x="29" y="12" width="7" height="8" rx="1.5" fill="#FAEDCD"/> <path d="M15 19 L41 19 L37 32 L16 32 Z" fill="#E76F51"/> <path d="M7 11 L12 11 L16 32" stroke="#2A2A2A" stroke-width="3" fill="none"/> <path d="M12 11 L15 11" stroke="#2A2A2A" stroke-width="3" fill="none"/> <circle cx="19" cy="38" r="3.5" fill="#2A2A2A" stroke="none"/> <circle cx="34" cy="38" r="3.5" fill="#2A2A2A" stroke="none"/> </svg>',
492
+ "cargo-ship": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M6 30 L42 30 L37 40 L11 40 Z" fill="#264653"/> <rect x="11" y="20" width="8" height="8" fill="#E76F51"/> <rect x="21" y="20" width="8" height="8" fill="#2A9D8F"/> <rect x="31" y="22" width="7" height="6" fill="#E9C46A"/> <path d="M9 30 L39 30" stroke="#FAEDCD" stroke-width="2.5" fill="none"/> </svg>',
493
+ "route": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M10 36 C 10 24 24 28 24 22 C 24 16 38 20 38 12" stroke="#2A9D8F" stroke-width="4" fill="none"/> <circle cx="10" cy="36" r="3.5" fill="#E76F51"/> <circle cx="38" cy="12" r="3.5" fill="#E9C46A"/> </svg>',
494
+ "map-pin": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M8 12 L 18 8 L 30 12 L 40 8 L 40 34 L 30 38 L 18 34 L 8 38 Z" fill="#FAEDCD"/> <path d="M18 8 L 18 34" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <path d="M30 12 L 30 38" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> <path d="M12 30 C 15 23 21 28 24 21 C 26 17 29 18 31 16" stroke="#E76F51" stroke-width="2.5" fill="none"/> <g transform="translate(11 2) scale(0.7)"><path d="M30 5 C 25.8 5 22.8 8 22.8 12 C 22.8 16.4 30 23 30 23 C 30 23 37.2 16.4 37.2 12 C 37.2 8 34.2 5 30 5 Z" fill="#E76F51"/><circle cx="30" cy="11.6" r="2.3" fill="#FFFFFF" stroke="none"/></g> </svg>',
495
+ "globe": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="21" r="14" fill="#2A9D8F"/> <ellipse cx="24" cy="21" rx="6" ry="14" stroke="#2A2A2A" stroke-width="2" fill="none"/> <path d="M10 21 L 38 21" stroke="#2A2A2A" stroke-width="2"/> <path d="M17 13 C 19 10 24 10 25 13 C 23 15 19 16 17 13 Z" fill="#588157" stroke="none"/> <path d="M26 27 C 28 25 32 26 31 29 C 29 31 25 30 26 27 Z" fill="#588157" stroke="none"/> <path d="M24 35 L 24 39" stroke="#2A2A2A" stroke-width="3"/> <path d="M15 42 L 33 42" stroke="#2A2A2A" stroke-width="3.5"/> </svg>',
496
+ "barcode": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="12" width="3" height="24" fill="#264653" stroke="none"/> <rect x="11" y="12" width="2" height="24" fill="#264653" stroke="none"/> <rect x="15" y="12" width="4" height="24" fill="#264653" stroke="none"/> <rect x="21" y="12" width="2" height="24" fill="#264653" stroke="none"/> <rect x="25" y="12" width="3" height="24" fill="#264653" stroke="none"/> <rect x="30" y="12" width="2" height="24" fill="#264653" stroke="none"/> <rect x="34" y="12" width="4" height="24" fill="#264653" stroke="none"/> <rect x="40" y="12" width="2" height="24" fill="#264653" stroke="none"/> </svg>',
497
+ "archive": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="7" y="12" width="34" height="10" rx="3" fill="#E9C46A"/> <path d="M9 22 L9 40 L39 40 L39 22" fill="#2A9D8F"/> <rect x="19" y="28" width="10" height="6" rx="2" fill="#FAEDCD" stroke="none"/> </svg>',
498
+ "toolbox": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="20" width="36" height="20" rx="3" fill="#E76F51"/> <rect x="6" y="16" width="36" height="6" rx="2" fill="#264653"/> <path d="M17 16 C 17 10 31 10 31 16" stroke="#2A2A2A" stroke-width="3" fill="none"/> <rect x="21" y="22" width="6" height="5" rx="1" fill="#E9C46A" stroke="none"/> </svg>',
499
+ "alert-triangle": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M24 7 L43 40 L5 40 Z" fill="#E9C46A" stroke="#2A2A2A" stroke-width="3.5"/> <path d="M24 18 L24 30" fill="none" stroke="#2A2A2A" stroke-width="4"/> <circle cx="24" cy="35" r="2.2" fill="#2A2A2A"/> </svg>',
500
+ "check-circle": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <circle cx="24" cy="24" r="17" fill="none" stroke="#2A2A2A" stroke-width="3.5"/> <path d="M15 24.5 L21 30.5 L32 18.5" fill="none" stroke="#588157" stroke-width="4"/> </svg>',
501
+ "shield-check": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M24 6 L38 12 V24 C38 34 32 39 24 42 C16 39 10 34 10 24 V12 Z" fill="#2A9D8F"/> <path d="M18 24 L23 29 L31 20" stroke="#FFFFFF" stroke-width="3" fill="none"/> </svg>',
502
+ "lock": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M16 21 L 16 15 C 16 7 32 7 32 15 L 32 21" stroke="#2A2A2A" stroke-width="4" fill="none"/> <rect x="10" y="21" width="28" height="19" rx="3" fill="#E9C46A"/> <circle cx="24" cy="29" r="3" fill="#2A2A2A"/> <path d="M24 29 L 21.5 35 L 26.5 35 Z" fill="#2A2A2A"/> </svg>',
503
+ "courthouse": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M5 19 L24 8 L43 19 Z" fill="#E76F51"/> <rect x="7" y="19" width="34" height="19" fill="#FFFFFF"/> <path d="M12 24 L12 36 M36 24 L36 36" stroke="#264653" stroke-width="3" fill="none"/> <path d="M19 38 L19 30 C19 26 29 26 29 30 L29 38" fill="#264653" stroke="none"/> <path d="M7 38 L41 38" stroke="#264653" stroke-width="3" fill="none"/> <path d="M11 41 L37 41" stroke="#264653" stroke-width="2.5" fill="none"/> </svg>',
504
+ "hammer": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="8" width="18" height="10" rx="2" fill="#264653"/> <path d="M22 18 L38 36 L34 40 L18 22 Z" fill="#8B5E3C"/> <path d="M10 12 L24 12" stroke="#E9C46A" stroke-width="2.5" fill="none"/> </svg>',
505
+ "scale": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="9" width="32" height="32" rx="7" fill="#FAEDCD"/> <circle cx="24" cy="21" r="7" fill="#2A9D8F"/> <path d="M24 21 L28 17" stroke="#FAEDCD" stroke-width="2" fill="none"/> <path d="M14 33 H34" stroke-width="2.5" fill="none"/> </svg>',
506
+ "search": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M29 29 L39.5 39.5" stroke="#264653" stroke-width="5.5"/> <circle cx="19" cy="19" r="13.5" fill="#2A9D8F"/> <circle cx="19" cy="19" r="8.5" fill="#FAEDCD" stroke="none"/> <circle cx="19" cy="19" r="4.5" fill="#2A9D8F" stroke="none"/> <circle cx="15.5" cy="15.5" r="2.3" fill="#FFFFFF" stroke="none"/> </svg>',
507
+ "flag": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M13.28 7.03 L 13.28 40.97" stroke="#2A2A2A" stroke-width="3.5"/> <path d="M13.28 9.71 C 19.53 6.14 25.79 13.28 32.04 9.71 L 32.04 22.21 C 25.79 25.79 19.53 18.64 13.28 22.21 Z" fill="#E76F51"/> <circle cx="13.28" cy="7.03" r="2.23" fill="#E9C46A" stroke="none"/> </svg>',
508
+ "stop-sign": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M18 6 L30 6 L42 18 L42 30 L30 42 L18 42 L6 30 L6 18 Z" fill="#E76F51"/> <path d="M14 24 L34 24" stroke="#FFFFFF" stroke-width="3" fill="none"/> </svg>',
509
+ "signpost": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="22" y="14" width="4" height="28" fill="#8B5E3C"/> <path d="M10 14 L32 14 L36 18 L32 22 L10 22 Z" fill="#E9C46A"/> <path d="M38 26 L16 26 L12 30 L16 34 L38 34 Z" fill="#2A9D8F"/> </svg>',
510
+ "database": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M11 13 L11 34 C 11 38 17 41 24 41 C 31 41 37 38 37 34 L37 13 Z" fill="#2A9D8F"/> <ellipse cx="24" cy="13" rx="13" ry="5.5" fill="#264653"/> <path d="M11 24 C 11 28 17 31 24 31 C 31 31 37 28 37 24" stroke="#2A2A2A" stroke-width="2.5" fill="none"/> </svg>',
511
+ "server": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="9" width="32" height="12" rx="3" fill="#264653"/> <rect x="8" y="24" width="32" height="12" rx="3" fill="#2A9D8F"/> <circle cx="14" cy="15" r="1.8" fill="#E9C46A" stroke="none"/> <circle cx="14" cy="30" r="1.8" fill="#E9C46A" stroke="none"/> <path d="M21 15 L36 15" stroke="#FFFFFF" stroke-width="2" fill="none"/> <path d="M21 30 L30 30" stroke="#FFFFFF" stroke-width="2" fill="none"/> </svg>',
512
+ "cloud": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M14 30 C 8 30 6 22 12 20 C 12 14 20 12 24 16 C 28 10 38 14 36 22 C 42 22 42 30 36 30 Z" fill="#FAEDCD"/> <circle cx="20" cy="24" r="1.5" fill="#2A2A2A"/> <circle cx="28" cy="24" r="1.5" fill="#2A2A2A"/> </svg>',
513
+ "settings": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M24 6 L27 11 L33 10 L34 16 L40 18 L37 23 L40 28 L34 30 L33 36 L27 35 L24 40 L21 35 L15 36 L14 30 L8 28 L11 23 L8 18 L14 16 L15 10 L21 11 Z" fill="#264653"/> <circle cx="24" cy="23" r="6" fill="#E9C46A"/> </svg>',
514
+ "refresh": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <path d="M11 16.5 A 15 15 0 0 1 37 16.5" fill="none" stroke="#2A9D8F" stroke-width="4.5"/> <path d="M40.7 23 L33 18.8 L41 14.2 Z" fill="#E76F51" stroke-width="3"/> <path d="M37 31.5 A 15 15 0 0 1 11 31.5" fill="none" stroke="#2A9D8F" stroke-width="4.5"/> <path d="M7.3 25 L15 29.2 L7 33.8 Z" fill="#E76F51" stroke-width="3"/> </svg>',
515
+ "laptop": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="8" y="10" width="32" height="22" rx="4" fill="#264653"/> <rect x="11" y="13" width="26" height="16" rx="2" fill="#FAEDCD" stroke="none"/> <path d="M6 34 L42 34 L39 40 L9 40 Z" fill="#E9C46A"/> </svg>',
516
+ "exchange": '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#2A2A2A" stroke-width="3.5" stroke-linecap="round" stroke-linejoin="round"> <rect x="6" y="8" width="20" height="12" rx="2" fill="#588157"/> <circle cx="16" cy="14" r="3.5" fill="#E9C46A" stroke="none"/> <rect x="22" y="28" width="20" height="12" rx="2" fill="#E76F51"/> <circle cx="32" cy="34" r="3.5" fill="#E9C46A" stroke="none"/> <path d="M19 22 L29 26" stroke="#264653" stroke-width="3" fill="none"/> <path d="M19 22 L23 21 M19 22 L20 26" stroke="#264653" stroke-width="2.5" fill="none"/> <path d="M29 26 L25 27 M29 26 L28 22" stroke="#264653" stroke-width="2.5" fill="none"/> </svg>'
517
+ };
518
+
519
+ // src/react/useBoard.ts
520
+ import { useCallback, useEffect, useRef, useState } from "react";
521
+ var BOARD_SAVED = "wb:board-saved";
522
+ var POLL_MS = BOARD2.pollMs;
523
+ var FAST_MS = BOARD2.fastMs;
524
+ var AGENT_WINDOW_MS = BOARD2.agentWindowMs;
525
+ var message = (e) => e instanceof Error ? e.message : BOARD_COPY.loadFailed;
526
+ function useBoard(transport, boardId, preview) {
527
+ const [board, setBoard] = useState(preview ?? null);
528
+ const [error, setError] = useState(null);
529
+ const [saving, setSaving] = useState(false);
530
+ const [activity, setActivity] = useState(null);
531
+ const [pendingBatch, setPendingBatch] = useState(null);
532
+ const batchRef = useRef(pendingBatch);
533
+ batchRef.current = pendingBatch;
534
+ const boardRef = useRef(board);
535
+ boardRef.current = board;
536
+ const activityRef = useRef(activity);
537
+ activityRef.current = activity;
538
+ const remote = useRef(null);
539
+ const queue = useRef([]);
540
+ const inflight = useRef(false);
541
+ const take = useCallback((d, fromPoll) => {
542
+ const a = d.board?.activity ?? d.activity ?? null;
543
+ if (JSON.stringify(a) !== JSON.stringify(activityRef.current)) setActivity(a);
544
+ if ("pendingBatch" in d) {
545
+ const pb = d.pendingBatch ?? null;
546
+ if (JSON.stringify(pb) !== JSON.stringify(batchRef.current)) setPendingBatch(pb);
547
+ }
548
+ if (d.board && (!fromPoll || !inflight.current && !queue.current.length)) {
549
+ remote.current = d.board;
550
+ setBoard(d.board);
551
+ }
552
+ }, []);
553
+ const load = useCallback(async (since) => {
554
+ try {
555
+ take(await transport.load(since), true);
556
+ setError(null);
557
+ } catch (e) {
558
+ setError(message(e));
559
+ }
560
+ }, [transport, take]);
561
+ const fastUntil = useRef(0);
562
+ const boost = useCallback((ms = BOARD2.boostMs) => {
563
+ fastUntil.current = Math.max(fastUntil.current, Date.now() + ms);
564
+ }, []);
565
+ useEffect(() => {
566
+ if (preview) return;
567
+ load();
568
+ let last = 0;
569
+ const t = setInterval(() => {
570
+ const b = boardRef.current;
571
+ if (document.visibilityState !== "visible" || !b) return;
572
+ const e = b.edits.at(-1);
573
+ const agentBusy = !!e?.agent && Date.now() - Date.parse(e.at) < AGENT_WINDOW_MS;
574
+ const a = activityRef.current;
575
+ const live = !!a && Date.now() - Date.parse(a.at) < BOARD2.activityFreshMs;
576
+ const due = Date.now() - last >= (agentBusy || live || Date.now() < fastUntil.current ? FAST_MS : POLL_MS);
577
+ if (due) {
578
+ last = Date.now();
579
+ load(b.version);
580
+ }
581
+ }, FAST_MS);
582
+ return () => clearInterval(t);
583
+ }, [load, preview]);
584
+ const flush = useCallback(async () => {
585
+ if (inflight.current || !queue.current.length || preview) return;
586
+ inflight.current = true;
587
+ setSaving(true);
588
+ const ops = queue.current.splice(0);
589
+ try {
590
+ const d = await transport.save(ops);
591
+ setBoard(queue.current.length ? applyOps(d.board, queue.current, d.board.updatedBy) : d.board);
592
+ setError(null);
593
+ window.dispatchEvent(new CustomEvent(BOARD_SAVED, { detail: boardId }));
594
+ } catch (e) {
595
+ setError(e instanceof Error ? BOARD_COPY.unsavedWhy(e.message) : BOARD_COPY.unsaved);
596
+ queue.current = [];
597
+ load();
598
+ } finally {
599
+ inflight.current = false;
600
+ setSaving(false);
601
+ if (queue.current.length) flush();
602
+ }
603
+ }, [transport, preview, load, boardId]);
604
+ const apply = useCallback((ops) => {
605
+ if (!ops.length) return;
606
+ setBoard((b) => b ? applyOps(b, ops, BOARD_COPY.you) : b);
607
+ queue.current.push(...ops);
608
+ flush();
609
+ }, [flush]);
610
+ const history = useCallback(async () => {
611
+ if (preview || !transport.history) return null;
612
+ try {
613
+ return await transport.history();
614
+ } catch {
615
+ return null;
616
+ }
617
+ }, [transport, preview]);
618
+ const versions = useRef(/* @__PURE__ */ new Map());
619
+ useEffect(() => {
620
+ versions.current.clear();
621
+ }, [transport]);
622
+ const at = useCallback(async (version) => {
623
+ const kept = versions.current.get(version);
624
+ if (kept) return kept;
625
+ if (preview || !transport.at) return null;
626
+ try {
627
+ const b = await transport.at(version);
628
+ if (b) versions.current.set(version, b);
629
+ return b;
630
+ } catch {
631
+ return null;
632
+ }
633
+ }, [transport, preview]);
634
+ const restore = useCallback(async (version) => {
635
+ if (preview || !transport.restore) return false;
636
+ try {
637
+ const d = await transport.restore(version);
638
+ if (d.board) take(d, false);
639
+ else await load();
640
+ return true;
641
+ } catch (e) {
642
+ setError(message(e));
643
+ return false;
644
+ }
645
+ }, [transport, preview, load, take]);
646
+ const decideBatch = useCallback(async (action) => {
647
+ if (preview || !transport.decide) {
648
+ setPendingBatch(null);
649
+ return null;
650
+ }
651
+ try {
652
+ const d = await transport.decide(action);
653
+ take({ ...d, pendingBatch: d.pendingBatch ?? null }, false);
654
+ return null;
655
+ } catch (e) {
656
+ return message(e);
657
+ }
658
+ }, [transport, preview, take]);
659
+ const keepBatch = useCallback((id) => decideBatch({ keepBatch: id }), [decideBatch]);
660
+ const undoBatch = useCallback((id) => decideBatch({ undoBatch: id }), [decideBatch]);
661
+ return { board, error, saving, apply, reload: () => load(), boost, activity, remote, history, at, restore, pendingBatch, keepBatch, undoBatch };
662
+ }
663
+
664
+ // src/react/Whiteboard.tsx
665
+ import { AnimatePresence as AnimatePresence2, animate, cubicBezier, motion as motion2, useMotionValue, useReducedMotion } from "motion/react";
666
+
667
+ // src/react/diff.ts
668
+ var EMPTY = { notes: [], frames: [], links: [] };
669
+ var SKIP = /* @__PURE__ */ new Set(["x", "y", "by"]);
670
+ function fieldsDiffer(a, b) {
671
+ const keys = /* @__PURE__ */ new Set([...Object.keys(a), ...Object.keys(b)]);
672
+ const out = [];
673
+ for (const k of keys) {
674
+ if (SKIP.has(k)) continue;
675
+ if (JSON.stringify(a[k]) !== JSON.stringify(b[k])) out.push(k);
676
+ }
677
+ return out;
678
+ }
679
+ var textOf = (r) => [r.title, r.text].filter(Boolean).join("\n");
680
+ function diffBoards(prev, next) {
681
+ const a = prev ?? EMPTY;
682
+ const d = { added: { notes: [], frames: [], links: [] }, removed: { notes: [], frames: [], links: [] }, moved: [], changed: [], text: [] };
683
+ const boxes = (before, after, add, rem) => {
684
+ const was = new Map(before.map((r) => [r.id, r]));
685
+ const now = new Set(after.map((r) => r.id));
686
+ for (const r of after) {
687
+ const o = was.get(r.id);
688
+ if (!o) {
689
+ add.push(r);
690
+ continue;
691
+ }
692
+ if (o.x !== r.x || o.y !== r.y) d.moved.push({ id: r.id, from: { x: o.x, y: o.y }, to: { x: r.x, y: r.y } });
693
+ const f = fieldsDiffer(o, r);
694
+ if (f.length) d.changed.push({ id: r.id, fields: f });
695
+ const t0 = textOf(o), t1 = textOf(r);
696
+ if (t0 !== t1) d.text.push({ id: r.id, before: t0, after: t1 });
697
+ }
698
+ for (const r of before) if (!now.has(r.id)) rem.push(r);
699
+ };
700
+ boxes(a.notes, next.notes, d.added.notes, d.removed.notes);
701
+ boxes(a.frames, next.frames, d.added.frames, d.removed.frames);
702
+ const wasL = new Map(a.links.map((l) => [l.id, l]));
703
+ const nowL = new Set(next.links.map((l) => l.id));
704
+ for (const l of next.links) {
705
+ const o = wasL.get(l.id);
706
+ if (!o) d.added.links.push(l);
707
+ else {
708
+ const f = fieldsDiffer(o, l);
709
+ if (f.length) d.changed.push({ id: l.id, fields: f });
710
+ }
711
+ }
712
+ for (const l of a.links) if (!nowL.has(l.id)) d.removed.links.push(l);
713
+ return d;
714
+ }
715
+ var center = (r) => ({ x: r.x + r.w / 2, y: r.y + r.h / 2 });
716
+ function kindOf(n) {
717
+ switch (n.shape) {
718
+ case "track":
719
+ return "track";
720
+ case "pill":
721
+ return "pill";
722
+ case "dot":
723
+ return "dot";
724
+ case "sticker":
725
+ return "sticker";
726
+ case "cell":
727
+ return "cell";
728
+ case "text":
729
+ return "heading";
730
+ default:
731
+ return "card";
732
+ }
733
+ }
734
+ function stepsOf(d, next, told = false) {
735
+ const steps = [];
736
+ if (told) {
737
+ for (const n of d.added.notes) steps.push({ id: n.id, kind: n.shape === "text" ? "heading" : kindOf(n), at: center(n) });
738
+ } else {
739
+ const frames = [...d.added.frames].sort((p, q) => p.y - q.y || p.x - q.x);
740
+ for (const f of frames) steps.push({ id: f.id, kind: "frame", at: { x: f.x + 24, y: f.y + 24 } });
741
+ const notes = d.added.notes;
742
+ const headings = notes.filter((n) => n.shape === "text").sort((p, q) => p.y - q.y || p.x - q.x);
743
+ for (const n of headings) steps.push({ id: n.id, kind: "heading", at: { x: n.x + 12, y: n.y + n.h / 2 } });
744
+ const tracks = notes.filter((n) => n.shape === "track");
745
+ for (const n of tracks) steps.push({ id: n.id, kind: "track", at: center(n) });
746
+ const rest = notes.filter((n) => n.shape !== "text" && n.shape !== "track");
747
+ const cells = rest.filter((n) => n.shape === "cell").sort((p, q) => p.y - q.y || p.x - q.x);
748
+ for (const n of cells) steps.push({ id: n.id, kind: "cell", at: center(n) });
749
+ const items = rest.filter((n) => n.shape !== "cell");
750
+ let ordered;
751
+ if (tracks.length || next.notes.some((n) => n.shape === "track") && items.some((n) => n.shape === "pill")) {
752
+ const rank = (n) => n.shape === "pill" ? 0 : n.shape === "dot" ? 1 : 2;
753
+ ordered = [...items].sort((p, q) => {
754
+ const dx = center(p).x - center(q).x;
755
+ return Math.abs(dx) < Math.min(p.w, q.w) / 2 ? rank(p) - rank(q) || dx : dx;
756
+ });
757
+ } else {
758
+ const band = Math.max(40, median(items.map((n) => n.h)) / 2);
759
+ ordered = [...items].sort((p, q) => {
760
+ const dy = center(p).y - center(q).y;
761
+ return Math.abs(dy) < band ? p.x - q.x : dy;
762
+ });
763
+ }
764
+ for (const n of ordered) steps.push({ id: n.id, kind: kindOf(n), at: center(n) });
765
+ }
766
+ const order = new Map(steps.map((s, i) => [s.id, i]));
767
+ const boxes = new Map([...next.notes, ...next.frames].map((r) => [r.id, r]));
768
+ const links = d.added.links.map((l) => {
769
+ const a = boxes.get(l.from), b = boxes.get(l.to);
770
+ const after = Math.max(order.get(l.from) ?? -1, order.get(l.to) ?? -1);
771
+ const at = a ? center(a) : b ? center(b) : { x: 0, y: 0 };
772
+ return { step: { id: l.id, kind: "link", at }, after };
773
+ });
774
+ const out = [];
775
+ for (let i = 0; i < steps.length; i++) {
776
+ out.push(steps[i]);
777
+ for (const l of links) if (l.after === i) out.push(l.step);
778
+ }
779
+ for (const l of links) if (l.after < 0) out.push(l.step);
780
+ for (const c of d.changed) {
781
+ if (order.has(c.id)) continue;
782
+ const r = boxes.get(c.id);
783
+ if (r) out.push({ id: c.id, kind: "change", at: center(r) });
784
+ }
785
+ return out;
786
+ }
787
+ function median(xs) {
788
+ if (!xs.length) return 0;
789
+ const s = [...xs].sort((a, b) => a - b);
790
+ return s[Math.floor(s.length / 2)];
791
+ }
792
+ var paceOf = (n, total, min, max) => n ? Math.max(min, Math.min(max, Math.floor(total / n))) : 0;
793
+
794
+ // src/react/boardMachine.ts
795
+ var initialMachine = { loaded: false, error: null, gesture: false, queued: 0, playing: false, activity: null, scrub: null, replay: null };
796
+ function machine(s, e) {
797
+ switch (e.type) {
798
+ case "loaded":
799
+ return { ...s, loaded: true, error: null };
800
+ case "error":
801
+ return { ...s, error: e.message };
802
+ case "gesture":
803
+ if (e.on) return { ...s, gesture: true };
804
+ return { ...s, gesture: false, playing: s.playing || s.queued > 0, queued: 0 };
805
+ case "incoming":
806
+ if (!e.steps || s.scrub !== null || s.replay) return s;
807
+ return s.gesture ? { ...s, queued: s.queued + 1 } : { ...s, playing: true };
808
+ case "played":
809
+ return { ...s, playing: false };
810
+ case "activity":
811
+ return { ...s, activity: e.activity };
812
+ case "scrub":
813
+ return { ...s, scrub: e.version, playing: false, queued: 0 };
814
+ case "latest":
815
+ return { ...s, scrub: null, replay: null, playing: false };
816
+ case "replay":
817
+ return { ...s, replay: { paused: false, speed: s.replay?.speed ?? 1 }, playing: false, queued: 0 };
818
+ case "pause":
819
+ return s.replay ? { ...s, replay: { ...s.replay, paused: e.paused } } : s;
820
+ case "speed":
821
+ return s.replay ? { ...s, replay: { ...s.replay, speed: e.speed } } : s;
822
+ case "replayDone":
823
+ return { ...s, replay: null, scrub: null, playing: false };
824
+ }
825
+ }
826
+ var freshActivity = (a, now, freshMs) => a && now - Date.parse(a.at) < freshMs ? a : null;
827
+ function modeOf(s, now, freshMs) {
828
+ if (s.error && !s.loaded) return "error";
829
+ if (!s.loaded) return "loading";
830
+ if (s.scrub !== null || s.replay) return "scrubbing";
831
+ if (s.gesture) return "editing";
832
+ if (s.playing) return "replaying";
833
+ if (freshActivity(s.activity, now, freshMs)?.agent) return "agentWorking";
834
+ return "idle";
835
+ }
836
+ function earliestRebuildable(list) {
837
+ let floor = list[0]?.version ?? 0;
838
+ for (const e of list) if (e.replayable === false) floor = Math.max(floor, e.version);
839
+ return floor;
840
+ }
841
+
842
+ // src/react/Choreo.tsx
843
+ import { memo, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
844
+ import { AnimatePresence, motion } from "motion/react";
845
+
846
+ // src/react/motion.ts
847
+ var uiMotionScale = 1;
848
+ var EASE = [0.16, 1, 0.3, 1];
849
+ var pace = uiMotionScale;
850
+ var D = {
851
+ d1: 0.12 * pace,
852
+ // 120ms: micro press, quick fade/exit
853
+ d2: 0.18 * pace,
854
+ // 180ms: hover, popover, view switch
855
+ d3: 0.24 * pace,
856
+ // 240ms: card, panel, drawer
857
+ d4: 0.36 * pace
858
+ // 360ms: shell, hero stagger, metric bars
859
+ };
860
+ var MOTION_VARS = {
861
+ "--ap-d1": `${Math.round(D.d1 * 1e3)}ms`,
862
+ "--ap-d2": `${Math.round(D.d2 * 1e3)}ms`,
863
+ "--ap-d3": `${Math.round(D.d3 * 1e3)}ms`,
864
+ "--ap-d4": `${Math.round(D.d4 * 1e3)}ms`
865
+ };
866
+ var DISCLOSE = {
867
+ /** A floating list over the content: in with a soft settle, out a little quicker; rows follow once it is in place. */
868
+ pop: 0.3 * pace,
869
+ popOut: 0.22 * pace,
870
+ rowsAfter: 0.06 * pace,
871
+ row: 0.04,
872
+ rowFade: 0.24 * pace
873
+ };
874
+ var REVEAL = {
875
+ initial: { opacity: 0, height: 0 },
876
+ animate: { opacity: 1, height: "auto", transition: { height: { duration: D.d3, ease: EASE }, opacity: { duration: D.d2, ease: EASE, delay: 0.04 } } },
877
+ exit: { opacity: 0, height: 0, transition: { height: { duration: D.d2, ease: EASE }, opacity: { duration: D.d1, ease: EASE } } }
878
+ };
879
+ var REVEAL_STILL = { initial: { opacity: 0 }, animate: { opacity: 1, transition: { duration: D.d1 } }, exit: { opacity: 0, transition: { duration: D.d1 } } };
880
+ var FADE = {
881
+ initial: { opacity: 0, y: 4 },
882
+ animate: { opacity: 1, y: 0, transition: { duration: D.d2, ease: EASE } },
883
+ exit: { opacity: 0, transition: { duration: D.d1, ease: EASE } }
884
+ };
885
+
886
+ // src/react/pop.ts
887
+ var POP_IN = {
888
+ initial: { opacity: 0, y: -4 },
889
+ animate: { opacity: 1, y: 0, transition: { duration: D.d2, ease: EASE } },
890
+ exit: { opacity: 0, y: -4, transition: { duration: D.d1, ease: EASE } }
891
+ };
892
+ var POP_UP = {
893
+ initial: { opacity: 0, y: 4 },
894
+ animate: { opacity: 1, y: 0, transition: { duration: D.d2, ease: EASE } },
895
+ exit: { opacity: 0, y: 4, transition: { duration: D.d1, ease: EASE } }
896
+ };
897
+
898
+ // src/react/Choreo.tsx
899
+ import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
900
+ var AgentCursor = memo(function AgentCursor2({ x, y, press, z, label, show, agent }) {
901
+ return /* @__PURE__ */ jsx2(AnimatePresence, { children: show && /* @__PURE__ */ jsx2(
902
+ motion.div,
903
+ {
904
+ className: "sp-wb-cursor",
905
+ "data-agent": agent || void 0,
906
+ style: { x, y },
907
+ "aria-hidden": true,
908
+ initial: { opacity: 0 },
909
+ animate: { opacity: 1 },
910
+ exit: { opacity: 0 },
911
+ transition: { duration: 0.18 },
912
+ children: /* @__PURE__ */ jsxs(motion.span, { className: "sp-wb-cursor-in", style: { scale: 1 / z, y: press }, children: [
913
+ /* @__PURE__ */ jsx2("svg", { width: "18", height: "18", viewBox: "0 0 18 18", children: /* @__PURE__ */ jsx2("path", { d: "M2 2 15 8.5 9.2 10 6.8 15.5Z" }) }),
914
+ /* @__PURE__ */ jsx2("span", { className: "sp-wb-cursor-label", children: label })
915
+ ] })
916
+ },
917
+ "cursor"
918
+ ) });
919
+ });
920
+ function Caption({ text, version, speed, instant, lead, onSkip }) {
921
+ const [n, setN] = useState2(instant ? text.length : 0);
922
+ useEffect2(() => {
923
+ if (instant) {
924
+ setN(text.length);
925
+ return;
926
+ }
927
+ setN(0);
928
+ let i = 0;
929
+ const t = setInterval(() => {
930
+ i += 1;
931
+ setN(i);
932
+ if (i >= text.length) clearInterval(t);
933
+ }, BOARD2.replay.typeMs / speed);
934
+ return () => clearInterval(t);
935
+ }, [text, instant, speed]);
936
+ return /* @__PURE__ */ jsxs("p", { className: "sp-wb-caption-bar", role: "status", "aria-live": "polite", children: [
937
+ /* @__PURE__ */ jsx2("strong", { children: lead ?? WB.viewing(version) }),
938
+ /* @__PURE__ */ jsxs("span", { dir: "auto", "aria-label": text, children: [
939
+ text.slice(0, n),
940
+ /* @__PURE__ */ jsx2("i", { className: "sp-wb-caption-caret", "aria-hidden": true })
941
+ ] }),
942
+ onSkip && /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-caption-skip", onClick: onSkip, children: WB.skip })
943
+ ] });
944
+ }
945
+ function HistoryStrip({ entries, loading, current, latest, replaying, paused, speed, note, onPick, onReplay, onPause, onSpeed, onClose }) {
946
+ const list = entries ?? [];
947
+ const floor = earliestRebuildable(list);
948
+ const at = current ?? latest;
949
+ const idx = Math.max(0, list.findIndex((e) => e.version === at));
950
+ const pick = useRef2(null);
951
+ useEffect2(() => () => {
952
+ if (pick.current) clearTimeout(pick.current);
953
+ }, []);
954
+ return /* @__PURE__ */ jsxs(motion.div, { className: "sp-wb-history", role: "region", "aria-label": WB.historyAria, ...POP_UP, children: [
955
+ /* @__PURE__ */ jsxs("div", { className: "sp-wb-history-row", children: [
956
+ /* @__PURE__ */ jsx2("strong", { className: "sp-wb-history-h", children: WB.history }),
957
+ replaying ? /* @__PURE__ */ jsxs(Fragment, { children: [
958
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn", onClick: () => onPause(!paused), children: paused ? WB.resume : WB.pause }),
959
+ /* @__PURE__ */ jsx2("div", { className: "sp-wb-seg", role: "group", "aria-label": WB.speedAria, children: [1, 2].map((s) => /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn", "aria-pressed": speed === s, onClick: () => onSpeed(s), children: WB.speed(s) }, s)) })
960
+ ] }) : /* @__PURE__ */ jsxs("button", { type: "button", className: "sp-wb-btn sp-wb-replay", onClick: onReplay, "aria-label": WB.replayAria, disabled: loading, children: [
961
+ /* @__PURE__ */ jsx2("svg", { width: "14", height: "14", viewBox: "0 0 16 16", "aria-hidden": true, children: /* @__PURE__ */ jsx2("path", { d: "M4 3v10l9-5z" }) }),
962
+ WB.replay
963
+ ] }),
964
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn sp-wb-history-x", onClick: onClose, children: WB.close })
965
+ ] }),
966
+ loading ? /* @__PURE__ */ jsx2("p", { className: "sp-wb-history-note", role: "status", children: WB.historyLoading }) : !list.length ? /* @__PURE__ */ jsx2("p", { className: "sp-wb-history-note", children: WB.historyEmpty }) : /* @__PURE__ */ jsxs("div", { className: "sp-wb-ticks", children: [
967
+ /* @__PURE__ */ jsx2(
968
+ "input",
969
+ {
970
+ type: "range",
971
+ min: 0,
972
+ max: list.length - 1,
973
+ step: 1,
974
+ value: idx,
975
+ "aria-label": WB.historyRange,
976
+ disabled: replaying,
977
+ "aria-valuetext": list[idx] ? WB.versionTick(list[idx].version, list[idx].by, ago(list[idx].at), list[idx].what) : void 0,
978
+ onChange: (e) => {
979
+ const v = list[Number(e.target.value)]?.version;
980
+ if (v === void 0 || v < floor) return;
981
+ if (pick.current) clearTimeout(pick.current);
982
+ pick.current = setTimeout(() => onPick(v), 120);
983
+ }
984
+ }
985
+ ),
986
+ /* @__PURE__ */ jsx2("ol", { className: "sp-wb-tick-list", children: list.map((e) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsx2(
987
+ "button",
988
+ {
989
+ type: "button",
990
+ className: "sp-wb-tick",
991
+ "data-agent": e.agent || void 0,
992
+ "aria-current": e.version === at || void 0,
993
+ disabled: replaying || e.version < floor,
994
+ title: WB.versionTick(e.version, e.by, ago(e.at), e.why || e.what),
995
+ "aria-label": WB.versionTick(e.version, e.by, ago(e.at), e.why || e.what),
996
+ onClick: () => onPick(e.version)
997
+ }
998
+ ) }, e.version)) })
999
+ ] }),
1000
+ note && /* @__PURE__ */ jsx2("p", { className: "sp-wb-history-note", role: "alert", children: note })
1001
+ ] });
1002
+ }
1003
+ function ScrubBanner({ version, why, restoring, onLatest, onRestore, replaying }) {
1004
+ return /* @__PURE__ */ jsxs(motion.div, { className: "sp-wb-float sp-wb-banner", role: "status", "data-dock": "top", ...POP_IN, children: [
1005
+ /* @__PURE__ */ jsxs("span", { className: "sp-wb-banner-text", children: [
1006
+ /* @__PURE__ */ jsx2("strong", { children: WB.viewing(version) }),
1007
+ why && /* @__PURE__ */ jsxs("span", { dir: "auto", children: [
1008
+ " \xB7 ",
1009
+ why
1010
+ ] })
1011
+ ] }),
1012
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn", onClick: onLatest, children: WB.latest }),
1013
+ !replaying && /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn sp-wb-send", onClick: onRestore, disabled: restoring, children: restoring ? WB.restoring : WB.restoreThis })
1014
+ ] });
1015
+ }
1016
+ function BatchPill({ batch, z, state, error, onKeep, onUndo }) {
1017
+ const busy = state !== "idle";
1018
+ return /* @__PURE__ */ jsxs(
1019
+ "div",
1020
+ {
1021
+ className: "sp-wb-batch",
1022
+ style: { scale: 1 / z },
1023
+ role: "group",
1024
+ "aria-label": WB.batchOf(batch.what),
1025
+ "aria-describedby": `batch-hint-${batch.id}`,
1026
+ onPointerDown: (e) => e.stopPropagation(),
1027
+ onDoubleClick: (e) => e.stopPropagation(),
1028
+ onKeyDown: (e) => {
1029
+ if (e.key === "Escape") {
1030
+ e.preventDefault();
1031
+ e.stopPropagation();
1032
+ if (!busy) onUndo();
1033
+ } else if (e.key === "Enter" && e.target.tagName !== "BUTTON") {
1034
+ e.preventDefault();
1035
+ e.stopPropagation();
1036
+ if (!busy) onKeep();
1037
+ }
1038
+ },
1039
+ children: [
1040
+ /* @__PURE__ */ jsx2(AnimatePresence, { mode: "popLayout", initial: false, children: state === "kept" ? /* @__PURE__ */ jsx2(
1041
+ motion.span,
1042
+ {
1043
+ className: "sp-wb-batch-stamp",
1044
+ role: "status",
1045
+ initial: { opacity: 0, scale: 1.3, rotate: -6 },
1046
+ animate: { opacity: 1, scale: 1, rotate: -2 },
1047
+ exit: { opacity: 0 },
1048
+ transition: { type: "spring", visualDuration: BOARD2.springs.stamp.visualDuration, bounce: BOARD2.springs.stamp.bounce },
1049
+ children: WB.kept
1050
+ },
1051
+ "kept"
1052
+ ) : /* @__PURE__ */ jsxs(motion.span, { className: "sp-wb-batch-row", initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0, transition: { duration: 0.12 } }, children: [
1053
+ /* @__PURE__ */ jsxs("span", { className: "sp-wb-batch-what", tabIndex: 0, children: [
1054
+ /* @__PURE__ */ jsx2("i", { "aria-hidden": true }),
1055
+ /* @__PURE__ */ jsx2("span", { dir: "auto", children: WB.batchOf(batch.what) }),
1056
+ batch.why && /* @__PURE__ */ jsx2("small", { dir: "auto", children: batch.why })
1057
+ ] }),
1058
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn sp-wb-send", onClick: onKeep, disabled: busy, "aria-label": WB.keepAria(batch.what), children: WB.keep }),
1059
+ /* @__PURE__ */ jsx2("button", { type: "button", className: "sp-wb-btn", onClick: onUndo, disabled: busy, "aria-label": WB.undoAria(batch.what), children: state === "undoing" ? WB.undoing : WB.undo })
1060
+ ] }, "ask") }),
1061
+ /* @__PURE__ */ jsx2("span", { id: `batch-hint-${batch.id}`, className: "ap-sr", children: WB.batchHint }),
1062
+ /* @__PURE__ */ jsx2(AnimatePresence, { children: error && /* @__PURE__ */ jsx2(motion.p, { className: "sp-wb-batch-err", role: "alert", initial: { opacity: 0, height: 0 }, animate: { opacity: 1, height: "auto" }, exit: { opacity: 0, height: 0 }, children: error }, "err") })
1063
+ ]
1064
+ }
1065
+ );
1066
+ }
1067
+ function EdgeMarker({ x, y, view, label, onFly }) {
1068
+ const ref = useRef2(null);
1069
+ const viewNow = useRef2(view);
1070
+ viewNow.current = view;
1071
+ useEffect2(() => {
1072
+ const el = ref.current, host = el?.parentElement;
1073
+ if (!el || !host) return;
1074
+ const place = () => {
1075
+ const v = viewNow.current, W = host.clientWidth, H = host.clientHeight;
1076
+ const sx = x.get() * v.z + v.x, sy = y.get() * v.z + v.y;
1077
+ const off = sx < 0 || sy < 0 || sx > W || sy > H;
1078
+ el.toggleAttribute("data-on", off);
1079
+ if (!off) return;
1080
+ const hw = el.offsetWidth / 2 + 10, hh = el.offsetHeight / 2 + 10;
1081
+ const cx = Math.min(W - hw, Math.max(hw, sx)), cy = Math.min(H - hh, Math.max(hh, sy));
1082
+ el.style.transform = `translate(${cx}px, ${cy}px) translate(-50%, -50%)`;
1083
+ el.style.setProperty("--sp-wb-edge-angle", `${Math.atan2(sy - cy, sx - cx)}rad`);
1084
+ };
1085
+ place();
1086
+ const a = x.on("change", place), b = y.on("change", place);
1087
+ return () => {
1088
+ a();
1089
+ b();
1090
+ };
1091
+ }, [x, y, view]);
1092
+ return /* @__PURE__ */ jsxs("button", { ref, type: "button", className: "sp-wb-edge", onClick: onFly, "aria-label": label, children: [
1093
+ /* @__PURE__ */ jsx2("svg", { className: "sp-wb-edge-arrow", width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": true, children: /* @__PURE__ */ jsx2("path", { d: "M2 6h7M6 2.5 9.5 6 6 9.5" }) }),
1094
+ /* @__PURE__ */ jsx2("span", { dir: "auto", children: label })
1095
+ ] });
1096
+ }
1097
+
1098
+ // src/react/ink.ts
1099
+ import getStroke from "perfect-freehand";
1100
+ import { getBoxToBoxArrow } from "perfect-arrows";
1101
+ import rough from "roughjs";
1102
+ function outlinePath(pts) {
1103
+ if (pts.length < 2) return "";
1104
+ let d = `M ${pts[0][0].toFixed(1)} ${pts[0][1].toFixed(1)} Q`;
1105
+ for (let i = 0; i < pts.length; i++) {
1106
+ const [x0, y0] = pts[i], [x1, y1] = pts[(i + 1) % pts.length];
1107
+ d += ` ${x0.toFixed(1)} ${y0.toFixed(1)} ${((x0 + x1) / 2).toFixed(1)} ${((y0 + y1) / 2).toFixed(1)}`;
1108
+ }
1109
+ return `${d} Z`;
1110
+ }
1111
+ function brushStroke(points, pressure, size, brush, weight) {
1112
+ const W = weight && weight > 0 ? weight : BOARD2.brush.width[brush][size];
1113
+ const n = Math.floor(points.length / 2);
1114
+ if (n < 1) return { body: "", brush };
1115
+ const real = !!pressure && pressure.length === n;
1116
+ const input = Array.from({ length: n }, (_, i) => real ? [points[i * 2], points[i * 2 + 1], pressure[i]] : [points[i * 2], points[i * 2 + 1]]);
1117
+ if (brush === "spidol") {
1118
+ return { brush, body: outlinePath(getStroke(input, { size: W, thinning: 0, smoothing: 0.6, streamline: 0.5, simulatePressure: false, start: { cap: true }, end: { cap: true } })) };
1119
+ }
1120
+ return { brush, body: inkPathSized(input, real, W) };
1121
+ }
1122
+ function inkPathSized(input, real, size) {
1123
+ const I = BOARD2.ink;
1124
+ return outlinePath(getStroke(input, { size, thinning: I.thinning, smoothing: I.smoothing, streamline: I.streamline, simulatePressure: !real, last: true, start: { taper: I.taper, cap: true }, end: { taper: I.taper, cap: true } }));
1125
+ }
1126
+ function liveStroke(points, pressure, size, brush, weight) {
1127
+ return brushStroke(points, pressure, size, brush, weight).body;
1128
+ }
1129
+ var brushCache = /* @__PURE__ */ new Map();
1130
+ function brushOf(id, points, pressure, size, brush, weight) {
1131
+ const key = `${id}|${points.length}|${size}|${brush}|${weight ?? 0}`;
1132
+ const hit = brushCache.get(key);
1133
+ if (hit) return hit;
1134
+ const made = brushStroke(points, pressure, size, brush, weight);
1135
+ if (brushCache.size >= BOARD2.rough.cacheMax) brushCache.delete(brushCache.keys().next().value);
1136
+ brushCache.set(key, made);
1137
+ return made;
1138
+ }
1139
+ function boxArrow(a, c, route) {
1140
+ const A = BOARD2.arrow;
1141
+ const [sx, sy, cx, cy, ex, ey, ae, as] = getBoxToBoxArrow(a.x, a.y, a.w, a.h, c.x, c.y, c.w, c.h, {
1142
+ bow: route === "curve" ? A.curveBow : 0,
1143
+ stretch: route === "curve" ? A.curveStretch : 0,
1144
+ padStart: A.padStart,
1145
+ padEnd: A.padEnd
1146
+ });
1147
+ return {
1148
+ d: `M ${sx} ${sy} Q ${cx} ${cy} ${ex} ${ey}`,
1149
+ mid: { x: (sx + 2 * cx + ex) / 4, y: (sy + 2 * cy + ey) / 4 },
1150
+ start: [sx, sy],
1151
+ end: [ex, ey],
1152
+ endAngle: ae,
1153
+ startAngle: as,
1154
+ q: [sx, sy, cx, cy, ex, ey]
1155
+ };
1156
+ }
1157
+ function headPath(x, y, angle) {
1158
+ const L = BOARD2.arrow.head, Wd = L * BOARD2.arrow.headWidth;
1159
+ const bx = x - Math.cos(angle) * L, by = y - Math.sin(angle) * L;
1160
+ const nx = -Math.sin(angle) * Wd, ny = Math.cos(angle) * Wd;
1161
+ const kx = x - Math.cos(angle) * L * 0.72, ky = y - Math.sin(angle) * L * 0.72;
1162
+ return `M ${x} ${y} L ${bx + nx} ${by + ny} L ${kx} ${ky} L ${bx - nx} ${by - ny} Z`;
1163
+ }
1164
+ var gen = rough.generator();
1165
+ var cache = /* @__PURE__ */ new Map();
1166
+ function seedOf(id) {
1167
+ let h = 2166136261;
1168
+ for (let i = 0; i < id.length; i++) h = Math.imul(h ^ id.charCodeAt(i), 16777619);
1169
+ return (h >>> 0) % 2147483646 + 1;
1170
+ }
1171
+ function remember(key, make) {
1172
+ const hit = cache.get(key);
1173
+ if (hit) return hit;
1174
+ const paths = make();
1175
+ if (cache.size >= BOARD2.rough.cacheMax) cache.delete(cache.keys().next().value);
1176
+ cache.set(key, paths);
1177
+ return paths;
1178
+ }
1179
+ var tenth = (d) => d.replace(/-?\d+\.\d+(e-?\d+)?/g, (n) => String(Math.round(Number(n) * 10) / 10));
1180
+ var strokesOf = (d) => gen.toPaths(d).map((p) => tenth(p.d));
1181
+ var opts = (id, extra = {}) => ({ roughness: BOARD2.rough.roughness, bowing: BOARD2.rough.bowing, seed: seedOf(id), fill: void 0, ...extra });
1182
+ var scalePath = (d, w0, h0, w, h) => {
1183
+ let i = 0;
1184
+ return d.replace(/-?\d+(\.\d+)?/g, (m) => String(Math.round(Number(m) * (i++ % 2 ? h / h0 : w / w0) * 10) / 10));
1185
+ };
1186
+ var CLOUD = "M24 56C9 56 4 42 15 36 11 22 27 12 39 19 45 6 68 5 74 20 89 15 99 31 89 40 97 52 84 58 75 56Z";
1187
+ function roughOutline(id, shape, w, h) {
1188
+ const W = Math.round(w), H = Math.round(h);
1189
+ return remember(`${id}|${shape}|${W}|${H}`, () => {
1190
+ switch (shape) {
1191
+ case "ellipse":
1192
+ return strokesOf(gen.ellipse(W / 2, H / 2, W - 2, H - 2, opts(id)));
1193
+ case "pill": {
1194
+ const r = Math.min(H, W) / 2 - 1;
1195
+ return strokesOf(gen.path(`M ${r + 1} 1 L ${W - r - 1} 1 A ${r} ${r} 0 0 1 ${W - r - 1} ${H - 1} L ${r + 1} ${H - 1} A ${r} ${r} 0 0 1 ${r + 1} 1 Z`, opts(id)));
1196
+ }
1197
+ case "cloud":
1198
+ return strokesOf(gen.path(scalePath(CLOUD, 100, 62, W, H), opts(id)));
1199
+ case "cylinder": {
1200
+ const ry = Math.min(H * 0.1, 14), x0 = 1, x1 = W - 1;
1201
+ return [
1202
+ ...strokesOf(gen.ellipse(W / 2, ry, W - 2, ry * 2, opts(id))),
1203
+ ...strokesOf(gen.path(`M ${x0} ${ry} L ${x0} ${H - ry} A ${(W - 2) / 2} ${ry} 0 0 0 ${x1} ${H - ry} L ${x1} ${ry}`, opts(id)))
1204
+ ];
1205
+ }
1206
+ case "diamond":
1207
+ case "triangle":
1208
+ case "pentagon":
1209
+ case "hexagon":
1210
+ case "parallelogram":
1211
+ return strokesOf(gen.polygon(polygonPoints(shape, W, H), opts(id)));
1212
+ case "cell":
1213
+ return strokesOf(gen.rectangle(0, 0, W, H, opts(id, { roughness: BOARD2.rough.cellRoughness, disableMultiStroke: true })));
1214
+ case "frame":
1215
+ return strokesOf(gen.rectangle(1, 1, W - 2, H - 2, opts(id, { roughness: BOARD2.rough.cellRoughness })));
1216
+ default:
1217
+ return strokesOf(gen.rectangle(1, 1, W - 2, H - 2, opts(id)));
1218
+ }
1219
+ });
1220
+ }
1221
+ function roughLine(id, geo) {
1222
+ const nums = (geo.q ?? geo.poly ?? []).map((v) => Math.round(v));
1223
+ return remember(`${id}|line|${nums.join(",")}`, () => {
1224
+ const o = opts(id, { roughness: BOARD2.rough.linkRoughness, disableMultiStroke: true });
1225
+ if (geo.q) {
1226
+ const [sx, sy, cx, cy, ex, ey] = nums;
1227
+ return strokesOf(gen.path(`M ${sx} ${sy} Q ${cx} ${cy} ${ex} ${ey}`, o));
1228
+ }
1229
+ const pts = [];
1230
+ for (let i = 0; i + 1 < nums.length; i += 2) pts.push([nums[i], nums[i + 1]]);
1231
+ return strokesOf(gen.linearPath(pts, o));
1232
+ });
1233
+ }
1234
+
1235
+ // src/react/camera.ts
1236
+ var toCam = (v, s) => [(s.w / 2 - v.x) / v.z, (s.h / 2 - v.y) / v.z, s.w / v.z];
1237
+ var toView = ([cx, cy, w], s) => {
1238
+ const z = s.w / w;
1239
+ return { z, x: s.w / 2 - cx * z, y: s.h / 2 - cy * z };
1240
+ };
1241
+ var easeInOut = (t) => t < 0.5 ? 4 * t * t * t : 1 - Math.pow(-2 * t + 2, 3) / 2;
1242
+ function zoomPath(a, b, s, opts2 = {}) {
1243
+ const rho = opts2.rho ?? Math.SQRT2, rho2 = rho * rho, rho4 = rho2 * rho2;
1244
+ const [ux0, uy0, w0] = toCam(a, s), [ux1, uy1, w1] = toCam(b, s);
1245
+ const dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy;
1246
+ let S;
1247
+ let raw;
1248
+ if (d2 < 1e-12) {
1249
+ S = Math.log(w1 / w0) / rho;
1250
+ raw = (t) => [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
1251
+ } else {
1252
+ const d1 = Math.sqrt(d2);
1253
+ const b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1);
1254
+ const b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1);
1255
+ const r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0);
1256
+ const r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
1257
+ S = (r1 - r0) / rho;
1258
+ raw = (t) => {
1259
+ const sv = t * S, c0 = Math.cosh(r0);
1260
+ const u = w0 / (rho2 * d1) * (c0 * Math.tanh(rho * sv + r0) - Math.sinh(r0));
1261
+ return [ux0 + u * dx, uy0 + u * dy, w0 * c0 / Math.cosh(rho * sv + r0)];
1262
+ };
1263
+ }
1264
+ const ms = Math.min(opts2.maxMs ?? 1200, Math.max(opts2.minMs ?? 400, Math.abs(S) * 1e3));
1265
+ return {
1266
+ ms,
1267
+ at: (t) => {
1268
+ if (t <= 0) return a;
1269
+ if (t >= 1) return b;
1270
+ return toView(raw(easeInOut(t)), s);
1271
+ }
1272
+ };
1273
+ }
1274
+ function isLongMove(a, b, s) {
1275
+ const [ax, ay] = toCam(a, s), [bx, by] = toCam(b, s);
1276
+ const screen = Math.hypot((bx - ax) * a.z, (by - ay) * a.z);
1277
+ const ratio = Math.max(a.z / b.z, b.z / a.z);
1278
+ return screen > Math.hypot(s.w, s.h) * 0.45 || ratio > 1.6;
1279
+ }
1280
+ function centreOn(p, v, s, bottom = 0) {
1281
+ return { z: v.z, x: s.w / 2 - p.x * v.z, y: (s.h - bottom) / 2 - p.y * v.z };
1282
+ }
1283
+ function stepCamera(v, s, target, bottom = 0, inset = 0.15) {
1284
+ const sx = target.x * v.z + v.x, sy = target.y * v.z + v.y;
1285
+ const h = s.h - bottom;
1286
+ const ix = s.w * inset, iy = h * inset;
1287
+ return sx >= ix && sx <= s.w - ix && sy >= iy && sy <= h - iy ? "stay" : "follow";
1288
+ }
1289
+ function readableView(bb, s, read, pad, top, bottom = 0) {
1290
+ const w = bb.x1 - bb.x0 || 1, h = bb.y1 - bb.y0 || 1;
1291
+ const z = Math.min(1, (s.w - pad * 2) / w, (s.h - pad * 2 - bottom) / h);
1292
+ if (z >= read) return { z, x: (s.w - w * z) / 2 - bb.x0 * z, y: pad + top - bb.y0 * z };
1293
+ return { z: read, x: pad - bb.x0 * read, y: pad + top - bb.y0 * read };
1294
+ }
1295
+ function planCamera(v, s, plan, bottom = 0) {
1296
+ if (!plan) return "stay";
1297
+ const x0 = plan.x0 * v.z + v.x, y0 = plan.y0 * v.z + v.y, x1 = plan.x1 * v.z + v.x, y1 = plan.y1 * v.z + v.y;
1298
+ return x0 >= 0 && y0 >= 0 && x1 <= s.w && y1 <= s.h - bottom ? "stay" : "overview";
1299
+ }
1300
+ var agentMayMove = (lastInputAt, now, quietMs = 2e3) => now - lastInputAt >= quietMs;
1301
+
1302
+ // src/react/motionKit.ts
1303
+ function springEasing(visualDuration, bounce, samples = 40) {
1304
+ const root = 2 * Math.PI / (visualDuration * 1.2);
1305
+ const zeta = Math.min(1, Math.max(0.05, 1 - bounce));
1306
+ const w0 = root;
1307
+ const pos = (t) => {
1308
+ if (zeta < 1) {
1309
+ const wd = w0 * Math.sqrt(1 - zeta * zeta);
1310
+ return 1 - Math.exp(-zeta * w0 * t) * (Math.cos(wd * t) + zeta * w0 / wd * Math.sin(wd * t));
1311
+ }
1312
+ return 1 - Math.exp(-w0 * t) * (1 + w0 * t);
1313
+ };
1314
+ let end = visualDuration;
1315
+ for (let t = visualDuration; t < 3; t += 0.01) {
1316
+ let calm = true;
1317
+ for (let k = t; k < t + 0.12; k += 0.01) if (Math.abs(pos(k) - 1) > 1e-3) {
1318
+ calm = false;
1319
+ break;
1320
+ }
1321
+ if (calm) {
1322
+ end = t;
1323
+ break;
1324
+ }
1325
+ end = t;
1326
+ }
1327
+ const pts = [];
1328
+ for (let i = 0; i <= samples; i++) pts.push(String(Math.round(pos(end * i / samples) * 1e3) / 1e3));
1329
+ pts[0] = "0";
1330
+ pts[pts.length - 1] = "1";
1331
+ return { ms: Math.round(end * 1e3), css: `linear(${pts.join(", ")})` };
1332
+ }
1333
+ function liveFootprints(plan, present, pending) {
1334
+ return (plan ?? []).filter((p) => !present.has(p.id) || pending.has(p.id));
1335
+ }
1336
+ function planBounds(plan) {
1337
+ if (!plan?.length) return null;
1338
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
1339
+ for (const p of plan) {
1340
+ x0 = Math.min(x0, p.x);
1341
+ y0 = Math.min(y0, p.y);
1342
+ x1 = Math.max(x1, p.x + p.w);
1343
+ y1 = Math.max(y1, p.y + p.h);
1344
+ }
1345
+ return { x0, y0, x1, y1 };
1346
+ }
1347
+ function arcPoint(from, to, t, bow = 0.08) {
1348
+ const dx = to.x - from.x, dy = to.y - from.y, d = Math.hypot(dx, dy);
1349
+ const cx = (from.x + to.x) / 2 - (d ? dy / d * d * bow : 0), cy = (from.y + to.y) / 2 + (d ? dx / d * d * bow : 0);
1350
+ const u = 1 - t;
1351
+ return { x: u * u * from.x + 2 * u * t * cx + t * t * to.x, y: u * u * from.y + 2 * u * t * cy + t * t * to.y };
1352
+ }
1353
+
1354
+ // src/react/sound.ts
1355
+ var ctx = null;
1356
+ var lastThud = 0;
1357
+ function soundOn() {
1358
+ try {
1359
+ return localStorage.getItem(BOARD2.sound.key) === "1";
1360
+ } catch {
1361
+ return false;
1362
+ }
1363
+ }
1364
+ function setSoundOn(on) {
1365
+ try {
1366
+ localStorage.setItem(BOARD2.sound.key, on ? "1" : "0");
1367
+ } catch {
1368
+ }
1369
+ }
1370
+ function audio() {
1371
+ if (typeof window === "undefined") return null;
1372
+ const AC = window.AudioContext ?? window.webkitAudioContext;
1373
+ if (!AC) return null;
1374
+ ctx ??= new AC();
1375
+ if (ctx.state === "suspended") void ctx.resume();
1376
+ return ctx;
1377
+ }
1378
+ function thud() {
1379
+ if (!soundOn()) return;
1380
+ const now = performance.now();
1381
+ if (now - lastThud < BOARD2.sound.thudGapMs) return;
1382
+ lastThud = now;
1383
+ const a = audio();
1384
+ if (!a) return;
1385
+ const t = a.currentTime, len = BOARD2.sound.thudMs / 1e3;
1386
+ const buf = a.createBuffer(1, Math.ceil(a.sampleRate * len), a.sampleRate);
1387
+ const ch = buf.getChannelData(0);
1388
+ for (let i = 0; i < ch.length; i++) ch[i] = (Math.random() * 2 - 1) * (1 - i / ch.length);
1389
+ const noise = a.createBufferSource();
1390
+ noise.buffer = buf;
1391
+ const lp = a.createBiquadFilter();
1392
+ lp.type = "lowpass";
1393
+ lp.frequency.value = 900;
1394
+ const ng = a.createGain();
1395
+ ng.gain.setValueAtTime(0.22, t);
1396
+ ng.gain.exponentialRampToValueAtTime(1e-3, t + len);
1397
+ noise.connect(lp).connect(ng).connect(a.destination);
1398
+ const osc = a.createOscillator();
1399
+ osc.frequency.setValueAtTime(140, t);
1400
+ osc.frequency.exponentialRampToValueAtTime(80, t + len);
1401
+ const og = a.createGain();
1402
+ og.gain.setValueAtTime(0.3, t);
1403
+ og.gain.exponentialRampToValueAtTime(1e-3, t + len);
1404
+ osc.connect(og).connect(a.destination);
1405
+ noise.start(t);
1406
+ osc.start(t);
1407
+ noise.stop(t + len);
1408
+ osc.stop(t + len);
1409
+ }
1410
+ function chime() {
1411
+ if (!soundOn()) return;
1412
+ const a = audio();
1413
+ if (!a) return;
1414
+ const t = a.currentTime;
1415
+ [[660, 0], [990, 0.11]].forEach(([f, at]) => {
1416
+ const o = a.createOscillator();
1417
+ o.type = "sine";
1418
+ o.frequency.value = f;
1419
+ const g = a.createGain();
1420
+ g.gain.setValueAtTime(0, t + at);
1421
+ g.gain.linearRampToValueAtTime(0.12, t + at + 0.015);
1422
+ g.gain.exponentialRampToValueAtTime(1e-3, t + at + 0.45);
1423
+ o.connect(g).connect(a.destination);
1424
+ o.start(t + at);
1425
+ o.stop(t + at + 0.5);
1426
+ });
1427
+ }
1428
+
1429
+ // src/react/tempo.ts
1430
+ var TEMPOS = Object.keys(BOARD2.tempo.factor);
1431
+ var factorOf = (t) => BOARD2.tempo.factor[t] ?? 1;
1432
+ function readTempo() {
1433
+ try {
1434
+ const v = localStorage.getItem(BOARD2.tempo.key);
1435
+ if (v && v in BOARD2.tempo.factor) return v;
1436
+ } catch {
1437
+ }
1438
+ return BOARD2.tempo.default;
1439
+ }
1440
+ function saveTempo(t) {
1441
+ try {
1442
+ localStorage.setItem(BOARD2.tempo.key, t);
1443
+ } catch {
1444
+ }
1445
+ }
1446
+
1447
+ // src/react/Whiteboard.tsx
1448
+ import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1449
+ var SKETCH = BOARD.draw.sketch;
1450
+ var STICKY_DATA = BOARD.sticky;
1451
+ function tempoVars(f) {
1452
+ const card = springEasing(BOARD2.springs.card.visualDuration * f, BOARD2.springs.card.bounce);
1453
+ const stamp = springEasing(BOARD2.springs.stamp.visualDuration * f, BOARD2.springs.stamp.bounce);
1454
+ const E = BOARD2.enter, ms = (v) => `${Math.round(v * f)}ms`;
1455
+ return {
1456
+ "--sp-wb-card-ms": `${card.ms}ms`,
1457
+ "--sp-wb-card-ease": card.css,
1458
+ "--sp-wb-stamp-ms": `${stamp.ms}ms`,
1459
+ "--sp-wb-stamp-ease": stamp.css,
1460
+ "--sp-wb-char-ms": `${Math.round(1e3 / E.typeCps * f * 10) / 10}ms`,
1461
+ "--sp-wb-type-min": ms(E.typeMinMs),
1462
+ "--sp-wb-road-ms": ms(E.roadMs),
1463
+ "--sp-wb-link-ms": ms(E.linkMs),
1464
+ "--sp-wb-sticker-ms": ms(E.stickerMs),
1465
+ "--sp-wb-ring-ms": ms(E.ringMs),
1466
+ "--sp-wb-heading-ms": ms(E.headingMs),
1467
+ "--sp-wb-frame-ms": ms(E.frameMs),
1468
+ "--sp-wb-cell-ms": ms(E.cellMs),
1469
+ "--sp-wb-dot-ms": ms(E.dotMs),
1470
+ "--sp-wb-fade-ms": ms(E.fadeMs),
1471
+ "--sp-wb-art-ms": ms(E.artMs),
1472
+ "--sp-wb-hand-ms": ms(E.handMs),
1473
+ "--sp-wb-onion-ms": `${BOARD2.onionMs}ms`
1474
+ };
1475
+ }
1476
+ var COLOR_NAME = WB.colors;
1477
+ var SWATCHES = ["paper", "ink", "red", "yellow", "blue", "green", "pink", "gray"];
1478
+ var INK_COLORS = ["ink", "blue", "red"];
1479
+ var BOX_SHAPES = ["box", "ellipse", "cloud", "cylinder", "diamond", "triangle", "pentagon", "hexagon", "parallelogram"].map((id) => ({ id, label: WB.shapes[id] }));
1480
+ var SIZES = [{ id: "s", label: WB.sizes.s }, { id: "m", label: WB.sizes.m }, { id: "l", label: WB.sizes.l }, { id: "xl", label: WB.sizes.xl }];
1481
+ var MIN_Z = BOARD2.minZoom;
1482
+ var MAX_Z = BOARD2.maxZoom;
1483
+ var clampZ = (z) => Math.min(MAX_Z, Math.max(MIN_Z, z));
1484
+ var RULE = BOARD2.rule;
1485
+ var PRESENCE_MS = BOARD2.presenceMs;
1486
+ var shapeOf = (n) => n.shape ?? "note";
1487
+ var isBoxy = (s) => OUTLINED.has(s);
1488
+ var UNDER = { track: 0, cell: 1 };
1489
+ var layered = (notes) => notes.some((n) => n.shape && n.shape in UNDER) ? [...notes].sort((a, b) => (UNDER[shapeOf(a)] ?? 2) - (UNDER[shapeOf(b)] ?? 2)) : notes;
1490
+ function bounds(rects) {
1491
+ if (!rects.length) return null;
1492
+ const x0 = Math.min(...rects.map((r) => r.x)), y0 = Math.min(...rects.map((r) => r.y));
1493
+ const x1 = Math.max(...rects.map((r) => r.x + r.w)), y1 = Math.max(...rects.map((r) => r.y + r.h));
1494
+ return { x0, y0, x1, y1 };
1495
+ }
1496
+ function routeOf(a, c, elbow) {
1497
+ 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;
1498
+ const horiz = Math.abs(cx - ax) - (a.w + c.w) / 2 > Math.abs(cy - ay) - (a.h + c.h) / 2;
1499
+ if (horiz) {
1500
+ const x1 = cx > ax ? a.x + a.w : a.x, x2 = cx > ax ? c.x : c.x + c.w;
1501
+ if (!elbow || Math.abs(ay - cy) < 1) return elbow ? [x1, ay, x2, ay] : [x1, ay, x2, cy];
1502
+ const mx = (x1 + x2) / 2;
1503
+ return [x1, ay, mx, ay, mx, cy, x2, cy];
1504
+ }
1505
+ const y1 = cy > ay ? a.y + a.h : a.y, y2 = cy > ay ? c.y : c.y + c.h;
1506
+ if (!elbow || Math.abs(ax - cx) < 1) return elbow ? [ax, y1, ax, y2] : [ax, y1, cx, y2];
1507
+ const my = (y1 + y2) / 2;
1508
+ return [ax, y1, ax, my, cx, my, cx, y2];
1509
+ }
1510
+ function smallestFont(root, id) {
1511
+ const box = root.querySelector(`[data-note="${CSS.escape(id)}"]`);
1512
+ let f = 0;
1513
+ for (const el of box?.querySelectorAll(".sp-wb-text, .sp-wb-title-line, .sp-wb-body > strong, .sp-wb-body > span, .sp-wb-tag") ?? []) {
1514
+ const px = parseFloat(getComputedStyle(el).fontSize);
1515
+ if (px && (!f || px < f)) f = px;
1516
+ }
1517
+ return f;
1518
+ }
1519
+ function typingMs(n, heading = false) {
1520
+ const E = BOARD2.enter, t = (n?.title ?? "").length, x = (n?.text ?? "").length + (n?.owner ?? "").length + (n?.due ?? "").length;
1521
+ const all = t || x;
1522
+ if (heading) return { title: all <= 60 ? Math.max(E.typeMinMs, all * 1e3 / E.typeCps) : Math.min(E.bodyMaxMs, all * 1e3 / E.bodyCps), body: 0, lines: Math.ceil(all / 40) };
1523
+ return { title: t ? Math.max(E.typeMinMs, t * 1e3 / E.typeCps) : 0, body: x ? Math.min(E.bodyMaxMs, x * 1e3 / E.bodyCps) : 0, lines: Math.ceil(t / 30) + Math.ceil(x / 38) };
1524
+ }
1525
+ function entranceMs(st, b) {
1526
+ const E = BOARD2.enter, n = b?.notes.find((x) => x.id === st.id);
1527
+ const ty = typingMs(n, st.kind === "heading"), typed = ty.title + ty.body + ty.lines * E.lineHopMs;
1528
+ switch (st.kind) {
1529
+ case "card":
1530
+ return Math.max(BOARD2.springs.card.visualDuration * 1e3, E.artMs * 0.55 + typed);
1531
+ case "heading":
1532
+ return E.handMs + typed;
1533
+ case "link":
1534
+ return E.handMs + E.linkMs;
1535
+ case "track":
1536
+ return E.roadMs;
1537
+ case "frame":
1538
+ return E.frameMs * 1.4;
1539
+ case "sticker":
1540
+ return E.stickerMs;
1541
+ case "pill":
1542
+ return BOARD2.springs.stamp.visualDuration * 1e3;
1543
+ case "dot":
1544
+ return E.dotMs;
1545
+ case "cell":
1546
+ return E.cellMs;
1547
+ default:
1548
+ return 0;
1549
+ }
1550
+ }
1551
+ var pathOf = (p) => p.reduce((d, v, i) => i % 2 ? `${d} ${v}` : `${d}${i ? " L" : "M"} ${v}`, "");
1552
+ function smoothOf(p) {
1553
+ const n = p.length / 2;
1554
+ if (n < 2) return "";
1555
+ if (n === 2) return `M ${p[0]} ${p[1]} L ${p[2]} ${p[3]}`;
1556
+ const at = (i) => [p[Math.max(0, Math.min(n - 1, i)) * 2], p[Math.max(0, Math.min(n - 1, i)) * 2 + 1]];
1557
+ let d = `M ${p[0]} ${p[1]}`;
1558
+ for (let i = 0; i < n - 1; i++) {
1559
+ const [x0, y0] = at(i - 1), [x1, y1] = at(i), [x2, y2] = at(i + 1), [x3, y3] = at(i + 2);
1560
+ d += ` C ${x1 + (x2 - x0) / 6} ${y1 + (y2 - y0) / 6}, ${x2 - (x3 - x1) / 6} ${y2 - (y3 - y1) / 6}, ${x2} ${y2}`;
1561
+ }
1562
+ return d;
1563
+ }
1564
+ var ASK_SPRING = { visualDuration: 0.34, bounce: 0.08 };
1565
+ var ROUTE_NEXT = { auto: "elbow", elbow: "curve", curve: "straight", straight: "auto" };
1566
+ function geoOf(a, c, route) {
1567
+ if (route === "curve" || route === "straight") return boxArrow(a, c, route);
1568
+ const p = routeOf(a, c, true);
1569
+ const k = p.length;
1570
+ return {
1571
+ d: pathOf(p),
1572
+ mid: midOf(p),
1573
+ start: [p[0], p[1]],
1574
+ end: [p[k - 2], p[k - 1]],
1575
+ poly: p,
1576
+ endAngle: Math.atan2(p[k - 1] - p[k - 3], p[k - 2] - p[k - 4]),
1577
+ startAngle: Math.atan2(p[1] - p[3], p[0] - p[2])
1578
+ };
1579
+ }
1580
+ function polyGeo(p) {
1581
+ const k = p.length;
1582
+ return { d: pathOf(p), mid: midOf(p), start: [p[0], p[1]], end: [p[k - 2], p[k - 1]], poly: p, endAngle: Math.atan2(p[k - 1] - p[k - 3], p[k - 2] - p[k - 4]), startAngle: Math.atan2(p[1] - p[3], p[0] - p[2]) };
1583
+ }
1584
+ var midOf = (p) => {
1585
+ const k = p.length / 2;
1586
+ if (k === 2) return { x: (p[0] + p[2]) / 2, y: (p[1] + p[3]) / 2 };
1587
+ const i = Math.floor((k - 1) / 2) * 2;
1588
+ return { x: (p[i] + p[i + 2]) / 2, y: (p[i + 1] + p[i + 3]) / 2 };
1589
+ };
1590
+ var Art = memo2(function Art2({ name, className, size }) {
1591
+ if (isLineIcon(name)) return /* @__PURE__ */ jsx3("svg", { className: `${className} sp-wb-line-icon`, "aria-hidden": true, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round", style: size ? { width: size, height: size } : void 0, dangerouslySetInnerHTML: { __html: LINE_ICON_SVG[name] } });
1592
+ if (!isIllustration(name)) return null;
1593
+ return /* @__PURE__ */ jsx3("span", { className, "aria-hidden": true, style: size ? { width: size, height: size } : void 0, dangerouslySetInnerHTML: { __html: ILLUSTRATION_SVG[name] } });
1594
+ });
1595
+ var Svg = ({ children }) => /* @__PURE__ */ jsx3("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": true, children });
1596
+ var TOOL_ICON = {
1597
+ select: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M5 3.5 18 11l-6 1.6L9.4 19z" }) }),
1598
+ pan: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M8 11V5.5a1.5 1.5 0 0 1 3 0V11m0-1V4.5a1.5 1.5 0 0 1 3 0V11m0-.5V6.5a1.5 1.5 0 0 1 3 0V14a6 6 0 0 1-6 6h-.6a6 6 0 0 1-4.6-2.2L4 14.5a1.5 1.5 0 0 1 2.3-1.9L8 14.5" }) }),
1599
+ text: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M5 6V4.5h14V6M12 4.5v15M9 19.5h6" }) }),
1600
+ frame: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M8 3v18M16 3v18M3 8h18M3 16h18" }) }),
1601
+ note: /* @__PURE__ */ jsxs2(Svg, { children: [
1602
+ /* @__PURE__ */ jsx3("path", { d: "M5 4.5h14v9.5l-5.5 5.5H5z" }),
1603
+ /* @__PURE__ */ jsx3("path", { d: "M13.5 19.5V14H19" })
1604
+ ] }),
1605
+ pen: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "m15 5 4 4L8 20H4v-4z" }) }),
1606
+ link: /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M4 18 18 6M11 6h7v7" }) })
1607
+ };
1608
+ var SHAPE_ICON = /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("rect", { x: "4", y: "6", width: "16", height: "12", rx: "1" }) });
1609
+ var STICKER_ICON = /* @__PURE__ */ jsxs2(Svg, { children: [
1610
+ /* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "8.5" }),
1611
+ /* @__PURE__ */ jsx3("path", { d: "M9 10h.01M15 10h.01M8.5 14a4.5 4.5 0 0 0 7 0" })
1612
+ ] });
1613
+ var AGENT_ICON = /* @__PURE__ */ jsx3(Svg, { children: /* @__PURE__ */ jsx3("path", { d: "M5 12c3-5 4 5 7 0s4 5 7 0" }) });
1614
+ var HISTORY_ICON = /* @__PURE__ */ jsxs2(Svg, { children: [
1615
+ /* @__PURE__ */ jsx3("path", { d: "M4 12a8 8 0 1 0 2.4-5.7M4 4v4h4" }),
1616
+ /* @__PURE__ */ jsx3("path", { d: "M12 8v4l3 2" })
1617
+ ] });
1618
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
1619
+ var reveals = (s) => s.kind !== "change";
1620
+ function ShapeBg({ shape }) {
1621
+ if (shape === "cloud") return /* @__PURE__ */ jsx3("svg", { className: "sp-wb-shape-bg", viewBox: "0 0 100 62", preserveAspectRatio: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx3("path", { vectorEffect: "non-scaling-stroke", d: "M24 56C9 56 4 42 15 36 11 22 27 12 39 19 45 6 68 5 74 20 89 15 99 31 89 40 97 52 84 58 75 56Z" }) });
1622
+ if (shape === "cylinder") return /* @__PURE__ */ jsxs2("svg", { className: "sp-wb-shape-bg", viewBox: "0 0 100 100", preserveAspectRatio: "none", "aria-hidden": true, children: [
1623
+ /* @__PURE__ */ jsx3("path", { vectorEffect: "non-scaling-stroke", d: "M2 12V88A48 10 0 0 0 98 88V12" }),
1624
+ /* @__PURE__ */ jsx3("ellipse", { vectorEffect: "non-scaling-stroke", cx: "50", cy: "12", rx: "48", ry: "10" })
1625
+ ] });
1626
+ return null;
1627
+ }
1628
+ var Ink = memo2(function Ink2({ n, w, h }) {
1629
+ const pts = n.points ?? [];
1630
+ let x0 = Infinity, y0 = Infinity, x1 = 1, y1 = 1;
1631
+ for (let i = 0; i < pts.length; i += 2) {
1632
+ x0 = Math.min(x0, pts[i]);
1633
+ y0 = Math.min(y0, pts[i + 1]);
1634
+ x1 = Math.max(x1, pts[i]);
1635
+ y1 = Math.max(y1, pts[i + 1]);
1636
+ }
1637
+ const vw = x1 + (Number.isFinite(x0) ? Math.max(0, x0) : 0), vh = y1 + (Number.isFinite(y0) ? Math.max(0, y0) : 0);
1638
+ const brush = n.brush ?? "pena";
1639
+ const size = n.size === "l" || n.size === "xl" ? "l" : n.size === "m" ? "m" : "s";
1640
+ const st = useMemo(() => brushOf(n.id, pts, n.pressure, size, brush, n.weight), [n.id, pts, n.pressure, size, brush, n.weight]);
1641
+ return /* @__PURE__ */ jsx3("svg", { className: "sp-wb-ink", "data-brush": brush, width: w, height: h, viewBox: `0 0 ${vw} ${vh}`, preserveAspectRatio: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx3("path", { d: st.body }) });
1642
+ });
1643
+ var RoughOutline = memo2(function RoughOutline2({ id, shape, w, h }) {
1644
+ const paths = roughOutline(id, shape, w, h);
1645
+ return /* @__PURE__ */ jsx3("svg", { className: "sp-wb-rough", "data-rough": shape, width: w, height: h, viewBox: `0 0 ${Math.round(w)} ${Math.round(h)}`, "aria-hidden": true, children: paths.map((d, i) => /* @__PURE__ */ jsx3("path", { d, pathLength: 1 }, i)) });
1646
+ });
1647
+ var TEXTY = /* @__PURE__ */ new Set(["text", "pill", "dot", "cell", "sticker"]);
1648
+ function Track({ n, w, h }) {
1649
+ const d = smoothOf(n.points ?? []);
1650
+ return /* @__PURE__ */ jsxs2("svg", { className: "sp-wb-track", width: w, height: h, viewBox: `0 0 ${w} ${h}`, "aria-hidden": true, children: [
1651
+ /* @__PURE__ */ jsx3("path", { className: "sp-wb-track-edge", d, pathLength: 1 }),
1652
+ /* @__PURE__ */ jsx3("path", { className: "sp-wb-track-road", d, pathLength: 1 })
1653
+ ] });
1654
+ }
1655
+ var LINK_CHAR = 19 * BOARD.draw.sketch.lower * BOARD.draw.sketch.wrapSlack;
1656
+ function sketchVars(shape, size = "m") {
1657
+ const S = SKETCH, px = (n) => `${n}px`;
1658
+ if (shape === "text") {
1659
+ const t2 = S.words[size];
1660
+ return { "--sp-wb-fs": px(t2.size), "--sp-wb-lh": px(t2.lh), "--sp-wb-case": t2.upper ? "uppercase" : "none" };
1661
+ }
1662
+ const t = S.block[size];
1663
+ return { "--sp-wb-ts": px(t.title), "--sp-wb-tl": px(t.titleLh), "--sp-wb-fs": px(t.text), "--sp-wb-lh": px(t.textLh), "--sp-wb-is": px(t.icon), "--sp-wb-pad": px(S.pad) };
1664
+ }
1665
+ var draftOf = (n) => {
1666
+ const s = shapeOf(n);
1667
+ if (TEXTY.has(s) || s === "note" && !n.title) return n.text;
1668
+ return n.title ? n.text ? `${n.title}
1669
+ ${n.text}` : n.title : n.text;
1670
+ };
1671
+ var Item = memo2(function Item2({ n, selected, hot, born, leaving, leaveDelay, drag, dx, dy, w, h, target, editing, inked, pending, enter, onCommit, onCancel }) {
1672
+ const shape = shapeOf(n);
1673
+ const [draft, setDraft] = useState3(() => draftOf(n));
1674
+ useEffect3(() => {
1675
+ if (editing) setDraft(draftOf(n));
1676
+ }, [editing]);
1677
+ const label = n.title ? `${n.title}. ${n.text}` : n.text;
1678
+ return /* @__PURE__ */ jsxs2(
1679
+ "div",
1680
+ {
1681
+ className: "sp-wb-note",
1682
+ "data-note": n.id,
1683
+ "data-shape": shape,
1684
+ "data-color": n.color,
1685
+ "data-size": shape === "text" ? n.size ?? "m" : void 0,
1686
+ "data-big": shape === "text" || shape === "sticker" || n.pen || h < BOARD2.big.h ? void 0 : w >= BOARD2.big.xl ? "xl" : w >= BOARD2.big.l ? "l" : void 0,
1687
+ "data-icon": (isIllustration(n.icon) || isLineIcon(n.icon)) && shape !== "sticker" ? "" : void 0,
1688
+ "data-pen": n.pen,
1689
+ "data-dashed": n.dashed || void 0,
1690
+ "data-selected": selected || void 0,
1691
+ "data-hot": hot || void 0,
1692
+ "data-born": born && !enter && !pending || void 0,
1693
+ "data-leaving": leaving || void 0,
1694
+ "data-moving": drag || void 0,
1695
+ "data-target": target || void 0,
1696
+ "data-pending": pending || void 0,
1697
+ "data-enter": enter,
1698
+ "aria-hidden": pending || void 0,
1699
+ tabIndex: 0,
1700
+ role: "button",
1701
+ "aria-label": shape === "ink" ? WB.inkAria : WB.itemAria(shape === "note" ? WB.note : shape === "text" ? WB.text : WB.shape, label.slice(0, BOARD2.labelAria)),
1702
+ "aria-pressed": selected,
1703
+ style: {
1704
+ translate: `${n.x + dx}px ${n.y + dy}px`,
1705
+ width: w,
1706
+ height: h,
1707
+ ...leaveDelay ? { animationDelay: `${leaveDelay}ms` } : {},
1708
+ // A title or heading types at a steady pace, so its length sets how long it takes.
1709
+ ...enter ? { "--sp-wb-chars": String(Math.max(4, Math.min(60, (n.title || n.text).length))) } : {},
1710
+ ...n.pen ? sketchVars(shape, n.size) : {}
1711
+ },
1712
+ children: [
1713
+ /* @__PURE__ */ jsx3(ShapeBg, { shape }),
1714
+ (inked || n.pen || isPolygon(shape)) && (isBoxy(shape) || shape === "cell" || n.pen && shape === "pill") && /* @__PURE__ */ jsx3(RoughOutline, { id: n.id, shape, w, h }),
1715
+ shape === "ink" ? /* @__PURE__ */ jsx3(Ink, { n, w, h }) : shape === "track" ? /* @__PURE__ */ jsx3(Track, { n, w, h }) : editing ? /* @__PURE__ */ jsx3(
1716
+ "textarea",
1717
+ {
1718
+ className: "sp-wb-edit",
1719
+ dir: "auto",
1720
+ autoFocus: true,
1721
+ value: draft,
1722
+ maxLength: BOARD2.noteMax,
1723
+ "aria-label": isBoxy(shape) || shape === "note" ? WB.titleAndBody : WB.body,
1724
+ placeholder: isBoxy(shape) ? WB.title : shape === "text" ? WB.text : WB.note,
1725
+ onChange: (e) => setDraft(e.target.value),
1726
+ onBlur: () => onCommit(n.id, draft),
1727
+ onKeyDown: (e) => {
1728
+ e.stopPropagation();
1729
+ if (e.key === "Escape") onCancel();
1730
+ else if (e.key === "Enter" && (e.metaKey || e.ctrlKey || TEXTY.has(shape) && !e.shiftKey)) {
1731
+ e.preventDefault();
1732
+ e.target.blur();
1733
+ }
1734
+ }
1735
+ }
1736
+ ) : shape === "sticker" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
1737
+ /* @__PURE__ */ jsx3(Art, { name: n.icon, className: "sp-wb-sticker", size: Math.round(Math.min(w, h - (n.text ? BOARD2.stickerCaption : 0)) * BOARD2.stickerScale) }),
1738
+ n.text && /* @__PURE__ */ jsx3("span", { className: "sp-wb-caption", dir: "auto", children: n.text })
1739
+ ] }) : shape === "pill" || shape === "dot" ? /* @__PURE__ */ jsx3("span", { className: "sp-wb-tag", dir: "auto", children: n.text }) : shape === "cell" ? n.text ? /* @__PURE__ */ jsx3("span", { className: "sp-wb-cell-label", dir: "auto", children: n.text }) : null : shape === "note" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
1740
+ /* @__PURE__ */ jsx3(Art, { name: n.icon, className: "sp-wb-icon" }),
1741
+ n.title && /* @__PURE__ */ jsx3("strong", { className: "sp-wb-title-line", dir: "auto", children: n.title }),
1742
+ /* @__PURE__ */ jsx3("p", { className: "sp-wb-text", dir: "auto", style: { WebkitLineClamp: Math.max(BOARD2.noteLines.min, Math.floor((h - BOARD2.noteLines.chrome - wrapLines(n.title, STICKY_DATA.titleCharW, w - STICKY_DATA.pad) * STICKY_DATA.titleLh) / BOARD2.noteLines.lh)) }, children: n.text || !n.title && /* @__PURE__ */ jsx3("span", { className: "sp-wb-placeholder", children: WB.emptyNote }) }),
1743
+ (n.owner || n.due) && /* @__PURE__ */ jsx3("p", { className: "sp-wb-meta", dir: "auto", children: [n.owner ? WB.owner(n.owner) : null, n.due ? WB.due(n.due) : null].filter(Boolean).join(" \xB7 ") }),
1744
+ /* @__PURE__ */ jsx3("p", { className: "sp-wb-by", dir: "auto", children: n.by })
1745
+ ] }) : shape === "text" ? /* @__PURE__ */ jsx3("p", { className: "sp-wb-text", dir: "auto", children: n.text || /* @__PURE__ */ jsx3("span", { className: "sp-wb-placeholder", children: WB.text }) }) : /* @__PURE__ */ jsxs2("div", { className: "sp-wb-body", style: isPolygon(shape) ? { padding: polygonPad(shape, w, h).map((v) => `${v + SKETCH.pad}px`).join(" ") } : void 0, children: [
1746
+ /* @__PURE__ */ jsx3(Art, { name: n.icon, className: "sp-wb-icon" }),
1747
+ n.title && /* @__PURE__ */ jsx3("strong", { dir: "auto", children: n.title }),
1748
+ n.text && /* @__PURE__ */ jsx3("span", { dir: "auto", children: n.text }),
1749
+ !n.title && !n.text && !n.icon && /* @__PURE__ */ jsx3("span", { className: "sp-wb-placeholder", children: WB.shape }),
1750
+ (n.owner || n.due) && /* @__PURE__ */ jsx3("em", { dir: "auto", children: [n.owner ? WB.owner(n.owner) : null, n.due].filter(Boolean).join(" \xB7 ") })
1751
+ ] }),
1752
+ !editing && /* @__PURE__ */ jsx3("span", { className: "sp-wb-resize", "data-resize": n.id, "aria-hidden": true, title: WB.resize })
1753
+ ]
1754
+ }
1755
+ );
1756
+ });
1757
+ var FrameBox = memo2(function FrameBox2({ f, dx, dy, w, h, target, hot, born, leaving, leaveDelay, editing, inked, pending, enter, onCommit, onCancel }) {
1758
+ const [draft, setDraft] = useState3(f.title);
1759
+ useEffect3(() => {
1760
+ if (editing) setDraft(f.title);
1761
+ }, [editing, f.title]);
1762
+ return (
1763
+ // A section with no name is an open area (a timeline, a free cluster): no card around it, the content stands alone.
1764
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-frame", "data-open": !f.title && !editing || void 0, "data-target": target || void 0, "data-hot": hot || void 0, "data-born": born && !enter && !pending || void 0, "data-leaving": leaving || void 0, "data-pending": pending || void 0, "data-enter": enter, style: { translate: `${f.x + dx}px ${f.y + dy}px`, width: w, height: h, ...leaveDelay ? { animationDelay: `${leaveDelay}ms` } : {} }, children: [
1765
+ inked && f.title && /* @__PURE__ */ jsx3(RoughOutline, { id: f.id, shape: "frame", w, h }),
1766
+ /* @__PURE__ */ jsx3("div", { className: "sp-wb-frame-head", "data-frame": f.id, title: WB.frameHead, children: editing ? /* @__PURE__ */ jsx3(
1767
+ "input",
1768
+ {
1769
+ className: "sp-wb-frame-input",
1770
+ dir: "auto",
1771
+ autoFocus: true,
1772
+ value: draft,
1773
+ maxLength: INPUT_MAX.frameName,
1774
+ "aria-label": WB.frameName,
1775
+ onChange: (e) => setDraft(e.target.value),
1776
+ onBlur: () => onCommit(f.id, draft),
1777
+ onKeyDown: (e) => {
1778
+ e.stopPropagation();
1779
+ if (e.key === "Escape") onCancel();
1780
+ else if (e.key === "Enter") e.target.blur();
1781
+ }
1782
+ }
1783
+ ) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
1784
+ /* @__PURE__ */ jsx3("strong", { dir: "auto", children: f.title || WB.untitled }),
1785
+ f.subtitle && /* @__PURE__ */ jsx3("span", { dir: "auto", children: f.subtitle })
1786
+ ] }) }),
1787
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-resize", "data-resize": f.id, "data-resize-frame": true, "aria-hidden": true, title: WB.resizeFrame })
1788
+ ] })
1789
+ );
1790
+ });
1791
+ function Links({ b, rect, selected, preview, inked, hidden, enter }) {
1792
+ const autos = autoWires(b.links);
1793
+ const items = autos.length ? obstacles(b.notes) : null;
1794
+ if (items) for (const [id, it] of items) {
1795
+ const r = rect(id);
1796
+ if (r) items.set(id, { ...it, x: r.x, y: r.y, w: r.w, h: r.h });
1797
+ }
1798
+ const sig = items ? [...items.values()].map((r) => `${Math.round(r.x)},${Math.round(r.y)},${Math.round(r.w)},${Math.round(r.h)}`).join(";") + "|" + autos.map((l) => `${l.from}>${l.to}:${l.label ?? ""}`).join(";") : "";
1799
+ const routed = useMemo(() => items ? routeWires(items, autos.map((l) => ({ from: l.from, to: l.to, ...l.label ? { label: l.label } : {} })), wireLabel) : /* @__PURE__ */ new Map(), [sig]);
1800
+ if (!b.links.length && !preview) return null;
1801
+ return /* @__PURE__ */ jsxs2("svg", { className: "sp-wb-links", width: "1", height: "1", "aria-hidden": true, children: [
1802
+ b.links.map((l) => {
1803
+ if (hidden.has(l.id) || hidden.has(l.from) || hidden.has(l.to)) return null;
1804
+ const a = rect(l.from), c = rect(l.to);
1805
+ if (!a || !c) return null;
1806
+ const auto = l.route === "auto" ? routed.get(autos.indexOf(l)) : void 0;
1807
+ const g = auto ? polyGeo(auto.pts) : geoOf(a, c, l.route);
1808
+ const m = auto?.label ? { x: auto.label.x + auto.label.w / 2, y: auto.label.y + auto.label.h / 2 } : g.mid;
1809
+ const arrow = l.arrow ?? "end";
1810
+ const on = selected === l.id;
1811
+ const rough2 = inked && !on && !l.dashed ? roughLine(l.id, g) : null;
1812
+ return /* @__PURE__ */ jsxs2("g", { className: "sp-wb-link-g", "data-selected": on || void 0, "data-dashed": l.dashed || void 0, "data-thin": arrow === "none" || void 0, "data-route": l.route ?? "elbow", "data-layer": l.layer || void 0, "data-inked": rough2 ? "" : void 0, "data-enter": enter.get(l.id), children: [
1813
+ rough2 ? rough2.map((d, i) => /* @__PURE__ */ jsx3("path", { d, className: "sp-wb-link-line", pathLength: enter.has(l.id) ? 1 : void 0 }, i)) : /* @__PURE__ */ jsx3("path", { d: g.d, className: "sp-wb-link-line", pathLength: enter.has(l.id) ? 1 : void 0 }),
1814
+ arrow !== "none" && /* @__PURE__ */ jsx3("path", { d: headPath(g.end[0], g.end[1], g.endAngle), className: "sp-wb-arrowhead" }),
1815
+ arrow === "both" && /* @__PURE__ */ jsx3("path", { d: headPath(g.start[0], g.start[1], g.startAngle), className: "sp-wb-arrowhead" }),
1816
+ l.route === "curve" && arrow === "end" && /* @__PURE__ */ jsx3("circle", { cx: g.start[0], cy: g.start[1], r: 3.5, className: "sp-wb-link-tail" }),
1817
+ /* @__PURE__ */ jsx3("path", { d: g.d, className: "sp-wb-link-hit", "data-link": l.id }),
1818
+ l.label && /* @__PURE__ */ jsxs2("g", { transform: `translate(${m.x} ${m.y})`, className: "sp-wb-link-label", children: [
1819
+ /* @__PURE__ */ jsx3("rect", { x: -(l.label.length * LINK_CHAR / 2 + 12), y: -15, width: l.label.length * LINK_CHAR + 24, height: 30, rx: 8 }),
1820
+ /* @__PURE__ */ jsx3("text", { textAnchor: "middle", dy: "4", children: l.label })
1821
+ ] }),
1822
+ on && /* @__PURE__ */ jsxs2(Fragment2, { children: [
1823
+ /* @__PURE__ */ jsx3("circle", { cx: g.start[0], cy: g.start[1], r: 4, className: "sp-wb-link-end" }),
1824
+ /* @__PURE__ */ jsx3("circle", { cx: g.end[0], cy: g.end[1], r: 4, className: "sp-wb-link-end" })
1825
+ ] })
1826
+ ] }, l.id);
1827
+ }),
1828
+ preview && (() => {
1829
+ const p = routeOf(preview.a, { x: preview.x, y: preview.y, w: 1, h: 1 }, true), k = p.length;
1830
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
1831
+ /* @__PURE__ */ jsx3("path", { className: "sp-wb-link-preview", d: pathOf(p) }),
1832
+ /* @__PURE__ */ jsx3("path", { className: "sp-wb-arrowhead", d: headPath(p[k - 2], p[k - 1], Math.atan2(p[k - 1] - p[k - 3], p[k - 2] - p[k - 4])) })
1833
+ ] });
1834
+ })()
1835
+ ] });
1836
+ }
1837
+ var TOOLS = [
1838
+ { id: "select", label: WB.tools.select, key: "V" },
1839
+ { id: "pan", label: WB.tools.pan, key: "H" },
1840
+ { id: "text", label: WB.tools.text, key: "T" },
1841
+ { id: "frame", label: WB.tools.frame, key: "F" },
1842
+ { id: "note", label: WB.tools.note, key: "N" },
1843
+ { id: "pen", label: WB.tools.pen, key: "P" },
1844
+ { id: "shape", label: WB.tools.shape, key: "S" },
1845
+ { id: "link", label: WB.tools.link, key: "A" }
1846
+ ];
1847
+ var KEY_TOOL = { v: "select", h: "pan", t: "text", f: "frame", n: "note", p: "pen", s: "shape", a: "link" };
1848
+ function Whiteboard({ boardId, boardRef: reference, title, transport, preview, onAsk }) {
1849
+ const data = { boardId, ref: reference, preview };
1850
+ const ctx2 = { onAsk: onAsk ?? (() => {
1851
+ }) };
1852
+ const { board: latest, error, saving, apply: applyLive, reload, boost, activity, remote, history, at, restore, pendingBatch, keepBatch, undoBatch } = useBoard(transport, boardId, preview);
1853
+ const [m, send] = useReducer(machine, initialMachine);
1854
+ const [scrubBoard, setScrubBoard] = useState3(null);
1855
+ const board = scrubBoard ?? latest;
1856
+ const readOnly = m.scrub !== null || !!m.replay;
1857
+ const readOnlyRef = useRef3(readOnly);
1858
+ readOnlyRef.current = readOnly;
1859
+ const ownEditAt = useRef3(0);
1860
+ const apply = useCallback2((ops) => {
1861
+ if (!readOnlyRef.current) {
1862
+ ownEditAt.current = Date.now();
1863
+ applyLive(ops);
1864
+ }
1865
+ }, [applyLive]);
1866
+ const viewRef = useRef3(null);
1867
+ const bottomRef = useRef3(BOARD2.fitBottom);
1868
+ const changeRef = useRef3(null);
1869
+ const [askOpen, setAskOpen] = useState3(false);
1870
+ const [view, setView] = useState3(BOARD2.startView);
1871
+ const [size, setSize] = useState3(BOARD2.startSize);
1872
+ const [tool, setTool] = useState3("select");
1873
+ const [boxShape, setBoxShape] = useState3("box");
1874
+ const [menu, setMenu] = useState3(null);
1875
+ const [inkColor, setInkColor] = useState3("ink");
1876
+ const [inkSize, setInkSize] = useState3("m");
1877
+ const [inkBrush, setInkBrush] = useState3("pena");
1878
+ const [look, setLook] = useState3("ink");
1879
+ useEffect3(() => {
1880
+ try {
1881
+ const v = localStorage.getItem(BOARD2.styleKey(data.boardId));
1882
+ if (v === "neat" || v === "ink") setLook(v);
1883
+ } catch {
1884
+ }
1885
+ }, [data.boardId]);
1886
+ const pickLook = (v) => {
1887
+ setLook(v);
1888
+ try {
1889
+ localStorage.setItem(BOARD2.styleKey(data.boardId), v);
1890
+ } catch {
1891
+ }
1892
+ };
1893
+ const inked = look === "ink";
1894
+ const [sound, setSound] = useState3(false);
1895
+ useEffect3(() => {
1896
+ setSound(soundOn());
1897
+ }, []);
1898
+ const [tempo, setTempo] = useState3(BOARD2.tempo.default);
1899
+ useEffect3(() => {
1900
+ setTempo(readTempo());
1901
+ }, []);
1902
+ const tf = factorOf(tempo);
1903
+ const tRef = useRef3(tf);
1904
+ tRef.current = tf;
1905
+ const vars = useMemo(() => tempoVars(tf), [tf]);
1906
+ const [full, setFull] = useState3(false);
1907
+ const [selected, setSelected] = useState3(/* @__PURE__ */ new Set());
1908
+ const [link, setLink] = useState3(null);
1909
+ const [editing, setEditing] = useState3(null);
1910
+ const [moving, setMoving] = useState3(null);
1911
+ const [sizing, setSizing] = useState3(null);
1912
+ const [linking, setLinking] = useState3(null);
1913
+ const [marquee, setMarquee] = useState3(null);
1914
+ const [pen, setPen] = useState3(false);
1915
+ const penPath = useRef3(null);
1916
+ const [seen, setSeen] = useState3(/* @__PURE__ */ new Set());
1917
+ const [question, setQuestion] = useState3("");
1918
+ const [change, setChange] = useState3("");
1919
+ const [labelDraft, setLabelDraft] = useState3(null);
1920
+ const [, setTick] = useState3(0);
1921
+ const drag = useRef3(null);
1922
+ const boardRef = useRef3(board);
1923
+ boardRef.current = board;
1924
+ const viewState = useRef3(view);
1925
+ viewState.current = view;
1926
+ const fitted = useRef3(false);
1927
+ const hasBoard = !!board;
1928
+ const known = useRef3(null);
1929
+ const born = useRef3(/* @__PURE__ */ new Set());
1930
+ if (board) {
1931
+ const ids = [...board.notes.map((n) => n.id), ...board.frames.map((f) => f.id)];
1932
+ if (!known.current) known.current = new Set(ids);
1933
+ else for (const id of ids) if (!known.current.has(id)) {
1934
+ known.current.add(id);
1935
+ born.current.add(id);
1936
+ }
1937
+ }
1938
+ const reduce = useReducedMotion();
1939
+ const glides = useRef3(/* @__PURE__ */ new Map());
1940
+ const shownAt = useRef3(/* @__PURE__ */ new Map());
1941
+ const leaving = useRef3(/* @__PURE__ */ new Map());
1942
+ const undoOrder = useRef3(null);
1943
+ const prevBoard = useRef3(null);
1944
+ const [frameNow, setFrameNow] = useState3(0);
1945
+ if (board && board !== prevBoard.current) {
1946
+ const before = prevBoard.current;
1947
+ if (before && !reduce) {
1948
+ const now = performance.now();
1949
+ for (const r of [...board.notes, ...board.frames]) {
1950
+ const at2 = shownAt.current.get(r.id);
1951
+ if (!at2 || moving?.ids.has(r.id)) continue;
1952
+ const fx = at2.x - r.x, fy = at2.y - r.y;
1953
+ if (Math.abs(fx) > 0.5 || Math.abs(fy) > 0.5) glides.current.set(r.id, { fx, fy, t0: now });
1954
+ }
1955
+ const ids = /* @__PURE__ */ new Set([...board.notes.map((n) => n.id), ...board.frames.map((f) => f.id)]);
1956
+ const order = undoOrder.current;
1957
+ undoOrder.current = null;
1958
+ const gap = order ? tRef.current * Math.max(BOARD2.choreo.minMs / 2, Math.min(BOARD2.choreo.maxMs / 2, BOARD2.choreo.totalMs / 2 / Math.max(1, order.length))) : 0;
1959
+ const delayOf = (id) => order ? Math.max(0, order.indexOf(id)) * gap : 0;
1960
+ for (const n of before.notes) if (!ids.has(n.id)) leaving.current.set(n.id, { item: n, frame: false, t0: now + delayOf(n.id), delay: delayOf(n.id) });
1961
+ for (const f of before.frames) if (!ids.has(f.id)) leaving.current.set(f.id, { item: f, frame: true, t0: now + delayOf(f.id), delay: delayOf(f.id) });
1962
+ }
1963
+ prevBoard.current = board;
1964
+ }
1965
+ const glideOf = (id) => {
1966
+ const g = glides.current.get(id);
1967
+ if (!g) return [0, 0];
1968
+ const t = Math.max(0, Math.min(1, (frameNow - g.t0) / (D.d4 * 1e3)));
1969
+ const k = Math.pow(1 - t, 4);
1970
+ return [g.fx * k, g.fy * k];
1971
+ };
1972
+ const animating = glides.current.size > 0 || leaving.current.size > 0;
1973
+ useEffect3(() => {
1974
+ if (!animating) return;
1975
+ let raf2 = 0;
1976
+ const tick = (now) => {
1977
+ for (const [id, g] of glides.current) if (now - g.t0 >= D.d4 * 1e3) glides.current.delete(id);
1978
+ for (const [id, l] of leaving.current) if (now - l.t0 >= D.d2 * 1e3) leaving.current.delete(id);
1979
+ setFrameNow(now);
1980
+ if (glides.current.size || leaving.current.size) raf2 = requestAnimationFrame(tick);
1981
+ };
1982
+ raf2 = requestAnimationFrame(tick);
1983
+ return () => cancelAnimationFrame(raf2);
1984
+ }, [animating, board]);
1985
+ useEffect3(() => {
1986
+ const el = viewRef.current;
1987
+ if (!el) return;
1988
+ const ro = new ResizeObserver(() => setSize({ w: el.clientWidth, h: el.clientHeight }));
1989
+ ro.observe(el);
1990
+ return () => ro.disconnect();
1991
+ }, [hasBoard]);
1992
+ const world = useCallback2((cx, cy) => {
1993
+ const r = viewRef.current.getBoundingClientRect();
1994
+ const v = viewState.current;
1995
+ return { x: (cx - r.left - v.x) / v.z, y: (cy - r.top - v.y) / v.z };
1996
+ }, []);
1997
+ const reduceRef = useRef3(reduce);
1998
+ reduceRef.current = reduce;
1999
+ const glide = useRef3(null);
2000
+ const flight = useRef3(null);
2001
+ const stopGlide = useCallback2(() => {
2002
+ if (glide.current) {
2003
+ cancelAnimationFrame(glide.current.raf);
2004
+ glide.current = null;
2005
+ }
2006
+ if (flight.current) {
2007
+ cancelAnimationFrame(flight.current.raf);
2008
+ flight.current = null;
2009
+ }
2010
+ }, []);
2011
+ useEffect3(() => stopGlide, [stopGlide]);
2012
+ const glideTo = useCallback2((to, anchor = null) => {
2013
+ if (reduceRef.current) {
2014
+ stopGlide();
2015
+ setView(to);
2016
+ return;
2017
+ }
2018
+ if (glide.current) {
2019
+ glide.current.to = to;
2020
+ glide.current.anchor = anchor;
2021
+ return;
2022
+ }
2023
+ const g = { raf: 0, to, anchor, last: performance.now() };
2024
+ glide.current = g;
2025
+ const step2 = (now) => {
2026
+ const k = 1 - Math.exp(-Math.min(BOARD2.glideFrameCapMs, now - g.last) / BOARD2.glideTauMs);
2027
+ g.last = now;
2028
+ const v = viewState.current, t = g.to;
2029
+ const z = Math.exp(Math.log(v.z) + (Math.log(t.z) - Math.log(v.z)) * k);
2030
+ const a = g.anchor;
2031
+ const next = a ? { z, x: a.px - a.wx * z, y: a.py - a.wy * z } : { z, x: v.x + (t.x - v.x) * k, y: v.y + (t.y - v.y) * k };
2032
+ const done = Math.abs(next.z - t.z) < 1e-4 && Math.abs(next.x - t.x) < 0.3 && Math.abs(next.y - t.y) < 0.3;
2033
+ const shown = done ? t : next;
2034
+ viewState.current = shown;
2035
+ setView(shown);
2036
+ if (done) glide.current = null;
2037
+ else g.raf = requestAnimationFrame(step2);
2038
+ };
2039
+ g.raf = requestAnimationFrame(step2);
2040
+ }, [stopGlide]);
2041
+ const flyTo = useCallback2((to) => {
2042
+ const el = viewRef.current;
2043
+ if (reduceRef.current || !el) {
2044
+ stopGlide();
2045
+ setView(to);
2046
+ viewState.current = to;
2047
+ return;
2048
+ }
2049
+ const s = { w: el.clientWidth, h: el.clientHeight };
2050
+ if (!isLongMove(viewState.current, to, s)) {
2051
+ glideTo(to);
2052
+ return;
2053
+ }
2054
+ stopGlide();
2055
+ const path = zoomPath(viewState.current, to, s, { minMs: BOARD2.flight.minMs * tRef.current, maxMs: BOARD2.flight.maxMs * tRef.current });
2056
+ const t0 = performance.now();
2057
+ const f = { raf: 0 };
2058
+ flight.current = f;
2059
+ const step2 = (now) => {
2060
+ if (flight.current !== f) return;
2061
+ const t = Math.min(1, (now - t0) / path.ms);
2062
+ const v = path.at(t);
2063
+ viewState.current = v;
2064
+ setView(v);
2065
+ if (t < 1) f.raf = requestAnimationFrame(step2);
2066
+ else flight.current = null;
2067
+ };
2068
+ f.raf = requestAnimationFrame(step2);
2069
+ }, [glideTo, stopGlide]);
2070
+ const panBy = useCallback2((f) => {
2071
+ userMoved.current = true;
2072
+ stopGlide();
2073
+ setView(f);
2074
+ }, [stopGlide]);
2075
+ const fitTo = useCallback2((bb, maxZ = 1) => {
2076
+ const el = viewRef.current;
2077
+ if (!el) return;
2078
+ if (!bb) {
2079
+ flyTo(BOARD2.homeView);
2080
+ return;
2081
+ }
2082
+ const w = el.clientWidth, h = el.clientHeight, pad = BOARD2.fitPad;
2083
+ const z = clampZ(Math.min(maxZ, (w - pad * 2) / (bb.x1 - bb.x0 || 1), (h - pad * 2 - bottomRef.current) / (bb.y1 - bb.y0 || 1)));
2084
+ flyTo({ z, x: (w - (bb.x1 - bb.x0) * z) / 2 - bb.x0 * z, y: pad + BOARD2.fitTop - bb.y0 * z });
2085
+ }, [flyTo]);
2086
+ const fit = useCallback2(() => {
2087
+ const b = boardRef.current;
2088
+ if (b) fitTo(bounds([...b.frames, ...b.notes]));
2089
+ }, [fitTo]);
2090
+ const fitZoom = useCallback2((bb, maxZ = 1) => {
2091
+ const el = viewRef.current;
2092
+ if (!el) return 0;
2093
+ return clampZ(Math.min(maxZ, (el.clientWidth - BOARD2.fitPad * 2) / (bb.x1 - bb.x0 || 1), (el.clientHeight - BOARD2.fitPad * 2 - bottomRef.current) / (bb.y1 - bb.y0 || 1)));
2094
+ }, []);
2095
+ const readFit = useCallback2(() => {
2096
+ const b = boardRef.current, el = viewRef.current;
2097
+ if (!b || !el) return;
2098
+ const bb = bounds([...b.frames, ...b.notes]);
2099
+ if (!bb) {
2100
+ flyTo(BOARD2.homeView);
2101
+ return;
2102
+ }
2103
+ flyTo(readableView(bb, { w: el.clientWidth, h: el.clientHeight }, BOARD2.readZoom, BOARD2.fitPad, BOARD2.fitTop, bottomRef.current));
2104
+ }, [flyTo]);
2105
+ const readFitRef = useRef3(readFit);
2106
+ readFitRef.current = readFit;
2107
+ const overview = useCallback2(() => {
2108
+ const b = boardRef.current, el = viewRef.current;
2109
+ if (!b || !el) return;
2110
+ const bb = bounds([...b.frames, ...b.notes]);
2111
+ if (!bb) {
2112
+ flyTo(BOARD2.homeView);
2113
+ return;
2114
+ }
2115
+ flyTo(readableView(bb, { w: el.clientWidth, h: el.clientHeight }, BOARD2.overviewZoom, BOARD2.fitPad, BOARD2.fitTop, bottomRef.current));
2116
+ }, [flyTo]);
2117
+ const userMoved = useRef3(false);
2118
+ const open = useCallback2(() => {
2119
+ const b = boardRef.current, el = viewRef.current;
2120
+ if (!b || !el || !el.clientWidth) return;
2121
+ const bb = bounds([...b.frames, ...b.notes]);
2122
+ if (!bb) {
2123
+ setView(BOARD2.homeView);
2124
+ return;
2125
+ }
2126
+ const w = el.clientWidth, h = el.clientHeight, pad = BOARD2.widthPad, width = bb.x1 - bb.x0 || 1, height = bb.y1 - bb.y0 || 1;
2127
+ const fitW = (w - pad * 2) / width, fitH = (h - pad - BOARD2.fitTop - bottomRef.current) / height;
2128
+ const z = clampZ(Math.max(BOARD2.readZoom, Math.min(1, fitW, fitH >= fitW * 0.6 ? fitH : fitW)));
2129
+ setView({ z, x: width * z <= w - pad * 2 ? (w - width * z) / 2 - bb.x0 * z : pad - bb.x0 * z, y: BOARD2.fitTop + pad / 2 - bb.y0 * z });
2130
+ }, []);
2131
+ useEffect3(() => {
2132
+ if (board && !fitted.current) {
2133
+ fitted.current = true;
2134
+ requestAnimationFrame(open);
2135
+ }
2136
+ }, [board, open]);
2137
+ useEffect3(() => {
2138
+ if (fitted.current && !userMoved.current) open();
2139
+ }, [size.w, size.h, open]);
2140
+ const wasFull = useRef3(full);
2141
+ useEffect3(() => {
2142
+ if (wasFull.current !== full) {
2143
+ wasFull.current = full;
2144
+ requestAnimationFrame(full ? overview : readFit);
2145
+ }
2146
+ }, [full, readFit, overview]);
2147
+ const zoomBy = useCallback2((k, cx, cy, instant = false) => {
2148
+ const el = viewRef.current;
2149
+ if (!el) return;
2150
+ userMoved.current = true;
2151
+ const r = el.getBoundingClientRect();
2152
+ const px = cx === void 0 ? el.clientWidth / 2 : cx - r.left, py = cy === void 0 ? el.clientHeight / 2 : cy - r.top;
2153
+ if (instant) {
2154
+ panBy((v2) => {
2155
+ const z2 = clampZ(v2.z * k);
2156
+ return { z: z2, x: px - (px - v2.x) / v2.z * z2, y: py - (py - v2.y) / v2.z * z2 };
2157
+ });
2158
+ return;
2159
+ }
2160
+ const base = glide.current?.to ?? viewState.current, v = viewState.current;
2161
+ const wx = (px - v.x) / v.z, wy = (py - v.y) / v.z;
2162
+ const z = clampZ(base.z * k);
2163
+ glideTo({ z, x: px - wx * z, y: py - wy * z }, { px, py, wx, wy });
2164
+ }, [glideTo, panBy]);
2165
+ useEffect3(() => {
2166
+ const el = viewRef.current;
2167
+ if (!el) return;
2168
+ const onWheel = (e) => {
2169
+ e.preventDefault();
2170
+ const notch = e.deltaMode !== 0 || Math.abs(e.deltaY) >= BOARD2.wheelNotch;
2171
+ if (e.ctrlKey || e.metaKey) zoomBy(Math.exp(-e.deltaY * (e.deltaMode === 1 ? BOARD2.wheelLinePx : 1) * BOARD2.wheelZoom), e.clientX, e.clientY, !notch);
2172
+ else panBy((v) => ({ ...v, x: v.x - e.deltaX, y: v.y - e.deltaY }));
2173
+ };
2174
+ el.addEventListener("wheel", onWheel, { passive: false });
2175
+ return () => el.removeEventListener("wheel", onWheel);
2176
+ }, [zoomBy, panBy, hasBoard]);
2177
+ useEffect3(() => {
2178
+ if (!full) return;
2179
+ const onKey = (e) => {
2180
+ if (e.key === "Escape" && !editing) setFull(false);
2181
+ };
2182
+ window.addEventListener("keydown", onKey);
2183
+ return () => window.removeEventListener("keydown", onKey);
2184
+ }, [full, editing]);
2185
+ useEffect3(() => {
2186
+ if (!menu) return;
2187
+ const close = (e) => {
2188
+ if (!e.target.closest(".sp-wb-pop, [data-menu]")) setMenu(null);
2189
+ };
2190
+ document.addEventListener("pointerdown", close);
2191
+ return () => document.removeEventListener("pointerdown", close);
2192
+ }, [menu]);
2193
+ const cursorX = useMotionValue(0), cursorY = useMotionValue(0), cursorPress = useMotionValue(0);
2194
+ const cursorFlight = useRef3(null);
2195
+ const flyCursor = useCallback2((to, ms = BOARD2.springs.cursor.visualDuration * 1e3 * tRef.current) => {
2196
+ cursorFlight.current?.stop();
2197
+ const from = { x: cursorX.get(), y: cursorY.get() };
2198
+ if (reduceRef.current || Math.hypot(to.x - from.x, to.y - from.y) < 1) {
2199
+ cursorX.set(to.x);
2200
+ cursorY.set(to.y);
2201
+ return;
2202
+ }
2203
+ cursorFlight.current = animate(0, 1, {
2204
+ type: "spring",
2205
+ visualDuration: ms / 1e3,
2206
+ bounce: BOARD2.springs.cursor.bounce,
2207
+ onUpdate: (t) => {
2208
+ const p = arcPoint(from, to, t, BOARD2.cursorArc);
2209
+ cursorX.set(p.x);
2210
+ cursorY.set(p.y);
2211
+ }
2212
+ });
2213
+ }, [cursorX, cursorY]);
2214
+ const handFollow = useCallback2((st, k) => {
2215
+ const view2 = viewRef.current, b = boardRef.current;
2216
+ if (reduceRef.current || !view2 || !b) return;
2217
+ const E = BOARD2.enter;
2218
+ requestAnimationFrame(() => {
2219
+ const phases = [];
2220
+ let last2 = { x: cursorX.get(), y: cursorY.get() };
2221
+ const glide2 = (to, ms) => {
2222
+ const from = last2;
2223
+ last2 = to;
2224
+ phases.push({ ms, at: (q) => {
2225
+ const e = 1 - (1 - q) ** 3;
2226
+ return { x: from.x + (to.x - from.x) * e, y: from.y + (to.y - from.y) * e };
2227
+ } });
2228
+ };
2229
+ const trace = (el, o, ms, ease) => {
2230
+ const len = el?.getTotalLength() ?? 0;
2231
+ if (!el || !len) return;
2232
+ const p0 = el.getPointAtLength(0), pe = el.getPointAtLength(len);
2233
+ glide2({ x: o.x + p0.x, y: o.y + p0.y }, E.handMs * k);
2234
+ phases.push({ ms, at: (q) => {
2235
+ const p = el.getPointAtLength(len * ease(q));
2236
+ return { x: o.x + p.x, y: o.y + p.y };
2237
+ } });
2238
+ last2 = { x: o.x + pe.x, y: o.y + pe.y };
2239
+ };
2240
+ const writeAll = (root, at2, blocks, lead) => {
2241
+ const parts = blocks.flatMap(({ el, ms }) => {
2242
+ let ox = 0, oy = 0, p = el;
2243
+ while (p && p !== root) {
2244
+ ox += p.offsetLeft;
2245
+ oy += p.offsetTop;
2246
+ p = p.offsetParent;
2247
+ }
2248
+ const br = el.getBoundingClientRect(), s = br.width ? el.offsetWidth / br.width : 1, H = el.offsetHeight;
2249
+ const r = document.createRange();
2250
+ r.selectNodeContents(el);
2251
+ const lines = [];
2252
+ for (const q of r.getClientRects()) {
2253
+ if (!q.width) continue;
2254
+ const l = { x0: (q.left - br.left) * s, x1: (q.right - br.left) * s, y0: (q.top - br.top) * s, y1: (q.bottom - br.top) * s };
2255
+ if (l.y0 > H) continue;
2256
+ const same = lines.find((m2) => Math.abs(m2.y0 - l.y0) < 3);
2257
+ if (same) {
2258
+ same.x0 = Math.min(same.x0, l.x0);
2259
+ same.x1 = Math.max(same.x1, l.x1);
2260
+ same.y1 = Math.max(same.y1, l.y1);
2261
+ } else lines.push(l);
2262
+ }
2263
+ if (!lines.length) return [];
2264
+ lines.sort((u, v) => u.y0 - v.y0);
2265
+ el.style.clipPath = "inset(0 100% 100% 0)";
2266
+ return [{ el, ox, oy, lines, ms, w: el.offsetWidth }];
2267
+ });
2268
+ if (!parts.length) return;
2269
+ root.dataset.typing = "";
2270
+ const show = () => {
2271
+ for (const p of parts) p.el.style.clipPath = "";
2272
+ };
2273
+ let first = true;
2274
+ parts.forEach((p, pi) => {
2275
+ const width = p.lines.reduce((t, l) => t + (l.x1 - l.x0), 0) || 1;
2276
+ p.lines.forEach((l, li) => {
2277
+ const y = at2.y + p.oy + (l.y0 + l.y1) / 2, x0 = at2.x + p.ox + l.x0;
2278
+ glide2({ x: x0, y }, first ? lead : E.lineHopMs * k);
2279
+ first = false;
2280
+ const done = p.lines.slice(0, li).reduce((m2, o) => Math.max(m2, o.y1), 0);
2281
+ phases.push({ ms: p.ms * ((l.x1 - l.x0) / width), at: (q) => {
2282
+ for (const o of parts.slice(0, pi)) if (o.el.style.clipPath) o.el.style.clipPath = "";
2283
+ const xc = l.x0 + (l.x1 - l.x0) * q;
2284
+ p.el.style.clipPath = `polygon(-4px -4px, ${p.w + 4}px -4px, ${p.w + 4}px ${done}px, ${xc}px ${done}px, ${xc}px ${l.y1 + 4}px, -4px ${l.y1 + 4}px)`;
2285
+ if (q >= 1 && li === p.lines.length - 1) p.el.style.clipPath = "";
2286
+ return { x: at2.x + p.ox + xc, y };
2287
+ } });
2288
+ last2 = { x: at2.x + p.ox + l.x1, y };
2289
+ });
2290
+ });
2291
+ const total2 = phases.reduce((t, ph) => t + ph.ms, 0);
2292
+ setTimeout(show, total2 + 600);
2293
+ };
2294
+ const draw = cubicBezier(0.45, 0, 0.25, 1);
2295
+ if (st.kind === "link") trace(view2.querySelector(`[data-link="${CSS.escape(st.id)}"]`), { x: 0, y: 0 }, E.linkMs * k, draw);
2296
+ else {
2297
+ const n = b.notes.find((x) => x.id === st.id), box = view2.querySelector(`[data-note="${CSS.escape(st.id)}"]`);
2298
+ if (!n || !box) return;
2299
+ const ty = typingMs(n, st.kind === "heading");
2300
+ const pick = (sel, ms) => {
2301
+ const el = box.querySelector(sel);
2302
+ return el && ms ? [{ el, ms: ms * k }] : [];
2303
+ };
2304
+ if (st.kind === "heading") writeAll(box, n, pick(".sp-wb-text", ty.title), E.handMs * k);
2305
+ else if (st.kind === "card") {
2306
+ const meta = box.querySelector(".sp-wb-meta, .sp-wb-body > em");
2307
+ writeAll(box, n, [
2308
+ ...pick(".sp-wb-title-line, .sp-wb-body > strong", ty.title),
2309
+ ...pick(".sp-wb-text, .sp-wb-body > span:not(.sp-wb-icon):not(.sp-wb-placeholder)", ty.body),
2310
+ ...meta ? [{ el: meta, ms: Math.min(E.bodyMaxMs, (meta.textContent ?? "").length * 1e3 / E.bodyCps) * k }] : []
2311
+ ], E.artMs * 0.55 * k);
2312
+ }
2313
+ }
2314
+ if (!phases.length) return;
2315
+ const total = phases.reduce((t, p) => t + p.ms, 0);
2316
+ const keep = (at2) => {
2317
+ const el = viewRef.current;
2318
+ if (!el || flight.current || !agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) return;
2319
+ const v = viewState.current, w = el.clientWidth, h = el.clientHeight - bottomRef.current;
2320
+ const sx = at2.x * v.z + v.x, sy = at2.y * v.z + v.y;
2321
+ const tx = sx > w * 0.8 ? v.x - (sx - w * 0.55) : sx < w * 0.1 ? v.x + (w * 0.3 - sx) : v.x;
2322
+ const ty = sy > h * 0.8 ? v.y - (sy - h * 0.55) : sy < h * 0.1 ? v.y + (h * 0.3 - sy) : v.y;
2323
+ if (tx !== v.x || ty !== v.y) glideTo({ z: v.z, x: tx, y: ty });
2324
+ };
2325
+ cursorFlight.current?.stop();
2326
+ cursorFlight.current = animate(0, 1, {
2327
+ duration: total / 1e3,
2328
+ ease: "linear",
2329
+ onUpdate: (t) => {
2330
+ let e = t * total;
2331
+ for (const p of phases) {
2332
+ if (e <= p.ms || p === phases[phases.length - 1]) {
2333
+ const at2 = p.at(p.ms ? Math.min(1, e / p.ms) : 1);
2334
+ cursorX.set(at2.x);
2335
+ cursorY.set(at2.y);
2336
+ keep(at2);
2337
+ return;
2338
+ }
2339
+ e -= p.ms;
2340
+ }
2341
+ }
2342
+ });
2343
+ });
2344
+ }, [cursorX, cursorY, glideTo]);
2345
+ const press = useCallback2(() => {
2346
+ if (reduceRef.current) return;
2347
+ void animate(cursorPress, [0, BOARD2.cursorPressPx, 0], { duration: 0.28 * tRef.current, ease: "easeInOut" });
2348
+ }, [cursorPress]);
2349
+ const lastInput = useRef3(0);
2350
+ const pending = useRef3(/* @__PURE__ */ new Set());
2351
+ const entering = useRef3(/* @__PURE__ */ new Map());
2352
+ const choreoIds = useRef3(/* @__PURE__ */ new Set());
2353
+ const [, setBeat] = useState3(0);
2354
+ const beat = useCallback2(() => setBeat((x) => x + 1), []);
2355
+ const play = useRef3(null);
2356
+ const settleTimers = useRef3([]);
2357
+ const [cursor, setCursor] = useState3(null);
2358
+ const sayAt = useRef3(/* @__PURE__ */ new Map());
2359
+ const beatAt = useRef3(/* @__PURE__ */ new Map());
2360
+ const agentLiveRef = useRef3(false);
2361
+ const speedRef = useRef3(1), pausedRef = useRef3(false);
2362
+ speedRef.current = m.replay?.speed ?? 1;
2363
+ const replayingRef = useRef3(false);
2364
+ replayingRef.current = !!m.replay;
2365
+ pausedRef.current = !!m.replay?.paused;
2366
+ const finish = useCallback2((natural = false) => {
2367
+ const p = play.current;
2368
+ if (!p) return;
2369
+ if (p.timer) clearTimeout(p.timer);
2370
+ if (p.reveal) clearTimeout(p.reveal);
2371
+ play.current = null;
2372
+ if (natural && p.agent && p.steps.length > 2 && !replayingRef.current) chime();
2373
+ pending.current.clear();
2374
+ sayAt.current.clear();
2375
+ beatAt.current.clear();
2376
+ if (natural && p.told && !replayingRef.current && !agentLiveRef.current && agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) readFitRef.current();
2377
+ settleTimers.current.push(setTimeout(() => {
2378
+ entering.current.clear();
2379
+ choreoIds.current.clear();
2380
+ beat();
2381
+ }, BOARD2.choreo.enterMs * tRef.current));
2382
+ setCursor(null);
2383
+ beat();
2384
+ send({ type: "played" });
2385
+ p.done?.();
2386
+ }, [beat]);
2387
+ const choreograph = useCallback2((steps, label, agent = true, from, told = false) => {
2388
+ const shown = steps.slice(0, BOARD2.choreo.maxSteps);
2389
+ if (reduceRef.current || !shown.length) {
2390
+ for (const st of shown) pending.current.delete(st.id);
2391
+ return Promise.resolve();
2392
+ }
2393
+ const running = play.current;
2394
+ for (const st of shown) if (reveals(st)) {
2395
+ pending.current.add(st.id);
2396
+ choreoIds.current.add(st.id);
2397
+ }
2398
+ if (told) beatAt.current.set(shown[0].id, shown.map((s) => s.id));
2399
+ if (running) {
2400
+ running.steps.push(...shown);
2401
+ running.told = told;
2402
+ sayAt.current.set(shown[0].id, label);
2403
+ return new Promise((r) => {
2404
+ const prev = running.done;
2405
+ running.done = () => {
2406
+ prev?.();
2407
+ r();
2408
+ };
2409
+ });
2410
+ }
2411
+ const start = from ?? { x: shown[0].at.x - 80, y: shown[0].at.y - 60 };
2412
+ cursorFlight.current?.stop();
2413
+ cursorX.set(start.x);
2414
+ cursorY.set(start.y);
2415
+ setCursor({ label, agent, told });
2416
+ return new Promise((resolve) => {
2417
+ const p = { steps: shown, i: 0, timer: null, reveal: null, done: resolve, agent, told };
2418
+ play.current = p;
2419
+ const next = () => {
2420
+ if (play.current !== p) return;
2421
+ if (pausedRef.current) {
2422
+ p.timer = setTimeout(next, BOARD2.choreo.minMs);
2423
+ return;
2424
+ }
2425
+ const st = p.steps[p.i];
2426
+ if (!st) {
2427
+ finish(true);
2428
+ return;
2429
+ }
2430
+ const say = sayAt.current.get(st.id);
2431
+ if (say !== void 0) {
2432
+ sayAt.current.delete(st.id);
2433
+ setCursor((c) => c ? { ...c, label: say, told: p.told } : c);
2434
+ }
2435
+ const beatIds = beatAt.current.get(st.id);
2436
+ let framed = false;
2437
+ if (beatIds) {
2438
+ beatAt.current.delete(st.id);
2439
+ const ids = new Set(beatIds), b = boardRef.current;
2440
+ const bb = b ? bounds(b.notes.filter((n) => ids.has(n.id) && n.shape !== "ink")) : null;
2441
+ const M = BOARD2.tell.margin, box = bb && { x0: bb.x0 - M, y0: bb.y0 - M, x1: bb.x1 + M, y1: bb.y1 + M };
2442
+ if (box && agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs) && fitZoom(box, BOARD2.tell.zoom) >= BOARD2.readZoom) {
2443
+ fitTo(box, BOARD2.tell.zoom);
2444
+ framed = true;
2445
+ }
2446
+ }
2447
+ const k = tRef.current / speedRef.current, C = BOARD2.choreo;
2448
+ const pace2 = paceOf(p.steps.length, C.totalMs, C.minMs, C.maxMs) * k;
2449
+ const flightMs = Math.min(C.flightMaxMs * k, Math.max(C.flightMinMs * k, pace2 * 0.9));
2450
+ flyCursor(st.at, flightMs);
2451
+ const el = viewRef.current, v = viewState.current;
2452
+ if (el && !framed && agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) {
2453
+ const s = { w: el.clientWidth, h: el.clientHeight }, it = boardRef.current?.notes.find((x) => x.id === st.id);
2454
+ const room = (s.h - bottomRef.current) * 0.8, wide = s.w * 0.85;
2455
+ const font = it ? smallestFont(el, it.id) : 0;
2456
+ const zRead = font ? BOARD2.readPx / font : BOARD2.readZoom;
2457
+ const want = clampZ(Math.max(zRead, it ? Math.min(1, wide / it.w, room / it.h) : zRead));
2458
+ const z = Math.abs(Math.log(v.z / want)) < 0.15 ? v.z : want;
2459
+ const target = it ? { x: it.w * z > wide ? it.x + s.w * 0.42 / z : it.x + it.w / 2, y: it.h * z > room ? it.y + room / 2 / z : it.y + it.h / 2 } : st.at;
2460
+ const box = it && { x0: it.x, y0: it.y, x1: it.x + Math.min(it.w, wide / z), y1: it.y + Math.min(it.h, room / z) };
2461
+ if (z !== v.z || stepCamera(v, s, target, bottomRef.current, BOARD2.followInset) === "follow" || box && planCamera(v, s, box, bottomRef.current) === "overview") {
2462
+ flyTo(centreOn(target, { ...v, z }, s, bottomRef.current));
2463
+ }
2464
+ }
2465
+ const said = p.told ? null : WB.stepLabel[st.kind];
2466
+ if (said) setCursor((c) => c && c.label !== said ? { ...c, label: said } : c);
2467
+ const revealAt = Math.max(C.minMs / 2 * k, flightMs - C.leadMs * k);
2468
+ p.reveal = setTimeout(() => {
2469
+ if (play.current !== p) return;
2470
+ pending.current.delete(st.id);
2471
+ if (reveals(st)) entering.current.set(st.id, st.kind);
2472
+ press();
2473
+ if (st.kind === "pill") thud();
2474
+ beat();
2475
+ handFollow(st, k);
2476
+ }, revealAt);
2477
+ p.i += 1;
2478
+ const settled = revealAt + entranceMs(st, boardRef.current) * k + C.holdMs * k;
2479
+ p.timer = setTimeout(next, p.i >= p.steps.length ? Math.max(pace2, settled) + C.enterMs * k : Math.max(pace2, settled));
2480
+ };
2481
+ p.timer = setTimeout(next, BOARD2.choreo.minMs * tRef.current / speedRef.current);
2482
+ beat();
2483
+ });
2484
+ }, [beat, cursorX, cursorY, finish, fitTo, fitZoom, flyCursor, flyTo, handFollow, press]);
2485
+ useEffect3(() => () => {
2486
+ const p = play.current;
2487
+ if (p?.timer) clearTimeout(p.timer);
2488
+ play.current = null;
2489
+ for (const t of settleTimers.current) clearTimeout(t);
2490
+ }, []);
2491
+ const onions = useRef3([]);
2492
+ const deleted = useRef3(/* @__PURE__ */ new Map());
2493
+ const seenLatest = useRef3(null);
2494
+ const kick = useRef3(null);
2495
+ const tellOnOpen = useRef3(false);
2496
+ const [telling, setTelling] = useState3(false);
2497
+ const scrubRef = useRef3(scrubBoard);
2498
+ scrubRef.current = scrubBoard;
2499
+ if (latest && latest !== seenLatest.current) {
2500
+ const before = seenLatest.current;
2501
+ seenLatest.current = latest;
2502
+ let steps = [];
2503
+ let label = "";
2504
+ let told = false;
2505
+ if (!before) {
2506
+ const first = latest.edits[0];
2507
+ if (first?.agent && !data.preview && !reduce && Date.now() - Date.parse(latest.createdAt) < BOARD2.buildFreshMs) {
2508
+ let played = null;
2509
+ try {
2510
+ played = JSON.parse(sessionStorage.getItem(BOARD2.playedKey) ?? "[]");
2511
+ } catch {
2512
+ played = null;
2513
+ }
2514
+ if (played && !played.includes(latest.id)) {
2515
+ try {
2516
+ sessionStorage.setItem(BOARD2.playedKey, JSON.stringify([...played, latest.id].slice(-50)));
2517
+ } catch {
2518
+ }
2519
+ const told_ = latest.edits.some((e) => e.told);
2520
+ if (told_ && !freshActivity(activity, Date.now(), BOARD2.activityFreshMs)?.agent) {
2521
+ tellOnOpen.current = true;
2522
+ setScrubBoard({ ...latest, frames: [], notes: [], links: [] });
2523
+ } else {
2524
+ told = told_;
2525
+ steps = stepsOf(diffBoards(null, latest), latest, told);
2526
+ label = latest.edits.at(-1)?.what || first.what || WB.agentBuilding;
2527
+ }
2528
+ }
2529
+ }
2530
+ } else if (latest === remote.current && !scrubBoard && latest.edits.at(-1)?.agent) {
2531
+ const d = diffBoards(before, latest);
2532
+ told = !!latest.edits.at(-1)?.told;
2533
+ steps = stepsOf(d, latest, told);
2534
+ label = latest.edits.at(-1)?.what || WB.agentBuilding;
2535
+ if (!reduce) {
2536
+ const t = Date.now();
2537
+ const was = (id) => before.notes.find((n) => n.id === id) ?? before.frames.find((f) => f.id === id);
2538
+ for (const mv of d.moved.slice(0, BOARD2.choreo.maxSteps)) {
2539
+ const r = was(mv.id);
2540
+ if (r) onions.current.push({ id: `${mv.id}@${t}`, x: r.x, y: r.y, w: r.w, h: r.h, title: "title" in r ? r.title ?? "" : "", at: t });
2541
+ }
2542
+ const batch = latest.edits.at(-1)?.batch;
2543
+ if (batch) for (const r of [...d.removed.notes, ...d.removed.frames]) deleted.current.set(r.id, { x: r.x, y: r.y, w: r.w, h: r.h, title: ("title" in r ? r.title : "") || ("text" in r ? r.text : ""), batch });
2544
+ }
2545
+ }
2546
+ if (steps.length && !reduce) {
2547
+ for (const st of steps.slice(0, BOARD2.choreo.maxSteps)) if (reveals(st)) {
2548
+ pending.current.add(st.id);
2549
+ choreoIds.current.add(st.id);
2550
+ }
2551
+ kick.current = kick.current ? { steps: [...kick.current.steps, ...steps], label, told } : { steps, label, told };
2552
+ }
2553
+ }
2554
+ const gestureActive = !!moving || !!sizing || pen || !!marquee || !!linking || !!editing;
2555
+ const gestureRef = useRef3(gestureActive);
2556
+ gestureRef.current = gestureActive;
2557
+ useEffect3(() => {
2558
+ send({ type: "gesture", on: gestureActive });
2559
+ }, [gestureActive]);
2560
+ useEffect3(() => {
2561
+ if (latest) send({ type: "loaded" });
2562
+ }, [!!latest]);
2563
+ useEffect3(() => {
2564
+ if (error && !latest) send({ type: "error", message: error });
2565
+ }, [error, latest]);
2566
+ useEffect3(() => {
2567
+ if (!kick.current || gestureActive) return;
2568
+ let inner = 0;
2569
+ const outer = requestAnimationFrame(() => {
2570
+ inner = requestAnimationFrame(() => {
2571
+ const k = kick.current;
2572
+ if (!k) return;
2573
+ kick.current = null;
2574
+ send({ type: "incoming", steps: true });
2575
+ void choreograph(k.steps, k.label, true, void 0, k.told);
2576
+ });
2577
+ });
2578
+ return () => {
2579
+ cancelAnimationFrame(outer);
2580
+ cancelAnimationFrame(inner);
2581
+ };
2582
+ }, [latest, gestureActive, choreograph]);
2583
+ useEffect3(() => {
2584
+ const t = setInterval(() => {
2585
+ if (play.current || kick.current || !pending.current.size) return;
2586
+ pending.current.clear();
2587
+ beat();
2588
+ }, BOARD2.choreo.totalMs + BOARD2.choreo.enterMs);
2589
+ return () => clearInterval(t);
2590
+ }, [beat]);
2591
+ const [, setNowTick] = useState3(0);
2592
+ useEffect3(() => {
2593
+ send({ type: "activity", activity });
2594
+ if (!activity) return;
2595
+ const left = Date.parse(activity.at) + BOARD2.activityFreshMs - Date.now();
2596
+ if (left <= 0) return;
2597
+ const t = setTimeout(() => setNowTick((x) => x + 1), left + BOARD2.presenceSlackMs);
2598
+ return () => clearTimeout(t);
2599
+ }, [activity]);
2600
+ const freshNow = readOnly ? null : freshActivity(activity, Date.now(), BOARD2.activityFreshMs);
2601
+ const live = freshNow && !freshNow.agent && Date.now() - ownEditAt.current < BOARD2.activityFreshMs ? null : freshNow;
2602
+ agentLiveRef.current = !!live?.agent;
2603
+ const agentLive = !!live?.agent;
2604
+ useEffect3(() => {
2605
+ if (agentLive || play.current || !boardRef.current?.edits.at(-1)?.told) return;
2606
+ if (agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) readFitRef.current();
2607
+ }, [agentLive]);
2608
+ const mode = modeOf(m, Date.now(), BOARD2.activityFreshMs);
2609
+ const planKeep = useRef3(null);
2610
+ const livePlan = live?.agent ? live.plan : void 0;
2611
+ if (livePlan?.length) planKeep.current = livePlan;
2612
+ else if (!play.current && !kick.current) planKeep.current = null;
2613
+ const present = useMemo(() => new Set(board ? [...board.notes.map((n) => n.id), ...board.frames.map((f) => f.id)] : []), [board]);
2614
+ const footprints = readOnly || board?.edits.at(-1)?.told ? [] : liveFootprints(planKeep.current, present, pending.current);
2615
+ const planKey = livePlan?.length ? `${live?.batch ?? live?.at}|${live?.what}|${livePlan.length}` : "";
2616
+ useEffect3(() => {
2617
+ const el = viewRef.current, pb = planBounds(livePlan);
2618
+ if (!el || !agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) return;
2619
+ const v = viewState.current;
2620
+ if (!planKey || !pb || board?.edits.at(-1)?.told) return;
2621
+ if (planCamera(v, { w: el.clientWidth, h: el.clientHeight }, pb, bottomRef.current) === "overview") fitTo(pb, v.z);
2622
+ }, [planKey]);
2623
+ useEffect3(() => {
2624
+ if (!onions.current.length) return;
2625
+ const t = setTimeout(() => {
2626
+ const now = Date.now();
2627
+ onions.current = onions.current.filter((o) => now - o.at < BOARD2.onionMs);
2628
+ beat();
2629
+ }, BOARD2.onionMs + 50);
2630
+ return () => clearTimeout(t);
2631
+ });
2632
+ useEffect3(() => {
2633
+ const el = viewRef.current;
2634
+ if (!el) return;
2635
+ const mark = () => {
2636
+ lastInput.current = Date.now();
2637
+ };
2638
+ el.addEventListener("pointerdown", mark, { capture: true });
2639
+ el.addEventListener("wheel", mark, { passive: true });
2640
+ el.addEventListener("keydown", mark);
2641
+ return () => {
2642
+ el.removeEventListener("pointerdown", mark, { capture: true });
2643
+ el.removeEventListener("wheel", mark);
2644
+ el.removeEventListener("keydown", mark);
2645
+ };
2646
+ }, [hasBoard]);
2647
+ const [batchUi, setBatchUi] = useState3({ state: "idle", error: null });
2648
+ const shownBatch = useRef3(null);
2649
+ if (pendingBatch) shownBatch.current = pendingBatch;
2650
+ else if (batchUi.state !== "kept") shownBatch.current = null;
2651
+ for (const [id, g] of deleted.current) if (g.batch !== pendingBatch?.id) deleted.current.delete(id);
2652
+ useEffect3(() => {
2653
+ setBatchUi({ state: "idle", error: null });
2654
+ }, [pendingBatch?.id]);
2655
+ const keepPending = async () => {
2656
+ const b = pendingBatch;
2657
+ if (!b || batchUi.state !== "idle") return;
2658
+ setBatchUi({ state: "keeping", error: null });
2659
+ const err = await keepBatch(b.id);
2660
+ if (err) {
2661
+ setBatchUi({ state: "idle", error: err });
2662
+ return;
2663
+ }
2664
+ thud();
2665
+ setBatchUi({ state: "kept", error: null });
2666
+ setTimeout(() => setBatchUi((u) => u.state === "kept" ? { state: "idle", error: null } : u), BOARD2.choreo.enterMs * 2);
2667
+ };
2668
+ const undoPending = async () => {
2669
+ const b = pendingBatch, cur = latest;
2670
+ if (!b || !cur || batchUi.state !== "idle") return;
2671
+ setBatchUi({ state: "undoing", error: null });
2672
+ const keys = new Set(b.keys);
2673
+ undoOrder.current = stepsOf(diffBoards(null, { notes: cur.notes.filter((n) => keys.has(n.id)), frames: cur.frames.filter((f) => keys.has(f.id)), links: [] }), cur).map((st) => st.id).reverse();
2674
+ const err = await undoBatch(b.id);
2675
+ if (err) {
2676
+ undoOrder.current = null;
2677
+ setBatchUi({ state: "idle", error: err });
2678
+ return;
2679
+ }
2680
+ setBatchUi({ state: "idle", error: null });
2681
+ };
2682
+ const [histOpen, setHistOpen] = useState3(false);
2683
+ bottomRef.current = BOARD2.fitBottom + (histOpen ? BOARD2.historyRoom : 0);
2684
+ useEffect3(() => {
2685
+ if (!userMoved.current) readFitRef.current?.();
2686
+ }, [histOpen]);
2687
+ const [hist, setHist] = useState3(null);
2688
+ const [histLoading, setHistLoading] = useState3(false);
2689
+ const [caption, setCaption] = useState3(null);
2690
+ const [restoring, setRestoring] = useState3(false);
2691
+ const [histNote, setHistNote] = useState3(null);
2692
+ const replayCancel = useRef3(false);
2693
+ useEffect3(() => () => {
2694
+ replayCancel.current = true;
2695
+ }, []);
2696
+ const loadHistory = useCallback2(async () => {
2697
+ setHistLoading(true);
2698
+ const h = await history();
2699
+ setHist(h);
2700
+ setHistLoading(false);
2701
+ return h;
2702
+ }, [history]);
2703
+ useEffect3(() => {
2704
+ if (histOpen) void loadHistory();
2705
+ }, [histOpen, latest?.version, loadHistory]);
2706
+ const entryOf = (v) => hist?.find((e) => e.version === v) ?? null;
2707
+ const showVersion = useCallback2(async (v) => {
2708
+ if (!latest) return;
2709
+ if (v === latest.version) {
2710
+ toLatestRef.current();
2711
+ return;
2712
+ }
2713
+ const target = await at(v);
2714
+ if (!target) {
2715
+ setHistNote(WB.versionMissing);
2716
+ return;
2717
+ }
2718
+ setHistNote(null);
2719
+ const before = scrubRef.current ?? latest;
2720
+ const e = hist?.find((x) => x.version === v);
2721
+ finish();
2722
+ send({ type: "scrub", version: v });
2723
+ void choreograph(stepsOf(diffBoards(before, target), target), e ? e.agent ? WB.agentWorking(e.what) : WB.personWorking(e.by, e.what) : WB.viewing(v), e?.agent ?? true);
2724
+ setScrubBoard(target);
2725
+ setCaption(null);
2726
+ }, [latest, at, hist, finish, choreograph]);
2727
+ const toLatestRef = useRef3(() => {
2728
+ });
2729
+ toLatestRef.current = () => {
2730
+ replayCancel.current = true;
2731
+ setTelling(false);
2732
+ finish();
2733
+ const before = scrubRef.current;
2734
+ send({ type: "latest" });
2735
+ setCaption(null);
2736
+ if (before && latest) void choreograph(stepsOf(diffBoards(before, latest), latest), WB.latest, false);
2737
+ setScrubBoard(null);
2738
+ };
2739
+ const runReplay = useCallback2(async () => {
2740
+ if (!latest) return;
2741
+ const h = hist ?? await loadHistory();
2742
+ replayCancel.current = false;
2743
+ finish();
2744
+ send({ type: "replay" });
2745
+ let shown = { ...latest, frames: [], notes: [], links: [] };
2746
+ setScrubBoard(shown);
2747
+ const versions = h?.length ? h.filter((e) => e.version >= earliestRebuildable(h)) : [{ version: latest.version, at: latest.updatedAt, by: latest.updatedBy, agent: !!latest.edits.at(-1)?.agent, what: WB.agentBuilding, why: latest.title, keys: [] }];
2748
+ setTelling(versions.some((e) => e.told));
2749
+ for (const e of versions) {
2750
+ while (pausedRef.current && !replayCancel.current) await sleep(BOARD2.choreo.maxMs);
2751
+ if (replayCancel.current) return;
2752
+ const b = e.version === latest.version ? latest : await at(e.version);
2753
+ if (replayCancel.current) return;
2754
+ if (!b) continue;
2755
+ send({ type: "scrub", version: e.version });
2756
+ setCaption({ text: e.why || e.what, version: e.version });
2757
+ const el = viewRef.current, fresh = e.told ? b.notes.filter((n) => !shown.notes.some((o) => o.id === n.id) && n.shape !== "ink") : [];
2758
+ if (el && fresh.length && agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) {
2759
+ const M = BOARD2.tell.margin, bb = bounds(fresh);
2760
+ const box = bb && { x0: bb.x0 - M, y0: bb.y0 - M, x1: bb.x1 + M, y1: bb.y0 - M + (bb.x1 - bb.x0 + M * 2) * BOARD2.tell.aspect };
2761
+ if (box && fitZoom(box, BOARD2.tell.zoom) >= BOARD2.readZoom) fitTo(box, BOARD2.tell.zoom);
2762
+ }
2763
+ const done = choreograph(stepsOf(diffBoards(shown, b), b, !!e.told), e.agent ? WB.agentWorking(e.what) : WB.personWorking(e.by, e.what), e.agent, void 0, !!e.told);
2764
+ setScrubBoard(b);
2765
+ shown = b;
2766
+ await done;
2767
+ await sleep(BOARD2.replay.holdMs * tRef.current / speedRef.current);
2768
+ }
2769
+ if (replayCancel.current) return;
2770
+ send({ type: "replayDone" });
2771
+ setCaption(null);
2772
+ setScrubBoard(null);
2773
+ setTelling(false);
2774
+ if (agentMayMove(lastInput.current, Date.now(), BOARD2.userWinsMs)) readFitRef.current();
2775
+ }, [latest, hist, loadHistory, at, finish, choreograph, fitTo, fitZoom]);
2776
+ const runReplayRef = useRef3(runReplay);
2777
+ runReplayRef.current = runReplay;
2778
+ useEffect3(() => {
2779
+ if (!tellOnOpen.current || !latest) return;
2780
+ tellOnOpen.current = false;
2781
+ setTelling(true);
2782
+ const t = setTimeout(() => void runReplayRef.current(), BOARD2.tell.startMs);
2783
+ return () => clearTimeout(t);
2784
+ }, [latest]);
2785
+ const restoreShown = async () => {
2786
+ if (m.scrub === null) return;
2787
+ setRestoring(true);
2788
+ const ok = await restore(m.scrub);
2789
+ setRestoring(false);
2790
+ if (!ok) return;
2791
+ replayCancel.current = true;
2792
+ finish();
2793
+ setScrubBoard(null);
2794
+ setCaption(null);
2795
+ send({ type: "latest" });
2796
+ void loadHistory();
2797
+ };
2798
+ const last = board?.edits.at(-1);
2799
+ const hot = useMemo(() => new Set(last?.agent ? last.keys : []), [last]);
2800
+ const markLayer = useRef3(null);
2801
+ const markView = useRef3(null);
2802
+ const titleRef = useRef3(null);
2803
+ const hotKey = last?.agent && last.keys.length ? `${last.at}|${last.keys.join(",")}` : "";
2804
+ useEffect3(() => {
2805
+ const layer = markLayer.current, b = boardRef.current;
2806
+ if (!hotKey || !layer || !b) return;
2807
+ const v = viewState.current;
2808
+ markView.current = v;
2809
+ layer.style.transform = "none";
2810
+ const ids = [...hot].filter((id) => !seen.has(id) && !choreoIds.current.has(id)).slice(0, BOARD2.notation.max);
2811
+ const color = getComputedStyle(layer).getPropertyValue("--sp-stamp").trim() || BOARD2.notation.stamp;
2812
+ const marks = [];
2813
+ const els = [];
2814
+ let gone = false;
2815
+ const clear = () => {
2816
+ for (const m2 of marks.splice(0)) m2.remove();
2817
+ for (const el of els.splice(0)) el.remove();
2818
+ };
2819
+ void import("rough-notation").then(({ annotate }) => {
2820
+ if (gone) return;
2821
+ for (const id of ids) {
2822
+ const r = b.frames.find((f) => f.id === id) ?? b.notes.find((n) => n.id === id);
2823
+ if (!r) continue;
2824
+ const el = document.createElement("span");
2825
+ el.className = "sp-wb-mark";
2826
+ el.style.cssText = `left:${v.x + r.x * v.z}px;top:${v.y + r.y * v.z}px;width:${r.w * v.z}px;height:${r.h * v.z}px`;
2827
+ layer.appendChild(el);
2828
+ els.push(el);
2829
+ const round = "shape" in r && (r.shape === "sticker" || r.shape === "pill" || r.shape === "dot" || r.shape === "ellipse");
2830
+ const m2 = annotate(el, { type: round ? "circle" : "box", color, animate: !reduceRef.current, animationDuration: BOARD2.notation.drawMs, padding: BOARD2.notation.pad, strokeWidth: BOARD2.notation.stroke, iterations: 1 });
2831
+ m2.show();
2832
+ marks.push(m2);
2833
+ }
2834
+ });
2835
+ const t = setTimeout(clear, BOARD2.notation.holdMs);
2836
+ return () => {
2837
+ gone = true;
2838
+ clearTimeout(t);
2839
+ clear();
2840
+ };
2841
+ }, [hotKey]);
2842
+ const underlined = useRef3(false);
2843
+ useEffect3(() => {
2844
+ const el = titleRef.current;
2845
+ if (!board || underlined.current || !el) return;
2846
+ underlined.current = true;
2847
+ let gone = false, mark = null;
2848
+ const color = getComputedStyle(el).getPropertyValue("--sp-stamp").trim() || BOARD2.notation.stamp;
2849
+ void import("rough-notation").then(({ annotate }) => {
2850
+ if (gone) return;
2851
+ mark = annotate(el, { type: "underline", color, animate: !reduceRef.current, animationDuration: BOARD2.notation.drawMs, strokeWidth: BOARD2.notation.stroke, padding: 1, iterations: 1 });
2852
+ mark.show();
2853
+ });
2854
+ const t = setTimeout(() => mark?.remove(), BOARD2.notation.holdMs);
2855
+ return () => {
2856
+ gone = true;
2857
+ clearTimeout(t);
2858
+ mark?.remove();
2859
+ };
2860
+ }, [board]);
2861
+ const touch = useCallback2((ids) => setSeen((s) => {
2862
+ const n = new Set(s);
2863
+ for (const id of ids) n.add(id);
2864
+ return n;
2865
+ }), []);
2866
+ const rectRaw = (b, id) => b.frames.find((f) => f.id === id) ?? b.notes.find((n) => n.id === id) ?? null;
2867
+ const dxy = (id) => {
2868
+ const [gx, gy] = glideOf(id);
2869
+ return moving?.ids.has(id) ? [moving.dx + gx, moving.dy + gy] : [gx, gy];
2870
+ };
2871
+ const sizeOf = (r) => sizing?.id === r.id ? [sizing.w, sizing.h] : [r.w, r.h];
2872
+ const rect = (id) => {
2873
+ const r = board ? rectRaw(board, id) : null;
2874
+ if (!r) return null;
2875
+ const [dx, dy] = dxy(id), [w, h] = sizeOf({ id, w: r.w, h: r.h });
2876
+ return { x: r.x + dx, y: r.y + dy, w, h };
2877
+ };
2878
+ const editRects = (b, keys) => keys.flatMap((k) => {
2879
+ const r = rectRaw(b, k);
2880
+ if (r) return [r];
2881
+ const l = b.links.find((x) => x.id === k);
2882
+ return l ? [rectRaw(b, l.from), rectRaw(b, l.to)].filter((x) => !!x) : [];
2883
+ });
2884
+ const presenceAge = last?.agent ? Date.now() - Date.parse(last.at) : Infinity;
2885
+ useEffect3(() => {
2886
+ if (presenceAge >= PRESENCE_MS) return;
2887
+ const t = setTimeout(() => setTick((x) => x + 1), PRESENCE_MS - presenceAge + BOARD2.presenceSlackMs);
2888
+ return () => clearTimeout(t);
2889
+ }, [last?.at, presenceAge]);
2890
+ const presence = board && last?.agent && presenceAge < PRESENCE_MS ? bounds(editRects(board, last.keys)) : null;
2891
+ const liveBox = board && live?.keys?.length ? bounds(editRects(board, live.keys)) : null;
2892
+ const liveKey = live ? `${live.at}|${live.keys?.join(",") ?? ""}` : "";
2893
+ useEffect3(() => {
2894
+ if (!live || play.current) return;
2895
+ const el = viewRef.current, v = viewState.current;
2896
+ const c = liveBox ? { x: (liveBox.x0 + liveBox.x1) / 2, y: liveBox.y0 } : el ? { x: (el.clientWidth / 2 - v.x) / v.z, y: (el.clientHeight / 3 - v.y) / v.z } : null;
2897
+ if (c) flyCursor(c);
2898
+ }, [liveKey]);
2899
+ const followed = useRef3(null);
2900
+ useEffect3(() => {
2901
+ const b = boardRef.current, el = viewRef.current;
2902
+ if (!b || !el || !last?.agent || last.told || followed.current === last.at) return;
2903
+ followed.current = last.at;
2904
+ if (Date.now() - Date.parse(last.at) > BOARD2.agentRecentMs) return;
2905
+ const bb = bounds(editRects(b, last.keys));
2906
+ if (!bb) return;
2907
+ const v = viewState.current;
2908
+ const vx0 = -v.x / v.z, vy0 = -v.y / v.z, vx1 = vx0 + el.clientWidth / v.z, vy1 = vy0 + el.clientHeight / v.z;
2909
+ if ((bb.x1 < vx0 || bb.x0 > vx1 || bb.y1 < vy0 || bb.y0 > vy1) && !userMoved.current) readFit();
2910
+ }, [last?.at]);
2911
+ const place = useCallback2((shape, x, y) => {
2912
+ const b = boardRef.current;
2913
+ if (!b) return;
2914
+ const id = uid("n");
2915
+ const n = BOARD2.newItem[shape === "note" ? "note" : shape === "text" ? "text" : "shape"];
2916
+ const [w, h] = [n.w, n.h];
2917
+ apply([{ op: "note.add", note: {
2918
+ id,
2919
+ text: "",
2920
+ x: Math.round(x - w / 2),
2921
+ y: Math.round(y - h / 2),
2922
+ w,
2923
+ h,
2924
+ color: shape === "note" ? "yellow" : "paper",
2925
+ ...shape !== "note" ? { shape } : {},
2926
+ ...shape === "text" ? { size: "m" } : {},
2927
+ frame: frameAt(b, x, y)
2928
+ } }]);
2929
+ setSelected(/* @__PURE__ */ new Set([id]));
2930
+ setEditing(id);
2931
+ setTool("select");
2932
+ }, [apply]);
2933
+ const placeSticker = useCallback2((icon) => {
2934
+ const b = boardRef.current, el = viewRef.current;
2935
+ if (!b || !el) return;
2936
+ const v = viewState.current, size2 = BOARD2.newSticker;
2937
+ const cx = (el.clientWidth / 2 - v.x) / v.z, cy = (el.clientHeight / 2 - v.y) / v.z;
2938
+ const id = uid("n");
2939
+ apply([{ op: "note.add", note: { id, text: "", shape: "sticker", icon, color: "paper", x: Math.round(cx - size2 / 2), y: Math.round(cy - size2 / 2), w: size2, h: size2, frame: frameAt(b, cx, cy) } }]);
2940
+ setSelected(/* @__PURE__ */ new Set([id]));
2941
+ setMenu(null);
2942
+ setTool("select");
2943
+ }, [apply]);
2944
+ const removeSelected = useCallback2(() => {
2945
+ const b = boardRef.current;
2946
+ if (!b || !selected.size) return;
2947
+ apply([...selected].filter((id) => b.notes.some((n) => n.id === id)).map((id) => ({ op: "note.remove", id })));
2948
+ setSelected(/* @__PURE__ */ new Set());
2949
+ }, [apply, selected]);
2950
+ const commitItem = useCallback2((id, raw) => {
2951
+ setEditing(null);
2952
+ const n = boardRef.current?.notes.find((x) => x.id === id);
2953
+ if (!n) return;
2954
+ const shape = shapeOf(n);
2955
+ if (shape === "note" || shape === "text") {
2956
+ if (!raw.trim() && !n.text) apply([{ op: "note.remove", id }]);
2957
+ else if (raw !== n.text) apply([{ op: "note.update", id, patch: { text: raw } }]);
2958
+ return;
2959
+ }
2960
+ const [first = "", ...rest] = raw.split("\n");
2961
+ const t = first.trim(), body = rest.join("\n").trim();
2962
+ if (!t && !body && !n.title && !n.text) {
2963
+ apply([{ op: "note.remove", id }]);
2964
+ return;
2965
+ }
2966
+ if (t !== (n.title ?? "") || body !== n.text) apply([{ op: "note.update", id, patch: { title: t, text: body } }]);
2967
+ }, [apply]);
2968
+ const commitFrame = useCallback2((id, t) => {
2969
+ setEditing(null);
2970
+ const f = boardRef.current?.frames.find((x) => x.id === id);
2971
+ if (f && t.trim() && t !== f.title) apply([{ op: "frame.update", id, patch: { title: t.trim() } }]);
2972
+ }, [apply]);
2973
+ const cancelEdit = useCallback2(() => setEditing(null), []);
2974
+ const targetAt = useCallback2((x, y, not) => {
2975
+ const b = boardRef.current;
2976
+ if (!b) return null;
2977
+ const hit = (r) => r.id !== not && x >= r.x && x <= r.x + r.w && y >= r.y && y <= r.y + r.h;
2978
+ return [...b.notes].reverse().find(hit)?.id ?? [...b.frames].reverse().find(hit)?.id ?? null;
2979
+ }, []);
2980
+ const raf = useRef3(0);
2981
+ const onPointerDown = (e) => {
2982
+ const b = boardRef.current;
2983
+ const t = e.target;
2984
+ if (!b || t.closest("textarea, input, button, .sp-wb-float, .sp-wb-pop")) return;
2985
+ if (e.button !== 0 && e.button !== 1) return;
2986
+ viewRef.current?.focus({ preventScroll: true });
2987
+ setMenu(null);
2988
+ stopGlide();
2989
+ const el = e.currentTarget, pid = e.pointerId;
2990
+ const capture = () => {
2991
+ try {
2992
+ el.setPointerCapture(pid);
2993
+ } catch {
2994
+ }
2995
+ };
2996
+ const w = world(e.clientX, e.clientY);
2997
+ if (e.button === 1 || tool === "pan" || readOnlyRef.current) {
2998
+ drag.current = { kind: "pan", sx: e.clientX, sy: e.clientY, vx: view.x, vy: view.y };
2999
+ return capture();
3000
+ }
3001
+ const noteEl = t.closest("[data-note]");
3002
+ const headEl = t.closest("[data-frame]");
3003
+ const sizeEl = t.closest("[data-resize]");
3004
+ const linkEl = t.closest("[data-link]");
3005
+ setLink(null);
3006
+ setLabelDraft(null);
3007
+ const handleEl = t.closest("[data-handle]");
3008
+ if (handleEl) {
3009
+ const from = handleEl.dataset.handle;
3010
+ drag.current = { kind: "link", from };
3011
+ setLinking({ from, x: w.x, y: w.y, to: null });
3012
+ return capture();
3013
+ }
3014
+ if (tool === "pen") {
3015
+ const real = e.pointerType === "pen" && e.pressure > 0;
3016
+ drag.current = { kind: "pen", pts: [w.x, w.y], pr: [real ? e.pressure : 0.5], real };
3017
+ setPen(true);
3018
+ return capture();
3019
+ }
3020
+ if (tool === "text" || tool === "note" || tool === "shape") {
3021
+ place(tool === "shape" ? boxShape : tool, w.x, w.y);
3022
+ return;
3023
+ }
3024
+ if (tool === "frame") {
3025
+ drag.current = { kind: "frameDraw", wx: w.x, wy: w.y };
3026
+ return capture();
3027
+ }
3028
+ const target = noteEl?.dataset.note ?? t.closest(".sp-wb-frame")?.querySelector("[data-frame]")?.dataset.frame;
3029
+ if (tool === "link") {
3030
+ if (!target) return;
3031
+ drag.current = { kind: "link", from: target };
3032
+ setLinking({ from: target, x: w.x, y: w.y, to: null });
3033
+ return capture();
3034
+ }
3035
+ if (linkEl) {
3036
+ setLink(linkEl.dataset.link);
3037
+ setSelected(/* @__PURE__ */ new Set());
3038
+ return;
3039
+ }
3040
+ if (sizeEl) {
3041
+ const id = sizeEl.dataset.resize, frame = sizeEl.hasAttribute("data-resize-frame");
3042
+ const r = frame ? b.frames.find((f) => f.id === id) : b.notes.find((n) => n.id === id);
3043
+ if (!r) return;
3044
+ drag.current = { kind: "resize", sx: e.clientX, sy: e.clientY, id, frame, w: r.w, h: r.h, min: frame ? BOARD2.frameMinSize : minSize(r.shape) };
3045
+ return capture();
3046
+ }
3047
+ if (noteEl && e.shiftKey) {
3048
+ const id = noteEl.dataset.note;
3049
+ setSelected((s) => {
3050
+ const n = new Set(s);
3051
+ if (n.has(id)) n.delete(id);
3052
+ else n.add(id);
3053
+ return n;
3054
+ });
3055
+ return;
3056
+ }
3057
+ if (noteEl) {
3058
+ const id = noteEl.dataset.note;
3059
+ const next = selected.has(id) ? new Set(selected) : /* @__PURE__ */ new Set([id]);
3060
+ setSelected(next);
3061
+ touch([id]);
3062
+ drag.current = { kind: "notes", sx: e.clientX, sy: e.clientY, ids: [...next].filter((x) => b.notes.some((n) => n.id === x)) };
3063
+ return capture();
3064
+ }
3065
+ if (headEl) {
3066
+ const id = headEl.dataset.frame;
3067
+ drag.current = { kind: "frame", sx: e.clientX, sy: e.clientY, id, ids: [id, ...b.notes.filter((n) => n.frame === id).map((n) => n.id)] };
3068
+ return capture();
3069
+ }
3070
+ drag.current = { kind: "box", wx: w.x, wy: w.y };
3071
+ if (!e.shiftKey) setSelected(/* @__PURE__ */ new Set());
3072
+ capture();
3073
+ };
3074
+ const onPointerMove = (e) => {
3075
+ const d = drag.current;
3076
+ if (!d) return;
3077
+ const { clientX, clientY } = e;
3078
+ if (d.kind === "pen") {
3079
+ const w = world(clientX, clientY);
3080
+ const n = d.pts.length;
3081
+ if (Math.hypot(w.x - d.pts[n - 2], w.y - d.pts[n - 1]) * viewState.current.z >= BOARD2.ink.minStep) {
3082
+ d.pts.push(Math.round(w.x * 10) / 10, Math.round(w.y * 10) / 10);
3083
+ d.pr.push(d.real ? e.pressure : 0.5);
3084
+ }
3085
+ }
3086
+ cancelAnimationFrame(raf.current);
3087
+ raf.current = requestAnimationFrame(() => {
3088
+ const z = viewState.current.z;
3089
+ if (d.kind === "pan") panBy((v) => ({ ...v, x: d.vx + clientX - d.sx, y: d.vy + clientY - d.sy }));
3090
+ else if (d.kind === "pen") penPath.current?.setAttribute("d", liveStroke(d.pts, d.real ? d.pr : void 0, inkSize, inkBrush, BOARD2.brush.width[inkBrush][inkSize] / viewState.current.z));
3091
+ else if (d.kind === "resize") setSizing({ id: d.id, w: Math.max(d.min.w, Math.round(d.w + (clientX - d.sx) / z)), h: Math.max(d.min.h, Math.round(d.h + (clientY - d.sy) / z)) });
3092
+ else if (d.kind === "link") {
3093
+ const w = world(clientX, clientY);
3094
+ setLinking({ from: d.from, x: w.x, y: w.y, to: targetAt(w.x, w.y, d.from) });
3095
+ } else if (d.kind === "box" || d.kind === "frameDraw") {
3096
+ const w = world(clientX, clientY);
3097
+ setMarquee({ x0: Math.min(d.wx, w.x), y0: Math.min(d.wy, w.y), x1: Math.max(d.wx, w.x), y1: Math.max(d.wy, w.y), frame: d.kind === "frameDraw" });
3098
+ } else setMoving({ ids: new Set(d.ids), dx: (clientX - d.sx) / z, dy: (clientY - d.sy) / z });
3099
+ });
3100
+ };
3101
+ const onPointerUp = (e) => {
3102
+ const d = drag.current;
3103
+ drag.current = null;
3104
+ cancelAnimationFrame(raf.current);
3105
+ const b = boardRef.current;
3106
+ if (!d || !b) return;
3107
+ const z = viewState.current.z;
3108
+ const dx = Math.round((e.clientX - ("sx" in d ? d.sx : 0)) / z), dy = Math.round((e.clientY - ("sy" in d ? d.sy : 0)) / z);
3109
+ if (d.kind === "resize") {
3110
+ if (sizing && sizing.id === d.id && (sizing.w !== d.w || sizing.h !== d.h)) apply([d.frame ? { op: "frame.update", id: d.id, patch: { w: sizing.w, h: sizing.h } } : { op: "note.update", id: d.id, patch: { w: sizing.w, h: sizing.h } }]);
3111
+ setSizing(null);
3112
+ return;
3113
+ }
3114
+ if (d.kind === "link") {
3115
+ const w = world(e.clientX, e.clientY);
3116
+ const to = targetAt(w.x, w.y, d.from);
3117
+ if (to && !b.links.some((l) => l.from === d.from && l.to === to)) apply([{ op: "link.add", link: { id: uid("l"), from: d.from, to, route: "elbow" } }]);
3118
+ setLinking(null);
3119
+ setTool("select");
3120
+ return;
3121
+ }
3122
+ if (d.kind === "pen") {
3123
+ setPen(false);
3124
+ if (d.pts.length < 4) return;
3125
+ const xs = d.pts.filter((_, i) => i % 2 === 0), ys = d.pts.filter((_, i) => i % 2 === 1);
3126
+ const x0 = Math.min(...xs) - 2, y0 = Math.min(...ys) - 2;
3127
+ const w = Math.max(...xs) - x0 + 2, h = Math.max(...ys) - y0 + 2;
3128
+ const weight = BOARD2.brush.width[inkBrush][inkSize] / viewState.current.z;
3129
+ const nib = Math.ceil(weight * 0.75);
3130
+ const bx = x0 - nib, by = y0 - nib;
3131
+ apply([{ op: "note.add", note: {
3132
+ id: uid("n"),
3133
+ shape: "ink",
3134
+ text: "",
3135
+ color: inkColor,
3136
+ size: inkSize,
3137
+ brush: inkBrush,
3138
+ weight,
3139
+ x: Math.round(bx),
3140
+ y: Math.round(by),
3141
+ w: Math.max(24, Math.round(w + nib * 2)),
3142
+ h: Math.max(16, Math.round(h + nib * 2)),
3143
+ frame: null,
3144
+ points: d.pts.map((v, i) => Math.round((v - (i % 2 ? by : bx)) * 10) / 10),
3145
+ ...d.real ? { pressure: d.pr.map((v) => Math.round(v * 100) / 100) } : {}
3146
+ } }]);
3147
+ return;
3148
+ }
3149
+ if (d.kind === "frameDraw") {
3150
+ const m2 = marquee;
3151
+ const id = uid("f");
3152
+ apply([{ op: "frame.add", frame: m2 && m2.x1 - m2.x0 > BOARD2.frameMin && m2.y1 - m2.y0 > BOARD2.frameMin ? { id, title: WB.newFrame, x: Math.round(m2.x0), y: Math.round(m2.y0), w: Math.round(m2.x1 - m2.x0), h: Math.round(m2.y1 - m2.y0) } : { id, title: WB.newFrame, x: Math.round(d.wx), y: Math.round(d.wy), w: BOARD2.newFrame.w, h: BOARD2.newFrame.h } }]);
3153
+ setEditing(id);
3154
+ setMarquee(null);
3155
+ setTool("select");
3156
+ return;
3157
+ }
3158
+ if (d.kind === "notes" && (Math.abs(dx) > 2 || Math.abs(dy) > 2)) {
3159
+ apply(d.ids.flatMap((id) => {
3160
+ const n = b.notes.find((x) => x.id === id);
3161
+ return n ? [{ op: "note.update", id, patch: { x: n.x + dx, y: n.y + dy } }] : [];
3162
+ }));
3163
+ } else if (d.kind === "frame" && (Math.abs(dx) > 2 || Math.abs(dy) > 2)) {
3164
+ apply([{ op: "frame.move", id: d.id, dx, dy }]);
3165
+ } else if (d.kind === "box" && marquee) {
3166
+ const hit = b.notes.filter((n) => n.x < marquee.x1 && n.x + n.w > marquee.x0 && n.y < marquee.y1 && n.y + n.h > marquee.y0).map((n) => n.id);
3167
+ setSelected((s) => /* @__PURE__ */ new Set([...e.shiftKey ? s : [], ...hit]));
3168
+ touch(hit);
3169
+ }
3170
+ setMoving(null);
3171
+ setMarquee(null);
3172
+ };
3173
+ const onDoubleClick = (e) => {
3174
+ const t = e.target;
3175
+ if (t.closest("textarea, input, button, .sp-wb-float, .sp-wb-pop") || tool !== "select" || readOnlyRef.current) return;
3176
+ const noteEl = t.closest("[data-note]");
3177
+ const headEl = t.closest("[data-frame]");
3178
+ if (noteEl) {
3179
+ if (noteEl.dataset.shape !== "ink") setEditing(noteEl.dataset.note);
3180
+ } else if (headEl) setEditing(headEl.dataset.frame);
3181
+ else {
3182
+ const w = world(e.clientX, e.clientY);
3183
+ place("note", w.x, w.y);
3184
+ }
3185
+ };
3186
+ const onKeyDown = (e) => {
3187
+ const el = e.target;
3188
+ if (editing || el.closest("textarea, input")) return;
3189
+ if (readOnlyRef.current) {
3190
+ if (e.key === "Escape") toLatestRef.current();
3191
+ return;
3192
+ }
3193
+ if ((e.key === "Delete" || e.key === "Backspace") && link) {
3194
+ e.preventDefault();
3195
+ apply([{ op: "link.remove", id: link }]);
3196
+ setLink(null);
3197
+ return;
3198
+ }
3199
+ if ((e.key === "Delete" || e.key === "Backspace") && selected.size) {
3200
+ e.preventDefault();
3201
+ removeSelected();
3202
+ return;
3203
+ }
3204
+ if (e.key === "Escape") {
3205
+ setLinking(null);
3206
+ setLink(null);
3207
+ setSelected(/* @__PURE__ */ new Set());
3208
+ setTool("select");
3209
+ setMenu(null);
3210
+ setPen(false);
3211
+ setMarquee(null);
3212
+ drag.current = null;
3213
+ return;
3214
+ }
3215
+ const id = el.closest("[data-note]")?.dataset.note;
3216
+ const k = e.key.toLowerCase();
3217
+ if (!id && !e.metaKey && !e.ctrlKey && !e.altKey && KEY_TOOL[k]) {
3218
+ e.preventDefault();
3219
+ setTool(KEY_TOOL[k]);
3220
+ return;
3221
+ }
3222
+ if (!id) return;
3223
+ const n = boardRef.current?.notes.find((x) => x.id === id);
3224
+ if (!n) return;
3225
+ if (e.key === "Enter") {
3226
+ e.preventDefault();
3227
+ if (shapeOf(n) !== "ink") setEditing(id);
3228
+ return;
3229
+ }
3230
+ if (e.key === " ") {
3231
+ e.preventDefault();
3232
+ setSelected(/* @__PURE__ */ new Set([id]));
3233
+ touch([id]);
3234
+ return;
3235
+ }
3236
+ const step2 = { ArrowLeft: [-BOARD2.nudge, 0], ArrowRight: [BOARD2.nudge, 0], ArrowUp: [0, -BOARD2.nudge], ArrowDown: [0, BOARD2.nudge] }[e.key];
3237
+ if (!step2) return;
3238
+ e.preventDefault();
3239
+ touch([id]);
3240
+ const min = minSize(n.shape);
3241
+ apply([e.shiftKey ? { op: "note.update", id, patch: { w: Math.max(min.w, n.w + step2[0] * 2), h: Math.max(min.h, n.h + step2[1] * 2) } } : { op: "note.update", id, patch: { x: n.x + step2[0], y: n.y + step2[1] } }]);
3242
+ };
3243
+ const askSelection = () => {
3244
+ const q = question.trim();
3245
+ if (!q || !selected.size) return;
3246
+ ctx2.onAsk(WB.askSelected(data.ref, [...selected].join(", "), q));
3247
+ setQuestion("");
3248
+ boost();
3249
+ };
3250
+ const sendChange = () => {
3251
+ const q = change.trim();
3252
+ if (!q) return;
3253
+ ctx2.onAsk(WB.askBoard(data.ref, q));
3254
+ setChange("");
3255
+ setAskOpen(false);
3256
+ boost();
3257
+ };
3258
+ const selNotes = board ? board.notes.filter((n) => selected.has(n.id)) : [];
3259
+ const selLink = board && link ? board.links.find((l) => l.id === link) ?? null : null;
3260
+ const empty = !!board && !board.notes.length && !board.frames.length;
3261
+ const linkFrom = linking ? rect(linking.from) : null;
3262
+ const toScreen = (x, y) => ({ x: x * view.z + view.x, y: y * view.z + view.y });
3263
+ const wireFrom = selNotes.length === 1 && !editing && !moving && !linking && shapeOf(selNotes[0]) !== "ink" ? { id: selNotes[0].id, r: rect(selNotes[0].id) } : null;
3264
+ const selBox = selNotes.length && !editing && !moving ? bounds(selNotes.map((n) => rect(n.id)).filter((r) => !!r)) : null;
3265
+ const linkA = selLink ? rect(selLink.from) : null, linkC = selLink ? rect(selLink.to) : null;
3266
+ const linkMid = selLink && linkA && linkC ? geoOf(linkA, linkC, selLink.route).mid : null;
3267
+ const allBoxy = selNotes.length > 0 && selNotes.every((n) => isBoxy(shapeOf(n)));
3268
+ const allText = selNotes.length > 0 && selNotes.every((n) => shapeOf(n) === "text");
3269
+ const step = RULE * view.z;
3270
+ const gridStyle = { backgroundSize: `${step}px ${step}px`, backgroundPosition: `${(view.x % step + step) % step}px ${(view.y % step + step) % step}px` };
3271
+ return /* @__PURE__ */ jsxs2("section", { className: "sp-lego sp-wb", "data-full": full || void 0, "data-look": look, "data-mode": mode, "aria-label": title, onKeyDown, style: vars, children: [
3272
+ /* @__PURE__ */ jsxs2("header", { className: "sp-wb-head", children: [
3273
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-title", children: [
3274
+ /* @__PURE__ */ jsx3("strong", { ref: titleRef, dir: "auto", children: board?.title ?? title }),
3275
+ /* @__PURE__ */ jsxs2("span", { className: "sp-wb-sub", children: [
3276
+ /* @__PURE__ */ jsx3("span", { children: data.ref }),
3277
+ board && /* @__PURE__ */ jsxs2("span", { children: [
3278
+ WB.changedBy(board.updatedBy),
3279
+ ago(board.updatedAt) ? ` \xB7 ${ago(board.updatedAt)}` : ""
3280
+ ] }),
3281
+ saving && /* @__PURE__ */ jsx3("span", { className: "sp-wb-saving", role: "status", children: WB.saving })
3282
+ ] })
3283
+ ] }),
3284
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", onClick: () => setFull((f) => !f), children: full ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
3285
+ /* @__PURE__ */ jsx3(IClose, { size: 14 }),
3286
+ " ",
3287
+ WB.close
3288
+ ] }) : /* @__PURE__ */ jsxs2(Fragment2, { children: [
3289
+ /* @__PURE__ */ jsx3(IPanel, { size: 14 }),
3290
+ " ",
3291
+ WB.fullscreen
3292
+ ] }) }),
3293
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-anchor", children: [
3294
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", "data-menu": true, "aria-haspopup": "menu", "aria-expanded": menu === "more", onClick: () => setMenu(menu === "more" ? null : "more"), children: WB.more }),
3295
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: menu === "more" && /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-pop sp-wb-pop-right", role: "menu", ...POP_IN, children: [
3296
+ /* @__PURE__ */ jsxs2("button", { type: "button", role: "menuitem", onClick: () => {
3297
+ setMenu(null);
3298
+ ctx2.onAsk(WB.toDocAsk(data.ref));
3299
+ }, children: [
3300
+ /* @__PURE__ */ jsx3(IDoc, { size: 14 }),
3301
+ " ",
3302
+ WB.toDoc
3303
+ ] }),
3304
+ /* @__PURE__ */ jsxs2("button", { type: "button", role: "menuitem", onClick: () => {
3305
+ setMenu(null);
3306
+ reload();
3307
+ }, children: [
3308
+ /* @__PURE__ */ jsx3(IRefresh, { size: 14 }),
3309
+ " ",
3310
+ WB.reload
3311
+ ] }),
3312
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-pop-group", role: "group", "aria-label": WB.styleLabel, children: [
3313
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-pop-label", children: WB.styleLabel }),
3314
+ ["ink", "neat"].map((v) => /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitemradio", "aria-checked": look === v, onClick: () => pickLook(v), children: WB.styleOf(WB.styles[v]) }, v))
3315
+ ] }),
3316
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-pop-group", role: "group", "aria-label": WB.tempoLabel, children: [
3317
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-pop-label", children: WB.tempoLabel }),
3318
+ TEMPOS.map((t) => /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitemradio", "aria-checked": tempo === t, onClick: () => {
3319
+ setTempo(t);
3320
+ saveTempo(t);
3321
+ }, children: WB.tempos[t] }, t))
3322
+ ] }),
3323
+ /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitemcheckbox", "aria-checked": sound, onClick: () => {
3324
+ const on = !sound;
3325
+ setSoundOn(on);
3326
+ setSound(on);
3327
+ }, children: sound ? WB.soundOn : WB.soundOff })
3328
+ ] }, "more") })
3329
+ ] })
3330
+ ] }),
3331
+ error && board && /* @__PURE__ */ jsxs2("p", { className: "sp-wb-error", role: "alert", children: [
3332
+ /* @__PURE__ */ jsx3("span", { children: error }),
3333
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-link", onClick: reload, children: [
3334
+ /* @__PURE__ */ jsx3(IRefresh, { size: 13 }),
3335
+ " ",
3336
+ WB.reload
3337
+ ] })
3338
+ ] }),
3339
+ !board ? error ? /* @__PURE__ */ jsxs2("div", { className: "sp-wb-state", role: "alert", children: [
3340
+ /* @__PURE__ */ jsx3("strong", { children: WB.loadFailed }),
3341
+ /* @__PURE__ */ jsx3("span", { children: error }),
3342
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-btn", onClick: reload, children: [
3343
+ /* @__PURE__ */ jsx3(IRefresh, { size: 14 }),
3344
+ " ",
3345
+ WB.retry
3346
+ ] })
3347
+ ] }) : /* @__PURE__ */ jsxs2("div", { className: "sp-wb-view sp-wb-loading", role: "status", "aria-label": WB.loading, children: [
3348
+ /* @__PURE__ */ jsx3("span", {}),
3349
+ /* @__PURE__ */ jsx3("span", {}),
3350
+ /* @__PURE__ */ jsx3("span", {})
3351
+ ] }) : /* @__PURE__ */ jsxs2(
3352
+ "div",
3353
+ {
3354
+ ref: viewRef,
3355
+ className: "sp-wb-view",
3356
+ "data-tool": readOnly ? "pan" : tool,
3357
+ "data-readonly": readOnly || void 0,
3358
+ tabIndex: 0,
3359
+ "aria-label": readOnly ? WB.readOnly : WB.canvasAria,
3360
+ style: gridStyle,
3361
+ onPointerDown,
3362
+ onPointerMove,
3363
+ onPointerUp,
3364
+ onPointerCancel: onPointerUp,
3365
+ onDoubleClick,
3366
+ children: [
3367
+ /* @__PURE__ */ jsx3("div", { ref: markLayer, className: "sp-wb-marks", "aria-hidden": true, style: markView.current ? (() => {
3368
+ const v0 = markView.current, k = view.z / v0.z;
3369
+ return { transform: `translate(${view.x - v0.x * k}px, ${view.y - v0.y * k}px) scale(${k})` };
3370
+ })() : void 0 }),
3371
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-world", style: { transform: `translate(${view.x}px, ${view.y}px) scale(${view.z})` }, children: [
3372
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: footprints.map((p, i) => /* @__PURE__ */ jsxs2(
3373
+ motion2.div,
3374
+ {
3375
+ className: "sp-wb-foot",
3376
+ "data-kind": p.kind,
3377
+ "aria-hidden": true,
3378
+ style: { translate: `${p.x}px ${p.y}px`, width: p.w, height: p.h },
3379
+ initial: { opacity: 0 },
3380
+ animate: { opacity: 1, transition: { duration: BOARD2.enter.footMs * tf / 1e3, ease: "easeInOut", delay: Math.min(i, 24) * BOARD2.footStepMs * tf / 1e3 } },
3381
+ exit: { opacity: 0, transition: { duration: BOARD2.enter.fadeMs * tf / 1e3, ease: "easeInOut" } },
3382
+ children: [
3383
+ p.kind !== "track" && p.kind !== "text" && /* @__PURE__ */ jsx3(RoughOutline, { id: `plan-${p.id}`, shape: p.kind === "frame" ? "frame" : p.kind === "cell" ? "cell" : "box", w: p.w, h: p.h }),
3384
+ p.kind === "track" && /* @__PURE__ */ jsx3("span", { className: "sp-wb-foot-road" }),
3385
+ p.kind === "card" && /* @__PURE__ */ jsx3("span", { className: "sp-wb-foot-line" })
3386
+ ]
3387
+ },
3388
+ `plan-${p.id}`
3389
+ )) }),
3390
+ onions.current.map((o) => /* @__PURE__ */ jsx3("div", { className: "sp-wb-onion", "aria-hidden": true, style: { translate: `${o.x}px ${o.y}px`, width: o.w, height: o.h }, children: o.title && /* @__PURE__ */ jsx3("span", { dir: "auto", children: o.title }) }, o.id)),
3391
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: [...deleted.current.entries()].map(([id, g]) => /* @__PURE__ */ jsx3(
3392
+ motion2.div,
3393
+ {
3394
+ className: "sp-wb-struck",
3395
+ "aria-hidden": true,
3396
+ style: { translate: `${g.x}px ${g.y}px`, width: g.w, height: g.h },
3397
+ initial: { opacity: 0 },
3398
+ animate: { opacity: 1 },
3399
+ exit: { opacity: 0, transition: { duration: 0.3 } },
3400
+ children: g.title && /* @__PURE__ */ jsx3("span", { dir: "auto", children: g.title })
3401
+ },
3402
+ `del-${id}`
3403
+ )) }),
3404
+ [...leaving.current.values()].filter((l) => l.frame).map(({ item, delay }) => /* @__PURE__ */ jsx3(FrameBox, { f: item, dx: 0, dy: 0, w: item.w, h: item.h, target: false, hot: false, born: false, leaving: true, leaveDelay: delay, editing: false, inked, onCommit: commitFrame, onCancel: cancelEdit }, `gone-${item.id}`)),
3405
+ board.frames.map((f) => {
3406
+ const [dx, dy] = dxy(f.id), [w, h] = sizeOf(f);
3407
+ shownAt.current.set(f.id, { x: f.x + dx, y: f.y + dy });
3408
+ return /* @__PURE__ */ jsx3(FrameBox, { f, dx, dy, w, h, target: linking?.to === f.id, hot: hot.has(f.id) && !seen.has(f.id), born: born.current.has(f.id), editing: editing === f.id, inked, pending: pending.current.has(f.id), enter: entering.current.get(f.id), onCommit: commitFrame, onCancel: cancelEdit }, f.id);
3409
+ }),
3410
+ /* @__PURE__ */ jsx3(Links, { b: board, rect, selected: link, preview: linking && linkFrom ? { a: linkFrom, x: linking.x, y: linking.y } : null, inked, hidden: pending.current, enter: entering.current }),
3411
+ [...leaving.current.values()].filter((l) => !l.frame).map(({ item, delay }) => /* @__PURE__ */ jsx3(Item, { n: item, selected: false, hot: false, born: false, leaving: true, leaveDelay: delay, drag: false, dx: 0, dy: 0, w: item.w, h: item.h, target: false, editing: false, inked, onCommit: commitItem, onCancel: cancelEdit }, `gone-${item.id}`)),
3412
+ layered(board.notes).map((n) => {
3413
+ const [dx, dy] = dxy(n.id), [w, h] = sizeOf(n);
3414
+ shownAt.current.set(n.id, { x: n.x + dx, y: n.y + dy });
3415
+ return /* @__PURE__ */ jsx3(Item, { n, selected: selected.has(n.id), hot: hot.has(n.id) && !seen.has(n.id), born: born.current.has(n.id), drag: !!moving?.ids.has(n.id), dx, dy, w, h, target: linking?.to === n.id, editing: editing === n.id, inked, pending: pending.current.has(n.id), enter: entering.current.get(n.id), onCommit: commitItem, onCancel: cancelEdit }, n.id);
3416
+ }),
3417
+ wireFrom && wireFrom.r && [[0.5, 0], [1, 0.5], [0.5, 1], [0, 0.5]].map(([fx, fy], i) => /* @__PURE__ */ jsx3(
3418
+ "span",
3419
+ {
3420
+ className: "sp-wb-handle",
3421
+ "data-handle": wireFrom.id,
3422
+ title: WB.wireHint,
3423
+ style: { left: wireFrom.r.x + wireFrom.r.w * fx, top: wireFrom.r.y + wireFrom.r.h * fy, transform: `translate(-50%, -50%) scale(${1 / view.z})` }
3424
+ },
3425
+ `h${i}`
3426
+ )),
3427
+ pen && /* @__PURE__ */ jsx3("svg", { className: "sp-wb-pen-live", "data-color": inkColor, width: "1", height: "1", "aria-hidden": true, children: /* @__PURE__ */ jsx3("path", { ref: penPath }) }),
3428
+ marquee && /* @__PURE__ */ jsx3("div", { className: "sp-wb-box", "data-frame-draw": marquee.frame || void 0, style: { left: marquee.x0, top: marquee.y0, width: marquee.x1 - marquee.x0, height: marquee.y1 - marquee.y0 } }),
3429
+ presence && !activity && !cursor && /* @__PURE__ */ jsx3("div", { className: "sp-wb-presence", style: { left: presence.x0 - 8, top: presence.y0 - 8, width: presence.x1 - presence.x0 + 16, height: presence.y1 - presence.y0 + 16 }, "aria-hidden": true, children: /* @__PURE__ */ jsxs2("span", { className: "sp-wb-presence-chip", style: { transform: `scale(${1 / view.z})` }, children: [
3430
+ /* @__PURE__ */ jsx3("i", {}),
3431
+ " ",
3432
+ WB.agentDrawing
3433
+ ] }) }),
3434
+ liveBox && /* @__PURE__ */ jsx3("div", { className: "sp-wb-live", "data-agent": live?.agent || void 0, style: { left: liveBox.x0 - 10, top: liveBox.y0 - 10, width: liveBox.x1 - liveBox.x0 + 20, height: liveBox.y1 - liveBox.y0 + 20 }, "aria-hidden": true }),
3435
+ /* @__PURE__ */ jsx3(
3436
+ AgentCursor,
3437
+ {
3438
+ x: cursorX,
3439
+ y: cursorY,
3440
+ press: cursorPress,
3441
+ z: view.z,
3442
+ show: !!cursor || !!live,
3443
+ agent: cursor ? cursor.agent : !!live?.agent,
3444
+ label: telling || cursor?.told ? WB.agent : cursor?.label ?? (live ? live.agent ? WB.agentWorking(live.what) : WB.personWorking(live.by, live.what) : "")
3445
+ }
3446
+ )
3447
+ ] }),
3448
+ empty && !readOnly && /* @__PURE__ */ jsx3("p", { className: "sp-wb-empty", children: WB.empty }),
3449
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: (cursor || live) && !telling && !cursor?.told && /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-float sp-wb-status", role: "status", "data-agent": (cursor ? cursor.agent : live?.agent) || void 0, ...POP_IN, children: [
3450
+ /* @__PURE__ */ jsx3("i", { "aria-hidden": true }),
3451
+ /* @__PURE__ */ jsx3("span", { dir: "auto", children: cursor?.label ?? (live ? live.agent ? WB.agentWorking(live.what) : WB.personWorking(live.by, live.what) : "") }),
3452
+ cursor && !m.replay && /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", onClick: () => finish(), "aria-label": WB.skipAria, children: WB.skip })
3453
+ ] }, "status") }),
3454
+ (cursor || live) && !telling && !cursor?.told && /* @__PURE__ */ jsx3(
3455
+ EdgeMarker,
3456
+ {
3457
+ x: cursorX,
3458
+ y: cursorY,
3459
+ view,
3460
+ label: WB.edgeOf(cursor?.label ?? live?.what ?? ""),
3461
+ onFly: () => {
3462
+ const el = viewRef.current;
3463
+ if (el) {
3464
+ lastInput.current = 0;
3465
+ flyTo(centreOn({ x: cursorX.get(), y: cursorY.get() }, viewState.current, { w: el.clientWidth, h: el.clientHeight }, bottomRef.current));
3466
+ }
3467
+ }
3468
+ }
3469
+ ),
3470
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: m.scrub !== null && !telling && /* @__PURE__ */ jsx3(
3471
+ ScrubBanner,
3472
+ {
3473
+ version: m.scrub,
3474
+ why: entryOf(m.scrub)?.why || entryOf(m.scrub)?.what || "",
3475
+ restoring,
3476
+ replaying: !!m.replay,
3477
+ onLatest: () => toLatestRef.current(),
3478
+ onRestore: () => void restoreShown()
3479
+ },
3480
+ "scrub"
3481
+ ) }),
3482
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-zoomctl sp-wb-float", children: [
3483
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", "data-menu": true, "aria-haspopup": "menu", "aria-expanded": menu === "zoom", onClick: () => setMenu(menu === "zoom" ? null : "zoom"), children: WB.zoom(Math.round(view.z * 100)) }),
3484
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: menu === "zoom" && /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-pop sp-wb-pop-right", role: "menu", ...POP_IN, children: [
3485
+ /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitem", onClick: () => zoomBy(BOARD2.zoomStep), children: WB.zoomIn }),
3486
+ /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitem", onClick: () => zoomBy(1 / BOARD2.zoomStep), children: WB.zoomOut }),
3487
+ /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitem", onClick: () => {
3488
+ setMenu(null);
3489
+ fit();
3490
+ }, children: WB.fit }),
3491
+ /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitem", onClick: () => {
3492
+ setMenu(null);
3493
+ zoomBy(1 / viewState.current.z);
3494
+ }, children: "100%" })
3495
+ ] }, "zoom") })
3496
+ ] }),
3497
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: selBox && (() => {
3498
+ return /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-float sp-wb-bar", role: "toolbar", "aria-label": WB.selected(selNotes.length), "data-dock": "top", ...POP_IN, children: [
3499
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-count", children: WB.selected(selNotes.length) }),
3500
+ /* @__PURE__ */ jsx3("div", { className: "sp-wb-swatches", role: "group", "aria-label": WB.color, children: SWATCHES.map((c) => /* @__PURE__ */ jsx3(
3501
+ "button",
3502
+ {
3503
+ type: "button",
3504
+ className: "sp-wb-swatch",
3505
+ "data-color": c,
3506
+ "aria-label": WB.colorOf(COLOR_NAME[c]),
3507
+ title: COLOR_NAME[c],
3508
+ "aria-pressed": selNotes.every((n) => n.color === c),
3509
+ onClick: () => apply(selNotes.map((n) => ({ op: "note.update", id: n.id, patch: { color: c } }))),
3510
+ children: /* @__PURE__ */ jsx3("span", {})
3511
+ },
3512
+ c
3513
+ )) }),
3514
+ allBoxy && /* @__PURE__ */ jsx3("div", { className: "sp-wb-seg", role: "group", "aria-label": WB.shape, children: BOX_SHAPES.map((s) => /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", "aria-pressed": selNotes.every((n) => n.shape === s.id), onClick: () => apply(selNotes.map((n) => ({ op: "note.update", id: n.id, patch: { shape: s.id } }))), children: s.label }, s.id)) }),
3515
+ allText && /* @__PURE__ */ jsx3("div", { className: "sp-wb-seg", role: "group", "aria-label": WB.textSize, children: SIZES.map((s) => /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", "aria-pressed": selNotes.every((n) => (n.size ?? "m") === s.id), onClick: () => apply(selNotes.map((n) => ({ op: "note.update", id: n.id, patch: { size: s.id } }))), children: s.label }, s.id)) }),
3516
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-btn", onClick: removeSelected, children: [
3517
+ /* @__PURE__ */ jsx3(ITrash, { size: 14 }),
3518
+ " ",
3519
+ WB.remove
3520
+ ] }),
3521
+ /* @__PURE__ */ jsxs2("form", { className: "sp-wb-ask", onSubmit: (e) => {
3522
+ e.preventDefault();
3523
+ askSelection();
3524
+ }, children: [
3525
+ /* @__PURE__ */ jsx3("input", { value: question, onChange: (e) => setQuestion(e.target.value), placeholder: WB.askPick, "aria-label": WB.askPick, maxLength: BOARD2.askMax, dir: "auto" }),
3526
+ /* @__PURE__ */ jsxs2("button", { type: "submit", className: "sp-wb-btn", disabled: !question.trim(), children: [
3527
+ /* @__PURE__ */ jsx3(IChat, { size: 14 }),
3528
+ " ",
3529
+ WB.ask
3530
+ ] })
3531
+ ] })
3532
+ ] }, "selbar");
3533
+ })() }),
3534
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: selLink && linkMid && (() => {
3535
+ const arrow = selLink.arrow ?? "end";
3536
+ const nextArrow = arrow === "end" ? "both" : arrow === "both" ? "none" : "end";
3537
+ const saveLabel = () => {
3538
+ if (labelDraft !== null && labelDraft.trim() !== (selLink.label ?? "")) apply([{ op: "link.update", id: selLink.id, patch: { label: labelDraft.trim() } }]);
3539
+ setLabelDraft(null);
3540
+ };
3541
+ return /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-float sp-wb-bar", role: "toolbar", "aria-label": WB.linkSelected, "data-dock": "top", ...POP_IN, children: [
3542
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", onClick: () => apply([{ op: "link.update", id: selLink.id, patch: { route: ROUTE_NEXT[selLink.route ?? "elbow"] } }]), children: WB.routeTo[ROUTE_NEXT[selLink.route ?? "elbow"]] }),
3543
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", "aria-pressed": !!selLink.dashed, onClick: () => apply([{ op: "link.update", id: selLink.id, patch: { dashed: !selLink.dashed } }]), children: WB.dashed }),
3544
+ /* @__PURE__ */ jsx3("button", { type: "button", className: "sp-wb-btn", onClick: () => apply([{ op: "link.update", id: selLink.id, patch: { arrow: nextArrow } }]), children: WB.ends(arrow === "end" ? WB.endsOne : arrow === "both" ? WB.endsTwo : WB.endsNone) }),
3545
+ /* @__PURE__ */ jsx3("form", { className: "sp-wb-ask", onSubmit: (e) => {
3546
+ e.preventDefault();
3547
+ saveLabel();
3548
+ }, children: /* @__PURE__ */ jsx3("input", { value: labelDraft ?? selLink.label ?? "", onChange: (e) => setLabelDraft(e.target.value), onBlur: saveLabel, placeholder: WB.linkLabel, "aria-label": WB.linkLabel, maxLength: BOARD2.linkLabelMax, dir: "auto" }) }),
3549
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-btn", onClick: () => {
3550
+ apply([{ op: "link.remove", id: selLink.id }]);
3551
+ setLink(null);
3552
+ }, children: [
3553
+ /* @__PURE__ */ jsx3(ITrash, { size: 14 }),
3554
+ " ",
3555
+ WB.remove
3556
+ ] })
3557
+ ] }, "linkbar");
3558
+ })() }),
3559
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-dock sp-wb-float", children: [
3560
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: shownBatch.current && !readOnly && !telling && !cursor && !live && /* @__PURE__ */ jsx3(
3561
+ motion2.div,
3562
+ {
3563
+ className: "sp-wb-batch-dock",
3564
+ layout: "position",
3565
+ initial: { opacity: 0, y: 6 },
3566
+ animate: { opacity: 1, y: 0 },
3567
+ exit: { opacity: 0, y: 4, transition: { duration: 0.18 } },
3568
+ transition: { type: "spring", visualDuration: 0.32, bounce: 0.15 },
3569
+ children: /* @__PURE__ */ jsx3(BatchPill, { batch: shownBatch.current, z: 1, state: batchUi.state, error: batchUi.error, onKeep: () => void keepPending(), onUndo: () => void undoPending() })
3570
+ },
3571
+ `batch-${shownBatch.current.id}`
3572
+ ) }),
3573
+ cursor?.told && !m.replay && /* @__PURE__ */ jsx3(Caption, { text: cursor.label, version: 0, speed: 1 / tf, instant: !!reduce, lead: WB.agent, onSkip: () => finish() }, "live-say"),
3574
+ caption && m.replay && /* @__PURE__ */ jsx3(Caption, { text: caption.text, version: caption.version, speed: m.replay.speed / tf, instant: !!reduce, ...telling ? { lead: WB.agent, onSkip: () => toLatestRef.current() } : {} }),
3575
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: histOpen && /* @__PURE__ */ jsx3(
3576
+ HistoryStrip,
3577
+ {
3578
+ entries: hist,
3579
+ loading: histLoading && !hist,
3580
+ current: m.scrub,
3581
+ note: histNote,
3582
+ latest: latest?.version ?? 0,
3583
+ replaying: !!m.replay,
3584
+ paused: !!m.replay?.paused,
3585
+ speed: m.replay?.speed ?? 1,
3586
+ onPick: (v) => void showVersion(v),
3587
+ onReplay: () => void runReplay(),
3588
+ onPause: (p) => send({ type: "pause", paused: p }),
3589
+ onSpeed: (x) => send({ type: "speed", speed: x }),
3590
+ onClose: () => {
3591
+ setHistOpen(false);
3592
+ if (readOnlyRef.current) toLatestRef.current();
3593
+ }
3594
+ },
3595
+ "history"
3596
+ ) }),
3597
+ /* @__PURE__ */ jsx3(AnimatePresence2, { initial: false, children: askOpen && /* @__PURE__ */ jsx3(
3598
+ motion2.div,
3599
+ {
3600
+ className: "sp-wb-change-wrap",
3601
+ initial: reduce ? { opacity: 0 } : { height: 0, opacity: 0, y: 6, overflow: "hidden" },
3602
+ animate: reduce ? { opacity: 1 } : { height: "auto", opacity: 1, y: 0, transitionEnd: { overflow: "visible" } },
3603
+ exit: reduce ? { opacity: 0 } : { height: 0, opacity: 0, y: 6, overflow: "hidden" },
3604
+ transition: { type: "spring", visualDuration: ASK_SPRING.visualDuration, bounce: ASK_SPRING.bounce },
3605
+ children: /* @__PURE__ */ jsxs2("form", { className: "sp-wb-change", onSubmit: (e) => {
3606
+ e.preventDefault();
3607
+ sendChange();
3608
+ }, children: [
3609
+ /* @__PURE__ */ jsx3(
3610
+ "input",
3611
+ {
3612
+ ref: changeRef,
3613
+ autoFocus: true,
3614
+ value: change,
3615
+ onChange: (e) => setChange(e.target.value),
3616
+ placeholder: WB.describeChange,
3617
+ "aria-label": WB.describeChangeAria,
3618
+ maxLength: BOARD2.changeMax,
3619
+ dir: "auto",
3620
+ onKeyDown: (e) => {
3621
+ if (e.key === "Escape") {
3622
+ e.stopPropagation();
3623
+ setAskOpen(false);
3624
+ }
3625
+ }
3626
+ }
3627
+ ),
3628
+ /* @__PURE__ */ jsx3("button", { type: "submit", className: "sp-wb-btn sp-wb-send", disabled: !change.trim(), children: WB.send })
3629
+ ] })
3630
+ },
3631
+ "change"
3632
+ ) }),
3633
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-toolbar", role: "toolbar", "aria-label": WB.toolbar, children: [
3634
+ TOOLS.map((t) => /* @__PURE__ */ jsxs2("div", { className: "sp-wb-anchor", children: [
3635
+ /* @__PURE__ */ jsxs2(
3636
+ "button",
3637
+ {
3638
+ type: "button",
3639
+ className: "sp-wb-tool",
3640
+ "aria-pressed": tool === t.id,
3641
+ title: `${t.label} (${t.key})`,
3642
+ "data-menu": t.id === "shape" || t.id === "pen" || void 0,
3643
+ onClick: () => {
3644
+ if (t.id === "shape" || t.id === "pen") setMenu(menu === t.id ? null : t.id);
3645
+ setTool(t.id);
3646
+ },
3647
+ children: [
3648
+ t.id === "shape" ? SHAPE_ICON : TOOL_ICON[t.id],
3649
+ /* @__PURE__ */ jsx3("span", { children: t.id === "shape" ? BOX_SHAPES.find((s) => s.id === boxShape).label : t.label })
3650
+ ]
3651
+ }
3652
+ ),
3653
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: t.id === "pen" && menu === "pen" && /* @__PURE__ */ jsxs2(motion2.div, { className: "sp-wb-pop sp-wb-pop-up sp-wb-pen-menu", role: "menu", "aria-label": WB.penMenu, ...POP_UP, children: [
3654
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-pop-group", role: "group", "aria-label": WB.penColorGroup, children: [
3655
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-pop-label", children: WB.penColorGroup }),
3656
+ INK_COLORS.map((c) => /* @__PURE__ */ jsxs2("button", { type: "button", role: "menuitemradio", "aria-checked": inkColor === c, "data-ink": c, onClick: () => {
3657
+ setInkColor(c);
3658
+ setTool("pen");
3659
+ }, children: [
3660
+ /* @__PURE__ */ jsx3("i", { className: "sp-wb-ink-dot", "aria-hidden": true }),
3661
+ WB.penColors[c]
3662
+ ] }, c))
3663
+ ] }),
3664
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-pop-group", role: "group", "aria-label": WB.penBrushGroup, children: [
3665
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-pop-label", children: WB.penBrushGroup }),
3666
+ ["pena", "spidol"].map((b) => /* @__PURE__ */ jsxs2("button", { type: "button", role: "menuitemradio", "aria-checked": inkBrush === b, "data-brush": b, onClick: () => {
3667
+ setInkBrush(b);
3668
+ setTool("pen");
3669
+ }, children: [
3670
+ /* @__PURE__ */ jsx3("i", { className: "sp-wb-brush-tip", "aria-hidden": true }),
3671
+ WB.penBrushes[b]
3672
+ ] }, b))
3673
+ ] }),
3674
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-pop-group", role: "group", "aria-label": WB.penSizeGroup, children: [
3675
+ /* @__PURE__ */ jsx3("span", { className: "sp-wb-pop-label", children: WB.penSizeGroup }),
3676
+ ["s", "m", "l"].map((z) => /* @__PURE__ */ jsxs2("button", { type: "button", role: "menuitemradio", "aria-checked": inkSize === z, "data-size": z, onClick: () => {
3677
+ setInkSize(z);
3678
+ setTool("pen");
3679
+ setMenu(null);
3680
+ }, children: [
3681
+ /* @__PURE__ */ jsx3("i", { className: "sp-wb-ink-width", "aria-hidden": true }),
3682
+ WB.penSizes[z]
3683
+ ] }, z))
3684
+ ] })
3685
+ ] }, "pen") }),
3686
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: t.id === "shape" && menu === "shape" && /* @__PURE__ */ jsx3(motion2.div, { className: "sp-wb-pop sp-wb-pop-up", role: "menu", ...POP_UP, children: BOX_SHAPES.map((s) => /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitemradio", "aria-checked": boxShape === s.id, onClick: () => {
3687
+ setBoxShape(s.id);
3688
+ setTool("shape");
3689
+ setMenu(null);
3690
+ }, children: s.label }, s.id)) }, "shape") })
3691
+ ] }, t.id)),
3692
+ /* @__PURE__ */ jsxs2("div", { className: "sp-wb-anchor", children: [
3693
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-tool", "data-menu": true, "aria-haspopup": "menu", "aria-expanded": menu === "sticker", onClick: () => setMenu(menu === "sticker" ? null : "sticker"), children: [
3694
+ STICKER_ICON,
3695
+ /* @__PURE__ */ jsx3("span", { children: WB.stickerTool })
3696
+ ] }),
3697
+ /* @__PURE__ */ jsx3(AnimatePresence2, { children: menu === "sticker" && /* @__PURE__ */ jsx3(motion2.div, { className: "sp-wb-pop sp-wb-pop-up sp-wb-stickers", role: "menu", "aria-label": WB.stickerMenu, ...POP_UP, children: ILLUSTRATIONS.map((name) => /* @__PURE__ */ jsx3("button", { type: "button", role: "menuitem", "aria-label": WB.stickerOf(name), title: WB.stickerOf(name), onClick: () => placeSticker(name), children: /* @__PURE__ */ jsx3(Art, { name, className: "sp-wb-pick-art" }) }, name)) }, "sticker") })
3698
+ ] }),
3699
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-tool", "aria-pressed": histOpen, "aria-expanded": histOpen, onClick: () => setHistOpen((o) => !o), children: [
3700
+ HISTORY_ICON,
3701
+ /* @__PURE__ */ jsx3("span", { children: WB.history })
3702
+ ] }),
3703
+ /* @__PURE__ */ jsxs2("button", { type: "button", className: "sp-wb-tool sp-wb-agent", "aria-pressed": askOpen, "aria-expanded": askOpen, onClick: () => setAskOpen((o) => !o), children: [
3704
+ AGENT_ICON,
3705
+ /* @__PURE__ */ jsx3("span", { children: WB.askAgent })
3706
+ ] })
3707
+ ] })
3708
+ ] })
3709
+ ]
3710
+ }
3711
+ )
3712
+ ] });
3713
+ }
3714
+
3715
+ // src/react/transport.ts
3716
+ async function json(r) {
3717
+ const d = await r.json().catch(() => ({}));
3718
+ if (!r.ok) throw new Error(typeof d.error === "string" ? d.error : typeof d.detail === "string" ? d.detail : `HTTP ${r.status}`);
3719
+ return d;
3720
+ }
3721
+ function httpTransport(url, init = () => ({})) {
3722
+ const join = (q) => `${url}${url.includes("?") ? "&" : "?"}${q}`;
3723
+ const send = async (target, extra = {}) => {
3724
+ const base = await init();
3725
+ return fetch(target, { ...base, ...extra, headers: { ...base.headers ?? {}, ...extra.headers ?? {} } });
3726
+ };
3727
+ const post = async (body) => await json(await send(url, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }));
3728
+ return {
3729
+ load: async (since) => await json(await send(since ? join(`since=${since}`) : url)),
3730
+ save: async (ops) => await json(await send(url, { method: "PATCH", headers: { "content-type": "application/json" }, body: JSON.stringify({ ops }) })),
3731
+ history: async () => {
3732
+ const d = await json(await send(join("history=1")));
3733
+ return Array.isArray(d.history) ? d.history : null;
3734
+ },
3735
+ at: async (version) => (await json(await send(join(`at=${version}`)))).board ?? null,
3736
+ restore: (version) => post({ restore: version }),
3737
+ decide: (action) => post(action)
3738
+ };
3739
+ }
3740
+ export {
3741
+ BOARD_SAVED,
3742
+ Whiteboard,
3743
+ httpTransport
3744
+ };
3745
+ //# sourceMappingURL=index.js.map