@icanbwell/baileyai-chat-ui 1.0.16 → 1.0.18

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,12 +1,12 @@
1
1
  import { n as e, t } from "./safeMarkdownUrl-Bqv6Q4u1.js";
2
- import { Fragment as n, createContext as r, memo as i, useCallback as a, useContext as o, useEffect as s, useLayoutEffect as c, useMemo as l, useRef as u, useState as d } from "react";
3
- import f from "react-markdown";
4
- import p from "remark-gfm";
5
- import * as m from "@radix-ui/react-dropdown-menu";
6
- import * as h from "@radix-ui/react-tooltip";
7
- import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
2
+ import { Fragment as n, createContext as r, memo as i, useCallback as a, useContext as o, useEffect as s, useId as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f } from "react";
3
+ import p from "react-markdown";
4
+ import m from "remark-gfm";
5
+ import * as h from "@radix-ui/react-dropdown-menu";
6
+ import * as g from "@radix-ui/react-tooltip";
7
+ import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
8
8
  //#region src/utils/pseudoToolCalls.ts
9
- var y = "search_tools|call_tool|function_calls|function_result", b = RegExp(`<(${y})>([\\s\\S]*?)<\\/\\1>`, "g"), x = RegExp(`<(?:${y})>[\\s\\S]*$`), S = /<name>([\s\S]*?)<\/name>/, C = /<arguments>([\s\S]*?)<\/arguments>/, w = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, T = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
9
+ var b = "search_tools|call_tool|function_calls|function_result", ee = RegExp(`<(${b})>([\\s\\S]*?)<\\/\\1>`, "g"), x = RegExp(`<(?:${b})>[\\s\\S]*$`), S = /<name>([\s\S]*?)<\/name>/, C = /<arguments>([\s\S]*?)<\/arguments>/, w = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, T = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
10
10
  function E(e) {
11
11
  let t = S.exec(e)?.[1]?.trim() || "unknown_tool", n = C.exec(e)?.[1]?.trim();
12
12
  return n ? {
@@ -32,7 +32,7 @@ function D(e) {
32
32
  return t;
33
33
  }
34
34
  function O(e, t = {}) {
35
- let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(b, (e, t, n) => (t === "call_tool" ? r.push(E(n)) : t === "search_tools" ? r.push({
35
+ let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(ee, (e, t, n) => (t === "call_tool" ? r.push(E(n)) : t === "search_tools" ? r.push({
36
36
  name: "search_tools",
37
37
  args: n.trim()
38
38
  }) : t === "function_calls" ? r.push(...D(n)) : r.push({
@@ -105,44 +105,219 @@ function A(e) {
105
105
  };
106
106
  }
107
107
  //#endregion
108
+ //#region src/utils/mapTranscript.ts
109
+ var j = {
110
+ inaccurate: !0,
111
+ unhelpful: !0,
112
+ unsafe: !0,
113
+ too_long: !0,
114
+ other: !0
115
+ }, M = (e) => Object.hasOwn(j, e) ? e : "other";
116
+ function N(e) {
117
+ if (!e || e.rating !== "up" && e.rating !== "down") return;
118
+ let t = (e.reasonCodes ?? []).map(M);
119
+ return {
120
+ rating: e.rating,
121
+ ...t.length > 0 ? { reasonCodes: t } : {},
122
+ ...e.comment ? { comment: e.comment } : {}
123
+ };
124
+ }
125
+ function te(e) {
126
+ let t = [];
127
+ return e.messages.forEach((e, n) => {
128
+ if (e.hidden || e.role !== "user" && e.role !== "assistant") return;
129
+ let r = Date.parse(e.createdAt), i = Number.isNaN(r) ? void 0 : r, a = e.messageId || `loaded-${n}-${e.role}-${i ?? 0}`, o = e.role === "assistant" ? N(e.feedback) : void 0;
130
+ t.push({
131
+ id: a,
132
+ role: e.role,
133
+ content: e.content,
134
+ streaming: !1,
135
+ ...i === void 0 ? {} : { createdAt: i },
136
+ ...e.role === "assistant" && e.messageId ? { serverMessageId: e.messageId } : {},
137
+ ...o ? { feedback: o } : {}
138
+ });
139
+ }), t;
140
+ }
141
+ var P = (e) => e.serverMessageId ?? e.id;
142
+ function ne(e) {
143
+ let t = new Set(e.current.map(P)), n = e.earlier.filter((e) => !t.has(P(e)));
144
+ return n.length === 0 ? e.current : [...n, ...e.current];
145
+ }
146
+ //#endregion
147
+ //#region src/logic/conversationId.ts
148
+ function re(e) {
149
+ let t = e.sub.trim();
150
+ if (!t) return !1;
151
+ let n = `${t}:`;
152
+ return e.conversationId.startsWith(n) && e.conversationId.length > n.length;
153
+ }
154
+ //#endregion
155
+ //#region src/logic/conversationStorage.ts
156
+ var ie = "baileyai-chat-ui:conversation";
157
+ function ae() {
158
+ return {
159
+ get: (e) => window.sessionStorage.getItem(e),
160
+ set: (e, t) => window.sessionStorage.setItem(e, t),
161
+ remove: (e) => window.sessionStorage.removeItem(e)
162
+ };
163
+ }
164
+ function F() {
165
+ let e = /* @__PURE__ */ new Map();
166
+ return {
167
+ get: (t) => e.get(t) ?? null,
168
+ set: (t, n) => void e.set(t, n),
169
+ remove: (t) => void e.delete(t)
170
+ };
171
+ }
172
+ //#endregion
108
173
  //#region src/logic/useBaileyChat.ts
109
- var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ee = (e, t, n) => {
174
+ var I = 200, oe = 100, L = 15e4, se = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, ce = (e, t, n) => {
110
175
  if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
111
176
  let r = `Bailey request failed (status ${e ?? "network error"}).`, i = (n || t || "").trim();
112
- return i ? `${r} ${i.length > j ? `${i.slice(0, j)}…` : i}` : r;
113
- }, P = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i, firstUserMessagePrefix: o, onAssistantMessageComplete: c, idleTimeoutMs: l = M }) => {
114
- let [f, p] = d([]), [m, h] = d([]), [g, _] = d(null), [v, y] = d("idle"), [b, x] = d(null), S = u(null), C = u(""), w = u(0), T = u([]);
177
+ return i ? `${r} ${i.length > I ? `${i.slice(0, I)}…` : i}` : r;
178
+ };
179
+ function le(e, t, n) {
180
+ if (e) try {
181
+ return e.get(t) || void 0;
182
+ } catch (e) {
183
+ n(e, "read");
184
+ return;
185
+ }
186
+ }
187
+ function ue(e, t) {
188
+ t.signal.aborted || typeof e != "string" || (t.historyStatus = e);
189
+ }
190
+ function de(e, t, n, r) {
191
+ try {
192
+ e?.set(t, n);
193
+ } catch (e) {
194
+ r(e, "write");
195
+ }
196
+ }
197
+ function R(e, t, n) {
198
+ try {
199
+ e?.remove(t);
200
+ } catch (e) {
201
+ n(e, "remove");
202
+ }
203
+ }
204
+ var z = (e, t) => t ? `${e}:${t}` : e;
205
+ function fe(e) {
206
+ let { seed: t, sub: n, storage: r, key: i, report: a } = e;
207
+ if (!n) return t || le(r, i, a);
208
+ if (t && re({
209
+ conversationId: t,
210
+ sub: n
211
+ })) return t;
212
+ let o = le(r, i, a);
213
+ if (o) {
214
+ if (re({
215
+ conversationId: o,
216
+ sub: n
217
+ })) return o;
218
+ R(r, i, a);
219
+ }
220
+ }
221
+ var B = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i, firstUserMessagePrefix: o, onAssistantMessageComplete: c, idleTimeoutMs: l = L, client: p, conversationId: m, sub: h, storage: g, storageKey: _ = ie, sendFullTranscript: v = !1, onStorageError: y, onContextLoss: b }) => {
222
+ let [ee, x] = f([]), [S, C] = f([]), [w, T] = f(null), [E, D] = f("idle"), [k, j] = f(null), M = h !== void 0 && h.trim() === "", N = M ? void 0 : h?.trim() || void 0, P = u(() => ae(), []), F = M ? null : g === void 0 ? P : g || null, I = d(y), le = d(b);
223
+ s(() => {
224
+ I.current = y, le.current = b;
225
+ }, [y, b]);
226
+ let B = a((e, t) => {
227
+ try {
228
+ I.current?.(e, t);
229
+ } catch {}
230
+ }, []), V = (e) => fe({
231
+ seed: m,
232
+ sub: N,
233
+ storage: F,
234
+ key: z(_, N),
235
+ report: e
236
+ }), [H] = f(() => {
237
+ let e = [];
238
+ return {
239
+ id: V((t, n) => void e.push({
240
+ error: t,
241
+ operation: n
242
+ })),
243
+ errors: e
244
+ };
245
+ }), [pe, U] = f(H.id), [me, he] = f(H.errors.length > 0), W = a((e, t) => {
246
+ he(!0), B(e, t);
247
+ }, [B]);
248
+ s(() => {
249
+ H.errors.forEach(({ error: e, operation: t }) => B(e, t));
250
+ }, [H, B]), s(() => {
251
+ M && B(/* @__PURE__ */ Error("sub is blank"), "key");
252
+ }, [M, B]);
253
+ let G = d(pe), K = d({
254
+ storage: F,
255
+ key: z(_, N),
256
+ sub: N,
257
+ sendFullTranscript: v
258
+ });
259
+ s(() => {
260
+ K.current = {
261
+ storage: F,
262
+ key: z(_, N),
263
+ sub: N,
264
+ sendFullTranscript: v
265
+ };
266
+ }, [
267
+ F,
268
+ _,
269
+ N,
270
+ v
271
+ ]);
272
+ let ge = g === !1 ? "off" : me || M ? "degraded" : "ok", [_e, ve] = f(!1), [ye, q] = f("idle"), [be, xe] = f(!1), J = d(0), Y = d(null), X = d(null), Se = d(!1), Z = a(() => {
273
+ J.current += 1, Y.current?.abort(), Y.current = null, X.current = null, Se.current = !1, xe(!1), q("idle");
274
+ }, []), Ce = d(p);
275
+ s(() => {
276
+ Ce.current = p;
277
+ }, [p]), s(() => () => Y.current?.abort(), []);
278
+ let we = d(null), Te = d(""), Ee = d(0), De = d([]);
115
279
  s(() => {
116
- T.current = f;
117
- }, [f]);
118
- let E = u([]), D = u(/* @__PURE__ */ new Map()), k = u(/* @__PURE__ */ new Map()), j = u(null), P = a(() => {
119
- j.current !== null && (clearTimeout(j.current), j.current = null);
120
- }, []), F = a((e) => {
121
- P(), j.current = setTimeout(() => {
280
+ De.current = ee;
281
+ }, [ee]);
282
+ let Q = d([]), Oe = d(/* @__PURE__ */ new Map()), ke = d(/* @__PURE__ */ new Map()), Ae = d(null), $ = a(() => {
283
+ Ae.current !== null && (clearTimeout(Ae.current), Ae.current = null);
284
+ }, []), je = a((e) => {
285
+ $(), Ae.current = setTimeout(() => {
122
286
  e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
123
287
  }, l);
124
- }, [P, l]);
288
+ }, [$, l]);
125
289
  s(() => () => {
126
- S.current?.abort(), P();
127
- }, [P]);
128
- let I = a((e, t, n) => {
129
- let r = (e) => {
130
- n.push(e), h((t) => [...t, e]);
290
+ we.current?.abort(), $();
291
+ }, [$]);
292
+ let Me = a(({ reportedId: e, source: t, turn: n }) => {
293
+ if (n.signal.aborted || typeof e != "string" || !e) return;
294
+ if (t === "event") n.reportedId = e, n.reportedFromEvent = !0;
295
+ else if (!n.reportedFromEvent) n.reportedId = e;
296
+ else return;
297
+ if (n.heldId || e === G.current) return;
298
+ let { sub: r, storage: i, key: a } = K.current;
299
+ r && !re({
300
+ conversationId: e,
301
+ sub: r
302
+ }) || (G.current = e, U(e), de(i, a, e, W));
303
+ }, [W]), Ne = a((e, t, n, r) => {
304
+ let i = (e) => {
305
+ n.push(e), C((t) => [...t, e]);
131
306
  };
132
307
  if (t.type === "response.output_text.delta") {
133
308
  if (!t.delta) return !1;
134
- let n = D.current.get(e) ?? {
309
+ let n = Oe.current.get(e) ?? {
135
310
  raw: "",
136
311
  emittedCount: 0
137
312
  };
138
313
  n.raw += t.delta;
139
- let { cleanedText: i, matches: a } = O(n.raw), o = i.trim(), s = a.slice(n.emittedCount);
140
- if (n.emittedCount = a.length, D.current.set(e, n), k.current.set(e, o), p((t) => t.map((t) => t.id === e ? {
314
+ let { cleanedText: r, matches: a } = O(n.raw), o = r.trim(), s = a.slice(n.emittedCount);
315
+ if (n.emittedCount = a.length, Oe.current.set(e, n), ke.current.set(e, o), x((t) => t.map((t) => t.id === e ? {
141
316
  ...t,
142
317
  content: o
143
318
  } : t)), s.length > 0) {
144
- let e = Date.now(), t = w.current;
145
- s.forEach((n) => r({
319
+ let e = Date.now(), t = Ee.current;
320
+ s.forEach((n) => i({
146
321
  kind: "pseudo_tool_call",
147
322
  name: n.name,
148
323
  args: n.args,
@@ -154,7 +329,7 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
154
329
  }
155
330
  if (t.type === "response.output_item.added" || t.type === "response.output_item.done") {
156
331
  let n = t.item;
157
- if (n.type === "output_image") return n.image_url && p((t) => t.map((t) => t.id === e ? {
332
+ if (n.type === "output_image") return n.image_url && x((t) => t.map((t) => t.id === e ? {
158
333
  ...t,
159
334
  parts: [...t.parts ?? [], {
160
335
  type: "image",
@@ -162,13 +337,13 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
162
337
  }]
163
338
  } : t)), !0;
164
339
  if (n.type === "function_call" || n.type === "mcp_call") {
165
- let e = Date.now(), i = w.current, a = n.name || "unknown_tool";
166
- return r(t.type === "response.output_item.added" ? {
340
+ let e = Date.now(), r = Ee.current, a = n.name || "unknown_tool";
341
+ return i(t.type === "response.output_item.added" ? {
167
342
  kind: "tool_start",
168
343
  name: a,
169
344
  args: n.arguments,
170
345
  at: e,
171
- turnSentAt: i,
346
+ turnSentAt: r,
172
347
  callId: n.call_id,
173
348
  displayName: n.display_name
174
349
  } : {
@@ -176,7 +351,7 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
176
351
  name: a,
177
352
  args: n.arguments,
178
353
  at: e,
179
- turnSentAt: i,
354
+ turnSentAt: r,
180
355
  callId: n.call_id,
181
356
  displayName: n.display_name,
182
357
  output: n.output,
@@ -186,61 +361,76 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
186
361
  }), !0;
187
362
  }
188
363
  if (n.type === "llm_call") {
189
- let e = Date.now(), i = w.current;
190
- return r(t.type === "response.output_item.added" ? {
364
+ let e = Date.now(), r = Ee.current;
365
+ return i(t.type === "response.output_item.added" ? {
191
366
  kind: "llm_call_start",
192
367
  request: n.request ?? [],
193
368
  at: e,
194
- turnSentAt: i
369
+ turnSentAt: r
195
370
  } : {
196
371
  kind: "llm_call_end",
197
372
  response: n.output,
198
373
  at: e,
199
- turnSentAt: i
374
+ turnSentAt: r
200
375
  }), !0;
201
376
  }
202
377
  return !1;
203
378
  }
204
- if (t.type === "task.progress") return r({
379
+ if (t.type === "task.progress") return i({
205
380
  kind: "progress",
206
381
  status: t.status,
207
382
  message: t.message,
208
383
  at: Date.now(),
209
- turnSentAt: w.current
384
+ turnSentAt: Ee.current
210
385
  }), !0;
211
- if (t.type === "response.output_text.done" || t.type === "response.created") return !1;
386
+ if (t.type === "response.output_text.done") return !1;
387
+ if (t.type === "response.created") return Me({
388
+ reportedId: t.response?.conversation?.id,
389
+ source: "event",
390
+ turn: r
391
+ }), ue(t.response?.conversation?.history_status, r), !1;
212
392
  if (t.type === "response.completed") {
213
- let t = D.current.get(e);
214
- if (t) {
215
- let { cleanedText: n } = O(t.raw, { hideOpenBlock: !1 }), r = n.trim();
216
- r !== k.current.get(e) && (k.current.set(e, r), p((t) => t.map((t) => t.id === e ? {
393
+ Me({
394
+ reportedId: t.response?.conversation?.id,
395
+ source: "event",
396
+ turn: r
397
+ }), ue(t.response?.conversation?.history_status, r);
398
+ let n = typeof t.message_id == "string" && t.message_id ? t.message_id : void 0;
399
+ n && x((t) => t.map((t) => t.id === e ? {
400
+ ...t,
401
+ serverMessageId: n
402
+ } : t));
403
+ let i = Oe.current.get(e);
404
+ if (i) {
405
+ let { cleanedText: t } = O(i.raw, { hideOpenBlock: !1 }), n = t.trim();
406
+ n !== ke.current.get(e) && (ke.current.set(e, n), x((t) => t.map((t) => t.id === e ? {
217
407
  ...t,
218
- content: r
408
+ content: n
219
409
  } : t)));
220
410
  }
221
411
  return !1;
222
412
  }
223
- if (t.type === "info") return r({
413
+ if (t.type === "info") return i({
224
414
  kind: "info",
225
415
  message: t.message,
226
416
  at: Date.now(),
227
- turnSentAt: w.current
417
+ turnSentAt: Ee.current
228
418
  }), !0;
229
419
  if (t.type === "mcp_app") {
230
420
  let n = t.resourceUri;
231
- if (!n) return r({
421
+ if (!n) return i({
232
422
  kind: "raw",
233
423
  eventType: t.type,
234
424
  raw: JSON.stringify(t),
235
425
  at: Date.now(),
236
- turnSentAt: w.current
426
+ turnSentAt: Ee.current
237
427
  }), !0;
238
- let { html: i, title: a, csp: o, permissions: s, prefersBorder: c, displayMode: l } = t;
239
- return p((t) => t.map((t) => t.id === e ? {
428
+ let { html: r, title: a, csp: o, permissions: s, prefersBorder: c, displayMode: l } = t;
429
+ return x((t) => t.map((t) => t.id === e ? {
240
430
  ...t,
241
431
  parts: [...t.parts ?? [], {
242
432
  type: "mcp_app",
243
- html: i,
433
+ html: r,
244
434
  title: a,
245
435
  resourceUri: n,
246
436
  csp: o,
@@ -250,25 +440,25 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
250
440
  }]
251
441
  } : t)), !0;
252
442
  }
253
- return r({
443
+ return i({
254
444
  kind: "raw",
255
445
  eventType: t.type,
256
446
  raw: JSON.stringify(t),
257
447
  at: Date.now(),
258
- turnSentAt: w.current
448
+ turnSentAt: Ee.current
259
449
  }), !0;
260
- }, []), L = a(async (a) => {
261
- y("streaming"), x(null);
450
+ }, [Me]), Pe = a(async (a) => {
451
+ D("streaming"), j(null), ve(!1);
262
452
  let s = Date.now();
263
- w.current = s;
264
- let l = N(), u = {
453
+ Ee.current = s;
454
+ let l = se(), u = {
265
455
  id: l,
266
456
  role: "assistant",
267
457
  content: "",
268
458
  streaming: !0,
269
459
  createdAt: s
270
460
  };
271
- p((e) => [...e, u]), E.current = [...a, u];
461
+ x((e) => [...e, u]), Q.current = [...a, u];
272
462
  let d = a.findIndex((e) => e.role === "user" && !e.hidden), f = a.map((e, t) => t === d && o ? {
273
463
  role: e.role,
274
464
  content: `${o}${e.content}`,
@@ -279,11 +469,11 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
279
469
  content: e.content,
280
470
  hidden: e.hidden,
281
471
  titleHint: e.titleHint
282
- });
283
- _({
472
+ }), { sendFullTranscript: p } = K.current, m = p ? void 0 : G.current, h = m ? f.slice(-1) : f;
473
+ T({
284
474
  model: t,
285
475
  systemPrompt: n,
286
- messages: f,
476
+ messages: h,
287
477
  tools: r,
288
478
  toolChoice: i,
289
479
  stream: !0,
@@ -294,10 +484,13 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
294
484
  lastChunkAt: null
295
485
  }
296
486
  });
297
- let m = new AbortController();
298
- S.current = m, F(m);
299
- let g = "", v = null, b = !1, C = !1, T = [], O = (e, t) => {
300
- y("error"), x(e);
487
+ let g = new AbortController();
488
+ we.current = g, je(g);
489
+ let _ = {
490
+ signal: g.signal,
491
+ heldId: m
492
+ }, v = "", y = null, b = !1, ee = !1, S = !1, w = [], E = (e, t) => {
493
+ D("error"), j(e);
301
494
  let n = {
302
495
  kind: "error",
303
496
  message: e,
@@ -305,40 +498,46 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
305
498
  turnSentAt: s,
306
499
  ...t
307
500
  };
308
- T.push(n), h((e) => [...e, n]);
309
- }, j = (e, t) => {
501
+ w.push(n), C((e) => [...e, n]);
502
+ }, O = (e, t) => {
310
503
  e.forEach((e) => {
311
504
  if (e.type === "error") {
312
- v = e.message;
505
+ y = e.message;
313
506
  let t = {
314
507
  kind: "error",
315
508
  message: e.message,
316
509
  at: Date.now(),
317
510
  turnSentAt: s
318
511
  };
319
- T.push(t), h((e) => [...e, t]);
512
+ w.push(t), C((e) => [...e, t]);
320
513
  return;
321
514
  }
322
- e.type === "response.output_text.delta" && e.delta && (C = !0), I(l, e, T) && (b = !0);
323
- }), t && p((e) => e.map((e) => e.id === l ? {
515
+ e.type === "response.output_text.delta" && e.delta && (S = !0), Ne(l, e, w, _) && (ee = !0);
516
+ }), t && (b = !0, x((e) => e.map((e) => e.id === l ? {
324
517
  ...e,
325
518
  streaming: !1
326
- } : e));
519
+ } : e)));
327
520
  };
328
521
  try {
329
- let { status: a, text: o, errorMessage: u } = await e.streamChat({
522
+ let { status: a, text: o, errorMessage: u, interrupted: d } = await e.streamChat({
330
523
  model: t,
331
524
  instructions: n,
332
- input: f,
525
+ input: h,
333
526
  tools: r,
334
527
  toolChoice: i,
335
- signal: m.signal,
528
+ ...m ? { conversationId: m } : {},
529
+ onConversationId: (e) => Me({
530
+ reportedId: e,
531
+ source: "header",
532
+ turn: _
533
+ }),
534
+ signal: g.signal,
336
535
  onChunk: (e) => {
337
- F(m), g += e;
338
- let { events: t, remainder: n, done: r } = A(g);
339
- g = n, j(t, r);
536
+ je(g), v += e;
537
+ let { events: t, remainder: n, done: r } = A(v);
538
+ v = n, O(t, r);
340
539
  let i = Date.now();
341
- _((e) => e && e.sentAt === s ? {
540
+ T((e) => e && e.sentAt === s ? {
342
541
  ...e,
343
542
  streamStats: {
344
543
  chunkCount: e.streamStats.chunkCount + 1,
@@ -348,66 +547,87 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
348
547
  } : e);
349
548
  },
350
549
  onRequestId: (e) => {
351
- _((t) => t && t.sentAt === s ? {
550
+ T((t) => t && t.sentAt === s ? {
352
551
  ...t,
353
552
  requestId: e
354
553
  } : t);
554
+ },
555
+ onMessageId: (e) => {
556
+ typeof e == "string" && e && x((t) => t.map((t) => t.id === l ? {
557
+ ...t,
558
+ serverMessageId: e
559
+ } : t));
355
560
  }
356
561
  });
357
- if (g.trim()) {
358
- let { events: e, done: t } = A(`${g}\n\n`);
359
- g = "", j(e, t);
562
+ if (v.trim()) {
563
+ let { events: e, done: t } = A(`${v}\n\n`);
564
+ v = "", O(e, t);
565
+ }
566
+ if (y) {
567
+ D("error"), j(y);
568
+ return;
360
569
  }
361
- if (v) {
362
- y("error"), x(v);
570
+ if (d && !b) {
571
+ E("The connection was interrupted before the answer finished. Try again.");
363
572
  return;
364
573
  }
365
574
  if (a === void 0 || a >= 400) {
366
- O(ee(a, o, u), {
575
+ E(ce(a, o, u), {
367
576
  httpStatus: a,
368
577
  rawBody: o || void 0
369
578
  });
370
579
  return;
371
580
  }
372
- if (!b) {
373
- O("Bailey returned an empty response.");
581
+ let f = _.reportedId, p = f !== m, C = _.historyStatus === "failed" || _.historyStatus === "empty";
582
+ if (m && !_.signal.aborted && (p || C)) {
583
+ G.current = void 0, U(void 0), R(K.current.storage, K.current.key, W), Z(), ve(!0);
584
+ try {
585
+ le.current?.({
586
+ sentId: m,
587
+ ...f ? { reportedId: f } : {},
588
+ reason: p ? "id" : "history"
589
+ });
590
+ } catch {}
591
+ }
592
+ if (!ee) {
593
+ E("Bailey returned an empty response.");
374
594
  return;
375
595
  }
376
- if (!C) {
377
- O("Bailey ran some tools but didn't return an answer. Try asking again.");
596
+ if (!S) {
597
+ E("Bailey ran some tools but didn't return an answer. Try asking again.");
378
598
  return;
379
599
  }
380
- y("idle");
381
- let d = k.current.get(l) ?? "";
382
- _((e) => e && e.sentAt === s ? {
600
+ D("idle");
601
+ let k = ke.current.get(l) ?? "";
602
+ T((e) => e && e.sentAt === s ? {
383
603
  ...e,
384
- response: { content: d }
604
+ response: { content: k }
385
605
  } : e), c && await c({
386
606
  id: l,
387
607
  role: "assistant",
388
- content: d,
608
+ content: k,
389
609
  streaming: !1
390
- }, T);
610
+ }, w);
391
611
  } catch (e) {
392
612
  let t = e;
393
613
  if (t?.name === "TimeoutError") {
394
- O(t.message, { source: "client-timeout" });
614
+ E(t.message, { source: "client-timeout" });
395
615
  return;
396
616
  }
397
617
  if (t?.name === "AbortError") {
398
- y("idle");
618
+ D("idle");
399
619
  return;
400
620
  }
401
- O(t?.message || "Bailey request failed.");
621
+ E(t?.message || "Bailey request failed.");
402
622
  } finally {
403
- P();
404
- let e = k.current.get(l) ?? "";
405
- D.current.delete(l), k.current.delete(l);
406
- let t = T.some((e) => e.kind === "tool_start" || e.kind === "tool_end");
407
- p((e) => e.flatMap((e) => e.id === l ? e.content || t ? [{
623
+ $();
624
+ let e = ke.current.get(l) ?? "";
625
+ Oe.current.delete(l), ke.current.delete(l);
626
+ let t = w.some((e) => e.kind === "tool_start" || e.kind === "tool_end");
627
+ x((e) => e.flatMap((e) => e.id === l ? e.content || t ? [{
408
628
  ...e,
409
629
  streaming: !1
410
- }] : [] : [e])), E.current = E.current.flatMap((t) => t.id === l ? e ? [{
630
+ }] : [] : [e])), Q.current = Q.current.flatMap((t) => t.id === l ? e ? [{
411
631
  ...t,
412
632
  content: e,
413
633
  streaming: !1
@@ -421,87 +641,614 @@ var j = 200, M = 15e4, N = () => typeof crypto < "u" && typeof crypto.randomUUID
421
641
  i,
422
642
  o,
423
643
  c,
424
- I,
425
- F,
426
- P
427
- ]), R = a((e) => {
428
- T.current = e, p(e);
644
+ Ne,
645
+ Me,
646
+ je,
647
+ $,
648
+ W,
649
+ Z
650
+ ]), Fe = a((e) => {
651
+ De.current = e, x(e);
652
+ }, []), Ie = a((e) => {
653
+ let t = e.trim();
654
+ if (!t) return;
655
+ Te.current = t;
656
+ let n = {
657
+ id: se(),
658
+ role: "user",
659
+ content: t,
660
+ createdAt: Date.now()
661
+ }, r = [...Q.current, n];
662
+ Q.current = r, Fe([...De.current, n]), Pe(r);
663
+ }, [Pe, Fe]), Le = a((e, t) => {
664
+ if (E === "streaming") return;
665
+ let n = e.trim();
666
+ if (!n) return;
667
+ Te.current = n;
668
+ let r = t?.trim(), i = {
669
+ id: se(),
670
+ role: "user",
671
+ content: n,
672
+ createdAt: Date.now(),
673
+ hidden: !0,
674
+ ...r ? { titleHint: r } : {}
675
+ }, a = [...Q.current, i];
676
+ Q.current = a, Pe(a);
677
+ }, [Pe, E]), Re = a(() => {
678
+ we.current?.abort();
679
+ }, []), ze = a(() => {
680
+ if (E === "streaming" || !Te.current) return;
681
+ let e = De.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
682
+ Fe(n);
683
+ let r = Q.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
684
+ Q.current = a, Pe(a);
685
+ }, [
686
+ Pe,
687
+ Fe,
688
+ E
689
+ ]), Be = a(() => C([]), []), Ve = a(() => {
690
+ j(null), D((e) => e === "error" ? "idle" : e);
691
+ }, []), He = a(() => {
692
+ we.current?.abort(), Z(), ve(!1), Fe([]), Q.current = [], C([]), T(null), D("idle"), j(null), Te.current = "";
693
+ }, [Z, Fe]), Ue = a(() => {
694
+ He(), G.current = void 0, U(void 0), R(K.current.storage, K.current.key, W);
695
+ }, [He, W]), We = d(N);
696
+ s(() => {
697
+ let e = We.current;
698
+ if (e === N) return;
699
+ We.current = N, e !== void 0 && He();
700
+ let t = V(W);
701
+ G.current = t, U(t);
702
+ }, [N]);
703
+ let Ge = a((e) => {
704
+ we.current?.abort();
705
+ let t = e.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
706
+ ...e,
707
+ streaming: !1
708
+ }));
709
+ Fe(t.filter((e) => !e.hidden)), Q.current = t, C([]), T(null), D("idle"), j(null), Te.current = "";
710
+ }, [Fe]), Ke = a((e) => {
711
+ Z(), Ge(e);
712
+ }, [Z, Ge]), qe = a((e) => {
713
+ G.current = e, U(e), de(K.current.storage, K.current.key, e, W), ve(!1);
714
+ }, [W]), Je = a((e) => {
715
+ let t = e.hasMoreBefore && e.nextBeforeAbsoluteIndex !== null;
716
+ X.current = t ? e.nextBeforeAbsoluteIndex : null, xe(t);
429
717
  }, []);
430
718
  return {
431
- messages: f,
432
- traceEvents: m,
433
- lastRequest: g,
434
- status: v,
435
- error: b,
436
- send: a((e) => {
437
- let t = e.trim();
438
- if (!t) return;
439
- C.current = t;
440
- let n = {
441
- id: N(),
442
- role: "user",
443
- content: t,
444
- createdAt: Date.now()
445
- }, r = [...E.current, n];
446
- E.current = r, R([...T.current, n]), L(r);
447
- }, [L, R]),
448
- sendHidden: a((e, t) => {
449
- if (v === "streaming") return;
450
- let n = e.trim();
451
- if (!n) return;
452
- C.current = n;
453
- let r = t?.trim(), i = {
454
- id: N(),
455
- role: "user",
456
- content: n,
457
- createdAt: Date.now(),
458
- hidden: !0,
459
- ...r ? { titleHint: r } : {}
460
- }, a = [...E.current, i];
461
- E.current = a, L(a);
462
- }, [L, v]),
463
- stop: a(() => {
464
- S.current?.abort();
465
- }, []),
466
- retryLast: a(() => {
467
- if (v === "streaming" || !C.current) return;
468
- let e = T.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
469
- R(n);
470
- let r = E.current, i = r[r.length - 1], a = i && i.role === "assistant" ? r.slice(0, -1) : r;
471
- E.current = a, L(a);
719
+ conversationId: pe,
720
+ persistence: ge,
721
+ contextLost: _e,
722
+ messages: ee,
723
+ traceEvents: S,
724
+ lastRequest: w,
725
+ status: E,
726
+ error: k,
727
+ send: Ie,
728
+ sendHidden: Le,
729
+ stop: Re,
730
+ retryLast: ze,
731
+ clearTrace: Be,
732
+ clearError: Ve,
733
+ newChat: Ue,
734
+ loadMessages: Ke,
735
+ loadConversation: a(async ({ conversationId: e }) => {
736
+ let t = Ce.current, { sub: n } = K.current, r = !!e && (!n || re({
737
+ conversationId: e,
738
+ sub: n
739
+ }));
740
+ if (!t || !r) throw q("error"), Error(t ? "invalid conversation id" : "no client");
741
+ we.current?.abort(), Z();
742
+ let i = J.current, a = new AbortController();
743
+ Y.current = a, q("loading");
744
+ try {
745
+ let n = await t.getConversation({
746
+ conversationId: e,
747
+ limit: oe,
748
+ signal: a.signal
749
+ });
750
+ if (i !== J.current) return;
751
+ Ge(te({ messages: n.messages })), qe(e), Je(n), q("idle");
752
+ } catch (e) {
753
+ if (i !== J.current) return;
754
+ throw q("error"), e;
755
+ }
472
756
  }, [
473
- L,
474
- R,
475
- v
757
+ Je,
758
+ Z,
759
+ qe,
760
+ Ge
476
761
  ]),
477
- clearTrace: a(() => h([]), []),
478
- clearError: a(() => {
479
- x(null), y((e) => e === "error" ? "idle" : e);
480
- }, []),
481
- newChat: a(() => {
482
- S.current?.abort(), R([]), E.current = [], h([]), _(null), y("idle"), x(null), C.current = "";
483
- }, [R]),
484
- loadMessages: a((e) => {
485
- S.current?.abort();
486
- let t = e.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
487
- ...e,
488
- streaming: !1
489
- }));
490
- R(t.filter((e) => !e.hidden)), E.current = t, h([]), _(null), y("idle"), x(null), C.current = "";
491
- }, [R])
762
+ loadEarlier: a(async () => {
763
+ let e = Ce.current, t = G.current, n = X.current;
764
+ if (!e || !t || n === null || Se.current) return;
765
+ let r = J.current, i = new AbortController();
766
+ Y.current = i, Se.current = !0, q("loading");
767
+ try {
768
+ let a = await e.getConversation({
769
+ conversationId: t,
770
+ limit: oe,
771
+ beforeAbsoluteIndex: n,
772
+ signal: i.signal
773
+ });
774
+ if (r !== J.current) return;
775
+ let o = te({ messages: a.messages });
776
+ Q.current = ne({
777
+ current: Q.current,
778
+ earlier: o
779
+ }), x((e) => {
780
+ let t = ne({
781
+ current: e,
782
+ earlier: o
783
+ });
784
+ return De.current = t, t;
785
+ }), Je(a), q("idle");
786
+ } catch (e) {
787
+ if (r !== J.current) return;
788
+ throw q("error"), e;
789
+ } finally {
790
+ r === J.current && (Se.current = !1);
791
+ }
792
+ }, [Je]),
793
+ hasEarlier: be,
794
+ historyStatus: ye
492
795
  };
796
+ }, V = class extends Error {
797
+ status;
798
+ kind;
799
+ constructor(e) {
800
+ super(e.message ?? H(e), e.cause === void 0 ? void 0 : { cause: e.cause }), this.name = "BaileyApiError", this.status = e.status, this.kind = e.kind;
801
+ }
802
+ };
803
+ function H(e) {
804
+ switch (e.kind) {
805
+ case "http": return `Bailey request failed (status ${e.status})`;
806
+ case "timeout": return "Bailey request timed out";
807
+ case "aborted": return "Bailey request aborted";
808
+ case "invalid-response": return `Bailey returned an unreadable response (status ${e.status})`;
809
+ default: return "Bailey request failed (network error)";
810
+ }
811
+ }
812
+ var pe = class extends Error {
813
+ operation;
814
+ constructor(e) {
815
+ super(`Bailey cleanup failed (${e.operation})`), this.name = "BaileyCleanupError", this.operation = e.operation;
816
+ }
817
+ }, U = (e) => e instanceof V ? e : new V({
818
+ status: 0,
819
+ kind: "network"
820
+ });
821
+ function me(e) {
822
+ let { pageSize: t, enabled: n = !0 } = e, [r, i] = f([]), [o, c] = f(n ? "loading" : "idle"), [l, u] = f(null), [p, m] = f(null), h = d(e.client), g = d([]);
823
+ s(() => {
824
+ h.current = e.client, g.current = r;
825
+ });
826
+ let _ = d(null), v = d(null), y = a(async (e) => {
827
+ v.current?.abort();
828
+ let n = new AbortController();
829
+ v.current = n, c("loading");
830
+ try {
831
+ let r = await h.current.listConversations({
832
+ ...t === void 0 ? {} : { limit: t },
833
+ cursor: e === "append" ? _.current ?? void 0 : void 0,
834
+ signal: n.signal
835
+ });
836
+ if (n.signal.aborted) return;
837
+ i((t) => {
838
+ if (e === "replace") return r.conversations;
839
+ let n = new Set(t.map((e) => e.conversationId));
840
+ return [...t, ...r.conversations.filter((e) => !n.has(e.conversationId))];
841
+ }), _.current = r.nextCursor, m(r.nextCursor), u(null), c("idle");
842
+ } catch (e) {
843
+ if (n.signal.aborted) return;
844
+ u(U(e)), c("error");
845
+ }
846
+ }, [t]);
847
+ s(() => {
848
+ if (n) return y("replace"), () => v.current?.abort();
849
+ }, [n, y]);
850
+ let b = a(() => y("replace"), [y]), ee = a(async () => {
851
+ _.current !== null && await y("append");
852
+ }, [y]), x = a(async ({ conversationId: e }) => {
853
+ let t = g.current.findIndex((t) => t.conversationId === e), n = t === -1 ? void 0 : {
854
+ row: g.current[t],
855
+ index: t
856
+ };
857
+ i((t) => t.filter((t) => t.conversationId !== e));
858
+ try {
859
+ await h.current.deleteConversation({ conversationId: e });
860
+ } catch (t) {
861
+ if (!n) throw t;
862
+ let { row: r, index: a } = n;
863
+ throw i((t) => {
864
+ if (t.some((t) => t.conversationId === e)) return t;
865
+ let n = [...t];
866
+ return n.splice(Math.min(a, n.length), 0, r), n;
867
+ }), t;
868
+ }
869
+ }, []);
870
+ return {
871
+ conversations: r,
872
+ status: o,
873
+ error: l,
874
+ hasMore: p !== null,
875
+ refresh: b,
876
+ loadMore: ee,
877
+ remove: x
878
+ };
879
+ }
880
+ //#endregion
881
+ //#region src/client/routes.ts
882
+ function he(e) {
883
+ return e.replace(/\/+$/, "");
884
+ }
885
+ function W(e, t) {
886
+ let n = new URLSearchParams();
887
+ for (let [e, r] of Object.entries(t)) r !== void 0 && n.set(e, String(r));
888
+ let r = n.toString();
889
+ return r ? `${e}?${r}` : e;
890
+ }
891
+ var G = {
892
+ responses(e) {
893
+ return `${he(e)}/responses`;
894
+ },
895
+ conversations(e, t) {
896
+ return W(`${he(e)}/conversations`, {
897
+ limit: t.limit,
898
+ cursor: t.cursor
899
+ });
900
+ },
901
+ conversation(e, t, n) {
902
+ return W(`${he(e)}/conversations/${encodeURIComponent(t)}`, {
903
+ limit: n.limit,
904
+ before_absolute_index: n.beforeAbsoluteIndex
905
+ });
906
+ },
907
+ feedback(e, t, n) {
908
+ return `${he(e)}/conversations/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/feedback`;
909
+ }
493
910
  };
494
911
  //#endregion
912
+ //#region src/client/createBaileyClient.ts
913
+ function K(e) {
914
+ return {
915
+ status: void 0,
916
+ text: "",
917
+ errorMessage: "Request failed",
918
+ errorKind: "network",
919
+ ...e ? { errorCause: e.cause } : {}
920
+ };
921
+ }
922
+ var ge = 3e4, _e = 155e3, ve = "x-chat-id", ye = "header", q = "body", be = "x-request-id", xe = "x-conversation-id", J = "x-message-id", Y = (e) => e && typeof e == "object" ? e : {}, X = (e, t = "") => typeof e == "string" ? e : t, Se = (e, t = 0) => typeof e == "number" ? e : t;
923
+ function Z(e) {
924
+ let t = Y(e);
925
+ return {
926
+ conversationId: X(t.conversation_id),
927
+ title: typeof t.title == "string" ? t.title : null,
928
+ status: X(t.status),
929
+ messageCount: Se(t.message_count),
930
+ createdAt: X(t.created_at),
931
+ updatedAt: X(t.updated_at)
932
+ };
933
+ }
934
+ function Ce(e) {
935
+ if (!e || typeof e != "object") return null;
936
+ let t = Y(e);
937
+ return {
938
+ rating: X(t.rating),
939
+ reasonCodes: Array.isArray(t.reason_codes) ? t.reason_codes.filter((e) => typeof e == "string") : [],
940
+ comment: typeof t.comment == "string" ? t.comment : null,
941
+ ...typeof t.updated_at == "string" ? { updatedAt: t.updated_at } : {}
942
+ };
943
+ }
944
+ function we(e) {
945
+ let t = Y(e);
946
+ return {
947
+ messageId: X(t.message_id),
948
+ role: X(t.role),
949
+ content: X(t.content),
950
+ hidden: t.hidden === !0,
951
+ createdAt: X(t.created_at),
952
+ feedback: Ce(t.feedback)
953
+ };
954
+ }
955
+ function Te(e) {
956
+ let t = new AbortController(), n = !1, r = setTimeout(() => {
957
+ n = !0, t.abort();
958
+ }, e.timeoutMs), i = () => t.abort(e.caller?.reason);
959
+ return e.caller?.aborted ? i() : e.caller?.addEventListener("abort", i, { once: !0 }), {
960
+ signal: t.signal,
961
+ timedOut: () => n,
962
+ dispose: () => {
963
+ clearTimeout(r), e.caller?.removeEventListener("abort", i);
964
+ }
965
+ };
966
+ }
967
+ function Ee(e) {
968
+ return e.timedOut() ? new V({
969
+ status: 0,
970
+ kind: "timeout",
971
+ cause: e.signal.reason
972
+ }) : new V({
973
+ status: 0,
974
+ kind: "aborted"
975
+ });
976
+ }
977
+ function De(e) {
978
+ let { baseUrl: t, getHeaders: n, onAuthError: r } = e, i = e.requestTimeoutMs ?? ge, a = e.idleTimeoutMs ?? _e, o = e.conversationVia ?? ye;
979
+ if (o !== ye && o !== q) throw TypeError("createBaileyClient: conversationVia must be 'header' or 'body'");
980
+ let s = e.fetch ?? ((e, t) => globalThis.fetch(e, t));
981
+ function c(t) {
982
+ try {
983
+ e.onCleanupError?.(new pe({ operation: t }));
984
+ } catch {}
985
+ }
986
+ function l(e) {
987
+ e.kind === "http" && (e.status === 401 || e.status === 403) && r?.(e);
988
+ }
989
+ async function u(e) {
990
+ let t = Te({
991
+ caller: e.signal,
992
+ timeoutMs: i
993
+ });
994
+ try {
995
+ let r;
996
+ try {
997
+ r = {
998
+ Accept: "application/json",
999
+ ...await n()
1000
+ };
1001
+ } catch {
1002
+ throw new V({
1003
+ status: 0,
1004
+ kind: "network"
1005
+ });
1006
+ }
1007
+ if (t.signal.aborted) throw Ee(t);
1008
+ e.body !== void 0 && (r["Content-Type"] = "application/json");
1009
+ let i;
1010
+ try {
1011
+ i = await s(e.url, {
1012
+ method: e.method,
1013
+ headers: r,
1014
+ ...e.body === void 0 ? {} : { body: JSON.stringify(e.body) },
1015
+ signal: t.signal
1016
+ });
1017
+ } catch (e) {
1018
+ throw t.signal.aborted ? Ee(t) : new V({
1019
+ status: 0,
1020
+ kind: "network",
1021
+ cause: e
1022
+ });
1023
+ }
1024
+ if (!i.ok) throw i.body?.cancel().catch(() => c("cancel-response-body")), new V({
1025
+ status: i.status,
1026
+ kind: "http"
1027
+ });
1028
+ if (i.status === 204) {
1029
+ if (e.requireJsonBody) throw new V({
1030
+ status: 204,
1031
+ kind: "invalid-response"
1032
+ });
1033
+ return;
1034
+ }
1035
+ try {
1036
+ let t = await i.json();
1037
+ if (e.requireJsonBody && (typeof t != "object" || !t || Array.isArray(t))) throw new V({
1038
+ status: i.status,
1039
+ kind: "invalid-response"
1040
+ });
1041
+ return t;
1042
+ } catch (n) {
1043
+ if (n instanceof V) throw n;
1044
+ if (t.timedOut() || t.signal.aborted) throw Ee(t);
1045
+ if (e.requireJsonBody) throw new V({
1046
+ status: i.status,
1047
+ kind: "invalid-response"
1048
+ });
1049
+ return;
1050
+ }
1051
+ } catch (e) {
1052
+ throw e instanceof V && l(e), e;
1053
+ } finally {
1054
+ t.dispose();
1055
+ }
1056
+ }
1057
+ return {
1058
+ streamChat: async (e) => {
1059
+ let r = new AbortController(), i = () => r.abort(e.signal.reason);
1060
+ e.signal.aborted ? i() : e.signal.addEventListener("abort", i, { once: !0 });
1061
+ let u, d = () => {
1062
+ clearTimeout(u), u = setTimeout(() => {
1063
+ r.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
1064
+ }, a);
1065
+ };
1066
+ try {
1067
+ d();
1068
+ let i;
1069
+ try {
1070
+ i = {
1071
+ Accept: "text/event-stream",
1072
+ ...await n()
1073
+ };
1074
+ } catch {
1075
+ return K();
1076
+ }
1077
+ if (r.signal.aborted) throw r.signal.reason;
1078
+ i["Content-Type"] = "application/json", e.conversationId && o === ye && (i[ve] = e.conversationId);
1079
+ let a = e.input[e.input.length - 1], u = {
1080
+ ...a?.hidden === !0 ? { hidden: !0 } : {},
1081
+ ...a?.titleHint ? { title_hint: a.titleHint } : {}
1082
+ }, f = {
1083
+ model: e.model,
1084
+ instructions: e.instructions,
1085
+ input: e.input.map(({ role: e, content: t }) => ({
1086
+ role: e,
1087
+ content: t
1088
+ })),
1089
+ stream: !0,
1090
+ ...Object.keys(u).length > 0 ? { metadata: u } : {}
1091
+ };
1092
+ e.conversationId && o === q && (f.conversation = e.conversationId), e.tools.length > 0 && (f.tools = e.tools), e.toolChoice && (f.tool_choice = e.toolChoice);
1093
+ let p;
1094
+ try {
1095
+ p = await s(G.responses(t), {
1096
+ method: "POST",
1097
+ headers: i,
1098
+ body: JSON.stringify(f),
1099
+ signal: r.signal
1100
+ });
1101
+ } catch (e) {
1102
+ if (r.signal.aborted) throw r.signal.reason;
1103
+ return K({ cause: e });
1104
+ }
1105
+ let m = p.headers.get(be);
1106
+ m && e.onRequestId?.(m);
1107
+ let h = p.headers.get(J);
1108
+ if (h && e.onMessageId?.(h), !p.ok) {
1109
+ l(new V({
1110
+ status: p.status,
1111
+ kind: "http"
1112
+ }));
1113
+ let e = await p.text().catch(() => "");
1114
+ return {
1115
+ status: p.status,
1116
+ text: e
1117
+ };
1118
+ }
1119
+ let g = p.headers.get(xe);
1120
+ if (g && e.onConversationId?.(g), !p.body) return {
1121
+ status: p.status,
1122
+ text: ""
1123
+ };
1124
+ let _ = p.body.getReader(), v = new TextDecoder(), y = () => void _.cancel(r.signal.reason).catch(() => c("cancel-stream-reader"));
1125
+ r.signal.addEventListener("abort", y, { once: !0 });
1126
+ try {
1127
+ for (;;) {
1128
+ let { done: t, value: n } = await _.read();
1129
+ if (r.signal.aborted) throw r.signal.reason;
1130
+ if (t) {
1131
+ let t = v.decode();
1132
+ t && e.onChunk(t);
1133
+ break;
1134
+ }
1135
+ d(), e.onChunk(v.decode(n, { stream: !0 }));
1136
+ }
1137
+ } catch {
1138
+ if (r.signal.aborted) throw r.signal.reason;
1139
+ if (e.signal.aborted) throw e.signal.reason;
1140
+ return {
1141
+ status: p.status,
1142
+ text: "",
1143
+ errorMessage: "Stream interrupted",
1144
+ interrupted: !0
1145
+ };
1146
+ }
1147
+ return r.signal.removeEventListener("abort", y), {
1148
+ status: p.status,
1149
+ text: ""
1150
+ };
1151
+ } finally {
1152
+ clearTimeout(u), e.signal.removeEventListener("abort", i);
1153
+ }
1154
+ },
1155
+ async listConversations(e = {}) {
1156
+ let n = Y(await u({
1157
+ method: "GET",
1158
+ url: G.conversations(t, e),
1159
+ signal: e.signal,
1160
+ requireJsonBody: !0
1161
+ }));
1162
+ return {
1163
+ conversations: Array.isArray(n.conversations) ? n.conversations.map(Z).filter((e) => e.conversationId !== "") : [],
1164
+ nextCursor: typeof n.next_cursor == "string" ? n.next_cursor : null
1165
+ };
1166
+ },
1167
+ async getConversation(e) {
1168
+ let n = Y(await u({
1169
+ method: "GET",
1170
+ url: G.conversation(t, e.conversationId, e),
1171
+ signal: e.signal,
1172
+ requireJsonBody: !0
1173
+ }));
1174
+ if (!n.conversation || typeof n.conversation != "object") throw new V({
1175
+ status: 200,
1176
+ kind: "invalid-response"
1177
+ });
1178
+ return {
1179
+ conversation: Z(n.conversation),
1180
+ messages: Array.isArray(n.messages) ? n.messages.map(we) : [],
1181
+ hasMoreBefore: n.has_more_before === !0,
1182
+ nextBeforeAbsoluteIndex: typeof n.next_before_absolute_index == "number" ? n.next_before_absolute_index : null
1183
+ };
1184
+ },
1185
+ async deleteConversation(e) {
1186
+ await u({
1187
+ method: "DELETE",
1188
+ url: G.conversation(t, e.conversationId, {}),
1189
+ signal: e.signal
1190
+ });
1191
+ },
1192
+ async submitFeedback(e) {
1193
+ await u({
1194
+ method: "PUT",
1195
+ url: G.feedback(t, e.conversationId, e.messageId),
1196
+ body: {
1197
+ rating: e.rating,
1198
+ ...e.reasonCodes ? { reason_codes: e.reasonCodes } : {},
1199
+ ...e.comment === void 0 ? {} : { comment: e.comment }
1200
+ },
1201
+ signal: e.signal
1202
+ });
1203
+ },
1204
+ async clearFeedback(e) {
1205
+ await u({
1206
+ method: "DELETE",
1207
+ url: G.feedback(t, e.conversationId, e.messageId),
1208
+ signal: e.signal
1209
+ });
1210
+ }
1211
+ };
1212
+ }
1213
+ //#endregion
1214
+ //#region src/client/feedbackHandlers.ts
1215
+ function Q(e) {
1216
+ let { client: t, getConversationId: n } = e, r = () => {
1217
+ let e = n();
1218
+ if (!e) throw Error("no conversation id");
1219
+ return e;
1220
+ };
1221
+ return {
1222
+ async onSubmit(e) {
1223
+ let n = r();
1224
+ await t.submitFeedback({
1225
+ conversationId: n,
1226
+ messageId: e.messageId,
1227
+ rating: e.rating,
1228
+ ...e.reasonCodes ? { reasonCodes: e.reasonCodes } : {},
1229
+ ...e.comment ? { comment: e.comment } : {}
1230
+ });
1231
+ },
1232
+ async onClear({ messageId: e }) {
1233
+ let n = r();
1234
+ await t.clearFeedback({
1235
+ conversationId: n,
1236
+ messageId: e
1237
+ });
1238
+ }
1239
+ };
1240
+ }
1241
+ //#endregion
495
1242
  //#region src/utils/prompt.ts
496
- function F(...e) {
1243
+ function Oe(...e) {
497
1244
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
498
1245
  }
499
1246
  //#endregion
500
1247
  //#region src/utils/toolCalls.ts
501
- var I = "call_tool", L = "a tool";
502
- function R(e, t) {
1248
+ var ke = "call_tool", Ae = "a tool";
1249
+ function $(e, t) {
503
1250
  let n = {
504
- name: e === I ? L : e,
1251
+ name: e === ke ? Ae : e,
505
1252
  args: null,
506
1253
  viaCallTool: !1
507
1254
  };
@@ -514,7 +1261,7 @@ function R(e, t) {
514
1261
  }
515
1262
  if (typeof r != "object" || !r) return n;
516
1263
  let i = r;
517
- if (e === I) {
1264
+ if (e === ke) {
518
1265
  let e = typeof i.name == "string" ? i.name : void 0;
519
1266
  if (!e) return n;
520
1267
  let t = i.arguments;
@@ -532,32 +1279,32 @@ function R(e, t) {
532
1279
  }
533
1280
  //#endregion
534
1281
  //#region src/utils/table.ts
535
- var te = 5, z = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(z).join(""), ne = (e) => {
1282
+ var je = 5, Me = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(Me).join(""), Ne = (e) => {
536
1283
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
537
1284
  for (let t of e.children ?? []) {
538
- let e = ne(t);
1285
+ let e = Ne(t);
539
1286
  if (e) return e;
540
1287
  }
541
- }, B = (e, t) => (e.children ?? []).find((e) => e.tagName === t), V = (e) => {
542
- let t = z(e), n = ne(e);
1288
+ }, Pe = (e, t) => (e.children ?? []).find((e) => e.tagName === t), Fe = (e) => {
1289
+ let t = Me(e), n = Ne(e);
543
1290
  return n ? {
544
1291
  text: t,
545
1292
  href: n
546
1293
  } : { text: t };
547
- }, H = (e) => (e.children ?? []).filter((e) => e.type === "element").map(V), U = (e) => {
1294
+ }, Ie = (e) => (e.children ?? []).filter((e) => e.type === "element").map(Fe), Le = (e) => {
548
1295
  if (e.tagName !== "table") return null;
549
- let t = B(e, "thead"), n = t && B(t, "tr");
1296
+ let t = Pe(e, "thead"), n = t && Pe(t, "tr");
550
1297
  return {
551
- headers: n ? H(n).map((e) => e.text) : [],
552
- rows: (B(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(H)
1298
+ headers: n ? Ie(n).map((e) => e.text) : [],
1299
+ rows: (Pe(e, "tbody")?.children ?? []).filter((e) => e.tagName === "tr").map(Ie)
553
1300
  };
554
- }, W = (e) => e.length > 5, re = "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```", G = [
1301
+ }, Re = (e) => e.length > 5, ze = "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```", Be = [
555
1302
  "bar",
556
1303
  "line",
557
1304
  "pie",
558
1305
  "doughnut",
559
1306
  "scatter"
560
- ], ie = 8, K = 50, ae = 8, oe = 500, se = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", q = (e) => {
1307
+ ], Ve = 8, He = 50, Ue = 8, We = 500, Ge = (e) => typeof e == "object" && !!e && typeof e.x == "number" && typeof e.y == "number", Ke = (e) => {
561
1308
  let t;
562
1309
  try {
563
1310
  t = JSON.parse(e);
@@ -566,17 +1313,17 @@ var te = 5, z = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).ma
566
1313
  }
567
1314
  if (typeof t != "object" || !t) return null;
568
1315
  let n = t;
569
- if (typeof n.type != "string" || !G.includes(n.type)) return null;
1316
+ if (typeof n.type != "string" || !Be.includes(n.type)) return null;
570
1317
  let r = n.type;
571
1318
  if (n.title !== void 0 && typeof n.title != "string") return null;
572
1319
  let i = n.title;
573
1320
  if (typeof n.data != "object" || n.data === null) return null;
574
1321
  let a = n.data;
575
- if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > ie || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
1322
+ if (!Array.isArray(a.datasets) || a.datasets.length < 1 || a.datasets.length > Ve || (r === "pie" || r === "doughnut") && a.datasets.length !== 1) return null;
576
1323
  for (let e of a.datasets) if (typeof e != "object" || !e || typeof e.label != "string" || !Array.isArray(e.data)) return null;
577
1324
  let o = a.datasets;
578
1325
  if (r === "scatter") {
579
- for (let e of o) if (e.data.length < 1 || e.data.length > oe || !e.data.every(se)) return null;
1326
+ for (let e of o) if (e.data.length < 1 || e.data.length > We || !e.data.every(Ge)) return null;
580
1327
  return {
581
1328
  type: r,
582
1329
  title: i,
@@ -584,7 +1331,7 @@ var te = 5, z = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).ma
584
1331
  };
585
1332
  }
586
1333
  if (!Array.isArray(a.labels) || !a.labels.every((e) => typeof e == "string")) return null;
587
- let s = a.labels, c = r === "pie" || r === "doughnut" ? ae : K;
1334
+ let s = a.labels, c = r === "pie" || r === "doughnut" ? Ue : He;
588
1335
  if (s.length < 1 || s.length > c) return null;
589
1336
  for (let e of o) if (e.data.length !== s.length || !e.data.every((e) => typeof e == "number")) return null;
590
1337
  return {
@@ -595,7 +1342,7 @@ var te = 5, z = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).ma
595
1342
  datasets: o
596
1343
  }
597
1344
  };
598
- }, ce = {
1345
+ }, qe = {
599
1346
  tool_start: "Tool start",
600
1347
  tool_end: "Tool end",
601
1348
  pseudo_tool_call: "Narrated tool call",
@@ -606,13 +1353,13 @@ var te = 5, z = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).ma
606
1353
  error: "Error",
607
1354
  raw: "Raw event"
608
1355
  };
609
- function J(e) {
610
- return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : R(e.name, e.args);
1356
+ function Je(e) {
1357
+ return e.kind !== "tool_start" && e.kind !== "tool_end" ? null : $(e.name, e.args);
611
1358
  }
612
- function Y(e, t = J(e)) {
1359
+ function Ye(e, t = Je(e)) {
613
1360
  return e.kind === "pseudo_tool_call" ? e.name : t?.name ?? null;
614
1361
  }
615
- function X(e, t = J(e)) {
1362
+ function Xe(e, t = Je(e)) {
616
1363
  switch (e.kind) {
617
1364
  case "tool_start": return t.viaCallTool ? `${t.name} (via call_tool)` : t.name;
618
1365
  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" : ""}`;
@@ -625,23 +1372,23 @@ function X(e, t = J(e)) {
625
1372
  case "raw": return `Unrecognized event: ${e.eventType}`;
626
1373
  }
627
1374
  }
628
- function Z(e, t = J(e)) {
1375
+ function Ze(e, t = Je(e)) {
629
1376
  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 : e.kind === "llm_call_start" ? JSON.stringify(e.request, null, 2) : null;
630
1377
  }
631
- function le(e) {
1378
+ function Qe(e) {
632
1379
  return e.kind === "tool_end" ? e.output ?? null : e.kind === "llm_call_end" ? e.response ?? null : null;
633
1380
  }
634
- function ue(e) {
1381
+ function $e(e) {
635
1382
  return e.kind === "tool_end" && e.structuredOutput ? JSON.stringify(e.structuredOutput, null, 2) : null;
636
1383
  }
637
- function de(e) {
1384
+ function et(e) {
638
1385
  return e.kind === "raw" ? e.raw : e.kind === "error" ? e.rawBody ?? null : null;
639
1386
  }
640
- function fe(e) {
1387
+ function tt(e) {
641
1388
  switch (e.kind) {
642
- case "tool_start": return `Calling ${R(e.name, e.args).name}...`;
1389
+ case "tool_start": return `Calling ${$(e.name, e.args).name}...`;
643
1390
  case "tool_end": {
644
- let t = R(e.name, e.args).name;
1391
+ let t = $(e.name, e.args).name;
645
1392
  return e.isError ? `${t} failed` : `${t} returned`;
646
1393
  }
647
1394
  case "pseudo_tool_call": return `${e.name} (written as text, not called)`;
@@ -653,11 +1400,11 @@ function fe(e) {
653
1400
  case "raw": return `Unrecognized event: ${e.eventType}`;
654
1401
  }
655
1402
  }
656
- function pe(e) {
1403
+ function nt(e) {
657
1404
  let t = new Date(e);
658
1405
  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")}`;
659
1406
  }
660
- function me(e) {
1407
+ function rt(e) {
661
1408
  if (e <= 0) return "+0ms";
662
1409
  if (e < 1e3) return `+${Math.round(e)}ms`;
663
1410
  let t = e / 1e3;
@@ -665,31 +1412,31 @@ function me(e) {
665
1412
  let n = Math.floor(t / 60), r = Math.round(t % 60);
666
1413
  return `+${n}m${String(r).padStart(2, "0")}s`;
667
1414
  }
668
- function he(e) {
1415
+ function it(e) {
669
1416
  return e.map((t, n) => {
670
- let r = J(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
1417
+ let r = Je(t), i = n === 0 ? t.turnSentAt : e[n - 1].at;
671
1418
  return {
672
1419
  key: `${t.at}-${n}`,
673
1420
  kind: t.kind,
674
- toolName: Y(t, r),
1421
+ toolName: Ye(t, r),
675
1422
  isToolStart: t.kind === "tool_start",
676
1423
  failed: t.kind === "tool_end" && t.isError === !0,
677
- time: pe(t.at),
1424
+ time: nt(t.at),
678
1425
  gapMs: t.at - i,
679
- label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : ce[t.kind],
680
- summary: X(t, r),
681
- argsDetail: Z(t, r),
682
- outputDetail: le(t),
683
- structuredOutputDetail: ue(t),
684
- rawDetail: de(t)
1426
+ label: t.kind === "tool_end" && t.isError === !0 ? "Tool failed" : qe[t.kind],
1427
+ summary: Xe(t, r),
1428
+ argsDetail: Ze(t, r),
1429
+ outputDetail: Qe(t),
1430
+ structuredOutputDetail: $e(t),
1431
+ rawDetail: et(t)
685
1432
  };
686
1433
  });
687
1434
  }
688
- function ge(e) {
1435
+ function at(e) {
689
1436
  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 === "llm_call_end"), i = e.filter((e) => e.kind === "error"), a = [];
690
1437
  return r.length > 0 && a.push(`${r.length} LLM call${r.length === 1 ? "" : "s"}`), t.length > 0 && a.push(`${t.length} tool call${t.length === 1 ? "" : "s"}` + (n.length > 0 ? `, ${n.length} failed` : "")), i.length > 0 && a.push(`${i.length} stream error${i.length === 1 ? "" : "s"}`), a.join(" · ");
691
1438
  }
692
- function _e(e) {
1439
+ function ot(e) {
693
1440
  let t = [];
694
1441
  for (let n of e) {
695
1442
  let e = t[t.length - 1];
@@ -708,22 +1455,22 @@ function _e(e) {
708
1455
  }
709
1456
  return t;
710
1457
  }
711
- function ve(e) {
1458
+ function st(e) {
712
1459
  return e.some((e) => e.kind === "tool_end" && e.isError || e.kind === "error");
713
1460
  }
714
- function ye(e, t) {
1461
+ function ct(e, t) {
715
1462
  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) => ({
716
1463
  key: `${e.at}-${t}`,
717
- text: fe(e),
718
- toolName: Y(e)
1464
+ text: tt(e),
1465
+ toolName: Ye(e)
719
1466
  }));
720
1467
  }
721
- function be(e, t) {
1468
+ function lt(e, t) {
722
1469
  if (t === void 0) return [];
723
1470
  let n = [];
724
1471
  for (let r of e) if (r.turnSentAt === t) {
725
1472
  if (r.kind === "tool_start") {
726
- let e = R(r.name, r.args).name;
1473
+ let e = $(r.name, r.args).name;
727
1474
  n.push({
728
1475
  key: `step-${n.length}`,
729
1476
  callId: r.callId,
@@ -732,7 +1479,7 @@ function be(e, t) {
732
1479
  status: "running"
733
1480
  });
734
1481
  } else if (r.kind === "tool_end") {
735
- let e = R(r.name, r.args).name, t = r.isError ? "failed" : "done", i = n.find((t) => t.status === "running" && t.callId === r.callId && t.toolName === e);
1482
+ let e = $(r.name, r.args).name, t = r.isError ? "failed" : "done", i = n.find((t) => t.status === "running" && t.callId === r.callId && t.toolName === e);
736
1483
  i ? (i.status = t, i.runtimeSeconds = r.runtimeSeconds, i.label = r.displayName || i.label) : n.push({
737
1484
  key: `step-${n.length}`,
738
1485
  callId: r.callId,
@@ -747,91 +1494,91 @@ function be(e, t) {
747
1494
  }
748
1495
  //#endregion
749
1496
  //#region src/styles.css?inline
750
- var xe = "/*! 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-50:oklch(98.5% .002 247.839);--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-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--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-lg:.5rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--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-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-tool-result-image{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);max-width:100%;height:auto;display:block}.bailey-mcp-app-frame{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:0;width:100%;height:480px;display:block}.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-tool-steps-live{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-activity-line{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-step-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;flex-shrink:0}@media (prefers-reduced-motion:no-preference){.bailey-step-spinner{animation:var(--animate-spin)}}.bailey-tool-steps-summary{margin-bottom: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)}.bailey-tool-steps-summary>summary{cursor:pointer;-webkit-user-select:none;user-select:none}.bailey-tool-steps-list{margin:0;margin-top:var(--spacing);gap:var(--spacing);flex-direction:column;padding:0;list-style-type:none;display:flex}.bailey-tool-step{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-tool-step-failed{color:var(--color-bailey-error)}.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-area{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.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);min-width:0;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;flex:1;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-menu-button{height:calc(var(--spacing) * 13);width:calc(var(--spacing) * 13);cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);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);border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-menu-button:hover{background-color:var(--color-gray-50)}}.bailey-menu-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-menu-content{z-index:50;min-width:calc(var(--spacing) * 44);border-radius:var(--radius-2xl);background-color:var(--color-white);padding-block:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-black);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px 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);font-family:var(--font-sans,\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif)}.bailey-menu-item{cursor:pointer;align-items:center;gap:calc(var(--spacing) * 3);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;outline-style:none;display:flex}.bailey-menu-item[data-highlighted]{background-color:var(--color-gray-100)}.bailey-menu-item-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-gray-600)}.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}@keyframes spin{to{transform:rotate(360deg)}}", Se = r(void 0), Ce = /:root\s*,\s*:host\s*\{/, we = ".bailey-chat-panel{";
751
- function Te(e) {
752
- let t = e.match(new RegExp(Ce, "g"))?.length ?? 0;
1497
+ var ut = "/*! 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;--tw-outline-style:solid}}}@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-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--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-50:oklch(98.5% .002 247.839);--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-600:oklch(44.6% .03 256.802);--color-gray-700:oklch(37.3% .034 259.733);--color-black:#000;--color-white:#fff;--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-lg:.5rem;--radius-xl:.75rem;--radius-2xl:1rem;--animate-spin:spin 1s linear infinite;--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;position:relative}.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-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-tool-result-image{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);max-width:100%;height:auto;display:block}.bailey-mcp-app-frame{margin-top:calc(var(--spacing) * 2);border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:0;width:100%;height:480px;display:block}.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);flex-wrap:wrap;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-tool-steps-live{margin-top:calc(var(--spacing) * 2);gap:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-activity-line{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-step-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;flex-shrink:0}@media (prefers-reduced-motion:no-preference){.bailey-step-spinner{animation:var(--animate-spin)}}.bailey-tool-steps-summary{margin-bottom: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)}.bailey-tool-steps-summary>summary{cursor:pointer;-webkit-user-select:none;user-select:none}.bailey-tool-steps-list{margin:0;margin-top:var(--spacing);gap:var(--spacing);flex-direction:column;padding:0;list-style-type:none;display:flex}.bailey-tool-step{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.bailey-tool-step-failed{color:var(--color-bailey-error)}.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-area{align-items:center;gap:calc(var(--spacing) * 2);display:flex}.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);min-width:0;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;flex:1;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-menu-button{height:calc(var(--spacing) * 13);width:calc(var(--spacing) * 13);cursor:pointer;appearance:none;border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);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);border-radius:2147483647px;flex-shrink:0;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-menu-button:hover{background-color:var(--color-gray-50)}}.bailey-menu-icon{height:calc(var(--spacing) * 5);width:calc(var(--spacing) * 5)}.bailey-menu-content{z-index:50;min-width:calc(var(--spacing) * 44);border-radius:var(--radius-2xl);background-color:var(--color-white);padding-block:calc(var(--spacing) * 2);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-black);--tw-shadow:0 10px 15px -3px var(--tw-shadow-color,#0000001a), 0 4px 6px -4px 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);font-family:var(--font-sans,\"Inter\", -apple-system, \"Segoe UI\", Roboto, Arial, sans-serif)}.bailey-menu-item{cursor:pointer;align-items:center;gap:calc(var(--spacing) * 3);padding-inline:calc(var(--spacing) * 4);padding-block:calc(var(--spacing) * 2);--tw-outline-style:none;outline-style:none;display:flex}.bailey-menu-item[data-highlighted]{background-color:var(--color-gray-100)}.bailey-menu-item-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4);color:var(--color-gray-600)}.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)}.bailey-feedback{align-items:center;gap:var(--spacing);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);flex-wrap:wrap;display:flex}.bailey-message-actions>.bailey-feedback{display:contents}.bailey-feedback-thumbs{margin-left:var(--spacing);align-items:center;gap:calc(var(--spacing) * .5);border-left-style:var(--tw-border-style);border-left-width:1px;border-color:var(--color-bailey-border);padding-left:calc(var(--spacing) * 2);display:flex}.bailey-feedback-thumb{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-feedback-thumb:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-feedback-thumb:hover{color:var(--color-bailey-text)}}.bailey-feedback-thumb:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-thumb:disabled{cursor:default;opacity:.5}.bailey-feedback-thumb[aria-pressed=true]{background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-thumb[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-thumb[aria-pressed=true]{color:var(--color-bailey-accent)}.bailey-feedback-icon{height:calc(var(--spacing) * 4);width:calc(var(--spacing) * 4)}.bailey-feedback-status{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:inline-flex}.bailey-feedback-status:empty{display:none}.bailey-feedback-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);animation:var(--animate-spin);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent);border-radius:2147483647px;display:inline-block}.bailey-feedback-link{cursor:pointer;appearance:none;--tw-border-style:none;padding-inline:var(--spacing);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}.bailey-feedback-link:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-feedback-form{margin-top:calc(var(--spacing) * 2);box-sizing:border-box;border-radius:var(--radius-xl);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding:calc(var(--spacing) * 3);flex-basis:100%}.bailey-feedback-reasons{margin:0;margin-bottom:calc(var(--spacing) * 2);--tw-border-style:none;border-style:none;min-width:0;padding:0}.bailey-feedback-legend{margin-bottom:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-text);padding:0;display:block}.bailey-feedback-chips{gap:calc(var(--spacing) * 1.5);flex-wrap:wrap;display:flex}.bailey-feedback-chip{cursor:pointer;appearance:none;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) * 3);padding-block:var(--spacing);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text);border-radius:2147483647px}.bailey-feedback-chip:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-chip:disabled{cursor:default;opacity:.5}.bailey-feedback-chip[aria-pressed=true]{border-color:var(--color-bailey-accent);background-color:#4f46e51a}@supports (color:color-mix(in lab, red, red)){.bailey-feedback-chip[aria-pressed=true]{background-color:color-mix(in oklab, var(--color-bailey-accent) 10%, transparent)}}.bailey-feedback-chip[aria-pressed=true]{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-feedback-textarea{box-sizing:border-box;min-height:calc(var(--spacing) * 18);resize:vertical;border-radius:var(--radius-lg);border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface);width:100%;padding-inline:calc(var(--spacing) * 2.5);padding-block:calc(var(--spacing) * 2);font-family:var(--font-sans);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text);display:block}.bailey-feedback-textarea:disabled{opacity:.5}.bailey-feedback-meta{margin-top:calc(var(--spacing) * 1.5);justify-content:space-between;align-items:flex-start;gap:calc(var(--spacing) * 3);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-feedback-buttons{margin-top:calc(var(--spacing) * 2.5);justify-content:flex-end;gap:calc(var(--spacing) * 2);display:flex}.bailey-feedback-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);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) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-feedback-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-feedback-button:disabled{cursor:default;opacity:.5}.bailey-feedback-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-load-earlier{align-items:center;gap:var(--spacing);padding-bottom:calc(var(--spacing) * 2);flex-direction:column;display:flex}.bailey-load-earlier-button{cursor:pointer;appearance:none;border-radius:var(--radius-lg);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) * 3.5);padding-block:calc(var(--spacing) * 1.5);font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-load-earlier-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-load-earlier-button:disabled{cursor:default;opacity:.5}.bailey-load-earlier-error{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error)}.bailey-history-drawer{z-index:10;background-color:var(--color-bailey-surface);font-family:var(--font-sans);color:var(--color-bailey-text);border-radius:14px;flex-direction:column;display:flex;position:absolute;inset:0;overflow:hidden;container-type:inline-size}.bailey-history-header{align-items:center;gap:calc(var(--spacing) * 2);border-bottom-style:var(--tw-border-style);border-bottom-width:1px;border-color:var(--color-bailey-border);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);display:flex}.bailey-history-heading{text-overflow:ellipsis;white-space:nowrap;--tw-font-weight:var(--font-weight-semibold);min-width:0;font-size:15px;font-weight:var(--font-weight-semibold);--tw-outline-style:none;outline-style:none;flex:1;margin:0;overflow:hidden}.bailey-history-icon-button{height:calc(var(--spacing) * 11);width:calc(var(--spacing) * 11);cursor:pointer;appearance:none;border-radius:var(--radius-lg);--tw-border-style:none;color:var(--color-bailey-text-secondary);background-color:#0000;border-style:none;flex:none;justify-content:center;align-items:center;display:flex}@media (hover:hover){.bailey-history-icon-button:hover{background-color:#0000000d}@supports (color:color-mix(in lab, red, red)){.bailey-history-icon-button:hover{background-color:color-mix(in oklab, var(--color-black) 5%, transparent)}}.bailey-history-icon-button:hover{color:var(--color-bailey-text)}}.bailey-history-icon-button:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-icon-button:disabled{cursor:default;opacity:.5}.bailey-history-icon{width:18px;height:18px}.bailey-history-icon-small{height:calc(var(--spacing) * 3.5);width:calc(var(--spacing) * 3.5);flex:none}.bailey-history-button{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;justify-content:center;align-items:center;gap:calc(var(--spacing) * 1.5);border-radius:var(--radius-lg);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) * 3);padding-block:calc(var(--spacing) * 1.5);white-space:nowrap;color:var(--color-bailey-text);font-size:13px;display:inline-flex}.bailey-history-button:focus-visible{outline-style:var(--tw-outline-style);outline-offset:2px;outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-button:disabled{cursor:default;opacity:.5}.bailey-history-button-primary{border-color:var(--color-bailey-accent);background-color:var(--color-bailey-accent);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-danger{border-color:var(--color-bailey-error);background-color:var(--color-bailey-error);--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold);color:var(--color-white)}.bailey-history-button-small{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.bailey-history-body{padding-inline:calc(var(--spacing) * 2);padding-block:calc(var(--spacing) * 1.5);flex:1;overflow-y:auto}.bailey-history-list{margin:0;padding:0;list-style-type:none}.bailey-history-row{border-radius:10px;flex-wrap:wrap;align-items:center;display:flex;position:relative}.bailey-history-row+.bailey-history-row{margin-top:calc(var(--spacing) * .5)}.bailey-history-row:not(.bailey-history-row-active):hover{background-color:var(--color-gray-100)}.bailey-history-row-active{box-shadow:inset 3px 0 0 var(--color-bailey-accent,#4f46e5);background-color:#4f46e514}.bailey-history-select{min-height:calc(var(--spacing) * 11);cursor:pointer;appearance:none;gap:calc(var(--spacing) * .5);--tw-border-style:none;min-width:0;padding-block:calc(var(--spacing) * 2.5);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);text-align:left;color:var(--color-bailey-text);background-color:#0000;border-style:none;border-radius:10px;flex-direction:column;flex:1;font-family:inherit;display:flex}.bailey-history-select:focus-visible{outline-style:var(--tw-outline-style);outline-width:2px;outline-color:var(--color-bailey-accent)}.bailey-history-select:disabled{cursor:default;opacity:.6}.bailey-history-row-title{text-overflow:ellipsis;white-space:nowrap;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);overflow:hidden}.bailey-history-meta{align-items:center;gap:calc(var(--spacing) * 1.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);display:flex}.bailey-history-meta>span+.bailey-history-count:before{content:\"·\";margin-right:.375rem}.bailey-history-current{--tw-font-weight:var(--font-weight-semibold);font-size:11px;font-weight:var(--font-weight-semibold);color:var(--color-bailey-accent)}.bailey-history-delete{margin-right:var(--spacing)}.bailey-history-row-confirming{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:var(--color-red-50)}.bailey-history-confirm{align-items:center;gap:calc(var(--spacing) * 2);min-width:0;padding-block:calc(var(--spacing) * 2);padding-right:calc(var(--spacing) * 2.5);padding-left:calc(var(--spacing) * 3);flex-wrap:wrap;flex:1;display:flex}.bailey-history-confirm-question{--tw-font-weight:var(--font-weight-semibold);min-width:7.5rem;font-size:13px;font-weight:var(--font-weight-semibold);flex:1}.bailey-history-confirm-title{text-overflow:ellipsis;white-space:nowrap;font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-text-secondary);flex-basis:100%;overflow:hidden}.bailey-history-row-failed{border-style:var(--tw-border-style);border-width:1px;border-color:var(--color-red-200);background-color:#fff7f7}.bailey-history-row-error{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-bottom:calc(var(--spacing) * 2.5);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;flex-basis:100%;display:flex}.bailey-history-state{align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 6);padding-block:calc(var(--spacing) * 12);text-align:center;color:var(--color-bailey-text-secondary);flex-direction:column;font-size:13px;display:flex}.bailey-history-state strong{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height));color:var(--color-bailey-text)}.bailey-history-state-icon{height:calc(var(--spacing) * 7);width:calc(var(--spacing) * 7);color:var(--color-gray-400)}.bailey-history-state-error .bailey-history-state-icon{color:var(--color-bailey-error)}.bailey-history-more{padding-top:calc(var(--spacing) * 2.5);padding-bottom:calc(var(--spacing) * 1.5);justify-content:center;display:flex}.bailey-history-inline-error{justify-content:center;align-items:center;gap:calc(var(--spacing) * 2);padding-inline:calc(var(--spacing) * 3);padding-block:calc(var(--spacing) * 2);font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height));color:var(--color-bailey-error);flex-wrap:wrap;display:flex}.bailey-history-status{min-height:calc(var(--spacing) * 9);align-items:center;gap:calc(var(--spacing) * 2);border-top-style:var(--tw-border-style);border-top-width:1px;border-color:var(--color-bailey-border);background-color:var(--color-bailey-surface-muted);padding-inline:calc(var(--spacing) * 3.5);padding-block: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-history-skeleton{margin-inline:var(--spacing);margin-bottom:calc(var(--spacing) * 1.5);background:linear-gradient(90deg,#f1f1f4 25%,#e6e6ec 50%,#f1f1f4 75%) 0 0/200% 100%;border-radius:10px;height:52px;animation:1.3s infinite bailey-history-shimmer}.bailey-history-spinner{height:calc(var(--spacing) * 3);width:calc(var(--spacing) * 3);border-style:var(--tw-border-style);border-width:2px;border-color:var(--color-bailey-border);border-top-color:var(--color-bailey-accent,#4f46e5);border-radius:2147483647px;animation:.8s linear infinite bailey-history-rotate;display:inline-block}@keyframes bailey-history-shimmer{to{background-position:-200% 0}}@keyframes bailey-history-rotate{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.bailey-history-skeleton,.bailey-history-spinner{animation:none}}@container (width<=340px){.bailey-history-new-chat{width:calc(var(--spacing) * 11);padding-inline:0}.bailey-history-new-chat-text,.bailey-history-count{display:none}}@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}@property --tw-outline-style{syntax:\"*\";inherits:false;initial-value:solid}@keyframes spin{to{transform:rotate(360deg)}}", dt = r(void 0), ft = /:root\s*,\s*:host\s*\{/, pt = ".bailey-chat-panel{";
1498
+ function mt(e) {
1499
+ let t = e.match(new RegExp(ft, "g"))?.length ?? 0;
753
1500
  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.`);
754
- return e.replace(Ce, we);
1501
+ return e.replace(ft, pt);
755
1502
  }
756
- var Ee = Te(xe), De = "data-source", Oe = "baileyai-chat-ui", Q = /* @__PURE__ */ new WeakMap();
757
- function ke(e) {
1503
+ var ht = mt(ut), gt = "data-source", _t = "baileyai-chat-ui", vt = /* @__PURE__ */ new WeakMap();
1504
+ function yt(e) {
758
1505
  let t = e.getRootNode();
759
1506
  return t instanceof ShadowRoot ? t : document;
760
1507
  }
761
- function Ae(e) {
762
- let t = e instanceof ShadowRoot ? e : document.head, n = Q.get(e) ?? 0;
763
- if (n === 0 && !t.querySelector(`style[${De}="${Oe}"]`)) {
1508
+ function bt(e) {
1509
+ let t = e instanceof ShadowRoot ? e : document.head, n = vt.get(e) ?? 0;
1510
+ if (n === 0 && !t.querySelector(`style[${gt}="${_t}"]`)) {
764
1511
  let e = document.createElement("style");
765
- e.setAttribute(De, Oe), e.textContent = Ee, t.appendChild(e);
1512
+ e.setAttribute(gt, _t), e.textContent = ht, t.appendChild(e);
766
1513
  }
767
- return Q.set(e, n + 1), () => {
768
- let n = (Q.get(e) ?? 1) - 1;
769
- n <= 0 ? (Q.delete(e), t.querySelector(`style[${De}="${Oe}"]`)?.remove()) : Q.set(e, n);
1514
+ return vt.set(e, n + 1), () => {
1515
+ let n = (vt.get(e) ?? 1) - 1;
1516
+ n <= 0 ? (vt.delete(e), t.querySelector(`style[${gt}="${_t}"]`)?.remove()) : vt.set(e, n);
770
1517
  };
771
1518
  }
772
- function je(e, t = !1) {
773
- let [n, r] = d(null);
774
- return c(() => {
1519
+ function xt(e, t = !1) {
1520
+ let [n, r] = f(null);
1521
+ return l(() => {
775
1522
  if (t) return;
776
1523
  let n = e.current;
777
1524
  if (!n) return;
778
- let i = ke(n);
779
- return r(i), Ae(i);
1525
+ let i = yt(n);
1526
+ return r(i), bt(i);
780
1527
  }, [t, e]), n;
781
1528
  }
782
- function Me(e) {
783
- let t = o(Se), n = t !== void 0, r = je(e, n);
1529
+ function St(e) {
1530
+ let t = o(dt), n = t !== void 0, r = xt(e, n);
784
1531
  return n ? t : r;
785
1532
  }
786
1533
  //#endregion
787
1534
  //#region src/ui/markdown.tsx
788
- function Ne({ renderTable: t, renderChart: n } = {}) {
1535
+ function Ct({ renderTable: t, renderChart: n } = {}) {
789
1536
  return {
790
- a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ _(g, { children: n }) : /* @__PURE__ */ _("a", {
1537
+ a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ v(_, { children: n }) : /* @__PURE__ */ v("a", {
791
1538
  href: t,
792
1539
  target: "_blank",
793
1540
  rel: "noopener noreferrer",
794
1541
  children: n
795
1542
  }),
796
1543
  table: ({ node: n, children: r }) => {
797
- let i = n && U(n);
798
- if (i && W(i.rows) && t) {
1544
+ let i = n && Le(n);
1545
+ if (i && Re(i.rows) && t) {
799
1546
  let n = i.rows.map((t) => t.map((t) => t.href && !e(t.href) ? { text: t.text } : t));
800
- return /* @__PURE__ */ _(g, { children: t({
1547
+ return /* @__PURE__ */ v(_, { children: t({
801
1548
  headers: i.headers,
802
1549
  rows: n
803
1550
  }) });
804
1551
  }
805
- return /* @__PURE__ */ _("table", { children: r });
1552
+ return /* @__PURE__ */ v("table", { children: r });
806
1553
  },
807
1554
  pre: ({ children: e }) => {
808
1555
  let t = (Array.isArray(e) ? e[0] : e)?.props;
809
1556
  if ((t?.className?.split(" ") ?? []).includes("language-chartjs") && n) {
810
- let e = t?.children, r = q(Array.isArray(e) ? e.join("") : String(e ?? ""));
811
- if (r) return /* @__PURE__ */ _(g, { children: n(r) });
1557
+ let e = t?.children, r = Ke(Array.isArray(e) ? e.join("") : String(e ?? ""));
1558
+ if (r) return /* @__PURE__ */ v(_, { children: n(r) });
812
1559
  }
813
- return /* @__PURE__ */ _("pre", { children: e });
1560
+ return /* @__PURE__ */ v("pre", { children: e });
814
1561
  }
815
1562
  };
816
1563
  }
817
1564
  //#endregion
818
1565
  //#region src/ui/icons.tsx
819
- function Pe({ className: e }) {
820
- return /* @__PURE__ */ _("svg", {
1566
+ function wt({ className: e }) {
1567
+ return /* @__PURE__ */ v("svg", {
821
1568
  viewBox: "0 0 24 24",
822
1569
  fill: "currentColor",
823
1570
  className: e,
824
1571
  "aria-hidden": "true",
825
- children: /* @__PURE__ */ _("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" })
1572
+ children: /* @__PURE__ */ v("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" })
826
1573
  });
827
1574
  }
828
- function Fe({ className: e }) {
829
- return /* @__PURE__ */ _("svg", {
1575
+ function Tt({ className: e }) {
1576
+ return /* @__PURE__ */ v("svg", {
830
1577
  viewBox: "0 0 24 24",
831
1578
  fill: "currentColor",
832
1579
  className: e,
833
1580
  "aria-hidden": "true",
834
- children: /* @__PURE__ */ _("rect", {
1581
+ children: /* @__PURE__ */ v("rect", {
835
1582
  x: "6",
836
1583
  y: "6",
837
1584
  width: "12",
@@ -840,8 +1587,8 @@ function Fe({ className: e }) {
840
1587
  })
841
1588
  });
842
1589
  }
843
- function Ie({ className: e }) {
844
- return /* @__PURE__ */ v("svg", {
1590
+ function Et({ className: e }) {
1591
+ return /* @__PURE__ */ y("svg", {
845
1592
  viewBox: "0 0 24 24",
846
1593
  fill: "none",
847
1594
  stroke: "currentColor",
@@ -850,11 +1597,11 @@ function Ie({ className: e }) {
850
1597
  strokeLinejoin: "round",
851
1598
  className: e,
852
1599
  "aria-hidden": "true",
853
- children: [/* @__PURE__ */ _("path", { d: "M7 17 17 7" }), /* @__PURE__ */ _("path", { d: "M9 7h8v8" })]
1600
+ children: [/* @__PURE__ */ v("path", { d: "M7 17 17 7" }), /* @__PURE__ */ v("path", { d: "M9 7h8v8" })]
854
1601
  });
855
1602
  }
856
- function Le({ className: e }) {
857
- return /* @__PURE__ */ v("svg", {
1603
+ function Dt({ className: e }) {
1604
+ return /* @__PURE__ */ y("svg", {
858
1605
  viewBox: "0 0 24 24",
859
1606
  fill: "none",
860
1607
  stroke: "currentColor",
@@ -863,17 +1610,17 @@ function Le({ className: e }) {
863
1610
  strokeLinejoin: "round",
864
1611
  className: e,
865
1612
  "aria-hidden": "true",
866
- children: [/* @__PURE__ */ _("rect", {
1613
+ children: [/* @__PURE__ */ v("rect", {
867
1614
  x: "8",
868
1615
  y: "8",
869
1616
  width: "12",
870
1617
  height: "12",
871
1618
  rx: "2"
872
- }), /* @__PURE__ */ _("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
1619
+ }), /* @__PURE__ */ v("path", { d: "M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" })]
873
1620
  });
874
1621
  }
875
- function Re({ className: e }) {
876
- return /* @__PURE__ */ _("svg", {
1622
+ function Ot({ className: e }) {
1623
+ return /* @__PURE__ */ v("svg", {
877
1624
  viewBox: "0 0 24 24",
878
1625
  fill: "none",
879
1626
  stroke: "currentColor",
@@ -882,11 +1629,11 @@ function Re({ className: e }) {
882
1629
  strokeLinejoin: "round",
883
1630
  className: e,
884
1631
  "aria-hidden": "true",
885
- children: /* @__PURE__ */ _("path", { d: "M5 12.5 9.5 17 19 7" })
1632
+ children: /* @__PURE__ */ v("path", { d: "M5 12.5 9.5 17 19 7" })
886
1633
  });
887
1634
  }
888
- function ze({ className: e }) {
889
- return /* @__PURE__ */ _("svg", {
1635
+ function kt({ className: e }) {
1636
+ return /* @__PURE__ */ v("svg", {
890
1637
  viewBox: "0 0 24 24",
891
1638
  fill: "none",
892
1639
  stroke: "currentColor",
@@ -895,11 +1642,11 @@ function ze({ className: e }) {
895
1642
  strokeLinejoin: "round",
896
1643
  className: e,
897
1644
  "aria-hidden": "true",
898
- children: /* @__PURE__ */ _("path", { d: "m22.7 13.5-2-2-2 2M21 12a9 9 0 1 1-1.245-4.57M12 7v5l3 2" })
1645
+ children: /* @__PURE__ */ v("path", { d: "m22.7 13.5-2-2-2 2M21 12a9 9 0 1 1-1.245-4.57M12 7v5l3 2" })
899
1646
  });
900
1647
  }
901
- function Be({ className: e }) {
902
- return /* @__PURE__ */ v("svg", {
1648
+ function At({ className: e }) {
1649
+ return /* @__PURE__ */ y("svg", {
903
1650
  viewBox: "0 0 24 24",
904
1651
  fill: "none",
905
1652
  stroke: "currentColor",
@@ -908,31 +1655,31 @@ function Be({ className: e }) {
908
1655
  strokeLinejoin: "round",
909
1656
  className: e,
910
1657
  "aria-hidden": "true",
911
- children: [/* @__PURE__ */ _("circle", {
1658
+ children: [/* @__PURE__ */ v("circle", {
912
1659
  cx: "12",
913
1660
  cy: "12",
914
1661
  r: "9"
915
- }), /* @__PURE__ */ _("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
1662
+ }), /* @__PURE__ */ v("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
916
1663
  });
917
1664
  }
918
- function Ve({ className: e }) {
919
- return /* @__PURE__ */ v("svg", {
1665
+ function jt({ className: e }) {
1666
+ return /* @__PURE__ */ y("svg", {
920
1667
  viewBox: "0 0 24 24",
921
1668
  fill: "currentColor",
922
1669
  className: e,
923
1670
  "aria-hidden": "true",
924
1671
  children: [
925
- /* @__PURE__ */ _("circle", {
1672
+ /* @__PURE__ */ v("circle", {
926
1673
  cx: "5",
927
1674
  cy: "12",
928
1675
  r: "1.75"
929
1676
  }),
930
- /* @__PURE__ */ _("circle", {
1677
+ /* @__PURE__ */ v("circle", {
931
1678
  cx: "12",
932
1679
  cy: "12",
933
1680
  r: "1.75"
934
1681
  }),
935
- /* @__PURE__ */ _("circle", {
1682
+ /* @__PURE__ */ v("circle", {
936
1683
  cx: "19",
937
1684
  cy: "12",
938
1685
  r: "1.75"
@@ -940,8 +1687,8 @@ function Ve({ className: e }) {
940
1687
  ]
941
1688
  });
942
1689
  }
943
- function He({ className: e }) {
944
- return /* @__PURE__ */ _("svg", {
1690
+ function Mt({ className: e }) {
1691
+ return /* @__PURE__ */ v("svg", {
945
1692
  viewBox: "0 0 24 24",
946
1693
  fill: "none",
947
1694
  stroke: "currentColor",
@@ -950,24 +1697,92 @@ function He({ className: e }) {
950
1697
  strokeLinejoin: "round",
951
1698
  className: e,
952
1699
  "aria-hidden": "true",
953
- children: /* @__PURE__ */ _("path", { d: "M12 5v14M5 12h14" })
1700
+ children: /* @__PURE__ */ v("path", { d: "M12 5v14M5 12h14" })
1701
+ });
1702
+ }
1703
+ var Nt = "M7 11v9H4v-9h3zm0 0 4-8c1.7 0 2.7 1.3 2.4 3L13 9h5.5a2 2 0 0 1 2 2.4l-1.3 6.8A2 2 0 0 1 17.2 20H7", Pt = "M17 13V4h3v9h-3zm0 0-4 8c-1.7 0-2.7-1.3-2.4-3L11 15H5.5a2 2 0 0 1-2-2.4l1.3-6.8A2 2 0 0 1 6.8 4H17";
1704
+ function Ft({ className: e, filled: t = !1 }) {
1705
+ return /* @__PURE__ */ v("svg", {
1706
+ viewBox: "0 0 24 24",
1707
+ fill: t ? "currentColor" : "none",
1708
+ stroke: "currentColor",
1709
+ strokeWidth: 1.8,
1710
+ strokeLinejoin: "round",
1711
+ className: e,
1712
+ "aria-hidden": "true",
1713
+ children: /* @__PURE__ */ v("path", { d: Nt })
1714
+ });
1715
+ }
1716
+ function It({ className: e, filled: t = !1 }) {
1717
+ return /* @__PURE__ */ v("svg", {
1718
+ viewBox: "0 0 24 24",
1719
+ fill: t ? "currentColor" : "none",
1720
+ stroke: "currentColor",
1721
+ strokeWidth: 1.8,
1722
+ strokeLinejoin: "round",
1723
+ className: e,
1724
+ "aria-hidden": "true",
1725
+ children: /* @__PURE__ */ v("path", { d: Pt })
1726
+ });
1727
+ }
1728
+ function Lt({ className: e }) {
1729
+ return /* @__PURE__ */ v("svg", {
1730
+ viewBox: "0 0 24 24",
1731
+ fill: "none",
1732
+ stroke: "currentColor",
1733
+ strokeWidth: 2,
1734
+ strokeLinecap: "round",
1735
+ strokeLinejoin: "round",
1736
+ className: e,
1737
+ "aria-hidden": "true",
1738
+ children: /* @__PURE__ */ v("path", { d: "M15 6l-6 6 6 6" })
1739
+ });
1740
+ }
1741
+ function Rt({ className: e }) {
1742
+ return /* @__PURE__ */ v("svg", {
1743
+ viewBox: "0 0 24 24",
1744
+ fill: "none",
1745
+ stroke: "currentColor",
1746
+ strokeWidth: 2,
1747
+ strokeLinecap: "round",
1748
+ strokeLinejoin: "round",
1749
+ className: e,
1750
+ "aria-hidden": "true",
1751
+ children: /* @__PURE__ */ v("path", { d: "M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3" })
1752
+ });
1753
+ }
1754
+ function zt({ className: e }) {
1755
+ return /* @__PURE__ */ y("svg", {
1756
+ viewBox: "0 0 24 24",
1757
+ fill: "none",
1758
+ stroke: "currentColor",
1759
+ strokeWidth: 2,
1760
+ strokeLinecap: "round",
1761
+ strokeLinejoin: "round",
1762
+ className: e,
1763
+ "aria-hidden": "true",
1764
+ children: [/* @__PURE__ */ v("circle", {
1765
+ cx: "12",
1766
+ cy: "12",
1767
+ r: "9"
1768
+ }), /* @__PURE__ */ v("path", { d: "M12 8v5M12 16.5v.01" })]
954
1769
  });
955
1770
  }
956
1771
  //#endregion
957
1772
  //#region src/ui/CopyMarkdownButton.tsx
958
- var Ue = 1500;
959
- function We({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
960
- let [a, o] = d(!1), [c, l] = d(!1), f = u(null), p = u(null), m = Me(p);
1773
+ var Bt = 1500;
1774
+ function Vt({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
1775
+ let [a, o] = f(!1), [c, l] = f(!1), u = d(null), p = d(null), m = St(p);
961
1776
  return s(() => () => {
962
- f.current !== null && clearTimeout(f.current);
963
- }, []), /* @__PURE__ */ _(h.Provider, {
1777
+ u.current !== null && clearTimeout(u.current);
1778
+ }, []), /* @__PURE__ */ v(g.Provider, {
964
1779
  delayDuration: 200,
965
- children: /* @__PURE__ */ v(h.Root, {
1780
+ children: /* @__PURE__ */ y(g.Root, {
966
1781
  open: a || c,
967
1782
  onOpenChange: l,
968
- children: [/* @__PURE__ */ _(h.Trigger, {
1783
+ children: [/* @__PURE__ */ v(g.Trigger, {
969
1784
  asChild: !0,
970
- children: /* @__PURE__ */ _("button", {
1785
+ children: /* @__PURE__ */ v("button", {
971
1786
  ref: p,
972
1787
  type: "button",
973
1788
  onClick: async () => {
@@ -976,18 +1791,18 @@ function We({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
976
1791
  } catch {
977
1792
  return;
978
1793
  }
979
- o(!0), f.current !== null && clearTimeout(f.current), f.current = setTimeout(() => o(!1), Ue);
1794
+ o(!0), u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => o(!1), Bt);
980
1795
  },
981
1796
  "aria-label": n,
982
1797
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
983
- children: _(a ? Re : Le, { className: "bailey-copy-icon" })
1798
+ children: v(a ? Ot : Dt, { className: "bailey-copy-icon" })
984
1799
  })
985
- }), /* @__PURE__ */ _(h.Portal, {
1800
+ }), /* @__PURE__ */ v(g.Portal, {
986
1801
  container: m instanceof ShadowRoot ? m : void 0,
987
- children: /* @__PURE__ */ v(h.Content, {
1802
+ children: /* @__PURE__ */ y(g.Content, {
988
1803
  side: "top",
989
1804
  className: "bailey-tooltip-content",
990
- children: [a ? i : r, /* @__PURE__ */ _(h.Arrow, { className: "bailey-tooltip-arrow" })]
1805
+ children: [a ? i : r, /* @__PURE__ */ v(g.Arrow, { className: "bailey-tooltip-arrow" })]
991
1806
  })
992
1807
  })]
993
1808
  })
@@ -995,20 +1810,20 @@ function We({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
995
1810
  }
996
1811
  //#endregion
997
1812
  //#region src/ui/BaileyTracePanel.tsx
998
- async function Ge(e) {
1813
+ async function Ht(e) {
999
1814
  try {
1000
1815
  await navigator.clipboard.writeText(e);
1001
1816
  } catch {}
1002
1817
  }
1003
- function Ke({ text: e, label: t = "Copy" }) {
1004
- return /* @__PURE__ */ _("button", {
1818
+ function Ut({ text: e, label: t = "Copy" }) {
1819
+ return /* @__PURE__ */ v("button", {
1005
1820
  type: "button",
1006
- onClick: () => Ge(e),
1821
+ onClick: () => Ht(e),
1007
1822
  className: "bailey-trace-copy-button",
1008
1823
  children: t
1009
1824
  });
1010
1825
  }
1011
- function qe(e) {
1826
+ function Wt(e) {
1012
1827
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
1013
1828
  switch (e.kind) {
1014
1829
  case "tool_start":
@@ -1019,78 +1834,78 @@ function qe(e) {
1019
1834
  default: return "bailey-trace-chip bailey-trace-chip-default";
1020
1835
  }
1021
1836
  }
1022
- function $({ label: e, content: t, copyable: n }) {
1023
- return /* @__PURE__ */ v("details", {
1837
+ function Gt({ label: e, content: t, copyable: n }) {
1838
+ return /* @__PURE__ */ y("details", {
1024
1839
  className: "bailey-trace-disclosure",
1025
1840
  children: [
1026
- /* @__PURE__ */ _("summary", {
1841
+ /* @__PURE__ */ v("summary", {
1027
1842
  className: "bailey-trace-disclosure-summary",
1028
1843
  children: e
1029
1844
  }),
1030
- n && /* @__PURE__ */ _("div", {
1845
+ n && /* @__PURE__ */ v("div", {
1031
1846
  className: "bailey-trace-disclosure-actions",
1032
- children: /* @__PURE__ */ _(Ke, { text: t })
1847
+ children: /* @__PURE__ */ v(Ut, { text: t })
1033
1848
  }),
1034
- /* @__PURE__ */ _("pre", {
1849
+ /* @__PURE__ */ v("pre", {
1035
1850
  className: "bailey-trace-disclosure-content",
1036
1851
  children: t
1037
1852
  })
1038
1853
  ]
1039
1854
  });
1040
1855
  }
1041
- function Je({ row: e }) {
1042
- return /* @__PURE__ */ v("div", {
1856
+ function Kt({ row: e }) {
1857
+ return /* @__PURE__ */ y("div", {
1043
1858
  className: "bailey-trace-row",
1044
1859
  children: [
1045
- /* @__PURE__ */ v("div", {
1860
+ /* @__PURE__ */ y("div", {
1046
1861
  className: "bailey-trace-row-header",
1047
1862
  children: [
1048
- /* @__PURE__ */ _("span", {
1863
+ /* @__PURE__ */ v("span", {
1049
1864
  className: "bailey-trace-row-time",
1050
1865
  children: e.time
1051
1866
  }),
1052
- /* @__PURE__ */ _("span", {
1867
+ /* @__PURE__ */ v("span", {
1053
1868
  className: "bailey-trace-row-gap",
1054
1869
  title: "Time since the previous event",
1055
- children: me(e.gapMs)
1870
+ children: rt(e.gapMs)
1056
1871
  }),
1057
- /* @__PURE__ */ _("span", {
1058
- className: qe(e),
1872
+ /* @__PURE__ */ v("span", {
1873
+ className: Wt(e),
1059
1874
  children: e.label
1060
1875
  }),
1061
- /* @__PURE__ */ _("span", {
1876
+ /* @__PURE__ */ v("span", {
1062
1877
  className: "bailey-trace-row-summary",
1063
1878
  children: e.summary
1064
1879
  })
1065
1880
  ]
1066
1881
  }),
1067
- e.argsDetail && /* @__PURE__ */ _($, {
1882
+ e.argsDetail && /* @__PURE__ */ v(Gt, {
1068
1883
  label: e.kind === "llm_call_start" ? "request" : "args",
1069
1884
  content: e.argsDetail
1070
1885
  }),
1071
- e.outputDetail && /* @__PURE__ */ _($, {
1886
+ e.outputDetail && /* @__PURE__ */ v(Gt, {
1072
1887
  label: e.kind === "llm_call_end" ? "response" : "output",
1073
1888
  content: e.outputDetail
1074
1889
  }),
1075
- e.structuredOutputDetail && /* @__PURE__ */ _($, {
1890
+ e.structuredOutputDetail && /* @__PURE__ */ v(Gt, {
1076
1891
  label: "structured output",
1077
1892
  content: e.structuredOutputDetail
1078
1893
  }),
1079
- e.rawDetail && /* @__PURE__ */ _($, {
1894
+ e.rawDetail && /* @__PURE__ */ v(Gt, {
1080
1895
  label: "raw",
1081
1896
  content: e.rawDetail
1082
1897
  })
1083
1898
  ]
1084
1899
  });
1085
1900
  }
1086
- function Ye(e, t) {
1901
+ function qt(e, t) {
1087
1902
  if (e.chunkCount === 0) return "Streamed: no chunks received";
1088
1903
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
1089
1904
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
1090
1905
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
1091
1906
  }
1092
- function Xe({ request: e }) {
1093
- let t = l(() => JSON.stringify({
1907
+ function Jt({ request: e }) {
1908
+ let t = u(() => JSON.stringify({
1094
1909
  model: e.model,
1095
1910
  instructions: e.systemPrompt,
1096
1911
  input: e.messages,
@@ -1098,10 +1913,10 @@ function Xe({ request: e }) {
1098
1913
  tools: e.tools,
1099
1914
  toolChoice: e.toolChoice
1100
1915
  }, null, 2), [e]);
1101
- return /* @__PURE__ */ v("div", {
1916
+ return /* @__PURE__ */ y("div", {
1102
1917
  className: "bailey-trace-request-details",
1103
1918
  children: [
1104
- /* @__PURE__ */ v("span", {
1919
+ /* @__PURE__ */ y("span", {
1105
1920
  className: "bailey-trace-request-meta",
1106
1921
  children: [
1107
1922
  "Last request — ",
@@ -1111,26 +1926,26 @@ function Xe({ request: e }) {
1111
1926
  e.requestId ? ` · ${e.requestId}` : ""
1112
1927
  ]
1113
1928
  }),
1114
- /* @__PURE__ */ _("span", {
1929
+ /* @__PURE__ */ v("span", {
1115
1930
  className: "bailey-trace-request-meta",
1116
- children: Ye(e.streamStats, e.sentAt)
1931
+ children: qt(e.streamStats, e.sentAt)
1117
1932
  }),
1118
- /* @__PURE__ */ _($, {
1933
+ /* @__PURE__ */ v(Gt, {
1119
1934
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
1120
1935
  content: e.systemPrompt,
1121
1936
  copyable: !0
1122
1937
  }),
1123
- /* @__PURE__ */ _($, {
1938
+ /* @__PURE__ */ v(Gt, {
1124
1939
  label: `Messages (${e.messages.length})`,
1125
1940
  content: JSON.stringify(e.messages, null, 2),
1126
1941
  copyable: !0
1127
1942
  }),
1128
- e.response && /* @__PURE__ */ _($, {
1943
+ e.response && /* @__PURE__ */ v(Gt, {
1129
1944
  label: `Response (${e.response.content.length.toLocaleString()} chars)`,
1130
1945
  content: e.response.content,
1131
1946
  copyable: !0
1132
1947
  }),
1133
- /* @__PURE__ */ _($, {
1948
+ /* @__PURE__ */ v(Gt, {
1134
1949
  label: "Full payload (JSON)",
1135
1950
  content: t,
1136
1951
  copyable: !0
@@ -1138,43 +1953,43 @@ function Xe({ request: e }) {
1138
1953
  ]
1139
1954
  });
1140
1955
  }
1141
- function Ze({ events: e, lastRequest: t, onClear: n }) {
1142
- let r = l(() => he(e), [e]), i = l(() => _e(r), [r]), a = l(() => JSON.stringify(e, null, 2), [e]);
1143
- return /* @__PURE__ */ v("div", {
1956
+ function Yt({ events: e, lastRequest: t, onClear: n }) {
1957
+ let r = u(() => it(e), [e]), i = u(() => ot(r), [r]), a = u(() => JSON.stringify(e, null, 2), [e]);
1958
+ return /* @__PURE__ */ y("div", {
1144
1959
  className: "bailey-trace-body",
1145
1960
  children: [
1146
- /* @__PURE__ */ v("div", {
1961
+ /* @__PURE__ */ y("div", {
1147
1962
  className: "bailey-trace-actions-row",
1148
- children: [e.length > 0 && /* @__PURE__ */ _(Ke, {
1963
+ children: [e.length > 0 && /* @__PURE__ */ v(Ut, {
1149
1964
  text: a,
1150
1965
  label: "Copy trace as JSON"
1151
- }), /* @__PURE__ */ _("button", {
1966
+ }), /* @__PURE__ */ v("button", {
1152
1967
  type: "button",
1153
1968
  onClick: n,
1154
1969
  className: "bailey-trace-copy-button",
1155
1970
  children: "Clear"
1156
1971
  })]
1157
1972
  }),
1158
- t && /* @__PURE__ */ _(Xe, { request: t }),
1159
- /* @__PURE__ */ _("div", {
1973
+ t && /* @__PURE__ */ v(Jt, { request: t }),
1974
+ /* @__PURE__ */ v("div", {
1160
1975
  className: "bailey-trace-rows",
1161
1976
  children: i.map((e, t) => {
1162
- if (e.type === "single") return /* @__PURE__ */ _(Je, { row: e.row }, e.row.key);
1977
+ if (e.type === "single") return /* @__PURE__ */ v(Kt, { row: e.row }, e.row.key);
1163
1978
  let n = e.rows.filter((e) => e.isToolStart).length;
1164
- if (n <= 1) return /* @__PURE__ */ _("div", {
1979
+ if (n <= 1) return /* @__PURE__ */ v("div", {
1165
1980
  className: "bailey-trace-rows",
1166
- children: e.rows.map((e) => /* @__PURE__ */ _(Je, { row: e }, e.key))
1981
+ children: e.rows.map((e) => /* @__PURE__ */ v(Kt, { row: e }, e.key))
1167
1982
  }, `group-${t}`);
1168
1983
  let r = e.rows.filter((e) => e.failed).length;
1169
- return /* @__PURE__ */ v("details", {
1984
+ return /* @__PURE__ */ y("details", {
1170
1985
  className: "bailey-trace-group",
1171
- children: [/* @__PURE__ */ v("summary", {
1986
+ children: [/* @__PURE__ */ y("summary", {
1172
1987
  className: "bailey-trace-group-summary",
1173
1988
  children: [
1174
- /* @__PURE__ */ _("strong", { children: e.toolName }),
1989
+ /* @__PURE__ */ v("strong", { children: e.toolName }),
1175
1990
  " × ",
1176
1991
  n,
1177
- r > 0 && /* @__PURE__ */ v("span", {
1992
+ r > 0 && /* @__PURE__ */ y("span", {
1178
1993
  className: "bailey-trace-group-failed",
1179
1994
  children: [
1180
1995
  " ",
@@ -1183,9 +1998,9 @@ function Ze({ events: e, lastRequest: t, onClear: n }) {
1183
1998
  ]
1184
1999
  })
1185
2000
  ]
1186
- }), /* @__PURE__ */ _("div", {
2001
+ }), /* @__PURE__ */ v("div", {
1187
2002
  className: "bailey-trace-rows",
1188
- children: e.rows.map((e) => /* @__PURE__ */ _(Je, { row: e }, e.key))
2003
+ children: e.rows.map((e) => /* @__PURE__ */ v(Kt, { row: e }, e.key))
1189
2004
  })]
1190
2005
  }, `group-${t}`);
1191
2006
  })
@@ -1193,13 +2008,13 @@ function Ze({ events: e, lastRequest: t, onClear: n }) {
1193
2008
  ]
1194
2009
  });
1195
2010
  }
1196
- function Qe({ events: e, lastRequest: t, onClear: n }) {
1197
- let [r, i] = d(!1), a = l(() => ve(e), [e]), o = l(() => ge(e), [e]);
1198
- return e.length === 0 && !t ? null : /* @__PURE__ */ v("div", {
2011
+ function Xt({ events: e, lastRequest: t, onClear: n }) {
2012
+ let [r, i] = f(!1), a = u(() => st(e), [e]), o = u(() => at(e), [e]);
2013
+ return e.length === 0 && !t ? null : /* @__PURE__ */ y("div", {
1199
2014
  className: "bailey-trace-panel",
1200
- children: [/* @__PURE__ */ v("div", {
2015
+ children: [/* @__PURE__ */ y("div", {
1201
2016
  className: "bailey-trace-toggle-row",
1202
- children: [/* @__PURE__ */ v("button", {
2017
+ children: [/* @__PURE__ */ y("button", {
1203
2018
  type: "button",
1204
2019
  onClick: () => i((e) => !e),
1205
2020
  "aria-expanded": r,
@@ -1211,11 +2026,11 @@ function Qe({ events: e, lastRequest: t, onClear: n }) {
1211
2026
  e.length,
1212
2027
  ")"
1213
2028
  ]
1214
- }), o && /* @__PURE__ */ _("span", {
2029
+ }), o && /* @__PURE__ */ v("span", {
1215
2030
  className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
1216
2031
  children: o
1217
2032
  })]
1218
- }), r && /* @__PURE__ */ _(Ze, {
2033
+ }), r && /* @__PURE__ */ v(Yt, {
1219
2034
  events: e,
1220
2035
  lastRequest: t,
1221
2036
  onClear: n
@@ -1224,8 +2039,8 @@ function Qe({ events: e, lastRequest: t, onClear: n }) {
1224
2039
  }
1225
2040
  //#endregion
1226
2041
  //#region src/ui/ToolResultImage.tsx
1227
- function $e({ src: e, alt: n, className: r }) {
1228
- return t(e) ? /* @__PURE__ */ _("img", {
2042
+ function Zt({ src: e, alt: n, className: r }) {
2043
+ return t(e) ? /* @__PURE__ */ v("img", {
1229
2044
  src: e,
1230
2045
  alt: n ?? "",
1231
2046
  className: `bailey-tool-result-image${r ? ` ${r}` : ""}`,
@@ -1234,26 +2049,26 @@ function $e({ src: e, alt: n, className: r }) {
1234
2049
  }
1235
2050
  //#endregion
1236
2051
  //#region src/utils/safeMcpAppResource.ts
1237
- var et = /^ui:\/\//, tt = 2097152, nt = /* @__PURE__ */ new Set([
2052
+ var Qt = /^ui:\/\//, $t = 2097152, en = /* @__PURE__ */ new Set([
1238
2053
  "connectDomains",
1239
2054
  "resourceDomains",
1240
2055
  "frameDomains",
1241
2056
  "baseUriDomains"
1242
- ]), rt = /* @__PURE__ */ new Set([
2057
+ ]), tn = /* @__PURE__ */ new Set([
1243
2058
  "camera",
1244
2059
  "microphone",
1245
2060
  "geolocation",
1246
2061
  "clipboardWrite"
1247
- ]), it = (e, t) => e === void 0 ? !0 : typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.keys(e).every((e) => t.has(e)), at = (e) => !(!et.test(e.resourceUri) || typeof e.html != "string" || e.html.length === 0 || e.html.length > tt || !it(e.csp, nt) || !it(e.permissions, rt));
2062
+ ]), nn = (e, t) => e === void 0 ? !0 : typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.keys(e).every((e) => t.has(e)), rn = (e) => !(!Qt.test(e.resourceUri) || typeof e.html != "string" || e.html.length === 0 || e.html.length > $t || !nn(e.csp, en) || !nn(e.permissions, tn));
1248
2063
  //#endregion
1249
2064
  //#region src/ui/McpAppFrame.tsx
1250
- function ot({ html: e, title: t, resourceUri: n, csp: r, permissions: i, className: a }) {
1251
- return at({
2065
+ function an({ html: e, title: t, resourceUri: n, csp: r, permissions: i, className: a }) {
2066
+ return rn({
1252
2067
  html: e,
1253
2068
  resourceUri: n,
1254
2069
  csp: r,
1255
2070
  permissions: i
1256
- }) ? /* @__PURE__ */ _("iframe", {
2071
+ }) ? /* @__PURE__ */ v("iframe", {
1257
2072
  title: t ?? "MCP App",
1258
2073
  srcDoc: e,
1259
2074
  sandbox: "allow-scripts",
@@ -1263,28 +2078,28 @@ function ot({ html: e, title: t, resourceUri: n, csp: r, permissions: i, classNa
1263
2078
  }
1264
2079
  //#endregion
1265
2080
  //#region src/ui/BaileyToolSteps.tsx
1266
- function st({ toolName: e, resolveActivityIcon: t }) {
2081
+ function on({ toolName: e, resolveActivityIcon: t }) {
1267
2082
  let n = t?.(e);
1268
- return n === 0 || n && n !== !0 ? /* @__PURE__ */ _("span", {
2083
+ return n === 0 || n && n !== !0 ? /* @__PURE__ */ v("span", {
1269
2084
  className: "bailey-activity-icon",
1270
2085
  children: n
1271
2086
  }) : null;
1272
2087
  }
1273
- function ct({ steps: e, resolveActivityIcon: t }) {
2088
+ function sn({ steps: e, resolveActivityIcon: t }) {
1274
2089
  let n = e.filter((e) => e.status === "running");
1275
- return n.length === 0 ? null : /* @__PURE__ */ _("div", {
2090
+ return n.length === 0 ? null : /* @__PURE__ */ v("div", {
1276
2091
  className: "bailey-tool-steps-live",
1277
2092
  role: "status",
1278
2093
  "aria-live": "polite",
1279
- children: n.map((e) => /* @__PURE__ */ v("div", {
2094
+ children: n.map((e) => /* @__PURE__ */ y("div", {
1280
2095
  className: "bailey-activity-line",
1281
2096
  children: [
1282
- /* @__PURE__ */ _(st, {
2097
+ /* @__PURE__ */ v(on, {
1283
2098
  toolName: e.toolName,
1284
2099
  resolveActivityIcon: t
1285
2100
  }),
1286
- /* @__PURE__ */ _("span", { children: e.label }),
1287
- /* @__PURE__ */ _("span", {
2101
+ /* @__PURE__ */ v("span", { children: e.label }),
2102
+ /* @__PURE__ */ v("span", {
1288
2103
  className: "bailey-step-spinner",
1289
2104
  "aria-hidden": "true"
1290
2105
  })
@@ -1292,35 +2107,407 @@ function ct({ steps: e, resolveActivityIcon: t }) {
1292
2107
  }, e.key))
1293
2108
  });
1294
2109
  }
1295
- function lt({ steps: e, labels: t, resolveActivityIcon: n }) {
2110
+ function cn({ steps: e, labels: t, resolveActivityIcon: n }) {
1296
2111
  if (e.length === 0) return null;
1297
2112
  let r = e.filter((e) => e.status === "failed").length, i = e.length === 1 ? t.toolStepsSummaryOne : t.toolStepsSummaryMany.replace("{count}", String(e.length)), a = r > 0 ? `${i}${t.toolStepsFailedSuffix.replace("{failed}", String(r))}` : i;
1298
- return /* @__PURE__ */ v("details", {
2113
+ return /* @__PURE__ */ y("details", {
1299
2114
  className: "bailey-tool-steps-summary",
1300
- children: [/* @__PURE__ */ _("summary", { children: a }), /* @__PURE__ */ _("ul", {
2115
+ children: [/* @__PURE__ */ v("summary", { children: a }), /* @__PURE__ */ v("ul", {
1301
2116
  className: "bailey-tool-steps-list",
1302
- children: e.map((e) => /* @__PURE__ */ v("li", {
2117
+ children: e.map((e) => /* @__PURE__ */ y("li", {
1303
2118
  className: "bailey-tool-step",
1304
2119
  children: [
1305
- /* @__PURE__ */ _(st, {
2120
+ /* @__PURE__ */ v(on, {
1306
2121
  toolName: e.toolName,
1307
2122
  resolveActivityIcon: n
1308
2123
  }),
1309
- /* @__PURE__ */ _("span", { children: e.label }),
1310
- e.runtimeSeconds !== void 0 && /* @__PURE__ */ _("span", { children: `${e.runtimeSeconds.toFixed(1)}s` }),
1311
- e.status === "failed" && /* @__PURE__ */ _("span", {
2124
+ /* @__PURE__ */ v("span", { children: e.label }),
2125
+ e.runtimeSeconds !== void 0 && /* @__PURE__ */ v("span", { children: `${e.runtimeSeconds.toFixed(1)}s` }),
2126
+ e.status === "failed" && /* @__PURE__ */ v("span", {
1312
2127
  className: "bailey-tool-step-failed",
1313
2128
  children: t.toolStepFailedText
1314
2129
  }),
1315
- e.status === "running" && /* @__PURE__ */ _("span", { children: t.toolStepStoppedText })
2130
+ e.status === "running" && /* @__PURE__ */ v("span", { children: t.toolStepStoppedText })
1316
2131
  ]
1317
2132
  }, e.key))
1318
2133
  })]
1319
2134
  });
1320
2135
  }
1321
2136
  //#endregion
1322
- //#region src/ui/BaileyChatPanel.tsx
1323
- var ut = "How can bailey AI help you today?", dt = "Reply to bailey AI", ft = {
2137
+ //#region src/utils/relativeTime.ts
2138
+ var ln = /(Z|[+-]\d{2}:?\d{2})$/i, un = 60, dn = 3600, fn = 24 * dn, pn = 30 * fn * 1e3;
2139
+ function mn(e) {
2140
+ return e ? Date.parse(ln.test(e) ? e : `${e}Z`) : NaN;
2141
+ }
2142
+ function hn(e) {
2143
+ let t = mn(e.iso);
2144
+ if (Number.isNaN(t)) return "";
2145
+ let n = e.now ?? Date.now(), r = Math.max(0, n - t);
2146
+ if (typeof Intl > "u" || typeof Intl.RelativeTimeFormat != "function") return e.justNowText ?? "";
2147
+ if (r >= pn) return new Intl.DateTimeFormat(e.locale, { dateStyle: "medium" }).format(t);
2148
+ let i = r / 1e3, a = new Intl.RelativeTimeFormat(e.locale, { numeric: "auto" });
2149
+ return i < un ? a.format(0, "second") : i < dn ? a.format(-Math.floor(i / un), "minute") : i < fn ? a.format(-Math.floor(i / dn), "hour") : a.format(-Math.floor(i / fn), "day");
2150
+ }
2151
+ //#endregion
2152
+ //#region src/ui/BaileyHistoryDrawer.tsx
2153
+ function gn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o }) {
2154
+ let s = me({
2155
+ client: e,
2156
+ pageSize: t
2157
+ }), { loadConversation: c, newChat: l } = n, u = a((e) => c ? c(e) : Promise.reject(/* @__PURE__ */ Error("no loadConversation")), [c]), d = a(() => {
2158
+ l(), o({ restoreFocusTo: "input" });
2159
+ }, [l, o]);
2160
+ return /* @__PURE__ */ v(yn, {
2161
+ conversations: s,
2162
+ activeConversationId: n.conversationId,
2163
+ selectStatus: n.historyStatus,
2164
+ onSelect: u,
2165
+ onActiveDeleted: l,
2166
+ onNewChat: d,
2167
+ onClose: o,
2168
+ labels: r,
2169
+ locale: i
2170
+ });
2171
+ }
2172
+ var _n = (e, t) => Object.entries(t).reduce((e, [t, n]) => e.split(`{${t}}`).join(String(n)), e), vn = (e) => !e || e.kind !== "http" ? !1 : e.status === 401 || e.status === 403;
2173
+ function yn({ conversations: e, activeConversationId: t, selectStatus: n, onSelect: r, onActiveDeleted: i, onNewChat: a, onClose: o, labels: l, locale: u, now: p }) {
2174
+ let { conversations: m, status: h, error: g, hasMore: b, refresh: ee, loadMore: x, remove: S } = e, C = c(), w = c(), T = d(null), E = d(null), D = d(null), O = d(/* @__PURE__ */ new Map()), k = d(/* @__PURE__ */ new Map()), A = d(null), j = d(null), [M, N] = f(null), [te, P] = f(null), [ne, re] = f(0), [ie, ae] = f(!1), [F, I] = f(!1), [oe, L] = f(!1), se = u ?? (typeof navigator < "u" ? navigator.language : void 0);
2175
+ s(() => {
2176
+ T.current?.focus();
2177
+ }, []), s(() => {
2178
+ let e = A.current;
2179
+ if (!e) return;
2180
+ let t = e.kind === "select" ? O.current.get(e.id) : e.kind === "delete" ? k.current.get(e.id) : e.kind === "cancel" ? D.current : E.current;
2181
+ t && (t.focus(), A.current = null);
2182
+ }), s(() => {
2183
+ let e = j.current;
2184
+ e !== null && h !== "loading" && (j.current = null, !b && m.length > e && (A.current = {
2185
+ kind: "select",
2186
+ id: m[e].conversationId
2187
+ }));
2188
+ }, [
2189
+ h,
2190
+ b,
2191
+ m
2192
+ ]);
2193
+ let ce = () => {
2194
+ j.current = m.length, x();
2195
+ }, le = (e) => {
2196
+ A.current = {
2197
+ kind: "delete",
2198
+ id: e
2199
+ }, N(null);
2200
+ }, ue = (e) => {
2201
+ if (e.key === "Escape") {
2202
+ if (e.stopPropagation(), M) {
2203
+ le(M);
2204
+ return;
2205
+ }
2206
+ o({ restoreFocusTo: "menu" });
2207
+ }
2208
+ }, de = async (e) => {
2209
+ if (L(!1), e === t) {
2210
+ o({ restoreFocusTo: "input" });
2211
+ return;
2212
+ }
2213
+ I(!0);
2214
+ try {
2215
+ await r({ conversationId: e });
2216
+ } catch {
2217
+ A.current = {
2218
+ kind: "select",
2219
+ id: e
2220
+ }, L(!0), I(!1);
2221
+ return;
2222
+ }
2223
+ I(!1), o({ restoreFocusTo: "input" });
2224
+ }, R = async (e) => {
2225
+ let n = m.findIndex((t) => t.conversationId === e), r = m[n + 1] ?? m[n - 1];
2226
+ A.current = r ? {
2227
+ kind: "select",
2228
+ id: r.conversationId
2229
+ } : { kind: "newChat" }, N(null), P(null), ae(!1), re((e) => e + 1);
2230
+ try {
2231
+ await S({ conversationId: e }), ae(!0), e === t && i?.();
2232
+ } catch {
2233
+ A.current = {
2234
+ kind: "delete",
2235
+ id: e
2236
+ }, P(e);
2237
+ } finally {
2238
+ re((e) => e - 1);
2239
+ }
2240
+ }, z = h === "loading" && m.length === 0, fe = h === "error" && m.length === 0, B = h === "error" && m.length > 0 && b, V = h === "loading" && m.length > 0, H = F || n === "loading", pe = z ? l.historyLoadingText : ne > 0 ? l.historyDeletingText : ie ? l.historyDeletedText : m.length > 0 ? _n(m.length === 1 ? l.historyCountTextOne : l.historyCountTextMany, { count: m.length }) : "", U = z || ne > 0;
2241
+ return /* @__PURE__ */ y("section", {
2242
+ role: "region",
2243
+ "aria-labelledby": C,
2244
+ className: "bailey-history-drawer",
2245
+ onKeyDown: ue,
2246
+ children: [
2247
+ /* @__PURE__ */ y("div", {
2248
+ className: "bailey-history-header",
2249
+ children: [
2250
+ /* @__PURE__ */ v("button", {
2251
+ type: "button",
2252
+ className: "bailey-history-icon-button",
2253
+ "aria-label": l.historyBackAriaLabel,
2254
+ onClick: () => o({ restoreFocusTo: "menu" }),
2255
+ children: /* @__PURE__ */ v(Lt, { className: "bailey-history-icon" })
2256
+ }),
2257
+ /* @__PURE__ */ v("h3", {
2258
+ id: C,
2259
+ ref: T,
2260
+ tabIndex: -1,
2261
+ className: "bailey-history-heading",
2262
+ children: l.historyTitle
2263
+ }),
2264
+ /* @__PURE__ */ y("button", {
2265
+ ref: E,
2266
+ type: "button",
2267
+ className: "bailey-history-button bailey-history-new-chat",
2268
+ "aria-label": l.newChatButtonText,
2269
+ disabled: z,
2270
+ onClick: a,
2271
+ children: [/* @__PURE__ */ v(Mt, { className: "bailey-history-icon-small" }), /* @__PURE__ */ v("span", {
2272
+ className: "bailey-history-new-chat-text",
2273
+ children: l.newChatButtonText
2274
+ })]
2275
+ })
2276
+ ]
2277
+ }),
2278
+ /* @__PURE__ */ y("div", {
2279
+ className: "bailey-history-body",
2280
+ "aria-busy": z || void 0,
2281
+ children: [
2282
+ z && /* @__PURE__ */ y("div", {
2283
+ "aria-hidden": "true",
2284
+ children: [
2285
+ /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" }),
2286
+ /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" }),
2287
+ /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" }),
2288
+ /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" })
2289
+ ]
2290
+ }),
2291
+ fe && /* @__PURE__ */ y("div", {
2292
+ role: "alert",
2293
+ className: "bailey-history-state bailey-history-state-error",
2294
+ children: [
2295
+ /* @__PURE__ */ v(zt, { className: "bailey-history-state-icon" }),
2296
+ /* @__PURE__ */ v("strong", { children: vn(g) ? l.historySessionExpiredTitle : l.historyErrorTitle }),
2297
+ /* @__PURE__ */ v("span", { children: vn(g) ? l.historySessionExpiredDescription : l.historyErrorDescription }),
2298
+ /* @__PURE__ */ v("button", {
2299
+ type: "button",
2300
+ className: "bailey-history-button bailey-history-button-primary",
2301
+ onClick: () => void ee(),
2302
+ children: l.retryButtonText
2303
+ })
2304
+ ]
2305
+ }),
2306
+ !z && !fe && m.length === 0 && /* @__PURE__ */ y("div", {
2307
+ className: "bailey-history-state",
2308
+ children: [
2309
+ /* @__PURE__ */ v(kt, { className: "bailey-history-state-icon" }),
2310
+ /* @__PURE__ */ v("strong", { children: l.historyEmptyTitle }),
2311
+ /* @__PURE__ */ v("span", { children: l.historyEmptyDescription }),
2312
+ /* @__PURE__ */ v("button", {
2313
+ type: "button",
2314
+ className: "bailey-history-button bailey-history-button-primary",
2315
+ onClick: a,
2316
+ children: l.historyEmptyCtaText
2317
+ })
2318
+ ]
2319
+ }),
2320
+ m.length > 0 && /* @__PURE__ */ v("ul", {
2321
+ className: "bailey-history-list",
2322
+ children: m.map((e) => {
2323
+ let n = e.conversationId, r = e.title?.trim() ? e.title : l.historyUntitledText, i = n === t;
2324
+ if (M === n) return /* @__PURE__ */ v("li", {
2325
+ className: "bailey-history-row bailey-history-row-confirming",
2326
+ children: /* @__PURE__ */ y("div", {
2327
+ role: "group",
2328
+ "aria-labelledby": w,
2329
+ className: "bailey-history-confirm",
2330
+ children: [
2331
+ /* @__PURE__ */ v("span", {
2332
+ id: w,
2333
+ className: "bailey-history-confirm-question",
2334
+ children: l.historyDeleteConfirmQuestion
2335
+ }),
2336
+ /* @__PURE__ */ v("span", {
2337
+ className: "bailey-history-confirm-title",
2338
+ children: r
2339
+ }),
2340
+ /* @__PURE__ */ v("button", {
2341
+ type: "button",
2342
+ className: "bailey-history-button bailey-history-button-danger",
2343
+ onClick: () => void R(n),
2344
+ children: l.historyDeleteConfirmText
2345
+ }),
2346
+ /* @__PURE__ */ v("button", {
2347
+ ref: D,
2348
+ type: "button",
2349
+ className: "bailey-history-button",
2350
+ onClick: () => le(n),
2351
+ children: l.historyDeleteCancelText
2352
+ })
2353
+ ]
2354
+ })
2355
+ }, n);
2356
+ let a = hn({
2357
+ iso: e.updatedAt,
2358
+ locale: se,
2359
+ now: p?.(),
2360
+ justNowText: l.historyJustNowText
2361
+ }), o = _n(e.messageCount === 1 ? l.historyMessageCountOne : l.historyMessageCountMany, { count: e.messageCount }), s = te === n;
2362
+ return /* @__PURE__ */ y("li", {
2363
+ className: `bailey-history-row${i ? " bailey-history-row-active" : ""}${s ? " bailey-history-row-failed" : ""}`,
2364
+ children: [
2365
+ /* @__PURE__ */ y("button", {
2366
+ type: "button",
2367
+ ref: (e) => {
2368
+ e ? O.current.set(n, e) : O.current.delete(n);
2369
+ },
2370
+ className: "bailey-history-select",
2371
+ "aria-current": i ? "true" : void 0,
2372
+ "aria-disabled": H || void 0,
2373
+ onClick: () => {
2374
+ H || de(n);
2375
+ },
2376
+ children: [/* @__PURE__ */ v("span", {
2377
+ className: "bailey-history-row-title",
2378
+ children: r
2379
+ }), /* @__PURE__ */ y("span", {
2380
+ className: "bailey-history-meta",
2381
+ children: [
2382
+ i && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("span", {
2383
+ className: "bailey-history-current",
2384
+ children: l.historyCurrentText
2385
+ }), /* @__PURE__ */ v("span", {
2386
+ "aria-hidden": "true",
2387
+ children: "·"
2388
+ })] }),
2389
+ a && /* @__PURE__ */ v("span", { children: a }),
2390
+ /* @__PURE__ */ v("span", {
2391
+ className: "bailey-history-count",
2392
+ children: o
2393
+ })
2394
+ ]
2395
+ })]
2396
+ }),
2397
+ /* @__PURE__ */ v("button", {
2398
+ type: "button",
2399
+ ref: (e) => {
2400
+ e ? k.current.set(n, e) : k.current.delete(n);
2401
+ },
2402
+ className: "bailey-history-icon-button bailey-history-delete",
2403
+ "aria-label": _n(l.historyDeleteAriaLabel, { title: r }),
2404
+ onClick: () => {
2405
+ P(null), ae(!1), A.current = { kind: "cancel" }, N(n);
2406
+ },
2407
+ children: /* @__PURE__ */ v(Rt, { className: "bailey-history-icon" })
2408
+ }),
2409
+ s && /* @__PURE__ */ y("div", {
2410
+ role: "alert",
2411
+ className: "bailey-history-row-error",
2412
+ children: [
2413
+ /* @__PURE__ */ v(zt, { className: "bailey-history-icon-small" }),
2414
+ /* @__PURE__ */ v("span", { children: l.historyDeleteFailedText }),
2415
+ /* @__PURE__ */ v("button", {
2416
+ type: "button",
2417
+ className: "bailey-history-button bailey-history-button-small",
2418
+ onClick: () => void R(n),
2419
+ children: l.historyDeleteRetryText
2420
+ }),
2421
+ /* @__PURE__ */ v("button", {
2422
+ type: "button",
2423
+ className: "bailey-history-button bailey-history-button-small",
2424
+ onClick: () => P(null),
2425
+ children: l.historyDeleteDismissText
2426
+ })
2427
+ ]
2428
+ })
2429
+ ]
2430
+ }, n);
2431
+ })
2432
+ }),
2433
+ oe && /* @__PURE__ */ v("div", {
2434
+ role: "alert",
2435
+ className: "bailey-history-inline-error",
2436
+ children: l.historySelectErrorText
2437
+ }),
2438
+ b && m.length > 0 && /* @__PURE__ */ v("div", {
2439
+ className: "bailey-history-more",
2440
+ children: B ? /* @__PURE__ */ y("div", {
2441
+ role: "alert",
2442
+ className: "bailey-history-inline-error",
2443
+ children: [/* @__PURE__ */ v("span", { children: l.historyLoadMoreErrorText }), /* @__PURE__ */ v("button", {
2444
+ type: "button",
2445
+ className: "bailey-history-button",
2446
+ onClick: ce,
2447
+ children: l.retryButtonText
2448
+ })]
2449
+ }) : /* @__PURE__ */ y("button", {
2450
+ type: "button",
2451
+ className: "bailey-history-button",
2452
+ disabled: V,
2453
+ onClick: ce,
2454
+ children: [V && /* @__PURE__ */ v("span", {
2455
+ className: "bailey-history-spinner",
2456
+ "aria-hidden": "true"
2457
+ }), V ? l.historyLoadingMoreText : l.historyLoadMoreText]
2458
+ })
2459
+ })
2460
+ ]
2461
+ }),
2462
+ /* @__PURE__ */ y("div", {
2463
+ role: "status",
2464
+ "aria-live": "polite",
2465
+ className: "bailey-history-status",
2466
+ children: [U && /* @__PURE__ */ v("span", {
2467
+ className: "bailey-history-spinner",
2468
+ "aria-hidden": "true"
2469
+ }), pe]
2470
+ })
2471
+ ]
2472
+ });
2473
+ }
2474
+ //#endregion
2475
+ //#region src/ui/historyLabels.ts
2476
+ var bn = {
2477
+ newChatButtonText: "New chat",
2478
+ retryButtonText: "Retry",
2479
+ historyTitle: "Chat history",
2480
+ historyBackAriaLabel: "Back to chat",
2481
+ historyLoadingText: "Loading conversations…",
2482
+ historyLoadingMoreText: "Loading…",
2483
+ historyLoadMoreText: "Load more",
2484
+ historyLoadMoreErrorText: "Couldn't load more conversations.",
2485
+ historyCountTextOne: "Showing {count} conversation",
2486
+ historyCountTextMany: "Showing {count} conversations",
2487
+ historyEmptyTitle: "No conversations yet",
2488
+ historyEmptyDescription: "Your past conversations will show up here.",
2489
+ historyEmptyCtaText: "Start a new chat",
2490
+ historyErrorTitle: "Couldn't load your conversations",
2491
+ historyErrorDescription: "Check your connection and try again.",
2492
+ historySessionExpiredTitle: "Your session has expired",
2493
+ historySessionExpiredDescription: "Sign in again to see your past conversations.",
2494
+ historySelectErrorText: "Couldn't open this conversation.",
2495
+ historyUntitledText: "Untitled conversation",
2496
+ historyCurrentText: "Current",
2497
+ historyMessageCountOne: "1 message",
2498
+ historyMessageCountMany: "{count} messages",
2499
+ historyDeleteAriaLabel: "Delete conversation: {title}",
2500
+ historyDeleteConfirmQuestion: "Delete this conversation?",
2501
+ historyDeleteConfirmText: "Delete",
2502
+ historyDeleteCancelText: "Cancel",
2503
+ historyDeletingText: "Deleting conversation…",
2504
+ historyDeletedText: "Conversation deleted",
2505
+ historyDeleteFailedText: "Couldn't delete this conversation.",
2506
+ historyDeleteRetryText: "Try again",
2507
+ historyDeleteDismissText: "Dismiss",
2508
+ historyJustNowText: "just now"
2509
+ }, xn = "How can bailey AI help you today?", Sn = "Reply to bailey AI", Cn = {
2510
+ ...bn,
1324
2511
  newChatButtonText: "New chat",
1325
2512
  newChatAriaLabel: "new chat",
1326
2513
  historyAriaLabel: "conversation history",
@@ -1343,274 +2530,594 @@ var ut = "How can bailey AI help you today?", dt = "Reply to bailey AI", ft = {
1343
2530
  toolStepsFailedSuffix: ", {failed} failed",
1344
2531
  toolStepFailedText: "failed",
1345
2532
  toolStepStoppedText: "stopped",
1346
- mcpAppDefaultTitle: "MCP App"
1347
- }, pt = [p], mt = {
1348
- ...Ne(),
1349
- p: ({ children: e }) => /* @__PURE__ */ _(g, { children: e })
1350
- }, ht = i(function({ content: e, components: t }) {
1351
- return /* @__PURE__ */ _("div", {
2533
+ mcpAppDefaultTitle: "MCP App",
2534
+ loadEarlierButtonText: "Load earlier messages",
2535
+ loadEarlierErrorText: "Couldn't load earlier messages."
2536
+ }, wn = [m], Tn = {
2537
+ ...Ct(),
2538
+ p: ({ children: e }) => /* @__PURE__ */ v(_, { children: e })
2539
+ }, En = i(function({ content: e, components: t }) {
2540
+ return /* @__PURE__ */ v("div", {
1352
2541
  className: "bailey-markdown-content",
1353
- children: /* @__PURE__ */ _(f, {
1354
- remarkPlugins: pt,
2542
+ children: /* @__PURE__ */ v(p, {
2543
+ remarkPlugins: wn,
1355
2544
  components: t,
1356
2545
  skipHtml: !0,
1357
2546
  children: e
1358
2547
  })
1359
2548
  });
1360
2549
  });
1361
- function gt(e, t, n) {
2550
+ function Dn(e, t, n) {
1362
2551
  if (e !== "streaming") return;
1363
2552
  let r = t.filter((e) => e.turnSentAt === n?.sentAt);
1364
2553
  return r[r.length - 1];
1365
2554
  }
1366
- function _t(e) {
1367
- if (!(!e || e.kind === "tool_end")) return fe(e);
2555
+ function On(e) {
2556
+ if (!(!e || e.kind === "tool_end")) return tt(e);
1368
2557
  }
1369
- function vt(e) {
2558
+ function kn(e) {
1370
2559
  let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
1371
2560
  hour: "numeric",
1372
2561
  minute: "2-digit"
1373
2562
  });
1374
2563
  return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
1375
2564
  }
1376
- function yt({ chat: e, placeholder: t, replyPlaceholder: r = dt, emptyPlaceholder: i, suggestions: a, onHistoryClick: o, privacyNote: c, resolveActivityIcon: p, className: g, height: y, width: b, hideDeveloperDetails: x = !1, renderMessageActions: S, renderTable: C, renderChart: w, renderMcpApp: T, labels: E, formatMessageTime: D }) {
1377
- let { messages: O, traceEvents: k, lastRequest: A, status: j, error: M, send: N, stop: ee, retryLast: P, clearTrace: F, clearError: I, newChat: L } = e, [R, te] = d(""), z = {
1378
- ...ft,
1379
- ...E
1380
- }, ne = D ?? vt, B = u(null), V = je(B), H = u(null), U = u(null), W = u(!0), re = l(() => Ne({
1381
- renderTable: C,
1382
- renderChart: w
1383
- }), [C, w]), G = l(() => gt(j, k, A), [
2565
+ function An({ chat: e, placeholder: t, replyPlaceholder: r = Sn, emptyPlaceholder: i, suggestions: o, onHistoryClick: c, history: l, locale: m, privacyNote: _, resolveActivityIcon: b, className: ee, height: x, width: S, hideDeveloperDetails: C = !1, renderMessageActions: w, renderTable: T, renderChart: E, renderMcpApp: D, labels: O, formatMessageTime: k }) {
2566
+ let { messages: A, traceEvents: j, lastRequest: M, status: N, error: te, send: P, stop: ne, retryLast: re, clearTrace: ie, clearError: ae, newChat: F } = e, [I, oe] = f(""), L = {
2567
+ ...Cn,
2568
+ ...O
2569
+ }, se = k ?? kn, ce = d(null), le = d(null), ue = d(null), de = d(null), [R, z] = f(!1), fe = d(null), B = d(!1), V = !!c || !!l, H = xt(ce), pe = d(null), U = d(null), me = d(!0), he = u(() => Ct({
2570
+ renderTable: T,
2571
+ renderChart: E
2572
+ }), [T, E]), W = u(() => Dn(N, j, M), [
2573
+ N,
1384
2574
  j,
1385
- k,
1386
- A
1387
- ]), ie = _t(G), K = G?.kind === "tool_end" ? G.at : void 0, ae = O[O.length - 1]?.content.length ?? 0, [oe, se] = d(null), q = oe;
1388
- K !== void 0 && oe?.at !== K && (q = {
2575
+ M
2576
+ ]), G = On(W), K = W?.kind === "tool_end" ? W.at : void 0, ge = A[A.length - 1]?.content.length ?? 0, [_e, ve] = f(null), ye = _e;
2577
+ K !== void 0 && _e?.at !== K && (ye = {
1389
2578
  at: K,
1390
- length: ae
1391
- }, se(q));
1392
- let ce = K !== void 0 && q?.at === K && ae <= q.length, J = ie ?? (ce ? z.thinkingHint : void 0), Y = O.length === 0, X = t ?? (Y ? i ?? ut : r);
2579
+ length: ge
2580
+ }, ve(ye));
2581
+ let q = K !== void 0 && ye?.at === K && ge <= ye.length, be = G ?? (q ? L.thinkingHint : void 0), xe = A.length === 0, J = t ?? (xe ? i ?? xn : r);
1393
2582
  s(() => {
1394
2583
  let e = U.current;
1395
2584
  if (!e) return;
1396
2585
  let t = () => {
1397
2586
  let t = e.scrollHeight - e.scrollTop - e.clientHeight;
1398
- W.current = t < 60;
2587
+ me.current = t < 60;
1399
2588
  };
1400
2589
  return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
1401
2590
  }, []), s(() => {
1402
- W.current && H.current?.scrollIntoView({
1403
- behavior: j === "streaming" ? "auto" : "smooth",
2591
+ me.current && pe.current?.scrollIntoView({
2592
+ behavior: N === "streaming" ? "auto" : "smooth",
1404
2593
  block: "nearest"
1405
2594
  });
1406
- }, [O, j]);
1407
- let Z = (e) => {
1408
- W.current = !0, N(e);
2595
+ }, [A, N]);
2596
+ let Y = (e) => {
2597
+ me.current = !0, P(e);
2598
+ }, X = d(null), Se = () => {
2599
+ let t = U.current;
2600
+ me.current = !1, X.current = t ? {
2601
+ height: t.scrollHeight,
2602
+ top: t.scrollTop
2603
+ } : null, e.loadEarlier?.().catch(() => {
2604
+ X.current = null;
2605
+ });
1409
2606
  };
1410
- return /* @__PURE__ */ _(Se.Provider, {
1411
- value: V,
1412
- children: /* @__PURE__ */ _("div", {
1413
- ref: B,
1414
- className: `bailey-chat-panel${g ? ` ${g}` : ""}`,
1415
- style: y !== void 0 || b !== void 0 ? {
1416
- height: y,
1417
- width: b
2607
+ s(() => {
2608
+ let e = X.current, t = U.current;
2609
+ !e || !t || t.scrollHeight === e.height || (t.scrollTop = e.top + (t.scrollHeight - e.height), X.current = null);
2610
+ }, [A]), s(() => {
2611
+ le.current?.toggleAttribute("inert", R);
2612
+ }, [R]), s(() => {
2613
+ R || !fe.current || ((fe.current === "input" ? ue.current : de.current)?.focus(), fe.current = null);
2614
+ }, [R]);
2615
+ let Z = a((e) => {
2616
+ fe.current = e.restoreFocusTo, z(!1);
2617
+ }, []);
2618
+ return /* @__PURE__ */ v(dt.Provider, {
2619
+ value: H,
2620
+ children: /* @__PURE__ */ y("div", {
2621
+ ref: ce,
2622
+ className: `bailey-chat-panel${ee ? ` ${ee}` : ""}`,
2623
+ style: x !== void 0 || S !== void 0 ? {
2624
+ height: x,
2625
+ width: S
1418
2626
  } : void 0,
1419
- children: /* @__PURE__ */ v("div", {
2627
+ children: [/* @__PURE__ */ y("div", {
1420
2628
  className: "bailey-chat-panel-inner",
2629
+ ref: le,
1421
2630
  children: [
1422
- /* @__PURE__ */ v("div", {
2631
+ /* @__PURE__ */ y("div", {
1423
2632
  className: "bailey-chat-transcript",
1424
2633
  ref: U,
1425
2634
  children: [
1426
- Y && (a && a.length > 0 ? /* @__PURE__ */ v("div", {
2635
+ e.hasEarlier && e.loadEarlier && /* @__PURE__ */ y("div", {
2636
+ className: "bailey-load-earlier",
2637
+ children: [/* @__PURE__ */ v("button", {
2638
+ type: "button",
2639
+ className: "bailey-load-earlier-button",
2640
+ disabled: e.historyStatus === "loading",
2641
+ onClick: Se,
2642
+ children: L.loadEarlierButtonText
2643
+ }), e.historyStatus === "error" && /* @__PURE__ */ v("div", {
2644
+ role: "alert",
2645
+ className: "bailey-load-earlier-error",
2646
+ children: L.loadEarlierErrorText
2647
+ })]
2648
+ }),
2649
+ xe && (o && o.length > 0 ? /* @__PURE__ */ y("div", {
1427
2650
  className: "bailey-suggestions",
1428
- children: [/* @__PURE__ */ _("div", {
2651
+ children: [/* @__PURE__ */ v("div", {
1429
2652
  className: "bailey-suggestions-title",
1430
- children: z.suggestionsTitle
1431
- }), a.map((e, t) => /* @__PURE__ */ v("button", {
2653
+ children: L.suggestionsTitle
2654
+ }), o.map((e, t) => /* @__PURE__ */ y("button", {
1432
2655
  type: "button",
1433
- onClick: () => Z(e.value ?? e.label),
2656
+ onClick: () => Y(e.value ?? e.label),
1434
2657
  className: "bailey-suggestion-card",
1435
- children: [/* @__PURE__ */ _("span", { children: e.label }), /* @__PURE__ */ _(Ie, { className: "bailey-suggestion-icon" })]
2658
+ children: [/* @__PURE__ */ v("span", { children: e.label }), /* @__PURE__ */ v(Et, { className: "bailey-suggestion-icon" })]
1436
2659
  }, `${e.label}-${t}`))]
1437
- }) : /* @__PURE__ */ _("div", {
2660
+ }) : /* @__PURE__ */ v("div", {
1438
2661
  className: "bailey-empty-state",
1439
- children: z.emptyStateMessage
2662
+ children: L.emptyStateMessage
1440
2663
  })),
1441
- O.map((e, t) => {
1442
- let r = e.role === "assistant" && t === O.length - 1, i = j === "streaming" && r && e.content === "", a = e.role === "assistant" ? be(k, e.createdAt) : [], o = a.some((e) => e.status === "running");
1443
- return /* @__PURE__ */ _("div", {
2664
+ A.map((e, t) => {
2665
+ let r = e.role === "assistant" && t === A.length - 1, i = N === "streaming" && r && e.content === "", a = e.role === "assistant" ? lt(j, e.createdAt) : [], o = a.some((e) => e.status === "running");
2666
+ return /* @__PURE__ */ v("div", {
1444
2667
  className: e.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
1445
- children: e.role === "user" ? /* @__PURE__ */ v("div", {
2668
+ children: e.role === "user" ? /* @__PURE__ */ y("div", {
1446
2669
  className: "bailey-user-message",
1447
- children: [/* @__PURE__ */ v("div", {
2670
+ children: [/* @__PURE__ */ y("div", {
1448
2671
  className: "bailey-message-meta",
1449
- children: [/* @__PURE__ */ _("span", {
2672
+ children: [/* @__PURE__ */ v("span", {
1450
2673
  className: "bailey-message-meta-name",
1451
- children: z.youLabel
1452
- }), e.createdAt !== void 0 && /* @__PURE__ */ _("span", { children: ne(e.createdAt) })]
1453
- }), /* @__PURE__ */ _("div", {
2674
+ children: L.youLabel
2675
+ }), e.createdAt !== void 0 && /* @__PURE__ */ v("span", { children: se(e.createdAt) })]
2676
+ }), /* @__PURE__ */ v("div", {
1454
2677
  className: "bailey-user-bubble",
1455
2678
  children: e.content
1456
2679
  })]
1457
- }) : i ? o ? /* @__PURE__ */ _(ct, {
2680
+ }) : i ? o ? /* @__PURE__ */ v(sn, {
1458
2681
  steps: a,
1459
- resolveActivityIcon: p
1460
- }) : /* @__PURE__ */ _("div", {
1461
- className: "bailey-thinking-hint",
1462
- children: ie ?? z.thinkingHint
2682
+ resolveActivityIcon: b
1463
2683
  }) : /* @__PURE__ */ v("div", {
2684
+ className: "bailey-thinking-hint",
2685
+ children: G ?? L.thinkingHint
2686
+ }) : /* @__PURE__ */ y("div", {
1464
2687
  className: "bailey-assistant-message",
1465
2688
  children: [
1466
- !e.streaming && /* @__PURE__ */ _(lt, {
2689
+ !e.streaming && /* @__PURE__ */ v(cn, {
1467
2690
  steps: a,
1468
- labels: z,
1469
- resolveActivityIcon: p
2691
+ labels: L,
2692
+ resolveActivityIcon: b
1470
2693
  }),
1471
- /* @__PURE__ */ _(ht, {
2694
+ /* @__PURE__ */ v(En, {
1472
2695
  content: e.content,
1473
- components: re
2696
+ components: he
1474
2697
  }),
1475
- e.parts?.map((e, t) => e.type === "image" ? /* @__PURE__ */ _($e, {
2698
+ e.parts?.map((e, t) => e.type === "image" ? /* @__PURE__ */ v(Zt, {
1476
2699
  src: e.src,
1477
2700
  alt: e.alt
1478
- }, t) : e.type === "mcp_app" ? /* @__PURE__ */ _(n, { children: T ? T(e) : /* @__PURE__ */ _(ot, {
2701
+ }, t) : e.type === "mcp_app" ? /* @__PURE__ */ v(n, { children: D ? D(e) : /* @__PURE__ */ v(an, {
1479
2702
  ...e,
1480
- title: e.title ?? z.mcpAppDefaultTitle
2703
+ title: e.title ?? L.mcpAppDefaultTitle
1481
2704
  }) }, t) : null),
1482
- e.streaming && /* @__PURE__ */ _(ct, {
2705
+ e.streaming && /* @__PURE__ */ v(sn, {
1483
2706
  steps: a,
1484
- resolveActivityIcon: p
2707
+ resolveActivityIcon: b
1485
2708
  }),
1486
- e.streaming && J && !o && /* @__PURE__ */ _("div", {
2709
+ e.streaming && be && !o && /* @__PURE__ */ v("div", {
1487
2710
  className: "bailey-streaming-hint",
1488
- children: J
2711
+ children: be
1489
2712
  }),
1490
- !e.streaming && /* @__PURE__ */ v("div", {
2713
+ !e.streaming && /* @__PURE__ */ y("div", {
1491
2714
  className: "bailey-message-actions",
1492
- children: [/* @__PURE__ */ _(We, {
2715
+ children: [/* @__PURE__ */ v(Vt, {
1493
2716
  markdown: e.content,
1494
- ariaLabel: z.copyButtonAriaLabel,
1495
- tooltipDefaultText: z.copyButtonTooltipDefault,
1496
- tooltipCopiedText: z.copyButtonTooltipCopied
1497
- }), S?.(e)]
2717
+ ariaLabel: L.copyButtonAriaLabel,
2718
+ tooltipDefaultText: L.copyButtonTooltipDefault,
2719
+ tooltipCopiedText: L.copyButtonTooltipCopied
2720
+ }), w?.(e)]
1498
2721
  })
1499
2722
  ]
1500
2723
  })
1501
2724
  }, e.id);
1502
2725
  }),
1503
- /* @__PURE__ */ _("div", { ref: H })
2726
+ /* @__PURE__ */ v("div", { ref: pe })
1504
2727
  ]
1505
2728
  }),
1506
- M && /* @__PURE__ */ v("div", {
2729
+ te && /* @__PURE__ */ y("div", {
1507
2730
  className: "bailey-error-banner",
1508
2731
  role: "alert",
1509
- children: [/* @__PURE__ */ _("span", { children: M }), /* @__PURE__ */ v("div", {
2732
+ children: [/* @__PURE__ */ v("span", { children: te }), /* @__PURE__ */ y("div", {
1510
2733
  className: "bailey-error-actions",
1511
- children: [/* @__PURE__ */ _("button", {
2734
+ children: [/* @__PURE__ */ v("button", {
1512
2735
  type: "button",
1513
- onClick: P,
2736
+ onClick: re,
1514
2737
  className: "bailey-retry-button",
1515
- children: z.retryButtonText
1516
- }), /* @__PURE__ */ _("button", {
2738
+ children: L.retryButtonText
2739
+ }), /* @__PURE__ */ v("button", {
1517
2740
  type: "button",
1518
- onClick: I,
1519
- "aria-label": z.dismissErrorAriaLabel,
2741
+ onClick: ae,
2742
+ "aria-label": L.dismissErrorAriaLabel,
1520
2743
  className: "bailey-dismiss-button",
1521
2744
  children: "✕"
1522
2745
  })]
1523
2746
  })]
1524
2747
  }),
1525
- !x && /* @__PURE__ */ _(Qe, {
1526
- events: k,
1527
- lastRequest: A,
1528
- onClear: F
2748
+ !C && /* @__PURE__ */ v(Xt, {
2749
+ events: j,
2750
+ lastRequest: M,
2751
+ onClear: ie
1529
2752
  }),
1530
- /* @__PURE__ */ v("div", {
2753
+ /* @__PURE__ */ y("div", {
1531
2754
  className: "bailey-input-area",
1532
- children: [/* @__PURE__ */ v("form", {
2755
+ children: [/* @__PURE__ */ y("form", {
1533
2756
  onSubmit: (e) => {
1534
- e.preventDefault(), !(!R.trim() || j === "streaming") && (Z(R), te(""));
2757
+ e.preventDefault(), !(!I.trim() || N === "streaming") && (Y(I), oe(""));
1535
2758
  },
1536
2759
  className: "bailey-input-row",
1537
- children: [/* @__PURE__ */ _("input", {
2760
+ children: [/* @__PURE__ */ v("input", {
2761
+ ref: ue,
1538
2762
  type: "text",
1539
- placeholder: X,
1540
- "aria-label": X,
1541
- value: R,
1542
- onChange: (e) => te(e.target.value),
1543
- disabled: j === "streaming",
2763
+ placeholder: J,
2764
+ "aria-label": J,
2765
+ value: I,
2766
+ onChange: (e) => oe(e.target.value),
2767
+ disabled: N === "streaming",
1544
2768
  className: "bailey-input"
1545
- }), j === "streaming" ? /* @__PURE__ */ _(h.Provider, {
2769
+ }), N === "streaming" ? /* @__PURE__ */ v(g.Provider, {
1546
2770
  delayDuration: 200,
1547
- children: /* @__PURE__ */ v(h.Root, { children: [/* @__PURE__ */ _(h.Trigger, {
2771
+ children: /* @__PURE__ */ y(g.Root, { children: [/* @__PURE__ */ v(g.Trigger, {
1548
2772
  asChild: !0,
1549
- children: /* @__PURE__ */ _("button", {
2773
+ children: /* @__PURE__ */ v("button", {
1550
2774
  type: "button",
1551
- onClick: ee,
1552
- "aria-label": z.stopAriaLabel,
2775
+ onClick: ne,
2776
+ "aria-label": L.stopAriaLabel,
1553
2777
  className: "bailey-stop-button",
1554
- children: /* @__PURE__ */ _(Fe, { className: "bailey-stop-icon" })
2778
+ children: /* @__PURE__ */ v(Tt, { className: "bailey-stop-icon" })
1555
2779
  })
1556
- }), /* @__PURE__ */ _(h.Portal, {
1557
- container: V instanceof ShadowRoot ? V : void 0,
1558
- children: /* @__PURE__ */ v(h.Content, {
2780
+ }), /* @__PURE__ */ v(g.Portal, {
2781
+ container: H instanceof ShadowRoot ? H : void 0,
2782
+ children: /* @__PURE__ */ y(g.Content, {
1559
2783
  side: "top",
1560
2784
  className: "bailey-tooltip-content",
1561
- children: [z.stopButtonText, /* @__PURE__ */ _(h.Arrow, { className: "bailey-tooltip-arrow" })]
2785
+ children: [L.stopButtonText, /* @__PURE__ */ v(g.Arrow, { className: "bailey-tooltip-arrow" })]
1562
2786
  })
1563
2787
  })] })
1564
- }) : /* @__PURE__ */ _("button", {
2788
+ }) : /* @__PURE__ */ v("button", {
1565
2789
  type: "submit",
1566
- "aria-label": z.sendAriaLabel,
1567
- disabled: !R.trim(),
2790
+ "aria-label": L.sendAriaLabel,
2791
+ disabled: !I.trim(),
1568
2792
  className: "bailey-send-button",
1569
- children: /* @__PURE__ */ _(Pe, { className: "bailey-send-icon" })
2793
+ children: /* @__PURE__ */ v(wt, { className: "bailey-send-icon" })
1570
2794
  })]
1571
- }), (!Y || o) && /* @__PURE__ */ v(m.Root, { children: [/* @__PURE__ */ _(m.Trigger, {
2795
+ }), (!xe || V) && /* @__PURE__ */ y(h.Root, { children: [/* @__PURE__ */ v(h.Trigger, {
1572
2796
  asChild: !0,
1573
- children: /* @__PURE__ */ _("button", {
2797
+ children: /* @__PURE__ */ v("button", {
1574
2798
  type: "button",
1575
- "aria-label": z.menuAriaLabel,
2799
+ ref: de,
2800
+ "aria-label": L.menuAriaLabel,
1576
2801
  className: "bailey-menu-button",
1577
- children: /* @__PURE__ */ _(Ve, { className: "bailey-menu-icon" })
2802
+ children: /* @__PURE__ */ v(jt, { className: "bailey-menu-icon" })
1578
2803
  })
1579
- }), /* @__PURE__ */ _(m.Portal, {
1580
- container: V instanceof ShadowRoot ? V : void 0,
1581
- children: /* @__PURE__ */ v(m.Content, {
2804
+ }), /* @__PURE__ */ v(h.Portal, {
2805
+ container: H instanceof ShadowRoot ? H : void 0,
2806
+ children: /* @__PURE__ */ y(h.Content, {
1582
2807
  side: "top",
1583
2808
  align: "end",
1584
2809
  sideOffset: 8,
1585
2810
  className: "bailey-menu-content",
1586
- children: [!Y && /* @__PURE__ */ v(m.Item, {
1587
- onSelect: () => L(),
2811
+ onCloseAutoFocus: (e) => {
2812
+ B.current &&= (e.preventDefault(), !1);
2813
+ },
2814
+ children: [!xe && /* @__PURE__ */ y(h.Item, {
2815
+ onSelect: () => F(),
1588
2816
  className: "bailey-menu-item",
1589
- children: [/* @__PURE__ */ _(He, { className: "bailey-menu-item-icon" }), z.newChatButtonText]
1590
- }), o && /* @__PURE__ */ v(m.Item, {
1591
- onSelect: () => o(),
2817
+ children: [/* @__PURE__ */ v(Mt, { className: "bailey-menu-item-icon" }), L.newChatButtonText]
2818
+ }), V && /* @__PURE__ */ y(h.Item, {
2819
+ onSelect: () => {
2820
+ if (c) {
2821
+ c();
2822
+ return;
2823
+ }
2824
+ B.current = !0, z(!0);
2825
+ },
1592
2826
  className: "bailey-menu-item",
1593
- children: [/* @__PURE__ */ _(ze, { className: "bailey-menu-item-icon" }), z.historyMenuItemText]
2827
+ children: [/* @__PURE__ */ v(kt, { className: "bailey-menu-item-icon" }), L.historyMenuItemText]
1594
2828
  })]
1595
2829
  })
1596
2830
  })] })]
1597
2831
  }),
1598
- (Y || c?.alwaysVisible) && c && /* @__PURE__ */ _("div", {
2832
+ (xe || _?.alwaysVisible) && _ && /* @__PURE__ */ v("div", {
1599
2833
  className: "bailey-privacy-note",
1600
- children: /* @__PURE__ */ _(f, {
1601
- remarkPlugins: pt,
1602
- components: mt,
2834
+ children: /* @__PURE__ */ v(p, {
2835
+ remarkPlugins: wn,
2836
+ components: Tn,
1603
2837
  skipHtml: !0,
1604
- children: c.markdown
2838
+ children: _.markdown
1605
2839
  })
1606
2840
  })
1607
2841
  ]
1608
- })
2842
+ }), R && l && !c && /* @__PURE__ */ v(gn, {
2843
+ client: l.client,
2844
+ pageSize: l.pageSize,
2845
+ chat: e,
2846
+ labels: L,
2847
+ locale: m,
2848
+ onClose: Z
2849
+ })]
1609
2850
  })
1610
2851
  });
1611
2852
  }
1612
2853
  //#endregion
2854
+ //#region src/ui/BaileyFeedbackButtons.tsx
2855
+ var jn = {
2856
+ feedbackGroupLabel: "Rate this response",
2857
+ feedbackThumbsUpAriaLabel: "Good response",
2858
+ feedbackThumbsDownAriaLabel: "Bad response",
2859
+ feedbackReasonGroupLabel: "What went wrong?",
2860
+ feedbackCommentLabel: "Tell us more",
2861
+ feedbackCommentPlaceholder: "What should Bailey have said or done differently?",
2862
+ feedbackSubmitText: "Submit",
2863
+ feedbackCancelText: "Cancel",
2864
+ feedbackThanksText: "Thanks for your feedback",
2865
+ feedbackUndoText: "Undo",
2866
+ feedbackEditText: "Edit",
2867
+ feedbackAddCommentText: "Add a comment",
2868
+ feedbackSavingText: "Saving…",
2869
+ feedbackErrorText: "Couldn't save your feedback. Try again.",
2870
+ feedbackPrivacyNote: "Your comment is saved with this conversation and may be reviewed by support.",
2871
+ feedbackReasonInaccurate: "Inaccurate",
2872
+ feedbackReasonUnhelpful: "Unhelpful",
2873
+ feedbackReasonUnsafe: "Unsafe",
2874
+ feedbackReasonTooLong: "Too long",
2875
+ feedbackReasonOther: "Other"
2876
+ }, Mn = 2e3, Nn = [
2877
+ "inaccurate",
2878
+ "unhelpful",
2879
+ "unsafe",
2880
+ "too_long",
2881
+ "other"
2882
+ ], Pn = {
2883
+ inaccurate: "feedbackReasonInaccurate",
2884
+ unhelpful: "feedbackReasonUnhelpful",
2885
+ unsafe: "feedbackReasonUnsafe",
2886
+ too_long: "feedbackReasonTooLong",
2887
+ other: "feedbackReasonOther"
2888
+ }, Fn = (e) => Nn.includes(e) ? e : "other";
2889
+ function In(e) {
2890
+ return Array.from(new Set((e ?? Nn).map(Fn)));
2891
+ }
2892
+ function Ln(e) {
2893
+ return typeof e == "number" && e > 0 ? Math.min(Math.floor(e), Mn) : Mn;
2894
+ }
2895
+ function Rn(e, t) {
2896
+ if (e === null || t === null) return e === t;
2897
+ let n = e.reasonCodes ?? [], r = t.reasonCodes ?? [];
2898
+ return e.rating === t.rating && (e.comment ?? "") === (t.comment ?? "") && n.length === r.length && n.every((e, t) => e === r[t]);
2899
+ }
2900
+ function zn(e) {
2901
+ return e.messageId ? /* @__PURE__ */ v(Bn, { ...e }, e.messageId) : null;
2902
+ }
2903
+ function Bn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOptions: i, maxCommentLength: a, labels: o, className: l }) {
2904
+ let u = {
2905
+ ...jn,
2906
+ ...o
2907
+ }, p = In(i), m = Ln(a), h = r ? { rating: r } : null, [b, ee] = f(h), [x, S] = f(r ?? null), [C, w] = f(!1), [T, E] = f("down"), [D, O] = f([]), [k, A] = f(""), [j, M] = f(!1), [N, te] = f(!1), [P, ne] = f(!1), [re, ie] = f(!1), ae = d(h), F = d(null), I = d(0), oe = d(!1), L = d(!0), se = d(null), ce = d(null), le = d(null), ue = d(null), de = d(null), R = St(ce), z = c(), fe = `${z}-comment`, B = `${z}-counter`, V = `${z}-privacy`;
2908
+ s(() => (L.current = !0, () => {
2909
+ L.current = !1;
2910
+ }), []), s(() => {
2911
+ C && de.current?.focus();
2912
+ }, [C]), s(() => {
2913
+ se.current && !P && !C && ((se.current === "up" ? le : ue).current?.focus(), se.current = null);
2914
+ });
2915
+ let H = () => {
2916
+ O([]), A("");
2917
+ }, pe = async (r) => {
2918
+ try {
2919
+ return r.kind === "clear" ? await n({ messageId: e }) : await t({
2920
+ messageId: e,
2921
+ ...r.snapshot
2922
+ }), !0;
2923
+ } catch {
2924
+ return !1;
2925
+ }
2926
+ }, U = async () => {
2927
+ if (!oe.current) {
2928
+ oe.current = !0, te(!0);
2929
+ try {
2930
+ for (; F.current && L.current;) {
2931
+ let e = F.current, t = e.kind === "clear" ? null : e.snapshot, n = !(e.kind === "submit" && e.formSubmit) && Rn(t, ae.current) || await pe(e);
2932
+ if (!L.current) return;
2933
+ let r = F.current?.version !== e.version;
2934
+ !n && r || (n ? (ae.current = t, ee(t)) : (S(ae.current?.rating ?? null), ie(!0)), r || (F.current = null, ne(!1), n && e.kind === "submit" && e.formSubmit && (w(!1), M(!0), se.current = e.snapshot.rating)));
2935
+ }
2936
+ } finally {
2937
+ oe.current = !1, L.current && te(!1);
2938
+ }
2939
+ }
2940
+ }, me = (e) => {
2941
+ I.current += 1, F.current = {
2942
+ ...e,
2943
+ version: I.current
2944
+ }, ie(!1), U();
2945
+ }, he = () => {
2946
+ S(null), w(!1), M(!1), H(), me({ kind: "clear" });
2947
+ }, W = (e) => {
2948
+ if (!P) {
2949
+ if (x === e) {
2950
+ he();
2951
+ return;
2952
+ }
2953
+ S(e), M(!1), H(), e === "down" ? (E("down"), w(!0)) : w(!1), me({
2954
+ kind: "submit",
2955
+ snapshot: { rating: e },
2956
+ formSubmit: !1
2957
+ });
2958
+ }
2959
+ }, G = (e) => {
2960
+ x !== null && (E(x), O((e?.reasonCodes ?? []).map(Fn)), A(e?.comment ?? ""), ie(!1), w(!0));
2961
+ }, K = () => {
2962
+ P || (w(!1), ie(!1), H(), se.current = T);
2963
+ }, ge = () => {
2964
+ if (P) return;
2965
+ let e = k.trim(), t = p.filter((e) => D.includes(e)), n = {
2966
+ rating: T,
2967
+ ...t.length > 0 ? { reasonCodes: t } : {},
2968
+ ...e ? { comment: e } : {}
2969
+ };
2970
+ ne(!0), S(T), me({
2971
+ kind: "submit",
2972
+ snapshot: n,
2973
+ formSubmit: !0
2974
+ });
2975
+ }, _e = (e) => {
2976
+ O((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
2977
+ }, ve = (e) => {
2978
+ e.key === "Escape" && (e.stopPropagation(), K());
2979
+ }, ye = x !== null && b?.rating === x && !N && !C, q = !!b && (!!b.comment || (b.reasonCodes?.length ?? 0) > 0), be = N ? u.feedbackSavingText : ye ? u.feedbackThanksText : "", xe = (e) => {
2980
+ let t = x === e, n = e === "up" ? u.feedbackThumbsUpAriaLabel : u.feedbackThumbsDownAriaLabel, r = e === "up" ? Ft : It;
2981
+ return /* @__PURE__ */ y(g.Root, { children: [/* @__PURE__ */ v(g.Trigger, {
2982
+ asChild: !0,
2983
+ children: /* @__PURE__ */ v("button", {
2984
+ ref: e === "up" ? le : ue,
2985
+ type: "button",
2986
+ className: "bailey-feedback-thumb",
2987
+ "aria-pressed": t,
2988
+ "aria-label": n,
2989
+ "aria-busy": t && N ? !0 : void 0,
2990
+ disabled: P,
2991
+ onClick: () => W(e),
2992
+ children: /* @__PURE__ */ v(r, {
2993
+ className: "bailey-feedback-icon",
2994
+ filled: t
2995
+ })
2996
+ })
2997
+ }), /* @__PURE__ */ v(g.Portal, {
2998
+ container: R instanceof ShadowRoot ? R : void 0,
2999
+ children: /* @__PURE__ */ y(g.Content, {
3000
+ side: "top",
3001
+ className: "bailey-tooltip-content",
3002
+ children: [n, /* @__PURE__ */ v(g.Arrow, { className: "bailey-tooltip-arrow" })]
3003
+ })
3004
+ })] });
3005
+ };
3006
+ return /* @__PURE__ */ y("div", {
3007
+ ref: ce,
3008
+ className: `bailey-feedback${l ? ` ${l}` : ""}`,
3009
+ children: [
3010
+ /* @__PURE__ */ v(g.Provider, {
3011
+ delayDuration: 200,
3012
+ children: /* @__PURE__ */ y("div", {
3013
+ role: "group",
3014
+ "aria-label": u.feedbackGroupLabel,
3015
+ "aria-busy": N ? !0 : void 0,
3016
+ className: "bailey-feedback-thumbs",
3017
+ children: [xe("up"), xe("down")]
3018
+ })
3019
+ }),
3020
+ /* @__PURE__ */ y("span", {
3021
+ role: "status",
3022
+ className: "bailey-feedback-status",
3023
+ children: [N && /* @__PURE__ */ v("span", {
3024
+ className: "bailey-feedback-spinner",
3025
+ "aria-hidden": "true"
3026
+ }), be]
3027
+ }),
3028
+ ye && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
3029
+ type: "button",
3030
+ className: "bailey-feedback-link",
3031
+ onClick: () => G(b),
3032
+ children: j || q ? u.feedbackEditText : u.feedbackAddCommentText
3033
+ }), /* @__PURE__ */ v("button", {
3034
+ type: "button",
3035
+ className: "bailey-feedback-link",
3036
+ onClick: he,
3037
+ children: u.feedbackUndoText
3038
+ })] }),
3039
+ re && /* @__PURE__ */ v("span", {
3040
+ role: "alert",
3041
+ className: "bailey-feedback-error",
3042
+ children: u.feedbackErrorText
3043
+ }),
3044
+ C && /* @__PURE__ */ y("div", {
3045
+ className: "bailey-feedback-form",
3046
+ onKeyDown: ve,
3047
+ children: [
3048
+ p.length > 0 && /* @__PURE__ */ y("fieldset", {
3049
+ className: "bailey-feedback-reasons",
3050
+ children: [/* @__PURE__ */ v("legend", {
3051
+ className: "bailey-feedback-legend",
3052
+ children: u.feedbackReasonGroupLabel
3053
+ }), /* @__PURE__ */ v("div", {
3054
+ className: "bailey-feedback-chips",
3055
+ children: p.map((e, t) => /* @__PURE__ */ v("button", {
3056
+ ref: t === 0 ? (e) => {
3057
+ de.current = e;
3058
+ } : void 0,
3059
+ type: "button",
3060
+ className: "bailey-feedback-chip",
3061
+ "aria-pressed": D.includes(e),
3062
+ disabled: P,
3063
+ onClick: () => _e(e),
3064
+ children: u[Pn[e]]
3065
+ }, e))
3066
+ })]
3067
+ }),
3068
+ /* @__PURE__ */ v("label", {
3069
+ htmlFor: fe,
3070
+ className: "bailey-feedback-legend",
3071
+ children: u.feedbackCommentLabel
3072
+ }),
3073
+ /* @__PURE__ */ v("textarea", {
3074
+ id: fe,
3075
+ ref: p.length === 0 ? (e) => {
3076
+ de.current = e;
3077
+ } : void 0,
3078
+ className: "bailey-feedback-textarea",
3079
+ value: k,
3080
+ maxLength: m,
3081
+ placeholder: u.feedbackCommentPlaceholder,
3082
+ "aria-describedby": `${B} ${V}`,
3083
+ disabled: P,
3084
+ onChange: (e) => A(e.target.value.slice(0, m))
3085
+ }),
3086
+ /* @__PURE__ */ y("div", {
3087
+ className: "bailey-feedback-meta",
3088
+ children: [/* @__PURE__ */ v("span", {
3089
+ id: V,
3090
+ className: "bailey-feedback-privacy",
3091
+ children: u.feedbackPrivacyNote
3092
+ }), /* @__PURE__ */ v("span", {
3093
+ id: B,
3094
+ className: "bailey-feedback-counter",
3095
+ children: `${k.length} / ${m}`
3096
+ })]
3097
+ }),
3098
+ /* @__PURE__ */ y("div", {
3099
+ className: "bailey-feedback-buttons",
3100
+ children: [/* @__PURE__ */ v("button", {
3101
+ type: "button",
3102
+ className: "bailey-feedback-button",
3103
+ disabled: P,
3104
+ onClick: K,
3105
+ children: u.feedbackCancelText
3106
+ }), /* @__PURE__ */ v("button", {
3107
+ type: "button",
3108
+ className: "bailey-feedback-button bailey-feedback-button-primary",
3109
+ disabled: P,
3110
+ onClick: ge,
3111
+ children: P ? u.feedbackSavingText : u.feedbackSubmitText
3112
+ })]
3113
+ })
3114
+ ]
3115
+ })
3116
+ ]
3117
+ });
3118
+ }
3119
+ //#endregion
1613
3120
  //#region src/index.ts
1614
- var bt = "0.3.1-pre.2";
3121
+ var Vn = "0.3.1-pre.2";
1615
3122
  //#endregion
1616
- export { Be as ActivityIcon, Ie as ArrowUpRightIcon, bt as BAILEYAI_CHAT_UI_VERSION, re as BAILEY_CHART_PROMPT_FRAGMENT, te as BAILEY_TABLE_GRID_ROW_THRESHOLD, yt as BaileyChatPanel, Qe as BaileyTracePanel, We as CopyMarkdownButton, Pe as HeartIcon, ce as TRACE_KIND_LABEL, Ne as createBaileyMarkdownComponents, O as extractPseudoToolCalls, U as extractTableData, me as formatTraceGap, pe as formatTraceTime, ve as hasTraceFailure, e as isSafeMarkdownUrl, F as joinInstructions, q as parseBaileyChartSpec, A as parseSseFrames, R as resolveToolCall, W as shouldUseGrid, ye as toActivityLines, be as toToolSteps, he as toTraceRows, _e as toTraceSegments, Z as traceEventArgsDetail, fe as traceEventHint, le as traceEventOutputDetail, de as traceEventRawDetail, X as traceEventSummary, Y as traceEventToolName, ge as traceSummaryLine, P as useBaileyChat };
3123
+ export { At as ActivityIcon, Et as ArrowUpRightIcon, Vn as BAILEYAI_CHAT_UI_VERSION, ze as BAILEY_CHART_PROMPT_FRAGMENT, je as BAILEY_TABLE_GRID_ROW_THRESHOLD, V as BaileyApiError, An as BaileyChatPanel, pe as BaileyCleanupError, zn as BaileyFeedbackButtons, gn as BaileyHistoryDrawer, Xt as BaileyTracePanel, Vt as CopyMarkdownButton, ie as DEFAULT_CONVERSATION_STORAGE_KEY, wt as HeartIcon, qe as TRACE_KIND_LABEL, It as ThumbDownIcon, Ft as ThumbUpIcon, De as createBaileyClient, Q as createBaileyFeedbackHandlers, Ct as createBaileyMarkdownComponents, F as createMemoryConversationStorage, ae as createSessionConversationStorage, O as extractPseudoToolCalls, Le as extractTableData, hn as formatRelativeTime, rt as formatTraceGap, nt as formatTraceTime, st as hasTraceFailure, re as isConversationIdForSub, e as isSafeMarkdownUrl, Oe as joinInstructions, te as mapTranscript, ne as mergeEarlierPage, Ke as parseBaileyChartSpec, A as parseSseFrames, $ as resolveToolCall, Re as shouldUseGrid, ct as toActivityLines, lt as toToolSteps, it as toTraceRows, ot as toTraceSegments, Ze as traceEventArgsDetail, tt as traceEventHint, Qe as traceEventOutputDetail, et as traceEventRawDetail, Xe as traceEventSummary, Ye as traceEventToolName, at as traceSummaryLine, B as useBaileyChat, me as useBaileyConversations };