@guideai/react-native 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.cjs CHANGED
@@ -3,7 +3,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const reactNative = require("react-native");
6
- const useOnboarding = require("./useOnboarding-DWkCW5v0.cjs");
6
+ const setup = require("./setup-Bl0ZLz8B.cjs");
7
+ const useOnboarding = require("./useOnboarding-CFxofFst.cjs");
8
+ const Svg = require("react-native-svg");
7
9
  function parseInline(text) {
8
10
  const spans = [];
9
11
  const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(__[^_]+__)|(\*[^*\n]+\*)|(_[^_\n]+_)|(\[[^\]]+\]\([^)]+\))/g;
@@ -142,9 +144,9 @@ function Spans({ spans, style, accentColor }) {
142
144
  {
143
145
  style: [
144
146
  style,
145
- span.bold ? styles$3.bold : null,
146
- span.italic ? styles$3.italic : null,
147
- span.code ? styles$3.inlineCode : null
147
+ span.bold ? styles$4.bold : null,
148
+ span.italic ? styles$4.italic : null,
149
+ span.code ? styles$4.inlineCode : null
148
150
  ],
149
151
  children: span.text
150
152
  },
@@ -160,7 +162,7 @@ function Markdown({
160
162
  }) {
161
163
  const blocks = React.useMemo(() => parseMarkdown(children), [children]);
162
164
  const body = { color, fontSize, lineHeight: fontSize * 1.45 };
163
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.container, children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(
165
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.container, children: blocks.map((block, index) => /* @__PURE__ */ jsxRuntime.jsx(
164
166
  Block,
165
167
  {
166
168
  block,
@@ -176,7 +178,7 @@ function Block({ block, body, color, accentColor, fontSize }) {
176
178
  switch (block.type) {
177
179
  case "heading": {
178
180
  const sizes = { 1: fontSize + 6, 2: fontSize + 3, 3: fontSize + 1 };
179
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.heading, { color, fontSize: sizes[block.level] }], children: /* @__PURE__ */ jsxRuntime.jsx(
181
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$4.heading, { color, fontSize: sizes[block.level] }], children: /* @__PURE__ */ jsxRuntime.jsx(
180
182
  Spans,
181
183
  {
182
184
  spans: block.spans,
@@ -186,24 +188,24 @@ function Block({ block, body, color, accentColor, fontSize }) {
186
188
  ) });
187
189
  }
188
190
  case "paragraph":
189
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.paragraph, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) });
191
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$4.paragraph, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) });
190
192
  case "bullet":
191
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$3.listRow, { marginLeft: block.depth * 14 }], children: [
193
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
192
194
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [body, { color: accentColor }], children: "•" }),
193
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.listText, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) })
195
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$4.listText, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) })
194
196
  ] });
195
197
  case "ordered":
196
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$3.listRow, { marginLeft: block.depth * 14 }], children: [
198
+ return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
197
199
  /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: [body, { color: accentColor, fontVariant: ["tabular-nums"] }], children: [
198
200
  block.index,
199
201
  "."
200
202
  ] }),
201
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.listText, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) })
203
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$4.listText, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) })
202
204
  ] });
203
205
  case "code":
204
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.codeBlock, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
206
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.codeBlock, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$4.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
205
207
  case "quote":
206
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
208
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$4.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
207
209
  Spans,
208
210
  {
209
211
  spans: block.spans,
@@ -212,12 +214,12 @@ function Block({ block, body, color, accentColor, fontSize }) {
212
214
  }
213
215
  ) }) });
214
216
  case "rule":
215
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.rule });
217
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.rule });
216
218
  case "table": {
217
219
  const columns = Math.max(block.header.length, ...block.rows.map((r) => r.length), 1);
218
220
  const scrolls = columns > 3;
219
- const table = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$3.table, scrolls ? { minWidth: columns * 116 } : null], children: [
220
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.tableRow, styles$3.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
221
+ const table = /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$4.table, scrolls ? { minWidth: columns * 116 } : null], children: [
222
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$4.tableRow, styles$4.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
221
223
  Spans,
222
224
  {
223
225
  spans: cell,
@@ -225,7 +227,7 @@ function Block({ block, body, color, accentColor, fontSize }) {
225
227
  style: { ...body, fontWeight: "700", fontSize: fontSize - 1 }
226
228
  }
227
229
  ) }) }, index)) }),
