@icanbwell/baileyai-chat-ui 1.0.3 → 1.0.5

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.
@@ -5,23 +5,23 @@ import d from "remark-gfm";
5
5
  import * as f from "@radix-ui/react-tooltip";
6
6
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
7
7
  //#region src/utils/pseudoToolCalls.ts
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();
8
+ var g = "search_tools|call_tool|function_calls|function_result", _ = RegExp(`<(${g})>([\\s\\S]*?)<\\/\\1>`, "g"), v = RegExp(`<(?:${g})>[\\s\\S]*$`), y = /<name>([\s\S]*?)<\/name>/, b = /<arguments>([\s\S]*?)<\/arguments>/, x = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, S = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
+ function C(e) {
10
+ let t = y.exec(e)?.[1]?.trim() || "unknown_tool", n = b.exec(e)?.[1]?.trim();
11
11
  return n ? {
12
12
  name: t,
13
13
  args: n
14
14
  } : { name: t };
15
15
  }
16
- function S(e) {
16
+ function w(e) {
17
17
  let t = [];
18
- y.lastIndex = 0;
18
+ x.lastIndex = 0;
19
19
  let n;
20
- for (; (n = y.exec(e)) !== null;) {
20
+ for (; (n = x.exec(e)) !== null;) {
21
21
  let [, e, r] = n, i = {};
22
- b.lastIndex = 0;
22
+ S.lastIndex = 0;
23
23
  let a;
24
- for (; (a = b.exec(r)) !== null;) i[a[1]] = a[2].trim();
24
+ for (; (a = S.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,25 +30,25 @@ function S(e) {
30
30
  }
31
31
  return t;
32
32
  }
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({
33
+ function T(e, t = {}) {
34
+ let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(_, (e, t, n) => (t === "call_tool" ? r.push(C(n)) : t === "search_tools" ? r.push({
35
35
  name: "search_tools",
36
- args: r.trim()
37
- }) : n === "function_calls" ? t.push(...S(r)) : t.push({
36
+ args: n.trim()
37
+ }) : t === "function_calls" ? r.push(...w(n)) : r.push({
38
38
  name: "function_result",
39
- args: r.trim()
40
- }), ""));
41
- return t.length === 0 ? {
42
- cleanedText: n,
43
- matches: t
39
+ args: n.trim()
40
+ }), "")), a = n ? i.replace(v, "") : i;
41
+ return r.length === 0 && a === i ? {
42
+ cleanedText: i,
43
+ matches: r
44
44
  } : {
45
- cleanedText: n.replace(/\n{3,}/g, "\n\n"),
46
- matches: t
45
+ cleanedText: a.replace(/\n{3,}/g, "\n\n"),
46
+ matches: r
47
47
  };
48
48
  }
49
49
  //#endregion
50
50
  //#region src/logic/sse.ts
51
- function w(e) {
51
+ function E(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 w(e) {
62
62
  }
63
63
  return t || null;
64
64
  }
65
- function T(e) {
65
+ function D(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 T(e) {
87
87
  message: e
88
88
  });
89
89
  } else if (c?.type === "response.output_text.delta" && typeof c.delta == "string") {
90
- let e = w(c.delta);
90
+ let e = E(c.delta);
91
91
  e && r.push({
92
92
  type: "response.output_text.delta",
93
93
  delta: e
@@ -105,16 +105,16 @@ function T(e) {
105
105
  }
106
106
  //#endregion
107
107
  //#region src/logic/useBaileyChat.ts
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) => {
108
+ var O = 200, k = 15e4, A = () => 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 > 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([]);
111
+ return i ? `${r} ${i.length > O ? `${i.slice(0, O)}…` : i}` : r;
112
+ }, j = ({ transport: e, model: t, instructions: n, tools: i = [], toolChoice: o, firstUserMessagePrefix: s, onAssistantMessageComplete: u, idleTimeoutMs: d = k }) => {
113
+ let [f, p] = l([]), [m, h] = l([]), [g, _] = l(null), [v, y] = l("idle"), [b, x] = l(null), S = c(null), C = c(""), w = c(0), E = c([]);
114
114
  a(() => {
115
- k.current = f;
115
+ E.current = f;
116
116
  }, [f]);
117
- let A = c([]), j = c(/* @__PURE__ */ new Map()), M = c(/* @__PURE__ */ new Map()), N = c(null), P = r(() => {
117
+ let O = c([]), j = c(/* @__PURE__ */ new Map()), M = c(/* @__PURE__ */ new Map()), N = c(null), P = r(() => {
118
118
  N.current !== null && (clearTimeout(N.current), N.current = null);
119
119
  }, []), F = r((e) => {
120
120
  P(), N.current = setTimeout(() => {
@@ -135,12 +135,12 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
135
135
  emittedCount: 0
136
136
  };
137
137
  n.raw += t.delta;
138
- let { cleanedText: i, matches: a } = C(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
138
+ let { cleanedText: i, matches: a } = T(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
139
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 = E.current;
143
+ let e = Date.now(), t = w.current;
144
144
  s.forEach((n) => r({
145
145
  kind: "pseudo_tool_call",
146
146
  name: n.name,
@@ -154,7 +154,7 @@ var E = 200, D = 15e4, O = () => 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 = E.current, a = e.name || "unknown_tool";
157
+ let n = Date.now(), i = w.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,
@@ -174,44 +174,59 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
174
174
  }
175
175
  return !1;
176
176
  }
177
- return t.type === "task.progress" ? (r({
177
+ if (t.type === "task.progress") return r({
178
178
  kind: "progress",
179
179
  status: t.status,
180
180
  message: t.message,
181
181
  at: Date.now(),
182
- turnSentAt: E.current
183
- }), !0) : t.type === "response.output_text.done" || t.type === "response.created" || t.type === "response.completed" ? !1 : t.type === "info" ? (r({
182
+ turnSentAt: w.current
183
+ }), !0;
184
+ if (t.type === "response.output_text.done" || t.type === "response.created") return !1;
185
+ if (t.type === "response.completed") {
186
+ let t = j.current.get(e);
187
+ if (t) {
188
+ let { cleanedText: n } = T(t.raw, { hideOpenBlock: !1 }), r = n.trim();
189
+ r !== M.current.get(e) && (M.current.set(e, r), p((t) => t.map((t) => t.id === e ? {
190
+ ...t,
191
+ content: r
192
+ } : t)));
193
+ }
194
+ return !1;
195
+ }
196
+ return t.type === "info" ? (r({
184
197
  kind: "info",
185
198
  message: t.message,
186
199
  at: Date.now(),
187
- turnSentAt: E.current
200
+ turnSentAt: w.current
188
201
  }), !0) : (r({
189
202
  kind: "raw",
190
203
  eventType: t.type,
191
204
  raw: JSON.stringify(t),
192
205
  at: Date.now(),
193
- turnSentAt: E.current
206
+ turnSentAt: w.current
194
207
  }), !0);
195
208
  }, []), L = r(async (r) => {
196
209
  y("streaming"), x(null);
197
210
  let a = Date.now();
198
- E.current = a;
199
- let c = O(), l = {
211
+ w.current = a;
212
+ let c = A(), l = {
200
213
  id: c,
201
214
  role: "assistant",
202
215
  content: "",
203
216
  streaming: !0,
204
217
  createdAt: a
205
218
  };
206
- p((e) => [...e, l]), A.current = [...r, l];
219
+ p((e) => [...e, l]), O.current = [...r, l];
207
220
  let d = r.findIndex((e) => e.role === "user" && !e.hidden), f = r.map((e, t) => t === d && s ? {
208
221
  role: e.role,
209
222
  content: `${s}${e.content}`,
210
- hidden: e.hidden
223
+ hidden: e.hidden,
224
+ titleHint: e.titleHint
211
225
  } : {
212
226
  role: e.role,
213
227
  content: e.content,
214
- hidden: e.hidden
228
+ hidden: e.hidden,
229
+ titleHint: e.titleHint
215
230
  });
216
231
  _({
217
232
  model: t,
@@ -229,7 +244,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
229
244
  });
230
245
  let m = new AbortController();
231
246
  S.current = m, F(m);
232
- let g = "", v = null, b = !1, C = !1, w = [], D = (e, t) => {
247
+ let g = "", v = null, b = !1, C = !1, T = [], E = (e, t) => {
233
248
  y("error"), x(e);
234
249
  let n = {
235
250
  kind: "error",
@@ -238,7 +253,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
238
253
  turnSentAt: a,
239
254
  ...t
240
255
  };
241
- w.push(n), h((e) => [...e, n]);
256
+ T.push(n), h((e) => [...e, n]);
242
257
  }, k = (e, t) => {
243
258
  e.forEach((e) => {
244
259
  if (e.type === "error") {
@@ -249,10 +264,10 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
249
264
  at: Date.now(),
250
265
  turnSentAt: a
251
266
  };
252
- w.push(t), h((e) => [...e, t]);
267
+ T.push(t), h((e) => [...e, t]);
253
268
  return;
254
269
  }
255
- e.type === "response.output_text.delta" && e.delta && (C = !0), I(c, e, w) && (b = !0);
270
+ e.type === "response.output_text.delta" && e.delta && (C = !0), I(c, e, T) && (b = !0);
256
271
  }), t && p((e) => e.map((e) => e.id === c ? {
257
272
  ...e,
258
273
  streaming: !1
@@ -268,7 +283,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
268
283
  signal: m.signal,
269
284
  onChunk: (e) => {
270
285
  F(m), g += e;
271
- let { events: t, remainder: n, done: r } = T(g);
286
+ let { events: t, remainder: n, done: r } = D(g);
272
287
  g = n, k(t, r);
273
288
  let i = Date.now();
274
289
  _((e) => e && e.sentAt === a ? {
@@ -288,7 +303,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
288
303
  }
289
304
  });
290
305
  if (g.trim()) {
291
- let { events: e, done: t } = T(`${g}\n\n`);
306
+ let { events: e, done: t } = D(`${g}\n\n`);
292
307
  g = "", k(e, t);
293
308
  }
294
309
  if (v) {
@@ -296,18 +311,18 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
296
311
  return;
297
312
  }
298
313
  if (r === void 0 || r >= 400) {
299
- D(ee(r, s, l), {
314
+ E(ee(r, s, l), {
300
315
  httpStatus: r,
301
316
  rawBody: s || void 0
302
317
  });
303
318
  return;
304
319
  }
305
320
  if (!b) {
306
- D("Bailey returned an empty response.");
321
+ E("Bailey returned an empty response.");
307
322
  return;
308
323
  }
309
324
  if (!C) {
310
- D("Bailey ran some tools but didn't return an answer. Try asking again.");
325
+ E("Bailey ran some tools but didn't return an answer. Try asking again.");
311
326
  return;
312
327
  }
313
328
  y("idle");
@@ -320,25 +335,25 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
320
335
  role: "assistant",
321
336
  content: d,
322
337
  streaming: !1
323
- }, w);
338
+ }, T);
324
339
  } catch (e) {
325
340
  let t = e;
326
341
  if (t?.name === "TimeoutError") {
327
- D(t.message, { source: "client-timeout" });
342
+ E(t.message, { source: "client-timeout" });
328
343
  return;
329
344
  }
330
345
  if (t?.name === "AbortError") {
331
346
  y("idle");
332
347
  return;
333
348
  }
334
- D(t?.message || "Bailey request failed.");
349
+ E(t?.message || "Bailey request failed.");
335
350
  } finally {
336
351
  P();
337
352
  let e = M.current.get(c) ?? "";
338
353
  j.current.delete(c), M.current.delete(c), p((e) => e.flatMap((e) => e.id === c ? e.content ? [{
339
354
  ...e,
340
355
  streaming: !1
341
- }] : [] : [e])), A.current = A.current.flatMap((t) => t.id === c ? e ? [{
356
+ }] : [] : [e])), O.current = O.current.flatMap((t) => t.id === c ? e ? [{
342
357
  ...t,
343
358
  content: e,
344
359
  streaming: !1
@@ -356,7 +371,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
356
371
  F,
357
372
  P
358
373
  ]), R = r((e) => {
359
- k.current = e, p(e);
374
+ E.current = e, p(e);
360
375
  }, []);
361
376
  return {
362
377
  messages: f,
@@ -367,38 +382,39 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
367
382
  send: r((e) => {
368
383
  let t = e.trim();
369
384
  if (!t) return;
370
- w.current = t;
385
+ C.current = t;
371
386
  let n = {
372
- id: O(),
387
+ id: A(),
373
388
  role: "user",
374
389
  content: t,
375
390
  createdAt: Date.now()
376
- }, r = [...A.current, n];
377
- A.current = r, R([...k.current, n]), L(r);
391
+ }, r = [...O.current, n];
392
+ O.current = r, R([...E.current, n]), L(r);
378
393
  }, [L, R]),
379
- sendHidden: r((e) => {
394
+ sendHidden: r((e, t) => {
380
395
  if (v === "streaming") return;
381
- let t = e.trim();
382
- if (!t) return;
383
- w.current = t;
384
- let n = {
385
- id: O(),
396
+ let n = e.trim();
397
+ if (!n) return;
398
+ C.current = n;
399
+ let r = t?.trim(), i = {
400
+ id: A(),
386
401
  role: "user",
387
- content: t,
402
+ content: n,
388
403
  createdAt: Date.now(),
389
- hidden: !0
390
- }, r = [...A.current, n];
391
- A.current = r, L(r);
404
+ hidden: !0,
405
+ ...r ? { titleHint: r } : {}
406
+ }, a = [...O.current, i];
407
+ O.current = a, L(a);
392
408
  }, [L, v]),
393
409
  stop: r(() => {
394
410
  S.current?.abort();
395
411
  }, []),
396
412
  retryLast: r(() => {
397
- if (v === "streaming" || !w.current) return;
398
- let e = k.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
413
+ if (v === "streaming" || !C.current) return;
414
+ let e = E.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
399
415
  R(n);
400
- let r = A.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
401
- A.current = a, L(a);
416
+ let r = O.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
417
+ O.current = a, L(a);
402
418
  }, [
403
419
  L,
404
420
  R,
@@ -409,7 +425,7 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
409
425
  x(null), y((e) => e === "error" ? "idle" : e);
410
426
  }, []),
411
427
  newChat: r(() => {
412
- S.current?.abort(), R([]), A.current = [], h([]), _(null), y("idle"), x(null), w.current = "";
428
+ S.current?.abort(), R([]), O.current = [], h([]), _(null), y("idle"), x(null), C.current = "";
413
429
  }, [R]),
414
430
  loadMessages: r((e) => {
415
431
  S.current?.abort();
@@ -417,21 +433,21 @@ var E = 200, D = 15e4, O = () => typeof crypto < "u" && typeof crypto.randomUUID
417
433
  ...e,
418
434
  streaming: !1
419
435
  }));
420
- R(t.filter((e) => !e.hidden)), A.current = t, h([]), _(null), y("idle"), x(null), w.current = "";
436
+ R(t.filter((e) => !e.hidden)), O.current = t, h([]), _(null), y("idle"), x(null), C.current = "";
421
437
  }, [R])
422
438
  };
423
439
  };
424
440
  //#endregion
425
441
  //#region src/utils/prompt.ts
426
- function A(...e) {
442
+ function M(...e) {
427
443
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
428
444
  }
429
445
  //#endregion
430
446
  //#region src/utils/toolCalls.ts
431
- var j = "call_tool", M = "a tool";
432
- function N(e, t) {
447
+ var N = "call_tool", P = "a tool";
448
+ function F(e, t) {
433
449
  let n = {
434
- name: e === j ? M : e,
450
+ name: e === N ? P : e,
435
451
  args: null,
436
452
  viaCallTool: !1
437
453
  };
@@ -444,7 +460,7 @@ function N(e, t) {
444
460
  }
445
461
  if (typeof r != "object" || !r) return n;
446
462
  let i = r;
447
- if (e === j) {
463
+ if (e === N) {
448
464
  let e = typeof i.name == "string" ? i.name : void 0;
449
465
  if (!e) return n;
450
466
  let t = i.arguments;
@@ -462,32 +478,32 @@ function N(e, t) {
462
478
  }
463
479
  //#endregion
464
480
  //#region src/utils/table.ts
465
- var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(F).join(""), I = (e) => {
481
+ var I = 5, L = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(L).join(""), R = (e) => {
466
482
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
467
483
  for (let t of e.children ?? []) {
468
- let e = I(t);
484
+ let e = R(t);
469
485
  if (e) return e;
470
486
  }
471
- }, L = (e, t) => (e.children ?? []).find((e) => e.tagName === t), R = (e) => {
472
- let t = F(e), n = I(e);
487
+ }, z = (e, t) => (e.children ?? []).find((e) => e.tagName === t), B = (e) => {
488
+ let t = L(e), n = R(e);
473
489
  return n ? {
474
490
  text: t,
475
491
  href: n
476
492
  } : { text: t };
477
- }, z = (e) => (e.children ?? []).filter((e) => e.type === "element").map(R), B = (e) => {
493
+ }, V = (e) => (e.children ?? []).filter((e) => e.type === "element").map(B), H = (e) => {
478
494
  if (e.tagName !== "table") return null;
479
- let t = L(e, "thead"), n = t && L(t, "tr");
495
+ let t = z(e, "thead"), n = t && z(t, "tr");
480
496
  return {
481
- headers: n ? z(n).map((e) => e.text) : [],
482
- rows: (L(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(z)
497
+ headers: n ? V(n).map((e) => e.text) : [],
498
+ rows: (z(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(V)
483
499
  };
484
- }, 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 = [
500
+ }, U = (e) => e.length > 5, te = "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```", W = [
485
501
  "bar",
486
502
  "line",
487
503
  "pie",
488
504
  "doughnut",
489
505
  "scatter"
490
- ], U = 8, W = 50, G = 8, K = 500, ne = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", re = (e) => {
506
+ ], G = 8, K = 50, q = 8, ne = 500, re = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", ie = (e) => {
491
507
  let t;
492
508
  try {
493
509
  t = JSON.parse(e);
@@ -496,17 +512,17 @@ var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
496
512
  }
497
513
  if (typeof t != "object" || !t) return null;
498
514
  let n = t;
499
- if (typeof n.type != "string" || !te.includes(n.type)) return null;
515
+ if (typeof n.type != "string" || !W.includes(n.type)) return null;
500
516
  let r = n.type;
501
517
  if (n.title !== void 0 && typeof n.title != "string") return null;
502
518
  let i = n.title;
503
519
  if (typeof n.data != "object" || n.data === null) return null;
504
520
  let a = n.data;
505
- if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > U || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
521
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > G || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
506
522
  for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
507
523
  let o = a.datasets;
508
524
  if (r === "scatter") {
509
- for (let e of o) if (e.data.length < 1 || e.data.length > K || !e.data.every(ne)) return null;
525
+ for (let e of o) if (e.data.length < 1 || e.data.length > ne || !e.data.every(re)) return null;
510
526
  return {
511
527
  type: r,
512
528
  title: i,
@@ -514,7 +530,7 @@ var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
514
530
  };
515
531
  }
516
532
  if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
517
- let s = a.labels, c = r === "pie" || r === "doughnut" ? G : W;
533
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? q : K;
518
534
  if (s.length < 1 || s.length > c) return null;
519
535
  for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
520
536
  return {
@@ -525,7 +541,7 @@ var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
525
541
  datasets: o
526
542
  }
527
543
  };
528
- }, ie = {
544
+ }, ae = {
529
545
  tool_start: "Tool start",
530
546
  tool_end: "Tool end",
531
547
  pseudo_tool_call: "Narrated tool call",
@@ -534,13 +550,13 @@ var P = 5, F = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map
534
550
  error: "Error",
535
551
  raw: "Raw event"
536
552
  };
537
- function q(e) {
538
- return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : N(e.name, e.args);
553
+ function J(e) {
554
+ return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : F(e.name, e.args);
539
555
  }
540
- function J(e, t = q(e)) {
556
+ function Y(e, t = J(e)) {
541
557
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
542
558
  }
543
- function ae(e, t = q(e)) {
559
+ function oe(e, t = J(e)) {
544
560
  switch (e.kind) {
545
561
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
546
562
  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" : ""}`;
@@ -551,20 +567,20 @@ function ae(e, t = q(e)) {
551
567
  case "raw": return `Unrecognized event: ${e.eventType}`;
552
568
  }
553
569
  }
554
- function oe(e, t = q(e)) {
570
+ function se(e, t = J(e)) {
555
571
  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;
556
572
  }
557
- function se(e) {
573
+ function ce(e) {
558
574
  return e.kind === "tool_end" ? e.output ?? null : null;
559
575
  }
560
- function ce(e) {
576
+ function le(e) {
561
577
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
562
578
  }
563
- function Y(e) {
579
+ function X(e) {
564
580
  switch (e.kind) {
565
- case "tool_start": return `Calling ${N(e.name, e.args).name}...`;
581
+ case "tool_start": return `Calling ${F(e.name, e.args).name}...`;
566
582
  case "tool_end": {
567
- let t = N(e.name, e.args).name;
583
+ let t = F(e.name, e.args).name;
568
584
  return e.isError ? `${t} failed` : `${t} returned`;
569
585
  }
570
586
  case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
@@ -574,11 +590,11 @@ function Y(e) {
574
590
  case "raw": return `Unrecognized event: ${e.eventType}`;
575
591
  }
576
592
  }
577
- function le(e) {
593
+ function ue(e) {
578
594
  let t = new Date(e);
579
595
  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")}`;
580
596
  }
581
- function ue(e) {
597
+ function de(e) {
582
598
  if (e <= 0) return "+0ms";
583
599
  if (e < 1e3) return `+${Math.round(e)}ms`;
584
600
  let t = e / 1e3;
@@ -586,30 +602,30 @@ function ue(e) {
586
602
  let n = Math.floor(t / 60), r = Math.round(t % 60);
587
603
  return `+${n}m${String(r).padStart(2, "0")}s`;
588
604
  }
589
- function de(e) {
605
+ function fe(e) {
590
606
  return e.map((t, n) => {
591
- let r = q(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
607
+ let r = J(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
592
608
  return {
593
609
  key: `${t.at}-${n}`,
594
610
  kind: t.kind,
595
- toolName: J(t, r),
611
+ toolName: Y(t, r),
596
612
  isToolStart: t.kind === "tool_start",
597
613
  failed: t.kind === "tool_end" && t.isError === !0,
598
- time: le(t.at),
614
+ time: ue(t.at),
599
615
  gapMs: t.at - i,
600
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ie[t.kind],
601
- summary: ae(t, r),
602
- argsDetail: oe(t, r),
603
- outputDetail: se(t),
604
- rawDetail: ce(t)
616
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ae[t.kind],
617
+ summary: oe(t, r),
618
+ argsDetail: se(t, r),
619
+ outputDetail: ce(t),
620
+ rawDetail: le(t)
605
621
  };
606
622
  });
607
623
  }
608
- function fe(e) {
624
+ function pe(e) {
609
625
  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 = [];
610
626
  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(" · ");
611
627
  }
612
- function pe(e) {
628
+ function me(e) {
613
629
  let t = [];
614
630
  for (let n of e) {
615
631
  let e = t[t.length - 1];
@@ -628,57 +644,57 @@ function pe(e) {
628
644
  }
629
645
  return t;
630
646
  }
631
- function me(e) {
647
+ function he(e) {
632
648
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
633
649
  }
634
- function he(e, t) {
650
+ function ge(e, t) {
635
651
  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) => ({
636
652
  key: `${e.at}-${t}`,
637
- text: Y(e),
638
- toolName: J(e)
653
+ text: X(e),
654
+ toolName: Y(e)
639
655
  }));
640
656
  }
641
657
  //#endregion
642
658
  //#region src/styles.css?inline
643
- 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{";
644
- function be(e) {
645
- let t = e.match(new RegExp(ve, "g"))?.length ?? 0;
659
+ var _e = "/*! 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-100:oklch(96.7% .003 264.542);--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;align-items:center;gap:calc(var(--spacing) * 3);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-history-button{height:calc(var(--spacing) * 8);width:calc(var(--spacing) * 8);color:var(--color-gray-700);border-radius:2147483647px;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-button:hover{background-color:var(--color-gray-100)}}.bailey-history-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.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}", ve = t(void 0), ye = /:root\s*,\s*:host\s*\{/, be = ".bailey-chat-panel{";
660
+ function xe(e) {
661
+ let t = e.match(new RegExp(ye, "g"))?.length ?? 0;
646
662
  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.`);
647
- return e.replace(ve, ye);
663
+ return e.replace(ye, be);
648
664
  }
649
- var xe = be(ge), X = "data-source", Z = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
650
- function Se(e) {
665
+ var Se = xe(_e), Z = "data-source", Ce = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
666
+ function we(e) {
651
667
  let t = e.getRootNode();
652
668
  return t instanceof ShadowRoot ? t : document;
653
669
  }
654
- function Ce(e) {
670
+ function Te(e) {
655
671
  let t = e instanceof ShadowRoot ? e : document.head, n = Q.get(e) ?? 0;
656
- if (n === 0 && !t.querySelector(`style[${X}="${Z}"]`)) {
672
+ if (n === 0 && !t.querySelector(`style[${Z}="${Ce}"]`)) {
657
673
  let e = document.createElement("style");
658
- e.setAttribute(X, Z), e.textContent = xe, t.appendChild(e);
674
+ e.setAttribute(Z, Ce), e.textContent = Se, t.appendChild(e);
659
675
  }
660
676
  return Q.set(e, n + 1), () => {
661
677
  let n = (Q.get(e) ?? 1) - 1;
662
- n <= 0 ? (Q.delete(e), t.querySelector(`style[${X}="${Z}"]`)?.remove()) : Q.set(e, n);
678
+ n <= 0 ? (Q.delete(e), t.querySelector(`style[${Z}="${Ce}"]`)?.remove()) : Q.set(e, n);
663
679
  };
664
680
  }
665
- function we(e, t = !1) {
681
+ function Ee(e, t = !1) {
666
682
  let [n, r] = l(null);
667
683
  return o(() => {
668
684
  if (t) return;
669
685
  let n = e.current;
670
686
  if (!n) return;
671
- let i = Se(n);
672
- return r(i), Ce(i);
687
+ let i = we(n);
688
+ return r(i), Te(i);
673
689
  }, [t, e]), n;
674
690
  }
675
- function Te(e) {
676
- let t = i(_e), n = t !== void 0, r = we(e, n);
691
+ function De(e) {
692
+ let t = i(ve), n = t !== void 0, r = Ee(e, n);
677
693
  return n ? t : r;
678
694
  }
679
695
  //#endregion
680
696
  //#region src/ui/markdown.tsx
681
- function Ee({ renderTable: t, renderChart: n } = {}) {
697
+ function Oe({ renderTable: t, renderChart: n } = {}) {
682
698
  return {
683
699
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ m(p, { children: n }) : /* @__PURE__ */ m("a", {
684
700
  href: t,
@@ -687,8 +703,8 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
687
703
  children: n
688
704
  }),
689
705
  table: ({ node: n, children: r }) => {
690
- let i = n && B(n);
691
- if (i && V(i.rows) && t) {
706
+ let i = n && H(n);
707
+ if (i && U(i.rows) && t) {
692
708
  let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
693
709
  return /* @__PURE__ */ m(p, { children: t({
694
710
  headers: i.headers,
@@ -700,7 +716,7 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
700
716
  pre: ({ children: e }) => {
701
717
  let t = (Array.isArray(e) ? e[0] : e)?.props;
702
718
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
703
- let e = t?.children, r = re(Array.isArray(e) ? e.join("") : String(e ?? ""));
719
+ let e = t?.children, r = ie(Array.isArray(e) ? e.join("") : String(e ?? ""));
704
720
  if (r) return /* @__PURE__ */ m(p, { children: n(r) });
705
721
  }
706
722
  return /* @__PURE__ */ m("pre", { children: e });
@@ -709,7 +725,7 @@ function Ee({ renderTable: t, renderChart: n } = {}) {
709
725
  }
710
726
  //#endregion
711
727
  //#region src/ui/icons.tsx
712
- function De({ className: e }) {
728
+ function ke({ className: e }) {
713
729
  return /* @__PURE__ */ m("svg", {
714
730
  viewBox: "0 0 24 24",
715
731
  fill: "currentColor",
@@ -718,7 +734,7 @@ function De({ className: e }) {
718
734
  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" })
719
735
  });
720
736
  }
721
- function Oe({ className: e }) {
737
+ function Ae({ className: e }) {
722
738
  return /* @__PURE__ */ m("svg", {
723
739
  viewBox: "0 0 24 24",
724
740
  fill: "currentColor",
@@ -733,7 +749,7 @@ function Oe({ className: e }) {
733
749
  })
734
750
  });
735
751
  }
736
- function ke({ className: e }) {
752
+ function je({ className: e }) {
737
753
  return /* @__PURE__ */ h("svg", {
738
754
  viewBox: "0 0 24 24",
739
755
  fill: "none",
@@ -746,7 +762,7 @@ function ke({ className: e }) {
746
762
  children: [/* @__PURE__ */ m("path", { d: "M7 17 17 7" }), /* @__PURE__ */ m("path", { d: "M9 7h8v8" })]
747
763
  });
748
764
  }
749
- function Ae({ className: e }) {
765
+ function Me({ className: e }) {
750
766
  return /* @__PURE__ */ h("svg", {
751
767
  viewBox: "0 0 24 24",
752
768
  fill: "none",
@@ -765,7 +781,7 @@ function Ae({ className: e }) {
765
781
  }), /* @__PURE__ */ m("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
766
782
  });
767
783
  }
768
- function je({ className: e }) {
784
+ function Ne({ className: e }) {
769
785
  return /* @__PURE__ */ m("svg", {
770
786
  viewBox: "0 0 24 24",
771
787
  fill: "none",
@@ -778,7 +794,20 @@ function je({ className: e }) {
778
794
  children: /* @__PURE__ */ m("path", { d: "M5 12.5 9.5 17 19 7" })
779
795
  });
780
796
  }
781
- function Me({ className: e }) {
797
+ function Pe({ className: e }) {
798
+ return /* @__PURE__ */ m("svg", {
799
+ viewBox: "0 0 24 24",
800
+ fill: "none",
801
+ stroke: "currentColor",
802
+ strokeWidth: 2,
803
+ strokeLinecap: "round",
804
+ strokeLinejoin: "round",
805
+ className: e,
806
+ "aria-hidden": "true",
807
+ children: /* @__PURE__ */ m("path", { d: "m22.7 13.5-2-2-2 2M21 12a9 9 0 1 1-1.245-4.57M12 7v5l3 2" })
808
+ });
809
+ }
810
+ function Fe({ className: e }) {
782
811
  return /* @__PURE__ */ h("svg", {
783
812
  viewBox: "0 0 24 24",
784
813
  fill: "none",
@@ -797,9 +826,9 @@ function Me({ className: e }) {
797
826
  }
798
827
  //#endregion
799
828
  //#region src/ui/CopyMarkdownButton.tsx
800
- var Ne = 1500;
801
- function Pe({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
802
- let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = Te(g);
829
+ var Ie = 1500;
830
+ function Le({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
831
+ let [o, s] = l(!1), [u, d] = l(!1), p = c(null), g = c(null), _ = De(g);
803
832
  return a(() => () => {
804
833
  p.current !== null && clearTimeout(p.current);
805
834
  }, []), /* @__PURE__ */ m(f.Provider, {
@@ -818,11 +847,11 @@ function Pe({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
818
847
  } catch {
819
848
  return;
820
849
  }
821
- s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Ne);
850
+ s(!0), p.current !== null && clearTimeout(p.current), p.current = setTimeout(() => s(!1), Ie);
822
851
  },
823
852
  "aria-label": n,
824
853
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
825
- children: m(o ? je : Ae, { className: "bailey-copy-icon" })
854
+ children: m(o ? Ne : Me, { className: "bailey-copy-icon" })
826
855
  })
827
856
  }), /* @__PURE__ */ m(f.Portal, {
828
857
  container: _ instanceof ShadowRoot ? _ : void 0,
@@ -837,20 +866,20 @@ function Pe({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
837
866
  }
838
867
  //#endregion
839
868
  //#region src/ui/BaileyTracePanel.tsx
840
- async function Fe(e) {
869
+ async function Re(e) {
841
870
  try {
842
871
  await navigator.clipboard.writeText(e);
843
872
  } catch {}
844
873
  }
845
- function Ie({ text: e, label: t = "Copy" }) {
874
+ function ze({ text: e, label: t = "Copy" }) {
846
875
  return /* @__PURE__ */ m("button", {
847
876
  type: "button",
848
- onClick: () => Fe(e),
877
+ onClick: () => Re(e),
849
878
  className: "bailey-trace-copy-button",
850
879
  children: t
851
880
  });
852
881
  }
853
- function Le(e) {
882
+ function Be(e) {
854
883
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
855
884
  switch (e.kind) {
856
885
  case "tool_start": return "bailey-trace-chip bailey-trace-chip-info";
@@ -869,7 +898,7 @@ function $({ label: e, content: t, copyable: n }) {
869
898
  }),
870
899
  n && /* @__PURE__ */ m("div", {
871
900
  className: "bailey-trace-disclosure-actions",
872
- children: /* @__PURE__ */ m(Ie, { text: t })
901
+ children: /* @__PURE__ */ m(ze, { text: t })
873
902
  }),
874
903
  /* @__PURE__ */ m("pre", {
875
904
  className: "bailey-trace-disclosure-content",
@@ -878,7 +907,7 @@ function $({ label: e, content: t, copyable: n }) {
878
907
  ]
879
908
  });
880
909
  }
881
- function Re({ row: e }) {
910
+ function Ve({ row: e }) {
882
911
  return /* @__PURE__ */ h("div", {
883
912
  className: "bailey-trace-row",
884
913
  children: [
@@ -892,10 +921,10 @@ function Re({ row: e }) {
892
921
  /* @__PURE__ */ m("span", {
893
922
  className: "bailey-trace-row-gap",
894
923
  title: "Time since the previous event",
895
- children: ue(e.gapMs)
924
+ children: de(e.gapMs)
896
925
  }),
897
926
  /* @__PURE__ */ m("span", {
898
- className: Le(e),
927
+ className: Be(e),
899
928
  children: e.label
900
929
  }),
901
930
  /* @__PURE__ */ m("span", {
@@ -919,13 +948,13 @@ function Re({ row: e }) {
919
948
  ]
920
949
  });
921
950
  }
922
- function ze(e, t) {
951
+ function He(e, t) {
923
952
  if (e.chunkCount === 0) return "Streamed: no chunks received";
924
953
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
925
954
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
926
955
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
927
956
  }
928
- function Be({ request: e }) {
957
+ function Ue({ request: e }) {
929
958
  let t = s(() => JSON.stringify({
930
959
  model: e.model,
931
960
  instructions: e.systemPrompt,
@@ -949,7 +978,7 @@ function Be({ request: e }) {
949
978
  }),
950
979
  /* @__PURE__ */ m("span", {
951
980
  className: "bailey-trace-request-meta",
952
- children: ze(e.streamStats, e.sentAt)
981
+ children: He(e.streamStats, e.sentAt)
953
982
  }),
954
983
  /* @__PURE__ */ m($, {
955
984
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
@@ -974,14 +1003,14 @@ function Be({ request: e }) {
974
1003
  ]
975
1004
  });
976
1005
  }
977
- function Ve({ events: e, lastRequest: t, onClear: n }) {
978
- let r = s(() => de(e), [e]), i = s(() => pe(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
1006
+ function We({ events: e, lastRequest: t, onClear: n }) {
1007
+ let r = s(() => fe(e), [e]), i = s(() => me(r), [r]), a = s(() => JSON.stringify(e, null, 2), [e]);
979
1008
  return /* @__PURE__ */ h("div", {
980
1009
  className: "bailey-trace-body",
981
1010
  children: [
982
1011
  /* @__PURE__ */ h("div", {
983
1012
  className: "bailey-trace-actions-row",
984
- children: [e.length > 0 && /* @__PURE__ */ m(Ie, {
1013
+ children: [e.length > 0 && /* @__PURE__ */ m(ze, {
985
1014
  text: a,
986
1015
  label: "Copy trace as JSON"
987
1016
  }), /* @__PURE__ */ m("button", {
@@ -991,15 +1020,15 @@ function Ve({ events: e, lastRequest: t, onClear: n }) {
991
1020
  children: "Clear"
992
1021
  })]
993
1022
  }),
994
- t && /* @__PURE__ */ m(Be, { request: t }),
1023
+ t && /* @__PURE__ */ m(Ue, { request: t }),
995
1024
  /* @__PURE__ */ m("div", {
996
1025
  className: "bailey-trace-rows",
997
1026
  children: i.map((e, t) => {
998
- if (e.type === "single") return /* @__PURE__ */ m(Re, { row: e.row }, e.row.key);
1027
+ if (e.type === "single") return /* @__PURE__ */ m(Ve, { row: e.row }, e.row.key);
999
1028
  let n = e.rows.filter((e) => e.isToolStart).length;
1000
1029
  if (n <= 1) return /* @__PURE__ */ m("div", {
1001
1030
  className: "bailey-trace-rows",
1002
- children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
1031
+ children: e.rows.map((e) => /* @__PURE__ */ m(Ve, { row: e }, e.key))
1003
1032
  }, `group-${t}`);
1004
1033
  let r = e.rows.filter((e) => e.failed).length;
1005
1034
  return /* @__PURE__ */ h("details", {
@@ -1021,7 +1050,7 @@ function Ve({ events: e, lastRequest: t, onClear: n }) {
1021
1050
  ]
1022
1051
  }), /* @__PURE__ */ m("div", {
1023
1052
  className: "bailey-trace-rows",
1024
- children: e.rows.map((e) => /* @__PURE__ */ m(Re, { row: e }, e.key))
1053
+ children: e.rows.map((e) => /* @__PURE__ */ m(Ve, { row: e }, e.key))
1025
1054
  })]
1026
1055
  }, `group-${t}`);
1027
1056
  })
@@ -1029,8 +1058,8 @@ function Ve({ events: e, lastRequest: t, onClear: n }) {
1029
1058
  ]
1030
1059
  });
1031
1060
  }
1032
- function He({ events: e, lastRequest: t, onClear: n }) {
1033
- let [r, i] = l(!1), a = s(() => me(e), [e]), o = s(() => fe(e), [e]);
1061
+ function Ge({ events: e, lastRequest: t, onClear: n }) {
1062
+ let [r, i] = l(!1), a = s(() => he(e), [e]), o = s(() => pe(e), [e]);
1034
1063
  return e.length === 0 && !t ? null : /* @__PURE__ */ h("div", {
1035
1064
  className: "bailey-trace-panel",
1036
1065
  children: [/* @__PURE__ */ h("div", {
@@ -1051,7 +1080,7 @@ function He({ events: e, lastRequest: t, onClear: n }) {
1051
1080
  className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
1052
1081
  children: o
1053
1082
  })]
1054
- }), r && /* @__PURE__ */ m(Ve, {
1083
+ }), r && /* @__PURE__ */ m(We, {
1055
1084
  events: e,
1056
1085
  lastRequest: t,
1057
1086
  onClear: n
@@ -1060,9 +1089,10 @@ function He({ events: e, lastRequest: t, onClear: n }) {
1060
1089
  }
1061
1090
  //#endregion
1062
1091
  //#region src/ui/BaileyChatPanel.tsx
1063
- var Ue = "How can bailey AI help you today?", We = "Reply to bailey AI", Ge = {
1092
+ var Ke = "How can bailey AI help you today?", qe = "Reply to bailey AI", Je = {
1064
1093
  newChatButtonText: "New chat",
1065
1094
  newChatAriaLabel: "new chat",
1095
+ historyAriaLabel: "conversation history",
1066
1096
  suggestionsTitle: "Suggested for you",
1067
1097
  emptyStateMessage: "Ask Bailey a question to get started.",
1068
1098
  youLabel: "You",
@@ -1075,104 +1105,110 @@ var Ue = "How can bailey AI help you today?", We = "Reply to bailey AI", Ge = {
1075
1105
  copyButtonAriaLabel: "copy response as markdown",
1076
1106
  copyButtonTooltipDefault: "Copy as markdown",
1077
1107
  copyButtonTooltipCopied: "Copied!"
1078
- }, Ke = [d], qe = {
1079
- ...Ee(),
1108
+ }, Ye = [d], Xe = {
1109
+ ...Oe(),
1080
1110
  p: ({ children: e }) => /* @__PURE__ */ m(p, { children: e })
1081
- }, Je = n(function({ content: e, components: t }) {
1111
+ }, Ze = n(function({ content: e, components: t }) {
1082
1112
  return /* @__PURE__ */ m("div", {
1083
1113
  className: "bailey-markdown-content",
1084
1114
  children: /* @__PURE__ */ m(u, {
1085
- remarkPlugins: Ke,
1115
+ remarkPlugins: Ye,
1086
1116
  components: t,
1087
1117
  skipHtml: !0,
1088
1118
  children: e
1089
1119
  })
1090
1120
  });
1091
1121
  });
1092
- function Ye(e, t, n) {
1122
+ function Qe(e, t, n) {
1093
1123
  if (e !== "streaming") return;
1094
1124
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
1095
- if (r.length !== 0) return Y(r[r.length - 1]);
1125
+ if (r.length !== 0) return X(r[r.length - 1]);
1096
1126
  }
1097
- function Xe(e) {
1127
+ function $e(e) {
1098
1128
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
1099
1129
  hour: "numeric",
1100
1130
  minute: "2-digit"
1101
1131
  });
1102
1132
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
1103
1133
  }
1104
- 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 }) {
1105
- 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 = {
1106
- ...Ge,
1107
- ...S
1108
- }, L = C ?? Xe, R = c(null), z = we(R), B = c(null), V = c(null), H = c(!0), te = s(() => Ee({
1109
- renderTable: b,
1110
- renderChart: x
1111
- }), [b, x]), U = s(() => Ye(D, T, E), [
1112
- D,
1113
- T,
1114
- E
1115
- ]), W = w.length === 0, G = t ?? (W ? r ?? Ue : n);
1134
+ function et({ chat: e, placeholder: t, replyPlaceholder: n = qe, emptyPlaceholder: r, suggestions: i, onHistoryClick: o, privacyNote: d, resolveActivityIcon: p, className: g, height: _, width: v, hideDeveloperDetails: y = !1, renderMessageActions: b, renderTable: x, renderChart: S, labels: C, formatMessageTime: w }) {
1135
+ let { messages: T, traceEvents: E, lastRequest: D, status: O, error: k, send: A, stop: ee, retryLast: j, clearTrace: M, clearError: N, newChat: P } = e, [F, I] = l(""), L = {
1136
+ ...Je,
1137
+ ...C
1138
+ }, R = w ?? $e, z = c(null), B = Ee(z), V = c(null), H = c(null), U = c(!0), te = s(() => Oe({
1139
+ renderTable: x,
1140
+ renderChart: S
1141
+ }), [x, S]), W = s(() => Qe(O, E, D), [
1142
+ O,
1143
+ E,
1144
+ D
1145
+ ]), G = T.length === 0, K = t ?? (G ? r ?? Ke : n);
1116
1146
  a(() => {
1117
- let e = V.current;
1147
+ let e = H.current;
1118
1148
  if (!e) return;
1119
1149
  let t = () => {
1120
1150
  let t = e.scrollHeight - e.scrollTop - e.clientHeight;
1121
- H.current = t < 60;
1151
+ U.current = t < 60;
1122
1152
  };
1123
1153
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1124
1154
  }, []), a(() => {
1125
- H.current && B.current?.scrollIntoView({
1126
- behavior: D === "streaming" ? "auto" : "smooth",
1155
+ U.current && V.current?.scrollIntoView({
1156
+ behavior: O === "streaming" ? "auto" : "smooth",
1127
1157
  block: "nearest"
1128
1158
  });
1129
- }, [w, D]);
1130
- let K = (e) => {
1131
- H.current = !0, ee(e);
1159
+ }, [T, O]);
1160
+ let q = (e) => {
1161
+ U.current = !0, A(e);
1132
1162
  };
1133
- return /* @__PURE__ */ m(_e.Provider, {
1134
- value: z,
1163
+ return /* @__PURE__ */ m(ve.Provider, {
1164
+ value: B,
1135
1165
  children: /* @__PURE__ */ m("div", {
1136
- ref: R,
1137
- className: `bailey-chat-panel${p ? ` ${p}` : ""}`,
1138
- style: g !== void 0 || _ !== void 0 ? {
1139
- height: g,
1140
- width: _
1166
+ ref: z,
1167
+ className: `bailey-chat-panel${g ? ` ${g}` : ""}`,
1168
+ style: _ !== void 0 || v !== void 0 ? {
1169
+ height: _,
1170
+ width: v
1141
1171
  } : void 0,
1142
1172
  children: /* @__PURE__ */ h("div", {
1143
1173
  className: "bailey-chat-panel-inner",
1144
1174
  children: [
1145
- /* @__PURE__ */ m("div", {
1175
+ /* @__PURE__ */ h("div", {
1146
1176
  className: "bailey-toolbar-row",
1147
- children: !W && /* @__PURE__ */ m("button", {
1177
+ children: [!G && /* @__PURE__ */ m("button", {
1148
1178
  type: "button",
1149
- onClick: N,
1150
- "aria-label": I.newChatAriaLabel,
1179
+ onClick: P,
1180
+ "aria-label": L.newChatAriaLabel,
1151
1181
  className: "bailey-new-chat-button",
1152
- children: I.newChatButtonText
1153
- })
1182
+ children: L.newChatButtonText
1183
+ }), o && /* @__PURE__ */ m("button", {
1184
+ type: "button",
1185
+ onClick: o,
1186
+ "aria-label": L.historyAriaLabel,
1187
+ className: "bailey-history-button",
1188
+ children: /* @__PURE__ */ m(Pe, { className: "bailey-history-icon" })
1189
+ })]
1154
1190
  }),
1155
1191
  /* @__PURE__ */ h("div", {
1156
1192
  className: "bailey-chat-transcript",
1157
- ref: V,
1193
+ ref: H,
1158
1194
  children: [
1159
- W && (i && i.length > 0 ? /* @__PURE__ */ h("div", {
1195
+ G && (i && i.length > 0 ? /* @__PURE__ */ h("div", {
1160
1196
  className: "bailey-suggestions",
1161
1197
  children: [/* @__PURE__ */ m("div", {
1162
1198
  className: "bailey-suggestions-title",
1163
- children: I.suggestionsTitle
1199
+ children: L.suggestionsTitle
1164
1200
  }), i.map((e, t) => /* @__PURE__ */ h("button", {
1165
1201
  type: "button",
1166
- onClick: () => K(e.value ?? e.label),
1202
+ onClick: () => q(e.value ?? e.label),
1167
1203
  className: "bailey-suggestion-card",
1168
- children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(ke, { className: "bailey-suggestion-icon" })]
1204
+ children: [/* @__PURE__ */ m("span", { children: e.label }), /* @__PURE__ */ m(je, { className: "bailey-suggestion-icon" })]
1169
1205
  }, `${e.label}-${t}`))]
1170
1206
  }) : /* @__PURE__ */ m("div", {
1171
1207
  className: "bailey-empty-state",
1172
- children: I.emptyStateMessage
1208
+ children: L.emptyStateMessage
1173
1209
  })),
1174
- w.map((e, t) => {
1175
- 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];
1210
+ T.map((e, t) => {
1211
+ let n = e.role === "assistant" && t === T.length - 1, r = O === "streaming" && n && e.content === "", i = e.role === "assistant" && !r ? ge(E, e.createdAt) : [], a = i[i.length - 1];
1176
1212
  return /* @__PURE__ */ m("div", {
1177
1213
  className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1178
1214
  children: e.role === "user" ? /* @__PURE__ */ h("div", {
@@ -1181,15 +1217,15 @@ function Ze({ chat: e, placeholder: t, replyPlaceholder: n = We, emptyPlaceholde
1181
1217
  className: "bailey-message-meta",
1182
1218
  children: [/* @__PURE__ */ m("span", {
1183
1219
  className: "bailey-message-meta-name",
1184
- children: I.youLabel
1185
- }), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: L(e.createdAt) })]
1220
+ children: L.youLabel
1221
+ }), e.createdAt !== void 0 && /* @__PURE__ */ m("span", { children: R(e.createdAt) })]
1186
1222
  }), /* @__PURE__ */ m("div", {
1187
1223
  className: "bailey-user-bubble",
1188
1224
  children: e.content
1189
1225
  })]
1190
1226
  }) : r ? /* @__PURE__ */ m("div", {
1191
1227
  className: "bailey-thinking-hint",
1192
- children: U ?? I.thinkingHint
1228
+ children: W ?? L.thinkingHint
1193
1229
  }) : /* @__PURE__ */ h("div", {
1194
1230
  className: "bailey-assistant-message",
1195
1231
  children: [
@@ -1197,104 +1233,104 @@ function Ze({ chat: e, placeholder: t, replyPlaceholder: n = We, emptyPlaceholde
1197
1233
  className: "bailey-activity-line",
1198
1234
  children: [/* @__PURE__ */ m("span", {
1199
1235
  className: "bailey-activity-icon",
1200
- children: d?.(a.toolName) ?? /* @__PURE__ */ m(Me, {})
1236
+ children: p?.(a.toolName) ?? /* @__PURE__ */ m(Fe, {})
1201
1237
  }), /* @__PURE__ */ m("span", { children: a.text })]
1202
1238
  }),
1203
- /* @__PURE__ */ m(Je, {
1239
+ /* @__PURE__ */ m(Ze, {
1204
1240
  content: e.content,
1205
1241
  components: te
1206
1242
  }),
1207
- e.streaming && U && /* @__PURE__ */ m("div", {
1243
+ e.streaming && W && /* @__PURE__ */ m("div", {
1208
1244
  className: "bailey-streaming-hint",
1209
- children: U
1245
+ children: W
1210
1246
  }),
1211
1247
  !e.streaming && /* @__PURE__ */ h("div", {
1212
1248
  className: "bailey-message-actions",
1213
- children: [/* @__PURE__ */ m(Pe, {
1249
+ children: [/* @__PURE__ */ m(Le, {
1214
1250
  markdown: e.content,
1215
- ariaLabel: I.copyButtonAriaLabel,
1216
- tooltipDefaultText: I.copyButtonTooltipDefault,
1217
- tooltipCopiedText: I.copyButtonTooltipCopied
1218
- }), y?.(e)]
1251
+ ariaLabel: L.copyButtonAriaLabel,
1252
+ tooltipDefaultText: L.copyButtonTooltipDefault,
1253
+ tooltipCopiedText: L.copyButtonTooltipCopied
1254
+ }), b?.(e)]
1219
1255
  })
1220
1256
  ]
1221
1257
  })
1222
1258
  }, e.id);
1223
1259
  }),
1224
- /* @__PURE__ */ m("div", { ref: B })
1260
+ /* @__PURE__ */ m("div", { ref: V })
1225
1261
  ]
1226
1262
  }),
1227
- O && /* @__PURE__ */ h("div", {
1263
+ k && /* @__PURE__ */ h("div", {
1228
1264
  className: "bailey-error-banner",
1229
1265
  role: "alert",
1230
- children: [/* @__PURE__ */ m("span", { children: O }), /* @__PURE__ */ h("div", {
1266
+ children: [/* @__PURE__ */ m("span", { children: k }), /* @__PURE__ */ h("div", {
1231
1267
  className: "bailey-error-actions",
1232
1268
  children: [/* @__PURE__ */ m("button", {
1233
1269
  type: "button",
1234
- onClick: A,
1270
+ onClick: j,
1235
1271
  className: "bailey-retry-button",
1236
- children: I.retryButtonText
1272
+ children: L.retryButtonText
1237
1273
  }), /* @__PURE__ */ m("button", {
1238
1274
  type: "button",
1239
- onClick: M,
1240
- "aria-label": I.dismissErrorAriaLabel,
1275
+ onClick: N,
1276
+ "aria-label": L.dismissErrorAriaLabel,
1241
1277
  className: "bailey-dismiss-button",
1242
1278
  children: "✕"
1243
1279
  })]
1244
1280
  })]
1245
1281
  }),
1246
- !v && /* @__PURE__ */ m(He, {
1247
- events: T,
1248
- lastRequest: E,
1249
- onClear: j
1282
+ !y && /* @__PURE__ */ m(Ge, {
1283
+ events: E,
1284
+ lastRequest: D,
1285
+ onClear: M
1250
1286
  }),
1251
1287
  /* @__PURE__ */ h("form", {
1252
1288
  onSubmit: (e) => {
1253
- e.preventDefault(), !(!P.trim() || D === "streaming") && (K(P), F(""));
1289
+ e.preventDefault(), !(!F.trim() || O === "streaming") && (q(F), I(""));
1254
1290
  },
1255
1291
  className: "bailey-input-row",
1256
1292
  children: [/* @__PURE__ */ m("input", {
1257
1293
  type: "text",
1258
- placeholder: G,
1259
- "aria-label": G,
1260
- value: P,
1261
- onChange: (e) => F(e.target.value),
1262
- disabled: D === "streaming",
1294
+ placeholder: K,
1295
+ "aria-label": K,
1296
+ value: F,
1297
+ onChange: (e) => I(e.target.value),
1298
+ disabled: O === "streaming",
1263
1299
  className: "bailey-input"
1264
- }), D === "streaming" ? /* @__PURE__ */ m(f.Provider, {
1300
+ }), O === "streaming" ? /* @__PURE__ */ m(f.Provider, {
1265
1301
  delayDuration: 200,
1266
1302
  children: /* @__PURE__ */ h(f.Root, { children: [/* @__PURE__ */ m(f.Trigger, {
1267
1303
  asChild: !0,
1268
1304
  children: /* @__PURE__ */ m("button", {
1269
1305
  type: "button",
1270
- onClick: k,
1271
- "aria-label": I.stopAriaLabel,
1306
+ onClick: ee,
1307
+ "aria-label": L.stopAriaLabel,
1272
1308
  className: "bailey-stop-button",
1273
- children: /* @__PURE__ */ m(Oe, { className: "bailey-stop-icon" })
1309
+ children: /* @__PURE__ */ m(Ae, { className: "bailey-stop-icon" })
1274
1310
  })
1275
1311
  }), /* @__PURE__ */ m(f.Portal, {
1276
- container: z instanceof ShadowRoot ? z : void 0,
1312
+ container: B instanceof ShadowRoot ? B : void 0,
1277
1313
  children: /* @__PURE__ */ h(f.Content, {
1278
1314
  side: "top",
1279
1315
  className: "bailey-tooltip-content",
1280
- children: [I.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
1316
+ children: [L.stopButtonText, /* @__PURE__ */ m(f.Arrow, { className: "bailey-tooltip-arrow" })]
1281
1317
  })
1282
1318
  })] })
1283
1319
  }) : /* @__PURE__ */ m("button", {
1284
1320
  type: "submit",
1285
- "aria-label": I.sendAriaLabel,
1286
- disabled: !P.trim(),
1321
+ "aria-label": L.sendAriaLabel,
1322
+ disabled: !F.trim(),
1287
1323
  className: "bailey-send-button",
1288
- children: /* @__PURE__ */ m(De, { className: "bailey-send-icon" })
1324
+ children: /* @__PURE__ */ m(ke, { className: "bailey-send-icon" })
1289
1325
  })]
1290
1326
  }),
1291
- (W || o?.alwaysVisible) && o && /* @__PURE__ */ m("div", {
1327
+ (G || d?.alwaysVisible) && d && /* @__PURE__ */ m("div", {
1292
1328
  className: "bailey-privacy-note",
1293
1329
  children: /* @__PURE__ */ m(u, {
1294
- remarkPlugins: Ke,
1295
- components: qe,
1330
+ remarkPlugins: Ye,
1331
+ components: Xe,
1296
1332
  skipHtml: !0,
1297
- children: o.markdown
1333
+ children: d.markdown
1298
1334
  })
1299
1335
  })
1300
1336
  ]
@@ -1304,6 +1340,6 @@ function Ze({ chat: e, placeholder: t, replyPlaceholder: n = We, emptyPlaceholde
1304
1340
  }
1305
1341
  //#endregion
1306
1342
  //#region src/index.ts
1307
- var Qe = "0.3.1-pre.2";
1343
+ var tt = "0.3.1-pre.2";
1308
1344
  //#endregion
1309
- 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 };
1345
+ export { Fe as ActivityIcon, je as ArrowUpRightIcon, tt as BAILEYAI_CHAT_UI_VERSION, te as BAILEY_CHART_PROMPT_FRAGMENT, I as BAILEY_TABLE_GRID_ROW_THRESHOLD, et as BaileyChatPanel, Ge as BaileyTracePanel, Le as CopyMarkdownButton, ke as HeartIcon, ae as TRACE_KIND_LABEL, Oe as createBaileyMarkdownComponents, T as extractPseudoToolCalls, H as extractTableData, de as formatTraceGap, ue as formatTraceTime, he as hasTraceFailure, e as isSafeMarkdownUrl, M as joinInstructions, ie as parseBaileyChartSpec, D as parseSseFrames, F as resolveToolCall, U as shouldUseGrid, ge as toActivityLines, fe as toTraceRows, me as toTraceSegments, se as traceEventArgsDetail, X as traceEventHint, ce as traceEventOutputDetail, le as traceEventRawDetail, oe as traceEventSummary, Y as traceEventToolName, pe as traceSummaryLine, j as useBaileyChat };