@icanbwell/baileyai-chat-ui 0.5.5 → 1.0.1

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