228
- block.rows.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
230
+ block.rows.map((row, rowIndex) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
229
231
  Spans,
230
232
  {
231
233
  spans: cell,
@@ -249,7 +251,7 @@ function Block({ block, body, color, accentColor, fontSize }) {
249
251
  }
250
252
  }
251
253
  const mono = { fontFamily: "Menlo" };
252
- const styles$3 = reactNative.StyleSheet.create({
254
+ const styles$4 = reactNative.StyleSheet.create({
253
255
  container: { gap: 6 },
254
256
  heading: { fontWeight: "700", marginTop: 4 },
255
257
  paragraph: {},
@@ -285,6 +287,1011 @@ const styles$3 = reactNative.StyleSheet.create({
285
287
  tableHeaderRow: { backgroundColor: "rgba(100,116,139,0.10)" },
286
288
  tableCell: { flex: 1, padding: 8 }
287
289
  });
290
+ const STEP_GAP_MS = 450;
291
+ function readTime(text) {
292
+ const words = text.trim().split(/\s+/).filter(Boolean).length;
293
+ return Math.min(6500, Math.max(1500, words * 280));
294
+ }
295
+ const SPEEDS = [0.75, 1, 1.5, 2];
296
+ class Player {
297
+ constructor(steps, hooks, reducedMotion = false) {
298
+ var _a, _b, _c;
299
+ this.steps = steps;
300
+ this.hooks = hooks;
301
+ this.reducedMotion = reducedMotion;
302
+ this.state = "idle";
303
+ this.speed = 1;
304
+ this.stepIndex = -1;
305
+ this.opIndex = 0;
306
+ this.opElapsed = 0;
307
+ this.stepElapsed = 0;
308
+ this.holdElapsed = 0;
309
+ this.spoken = null;
310
+ this.narrationToken = 0;
311
+ this.frame = null;
312
+ this.last = 0;
313
+ this.requestFrame = (_a = hooks.requestFrame) != null ? _a : ((cb) => requestAnimationFrame(cb));
314
+ this.cancelFrame = (_b = hooks.cancelFrame) != null ? _b : ((id) => cancelAnimationFrame(id));
315
+ this.now = (_c = hooks.now) != null ? _c : (() => performance.now());
316
+ }
317
+ get current() {
318
+ return this.stepIndex;
319
+ }
320
+ get status() {
321
+ return this.state;
322
+ }
323
+ get rate() {
324
+ return this.speed;
325
+ }
326
+ setSpeed(speed) {
327
+ this.speed = Math.min(3, Math.max(0.25, speed));
328
+ }
329
+ play() {
330
+ if (this.state === "playing") return;
331
+ if (this.state === "done" || this.state === "idle") {
332
+ this.restart();
333
+ return;
334
+ }
335
+ this.setState("playing");
336
+ this.schedule();
337
+ }
338
+ pause() {
339
+ if (this.state !== "playing") return;
340
+ this.setState("paused");
341
+ this.unschedule();
342
+ if (this.spoken === null) {
343
+ this.narrationToken += 1;
344
+ this.hooks.stopNarration();
345
+ this.spoken = false;
346
+ }
347
+ }
348
+ replay() {
349
+ this.restart();
350
+ }
351
+ /**
352
+ * Jump to step *index*, as a scrubber does: the board is rebuilt with every
353
+ * step before it already drawn, then playback carries on from there.
354
+ */
355
+ seek(index) {
356
+ const target = Math.max(0, Math.min(this.steps.length - 1, Math.floor(index)));
357
+ this.unschedule();
358
+ this.narrationToken += 1;
359
+ this.hooks.stopNarration();
360
+ this.hooks.reset();
361
+ for (let i = 0; i < target; i += 1) {
362
+ const step = this.steps[i];
363
+ step.enter();
364
+ for (const op of step.ops) op.run(1);
365
+ }
366
+ this.stepIndex = -1;
367
+ this.setState("playing");
368
+ this.enterStep(target);
369
+ this.schedule();
370
+ }
371
+ /** Stop for good: no frames, no voice. */
372
+ destroy() {
373
+ this.unschedule();
374
+ this.narrationToken += 1;
375
+ this.hooks.stopNarration();
376
+ this.state = "done";
377
+ }
378
+ restart() {
379
+ this.unschedule();
380
+ this.narrationToken += 1;
381
+ this.hooks.stopNarration();
382
+ this.hooks.reset();
383
+ this.stepIndex = -1;
384
+ this.setState("playing");
385
+ this.enterStep(0);
386
+ this.schedule();
387
+ }
388
+ setState(state) {
389
+ var _a, _b;
390
+ if (this.state === state) return;
391
+ this.state = state;
392
+ (_b = (_a = this.hooks).onState) == null ? void 0 : _b.call(_a, state);
393
+ }
394
+ enterStep(index) {
395
+ var _a, _b;
396
+ const step = this.steps[index];
397
+ if (!step) {
398
+ this.unschedule();
399
+ this.setState("done");
400
+ return;
401
+ }
402
+ this.stepIndex = index;
403
+ this.opIndex = 0;
404
+ this.opElapsed = 0;
405
+ this.stepElapsed = 0;
406
+ this.holdElapsed = 0;
407
+ this.spoken = null;
408
+ step.enter();
409
+ (_b = (_a = this.hooks).onStep) == null ? void 0 : _b.call(_a, index, step);
410
+ const token = ++this.narrationToken;
411
+ this.hooks.narrate(step.say).then(
412
+ (said) => {
413
+ if (token === this.narrationToken) this.spoken = said;
414
+ },
415
+ () => {
416
+ if (token === this.narrationToken) this.spoken = false;
417
+ }
418
+ );
419
+ if (this.reducedMotion) {
420
+ for (const op of step.ops) op.run(1);
421
+ this.opIndex = step.ops.length;
422
+ }
423
+ }
424
+ schedule() {
425
+ if (this.frame !== null || this.state !== "playing") return;
426
+ this.last = this.now();
427
+ this.frame = this.requestFrame((t) => this.tick(t));
428
+ }
429
+ unschedule() {
430
+ if (this.frame !== null) this.cancelFrame(this.frame);
431
+ this.frame = null;
432
+ }
433
+ /** One frame. Public so tests can drive time by hand. */
434
+ tick(now) {
435
+ this.frame = null;
436
+ if (this.state !== "playing") return;
437
+ const dt = Math.max(0, Math.min(100, now - this.last)) * this.speed;
438
+ this.last = now;
439
+ this.advance(dt);
440
+ if (this.state === "playing") this.frame = this.requestFrame((t) => this.tick(t));
441
+ }
442
+ advance(dt) {
443
+ const step = this.steps[this.stepIndex];
444
+ if (!step) return;
445
+ this.stepElapsed += dt;
446
+ let left = dt;
447
+ while (this.opIndex < step.ops.length && left > 0) {
448
+ const op = step.ops[this.opIndex];
449
+ const remaining = op.duration - this.opElapsed;
450
+ if (op.duration <= 0 || left >= remaining) {
451
+ op.run(1);
452
+ left -= Math.max(0, remaining);
453
+ this.opIndex += 1;
454
+ this.opElapsed = 0;
455
+ } else {
456
+ this.opElapsed += left;
457
+ op.run(this.opElapsed / op.duration);
458
+ left = 0;
459
+ }
460
+ }
461
+ while (this.opIndex < step.ops.length && step.ops[this.opIndex].duration <= 0) {
462
+ step.ops[this.opIndex].run(1);
463
+ this.opIndex += 1;
464
+ }
465
+ if (this.opIndex < step.ops.length || this.spoken === null) return;
466
+ const hold = this.spoken ? 0 : readTime(step.say);
467
+ if (this.stepElapsed < hold) return;
468
+ this.holdElapsed += dt;
469
+ if (this.holdElapsed < STEP_GAP_MS) return;
470
+ this.enterStep(this.stepIndex + 1);
471
+ }
472
+ }
473
+ const STORYBOARD_ICON_STROKES = {
474
+ phone: [
475
+ "M 32 6 Q 24 6 24 14 L 24 86 Q 24 94 32 94 L 68 94 Q 76 94 76 86 L 76 14 Q 76 6 68 6 Z",
476
+ "M 43 13 L 57 13",
477
+ "M 41 88 L 59 88"
478
+ ],
479
+ screen: [
480
+ "M 8 18 L 92 18 L 92 66 L 8 66 Z",
481
+ "M 42 66 L 38 84 L 62 84 L 58 66",
482
+ "M 30 84 L 70 84"
483
+ ],
484
+ window: [
485
+ "M 6 16 L 94 16 L 94 84 L 6 84 Z",
486
+ "M 6 32 L 94 32",
487
+ "M 11 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0 M 23 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0 M 35 24 a 3 3 0 1 0 6 0 a 3 3 0 1 0 -6 0"
488
+ ],
489
+ video: [
490
+ "M 8 20 L 92 20 L 92 80 L 8 80 Z",
491
+ "M 20 20 L 20 80 M 80 20 L 80 80",
492
+ "M 42 40 L 64 50 L 42 60 Z"
493
+ ],
494
+ play: [
495
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
496
+ "M 40 32 L 70 50 L 40 68 Z"
497
+ ],
498
+ input: [
499
+ "M 6 36 L 94 36 L 94 64 L 6 64 Z",
500
+ "M 18 43 L 18 57",
501
+ "M 28 50 L 66 50"
502
+ ],
503
+ cursor: [
504
+ "M 24 12 L 24 74 L 39 60 L 49 82 L 60 77 L 50 56 L 70 55 Z"
505
+ ],
506
+ document: [
507
+ "M 24 8 L 62 8 L 78 26 L 78 92 L 24 92 Z",
508
+ "M 62 8 L 62 26 L 78 26",
509
+ "M 36 44 L 66 44 M 36 58 L 66 58 M 36 72 L 54 72"
510
+ ],
511
+ image: [
512
+ "M 10 20 L 90 20 L 90 80 L 10 80 Z",
513
+ "M 10 68 L 36 44 L 56 64 L 68 54 L 90 74",
514
+ "M 61 34 a 7 7 0 1 0 14 0 a 7 7 0 1 0 -14 0"
515
+ ],
516
+ gear: [
517
+ "M 50.0 17.0 L 58.8 5.9 L 67.2 8.4 L 68.3 22.6 L 73.3 26.7 L 87.4 25.0 L 91.6 32.8 L 82.4 43.6 L 83.0 50.0 L 94.1 58.8 L 91.6 67.2 L 77.4 68.3 L 73.3 73.3 L 75.0 87.4 L 67.2 91.6 L 56.4 82.4 L 50.0 83.0 L 41.2 94.1 L 32.8 91.6 L 31.7 77.4 L 26.7 73.3 L 12.6 75.0 L 8.4 67.2 L 17.6 56.4 L 17.0 50.0 L 5.9 41.2 L 8.4 32.8 L 22.6 31.7 L 26.7 26.7 L 25.0 12.6 L 32.8 8.4 L 43.6 17.6 Z",
518
+ "M 39 50 a 11 11 0 1 0 22 0 a 11 11 0 1 0 -22 0"
519
+ ],
520
+ cloud: [
521
+ "M 28 74 Q 8 74 8 58 Q 8 44 24 42 Q 28 22 48 22 Q 68 22 72 42 Q 92 44 92 58 Q 92 74 74 74 Z"
522
+ ],
523
+ database: [
524
+ "M 18 24 a 32 10 0 1 0 64 0 a 32 10 0 1 0 -64 0",
525
+ "M 18 24 L 18 76 Q 18 88 50 88 Q 82 88 82 76 L 82 24",
526
+ "M 18 50 Q 18 62 50 62 Q 82 62 82 50"
527
+ ],
528
+ user: [
529
+ "M 33 31 a 17 17 0 1 0 34 0 a 17 17 0 1 0 -34 0",
530
+ "M 16 88 Q 16 56 50 56 Q 84 56 84 88"
531
+ ],
532
+ sparkle: [
533
+ "M 50 6 Q 56 40 90 50 Q 56 60 50 94 Q 44 60 10 50 Q 44 40 50 6 Z"
534
+ ],
535
+ check: [
536
+ "M 16 54 L 40 78 L 86 22"
537
+ ],
538
+ clock: [
539
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
540
+ "M 50 26 L 50 52 L 70 62"
541
+ ],
542
+ lock: [
543
+ "M 22 46 L 78 46 L 78 90 L 22 90 Z",
544
+ "M 34 46 L 34 30 Q 34 12 50 12 Q 66 12 66 30 L 66 46",
545
+ "M 50 62 L 50 74"
546
+ ],
547
+ chat: [
548
+ "M 10 20 L 90 20 L 90 68 L 46 68 L 26 86 L 28 68 L 10 68 Z",
549
+ "M 28 38 L 72 38 M 28 52 L 60 52"
550
+ ],
551
+ cross: [
552
+ "M 22 22 L 78 78",
553
+ "M 78 22 L 22 78"
554
+ ],
555
+ server: [
556
+ "M 16 10 L 84 10 L 84 34 L 16 34 Z",
557
+ "M 16 38 L 84 38 L 84 62 L 16 62 Z",
558
+ "M 16 66 L 84 66 L 84 90 L 16 90 Z",
559
+ "M 26 22 L 32 22 M 26 50 L 32 50 M 26 78 L 32 78",
560
+ "M 54 22 L 74 22 M 54 50 L 74 50 M 54 78 L 74 78"
561
+ ],
562
+ queue: [
563
+ "M 6 32 L 94 32 M 6 68 L 94 68",
564
+ "M 14 40 L 30 40 L 30 60 L 14 60 Z",
565
+ "M 38 40 L 54 40 L 54 60 L 38 60 Z",
566
+ "M 62 40 L 78 40 L 78 60 L 62 60 Z",
567
+ "M 82 50 L 94 50 M 88 44 L 94 50 L 88 56"
568
+ ],
569
+ globe: [
570
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
571
+ "M 50 8 Q 22 50 50 92 Q 78 50 50 8",
572
+ "M 8 50 L 92 50",
573
+ "M 16 28 L 84 28 M 16 72 L 84 72"
574
+ ],
575
+ balancer: [
576
+ "M 36 8 L 64 8 L 64 30 L 36 30 Z",
577
+ "M 50 30 L 50 46 M 18 46 L 82 46 M 18 46 L 18 62 M 50 46 L 50 62 M 82 46 L 82 62",
578
+ "M 8 62 L 28 62 L 28 86 L 8 86 Z",
579
+ "M 40 62 L 60 62 L 60 86 L 40 86 Z",
580
+ "M 72 62 L 92 62 L 92 86 L 72 86 Z"
581
+ ],
582
+ cache: [
583
+ "M 58 6 L 24 54 L 48 54 L 40 94 L 78 40 L 54 40 Z"
584
+ ],
585
+ container: [
586
+ "M 50 8 L 88 28 L 88 72 L 50 92 L 12 72 L 12 28 Z",
587
+ "M 12 28 L 50 48 L 88 28",
588
+ "M 50 48 L 50 92"
589
+ ]
590
+ };
591
+ function storyboardIconStrokes(icon) {
592
+ var _a;
593
+ return (_a = STORYBOARD_ICON_STROKES[icon]) != null ? _a : [];
594
+ }
595
+ const SHEET_W$1 = 1600;
596
+ const SHEET_H$1 = 1e3;
597
+ const sx = (x) => x * (SHEET_W$1 / 160);
598
+ const sy = (y) => y * (SHEET_H$1 / 100);
599
+ function seeded(seed) {
600
+ let s = seed >>> 0 || 1;
601
+ return () => {
602
+ s ^= s << 13;
603
+ s ^= s >>> 17;
604
+ s ^= s << 5;
605
+ return (s >>> 0) % 1e4 / 1e4;
606
+ };
607
+ }
608
+ function strokeLength(stroke) {
609
+ let length = 0;
610
+ for (let i = 1; i < stroke.length; i += 1) {
611
+ length += Math.hypot(stroke[i].x - stroke[i - 1].x, stroke[i].y - stroke[i - 1].y);
612
+ }
613
+ return length;
614
+ }
615
+ function totalLength(strokes) {
616
+ return strokes.reduce((sum, s) => sum + strokeLength(s), 0);
617
+ }
618
+ function bounds(strokes) {
619
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
620
+ for (const s of strokes) for (const p of s) {
621
+ x0 = Math.min(x0, p.x);
622
+ y0 = Math.min(y0, p.y);
623
+ x1 = Math.max(x1, p.x);
624
+ y1 = Math.max(y1, p.y);
625
+ }
626
+ return Number.isFinite(x0) ? { x0, y0, x1, y1 } : null;
627
+ }
628
+ function handLine(a, b, rand, steps = 14) {
629
+ const length = Math.hypot(b.x - a.x, b.y - a.y) || 1;
630
+ const nx = -(b.y - a.y) / length;
631
+ const ny = (b.x - a.x) / length;
632
+ const bow = (rand() - 0.5) * Math.min(18, length * 0.04);
633
+ const out = [];
634
+ for (let i = 0; i <= steps; i += 1) {
635
+ const t = i / steps;
636
+ const lift = Math.sin(Math.PI * t) * bow + (rand() - 0.5) * 1.6;
637
+ out.push({ x: a.x + (b.x - a.x) * t + nx * lift, y: a.y + (b.y - a.y) * t + ny * lift });
638
+ }
639
+ return out;
640
+ }
641
+ function handEllipse(b, rand) {
642
+ const cx = sx(b[0] + b[2] / 2);
643
+ const cy = sy(b[1] + b[3] / 2);
644
+ const rx = sx(b[2]) / 2 + 8;
645
+ const ry = sy(b[3]) / 2 + 8;
646
+ const start = -Math.PI * (0.55 + rand() * 0.2);
647
+ const sweep = Math.PI * 2 * (1.06 + rand() * 0.05);
648
+ const out = [];
649
+ const n = 48;
650
+ for (let i = 0; i <= n; i += 1) {
651
+ const t = i / n;
652
+ const a = start + sweep * t;
653
+ const grow = 1 + (t - 0.5) * 0.06 + (rand() - 0.5) * 0.012;
654
+ out.push({ x: cx + Math.cos(a) * rx * grow, y: cy + Math.sin(a) * ry * grow });
655
+ }
656
+ return out;
657
+ }
658
+ function smooth(points, per = 8) {
659
+ if (points.length < 3) return points;
660
+ const out = [];
661
+ for (let i = 0; i < points.length - 1; i += 1) {
662
+ const p0 = points[Math.max(0, i - 1)];
663
+ const p1 = points[i];
664
+ const p2 = points[i + 1];
665
+ const p3 = points[Math.min(points.length - 1, i + 2)];
666
+ for (let j = 0; j < per; j += 1) {
667
+ const t = j / per;
668
+ const t2 = t * t;
669
+ const t3 = t2 * t;
670
+ out.push({
671
+ x: 0.5 * (2 * p1.x + (-p0.x + p2.x) * t + (2 * p0.x - 5 * p1.x + 4 * p2.x - p3.x) * t2 + (-p0.x + 3 * p1.x - 3 * p2.x + p3.x) * t3),
672
+ y: 0.5 * (2 * p1.y + (-p0.y + p2.y) * t + (2 * p0.y - 5 * p1.y + 4 * p2.y - p3.y) * t2 + (-p0.y + 3 * p1.y - 3 * p2.y + p3.y) * t3)
673
+ });
674
+ }
675
+ }
676
+ out.push(points[points.length - 1]);
677
+ return out;
678
+ }
679
+ function arrowHead(from, to, rand) {
680
+ const angle = Math.atan2(to.y - from.y, to.x - from.x);
681
+ const size = 26 + rand() * 6;
682
+ const spread = 0.45;
683
+ return [
684
+ { x: to.x - size * Math.cos(angle - spread), y: to.y - size * Math.sin(angle - spread) },
685
+ to,
686
+ { x: to.x - size * Math.cos(angle + spread), y: to.y - size * Math.sin(angle + spread) }
687
+ ];
688
+ }
689
+ const corner = (b) => {
690
+ const x0 = sx(b[0]), y0 = sy(b[1]), x1 = sx(b[0] + b[2]), y1 = sy(b[1] + b[3]);
691
+ return [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }];
692
+ };
693
+ function handPoly(points, closed, rand) {
694
+ const corners = closed ? [...points, points[0]] : points;
695
+ const out = [];
696
+ for (let i = 1; i < corners.length; i += 1) {
697
+ const length = Math.hypot(corners[i].x - corners[i - 1].x, corners[i].y - corners[i - 1].y);
698
+ const segment = handLine(corners[i - 1], corners[i], rand, Math.max(6, Math.min(24, Math.round(length / 30))));
699
+ out.push(...i === 1 ? segment : segment.slice(1));
700
+ }
701
+ return out;
702
+ }
703
+ function handOval(b, rand) {
704
+ const cx = sx(b[0] + b[2] / 2);
705
+ const cy = sy(b[1] + b[3] / 2);
706
+ const rx = sx(b[2]) / 2;
707
+ const ry = sy(b[3]) / 2;
708
+ const start = -Math.PI * (0.6 + rand() * 0.2);
709
+ const sweep = Math.PI * 2 * (1.03 + rand() * 0.03);
710
+ const n = Math.max(32, Math.round((rx + ry) / 6));
711
+ const out = [];
712
+ for (let i = 0; i <= n; i += 1) {
713
+ const a = start + sweep * i / n;
714
+ const wobble = 1 + (rand() - 0.5) * 0.012;
715
+ out.push({ x: cx + Math.cos(a) * rx * wobble, y: cy + Math.sin(a) * ry * wobble });
716
+ }
717
+ return out;
718
+ }
719
+ const unit = (from, to) => {
720
+ const d = Math.hypot(to.x - from.x, to.y - from.y) || 1;
721
+ return { x: (to.x - from.x) / d, y: (to.y - from.y) / d };
722
+ };
723
+ function rightAngle(a, v, b, rand) {
724
+ const size = Math.min(44, 0.3 * Math.min(Math.hypot(a.x - v.x, a.y - v.y), Math.hypot(b.x - v.x, b.y - v.y)));
725
+ const ua = unit(v, a);
726
+ const ub = unit(v, b);
727
+ const p1 = { x: v.x + ua.x * size, y: v.y + ua.y * size };
728
+ const p2 = { x: p1.x + ub.x * size, y: p1.y + ub.y * size };
729
+ const p3 = { x: v.x + ub.x * size, y: v.y + ub.y * size };
730
+ return handPoly([p1, p2, p3], false, rand);
731
+ }
732
+ function angleArc(a, v, b, rand) {
733
+ const r = Math.min(70, 0.3 * Math.min(Math.hypot(a.x - v.x, a.y - v.y), Math.hypot(b.x - v.x, b.y - v.y)));
734
+ const from = Math.atan2(a.y - v.y, a.x - v.x);
735
+ let delta = Math.atan2(b.y - v.y, b.x - v.x) - from;
736
+ while (delta > Math.PI) delta -= 2 * Math.PI;
737
+ while (delta < -Math.PI) delta += 2 * Math.PI;
738
+ const n = 18;
739
+ const out = [];
740
+ for (let i = 0; i <= n; i += 1) {
741
+ const t = from + delta * i / n;
742
+ const rr = r * (1 + (rand() - 0.5) * 0.03);
743
+ out.push({ x: v.x + Math.cos(t) * rr, y: v.y + Math.sin(t) * rr });
744
+ }
745
+ return out;
746
+ }
747
+ function handDot(c) {
748
+ const out = [];
749
+ for (let i = 0; i <= 14; i += 1) {
750
+ const t = i / 14 * Math.PI * 4;
751
+ const r = 7 * (1 - i / 16);
752
+ out.push({ x: c.x + Math.cos(t) * r, y: c.y + Math.sin(t) * r });
753
+ }
754
+ return out;
755
+ }
756
+ function roughen(strokes, seed, amount = 2.2) {
757
+ const rand = seeded(seed);
758
+ return strokes.map((stroke) => {
759
+ let dx = 0;
760
+ let dy = 0;
761
+ return stroke.map((p) => {
762
+ dx = dx * 0.6 + (rand() - 0.5) * amount;
763
+ dy = dy * 0.6 + (rand() - 0.5) * amount;
764
+ return { x: p.x + dx, y: p.y + dy };
765
+ });
766
+ });
767
+ }
768
+ function inkStrokes(kind, geometry, seed) {
769
+ var _a, _b, _c;
770
+ const rand = seeded(seed);
771
+ const p = (q) => ({ x: sx(q[0]), y: sy(q[1]) });
772
+ const pts = (_b = (_a = geometry.pts) == null ? void 0 : _a.map(p)) != null ? _b : [];
773
+ switch (kind) {
774
+ case "line":
775
+ case "arrow": {
776
+ if (!geometry.at || geometry.at.length !== 2 || !geometry.to) return [];
777
+ const a = p(geometry.at);
778
+ const b2 = p(geometry.to);
779
+ const shaft = handLine(a, b2, rand);
780
+ return kind === "arrow" ? [shaft, arrowHead((_c = shaft[shaft.length - 2]) != null ? _c : a, b2, rand)] : [shaft];
781
+ }
782
+ case "free":
783
+ case "curve":
784
+ return pts.length >= 2 ? [smooth(pts)] : [];
785
+ case "poly":
786
+ return pts.length >= 2 ? [handPoly(pts, !!geometry.closed && pts.length > 2, rand)] : [];
787
+ case "corner":
788
+ return pts.length === 3 ? [rightAngle(pts[0], pts[1], pts[2], rand)] : [];
789
+ case "arc":
790
+ return pts.length === 3 ? [angleArc(pts[0], pts[1], pts[2], rand)] : [];
791
+ case "dot":
792
+ return geometry.at && geometry.at.length === 2 ? [handDot(p(geometry.at))] : [];
793
+ }
794
+ const b = geometry.at && geometry.at.length === 4 ? geometry.at : null;
795
+ if (!b) return [];
796
+ const [tl, tr, br, bl] = corner(b);
797
+ switch (kind) {
798
+ case "oval":
799
+ return [handOval(b, rand)];
800
+ case "circle":
801
+ return [handEllipse(b, rand)];
802
+ case "box":
803
+ return [handLine(tl, tr, rand, 10), handLine(tr, br, rand, 8), handLine(br, bl, rand, 10), handLine(bl, tl, rand, 8)];
804
+ case "underline": {
805
+ const y = br.y + 6;
806
+ return [handLine({ x: bl.x - 4, y }, { x: br.x + 4, y: y + (rand() - 0.5) * 6 }, rand, 18)];
807
+ }
808
+ case "cross":
809
+ return [handLine(tl, br, rand, 10), handLine(tr, bl, rand, 10)];
810
+ case "tick": {
811
+ const mid = { x: tl.x + (br.x - tl.x) * 0.38, y: br.y };
812
+ return [[...handLine({ x: tl.x, y: tl.y + (br.y - tl.y) * 0.55 }, mid, rand, 6), ...handLine(mid, tr, rand, 10).slice(1)]];
813
+ }
814
+ case "bracket": {
815
+ const x = tr.x;
816
+ const mid = (tr.y + br.y) / 2;
817
+ return [smooth([{ x: x - 14, y: tr.y }, { x, y: tr.y + 12 }, { x, y: mid - 12 }, { x: x + 14, y: mid }, { x, y: mid + 12 }, { x, y: br.y - 12 }, { x: x - 14, y: br.y }], 5)];
818
+ }
819
+ default:
820
+ return [];
821
+ }
822
+ }
823
+ const TOKEN = /([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g;
824
+ function flattenPath(d, curveSteps = 8) {
825
+ var _a;
826
+ const tokens = [];
827
+ for (const m of d.matchAll(TOKEN)) tokens.push((_a = m[1]) != null ? _a : Number(m[2]));
828
+ const strokes = [];
829
+ let current = [];
830
+ let x = 0, y = 0, startX = 0, startY = 0;
831
+ let lastCtrl = null;
832
+ let lastQuad = null;
833
+ let cmd = "";
834
+ let i = 0;
835
+ const next = () => {
836
+ const v = tokens[i++];
837
+ return typeof v === "number" ? v : NaN;
838
+ };
839
+ const hasNumber = () => typeof tokens[i] === "number";
840
+ const push = (px, py) => {
841
+ current.push({ x: px, y: py });
842
+ };
843
+ const finish = () => {
844
+ if (current.length > 1) strokes.push(current);
845
+ current = [];
846
+ };
847
+ const cubic = (c1, c2, end) => {
848
+ const sx0 = x, sy0 = y;
849
+ for (let s = 1; s <= curveSteps; s += 1) {
850
+ const t = s / curveSteps;
851
+ const u = 1 - t;
852
+ push(
853
+ u * u * u * sx0 + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * end.x,
854
+ u * u * u * sy0 + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * end.y
855
+ );
856
+ }
857
+ x = end.x;
858
+ y = end.y;
859
+ };
860
+ const quad = (c, end) => {
861
+ const sx0 = x, sy0 = y;
862
+ for (let s = 1; s <= curveSteps; s += 1) {
863
+ const t = s / curveSteps;
864
+ const u = 1 - t;
865
+ push(u * u * sx0 + 2 * u * t * c.x + t * t * end.x, u * u * sy0 + 2 * u * t * c.y + t * t * end.y);
866
+ }
867
+ x = end.x;
868
+ y = end.y;
869
+ };
870
+ while (i < tokens.length) {
871
+ if (typeof tokens[i] === "string") cmd = tokens[i++];
872
+ else if (!cmd) {
873
+ i += 1;
874
+ continue;
875
+ }
876
+ const rel = cmd === cmd.toLowerCase();
877
+ const ox = rel ? x : 0;
878
+ const oy = rel ? y : 0;
879
+ switch (cmd.toUpperCase()) {
880
+ case "M": {
881
+ finish();
882
+ x = ox + next();
883
+ y = oy + next();
884
+ startX = x;
885
+ startY = y;
886
+ push(x, y);
887
+ cmd = rel ? "l" : "L";
888
+ lastCtrl = lastQuad = null;
889
+ break;
890
+ }
891
+ case "L":
892
+ x = ox + next();
893
+ y = oy + next();
894
+ push(x, y);
895
+ lastCtrl = lastQuad = null;
896
+ break;
897
+ case "H":
898
+ x = ox + next();
899
+ push(x, y);
900
+ lastCtrl = lastQuad = null;
901
+ break;
902
+ case "V":
903
+ y = oy + next();
904
+ push(x, y);
905
+ lastCtrl = lastQuad = null;
906
+ break;
907
+ case "C": {
908
+ const c1 = { x: ox + next(), y: oy + next() };
909
+ const c2 = { x: ox + next(), y: oy + next() };
910
+ const end = { x: ox + next(), y: oy + next() };
911
+ cubic(c1, c2, end);
912
+ lastCtrl = c2;
913
+ lastQuad = null;
914
+ break;
915
+ }
916
+ case "S": {
917
+ const c1 = lastCtrl ? { x: 2 * x - lastCtrl.x, y: 2 * y - lastCtrl.y } : { x, y };
918
+ const c2 = { x: ox + next(), y: oy + next() };
919
+ const end = { x: ox + next(), y: oy + next() };
920
+ cubic(c1, c2, end);
921
+ lastCtrl = c2;
922
+ lastQuad = null;
923
+ break;
924
+ }
925
+ case "Q": {
926
+ const c = { x: ox + next(), y: oy + next() };
927
+ const end = { x: ox + next(), y: oy + next() };
928
+ quad(c, end);
929
+ lastQuad = c;
930
+ lastCtrl = null;
931
+ break;
932
+ }
933
+ case "T": {
934
+ const c = lastQuad ? { x: 2 * x - lastQuad.x, y: 2 * y - lastQuad.y } : { x, y };
935
+ const end = { x: ox + next(), y: oy + next() };
936
+ quad(c, end);
937
+ lastQuad = c;
938
+ lastCtrl = null;
939
+ break;
940
+ }
941
+ case "A": {
942
+ const rx = next(), ry = next(), rotation = next(), large = next(), sweep = next();
943
+ const end = { x: ox + next(), y: oy + next() };
944
+ for (const p of arcPoints({ x, y }, end, rx, ry, rotation, large !== 0, sweep !== 0, curveSteps * 2)) push(p.x, p.y);
945
+ x = end.x;
946
+ y = end.y;
947
+ lastCtrl = lastQuad = null;
948
+ break;
949
+ }
950
+ case "Z":
951
+ push(startX, startY);
952
+ x = startX;
953
+ y = startY;
954
+ finish();
955
+ current = [{ x, y }];
956
+ lastCtrl = lastQuad = null;
957
+ if (hasNumber()) cmd = rel ? "l" : "L";
958
+ else cmd = "";
959
+ break;
960
+ default:
961
+ i += 1;
962
+ }
963
+ if (Number.isNaN(x) || Number.isNaN(y)) return strokes;
964
+ }
965
+ finish();
966
+ return strokes;
967
+ }
968
+ function arcPoints(from, to, rx, ry, degrees, large, sweep, steps) {
969
+ if (!rx || !ry || from.x === to.x && from.y === to.y) return [to];
970
+ const phi = degrees * Math.PI / 180;
971
+ const cos = Math.cos(phi), sin = Math.sin(phi);
972
+ const dx = (from.x - to.x) / 2, dy = (from.y - to.y) / 2;
973
+ const x1 = cos * dx + sin * dy, y1 = -sin * dx + cos * dy;
974
+ let rxa = Math.abs(rx), rya = Math.abs(ry);
975
+ const scale = x1 * x1 / (rxa * rxa) + y1 * y1 / (rya * rya);
976
+ if (scale > 1) {
977
+ rxa *= Math.sqrt(scale);
978
+ rya *= Math.sqrt(scale);
979
+ }
980
+ const num = rxa * rxa * rya * rya - rxa * rxa * y1 * y1 - rya * rya * x1 * x1;
981
+ const den = rxa * rxa * y1 * y1 + rya * rya * x1 * x1;
982
+ const k = (large === sweep ? -1 : 1) * Math.sqrt(Math.max(0, num / den));
983
+ const cx1 = k * rxa * y1 / rya, cy1 = -k * rya * x1 / rxa;
984
+ const cx = cos * cx1 - sin * cy1 + (from.x + to.x) / 2;
985
+ const cy = sin * cx1 + cos * cy1 + (from.y + to.y) / 2;
986
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
987
+ const start = angle(1, 0, (x1 - cx1) / rxa, (y1 - cy1) / rya);
988
+ let delta = angle((x1 - cx1) / rxa, (y1 - cy1) / rya, (-x1 - cx1) / rxa, (-y1 - cy1) / rya);
989
+ if (!sweep && delta > 0) delta -= 2 * Math.PI;
990
+ if (sweep && delta < 0) delta += 2 * Math.PI;
991
+ const out = [];
992
+ for (let i = 1; i <= steps; i += 1) {
993
+ const t = start + delta * i / steps;
994
+ out.push({ x: cx + rxa * Math.cos(t) * cos - rya * Math.sin(t) * sin, y: cy + rxa * Math.cos(t) * sin + rya * Math.sin(t) * cos });
995
+ }
996
+ out[out.length - 1] = to;
997
+ return out;
998
+ }
999
+ function parseTransform(transform) {
1000
+ const t = /translate\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
1001
+ const s = /scale\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
1002
+ const kx = s ? Number(s[1]) : 1;
1003
+ return {
1004
+ tx: t ? Number(t[1]) : 0,
1005
+ ty: t && t[2] !== void 0 ? Number(t[2]) : 0,
1006
+ kx,
1007
+ ky: s && s[2] !== void 0 ? Number(s[2]) : kx
1008
+ };
1009
+ }
1010
+ function fit(strokes, viewBox, transform, b) {
1011
+ const [vx, vy, vw, vh] = viewBox.split(/[\s,]+/).map(Number);
1012
+ const w = vw > 0 ? vw : 100;
1013
+ const h = vh > 0 ? vh : 100;
1014
+ const { tx, ty, kx, ky } = parseTransform(transform);
1015
+ const bx = sx(b[0]), by = sy(b[1]), bw = sx(b[2]), bh = sy(b[3]);
1016
+ const k = Math.min(bw / w, bh / h);
1017
+ const offX = bx + (bw - w * k) / 2;
1018
+ const offY = by + (bh - h * k) / 2;
1019
+ return strokes.map((stroke) => stroke.map((p) => ({
1020
+ x: offX + (tx + kx * p.x - (vx || 0)) * k,
1021
+ y: offY + (ty + ky * p.y - (vy || 0)) * k
1022
+ })));
1023
+ }
1024
+ function artStrokes(ink, b, seed = 1) {
1025
+ if ("icon" in ink) {
1026
+ const paths = storyboardIconStrokes(ink.icon);
1027
+ return roughen(fit(paths.flatMap((d) => flattenPath(d, 14)), "0 0 100 100", "", b), seed);
1028
+ }
1029
+ return fit(ink.contours.flatMap((d) => flattenPath(d, 6)), ink.view_box, ink.transform, b);
1030
+ }
1031
+ function pointAlong(strokes, length) {
1032
+ let left = length;
1033
+ for (const s of strokes) {
1034
+ for (let i = 1; i < s.length; i += 1) {
1035
+ const seg = Math.hypot(s[i].x - s[i - 1].x, s[i].y - s[i - 1].y);
1036
+ if (left <= seg) {
1037
+ const t = seg ? left / seg : 1;
1038
+ return { x: s[i - 1].x + (s[i].x - s[i - 1].x) * t, y: s[i - 1].y + (s[i].y - s[i - 1].y) * t };
1039
+ }
1040
+ left -= seg;
1041
+ }
1042
+ }
1043
+ const last = strokes[strokes.length - 1];
1044
+ return last ? last[last.length - 1] : null;
1045
+ }
1046
+ const INK = { ink: "#1f2937", blue: "#2563eb", red: "#dc2626", green: "#059669" };
1047
+ const MARKER = "rgba(250, 204, 21, 0.42)";
1048
+ const TEXT_SIZE = { s: 2.3, m: 3.1, l: 4.3 };
1049
+ const TRAVEL_MS = 200;
1050
+ class BoardModel {
1051
+ constructor(options) {
1052
+ this.options = options;
1053
+ this.inks = [];
1054
+ this.words = [];
1055
+ this.pen = null;
1056
+ this.caption = "";
1057
+ this.step = -1;
1058
+ this.player = null;
1059
+ this.scene = null;
1060
+ this.nextKey = 1;
1061
+ }
1062
+ snapshot() {
1063
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1064
+ return {
1065
+ inks: this.inks,
1066
+ words: this.words,
1067
+ pen: this.pen,
1068
+ caption: this.caption,
1069
+ step: this.step,
1070
+ steps: (_b = (_a = this.scene) == null ? void 0 : _a.steps.length) != null ? _b : 0,
1071
+ state: (_d = (_c = this.player) == null ? void 0 : _c.status) != null ? _d : "idle",
1072
+ title: (_f = (_e = this.scene) == null ? void 0 : _e.title) != null ? _f : "",
1073
+ sample: (_h = (_g = this.scene) == null ? void 0 : _g.sample) != null ? _h : false
1074
+ };
1075
+ }
1076
+ play(scene) {
1077
+ var _a, _b, _c, _d, _e;
1078
+ this.destroy();
1079
+ this.scene = scene;
1080
+ const steps = scene.steps.map((step, index) => this.buildStep(step, index));
1081
+ this.player = new Player(steps, {
1082
+ narrate: (_a = this.options.narrate) != null ? _a : (async () => false),
1083
+ stopNarration: () => {
1084
+ var _a2, _b2;
1085
+ return (_b2 = (_a2 = this.options).stopNarration) == null ? void 0 : _b2.call(_a2);
1086
+ },
1087
+ reset: () => this.wipe(),
1088
+ onStep: (index, step) => {
1089
+ this.step = index;
1090
+ this.caption = step.say;
1091
+ this.changed();
1092
+ },
1093
+ onState: () => this.changed(),
1094
+ requestFrame: (_b = this.options.requestFrame) != null ? _b : ((cb) => requestAnimationFrame(cb)),
1095
+ cancelFrame: (_c = this.options.cancelFrame) != null ? _c : ((id) => cancelAnimationFrame(id)),
1096
+ now: (_d = this.options.now) != null ? _d : (() => Date.now())
1097
+ }, (_e = this.options.reducedMotion) != null ? _e : false);
1098
+ this.player.play();
1099
+ }
1100
+ /** Pause, or carry on from where it was. */
1101
+ toggle() {
1102
+ if (!this.player) return;
1103
+ if (this.player.status === "playing") this.player.pause();
1104
+ else this.player.play();
1105
+ }
1106
+ replay() {
1107
+ var _a;
1108
+ (_a = this.player) == null ? void 0 : _a.replay();
1109
+ }
1110
+ seek(step) {
1111
+ var _a;
1112
+ (_a = this.player) == null ? void 0 : _a.seek(step);
1113
+ }
1114
+ setSpeed(speed) {
1115
+ var _a;
1116
+ (_a = this.player) == null ? void 0 : _a.setSpeed(speed);
1117
+ }
1118
+ get speed() {
1119
+ var _a, _b;
1120
+ return (_b = (_a = this.player) == null ? void 0 : _a.rate) != null ? _b : 1;
1121
+ }
1122
+ /** Stop for good: no frames, nothing on the board. */
1123
+ destroy() {
1124
+ var _a;
1125
+ (_a = this.player) == null ? void 0 : _a.destroy();
1126
+ this.player = null;
1127
+ this.scene = null;
1128
+ this.wipe();
1129
+ this.step = -1;
1130
+ this.caption = "";
1131
+ }
1132
+ changed() {
1133
+ this.options.onChange();
1134
+ }
1135
+ wipe() {
1136
+ this.inks = [];
1137
+ this.words = [];
1138
+ this.pen = null;
1139
+ this.changed();
1140
+ }
1141
+ // ------------------------------------------------------------- steps → ops
1142
+ buildStep(step, index) {
1143
+ return {
1144
+ say: step.say,
1145
+ enter: () => {
1146
+ if (step.clear) this.wipe();
1147
+ },
1148
+ ops: step.draw.map((item, i) => this.opFor(item, index * 100 + i + 1))
1149
+ };
1150
+ }
1151
+ opFor(item, seed) {
1152
+ var _a;
1153
+ switch (item.kind) {
1154
+ case "ink":
1155
+ return this.inkOp(item.id, inkStrokes(item.ink, item, seed), INK[item.tone], item.ink === "dot" ? 9 : 7, item.ink === "dot" ? 250 : 350, 2600, 1.1);
1156
+ case "art": {
1157
+ const ink = (_a = this.scene) == null ? void 0 : _a.art[item.art];
1158
+ if (!ink) {
1159
+ const [x, y, w, h] = item.at;
1160
+ return this.textOp({ kind: "text", id: item.id, text: item.art, at: [x + 1, y + h / 2], size: w < 15 ? "s" : "m", tone: item.tone });
1161
+ }
1162
+ return this.inkOp(item.id, artStrokes(ink, item.at, seed), INK[item.tone], "icon" in ink ? 7 : 4, 1100, 4500, 2.6);
1163
+ }
1164
+ case "text":
1165
+ return this.textOp(item);
1166
+ case "table":
1167
+ return this.tableOp(item);
1168
+ case "mark":
1169
+ return this.markOp(item.mark);
1170
+ case "erase":
1171
+ return this.eraseOp(item.erase);
1172
+ default:
1173
+ return { duration: 0, run: () => void 0 };
1174
+ }
1175
+ }
1176
+ inkOp(id, strokes, color, width, min, max, perMs, marker = false) {
1177
+ const length = totalLength(strokes);
1178
+ const duration = Math.min(max, Math.max(min, length / perMs)) + TRAVEL_MS;
1179
+ const share = TRAVEL_MS / duration;
1180
+ let obj = null;
1181
+ return {
1182
+ duration,
1183
+ run: (progress) => {
1184
+ var _a, _b;
1185
+ if (!obj) {
1186
+ obj = { key: this.nextKey++, id, strokes, length, color, width, marker, drawn: 0 };
1187
+ this.inks = [...this.inks, obj];
1188
+ }
1189
+ if (!length) return;
1190
+ const drawn = progress >= 1 ? 1 : Math.max(0, (progress - share) / (1 - share));
1191
+ obj.drawn = drawn;
1192
+ this.pen = drawn > 0 ? pointAlong(strokes, length * drawn) : (_b = (_a = strokes[0]) == null ? void 0 : _a[0]) != null ? _b : this.pen;
1193
+ this.changed();
1194
+ }
1195
+ };
1196
+ }
1197
+ textOp(item) {
1198
+ const duration = Math.min(2e3, Math.max(350, item.text.length * 60)) + TRAVEL_MS;
1199
+ let word = null;
1200
+ return {
1201
+ duration,
1202
+ run: (progress) => {
1203
+ if (!word) {
1204
+ word = { key: this.nextKey++, id: item.id, kind: "text", text: item.text, at: item.at, size: item.size, color: INK[item.tone], shown: 0, marked: false, gone: false };
1205
+ this.words = [...this.words, word];
1206
+ }
1207
+ word.shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1208
+ const height = TEXT_SIZE[item.size] / 100 * useOnboarding.BOARD_W;
1209
+ this.pen = { x: sx(item.at[0] + item.text.length * height * 0.55 * word.shown), y: sy(item.at[1]) };
1210
+ this.changed();
1211
+ }
1212
+ };
1213
+ }
1214
+ tableOp(item) {
1215
+ let table = null;
1216
+ return {
1217
+ duration: item.rows.length * 450 + TRAVEL_MS,
1218
+ run: (progress) => {
1219
+ if (!table) {
1220
+ table = { key: this.nextKey++, id: item.id, kind: "table", rows: item.rows, at: item.at, color: INK[item.tone], rowsShown: 0, marked: false, gone: false };
1221
+ this.words = [...this.words, table];
1222
+ }
1223
+ table.rowsShown = progress >= 1 ? item.rows.length : Math.max(progress > 0 ? 1 : 0, Math.floor(progress * item.rows.length));
1224
+ this.pen = { x: sx(item.at[0] + item.at[2]), y: sy(item.at[1]) };
1225
+ this.changed();
1226
+ }
1227
+ };
1228
+ }
1229
+ markOp(id) {
1230
+ let done = false;
1231
+ return {
1232
+ duration: 650,
1233
+ run: () => {
1234
+ if (done) return;
1235
+ done = true;
1236
+ const word = this.words.find((w) => w.id === id);
1237
+ if (word) {
1238
+ word.marked = true;
1239
+ this.changed();
1240
+ return;
1241
+ }
1242
+ const ink = this.inks.find((obj) => obj.id === id && !obj.marker);
1243
+ const box = ink ? bounds(ink.strokes) : null;
1244
+ if (!box) return;
1245
+ const mid = (box.y0 + box.y1) / 2;
1246
+ const swipe = [{ x: box.x0 - 14, y: mid }, { x: box.x1 + 14, y: mid }];
1247
+ this.inks = [{
1248
+ key: this.nextKey++,
1249
+ strokes: [swipe],
1250
+ length: totalLength([swipe]),
1251
+ color: MARKER,
1252
+ width: Math.max(24, (box.y1 - box.y0) * 0.6),
1253
+ marker: true,
1254
+ drawn: 1
1255
+ }, ...this.inks];
1256
+ this.changed();
1257
+ }
1258
+ };
1259
+ }
1260
+ eraseOp(id) {
1261
+ return {
1262
+ duration: 350,
1263
+ run: (progress) => {
1264
+ if (progress < 1) return;
1265
+ this.words = this.words.filter((w) => w.id !== id);
1266
+ this.inks = this.inks.filter((obj) => obj.id !== id);
1267
+ this.changed();
1268
+ }
1269
+ };
1270
+ }
1271
+ }
1272
+ function inkPath(strokes, length, upTo) {
1273
+ let left = length * upTo;
1274
+ const parts = [];
1275
+ for (const stroke of strokes) {
1276
+ if (left <= 0 || stroke.length < 2) break;
1277
+ let d = `M${stroke[0].x.toFixed(1)} ${stroke[0].y.toFixed(1)}`;
1278
+ for (let i = 1; i < stroke.length; i += 1) {
1279
+ const a = stroke[i - 1];
1280
+ const b = stroke[i];
1281
+ const seg = Math.hypot(b.x - a.x, b.y - a.y);
1282
+ if (seg >= left) {
1283
+ const t = seg ? left / seg : 1;
1284
+ d += `L${(a.x + (b.x - a.x) * t).toFixed(1)} ${(a.y + (b.y - a.y) * t).toFixed(1)}`;
1285
+ left = 0;
1286
+ break;
1287
+ }
1288
+ d += `L${b.x.toFixed(1)} ${b.y.toFixed(1)}`;
1289
+ left -= seg;
1290
+ }
1291
+ parts.push(d);
1292
+ }
1293
+ return parts.join("");
1294
+ }
288
1295
  const darkTheme = {
289
1296
  background: "#0B0713",
290
1297
  surface: "rgba(255,255,255,0.06)",
@@ -318,6 +1325,208 @@ const lightTheme = {
318
1325
  function resolveTheme(overrides, base = lightTheme) {
319
1326
  return overrides ? { ...base, ...overrides } : base;
320
1327
  }
1328
+ const SHEET_W = 1600;
1329
+ const SHEET_H = 1e3;
1330
+ const HAND = reactNative.Platform.select({ ios: "Bradley Hand", android: "casual", default: void 0 });
1331
+ const PEN = "M0 0 L-5 -22 L22 -70 L32 -63 L5 -16 Z";
1332
+ function GuideAIWhiteboard({ theme: overrides }) {
1333
+ const theme = resolveTheme(overrides);
1334
+ const { state, close, retry } = useOnboarding.useWhiteboard();
1335
+ const [, repaint] = React.useReducer((n) => n + 1, 0);
1336
+ const [width, setWidth] = React.useState(0);
1337
+ const [expanded, setExpanded] = React.useState(false);
1338
+ const motion = React.useRef({ reduced: false });
1339
+ const model = React.useMemo(() => new BoardModel({
1340
+ onChange: () => repaint(),
1341
+ get reducedMotion() {
1342
+ return motion.current.reduced;
1343
+ }
1344
+ }), []);
1345
+ React.useEffect(() => {
1346
+ var _a, _b;
1347
+ void ((_b = (_a = reactNative.AccessibilityInfo).isReduceMotionEnabled) == null ? void 0 : _b.call(_a).then((on) => {
1348
+ motion.current.reduced = on;
1349
+ }, () => void 0));
1350
+ }, []);
1351
+ React.useEffect(() => {
1352
+ if (state.status === "playing" && state.scene) model.play(state.scene);
1353
+ else model.destroy();
1354
+ }, [model, state.status, state.scene]);
1355
+ React.useEffect(() => () => model.destroy(), [model]);
1356
+ if (state.status === "closed") return null;
1357
+ const board = model.snapshot();
1358
+ const height = width / (useOnboarding.BOARD_W / useOnboarding.BOARD_H);
1359
+ const unit2 = width / 100;
1360
+ const playing = board.state === "playing";
1361
+ const title = state.status === "playing" ? board.title : state.question;
1362
+ const shut = () => {
1363
+ model.destroy();
1364
+ close();
1365
+ };
1366
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: shut, supportedOrientations: ["portrait", "landscape"], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.backdrop, expanded ? styles$3.centre : null], pointerEvents: "box-none", children: /* @__PURE__ */ jsxRuntime.jsxs(
1367
+ reactNative.View,
1368
+ {
1369
+ style: [styles$3.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, maxWidth: expanded ? 1040 : 540 }],
1370
+ accessibilityViewIsModal: true,
1371
+ accessibilityLabel: `Whiteboard: ${title}`,
1372
+ children: [
1373
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$3.head, children: [
1374
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.title, { color: theme.text }], numberOfLines: 1, children: title || "Whiteboard" }),
1375
+ board.sample && state.status === "playing" ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.badge, accessibilityHint: "This board uses example numbers.", children: "Example" }) : null,
1376
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton, { label: expanded ? "Collapse whiteboard" : "Expand whiteboard", glyph: expanded ? "⤡" : "⤢", color: theme.textMuted, onPress: () => setExpanded((v) => !v) }),
1377
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton, { label: "Close whiteboard", glyph: "✕", color: theme.textMuted, onPress: shut })
1378
+ ] }),
1379
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$3.sheet, onLayout: (e) => setWidth(e.nativeEvent.layout.width), children: [
1380
+ width > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1381
+ /* @__PURE__ */ jsxRuntime.jsxs(Svg, { width, height, viewBox: `0 0 ${SHEET_W} ${SHEET_H}`, children: [
1382
+ board.inks.filter((obj) => obj.marker).map((obj) => /* @__PURE__ */ jsxRuntime.jsx(Ink, { obj }, obj.key)),
1383
+ board.inks.filter((obj) => !obj.marker).map((obj) => /* @__PURE__ */ jsxRuntime.jsx(Ink, { obj }, obj.key)),
1384
+ board.pen && playing && !motion.current.reduced ? /* @__PURE__ */ jsxRuntime.jsx(Svg.G, { transform: `translate(${board.pen.x.toFixed(1)} ${board.pen.y.toFixed(1)})`, children: /* @__PURE__ */ jsxRuntime.jsx(Svg.Path, { d: PEN, fill: "#fde68a", stroke: "#1f2937", strokeWidth: 3, strokeLinejoin: "round" }) }) : null
1385
+ ] }),
1386
+ board.words.map((word) => /* @__PURE__ */ jsxRuntime.jsx(Word, { word, width, height, unit: unit2 }, word.key))
1387
+ ] }) : null,
1388
+ state.status === "loading" ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$3.status, accessibilityLiveRegion: "polite", children: [
1389
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { color: theme.accent }),
1390
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.statusText, children: "Drawing your board…" })
1391
+ ] }) : null,
1392
+ state.status === "error" ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$3.status, accessibilityLiveRegion: "assertive", children: [
1393
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: styles$3.statusText, children: state.error }),
1394
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityRole: "button", onPress: retry, style: [styles$3.retry, { backgroundColor: theme.accent }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Try again" }) })
1395
+ ] }) : null
1396
+ ] }),
1397
+ state.status === "playing" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1398
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.caption, { color: theme.text }], accessibilityLiveRegion: "polite", children: board.caption }),
1399
+ board.steps > 1 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.track, accessibilityLabel: "Steps", children: Array.from({ length: board.steps }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx(
1400
+ reactNative.Pressable,
1401
+ {
1402
+ accessibilityRole: "button",
1403
+ accessibilityLabel: `Go to step ${i + 1}`,
1404
+ accessibilityState: { selected: i === board.step },
1405
+ onPress: () => model.seek(i),
1406
+ hitSlop: 8,
1407
+ style: [styles$3.segment, { backgroundColor: i <= board.step ? theme.accent : theme.border }]
1408
+ },
1409
+ i
1410
+ )) }) : null,
1411
+ /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$3.bar, children: [
1412
+ /* @__PURE__ */ jsxRuntime.jsx(
1413
+ IconButton,
1414
+ {
1415
+ label: playing ? "Pause" : board.state === "done" ? "Play again" : "Resume",
1416
+ glyph: playing ? "❚❚" : board.state === "done" ? "↻" : "▶",
1417
+ color: theme.text,
1418
+ onPress: () => model.toggle()
1419
+ }
1420
+ ),
1421
+ /* @__PURE__ */ jsxRuntime.jsx(IconButton, { label: "Replay from the start", glyph: "↺", color: theme.text, onPress: () => model.replay() }),
1422
+ /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.step, { color: theme.textMuted }], children: board.step >= 0 ? `Step ${board.step + 1} of ${board.steps}` : "" }),
1423
+ /* @__PURE__ */ jsxRuntime.jsx(
1424
+ reactNative.Pressable,
1425
+ {
1426
+ accessibilityRole: "button",
1427
+ accessibilityLabel: `Speed ${model.speed} times. Change speed`,
1428
+ onPress: () => {
1429
+ const at = SPEEDS.indexOf(model.speed);
1430
+ model.setSpeed(SPEEDS[(at + 1) % SPEEDS.length]);
1431
+ repaint();
1432
+ },
1433
+ style: [styles$3.speed, { borderColor: theme.border }],
1434
+ children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: { color: theme.text, fontSize: 12 }, children: [
1435
+ model.speed,
1436
+ "×"
1437
+ ] })
1438
+ }
1439
+ )
1440
+ ] })
1441
+ ] }) : null
1442
+ ]
1443
+ }
1444
+ ) }) });
1445
+ }
1446
+ function Ink({ obj }) {
1447
+ if (obj.drawn <= 0) return null;
1448
+ return /* @__PURE__ */ jsxRuntime.jsx(
1449
+ Svg.Path,
1450
+ {
1451
+ d: inkPath(obj.strokes, obj.length, obj.drawn),
1452
+ stroke: obj.color,
1453
+ strokeWidth: obj.width,
1454
+ fill: "none",
1455
+ strokeLinecap: "round",
1456
+ strokeLinejoin: "round"
1457
+ }
1458
+ );
1459
+ }
1460
+ function Word({ word, width, height, unit: unit2 }) {
1461
+ const left = word.at[0] / useOnboarding.BOARD_W * width;
1462
+ const top = word.at[1] / useOnboarding.BOARD_H * height;
1463
+ if (word.kind === "text") {
1464
+ const size2 = unit2 * TEXT_SIZE[word.size];
1465
+ const shown = word.text.slice(0, Math.ceil(word.text.length * word.shown));
1466
+ if (!shown) return null;
1467
+ return /* @__PURE__ */ jsxRuntime.jsx(
1468
+ reactNative.Text,
1469
+ {
1470
+ style: [styles$3.word, {
1471
+ left,
1472
+ top: top - size2 * 0.62,
1473
+ fontSize: size2,
1474
+ color: word.color,
1475
+ fontFamily: HAND,
1476
+ backgroundColor: word.marked ? MARKER : "transparent"
1477
+ }],
1478
+ accessibilityLabel: word.text,
1479
+ children: shown
1480
+ }
1481
+ );
1482
+ }
1483
+ if (word.rowsShown <= 0) return null;
1484
+ const size = unit2 * 2.2;
1485
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.table, { left, top, width: word.at[2] / useOnboarding.BOARD_W * width, borderColor: word.color, backgroundColor: word.marked ? MARKER : "transparent" }], children: word.rows.slice(0, word.rowsShown).map((row, r) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.row, children: row.map((cell, c) => /* @__PURE__ */ jsxRuntime.jsx(
1486
+ reactNative.Text,
1487
+ {
1488
+ style: [styles$3.cell, { fontSize: size, color: word.color, borderColor: word.color, fontFamily: HAND, fontWeight: r === 0 ? "700" : "400" }],
1489
+ children: cell
1490
+ },
1491
+ c
1492
+ )) }, r)) });
1493
+ }
1494
+ function IconButton({ label, glyph, color, onPress }) {
1495
+ return /* @__PURE__ */ jsxRuntime.jsx(reactNative.Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, hitSlop: 8, style: styles$3.icon, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color, fontSize: 16 }, children: glyph }) });
1496
+ }
1497
+ const styles$3 = reactNative.StyleSheet.create({
1498
+ backdrop: { flex: 1, justifyContent: "flex-end", alignItems: "center", padding: 12 },
1499
+ centre: { justifyContent: "center" },
1500
+ card: {
1501
+ width: "100%",
1502
+ borderRadius: 16,
1503
+ borderWidth: reactNative.StyleSheet.hairlineWidth,
1504
+ overflow: "hidden",
1505
+ shadowColor: "#0f172a",
1506
+ shadowOpacity: 0.25,
1507
+ shadowRadius: 24,
1508
+ shadowOffset: { width: 0, height: 12 },
1509
+ elevation: 12
1510
+ },
1511
+ head: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
1512
+ title: { flex: 1, fontSize: 14, fontWeight: "600" },
1513
+ badge: { fontSize: 11, fontWeight: "600", color: "#92400e", backgroundColor: "#fef3c7", borderRadius: 999, paddingHorizontal: 8, paddingVertical: 2, overflow: "hidden" },
1514
+ sheet: { width: "100%", aspectRatio: useOnboarding.BOARD_W / useOnboarding.BOARD_H, backgroundColor: "#fcfcfd" },
1515
+ status: { ...reactNative.StyleSheet.absoluteFillObject, alignItems: "center", justifyContent: "center", gap: 10, backgroundColor: "rgba(252,252,253,0.92)", padding: 16 },
1516
+ statusText: { color: "#475569", fontSize: 13, textAlign: "center" },
1517
+ retry: { paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8 },
1518
+ caption: { paddingHorizontal: 14, paddingTop: 10, fontSize: 14, lineHeight: 20, minHeight: 46 },
1519
+ track: { flexDirection: "row", gap: 4, paddingHorizontal: 14, paddingTop: 4 },
1520
+ segment: { flex: 1, height: 6, borderRadius: 3 },
1521
+ bar: { flexDirection: "row", alignItems: "center", paddingHorizontal: 8, paddingVertical: 6, gap: 4 },
1522
+ step: { flex: 1, fontSize: 12, marginLeft: 4 },
1523
+ speed: { borderWidth: 1, borderRadius: 8, paddingHorizontal: 8, paddingVertical: 4 },
1524
+ icon: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
1525
+ word: { position: "absolute", fontWeight: "600" },
1526
+ table: { position: "absolute", borderWidth: 1.5 },
1527
+ row: { flexDirection: "row" },
1528
+ cell: { flex: 1, borderWidth: 0.75, paddingHorizontal: 6, paddingVertical: 3 }
1529
+ });
321
1530
  function PersonIcon({ color }) {
322
1531
  return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.iconWrap, children: [
323
1532
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.iconBand, { borderColor: color }] }),
@@ -367,7 +1576,7 @@ function Orb({ theme, active }) {
367
1576
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.orbCore, { backgroundColor: theme.accent }] })
368
1577
  ] });
