@icanbwell/baileyai-chat-ui 1.0.28 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,28 +1,28 @@
1
- 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
9
- var b = "search_tools|call_tool|function_calls|function_result", x = RegExp(`<(${b})>([\\s\\S]*?)<\\/\\1>`, "g"), S = RegExp(`<(?:${b})>[\\s\\S]*$`), C = /<name>([\s\S]*?)<\/name>/, w = /<arguments>([\s\S]*?)<\/arguments>/, T = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, E = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
10
- function D(e) {
11
- let t = C.exec(e)?.[1]?.trim() || "unknown_tool", n = w.exec(e)?.[1]?.trim();
8
+ // src/utils/pseudoToolCalls.ts
9
+ var b = "search_tools|call_tool|function_calls|function_result", ee = RegExp(`<(${b})>([\\s\\S]*?)<\\/\\1>`, "g"), x = RegExp(`<(?:${b})>[\\s\\S]*$`), S = /<name>([\s\S]*?)<\/name>/, C = /<arguments>([\s\S]*?)<\/arguments>/, w = /<invoke\s+name="([^"]*)"\s*>([\s\S]*?)<\/invoke>/g, T = /<parameter\s+name="([^"]*)"\s*>([\s\S]*?)<\/parameter>/g;
10
+ function E(e) {
11
+ let t = S.exec(e)?.[1]?.trim() || "unknown_tool", n = C.exec(e)?.[1]?.trim();
12
12
  return n ? {
13
13
  name: t,
14
14
  args: n
15
15
  } : { name: t };
16
16
  }
17
- function O(e) {
17
+ function D(e) {
18
18
  let t = [];
19
- T.lastIndex = 0;
19
+ w.lastIndex = 0;
20
20
  let n;
21
- for (; (n = T.exec(e)) !== null;) {
21
+ for (; (n = w.exec(e)) !== null;) {
22
22
  let [, e, r] = n, i = {};
23
- E.lastIndex = 0;
23
+ T.lastIndex = 0;
24
24
  let a;
25
- for (; (a = E.exec(r)) !== null;) i[a[1]] = a[2].trim();
25
+ for (; (a = T.exec(r)) !== null;) i[a[1]] = a[2].trim();
26
26
  let o = e.trim() || "unknown_tool";
27
27
  t.push(Object.keys(i).length > 0 ? {
28
28
  name: o,
@@ -31,14 +31,14 @@ function O(e) {
31
31
  }
32
32
  return t;
33
33
  }
34
- function k(e, t = {}) {
35
- let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(x, (e, t, n) => (t === "call_tool" ? r.push(D(n)) : t === "search_tools" ? r.push({
34
+ function O(e, t = {}) {
35
+ let { hideOpenBlock: n = !0 } = t, r = [], i = e.replace(ee, (e, t, n) => (t === "call_tool" ? r.push(E(n)) : t === "search_tools" ? r.push({
36
36
  name: "search_tools",
37
37
  args: n.trim()
38
- }) : t === "function_calls" ? r.push(...O(n)) : r.push({
38
+ }) : t === "function_calls" ? r.push(...D(n)) : r.push({
39
39
  name: "function_result",
40
40
  args: n.trim()
41
- }), "")), a = n ? i.replace(S, "") : i;
41
+ }), "")), a = n ? i.replace(x, "") : i;
42
42
  return r.length === 0 && a === i ? {
43
43
  cleanedText: i,
44
44
  matches: r
@@ -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 ?? M(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 M(e) {
115
+ switch (e.kind) {
116
+ case "http": return `Bailey request failed (status ${e.status})`;
117
+ case "timeout": return "Bailey request timed out";
118
+ case "aborted": return "Bailey request aborted";
119
+ case "invalid-response": return `Bailey returned an unreadable response (status ${e.status})`;
120
+ default: return "Bailey request failed (network error)";
121
+ }
122
+ }
123
+ var N = class extends Error {
124
+ operation;
125
+ constructor(e) {
126
+ super(`Bailey cleanup failed (${e.operation})`), this.name = "BaileyCleanupError", this.operation = e.operation;
127
+ }
128
+ }, P = {
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
+ }, F = (e) => Object.hasOwn(P, e) ? e : "other";
135
+ function I(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(F);
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 te(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" ? I(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 ne = (e) => e.serverMessageId ?? e.id;
161
+ function re(e) {
162
+ let t = new Set(e.current.map(ne)), n = e.earlier.filter((e) => !t.has(ne(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 ie(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 ae = "baileyai-chat-ui:conversation";
201
+ function R() {
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 z() {
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) => {
216
+ // src/logic/useBaileyChat.ts
217
+ var B = 200, oe = 100, se = 15e4, ce = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `bailey-${Date.now()}-${Math.random().toString(36).slice(2)}`, le = (e, t, n) => {
175
218
  if (e === 401 || e === 403) return "Bailey isn't reachable with your current login.";
176
219
  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;
220
+ return i ? `${r} ${i.length > B ? `${i.slice(0, B)}…` : i}` : r;
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) {
@@ -194,129 +237,129 @@ function de(e, t, n, r) {
194
237
  r(e, "write");
195
238
  }
196
239
  }
197
- function fe(e, t, n) {
240
+ function H(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 U = (e, t) => t ? `${e}:${t}` : e;
248
+ function fe(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
+ H(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 W = ({ 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: _ = ae, sendFullTranscript: v = !1, onStorageError: y, onContextLoss: b }) => {
265
+ let [ee, x] = f([]), [S, C] = f([]), [w, T] = f(null), [E, D] = f("idle"), [k, M] = f(null), N = h !== void 0 && h.trim() === "", P = N ? void 0 : h?.trim() || void 0, F = u(() => R(), []), I = N ? null : g === void 0 ? F : g || null, ne = d(y), z = d(b);
223
266
  s(() => {
224
- ae.current = y, le.current = b;
267
+ ne.current = y, z.current = b;
225
268
  }, [y, b]);
226
- let z = a((e, t) => {
269
+ let B = a((e, t) => {
227
270
  try {
228
- ae.current?.(e, t);
271
+ ne.current?.(e, t);
229
272
  } catch {}
230
- }, []), B = (e) => pe({
273
+ }, []), V = (e) => fe({
231
274
  seed: m,
232
- sub: N,
275
+ sub: P,
233
276
  storage: I,
234
- key: R(_, N),
277
+ key: U(_, P),
235
278
  report: e
236
- }), [V] = f(() => {
279
+ }), [W] = f(() => {
237
280
  let e = [];
238
281
  return {
239
- id: B((t, n) => void e.push({
282
+ id: V((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
+ }), [pe, G] = f(W.id), [me, he] = f(W.errors.length > 0), K = a((e, t) => {
289
+ he(!0), B(e, t);
290
+ }, [B]);
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
+ W.errors.forEach(({ error: e, operation: t }) => B(e, t));
293
+ }, [W, B]), s(() => {
294
+ N && B(/* @__PURE__ */ Error("sub is blank"), "key");
295
+ }, [N, B]);
296
+ let q = d(pe), J = d({
254
297
  storage: I,
255
- key: R(_, N),
256
- sub: N,
298
+ key: U(_, P),
299
+ sub: P,
257
300
  sendFullTranscript: v
258
301
  });
259
302
  s(() => {
260
- q.current = {
303
+ J.current = {
261
304
  storage: I,
262
- key: R(_, N),
263
- sub: N,
305
+ key: U(_, P),
306
+ sub: P,
264
307
  sendFullTranscript: v
265
308
  };
266
309
  }, [
267
310
  I,
268
311
  _,
269
- N,
312
+ P,
270
313
  v
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 ge = g === !1 ? "off" : me || N ? "degraded" : "ok", [_e, ve] = f(!1), [ye, Y] = f("idle"), [be, xe] = f(!1), Se = d(0), Ce = d(null), we = d(null), X = d(!1), Z = a(() => {
316
+ Se.current += 1, Ce.current?.abort(), Ce.current = null, we.current = null, X.current = !1, xe(!1), Y("idle");
317
+ }, []), Te = d(p);
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
+ Te.current = p;
320
+ }, [p]), s(() => () => Ce.current?.abort(), []);
321
+ let Ee = d(null), De = d(""), Oe = d(0), ke = 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
+ ke.current = ee;
324
+ }, [ee]);
325
+ let Q = d([]), Ae = d(/* @__PURE__ */ new Map()), je = d(/* @__PURE__ */ new Map()), Me = d(null), $ = a(() => {
326
+ Me.current !== null && (clearTimeout(Me.current), Me.current = null);
327
+ }, []), Ne = a((e) => {
328
+ $(), Me.current = setTimeout(() => {
286
329
  e.abort(new DOMException("The assistant took too long to respond. Please try again.", "TimeoutError"));
287
330
  }, l);
288
- }, [je, l]);
331
+ }, [$, l]);
289
332
  s(() => () => {
290
- we.current?.abort(), je();
291
- }, [je]);
292
- let $ = a(({ reportedId: e, source: t, turn: n }) => {
333
+ Ee.current?.abort(), $();
334
+ }, [$]);
335
+ let Pe = 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
- if (n.heldId || e === K.current) return;
298
- let { sub: r, storage: i, key: a } = q.current;
299
- r && !ne({
340
+ if (n.heldId || e === q.current) return;
341
+ let { sub: r, storage: i, key: a } = J.current;
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
+ })) && (q.current = e, G(e), de(i, a, e, K));
346
+ }, [K]), Fe = a((e, t, n, r) => {
304
347
  let i = (e) => {
305
- n.push(e), w((t) => [...t, e]);
348
+ n.push(e), C((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 = Ae.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 } = O(n.raw), o = r.trim(), s = a.slice(n.emittedCount);
358
+ if (n.emittedCount = a.length, Ae.current.set(e, n), je.current.set(e, o), x((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 = Oe.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 && x((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 = Oe.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 = Oe.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: Oe.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 Pe({
388
431
  reportedId: t.response?.conversation?.id,
389
432
  source: "event",
390
433
  turn: r
391
434
  }), ue(t.response?.conversation?.history_status, r), !1;
392
435
  if (t.type === "response.completed") {
393
- $({
436
+ Pe({
394
437
  reportedId: t.response?.conversation?.id,
395
438
  source: "event",
396
439
  turn: r
397
440
  }), ue(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 && x((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 = Ae.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 } = O(i.raw, { hideOpenBlock: !1 }), n = t.trim();
449
+ n !== je.current.get(e) && (je.current.set(e, n), x((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: Oe.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: Oe.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 x((t) => t.map((t) => t.id === e ? {
430
473
  ...t,
431
474
  parts: [...t.parts ?? [], {
432
475
  type: "mcp_app",
@@ -445,20 +488,20 @@ 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: Oe.current
449
492
  }), !0;
450
- }, [$]), Pe = a(async (a) => {
451
- O("streaming"), j(null), _e(!1);
493
+ }, [Pe]), Ie = a(async (a) => {
494
+ D("streaming"), M(null), ve(!1);
452
495
  let s = Date.now();
453
- Ee.current = s;
454
- let l = L(), u = {
496
+ Oe.current = s;
497
+ let l = ce(), u = {
455
498
  id: l,
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];
504
+ x((e) => [...e, u]), Q.current = [...a, u];
462
505
  let d = a.findIndex((e) => e.role === "user" && !e.hidden), f = a.map((e, t) => t === d && o ? {
463
506
  role: e.role,
464
507
  content: `${o}${e.content}`,
@@ -469,8 +512,8 @@ 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: p } = J.current, m = p ? void 0 : q.current, h = m ? f.slice(-1) : f;
516
+ T({
474
517
  model: t,
475
518
  systemPrompt: n,
476
519
  messages: h,
@@ -485,12 +528,12 @@ var z = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
485
528
  }
486
529
  });
487
530
  let g = new AbortController();
488
- we.current = g, Me(g);
531
+ Ee.current = g, Ne(g);
489
532
  let _ = {
490
533
  signal: g.signal,
491
534
  heldId: m
492
- }, v = "", y = null, b = !1, x = !1, C = !1, T = [], D = (e, t) => {
493
- O("error"), j(e);
535
+ }, v = "", y = null, b = !1, ee = !1, S = !1, w = [], E = (e, t) => {
536
+ D("error"), M(e);
494
537
  let n = {
495
538
  kind: "error",
496
539
  message: e,
@@ -498,8 +541,8 @@ 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
+ w.push(n), C((e) => [...e, n]);
545
+ }, O = (e, t) => {
503
546
  e.forEach((e) => {
504
547
  if (e.type === "error") {
505
548
  y = e.message;
@@ -509,11 +552,9 @@ var z = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
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
+ w.push(t), C((e) => [...e, t]);
556
+ } else e.type === "response.output_text.delta" && e.delta && (S = !0), Fe(l, e, w, _) && (ee = !0);
557
+ }), t && (b = !0, x((e) => e.map((e) => e.id === l ? {
517
558
  ...e,
518
559
  streaming: !1
519
560
  } : e)));
@@ -526,18 +567,18 @@ var z = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
526
567
  tools: r,
527
568
  toolChoice: i,
528
569
  ...m ? { conversationId: m } : {},
529
- onConversationId: (e) => $({
570
+ onConversationId: (e) => Pe({
530
571
  reportedId: e,
531
572
  source: "header",
532
573
  turn: _
533
574
  }),
534
575
  signal: g.signal,
535
576
  onChunk: (e) => {
536
- Me(g), v += e;
577
+ Ne(g), v += e;
537
578
  let { events: t, remainder: n, done: r } = A(v);
538
- v = n, k(t, r);
579
+ v = n, O(t, r);
539
580
  let i = Date.now();
540
- E((e) => e && e.sentAt === s ? {
581
+ T((e) => e && e.sentAt === s ? {
541
582
  ...e,
542
583
  streamStats: {
543
584
  chunkCount: e.streamStats.chunkCount + 1,
@@ -547,13 +588,13 @@ 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
+ T((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 && x((t) => t.map((t) => t.id === l ? {
557
598
  ...t,
558
599
  serverMessageId: e
559
600
  } : t));
@@ -561,74 +602,74 @@ var z = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
561
602
  });
562
603
  if (v.trim()) {
563
604
  let { events: e, done: t } = A(`${v}\n\n`);
564
- v = "", k(e, t);
605
+ v = "", O(e, t);
565
606
  }
566
607
  if (y) {
567
- O("error"), j(y);
608
+ D("error"), M(y);
568
609
  return;
569
610
  }
570
611
  if (d === "timeout" && !b) {
571
- D(u || "The assistant took too long to respond. Please try again.", { source: "client-timeout" });
612
+ E(u || "The assistant took too long to respond. Please try again.", { source: "client-timeout" });
572
613
  return;
573
614
  }
574
615
  if (f && !b) {
575
- D("The connection was interrupted before the answer finished. Try again.");
616
+ E("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
+ E(le(a, o, u), {
580
621
  httpStatus: a,
581
622
  rawBody: o || 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 p = _.reportedId, C = p !== m, k = _.historyStatus === "failed" || _.historyStatus === "empty";
627
+ if (m && !_.signal.aborted && (C || k)) {
628
+ q.current = void 0, G(void 0), H(J.current.storage, J.current.key, K), Z(), ve(!0);
588
629
  try {
589
- le.current?.({
630
+ z.current?.({
590
631
  sentId: m,
591
632
  ...p ? { reportedId: p } : {},
592
- reason: w ? "id" : "history"
633
+ reason: C ? "id" : "history"
593
634
  });
594
635
  } catch {}
595
636
  }
596
- if (!x) {
597
- D("Bailey returned an empty response.");
637
+ if (!ee) {
638
+ E("Bailey 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 (!S) {
642
+ E("Bailey 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
+ D("idle");
646
+ let j = je.current.get(l) ?? "";
647
+ T((e) => e && e.sentAt === s ? {
607
648
  ...e,
608
- response: { content: M }
649
+ response: { content: j }
609
650
  } : e), c && await c({
610
651
  id: l,
611
652
  role: "assistant",
612
- content: M,
653
+ content: j,
613
654
  streaming: !1
614
- }, T);
655
+ }, w);
615
656
  } catch (e) {
616
657
  let t = e;
617
658
  if (t?.name === "TimeoutError") {
618
- D(t.message, { source: "client-timeout" });
659
+ E(t.message, { source: "client-timeout" });
619
660
  return;
620
661
  }
621
662
  if (t?.name === "AbortError") {
622
- O("idle");
663
+ D("idle");
623
664
  return;
624
665
  }
625
- D(t?.message || "Bailey request failed.");
666
+ E(t?.message || "Bailey 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
+ $();
669
+ let e = je.current.get(l) ?? "";
670
+ Ae.current.delete(l), je.current.delete(l);
671
+ let t = w.some((e) => e.kind === "tool_start" || e.kind === "tool_end");
672
+ x((e) => e.flatMap((e) => e.id === l ? e.content || t ? [{
632
673
  ...e,
633
674
  streaming: !1
634
675
  }] : [] : [e])), Q.current = Q.current.flatMap((t) => t.id === l ? e ? [{
@@ -645,184 +686,197 @@ var z = ({ transport: e, model: t, instructions: n, tools: r = [], toolChoice: i
645
686
  i,
646
687
  o,
647
688
  c,
689
+ Fe,
690
+ Pe,
648
691
  Ne,
649
692
  $,
650
- Me,
651
- je,
652
- G,
693
+ K,
653
694
  Z
654
- ]), Fe = a((e) => {
655
- De.current = e, S(e);
656
- }, []), Ie = a((e) => {
695
+ ]), Le = a((e) => {
696
+ ke.current = e, x(e);
697
+ }, []), Re = a((e) => {
657
698
  let t = e.trim();
658
699
  if (!t) return;
659
- Te.current = t;
700
+ De.current = t;
660
701
  let n = {
661
- id: L(),
702
+ id: ce(),
662
703
  role: "user",
663
704
  content: t,
664
705
  createdAt: Date.now()
665
706
  }, 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
+ Q.current = r, Le([...ke.current, n]), Ie(r);
708
+ }, [Ie, Le]), ze = a((e, t) => {
709
+ if (E === "streaming") return;
669
710
  let n = e.trim();
670
711
  if (!n) return;
671
- Te.current = n;
712
+ De.current = n;
672
713
  let r = t?.trim(), i = {
673
- id: L(),
714
+ id: ce(),
674
715
  role: "user",
675
716
  content: n,
676
717
  createdAt: Date.now(),
677
718
  hidden: !0,
678
719
  ...r ? { titleHint: r } : {}
679
720
  }, 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);
721
+ Q.current = a, Ie(a);
722
+ }, [Ie, E]), Be = a(() => {
723
+ Ee.current?.abort();
724
+ }, []), Ve = a(() => {
725
+ if (E === "streaming" || !De.current) return;
726
+ let e = ke.current, t = e[e.length - 1], n = t && t.role === "assistant" ? e.slice(0, -1) : e;
727
+ Le(n);
687
728
  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);
729
+ Q.current = a, Ie(a);
689
730
  }, [
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);
731
+ Ie,
732
+ Le,
733
+ E
734
+ ]), He = a(() => C([]), []), Ue = a(() => {
735
+ M(null), D((e) => e === "error" ? "idle" : e);
736
+ }, []), We = a(() => {
737
+ Ee.current?.abort(), Z(), ve(!1), Le([]), Q.current = [], C([]), T(null), D("idle"), M(null), De.current = "";
738
+ }, [Z, Le]), Ge = a(() => {
739
+ We(), q.current = void 0, G(void 0), H(J.current.storage, J.current.key, K);
740
+ }, [We, K]), Ke = d(P);
700
741
  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();
742
+ let e = Ke.current;
743
+ if (e === P) return;
744
+ Ke.current = P, e !== void 0 && We();
745
+ let t = V(K);
746
+ q.current = t, G(t);
747
+ }, [P]);
748
+ let qe = a((e) => {
749
+ Ee.current?.abort();
709
750
  let t = e.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
710
751
  ...e,
711
752
  streaming: !1
712
753
  }));
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) => {
754
+ Le(t.filter((e) => !e.hidden)), Q.current = t, C([]), T(null), D("idle"), M(null), De.current = "";
755
+ }, [Le]), Je = a((e) => {
756
+ Z(), qe(e);
757
+ }, [Z, qe]), Ye = a((e) => {
758
+ q.current = e, G(e), de(J.current.storage, J.current.key, e, K), ve(!1);
759
+ }, [K]), Xe = a((e) => {
719
760
  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({
761
+ we.current = t ? e.nextBeforeAbsoluteIndex : null, xe(t);
762
+ }, []), Ze = a(async ({ conversationId: e }) => {
763
+ let t = Te.current, { sub: n } = J.current, r = !!e && (!n || L({
764
+ conversationId: e,
765
+ sub: n
766
+ }));
767
+ if (!t || !r) throw Y("error"), Error(t ? "invalid conversation id" : "no client");
768
+ Ee.current?.abort(), Z();
769
+ let i = Se.current, a = new AbortController();
770
+ Ce.current = a, Y("loading");
771
+ try {
772
+ let n = await t.getConversation({
741
773
  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,
774
+ limit: oe,
775
+ signal: a.signal
776
+ });
777
+ if (i !== Se.current) return;
778
+ qe(te({ messages: n.messages })), Ye(e), Xe(n), Y("idle");
779
+ } catch (e) {
780
+ if (i !== Se.current) return;
781
+ throw Y("error"), e;
782
+ }
783
+ }, [
784
+ Xe,
785
+ Z,
786
+ Ye,
787
+ qe
788
+ ]), Qe = a(async () => {
789
+ let e = Te.current, t = q.current, n = we.current;
790
+ if (!e || !t || n === null || X.current) return;
791
+ let r = Se.current, i = new AbortController();
792
+ Ce.current = i, X.current = !0, Y("loading");
793
+ try {
794
+ let a = await e.getConversation({
795
+ conversationId: t,
796
+ limit: oe,
797
+ beforeAbsoluteIndex: n,
798
+ signal: i.signal
799
+ });
800
+ if (r !== Se.current) return;
801
+ let o = te({ messages: a.messages });
802
+ Q.current = re({
803
+ current: Q.current,
804
+ earlier: o
805
+ }), x((e) => {
806
+ let t = re({
807
+ current: e,
782
808
  earlier: o
783
- }), S((e) => {
784
- let t = te({
785
- current: e,
786
- earlier: o
809
+ });
810
+ return ke.current = t, t;
811
+ }), Xe(a), Y("idle");
812
+ } catch (e) {
813
+ if (r !== Se.current) return;
814
+ throw Y("error"), e;
815
+ } finally {
816
+ r === Se.current && (X.current = !1);
817
+ }
818
+ }, [Xe]), [$e, et] = f();
819
+ return {
820
+ conversationId: pe,
821
+ persistence: ge,
822
+ contextLost: _e,
823
+ messages: ee,
824
+ traceEvents: S,
825
+ lastRequest: w,
826
+ status: E,
827
+ error: k,
828
+ send: Re,
829
+ sendHidden: ze,
830
+ stop: Be,
831
+ retryLast: Ve,
832
+ clearTrace: He,
833
+ clearError: Ue,
834
+ newChat: Ge,
835
+ loadMessages: Je,
836
+ loadConversation: Ze,
837
+ loadEarlier: Qe,
838
+ hasEarlier: be,
839
+ historyStatus: ye,
840
+ feedback: u(() => {
841
+ if (!p || $e === p) return;
842
+ let e = ie({
843
+ client: p,
844
+ getConversationId: () => pe
845
+ }), t = async (e) => {
846
+ try {
847
+ await e();
848
+ } catch (e) {
849
+ throw e instanceof j && e.status === 503 && et(p), e;
850
+ }
851
+ }, n = (e, t) => x((n) => n.map((n) => n.serverMessageId === e ? {
852
+ ...n,
853
+ feedback: t
854
+ } : n));
855
+ return {
856
+ onSubmit: async (r) => {
857
+ await t(() => e.onSubmit(r));
858
+ let { messageId: i, rating: a, reasonCodes: o, comment: s } = r;
859
+ n(i, {
860
+ rating: a,
861
+ ...o ? { reasonCodes: o } : {},
862
+ ...s ? { comment: s } : {}
787
863
  });
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
864
+ },
865
+ onClear: async (r) => {
866
+ await t(() => e.onClear(r)), n(r.messageId, void 0);
867
+ }
868
+ };
869
+ }, [
870
+ p,
871
+ pe,
872
+ $e
873
+ ])
799
874
  };
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({
875
+ }, pe = (e) => e instanceof j ? e : new j({
822
876
  status: 0,
823
877
  kind: "network"
824
878
  });
825
- function me(e) {
879
+ function G(e) {
826
880
  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
881
  s(() => {
828
882
  h.current = e.client, g.current = r;
@@ -845,15 +899,15 @@ function me(e) {
845
899
  }), _.current = r.nextCursor, m(r.nextCursor), u(null), c("idle");
846
900
  } catch (e) {
847
901
  if (n.signal.aborted) return;
848
- u(U(e)), c("error");
902
+ u(pe(e)), c("error");
849
903
  }
850
904
  }, [t]);
851
905
  s(() => {
852
906
  if (n) return y("replace"), () => v.current?.abort();
853
907
  }, [n, y]);
854
- let b = a(() => y("replace"), [y]), x = a(async () => {
908
+ let b = a(() => y("replace"), [y]), ee = a(async () => {
855
909
  _.current !== null && await y("append");
856
- }, [y]), S = a(async ({ conversationId: e }) => {
910
+ }, [y]), x = a(async ({ conversationId: e }) => {
857
911
  let t = g.current.findIndex((t) => t.conversationId === e), n = t === -1 ? void 0 : {
858
912
  row: g.current[t],
859
913
  index: t
@@ -877,16 +931,15 @@ function me(e) {
877
931
  error: l,
878
932
  hasMore: p !== null,
879
933
  refresh: b,
880
- loadMore: x,
881
- remove: S
934
+ loadMore: ee,
935
+ remove: x
882
936
  };
883
937
  }
884
- //#endregion
885
- //#region src/client/routes.ts
886
- function W(e) {
938
+ // src/client/routes.ts
939
+ function me(e) {
887
940
  return e.replace(/\/+$/, "");
888
941
  }
889
- function G(e, t) {
942
+ function he(e, t) {
890
943
  let n = new URLSearchParams();
891
944
  for (let [e, r] of Object.entries(t)) r !== void 0 && n.set(e, String(r));
892
945
  let r = n.toString();
@@ -894,26 +947,25 @@ function G(e, t) {
894
947
  }
895
948
  var K = {
896
949
  responses(e) {
897
- return `${W(e)}/responses`;
950
+ return `${me(e)}/responses`;
898
951
  },
899
952
  conversations(e, t) {
900
- return G(`${W(e)}/conversations`, {
953
+ return he(`${me(e)}/conversations`, {
901
954
  limit: t.limit,
902
955
  cursor: t.cursor
903
956
  });
904
957
  },
905
958
  conversation(e, t, n) {
906
- return G(`${W(e)}/conversations/${encodeURIComponent(t)}`, {
959
+ return he(`${me(e)}/conversations/${encodeURIComponent(t)}`, {
907
960
  limit: n.limit,
908
961
  before_absolute_index: n.beforeAbsoluteIndex
909
962
  });
910
963
  },
911
964
  feedback(e, t, n) {
912
- return `${W(e)}/conversations/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/feedback`;
965
+ return `${me(e)}/conversations/${encodeURIComponent(t)}/messages/${encodeURIComponent(n)}/feedback`;
913
966
  }
914
967
  };
915
- //#endregion
916
- //#region src/client/createBaileyClient.ts
968
+ // src/client/createBaileyClient.ts
917
969
  function q(e) {
918
970
  return {
919
971
  status: void 0,
@@ -923,51 +975,51 @@ function q(e) {
923
975
  ...e ? { errorCause: e.cause } : {}
924
976
  };
925
977
  }
926
- var he = "The assistant took too long to respond. Please try again.";
978
+ var J = "The assistant took too long to respond. Please try again.";
927
979
  function ge(e) {
928
980
  return {
929
981
  status: e.status,
930
982
  text: "",
931
- errorMessage: he,
983
+ errorMessage: J,
932
984
  errorKind: "timeout",
933
985
  errorCause: e.cause,
934
986
  ...e.status === void 0 ? {} : { interrupted: !0 }
935
987
  };
936
988
  }
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);
989
+ var _e = 3e4, ve = 155e3, ye = "x-chat-id", Y = "header", be = "body", xe = "x-request-id", Se = "x-conversation-id", Ce = "x-message-id", we = (e) => e && typeof e == "object" ? e : {}, X = (e, t = "") => typeof e == "string" ? e : t, Z = (e, t = 0) => typeof e == "number" ? e : t;
990
+ function Te(e) {
991
+ let t = we(e);
940
992
  return {
941
- conversationId: Z(t.conversation_id),
993
+ conversationId: X(t.conversation_id),
942
994
  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)
995
+ status: X(t.status),
996
+ messageCount: Z(t.message_count),
997
+ createdAt: X(t.created_at),
998
+ updatedAt: X(t.updated_at)
947
999
  };
948
1000
  }
949
- function Te(e) {
1001
+ function Ee(e) {
950
1002
  if (!e || typeof e != "object") return null;
951
- let t = X(e);
1003
+ let t = we(e);
952
1004
  return {
953
- rating: Z(t.rating),
1005
+ rating: X(t.rating),
954
1006
  reasonCodes: Array.isArray(t.reason_codes) ? t.reason_codes.filter((e) => typeof e == "string") : [],
955
1007
  comment: typeof t.comment == "string" ? t.comment : null,
956
1008
  ...typeof t.updated_at == "string" ? { updatedAt: t.updated_at } : {}
957
1009
  };
958
1010
  }
959
- function Ee(e) {
960
- let t = X(e);
1011
+ function De(e) {
1012
+ let t = we(e);
961
1013
  return {
962
- messageId: Z(t.message_id),
963
- role: Z(t.role),
964
- content: Z(t.content),
1014
+ messageId: X(t.message_id),
1015
+ role: X(t.role),
1016
+ content: X(t.content),
965
1017
  hidden: t.hidden === !0,
966
- createdAt: Z(t.created_at),
967
- feedback: Te(t.feedback)
1018
+ createdAt: X(t.created_at),
1019
+ feedback: Ee(t.feedback)
968
1020
  };
969
1021
  }
970
- function De(e) {
1022
+ function Oe(e) {
971
1023
  let t = new AbortController(), n = !1, r = setTimeout(() => {
972
1024
  n = !0, t.abort();
973
1025
  }, e.timeoutMs), i = () => t.abort(e.caller?.reason);
@@ -979,30 +1031,30 @@ function De(e) {
979
1031
  }
980
1032
  };
981
1033
  }
982
- function Q(e) {
983
- return e.timedOut() ? new B({
1034
+ function ke(e) {
1035
+ return e.timedOut() ? new j({
984
1036
  status: 0,
985
1037
  kind: "timeout",
986
1038
  cause: e.signal.reason
987
- }) : new B({
1039
+ }) : new j({
988
1040
  status: 0,
989
1041
  kind: "aborted"
990
1042
  });
991
1043
  }
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'");
1044
+ function Q(e) {
1045
+ let { baseUrl: t, getHeaders: n, onAuthError: r } = e, i = e.requestTimeoutMs ?? _e, a = e.idleTimeoutMs ?? ve, o = e.conversationVia ?? Y;
1046
+ if (o !== Y && o !== be) throw TypeError("createBaileyClient: conversationVia must be 'header' or 'body'");
995
1047
  let s = e.fetch ?? ((e, t) => globalThis.fetch(e, t));
996
1048
  function c(t) {
997
1049
  try {
998
- e.onCleanupError?.(new H({ operation: t }));
1050
+ e.onCleanupError?.(new N({ operation: t }));
999
1051
  } catch {}
1000
1052
  }
1001
1053
  function l(e) {
1002
1054
  e.kind === "http" && (e.status === 401 || e.status === 403) && r?.(e);
1003
1055
  }
1004
1056
  async function u(e) {
1005
- let t = De({
1057
+ let t = Oe({
1006
1058
  caller: e.signal,
1007
1059
  timeoutMs: i
1008
1060
  });
@@ -1014,12 +1066,12 @@ function Oe(e) {
1014
1066
  ...await n()
1015
1067
  };
1016
1068
  } catch {
1017
- throw new B({
1069
+ throw new j({
1018
1070
  status: 0,
1019
1071
  kind: "network"
1020
1072
  });
1021
1073
  }
1022
- if (t.signal.aborted) throw Q(t);
1074
+ if (t.signal.aborted) throw ke(t);
1023
1075
  e.body !== void 0 && (r["Content-Type"] = "application/json");
1024
1076
  let i;
1025
1077
  try {
@@ -1030,18 +1082,18 @@ function Oe(e) {
1030
1082
  signal: t.signal
1031
1083
  });
1032
1084
  } catch (e) {
1033
- throw t.signal.aborted ? Q(t) : new B({
1085
+ throw t.signal.aborted ? ke(t) : new j({
1034
1086
  status: 0,
1035
1087
  kind: "network",
1036
1088
  cause: e
1037
1089
  });
1038
1090
  }
1039
- if (!i.ok) throw i.body?.cancel().catch(() => c("cancel-response-body")), new B({
1091
+ if (!i.ok) throw i.body?.cancel().catch(() => c("cancel-response-body")), new j({
1040
1092
  status: i.status,
1041
1093
  kind: "http"
1042
1094
  });
1043
1095
  if (i.status === 204) {
1044
- if (e.requireJsonBody) throw new B({
1096
+ if (e.requireJsonBody) throw new j({
1045
1097
  status: 204,
1046
1098
  kind: "invalid-response"
1047
1099
  });
@@ -1049,22 +1101,22 @@ function Oe(e) {
1049
1101
  }
1050
1102
  try {
1051
1103
  let t = await i.json();
1052
- if (e.requireJsonBody && (typeof t != "object" || !t || Array.isArray(t))) throw new B({
1104
+ if (e.requireJsonBody && (typeof t != "object" || !t || Array.isArray(t))) throw new j({
1053
1105
  status: i.status,
1054
1106
  kind: "invalid-response"
1055
1107
  });
1056
1108
  return t;
1057
1109
  } catch (n) {
1058
- if (n instanceof B) throw n;
1059
- if (t.timedOut() || t.signal.aborted) throw Q(t);
1060
- if (e.requireJsonBody) throw new B({
1110
+ if (n instanceof j) throw n;
1111
+ if (t.timedOut() || t.signal.aborted) throw ke(t);
1112
+ if (e.requireJsonBody) throw new j({
1061
1113
  status: i.status,
1062
1114
  kind: "invalid-response"
1063
1115
  });
1064
1116
  return;
1065
1117
  }
1066
1118
  } catch (e) {
1067
- throw e instanceof B && l(e), e;
1119
+ throw e instanceof j && l(e), e;
1068
1120
  } finally {
1069
1121
  t.dispose();
1070
1122
  }
@@ -1075,7 +1127,7 @@ function Oe(e) {
1075
1127
  e.signal.aborted ? i() : e.signal.addEventListener("abort", i, { once: !0 });
1076
1128
  let u, d, f = () => {
1077
1129
  clearTimeout(u), u = setTimeout(() => {
1078
- d = new DOMException(he, "TimeoutError"), r.abort(d);
1130
+ d = new DOMException(J, "TimeoutError"), r.abort(d);
1079
1131
  }, a);
1080
1132
  }, p = (t) => {
1081
1133
  if (d && !e.signal.aborted) return ge({
@@ -1096,7 +1148,7 @@ function Oe(e) {
1096
1148
  return q();
1097
1149
  }
1098
1150
  if (r.signal.aborted) return p();
1099
- i["Content-Type"] = "application/json", e.conversationId && o === ye && (i[J] = e.conversationId);
1151
+ i["Content-Type"] = "application/json", e.conversationId && o === Y && (i[ye] = e.conversationId);
1100
1152
  let a = e.input[e.input.length - 1], u = {
1101
1153
  ...a?.hidden === !0 ? { hidden: !0 } : {},
1102
1154
  ...a?.titleHint ? { title_hint: a.titleHint } : {}
@@ -1122,11 +1174,11 @@ function Oe(e) {
1122
1174
  } catch (e) {
1123
1175
  return r.signal.aborted ? p() : q({ cause: e });
1124
1176
  }
1125
- let h = m.headers.get(Y);
1177
+ let h = m.headers.get(xe);
1126
1178
  h && e.onRequestId?.(h);
1127
- let g = m.headers.get(Se);
1179
+ let g = m.headers.get(Ce);
1128
1180
  if (g && e.onMessageId?.(g), !m.ok) {
1129
- l(new B({
1181
+ l(new j({
1130
1182
  status: m.status,
1131
1183
  kind: "http"
1132
1184
  }));
@@ -1136,7 +1188,7 @@ function Oe(e) {
1136
1188
  text: e
1137
1189
  };
1138
1190
  }
1139
- let _ = m.headers.get(xe);
1191
+ let _ = m.headers.get(Se);
1140
1192
  if (_ && e.onConversationId?.(_), !m.body) return {
1141
1193
  status: m.status,
1142
1194
  text: ""
@@ -1173,31 +1225,31 @@ function Oe(e) {
1173
1225
  }
1174
1226
  },
1175
1227
  async listConversations(e = {}) {
1176
- let n = X(await u({
1228
+ let n = we(await u({
1177
1229
  method: "GET",
1178
1230
  url: K.conversations(t, e),
1179
1231
  signal: e.signal,
1180
1232
  requireJsonBody: !0
1181
1233
  }));
1182
1234
  return {
1183
- conversations: Array.isArray(n.conversations) ? n.conversations.map(we).filter((e) => e.conversationId !== "") : [],
1235
+ conversations: Array.isArray(n.conversations) ? n.conversations.map(Te).filter((e) => e.conversationId !== "") : [],
1184
1236
  nextCursor: typeof n.next_cursor == "string" ? n.next_cursor : null
1185
1237
  };
1186
1238
  },
1187
1239
  async getConversation(e) {
1188
- let n = X(await u({
1240
+ let n = we(await u({
1189
1241
  method: "GET",
1190
1242
  url: K.conversation(t, e.conversationId, e),
1191
1243
  signal: e.signal,
1192
1244
  requireJsonBody: !0
1193
1245
  }));
1194
- if (!n.conversation || typeof n.conversation != "object") throw new B({
1246
+ if (!n.conversation || typeof n.conversation != "object") throw new j({
1195
1247
  status: 200,
1196
1248
  kind: "invalid-response"
1197
1249
  });
1198
1250
  return {
1199
- conversation: we(n.conversation),
1200
- messages: Array.isArray(n.messages) ? n.messages.map(Ee) : [],
1251
+ conversation: Te(n.conversation),
1252
+ messages: Array.isArray(n.messages) ? n.messages.map(De) : [],
1201
1253
  hasMoreBefore: n.has_more_before === !0,
1202
1254
  nextBeforeAbsoluteIndex: typeof n.next_before_absolute_index == "number" ? n.next_before_absolute_index : null
1203
1255
  };
@@ -1230,41 +1282,11 @@ function Oe(e) {
1230
1282
  }
1231
1283
  };
1232
1284
  }
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
1285
+ // src/utils/prompt.ts
1263
1286
  function Ae(...e) {
1264
1287
  return e.filter((e) => !!(e && e.trim())).join("\n\n");
1265
1288
  }
1266
- //#endregion
1267
- //#region src/utils/toolCalls.ts
1289
+ // src/utils/toolCalls.ts
1268
1290
  var je = "call_tool", Me = "a tool";
1269
1291
  function $(e, t) {
1270
1292
  let n = {
@@ -1297,8 +1319,7 @@ function $(e, t) {
1297
1319
  viaCallTool: !1
1298
1320
  };
1299
1321
  }
1300
- //#endregion
1301
- //#region src/utils/table.ts
1322
+ // src/utils/table.ts
1302
1323
  var Ne = 5, Pe = (e) => e.type === "text" ? e.value ?? "" : (e.children ?? []).map(Pe).join(""), Fe = (e) => {
1303
1324
  if (e.tagName === "a" && e.properties?.href) return e.properties.href;
1304
1325
  for (let t of e.children ?? []) {
@@ -1460,11 +1481,7 @@ function ct(e) {
1460
1481
  let t = [];
1461
1482
  for (let n of e) {
1462
1483
  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 ? {
1484
+ n.toolName && e?.type === "group" && e.toolName === n.toolName ? e.rows.push(n) : t.push(n.toolName ? {
1468
1485
  type: "group",
1469
1486
  toolName: n.toolName,
1470
1487
  rows: [n]
@@ -1514,8 +1531,7 @@ function dt(e, t) {
1514
1531
  }
1515
1532
  return n;
1516
1533
  }
1517
- //#endregion
1518
- //#region src/styles.css?inline
1534
+ // src/styles.css?inline
1519
1535
  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
1536
  function vt(e) {
1521
1537
  let t = e.match(new RegExp(mt, "g"))?.length ?? 0;
@@ -1552,9 +1568,10 @@ function Et(e) {
1552
1568
  let t = o(pt), n = t !== void 0, r = Tt(e, n);
1553
1569
  return n ? t : r;
1554
1570
  }
1555
- //#endregion
1556
- //#region src/ui/markdown.tsx
1557
- function Dt({ renderTable: t, renderChart: n } = {}) {
1571
+ // src/context/BaileyFeedbackSlotContext.ts
1572
+ var Dt = r(void 0);
1573
+ // src/ui/markdown.tsx
1574
+ function Ot({ renderTable: t, renderChart: n } = {}) {
1558
1575
  return {
1559
1576
  a: ({ href: t, children: n }) => !t || !e(t) ? /* @__PURE__ */ v(_, { children: n }) : /* @__PURE__ */ v("a", {
1560
1577
  href: t,
@@ -1583,9 +1600,8 @@ function Dt({ renderTable: t, renderChart: n } = {}) {
1583
1600
  }
1584
1601
  };
1585
1602
  }
1586
- //#endregion
1587
- //#region src/ui/icons.tsx
1588
- function Ot({ className: e }) {
1603
+ // src/ui/icons.tsx
1604
+ function kt({ className: e }) {
1589
1605
  return /* @__PURE__ */ v("svg", {
1590
1606
  viewBox: "0 0 24 24",
1591
1607
  fill: "currentColor",
@@ -1594,7 +1610,7 @@ function Ot({ className: e }) {
1594
1610
  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
1611
  });
1596
1612
  }
1597
- function kt({ className: e }) {
1613
+ function At({ className: e }) {
1598
1614
  return /* @__PURE__ */ v("svg", {
1599
1615
  viewBox: "0 0 24 24",
1600
1616
  fill: "currentColor",
@@ -1609,7 +1625,7 @@ function kt({ className: e }) {
1609
1625
  })
1610
1626
  });
1611
1627
  }
1612
- function At({ className: e }) {
1628
+ function jt({ className: e }) {
1613
1629
  return /* @__PURE__ */ y("svg", {
1614
1630
  viewBox: "0 0 24 24",
1615
1631
  fill: "none",
@@ -1622,7 +1638,7 @@ function At({ className: e }) {
1622
1638
  children: [/* @__PURE__ */ v("path", { d: "M7 17 17 7" }), /* @__PURE__ */ v("path", { d: "M9 7h8v8" })]
1623
1639
  });
1624
1640
  }
1625
- function jt({ className: e }) {
1641
+ function Mt({ className: e }) {
1626
1642
  return /* @__PURE__ */ y("svg", {
1627
1643
  viewBox: "0 0 24 24",
1628
1644
  fill: "none",
@@ -1641,7 +1657,7 @@ function jt({ className: e }) {
1641
1657
  }), /* @__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
1658
  });
1643
1659
  }
1644
- function Mt({ className: e }) {
1660
+ function Nt({ className: e }) {
1645
1661
  return /* @__PURE__ */ v("svg", {
1646
1662
  viewBox: "0 0 24 24",
1647
1663
  fill: "none",
@@ -1654,7 +1670,7 @@ function Mt({ className: e }) {
1654
1670
  children: /* @__PURE__ */ v("path", { d: "M5 12.5 9.5 17 19 7" })
1655
1671
  });
1656
1672
  }
1657
- function Nt({ className: e }) {
1673
+ function Pt({ className: e }) {
1658
1674
  return /* @__PURE__ */ v("svg", {
1659
1675
  viewBox: "0 0 24 24",
1660
1676
  fill: "none",
@@ -1667,7 +1683,7 @@ function Nt({ className: e }) {
1667
1683
  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
1684
  });
1669
1685
  }
1670
- function Pt({ className: e }) {
1686
+ function Ft({ className: e }) {
1671
1687
  return /* @__PURE__ */ y("svg", {
1672
1688
  viewBox: "0 0 24 24",
1673
1689
  fill: "none",
@@ -1684,7 +1700,7 @@ function Pt({ className: e }) {
1684
1700
  }), /* @__PURE__ */ v("path", { d: "M8.5 12.5 11 15l4.5-5.5" })]
1685
1701
  });
1686
1702
  }
1687
- function Ft({ className: e }) {
1703
+ function It({ className: e }) {
1688
1704
  return /* @__PURE__ */ y("svg", {
1689
1705
  viewBox: "0 0 24 24",
1690
1706
  fill: "currentColor",
@@ -1709,7 +1725,7 @@ function Ft({ className: e }) {
1709
1725
  ]
1710
1726
  });
1711
1727
  }
1712
- function It({ className: e }) {
1728
+ function Lt({ className: e }) {
1713
1729
  return /* @__PURE__ */ v("svg", {
1714
1730
  viewBox: "0 0 24 24",
1715
1731
  fill: "none",
@@ -1722,8 +1738,8 @@ function It({ className: e }) {
1722
1738
  children: /* @__PURE__ */ v("path", { d: "M12 5v14M5 12h14" })
1723
1739
  });
1724
1740
  }
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 }) {
1741
+ var Rt = "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", zt = "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";
1742
+ function Bt({ className: e, filled: t = !1 }) {
1727
1743
  return /* @__PURE__ */ v("svg", {
1728
1744
  viewBox: "0 0 24 24",
1729
1745
  fill: t ? "currentColor" : "none",
@@ -1732,10 +1748,10 @@ function zt({ className: e, filled: t = !1 }) {
1732
1748
  strokeLinejoin: "round",
1733
1749
  className: e,
1734
1750
  "aria-hidden": "true",
1735
- children: /* @__PURE__ */ v("path", { d: Lt })
1751
+ children: /* @__PURE__ */ v("path", { d: Rt })
1736
1752
  });
1737
1753
  }
1738
- function Bt({ className: e, filled: t = !1 }) {
1754
+ function Vt({ className: e, filled: t = !1 }) {
1739
1755
  return /* @__PURE__ */ v("svg", {
1740
1756
  viewBox: "0 0 24 24",
1741
1757
  fill: t ? "currentColor" : "none",
@@ -1744,10 +1760,10 @@ function Bt({ className: e, filled: t = !1 }) {
1744
1760
  strokeLinejoin: "round",
1745
1761
  className: e,
1746
1762
  "aria-hidden": "true",
1747
- children: /* @__PURE__ */ v("path", { d: Rt })
1763
+ children: /* @__PURE__ */ v("path", { d: zt })
1748
1764
  });
1749
1765
  }
1750
- function Vt({ className: e }) {
1766
+ function Ht({ className: e }) {
1751
1767
  return /* @__PURE__ */ v("svg", {
1752
1768
  viewBox: "0 0 24 24",
1753
1769
  fill: "none",
@@ -1760,7 +1776,7 @@ function Vt({ className: e }) {
1760
1776
  children: /* @__PURE__ */ v("path", { d: "M15 6l-6 6 6 6" })
1761
1777
  });
1762
1778
  }
1763
- function Ht({ className: e }) {
1779
+ function Ut({ className: e }) {
1764
1780
  return /* @__PURE__ */ v("svg", {
1765
1781
  viewBox: "0 0 24 24",
1766
1782
  fill: "none",
@@ -1773,7 +1789,7 @@ function Ht({ className: e }) {
1773
1789
  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
1790
  });
1775
1791
  }
1776
- function Ut({ className: e }) {
1792
+ function Wt({ className: e }) {
1777
1793
  return /* @__PURE__ */ y("svg", {
1778
1794
  viewBox: "0 0 24 24",
1779
1795
  fill: "none",
@@ -1790,10 +1806,9 @@ function Ut({ className: e }) {
1790
1806
  }), /* @__PURE__ */ v("path", { d: "M12 8v5M12 16.5v.01" })]
1791
1807
  });
1792
1808
  }
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!" }) {
1809
+ // src/ui/CopyMarkdownButton.tsx
1810
+ var Gt = 1500;
1811
+ function Kt({ markdown: e, className: t, ariaLabel: n = "copy response as markdown", tooltipDefaultText: r = "Copy as markdown", tooltipCopiedText: i = "Copied!" }) {
1797
1812
  let [a, o] = f(!1), [c, l] = f(!1), u = d(null), p = d(null), m = Et(p);
1798
1813
  return s(() => () => {
1799
1814
  u.current !== null && clearTimeout(u.current);
@@ -1813,11 +1828,11 @@ function Gt({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
1813
1828
  } catch {
1814
1829
  return;
1815
1830
  }
1816
- o(!0), u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => o(!1), Wt);
1831
+ o(!0), u.current !== null && clearTimeout(u.current), u.current = setTimeout(() => o(!1), Gt);
1817
1832
  },
1818
1833
  "aria-label": n,
1819
1834
  className: `bailey-copy-button${t ? ` ${t}` : ""}`,
1820
- children: v(a ? Mt : jt, { className: "bailey-copy-icon" })
1835
+ children: v(a ? Nt : Mt, { className: "bailey-copy-icon" })
1821
1836
  })
1822
1837
  }), /* @__PURE__ */ v(g.Portal, {
1823
1838
  container: m instanceof ShadowRoot ? m : void 0,
@@ -1830,22 +1845,21 @@ function Gt({ markdown: e, className: t, ariaLabel: n = "copy response as markdo
1830
1845
  })
1831
1846
  });
1832
1847
  }
1833
- //#endregion
1834
- //#region src/ui/BaileyTracePanel.tsx
1835
- async function Kt(e) {
1848
+ // src/ui/BaileyTracePanel.tsx
1849
+ async function qt(e) {
1836
1850
  try {
1837
1851
  await navigator.clipboard.writeText(e);
1838
1852
  } catch {}
1839
1853
  }
1840
- function qt({ text: e, label: t = "Copy" }) {
1854
+ function Jt({ text: e, label: t = "Copy" }) {
1841
1855
  return /* @__PURE__ */ v("button", {
1842
1856
  type: "button",
1843
- onClick: () => Kt(e),
1857
+ onClick: () => qt(e),
1844
1858
  className: "bailey-trace-copy-button",
1845
1859
  children: t
1846
1860
  });
1847
1861
  }
1848
- function Jt(e) {
1862
+ function Yt(e) {
1849
1863
  if (e.failed || e.kind === "error") return "bailey-trace-chip bailey-trace-chip-error";
1850
1864
  switch (e.kind) {
1851
1865
  case "tool_start":
@@ -1856,7 +1870,7 @@ function Jt(e) {
1856
1870
  default: return "bailey-trace-chip bailey-trace-chip-default";
1857
1871
  }
1858
1872
  }
1859
- function Yt({ label: e, content: t, copyable: n }) {
1873
+ function Xt({ label: e, content: t, copyable: n }) {
1860
1874
  return /* @__PURE__ */ y("details", {
1861
1875
  className: "bailey-trace-disclosure",
1862
1876
  children: [
@@ -1866,7 +1880,7 @@ function Yt({ label: e, content: t, copyable: n }) {
1866
1880
  }),
1867
1881
  n && /* @__PURE__ */ v("div", {
1868
1882
  className: "bailey-trace-disclosure-actions",
1869
- children: /* @__PURE__ */ v(qt, { text: t })
1883
+ children: /* @__PURE__ */ v(Jt, { text: t })
1870
1884
  }),
1871
1885
  /* @__PURE__ */ v("pre", {
1872
1886
  className: "bailey-trace-disclosure-content",
@@ -1875,7 +1889,7 @@ function Yt({ label: e, content: t, copyable: n }) {
1875
1889
  ]
1876
1890
  });
1877
1891
  }
1878
- function Xt({ row: e }) {
1892
+ function Zt({ row: e }) {
1879
1893
  return /* @__PURE__ */ y("div", {
1880
1894
  className: "bailey-trace-row",
1881
1895
  children: [
@@ -1892,7 +1906,7 @@ function Xt({ row: e }) {
1892
1906
  children: at(e.gapMs)
1893
1907
  }),
1894
1908
  /* @__PURE__ */ v("span", {
1895
- className: Jt(e),
1909
+ className: Yt(e),
1896
1910
  children: e.label
1897
1911
  }),
1898
1912
  /* @__PURE__ */ v("span", {
@@ -1901,32 +1915,32 @@ function Xt({ row: e }) {
1901
1915
  })
1902
1916
  ]
1903
1917
  }),
1904
- e.argsDetail && /* @__PURE__ */ v(Yt, {
1918
+ e.argsDetail && /* @__PURE__ */ v(Xt, {
1905
1919
  label: e.kind === "llm_call_start" ? "request" : "args",
1906
1920
  content: e.argsDetail
1907
1921
  }),
1908
- e.outputDetail && /* @__PURE__ */ v(Yt, {
1922
+ e.outputDetail && /* @__PURE__ */ v(Xt, {
1909
1923
  label: e.kind === "llm_call_end" ? "response" : "output",
1910
1924
  content: e.outputDetail
1911
1925
  }),
1912
- e.structuredOutputDetail && /* @__PURE__ */ v(Yt, {
1926
+ e.structuredOutputDetail && /* @__PURE__ */ v(Xt, {
1913
1927
  label: "structured output",
1914
1928
  content: e.structuredOutputDetail
1915
1929
  }),
1916
- e.rawDetail && /* @__PURE__ */ v(Yt, {
1930
+ e.rawDetail && /* @__PURE__ */ v(Xt, {
1917
1931
  label: "raw",
1918
1932
  content: e.rawDetail
1919
1933
  })
1920
1934
  ]
1921
1935
  });
1922
1936
  }
1923
- function Zt(e, t) {
1937
+ function Qt(e, t) {
1924
1938
  if (e.chunkCount === 0) return "Streamed: no chunks received";
1925
1939
  if (e.chunkCount === 1 || e.firstChunkAt === null) return "Streamed: 1 chunk (not incremental)";
1926
1940
  let n = e.firstChunkAt - t, r = (e.lastChunkAt ?? e.firstChunkAt) - e.firstChunkAt;
1927
1941
  return `Streamed: ${e.chunkCount} chunks · first chunk after ${n}ms · spread over ${(r / 1e3).toFixed(1)}s`;
1928
1942
  }
1929
- function Qt({ request: e }) {
1943
+ function $t({ request: e }) {
1930
1944
  let t = u(() => JSON.stringify({
1931
1945
  model: e.model,
1932
1946
  instructions: e.systemPrompt,
@@ -1950,24 +1964,24 @@ function Qt({ request: e }) {
1950
1964
  }),
1951
1965
  /* @__PURE__ */ v("span", {
1952
1966
  className: "bailey-trace-request-meta",
1953
- children: Zt(e.streamStats, e.sentAt)
1967
+ children: Qt(e.streamStats, e.sentAt)
1954
1968
  }),
1955
- /* @__PURE__ */ v(Yt, {
1969
+ /* @__PURE__ */ v(Xt, {
1956
1970
  label: `System prompt (${e.systemPrompt.length.toLocaleString()} chars)`,
1957
1971
  content: e.systemPrompt,
1958
1972
  copyable: !0
1959
1973
  }),
1960
- /* @__PURE__ */ v(Yt, {
1974
+ /* @__PURE__ */ v(Xt, {
1961
1975
  label: `Messages (${e.messages.length})`,
1962
1976
  content: JSON.stringify(e.messages, null, 2),
1963
1977
  copyable: !0
1964
1978
  }),
1965
- e.response && /* @__PURE__ */ v(Yt, {
1979
+ e.response && /* @__PURE__ */ v(Xt, {
1966
1980
  label: `Response (${e.response.content.length.toLocaleString()} chars)`,
1967
1981
  content: e.response.content,
1968
1982
  copyable: !0
1969
1983
  }),
1970
- /* @__PURE__ */ v(Yt, {
1984
+ /* @__PURE__ */ v(Xt, {
1971
1985
  label: "Full payload (JSON)",
1972
1986
  content: t,
1973
1987
  copyable: !0
@@ -1975,14 +1989,14 @@ function Qt({ request: e }) {
1975
1989
  ]
1976
1990
  });
1977
1991
  }
1978
- function $t({ events: e, lastRequest: t, onClear: n }) {
1992
+ function en({ events: e, lastRequest: t, onClear: n }) {
1979
1993
  let r = u(() => ot(e), [e]), i = u(() => ct(r), [r]), a = u(() => JSON.stringify(e, null, 2), [e]);
1980
1994
  return /* @__PURE__ */ y("div", {
1981
1995
  className: "bailey-trace-body",
1982
1996
  children: [
1983
1997
  /* @__PURE__ */ y("div", {
1984
1998
  className: "bailey-trace-actions-row",
1985
- children: [e.length > 0 && /* @__PURE__ */ v(qt, {
1999
+ children: [e.length > 0 && /* @__PURE__ */ v(Jt, {
1986
2000
  text: a,
1987
2001
  label: "Copy trace as JSON"
1988
2002
  }), /* @__PURE__ */ v("button", {
@@ -1992,15 +2006,15 @@ function $t({ events: e, lastRequest: t, onClear: n }) {
1992
2006
  children: "Clear"
1993
2007
  })]
1994
2008
  }),
1995
- t && /* @__PURE__ */ v(Qt, { request: t }),
2009
+ t && /* @__PURE__ */ v($t, { request: t }),
1996
2010
  /* @__PURE__ */ v("div", {
1997
2011
  className: "bailey-trace-rows",
1998
2012
  children: i.map((e, t) => {
1999
- if (e.type === "single") return /* @__PURE__ */ v(Xt, { row: e.row }, e.row.key);
2013
+ if (e.type === "single") return /* @__PURE__ */ v(Zt, { row: e.row }, e.row.key);
2000
2014
  let n = e.rows.filter((e) => e.isToolStart).length;
2001
2015
  if (n <= 1) return /* @__PURE__ */ v("div", {
2002
2016
  className: "bailey-trace-rows",
2003
- children: e.rows.map((e) => /* @__PURE__ */ v(Xt, { row: e }, e.key))
2017
+ children: e.rows.map((e) => /* @__PURE__ */ v(Zt, { row: e }, e.key))
2004
2018
  }, `group-${t}`);
2005
2019
  let r = e.rows.filter((e) => e.failed).length;
2006
2020
  return /* @__PURE__ */ y("details", {
@@ -2022,7 +2036,7 @@ function $t({ events: e, lastRequest: t, onClear: n }) {
2022
2036
  ]
2023
2037
  }), /* @__PURE__ */ v("div", {
2024
2038
  className: "bailey-trace-rows",
2025
- children: e.rows.map((e) => /* @__PURE__ */ v(Xt, { row: e }, e.key))
2039
+ children: e.rows.map((e) => /* @__PURE__ */ v(Zt, { row: e }, e.key))
2026
2040
  })]
2027
2041
  }, `group-${t}`);
2028
2042
  })
@@ -2030,7 +2044,7 @@ function $t({ events: e, lastRequest: t, onClear: n }) {
2030
2044
  ]
2031
2045
  });
2032
2046
  }
2033
- function en({ events: e, lastRequest: t, onClear: n }) {
2047
+ function tn({ events: e, lastRequest: t, onClear: n }) {
2034
2048
  let [r, i] = f(!1), a = u(() => lt(e), [e]), o = u(() => st(e), [e]);
2035
2049
  return e.length === 0 && !t ? null : /* @__PURE__ */ y("div", {
2036
2050
  className: "bailey-trace-panel",
@@ -2052,16 +2066,15 @@ function en({ events: e, lastRequest: t, onClear: n }) {
2052
2066
  className: a ? "bailey-trace-summary bailey-trace-summary-error" : "bailey-trace-summary",
2053
2067
  children: o
2054
2068
  })]
2055
- }), r && /* @__PURE__ */ v($t, {
2069
+ }), r && /* @__PURE__ */ v(en, {
2056
2070
  events: e,
2057
2071
  lastRequest: t,
2058
2072
  onClear: n
2059
2073
  })]
2060
2074
  });
2061
2075
  }
2062
- //#endregion
2063
- //#region src/ui/ToolResultImage.tsx
2064
- function tn({ src: e, alt: n, className: r }) {
2076
+ // src/ui/ToolResultImage.tsx
2077
+ function nn({ src: e, alt: n, className: r }) {
2065
2078
  return t(e) ? /* @__PURE__ */ v("img", {
2066
2079
  src: e,
2067
2080
  alt: n ?? "",
@@ -2069,23 +2082,21 @@ function tn({ src: e, alt: n, className: r }) {
2069
2082
  referrerPolicy: "no-referrer"
2070
2083
  }) : null;
2071
2084
  }
2072
- //#endregion
2073
- //#region src/utils/safeMcpAppResource.ts
2074
- var nn = /^ui:\/\//, rn = 2097152, an = /* @__PURE__ */ new Set([
2085
+ // src/utils/safeMcpAppResource.ts
2086
+ var rn = /^ui:\/\//, an = 2097152, on = /* @__PURE__ */ new Set([
2075
2087
  "connectDomains",
2076
2088
  "resourceDomains",
2077
2089
  "frameDomains",
2078
2090
  "baseUriDomains"
2079
- ]), on = /* @__PURE__ */ new Set([
2091
+ ]), sn = /* @__PURE__ */ new Set([
2080
2092
  "camera",
2081
2093
  "microphone",
2082
2094
  "geolocation",
2083
2095
  "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({
2096
+ ]), cn = (e, t) => e === void 0 ? !0 : typeof e != "object" || !e || Array.isArray(e) ? !1 : Object.keys(e).every((e) => t.has(e)), ln = (e) => !(!rn.test(e.resourceUri) || typeof e.html != "string" || e.html.length === 0 || e.html.length > an || !cn(e.csp, on) || !cn(e.permissions, sn));
2097
+ // src/ui/McpAppFrame.tsx
2098
+ function un({ html: e, title: t, resourceUri: n, csp: r, permissions: i, className: a }) {
2099
+ return ln({
2089
2100
  html: e,
2090
2101
  resourceUri: n,
2091
2102
  csp: r,
@@ -2098,16 +2109,15 @@ function ln({ html: e, title: t, resourceUri: n, csp: r, permissions: i, classNa
2098
2109
  className: `bailey-mcp-app-frame${a ? ` ${a}` : ""}`
2099
2110
  }) : null;
2100
2111
  }
2101
- //#endregion
2102
- //#region src/ui/BaileyToolSteps.tsx
2103
- function un({ toolName: e, resolveActivityIcon: t }) {
2112
+ // src/ui/BaileyToolSteps.tsx
2113
+ function dn({ toolName: e, resolveActivityIcon: t }) {
2104
2114
  let n = t?.(e);
2105
2115
  return n === 0 || n && n !== !0 ? /* @__PURE__ */ v("span", {
2106
2116
  className: "bailey-activity-icon",
2107
2117
  children: n
2108
2118
  }) : null;
2109
2119
  }
2110
- function dn({ offsetMs: e, labels: t }) {
2120
+ function fn({ offsetMs: e, labels: t }) {
2111
2121
  let n = at(e), r = t.toolStepStartedText?.replace("{offset}", n);
2112
2122
  return /* @__PURE__ */ v("span", {
2113
2123
  className: "bailey-tool-step-start",
@@ -2117,7 +2127,7 @@ function dn({ offsetMs: e, labels: t }) {
2117
2127
  children: n
2118
2128
  });
2119
2129
  }
2120
- function fn({ steps: e, resolveActivityIcon: t }) {
2130
+ function pn({ steps: e, resolveActivityIcon: t }) {
2121
2131
  let n = e.filter((e) => e.status === "running");
2122
2132
  return n.length === 0 ? null : /* @__PURE__ */ v("div", {
2123
2133
  className: "bailey-tool-steps-live",
@@ -2126,7 +2136,7 @@ function fn({ steps: e, resolveActivityIcon: t }) {
2126
2136
  children: n.map((e) => /* @__PURE__ */ y("div", {
2127
2137
  className: "bailey-activity-line",
2128
2138
  children: [
2129
- /* @__PURE__ */ v(un, {
2139
+ /* @__PURE__ */ v(dn, {
2130
2140
  toolName: e.toolName,
2131
2141
  resolveActivityIcon: t
2132
2142
  }),
@@ -2139,7 +2149,7 @@ function fn({ steps: e, resolveActivityIcon: t }) {
2139
2149
  }, e.key))
2140
2150
  });
2141
2151
  }
2142
- function pn({ steps: e, labels: t, resolveActivityIcon: n }) {
2152
+ function mn({ steps: e, labels: t, resolveActivityIcon: n }) {
2143
2153
  if (e.length === 0) return null;
2144
2154
  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
2155
  return /* @__PURE__ */ y("details", {
@@ -2149,12 +2159,12 @@ function pn({ steps: e, labels: t, resolveActivityIcon: n }) {
2149
2159
  children: e.map((e) => /* @__PURE__ */ y("li", {
2150
2160
  className: "bailey-tool-step",
2151
2161
  children: [
2152
- /* @__PURE__ */ v(un, {
2162
+ /* @__PURE__ */ v(dn, {
2153
2163
  toolName: e.toolName,
2154
2164
  resolveActivityIcon: n
2155
2165
  }),
2156
2166
  /* @__PURE__ */ v("span", { children: e.label }),
2157
- e.startOffsetMs !== void 0 && /* @__PURE__ */ v(dn, {
2167
+ e.startOffsetMs !== void 0 && /* @__PURE__ */ v(fn, {
2158
2168
  offsetMs: e.startOffsetMs,
2159
2169
  labels: t
2160
2170
  }),
@@ -2169,31 +2179,29 @@ function pn({ steps: e, labels: t, resolveActivityIcon: n }) {
2169
2179
  })]
2170
2180
  });
2171
2181
  }
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;
2177
- }
2182
+ // src/utils/relativeTime.ts
2183
+ var hn = /(Z|[+-]\d{2}:?\d{2})$/i, gn = 60, _n = 3600, vn = 24 * _n, yn = 30 * vn * 1e3;
2178
2184
  function bn(e) {
2179
- let t = yn(e.iso);
2185
+ return e ? Date.parse(hn.test(e) ? e : `${e}Z`) : NaN;
2186
+ }
2187
+ function xn(e) {
2188
+ let t = bn(e.iso);
2180
2189
  if (Number.isNaN(t)) return "";
2181
2190
  let n = e.now ?? Date.now(), r = Math.max(0, n - t);
2182
2191
  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);
2192
+ if (r >= yn) return new Intl.DateTimeFormat(e.locale, { dateStyle: "medium" }).format(t);
2184
2193
  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");
2194
+ return i < gn ? a.format(0, "second") : i < _n ? a.format(-Math.floor(i / gn), "minute") : i < vn ? a.format(-Math.floor(i / _n), "hour") : a.format(-Math.floor(i / vn), "day");
2186
2195
  }
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({
2196
+ // src/ui/BaileyHistoryDrawer.tsx
2197
+ function Sn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o }) {
2198
+ let s = G({
2191
2199
  client: e,
2192
2200
  pageSize: t
2193
2201
  }), { loadConversation: c, newChat: l } = n, u = a((e) => c ? c(e) : Promise.reject(/* @__PURE__ */ Error("no loadConversation")), [c]), d = a(() => {
2194
2202
  l(), o({ restoreFocusTo: "input" });
2195
2203
  }, [l, o]);
2196
- return /* @__PURE__ */ v(wn, {
2204
+ return /* @__PURE__ */ v(Tn, {
2197
2205
  conversations: s,
2198
2206
  activeConversationId: n.conversationId,
2199
2207
  selectStatus: n.historyStatus,
@@ -2205,15 +2213,15 @@ function xn({ client: e, pageSize: t, chat: n, labels: r, locale: i, onClose: o
2205
2213
  locale: i
2206
2214
  });
2207
2215
  }
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);
2216
+ var Cn = (e, t) => Object.entries(t).reduce((e, [t, n]) => e.split(`{${t}}`).join(String(n)), e), wn = (e) => !e || e.kind !== "http" ? !1 : e.status === 401 || e.status === 403;
2217
+ function Tn({ conversations: e, activeConversationId: t, selectStatus: n, onSelect: r, onActiveDeleted: i, onNewChat: a, onClose: o, labels: l, locale: u, now: p }) {
2218
+ let { conversations: m, status: h, error: g, hasMore: b, refresh: ee, loadMore: x, remove: S } = e, C = c(), w = c(), T = d(null), E = d(null), D = d(null), O = d(/* @__PURE__ */ new Map()), k = d(/* @__PURE__ */ new Map()), A = d(null), j = d(null), [M, N] = f(null), [P, F] = f(null), [I, te] = f(0), [ne, re] = f(!1), [L, ie] = f(!1), [ae, R] = f(!1), z = u ?? (typeof navigator < "u" ? navigator.language : void 0);
2211
2219
  s(() => {
2212
- E.current?.focus();
2220
+ T.current?.focus();
2213
2221
  }, []), s(() => {
2214
2222
  let e = A.current;
2215
2223
  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;
2224
+ let t = e.kind === "select" ? O.current.get(e.id) : e.kind === "delete" ? k.current.get(e.id) : e.kind === "cancel" ? D.current : E.current;
2217
2225
  t && (t.focus(), A.current = null);
2218
2226
  }), s(() => {
2219
2227
  let e = j.current;
@@ -2226,59 +2234,52 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2226
2234
  b,
2227
2235
  m
2228
2236
  ]);
2229
- let ce = () => {
2230
- j.current = m.length, S();
2231
- }, le = (e) => {
2237
+ let B = () => {
2238
+ j.current = m.length, x();
2239
+ }, oe = (e) => {
2232
2240
  A.current = {
2233
2241
  kind: "delete",
2234
2242
  id: e
2235
2243
  }, N(null);
2236
- }, ue = (e) => {
2237
- if (e.key === "Escape") {
2238
- if (e.stopPropagation(), M) {
2239
- le(M);
2244
+ }, se = (e) => {
2245
+ e.key === "Escape" && (e.stopPropagation(), M ? oe(M) : o({ restoreFocusTo: "menu" }));
2246
+ }, ce = async (e) => {
2247
+ if (R(!1), e === t) o({ restoreFocusTo: "input" });
2248
+ else {
2249
+ ie(!0);
2250
+ try {
2251
+ await r({ conversationId: e });
2252
+ } catch {
2253
+ A.current = {
2254
+ kind: "select",
2255
+ id: e
2256
+ }, R(!0), ie(!1);
2240
2257
  return;
2241
2258
  }
2242
- o({ restoreFocusTo: "menu" });
2243
- }
2244
- }, de = async (e) => {
2245
- if (se(!1), e === t) {
2246
- o({ restoreFocusTo: "input" });
2247
- return;
2259
+ ie(!1), o({ restoreFocusTo: "input" });
2248
2260
  }
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) => {
2261
+ }, le = async (e) => {
2261
2262
  let n = m.findIndex((t) => t.conversationId === e), r = m[n + 1] ?? m[n - 1];
2262
2263
  A.current = r ? {
2263
2264
  kind: "select",
2264
2265
  id: r.conversationId
2265
- } : { kind: "newChat" }, N(null), F(null), ie(!1), ne((e) => e + 1);
2266
+ } : { kind: "newChat" }, N(null), F(null), re(!1), te((e) => e + 1);
2266
2267
  try {
2267
- await C({ conversationId: e }), ie(!0), e === t && i?.();
2268
+ await S({ conversationId: e }), re(!0), e === t && i?.();
2268
2269
  } catch {
2269
2270
  A.current = {
2270
2271
  kind: "delete",
2271
2272
  id: e
2272
2273
  }, F(e);
2273
2274
  } finally {
2274
- ne((e) => e - 1);
2275
+ te((e) => e - 1);
2275
2276
  }
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;
2277
+ }, V = h === "loading" && m.length === 0, ue = h === "error" && m.length === 0, de = h === "error" && m.length > 0 && b, H = h === "loading" && m.length > 0, U = L || n === "loading", fe = V ? l.historyLoadingText : I > 0 ? l.historyDeletingText : ne ? l.historyDeletedText : m.length > 0 ? Cn(m.length === 1 ? l.historyCountTextOne : l.historyCountTextMany, { count: m.length }) : "", W = V || I > 0;
2277
2278
  return /* @__PURE__ */ y("section", {
2278
2279
  role: "region",
2279
- "aria-labelledby": w,
2280
+ "aria-labelledby": C,
2280
2281
  className: "bailey-history-drawer",
2281
- onKeyDown: ue,
2282
+ onKeyDown: se,
2282
2283
  children: [
2283
2284
  /* @__PURE__ */ y("div", {
2284
2285
  className: "bailey-history-header",
@@ -2288,23 +2289,23 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2288
2289
  className: "bailey-history-icon-button",
2289
2290
  "aria-label": l.historyBackAriaLabel,
2290
2291
  onClick: () => o({ restoreFocusTo: "menu" }),
2291
- children: /* @__PURE__ */ v(Vt, { className: "bailey-history-icon" })
2292
+ children: /* @__PURE__ */ v(Ht, { className: "bailey-history-icon" })
2292
2293
  }),
2293
2294
  /* @__PURE__ */ v("h3", {
2294
- id: w,
2295
- ref: E,
2295
+ id: C,
2296
+ ref: T,
2296
2297
  tabIndex: -1,
2297
2298
  className: "bailey-history-heading",
2298
2299
  children: l.historyTitle
2299
2300
  }),
2300
2301
  /* @__PURE__ */ y("button", {
2301
- ref: D,
2302
+ ref: E,
2302
2303
  type: "button",
2303
2304
  className: "bailey-history-button bailey-history-new-chat",
2304
2305
  "aria-label": l.newChatButtonText,
2305
- disabled: R,
2306
+ disabled: V,
2306
2307
  onClick: a,
2307
- children: [/* @__PURE__ */ v(It, { className: "bailey-history-icon-small" }), /* @__PURE__ */ v("span", {
2308
+ children: [/* @__PURE__ */ v(Lt, { className: "bailey-history-icon-small" }), /* @__PURE__ */ v("span", {
2308
2309
  className: "bailey-history-new-chat-text",
2309
2310
  children: l.newChatButtonText
2310
2311
  })]
@@ -2313,9 +2314,9 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2313
2314
  }),
2314
2315
  /* @__PURE__ */ y("div", {
2315
2316
  className: "bailey-history-body",
2316
- "aria-busy": R || void 0,
2317
+ "aria-busy": V || void 0,
2317
2318
  children: [
2318
- R && /* @__PURE__ */ y("div", {
2319
+ V && /* @__PURE__ */ y("div", {
2319
2320
  "aria-hidden": "true",
2320
2321
  children: [
2321
2322
  /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" }),
@@ -2324,25 +2325,25 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2324
2325
  /* @__PURE__ */ v("div", { className: "bailey-history-skeleton" })
2325
2326
  ]
2326
2327
  }),
2327
- pe && /* @__PURE__ */ y("div", {
2328
+ ue && /* @__PURE__ */ y("div", {
2328
2329
  role: "alert",
2329
2330
  className: "bailey-history-state bailey-history-state-error",
2330
2331
  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 }),
2332
+ /* @__PURE__ */ v(Wt, { className: "bailey-history-state-icon" }),
2333
+ /* @__PURE__ */ v("strong", { children: wn(g) ? l.historySessionExpiredTitle : l.historyErrorTitle }),
2334
+ /* @__PURE__ */ v("span", { children: wn(g) ? l.historySessionExpiredDescription : l.historyErrorDescription }),
2334
2335
  /* @__PURE__ */ v("button", {
2335
2336
  type: "button",
2336
2337
  className: "bailey-history-button bailey-history-button-primary",
2337
- onClick: () => void x(),
2338
+ onClick: () => void ee(),
2338
2339
  children: l.retryButtonText
2339
2340
  })
2340
2341
  ]
2341
2342
  }),
2342
- !R && !pe && m.length === 0 && /* @__PURE__ */ y("div", {
2343
+ !V && !ue && m.length === 0 && /* @__PURE__ */ y("div", {
2343
2344
  className: "bailey-history-state",
2344
2345
  children: [
2345
- /* @__PURE__ */ v(Nt, { className: "bailey-history-state-icon" }),
2346
+ /* @__PURE__ */ v(Pt, { className: "bailey-history-state-icon" }),
2346
2347
  /* @__PURE__ */ v("strong", { children: l.historyEmptyTitle }),
2347
2348
  /* @__PURE__ */ v("span", { children: l.historyEmptyDescription }),
2348
2349
  /* @__PURE__ */ v("button", {
@@ -2361,11 +2362,11 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2361
2362
  className: "bailey-history-row bailey-history-row-confirming",
2362
2363
  children: /* @__PURE__ */ y("div", {
2363
2364
  role: "group",
2364
- "aria-labelledby": T,
2365
+ "aria-labelledby": w,
2365
2366
  className: "bailey-history-confirm",
2366
2367
  children: [
2367
2368
  /* @__PURE__ */ v("span", {
2368
- id: T,
2369
+ id: w,
2369
2370
  className: "bailey-history-confirm-question",
2370
2371
  children: l.historyDeleteConfirmQuestion
2371
2372
  }),
@@ -2376,38 +2377,38 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2376
2377
  /* @__PURE__ */ v("button", {
2377
2378
  type: "button",
2378
2379
  className: "bailey-history-button bailey-history-button-danger",
2379
- onClick: () => void fe(n),
2380
+ onClick: () => void le(n),
2380
2381
  children: l.historyDeleteConfirmText
2381
2382
  }),
2382
2383
  /* @__PURE__ */ v("button", {
2383
- ref: O,
2384
+ ref: D,
2384
2385
  type: "button",
2385
2386
  className: "bailey-history-button",
2386
- onClick: () => le(n),
2387
+ onClick: () => oe(n),
2387
2388
  children: l.historyDeleteCancelText
2388
2389
  })
2389
2390
  ]
2390
2391
  })
2391
2392
  }, n);
2392
- let a = bn({
2393
+ let a = xn({
2393
2394
  iso: e.updatedAt,
2394
- locale: L,
2395
+ locale: z,
2395
2396
  now: p?.(),
2396
2397
  justNowText: l.historyJustNowText
2397
- }), o = Sn(e.messageCount === 1 ? l.historyMessageCountOne : l.historyMessageCountMany, { count: e.messageCount }), s = P === n;
2398
+ }), o = Cn(e.messageCount === 1 ? l.historyMessageCountOne : l.historyMessageCountMany, { count: e.messageCount }), s = P === n;
2398
2399
  return /* @__PURE__ */ y("li", {
2399
2400
  className: `bailey-history-row${i ? " bailey-history-row-active" : ""}${s ? " bailey-history-row-failed" : ""}`,
2400
2401
  children: [
2401
2402
  /* @__PURE__ */ y("button", {
2402
2403
  type: "button",
2403
2404
  ref: (e) => {
2404
- e ? k.current.set(n, e) : k.current.delete(n);
2405
+ e ? O.current.set(n, e) : O.current.delete(n);
2405
2406
  },
2406
2407
  className: "bailey-history-select",
2407
2408
  "aria-current": i ? "true" : void 0,
2408
- "aria-disabled": V || void 0,
2409
+ "aria-disabled": U || void 0,
2409
2410
  onClick: () => {
2410
- V || de(n);
2411
+ U || ce(n);
2411
2412
  },
2412
2413
  children: [/* @__PURE__ */ v("span", {
2413
2414
  className: "bailey-history-row-title",
@@ -2433,25 +2434,25 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2433
2434
  /* @__PURE__ */ v("button", {
2434
2435
  type: "button",
2435
2436
  ref: (e) => {
2436
- e ? ee.current.set(n, e) : ee.current.delete(n);
2437
+ e ? k.current.set(n, e) : k.current.delete(n);
2437
2438
  },
2438
2439
  className: "bailey-history-icon-button bailey-history-delete",
2439
- "aria-label": Sn(l.historyDeleteAriaLabel, { title: r }),
2440
+ "aria-label": Cn(l.historyDeleteAriaLabel, { title: r }),
2440
2441
  onClick: () => {
2441
- F(null), ie(!1), A.current = { kind: "cancel" }, N(n);
2442
+ F(null), re(!1), A.current = { kind: "cancel" }, N(n);
2442
2443
  },
2443
- children: /* @__PURE__ */ v(Ht, { className: "bailey-history-icon" })
2444
+ children: /* @__PURE__ */ v(Ut, { className: "bailey-history-icon" })
2444
2445
  }),
2445
2446
  s && /* @__PURE__ */ y("div", {
2446
2447
  role: "alert",
2447
2448
  className: "bailey-history-row-error",
2448
2449
  children: [
2449
- /* @__PURE__ */ v(Ut, { className: "bailey-history-icon-small" }),
2450
+ /* @__PURE__ */ v(Wt, { className: "bailey-history-icon-small" }),
2450
2451
  /* @__PURE__ */ v("span", { children: l.historyDeleteFailedText }),
2451
2452
  /* @__PURE__ */ v("button", {
2452
2453
  type: "button",
2453
2454
  className: "bailey-history-button bailey-history-button-small",
2454
- onClick: () => void fe(n),
2455
+ onClick: () => void le(n),
2455
2456
  children: l.historyDeleteRetryText
2456
2457
  }),
2457
2458
  /* @__PURE__ */ v("button", {
@@ -2466,31 +2467,31 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2466
2467
  }, n);
2467
2468
  })
2468
2469
  }),
2469
- oe && /* @__PURE__ */ v("div", {
2470
+ ae && /* @__PURE__ */ v("div", {
2470
2471
  role: "alert",
2471
2472
  className: "bailey-history-inline-error",
2472
2473
  children: l.historySelectErrorText
2473
2474
  }),
2474
2475
  b && m.length > 0 && /* @__PURE__ */ v("div", {
2475
2476
  className: "bailey-history-more",
2476
- children: z ? /* @__PURE__ */ y("div", {
2477
+ children: de ? /* @__PURE__ */ y("div", {
2477
2478
  role: "alert",
2478
2479
  className: "bailey-history-inline-error",
2479
2480
  children: [/* @__PURE__ */ v("span", { children: l.historyLoadMoreErrorText }), /* @__PURE__ */ v("button", {
2480
2481
  type: "button",
2481
2482
  className: "bailey-history-button",
2482
- onClick: ce,
2483
+ onClick: B,
2483
2484
  children: l.retryButtonText
2484
2485
  })]
2485
2486
  }) : /* @__PURE__ */ y("button", {
2486
2487
  type: "button",
2487
2488
  className: "bailey-history-button",
2488
- disabled: B,
2489
- onClick: ce,
2490
- children: [B && /* @__PURE__ */ v("span", {
2489
+ disabled: H,
2490
+ onClick: B,
2491
+ children: [H && /* @__PURE__ */ v("span", {
2491
2492
  className: "bailey-history-spinner",
2492
2493
  "aria-hidden": "true"
2493
- }), B ? l.historyLoadingMoreText : l.historyLoadMoreText]
2494
+ }), H ? l.historyLoadingMoreText : l.historyLoadMoreText]
2494
2495
  })
2495
2496
  })
2496
2497
  ]
@@ -2499,17 +2500,16 @@ function wn({ conversations: e, activeConversationId: t, selectStatus: n, onSele
2499
2500
  role: "status",
2500
2501
  "aria-live": "polite",
2501
2502
  className: "bailey-history-status",
2502
- children: [U && /* @__PURE__ */ v("span", {
2503
+ children: [W && /* @__PURE__ */ v("span", {
2503
2504
  className: "bailey-history-spinner",
2504
2505
  "aria-hidden": "true"
2505
- }), H]
2506
+ }), fe]
2506
2507
  })
2507
2508
  ]
2508
2509
  });
2509
2510
  }
2510
- //#endregion
2511
- //#region src/ui/historyLabels.ts
2512
- var Tn = {
2511
+ // src/ui/historyLabels.ts
2512
+ var En = {
2513
2513
  newChatButtonText: "New chat",
2514
2514
  retryButtonText: "Retry",
2515
2515
  historyTitle: "Chat history",
@@ -2542,360 +2542,7 @@ var Tn = {
2542
2542
  historyDeleteRetryText: "Try again",
2543
2543
  historyDeleteDismissText: "Dismiss",
2544
2544
  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 = {
2545
+ }, Dn = {
2899
2546
  feedbackGroupLabel: "Rate this response",
2900
2547
  feedbackThumbsUpAriaLabel: "Good response",
2901
2548
  feedbackThumbsDownAriaLabel: "Bad response",
@@ -2916,48 +2563,49 @@ var In = {
2916
2563
  feedbackReasonUnsafe: "Unsafe",
2917
2564
  feedbackReasonTooLong: "Too long",
2918
2565
  feedbackReasonOther: "Other"
2919
- }, Ln = 2e3, Rn = [
2566
+ }, On = 2e3, kn = [
2920
2567
  "inaccurate",
2921
2568
  "unhelpful",
2922
2569
  "unsafe",
2923
2570
  "too_long",
2924
2571
  "other"
2925
- ], zn = {
2572
+ ], An = {
2926
2573
  inaccurate: "feedbackReasonInaccurate",
2927
2574
  unhelpful: "feedbackReasonUnhelpful",
2928
2575
  unsafe: "feedbackReasonUnsafe",
2929
2576
  too_long: "feedbackReasonTooLong",
2930
2577
  other: "feedbackReasonOther"
2931
- }, Bn = (e) => Rn.includes(e) ? e : "other";
2932
- function Vn(e) {
2933
- return Array.from(new Set((e ?? Rn).map(Bn)));
2578
+ }, jn = (e) => kn.includes(e) ? e : "other";
2579
+ function Mn(e) {
2580
+ return Array.from(new Set((e ?? kn).map(jn)));
2934
2581
  }
2935
- function Hn(e) {
2936
- return typeof e == "number" && e > 0 ? Math.min(Math.floor(e), Ln) : Ln;
2582
+ function Nn(e) {
2583
+ return typeof e == "number" && e > 0 ? Math.min(Math.floor(e), On) : On;
2937
2584
  }
2938
- function Un(e, t) {
2585
+ function Pn(e, t) {
2939
2586
  if (e === null || t === null) return e === t;
2940
2587
  let n = e.reasonCodes ?? [], r = t.reasonCodes ?? [];
2941
2588
  return e.rating === t.rating && (e.comment ?? "") === (t.comment ?? "") && n.length === r.length && n.every((e, t) => e === r[t]);
2942
2589
  }
2943
- function Wn(e) {
2944
- return e.messageId ? /* @__PURE__ */ v(Gn, { ...e }, e.messageId) : null;
2590
+ function Fn(e) {
2591
+ let t = o(Dt), n = t && !t.builtIn ? t.claim : void 0, { messageId: r } = e;
2592
+ return l(() => n && r ? n(r) : void 0, [n, r]), e.messageId ? /* @__PURE__ */ v(In, { ...e }, e.messageId) : null;
2945
2593
  }
2946
- function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOptions: i, maxCommentLength: a, labels: o, className: l }) {
2594
+ function In({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOptions: i, maxCommentLength: a, labels: o, className: l }) {
2947
2595
  let u = {
2948
- ...In,
2596
+ ...Dn,
2949
2597
  ...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`;
2951
- s(() => (se.current = !0, () => {
2952
- se.current = !1;
2598
+ }, p = Mn(i), m = Nn(a), h = r ? { rating: r } : null, [b, ee] = f(h), [x, S] = f(r ?? null), [C, w] = f(!1), [T, E] = f("down"), [D, O] = f([]), [k, A] = f(""), [j, M] = f(!1), [N, P] = f(!1), [F, I] = f(!1), [te, ne] = f(!1), re = d(h), L = d(null), ie = d(0), ae = d(!1), R = d(!0), z = d(null), B = d(null), oe = d(null), se = d(null), ce = d(null), le = Et(B), V = c(), ue = `${V}-comment`, de = `${V}-counter`, H = `${V}-privacy`;
2599
+ s(() => (R.current = !0, () => {
2600
+ R.current = !1;
2953
2601
  }), []), s(() => {
2954
- w && de.current?.focus();
2955
- }, [w]), s(() => {
2956
- L.current && !F && !w && ((L.current === "up" ? le : ue).current?.focus(), L.current = null);
2602
+ C && ce.current?.focus();
2603
+ }, [C]), s(() => {
2604
+ z.current && !F && !C && ((z.current === "up" ? oe : se).current?.focus(), z.current = null);
2957
2605
  });
2958
- let V = () => {
2959
- k([]), A("");
2960
- }, H = async (r) => {
2606
+ let U = () => {
2607
+ O([]), A("");
2608
+ }, fe = async (r) => {
2961
2609
  try {
2962
2610
  return r.kind === "clear" ? await n({ messageId: e }) : await t({
2963
2611
  messageId: e,
@@ -2966,79 +2614,73 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
2966
2614
  } catch {
2967
2615
  return !1;
2968
2616
  }
2969
- }, U = async () => {
2970
- if (!oe.current) {
2971
- oe.current = !0, P(!0);
2617
+ }, W = async () => {
2618
+ if (!ae.current) {
2619
+ ae.current = !0, P(!0);
2972
2620
  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);
2975
- 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)));
2621
+ for (; L.current && R.current;) {
2622
+ let e = L.current, t = e.kind === "clear" ? null : e.snapshot, n = !(e.kind === "submit" && e.formSubmit) && Pn(t, re.current) || await fe(e);
2623
+ if (!R.current) return;
2624
+ let r = L.current?.version !== e.version;
2625
+ (n || !r) && (n ? (re.current = t, ee(t)) : (S(re.current?.rating ?? null), ne(!0)), r || (L.current = null, I(!1), n && e.kind === "submit" && e.formSubmit && (w(!1), M(!0), z.current = e.snapshot.rating)));
2978
2626
  }
2979
2627
  } finally {
2980
- oe.current = !1, se.current && P(!1);
2628
+ ae.current = !1, R.current && P(!1);
2981
2629
  }
2982
2630
  }
2983
- }, me = (e) => {
2984
- ae.current += 1, I.current = {
2631
+ }, pe = (e) => {
2632
+ ie.current += 1, L.current = {
2985
2633
  ...e,
2986
- 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));
2634
+ version: ie.current
2635
+ }, ne(!1), W();
2636
+ }, G = () => {
2637
+ S(null), w(!1), M(!1), U(), pe({ kind: "clear" });
2638
+ }, me = (e) => {
2639
+ F || (x === e ? G() : (S(e), M(!1), U(), e === "down" ? (E("down"), w(!0)) : w(!1), pe({
2640
+ kind: "submit",
2641
+ snapshot: { rating: e },
2642
+ formSubmit: !1
2643
+ })));
2644
+ }, he = (e) => {
2645
+ x !== null && (E(x), O((e?.reasonCodes ?? []).map(jn)), A(e?.comment ?? ""), ne(!1), w(!0));
2646
+ }, K = () => {
2647
+ F || (w(!1), ne(!1), U(), z.current = T);
3004
2648
  }, q = () => {
3005
- F || (T(!1), re(!1), V(), L.current = E);
3006
- }, he = () => {
3007
2649
  if (F) return;
3008
- let e = ee.trim(), t = p.filter((e) => O.includes(e)), n = {
3009
- rating: E,
2650
+ let e = k.trim(), t = p.filter((e) => D.includes(e)), n = {
2651
+ rating: T,
3010
2652
  ...t.length > 0 ? { reasonCodes: t } : {},
3011
2653
  ...e ? { comment: e } : {}
3012
2654
  };
3013
- te(!0), C(E), me({
2655
+ I(!0), S(T), pe({
3014
2656
  kind: "submit",
3015
2657
  snapshot: n,
3016
2658
  formSubmit: !0
3017
2659
  });
2660
+ }, J = (e) => {
2661
+ O((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
3018
2662
  }, ge = (e) => {
3019
- 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;
2663
+ e.key === "Escape" && (e.stopPropagation(), K());
2664
+ }, _e = x !== null && b?.rating === x && !N && !C, ve = !!b && (!!b.comment || (b.reasonCodes?.length ?? 0) > 0), ye = N ? u.feedbackSavingText : _e ? u.feedbackThanksText : "", Y = (e) => {
2665
+ let t = x === e, n = e === "up" ? u.feedbackThumbsUpAriaLabel : u.feedbackThumbsDownAriaLabel, r = e === "up" ? Bt : Vt;
3024
2666
  return /* @__PURE__ */ y(g.Root, { children: [/* @__PURE__ */ v(g.Trigger, {
3025
2667
  asChild: !0,
3026
2668
  children: /* @__PURE__ */ v("button", {
3027
- ref: e === "up" ? le : ue,
2669
+ ref: e === "up" ? oe : se,
3028
2670
  type: "button",
3029
2671
  className: "bailey-feedback-thumb",
3030
2672
  "aria-pressed": t,
3031
2673
  "aria-label": n,
3032
2674
  "aria-busy": t && N ? !0 : void 0,
3033
2675
  disabled: F,
3034
- onClick: () => G(e),
2676
+ onClick: () => me(e),
3035
2677
  children: /* @__PURE__ */ v(r, {
3036
2678
  className: "bailey-feedback-icon",
3037
2679
  filled: t
3038
2680
  })
3039
2681
  })
3040
2682
  }), /* @__PURE__ */ v(g.Portal, {
3041
- container: fe instanceof ShadowRoot ? fe : void 0,
2683
+ container: le instanceof ShadowRoot ? le : void 0,
3042
2684
  children: /* @__PURE__ */ y(g.Content, {
3043
2685
  side: "top",
3044
2686
  className: "bailey-tooltip-content",
@@ -3047,7 +2689,7 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3047
2689
  })] });
3048
2690
  };
3049
2691
  return /* @__PURE__ */ y("div", {
3050
- ref: ce,
2692
+ ref: B,
3051
2693
  className: `bailey-feedback${l ? ` ${l}` : ""}`,
3052
2694
  children: [
3053
2695
  /* @__PURE__ */ v(g.Provider, {
@@ -3057,7 +2699,7 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3057
2699
  "aria-label": u.feedbackGroupLabel,
3058
2700
  "aria-busy": N ? !0 : void 0,
3059
2701
  className: "bailey-feedback-thumbs",
3060
- children: [be("up"), be("down")]
2702
+ children: [Y("up"), Y("down")]
3061
2703
  })
3062
2704
  }),
3063
2705
  /* @__PURE__ */ y("span", {
@@ -3068,25 +2710,25 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3068
2710
  "aria-hidden": "true"
3069
2711
  }), ye]
3070
2712
  }),
3071
- ve && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
2713
+ _e && /* @__PURE__ */ y(_, { children: [/* @__PURE__ */ v("button", {
3072
2714
  type: "button",
3073
2715
  className: "bailey-feedback-link",
3074
- onClick: () => K(b),
3075
- children: j || J ? u.feedbackEditText : u.feedbackAddCommentText
2716
+ onClick: () => he(b),
2717
+ children: j || ve ? u.feedbackEditText : u.feedbackAddCommentText
3076
2718
  }), /* @__PURE__ */ v("button", {
3077
2719
  type: "button",
3078
2720
  className: "bailey-feedback-link",
3079
- onClick: W,
2721
+ onClick: G,
3080
2722
  children: u.feedbackUndoText
3081
2723
  })] }),
3082
- ne && /* @__PURE__ */ v("span", {
2724
+ te && /* @__PURE__ */ v("span", {
3083
2725
  role: "alert",
3084
2726
  className: "bailey-feedback-error",
3085
2727
  children: u.feedbackErrorText
3086
2728
  }),
3087
- w && /* @__PURE__ */ y("div", {
2729
+ C && /* @__PURE__ */ y("div", {
3088
2730
  className: "bailey-feedback-form",
3089
- onKeyDown: _e,
2731
+ onKeyDown: ge,
3090
2732
  children: [
3091
2733
  p.length > 0 && /* @__PURE__ */ y("fieldset", {
3092
2734
  className: "bailey-feedback-reasons",
@@ -3097,45 +2739,45 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3097
2739
  className: "bailey-feedback-chips",
3098
2740
  children: p.map((e, t) => /* @__PURE__ */ v("button", {
3099
2741
  ref: t === 0 ? (e) => {
3100
- de.current = e;
2742
+ ce.current = e;
3101
2743
  } : void 0,
3102
2744
  type: "button",
3103
2745
  className: "bailey-feedback-chip",
3104
- "aria-pressed": O.includes(e),
2746
+ "aria-pressed": D.includes(e),
3105
2747
  disabled: F,
3106
- onClick: () => ge(e),
3107
- children: u[zn[e]]
2748
+ onClick: () => J(e),
2749
+ children: u[An[e]]
3108
2750
  }, e))
3109
2751
  })]
3110
2752
  }),
3111
2753
  /* @__PURE__ */ v("label", {
3112
- htmlFor: pe,
2754
+ htmlFor: ue,
3113
2755
  className: "bailey-feedback-legend",
3114
2756
  children: u.feedbackCommentLabel
3115
2757
  }),
3116
2758
  /* @__PURE__ */ v("textarea", {
3117
- id: pe,
2759
+ id: ue,
3118
2760
  ref: p.length === 0 ? (e) => {
3119
- de.current = e;
2761
+ ce.current = e;
3120
2762
  } : void 0,
3121
2763
  className: "bailey-feedback-textarea",
3122
- value: ee,
2764
+ value: k,
3123
2765
  maxLength: m,
3124
2766
  placeholder: u.feedbackCommentPlaceholder,
3125
- "aria-describedby": `${z} ${B}`,
2767
+ "aria-describedby": `${de} ${H}`,
3126
2768
  disabled: F,
3127
2769
  onChange: (e) => A(e.target.value.slice(0, m))
3128
2770
  }),
3129
2771
  /* @__PURE__ */ y("div", {
3130
2772
  className: "bailey-feedback-meta",
3131
2773
  children: [/* @__PURE__ */ v("span", {
3132
- id: B,
2774
+ id: H,
3133
2775
  className: "bailey-feedback-privacy",
3134
2776
  children: u.feedbackPrivacyNote
3135
2777
  }), /* @__PURE__ */ v("span", {
3136
- id: z,
2778
+ id: de,
3137
2779
  className: "bailey-feedback-counter",
3138
- children: `${ee.length} / ${m}`
2780
+ children: `${k.length} / ${m}`
3139
2781
  })]
3140
2782
  }),
3141
2783
  /* @__PURE__ */ y("div", {
@@ -3144,13 +2786,13 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3144
2786
  type: "button",
3145
2787
  className: "bailey-feedback-button",
3146
2788
  disabled: F,
3147
- onClick: q,
2789
+ onClick: K,
3148
2790
  children: u.feedbackCancelText
3149
2791
  }), /* @__PURE__ */ v("button", {
3150
2792
  type: "button",
3151
2793
  className: "bailey-feedback-button bailey-feedback-button-primary",
3152
2794
  disabled: F,
3153
- onClick: he,
2795
+ onClick: q,
3154
2796
  children: F ? u.feedbackSavingText : u.feedbackSubmitText
3155
2797
  })]
3156
2798
  })
@@ -3159,8 +2801,382 @@ function Gn({ messageId: e, onSubmit: t, onClear: n, initialRating: r, reasonOpt
3159
2801
  ]
3160
2802
  });
3161
2803
  }
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 };
2804
+ // src/ui/BaileyChatPanel.tsx
2805
+ var Ln = "How can bailey AI help you today?", Rn = "Reply to bailey AI", zn = {
2806
+ ...En,
2807
+ newChatButtonText: "New chat",
2808
+ newChatAriaLabel: "new chat",
2809
+ historyAriaLabel: "conversation history",
2810
+ historyMenuItemText: "Chat history",
2811
+ menuAriaLabel: "more options",
2812
+ suggestionsTitle: "Suggested for you",
2813
+ emptyStateMessage: "Ask Bailey a question to get started.",
2814
+ youLabel: "You",
2815
+ thinkingHint: "Thinking…",
2816
+ retryButtonText: "Retry",
2817
+ dismissErrorAriaLabel: "dismiss error",
2818
+ sendAriaLabel: "send",
2819
+ stopButtonText: "Stop",
2820
+ stopAriaLabel: "stop",
2821
+ copyButtonAriaLabel: "copy response as markdown",
2822
+ copyButtonTooltipDefault: "Copy as markdown",
2823
+ copyButtonTooltipCopied: "Copied!",
2824
+ toolStepsSummaryOne: "Used 1 agent",
2825
+ toolStepsSummaryMany: "Used {count} agents",
2826
+ toolStepsFailedSuffix: ", {failed} failed",
2827
+ toolStepFailedText: "failed",
2828
+ toolStepStoppedText: "stopped",
2829
+ toolStepStartedText: "started {offset} after send",
2830
+ mcpAppDefaultTitle: "MCP App",
2831
+ loadEarlierButtonText: "Load earlier messages",
2832
+ loadEarlierErrorText: "Couldn't load earlier messages."
2833
+ }, Bn = [m], Vn = {
2834
+ ...Ot(),
2835
+ p: ({ children: e }) => /* @__PURE__ */ v(_, { children: e })
2836
+ }, Hn = i(function({ content: e, components: t }) {
2837
+ return /* @__PURE__ */ v("div", {
2838
+ className: "bailey-markdown-content",
2839
+ children: /* @__PURE__ */ v(p, {
2840
+ remarkPlugins: Bn,
2841
+ components: t,
2842
+ skipHtml: !0,
2843
+ children: e
2844
+ })
2845
+ });
2846
+ });
2847
+ function Un(e, t, n) {
2848
+ if (e !== "streaming") return;
2849
+ let r = t.filter((e) => e.turnSentAt === n?.sentAt);
2850
+ return r[r.length - 1];
2851
+ }
2852
+ function Wn(e) {
2853
+ if (e && e.kind !== "tool_end") return rt(e);
2854
+ }
2855
+ function Gn(e) {
2856
+ let t = new Date(e), n = t.toDateString() === (/* @__PURE__ */ new Date()).toDateString(), r = t.toLocaleTimeString([], {
2857
+ hour: "numeric",
2858
+ minute: "2-digit"
2859
+ });
2860
+ return n ? `Today ${r}` : `${t.toLocaleDateString()} ${r}`;
2861
+ }
2862
+ function Kn({ chat: e, placeholder: t, replyPlaceholder: r = Rn, emptyPlaceholder: i, suggestions: o, onHistoryClick: c, history: l, locale: m, privacyNote: _, resolveActivityIcon: b, sendIcon: ee, className: x, height: S, width: C, hideDeveloperDetails: w = !1, renderMessageActions: T, feedback: E, renderTable: D, renderChart: O, renderMcpApp: k, labels: A, formatMessageTime: j }) {
2863
+ let { messages: M, traceEvents: N, lastRequest: P, status: F, error: I, send: te, stop: ne, retryLast: re, clearTrace: L, clearError: ie, newChat: ae } = e, [R, z] = f(""), [B, oe] = f(/* @__PURE__ */ new Map()), se = a((e) => {
2864
+ let t = (t) => oe((n) => {
2865
+ let r = new Map(n), i = (r.get(e) ?? 0) + t;
2866
+ return i > 0 ? r.set(e, i) : r.delete(e), r;
2867
+ });
2868
+ return t(1), () => t(-1);
2869
+ }, []), ce = u(() => ({
2870
+ builtIn: !1,
2871
+ claim: se
2872
+ }), [se]), le = u(() => ({
2873
+ builtIn: !0,
2874
+ claim: se
2875
+ }), [se]), V = {
2876
+ ...zn,
2877
+ ...A
2878
+ }, ue = j ?? Gn, de = d(null), H = d(null), U = d(null), fe = d(null), [W, pe] = f(!1), G = d(null), me = d(!1), he = !!c || !!l, K = Tt(de), q = d(null), J = d(null), ge = d(!0), _e = u(() => Ot({
2879
+ renderTable: D,
2880
+ renderChart: O
2881
+ }), [D, O]), ve = u(() => Un(F, N, P), [
2882
+ F,
2883
+ N,
2884
+ P
2885
+ ]), ye = Wn(ve), Y = ve?.kind === "tool_end" ? ve.at : void 0, be = M[M.length - 1]?.content.length ?? 0, [xe, Se] = f(null), Ce = xe;
2886
+ Y !== void 0 && xe?.at !== Y && (Ce = {
2887
+ at: Y,
2888
+ length: be
2889
+ }, Se(Ce));
2890
+ let we = Y !== void 0 && Ce?.at === Y && be <= Ce.length, X = ye ?? (we ? V.thinkingHint : void 0), Z = M.length === 0, Te = t ?? (Z ? i ?? Ln : r);
2891
+ s(() => {
2892
+ let e = J.current;
2893
+ if (!e) return;
2894
+ let t = () => {
2895
+ let t = e.scrollHeight - e.scrollTop - e.clientHeight;
2896
+ ge.current = t < 60;
2897
+ };
2898
+ return e.addEventListener("scroll", t, { passive: !0 }), () => e.removeEventListener("scroll", t);
2899
+ }, []), s(() => {
2900
+ ge.current && q.current?.scrollIntoView({
2901
+ behavior: F === "streaming" ? "auto" : "smooth",
2902
+ block: "nearest"
2903
+ });
2904
+ }, [M, F]);
2905
+ let Ee = (e) => {
2906
+ ge.current = !0, te(e);
2907
+ }, De = d(null), Oe = () => {
2908
+ let t = J.current;
2909
+ ge.current = !1, De.current = t ? {
2910
+ height: t.scrollHeight,
2911
+ top: t.scrollTop
2912
+ } : null, e.loadEarlier?.().catch(() => {
2913
+ De.current = null;
2914
+ });
2915
+ };
2916
+ s(() => {
2917
+ let e = De.current, t = J.current;
2918
+ e && t && t.scrollHeight !== e.height && (t.scrollTop = e.top + (t.scrollHeight - e.height), De.current = null);
2919
+ }, [M]), s(() => {
2920
+ H.current?.toggleAttribute("inert", W);
2921
+ }, [W]), s(() => {
2922
+ !W && G.current && ((G.current === "input" ? U.current : fe.current)?.focus(), G.current = null);
2923
+ }, [W]);
2924
+ let ke = a((e) => {
2925
+ G.current = e.restoreFocusTo, pe(!1);
2926
+ }, []);
2927
+ return /* @__PURE__ */ v(pt.Provider, {
2928
+ value: K,
2929
+ children: /* @__PURE__ */ v(Dt.Provider, {
2930
+ value: ce,
2931
+ children: /* @__PURE__ */ y("div", {
2932
+ ref: de,
2933
+ className: `bailey-chat-panel${x ? ` ${x}` : ""}`,
2934
+ style: S !== void 0 || C !== void 0 ? {
2935
+ height: S,
2936
+ width: C
2937
+ } : void 0,
2938
+ children: [/* @__PURE__ */ y("div", {
2939
+ className: "bailey-chat-panel-inner",
2940
+ ref: H,
2941
+ children: [
2942
+ /* @__PURE__ */ y("div", {
2943
+ className: "bailey-chat-transcript",
2944
+ ref: J,
2945
+ children: [
2946
+ e.hasEarlier && e.loadEarlier && /* @__PURE__ */ y("div", {
2947
+ className: "bailey-load-earlier",
2948
+ children: [/* @__PURE__ */ v("button", {
2949
+ type: "button",
2950
+ className: "bailey-load-earlier-button",
2951
+ disabled: e.historyStatus === "loading",
2952
+ onClick: Oe,
2953
+ children: V.loadEarlierButtonText
2954
+ }), e.historyStatus === "error" && /* @__PURE__ */ v("div", {
2955
+ role: "alert",
2956
+ className: "bailey-load-earlier-error",
2957
+ children: V.loadEarlierErrorText
2958
+ })]
2959
+ }),
2960
+ Z && (o && o.length > 0 ? /* @__PURE__ */ y("div", {
2961
+ className: "bailey-suggestions",
2962
+ children: [/* @__PURE__ */ v("div", {
2963
+ className: "bailey-suggestions-title",
2964
+ children: V.suggestionsTitle
2965
+ }), o.map((e, t) => /* @__PURE__ */ y("button", {
2966
+ type: "button",
2967
+ onClick: () => Ee(e.value ?? e.label),
2968
+ className: "bailey-suggestion-card",
2969
+ children: [/* @__PURE__ */ v("span", { children: e.label }), e.icon ?? /* @__PURE__ */ v(jt, { className: "bailey-suggestion-icon" })]
2970
+ }, `${e.label}-${t}`))]
2971
+ }) : /* @__PURE__ */ v("div", {
2972
+ className: "bailey-empty-state",
2973
+ children: V.emptyStateMessage
2974
+ })),
2975
+ M.map((t, r) => {
2976
+ let i = t.role === "assistant" && r === M.length - 1, a = F === "streaming" && i && t.content === "", o = t.role === "assistant" ? dt(N, t.createdAt) : [], s = o.some((e) => e.status === "running");
2977
+ return /* @__PURE__ */ v("div", {
2978
+ className: t.role === "user" ? "bailey-message-row bailey-message-row-user" : "bailey-message-row",
2979
+ children: t.role === "user" ? /* @__PURE__ */ y("div", {
2980
+ className: "bailey-user-message",
2981
+ children: [/* @__PURE__ */ y("div", {
2982
+ className: "bailey-message-meta",
2983
+ children: [/* @__PURE__ */ v("span", {
2984
+ className: "bailey-message-meta-name",
2985
+ children: V.youLabel
2986
+ }), t.createdAt !== void 0 && /* @__PURE__ */ v("span", { children: ue(t.createdAt) })]
2987
+ }), /* @__PURE__ */ v("div", {
2988
+ className: "bailey-user-bubble",
2989
+ children: t.content
2990
+ })]
2991
+ }) : a ? s ? /* @__PURE__ */ v(pn, {
2992
+ steps: o,
2993
+ resolveActivityIcon: b
2994
+ }) : /* @__PURE__ */ y("div", {
2995
+ className: "bailey-thinking-hint",
2996
+ children: [/* @__PURE__ */ v("span", { children: ye ?? V.thinkingHint }), /* @__PURE__ */ v("span", {
2997
+ className: "bailey-step-spinner",
2998
+ "aria-hidden": "true"
2999
+ })]
3000
+ }) : /* @__PURE__ */ y("div", {
3001
+ className: "bailey-assistant-message",
3002
+ children: [
3003
+ !t.streaming && /* @__PURE__ */ v(mn, {
3004
+ steps: o,
3005
+ labels: V,
3006
+ resolveActivityIcon: b
3007
+ }),
3008
+ /* @__PURE__ */ v(Hn, {
3009
+ content: t.content,
3010
+ components: _e
3011
+ }),
3012
+ t.parts?.map((e, t) => e.type === "image" ? /* @__PURE__ */ v(nn, {
3013
+ src: e.src,
3014
+ alt: e.alt
3015
+ }, t) : e.type === "mcp_app" ? /* @__PURE__ */ v(n, { children: k ? k(e) : /* @__PURE__ */ v(un, {
3016
+ ...e,
3017
+ title: e.title ?? V.mcpAppDefaultTitle
3018
+ }) }, t) : null),
3019
+ t.streaming && /* @__PURE__ */ v(pn, {
3020
+ steps: o,
3021
+ resolveActivityIcon: b
3022
+ }),
3023
+ t.streaming && X && !s && /* @__PURE__ */ y("div", {
3024
+ className: "bailey-streaming-hint",
3025
+ children: [/* @__PURE__ */ v("span", { children: X }), /* @__PURE__ */ v("span", {
3026
+ className: "bailey-step-spinner",
3027
+ "aria-hidden": "true"
3028
+ })]
3029
+ }),
3030
+ !t.streaming && /* @__PURE__ */ y("div", {
3031
+ className: "bailey-message-actions",
3032
+ children: [
3033
+ /* @__PURE__ */ v(Kt, {
3034
+ markdown: t.content,
3035
+ ariaLabel: V.copyButtonAriaLabel,
3036
+ tooltipDefaultText: V.copyButtonTooltipDefault,
3037
+ tooltipCopiedText: V.copyButtonTooltipCopied
3038
+ }),
3039
+ E !== !1 && e.feedback && e.conversationId && t.serverMessageId && !B.has(t.serverMessageId) && /* @__PURE__ */ v(Dt.Provider, {
3040
+ value: le,
3041
+ children: /* @__PURE__ */ v(Fn, {
3042
+ ...E,
3043
+ messageId: t.serverMessageId,
3044
+ initialRating: t.feedback?.rating,
3045
+ onSubmit: e.feedback.onSubmit,
3046
+ onClear: e.feedback.onClear
3047
+ })
3048
+ }),
3049
+ T?.(t)
3050
+ ]
3051
+ })
3052
+ ]
3053
+ })
3054
+ }, t.id);
3055
+ }),
3056
+ /* @__PURE__ */ v("div", { ref: q })
3057
+ ]
3058
+ }),
3059
+ I && /* @__PURE__ */ y("div", {
3060
+ className: "bailey-error-banner",
3061
+ role: "alert",
3062
+ children: [/* @__PURE__ */ v("span", { children: I }), /* @__PURE__ */ y("div", {
3063
+ className: "bailey-error-actions",
3064
+ children: [/* @__PURE__ */ v("button", {
3065
+ type: "button",
3066
+ onClick: re,
3067
+ className: "bailey-retry-button",
3068
+ children: V.retryButtonText
3069
+ }), /* @__PURE__ */ v("button", {
3070
+ type: "button",
3071
+ onClick: ie,
3072
+ "aria-label": V.dismissErrorAriaLabel,
3073
+ className: "bailey-dismiss-button",
3074
+ children: "✕"
3075
+ })]
3076
+ })]
3077
+ }),
3078
+ !w && /* @__PURE__ */ v(tn, {
3079
+ events: N,
3080
+ lastRequest: P,
3081
+ onClear: L
3082
+ }),
3083
+ /* @__PURE__ */ y("div", {
3084
+ className: "bailey-input-area",
3085
+ children: [/* @__PURE__ */ y("form", {
3086
+ onSubmit: (e) => {
3087
+ e.preventDefault(), R.trim() && F !== "streaming" && (Ee(R), z(""));
3088
+ },
3089
+ className: "bailey-input-row",
3090
+ children: [/* @__PURE__ */ v("input", {
3091
+ ref: U,
3092
+ type: "text",
3093
+ placeholder: Te,
3094
+ "aria-label": Te,
3095
+ value: R,
3096
+ onChange: (e) => z(e.target.value),
3097
+ disabled: F === "streaming",
3098
+ className: "bailey-input"
3099
+ }), F === "streaming" ? /* @__PURE__ */ v(g.Provider, {
3100
+ delayDuration: 200,
3101
+ children: /* @__PURE__ */ y(g.Root, { children: [/* @__PURE__ */ v(g.Trigger, {
3102
+ asChild: !0,
3103
+ children: /* @__PURE__ */ v("button", {
3104
+ type: "button",
3105
+ onClick: ne,
3106
+ "aria-label": V.stopAriaLabel,
3107
+ className: "bailey-stop-button",
3108
+ children: /* @__PURE__ */ v(At, { className: "bailey-stop-icon" })
3109
+ })
3110
+ }), /* @__PURE__ */ v(g.Portal, {
3111
+ container: K instanceof ShadowRoot ? K : void 0,
3112
+ children: /* @__PURE__ */ y(g.Content, {
3113
+ side: "top",
3114
+ className: "bailey-tooltip-content",
3115
+ children: [V.stopButtonText, /* @__PURE__ */ v(g.Arrow, { className: "bailey-tooltip-arrow" })]
3116
+ })
3117
+ })] })
3118
+ }) : /* @__PURE__ */ v("button", {
3119
+ type: "submit",
3120
+ "aria-label": V.sendAriaLabel,
3121
+ disabled: !R.trim(),
3122
+ className: "bailey-send-button",
3123
+ children: ee ?? /* @__PURE__ */ v(kt, { className: "bailey-send-icon" })
3124
+ })]
3125
+ }), (!Z || he) && /* @__PURE__ */ y(h.Root, { children: [/* @__PURE__ */ v(h.Trigger, {
3126
+ asChild: !0,
3127
+ children: /* @__PURE__ */ v("button", {
3128
+ type: "button",
3129
+ ref: fe,
3130
+ "aria-label": V.menuAriaLabel,
3131
+ className: "bailey-menu-button",
3132
+ children: /* @__PURE__ */ v(It, { className: "bailey-menu-icon" })
3133
+ })
3134
+ }), /* @__PURE__ */ v(h.Portal, {
3135
+ container: K instanceof ShadowRoot ? K : void 0,
3136
+ children: /* @__PURE__ */ y(h.Content, {
3137
+ side: "top",
3138
+ align: "end",
3139
+ sideOffset: 8,
3140
+ className: "bailey-menu-content",
3141
+ onCloseAutoFocus: (e) => {
3142
+ me.current &&= (e.preventDefault(), !1);
3143
+ },
3144
+ children: [!Z && /* @__PURE__ */ y(h.Item, {
3145
+ onSelect: () => ae(),
3146
+ className: "bailey-menu-item",
3147
+ children: [/* @__PURE__ */ v(Lt, { className: "bailey-menu-item-icon" }), V.newChatButtonText]
3148
+ }), he && /* @__PURE__ */ y(h.Item, {
3149
+ onSelect: () => {
3150
+ c ? c() : (me.current = !0, pe(!0));
3151
+ },
3152
+ className: "bailey-menu-item",
3153
+ children: [/* @__PURE__ */ v(Pt, { className: "bailey-menu-item-icon" }), V.historyMenuItemText]
3154
+ })]
3155
+ })
3156
+ })] })]
3157
+ }),
3158
+ (Z || _?.alwaysVisible) && _ && /* @__PURE__ */ v("div", {
3159
+ className: "bailey-privacy-note",
3160
+ children: /* @__PURE__ */ v(p, {
3161
+ remarkPlugins: Bn,
3162
+ components: Vn,
3163
+ skipHtml: !0,
3164
+ children: _.markdown
3165
+ })
3166
+ })
3167
+ ]
3168
+ }), W && l && !c && /* @__PURE__ */ v(Sn, {
3169
+ client: l.client,
3170
+ pageSize: l.pageSize,
3171
+ chat: e,
3172
+ labels: V,
3173
+ locale: m,
3174
+ onClose: ke
3175
+ })]
3176
+ })
3177
+ })
3178
+ });
3179
+ }
3180
+ // src/index.ts
3181
+ var qn = "0.3.1-pre.2";
3182
+ export { Ft as ActivityIcon, jt as ArrowUpRightIcon, qn as BAILEYAI_CHAT_UI_VERSION, Ve as BAILEY_CHART_PROMPT_FRAGMENT, Ne as BAILEY_TABLE_GRID_ROW_THRESHOLD, j as BaileyApiError, Kn as BaileyChatPanel, N as BaileyCleanupError, Fn as BaileyFeedbackButtons, Sn as BaileyHistoryDrawer, tn as BaileyTracePanel, Kt as CopyMarkdownButton, ae as DEFAULT_CONVERSATION_STORAGE_KEY, kt as HeartIcon, Ye as TRACE_KIND_LABEL, Vt as ThumbDownIcon, Bt as ThumbUpIcon, Q as createBaileyClient, ie as createBaileyFeedbackHandlers, Ot as createBaileyMarkdownComponents, z as createMemoryConversationStorage, R as createSessionConversationStorage, O as extractPseudoToolCalls, ze as extractTableData, xn as formatRelativeTime, at as formatTraceGap, it as formatTraceTime, lt as hasTraceFailure, L as isConversationIdForSub, e as isSafeMarkdownUrl, Ae as joinInstructions, te as mapTranscript, re 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, W as useBaileyChat, G as useBaileyConversations };