@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.
package/dist/ui.cjs CHANGED
@@ -3,765 +3,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const reactNative = require("react-native");
6
- const useOnboarding = require("./useOnboarding-DWkCW5v0.cjs");
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$3.bold : null,
146
- span.italic ? styles$3.italic : null,
147
- span.code ? styles$3.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$3.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$3.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$3.paragraph, children: /* @__PURE__ */ jsxRuntime.jsx(Spans, { spans: block.spans, style: body, accentColor }) });
190
- case "bullet":
191
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [styles$3.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$3.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$3.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$3.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$3.codeBlock, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$3.codeText, { fontSize: fontSize - 2 }], children: block.text }) });
205
- case "quote":
206
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.quote, { borderLeftColor: accentColor }], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
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$3.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$3.table, scrolls ? { minWidth: columns * 116 } : null], children: [
220
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$3.tableRow, styles$3.tableHeaderRow], children: block.header.map((cell, index) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
221
- 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$3.tableRow, children: row.map((cell, cellIndex) => /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$3.tableCell, children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { children: /* @__PURE__ */ jsxRuntime.jsx(
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$3 = 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 darkTheme = {
289
- background: "#0B0713",
290
- surface: "rgba(255,255,255,0.06)",
291
- surfaceRaised: "#1C1626",
292
- text: "#F5F3FF",
293
- textMuted: "#8B85A0",
294
- accent: "#7C5CFF",
295
- onAccent: "#FFFFFF",
296
- userBubble: "#7C5CFF",
297
- onUserBubble: "#FFFFFF",
298
- error: "rgba(248,113,113,0.16)",
299
- border: "rgba(255,255,255,0.10)",
300
- radius: 22,
301
- fontSize: 15
302
- };
303
- const lightTheme = {
304
- background: "#FFFFFF",
305
- surface: "#F1F5F9",
306
- surfaceRaised: "#FFFFFF",
307
- text: "#0F172A",
308
- textMuted: "#64748B",
309
- accent: "#7C5CFF",
310
- onAccent: "#FFFFFF",
311
- userBubble: "#7C5CFF",
312
- onUserBubble: "#FFFFFF",
313
- error: "#FEE2E2",
314
- border: "#E2E8F0",
315
- radius: 22,
316
- fontSize: 15
317
- };
318
- function resolveTheme(overrides, base = lightTheme) {
319
- return overrides ? { ...base, ...overrides } : base;
320
- }
321
- function PersonIcon({ color }) {
322
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.iconWrap, children: [
323
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.iconBand, { borderColor: color }] }),
324
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.iconCup, styles$2.iconCupLeft, { backgroundColor: color }] }),
325
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.iconCup, styles$2.iconCupRight, { backgroundColor: color }] })
326
- ] });
327
- }
328
- function Orb({ theme, active }) {
329
- const pulse = React.useRef(new reactNative.Animated.Value(0)).current;
330
- React.useEffect(() => {
331
- if (!active) {
332
- pulse.stopAnimation();
333
- reactNative.Animated.timing(pulse, { toValue: 0, duration: 240, useNativeDriver: true }).start();
334
- return;
335
- }
336
- const loop = reactNative.Animated.loop(
337
- reactNative.Animated.sequence([
338
- reactNative.Animated.timing(pulse, {
339
- toValue: 1,
340
- duration: 900,
341
- easing: reactNative.Easing.inOut(reactNative.Easing.quad),
342
- useNativeDriver: true
343
- }),
344
- reactNative.Animated.timing(pulse, {
345
- toValue: 0,
346
- duration: 900,
347
- easing: reactNative.Easing.inOut(reactNative.Easing.quad),
348
- useNativeDriver: true
349
- })
350
- ])
351
- );
352
- loop.start();
353
- return () => loop.stop();
354
- }, [active, pulse]);
355
- const scale = pulse.interpolate({ inputRange: [0, 1], outputRange: [1, 1.18] });
356
- const glow = pulse.interpolate({ inputRange: [0, 1], outputRange: [0.35, 0.7] });
357
- return /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.orbWrap, children: [
358
- /* @__PURE__ */ jsxRuntime.jsx(
359
- reactNative.Animated.View,
360
- {
361
- style: [
362
- styles$2.orbGlow,
363
- { backgroundColor: theme.accent, opacity: glow, transform: [{ scale }] }
364
- ]
365
- }
366
- ),
367
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.orbCore, { backgroundColor: theme.accent }] })
368
- ] });
369
- }
370
- function Bubble$1({ message, theme, onTalkToHuman }) {
371
- if (message.role === "user") {
372
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.row, styles$2.rowUser], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [
373
- styles$2.bubble,
374
- { backgroundColor: theme.userBubble, borderRadius: theme.radius },
375
- message.error ? { backgroundColor: theme.error } : null
376
- ], children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: {
377
- color: theme.onUserBubble,
378
- fontSize: theme.fontSize,
379
- lineHeight: theme.fontSize * 1.4
380
- }, children: message.content }) }) });
381
- }
382
- return /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: [styles$2.row, styles$2.rowAssistant], children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
383
- styles$2.assistantBody,
384
- message.error ? { backgroundColor: theme.error, borderRadius: theme.radius, padding: 12 } : null
385
- ], children: [
386
- message.content ? /* @__PURE__ */ jsxRuntime.jsx(Markdown, { color: theme.text, accentColor: theme.accent, fontSize: theme.fontSize, children: message.content }) : (
387
- // A streaming message with no text yet would be an empty box.
388
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: theme.fontSize }, children: message.streaming ? "…" : "" })
389
- ),
390
- message.error && onTalkToHuman ? /* @__PURE__ */ jsxRuntime.jsxs(
391
- reactNative.Pressable,
392
- {
393
- onPress: onTalkToHuman,
394
- accessibilityRole: "button",
395
- accessibilityLabel: "Talk to a person",
396
- style: [styles$2.errorAction, { borderColor: theme.accent }],
397
- hitSlop: 6,
398
- children: [
399
- /* @__PURE__ */ jsxRuntime.jsx(PersonIcon, { color: theme.accent }),
400
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$2.humanText, {
401
- color: theme.accent,
402
- fontSize: theme.fontSize - 1
403
- }], children: "Talk to a human" })
404
- ]
405
- }
406
- ) : null
407
- ] }) });
408
- }
409
- function resolveTopInset(explicit) {
410
- var _a;
411
- if (explicit !== void 0) return explicit;
412
- if (reactNative.Platform.OS === "android") return (_a = reactNative.StatusBar.currentHeight) != null ? _a : 24;
413
- return 8;
414
- }
415
- function useHumanHandover(onTalkToHuman, available) {
416
- const [reachable, setReachable] = React.useState(false);
417
- React.useEffect(() => {
418
- if (!onTalkToHuman || available !== void 0) return;
419
- let cancelled = false;
420
- void (async () => {
421
- try {
422
- const { api } = useOnboarding.requireConfigured();
423
- const status = await api.get(
424
- useOnboarding.EP.supportStatus()
425
- );
426
- if (!cancelled) setReachable(!!(status == null ? void 0 : status.enabled));
427
- } catch {
428
- }
429
- })();
430
- return () => {
431
- cancelled = true;
432
- };
433
- }, [onTalkToHuman, available]);
434
- if (!onTalkToHuman) return false;
435
- return available != null ? available : reachable;
436
- }
437
- function GuideAIChat({
438
- theme: overrides,
439
- placeholder = "Ask me anything",
440
- greeting = "Ask me anything",
441
- emptyState,
442
- showMic = false,
443
- leadingAccessory,
444
- title,
445
- onClose,
446
- onTalkToHuman,
447
- humanHandoverAvailable,
448
- topInset
449
- }) {
450
- const { harness, debug } = useOnboarding.requireConfigured();
451
- const {
452
- messages,
453
- input,
454
- setInput,
455
- send,
456
- busy,
457
- canSend,
458
- status
459
- } = useOnboarding.useGuideAI({ harness, trace: debug });
460
- const theme = resolveTheme(overrides);
461
- const listRef = React.useRef(null);
462
- const showHuman = useHumanHandover(onTalkToHuman, humanHandoverAvailable);
463
- const { checklist, dismiss } = useOnboarding.useOnboarding();
464
- const nextSetupStep = checklist == null ? void 0 : checklist.steps.find((step) => step.state === "available");
465
- const headerTop = resolveTopInset(topInset);
466
- const submit = () => {
467
- void send();
468
- };
469
- return /* @__PURE__ */ jsxRuntime.jsxs(
470
- reactNative.KeyboardAvoidingView,
471
- {
472
- style: [styles$2.container, { backgroundColor: theme.background }],
473
- behavior: reactNative.Platform.OS === "ios" ? "padding" : void 0,
474
- children: [
475
- title || onClose || showHuman ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
476
- styles$2.header,
477
- { borderBottomColor: theme.border, paddingTop: headerTop + 14 }
478
- ], children: [
479
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$2.headerSide, children: title ? /* @__PURE__ */ jsxRuntime.jsx(
480
- reactNative.Text,
481
- {
482
- numberOfLines: 1,
483
- style: [styles$2.title, { color: theme.text, fontSize: theme.fontSize + 1 }],
484
- children: title
485
- }
486
- ) : null }),
487
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.headerActions, children: [
488
- showHuman ? /* @__PURE__ */ jsxRuntime.jsxs(
489
- reactNative.Pressable,
490
- {
491
- onPress: onTalkToHuman,
492
- accessibilityRole: "button",
493
- accessibilityLabel: "Talk to a person",
494
- style: [styles$2.human, {
495
- backgroundColor: theme.surface,
496
- borderColor: theme.border
497
- }],
498
- hitSlop: 8,
499
- children: [
500
- /* @__PURE__ */ jsxRuntime.jsx(PersonIcon, { color: theme.accent }),
501
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$2.humanText, {
502
- color: theme.accent,
503
- fontSize: theme.fontSize - 2
504
- }], children: "Talk to human" })
505
- ]
506
- }
507
- ) : null,
508
- onClose ? /* @__PURE__ */ jsxRuntime.jsx(
509
- reactNative.Pressable,
510
- {
511
- onPress: onClose,
512
- accessibilityRole: "button",
513
- accessibilityLabel: "Close assistant",
514
- style: [styles$2.close, { backgroundColor: theme.surface }],
515
- hitSlop: 10,
516
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [styles$2.closeIcon, { color: theme.text }], children: "✕" })
517
- }
518
- ) : null
519
- ] })
520
- ] }) : null,
521
- 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: [
522
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.text, fontWeight: "700", fontSize: theme.fontSize + 2 }, children: checklist.title }),
523
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, marginTop: 3 }, children: checklist.goal }),
524
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: { color: theme.textMuted, marginTop: 8 }, children: [
525
- checklist.completed_required,
526
- " of ",
527
- checklist.total_required,
528
- " required steps complete"
529
- ] }),
530
- checklist.steps.map((step) => /* @__PURE__ */ jsxRuntime.jsxs(reactNative.Text, { style: { color: step.state === "locked" ? theme.textMuted : theme.text, marginTop: 5 }, children: [
531
- step.state === "complete" ? "✓" : step.state === "locked" ? "–" : "○",
532
- " ",
533
- step.title
534
- ] }, step.id)),
535
- 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,
536
- 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.", [
537
- { text: "Keep setup", style: "cancel" },
538
- { text: "I don't need it", onPress: () => {
539
- void dismiss().catch(() => reactNative.Alert.alert("Could not dismiss setup", "Please try again."));
540
- } }
541
- ]), 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
542
- ] }) : null,
543
- messages.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$2.empty, children: emptyState != null ? emptyState : /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.greetingRow, children: [
544
- /* @__PURE__ */ jsxRuntime.jsx(Orb, { theme, active: busy }),
545
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
546
- styles$2.greeting,
547
- { color: theme.textMuted, fontSize: theme.fontSize + 3 }
548
- ], children: greeting })
549
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
550
- reactNative.FlatList,
551
- {
552
- ref: listRef,
553
- data: messages,
554
- keyExtractor: (message) => message.id,
555
- renderItem: ({ item }) => /* @__PURE__ */ jsxRuntime.jsx(Bubble$1, { message: item, theme, onTalkToHuman }),
556
- contentContainerStyle: styles$2.list,
557
- onContentSizeChange: () => {
558
- var _a;
559
- return (_a = listRef.current) == null ? void 0 : _a.scrollToEnd({ animated: true });
560
- },
561
- keyboardShouldPersistTaps: "handled"
562
- }
563
- ),
564
- status ? /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.status, children: [
565
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.ActivityIndicator, { size: "small", color: theme.accent }),
566
- /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: theme.fontSize - 2 }, children: status })
567
- ] }) : null,
568
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: styles$2.composerRow, children: [
569
- /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: [
570
- styles$2.composer,
571
- {
572
- backgroundColor: theme.surface,
573
- borderRadius: theme.radius + 6,
574
- borderColor: theme.border
575
- }
576
- ], children: [
577
- leadingAccessory ? /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: styles$2.leading, children: leadingAccessory }) : null,
578
- /* @__PURE__ */ jsxRuntime.jsx(
579
- reactNative.TextInput,
580
- {
581
- style: [styles$2.input, { color: theme.text, fontSize: theme.fontSize }],
582
- value: input,
583
- onChangeText: setInput,
584
- placeholder: checklist && !checklist.completed && checklist.chat_policy === "setup_only" ? "Ask about your setup" : placeholder,
585
- placeholderTextColor: theme.textMuted,
586
- editable: !busy,
587
- onSubmitEditing: submit,
588
- returnKeyType: "send",
589
- multiline: true,
590
- accessibilityLabel: placeholder
591
- }
592
- ),
593
- /* @__PURE__ */ jsxRuntime.jsx(
594
- reactNative.Pressable,
595
- {
596
- onPress: submit,
597
- disabled: !canSend,
598
- accessibilityRole: "button",
599
- accessibilityLabel: "Send",
600
- style: [styles$2.send, { backgroundColor: canSend ? theme.accent : theme.border }],
601
- hitSlop: 6,
602
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: [
603
- styles$2.sendIcon,
604
- { color: canSend ? theme.onAccent : theme.textMuted }
605
- ], children: "↑" })
606
- }
607
- )
608
- ] }),
609
- showMic ? /* @__PURE__ */ jsxRuntime.jsx(
610
- reactNative.Pressable,
611
- {
612
- accessibilityRole: "button",
613
- accessibilityLabel: "Voice input",
614
- style: [styles$2.mic, { backgroundColor: theme.surface, borderColor: theme.border }],
615
- children: /* @__PURE__ */ jsxRuntime.jsx(reactNative.Text, { style: { color: theme.textMuted, fontSize: 18 }, children: "🎤" })
616
- }
617
- ) : null
618
- ] })
619
- ]
620
- }
621
- );
622
- }
623
- const styles$2 = reactNative.StyleSheet.create({
624
- container: { flex: 1 },
625
- header: {
626
- flexDirection: "row",
627
- alignItems: "center",
628
- justifyContent: "space-between",
629
- // paddingTop is set inline from the status-bar inset; only the
630
- // bottom half of the navbar's breathing room lives here.
631
- paddingHorizontal: 16,
632
- paddingBottom: 14,
633
- borderBottomWidth: reactNative.StyleSheet.hairlineWidth
634
- },
635
- headerSide: { flex: 1, minWidth: 0 },
636
- headerActions: { flexDirection: "row", alignItems: "center", gap: 8 },
637
- title: { fontWeight: "600" },
638
- human: {
639
- flexDirection: "row",
640
- alignItems: "center",
641
- gap: 6,
642
- paddingHorizontal: 10,
643
- paddingVertical: 6,
644
- borderRadius: 999,
645
- borderWidth: reactNative.StyleSheet.hairlineWidth
646
- },
647
- humanText: { fontWeight: "600" },
648
- errorAction: {
649
- flexDirection: "row",
650
- alignItems: "center",
651
- gap: 6,
652
- alignSelf: "flex-start",
653
- marginTop: 10,
654
- paddingHorizontal: 12,
655
- paddingVertical: 7,
656
- borderRadius: 999,
657
- borderWidth: reactNative.StyleSheet.hairlineWidth
658
- },
659
- iconWrap: { width: 14, height: 14, alignItems: "center", justifyContent: "center" },
660
- iconBand: {
661
- position: "absolute",
662
- top: 1,
663
- width: 12,
664
- height: 9,
665
- borderWidth: 1.6,
666
- borderBottomWidth: 0,
667
- borderTopLeftRadius: 6,
668
- borderTopRightRadius: 6
669
- },
670
- iconCup: { position: "absolute", bottom: 1, width: 3.5, height: 6, borderRadius: 1.5 },
671
- iconCupLeft: { left: 0 },
672
- iconCupRight: { right: 0 },
673
- close: {
674
- width: 32,
675
- height: 32,
676
- borderRadius: 16,
677
- alignItems: "center",
678
- justifyContent: "center"
679
- },
680
- closeIcon: { fontSize: 15, fontWeight: "600", lineHeight: 18 },
681
- list: { padding: 16, paddingBottom: 8, gap: 14 },
682
- empty: {
683
- // Centred, not pinned near the top: before the first message the
684
- // greeting is the only thing on screen, and hanging it under the
685
- // navbar leaves the rest of the display empty.
686
- flex: 1,
687
- alignItems: "center",
688
- justifyContent: "center",
689
- paddingHorizontal: 24,
690
- paddingBottom: 24
691
- },
692
- greetingRow: { flexDirection: "row", alignItems: "center", gap: 14 },
693
- greeting: { fontWeight: "400", textAlign: "center", flexShrink: 1 },
694
- orbWrap: { width: 34, height: 34, alignItems: "center", justifyContent: "center" },
695
- orbGlow: { position: "absolute", width: 34, height: 34, borderRadius: 17 },
696
- orbCore: { width: 20, height: 20, borderRadius: 10 },
697
- row: { flexDirection: "row" },
698
- rowUser: { justifyContent: "flex-end" },
699
- rowAssistant: { justifyContent: "flex-start" },
700
- // The user's bubble hugs its text: a three-word question drawn as a
701
- // full-width block reads as a paragraph, not a chat message. It is
702
- // capped at 80% so a long one still leaves the reply side legible.
703
- bubble: { maxWidth: "80%", paddingHorizontal: 16, paddingVertical: 11 },
704
- // The assistant's body does NOT hug its content, and that is the whole
705
- // point of `width` here rather than `maxWidth` alone.
706
- //
707
- // A View with only maxWidth shrink-wraps — React Native's equivalent of
708
- // width: fit-content. For a paragraph that looks fine, because the text
709
- // fills the measure anyway. For anything that lays itself out against
710
- // its parent — a table whose cells are `flex: 1`, a fenced code block,
711
- // a numbered list — the parent has collapsed to nothing by the time the
712
- // child is measured, so the table renders as an empty sliver and every
713
- // reply ends up a different width.
714
- //
715
- // Fixing it here rather than on the table keeps every block type
716
- // consistent: one column, the same measure for prose, code and tables.
717
- assistantBody: { width: "80%" },
718
- status: {
719
- flexDirection: "row",
720
- alignItems: "center",
721
- gap: 8,
722
- paddingHorizontal: 22,
723
- paddingBottom: 8
724
- },
725
- composerRow: {
726
- flexDirection: "row",
727
- alignItems: "flex-end",
728
- gap: 10,
729
- paddingHorizontal: 14,
730
- paddingBottom: reactNative.Platform.OS === "ios" ? 10 : 14,
731
- paddingTop: 4
732
- },
733
- composer: {
734
- flex: 1,
735
- flexDirection: "row",
736
- alignItems: "center",
737
- paddingLeft: 8,
738
- paddingRight: 6,
739
- paddingVertical: 6,
740
- borderWidth: reactNative.StyleSheet.hairlineWidth,
741
- gap: 6
742
- },
743
- leading: { paddingLeft: 4 },
744
- input: {
745
- flex: 1,
746
- paddingHorizontal: 8,
747
- paddingVertical: reactNative.Platform.OS === "ios" ? 8 : 4,
748
- maxHeight: 120
749
- },
750
- send: { width: 34, height: 34, borderRadius: 17, alignItems: "center", justifyContent: "center" },
751
- sendIcon: { fontSize: 17, fontWeight: "700", lineHeight: 20 },
752
- mic: {
753
- width: 46,
754
- height: 46,
755
- borderRadius: 23,
756
- alignItems: "center",
757
- justifyContent: "center",
758
- borderWidth: reactNative.StyleSheet.hairlineWidth
759
- }
760
- });
6
+ const GuideAIChat = require("./GuideAIChat-DQEa_Ff0.cjs");
7
+ const useConversations = require("./useConversations-C9ivx2l-.cjs");
761
8
  const POLL_INTERVAL_MS = 3e3;
