@icanbwell/baileyai-chat-ui 1.0.0 → 1.0.2

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.
@@ -1,27 +1,27 @@
1
1
  import { t as e } from "./safeMarkdownUrl-xI42YYzd.js";
2
- import { memo as t, useCallback as n, useEffect as r, useMemo as i, useRef as a, useState as o } from "react";
3
- import s from "react-markdown";
4
- import c from "remark-gfm";
5
- import * as l from "@radix-ui/react-tooltip";
6
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
2
+ import { createContext as t, memo as n, useCallback as r, useContext as i, useEffect as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l } from "react";
3
+ import u from "react-markdown";
4
+ import d from "remark-gfm";
5
+ import * as f from "@radix-ui/react-tooltip";
6
+ import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
7
7
  //#region src/utils/pseudoToolCalls.ts
8
- var p = /<(search_tools|call_tool|function_calls|function_result)>([\s\S]*?)<\/\1>/g, m = /<name>([\s\S]*?)<\/name>/, h = /<arguments>([\s\S]*?)<\/arguments>/, g = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, _ = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
- function v(e) {
10
- let t = m.exec(e)?.[1]?.trim() || "unknown_tool", n = h.exec(e)?.[1]?.trim();
8
+ var g = /<(search_tools|call_tool|function_calls|function_result)>([\s\S]*?)<\/\1>/g, _ = /<name>([\s\S]*?)<\/name>/, v = /<arguments>([\s\S]*?)<\/arguments>/, y = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, b = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
+ function x(e) {
10
+ let t = _.exec(e)?.[1]?.trim() || "unknown_tool", n = v.exec(e)?.[1]?.trim();
11
11
  return n ? {
12
12
  name: t,
13
13
  args: n
14
14
  } : { name: t };
15
15
  }
16
- function y(e) {
16
+ function S(e) {
17
17
  let t = [];
18
- g.lastIndex = 0;
18
+ y.lastIndex = 0;
19
19
  let n;
20
- for (; (n = g.exec(e)) !== null;) {
20
+ for (; (n = y.exec(e)) !== null;) {
21
21
  let [, e, r] = n, i = {};
22
- _.lastIndex = 0;
22
+ b.lastIndex = 0;
23
23
  let a;
24
- for (; (a = _.exec(r)) !== null;) i[a[1]] = a[2].trim();
24
+ for (; (a = b.exec(r)) !== null;) i[a[1]] = a[2].trim();
25
25
  let o = e.trim() || "unknown_tool";
26
26
  t.push(Object.keys(i).length > 0 ? {
27
27
  name: o,
@@ -30,11 +30,11 @@ function y(e) {
30
30
  }
31
31
  return t;
32
32
  }
33
- function b(e) {
34
- let t = [], n = e.replace(p, (e, n, r) => (n === "call_tool" ? t.push(v(r)) : n === "search_tools" ? t.push({
33
+ function C(e) {
34
+ let t = [], n = e.replace(g, (e, n, r) => (n === "call_tool" ? t.push(x(r)) : n === "search_tools" ? t.push({
35
35
  name: "search_tools",
36
36
  args: r.trim()
37
- }) : n === "function_calls" ? t.push(...y(r)) : t.push({
37
+ }) : n === "function_calls" ? t.push(...S(r)) : t.push({
38
38
  name: "function_result",
39
39
  args: r.trim()
40
40
  }), ""));
@@ -48,7 +48,7 @@ function b(e) {
48
48
  }
49
49
  //#endregion
50
50
  //#region src/logic/sse.ts
51
- function x(e) {
51
+ function w(e) {
52
52
  if (!e.startsWith("data: ")) return e;
53
53
  let t = "";
54
54
  for (let n of e.split("\n")) {
@@ -62,7 +62,7 @@ function x(e) {
62
62
  }
63
63
  return t || null;
64
64
  }
65
- function S(e) {
65
+ function T(e) {
66
66
  let t = e.replace(/\r\n/g, "\n").split("\n\n"), n = t.pop() ?? "", r = [], i = !1;
67
67
  for (let e of t) {
68
68
  let t = e.split("\n").filter((e) => e.length > 0), n = "message", a = [];
@@ -87,7 +87,7 @@ function S(e) {
87
87
  message: e
88
88
  });
89
89
  } else if (c?.type === "response.output_text.delta" && typeof c.delta == "string") {
90
- let e = x(c.delta);
90
+ let e = w(c.delta);
91
91
  e && r.push({
92
92
  type: "response.output_text.delta",
93
93
  delta: e
@@ -105,42 +105,42 @@ function S(e) {
105
105
  }
106
106
  //#endregion
107
107
  //#region src/logic/useBaileyChat.ts
108
- var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, E = (e, t, n) => {
108
+ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ee = (e, t, n) => {
109
109
  if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
110
110
  let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
111
- return i ? `${r} ${i.length > C ? `${i.slice(0, C)}…` : i}` : r;
112
- }, D = ({ transport: e, model: t, instructions: i, tools: s = [], toolChoice: c, firstUserMessagePrefix: l, onAssistantMessageComplete: u, idleTimeoutMs: d = w }) => {
113
- let [f, p] = o([]), [m, h] = o([]), [g, _] = o(null), [v, y] = o("idle"), [x, C] = o(null), D = a(null), O = a(""), k = a(0), A = a([]);
114
- r(() => {
115
- A.current = f;
111
+ return i ? `${r} ${i.length > E ? `${i.slice(0, E)}…` : i}` : r;
112
+ }, k = ({ transport: e, model: t, instructions: n, tools: i = [], toolChoice: o, firstUserMessagePrefix: s, onAssistantMessageComplete: u, idleTimeoutMs: d = D }) => {
113
+ let [f, p] = l([]), [m, h] = l([]), [g, _] = l(null), [v, y] = l("idle"), [b, x] = l(null), S = c(null), w = c(""), E = c(0), k = c([]);
114
+ a(() => {
115
+ k.current = f;
116
116
  }, [f]);
117
- let j = a([]), M = a(/* @__PURE__ */ new Map()), N = a(/* @__PURE__ */ new Map()), P = a(null), F = n(() => {
118
- P.current !== null && (clearTimeout(P.current), P.current = null);
119
- }, []), I = n((e) => {
120
- F(), P.current = setTimeout(() => {
117
+ let A = c([]), j = c(/* @__PURE__ */ new Map()), M = c(/* @__PURE__ */ new Map()), N = c(null), P = r(() => {
118
+ N.current !== null && (clearTimeout(N.current), N.current = null);
119
+ }, []), F = r((e) => {
120
+ P(), N.current = setTimeout(() => {
121
121
  e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
122
122
  }, d);
123
- }, [F, d]);
124
- r(() => () => {
125
- D.current?.abort(), F();
126
- }, [F]);
127
- let L = n((e, t, n) => {
123
+ }, [P, d]);
124
+ a(() => () => {
125
+ S.current?.abort(), P();
126
+ }, [P]);
127
+ let I = r((e, t, n) => {
128
128
  let r = (e) => {
129
129
  n.push(e), h((t) => [...t, e]);
130
130
  };
131
131
  if (t.type === "response.output_text.delta") {
132
132
  if (!t.delta) return !1;
133
- let n = M.current.get(e) ?? {
133
+ let n = j.current.get(e) ?? {
134
134
  raw: "",
135
135
  emittedCount: 0
136
136
  };
137
137
  n.raw += t.delta;
138
- let { cleanedText: i, matches: a } = b(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
139
- if (n.emittedCount = a.length, M.current.set(e, n), N.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
138
+ let { cleanedText: i, matches: a } = C(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
139
+ if (n.emittedCount = a.length, j.current.set(e, n), M.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
140
140
  ...t,
141
141
  content: o
142
142
  } : t)), s.length > 0) {
143
- let e = Date.now(), t = k.current;
143
+ let e = Date.now(), t = E.current;
144
144
  s.forEach((n) => r({
145
145
  kind: "pseudo_tool_call",
146
146
  name: n.name,
@@ -154,7 +154,7 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
154
154
  if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
155
155
  let e = t.item;
156
156
  if (e.type === "function_call" || e.type === "mcp_call") {
157
- let n = Date.now(), i = k.current, a = e.name || "unknown_tool";
157
+ let n = Date.now(), i = E.current, a = e.name || "unknown_tool";
158
158
  return r(t.type === "response.output_item.added" ? {
159
159
  kind: "tool_start",
160
160
  name: a,
@@ -179,46 +179,46 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
179
179
  status: t.status,
180
180
  message: t.message,
181
181
  at: Date.now(),
182
- turnSentAt: k.current
182
+ turnSentAt: E.current
183
183
  }), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
184
184
  kind: "info",
185
185
  message: t.message,
186
186
  at: Date.now(),
187
- turnSentAt: k.current
187
+ turnSentAt: E.current
188
188
  }), !0) : (r({
189
189
  kind: "raw",
190
190
  eventType: t.type,
191
191
  raw: JSON.stringify(t),
192
192
  at: Date.now(),
193
- turnSentAt: k.current
193
+ turnSentAt: E.current
194
194
  }), !0);
195
- }, []), R = n(async (n) => {
196
- y("streaming"), C(null);
197
- let r = Date.now();
198
- k.current = r;
199
- let a = T(), o = {
200
- id: a,
195
+ }, []), L = r(async (r) => {
196
+ y("streaming"), x(null);
197
+ let a = Date.now();
198
+ E.current = a;
199
+ let c = O(), l = {
200
+ id: c,
201
201
  role: "assistant",
202
202
  content: "",
203
203
  streaming: !0,
204
- createdAt: r
204
+ createdAt: a
205
205
  };
206
- p((e) => [...e, o]), j.current = [...n, o];
207
- let d = n.findIndex((e) => e.role === "user" && !e.hidden), f = n.map((e, t) => t === d && l ? {
206
+ p((e) => [...e, l]), A.current = [...r, l];
207
+ let d = r.findIndex((e) => e.role === "user" && !e.hidden), f = r.map((e, t) => t === d && s ? {
208
208
  role: e.role,
209
- content: `${l}${e.content}`
209
+ content: `${s}${e.content}`
210
210
  } : {
211
211
  role: e.role,
212
212
  content: e.content
213
213
  });
214
214
  _({
215
215
  model: t,
216
- systemPrompt: i,
216
+ systemPrompt: n,
217
217
  messages: f,
218
- tools: s,
219
- toolChoice: c,
218
+ tools: i,
219
+ toolChoice: o,
220
220
  stream: !0,
221
- sentAt: r,
221
+ sentAt: a,
222
222
  streamStats: {
223
223
  chunkCount: 0,
224
224
  firstChunkAt: null,
@@ -226,18 +226,18 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
226
226
  }
227
227
  });
228
228
  let m = new AbortController();
229
- D.current = m, I(m);
230
- let g = "", v = null, b = !1, x = !1, w = [], O = (e, t) => {
231
- y("error"), C(e);
229
+ S.current = m, F(m);
230
+ let g = "", v = null, b = !1, C = !1, w = [], D = (e, t) => {
231
+ y("error"), x(e);
232
232
  let n = {
233
233
  kind: "error",
234
234
  message: e,
235
235
  at: Date.now(),
236
- turnSentAt: r,
236
+ turnSentAt: a,
237
237
  ...t
238
238
  };
239
239
  w.push(n), h((e) => [...e, n]);
240
- }, A = (e, t) => {
240
+ }, k = (e, t) => {
241
241
  e.forEach((e) => {
242
242
  if (e.type === "error") {
243
243
  v = e.message;
@@ -245,76 +245,76 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
245
245
  kind: "error",
246
246
  message: e.message,
247
247
  at: Date.now(),
248
- turnSentAt: r
248
+ turnSentAt: a
249
249
  };
250
250
  w.push(t), h((e) => [...e, t]);
251
251
  return;
252
252
  }
253
- e.type === "response.output_text.delta" && e.delta && (x = !0), L(a, e, w) && (b = !0);
254
- }), t && p((e) => e.map((e) => e.id === a ? {
253
+ e.type === "response.output_text.delta" && e.delta && (C = !0), I(c, e, w) && (b = !0);
254
+ }), t && p((e) => e.map((e) => e.id === c ? {
255
255
  ...e,
256
256
  streaming: !1
257
257
  } : e));
258
258
  };
259
259
  try {
260
- let { status: n, text: o, errorMessage: l } = await e.streamChat({
260
+ let { status: r, text: s, errorMessage: l } = await e.streamChat({
261
261
  model: t,
262
- instructions: i,
262
+ instructions: n,
263
263
  input: f,
264
- tools: s,
265
- toolChoice: c,
264
+ tools: i,
265
+ toolChoice: o,
266
266
  signal: m.signal,
267
267
  onChunk: (e) => {
268
- I(m), g += e;
269
- let { events: t, remainder: n, done: i } = S(g);
270
- g = n, A(t, i);
271
- let a = Date.now();
272
- _((e) => e && e.sentAt === r ? {
268
+ F(m), g += e;
269
+ let { events: t, remainder: n, done: r } = T(g);
270
+ g = n, k(t, r);
271
+ let i = Date.now();
272
+ _((e) => e && e.sentAt === a ? {
273
273
  ...e,
274
274
  streamStats: {
275
275
  chunkCount: e.streamStats.chunkCount + 1,
276
- firstChunkAt: e.streamStats.firstChunkAt ?? a,
277
- lastChunkAt: a
276
+ firstChunkAt: e.streamStats.firstChunkAt ?? i,
277
+ lastChunkAt: i
278
278
  }
279
279
  } : e);
280
280
  },
281
281
  onRequestId: (e) => {
282
- _((t) => t && t.sentAt === r ? {
282
+ _((t) => t && t.sentAt === a ? {
283
283
  ...t,
284
284
  requestId: e
285
285
  } : t);
286
286
  }
287
287
  });
288
288
  if (g.trim()) {
289
- let { events: e, done: t } = S(`${g}\n\n`);
290
- g = "", A(e, t);
289
+ let { events: e, done: t } = T(`${g}\n\n`);
290
+ g = "", k(e, t);
291
291
  }
292
292
  if (v) {
293
- y("error"), C(v);
293
+ y("error"), x(v);
294
294
  return;
295
295
  }
296
- if (n === void 0 || n >= 400) {
297
- O(E(n, o, l), {
298
- httpStatus: n,
299
- rawBody: o || void 0
296
+ if (r === void 0 || r >= 400) {
297
+ D(ee(r, s, l), {
298
+ httpStatus: r,
299
+ rawBody: s || void 0
300
300
  });
301
301
  return;
302
302
  }
303
303
  if (!b) {
304
- O("Bailey returned an empty response.");
304
+ D("Bailey returned an empty response.");
305
305
  return;
306
306
  }
307
- if (!x) {
308
- O("Bailey ran some tools but didn't return an answer. Try asking again.");
307
+ if (!C) {
308
+ D("Bailey ran some tools but didn't return an answer. Try asking again.");
309
309
  return;
310
310
  }
311
311
  y("idle");
312
- let d = N.current.get(a) ?? "";
313
- _((e) => e && e.sentAt === r ? {
312
+ let d = M.current.get(c) ?? "";
313
+ _((e) => e && e.sentAt === a ? {
314
314
  ...e,
315
315
  response: { content: d }
316
316
  } : e), u && await u({
317
- id: a,
317
+ id: c,
318
318
  role: "assistant",
319
319
  content: d,
320
320
  streaming: !1
@@ -322,21 +322,21 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
322
322
  } catch (e) {
323
323
  let t = e;
324
324
  if (t?.name === "TimeoutError") {
325
- O(t.message, { source: "client-timeout" });
325
+ D(t.message, { source: "client-timeout" });
326
326
  return;
327
327
  }
328
328
  if (t?.name === "AbortError") {
329
329
  y("idle");
330
330
  return;
331
331
  }
332
- O(t?.message || "Bailey request failed.");
332
+ D(t?.message || "Bailey request failed.");
333
333
  } finally {
334
- F();
335
- let e = N.current.get(a) ?? "";
336
- M.current.delete(a), N.current.delete(a), p((e) => e.flatMap((e) => e.id === a ? e.content ? [{
334
+ P();
335
+ let e = M.current.get(c) ?? "";
336
+ j.current.delete(c), M.current.delete(c), p((e) => e.flatMap((e) => e.id === c ? e.content ? [{
337
337
  ...e,
338
338
  streaming: !1
339
- }] : [] : [e])), j.current = j.current.flatMap((t) => t.id === a ? e ? [{
339
+ }] : [] : [e])), A.current = A.current.flatMap((t) => t.id === c ? e ? [{
340
340
  ...t,
341
341
  content: e,
342
342
  streaming: !1
@@ -345,83 +345,91 @@ var C = 200, w = 15e4, T = () => typeof crypto < "u" && typeof crypto.randomUUID
345
345
  }, [
346
346
  e,
347
347
  t,
348
+ n,
348
349
  i,
350
+ o,
349
351
  s,
350
- c,
351
- l,
352
352
  u,
353
- L,
354
353
  I,
355
- F
356
- ]), z = n((e) => {
357
- A.current = e, p(e);
354
+ F,
355
+ P
356
+ ]), R = r((e) => {
357
+ k.current = e, p(e);
358
358
  }, []);
359
359
  return {
360
360
  messages: f,
361
361
  traceEvents: m,
362
362
  lastRequest: g,
363
363
  status: v,
364
- error: x,
365
- send: n((e) => {
364
+ error: b,
365
+ send: r((e) => {
366
366
  let t = e.trim();
367
367
  if (!t) return;
368
- O.current = t;
368
+ w.current = t;
369
369
  let n = {
370
- id: T(),
370
+ id: O(),
371
371
  role: "user",
372
372
  content: t,
373
373
  createdAt: Date.now()
374
- }, r = [...j.current, n];
375
- j.current = r, z([...A.current, n]), R(r);
376
- }, [R, z]),
377
- sendHidden: n((e) => {
374
+ }, r = [...A.current, n];
375
+ A.current = r, R([...k.current, n]), L(r);
376
+ }, [L, R]),
377
+ sendHidden: r((e) => {
378
378
  if (v === "streaming") return;
379
379
  let t = e.trim();
380
380
  if (!t) return;
381
- O.current = t;
381
+ w.current = t;
382
382
  let n = {
383
- id: T(),
383
+ id: O(),
384
384
  role: "user",
385
385
  content: t,
386
386
  createdAt: Date.now(),
387
387
  hidden: !0
388
- }, r = [...j.current, n];
389
- j.current = r, R(r);
390
- }, [R, v]),
391
- stop: n(() => {
392
- D.current?.abort();
388
+ }, r = [...A.current, n];
389
+ A.current = r, L(r);
390
+ }, [L, v]),
391
+ stop: r(() => {
392
+ S.current?.abort();
393
393
  }, []),
394
- retryLast: n(() => {
395
- if (v === "streaming" || !O.current) return;
396
- let e = A.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
397
- z(n);
398
- let r = j.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
399
- j.current = a, R(a);
394
+ retryLast: r(() => {
395
+ if (v === "streaming" || !w.current) return;
396
+ let e = k.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
397
+ R(n);
398
+ let r = A.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
399
+ A.current = a, L(a);
400
400
  }, [
401
+ L,
401
402
  R,
402
- z,
403
403
  v
404
404
  ]),
405
- clearTrace: n(() => h([]), []),
406
- clearError: n(() => {
407
- C(null), y((e) => e === "error" ? "idle" : e);
405
+ clearTrace: r(() => h([]), []),
406
+ clearError: r(() => {
407
+ x(null), y((e) => e === "error" ? "idle" : e);
408
408
  }, []),
409
- newChat: n(() => {
410
- D.current?.abort(), z([]), j.current = [], h([]), _(null), y("idle"), C(null), O.current = "";
411
- }, [z])
409
+ newChat: r(() => {
410
+ S.current?.abort(), R([]), A.current = [], h([]), _(null), y("idle"), x(null), w.current = "";
411
+ }, [R]),
412
+ loadMessages: r((e) => {
413
+ S.current?.abort();
414
+ let t = e.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
415
+ ...e,
416
+ streaming: !1
417
+ }));
418
+ R(t.filter((e) => !e.hidden)), A.current = t, h([]), _(null), y("idle"), x(null), w.current = "";
419
+ }, [R])
412
420
  };
413
421
  };
414
422
  //#endregion
415
423
  //#region src/utils/prompt.ts
416
- function O(...e) {
424
+ function A(...e) {
417
425
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
418
426
  }
419
427
  //#endregion
420
428
  //#region src/utils/toolCalls.ts
421
- var k = "call_tool", A = "a tool";
422
- function j(e, t) {
429
+ var j = "call_tool", M = "a tool";
430
+ function N(e, t) {
423
431
  let n = {
424
- name: e === k ? A : e,
432
+ name: e === j ? M : e,
425
433
  args: null,
426
434
  viaCallTool: !1
427
435
  };
@@ -434,7 +442,7 @@ function j(e, t) {
434
442
  }
435
443
  if (typeof r != "object" || !r) return n;
436
444
  let i = r;
437
- if (e === k) {
445
+ if (e === j) {
438
446
  let e = typeof i.name == "string" ? i.name : void 0;
439
447
  if (!e) return n;
440
448
  let t = i.arguments;
@@ -452,32 +460,32 @@ function j(e, t) {
452
460
  }
453
461
  //#endregion
454
462
  //#region src/utils/table.ts
455
- var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(N).join(""), P = (e) => {
463
+ var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(F).join(""), I = (e) => {
456
464
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
457
465
  for (let t of e.children ?? []) {
458
- let e = P(t);
466
+ let e = I(t);
459
467
  if (e) return e;
460
468
  }
461
- }, F = (e, t) => (e.children ?? []).find((e) => e.tagName === t), I = (e) => {
462
- let t = N(e), n = P(e);
469
+ }, L = (e, t) => (e.children ?? []).find((e) => e.tagName === t), R = (e) => {
470
+ let t = F(e), n = I(e);
463
471
  return n ? {
464
472
  text: t,
465
473
  href: n
466
474
  } : { text: t };
467
- }, L = (e) => (e.children ?? []).filter((e) => e.type === "element").map(I), R = (e) => {
475
+ }, z = (e) => (e.children ?? []).filter((e) => e.type === "element").map(R), B = (e) => {
468
476
  if (e.tagName !== "table") return null;
469
- let t = F(e, "thead"), n = t && F(t, "tr");
477
+ let t = L(e, "thead"), n = t && L(t, "tr");
470
478
  return {
471
- headers: n ? L(n).map((e) => e.text) : [],
472
- rows: (F(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(L)
479
+ headers: n ? z(n).map((e) => e.text) : [],
480
+ rows: (L(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(z)
473
481
  };
474
- }, z = (e) => e.length > 5, B = "When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {\"type\": \"bar\" | \"line\" | \"pie\" | \"doughnut\" | \"scatter\", \"title\"?: string, \"data\": {\"labels\": string[], \"datasets\": [{\"label\": string, \"data\": number[]}]}}. For \"scatter\" charts, omit \"labels\" and give each dataset \"data\" as an array of {\"x\": number, \"y\": number} points instead of a number array. \"pie\" and \"doughnut\" charts must have exactly one dataset. Do not include any other fields (no \"options\", no colors) — the app handles styling. Example:\n```chartjs\n{\"type\": \"line\", \"title\": \"BP readings\", \"data\": {\"labels\": [\"Jul 14\", \"Jul 21\", \"Jul 28\"], \"datasets\": [{\"label\": \"Systolic\", \"data\": [120, 118, 122]}]}}\n```", V = [
482
+ }, V = (e) => e.length > 5, H = "When a chart would help answer a question (e.g. plotting a trend over time), include a fenced code block tagged `chartjs` containing a JSON object with this exact shape: {\"type\": \"bar\" | \"line\" | \"pie\" | \"doughnut\" | \"scatter\", \"title\"?: string, \"data\": {\"labels\": string[], \"datasets\": [{\"label\": string, \"data\": number[]}]}}. For \"scatter\" charts, omit \"labels\" and give each dataset \"data\" as an array of {\"x\": number, \"y\": number} points instead of a number array. \"pie\" and \"doughnut\" charts must have exactly one dataset. Do not include any other fields (no \"options\", no colors) — the app handles styling. Example:\n```chartjs\n{\"type\": \"line\", \"title\": \"BP readings\", \"data\": {\"labels\": [\"Jul 14\", \"Jul 21\", \"Jul 28\"], \"datasets\": [{\"label\": \"Systolic\", \"data\": [120, 118, 122]}]}}\n```", te = [
475
483
  "bar",
476
484
  "line",
477
485
  "pie",
478
486
  "doughnut",
479
487
  "scatter"
480
- ], ee = 8, H = 50, U = 8, W = 500, G = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", te = (e) => {
488
+ ], U = 8, W = 50, G = 8, K = 500, ne = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", re = (e) => {
481
489
  let t;
482
490
  try {
483
491
  t = JSON.parse(e);
@@ -486,17 +494,17 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
486
494
  }
487
495
  if (typeof t != "object" || !t) return null;
488
496
  let n = t;
489
- if (typeof n.type != "string" || !V.includes(n.type)) return null;
497
+ if (typeof n.type != "string" || !te.includes(n.type)) return null;
490
498
  let r = n.type;
491
499
  if (n.title !== void 0 && typeof n.title != "string") return null;
492
500
  let i = n.title;
493
501
  if (typeof n.data != "object" || n.data === null) return null;
494
502
  let a = n.data;
495
- if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > ee || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
503
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > U || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
496
504
  for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
497
505
  let o = a.datasets;
498
506
  if (r === "scatter") {
499
- for (let e of o) if (e.data.length < 1 || e.data.length > W || !e.data.every(G)) return null;
507
+ for (let e of o) if (e.data.length < 1 || e.data.length > K || !e.data.every(ne)) return null;
500
508
  return {
501
509
  type: r,
502
510
  title: i,
@@ -504,7 +512,7 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
504
512
  };
505
513
  }
506
514
  if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
507
- let s = a.labels, c = r === "pie" || r === "doughnut" ? U : H;
515
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? G : W;
508
516
  if (s.length < 1 || s.length > c) return null;
509
517
  for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
510
518
  return {
@@ -515,7 +523,7 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
515
523
  datasets: o
516
524
  }
517
525
  };
518
- }, ne = {
526
+ }, ie = {
519
527
  tool_start: "Tool start",
520
528
  tool_end: "Tool end",
521
529
  pseudo_tool_call: "Narrated tool call",
@@ -524,13 +532,13 @@ var M = 5, N = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
524
532
  error: "Error",
525
533
  raw: "Raw event"
526
534
  };
527
- function K(e) {
528
- return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : j(e.name, e.args);
535
+ function q(e) {
536
+ return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : N(e.name, e.args);
529
537
  }
530
- function q(e, t = K(e)) {
538
+ function J(e, t = q(e)) {
531
539
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
532
540
  }
533
- function J(e, t = K(e)) {
541
+ function ae(e, t = q(e)) {
534
542
  switch (e.kind) {
535
543
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
536
544
  case "tool_end": return `${t.viaCallTool ? `${t.name} (via call_tool)` : t.name}${e.runtimeSeconds === void 0 ? "" : ` — ${e.runtimeSeconds.toFixed(2)}s`}${e.isError ? " — failed" : ""}`;
@@ -541,20 +549,20 @@ function J(e, t = K(e)) {
541
549
  case "raw": return `Unrecognized event: ${e.eventType}`;
542
550
  }
543
551
  }
544
- function re(e, t = K(e)) {
552
+ function oe(e, t = q(e)) {
545
553
  return e.kind === "tool_start" || e.kind === "tool_end" ? t.args ? JSON.stringify(t.args, null, 2) : e.args ?? null : e.kind === "pseudo_tool_call" ? e.args ?? null : null;
546
554
  }
547
- function ie(e) {
555
+ function se(e) {
548
556
  return e.kind === "tool_end" ? e.output ?? null : null;
549
557
  }
550
- function Y(e) {
558
+ function ce(e) {
551
559
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
552
560
  }
553
- function X(e) {
561
+ function Y(e) {
554
562
  switch (e.kind) {
555
- case "tool_start": return `Calling ${j(e.name, e.args).name}...`;
563
+ case "tool_start": return `Calling ${N(e.name, e.args).name}...`;
556
564
  case "tool_end": {
557
- let t = j(e.name, e.args).name;
565
+ let t = N(e.name, e.args).name;
558
566
  return e.isError ? `${t} failed` : `${t} returned`;
559
567
  }
560
568
  case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
@@ -564,11 +572,11 @@ function X(e) {
564
572
  case "raw": return `Unrecognized event: ${e.eventType}`;
565
573
  }
566
574
  }
567
- function ae(e) {
575
+ function le(e) {
568
576
  let t = new Date(e);
569
577
  return `${String(t.getHours()).padStart(2, "0")}:${String(t.getMinutes()).padStart(2, "0")}:${String(t.getSeconds()).padStart(2, "0")}.${String(t.getMilliseconds()).padStart(3, "0")}`;
570
578
  }
571
- function oe(e) {
579
+ function ue(e) {
572
580
  if (e <= 0) return "+0ms";
573
581
  if (e < 1e3) return `+${Math.round(e)}ms`;
574
582
  let t = e / 1e3;
@@ -576,30 +584,30 @@ function oe(e) {
576
584
  let n = Math.floor(t / 60), r = Math.round(t % 60);
577
585
  return `+${n}m${String(r).padStart(2, "0")}s`;
578
586
  }
579
- function se(e) {
587
+ function de(e) {
580
588
  return e.map((t, n) => {
581
- let r = K(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
589
+ let r = q(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
582
590
  return {
583
591
  key: `${t.at}-${n}`,
584
592
  kind: t.kind,
585
- toolName: q(t, r),
593
+ toolName: J(t, r),
586
594
  isToolStart: t.kind === "tool_start",
587
595
  failed: t.kind === "tool_end" && t.isError === !0,
588
- time: ae(t.at),
596
+ time: le(t.at),
589
597
  gapMs: t.at - i,
590
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ne[t.kind],
591
- summary: J(t, r),
592
- argsDetail: re(t, r),
593
- outputDetail: ie(t),
594
- rawDetail: Y(t)
598
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ie[t.kind],
599
+ summary: ae(t, r),
600
+ argsDetail: oe(t, r),
601
+ outputDetail: se(t),
602
+ rawDetail: ce(t)
595
603
  };
596
604
  });
597
605
  }
598
- function ce(e) {
606
+ function fe(e) {
599
607
  let t = e.filter((e) => e.kind === "tool_end"), n = t.filter((e) => e.kind === "tool_end" && e.isError), r = e.filter((e) => e.kind === "error"), i = [];
600
608
  return t.length > 0 && i.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), r.length > 0 && i.push(`${r.length} stream error${r.length === 1 ? "" : "s"}`), i.join(" · ");
601
609
  }
602
- function le(e) {
610
+ function pe(e) {
603
611
  let t = [];
604
612
  for (let n of e) {
605
613
  let e = t[t.length - 1];
@@ -618,65 +626,103 @@ function le(e) {
618
626
  }
619
627
  return t;
620
628
  }
621
- function ue(e) {
629
+ function me(e) {
622
630
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
623
631
  }
624
- function de(e, t) {
632
+ function he(e, t) {
625
633
  return t === void 0 ? [] : e.filter((e) => e.turnSentAt === t && (e.kind === "tool_end" || e.kind === "pseudo_tool_call" || e.kind === "progress")).map((e, t) => ({
626
634
  key: `${e.at}-${t}`,
627
- text: X(e),
628
- toolName: q(e)
635
+ text: Y(e),
636
+ toolName: J(e)
629
637
  }));
630
638
  }
631
639
  //#endregion
640
+ //#region src/styles.css?inline
641
+ var ge = "/*! tailwindcss v4.3.3 | MIT License | https://tailwindcss.com */\n@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-border-style:solid;--tw-leading:initial;--tw-space-y-reverse:0}}}@layer theme{:root,:host{--font-sans:\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;--color-red-100:oklch(93.6% .032 17.717);--color-green-100:oklch(96.2% .044 156.743);--color-green-700:oklch(52.7% .154 150.069);--color-blue-100:oklch(93.2% .032 255.585);--color-blue-700:oklch(48.8% .243 264.376);--color-purple-100:oklch(94.6% .033 307.174);--color-purple-700:oklch(49.6% .265 301.924);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1 / .75);--text-sm:.875rem;--text-sm--line-height:calc(1.25 / .875);--text-base:1rem;--text-base--line-height:calc(1.5 / 1);--text-lg:1.125rem;--text-lg--line-height:calc(1.75 / 1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75 / 1.25);--font-weight-medium:500;--font-weight-semibold:600;--leading-relaxed:1.625;--radius-md:.375rem;--radius-2xl:1rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1);--color-bailey-accent:#4f46e5;--color-bailey-bubble-bg:#fff;--color-bailey-error:#d32f2f;--color-bailey-border:#e5e5e5;--color-bailey-surface:#fff;--color-bailey-surface-muted:#f9fafb;--color-bailey-text:#000;--color-bailey-text-secondary:#6b6b6b;--color-bailey-tooltip-bg:#000;--color-bailey-tooltip-text:#fff;--color-bailey-page-bg:#eceef4;--color-bailey-heart:#16a34a}}@layer utilities;.bailey-chat-panel{box-sizing:border-box;background-color:var(--color-bailey-page-bg);height:100%;padding:calc(var(--spacing) * 3);font-family:var(--font-sans);flex-direction:column;display:flex}.bailey-chat-panel-inner{width:100%;min-height:0;max-width:var(--container-3xl);gap:calc(var(--spacing) * 2);flex-direction:column;flex:1;margin-inline:auto;display:flex;overflow-y:auto}.bailey-toolbar-row{justify-content:flex-end;display:flex}.bailey-new-chat-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-new-chat-button:hover{text-decoration-line:underline}}.bailey-new-chat-button:disabled{cursor:default;opacity:.5;text-decoration-line:none}.bailey-chat-transcript{min-height:0;padding:calc(var(--spacing) * 2);padding-bottom:calc(var(--spacing) * 4);flex:1;overflow-y:auto}.bailey-message-row{margin-bottom:calc(var(--spacing) * 3);justify-content:flex-start;display:flex}.bailey-message-row-user{justify-content:flex-end}.bailey-user-message{flex-direction:column;align-items:flex-end;max-width:75%;display:flex}.bailey-message-meta{margin-bottom:var(--spacing);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-message-meta-name{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);color:var(--color-bailey-text)}.bailey-user-bubble{border-radius:var(--radius-2xl);background-color:var(--color-bailey-bubble-bg);max-width:100%;padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);white-space:pre-wrap;color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.bailey-assistant-message{width:100%;padding-inline:var(--spacing)}.bailey-thinking-hint{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);font-style:italic}.bailey-streaming-hint{margin-top:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);font-style:italic;display:block}.bailey-message-actions{margin-top:var(--spacing);align-items:center;gap:var(--spacing);display:flex}.bailey-empty-state{text-align:center;height:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);justify-content:center;align-items:center;display:flex}.bailey-suggestions{gap:calc(var(--spacing) * 3);padding:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-suggestions-title{padding-inline:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text)}.bailey-suggestion-card{cursor:pointer;appearance:none;justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-2xl);--tw-border-style:none;background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 3);text-align:left;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);transition-property:box-shadow;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration));border-style:none;display:flex}@media (hover:hover){.bailey-suggestion-card:hover{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a), 0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}}.bailey-suggestion-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-text-secondary);flex-shrink:0}.bailey-privacy-note{border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 4);padding-top:calc(var(--spacing) * 3);padding-bottom:var(--spacing);text-align:center;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-privacy-note a{color:var(--color-bailey-text-secondary);text-decoration-line:underline}.bailey-activity-line{margin-bottom:calc(var(--spacing) * 2);align-items:center;gap:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-activity-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-bailey-accent);flex-shrink:0}.bailey-error-banner{margin-bottom:calc(var(--spacing) * 2);justify-content:space-between;align-items:center;gap:calc(var(--spacing) * 2);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-error);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);color:var(--color-bailey-error);display:flex}.bailey-retry-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium);background-color:#0000;border-style:none;text-decoration-line:underline}.bailey-error-actions{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-dismiss-button{cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-error);background-color:#0000;border-style:none}@media (hover:hover){.bailey-dismiss-button:hover{opacity:.7}}.bailey-input-row{align-items:center;gap:calc(var(--spacing) * 2);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);--tw-shadow:0 1px 3px 0 var(--tw-shadow-color,#0000001a), 0 1px 2px -1px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);border-radius:2147483647px;display:flex}.bailey-input-row:focus-within{border-color:var(--color-bailey-accent)}.bailey-input{--tw-border-style:none;min-width:0;padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;background-color:#0000;border-style:none;outline-style:none;flex:1}.bailey-input:disabled{opacity:.5}.bailey-send-button,.bailey-stop-button{cursor:pointer;appearance:none;background-color:#0000;border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}:is(.bailey-send-button,.bailey-stop-button):disabled{cursor:default;opacity:.4}.bailey-send-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-heart);border-style:none}@media (hover:hover){.bailey-send-button:hover{background-color:#16a34a1a}@supports (color:color-mix(in lab, red, red)){.bailey-send-button:hover{background-color:color-mix(in oklab, var(--color-bailey-heart) 10%, transparent)}}}.bailey-send-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-stop-button{height:calc(var(--spacing) * 9);width:calc(var(--spacing) * 9);--tw-border-style:none;color:var(--color-bailey-error);border-style:none}@media (hover:hover){.bailey-stop-button:hover{background-color:#d32f2f1a}@supports (color:color-mix(in lab, red, red)){.bailey-stop-button:hover{background-color:color-mix(in oklab, var(--color-bailey-error) 10%, transparent)}}}.bailey-stop-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-copy-button{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-copy-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-copy-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-copy-button:hover{color:var(--color-bailey-text)}}.bailey-copy-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-tooltip-content{padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));background-color:var(--color-bailey-tooltip-bg,#000);color:var(--color-bailey-tooltip-text,#fff);border-radius:.25rem}.bailey-tooltip-arrow{fill:var(--color-bailey-tooltip-bg,#000)}.bailey-markdown-content table{border-collapse:collapse;width:100%;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.bailey-markdown-content th{background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);text-align:left;--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content td{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);vertical-align:top}.bailey-markdown-content tr:nth-child(2n){background-color:var(--color-bailey-surface-muted)}.bailey-markdown-content{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-leading:var(--leading-relaxed);line-height:var(--leading-relaxed)}.bailey-markdown-content>:first-child{margin-top:0}.bailey-markdown-content>:last-child{margin-bottom:0}.bailey-markdown-content p{margin-block:calc(var(--spacing) * 2)}.bailey-markdown-content h1{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h2{margin-top:calc(var(--spacing) * 4);margin-bottom:calc(var(--spacing) * 2);font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h3{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-base);line-height:var(--tw-leading,var(--text-base--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content h4,.bailey-markdown-content h5,.bailey-markdown-content h6{margin-top:calc(var(--spacing) * 3);margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.bailey-markdown-content ul{margin-block:calc(var(--spacing) * 2);list-style-type:disc}:where(.bailey-markdown-content ul>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ul{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content ol{margin-block:calc(var(--spacing) * 2);list-style-type:decimal}:where(.bailey-markdown-content ol>:not(:last-child)){--tw-space-y-reverse:0;margin-block-start:calc(var(--spacing) * var(--tw-space-y-reverse));margin-block-end:calc(var(--spacing) * calc(1 - var(--tw-space-y-reverse)))}.bailey-markdown-content ol{padding-left:calc(var(--spacing) * 5)}.bailey-markdown-content a{color:var(--color-bailey-accent);text-underline-offset:2px;text-decoration-line:underline}.bailey-markdown-content code{background-color:var(--color-bailey-surface-muted);padding-inline:var(--spacing);padding-block:calc(var(--spacing) * .5);font-family:var(--font-mono);border-radius:.25rem;font-size:.85em}.bailey-markdown-content pre{margin-block:calc(var(--spacing) * 2);border-radius:var(--radius-md);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 2);overflow-x:auto}.bailey-markdown-content pre code{background-color:#0000;padding:0}.bailey-markdown-content blockquote{margin-block:calc(var(--spacing) * 2);border-left-style:var(--tw-border-style);border-left-width:2px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 3);color:var(--color-bailey-text-secondary);font-style:italic}.bailey-markdown-content hr{margin-block:calc(var(--spacing) * 3);border-color:var(--color-bailey-border)}.bailey-trace-panel{margin-bottom:calc(var(--spacing) * 2)}.bailey-trace-toggle-row{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-trace-toggle{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none}@media (hover:hover){.bailey-trace-toggle:hover{text-decoration-line:underline}}.bailey-trace-toggle-error{color:var(--color-bailey-error)}.bailey-trace-summary{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary)}.bailey-trace-summary-error{color:var(--color-bailey-error)}.bailey-trace-body{margin-top:var(--spacing);max-height:calc(var(--spacing) * 80);overflow-y:auto}.bailey-trace-actions-row{justify-content:flex-end;gap:calc(var(--spacing) * 3);display:flex}.bailey-trace-copy-button{cursor:pointer;appearance:none;--tw-border-style:none;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-accent);background-color:#0000;border-style:none;text-decoration-line:underline}@media (hover:hover){.bailey-trace-copy-button:hover{text-decoration-line:none}}.bailey-trace-request-details{margin-bottom:var(--spacing);border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);padding:calc(var(--spacing) * 2)}.bailey-trace-request-meta{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:block}.bailey-trace-rows{gap:var(--spacing);flex-direction:column;display:flex}.bailey-trace-row{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing);font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-row-header{align-items:center;gap:calc(var(--spacing) * 2);flex-wrap:wrap;display:flex}.bailey-trace-row-time{color:var(--color-bailey-text-secondary)}.bailey-trace-row-gap{color:var(--color-gray-400)}.bailey-trace-row-summary{word-break:break-all}.bailey-trace-chip{padding-inline:calc(var(--spacing) * 1.5);padding-block:calc(var(--spacing) * .5);--tw-font-weight:var(--font-weight-semibold);font-size:.65rem;font-weight:var(--font-weight-semibold);border-radius:.25rem}.bailey-trace-chip-default{background-color:var(--color-gray-200);color:var(--color-gray-700)}.bailey-trace-chip-info{background-color:var(--color-blue-100);color:var(--color-blue-700)}.bailey-trace-chip-success{background-color:var(--color-green-100);color:var(--color-green-700)}.bailey-trace-chip-secondary{background-color:var(--color-purple-100);color:var(--color-purple-700)}.bailey-trace-chip-error{background-color:var(--color-red-100);color:var(--color-bailey-error)}.bailey-trace-disclosure{margin-top:var(--spacing)}.bailey-trace-disclosure-summary{cursor:pointer;color:var(--color-bailey-text-secondary);font-size:.7rem}.bailey-trace-disclosure-actions{margin-top:var(--spacing);justify-content:flex-end;display:flex}.bailey-trace-disclosure-content{margin-top:var(--spacing);max-height:calc(var(--spacing) * 48);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding:calc(var(--spacing) * 1.5);word-break:break-all;white-space:pre-wrap;border-radius:.25rem;font-size:.7rem;overflow:auto}.bailey-trace-group{border-radius:var(--radius-md);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 2);padding-block:var(--spacing)}.bailey-trace-group-summary{cursor:pointer;font-family:var(--font-mono);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-trace-group-failed{margin-left:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}@property --tw-font-weight{syntax:\"*\";inherits:false}@property --tw-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:\"*\";inherits:false}@property --tw-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:\"*\";inherits:false}@property --tw-inset-shadow-alpha{syntax:\"<percentage>\";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:\"*\";inherits:false}@property --tw-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:\"*\";inherits:false}@property --tw-inset-ring-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:\"*\";inherits:false}@property --tw-ring-offset-width{syntax:\"<length>\";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:\"*\";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:\"*\";inherits:false;initial-value:0 0 #0000}@property --tw-border-style{syntax:\"*\";inherits:false;initial-value:solid}@property --tw-leading{syntax:\"*\";inherits:false}@property --tw-space-y-reverse{syntax:\"*\";inherits:false;initial-value:0}", _e = t(void 0), ve = /:root\s*,\s*:host\s*\{/, ye = ".bailey-chat-panel{";
642
+ function be(e) {
643
+ let t = e.match(new RegExp(ve, "g"))?.length ?? 0;
644
+ if (t !== 1) throw Error(`Expected exactly one ":root, :host {" rule in the compiled styles.css, found ${t}. Tailwind likely changed how @theme compiles — update this rewrite (and its sibling, scripts/scope-theme-vars.js) before shipping.`);
645
+ return e.replace(ve, ye);
646
+ }
647
+ var xe = be(ge), X = "data-source", Z = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
648
+ function Se(e) {
649
+ let t = e.getRootNode();
650
+ return t instanceof ShadowRoot ? t : document;
651
+ }
652
+ function Ce(e) {
653
+ let t = e instanceof ShadowRoot ? e : document.head, n = Q.get(e) ?? 0;
654
+ if (n === 0 && !t.querySelector(`style[${X}="${Z}"]`)) {
655
+ let e = document.createElement("style");
656
+ e.setAttribute(X, Z), e.textContent = xe, t.appendChild(e);
657
+ }
658
+ return Q.set(e, n + 1), () => {
659
+ let n = (Q.get(e) ?? 1) - 1;
660
+ n <= 0 ? (Q.delete(e), t.querySelector(`style[${X}="${Z}"]`)?.remove()) : Q.set(e, n);
661
+ };
662
+ }
663
+ function we(e, t = !1) {
664
+ let [n, r] = l(null);
665
+ return o(() => {
666
+ if (t) return;
667
+ let n = e.current;
668
+ if (!n) return;
669
+ let i = Se(n);
670
+ return r(i), Ce(i);
671
+ }, [t, e]), n;
672
+ }
673
+ function Te(e) {
674
+ let t = i(_e), n = t !== void 0, r = we(e, n);
675
+ return n ? t : r;
676
+ }
677
+ //#endregion
632
678
  //#region src/ui/markdown.tsx
633
- function Z({ renderTable: t, renderChart: n } = {}) {
679
+ function Ee({ renderTable: t, renderChart: n } = {}) {
634
680
  return {
635
- a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ d(u, { children: n }) : /* @__PURE__ */ d("a", {
681
+ a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ m(p, { children: n }) : /* @__PURE__ */ m("a", {
636
682
  href: t,
637
683
  target: "_blank",
638
684
  rel: "noopener noreferrer",
639
685
  children: n
640
686
  }),
641
687
  table: ({ node: n, children: r }) => {
642
- let i = n && R(n);
643
- if (i && z(i.rows) && t) {
688
+ let i = n && B(n);
689
+ if (i && V(i.rows) && t) {
644
690
  let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
645
- return /* @__PURE__ */ d(u, { children: t({
691
+ return /* @__PURE__ */ m(p, { children: t({
646
692
  headers: i.headers,
647
693
  rows: n
648
694
  }) });
649
695
  }
650
- return /* @__PURE__ */ d("table", { children: r });
696
+ return /* @__PURE__ */ m("table", { children: r });
651
697
  },
652
698
  pre: ({ children: e }) => {
653
699
  let t = (Array.isArray(e) ? e[0] : e)?.props;
654
700
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
655
- let e = t?.children, r = te(Array.isArray(e) ? e.join("") : String(e ?? ""));
656
- if (r) return /* @__PURE__ */ d(u, { children: n(r) });
701
+ let e = t?.children, r = re(Array.isArray(e) ? e.join("") : String(e ?? ""));
702
+ if (r) return /* @__PURE__ */ m(p, { children: n(r) });
657
703
  }
658
- return /* @__PURE__ */ d("pre", { children: e });
704
+ return /* @__PURE__ */ m("pre", { children: e });
659
705
  }
660
706
  };
661
707
  }
662
708
  //#endregion
663
709
  //#region src/ui/icons.tsx
664
- function fe({ className: e }) {
665
- return /* @__PURE__ */ d("svg", {
710
+ function De({ className: e }) {
711
+ return /* @__PURE__ */ m("svg", {
666
712
  viewBox: "0 0 24 24",
667
713
  fill: "currentColor",
668
714
  className: e,
669
715
  "aria-hidden": "true",
670
- children: /* @__PURE__ */ d("path", { d: "M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z" })
716
+ children: /* @__PURE__ */ m("path", { d: "M12 20.3s-7.6-4.7-10-9.4C.4 7.7 1.7 4 5.2 3.1c2.2-.6 4.4.4 5.5 2.2 1.2-1.8 3.4-2.8 5.6-2.2 3.5.9 4.8 4.6 3.2 7.8-2.4 4.7-10 9.4-10 9.4z" })
671
717
  });
672
718
  }
673
- function pe({ className: e }) {
674
- return /* @__PURE__ */ d("svg", {
719
+ function Oe({ className: e }) {
720
+ return /* @__PURE__ */ m("svg", {
675
721
  viewBox: "0 0 24 24",
676
722
  fill: "currentColor",
677
723
  className: e,
678
724
  "aria-hidden": "true",
679
- children: /* @__PURE__ */ d("rect", {
725
+ children: /* @__PURE__ */ m("rect", {
680
726
  x: "6",
681
727
  y: "6",
682
728
  width: "12",
@@ -685,8 +731,8 @@ function pe({ className: e }) {
685
731
  })
686
732
  });
687
733
  }
688
- function me({ className: e }) {
689
- return /* @__PURE__ */ f("svg", {
734
+ function ke({ className: e }) {
735
+ return /* @__PURE__ */ h("svg", {
690
736
  viewBox: "0 0 24 24",
691
737
  fill: "none",
692
738
  stroke: "currentColor",
@@ -695,11 +741,11 @@ function me({ className: e }) {
695
741
  strokeLinejoin: "round",
696
742
  className: e,
697
743
  "aria-hidden": "true",
698
- children: [/* @__PURE__ */ d("path", { d: "M7 17 17 7" }), /* @__PURE__ */ d("path", { d: "M9 7h8v8" })]
744
+ children: [/* @__PURE__ */ m("path", { d: "M7 17 17 7" }), /* @__PURE__ */ m("path", { d: "M9 7h8v8" })]
699
745
  });
700
746
  }
701
- function he({ className: e }) {
702
- return /* @__PURE__ */ f("svg", {
747
+ function Ae({ className: e }) {
748
+ return /* @__PURE__ */ h("svg", {
703
749
  viewBox: "0 0 24 24",
704
750
  fill: "none",
705
751
  stroke: "currentColor",
@@ -708,17 +754,17 @@ function he({ className: e }) {
708
754
  strokeLinejoin: "round",
709
755
  className: e,
710
756
  "aria-hidden": "true",
711
- children: [/* @__PURE__ */ d("rect", {
757
+ children: [/* @__PURE__ */ m("rect", {
712
758
  x: "8",
713
759
  y: "8",
714
760
  width: "12",
715
761
  height: "12",
716
762
  rx: "2"
717
- }), /* @__PURE__ */ d("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
763
+ }), /* @__PURE__ */ m("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
718
764
  });
719
765
  }
720
- function ge({ className: e }) {
721
- return /* @__PURE__ */ d("svg", {
766
+ function je({ className: e }) {
767
+ return /* @__PURE__ */ m("svg", {
722
768
  viewBox: "0 0 24 24",
723
769
  fill: "none",
724
770
  stroke: "currentColor",
@@ -727,11 +773,11 @@ function ge({ className: e }) {
727
773
  strokeLinejoin: "round",
728
774
  className: e,
729
775
  "aria-hidden": "true",
730
- children: /* @__PURE__ */ d("path", { d: "M5 12.5 9.5 17 19 7" })
776
+ children: /* @__PURE__ */ m("path", { d: "M5 12.5 9.5 17 19 7" })
731
777
  });
732
778
  }
733
- function _e({ className: e }) {
734
- return /* @__PURE__ */ f("svg", {
779
+ function Me({ className: e }) {
780
+ return /* @__PURE__ */ h("svg", {
735
781
  viewBox: "0 0 24 24",
736
782
  fill: "none",
737
783
  stroke: "currentColor",
@@ -740,28 +786,29 @@ function _e({ className: e }) {
740
786
  strokeLinejoin: "round",
741
787
  className: e,
742
788
  "aria-hidden": "true",
743
- children: [/* @__PURE__ */ d("circle", {
789
+ children: [/* @__PURE__ */ m("circle", {
744
790
  cx: "12",
745
791
  cy: "12",
746
792
  r: "9"
747
- }), /* @__PURE__ */ d("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
793
+ }), /* @__PURE__ */ m("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
748
794
  });
749
795
  }
750
796
  //#endregion
751
797
  //#region src/ui/CopyMarkdownButton.tsx
752
- var ve = 1500;
753
- function ye({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: i = "Copy as markdown", tooltipCopiedText: s = "Copied!" }) {
754
- let [c, u] = o(!1), [p, m] = o(!1), h = a(null);
755
- return r(() => () => {
756
- h.current !== null && clearTimeout(h.current);
757
- }, []), /* @__PURE__ */ d(l.Provider, {
798
+ var Ne = 1500;
799
+ function Pe({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
800
+ let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = Te(g);
801
+ return a(() => () => {
802
+ p.current !== null && clearTimeout(p.current);
803
+ }, []), /* @__PURE__ */ m(f.Provider, {
758
804
  delayDuration: 200,
759
- children: /* @__PURE__ */ f(l.Root, {
760
- open: c || p,
761
- onOpenChange: m,
762
- children: [/* @__PURE__ */ d(l.Trigger, {
805
+ children: /* @__PURE__ */ h(f.Root, {
806
+ open: o || u,
807
+ onOpenChange: d,
808
+ children: [/* @__PURE__ */ m(f.Trigger, {
763
809
  asChild: !0,
764
- children: /* @__PURE__ */ d("button", {
810
+ children: /* @__PURE__ */ m("button", {
811
+ ref: g,
765
812
  type: "button",
766
813
  onClick: async () => {
767
814
  try {
@@ -769,36 +816,39 @@ function ye({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
769
816
  } catch {
770
817
  return;
771
818
  }
772
- u(!0), h.current !== null && clearTimeout(h.current), h.current = setTimeout(() => u(!1), ve);
819
+ s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Ne);
773
820
  },
774
821
  "aria-label": n,
775
822
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
776
- children: d(c ? ge : he, { className: "bailey-copy-icon" })
823
+ children: m(o ? je : Ae, { className: "bailey-copy-icon" })
777
824
  })
778
- }), /* @__PURE__ */ d(l.Portal, { children: /* @__PURE__ */ f(l.Content, {
779
- side: "top",
780
- className: "bailey-tooltip-content",
781
- children: [c ? s : i, /* @__PURE__ */ d(l.Arrow, { className: "bailey-tooltip-arrow" })]
782
- }) })]
825
+ }), /* @__PURE__ */ m(f.Portal, {
826
+ container: _ instanceof ShadowRoot ? _ : void 0,
827
+ children: /* @__PURE__ */ h(f.Content, {
828
+ side: "top",
829
+ className: "bailey-tooltip-content",
830
+ children: [o ? i : r, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
831
+ })
832
+ })]
783
833
  })
784
834
  });
785
835
  }
786
836
  //#endregion
787
837
  //#region src/ui/BaileyTracePanel.tsx
788
- async function be(e) {
838
+ async function Fe(e) {
789
839
  try {
790
840
  await navigator.clipboard.writeText(e);
791
841
  } catch {}
792
842
  }
793
- function xe({ text: e, label: t = "Copy" }) {
794
- return /* @__PURE__ */ d("button", {
843
+ function Ie({ text: e, label: t = "Copy" }) {
844
+ return /* @__PURE__ */ m("button", {
795
845
  type: "button",
796
- onClick: () => be(e),
846
+ onClick: () => Fe(e),
797
847
  className: "bailey-trace-copy-button",
798
848
  children: t
799
849
  });
800
850
  }
801
- function Se(e) {
851
+ function Le(e) {
802
852
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
803
853
  switch (e.kind) {
804
854
  case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
@@ -807,74 +857,74 @@ function Se(e) {
807
857
  default: return "bailey-trace-chip bailey-trace-chip-default";
808
858
  }
809
859
  }
810
- function Q({ label: e, content: t, copyable: n }) {
811
- return /* @__PURE__ */ f("details", {
860
+ function $({ label: e, content: t, copyable: n }) {
861
+ return /* @__PURE__ */ h("details", {
812
862
  className: "bailey-trace-disclosure",
813
863
  children: [
814
- /* @__PURE__ */ d("summary", {
864
+ /* @__PURE__ */ m("summary", {
815
865
  className: "bailey-trace-disclosure-summary",
816
866
  children: e
817
867
  }),
818
- n && /* @__PURE__ */ d("div", {
868
+ n && /* @__PURE__ */ m("div", {
819
869
  className: "bailey-trace-disclosure-actions",
820
- children: /* @__PURE__ */ d(xe, { text: t })
870
+ children: /* @__PURE__ */ m(Ie, { text: t })
821
871
  }),
822
- /* @__PURE__ */ d("pre", {
872
+ /* @__PURE__ */ m("pre", {
823
873
  className: "bailey-trace-disclosure-content",
824
874
  children: t
825
875
  })
826
876
  ]
827
877
  });
828
878
  }
829
- function $({ row: e }) {
830
- return /* @__PURE__ */ f("div", {
879
+ function Re({ row: e }) {
880
+ return /* @__PURE__ */ h("div", {
831
881
  className: "bailey-trace-row",
832
882
  children: [
833
- /* @__PURE__ */ f("div", {
883
+ /* @__PURE__ */ h("div", {
834
884
  className: "bailey-trace-row-header",
835
885
  children: [
836
- /* @__PURE__ */ d("span", {
886
+ /* @__PURE__ */ m("span", {
837
887
  className: "bailey-trace-row-time",
838
888
  children: e.time
839
889
  }),
840
- /* @__PURE__ */ d("span", {
890
+ /* @__PURE__ */ m("span", {
841
891
  className: "bailey-trace-row-gap",
842
892
  title: "Time since the previous event",
843
- children: oe(e.gapMs)
893
+ children: ue(e.gapMs)
844
894
  }),
845
- /* @__PURE__ */ d("span", {
846
- className: Se(e),
895
+ /* @__PURE__ */ m("span", {
896
+ className: Le(e),
847
897
  children: e.label
848
898
  }),
849
- /* @__PURE__ */ d("span", {
899
+ /* @__PURE__ */ m("span", {
850
900
  className: "bailey-trace-row-summary",
851
901
  children: e.summary
852
902
  })
853
903
  ]
854
904
  }),
855
- e.argsDetail && /* @__PURE__ */ d(Q, {
905
+ e.argsDetail && /* @__PURE__ */ m($, {
856
906
  label: "args",
857
907
  content: e.argsDetail
858
908
  }),
859
- e.outputDetail && /* @__PURE__ */ d(Q, {
909
+ e.outputDetail && /* @__PURE__ */ m($, {
860
910
  label: "output",
861
911
  content: e.outputDetail
862
912
  }),
863
- e.rawDetail && /* @__PURE__ */ d(Q, {
913
+ e.rawDetail && /* @__PURE__ */ m($, {
864
914
  label: "raw",
865
915
  content: e.rawDetail
866
916
  })
867
917
  ]
868
918
  });
869
919
  }
870
- function Ce(e, t) {
920
+ function ze(e, t) {
871
921
  if (e.chunkCount === 0) return "Streamed: no chunks received";
872
922
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
873
923
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
874
924
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
875
925
  }
876
- function we({ request: e }) {
877
- let t = i(() => JSON.stringify({
926
+ function Be({ request: e }) {
927
+ let t = s(() => JSON.stringify({
878
928
  model: e.model,
879
929
  instructions: e.systemPrompt,
880
930
  input: e.messages,
@@ -882,10 +932,10 @@ function we({ request: e }) {
882
932
  tools: e.tools,
883
933
  toolChoice: e.toolChoice
884
934
  }, null, 2), [e]);
885
- return /* @__PURE__ */ f("div", {
935
+ return /* @__PURE__ */ h("div", {
886
936
  className: "bailey-trace-request-details",
887
937
  children: [
888
- /* @__PURE__ */ f("span", {
938
+ /* @__PURE__ */ h("span", {
889
939
  className: "bailey-trace-request-meta",
890
940
  children: [
891
941
  "Last request — ",
@@ -895,26 +945,26 @@ function we({ request: e }) {
895
945
  e.requestId ? ` · ${e.requestId}` : ""
896
946
  ]
897
947
  }),
898
- /* @__PURE__ */ d("span", {
948
+ /* @__PURE__ */ m("span", {
899
949
  className: "bailey-trace-request-meta",
900
- children: Ce(e.streamStats, e.sentAt)
950
+ children: ze(e.streamStats, e.sentAt)
901
951
  }),
902
- /* @__PURE__ */ d(Q, {
952
+ /* @__PURE__ */ m($, {
903
953
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
904
954
  content: e.systemPrompt,
905
955
  copyable: !0
906
956
  }),
907
- /* @__PURE__ */ d(Q, {
957
+ /* @__PURE__ */ m($, {
908
958
  label: `Messages (${e.messages.length})`,
909
959
  content: JSON.stringify(e.messages, null, 2),
910
960
  copyable: !0
911
961
  }),
912
- e.response && /* @__PURE__ */ d(Q, {
962
+ e.response && /* @__PURE__ */ m($, {
913
963
  label: `Response (${e.response.content.length.toLocaleString()} chars)`,
914
964
  content: e.response.content,
915
965
  copyable: !0
916
966
  }),
917
- /* @__PURE__ */ d(Q, {
967
+ /* @__PURE__ */ m($, {
918
968
  label: "Full payload (JSON)",
919
969
  content: t,
920
970
  copyable: !0
@@ -922,43 +972,43 @@ function we({ request: e }) {
922
972
  ]
923
973
  });
924
974
  }
925
- function Te({ events: e, lastRequest: t, onClear: n }) {
926
- let r = i(() => se(e), [e]), a = i(() => le(r), [r]), o = i(() => JSON.stringify(e, null, 2), [e]);
927
- return /* @__PURE__ */ f("div", {
975
+ function Ve({ events: e, lastRequest: t, onClear: n }) {
976
+ let r = s(() => de(e), [e]), i = s(() => pe(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
977
+ return /* @__PURE__ */ h("div", {
928
978
  className: "bailey-trace-body",
929
979
  children: [
930
- /* @__PURE__ */ f("div", {
980
+ /* @__PURE__ */ h("div", {
931
981
  className: "bailey-trace-actions-row",
932
- children: [e.length > 0 && /* @__PURE__ */ d(xe, {
933
- text: o,
982
+ children: [e.length > 0 && /* @__PURE__ */ m(Ie, {
983
+ text: a,
934
984
  label: "Copy trace as JSON"
935
- }), /* @__PURE__ */ d("button", {
985
+ }), /* @__PURE__ */ m("button", {
936
986
  type: "button",
937
987
  onClick: n,
938
988
  className: "bailey-trace-copy-button",
939
989
  children: "Clear"
940
990
  })]
941
991
  }),
942
- t && /* @__PURE__ */ d(we, { request: t }),
943
- /* @__PURE__ */ d("div", {
992
+ t && /* @__PURE__ */ m(Be, { request: t }),
993
+ /* @__PURE__ */ m("div", {
944
994
  className: "bailey-trace-rows",
945
- children: a.map((e, t) => {
946
- if (e.type === "single") return /* @__PURE__ */ d($, { row: e.row }, e.row.key);
995
+ children: i.map((e, t) => {
996
+ if (e.type === "single") return /* @__PURE__ */ m(Re, { row: e.row }, e.row.key);
947
997
  let n = e.rows.filter((e) => e.isToolStart).length;
948
- if (n <= 1) return /* @__PURE__ */ d("div", {
998
+ if (n <= 1) return /* @__PURE__ */ m("div", {
949
999
  className: "bailey-trace-rows",
950
- children: e.rows.map((e) => /* @__PURE__ */ d($, { row: e }, e.key))
1000
+ children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
951
1001
  }, `group-${t}`);
952
1002
  let r = e.rows.filter((e) => e.failed).length;
953
- return /* @__PURE__ */ f("details", {
1003
+ return /* @__PURE__ */ h("details", {
954
1004
  className: "bailey-trace-group",
955
- children: [/* @__PURE__ */ f("summary", {
1005
+ children: [/* @__PURE__ */ h("summary", {
956
1006
  className: "bailey-trace-group-summary",
957
1007
  children: [
958
- /* @__PURE__ */ d("strong", { children: e.toolName }),
1008
+ /* @__PURE__ */ m("strong", { children: e.toolName }),
959
1009
  " × ",
960
1010
  n,
961
- r > 0 && /* @__PURE__ */ f("span", {
1011
+ r > 0 && /* @__PURE__ */ h("span", {
962
1012
  className: "bailey-trace-group-failed",
963
1013
  children: [
964
1014
  " ",
@@ -967,9 +1017,9 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
967
1017
  ]
968
1018
  })
969
1019
  ]
970
- }), /* @__PURE__ */ d("div", {
1020
+ }), /* @__PURE__ */ m("div", {
971
1021
  className: "bailey-trace-rows",
972
- children: e.rows.map((e) => /* @__PURE__ */ d($, { row: e }, e.key))
1022
+ children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
973
1023
  })]
974
1024
  }, `group-${t}`);
975
1025
  })
@@ -977,29 +1027,29 @@ function Te({ events: e, lastRequest: t, onClear: n }) {
977
1027
  ]
978
1028
  });
979
1029
  }
980
- function Ee({ events: e, lastRequest: t, onClear: n }) {
981
- let [r, a] = o(!1), s = i(() => ue(e), [e]), c = i(() => ce(e), [e]);
982
- return e.length === 0 && !t ? null : /* @__PURE__ */ f("div", {
1030
+ function He({ events: e, lastRequest: t, onClear: n }) {
1031
+ let [r, i] = l(!1), a = s(() => me(e), [e]), o = s(() => fe(e), [e]);
1032
+ return e.length === 0 && !t ? null : /* @__PURE__ */ h("div", {
983
1033
  className: "bailey-trace-panel",
984
- children: [/* @__PURE__ */ f("div", {
1034
+ children: [/* @__PURE__ */ h("div", {
985
1035
  className: "bailey-trace-toggle-row",
986
- children: [/* @__PURE__ */ f("button", {
1036
+ children: [/* @__PURE__ */ h("button", {
987
1037
  type: "button",
988
- onClick: () => a((e) => !e),
1038
+ onClick: () => i((e) => !e),
989
1039
  "aria-expanded": r,
990
- className: s ? "bailey-trace-toggle bailey-trace-toggle-error" : "bailey-trace-toggle",
1040
+ className: a ? "bailey-trace-toggle bailey-trace-toggle-error" : "bailey-trace-toggle",
991
1041
  children: [
992
- s && !r ? "⚠ " : "",
1042
+ a && !r ? "⚠ " : "",
993
1043
  r ? "Hide details" : "Show details",
994
1044
  " (",
995
1045
  e.length,
996
1046
  ")"
997
1047
  ]
998
- }), c && /* @__PURE__ */ d("span", {
999
- className: s ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
1000
- children: c
1048
+ }), o && /* @__PURE__ */ m("span", {
1049
+ className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
1050
+ children: o
1001
1051
  })]
1002
- }), r && /* @__PURE__ */ d(Te, {
1052
+ }), r && /* @__PURE__ */ m(Ve, {
1003
1053
  events: e,
1004
1054
  lastRequest: t,
1005
1055
  onClear: n
@@ -1008,7 +1058,7 @@ function Ee({ events: e, lastRequest: t, onClear: n }) {
1008
1058
  }
1009
1059
  //#endregion
1010
1060
  //#region src/ui/BaileyChatPanel.tsx
1011
- var De = "How can bailey AI help you today?", Oe = "Reply to bailey AI", ke = {
1061
+ var Ue = "How can bailey AI help you today?", We = "Reply to bailey AI", Ge = {
1012
1062
  newChatButtonText: "New chat",
1013
1063
  newChatAriaLabel: "new chat",
1014
1064
  suggestionsTitle: "Suggested for you",
@@ -1023,229 +1073,235 @@ var De = "How can bailey AI help you today?", Oe = "Reply to bailey AI", ke = {
1023
1073
  copyButtonAriaLabel: "copy response as markdown",
1024
1074
  copyButtonTooltipDefault: "Copy as markdown",
1025
1075
  copyButtonTooltipCopied: "Copied!"
1026
- }, Ae = [c], je = {
1027
- ...Z(),
1028
- p: ({ children: e }) => /* @__PURE__ */ d(u, { children: e })
1029
- }, Me = t(function({ content: e, components: t }) {
1030
- return /* @__PURE__ */ d("div", {
1076
+ }, Ke = [d], qe = {
1077
+ ...Ee(),
1078
+ p: ({ children: e }) => /* @__PURE__ */ m(p, { children: e })
1079
+ }, Je = n(function({ content: e, components: t }) {
1080
+ return /* @__PURE__ */ m("div", {
1031
1081
  className: "bailey-markdown-content",
1032
- children: /* @__PURE__ */ d(s, {
1033
- remarkPlugins: Ae,
1082
+ children: /* @__PURE__ */ m(u, {
1083
+ remarkPlugins: Ke,
1034
1084
  components: t,
1035
1085
  skipHtml: !0,
1036
1086
  children: e
1037
1087
  })
1038
1088
  });
1039
1089
  });
1040
- function Ne(e, t, n) {
1090
+ function Ye(e, t, n) {
1041
1091
  if (e !== "streaming") return;
1042
1092
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
1043
- if (r.length !== 0) return X(r[r.length - 1]);
1093
+ if (r.length !== 0) return Y(r[r.length - 1]);
1044
1094
  }
1045
- function Pe(e) {
1095
+ function Xe(e) {
1046
1096
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
1047
1097
  hour: "numeric",
1048
1098
  minute: "2-digit"
1049
1099
  });
1050
1100
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
1051
1101
  }
1052
- function Fe({ chat: e, placeholder: t, replyPlaceholder: n = Oe, emptyPlaceholder: c, suggestions: u, privacyNote: p, resolveActivityIcon: m, className: h, height: g, width: _, hideDeveloperDetails: v = !1, renderMessageActions: y, renderTable: b, renderChart: x, labels: S, formatMessageTime: C }) {
1053
- let { messages: w, traceEvents: T, lastRequest: E, status: D, error: O, send: k, stop: A, retryLast: j, clearTrace: M, clearError: N, newChat: P } = e, [F, I] = o(""), L = {
1054
- ...ke,
1102
+ function Ze({ chat: e, placeholder: t, replyPlaceholder: n = We, emptyPlaceholder: r, suggestions: i, privacyNote: o, resolveActivityIcon: d, className: p, height: g, width: _, hideDeveloperDetails: v = !1, renderMessageActions: y, renderTable: b, renderChart: x, labels: S, formatMessageTime: C }) {
1103
+ let { messages: w, traceEvents: T, lastRequest: E, status: D, error: O, send: ee, stop: k, retryLast: A, clearTrace: j, clearError: M, newChat: N } = e, [P, F] = l(""), I = {
1104
+ ...Ge,
1055
1105
  ...S
1056
- }, R = C ?? Pe, z = a(null), B = a(null), V = a(!0), ee = i(() => Z({
1106
+ }, L = C ?? Xe, R = c(null), z = we(R), B = c(null), V = c(null), H = c(!0), te = s(() => Ee({
1057
1107
  renderTable: b,
1058
1108
  renderChart: x
1059
- }), [b, x]), H = i(() => Ne(D, T, E), [
1109
+ }), [b, x]), U = s(() => Ye(D, T, E), [
1060
1110
  D,
1061
1111
  T,
1062
1112
  E
1063
- ]), U = w.length === 0, W = t ?? (U ? c ?? De : n);
1064
- r(() => {
1065
- let e = B.current;
1113
+ ]), W = w.length === 0, G = t ?? (W ? r ?? Ue : n);
1114
+ a(() => {
1115
+ let e = V.current;
1066
1116
  if (!e) return;
1067
1117
  let t = () => {
1068
1118
  let t = e.scrollHeight - e.scrollTop - e.clientHeight;
1069
- V.current = t < 60;
1119
+ H.current = t < 60;
1070
1120
  };
1071
1121
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1072
- }, []), r(() => {
1073
- V.current && z.current?.scrollIntoView({
1122
+ }, []), a(() => {
1123
+ H.current && B.current?.scrollIntoView({
1074
1124
  behavior: D === "streaming" ? "auto" : "smooth",
1075
1125
  block: "nearest"
1076
1126
  });
1077
1127
  }, [w, D]);
1078
- let G = (e) => {
1079
- V.current = !0, k(e);
1128
+ let K = (e) => {
1129
+ H.current = !0, ee(e);
1080
1130
  };
1081
- return /* @__PURE__ */ d("div", {
1082
- className: `bailey-chat-panel${h ? ` ${h}` : ""}`,
1083
- style: g !== void 0 || _ !== void 0 ? {
1084
- height: g,
1085
- width: _
1086
- } : void 0,
1087
- children: /* @__PURE__ */ f("div", {
1088
- className: "bailey-chat-panel-inner",
1089
- children: [
1090
- /* @__PURE__ */ d("div", {
1091
- className: "bailey-toolbar-row",
1092
- children: /* @__PURE__ */ d("button", {
1093
- type: "button",
1094
- onClick: P,
1095
- disabled: w.length === 0,
1096
- "aria-label": L.newChatAriaLabel,
1097
- className: "bailey-new-chat-button",
1098
- children: L.newChatButtonText
1099
- })
1100
- }),
1101
- /* @__PURE__ */ f("div", {
1102
- className: "bailey-chat-transcript",
1103
- ref: B,
1104
- children: [
1105
- U && (u && u.length > 0 ? /* @__PURE__ */ f("div", {
1106
- className: "bailey-suggestions",
1107
- children: [/* @__PURE__ */ d("div", {
1108
- className: "bailey-suggestions-title",
1109
- children: L.suggestionsTitle
1110
- }), u.map((e, t) => /* @__PURE__ */ f("button", {
1111
- type: "button",
1112
- onClick: () => G(e.value ?? e.label),
1113
- className: "bailey-suggestion-card",
1114
- children: [/* @__PURE__ */ d("span", { children: e.label }), /* @__PURE__ */ d(me, { className: "bailey-suggestion-icon" })]
1115
- }, `${e.label}-${t}`))]
1116
- }) : /* @__PURE__ */ d("div", {
1117
- className: "bailey-empty-state",
1118
- children: L.emptyStateMessage
1119
- })),
1120
- w.map((e, t) => {
1121
- let n = e.role === "assistant" && t === w.length - 1, r = D === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? de(T, e.createdAt) : [], a = i[i.length - 1];
1122
- return /* @__PURE__ */ d("div", {
1123
- className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1124
- children: e.role === "user" ? /* @__PURE__ */ f("div", {
1125
- className: "bailey-user-message",
1126
- children: [/* @__PURE__ */ f("div", {
1127
- className: "bailey-message-meta",
1128
- children: [/* @__PURE__ */ d("span", {
1129
- className: "bailey-message-meta-name",
1130
- children: L.youLabel
1131
- }), e.createdAt !== void 0 && /* @__PURE__ */ d("span", { children: R(e.createdAt) })]
1132
- }), /* @__PURE__ */ d("div", {
1133
- className: "bailey-user-bubble",
1134
- children: e.content
1135
- })]
1136
- }) : r ? /* @__PURE__ */ d("div", {
1137
- className: "bailey-thinking-hint",
1138
- children: H ?? L.thinkingHint
1139
- }) : /* @__PURE__ */ f("div", {
1140
- className: "bailey-assistant-message",
1141
- children: [
1142
- a && /* @__PURE__ */ f("div", {
1143
- className: "bailey-activity-line",
1144
- children: [/* @__PURE__ */ d("span", {
1145
- className: "bailey-activity-icon",
1146
- children: m?.(a.toolName) ?? /* @__PURE__ */ d(_e, {})
1147
- }), /* @__PURE__ */ d("span", { children: a.text })]
1148
- }),
1149
- /* @__PURE__ */ d(Me, {
1150
- content: e.content,
1151
- components: ee
1152
- }),
1153
- e.streaming && H && /* @__PURE__ */ d("div", {
1154
- className: "bailey-streaming-hint",
1155
- children: H
1156
- }),
1157
- !e.streaming && /* @__PURE__ */ f("div", {
1158
- className: "bailey-message-actions",
1159
- children: [/* @__PURE__ */ d(ye, {
1160
- markdown: e.content,
1161
- ariaLabel: L.copyButtonAriaLabel,
1162
- tooltipDefaultText: L.copyButtonTooltipDefault,
1163
- tooltipCopiedText: L.copyButtonTooltipCopied
1164
- }), y?.(e)]
1165
- })
1166
- ]
1167
- })
1168
- }, e.id);
1169
- }),
1170
- /* @__PURE__ */ d("div", { ref: z })
1171
- ]
1172
- }),
1173
- O && /* @__PURE__ */ f("div", {
1174
- className: "bailey-error-banner",
1175
- role: "alert",
1176
- children: [/* @__PURE__ */ d("span", { children: O }), /* @__PURE__ */ f("div", {
1177
- className: "bailey-error-actions",
1178
- children: [/* @__PURE__ */ d("button", {
1179
- type: "button",
1180
- onClick: j,
1181
- className: "bailey-retry-button",
1182
- children: L.retryButtonText
1183
- }), /* @__PURE__ */ d("button", {
1131
+ return /* @__PURE__ */ m(_e.Provider, {
1132
+ value: z,
1133
+ children: /* @__PURE__ */ m("div", {
1134
+ ref: R,
1135
+ className: `bailey-chat-panel${p ? ` ${p}` : ""}`,
1136
+ style: g !== void 0 || _ !== void 0 ? {
1137
+ height: g,
1138
+ width: _
1139
+ } : void 0,
1140
+ children: /* @__PURE__ */ h("div", {
1141
+ className: "bailey-chat-panel-inner",
1142
+ children: [
1143
+ /* @__PURE__ */ m("div", {
1144
+ className: "bailey-toolbar-row",
1145
+ children: !W && /* @__PURE__ */ m("button", {
1184
1146
  type: "button",
1185
1147
  onClick: N,
1186
- "aria-label": L.dismissErrorAriaLabel,
1187
- className: "bailey-dismiss-button",
1188
- children: "✕"
1189
- })]
1190
- })]
1191
- }),
1192
- !v && /* @__PURE__ */ d(Ee, {
1193
- events: T,
1194
- lastRequest: E,
1195
- onClear: M
1196
- }),
1197
- /* @__PURE__ */ f("form", {
1198
- onSubmit: (e) => {
1199
- e.preventDefault(), !(!F.trim() || D === "streaming") && (G(F), I(""));
1200
- },
1201
- className: "bailey-input-row",
1202
- children: [/* @__PURE__ */ d("input", {
1203
- type: "text",
1204
- placeholder: W,
1205
- "aria-label": W,
1206
- value: F,
1207
- onChange: (e) => I(e.target.value),
1208
- disabled: D === "streaming",
1209
- className: "bailey-input"
1210
- }), D === "streaming" ? /* @__PURE__ */ d(l.Provider, {
1211
- delayDuration: 200,
1212
- children: /* @__PURE__ */ f(l.Root, { children: [/* @__PURE__ */ d(l.Trigger, {
1213
- asChild: !0,
1214
- children: /* @__PURE__ */ d("button", {
1148
+ "aria-label": I.newChatAriaLabel,
1149
+ className: "bailey-new-chat-button",
1150
+ children: I.newChatButtonText
1151
+ })
1152
+ }),
1153
+ /* @__PURE__ */ h("div", {
1154
+ className: "bailey-chat-transcript",
1155
+ ref: V,
1156
+ children: [
1157
+ W && (i && i.length > 0 ? /* @__PURE__ */ h("div", {
1158
+ className: "bailey-suggestions",
1159
+ children: [/* @__PURE__ */ m("div", {
1160
+ className: "bailey-suggestions-title",
1161
+ children: I.suggestionsTitle
1162
+ }), i.map((e, t) => /* @__PURE__ */ h("button", {
1163
+ type: "button",
1164
+ onClick: () => K(e.value ?? e.label),
1165
+ className: "bailey-suggestion-card",
1166
+ children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(ke, { className: "bailey-suggestion-icon" })]
1167
+ }, `${e.label}-${t}`))]
1168
+ }) : /* @__PURE__ */ m("div", {
1169
+ className: "bailey-empty-state",
1170
+ children: I.emptyStateMessage
1171
+ })),
1172
+ w.map((e, t) => {
1173
+ let n = e.role === "assistant" && t === w.length - 1, r = D === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? he(T, e.createdAt) : [], a = i[i.length - 1];
1174
+ return /* @__PURE__ */ m("div", {
1175
+ className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1176
+ children: e.role === "user" ? /* @__PURE__ */ h("div", {
1177
+ className: "bailey-user-message",
1178
+ children: [/* @__PURE__ */ h("div", {
1179
+ className: "bailey-message-meta",
1180
+ children: [/* @__PURE__ */ m("span", {
1181
+ className: "bailey-message-meta-name",
1182
+ children: I.youLabel
1183
+ }), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: L(e.createdAt) })]
1184
+ }), /* @__PURE__ */ m("div", {
1185
+ className: "bailey-user-bubble",
1186
+ children: e.content
1187
+ })]
1188
+ }) : r ? /* @__PURE__ */ m("div", {
1189
+ className: "bailey-thinking-hint",
1190
+ children: U ?? I.thinkingHint
1191
+ }) : /* @__PURE__ */ h("div", {
1192
+ className: "bailey-assistant-message",
1193
+ children: [
1194
+ a && /* @__PURE__ */ h("div", {
1195
+ className: "bailey-activity-line",
1196
+ children: [/* @__PURE__ */ m("span", {
1197
+ className: "bailey-activity-icon",
1198
+ children: d?.(a.toolName) ?? /* @__PURE__ */ m(Me, {})
1199
+ }), /* @__PURE__ */ m("span", { children: a.text })]
1200
+ }),
1201
+ /* @__PURE__ */ m(Je, {
1202
+ content: e.content,
1203
+ components: te
1204
+ }),
1205
+ e.streaming && U && /* @__PURE__ */ m("div", {
1206
+ className: "bailey-streaming-hint",
1207
+ children: U
1208
+ }),
1209
+ !e.streaming && /* @__PURE__ */ h("div", {
1210
+ className: "bailey-message-actions",
1211
+ children: [/* @__PURE__ */ m(Pe, {
1212
+ markdown: e.content,
1213
+ ariaLabel: I.copyButtonAriaLabel,
1214
+ tooltipDefaultText: I.copyButtonTooltipDefault,
1215
+ tooltipCopiedText: I.copyButtonTooltipCopied
1216
+ }), y?.(e)]
1217
+ })
1218
+ ]
1219
+ })
1220
+ }, e.id);
1221
+ }),
1222
+ /* @__PURE__ */ m("div", { ref: B })
1223
+ ]
1224
+ }),
1225
+ O && /* @__PURE__ */ h("div", {
1226
+ className: "bailey-error-banner",
1227
+ role: "alert",
1228
+ children: [/* @__PURE__ */ m("span", { children: O }), /* @__PURE__ */ h("div", {
1229
+ className: "bailey-error-actions",
1230
+ children: [/* @__PURE__ */ m("button", {
1215
1231
  type: "button",
1216
1232
  onClick: A,
1217
- "aria-label": L.stopAriaLabel,
1218
- className: "bailey-stop-button",
1219
- children: /* @__PURE__ */ d(pe, { className: "bailey-stop-icon" })
1220
- })
1221
- }), /* @__PURE__ */ d(l.Portal, { children: /* @__PURE__ */ f(l.Content, {
1222
- side: "top",
1223
- className: "bailey-tooltip-content",
1224
- children: [L.stopButtonText, /* @__PURE__ */ d(l.Arrow, { className: "bailey-tooltip-arrow" })]
1225
- }) })] })
1226
- }) : /* @__PURE__ */ d("button", {
1227
- type: "submit",
1228
- "aria-label": L.sendAriaLabel,
1229
- disabled: !F.trim(),
1230
- className: "bailey-send-button",
1231
- children: /* @__PURE__ */ d(fe, { className: "bailey-send-icon" })
1232
- })]
1233
- }),
1234
- (U || p?.alwaysVisible) && p && /* @__PURE__ */ d("div", {
1235
- className: "bailey-privacy-note",
1236
- children: /* @__PURE__ */ d(s, {
1237
- remarkPlugins: Ae,
1238
- components: je,
1239
- skipHtml: !0,
1240
- children: p.markdown
1233
+ className: "bailey-retry-button",
1234
+ children: I.retryButtonText
1235
+ }), /* @__PURE__ */ m("button", {
1236
+ type: "button",
1237
+ onClick: M,
1238
+ "aria-label": I.dismissErrorAriaLabel,
1239
+ className: "bailey-dismiss-button",
1240
+ children: "✕"
1241
+ })]
1242
+ })]
1243
+ }),
1244
+ !v && /* @__PURE__ */ m(He, {
1245
+ events: T,
1246
+ lastRequest: E,
1247
+ onClear: j
1248
+ }),
1249
+ /* @__PURE__ */ h("form", {
1250
+ onSubmit: (e) => {
1251
+ e.preventDefault(), !(!P.trim() || D === "streaming") && (K(P), F(""));
1252
+ },
1253
+ className: "bailey-input-row",
1254
+ children: [/* @__PURE__ */ m("input", {
1255
+ type: "text",
1256
+ placeholder: G,
1257
+ "aria-label": G,
1258
+ value: P,
1259
+ onChange: (e) => F(e.target.value),
1260
+ disabled: D === "streaming",
1261
+ className: "bailey-input"
1262
+ }), D === "streaming" ? /* @__PURE__ */ m(f.Provider, {
1263
+ delayDuration: 200,
1264
+ children: /* @__PURE__ */ h(f.Root, { children: [/* @__PURE__ */ m(f.Trigger, {
1265
+ asChild: !0,
1266
+ children: /* @__PURE__ */ m("button", {
1267
+ type: "button",
1268
+ onClick: k,
1269
+ "aria-label": I.stopAriaLabel,
1270
+ className: "bailey-stop-button",
1271
+ children: /* @__PURE__ */ m(Oe, { className: "bailey-stop-icon" })
1272
+ })
1273
+ }), /* @__PURE__ */ m(f.Portal, {
1274
+ container: z instanceof ShadowRoot ? z : void 0,
1275
+ children: /* @__PURE__ */ h(f.Content, {
1276
+ side: "top",
1277
+ className: "bailey-tooltip-content",
1278
+ children: [I.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
1279
+ })
1280
+ })] })
1281
+ }) : /* @__PURE__ */ m("button", {
1282
+ type: "submit",
1283
+ "aria-label": I.sendAriaLabel,
1284
+ disabled: !P.trim(),
1285
+ className: "bailey-send-button",
1286
+ children: /* @__PURE__ */ m(De, { className: "bailey-send-icon" })
1287
+ })]
1288
+ }),
1289
+ (W || o?.alwaysVisible) && o && /* @__PURE__ */ m("div", {
1290
+ className: "bailey-privacy-note",
1291
+ children: /* @__PURE__ */ m(u, {
1292
+ remarkPlugins: Ke,
1293
+ components: qe,
1294
+ skipHtml: !0,
1295
+ children: o.markdown
1296
+ })
1241
1297
  })
1242
- })
1243
- ]
1298
+ ]
1299
+ })
1244
1300
  })
1245
1301
  });
1246
1302
  }
1247
1303
  //#endregion
1248
1304
  //#region src/index.ts
1249
- var Ie = "0.3.1-pre.2";
1305
+ var Qe = "0.3.1-pre.2";
1250
1306
  //#endregion
1251
- export { _e as ActivityIcon, me as ArrowUpRightIcon, Ie as BAILEYAI_CHAT_UI_VERSION, B as BAILEY_CHART_PROMPT_FRAGMENT, M as BAILEY_TABLE_GRID_ROW_THRESHOLD, Fe as BaileyChatPanel, Ee as BaileyTracePanel, ye as CopyMarkdownButton, fe as HeartIcon, ne as TRACE_KIND_LABEL, Z as createBaileyMarkdownComponents, b as extractPseudoToolCalls, R as extractTableData, oe as formatTraceGap, ae as formatTraceTime, ue as hasTraceFailure, e as isSafeMarkdownUrl, O as joinInstructions, te as parseBaileyChartSpec, S as parseSseFrames, j as resolveToolCall, z as shouldUseGrid, de as toActivityLines, se as toTraceRows, le as toTraceSegments, re as traceEventArgsDetail, X as traceEventHint, ie as traceEventOutputDetail, Y as traceEventRawDetail, J as traceEventSummary, q as traceEventToolName, ce as traceSummaryLine, D as useBaileyChat };
1307
+ export { Me as ActivityIcon, ke as ArrowUpRightIcon, Qe as BAILEYAI_CHAT_UI_VERSION, H as BAILEY_CHART_PROMPT_FRAGMENT, P as BAILEY_TABLE_GRID_ROW_THRESHOLD, Ze as BaileyChatPanel, He as BaileyTracePanel, Pe as CopyMarkdownButton, De as HeartIcon, ie as TRACE_KIND_LABEL, Ee as createBaileyMarkdownComponents, C as extractPseudoToolCalls, B as extractTableData, ue as formatTraceGap, le as formatTraceTime, me as hasTraceFailure, e as isSafeMarkdownUrl, A as joinInstructions, re as parseBaileyChartSpec, T as parseSseFrames, N as resolveToolCall, V as shouldUseGrid, he as toActivityLines, de as toTraceRows, pe as toTraceSegments, oe as traceEventArgsDetail, Y as traceEventHint, se as traceEventOutputDetail, ce as traceEventRawDetail, ae as traceEventSummary, J as traceEventToolName, fe as traceSummaryLine, k as useBaileyChat };