@green-on-grey/ui-kit 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/chat.js CHANGED
@@ -1,14 +1,14 @@
1
- import { c as e, d as t, i as n, l as r, s as i } from "./ui-joAvYmUH.js";
1
+ import { c as e, d as t, i as n, l as r, s as i } from "./ui-ChXUXoIB.js";
2
2
  import { n as a, t as o } from "./i18n-BJ8rsBp6.js";
3
3
  import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
4
- import { useCallback as u, useEffect as d, useLayoutEffect as f, useRef as p, useState as m } from "react";
5
- import { useTranslation as h } from "react-i18next";
4
+ import { useCallback as u, useEffect as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
5
+ import { useTranslation as g } from "react-i18next";
6
6
  //#region src/chat/CommandPalette.tsx
7
- function g(e, t) {
7
+ function _(e, t) {
8
8
  let n = t.toLowerCase();
9
9
  return e.filter((e) => e.name.toLowerCase().includes(n) || (e.description ?? "").toLowerCase().includes(n));
10
10
  }
11
- function _({ items: e, active: n, onPick: r, onHover: i }) {
11
+ function v({ items: e, active: n, onPick: r, onHover: i }) {
12
12
  let o = a(), s = e.filter((e) => e.kind === "command"), u = e.filter((e) => e.kind === "skill"), d = (e, a) => /* @__PURE__ */ l("button", {
13
13
  type: "button",
14
14
  role: "option",
@@ -24,7 +24,7 @@ function _({ items: e, active: n, onPick: r, onHover: i }) {
24
24
  size: 14
25
25
  }) : /* @__PURE__ */ c("span", {
26
26
  className: "slash",
27
- children: "/"
27
+ "aria-hidden": "true"
28
28
  }),
29
29
  /* @__PURE__ */ c("span", {
30
30
  className: "nm",
@@ -67,31 +67,34 @@ function _({ items: e, active: n, onPick: r, onHover: i }) {
67
67
  });
68
68
  }
69
69
  //#endregion
70
+ //#region src/chat/intl.ts
71
+ var y = (e) => e === "zh" ? "zh-CN" : e;
72
+ //#endregion
70
73
  //#region src/chat/ContextMeter.tsx
71
- function v(e, t) {
72
- return new Intl.NumberFormat(t === "zh" ? "zh-CN" : t, {
74
+ function b(e, t) {
75
+ return new Intl.NumberFormat(y(t), {
73
76
  notation: "compact",
74
77
  maximumFractionDigits: 1
75
78
  }).format(e);
76
79
  }
77
- function y({ context: e, onCompact: n, onReset: r }) {
78
- let s = a(), { i18n: u } = h(o), [d, f] = m(!1), p = i(d, () => f(!1)), g = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, _ = Math.round(g * 100), y = g >= .9 ? "full" : g >= .7 ? "warn" : "", b = 2 * Math.PI * 7, x = u.language;
80
+ function x({ context: e, onCompact: n, onReset: r }) {
81
+ let s = a(), { i18n: u } = g(o), [d, f] = h(!1), p = i(d, () => f(!1)), m = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, _ = Math.round(m * 100), v = m >= .9 ? "full" : m >= .7 ? "warn" : "", y = 2 * Math.PI * 7, x = u.language;
79
82
  return /* @__PURE__ */ l("div", {
80
83
  className: "ctxmeter",
81
84
  ref: p,
82
85
  children: [/* @__PURE__ */ c("button", {
83
86
  type: "button",
84
- className: `ctxring ${y}`,
87
+ className: `ctxring ${v}`,
85
88
  "aria-expanded": d,
86
89
  onClick: () => f((e) => !e),
87
90
  "aria-label": s("chat.context.meter", {
88
- used: v(e.tokens, x),
89
- total: v(e.window, x),
91
+ used: b(e.tokens, x),
92
+ total: b(e.window, x),
90
93
  pct: _
91
94
  }),
92
95
  title: s("chat.context.meter", {
93
- used: v(e.tokens, x),
94
- total: v(e.window, x),
96
+ used: b(e.tokens, x),
97
+ total: b(e.window, x),
95
98
  pct: _
96
99
  }),
97
100
  children: /* @__PURE__ */ l("svg", {
@@ -107,7 +110,7 @@ function y({ context: e, onCompact: n, onReset: r }) {
107
110
  cx: "9",
108
111
  cy: "9",
109
112
  r: 7,
110
- strokeDasharray: `${(b * g).toFixed(1)} ${b.toFixed(1)}`,
113
+ strokeDasharray: `${(y * m).toFixed(1)} ${y.toFixed(1)}`,
111
114
  transform: "rotate(-90 9 9)"
112
115
  })]
113
116
  })
@@ -116,16 +119,16 @@ function y({ context: e, onCompact: n, onReset: r }) {
116
119
  role: "dialog",
117
120
  children: [
118
121
  /* @__PURE__ */ c("div", { children: s("chat.context.meter", {
119
- used: v(e.tokens, x),
120
- total: v(e.window, x),
122
+ used: b(e.tokens, x),
123
+ total: b(e.window, x),
121
124
  pct: _
122
125
  }) }),
123
- y === "full" && /* @__PURE__ */ c("div", {
126
+ v === "full" && /* @__PURE__ */ c("div", {
124
127
  className: "small muted",
125
128
  style: { marginTop: 4 },
126
129
  children: s("chat.context.full")
127
130
  }),
128
- y === "full" && (n || r) && /* @__PURE__ */ l("div", {
131
+ v === "full" && (n || r) && /* @__PURE__ */ l("div", {
129
132
  className: "row",
130
133
  style: {
131
134
  marginTop: 8,
@@ -158,18 +161,280 @@ function y({ context: e, onCompact: n, onReset: r }) {
158
161
  });
159
162
  }
160
163
  //#endregion
164
+ //#region src/chat/Attachments.tsx
165
+ var S = /* @__PURE__ */ new Set([
166
+ "image/png",
167
+ "image/jpeg",
168
+ "image/gif",
169
+ "image/webp",
170
+ "image/svg+xml"
171
+ ]), C = /\.(png|jpe?g|gif|webp|svg)$/, w = /\.(txt|log|json|ya?ml|xml|ini|toml|sql|sh|py|go|js|ts|tsx|java|kt|rb|rs|c|cpp|h|css|html?)$/;
172
+ function T(e) {
173
+ let t = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), n = e.fileName.toLowerCase();
174
+ return S.has(t) || (!t || t === "application/octet-stream") && C.test(n) ? "image" : t === "application/pdf" || n.endsWith(".pdf") ? "pdf" : t === "text/markdown" || /\.(md|markdown)$/.test(n) ? "markdown" : t === "text/csv" || t === "text/tab-separated-values" || /\.(csv|tsv)$/.test(n) ? "table" : t.startsWith("text/") || t === "application/json" || t === "application/xml" || w.test(n) ? "text" : null;
175
+ }
176
+ var E = {
177
+ image: "image",
178
+ pdf: "pdf",
179
+ markdown: "markdown",
180
+ table: "table",
181
+ text: "source"
182
+ };
183
+ function D(e, t) {
184
+ return t === "pdf" ? "PDF" : t === "markdown" ? "MD" : /\.([a-z0-9]{1,5})$/i.exec(e.fileName)?.[1]?.toUpperCase() ?? (t ? "TXT" : "FILE");
185
+ }
186
+ function O(e, t) {
187
+ let n = [
188
+ "byte",
189
+ "kilobyte",
190
+ "megabyte",
191
+ "gigabyte"
192
+ ], r = e, i = 0;
193
+ for (; r >= 1024 && i < n.length - 1;) r /= 1024, i++;
194
+ return new Intl.NumberFormat(y(t), {
195
+ style: "unit",
196
+ unit: n[i],
197
+ unitDisplay: "short",
198
+ maximumFractionDigits: i === 0 ? 0 : 1
199
+ }).format(r);
200
+ }
201
+ function k(e, t) {
202
+ if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
203
+ let n = [], r = [], i = "", a = !1;
204
+ for (let t = 0; t < e.length; t++) {
205
+ let o = e[t];
206
+ a ? o === "\"" && e[t + 1] === "\"" ? (i += "\"", t++) : o === "\"" ? a = !1 : i += o : o === "\"" ? a = !0 : o === "," ? (r.push(i), i = "") : o === "\n" || o === "\r" ? (o === "\r" && e[t + 1] === "\n" && t++, r.push(i), n.push(r), r = [], i = "") : i += o;
207
+ }
208
+ return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
209
+ }
210
+ function A(e, t, n = !0) {
211
+ let [r, i] = h({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
212
+ return d(() => {
213
+ if (!n) return;
214
+ let e, r = !0;
215
+ return t({
216
+ id: a,
217
+ href: o,
218
+ fileName: s,
219
+ mimeType: c,
220
+ size: l
221
+ }).then((t) => {
222
+ if (!r) return;
223
+ let n = c && t.type !== c ? new Blob([t], { type: c }) : t;
224
+ e = URL.createObjectURL(n), i({
225
+ url: e,
226
+ blob: n
227
+ });
228
+ }, () => r && i({ failed: !0 })), () => {
229
+ r = !1, e && URL.revokeObjectURL(e);
230
+ };
231
+ }, [
232
+ n,
233
+ t,
234
+ a,
235
+ o,
236
+ s,
237
+ c,
238
+ l
239
+ ]), r;
240
+ }
241
+ function j({ a: e, load: t, onOpen: n }) {
242
+ let r = a(), { url: i, failed: o } = A(e, t);
243
+ return o ? /* @__PURE__ */ c(M, {
244
+ a: e,
245
+ kind: "image",
246
+ onOpen: n
247
+ }) : /* @__PURE__ */ l("button", {
248
+ type: "button",
249
+ className: "att-thumb",
250
+ onClick: n,
251
+ "aria-label": r("chat.files.open", { name: e.fileName }),
252
+ title: e.fileName,
253
+ children: [i ? /* @__PURE__ */ c("img", {
254
+ src: i,
255
+ alt: ""
256
+ }) : /* @__PURE__ */ c("span", {
257
+ className: "spin",
258
+ "aria-hidden": "true"
259
+ }), /* @__PURE__ */ c("span", {
260
+ className: "att-cap",
261
+ children: e.fileName
262
+ })]
263
+ });
264
+ }
265
+ function M({ a: e, kind: n, onOpen: r }) {
266
+ let i = a(), { i18n: u } = g(o), d = n !== null && r !== void 0, f = /* @__PURE__ */ l(s, { children: [
267
+ /* @__PURE__ */ l("span", {
268
+ className: "att-ic",
269
+ children: [/* @__PURE__ */ c(t, {
270
+ name: d && n ? E[n] : "download",
271
+ size: 24
272
+ }), /* @__PURE__ */ c("span", {
273
+ className: "att-kl",
274
+ children: D(e, n)
275
+ })]
276
+ }),
277
+ /* @__PURE__ */ c("span", {
278
+ className: "att-name",
279
+ children: e.fileName
280
+ }),
281
+ e.size != null && /* @__PURE__ */ c("span", {
282
+ className: "att-size",
283
+ children: O(e.size, u.language)
284
+ })
285
+ ] });
286
+ return d ? /* @__PURE__ */ c("button", {
287
+ type: "button",
288
+ className: `att-tile ${n}`,
289
+ onClick: r,
290
+ "aria-label": i("chat.files.open", { name: e.fileName }),
291
+ title: e.fileName,
292
+ children: f
293
+ }) : /* @__PURE__ */ c("a", {
294
+ className: "att-tile dl",
295
+ href: e.href,
296
+ download: e.fileName,
297
+ "aria-label": i("chat.files.save", { name: e.fileName }),
298
+ title: e.fileName,
299
+ children: f
300
+ });
301
+ }
302
+ function N({ items: e, load: t, onOpen: n }) {
303
+ return /* @__PURE__ */ c("div", {
304
+ className: "atts",
305
+ children: e.map((e) => {
306
+ let r = t && n ? () => n(e) : void 0, i = T(e);
307
+ return t && r && i === "image" ? /* @__PURE__ */ c(j, {
308
+ a: e,
309
+ load: t,
310
+ onOpen: r
311
+ }, e.id) : /* @__PURE__ */ c(M, {
312
+ a: e,
313
+ kind: i,
314
+ onOpen: r
315
+ }, e.id);
316
+ })
317
+ });
318
+ }
319
+ function P({ text: e, tab: t }) {
320
+ let n = a(), [r, ...i] = k(e, t), o = i.slice(0, 500);
321
+ return /* @__PURE__ */ l("div", {
322
+ className: "att-table",
323
+ children: [/* @__PURE__ */ l("table", { children: [r && /* @__PURE__ */ c("thead", { children: /* @__PURE__ */ c("tr", { children: r.map((e, t) => /* @__PURE__ */ c("th", { children: e }, t)) }) }), /* @__PURE__ */ c("tbody", { children: o.map((e, t) => /* @__PURE__ */ c("tr", { children: e.map((e, t) => /* @__PURE__ */ c("td", { children: e }, t)) }, t)) })] }), i.length > o.length && /* @__PURE__ */ c("div", {
324
+ className: "att-more",
325
+ children: n("chat.files.rows", {
326
+ shown: o.length,
327
+ total: i.length
328
+ })
329
+ })]
330
+ });
331
+ }
332
+ function ee({ a: e, load: i, onClose: u }) {
333
+ let f = a(), { i18n: p } = g(o), m = T(e), _ = m === "markdown" || m === "table" || m === "text", v = _ && (e.size ?? 0) > 1048576, { url: y, blob: b, failed: x } = A(e, i, !v), [S, C] = h(null), w = v || _ && (b?.size ?? 0) > 1048576;
334
+ d(() => {
335
+ _ && b && !w && b.arrayBuffer().then((e) => {
336
+ try {
337
+ C({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
338
+ } catch {
339
+ C({ text: null });
340
+ }
341
+ }, () => C({ text: null }));
342
+ }, [
343
+ _,
344
+ b,
345
+ w
346
+ ]);
347
+ let E = S?.text, D;
348
+ return D = x ? /* @__PURE__ */ c("div", {
349
+ className: "att-msg err-text",
350
+ children: f("chat.files.failed")
351
+ }) : w ? /* @__PURE__ */ c("div", {
352
+ className: "att-msg",
353
+ children: f("chat.files.tooLarge")
354
+ }) : S && E === null ? /* @__PURE__ */ c("div", {
355
+ className: "att-msg",
356
+ children: f("chat.files.notUtf8")
357
+ }) : !y || _ && E == null ? /* @__PURE__ */ l("div", {
358
+ className: "att-msg",
359
+ children: [
360
+ /* @__PURE__ */ c("span", {
361
+ className: "spin",
362
+ "aria-hidden": "true"
363
+ }),
364
+ " ",
365
+ f("loading")
366
+ ]
367
+ }) : m === "image" ? /* @__PURE__ */ c("img", {
368
+ className: "att-img",
369
+ src: y,
370
+ alt: e.fileName
371
+ }) : m === "pdf" ? /* @__PURE__ */ c("object", {
372
+ className: "att-pdf",
373
+ data: y,
374
+ type: "application/pdf",
375
+ "aria-label": e.fileName,
376
+ children: /* @__PURE__ */ c("div", {
377
+ className: "att-msg",
378
+ children: f("chat.files.failed")
379
+ })
380
+ }) : m === "markdown" ? /* @__PURE__ */ c("div", {
381
+ className: "att-md",
382
+ children: /* @__PURE__ */ c(r, { text: E ?? "" })
383
+ }) : m === "table" ? /* @__PURE__ */ c(P, {
384
+ text: E ?? "",
385
+ tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
386
+ }) : /* @__PURE__ */ c("pre", {
387
+ className: "att-text",
388
+ children: E
389
+ }), /* @__PURE__ */ c(n, {
390
+ wide: !0,
391
+ onClose: u,
392
+ title: /* @__PURE__ */ l("span", {
393
+ className: "att-title",
394
+ children: [/* @__PURE__ */ c("span", {
395
+ className: "att-name",
396
+ children: e.fileName
397
+ }), e.size != null && /* @__PURE__ */ c("span", {
398
+ className: "muted small",
399
+ children: O(e.size, p.language)
400
+ })]
401
+ }),
402
+ footer: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("a", {
403
+ className: "btn ghost",
404
+ href: y ?? e.href,
405
+ download: e.fileName,
406
+ children: [
407
+ /* @__PURE__ */ c(t, {
408
+ name: "download",
409
+ size: 14
410
+ }),
411
+ " ",
412
+ f("chat.files.download")
413
+ ]
414
+ }), /* @__PURE__ */ c("button", {
415
+ type: "button",
416
+ className: "btn primary",
417
+ onClick: u,
418
+ children: f("close")
419
+ })] }),
420
+ children: /* @__PURE__ */ c("div", {
421
+ className: `att-view ${m ?? ""}`,
422
+ children: D
423
+ })
424
+ });
425
+ }
426
+ //#endregion
161
427
  //#region src/chat/MessageView.tsx
162
- var b = (e) => e === "zh" ? "zh-CN" : e;
163
- function x(e, t) {
164
- return new Intl.DateTimeFormat(b(t), {
428
+ function F(e, t) {
429
+ return new Intl.DateTimeFormat(y(t), {
165
430
  hour: "2-digit",
166
431
  minute: "2-digit"
167
432
  }).format(new Date(e));
168
433
  }
169
- function S(e, t) {
434
+ function I(e, t) {
170
435
  return t || e.length <= 3 ? e : e.slice(-2);
171
436
  }
172
- var C = {
437
+ var L = {
173
438
  done: {
174
439
  icon: "check",
175
440
  cls: "ok"
@@ -183,14 +448,14 @@ var C = {
183
448
  cls: "run"
184
449
  }
185
450
  };
186
- function w({ m: e, busy: n, onRetry: i }) {
187
- let { t: a, i18n: u } = h(o), [d, f] = m(!1);
451
+ function R({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u }) {
452
+ let { t: d, i18n: f } = g(o), [p, m] = h(!1);
188
453
  if (e.role === "note") return /* @__PURE__ */ c("div", {
189
454
  className: "sysnote",
190
455
  children: e.text
191
456
  });
192
- if (e.role === "event" && e.event) return /* @__PURE__ */ c(T, { m: e });
193
- let p = e.mark && /* @__PURE__ */ l("div", {
457
+ if (e.role === "event" && e.event) return /* @__PURE__ */ c(z, { m: e });
458
+ let _ = e.mark && /* @__PURE__ */ l("div", {
194
459
  className: "chan",
195
460
  children: [
196
461
  /* @__PURE__ */ c(t, {
@@ -200,73 +465,64 @@ function w({ m: e, busy: n, onRetry: i }) {
200
465
  " ",
201
466
  e.mark.text,
202
467
  " · ",
203
- x(e.createdAt, u.language)
468
+ F(e.createdAt, f.language)
204
469
  ]
205
- }), g = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c("div", {
206
- className: "atts",
207
- children: e.attachments.map((e) => /* @__PURE__ */ l("a", {
208
- href: e.href,
209
- children: [
210
- /* @__PURE__ */ c(t, {
211
- name: "clip",
212
- size: 12
213
- }),
214
- " ",
215
- e.fileName
216
- ]
217
- }, e.id))
470
+ }), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(N, {
471
+ items: e.attachments,
472
+ load: a,
473
+ onOpen: u
218
474
  });
219
475
  if (e.role === "user") return /* @__PURE__ */ l("div", {
220
476
  className: "m u",
221
477
  children: [
222
- p,
478
+ _,
223
479
  e.content,
224
480
  e.text && /* @__PURE__ */ c("div", {
225
481
  className: "bub",
226
482
  children: e.text
227
483
  }),
228
- g,
484
+ v,
229
485
  e.wait && /* @__PURE__ */ c("div", {
230
486
  className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
231
487
  role: "status",
232
488
  children: e.wait.state === "queued" ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
233
489
  name: "clock",
234
490
  size: 12
235
- }), a("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
491
+ }), d("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
236
492
  className: "spin",
237
493
  "aria-hidden": "true"
238
- }), a("chat.wait.starting")] })
494
+ }), d("chat.wait.starting")] })
239
495
  })
240
496
  ]
241
497
  });
242
- let _ = e.steps ?? [], v = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
498
+ let y = e.steps ?? [], b = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
243
499
  return /* @__PURE__ */ l("div", {
244
500
  className: "m a",
245
501
  children: [
246
- p,
247
- _.length > 3 && /* @__PURE__ */ c("button", {
502
+ _,
503
+ y.length > 3 && /* @__PURE__ */ c("button", {
248
504
  className: "tools-fold",
249
- onClick: () => f((e) => !e),
250
- "aria-expanded": d,
251
- children: d ? a("chat.hideSteps") : a("chat.moreSteps", { count: _.length - 2 })
505
+ onClick: () => m((e) => !e),
506
+ "aria-expanded": p,
507
+ children: p ? d("chat.hideSteps") : d("chat.moreSteps", { count: y.length - 2 })
252
508
  }),
253
- S(_, d).map((e) => /* @__PURE__ */ l("div", {
509
+ I(y, p).map((e) => /* @__PURE__ */ l("div", {
254
510
  className: "tool",
255
511
  title: e.title,
256
512
  children: [/* @__PURE__ */ c(t, {
257
- name: C[e.status].icon,
513
+ name: L[e.status].icon,
258
514
  size: 14,
259
- className: C[e.status].cls
515
+ className: L[e.status].cls
260
516
  }), /* @__PURE__ */ c("span", {
261
517
  className: "tx",
262
518
  children: e.text
263
519
  })]
264
520
  }, e.id)),
265
- v && /* @__PURE__ */ c("div", {
521
+ b && /* @__PURE__ */ c("div", {
266
522
  className: "bub",
267
523
  children: /* @__PURE__ */ l("span", {
268
524
  className: "typing",
269
- "aria-label": a("chat.typing"),
525
+ "aria-label": d("chat.typing"),
270
526
  children: [
271
527
  /* @__PURE__ */ c("i", {}),
272
528
  /* @__PURE__ */ c("i", {}),
@@ -279,7 +535,7 @@ function w({ m: e, busy: n, onRetry: i }) {
279
535
  title: e.hint,
280
536
  children: /* @__PURE__ */ c(r, { text: e.text })
281
537
  })),
282
- g,
538
+ v,
283
539
  e.error && /* @__PURE__ */ l("div", {
284
540
  className: `llmerr${e.error.transient ? " amber" : ""}`,
285
541
  role: "alert",
@@ -293,15 +549,15 @@ function w({ m: e, busy: n, onRetry: i }) {
293
549
  children: [/* @__PURE__ */ c(t, {
294
550
  name: "refresh",
295
551
  size: 14
296
- }), a("chat.retry")]
552
+ }), d("chat.retry")]
297
553
  })
298
554
  })]
299
555
  })
300
556
  ]
301
557
  });
302
558
  }
303
- function T({ m: e }) {
304
- let { t: n, i18n: r } = h(o), [i, a] = m(!1), s = e.event;
559
+ function z({ m: e }) {
560
+ let { t: n, i18n: r } = g(o), [i, a] = h(!1), s = e.event;
305
561
  return /* @__PURE__ */ l("div", {
306
562
  className: "evdiv",
307
563
  children: [/* @__PURE__ */ c("div", {
@@ -316,7 +572,7 @@ function T({ m: e }) {
316
572
  }),
317
573
  s.text,
318
574
  " · ",
319
- x(e.createdAt, r.language),
575
+ F(e.createdAt, r.language),
320
576
  s.details && /* @__PURE__ */ l("button", {
321
577
  type: "button",
322
578
  className: "textbtn",
@@ -337,16 +593,29 @@ function T({ m: e }) {
337
593
  });
338
594
  }
339
595
  //#endregion
596
+ //#region src/chat/transcription.ts
597
+ async function te(e, t, n) {
598
+ n.busy(!0);
599
+ let r;
600
+ try {
601
+ r = await t(e);
602
+ } catch (r) {
603
+ n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void te(e, t, n));
604
+ return;
605
+ }
606
+ n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
607
+ }
608
+ //#endregion
340
609
  //#region src/chat/useRecorder.ts
341
- function E(e = 300, t) {
342
- let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = m(!1), [a, o] = m(0), [s, c] = m(0), [l, f] = m(!1), h = p(null), g = p([]), _ = p(void 0), v = p(null), y = p(null), b = p(!1), x = p(t);
610
+ function ne(e = 300, t) {
611
+ let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = h(!1), [a, o] = h(0), [s, c] = h(0), [l, f] = h(!1), p = m(null), g = m([]), _ = m(void 0), v = m(null), y = m(null), b = m(!1), x = m(t);
343
612
  d(() => {
344
613
  x.current = t;
345
614
  });
346
615
  let S = u(() => {
347
- window.clearInterval(_.current), h.current?.stream.getTracks().forEach((e) => e.stop()), h.current = null, v.current?.close().catch(() => void 0), v.current = null, i(!1), c(0);
616
+ window.clearInterval(_.current), p.current?.stream.getTracks().forEach((e) => e.stop()), p.current = null, v.current?.close().catch(() => void 0), v.current = null, i(!1), c(0);
348
617
  }, []), C = u(async () => {
349
- if (n && !h.current) {
618
+ if (n && !p.current) {
350
619
  f(!1);
351
620
  try {
352
621
  let t = await navigator.mediaDevices.getUserMedia({ audio: !0 }), n = new MediaRecorder(t);
@@ -362,7 +631,7 @@ function E(e = 300, t) {
362
631
  r = null;
363
632
  }
364
633
  let a = r ? new Uint8Array(r.fftSize) : null;
365
- h.current = n, n.start(), o(0), i(!0);
634
+ p.current = n, n.start(), o(0), i(!0);
366
635
  let s = Date.now(), l = !1;
367
636
  _.current = window.setInterval(() => {
368
637
  let t = Math.floor((Date.now() - s) / 1e3);
@@ -383,7 +652,7 @@ function E(e = 300, t) {
383
652
  S,
384
653
  e
385
654
  ]), w = u(() => new Promise((e) => {
386
- let t = h.current;
655
+ let t = p.current;
387
656
  if (!t || t.state === "inactive") return e(null);
388
657
  y.current = e, t.stop();
389
658
  }), []), T = u(() => {
@@ -400,71 +669,75 @@ function E(e = 300, t) {
400
669
  cancel: T
401
670
  };
402
671
  }
403
- function D(e) {
672
+ function re(e) {
404
673
  return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
405
674
  }
406
675
  //#endregion
407
676
  //#region src/chat/Chat.tsx
408
- function O(n) {
409
- let r = a(), i = e(), [o, u] = m(""), [h, v] = m([]), [b, x] = m(!1), [S, C] = m(null), [T, O] = m(0), [k, A] = m(!1), [j, M] = m(null), [N, P] = m(!1), F = p(!1), I = p(null), L = p(null), R = p(null), z = n.voiceMaxSeconds ?? 300, B = E(z, () => void ae()), { messages: V, busy: H = !1 } = n, U = n.onPendingChange;
410
- d(() => U?.(h), [h, U]);
411
- let W = V[0]?.id, G = V[V.length - 1], K = G?.id, ee = G?.text.length, te = G?.steps?.length, q = p({ height: 0 });
677
+ function B(n) {
678
+ let r = a(), i = e(), [o, u] = h(""), [g, y] = h([]), [b, S] = h(!1), [C, w] = h(null), [T, E] = h(0), [D, O] = h(!1), [k, A] = h(null), [j, M] = h(!1), [N, P] = h(null), F = m(n.loadAttachment);
679
+ d(() => {
680
+ F.current = n.loadAttachment;
681
+ });
682
+ let I = !!n.loadAttachment, L = p(() => I ? (e) => F.current ? F.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [I]), z = m(!1), B = m(null), V = m(null), H = m(null), U = n.voiceMaxSeconds ?? 300, W = ne(U, () => void me()), { messages: G, busy: K = !1 } = n, ae = n.onPendingChange;
683
+ d(() => ae?.(g), [g, ae]);
684
+ let q = G[0]?.id, J = G[G.length - 1], Y = J?.id, oe = J?.text.length, se = J?.steps?.length, ce = m({ height: 0 });
412
685
  f(() => {
413
- let e = I.current;
686
+ let e = B.current;
414
687
  if (!e) return;
415
- let t = q.current;
416
- e.scrollTop = t.first !== void 0 && W !== t.first && K === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, q.current = {
417
- first: W,
418
- last: K,
688
+ let t = ce.current;
689
+ e.scrollTop = t.first !== void 0 && q !== t.first && Y === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, ce.current = {
690
+ first: q,
691
+ last: Y,
419
692
  height: e.scrollHeight
420
693
  };
421
694
  }, [
422
- V.length,
423
- W,
424
- K,
425
- ee,
426
- te
695
+ G.length,
696
+ q,
697
+ Y,
698
+ oe,
699
+ se
427
700
  ]);
428
- let J = n.commands && !S && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Y = J === null ? [] : g(n.commands ?? [], J), X = J !== null && !k, Z = () => {
429
- u(""), v([]), C(null), M(null), F.current = !1;
430
- }, Q = async (e, t) => {
701
+ let X = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Z = X === null ? [] : _(n.commands ?? [], X), Q = X !== null && !D, le = () => {
702
+ u(""), y([]), w(null), A(null), z.current = !1;
703
+ }, ue = async (e, t) => {
431
704
  if (n.onCommand) try {
432
- await n.onCommand(e, t), Z();
705
+ await n.onCommand(e, t), le();
433
706
  } catch {}
434
707
  }, $ = async (e, t = !1) => {
435
708
  let r = e.trim();
436
- if (!(!r && h.length === 0 && !S || H || n.readOnly)) {
437
- if (!t && !S && n.commands && r.startsWith("/")) {
709
+ if (!(!r && g.length === 0 && !C || K || n.readOnly)) {
710
+ if (!t && !C && n.commands && r.startsWith("/")) {
438
711
  let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
439
- if (i) return Q(i.name, t.join(" "));
712
+ if (i) return ue(i.name, t.join(" "));
440
713
  if (e && !r.includes("\n")) {
441
- M("/" + e);
714
+ A("/" + e);
442
715
  return;
443
716
  }
444
717
  }
445
718
  try {
446
- await n.onSend(r, h.map((e) => e.id), F.current, S ?? void 0), Z();
719
+ await n.onSend(r, g.map((e) => e.id), z.current, C ?? void 0), le();
447
720
  } catch {}
448
721
  }
449
- }, ne = (e) => {
450
- O(0), e.kind === "skill" ? (C(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : Q(e.name, ""), R.current?.focus();
451
- }, re = (e) => {
452
- if (X && Y.length > 0) {
722
+ }, de = (e) => {
723
+ E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : ue(e.name, ""), H.current?.focus();
724
+ }, fe = (e) => {
725
+ if (Q && Z.length > 0) {
453
726
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
454
727
  e.preventDefault();
455
728
  let t = e.key === "ArrowDown" ? 1 : -1;
456
- O((e) => (e + t + Y.length) % Y.length);
729
+ E((e) => (e + t + Z.length) % Z.length);
457
730
  return;
458
731
  }
459
732
  if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
460
- e.preventDefault(), ne(Y[Math.min(T, Y.length - 1)]);
733
+ e.preventDefault(), de(Z[Math.min(T, Z.length - 1)]);
461
734
  return;
462
735
  }
463
736
  }
464
- X && e.key === "Escape" ? (e.preventDefault(), A(!0)) : e.key === "Backspace" && S && o === "" ? C(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), $(o));
465
- }, ie = async (e) => {
737
+ Q && e.key === "Escape" ? (e.preventDefault(), O(!0)) : e.key === "Backspace" && C && o === "" ? w(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && (e.preventDefault(), $(o));
738
+ }, pe = async (e) => {
466
739
  if (e?.length && n.onUpload) {
467
- x(!0);
740
+ S(!0);
468
741
  for (let t of Array.from(e)) {
469
742
  if (n.upload && t.size > n.upload.maxBytes) {
470
743
  i({
@@ -475,24 +748,36 @@ function O(n) {
475
748
  continue;
476
749
  }
477
750
  let e = await n.onUpload(t).catch(() => null);
478
- e && v((t) => [...t, e]);
751
+ e && y((t) => [...t, e]);
479
752
  }
480
- x(!1), L.current && (L.current.value = "");
753
+ S(!1), V.current && (V.current.value = "");
481
754
  }
482
755
  };
483
- async function ae() {
484
- let e = await B.stop();
485
- if (!e || !n.onTranscribe) return;
486
- P(!0);
487
- let t = await n.onTranscribe(e).catch(() => null);
488
- P(!1), t !== null && (t ? (F.current = !0, u((e) => e.trim() ? e.trimEnd() + " " + t : t), R.current?.focus()) : i({
489
- kind: "error",
490
- title: r("chat.voice.notRecognized")
491
- }));
756
+ async function me() {
757
+ let e = await W.stop();
758
+ e && n.onTranscribe && await te(e, n.onTranscribe, {
759
+ busy: M,
760
+ empty: () => i({
761
+ kind: "error",
762
+ title: r("chat.voice.notRecognized")
763
+ }),
764
+ failed: (e, t) => i({
765
+ kind: "error",
766
+ title: e ?? r("chat.voice.failed"),
767
+ actions: [{
768
+ label: r("chat.voice.retry"),
769
+ primary: !0,
770
+ onClick: t
771
+ }]
772
+ }),
773
+ text: (e) => {
774
+ z.current = !0, u((t) => t.trim() ? t.trimEnd() + " " + e : e), H.current?.focus();
775
+ }
776
+ });
492
777
  }
493
- let oe = (e) => {
494
- e.key === "Escape" && B.recording && (e.preventDefault(), B.cancel());
495
- }, se = S ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), ce = z - B.seconds;
778
+ let he = (e) => {
779
+ e.key === "Escape" && W.recording && (e.preventDefault(), W.cancel());
780
+ }, ge = C ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), _e = U - W.seconds;
496
781
  return /* @__PURE__ */ l("section", {
497
782
  className: "nb-chat",
498
783
  "aria-label": r("chat.title"),
@@ -500,7 +785,7 @@ function O(n) {
500
785
  n.header,
501
786
  /* @__PURE__ */ l("div", {
502
787
  className: "msgs",
503
- ref: I,
788
+ ref: B,
504
789
  "aria-live": "polite",
505
790
  children: [
506
791
  n.hasOlder && n.onLoadOlder && /* @__PURE__ */ c("button", {
@@ -514,7 +799,7 @@ function O(n) {
514
799
  className: "err-text",
515
800
  children: n.historyError
516
801
  }),
517
- V.length === 0 && !n.loading && !n.historyError && /* @__PURE__ */ l("div", {
802
+ G.length === 0 && !n.loading && !n.historyError && /* @__PURE__ */ l("div", {
518
803
  className: "empty",
519
804
  children: [
520
805
  /* @__PURE__ */ c("div", {
@@ -525,10 +810,12 @@ function O(n) {
525
810
  n.emptyHint
526
811
  ]
527
812
  }),
528
- V.map((e) => /* @__PURE__ */ c(w, {
813
+ G.map((e) => /* @__PURE__ */ c(R, {
529
814
  m: e,
530
- busy: H,
531
- onRetry: n.onRetry && (() => n.onRetry?.(e.id))
815
+ busy: K,
816
+ onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
817
+ loadAttachment: L,
818
+ onOpenAttachment: P
532
819
  }, e.id)),
533
820
  n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ l("div", {
534
821
  className: "confirm",
@@ -570,16 +857,16 @@ function O(n) {
570
857
  }) : /* @__PURE__ */ l("div", {
571
858
  className: "composer-wrap",
572
859
  children: [
573
- X && /* @__PURE__ */ c(_, {
574
- items: Y,
575
- active: Math.min(T, Math.max(Y.length - 1, 0)),
576
- onPick: ne,
577
- onHover: O
860
+ Q && /* @__PURE__ */ c(v, {
861
+ items: Z,
862
+ active: Math.min(T, Math.max(Z.length - 1, 0)),
863
+ onPick: de,
864
+ onHover: E
578
865
  }),
579
866
  n.aboveComposer,
580
- h.length > 0 && /* @__PURE__ */ c("div", {
867
+ g.length > 0 && /* @__PURE__ */ c("div", {
581
868
  className: "pending-files",
582
- children: h.map((e) => /* @__PURE__ */ l("span", {
869
+ children: g.map((e) => /* @__PURE__ */ l("span", {
583
870
  className: "chip",
584
871
  children: [
585
872
  /* @__PURE__ */ c(t, {
@@ -594,7 +881,7 @@ function O(n) {
594
881
  height: 18
595
882
  },
596
883
  "aria-label": r("remove"),
597
- onClick: () => v((t) => t.filter((t) => t.id !== e.id)),
884
+ onClick: () => y((t) => t.filter((t) => t.id !== e.id)),
598
885
  children: /* @__PURE__ */ c(t, {
599
886
  name: "x",
600
887
  size: 12
@@ -603,10 +890,10 @@ function O(n) {
603
890
  ]
604
891
  }, e.id))
605
892
  }),
606
- j && /* @__PURE__ */ l("div", {
893
+ k && /* @__PURE__ */ l("div", {
607
894
  className: "cmd-unknown",
608
895
  role: "status",
609
- children: [r("chat.unknownCommand", { name: j }), /* @__PURE__ */ c("button", {
896
+ children: [r("chat.unknownCommand", { name: k }), /* @__PURE__ */ c("button", {
610
897
  type: "button",
611
898
  className: "textbtn",
612
899
  onClick: () => void $(o, !0),
@@ -616,22 +903,22 @@ function O(n) {
616
903
  /* @__PURE__ */ l("div", {
617
904
  className: "composer",
618
905
  children: [
619
- n.onUpload && !B.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
906
+ n.onUpload && !W.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
620
907
  className: "iconbtn",
621
908
  "aria-label": r("chat.attach"),
622
909
  disabled: b,
623
- onClick: () => L.current?.click(),
910
+ onClick: () => V.current?.click(),
624
911
  children: /* @__PURE__ */ c(t, { name: "clip" })
625
912
  }), /* @__PURE__ */ c("input", {
626
- ref: L,
913
+ ref: V,
627
914
  type: "file",
628
915
  multiple: !0,
629
916
  hidden: !0,
630
917
  accept: n.upload?.accept,
631
- onChange: (e) => ie(e.target.files)
918
+ onChange: (e) => pe(e.target.files)
632
919
  })] }),
633
- B.recording ? /* @__PURE__ */ l("div", {
634
- className: `recbar${ce <= 15 ? " ending" : ""}`,
920
+ W.recording ? /* @__PURE__ */ l("div", {
921
+ className: `recbar${_e <= 15 ? " ending" : ""}`,
635
922
  role: "status",
636
923
  "aria-label": r("chat.voice.recordingNow"),
637
924
  children: [
@@ -642,40 +929,41 @@ function O(n) {
642
929
  /* @__PURE__ */ l("span", {
643
930
  className: "tm",
644
931
  children: [
645
- D(B.seconds),
932
+ re(W.seconds),
646
933
  " / ",
647
- D(z)
934
+ re(U)
648
935
  ]
649
936
  }),
650
937
  /* @__PURE__ */ c("span", {
651
938
  className: "lvl",
652
939
  "aria-hidden": "true",
653
- children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, B.level)})` } })
940
+ children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, W.level)})` } })
654
941
  }),
655
942
  /* @__PURE__ */ c("button", {
656
943
  type: "button",
657
944
  className: "btn ghost sm",
658
- onClick: B.cancel,
945
+ onClick: W.cancel,
659
946
  children: r("cancel")
660
947
  }),
661
948
  /* @__PURE__ */ c("button", {
662
949
  type: "button",
663
950
  className: "btn primary sm",
664
- onKeyDown: oe,
665
- onClick: () => void ae(),
951
+ onKeyDown: he,
952
+ onClick: () => void me(),
666
953
  children: r("chat.voice.done")
667
954
  })
668
955
  ]
669
956
  }) : /* @__PURE__ */ l("div", {
670
- className: `field${S ? " with-skill" : ""}`,
671
- children: [S && /* @__PURE__ */ l("span", {
957
+ className: `field${C ? " with-skill" : ""}${j ? " recognizing" : ""}`,
958
+ "aria-busy": j || void 0,
959
+ children: [C && /* @__PURE__ */ l("span", {
672
960
  className: "chip skill-chip",
673
961
  children: [
674
962
  /* @__PURE__ */ c(t, {
675
963
  name: "spark",
676
964
  size: 12
677
965
  }),
678
- S,
966
+ C,
679
967
  /* @__PURE__ */ c("button", {
680
968
  className: "iconbtn",
681
969
  style: {
@@ -683,7 +971,7 @@ function O(n) {
683
971
  height: 18
684
972
  },
685
973
  "aria-label": r("remove"),
686
- onClick: () => C(null),
974
+ onClick: () => w(null),
687
975
  children: /* @__PURE__ */ c(t, {
688
976
  name: "x",
689
977
  size: 12
@@ -691,34 +979,31 @@ function O(n) {
691
979
  })
692
980
  ]
693
981
  }), /* @__PURE__ */ c("textarea", {
694
- ref: R,
982
+ ref: H,
695
983
  rows: 1,
696
984
  value: o,
697
- placeholder: N ? r("chat.voice.recognizing") : se,
698
- "aria-label": se,
699
- disabled: N,
700
- "aria-expanded": X,
985
+ placeholder: j ? r("chat.voice.recognizing") : ge,
986
+ "aria-label": ge,
987
+ disabled: j,
988
+ "aria-expanded": Q,
701
989
  "aria-autocomplete": n.commands ? "list" : void 0,
702
990
  onChange: (e) => {
703
- u(e.target.value), A(!1), O(0), M(null);
991
+ u(e.target.value), O(!1), E(0), A(null);
704
992
  },
705
- onKeyDown: re
993
+ onKeyDown: fe
706
994
  })]
707
995
  }),
708
- n.context && !B.recording && /* @__PURE__ */ c(y, {
996
+ n.context && !W.recording && /* @__PURE__ */ c(x, {
709
997
  context: n.context,
710
998
  onCompact: n.onCompact,
711
999
  onReset: n.onReset
712
1000
  }),
713
- n.onTranscribe && !B.recording && /* @__PURE__ */ c("button", {
714
- className: "iconbtn",
715
- disabled: !B.supported || N,
716
- "aria-label": r("chat.voice.start"),
717
- title: B.supported ? r("chat.voice.start") : r("chat.voice.unsupported"),
718
- onClick: () => void B.start(),
719
- children: /* @__PURE__ */ c(t, { name: "mic" })
1001
+ n.onTranscribe && !W.recording && /* @__PURE__ */ c(ie, {
1002
+ supported: W.supported,
1003
+ recognizing: j,
1004
+ onStart: () => void W.start()
720
1005
  }),
721
- !B.recording && (n.onCancel && H ? /* @__PURE__ */ c("button", {
1006
+ !W.recording && (n.onCancel && K ? /* @__PURE__ */ c("button", {
722
1007
  className: "iconbtn fill",
723
1008
  "aria-label": r("chat.stop"),
724
1009
  onClick: n.onCancel,
@@ -726,26 +1011,54 @@ function O(n) {
726
1011
  }) : /* @__PURE__ */ c("button", {
727
1012
  className: "iconbtn fill",
728
1013
  "aria-label": r("chat.send"),
729
- disabled: !o.trim() && h.length === 0 && !S || H,
1014
+ disabled: !o.trim() && g.length === 0 && !C || K || j,
730
1015
  onClick: () => $(o),
731
1016
  children: /* @__PURE__ */ c(t, { name: "send" })
732
1017
  }))
733
1018
  ]
734
1019
  }),
735
- B.error && /* @__PURE__ */ c("div", {
1020
+ W.error && /* @__PURE__ */ c("div", {
736
1021
  className: "err-text",
737
1022
  style: { padding: "0 12px 8px" },
738
1023
  children: r("chat.voice.micDenied")
739
1024
  })
740
1025
  ]
1026
+ }),
1027
+ N && L && /* @__PURE__ */ c(ee, {
1028
+ a: N,
1029
+ load: L,
1030
+ onClose: () => P(null)
741
1031
  })
742
1032
  ]
743
1033
  });
744
1034
  }
1035
+ function ie({ supported: e, recognizing: n, onStart: r }) {
1036
+ let i = a();
1037
+ return n ? /* @__PURE__ */ l("span", {
1038
+ className: "voicewait",
1039
+ role: "status",
1040
+ "aria-label": i("chat.voice.recognizing"),
1041
+ title: i("chat.voice.recognizing"),
1042
+ children: [
1043
+ /* @__PURE__ */ c("i", {}),
1044
+ /* @__PURE__ */ c("i", {}),
1045
+ /* @__PURE__ */ c("i", {}),
1046
+ /* @__PURE__ */ c("i", {}),
1047
+ /* @__PURE__ */ c("i", {})
1048
+ ]
1049
+ }) : /* @__PURE__ */ c("button", {
1050
+ className: "iconbtn",
1051
+ disabled: !e,
1052
+ "aria-label": i("chat.voice.start"),
1053
+ title: i(e ? "chat.voice.start" : "chat.voice.unsupported"),
1054
+ onClick: r,
1055
+ children: /* @__PURE__ */ c(t, { name: "mic" })
1056
+ });
1057
+ }
745
1058
  //#endregion
746
1059
  //#region src/chat/ConversationList.tsx
747
- function k({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
748
- let f = a(), [p, h] = m(!1);
1060
+ function V({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
1061
+ let f = a(), [p, m] = h(!1);
749
1062
  d(() => {
750
1063
  if (!r) return;
751
1064
  let e = (e) => e.key === "Escape" && o();
@@ -786,7 +1099,7 @@ function k({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
786
1099
  width: "100%",
787
1100
  justifyContent: "center"
788
1101
  },
789
- onClick: () => h(!0),
1102
+ onClick: () => m(!0),
790
1103
  children: [/* @__PURE__ */ c(t, {
791
1104
  name: "plus",
792
1105
  size: 15
@@ -820,20 +1133,20 @@ function k({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
820
1133
  "aria-label": f("close"),
821
1134
  onClick: o
822
1135
  }),
823
- p && u && /* @__PURE__ */ c(j, {
824
- onClose: () => h(!1),
1136
+ p && u && /* @__PURE__ */ c(U, {
1137
+ onClose: () => m(!1),
825
1138
  onCreate: u
826
1139
  })
827
1140
  ] });
828
1141
  }
829
- function A({ narrow: e, children: t }) {
1142
+ function H({ narrow: e, children: t }) {
830
1143
  return /* @__PURE__ */ c("div", {
831
1144
  className: `nb-app${e ? " narrow" : ""}`,
832
1145
  children: t
833
1146
  });
834
1147
  }
835
- function j({ onClose: e, onCreate: t }) {
836
- let r = a(), [i, o] = m(""), [u, d] = m(!1), [f, p] = m(null), h = async () => {
1148
+ function U({ onClose: e, onCreate: t }) {
1149
+ let r = a(), [i, o] = h(""), [u, d] = h(!1), [f, p] = h(null), m = async () => {
837
1150
  if (i.trim() && !u) {
838
1151
  d(!0), p(null);
839
1152
  try {
@@ -853,7 +1166,7 @@ function j({ onClose: e, onCreate: t }) {
853
1166
  }), /* @__PURE__ */ c("button", {
854
1167
  className: "btn primary",
855
1168
  disabled: !i.trim() || u,
856
- onClick: h,
1169
+ onClick: m,
857
1170
  children: r("create")
858
1171
  })] }),
859
1172
  children: [/* @__PURE__ */ l("div", {
@@ -869,7 +1182,7 @@ function j({ onClose: e, onCreate: t }) {
869
1182
  value: i,
870
1183
  maxLength: 120,
871
1184
  onChange: (e) => o(e.target.value),
872
- onKeyDown: (e) => e.key === "Enter" && h()
1185
+ onKeyDown: (e) => e.key === "Enter" && m()
873
1186
  }),
874
1187
  /* @__PURE__ */ c("div", {
875
1188
  className: "hint",
@@ -884,7 +1197,7 @@ function j({ onClose: e, onCreate: t }) {
884
1197
  }
885
1198
  //#endregion
886
1199
  //#region src/chat/AgentMenu.tsx
887
- function M({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
1200
+ function W({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
888
1201
  return /* @__PURE__ */ c("button", {
889
1202
  type: "button",
890
1203
  className: `agentbtn${a ? " s" : ""}`,
@@ -900,8 +1213,8 @@ function M({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, on
900
1213
  })
901
1214
  });
902
1215
  }
903
- function N({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: h, onPick: g, onClose: _ }) {
904
- let v = a(), [y, b] = m(n), x = i(!0, _);
1216
+ function G({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: m, onPick: g, onClose: _ }) {
1217
+ let v = a(), [y, b] = h(n), x = i(!0, _);
905
1218
  return /* @__PURE__ */ l("div", {
906
1219
  className: `agentmenu${f ? " narrow" : ""}`,
907
1220
  ref: x,
@@ -921,7 +1234,7 @@ function N({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
921
1234
  onChange: (e) => b(e.target.value),
922
1235
  onBlur: () => {
923
1236
  let e = y.trim();
924
- e && e !== n && h(e);
1237
+ e && e !== n && m(e);
925
1238
  },
926
1239
  onKeyDown: (e) => e.key === "Enter" && e.target.blur()
927
1240
  }),
@@ -1011,6 +1324,6 @@ function N({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
1011
1324
  });
1012
1325
  }
1013
1326
  //#endregion
1014
- export { M as AgentButton, N as AgentMenu, O as Chat, A as ChatLayout, _ as CommandPalette, y as ContextMeter, k as ConversationList, w as MessageView, j as NewTopicModal, v as tokens, E as useRecorder };
1327
+ export { W as AgentButton, G as AgentMenu, N as AttachmentList, ee as AttachmentPreview, B as Chat, H as ChatLayout, v as CommandPalette, x as ContextMeter, V as ConversationList, R as MessageView, U as NewTopicModal, ie as VoiceButton, O as fileSize, k as parseTable, T as previewKind, b as tokens, ne as useRecorder };
1015
1328
 
1016
1329
  //# sourceMappingURL=chat.js.map