762
9
  const CONVERSATION_KEY = "guideai_support_conversation";
763
10
  function useStoredConversation() {
764
- const { runtime } = useOnboarding.requireConfigured();
11
+ const { runtime } = useConversations.requireConfigured();
765
12
  const [id, setId] = React.useState(() => {
766
13
  try {
767
14
  return runtime.storage.getItem(CONVERSATION_KEY);
@@ -813,8 +60,8 @@ function GuideAISupportChat({
813
60
  openingContext
814
61
  }) {
815
62
  var _a;
816
- const { api } = useOnboarding.requireConfigured();
817
- const theme = resolveTheme(overrides);
63
+ const { api } = useConversations.requireConfigured();
64
+ const theme = GuideAIChat.resolveTheme(overrides);
818
65
  const headerTop = topInset != null ? topInset : reactNative.Platform.OS === "android" ? (_a = reactNative.StatusBar.currentHeight) != null ? _a : 24 : 8;
819
66
  const [conversationId, setConversationId] = useStoredConversation();
820
67
  const [messages, setMessages] = React.useState([]);
@@ -835,7 +82,7 @@ function GuideAISupportChat({
835
82
  const poll = React.useCallback(async (id) => {
836
83
  var _a2;
837
84
  try {
838
- const path = useOnboarding.EP.supportMsgs(id);
85
+ const path = useConversations.EP.supportMsgs(id);
839
86
  const result = await api.get(
840
87
  cursor.current ? `${path}?since=${encodeURIComponent(cursor.current)}` : path
841
88
  );
@@ -868,7 +115,7 @@ function GuideAISupportChat({
868
115
  setFailed(false);
869
116
  try {
870
117
  const result = await api.post(
871
- useOnboarding.EP.supportConvs(),
118
+ useConversations.EP.supportConvs(),
872
119
  {
873
120
  message: openingContext ? `${text}
874
121
 
@@ -893,7 +140,7 @@ ${openingContext}` : text,
893
140
  setInput("");
894
141
  setBusy(true);
895
142
  try {
896
- await api.post(useOnboarding.EP.supportMsgs(conversationId), { body: text });
143
+ await api.post(useConversations.EP.supportMsgs(conversationId), { body: text });
897
144
  await poll(conversationId);
898
145
  } catch {
899
146
  if (mounted.current) {
@@ -1296,10 +543,10 @@ function GuideAILauncher({
1296
543
  }) {
1297
544
  var _a, _b, _c;
1298
545
  const [isOpen, setIsOpen] = React.useState(false);
1299
- const { checklist } = useOnboarding.useOnboarding();
546
+ const { checklist } = useConversations.useOnboarding();
1300
547
  const autoOpenedFor = React.useRef(null);
1301
548
  const [view, setView] = React.useState("assistant");
1302
- const theme = resolveTheme(chatProps.theme);
549
+ const theme = GuideAIChat.resolveTheme(chatProps.theme);
1303
550
  React.useEffect(() => {
1304
551
  if (checklist && !checklist.completed && !checklist.dismissed && checklist.start_mode === "automatic" && autoOpenedFor.current !== checklist.id) {
1305
552
  autoOpenedFor.current = checklist.id;
@@ -1432,7 +679,7 @@ function GuideAILauncher({
1432
679
  onRequestClose: close,
1433
680
  children: /* @__PURE__ */ jsxRuntime.jsxs(reactNative.View, { style: { flex: 1, backgroundColor: theme.background }, children: [
1434
681
  /* @__PURE__ */ jsxRuntime.jsx(reactNative.View, { style: view === "assistant" ? styles.pane : styles.paneHidden, children: /* @__PURE__ */ jsxRuntime.jsx(
1435
- GuideAIChat,
682
+ GuideAIChat.GuideAIChat,
1436
683
  {
1437
684
  ...chatProps,
1438
685
  onClose: close,
@@ -1460,7 +707,7 @@ function GuideAIButton({
1460
707
  size = 56
1461
708
  }) {
1462
709
  const { open } = useGuideAISheet();
1463
- const theme = resolveTheme(overrides);
710
+ const theme = GuideAIChat.resolveTheme(overrides);
1464
711
  return /* @__PURE__ */ jsxRuntime.jsx(
1465
712
  reactNative.Pressable,
1466
713
  {
@@ -1513,13 +760,18 @@ const styles = reactNative.StyleSheet.create({
1513
760
  },
1514
761
  nudgeText: { lineHeight: 19 }
1515
762
  });
763
+ exports.DEFAULT_LANGUAGE_PICKER_LABELS = GuideAIChat.DEFAULT_LANGUAGE_PICKER_LABELS;
764
+ exports.DEFAULT_LIVE_VOICE_LABELS = GuideAIChat.DEFAULT_LIVE_VOICE_LABELS;
765
+ exports.GuideAIChat = GuideAIChat.GuideAIChat;
766
+ exports.GuideAILanguagePicker = GuideAIChat.GuideAILanguagePicker;
767
+ exports.GuideAILiveVoice = GuideAIChat.GuideAILiveVoice;
768
+ exports.GuideAIWhiteboard = GuideAIChat.GuideAIWhiteboard;
769
+ exports.Markdown = GuideAIChat.Markdown;
770
+ exports.darkTheme = GuideAIChat.darkTheme;
771
+ exports.lightTheme = GuideAIChat.lightTheme;
772
+ exports.resolveTheme = GuideAIChat.resolveTheme;
1516
773
  exports.GuideAIButton = GuideAIButton;
1517
- exports.GuideAIChat = GuideAIChat;
1518
774
  exports.GuideAILauncher = GuideAILauncher;
1519
775
  exports.GuideAISupportChat = GuideAISupportChat;
1520
- exports.Markdown = Markdown;
1521
- exports.darkTheme = darkTheme;
1522
- exports.lightTheme = lightTheme;
1523
- exports.resolveTheme = resolveTheme;
1524
776
  exports.useGuideAISheet = useGuideAISheet;
1525
777
  //# sourceMappingURL=ui.cjs.map