369
1578
  }
370
- function Bubble$1({ message, theme, onTalkToHuman }) {
1579
+ function Bubble$1({ message, theme, onTalkToHuman, onWhiteboard }) {
371
1580
  if (message.role === "user") {
372
1581
  return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.row, styles$2.rowUser], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
373
1582
  styles$2.bubble,
@@ -383,10 +1592,18 @@ function Bubble$1({ message, theme, onTalkToHuman }) {
383
1592
  styles$2.assistantBody,
384
1593
  message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
385
1594
  ], children: [
386
- message.content ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }) : (
387
- // A streaming message with no text yet would be an empty box.
388
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: message.streaming ? "…" : "" })
389
- ),
1595
+ /* @__PURE__ */ jsxRuntime.jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }),
1596
+ onWhiteboard ? /* @__PURE__ */ jsxRuntime.jsx(
1597
+ reactNative.Pressable,
1598
+ {
1599
+ onPress: onWhiteboard,
1600
+ accessibilityRole: "button",
1601
+ accessibilityLabel: "Explain on whiteboard",
1602
+ style: [styles$2.errorAction, { borderColor: theme.accent }],
1603
+ hitSlop: 6,
1604
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$2.humanText, { color: theme.accent, fontSize: theme.fontSize - 1 }], children: "✎ Explain on whiteboard" })
1605
+ }
1606
+ ) : null,
390
1607
  message.error && onTalkToHuman ? /* @__PURE__ */ jsxRuntime.jsxs(
391
1608
  reactNative.Pressable,
392
1609
  {
@@ -419,9 +1636,9 @@ function useHumanHandover(onTalkToHuman, available) {
419
1636
  let cancelled = false;
420
1637
  void (async () => {
421
1638
  try {
422
- const { api } = useOnboarding.requireConfigured();
1639
+ const { api } = setup.requireConfigured();
423
1640
  const status = await api.get(
424
- useOnboarding.EP.supportStatus()
1641
+ setup.EP.supportStatus()
425
1642
  );
426
1643
  if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
427
1644
  } catch {
@@ -447,7 +1664,7 @@ function GuideAIChat({
447
1664
  humanHandoverAvailable,
448
1665
  topInset
449
1666
  }) {
450
- const { harness, debug } = useOnboarding.requireConfigured();
1667
+ const { harness, debug } = setup.requireConfigured();
451
1668
  const {
452
1669
  messages,
453
1670
  input,
@@ -455,7 +1672,10 @@ function GuideAIChat({
455
1672
  send,
456
1673
  busy,
457
1674
  canSend,
458
- status
1675
+ status,
1676
+ typing,
1677
+ followUps,
1678
+ explainOnWhiteboard
459
1679
  } = useOnboarding.useGuideAI({ harness, trace: debug });
460
1680
  const theme = resolveTheme(overrides);
461
1681
  const listRef = React.useRef(null);
@@ -552,7 +1772,33 @@ function GuideAIChat({
552
1772
  ref: listRef,
553
1773
  data: messages,
554
1774
  keyExtractor: (message) => message.id,
555
- renderItem: ({ item }) => /* @__PURE__ */ jsxRuntime.jsx(Bubble$1, { message: item, theme, onTalkToHuman }),
1775
+ renderItem: ({ item }) => /* @__PURE__ */ jsxRuntime.jsx(
1776
+ Bubble$1,
1777
+ {
1778
+ message: item,
1779
+ theme,
1780
+ onTalkToHuman,
1781
+ onWhiteboard: item.whiteboard ? () => {
1782
+ void explainOnWhiteboard(item.id);
1783
+ } : void 0
1784
+ }
1785
+ ),
1786
+ ListFooterComponent: typing || followUps.length ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.footer, children: [
1787
+ typing ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "…" }) : null,
1788
+ followUps.map((label) => /* @__PURE__ */ jsxRuntime.jsx(
1789
+ reactNative.Pressable,
1790
+ {
1791
+ onPress: () => {
1792
+ void send(label);
1793
+ },
1794
+ accessibilityRole: "button",
1795
+ style: [styles$2.chip, { borderColor: theme.accent, borderRadius: theme.radius }],
1796
+ hitSlop: 4,
1797
+ children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.accent, fontSize: theme.fontSize - 1 }, children: label })
1798
+ },
1799
+ label
1800
+ ))
1801
+ ] }) : null,
556
1802
  contentContainerStyle: styles$2.list,
557
1803
  onContentSizeChange: () => {
558
1804
  var _a;
@@ -615,7 +1861,8 @@ function GuideAIChat({
615
1861
  children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: 18 }, children: "🎤" })
616
1862
  }
617
1863
  ) : null
618
- ] })
1864
+ ] }),
1865
+ /* @__PURE__ */ jsxRuntime.jsx(GuideAIWhiteboard, { theme: overrides })
619
1866
  ]
