@icanbwell/baileyai-chat-ui 1.0.28 → 1.1.0

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