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