@icanbwell/baileyai-chat-ui 1.0.16 → 1.0.17

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