@guideai/react-native 0.3.0 → 0.7.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.
@@ -0,0 +1,2494 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import React, { useReducer, useState, useRef, useMemo, useEffect } from "react";
3
+ import { View, StyleSheet, Text, ScrollView, Linking, AccessibilityInfo, Modal, ActivityIndicator, Pressable, Platform, Animated, Easing, KeyboardAvoidingView, Alert, FlatList, TextInput, StatusBar } from "react-native";
4
+ import { B as BOARD_W, e as useWhiteboard, G as GuideAI, r as requireConfigured, f as BOARD_H, c as useGuideAI, d as useOnboarding, E as EP, b as useConversations } from "./useConversations-B_7km_uH.js";
5
+ import { Svg, G, Path, Defs, ClipPath, Rect, Image } from "react-native-svg";
6
+ function parseInline(text) {
7
+ const spans = [];
8
+ const pattern = /(`[^`]+`)|(\*\*[^*]+\*\*)|(__[^_]+__)|(\*[^*\n]+\*)|(_[^_\n]+_)|(\[[^\]]+\]\([^)]+\))/g;
9
+ let cursor = 0;
10
+ let match;
11
+ while ((match = pattern.exec(text)) !== null) {
12
+ if (match.index > cursor) {
13
+ spans.push({ text: text.slice(cursor, match.index) });
14
+ }
15
+ const token = match[0];
16
+ if (token.startsWith("`")) {
17
+ spans.push({ text: token.slice(1, -1), code: true });
18
+ } else if (token.startsWith("**") || token.startsWith("__")) {
19
+ spans.push({ text: token.slice(2, -2), bold: true });
20
+ } else if (token.startsWith("[")) {
21
+ const split = token.indexOf("](");
22
+ spans.push({
23
+ text: token.slice(1, split),
24
+ href: token.slice(split + 2, -1)
25
+ });
26
+ } else {
27
+ spans.push({ text: token.slice(1, -1), italic: true });
28
+ }
29
+ cursor = match.index + token.length;
30
+ }
31
+ if (cursor < text.length) spans.push({ text: text.slice(cursor) });
32
+ return spans.length ? spans : [{ text }];
33
+ }
34
+ function tableCells(line) {
35
+ return line.replace(/^\s*\|/, "").replace(/\|\s*$/, "").split("|").map((cell) => parseInline(cell.trim()));
36
+ }
37
+ const TABLE_DIVIDER = /^\s*\|?[\s:-]*-[\s|:-]*\|?\s*$/;
38
+ function parseMarkdown(source) {
39
+ var _a, _b;
40
+ const blocks = [];
41
+ const lines = source.replace(/\r\n/g, "\n").split("\n");
42
+ let index = 0;
43
+ while (index < lines.length) {
44
+ const line = lines[index];
45
+ const trimmed = line.trim();
46
+ if (!trimmed) {
47
+ index += 1;
48
+ continue;
49
+ }
50
+ const fence = /^```(\w+)?/.exec(trimmed);
51
+ if (fence) {
52
+ const language = fence[1];
53
+ const body = [];
54
+ index += 1;
55
+ while (index < lines.length && !lines[index].trim().startsWith("```")) {
56
+ body.push(lines[index]);
57
+ index += 1;
58
+ }
59
+ index += 1;
60
+ blocks.push({ type: "code", text: body.join("\n"), language });
61
+ continue;
62
+ }
63
+ if (trimmed.includes("|") && index + 1 < lines.length && TABLE_DIVIDER.test(lines[index + 1])) {
64
+ const header = tableCells(trimmed);
65
+ const rows = [];
66
+ index += 2;
67
+ while (index < lines.length && lines[index].includes("|") && lines[index].trim()) {
68
+ rows.push(tableCells(lines[index]));
69
+ index += 1;
70
+ }
71
+ blocks.push({ type: "table", header, rows });
72
+ continue;
73
+ }
74
+ const heading = /^(#{1,6})\s+(.*)$/.exec(trimmed);
75
+ if (heading) {
76
+ const level = Math.min(heading[1].length, 3);
77
+ blocks.push({ type: "heading", level, spans: parseInline(heading[2]) });
78
+ index += 1;
79
+ continue;
80
+ }
81
+ if (/^(\*\s*){3,}$|^(-\s*){3,}$|^(_\s*){3,}$/.test(trimmed)) {
82
+ blocks.push({ type: "rule" });
83
+ index += 1;
84
+ continue;
85
+ }
86
+ const quote = /^>\s?(.*)$/.exec(trimmed);
87
+ if (quote) {
88
+ blocks.push({ type: "quote", spans: parseInline(quote[1]) });
89
+ index += 1;
90
+ continue;
91
+ }
92
+ const indent = (_b = (_a = /^(\s*)/.exec(line)) == null ? void 0 : _a[1].length) != null ? _b : 0;
93
+ const depth = Math.floor(indent / 2);
94
+ const bullet = /^[-*+]\s+(.*)$/.exec(trimmed);
95
+ if (bullet) {
96
+ blocks.push({ type: "bullet", spans: parseInline(bullet[1]), depth });
97
+ index += 1;
98
+ continue;
99
+ }
100
+ const ordered = /^(\d+)[.)]\s+(.*)$/.exec(trimmed);
101
+ if (ordered) {
102
+ blocks.push({
103
+ type: "ordered",
104
+ spans: parseInline(ordered[2]),
105
+ index: Number(ordered[1]),
106
+ depth
107
+ });
108
+ index += 1;
109
+ continue;
110
+ }
111
+ const paragraph = [trimmed];
112
+ index += 1;
113
+ while (index < lines.length) {
114
+ const nextLine = lines[index].trim();
115
+ if (!nextLine || /^(#{1,6})\s/.test(nextLine) || /^[-*+]\s/.test(nextLine) || /^\d+[.)]\s/.test(nextLine) || nextLine.startsWith("```") || nextLine.startsWith(">") || nextLine.includes("|")) break;
116
+ paragraph.push(nextLine);
117
+ index += 1;
118
+ }
119
+ blocks.push({ type: "paragraph", spans: parseInline(paragraph.join(" ")) });
120
+ }
121
+ return blocks;
122
+ }
123
+ function Spans({ spans, style, accentColor }) {
124
+ return /* @__PURE__ */ jsx(Fragment, { children: spans.map((span, index) => {
125
+ if (span.href) {
126
+ return /* @__PURE__ */ jsx(
127
+ Text,
128
+ {
129
+ style: [style, { color: accentColor, textDecorationLine: "underline" }],
130
+ onPress: () => {
131
+ void Linking.openURL(span.href);
132
+ },
133
+ accessibilityRole: "link",
134
+ children: span.text
135
+ },
136
+ index
137
+ );
138
+ }
139
+ return /* @__PURE__ */ jsx(
140
+ Text,
141
+ {
142
+ style: [
143
+ style,
144
+ span.bold ? styles$4.bold : null,
145
+ span.italic ? styles$4.italic : null,
146
+ span.code ? styles$4.inlineCode : null
147
+ ],
148
+ children: span.text
149
+ },
150
+ index
151
+ );
152
+ }) });
153
+ }
154
+ function Markdown({
155
+ children,
156
+ color = "#0f172a",
157
+ accentColor = "#2563eb",
158
+ fontSize = 15
159
+ }) {
160
+ const blocks = React.useMemo(() => parseMarkdown(children), [children]);
161
+ const body = { color, fontSize, lineHeight: fontSize * 1.45 };
162
+ return /* @__PURE__ */ jsx(View, { style: styles$4.container, children: blocks.map((block, index) => /* @__PURE__ */ jsx(
163
+ Block,
164
+ {
165
+ block,
166
+ body,
167
+ color,
168
+ accentColor,
169
+ fontSize
170
+ },
171
+ index
172
+ )) });
173
+ }
174
+ function Block({ block, body, color, accentColor, fontSize }) {
175
+ switch (block.type) {
176
+ case "heading": {
177
+ const sizes = { 1: fontSize + 6, 2: fontSize + 3, 3: fontSize + 1 };
178
+ return /* @__PURE__ */ jsx(Text, { style: [styles$4.heading, { color, fontSize: sizes[block.level] }], children: /* @__PURE__ */ jsx(
179
+ Spans,
180
+ {
181
+ spans: block.spans,
182
+ accentColor,
183
+ style: { color, fontSize: sizes[block.level], fontWeight: "700" }
184
+ }
185
+ ) });
186
+ }
187
+ case "paragraph":
188
+ return /* @__PURE__ */ jsx(Text, { style: styles$4.paragraph, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) });
189
+ case "bullet":
190
+ return /* @__PURE__ */ jsxs(View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
191
+ /* @__PURE__ */ jsx(Text, { style: [body, { color: accentColor }], children: "•" }),
192
+ /* @__PURE__ */ jsx(Text, { style: styles$4.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
193
+ ] });
194
+ case "ordered":
195
+ return /* @__PURE__ */ jsxs(View, { style: [styles$4.listRow, { marginLeft: block.depth * 14 }], children: [
196
+ /* @__PURE__ */ jsxs(Text, { style: [body, { color: accentColor, fontVariant: ["tabular-nums"] }], children: [
197
+ block.index,
198
+ "."
199
+ ] }),
200
+ /* @__PURE__ */ jsx(Text, { style: styles$4.listText, children: /* @__PURE__ */ jsx(Spans, { spans: block.spans, style: body, accentColor }) })
201
+ ] });
202
+ case "code":
203
+ return /* @__PURE__ */ jsx(View, { style: styles$4.codeBlock, children: /* @__PURE__ */ jsx(Text, { style: [styles$4.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
204
+ case "quote":
205
+ return /* @__PURE__ */ jsx(View, { style: [styles$4.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
206
+ Spans,
207
+ {
208
+ spans: block.spans,
209
+ accentColor,
210
+ style: { ...body, color: "#475569", fontStyle: "italic" }
211
+ }
212
+ ) }) });
213
+ case "rule":
214
+ return /* @__PURE__ */ jsx(View, { style: styles$4.rule });
215
+ case "table": {
216
+ const columns = Math.max(block.header.length, ...block.rows.map((r) => r.length), 1);
217
+ const scrolls = columns > 3;
218
+ const table = /* @__PURE__ */ jsxs(View, { style: [styles$4.table, scrolls ? { minWidth: columns * 116 } : null], children: [
219
+ /* @__PURE__ */ jsx(View, { style: [styles$4.tableRow, styles$4.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsx(View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
220
+ Spans,
221
+ {
222
+ spans: cell,
223
+ accentColor,
224
+ style: { ...body, fontWeight: "700", fontSize: fontSize - 1 }
225
+ }
226
+ ) }) }, index)) }),
227
+ block.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(View, { style: styles$4.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsx(View, { style: styles$4.tableCell, children: /* @__PURE__ */ jsx(Text, { children: /* @__PURE__ */ jsx(
228
+ Spans,
229
+ {
230
+ spans: cell,
231
+ accentColor,
232
+ style: { ...body, fontSize: fontSize - 1 }
233
+ }
234
+ ) }) }, cellIndex)) }, rowIndex))
235
+ ] });
236
+ return scrolls ? /* @__PURE__ */ jsx(
237
+ ScrollView,
238
+ {
239
+ horizontal: true,
240
+ showsHorizontalScrollIndicator: false,
241
+ alwaysBounceHorizontal: false,
242
+ children: table
243
+ }
244
+ ) : table;
245
+ }
246
+ default:
247
+ return null;
248
+ }
249
+ }
250
+ const mono = { fontFamily: "Menlo" };
251
+ const styles$4 = StyleSheet.create({
252
+ container: { gap: 6 },
253
+ heading: { fontWeight: "700", marginTop: 4 },
254
+ paragraph: {},
255
+ listRow: { flexDirection: "row", gap: 8, alignItems: "flex-start" },
256
+ listText: { flex: 1 },
257
+ bold: { fontWeight: "700" },
258
+ italic: { fontStyle: "italic" },
259
+ inlineCode: {
260
+ ...mono,
261
+ backgroundColor: "rgba(100,116,139,0.14)",
262
+ color: "#0f172a"
263
+ },
264
+ codeBlock: {
265
+ backgroundColor: "#0f172a",
266
+ borderRadius: 10,
267
+ padding: 12,
268
+ marginVertical: 2
269
+ },
270
+ codeText: { ...mono, color: "#e2e8f0" },
271
+ quote: { borderLeftWidth: 3, paddingLeft: 10, paddingVertical: 2 },
272
+ rule: { height: StyleSheet.hairlineWidth, backgroundColor: "#cbd5e1", marginVertical: 6 },
273
+ table: {
274
+ borderWidth: StyleSheet.hairlineWidth,
275
+ borderColor: "#cbd5e1",
276
+ borderRadius: 8,
277
+ overflow: "hidden"
278
+ },
279
+ tableRow: {
280
+ flexDirection: "row",
281
+ borderBottomWidth: StyleSheet.hairlineWidth,
282
+ borderBottomColor: "#e2e8f0"
283
+ },
284
+ tableHeaderRow: { backgroundColor: "rgba(100,116,139,0.10)" },
285
+ tableCell: { flex: 1, padding: 8 }
286
+ });
287
+ const STEP_GAP_MS = 450;
288
+ function readTime(text) {
289
+ const words = text.trim().split(/\s+/).filter(Boolean).length;
290
+ return Math.min(6500, Math.max(1500, words * 280));
291
+ }
292
+ const SPEEDS = [0.75, 1, 1.5, 2];
293
+ class Player {
294
+ constructor(steps, hooks, reducedMotion = false) {
295
+ var _a, _b, _c;
296
+ this.steps = steps;
297
+ this.hooks = hooks;
298
+ this.reducedMotion = reducedMotion;
299
+ this.state = "idle";
300
+ this.speed = 1;
301
+ this.stepIndex = -1;
302
+ this.opIndex = 0;
303
+ this.opElapsed = 0;
304
+ this.stepElapsed = 0;
305
+ this.holdElapsed = 0;
306
+ this.spoken = null;
307
+ this.narrationToken = 0;
308
+ this.frame = null;
309
+ this.last = 0;
310
+ this.requestFrame = (_a = hooks.requestFrame) != null ? _a : ((cb) => requestAnimationFrame(cb));
311
+ this.cancelFrame = (_b = hooks.cancelFrame) != null ? _b : ((id) => cancelAnimationFrame(id));
312
+ this.now = (_c = hooks.now) != null ? _c : (() => performance.now());
313
+ }
314
+ get current() {
315
+ return this.stepIndex;
316
+ }
317
+ get status() {
318
+ return this.state;
319
+ }
320
+ get rate() {
321
+ return this.speed;
322
+ }
323
+ setSpeed(speed) {
324
+ this.speed = Math.min(3, Math.max(0.25, speed));
325
+ }
326
+ play() {
327
+ if (this.state === "playing") return;
328
+ if (this.state === "done" || this.state === "idle") {
329
+ this.restart();
330
+ return;
331
+ }
332
+ this.setState("playing");
333
+ this.schedule();
334
+ }
335
+ pause() {
336
+ if (this.state !== "playing") return;
337
+ this.setState("paused");
338
+ this.unschedule();
339
+ if (this.spoken === null) {
340
+ this.narrationToken += 1;
341
+ this.hooks.stopNarration();
342
+ this.spoken = false;
343
+ }
344
+ }
345
+ replay() {
346
+ this.restart();
347
+ }
348
+ /**
349
+ * Jump to step *index*, as a scrubber does: the board is rebuilt with every
350
+ * step before it already drawn, then playback carries on from there.
351
+ */
352
+ seek(index) {
353
+ const target = Math.max(0, Math.min(this.steps.length - 1, Math.floor(index)));
354
+ this.unschedule();
355
+ this.narrationToken += 1;
356
+ this.hooks.stopNarration();
357
+ this.hooks.reset();
358
+ for (let i = 0; i < target; i += 1) {
359
+ const step = this.steps[i];
360
+ step.enter();
361
+ for (const op of step.ops) op.run(1);
362
+ }
363
+ this.stepIndex = -1;
364
+ this.setState("playing");
365
+ this.enterStep(target);
366
+ this.schedule();
367
+ }
368
+ /** Stop for good: no frames, no voice. */
369
+ destroy() {
370
+ this.unschedule();
371
+ this.narrationToken += 1;
372
+ this.hooks.stopNarration();
373
+ this.state = "done";
374
+ }
375
+ restart() {
376
+ this.unschedule();
377
+ this.narrationToken += 1;
378
+ this.hooks.stopNarration();
379
+ this.hooks.reset();
380
+ this.stepIndex = -1;
381
+ this.setState("playing");
382
+ this.enterStep(0);
383
+ this.schedule();
384
+ }
385
+ setState(state) {
386
+ var _a, _b;
387
+ if (this.state === state) return;
388
+ this.state = state;
389
+ (_b = (_a = this.hooks).onState) == null ? void 0 : _b.call(_a, state);
390
+ }
391
+ enterStep(index) {
392
+ var _a, _b;
393
+ const step = this.steps[index];
394
+ if (!step) {
395
+ this.unschedule();
396
+ this.setState("done");
397
+ return;
398
+ }
399
+ this.stepIndex = index;
400
+ this.opIndex = 0;
401
+ this.opElapsed = 0;
402
+ this.stepElapsed = 0;
403
+ this.holdElapsed = 0;
404
+ this.spoken = null;
405
+ step.enter();
406
+ (_b = (_a = this.hooks).onStep) == null ? void 0 : _b.call(_a, index, step);
407
+ const token = ++this.narrationToken;
408
+ this.hooks.narrate(step.say).then(
409
+ (said) => {
410
+ if (token === this.narrationToken) this.spoken = said;
411
+ },
412
+ () => {
413
+ if (token === this.narrationToken) this.spoken = false;
414
+ }
415
+ );
416
+ if (this.reducedMotion) {
417
+ for (const op of step.ops) op.run(1);
418
+ this.opIndex = step.ops.length;
419
+ }
420
+ }
421
+ schedule() {
422
+ if (this.frame !== null || this.state !== "playing") return;
423
+ this.last = this.now();
424
+ this.frame = this.requestFrame((t) => this.tick(t));
425
+ }
426
+ unschedule() {
427
+ if (this.frame !== null) this.cancelFrame(this.frame);
428
+ this.frame = null;
429
+ }
430
+ /** One frame. Public so tests can drive time by hand. */
431
+ tick(now) {
432
+ this.frame = null;
433
+ if (this.state !== "playing") return;
434
+ const dt = Math.max(0, Math.min(100, now - this.last)) * this.speed;
435
+ this.last = now;
436
+ this.advance(dt);
437
+ if (this.state === "playing") this.frame = this.requestFrame((t) => this.tick(t));
438
+ }
439
+ advance(dt) {
440
+ const step = this.steps[this.stepIndex];
441
+ if (!step) return;
442
+ this.stepElapsed += dt;
443
+ let left = dt;
444
+ while (this.opIndex < step.ops.length && left > 0) {
445
+ const op = step.ops[this.opIndex];
446
+ const remaining = op.duration - this.opElapsed;
447
+ if (op.duration <= 0 || left >= remaining) {
448
+ op.run(1);
449
+ left -= Math.max(0, remaining);
450
+ this.opIndex += 1;
451
+ this.opElapsed = 0;
452
+ } else {
453
+ this.opElapsed += left;
454
+ op.run(this.opElapsed / op.duration);
455
+ left = 0;
456
+ }
457
+ }
458
+ while (this.opIndex < step.ops.length && step.ops[this.opIndex].duration <= 0) {
459
+ step.ops[this.opIndex].run(1);
460
+ this.opIndex += 1;
461
+ }
462
+ if (this.opIndex < step.ops.length || this.spoken === null) return;
463
+ const hold = this.spoken ? 0 : readTime(step.say);
464
+ if (this.stepElapsed < hold) return;
465
+ this.holdElapsed += dt;
466
+ if (this.holdElapsed < STEP_GAP_MS) return;
467
+ this.enterStep(this.stepIndex + 1);
468
+ }
469
+ }
470
+ const STORYBOARD_ICON_STROKES = {
471
+ phone: [
472
+ "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",
473
+ "M 43 13 L 57 13",
474
+ "M 41 88 L 59 88"
475
+ ],
476
+ screen: [
477
+ "M 8 18 L 92 18 L 92 66 L 8 66 Z",
478
+ "M 42 66 L 38 84 L 62 84 L 58 66",
479
+ "M 30 84 L 70 84"
480
+ ],
481
+ window: [
482
+ "M 6 16 L 94 16 L 94 84 L 6 84 Z",
483
+ "M 6 32 L 94 32",
484
+ "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"
485
+ ],
486
+ video: [
487
+ "M 8 20 L 92 20 L 92 80 L 8 80 Z",
488
+ "M 20 20 L 20 80 M 80 20 L 80 80",
489
+ "M 42 40 L 64 50 L 42 60 Z"
490
+ ],
491
+ play: [
492
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
493
+ "M 40 32 L 70 50 L 40 68 Z"
494
+ ],
495
+ input: [
496
+ "M 6 36 L 94 36 L 94 64 L 6 64 Z",
497
+ "M 18 43 L 18 57",
498
+ "M 28 50 L 66 50"
499
+ ],
500
+ cursor: [
501
+ "M 24 12 L 24 74 L 39 60 L 49 82 L 60 77 L 50 56 L 70 55 Z"
502
+ ],
503
+ document: [
504
+ "M 24 8 L 62 8 L 78 26 L 78 92 L 24 92 Z",
505
+ "M 62 8 L 62 26 L 78 26",
506
+ "M 36 44 L 66 44 M 36 58 L 66 58 M 36 72 L 54 72"
507
+ ],
508
+ image: [
509
+ "M 10 20 L 90 20 L 90 80 L 10 80 Z",
510
+ "M 10 68 L 36 44 L 56 64 L 68 54 L 90 74",
511
+ "M 61 34 a 7 7 0 1 0 14 0 a 7 7 0 1 0 -14 0"
512
+ ],
513
+ gear: [
514
+ "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",
515
+ "M 39 50 a 11 11 0 1 0 22 0 a 11 11 0 1 0 -22 0"
516
+ ],
517
+ cloud: [
518
+ "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"
519
+ ],
520
+ database: [
521
+ "M 18 24 a 32 10 0 1 0 64 0 a 32 10 0 1 0 -64 0",
522
+ "M 18 24 L 18 76 Q 18 88 50 88 Q 82 88 82 76 L 82 24",
523
+ "M 18 50 Q 18 62 50 62 Q 82 62 82 50"
524
+ ],
525
+ user: [
526
+ "M 33 31 a 17 17 0 1 0 34 0 a 17 17 0 1 0 -34 0",
527
+ "M 16 88 Q 16 56 50 56 Q 84 56 84 88"
528
+ ],
529
+ sparkle: [
530
+ "M 50 6 Q 56 40 90 50 Q 56 60 50 94 Q 44 60 10 50 Q 44 40 50 6 Z"
531
+ ],
532
+ check: [
533
+ "M 16 54 L 40 78 L 86 22"
534
+ ],
535
+ clock: [
536
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
537
+ "M 50 26 L 50 52 L 70 62"
538
+ ],
539
+ lock: [
540
+ "M 22 46 L 78 46 L 78 90 L 22 90 Z",
541
+ "M 34 46 L 34 30 Q 34 12 50 12 Q 66 12 66 30 L 66 46",
542
+ "M 50 62 L 50 74"
543
+ ],
544
+ chat: [
545
+ "M 10 20 L 90 20 L 90 68 L 46 68 L 26 86 L 28 68 L 10 68 Z",
546
+ "M 28 38 L 72 38 M 28 52 L 60 52"
547
+ ],
548
+ cross: [
549
+ "M 22 22 L 78 78",
550
+ "M 78 22 L 22 78"
551
+ ],
552
+ server: [
553
+ "M 16 10 L 84 10 L 84 34 L 16 34 Z",
554
+ "M 16 38 L 84 38 L 84 62 L 16 62 Z",
555
+ "M 16 66 L 84 66 L 84 90 L 16 90 Z",
556
+ "M 26 22 L 32 22 M 26 50 L 32 50 M 26 78 L 32 78",
557
+ "M 54 22 L 74 22 M 54 50 L 74 50 M 54 78 L 74 78"
558
+ ],
559
+ queue: [
560
+ "M 6 32 L 94 32 M 6 68 L 94 68",
561
+ "M 14 40 L 30 40 L 30 60 L 14 60 Z",
562
+ "M 38 40 L 54 40 L 54 60 L 38 60 Z",
563
+ "M 62 40 L 78 40 L 78 60 L 62 60 Z",
564
+ "M 82 50 L 94 50 M 88 44 L 94 50 L 88 56"
565
+ ],
566
+ globe: [
567
+ "M 8 50 a 42 42 0 1 0 84 0 a 42 42 0 1 0 -84 0",
568
+ "M 50 8 Q 22 50 50 92 Q 78 50 50 8",
569
+ "M 8 50 L 92 50",
570
+ "M 16 28 L 84 28 M 16 72 L 84 72"
571
+ ],
572
+ balancer: [
573
+ "M 36 8 L 64 8 L 64 30 L 36 30 Z",
574
+ "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",
575
+ "M 8 62 L 28 62 L 28 86 L 8 86 Z",
576
+ "M 40 62 L 60 62 L 60 86 L 40 86 Z",
577
+ "M 72 62 L 92 62 L 92 86 L 72 86 Z"
578
+ ],
579
+ cache: [
580
+ "M 58 6 L 24 54 L 48 54 L 40 94 L 78 40 L 54 40 Z"
581
+ ],
582
+ container: [
583
+ "M 50 8 L 88 28 L 88 72 L 50 92 L 12 72 L 12 28 Z",
584
+ "M 12 28 L 50 48 L 88 28",
585
+ "M 50 48 L 50 92"
586
+ ]
587
+ };
588
+ function storyboardIconStrokes(icon) {
589
+ var _a;
590
+ return (_a = STORYBOARD_ICON_STROKES[icon]) != null ? _a : [];
591
+ }
592
+ const SHEET_W$1 = 1600;
593
+ const SHEET_H$1 = 1e3;
594
+ const sx = (x) => x * (SHEET_W$1 / 160);
595
+ const sy = (y) => y * (SHEET_H$1 / 100);
596
+ function seeded(seed) {
597
+ let s = seed >>> 0 || 1;
598
+ return () => {
599
+ s ^= s << 13;
600
+ s ^= s >>> 17;
601
+ s ^= s << 5;
602
+ return (s >>> 0) % 1e4 / 1e4;
603
+ };
604
+ }
605
+ function strokeLength(stroke) {
606
+ let length = 0;
607
+ for (let i = 1; i < stroke.length; i += 1) {
608
+ length += Math.hypot(stroke[i].x - stroke[i - 1].x, stroke[i].y - stroke[i - 1].y);
609
+ }
610
+ return length;
611
+ }
612
+ function totalLength(strokes) {
613
+ return strokes.reduce((sum, s) => sum + strokeLength(s), 0);
614
+ }
615
+ function bounds(strokes) {
616
+ let x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
617
+ for (const s of strokes) for (const p of s) {
618
+ x0 = Math.min(x0, p.x);
619
+ y0 = Math.min(y0, p.y);
620
+ x1 = Math.max(x1, p.x);
621
+ y1 = Math.max(y1, p.y);
622
+ }
623
+ return Number.isFinite(x0) ? { x0, y0, x1, y1 } : null;
624
+ }
625
+ function handLine(a, b, rand, steps = 14) {
626
+ const length = Math.hypot(b.x - a.x, b.y - a.y) || 1;
627
+ const nx = -(b.y - a.y) / length;
628
+ const ny = (b.x - a.x) / length;
629
+ const bow = (rand() - 0.5) * Math.min(18, length * 0.04);
630
+ const out = [];
631
+ for (let i = 0; i <= steps; i += 1) {
632
+ const t = i / steps;
633
+ const lift = Math.sin(Math.PI * t) * bow + (rand() - 0.5) * 1.6;
634
+ out.push({ x: a.x + (b.x - a.x) * t + nx * lift, y: a.y + (b.y - a.y) * t + ny * lift });
635
+ }
636
+ return out;
637
+ }
638
+ function handEllipse(b, rand) {
639
+ const cx = sx(b[0] + b[2] / 2);
640
+ const cy = sy(b[1] + b[3] / 2);
641
+ const rx = sx(b[2]) / 2 + 8;
642
+ const ry = sy(b[3]) / 2 + 8;
643
+ const start = -Math.PI * (0.55 + rand() * 0.2);
644
+ const sweep = Math.PI * 2 * (1.06 + rand() * 0.05);
645
+ const out = [];
646
+ const n = 48;
647
+ for (let i = 0; i <= n; i += 1) {
648
+ const t = i / n;
649
+ const a = start + sweep * t;
650
+ const grow = 1 + (t - 0.5) * 0.06 + (rand() - 0.5) * 0.012;
651
+ out.push({ x: cx + Math.cos(a) * rx * grow, y: cy + Math.sin(a) * ry * grow });
652
+ }
653
+ return out;
654
+ }
655
+ function smooth(points, per = 8) {
656
+ if (points.length < 3) return points;
657
+ const out = [];
658
+ for (let i = 0; i < points.length - 1; i += 1) {
659
+ const p0 = points[Math.max(0, i - 1)];
660
+ const p1 = points[i];
661
+ const p2 = points[i + 1];
662
+ const p3 = points[Math.min(points.length - 1, i + 2)];
663
+ for (let j = 0; j < per; j += 1) {
664
+ const t = j / per;
665
+ const t2 = t * t;
666
+ const t3 = t2 * t;
667
+ out.push({
668
+ 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),
669
+ 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)
670
+ });
671
+ }
672
+ }
673
+ out.push(points[points.length - 1]);
674
+ return out;
675
+ }
676
+ function arrowHead(from, to, rand) {
677
+ const angle = Math.atan2(to.y - from.y, to.x - from.x);
678
+ const size = 26 + rand() * 6;
679
+ const spread = 0.45;
680
+ return [
681
+ { x: to.x - size * Math.cos(angle - spread), y: to.y - size * Math.sin(angle - spread) },
682
+ to,
683
+ { x: to.x - size * Math.cos(angle + spread), y: to.y - size * Math.sin(angle + spread) }
684
+ ];
685
+ }
686
+ const corner = (b) => {
687
+ const x0 = sx(b[0]), y0 = sy(b[1]), x1 = sx(b[0] + b[2]), y1 = sy(b[1] + b[3]);
688
+ return [{ x: x0, y: y0 }, { x: x1, y: y0 }, { x: x1, y: y1 }, { x: x0, y: y1 }];
689
+ };
690
+ function handPoly(points, closed, rand) {
691
+ const corners = closed ? [...points, points[0]] : points;
692
+ const out = [];
693
+ for (let i = 1; i < corners.length; i += 1) {
694
+ const length = Math.hypot(corners[i].x - corners[i - 1].x, corners[i].y - corners[i - 1].y);
695
+ const segment = handLine(corners[i - 1], corners[i], rand, Math.max(6, Math.min(24, Math.round(length / 30))));
696
+ out.push(...i === 1 ? segment : segment.slice(1));
697
+ }
698
+ return out;
699
+ }
700
+ function handOval(b, rand) {
701
+ const cx = sx(b[0] + b[2] / 2);
702
+ const cy = sy(b[1] + b[3] / 2);
703
+ const rx = sx(b[2]) / 2;
704
+ const ry = sy(b[3]) / 2;
705
+ const start = -Math.PI * (0.6 + rand() * 0.2);
706
+ const sweep = Math.PI * 2 * (1.03 + rand() * 0.03);
707
+ const n = Math.max(32, Math.round((rx + ry) / 6));
708
+ const out = [];
709
+ for (let i = 0; i <= n; i += 1) {
710
+ const a = start + sweep * i / n;
711
+ const wobble = 1 + (rand() - 0.5) * 0.012;
712
+ out.push({ x: cx + Math.cos(a) * rx * wobble, y: cy + Math.sin(a) * ry * wobble });
713
+ }
714
+ return out;
715
+ }
716
+ const unit = (from, to) => {
717
+ const d = Math.hypot(to.x - from.x, to.y - from.y) || 1;
718
+ return { x: (to.x - from.x) / d, y: (to.y - from.y) / d };
719
+ };
720
+ function rightAngle(a, v, b, rand) {
721
+ 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)));
722
+ const ua = unit(v, a);
723
+ const ub = unit(v, b);
724
+ const p1 = { x: v.x + ua.x * size, y: v.y + ua.y * size };
725
+ const p2 = { x: p1.x + ub.x * size, y: p1.y + ub.y * size };
726
+ const p3 = { x: v.x + ub.x * size, y: v.y + ub.y * size };
727
+ return handPoly([p1, p2, p3], false, rand);
728
+ }
729
+ function angleArc(a, v, b, rand) {
730
+ 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)));
731
+ const from = Math.atan2(a.y - v.y, a.x - v.x);
732
+ let delta = Math.atan2(b.y - v.y, b.x - v.x) - from;
733
+ while (delta > Math.PI) delta -= 2 * Math.PI;
734
+ while (delta < -Math.PI) delta += 2 * Math.PI;
735
+ const n = 18;
736
+ const out = [];
737
+ for (let i = 0; i <= n; i += 1) {
738
+ const t = from + delta * i / n;
739
+ const rr = r * (1 + (rand() - 0.5) * 0.03);
740
+ out.push({ x: v.x + Math.cos(t) * rr, y: v.y + Math.sin(t) * rr });
741
+ }
742
+ return out;
743
+ }
744
+ function handDot(c) {
745
+ const out = [];
746
+ for (let i = 0; i <= 14; i += 1) {
747
+ const t = i / 14 * Math.PI * 4;
748
+ const r = 7 * (1 - i / 16);
749
+ out.push({ x: c.x + Math.cos(t) * r, y: c.y + Math.sin(t) * r });
750
+ }
751
+ return out;
752
+ }
753
+ function roughen(strokes, seed, amount = 2.2) {
754
+ const rand = seeded(seed);
755
+ return strokes.map((stroke) => {
756
+ let dx = 0;
757
+ let dy = 0;
758
+ return stroke.map((p) => {
759
+ dx = dx * 0.6 + (rand() - 0.5) * amount;
760
+ dy = dy * 0.6 + (rand() - 0.5) * amount;
761
+ return { x: p.x + dx, y: p.y + dy };
762
+ });
763
+ });
764
+ }
765
+ function inkStrokes(kind, geometry, seed) {
766
+ var _a, _b, _c;
767
+ const rand = seeded(seed);
768
+ const p = (q) => ({ x: sx(q[0]), y: sy(q[1]) });
769
+ const pts = (_b = (_a = geometry.pts) == null ? void 0 : _a.map(p)) != null ? _b : [];
770
+ switch (kind) {
771
+ case "line":
772
+ case "arrow": {
773
+ if (!geometry.at || geometry.at.length !== 2 || !geometry.to) return [];
774
+ const a = p(geometry.at);
775
+ const b2 = p(geometry.to);
776
+ const shaft = handLine(a, b2, rand);
777
+ return kind === "arrow" ? [shaft, arrowHead((_c = shaft[shaft.length - 2]) != null ? _c : a, b2, rand)] : [shaft];
778
+ }
779
+ case "free":
780
+ case "curve":
781
+ return pts.length >= 2 ? [smooth(pts)] : [];
782
+ case "poly":
783
+ return pts.length >= 2 ? [handPoly(pts, !!geometry.closed && pts.length > 2, rand)] : [];
784
+ case "corner":
785
+ return pts.length === 3 ? [rightAngle(pts[0], pts[1], pts[2], rand)] : [];
786
+ case "arc":
787
+ return pts.length === 3 ? [angleArc(pts[0], pts[1], pts[2], rand)] : [];
788
+ case "dot":
789
+ return geometry.at && geometry.at.length === 2 ? [handDot(p(geometry.at))] : [];
790
+ }
791
+ const b = geometry.at && geometry.at.length === 4 ? geometry.at : null;
792
+ if (!b) return [];
793
+ const [tl, tr, br, bl] = corner(b);
794
+ switch (kind) {
795
+ case "oval":
796
+ return [handOval(b, rand)];
797
+ case "circle":
798
+ return [handEllipse(b, rand)];
799
+ case "box":
800
+ return [handLine(tl, tr, rand, 10), handLine(tr, br, rand, 8), handLine(br, bl, rand, 10), handLine(bl, tl, rand, 8)];
801
+ case "underline": {
802
+ const y = br.y + 6;
803
+ return [handLine({ x: bl.x - 4, y }, { x: br.x + 4, y: y + (rand() - 0.5) * 6 }, rand, 18)];
804
+ }
805
+ case "cross":
806
+ return [handLine(tl, br, rand, 10), handLine(tr, bl, rand, 10)];
807
+ case "tick": {
808
+ const mid = { x: tl.x + (br.x - tl.x) * 0.38, y: br.y };
809
+ return [[...handLine({ x: tl.x, y: tl.y + (br.y - tl.y) * 0.55 }, mid, rand, 6), ...handLine(mid, tr, rand, 10).slice(1)]];
810
+ }
811
+ case "bracket": {
812
+ const x = tr.x;
813
+ const mid = (tr.y + br.y) / 2;
814
+ 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)];
815
+ }
816
+ default:
817
+ return [];
818
+ }
819
+ }
820
+ const TOKEN = /([MmLlHhVvCcSsQqTtAaZz])|(-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?)/g;
821
+ function flattenPath(d, curveSteps = 8) {
822
+ var _a;
823
+ const tokens = [];
824
+ for (const m of d.matchAll(TOKEN)) tokens.push((_a = m[1]) != null ? _a : Number(m[2]));
825
+ const strokes = [];
826
+ let current = [];
827
+ let x = 0, y = 0, startX = 0, startY = 0;
828
+ let lastCtrl = null;
829
+ let lastQuad = null;
830
+ let cmd = "";
831
+ let i = 0;
832
+ const next = () => {
833
+ const v = tokens[i++];
834
+ return typeof v === "number" ? v : NaN;
835
+ };
836
+ const hasNumber = () => typeof tokens[i] === "number";
837
+ const push = (px, py) => {
838
+ current.push({ x: px, y: py });
839
+ };
840
+ const finish = () => {
841
+ if (current.length > 1) strokes.push(current);
842
+ current = [];
843
+ };
844
+ const cubic = (c1, c2, end) => {
845
+ const sx0 = x, sy0 = y;
846
+ for (let s = 1; s <= curveSteps; s += 1) {
847
+ const t = s / curveSteps;
848
+ const u = 1 - t;
849
+ push(
850
+ u * u * u * sx0 + 3 * u * u * t * c1.x + 3 * u * t * t * c2.x + t * t * t * end.x,
851
+ u * u * u * sy0 + 3 * u * u * t * c1.y + 3 * u * t * t * c2.y + t * t * t * end.y
852
+ );
853
+ }
854
+ x = end.x;
855
+ y = end.y;
856
+ };
857
+ const quad = (c, end) => {
858
+ const sx0 = x, sy0 = y;
859
+ for (let s = 1; s <= curveSteps; s += 1) {
860
+ const t = s / curveSteps;
861
+ const u = 1 - t;
862
+ 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);
863
+ }
864
+ x = end.x;
865
+ y = end.y;
866
+ };
867
+ while (i < tokens.length) {
868
+ if (typeof tokens[i] === "string") cmd = tokens[i++];
869
+ else if (!cmd) {
870
+ i += 1;
871
+ continue;
872
+ }
873
+ const rel = cmd === cmd.toLowerCase();
874
+ const ox = rel ? x : 0;
875
+ const oy = rel ? y : 0;
876
+ switch (cmd.toUpperCase()) {
877
+ case "M": {
878
+ finish();
879
+ x = ox + next();
880
+ y = oy + next();
881
+ startX = x;
882
+ startY = y;
883
+ push(x, y);
884
+ cmd = rel ? "l" : "L";
885
+ lastCtrl = lastQuad = null;
886
+ break;
887
+ }
888
+ case "L":
889
+ x = ox + next();
890
+ y = oy + next();
891
+ push(x, y);
892
+ lastCtrl = lastQuad = null;
893
+ break;
894
+ case "H":
895
+ x = ox + next();
896
+ push(x, y);
897
+ lastCtrl = lastQuad = null;
898
+ break;
899
+ case "V":
900
+ y = oy + next();
901
+ push(x, y);
902
+ lastCtrl = lastQuad = null;
903
+ break;
904
+ case "C": {
905
+ const c1 = { x: ox + next(), y: oy + next() };
906
+ const c2 = { x: ox + next(), y: oy + next() };
907
+ const end = { x: ox + next(), y: oy + next() };
908
+ cubic(c1, c2, end);
909
+ lastCtrl = c2;
910
+ lastQuad = null;
911
+ break;
912
+ }
913
+ case "S": {
914
+ const c1 = lastCtrl ? { x: 2 * x - lastCtrl.x, y: 2 * y - lastCtrl.y } : { x, y };
915
+ const c2 = { x: ox + next(), y: oy + next() };
916
+ const end = { x: ox + next(), y: oy + next() };
917
+ cubic(c1, c2, end);
918
+ lastCtrl = c2;
919
+ lastQuad = null;
920
+ break;
921
+ }
922
+ case "Q": {
923
+ const c = { x: ox + next(), y: oy + next() };
924
+ const end = { x: ox + next(), y: oy + next() };
925
+ quad(c, end);
926
+ lastQuad = c;
927
+ lastCtrl = null;
928
+ break;
929
+ }
930
+ case "T": {
931
+ const c = lastQuad ? { x: 2 * x - lastQuad.x, y: 2 * y - lastQuad.y } : { x, y };
932
+ const end = { x: ox + next(), y: oy + next() };
933
+ quad(c, end);
934
+ lastQuad = c;
935
+ lastCtrl = null;
936
+ break;
937
+ }
938
+ case "A": {
939
+ const rx = next(), ry = next(), rotation = next(), large = next(), sweep = next();
940
+ const end = { x: ox + next(), y: oy + next() };
941
+ for (const p of arcPoints({ x, y }, end, rx, ry, rotation, large !== 0, sweep !== 0, curveSteps * 2)) push(p.x, p.y);
942
+ x = end.x;
943
+ y = end.y;
944
+ lastCtrl = lastQuad = null;
945
+ break;
946
+ }
947
+ case "Z":
948
+ push(startX, startY);
949
+ x = startX;
950
+ y = startY;
951
+ finish();
952
+ current = [{ x, y }];
953
+ lastCtrl = lastQuad = null;
954
+ if (hasNumber()) cmd = rel ? "l" : "L";
955
+ else cmd = "";
956
+ break;
957
+ default:
958
+ i += 1;
959
+ }
960
+ if (Number.isNaN(x) || Number.isNaN(y)) return strokes;
961
+ }
962
+ finish();
963
+ return strokes;
964
+ }
965
+ function arcPoints(from, to, rx, ry, degrees, large, sweep, steps) {
966
+ if (!rx || !ry || from.x === to.x && from.y === to.y) return [to];
967
+ const phi = degrees * Math.PI / 180;
968
+ const cos = Math.cos(phi), sin = Math.sin(phi);
969
+ const dx = (from.x - to.x) / 2, dy = (from.y - to.y) / 2;
970
+ const x1 = cos * dx + sin * dy, y1 = -sin * dx + cos * dy;
971
+ let rxa = Math.abs(rx), rya = Math.abs(ry);
972
+ const scale = x1 * x1 / (rxa * rxa) + y1 * y1 / (rya * rya);
973
+ if (scale > 1) {
974
+ rxa *= Math.sqrt(scale);
975
+ rya *= Math.sqrt(scale);
976
+ }
977
+ const num = rxa * rxa * rya * rya - rxa * rxa * y1 * y1 - rya * rya * x1 * x1;
978
+ const den = rxa * rxa * y1 * y1 + rya * rya * x1 * x1;
979
+ const k = (large === sweep ? -1 : 1) * Math.sqrt(Math.max(0, num / den));
980
+ const cx1 = k * rxa * y1 / rya, cy1 = -k * rya * x1 / rxa;
981
+ const cx = cos * cx1 - sin * cy1 + (from.x + to.x) / 2;
982
+ const cy = sin * cx1 + cos * cy1 + (from.y + to.y) / 2;
983
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
984
+ const start = angle(1, 0, (x1 - cx1) / rxa, (y1 - cy1) / rya);
985
+ let delta = angle((x1 - cx1) / rxa, (y1 - cy1) / rya, (-x1 - cx1) / rxa, (-y1 - cy1) / rya);
986
+ if (!sweep && delta > 0) delta -= 2 * Math.PI;
987
+ if (sweep && delta < 0) delta += 2 * Math.PI;
988
+ const out = [];
989
+ for (let i = 1; i <= steps; i += 1) {
990
+ const t = start + delta * i / steps;
991
+ 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 });
992
+ }
993
+ out[out.length - 1] = to;
994
+ return out;
995
+ }
996
+ function parseTransform(transform) {
997
+ const t = /translate\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
998
+ const s = /scale\(\s*(-?[\d.]+)(?:[\s,]+(-?[\d.]+))?/.exec(transform);
999
+ const kx = s ? Number(s[1]) : 1;
1000
+ return {
1001
+ tx: t ? Number(t[1]) : 0,
1002
+ ty: t && t[2] !== void 0 ? Number(t[2]) : 0,
1003
+ kx,
1004
+ ky: s && s[2] !== void 0 ? Number(s[2]) : kx
1005
+ };
1006
+ }
1007
+ function fit(strokes, viewBox, transform, b) {
1008
+ const [vx, vy, vw, vh] = viewBox.split(/[\s,]+/).map(Number);
1009
+ const w = vw > 0 ? vw : 100;
1010
+ const h = vh > 0 ? vh : 100;
1011
+ const { tx, ty, kx, ky } = parseTransform(transform);
1012
+ const bx = sx(b[0]), by = sy(b[1]), bw = sx(b[2]), bh = sy(b[3]);
1013
+ const k = Math.min(bw / w, bh / h);
1014
+ const offX = bx + (bw - w * k) / 2;
1015
+ const offY = by + (bh - h * k) / 2;
1016
+ return strokes.map((stroke) => stroke.map((p) => ({
1017
+ x: offX + (tx + kx * p.x - (vx || 0)) * k,
1018
+ y: offY + (ty + ky * p.y - (vy || 0)) * k
1019
+ })));
1020
+ }
1021
+ function artStrokes(ink, b, seed = 1) {
1022
+ if ("icon" in ink) {
1023
+ const paths = storyboardIconStrokes(ink.icon);
1024
+ return roughen(fit(paths.flatMap((d) => flattenPath(d, 14)), "0 0 100 100", "", b), seed);
1025
+ }
1026
+ return fit(ink.contours.flatMap((d) => flattenPath(d, 6)), ink.view_box, ink.transform, b);
1027
+ }
1028
+ function pointAlong(strokes, length) {
1029
+ let left = length;
1030
+ for (const s of strokes) {
1031
+ for (let i = 1; i < s.length; i += 1) {
1032
+ const seg = Math.hypot(s[i].x - s[i - 1].x, s[i].y - s[i - 1].y);
1033
+ if (left <= seg) {
1034
+ const t = seg ? left / seg : 1;
1035
+ 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 };
1036
+ }
1037
+ left -= seg;
1038
+ }
1039
+ }
1040
+ const last = strokes[strokes.length - 1];
1041
+ return last ? last[last.length - 1] : null;
1042
+ }
1043
+ const INK = { ink: "#1f2937", blue: "#2563eb", red: "#dc2626", green: "#059669" };
1044
+ const MARKER = "rgba(250, 204, 21, 0.42)";
1045
+ const TEXT_SIZE = { s: 2.3, m: 3.1, l: 4.3 };
1046
+ const TRAVEL_MS = 200;
1047
+ class BoardModel {
1048
+ constructor(options) {
1049
+ this.options = options;
1050
+ this.inks = [];
1051
+ this.pictures = [];
1052
+ this.credit = null;
1053
+ this.words = [];
1054
+ this.pen = null;
1055
+ this.caption = "";
1056
+ this.step = -1;
1057
+ this.player = null;
1058
+ this.scene = null;
1059
+ this.nextKey = 1;
1060
+ }
1061
+ snapshot() {
1062
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1063
+ return {
1064
+ inks: this.inks,
1065
+ pictures: this.pictures,
1066
+ credit: this.credit,
1067
+ words: this.words,
1068
+ pen: this.pen,
1069
+ caption: this.caption,
1070
+ step: this.step,
1071
+ steps: (_b = (_a = this.scene) == null ? void 0 : _a.steps.length) != null ? _b : 0,
1072
+ state: (_d = (_c = this.player) == null ? void 0 : _c.status) != null ? _d : "idle",
1073
+ title: (_f = (_e = this.scene) == null ? void 0 : _e.title) != null ? _f : "",
1074
+ sample: (_h = (_g = this.scene) == null ? void 0 : _g.sample) != null ? _h : false
1075
+ };
1076
+ }
1077
+ play(scene) {
1078
+ var _a, _b, _c, _d, _e;
1079
+ this.destroy();
1080
+ this.scene = scene;
1081
+ const steps = scene.steps.map((step, index) => this.buildStep(step, index));
1082
+ this.player = new Player(steps, {
1083
+ narrate: (_a = this.options.narrate) != null ? _a : (async () => false),
1084
+ stopNarration: () => {
1085
+ var _a2, _b2;
1086
+ return (_b2 = (_a2 = this.options).stopNarration) == null ? void 0 : _b2.call(_a2);
1087
+ },
1088
+ reset: () => this.wipe(),
1089
+ onStep: (index, step) => {
1090
+ this.step = index;
1091
+ this.caption = step.say;
1092
+ this.changed();
1093
+ },
1094
+ onState: () => this.changed(),
1095
+ requestFrame: (_b = this.options.requestFrame) != null ? _b : ((cb) => requestAnimationFrame(cb)),
1096
+ cancelFrame: (_c = this.options.cancelFrame) != null ? _c : ((id) => cancelAnimationFrame(id)),
1097
+ now: (_d = this.options.now) != null ? _d : (() => Date.now())
1098
+ }, (_e = this.options.reducedMotion) != null ? _e : false);
1099
+ this.player.play();
1100
+ }
1101
+ /** Pause, or carry on from where it was. */
1102
+ toggle() {
1103
+ if (!this.player) return;
1104
+ if (this.player.status === "playing") this.player.pause();
1105
+ else this.player.play();
1106
+ }
1107
+ replay() {
1108
+ var _a;
1109
+ (_a = this.player) == null ? void 0 : _a.replay();
1110
+ }
1111
+ seek(step) {
1112
+ var _a;
1113
+ (_a = this.player) == null ? void 0 : _a.seek(step);
1114
+ }
1115
+ setSpeed(speed) {
1116
+ var _a;
1117
+ (_a = this.player) == null ? void 0 : _a.setSpeed(speed);
1118
+ }
1119
+ get speed() {
1120
+ var _a, _b;
1121
+ return (_b = (_a = this.player) == null ? void 0 : _a.rate) != null ? _b : 1;
1122
+ }
1123
+ /** Stop for good: no frames, nothing on the board. */
1124
+ destroy() {
1125
+ var _a;
1126
+ (_a = this.player) == null ? void 0 : _a.destroy();
1127
+ this.player = null;
1128
+ this.scene = null;
1129
+ this.wipe();
1130
+ this.step = -1;
1131
+ this.caption = "";
1132
+ }
1133
+ changed() {
1134
+ this.options.onChange();
1135
+ }
1136
+ wipe() {
1137
+ this.inks = [];
1138
+ this.pictures = [];
1139
+ this.credit = null;
1140
+ this.words = [];
1141
+ this.pen = null;
1142
+ this.changed();
1143
+ }
1144
+ // ------------------------------------------------------------- steps → ops
1145
+ buildStep(step, index) {
1146
+ return {
1147
+ say: step.say,
1148
+ enter: () => {
1149
+ if (step.clear) this.wipe();
1150
+ },
1151
+ ops: step.draw.map((item, i) => this.opFor(item, index * 100 + i + 1))
1152
+ };
1153
+ }
1154
+ opFor(item, seed) {
1155
+ var _a, _b, _c, _d;
1156
+ switch (item.kind) {
1157
+ case "ink":
1158
+ 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);
1159
+ case "art": {
1160
+ const ink = (_a = this.scene) == null ? void 0 : _a.art[item.art];
1161
+ if (!ink) {
1162
+ const [x, y, w, h] = item.at;
1163
+ 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 });
1164
+ }
1165
+ return this.inkOp(item.id, artStrokes(ink, item.at, seed), INK[item.tone], "icon" in ink ? 7 : 4, 1100, 4500, 2.6);
1166
+ }
1167
+ case "photo": {
1168
+ const pic = (_c = (_b = this.scene) == null ? void 0 : _b.photos) == null ? void 0 : _c[item.photo];
1169
+ if (!pic) {
1170
+ const [x, y, w, h] = item.at;
1171
+ return this.textOp({ kind: "text", id: item.id, text: item.photo, at: [x + 1, y + h / 2], size: w < 15 ? "s" : "m", tone: "ink" });
1172
+ }
1173
+ return this.photoOp(item, pic.url, (_d = pic.credit) != null ? _d : null);
1174
+ }
1175
+ case "text":
1176
+ return this.textOp(item);
1177
+ case "table":
1178
+ return this.tableOp(item);
1179
+ case "mark":
1180
+ return this.markOp(item.mark);
1181
+ case "erase":
1182
+ return this.eraseOp(item.erase);
1183
+ default:
1184
+ return { duration: 0, run: () => void 0 };
1185
+ }
1186
+ }
1187
+ inkOp(id, strokes, color, width, min, max, perMs, marker = false) {
1188
+ const length = totalLength(strokes);
1189
+ const duration = Math.min(max, Math.max(min, length / perMs)) + TRAVEL_MS;
1190
+ const share = TRAVEL_MS / duration;
1191
+ let obj = null;
1192
+ return {
1193
+ duration,
1194
+ run: (progress) => {
1195
+ var _a, _b;
1196
+ if (!obj) {
1197
+ obj = { key: this.nextKey++, id, strokes, length, color, width, marker, drawn: 0 };
1198
+ this.inks = [...this.inks, obj];
1199
+ }
1200
+ if (!length) return;
1201
+ const drawn = progress >= 1 ? 1 : Math.max(0, (progress - share) / (1 - share));
1202
+ obj.drawn = drawn;
1203
+ this.pen = drawn > 0 ? pointAlong(strokes, length * drawn) : (_b = (_a = strokes[0]) == null ? void 0 : _a[0]) != null ? _b : this.pen;
1204
+ this.changed();
1205
+ }
1206
+ };
1207
+ }
1208
+ photoOp(item, url, credit) {
1209
+ const duration = 1400 + TRAVEL_MS;
1210
+ const [x, y, w, h] = item.at;
1211
+ let pic = null;
1212
+ return {
1213
+ duration,
1214
+ run: (progress) => {
1215
+ if (!pic) {
1216
+ pic = { key: this.nextKey++, id: item.id, url, alt: item.photo, at: item.at, shown: 0, marked: false };
1217
+ this.pictures = [...this.pictures, pic];
1218
+ if (credit) this.credit = credit;
1219
+ }
1220
+ const shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1221
+ pic.shown = shown;
1222
+ this.pen = shown < 1 ? { x: sx(x + w * shown), y: sy(y + h * (0.5 + 0.35 * Math.sin(shown * 9))) } : this.pen;
1223
+ this.changed();
1224
+ }
1225
+ };
1226
+ }
1227
+ textOp(item) {
1228
+ const duration = Math.min(2e3, Math.max(350, item.text.length * 60)) + TRAVEL_MS;
1229
+ let word = null;
1230
+ return {
1231
+ duration,
1232
+ run: (progress) => {
1233
+ if (!word) {
1234
+ 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 };
1235
+ this.words = [...this.words, word];
1236
+ }
1237
+ word.shown = progress >= 1 ? 1 : Math.max(0, (progress * duration - TRAVEL_MS) / (duration - TRAVEL_MS));
1238
+ const height = TEXT_SIZE[item.size] / 100 * BOARD_W;
1239
+ this.pen = { x: sx(item.at[0] + item.text.length * height * 0.55 * word.shown), y: sy(item.at[1]) };
1240
+ this.changed();
1241
+ }
1242
+ };
1243
+ }
1244
+ tableOp(item) {
1245
+ let table = null;
1246
+ return {
1247
+ duration: item.rows.length * 450 + TRAVEL_MS,
1248
+ run: (progress) => {
1249
+ if (!table) {
1250
+ 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 };
1251
+ this.words = [...this.words, table];
1252
+ }
1253
+ table.rowsShown = progress >= 1 ? item.rows.length : Math.max(progress > 0 ? 1 : 0, Math.floor(progress * item.rows.length));
1254
+ this.pen = { x: sx(item.at[0] + item.at[2]), y: sy(item.at[1]) };
1255
+ this.changed();
1256
+ }
1257
+ };
1258
+ }
1259
+ markOp(id) {
1260
+ let done = false;
1261
+ return {
1262
+ duration: 650,
1263
+ run: () => {
1264
+ var _a;
1265
+ if (done) return;
1266
+ done = true;
1267
+ const thing = (_a = this.words.find((w) => w.id === id)) != null ? _a : this.pictures.find((p) => p.id === id);
1268
+ if (thing) {
1269
+ thing.marked = true;
1270
+ this.changed();
1271
+ return;
1272
+ }
1273
+ const ink = this.inks.find((obj) => obj.id === id && !obj.marker);
1274
+ const box = ink ? bounds(ink.strokes) : null;
1275
+ if (!ink || !box) return;
1276
+ const tall = box.y1 - box.y0;
1277
+ const mid = (box.y0 + box.y1) / 2;
1278
+ const strokes = tall <= 120 ? [[{ x: box.x0 - 14, y: mid }, { x: box.x1 + 14, y: mid }]] : ink.strokes;
1279
+ this.inks = [{
1280
+ key: this.nextKey++,
1281
+ strokes,
1282
+ length: totalLength(strokes),
1283
+ color: MARKER,
1284
+ width: tall <= 120 ? Math.max(24, tall * 0.6) : 26,
1285
+ marker: true,
1286
+ drawn: 1
1287
+ }, ...this.inks];
1288
+ this.changed();
1289
+ }
1290
+ };
1291
+ }
1292
+ eraseOp(id) {
1293
+ return {
1294
+ duration: 350,
1295
+ run: (progress) => {
1296
+ if (progress < 1) return;
1297
+ this.words = this.words.filter((w) => w.id !== id);
1298
+ this.pictures = this.pictures.filter((p) => p.id !== id);
1299
+ this.inks = this.inks.filter((obj) => obj.id !== id);
1300
+ this.changed();
1301
+ }
1302
+ };
1303
+ }
1304
+ }
1305
+ function inkPath(strokes, length, upTo) {
1306
+ let left = length * upTo;
1307
+ const parts = [];
1308
+ for (const stroke of strokes) {
1309
+ if (left <= 0 || stroke.length < 2) break;
1310
+ let d = `M${stroke[0].x.toFixed(1)} ${stroke[0].y.toFixed(1)}`;
1311
+ for (let i = 1; i < stroke.length; i += 1) {
1312
+ const a = stroke[i - 1];
1313
+ const b = stroke[i];
1314
+ const seg = Math.hypot(b.x - a.x, b.y - a.y);
1315
+ if (seg >= left) {
1316
+ const t = seg ? left / seg : 1;
1317
+ d += `L${(a.x + (b.x - a.x) * t).toFixed(1)} ${(a.y + (b.y - a.y) * t).toFixed(1)}`;
1318
+ left = 0;
1319
+ break;
1320
+ }
1321
+ d += `L${b.x.toFixed(1)} ${b.y.toFixed(1)}`;
1322
+ left -= seg;
1323
+ }
1324
+ parts.push(d);
1325
+ }
1326
+ return parts.join("");
1327
+ }
1328
+ const darkTheme = {
1329
+ background: "#0B0713",
1330
+ surface: "rgba(255,255,255,0.06)",
1331
+ surfaceRaised: "#1C1626",
1332
+ text: "#F5F3FF",
1333
+ textMuted: "#8B85A0",
1334
+ accent: "#7C5CFF",
1335
+ onAccent: "#FFFFFF",
1336
+ userBubble: "#7C5CFF",
1337
+ onUserBubble: "#FFFFFF",
1338
+ error: "rgba(248,113,113,0.16)",
1339
+ border: "rgba(255,255,255,0.10)",
1340
+ radius: 22,
1341
+ fontSize: 15
1342
+ };
1343
+ const lightTheme = {
1344
+ background: "#FFFFFF",
1345
+ surface: "#F1F5F9",
1346
+ surfaceRaised: "#FFFFFF",
1347
+ text: "#0F172A",
1348
+ textMuted: "#64748B",
1349
+ accent: "#7C5CFF",
1350
+ onAccent: "#FFFFFF",
1351
+ userBubble: "#7C5CFF",
1352
+ onUserBubble: "#FFFFFF",
1353
+ error: "#FEE2E2",
1354
+ border: "#E2E8F0",
1355
+ radius: 22,
1356
+ fontSize: 15
1357
+ };
1358
+ function resolveTheme(overrides, base = lightTheme) {
1359
+ return overrides ? { ...base, ...overrides } : base;
1360
+ }
1361
+ const SHEET_W = 1600;
1362
+ const SHEET_H = 1e3;
1363
+ const HAND = Platform.select({ ios: "Bradley Hand", android: "casual", default: void 0 });
1364
+ const PEN = "M0 0 L-5 -22 L22 -70 L32 -63 L5 -16 Z";
1365
+ function GuideAIWhiteboard({ theme: overrides }) {
1366
+ const theme = resolveTheme(overrides);
1367
+ const { state, close, retry } = useWhiteboard();
1368
+ const [, repaint] = useReducer((n) => n + 1, 0);
1369
+ const [width, setWidth] = useState(0);
1370
+ const [expanded, setExpanded] = useState(false);
1371
+ const motion = useRef({ reduced: false });
1372
+ const speech = GuideAI.isConfigured() ? requireConfigured().speech : null;
1373
+ const [muted, setMuted] = useState(false);
1374
+ const voice = useRef({ muted: false });
1375
+ voice.current.muted = muted;
1376
+ const model = useMemo(() => new BoardModel({
1377
+ onChange: () => repaint(),
1378
+ get reducedMotion() {
1379
+ return motion.current.reduced;
1380
+ },
1381
+ narrate: async (text) => speech && !voice.current.muted ? speech.say(text) : false,
1382
+ stopNarration: () => speech == null ? void 0 : speech.stop()
1383
+ }), [speech]);
1384
+ const toggleVoice = () => {
1385
+ if (!muted) speech == null ? void 0 : speech.stop();
1386
+ setMuted((on) => !on);
1387
+ };
1388
+ useEffect(() => {
1389
+ var _a, _b;
1390
+ void ((_b = (_a = AccessibilityInfo).isReduceMotionEnabled) == null ? void 0 : _b.call(_a).then((on) => {
1391
+ motion.current.reduced = on;
1392
+ }, () => void 0));
1393
+ }, []);
1394
+ useEffect(() => {
1395
+ if (state.status === "playing" && state.scene) model.play(state.scene);
1396
+ else model.destroy();
1397
+ }, [model, state.status, state.scene]);
1398
+ useEffect(() => () => model.destroy(), [model]);
1399
+ if (state.status === "closed") return null;
1400
+ const board = model.snapshot();
1401
+ const height = width / (BOARD_W / BOARD_H);
1402
+ const unit2 = width / 100;
1403
+ const playing = board.state === "playing";
1404
+ const title = state.status === "playing" ? board.title : state.question;
1405
+ const shut = () => {
1406
+ model.destroy();
1407
+ close();
1408
+ };
1409
+ return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: shut, supportedOrientations: ["portrait", "landscape"], children: /* @__PURE__ */ jsx(View, { style: [styles$3.backdrop, expanded ? styles$3.centre : null], pointerEvents: "box-none", children: /* @__PURE__ */ jsxs(
1410
+ View,
1411
+ {
1412
+ style: [styles$3.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, maxWidth: expanded ? 1040 : 540 }],
1413
+ accessibilityViewIsModal: true,
1414
+ accessibilityLabel: `Whiteboard: ${title}`,
1415
+ children: [
1416
+ /* @__PURE__ */ jsxs(View, { style: styles$3.head, children: [
1417
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.title, { color: theme.text }], numberOfLines: 1, children: title || "Whiteboard" }),
1418
+ board.sample && state.status === "playing" ? /* @__PURE__ */ jsx(Text, { style: styles$3.badge, accessibilityHint: "This board uses example numbers.", children: "Example" }) : null,
1419
+ speech ? /* @__PURE__ */ jsx(IconButton, { label: muted ? "Read the board aloud" : "Mute the board", glyph: muted ? "🔇" : "🔈", color: theme.textMuted, onPress: toggleVoice }) : null,
1420
+ /* @__PURE__ */ jsx(IconButton, { label: expanded ? "Collapse whiteboard" : "Expand whiteboard", glyph: expanded ? "⤡" : "⤢", color: theme.textMuted, onPress: () => setExpanded((v) => !v) }),
1421
+ /* @__PURE__ */ jsx(IconButton, { label: "Close whiteboard", glyph: "✕", color: theme.textMuted, onPress: shut })
1422
+ ] }),
1423
+ /* @__PURE__ */ jsxs(View, { style: styles$3.sheet, onLayout: (e) => setWidth(e.nativeEvent.layout.width), children: [
1424
+ width > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1425
+ /* @__PURE__ */ jsxs(Svg, { width, height, viewBox: `0 0 ${SHEET_W} ${SHEET_H}`, children: [
1426
+ board.pictures.map((pic) => /* @__PURE__ */ jsx(Picture, { pic }, pic.key)),
1427
+ board.inks.filter((obj) => obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1428
+ board.inks.filter((obj) => !obj.marker).map((obj) => /* @__PURE__ */ jsx(Ink, { obj }, obj.key)),
1429
+ board.pen && playing && !motion.current.reduced ? /* @__PURE__ */ jsx(G, { transform: `translate(${board.pen.x.toFixed(1)} ${board.pen.y.toFixed(1)})`, children: /* @__PURE__ */ jsx(Path, { d: PEN, fill: "#fde68a", stroke: "#1f2937", strokeWidth: 3, strokeLinejoin: "round" }) }) : null
1430
+ ] }),
1431
+ board.words.map((word) => /* @__PURE__ */ jsx(Word, { word, width, height, unit: unit2 }, word.key)),
1432
+ board.credit ? /* @__PURE__ */ jsxs(Text, { style: styles$3.credit, numberOfLines: 1, children: [
1433
+ "Picture: ",
1434
+ board.credit
1435
+ ] }) : null
1436
+ ] }) : null,
1437
+ state.status === "loading" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "polite", children: [
1438
+ /* @__PURE__ */ jsx(ActivityIndicator, { color: theme.accent }),
1439
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: "Drawing your board…" })
1440
+ ] }) : null,
1441
+ state.status === "error" ? /* @__PURE__ */ jsxs(View, { style: styles$3.status, accessibilityLiveRegion: "assertive", children: [
1442
+ /* @__PURE__ */ jsx(Text, { style: styles$3.statusText, children: state.error }),
1443
+ /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", onPress: retry, style: [styles$3.retry, { backgroundColor: theme.accent }], children: /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Try again" }) })
1444
+ ] }) : null
1445
+ ] }),
1446
+ state.status === "playing" ? /* @__PURE__ */ jsxs(Fragment, { children: [
1447
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.caption, { color: theme.text }], accessibilityLiveRegion: "polite", children: board.caption }),
1448
+ board.steps > 1 ? /* @__PURE__ */ jsx(View, { style: styles$3.track, accessibilityLabel: "Steps", children: Array.from({ length: board.steps }, (_, i) => /* @__PURE__ */ jsx(
1449
+ Pressable,
1450
+ {
1451
+ accessibilityRole: "button",
1452
+ accessibilityLabel: `Go to step ${i + 1}`,
1453
+ accessibilityState: { selected: i === board.step },
1454
+ onPress: () => model.seek(i),
1455
+ hitSlop: 8,
1456
+ style: [styles$3.segment, { backgroundColor: i <= board.step ? theme.accent : theme.border }]
1457
+ },
1458
+ i
1459
+ )) }) : null,
1460
+ /* @__PURE__ */ jsxs(View, { style: styles$3.bar, children: [
1461
+ /* @__PURE__ */ jsx(
1462
+ IconButton,
1463
+ {
1464
+ label: playing ? "Pause" : board.state === "done" ? "Play again" : "Resume",
1465
+ glyph: playing ? "❚❚" : board.state === "done" ? "↻" : "▶",
1466
+ color: theme.text,
1467
+ onPress: () => model.toggle()
1468
+ }
1469
+ ),
1470
+ /* @__PURE__ */ jsx(IconButton, { label: "Replay from the start", glyph: "↺", color: theme.text, onPress: () => model.replay() }),
1471
+ /* @__PURE__ */ jsx(Text, { style: [styles$3.step, { color: theme.textMuted }], children: board.step >= 0 ? `Step ${board.step + 1} of ${board.steps}` : "" }),
1472
+ /* @__PURE__ */ jsx(
1473
+ Pressable,
1474
+ {
1475
+ accessibilityRole: "button",
1476
+ accessibilityLabel: `Speed ${model.speed} times. Change speed`,
1477
+ onPress: () => {
1478
+ const at = SPEEDS.indexOf(model.speed);
1479
+ model.setSpeed(SPEEDS[(at + 1) % SPEEDS.length]);
1480
+ repaint();
1481
+ },
1482
+ style: [styles$3.speed, { borderColor: theme.border }],
1483
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.text, fontSize: 12 }, children: [
1484
+ model.speed,
1485
+ "×"
1486
+ ] })
1487
+ }
1488
+ )
1489
+ ] })
1490
+ ] }) : null
1491
+ ]
1492
+ }
1493
+ ) }) });
1494
+ }
1495
+ function Ink({ obj }) {
1496
+ if (obj.drawn <= 0) return null;
1497
+ return /* @__PURE__ */ jsx(
1498
+ Path,
1499
+ {
1500
+ d: inkPath(obj.strokes, obj.length, obj.drawn),
1501
+ stroke: obj.color,
1502
+ strokeWidth: obj.width,
1503
+ fill: "none",
1504
+ strokeLinecap: "round",
1505
+ strokeLinejoin: "round"
1506
+ }
1507
+ );
1508
+ }
1509
+ function Picture({ pic }) {
1510
+ if (pic.shown <= 0) return null;
1511
+ const x = pic.at[0] / BOARD_W * SHEET_W;
1512
+ const y = pic.at[1] / BOARD_H * SHEET_H;
1513
+ const w = pic.at[2] / BOARD_W * SHEET_W;
1514
+ const h = pic.at[3] / BOARD_H * SHEET_H;
1515
+ const clip = `wb-pic-${pic.key}`;
1516
+ return /* @__PURE__ */ jsxs(G, { children: [
1517
+ /* @__PURE__ */ jsx(Defs, { children: /* @__PURE__ */ jsx(ClipPath, { id: clip, children: /* @__PURE__ */ jsx(Rect, { x, y, width: w * pic.shown, height: h }) }) }),
1518
+ pic.marked ? /* @__PURE__ */ jsx(Rect, { x: x - 12, y: y - 12, width: w + 24, height: h + 24, rx: 14, fill: MARKER }) : null,
1519
+ /* @__PURE__ */ jsx(Image, { href: { uri: pic.url }, x, y, width: w, height: h, preserveAspectRatio: "xMidYMid meet", clipPath: `url(#${clip})` })
1520
+ ] });
1521
+ }
1522
+ function Word({ word, width, height, unit: unit2 }) {
1523
+ const left = word.at[0] / BOARD_W * width;
1524
+ const top = word.at[1] / BOARD_H * height;
1525
+ if (word.kind === "text") {
1526
+ const size2 = unit2 * TEXT_SIZE[word.size];
1527
+ const shown = word.text.slice(0, Math.ceil(word.text.length * word.shown));
1528
+ if (!shown) return null;
1529
+ return /* @__PURE__ */ jsx(
1530
+ Text,
1531
+ {
1532
+ style: [styles$3.word, {
1533
+ left,
1534
+ top: top - size2 * 0.62,
1535
+ fontSize: size2,
1536
+ color: word.color,
1537
+ fontFamily: HAND,
1538
+ backgroundColor: word.marked ? MARKER : "transparent"
1539
+ }],
1540
+ accessibilityLabel: word.text,
1541
+ children: shown
1542
+ }
1543
+ );
1544
+ }
1545
+ if (word.rowsShown <= 0) return null;
1546
+ const size = unit2 * 2.2;
1547
+ return /* @__PURE__ */ jsx(View, { style: [styles$3.table, { left, top, width: word.at[2] / BOARD_W * width, borderColor: word.color, backgroundColor: word.marked ? MARKER : "transparent" }], children: word.rows.slice(0, word.rowsShown).map((row, r) => /* @__PURE__ */ jsx(View, { style: styles$3.row, children: row.map((cell, c) => /* @__PURE__ */ jsx(
1548
+ Text,
1549
+ {
1550
+ style: [styles$3.cell, { fontSize: size, color: word.color, borderColor: word.color, fontFamily: HAND, fontWeight: r === 0 ? "700" : "400" }],
1551
+ children: cell
1552
+ },
1553
+ c
1554
+ )) }, r)) });
1555
+ }
1556
+ function IconButton({ label, glyph, color, onPress }) {
1557
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: label, onPress, hitSlop: 8, style: styles$3.icon, children: /* @__PURE__ */ jsx(Text, { style: { color, fontSize: 16 }, children: glyph }) });
1558
+ }
1559
+ const styles$3 = StyleSheet.create({
1560
+ backdrop: { flex: 1, justifyContent: "flex-end", alignItems: "center", padding: 12 },
1561
+ centre: { justifyContent: "center" },
1562
+ card: {
1563
+ width: "100%",
1564
+ borderRadius: 16,
1565
+ borderWidth: StyleSheet.hairlineWidth,
1566
+ overflow: "hidden",
1567
+ shadowColor: "#0f172a",
1568
+ shadowOpacity: 0.25,
1569
+ shadowRadius: 24,
1570
+ shadowOffset: { width: 0, height: 12 },
1571
+ elevation: 12
1572
+ },
1573
+ head: { flexDirection: "row", alignItems: "center", paddingHorizontal: 12, paddingVertical: 8, gap: 6 },
1574
+ title: { flex: 1, fontSize: 14, fontWeight: "600" },
1575
+ badge: { fontSize: 11, fontWeight: "600", color: "#92400e", backgroundColor: "#fef3c7", borderRadius: 999, paddingHorizontal: 8, paddingVertical: 2, overflow: "hidden" },
1576
+ sheet: { width: "100%", aspectRatio: BOARD_W / BOARD_H, backgroundColor: "#fcfcfd" },
1577
+ status: { ...StyleSheet.absoluteFillObject, alignItems: "center", justifyContent: "center", gap: 10, backgroundColor: "rgba(252,252,253,0.92)", padding: 16 },
1578
+ statusText: { color: "#475569", fontSize: 13, textAlign: "center" },
1579
+ retry: { paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8 },
1580
+ caption: { paddingHorizontal: 14, paddingTop: 10, fontSize: 14, lineHeight: 20, minHeight: 46 },
1581
+ track: { flexDirection: "row", gap: 4, paddingHorizontal: 14, paddingTop: 4 },
1582
+ segment: { flex: 1, height: 6, borderRadius: 3 },
1583
+ bar: { flexDirection: "row", alignItems: "center", paddingHorizontal: 8, paddingVertical: 6, gap: 4 },
1584
+ step: { flex: 1, fontSize: 12, marginLeft: 4 },
1585
+ speed: { borderWidth: 1, borderRadius: 8, paddingHorizontal: 8, paddingVertical: 4 },
1586
+ icon: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
1587
+ word: { position: "absolute", fontWeight: "600" },
1588
+ credit: { position: "absolute", right: 6, bottom: 3, fontSize: 9, color: "#94a3b8", maxWidth: "60%" },
1589
+ table: { position: "absolute", borderWidth: 1.5 },
1590
+ row: { flexDirection: "row" },
1591
+ cell: { flex: 1, borderWidth: 0.75, paddingHorizontal: 6, paddingVertical: 3 }
1592
+ });
1593
+ const DEFAULT_LIVE_VOICE_LABELS = {
1594
+ eyebrow: "Live conversation",
1595
+ listeningTitle: "Listening — go ahead",
1596
+ listeningText: "Speak naturally. Pause when you are ready for an answer.",
1597
+ hearingTitle: "You’re speaking…",
1598
+ hearingText: "I’m listening. Pause when you’re done.",
1599
+ thinkingTitle: "Thinking…",
1600
+ thinkingText: "I’m working on your answer.",
1601
+ speakingTitle: "Speaking…",
1602
+ speakingText: "Tap the circle to interrupt.",
1603
+ end: "End",
1604
+ language: "Language"
1605
+ };
1606
+ const ORB = 96;
1607
+ const CORE = ORB - 24;
1608
+ function useLoop(make, key) {
1609
+ useEffect(() => {
1610
+ if (!key) return void 0;
1611
+ const animation = Animated.loop(make());
1612
+ animation.start();
1613
+ return () => animation.stop();
1614
+ }, [key]);
1615
+ }
1616
+ function Ring({ color, running, duration, delay = 0 }) {
1617
+ const t = useRef(new Animated.Value(0)).current;
1618
+ useLoop(() => Animated.sequence([
1619
+ Animated.delay(delay),
1620
+ Animated.timing(t, { toValue: 1, duration, easing: Easing.out(Easing.quad), useNativeDriver: true }),
1621
+ Animated.timing(t, { toValue: 0, duration: 0, useNativeDriver: true })
1622
+ ]), running ? "on" : false);
1623
+ useEffect(() => {
1624
+ if (!running) t.setValue(0);
1625
+ }, [running, t]);
1626
+ return /* @__PURE__ */ jsx(
1627
+ Animated.View,
1628
+ {
1629
+ pointerEvents: "none",
1630
+ style: [styles$2.ring, {
1631
+ borderColor: color,
1632
+ opacity: t.interpolate({ inputRange: [0, 0.1, 1], outputRange: [0, 0.55, 0] }),
1633
+ transform: [{ scale: t.interpolate({ inputRange: [0, 1], outputRange: [1, 1.55] }) }]
1634
+ }]
1635
+ }
1636
+ );
1637
+ }
1638
+ function Wave({ color }) {
1639
+ const bars = useRef([0, 1, 2, 3, 4, 5, 6].map(() => new Animated.Value(0))).current;
1640
+ useEffect(() => {
1641
+ const delays = [0, 230, 380, 560, 380, 230, 0];
1642
+ const loops = bars.map((bar, i) => Animated.loop(Animated.sequence([
1643
+ Animated.delay(delays[i]),
1644
+ Animated.timing(bar, { toValue: 1, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1645
+ Animated.timing(bar, { toValue: 0, duration: 340, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1646
+ ])));
1647
+ loops.forEach((loop) => loop.start());
1648
+ return () => loops.forEach((loop) => loop.stop());
1649
+ }, [bars]);
1650
+ return /* @__PURE__ */ jsx(View, { style: styles$2.wave, children: bars.map((bar, i) => /* @__PURE__ */ jsx(
1651
+ Animated.View,
1652
+ {
1653
+ style: [styles$2.bar, {
1654
+ backgroundColor: color,
1655
+ transform: [{ scaleY: bar.interpolate({ inputRange: [0, 1], outputRange: [0.32, 1] }) }]
1656
+ }]
1657
+ },
1658
+ i
1659
+ )) });
1660
+ }
1661
+ function Dots({ color }) {
1662
+ const dots = useRef([0, 1, 2].map(() => new Animated.Value(0))).current;
1663
+ useEffect(() => {
1664
+ const loops = dots.map((dot, i) => Animated.loop(Animated.sequence([
1665
+ Animated.delay(i * 150),
1666
+ Animated.timing(dot, { toValue: 1, duration: 450, useNativeDriver: true }),
1667
+ Animated.timing(dot, { toValue: 0, duration: 450, useNativeDriver: true }),
1668
+ Animated.delay((2 - i) * 150)
1669
+ ])));
1670
+ loops.forEach((loop) => loop.start());
1671
+ return () => loops.forEach((loop) => loop.stop());
1672
+ }, [dots]);
1673
+ return /* @__PURE__ */ jsx(View, { style: styles$2.dots, children: dots.map((dot, i) => /* @__PURE__ */ jsx(
1674
+ Animated.View,
1675
+ {
1676
+ style: [styles$2.dot, {
1677
+ backgroundColor: color,
1678
+ opacity: dot.interpolate({ inputRange: [0, 1], outputRange: [0.35, 1] }),
1679
+ transform: [{ translateY: dot.interpolate({ inputRange: [0, 1], outputRange: [0, -4] }) }]
1680
+ }]
1681
+ },
1682
+ i
1683
+ )) });
1684
+ }
1685
+ function GuideAILiveVoice({ live, theme: overrides, labels: given }) {
1686
+ const theme = resolveTheme(overrides);
1687
+ const labels = { ...DEFAULT_LIVE_VOICE_LABELS, ...given };
1688
+ const breathe = useRef(new Animated.Value(0)).current;
1689
+ const level = useRef(new Animated.Value(0)).current;
1690
+ const { state } = live;
1691
+ const breathing = state === "listening" || state === "speaking";
1692
+ useLoop(() => Animated.sequence([
1693
+ Animated.timing(breathe, { toValue: 1, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true }),
1694
+ Animated.timing(breathe, { toValue: 0, duration: state === "speaking" ? 450 : 1200, easing: Easing.inOut(Easing.ease), useNativeDriver: true })
1695
+ ]), breathing ? state : false);
1696
+ useEffect(() => {
1697
+ Animated.timing(level, { toValue: state === "hearing" ? live.level : 0, duration: 110, useNativeDriver: true }).start();
1698
+ }, [live.level, state, level]);
1699
+ if (!live.active) return null;
1700
+ const [title, text] = {
1701
+ off: ["", ""],
1702
+ listening: [labels.listeningTitle, labels.listeningText],
1703
+ hearing: [labels.hearingTitle, labels.hearingText],
1704
+ thinking: [labels.thinkingTitle, labels.thinkingText],
1705
+ speaking: [labels.speakingTitle, labels.speakingText]
1706
+ }[state];
1707
+ const coreScale = Animated.add(
1708
+ breathe.interpolate({ inputRange: [0, 1], outputRange: [1, breathing ? 1.06 : 1] }),
1709
+ level.interpolate({ inputRange: [0, 1], outputRange: [state === "hearing" ? 0.04 : 0, 0.22] })
1710
+ );
1711
+ return /* @__PURE__ */ jsxs(
1712
+ View,
1713
+ {
1714
+ accessibilityRole: "summary",
1715
+ accessibilityLabel: `${labels.eyebrow}: ${title}`,
1716
+ style: [styles$2.panel, { borderColor: theme.border, backgroundColor: theme.surface }],
1717
+ children: [
1718
+ /* @__PURE__ */ jsxs(
1719
+ Pressable,
1720
+ {
1721
+ onPress: state === "speaking" ? live.interrupt : void 0,
1722
+ accessibilityRole: state === "speaking" ? "button" : void 0,
1723
+ accessibilityLabel: state === "speaking" ? labels.speakingText : void 0,
1724
+ style: styles$2.orb,
1725
+ children: [
1726
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "listening", duration: 2400 }),
1727
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100 }),
1728
+ /* @__PURE__ */ jsx(Ring, { color: theme.accent, running: state === "hearing", duration: 1100, delay: 550 }),
1729
+ /* @__PURE__ */ jsx(
1730
+ Animated.View,
1731
+ {
1732
+ style: [styles$2.core, {
1733
+ backgroundColor: theme.accent,
1734
+ shadowColor: theme.accent,
1735
+ opacity: state === "thinking" ? 0.85 : 1,
1736
+ transform: [{ scale: coreScale }]
1737
+ }]
1738
+ }
1739
+ ),
1740
+ state === "speaking" ? /* @__PURE__ */ jsx(Wave, { color: theme.onAccent }) : null,
1741
+ state === "thinking" ? /* @__PURE__ */ jsx(Dots, { color: theme.onAccent }) : null
1742
+ ]
1743
+ }
1744
+ ),
1745
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.eyebrow, { color: theme.textMuted, fontSize: theme.fontSize - 3 }], children: labels.eyebrow }),
1746
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.title, { color: theme.text, fontSize: theme.fontSize + 2 }], children: title }),
1747
+ /* @__PURE__ */ jsx(Text, { style: [styles$2.text, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: text }),
1748
+ /* @__PURE__ */ jsxs(View, { style: styles$2.actions, children: [
1749
+ live.language ? /* @__PURE__ */ jsx(
1750
+ Pressable,
1751
+ {
1752
+ onPress: live.changeLanguage,
1753
+ accessibilityRole: "button",
1754
+ style: [styles$2.chip, { borderColor: theme.border }],
1755
+ hitSlop: 6,
1756
+ children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: [
1757
+ labels.language,
1758
+ ": ",
1759
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "600" }, children: live.language.label })
1760
+ ] })
1761
+ }
1762
+ ) : null,
1763
+ /* @__PURE__ */ jsx(
1764
+ Pressable,
1765
+ {
1766
+ onPress: live.stop,
1767
+ accessibilityRole: "button",
1768
+ accessibilityLabel: labels.end,
1769
+ style: [styles$2.end, { backgroundColor: theme.error }],
1770
+ hitSlop: 6,
1771
+ children: /* @__PURE__ */ jsxs(Text, { style: [styles$2.endText, { fontSize: theme.fontSize - 1 }], children: [
1772
+ "✆ ",
1773
+ labels.end
1774
+ ] })
1775
+ }
1776
+ )
1777
+ ] })
1778
+ ]
1779
+ }
1780
+ );
1781
+ }
1782
+ const styles$2 = StyleSheet.create({
1783
+ panel: {
1784
+ alignItems: "center",
1785
+ paddingTop: 18,
1786
+ paddingBottom: 14,
1787
+ paddingHorizontal: 16,
1788
+ borderTopWidth: StyleSheet.hairlineWidth,
1789
+ borderBottomWidth: StyleSheet.hairlineWidth
1790
+ },
1791
+ orb: { width: ORB, height: ORB, alignItems: "center", justifyContent: "center", marginBottom: 8 },
1792
+ core: {
1793
+ position: "absolute",
1794
+ width: CORE,
1795
+ height: CORE,
1796
+ borderRadius: CORE / 2,
1797
+ shadowOffset: { width: 0, height: 8 },
1798
+ shadowOpacity: 0.35,
1799
+ shadowRadius: 12,
1800
+ elevation: 6
1801
+ },
1802
+ ring: { position: "absolute", width: CORE, height: CORE, borderRadius: CORE / 2, borderWidth: 2 },
1803
+ wave: { flexDirection: "row", alignItems: "center", gap: 3, height: 26 },
1804
+ bar: { width: 3, height: 26, borderRadius: 2 },
1805
+ dots: { flexDirection: "row", alignItems: "center", gap: 6 },
1806
+ dot: { width: 7, height: 7, borderRadius: 4 },
1807
+ eyebrow: { fontWeight: "500", marginBottom: 2 },
1808
+ title: { fontWeight: "700", textAlign: "center" },
1809
+ text: { textAlign: "center", marginTop: 3, lineHeight: 19 },
1810
+ actions: { flexDirection: "row", alignItems: "center", gap: 10, marginTop: 12 },
1811
+ chip: { borderWidth: 1, borderRadius: 999, paddingHorizontal: 12, paddingVertical: 7 },
1812
+ end: { borderRadius: 999, paddingHorizontal: 18, paddingVertical: 9 },
1813
+ endText: { color: "#FFFFFF", fontWeight: "700" }
1814
+ });
1815
+ const DEFAULT_LANGUAGE_PICKER_LABELS = {
1816
+ title: "Which language will you speak?",
1817
+ hint: "The assistant listens in this language. You can change it any time.",
1818
+ cancel: "Cancel"
1819
+ };
1820
+ function GuideAILanguagePicker({ voice, theme: overrides, labels: given }) {
1821
+ if (!voice.choosingLanguage) return null;
1822
+ const theme = resolveTheme(overrides);
1823
+ const labels = { ...DEFAULT_LANGUAGE_PICKER_LABELS, ...given };
1824
+ return /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: voice.cancelLanguage, children: /* @__PURE__ */ jsxs(View, { style: styles$1.backdrop, children: [
1825
+ /* @__PURE__ */ jsx(Pressable, { style: StyleSheet.absoluteFill, onPress: voice.cancelLanguage, accessibilityLabel: labels.cancel }),
1826
+ /* @__PURE__ */ jsxs(View, { style: [styles$1.card, { backgroundColor: theme.surfaceRaised, borderColor: theme.border, borderRadius: theme.radius + 6 }], children: [
1827
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.title, { color: theme.text, fontSize: theme.fontSize + 3 }], children: labels.title }),
1828
+ /* @__PURE__ */ jsx(Text, { style: [styles$1.hint, { color: theme.textMuted, fontSize: theme.fontSize - 1 }], children: labels.hint }),
1829
+ /* @__PURE__ */ jsx(ScrollView, { style: styles$1.list, contentContainerStyle: styles$1.listContent, children: voice.languages.map((lang) => {
1830
+ var _a;
1831
+ const on = ((_a = voice.language) == null ? void 0 : _a.code) === lang.code;
1832
+ return /* @__PURE__ */ jsxs(
1833
+ Pressable,
1834
+ {
1835
+ accessibilityRole: "button",
1836
+ accessibilityState: { selected: on },
1837
+ onPress: () => {
1838
+ void voice.chooseLanguage(lang.code);
1839
+ },
1840
+ style: ({ pressed }) => [styles$1.row, {
1841
+ borderColor: on ? theme.accent : theme.border,
1842
+ backgroundColor: on ? theme.accent : pressed ? theme.surface : "transparent",
1843
+ borderRadius: theme.radius
1844
+ }],
1845
+ children: [
1846
+ /* @__PURE__ */ jsx(Text, { style: { color: on ? theme.onAccent : theme.text, fontSize: theme.fontSize + 1, fontWeight: on ? "700" : "500" }, children: lang.label }),
1847
+ on ? /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontSize: theme.fontSize }, children: "✓" }) : null
1848
+ ]
1849
+ },
1850
+ lang.code
1851
+ );
1852
+ }) }),
1853
+ /* @__PURE__ */ jsx(Pressable, { onPress: voice.cancelLanguage, accessibilityRole: "button", style: styles$1.cancel, hitSlop: 8, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize, fontWeight: "600" }, children: labels.cancel }) })
1854
+ ] })
1855
+ ] }) });
1856
+ }
1857
+ const styles$1 = StyleSheet.create({
1858
+ backdrop: { flex: 1, justifyContent: "center", padding: 22, backgroundColor: "rgba(0,0,0,0.45)" },
1859
+ card: { borderWidth: StyleSheet.hairlineWidth, padding: 20, maxHeight: "80%" },
1860
+ title: { fontWeight: "700" },
1861
+ hint: { marginTop: 6, marginBottom: 14, lineHeight: 19 },
1862
+ list: { flexGrow: 0 },
1863
+ listContent: { gap: 8 },
1864
+ row: {
1865
+ flexDirection: "row",
1866
+ alignItems: "center",
1867
+ justifyContent: "space-between",
1868
+ borderWidth: 1,
1869
+ paddingVertical: 13,
1870
+ paddingHorizontal: 16
1871
+ },
1872
+ cancel: { alignSelf: "center", marginTop: 14, paddingVertical: 4, paddingHorizontal: 12 }
1873
+ });
1874
+ function PersonIcon({ color }) {
1875
+ return /* @__PURE__ */ jsxs(View, { style: styles.iconWrap, children: [
1876
+ /* @__PURE__ */ jsx(View, { style: [styles.iconBand, { borderColor: color }] }),
1877
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupLeft, { backgroundColor: color }] }),
1878
+ /* @__PURE__ */ jsx(View, { style: [styles.iconCup, styles.iconCupRight, { backgroundColor: color }] })
1879
+ ] });
1880
+ }
1881
+ function Orb({ theme, active }) {
1882
+ const pulse = useRef(new Animated.Value(0)).current;
1883
+ React.useEffect(() => {
1884
+ if (!active) {
1885
+ pulse.stopAnimation();
1886
+ Animated.timing(pulse, { toValue: 0, duration: 240, useNativeDriver: true }).start();
1887
+ return;
1888
+ }
1889
+ const loop = Animated.loop(
1890
+ Animated.sequence([
1891
+ Animated.timing(pulse, {
1892
+ toValue: 1,
1893
+ duration: 900,
1894
+ easing: Easing.inOut(Easing.quad),
1895
+ useNativeDriver: true
1896
+ }),
1897
+ Animated.timing(pulse, {
1898
+ toValue: 0,
1899
+ duration: 900,
1900
+ easing: Easing.inOut(Easing.quad),
1901
+ useNativeDriver: true
1902
+ })
1903
+ ])
1904
+ );
1905
+ loop.start();
1906
+ return () => loop.stop();
1907
+ }, [active, pulse]);
1908
+ const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, 1.18] });
1909
+ const glow = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 0.7] });
1910
+ return /* @__PURE__ */ jsxs(View, { style: styles.orbWrap, children: [
1911
+ /* @__PURE__ */ jsx(
1912
+ Animated.View,
1913
+ {
1914
+ style: [
1915
+ styles.orbGlow,
1916
+ { backgroundColor: theme.accent, opacity: glow, transform: [{ scale }] }
1917
+ ]
1918
+ }
1919
+ ),
1920
+ /* @__PURE__ */ jsx(View, { style: [styles.orbCore, { backgroundColor: theme.accent }] })
1921
+ ] });
1922
+ }
1923
+ function Bubble({ message, theme, onTalkToHuman, onWhiteboard }) {
1924
+ if (message.role === "user") {
1925
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowUser], children: /* @__PURE__ */ jsx(View, { style: [
1926
+ styles.bubble,
1927
+ { backgroundColor: theme.userBubble, borderRadius: theme.radius },
1928
+ message.error ? { backgroundColor: theme.error } : null
1929
+ ], children: /* @__PURE__ */ jsx(Text, { style: {
1930
+ color: theme.onUserBubble,
1931
+ fontSize: theme.fontSize,
1932
+ lineHeight: theme.fontSize * 1.4
1933
+ }, children: message.content }) }) });
1934
+ }
1935
+ return /* @__PURE__ */ jsx(View, { style: [styles.row, styles.rowAssistant], children: /* @__PURE__ */ jsxs(View, { style: [
1936
+ styles.assistantBody,
1937
+ message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
1938
+ ], children: [
1939
+ /* @__PURE__ */ jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }),
1940
+ onWhiteboard ? /* @__PURE__ */ jsx(
1941
+ Pressable,
1942
+ {
1943
+ onPress: onWhiteboard,
1944
+ accessibilityRole: "button",
1945
+ accessibilityLabel: "Explain on whiteboard",
1946
+ style: [styles.errorAction, { borderColor: theme.accent }],
1947
+ hitSlop: 6,
1948
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.humanText, { color: theme.accent, fontSize: theme.fontSize - 1 }], children: "✎ Explain on whiteboard" })
1949
+ }
1950
+ ) : null,
1951
+ message.error && onTalkToHuman ? /* @__PURE__ */ jsxs(
1952
+ Pressable,
1953
+ {
1954
+ onPress: onTalkToHuman,
1955
+ accessibilityRole: "button",
1956
+ accessibilityLabel: "Talk to a person",
1957
+ style: [styles.errorAction, { borderColor: theme.accent }],
1958
+ hitSlop: 6,
1959
+ children: [
1960
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
1961
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
1962
+ color: theme.accent,
1963
+ fontSize: theme.fontSize - 1
1964
+ }], children: "Talk to a human" })
1965
+ ]
1966
+ }
1967
+ ) : null
1968
+ ] }) });
1969
+ }
1970
+ function HistoryPanel({ theme, onClose }) {
1971
+ const { conversations, activeId, newConversation, openConversation, deleteConversation } = useConversations();
1972
+ return /* @__PURE__ */ jsxs(Modal, { visible: true, transparent: true, animationType: "fade", onRequestClose: onClose, children: [
1973
+ /* @__PURE__ */ jsx(Pressable, { style: styles.sheetBackdrop, onPress: onClose, accessibilityLabel: "Close chat history" }),
1974
+ /* @__PURE__ */ jsxs(View, { style: [styles.sheet, { backgroundColor: theme.background, borderColor: theme.border }], children: [
1975
+ /* @__PURE__ */ jsx(Text, { style: [styles.sheetTitle, { color: theme.text, fontSize: theme.fontSize + 2 }], children: "Chats" }),
1976
+ /* @__PURE__ */ jsx(
1977
+ Pressable,
1978
+ {
1979
+ accessibilityRole: "button",
1980
+ onPress: () => {
1981
+ newConversation();
1982
+ onClose();
1983
+ },
1984
+ style: [styles.sheetRow, { borderColor: theme.accent }],
1985
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontWeight: "600", fontSize: theme.fontSize }, children: "+ New chat" })
1986
+ }
1987
+ ),
1988
+ /* @__PURE__ */ jsx(
1989
+ FlatList,
1990
+ {
1991
+ data: conversations,
1992
+ keyExtractor: (c) => c.id,
1993
+ ListEmptyComponent: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, padding: 12 }, children: "No previous chats yet." }),
1994
+ renderItem: ({ item }) => /* @__PURE__ */ jsxs(View, { style: [styles.historyItem, { backgroundColor: item.id === activeId ? theme.surface : void 0 }], children: [
1995
+ /* @__PURE__ */ jsx(
1996
+ Pressable,
1997
+ {
1998
+ accessibilityRole: "button",
1999
+ style: { flex: 1 },
2000
+ onPress: () => {
2001
+ openConversation(item.id);
2002
+ onClose();
2003
+ },
2004
+ children: /* @__PURE__ */ jsx(Text, { numberOfLines: 2, style: { color: theme.text, fontSize: theme.fontSize }, children: item.title })
2005
+ }
2006
+ ),
2007
+ /* @__PURE__ */ jsx(
2008
+ Pressable,
2009
+ {
2010
+ accessibilityRole: "button",
2011
+ accessibilityLabel: `Delete ${item.title}`,
2012
+ hitSlop: 8,
2013
+ onPress: () => deleteConversation(item.id),
2014
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "✕" })
2015
+ }
2016
+ )
2017
+ ] })
2018
+ }
2019
+ )
2020
+ ] })
2021
+ ] });
2022
+ }
2023
+ function resolveTopInset(explicit) {
2024
+ var _a;
2025
+ if (explicit !== void 0) return explicit;
2026
+ if (Platform.OS === "android") return (_a = StatusBar.currentHeight) != null ? _a : 24;
2027
+ return 8;
2028
+ }
2029
+ function useHumanHandover(onTalkToHuman, available) {
2030
+ const [reachable, setReachable] = useState(false);
2031
+ useEffect(() => {
2032
+ if (!onTalkToHuman || available !== void 0) return;
2033
+ let cancelled = false;
2034
+ void (async () => {
2035
+ try {
2036
+ const { api } = requireConfigured();
2037
+ const status = await api.get(
2038
+ EP.supportStatus()
2039
+ );
2040
+ if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
2041
+ } catch {
2042
+ }
2043
+ })();
2044
+ return () => {
2045
+ cancelled = true;
2046
+ };
2047
+ }, [onTalkToHuman, available]);
2048
+ if (!onTalkToHuman) return false;
2049
+ return available != null ? available : reachable;
2050
+ }
2051
+ function GuideAIChat({
2052
+ theme: overrides,
2053
+ placeholder = "Ask me anything",
2054
+ greeting = "Ask me anything",
2055
+ emptyState,
2056
+ showMic = true,
2057
+ showHistory = true,
2058
+ useVoice,
2059
+ leadingAccessory,
2060
+ title,
2061
+ onClose,
2062
+ onTalkToHuman,
2063
+ humanHandoverAvailable,
2064
+ topInset
2065
+ }) {
2066
+ const { harness, debug } = requireConfigured();
2067
+ const chat = useGuideAI({ harness, trace: debug });
2068
+ const {
2069
+ messages,
2070
+ input,
2071
+ setInput,
2072
+ send,
2073
+ busy,
2074
+ canSend,
2075
+ status,
2076
+ typing,
2077
+ followUps,
2078
+ explainOnWhiteboard
2079
+ } = chat;
2080
+ const voice = useVoice ? useVoice(chat) : null;
2081
+ const [historyOpen, setHistoryOpen] = useState(false);
2082
+ const theme = resolveTheme(overrides);
2083
+ const listRef = useRef(null);
2084
+ const showHuman = useHumanHandover(onTalkToHuman, humanHandoverAvailable);
2085
+ const { checklist, dismiss } = useOnboarding();
2086
+ const nextSetupStep = checklist == null ? void 0 : checklist.steps.find((step) => step.state === "available");
2087
+ const headerTop = resolveTopInset(topInset);
2088
+ const submit = () => {
2089
+ void send();
2090
+ };
2091
+ return /* @__PURE__ */ jsxs(
2092
+ KeyboardAvoidingView,
2093
+ {
2094
+ style: [styles.container, { backgroundColor: theme.background }],
2095
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
2096
+ children: [
2097
+ title || onClose || showHuman || showHistory ? /* @__PURE__ */ jsxs(View, { style: [
2098
+ styles.header,
2099
+ { borderBottomColor: theme.border, paddingTop: headerTop + 14 }
2100
+ ], children: [
2101
+ /* @__PURE__ */ jsx(View, { style: styles.headerSide, children: title ? /* @__PURE__ */ jsx(
2102
+ Text,
2103
+ {
2104
+ numberOfLines: 1,
2105
+ style: [styles.title, { color: theme.text, fontSize: theme.fontSize + 1 }],
2106
+ children: title
2107
+ }
2108
+ ) : null }),
2109
+ /* @__PURE__ */ jsxs(View, { style: styles.headerActions, children: [
2110
+ showHistory ? /* @__PURE__ */ jsx(
2111
+ Pressable,
2112
+ {
2113
+ onPress: () => setHistoryOpen(true),
2114
+ accessibilityRole: "button",
2115
+ accessibilityLabel: "Chat history",
2116
+ style: [styles.close, { backgroundColor: theme.surface }],
2117
+ hitSlop: 8,
2118
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "☰" })
2119
+ }
2120
+ ) : null,
2121
+ showHuman ? /* @__PURE__ */ jsxs(
2122
+ Pressable,
2123
+ {
2124
+ onPress: onTalkToHuman,
2125
+ accessibilityRole: "button",
2126
+ accessibilityLabel: "Talk to a person",
2127
+ style: [styles.human, {
2128
+ backgroundColor: theme.surface,
2129
+ borderColor: theme.border
2130
+ }],
2131
+ hitSlop: 8,
2132
+ children: [
2133
+ /* @__PURE__ */ jsx(PersonIcon, { color: theme.accent }),
2134
+ /* @__PURE__ */ jsx(Text, { style: [styles.humanText, {
2135
+ color: theme.accent,
2136
+ fontSize: theme.fontSize - 2
2137
+ }], children: "Talk to human" })
2138
+ ]
2139
+ }
2140
+ ) : null,
2141
+ onClose ? /* @__PURE__ */ jsx(
2142
+ Pressable,
2143
+ {
2144
+ onPress: onClose,
2145
+ accessibilityRole: "button",
2146
+ accessibilityLabel: "Close assistant",
2147
+ style: [styles.close, { backgroundColor: theme.surface }],
2148
+ hitSlop: 10,
2149
+ children: /* @__PURE__ */ jsx(Text, { style: [styles.closeIcon, { color: theme.text }], children: "✕" })
2150
+ }
2151
+ ) : null
2152
+ ] })
2153
+ ] }) : null,
2154
+ checklist && !checklist.completed && !checklist.dismissed ? /* @__PURE__ */ jsxs(View, { style: { margin: 14, padding: 14, borderRadius: 12, borderWidth: 1, borderColor: theme.border, backgroundColor: theme.surface }, accessibilityLabel: "Setup checklist", children: [
2155
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.text, fontWeight: "700", fontSize: theme.fontSize + 2 }, children: checklist.title }),
2156
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, marginTop: 3 }, children: checklist.goal }),
2157
+ /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, marginTop: 8 }, children: [
2158
+ checklist.completed_required,
2159
+ " of ",
2160
+ checklist.total_required,
2161
+ " required steps complete"
2162
+ ] }),
2163
+ checklist.steps.map((step) => /* @__PURE__ */ jsxs(Text, { style: { color: step.state === "locked" ? theme.textMuted : theme.text, marginTop: 5 }, children: [
2164
+ step.state === "complete" ? "✓" : step.state === "locked" ? "–" : "○",
2165
+ " ",
2166
+ step.title
2167
+ ] }, step.id)),
2168
+ nextSetupStep ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: `Help with ${nextSetupStep.title}`, onPress: () => void send(`Help me with ${nextSetupStep.title}`), style: { alignSelf: "flex-start", marginTop: 10, padding: 10, borderRadius: 8, backgroundColor: theme.accent }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.onAccent, fontWeight: "600" }, children: "Continue setup" }) }) : null,
2169
+ checklist.allow_dismissal ? /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "I don't need this setup", onPress: () => Alert.alert("Stop showing setup?", "This checklist will not appear again on future visits.", [
2170
+ { text: "Keep setup", style: "cancel" },
2171
+ { text: "I don't need it", onPress: () => {
2172
+ void dismiss().catch(() => Alert.alert("Could not dismiss setup", "Please try again."));
2173
+ } }
2174
+ ]), style: { alignSelf: "flex-start", marginTop: 10, padding: 10 }, children: /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, textDecorationLine: "underline" }, children: "I don't need this setup" }) }) : null
2175
+ ] }) : null,
2176
+ messages.length === 0 ? /* @__PURE__ */ jsx(View, { style: styles.empty, children: emptyState != null ? emptyState : /* @__PURE__ */ jsxs(View, { style: styles.greetingRow, children: [
2177
+ /* @__PURE__ */ jsx(Orb, { theme, active: busy }),
2178
+ /* @__PURE__ */ jsx(Text, { style: [
2179
+ styles.greeting,
2180
+ { color: theme.textMuted, fontSize: theme.fontSize + 3 }
2181
+ ], children: greeting })
2182
+ ] }) }) : /* @__PURE__ */ jsx(
2183
+ FlatList,
2184
+ {
2185
+ ref: listRef,
2186
+ data: messages,
2187
+ keyExtractor: (message) => message.id,
2188
+ renderItem: ({ item }) => /* @__PURE__ */ jsx(
2189
+ Bubble,
2190
+ {
2191
+ message: item,
2192
+ theme,
2193
+ onTalkToHuman,
2194
+ onWhiteboard: item.whiteboard ? () => {
2195
+ void explainOnWhiteboard(item.id);
2196
+ } : void 0
2197
+ }
2198
+ ),
2199
+ ListFooterComponent: typing || followUps.length ? /* @__PURE__ */ jsxs(View, { style: styles.footer, children: [
2200
+ typing ? /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: "…" }) : null,
2201
+ followUps.map((label) => /* @__PURE__ */ jsx(
2202
+ Pressable,
2203
+ {
2204
+ onPress: () => {
2205
+ void send(label);
2206
+ },
2207
+ accessibilityRole: "button",
2208
+ style: [styles.chip, { borderColor: theme.accent, borderRadius: theme.radius }],
2209
+ hitSlop: 4,
2210
+ children: /* @__PURE__ */ jsx(Text, { style: { color: theme.accent, fontSize: theme.fontSize - 1 }, children: label })
2211
+ },
2212
+ label
2213
+ ))
2214
+ ] }) : null,
2215
+ contentContainerStyle: styles.list,
2216
+ onContentSizeChange: () => {
2217
+ var _a;
2218
+ return (_a = listRef.current) == null ? void 0 : _a.scrollToEnd({ animated: true });
2219
+ },
2220
+ keyboardShouldPersistTaps: "handled"
2221
+ }
2222
+ ),
2223
+ voice ? /* @__PURE__ */ jsx(GuideAILiveVoice, { live: voice.live, theme: overrides }) : null,
2224
+ (voice == null ? void 0 : voice.live.error) || (voice == null ? void 0 : voice.mic.error) ? /* @__PURE__ */ jsx(Text, { style: [styles.voiceError, { color: theme.textMuted, fontSize: theme.fontSize - 2 }], children: voice.live.error || voice.mic.error }) : null,
2225
+ status ? /* @__PURE__ */ jsxs(View, { style: styles.status, children: [
2226
+ /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }),
2227
+ /* @__PURE__ */ jsx(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: status })
2228
+ ] }) : null,
2229
+ /* @__PURE__ */ jsxs(View, { style: styles.composerRow, children: [
2230
+ /* @__PURE__ */ jsxs(View, { style: [
2231
+ styles.composer,
2232
+ {
2233
+ backgroundColor: theme.surface,
2234
+ borderRadius: theme.radius + 6,
2235
+ borderColor: theme.border
2236
+ }
2237
+ ], children: [
2238
+ leadingAccessory ? /* @__PURE__ */ jsx(View, { style: styles.leading, children: leadingAccessory }) : null,
2239
+ /* @__PURE__ */ jsx(
2240
+ TextInput,
2241
+ {
2242
+ style: [styles.input, { color: theme.text, fontSize: theme.fontSize }],
2243
+ value: input,
2244
+ onChangeText: setInput,
2245
+ placeholder: checklist && !checklist.completed && checklist.chat_policy === "setup_only" ? "Ask about your setup" : placeholder,
2246
+ placeholderTextColor: theme.textMuted,
2247
+ editable: !busy,
2248
+ onSubmitEditing: submit,
2249
+ returnKeyType: "send",
2250
+ multiline: true,
2251
+ accessibilityLabel: placeholder
2252
+ }
2253
+ ),
2254
+ /* @__PURE__ */ jsx(
2255
+ Pressable,
2256
+ {
2257
+ onPress: submit,
2258
+ disabled: !canSend,
2259
+ accessibilityRole: "button",
2260
+ accessibilityLabel: "Send",
2261
+ style: [styles.send, { backgroundColor: canSend ? theme.accent : theme.border }],
2262
+ hitSlop: 6,
2263
+ children: /* @__PURE__ */ jsx(Text, { style: [
2264
+ styles.sendIcon,
2265
+ { color: canSend ? theme.onAccent : theme.textMuted }
2266
+ ], children: "↑" })
2267
+ }
2268
+ )
2269
+ ] }),
2270
+ showMic && voice ? /* @__PURE__ */ jsxs(Fragment, { children: [
2271
+ /* @__PURE__ */ jsx(
2272
+ Pressable,
2273
+ {
2274
+ onPress: () => {
2275
+ void voice.mic.toggle();
2276
+ },
2277
+ disabled: busy || voice.mic.transcribing || voice.live.active,
2278
+ accessibilityRole: "button",
2279
+ accessibilityLabel: voice.mic.recording ? "Stop and send" : "Speak a message",
2280
+ style: [styles.mic, {
2281
+ backgroundColor: voice.mic.recording ? theme.error : theme.surface,
2282
+ borderColor: theme.border
2283
+ }],
2284
+ children: voice.mic.transcribing ? /* @__PURE__ */ jsx(ActivityIndicator, { size: "small", color: theme.accent }) : /* @__PURE__ */ jsx(Text, { style: { color: voice.mic.recording ? theme.onAccent : theme.text, fontSize: 18 }, children: voice.mic.recording ? "■" : "🎤" })
2285
+ }
2286
+ ),
2287
+ /* @__PURE__ */ jsx(
2288
+ Pressable,
2289
+ {
2290
+ onPress: () => {
2291
+ if (voice.live.active) voice.live.stop();
2292
+ else void voice.live.start();
2293
+ },
2294
+ disabled: voice.mic.recording,
2295
+ accessibilityRole: "button",
2296
+ accessibilityLabel: voice.live.active ? "End live voice" : "Talk live",
2297
+ style: [styles.mic, {
2298
+ backgroundColor: voice.live.active ? theme.accent : theme.surface,
2299
+ borderColor: theme.border
2300
+ }],
2301
+ children: /* @__PURE__ */ jsx(Text, { style: { color: voice.live.active ? theme.onAccent : theme.text, fontSize: 16 }, children: voice.live.active ? "✕" : "◉" })
2302
+ }
2303
+ )
2304
+ ] }) : null
2305
+ ] }),
2306
+ (voice == null ? void 0 : voice.mic.language) && showMic ? /* @__PURE__ */ jsx(Pressable, { onPress: voice.mic.changeLanguage, accessibilityRole: "button", style: styles.languageChip, hitSlop: 6, children: /* @__PURE__ */ jsxs(Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 3 }, children: [
2307
+ "🎙 ",
2308
+ voice.mic.language.label
2309
+ ] }) }) : null,
2310
+ voice ? /* @__PURE__ */ jsx(GuideAILanguagePicker, { voice: voice.mic, theme: overrides }) : null,
2311
+ historyOpen ? /* @__PURE__ */ jsx(HistoryPanel, { theme, onClose: () => setHistoryOpen(false) }) : null,
2312
+ /* @__PURE__ */ jsx(GuideAIWhiteboard, { theme: overrides })
2313
+ ]
2314
+ }
2315
+ );
2316
+ }
2317
+ const styles = StyleSheet.create({
2318
+ container: { flex: 1 },
2319
+ header: {
2320
+ flexDirection: "row",
2321
+ alignItems: "center",
2322
+ justifyContent: "space-between",
2323
+ // paddingTop is set inline from the status-bar inset; only the
2324
+ // bottom half of the navbar's breathing room lives here.
2325
+ paddingHorizontal: 16,
2326
+ paddingBottom: 14,
2327
+ borderBottomWidth: StyleSheet.hairlineWidth
2328
+ },
2329
+ headerSide: { flex: 1, minWidth: 0 },
2330
+ headerActions: { flexDirection: "row", alignItems: "center", gap: 8 },
2331
+ title: { fontWeight: "600" },
2332
+ human: {
2333
+ flexDirection: "row",
2334
+ alignItems: "center",
2335
+ gap: 6,
2336
+ paddingHorizontal: 10,
2337
+ paddingVertical: 6,
2338
+ borderRadius: 999,
2339
+ borderWidth: StyleSheet.hairlineWidth
2340
+ },
2341
+ humanText: { fontWeight: "600" },
2342
+ errorAction: {
2343
+ flexDirection: "row",
2344
+ alignItems: "center",
2345
+ gap: 6,
2346
+ alignSelf: "flex-start",
2347
+ marginTop: 10,
2348
+ paddingHorizontal: 12,
2349
+ paddingVertical: 7,
2350
+ borderRadius: 999,
2351
+ borderWidth: StyleSheet.hairlineWidth
2352
+ },
2353
+ iconWrap: { width: 14, height: 14, alignItems: "center", justifyContent: "center" },
2354
+ iconBand: {
2355
+ position: "absolute",
2356
+ top: 1,
2357
+ width: 12,
2358
+ height: 9,
2359
+ borderWidth: 1.6,
2360
+ borderBottomWidth: 0,
2361
+ borderTopLeftRadius: 6,
2362
+ borderTopRightRadius: 6
2363
+ },
2364
+ iconCup: { position: "absolute", bottom: 1, width: 3.5, height: 6, borderRadius: 1.5 },
2365
+ iconCupLeft: { left: 0 },
2366
+ iconCupRight: { right: 0 },
2367
+ close: {
2368
+ width: 32,
2369
+ height: 32,
2370
+ borderRadius: 16,
2371
+ alignItems: "center",
2372
+ justifyContent: "center"
2373
+ },
2374
+ closeIcon: { fontSize: 15, fontWeight: "600", lineHeight: 18 },
2375
+ list: { padding: 16, paddingBottom: 8, gap: 14 },
2376
+ empty: {
2377
+ // Centred, not pinned near the top: before the first message the
2378
+ // greeting is the only thing on screen, and hanging it under the
2379
+ // navbar leaves the rest of the display empty.
2380
+ flex: 1,
2381
+ alignItems: "center",
2382
+ justifyContent: "center",
2383
+ paddingHorizontal: 24,
2384
+ paddingBottom: 24
2385
+ },
2386
+ greetingRow: { flexDirection: "row", alignItems: "center", gap: 14 },
2387
+ greeting: { fontWeight: "400", textAlign: "center", flexShrink: 1 },
2388
+ orbWrap: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
2389
+ orbGlow: { position: "absolute", width: 34, height: 34, borderRadius: 17 },
2390
+ orbCore: { width: 20, height: 20, borderRadius: 10 },
2391
+ row: { flexDirection: "row" },
2392
+ rowUser: { justifyContent: "flex-end" },
2393
+ rowAssistant: { justifyContent: "flex-start" },
2394
+ // The user's bubble hugs its text: a three-word question drawn as a
2395
+ // full-width block reads as a paragraph, not a chat message. It is
2396
+ // capped at 80% so a long one still leaves the reply side legible.
2397
+ bubble: { maxWidth: "80%", paddingHorizontal: 16, paddingVertical: 11 },
2398
+ // The assistant's body does NOT hug its content, and that is the whole
2399
+ // point of `width` here rather than `maxWidth` alone.
2400
+ //
2401
+ // A View with only maxWidth shrink-wraps — React Native's equivalent of
2402
+ // width: fit-content. For a paragraph that looks fine, because the text
2403
+ // fills the measure anyway. For anything that lays itself out against
2404
+ // its parent — a table whose cells are `flex: 1`, a fenced code block,
2405
+ // a numbered list — the parent has collapsed to nothing by the time the
2406
+ // child is measured, so the table renders as an empty sliver and every
2407
+ // reply ends up a different width.
2408
+ //
2409
+ // Fixing it here rather than on the table keeps every block type
2410
+ // consistent: one column, the same measure for prose, code and tables.
2411
+ assistantBody: { width: "80%" },
2412
+ status: {
2413
+ flexDirection: "row",
2414
+ alignItems: "center",
2415
+ gap: 8,
2416
+ paddingHorizontal: 22,
2417
+ paddingBottom: 8
2418
+ },
2419
+ composerRow: {
2420
+ flexDirection: "row",
2421
+ alignItems: "flex-end",
2422
+ gap: 10,
2423
+ paddingHorizontal: 14,
2424
+ paddingBottom: Platform.OS === "ios" ? 10 : 14,
2425
+ paddingTop: 4
2426
+ },
2427
+ composer: {
2428
+ flex: 1,
2429
+ flexDirection: "row",
2430
+ alignItems: "center",
2431
+ paddingLeft: 8,
2432
+ paddingRight: 6,
2433
+ paddingVertical: 6,
2434
+ borderWidth: StyleSheet.hairlineWidth,
2435
+ gap: 6
2436
+ },
2437
+ leading: { paddingLeft: 4 },
2438
+ input: {
2439
+ flex: 1,
2440
+ paddingHorizontal: 8,
2441
+ paddingVertical: Platform.OS === "ios" ? 8 : 4,
2442
+ maxHeight: 120
2443
+ },
2444
+ send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
2445
+ sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
2446
+ footer: {
2447
+ flexDirection: "row",
2448
+ flexWrap: "wrap",
2449
+ gap: 8,
2450
+ paddingTop: 4
2451
+ },
2452
+ chip: {
2453
+ borderWidth: 1,
2454
+ paddingHorizontal: 12,
2455
+ paddingVertical: 7
2456
+ },
2457
+ languageChip: { alignSelf: "flex-end", paddingHorizontal: 16, paddingBottom: 6 },
2458
+ voiceError: { paddingHorizontal: 16, paddingBottom: 6 },
2459
+ sheetBackdrop: { ...StyleSheet.absoluteFillObject, backgroundColor: "rgba(0,0,0,0.4)" },
2460
+ sheet: {
2461
+ position: "absolute",
2462
+ left: 16,
2463
+ right: 16,
2464
+ top: "18%",
2465
+ maxHeight: "64%",
2466
+ borderRadius: 16,
2467
+ borderWidth: StyleSheet.hairlineWidth,
2468
+ padding: 16
2469
+ },
2470
+ sheetTitle: { fontWeight: "700", marginBottom: 12 },
2471
+ sheetRow: { borderWidth: 1, borderRadius: 12, paddingVertical: 11, paddingHorizontal: 14, marginBottom: 8 },
2472
+ historyItem: { flexDirection: "row", alignItems: "center", gap: 10, paddingVertical: 10, paddingHorizontal: 8, borderRadius: 10 },
2473
+ mic: {
2474
+ width: 46,
2475
+ height: 46,
2476
+ borderRadius: 23,
2477
+ alignItems: "center",
2478
+ justifyContent: "center",
2479
+ borderWidth: StyleSheet.hairlineWidth
2480
+ }
2481
+ });
2482
+ export {
2483
+ DEFAULT_LANGUAGE_PICKER_LABELS as D,
2484
+ GuideAIChat as G,
2485
+ Markdown as M,
2486
+ DEFAULT_LIVE_VOICE_LABELS as a,
2487
+ GuideAILanguagePicker as b,
2488
+ GuideAILiveVoice as c,
2489
+ GuideAIWhiteboard as d,
2490
+ darkTheme as e,
2491
+ lightTheme as l,
2492
+ resolveTheme as r
2493
+ };
2494
+ //# sourceMappingURL=GuideAIChat-DOC4zx-a.js.map