620
1867
  }
621
1868
  );
@@ -749,6 +1996,17 @@ const styles$2 = reactNative.StyleSheet.create({
749
1996
  },
750
1997
  send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
751
1998
  sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
1999
+ footer: {
2000
+ flexDirection: "row",
2001
+ flexWrap: "wrap",
2002
+ gap: 8,
2003
+ paddingTop: 4
2004
+ },
2005
+ chip: {
2006
+ borderWidth: 1,
2007
+ paddingHorizontal: 12,
2008
+ paddingVertical: 7
2009
+ },
752
2010
  mic: {
753
2011
  width: 46,
754
2012
  height: 46,
@@ -761,7 +2019,7 @@ const styles$2 = reactNative.StyleSheet.create({
761
2019
  const POLL_INTERVAL_MS = 3e3;
762
2020
  const CONVERSATION_KEY = "guideai_support_conversation";
763
2021
  function useStoredConversation() {
764
- const { runtime } = useOnboarding.requireConfigured();
2022
+ const { runtime } = setup.requireConfigured();
765
2023
  const [id, setId] = React.useState(() => {
766
2024
  try {
767
2025
  return runtime.storage.getItem(CONVERSATION_KEY);
@@ -813,7 +2071,7 @@ function GuideAISupportChat({
813
2071
  openingContext
814
2072
  }) {
815
2073
  var _a;
816
- const { api } = useOnboarding.requireConfigured();
2074
+ const { api } = setup.requireConfigured();
817
2075
  const theme = resolveTheme(overrides);
818
2076
  const headerTop = topInset != null ? topInset : reactNative.Platform.OS === "android" ? (_a = reactNative.StatusBar.currentHeight) != null ? _a : 24 : 8;
819
2077
  const [conversationId, setConversationId] = useStoredConversation();
@@ -835,7 +2093,7 @@ function GuideAISupportChat({
835
2093
  const poll = React.useCallback(async (id) => {
836
2094
  var _a2;
837
2095
  try {
838
- const path = useOnboarding.EP.supportMsgs(id);
2096
+ const path = setup.EP.supportMsgs(id);
839
2097
  const result = await api.get(
840
2098
  cursor.current ? `${path}?since=${encodeURIComponent(cursor.current)}` : path
841
2099
  );
@@ -868,7 +2126,7 @@ function GuideAISupportChat({
868
2126
  setFailed(false);
869
2127
  try {
870
2128
  const result = await api.post(
871
- useOnboarding.EP.supportConvs(),
2129
+ setup.EP.supportConvs(),
872
2130
  {
873
2131
  message: openingContext ? `${text}
874
2132
 
@@ -893,7 +2151,7 @@ ${openingContext}` : text,
893
2151
  setInput("");
894
2152
  setBusy(true);
895
2153
  try {
896
- await api.post(useOnboarding.EP.supportMsgs(conversationId), { body: text });
2154
+ await api.post(setup.EP.supportMsgs(conversationId), { body: text });
897
2155
  await poll(conversationId);
898
2156
  } catch {
899
2157
  if (mounted.current) {
@@ -1517,6 +2775,7 @@ exports.GuideAIButton = GuideAIButton;
1517
2775
  exports.GuideAIChat = GuideAIChat;
1518
2776
  exports.GuideAILauncher = GuideAILauncher;
1519
2777
  exports.GuideAISupportChat = GuideAISupportChat;
2778
+ exports.GuideAIWhiteboard = GuideAIWhiteboard;
1520
2779
  exports.Markdown = Markdown;
1521
2780
  exports.darkTheme = darkTheme;
1522
2781
  exports.lightTheme = lightTheme;