@green-on-grey/ui-kit 1.2.0 → 1.4.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/Attachments.d.ts +37 -0
- package/dist/chat/Chat.d.ts +5 -0
- package/dist/chat/MessageView.d.ts +6 -2
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/intl.d.ts +2 -0
- package/dist/chat/types.d.ts +6 -0
- package/dist/chat.js +564 -178
- package/dist/chat.js.map +1 -1
- package/dist/components/Icon.d.ts +3 -0
- package/dist/components/TopBar.d.ts +10 -2
- package/dist/index.js +25 -21
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +55 -0
- package/dist/locales.js +60 -5
- package/dist/locales.js.map +1 -1
- package/dist/manifest.json +45 -1
- package/dist/styles.css +77 -2
- package/dist/{ui-joAvYmUH.js → ui-ChXUXoIB.js} +4 -1
- package/dist/ui-ChXUXoIB.js.map +1 -0
- package/package.json +1 -1
- package/dist/ui-joAvYmUH.js.map +0 -1
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-
|
|
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,
|
|
5
|
-
import { useTranslation as
|
|
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
|
|
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
|
|
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",
|
|
@@ -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
|
|
72
|
-
return new Intl.NumberFormat(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
|
|
78
|
-
let s = a(), { i18n: u } =
|
|
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 ${
|
|
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:
|
|
89
|
-
total:
|
|
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:
|
|
94
|
-
total:
|
|
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: `${(
|
|
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:
|
|
120
|
-
total:
|
|
122
|
+
used: b(e.tokens, x),
|
|
123
|
+
total: b(e.window, x),
|
|
121
124
|
pct: _
|
|
122
125
|
}) }),
|
|
123
|
-
|
|
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
|
-
|
|
131
|
+
v === "full" && (n || r) && /* @__PURE__ */ l("div", {
|
|
129
132
|
className: "row",
|
|
130
133
|
style: {
|
|
131
134
|
marginTop: 8,
|
|
@@ -158,18 +161,363 @@ 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)$/;
|
|
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 === "text/html" || /\.html?$/.test(n) ? "html" : 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
|
+
html: "globe",
|
|
182
|
+
text: "source"
|
|
183
|
+
}, D = (e) => E[e];
|
|
184
|
+
function O(e, t) {
|
|
185
|
+
return t === "pdf" ? "PDF" : t === "markdown" ? "MD" : t === "html" ? "HTML" : /\.([a-z0-9]{1,5})$/i.exec(e.fileName)?.[1]?.toUpperCase() ?? (t ? "TXT" : "FILE");
|
|
186
|
+
}
|
|
187
|
+
function k(e, t) {
|
|
188
|
+
let n = [
|
|
189
|
+
"byte",
|
|
190
|
+
"kilobyte",
|
|
191
|
+
"megabyte",
|
|
192
|
+
"gigabyte"
|
|
193
|
+
], r = e, i = 0;
|
|
194
|
+
for (; r >= 1024 && i < n.length - 1;) r /= 1024, i++;
|
|
195
|
+
return new Intl.NumberFormat(y(t), {
|
|
196
|
+
style: "unit",
|
|
197
|
+
unit: n[i],
|
|
198
|
+
unitDisplay: "short",
|
|
199
|
+
maximumFractionDigits: i === 0 ? 0 : 1
|
|
200
|
+
}).format(r);
|
|
201
|
+
}
|
|
202
|
+
var A = "default-src 'none'; img-src data: blob:; media-src data: blob:; font-src data:; style-src 'unsafe-inline' data:";
|
|
203
|
+
function j(e) {
|
|
204
|
+
let t = `<meta http-equiv="Content-Security-Policy" content="${A}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
|
|
205
|
+
if (typeof DOMParser > "u") return n + t + e.slice(n.length);
|
|
206
|
+
let r = new DOMParser().parseFromString(e, "text/html");
|
|
207
|
+
r.querySelectorAll("script, noscript, iframe, frame, frameset, object, embed, applet, base, link, meta[http-equiv], portal").forEach((e) => e.remove()), r.querySelectorAll("*").forEach((e) => {
|
|
208
|
+
for (let t of Array.from(e.attributes)) {
|
|
209
|
+
let n = t.name.toLowerCase();
|
|
210
|
+
n.startsWith("on") || ee.has(n) && !M.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !M.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", N(t.value));
|
|
211
|
+
}
|
|
212
|
+
}), r.querySelectorAll("style").forEach((e) => {
|
|
213
|
+
e.textContent = N(e.textContent ?? "");
|
|
214
|
+
});
|
|
215
|
+
let i = r.createElement("meta");
|
|
216
|
+
return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", A), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
|
|
217
|
+
}
|
|
218
|
+
var ee = /* @__PURE__ */ new Set([
|
|
219
|
+
"src",
|
|
220
|
+
"href",
|
|
221
|
+
"xlink:href",
|
|
222
|
+
"action",
|
|
223
|
+
"formaction",
|
|
224
|
+
"poster",
|
|
225
|
+
"background",
|
|
226
|
+
"data",
|
|
227
|
+
"ping",
|
|
228
|
+
"lowsrc",
|
|
229
|
+
"dynsrc",
|
|
230
|
+
"manifest",
|
|
231
|
+
"cite",
|
|
232
|
+
"longdesc",
|
|
233
|
+
"codebase",
|
|
234
|
+
"archive",
|
|
235
|
+
"usemap"
|
|
236
|
+
]), M = /^\s*(data:|blob:|#|$)/i;
|
|
237
|
+
function N(e) {
|
|
238
|
+
return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => M.test(n) && n.trim() !== "" ? e : "none");
|
|
239
|
+
}
|
|
240
|
+
var P = {
|
|
241
|
+
png: "image/png",
|
|
242
|
+
jpg: "image/jpeg",
|
|
243
|
+
jpeg: "image/jpeg",
|
|
244
|
+
gif: "image/gif",
|
|
245
|
+
webp: "image/webp",
|
|
246
|
+
svg: "image/svg+xml",
|
|
247
|
+
pdf: "application/pdf",
|
|
248
|
+
md: "text/markdown",
|
|
249
|
+
markdown: "text/markdown",
|
|
250
|
+
csv: "text/csv",
|
|
251
|
+
tsv: "text/tab-separated-values",
|
|
252
|
+
html: "text/html",
|
|
253
|
+
htm: "text/html"
|
|
254
|
+
};
|
|
255
|
+
function F(e) {
|
|
256
|
+
let t = (e.mimeType ?? "").split(";")[0].trim().toLowerCase();
|
|
257
|
+
return t && t !== "application/octet-stream" ? t : P[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
|
|
258
|
+
}
|
|
259
|
+
function I(e, t) {
|
|
260
|
+
if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
|
|
261
|
+
let n = [], r = [], i = "", a = !1;
|
|
262
|
+
for (let t = 0; t < e.length; t++) {
|
|
263
|
+
let o = e[t];
|
|
264
|
+
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;
|
|
265
|
+
}
|
|
266
|
+
return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
|
|
267
|
+
}
|
|
268
|
+
function L(e, t, n = !0) {
|
|
269
|
+
let [r, i] = h({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
|
|
270
|
+
return d(() => {
|
|
271
|
+
if (!n) return;
|
|
272
|
+
let e, r = !0;
|
|
273
|
+
return t({
|
|
274
|
+
id: a,
|
|
275
|
+
href: o,
|
|
276
|
+
fileName: s,
|
|
277
|
+
mimeType: c,
|
|
278
|
+
size: l
|
|
279
|
+
}).then((t) => {
|
|
280
|
+
if (!r) return;
|
|
281
|
+
let n = F({
|
|
282
|
+
fileName: s,
|
|
283
|
+
mimeType: c
|
|
284
|
+
}), a = n && t.type !== n ? new Blob([t], { type: n }) : t;
|
|
285
|
+
e = URL.createObjectURL(a), i({
|
|
286
|
+
url: e,
|
|
287
|
+
blob: a
|
|
288
|
+
});
|
|
289
|
+
}, () => r && i({ failed: !0 })), () => {
|
|
290
|
+
r = !1, e && URL.revokeObjectURL(e);
|
|
291
|
+
};
|
|
292
|
+
}, [
|
|
293
|
+
n,
|
|
294
|
+
t,
|
|
295
|
+
a,
|
|
296
|
+
o,
|
|
297
|
+
s,
|
|
298
|
+
c,
|
|
299
|
+
l
|
|
300
|
+
]), r;
|
|
301
|
+
}
|
|
302
|
+
function R({ a: e, load: t, onOpen: n }) {
|
|
303
|
+
let r = a(), { url: i, failed: o } = L(e, t);
|
|
304
|
+
return o ? /* @__PURE__ */ c(z, {
|
|
305
|
+
a: e,
|
|
306
|
+
kind: "image",
|
|
307
|
+
onOpen: n
|
|
308
|
+
}) : /* @__PURE__ */ l("button", {
|
|
309
|
+
type: "button",
|
|
310
|
+
className: "att-thumb",
|
|
311
|
+
onClick: n,
|
|
312
|
+
"aria-label": r("chat.files.open", { name: e.fileName }),
|
|
313
|
+
title: e.fileName,
|
|
314
|
+
children: [i ? /* @__PURE__ */ c("img", {
|
|
315
|
+
src: i,
|
|
316
|
+
alt: ""
|
|
317
|
+
}) : /* @__PURE__ */ c("span", {
|
|
318
|
+
className: "spin",
|
|
319
|
+
"aria-hidden": "true"
|
|
320
|
+
}), /* @__PURE__ */ c("span", {
|
|
321
|
+
className: "att-cap",
|
|
322
|
+
children: e.fileName
|
|
323
|
+
})]
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
function z({ a: e, kind: n, onOpen: r }) {
|
|
327
|
+
let i = a(), { i18n: u } = g(o), d = n !== null && r !== void 0, f = /* @__PURE__ */ l(s, { children: [
|
|
328
|
+
/* @__PURE__ */ l("span", {
|
|
329
|
+
className: "att-ic",
|
|
330
|
+
children: [/* @__PURE__ */ c(t, {
|
|
331
|
+
name: d && n ? E[n] : "download",
|
|
332
|
+
size: 24
|
|
333
|
+
}), /* @__PURE__ */ c("span", {
|
|
334
|
+
className: "att-kl",
|
|
335
|
+
children: O(e, n)
|
|
336
|
+
})]
|
|
337
|
+
}),
|
|
338
|
+
/* @__PURE__ */ c("span", {
|
|
339
|
+
className: "att-name",
|
|
340
|
+
children: e.fileName
|
|
341
|
+
}),
|
|
342
|
+
e.size != null && /* @__PURE__ */ c("span", {
|
|
343
|
+
className: "att-size",
|
|
344
|
+
children: k(e.size, u.language)
|
|
345
|
+
})
|
|
346
|
+
] });
|
|
347
|
+
return d ? /* @__PURE__ */ c("button", {
|
|
348
|
+
type: "button",
|
|
349
|
+
className: `att-tile ${n}`,
|
|
350
|
+
onClick: r,
|
|
351
|
+
"aria-label": i("chat.files.open", { name: e.fileName }),
|
|
352
|
+
title: e.fileName,
|
|
353
|
+
children: f
|
|
354
|
+
}) : /* @__PURE__ */ c("a", {
|
|
355
|
+
className: "att-tile dl",
|
|
356
|
+
href: e.href,
|
|
357
|
+
download: e.fileName,
|
|
358
|
+
"aria-label": i("chat.files.save", { name: e.fileName }),
|
|
359
|
+
title: e.fileName,
|
|
360
|
+
children: f
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
function B({ items: e, load: t, onOpen: n }) {
|
|
364
|
+
return /* @__PURE__ */ c("div", {
|
|
365
|
+
className: "atts",
|
|
366
|
+
children: e.map((e) => {
|
|
367
|
+
let r = t && n ? () => n(e) : void 0, i = T(e);
|
|
368
|
+
return t && r && i === "image" ? /* @__PURE__ */ c(R, {
|
|
369
|
+
a: e,
|
|
370
|
+
load: t,
|
|
371
|
+
onOpen: r
|
|
372
|
+
}, e.id) : /* @__PURE__ */ c(z, {
|
|
373
|
+
a: e,
|
|
374
|
+
kind: i,
|
|
375
|
+
onOpen: r
|
|
376
|
+
}, e.id);
|
|
377
|
+
})
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
function V({ text: e, tab: t }) {
|
|
381
|
+
let n = a(), [r, ...i] = I(e, t), o = i.slice(0, 500);
|
|
382
|
+
return /* @__PURE__ */ l("div", {
|
|
383
|
+
className: "att-table",
|
|
384
|
+
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", {
|
|
385
|
+
className: "att-more",
|
|
386
|
+
children: n("chat.files.rows", {
|
|
387
|
+
shown: o.length,
|
|
388
|
+
total: i.length
|
|
389
|
+
})
|
|
390
|
+
})]
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
function te({ a: e, load: i, onClose: u }) {
|
|
394
|
+
let f = a(), { i18n: p } = g(o), m = T(e), _ = m === "markdown" || m === "table" || m === "html" || m === "text", [v, y] = h(!1), b = _ && (e.size ?? 0) > 1048576, { url: x, blob: S, failed: C } = L(e, i, !b), [w, E] = h(null), D = b || _ && (S?.size ?? 0) > 1048576;
|
|
395
|
+
d(() => {
|
|
396
|
+
_ && S && !D && S.arrayBuffer().then((e) => {
|
|
397
|
+
try {
|
|
398
|
+
E({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
|
|
399
|
+
} catch {
|
|
400
|
+
E({ text: null });
|
|
401
|
+
}
|
|
402
|
+
}, () => E({ text: null }));
|
|
403
|
+
}, [
|
|
404
|
+
_,
|
|
405
|
+
S,
|
|
406
|
+
D
|
|
407
|
+
]);
|
|
408
|
+
let O = w?.text, A;
|
|
409
|
+
return A = C ? /* @__PURE__ */ c("div", {
|
|
410
|
+
className: "att-msg err-text",
|
|
411
|
+
children: f("chat.files.failed")
|
|
412
|
+
}) : D ? /* @__PURE__ */ c("div", {
|
|
413
|
+
className: "att-msg",
|
|
414
|
+
children: f("chat.files.tooLarge")
|
|
415
|
+
}) : w && O === null ? /* @__PURE__ */ c("div", {
|
|
416
|
+
className: "att-msg",
|
|
417
|
+
children: f("chat.files.notUtf8")
|
|
418
|
+
}) : !x || _ && O == null ? /* @__PURE__ */ l("div", {
|
|
419
|
+
className: "att-msg",
|
|
420
|
+
children: [
|
|
421
|
+
/* @__PURE__ */ c("span", {
|
|
422
|
+
className: "spin",
|
|
423
|
+
"aria-hidden": "true"
|
|
424
|
+
}),
|
|
425
|
+
" ",
|
|
426
|
+
f("loading")
|
|
427
|
+
]
|
|
428
|
+
}) : m === "image" ? /* @__PURE__ */ c("img", {
|
|
429
|
+
className: "att-img",
|
|
430
|
+
src: x,
|
|
431
|
+
alt: e.fileName
|
|
432
|
+
}) : m === "pdf" ? /* @__PURE__ */ c("object", {
|
|
433
|
+
className: "att-pdf",
|
|
434
|
+
data: x,
|
|
435
|
+
type: "application/pdf",
|
|
436
|
+
"aria-label": e.fileName,
|
|
437
|
+
children: /* @__PURE__ */ c("div", {
|
|
438
|
+
className: "att-msg",
|
|
439
|
+
children: f("chat.files.failed")
|
|
440
|
+
})
|
|
441
|
+
}) : m === "markdown" ? /* @__PURE__ */ c("div", {
|
|
442
|
+
className: "att-md",
|
|
443
|
+
children: /* @__PURE__ */ c(r, { text: O ?? "" })
|
|
444
|
+
}) : m === "table" ? /* @__PURE__ */ c(V, {
|
|
445
|
+
text: O ?? "",
|
|
446
|
+
tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
|
|
447
|
+
}) : m === "html" && !v ? /* @__PURE__ */ c("iframe", {
|
|
448
|
+
className: "att-html",
|
|
449
|
+
sandbox: "",
|
|
450
|
+
srcDoc: j(O ?? ""),
|
|
451
|
+
title: e.fileName,
|
|
452
|
+
referrerPolicy: "no-referrer"
|
|
453
|
+
}) : /* @__PURE__ */ c("pre", {
|
|
454
|
+
className: "att-text",
|
|
455
|
+
children: O
|
|
456
|
+
}), /* @__PURE__ */ c(n, {
|
|
457
|
+
wide: !0,
|
|
458
|
+
onClose: u,
|
|
459
|
+
title: /* @__PURE__ */ l("span", {
|
|
460
|
+
className: "att-title",
|
|
461
|
+
children: [/* @__PURE__ */ c("span", {
|
|
462
|
+
className: "att-name",
|
|
463
|
+
children: e.fileName
|
|
464
|
+
}), e.size != null && /* @__PURE__ */ c("span", {
|
|
465
|
+
className: "muted small",
|
|
466
|
+
children: k(e.size, p.language)
|
|
467
|
+
})]
|
|
468
|
+
}),
|
|
469
|
+
footer: /* @__PURE__ */ l(s, { children: [
|
|
470
|
+
m === "html" && /* @__PURE__ */ l("button", {
|
|
471
|
+
type: "button",
|
|
472
|
+
className: "btn ghost",
|
|
473
|
+
onClick: () => y((e) => !e),
|
|
474
|
+
children: [
|
|
475
|
+
/* @__PURE__ */ c(t, {
|
|
476
|
+
name: v ? "globe" : "code",
|
|
477
|
+
size: 14
|
|
478
|
+
}),
|
|
479
|
+
" ",
|
|
480
|
+
f(v ? "chat.files.page" : "chat.files.source")
|
|
481
|
+
]
|
|
482
|
+
}),
|
|
483
|
+
/* @__PURE__ */ l("a", {
|
|
484
|
+
className: "btn ghost",
|
|
485
|
+
href: x ?? e.href,
|
|
486
|
+
download: e.fileName,
|
|
487
|
+
children: [
|
|
488
|
+
/* @__PURE__ */ c(t, {
|
|
489
|
+
name: "download",
|
|
490
|
+
size: 14
|
|
491
|
+
}),
|
|
492
|
+
" ",
|
|
493
|
+
f("chat.files.download")
|
|
494
|
+
]
|
|
495
|
+
}),
|
|
496
|
+
/* @__PURE__ */ c("button", {
|
|
497
|
+
type: "button",
|
|
498
|
+
className: "btn primary",
|
|
499
|
+
onClick: u,
|
|
500
|
+
children: f("close")
|
|
501
|
+
})
|
|
502
|
+
] }),
|
|
503
|
+
children: /* @__PURE__ */ c("div", {
|
|
504
|
+
className: `att-view ${m ?? ""}`,
|
|
505
|
+
children: A
|
|
506
|
+
})
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
//#endregion
|
|
161
510
|
//#region src/chat/MessageView.tsx
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
return new Intl.DateTimeFormat(b(t), {
|
|
511
|
+
function H(e, t) {
|
|
512
|
+
return new Intl.DateTimeFormat(y(t), {
|
|
165
513
|
hour: "2-digit",
|
|
166
514
|
minute: "2-digit"
|
|
167
515
|
}).format(new Date(e));
|
|
168
516
|
}
|
|
169
|
-
function
|
|
517
|
+
function U(e, t) {
|
|
170
518
|
return t || e.length <= 3 ? e : e.slice(-2);
|
|
171
519
|
}
|
|
172
|
-
var
|
|
520
|
+
var W = {
|
|
173
521
|
done: {
|
|
174
522
|
icon: "check",
|
|
175
523
|
cls: "ok"
|
|
@@ -183,14 +531,14 @@ var C = {
|
|
|
183
531
|
cls: "run"
|
|
184
532
|
}
|
|
185
533
|
};
|
|
186
|
-
function
|
|
187
|
-
let { t:
|
|
534
|
+
function ne({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u }) {
|
|
535
|
+
let { t: d, i18n: f } = g(o), [p, m] = h(!1);
|
|
188
536
|
if (e.role === "note") return /* @__PURE__ */ c("div", {
|
|
189
537
|
className: "sysnote",
|
|
190
538
|
children: e.text
|
|
191
539
|
});
|
|
192
|
-
if (e.role === "event" && e.event) return /* @__PURE__ */ c(
|
|
193
|
-
let
|
|
540
|
+
if (e.role === "event" && e.event) return /* @__PURE__ */ c(G, { m: e });
|
|
541
|
+
let _ = e.mark && /* @__PURE__ */ l("div", {
|
|
194
542
|
className: "chan",
|
|
195
543
|
children: [
|
|
196
544
|
/* @__PURE__ */ c(t, {
|
|
@@ -200,73 +548,64 @@ function w({ m: e, busy: n, onRetry: i }) {
|
|
|
200
548
|
" ",
|
|
201
549
|
e.mark.text,
|
|
202
550
|
" · ",
|
|
203
|
-
|
|
551
|
+
H(e.createdAt, f.language)
|
|
204
552
|
]
|
|
205
|
-
}),
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
children: [
|
|
210
|
-
/* @__PURE__ */ c(t, {
|
|
211
|
-
name: "clip",
|
|
212
|
-
size: 12
|
|
213
|
-
}),
|
|
214
|
-
" ",
|
|
215
|
-
e.fileName
|
|
216
|
-
]
|
|
217
|
-
}, e.id))
|
|
553
|
+
}), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(B, {
|
|
554
|
+
items: e.attachments,
|
|
555
|
+
load: a,
|
|
556
|
+
onOpen: u
|
|
218
557
|
});
|
|
219
558
|
if (e.role === "user") return /* @__PURE__ */ l("div", {
|
|
220
559
|
className: "m u",
|
|
221
560
|
children: [
|
|
222
|
-
|
|
561
|
+
_,
|
|
223
562
|
e.content,
|
|
224
563
|
e.text && /* @__PURE__ */ c("div", {
|
|
225
564
|
className: "bub",
|
|
226
565
|
children: e.text
|
|
227
566
|
}),
|
|
228
|
-
|
|
567
|
+
v,
|
|
229
568
|
e.wait && /* @__PURE__ */ c("div", {
|
|
230
569
|
className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
|
|
231
570
|
role: "status",
|
|
232
571
|
children: e.wait.state === "queued" ? /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(t, {
|
|
233
572
|
name: "clock",
|
|
234
573
|
size: 12
|
|
235
|
-
}),
|
|
574
|
+
}), d("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("span", {
|
|
236
575
|
className: "spin",
|
|
237
576
|
"aria-hidden": "true"
|
|
238
|
-
}),
|
|
577
|
+
}), d("chat.wait.starting")] })
|
|
239
578
|
})
|
|
240
579
|
]
|
|
241
580
|
});
|
|
242
|
-
let
|
|
581
|
+
let y = e.steps ?? [], b = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
|
|
243
582
|
return /* @__PURE__ */ l("div", {
|
|
244
583
|
className: "m a",
|
|
245
584
|
children: [
|
|
246
|
-
|
|
247
|
-
|
|
585
|
+
_,
|
|
586
|
+
y.length > 3 && /* @__PURE__ */ c("button", {
|
|
248
587
|
className: "tools-fold",
|
|
249
|
-
onClick: () =>
|
|
250
|
-
"aria-expanded":
|
|
251
|
-
children:
|
|
588
|
+
onClick: () => m((e) => !e),
|
|
589
|
+
"aria-expanded": p,
|
|
590
|
+
children: p ? d("chat.hideSteps") : d("chat.moreSteps", { count: y.length - 2 })
|
|
252
591
|
}),
|
|
253
|
-
|
|
592
|
+
U(y, p).map((e) => /* @__PURE__ */ l("div", {
|
|
254
593
|
className: "tool",
|
|
255
594
|
title: e.title,
|
|
256
595
|
children: [/* @__PURE__ */ c(t, {
|
|
257
|
-
name:
|
|
596
|
+
name: W[e.status].icon,
|
|
258
597
|
size: 14,
|
|
259
|
-
className:
|
|
598
|
+
className: W[e.status].cls
|
|
260
599
|
}), /* @__PURE__ */ c("span", {
|
|
261
600
|
className: "tx",
|
|
262
601
|
children: e.text
|
|
263
602
|
})]
|
|
264
603
|
}, e.id)),
|
|
265
|
-
|
|
604
|
+
b && /* @__PURE__ */ c("div", {
|
|
266
605
|
className: "bub",
|
|
267
606
|
children: /* @__PURE__ */ l("span", {
|
|
268
607
|
className: "typing",
|
|
269
|
-
"aria-label":
|
|
608
|
+
"aria-label": d("chat.typing"),
|
|
270
609
|
children: [
|
|
271
610
|
/* @__PURE__ */ c("i", {}),
|
|
272
611
|
/* @__PURE__ */ c("i", {}),
|
|
@@ -279,7 +618,7 @@ function w({ m: e, busy: n, onRetry: i }) {
|
|
|
279
618
|
title: e.hint,
|
|
280
619
|
children: /* @__PURE__ */ c(r, { text: e.text })
|
|
281
620
|
})),
|
|
282
|
-
|
|
621
|
+
v,
|
|
283
622
|
e.error && /* @__PURE__ */ l("div", {
|
|
284
623
|
className: `llmerr${e.error.transient ? " amber" : ""}`,
|
|
285
624
|
role: "alert",
|
|
@@ -293,15 +632,15 @@ function w({ m: e, busy: n, onRetry: i }) {
|
|
|
293
632
|
children: [/* @__PURE__ */ c(t, {
|
|
294
633
|
name: "refresh",
|
|
295
634
|
size: 14
|
|
296
|
-
}),
|
|
635
|
+
}), d("chat.retry")]
|
|
297
636
|
})
|
|
298
637
|
})]
|
|
299
638
|
})
|
|
300
639
|
]
|
|
301
640
|
});
|
|
302
641
|
}
|
|
303
|
-
function
|
|
304
|
-
let { t: n, i18n: r } =
|
|
642
|
+
function G({ m: e }) {
|
|
643
|
+
let { t: n, i18n: r } = g(o), [i, a] = h(!1), s = e.event;
|
|
305
644
|
return /* @__PURE__ */ l("div", {
|
|
306
645
|
className: "evdiv",
|
|
307
646
|
children: [/* @__PURE__ */ c("div", {
|
|
@@ -316,7 +655,7 @@ function T({ m: e }) {
|
|
|
316
655
|
}),
|
|
317
656
|
s.text,
|
|
318
657
|
" · ",
|
|
319
|
-
|
|
658
|
+
H(e.createdAt, r.language),
|
|
320
659
|
s.details && /* @__PURE__ */ l("button", {
|
|
321
660
|
type: "button",
|
|
322
661
|
className: "textbtn",
|
|
@@ -338,28 +677,28 @@ function T({ m: e }) {
|
|
|
338
677
|
}
|
|
339
678
|
//#endregion
|
|
340
679
|
//#region src/chat/transcription.ts
|
|
341
|
-
async function
|
|
680
|
+
async function re(e, t, n) {
|
|
342
681
|
n.busy(!0);
|
|
343
682
|
let r;
|
|
344
683
|
try {
|
|
345
684
|
r = await t(e);
|
|
346
685
|
} catch (r) {
|
|
347
|
-
n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void
|
|
686
|
+
n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void re(e, t, n));
|
|
348
687
|
return;
|
|
349
688
|
}
|
|
350
689
|
n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
|
|
351
690
|
}
|
|
352
691
|
//#endregion
|
|
353
692
|
//#region src/chat/useRecorder.ts
|
|
354
|
-
function
|
|
355
|
-
let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] =
|
|
693
|
+
function ie(e = 300, t) {
|
|
694
|
+
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);
|
|
356
695
|
d(() => {
|
|
357
696
|
x.current = t;
|
|
358
697
|
});
|
|
359
698
|
let S = u(() => {
|
|
360
|
-
window.clearInterval(_.current),
|
|
699
|
+
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);
|
|
361
700
|
}, []), C = u(async () => {
|
|
362
|
-
if (n && !
|
|
701
|
+
if (n && !p.current) {
|
|
363
702
|
f(!1);
|
|
364
703
|
try {
|
|
365
704
|
let t = await navigator.mediaDevices.getUserMedia({ audio: !0 }), n = new MediaRecorder(t);
|
|
@@ -375,7 +714,7 @@ function D(e = 300, t) {
|
|
|
375
714
|
r = null;
|
|
376
715
|
}
|
|
377
716
|
let a = r ? new Uint8Array(r.fftSize) : null;
|
|
378
|
-
|
|
717
|
+
p.current = n, n.start(), o(0), i(!0);
|
|
379
718
|
let s = Date.now(), l = !1;
|
|
380
719
|
_.current = window.setInterval(() => {
|
|
381
720
|
let t = Math.floor((Date.now() - s) / 1e3);
|
|
@@ -396,7 +735,7 @@ function D(e = 300, t) {
|
|
|
396
735
|
S,
|
|
397
736
|
e
|
|
398
737
|
]), w = u(() => new Promise((e) => {
|
|
399
|
-
let t =
|
|
738
|
+
let t = p.current;
|
|
400
739
|
if (!t || t.state === "inactive") return e(null);
|
|
401
740
|
y.current = e, t.stop();
|
|
402
741
|
}), []), T = u(() => {
|
|
@@ -413,71 +752,84 @@ function D(e = 300, t) {
|
|
|
413
752
|
cancel: T
|
|
414
753
|
};
|
|
415
754
|
}
|
|
416
|
-
function
|
|
755
|
+
function ae(e) {
|
|
417
756
|
return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
|
|
418
757
|
}
|
|
419
758
|
//#endregion
|
|
420
759
|
//#region src/chat/Chat.tsx
|
|
421
|
-
function
|
|
422
|
-
let r = a(), i = e(), [o, u] =
|
|
423
|
-
d(() =>
|
|
424
|
-
|
|
760
|
+
function K(n) {
|
|
761
|
+
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, ee] = h(!1), [M, N] = h(null), P = m(n.loadAttachment);
|
|
762
|
+
d(() => {
|
|
763
|
+
P.current = n.loadAttachment;
|
|
764
|
+
});
|
|
765
|
+
let F = !!n.loadAttachment, I = p(() => F ? (e) => P.current ? P.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [F]), L = m(!1), R = m(null), z = m(null), B = m(null), V = n.voiceMaxSeconds ?? 300, H = ie(V, () => void ge()), { messages: U, busy: W = !1 } = n, G = n.onPendingChange;
|
|
766
|
+
d(() => G?.(g), [g, G]);
|
|
767
|
+
let K = U[0]?.id, q = U[U.length - 1], J = q?.id, Y = q?.text.length, le = q?.steps?.length, X = m({ height: 0 });
|
|
425
768
|
f(() => {
|
|
426
|
-
let e =
|
|
769
|
+
let e = R.current;
|
|
427
770
|
if (!e) return;
|
|
428
|
-
let t =
|
|
429
|
-
e.scrollTop = t.first !== void 0 &&
|
|
430
|
-
first:
|
|
431
|
-
last:
|
|
771
|
+
let t = X.current;
|
|
772
|
+
e.scrollTop = t.first !== void 0 && K !== t.first && J === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, X.current = {
|
|
773
|
+
first: K,
|
|
774
|
+
last: J,
|
|
432
775
|
height: e.scrollHeight
|
|
433
776
|
};
|
|
434
777
|
}, [
|
|
435
|
-
|
|
436
|
-
W,
|
|
778
|
+
U.length,
|
|
437
779
|
K,
|
|
438
|
-
|
|
439
|
-
|
|
780
|
+
J,
|
|
781
|
+
Y,
|
|
782
|
+
le
|
|
440
783
|
]);
|
|
441
|
-
let
|
|
442
|
-
u(""),
|
|
443
|
-
},
|
|
784
|
+
let Z = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Q = Z === null ? [] : _(n.commands ?? [], Z), $ = Z !== null && !D, ue = () => {
|
|
785
|
+
u(""), y([]), w(null), A(null), L.current = !1;
|
|
786
|
+
}, de = async (e, t) => {
|
|
444
787
|
if (n.onCommand) try {
|
|
445
|
-
await n.onCommand(e, t),
|
|
788
|
+
await n.onCommand(e, t), ue();
|
|
446
789
|
} catch {}
|
|
447
|
-
},
|
|
790
|
+
}, fe = async (e, t = !1) => {
|
|
448
791
|
let r = e.trim();
|
|
449
|
-
if (!(!r &&
|
|
450
|
-
if (!t && !
|
|
792
|
+
if (!(!r && g.length === 0 && !C || W || n.readOnly)) {
|
|
793
|
+
if (!t && !C && n.commands && r.startsWith("/")) {
|
|
451
794
|
let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
|
|
452
|
-
if (i) return
|
|
795
|
+
if (i) return de(i.name, t.join(" "));
|
|
453
796
|
if (e && !r.includes("\n")) {
|
|
454
|
-
|
|
797
|
+
A("/" + e);
|
|
455
798
|
return;
|
|
456
799
|
}
|
|
457
800
|
}
|
|
458
801
|
try {
|
|
459
|
-
await n.onSend(r,
|
|
802
|
+
await n.onSend(r, g.map((e) => e.id), L.current, C ?? void 0), ue();
|
|
460
803
|
} catch {}
|
|
461
804
|
}
|
|
462
|
-
},
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
if (
|
|
805
|
+
}, pe = (e) => {
|
|
806
|
+
E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : de(e.name, ""), B.current?.focus();
|
|
807
|
+
}, me = (e) => {
|
|
808
|
+
if ($ && Q.length > 0) {
|
|
466
809
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
467
810
|
e.preventDefault();
|
|
468
811
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
469
|
-
|
|
812
|
+
E((e) => (e + t + Q.length) % Q.length);
|
|
470
813
|
return;
|
|
471
814
|
}
|
|
472
815
|
if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
|
|
473
|
-
e.preventDefault(),
|
|
816
|
+
e.preventDefault(), pe(Q[Math.min(T, Q.length - 1)]);
|
|
474
817
|
return;
|
|
475
818
|
}
|
|
476
819
|
}
|
|
477
|
-
|
|
478
|
-
}
|
|
820
|
+
$ && e.key === "Escape" ? (e.preventDefault(), O(!0)) : e.key === "Backspace" && C && o === "" ? w(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && !se() && (e.preventDefault(), fe(o));
|
|
821
|
+
};
|
|
822
|
+
f(() => ce(B.current), [o]), d(() => {
|
|
823
|
+
let e = B.current;
|
|
824
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
825
|
+
let t = e.clientWidth, n = new ResizeObserver(() => {
|
|
826
|
+
e.clientWidth !== t && (t = e.clientWidth, ce(e));
|
|
827
|
+
});
|
|
828
|
+
return n.observe(e), () => n.disconnect();
|
|
829
|
+
}, [H.recording]);
|
|
830
|
+
let he = async (e) => {
|
|
479
831
|
if (e?.length && n.onUpload) {
|
|
480
|
-
|
|
832
|
+
S(!0);
|
|
481
833
|
for (let t of Array.from(e)) {
|
|
482
834
|
if (n.upload && t.size > n.upload.maxBytes) {
|
|
483
835
|
i({
|
|
@@ -488,14 +840,14 @@ function k(n) {
|
|
|
488
840
|
continue;
|
|
489
841
|
}
|
|
490
842
|
let e = await n.onUpload(t).catch(() => null);
|
|
491
|
-
e &&
|
|
843
|
+
e && y((t) => [...t, e]);
|
|
492
844
|
}
|
|
493
|
-
|
|
845
|
+
S(!1), z.current && (z.current.value = "");
|
|
494
846
|
}
|
|
495
847
|
};
|
|
496
|
-
async function
|
|
497
|
-
let e = await
|
|
498
|
-
e && n.onTranscribe && await
|
|
848
|
+
async function ge() {
|
|
849
|
+
let e = await H.stop();
|
|
850
|
+
e && n.onTranscribe && await re(e, n.onTranscribe, {
|
|
499
851
|
busy: ee,
|
|
500
852
|
empty: () => i({
|
|
501
853
|
kind: "error",
|
|
@@ -511,13 +863,13 @@ function k(n) {
|
|
|
511
863
|
}]
|
|
512
864
|
}),
|
|
513
865
|
text: (e) => {
|
|
514
|
-
|
|
866
|
+
L.current = !0, u((t) => t.trim() ? t.trimEnd() + " " + e : e), B.current?.focus();
|
|
515
867
|
}
|
|
516
868
|
});
|
|
517
869
|
}
|
|
518
|
-
let
|
|
519
|
-
e.key === "Escape" &&
|
|
520
|
-
},
|
|
870
|
+
let _e = (e) => {
|
|
871
|
+
e.key === "Escape" && H.recording && (e.preventDefault(), H.cancel());
|
|
872
|
+
}, ve = C ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), ye = V - H.seconds;
|
|
521
873
|
return /* @__PURE__ */ l("section", {
|
|
522
874
|
className: "nb-chat",
|
|
523
875
|
"aria-label": r("chat.title"),
|
|
@@ -525,7 +877,7 @@ function k(n) {
|
|
|
525
877
|
n.header,
|
|
526
878
|
/* @__PURE__ */ l("div", {
|
|
527
879
|
className: "msgs",
|
|
528
|
-
ref:
|
|
880
|
+
ref: R,
|
|
529
881
|
"aria-live": "polite",
|
|
530
882
|
children: [
|
|
531
883
|
n.hasOlder && n.onLoadOlder && /* @__PURE__ */ c("button", {
|
|
@@ -539,7 +891,7 @@ function k(n) {
|
|
|
539
891
|
className: "err-text",
|
|
540
892
|
children: n.historyError
|
|
541
893
|
}),
|
|
542
|
-
|
|
894
|
+
U.length === 0 && !n.loading && !n.historyError && /* @__PURE__ */ l("div", {
|
|
543
895
|
className: "empty",
|
|
544
896
|
children: [
|
|
545
897
|
/* @__PURE__ */ c("div", {
|
|
@@ -550,10 +902,12 @@ function k(n) {
|
|
|
550
902
|
n.emptyHint
|
|
551
903
|
]
|
|
552
904
|
}),
|
|
553
|
-
|
|
905
|
+
U.map((e) => /* @__PURE__ */ c(ne, {
|
|
554
906
|
m: e,
|
|
555
|
-
busy:
|
|
556
|
-
onRetry: n.onRetry && (() => n.onRetry?.(e.id))
|
|
907
|
+
busy: W,
|
|
908
|
+
onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
|
|
909
|
+
loadAttachment: I,
|
|
910
|
+
onOpenAttachment: N
|
|
557
911
|
}, e.id)),
|
|
558
912
|
n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ l("div", {
|
|
559
913
|
className: "confirm",
|
|
@@ -595,16 +949,16 @@ function k(n) {
|
|
|
595
949
|
}) : /* @__PURE__ */ l("div", {
|
|
596
950
|
className: "composer-wrap",
|
|
597
951
|
children: [
|
|
598
|
-
|
|
599
|
-
items:
|
|
600
|
-
active: Math.min(T, Math.max(
|
|
601
|
-
onPick:
|
|
602
|
-
onHover:
|
|
952
|
+
$ && /* @__PURE__ */ c(v, {
|
|
953
|
+
items: Q,
|
|
954
|
+
active: Math.min(T, Math.max(Q.length - 1, 0)),
|
|
955
|
+
onPick: pe,
|
|
956
|
+
onHover: E
|
|
603
957
|
}),
|
|
604
958
|
n.aboveComposer,
|
|
605
|
-
|
|
959
|
+
g.length > 0 && /* @__PURE__ */ c("div", {
|
|
606
960
|
className: "pending-files",
|
|
607
|
-
children:
|
|
961
|
+
children: g.map((e) => /* @__PURE__ */ l("span", {
|
|
608
962
|
className: "chip",
|
|
609
963
|
children: [
|
|
610
964
|
/* @__PURE__ */ c(t, {
|
|
@@ -619,7 +973,7 @@ function k(n) {
|
|
|
619
973
|
height: 18
|
|
620
974
|
},
|
|
621
975
|
"aria-label": r("remove"),
|
|
622
|
-
onClick: () =>
|
|
976
|
+
onClick: () => y((t) => t.filter((t) => t.id !== e.id)),
|
|
623
977
|
children: /* @__PURE__ */ c(t, {
|
|
624
978
|
name: "x",
|
|
625
979
|
size: 12
|
|
@@ -628,35 +982,35 @@ function k(n) {
|
|
|
628
982
|
]
|
|
629
983
|
}, e.id))
|
|
630
984
|
}),
|
|
631
|
-
|
|
985
|
+
k && /* @__PURE__ */ l("div", {
|
|
632
986
|
className: "cmd-unknown",
|
|
633
987
|
role: "status",
|
|
634
|
-
children: [r("chat.unknownCommand", { name:
|
|
988
|
+
children: [r("chat.unknownCommand", { name: k }), /* @__PURE__ */ c("button", {
|
|
635
989
|
type: "button",
|
|
636
990
|
className: "textbtn",
|
|
637
|
-
onClick: () => void
|
|
991
|
+
onClick: () => void fe(o, !0),
|
|
638
992
|
children: r("chat.sendAsText")
|
|
639
993
|
})]
|
|
640
994
|
}),
|
|
641
995
|
/* @__PURE__ */ l("div", {
|
|
642
996
|
className: "composer",
|
|
643
997
|
children: [
|
|
644
|
-
n.onUpload && !
|
|
998
|
+
n.onUpload && !H.recording && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
|
|
645
999
|
className: "iconbtn",
|
|
646
1000
|
"aria-label": r("chat.attach"),
|
|
647
1001
|
disabled: b,
|
|
648
|
-
onClick: () =>
|
|
1002
|
+
onClick: () => z.current?.click(),
|
|
649
1003
|
children: /* @__PURE__ */ c(t, { name: "clip" })
|
|
650
1004
|
}), /* @__PURE__ */ c("input", {
|
|
651
|
-
ref:
|
|
1005
|
+
ref: z,
|
|
652
1006
|
type: "file",
|
|
653
1007
|
multiple: !0,
|
|
654
1008
|
hidden: !0,
|
|
655
1009
|
accept: n.upload?.accept,
|
|
656
|
-
onChange: (e) =>
|
|
1010
|
+
onChange: (e) => he(e.target.files)
|
|
657
1011
|
})] }),
|
|
658
|
-
|
|
659
|
-
className: `recbar${
|
|
1012
|
+
H.recording ? /* @__PURE__ */ l("div", {
|
|
1013
|
+
className: `recbar${ye <= 15 ? " ending" : ""}`,
|
|
660
1014
|
role: "status",
|
|
661
1015
|
"aria-label": r("chat.voice.recordingNow"),
|
|
662
1016
|
children: [
|
|
@@ -667,40 +1021,41 @@ function k(n) {
|
|
|
667
1021
|
/* @__PURE__ */ l("span", {
|
|
668
1022
|
className: "tm",
|
|
669
1023
|
children: [
|
|
670
|
-
|
|
1024
|
+
ae(H.seconds),
|
|
671
1025
|
" / ",
|
|
672
|
-
|
|
1026
|
+
ae(V)
|
|
673
1027
|
]
|
|
674
1028
|
}),
|
|
675
1029
|
/* @__PURE__ */ c("span", {
|
|
676
1030
|
className: "lvl",
|
|
677
1031
|
"aria-hidden": "true",
|
|
678
|
-
children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04,
|
|
1032
|
+
children: /* @__PURE__ */ c("i", { style: { transform: `scaleX(${Math.max(.04, H.level)})` } })
|
|
679
1033
|
}),
|
|
680
1034
|
/* @__PURE__ */ c("button", {
|
|
681
1035
|
type: "button",
|
|
682
1036
|
className: "btn ghost sm",
|
|
683
|
-
onClick:
|
|
1037
|
+
onClick: H.cancel,
|
|
684
1038
|
children: r("cancel")
|
|
685
1039
|
}),
|
|
686
1040
|
/* @__PURE__ */ c("button", {
|
|
687
1041
|
type: "button",
|
|
688
1042
|
className: "btn primary sm",
|
|
689
|
-
onKeyDown:
|
|
690
|
-
onClick: () => void
|
|
1043
|
+
onKeyDown: _e,
|
|
1044
|
+
onClick: () => void ge(),
|
|
691
1045
|
children: r("chat.voice.done")
|
|
692
1046
|
})
|
|
693
1047
|
]
|
|
694
1048
|
}) : /* @__PURE__ */ l("div", {
|
|
695
|
-
className: `field${
|
|
696
|
-
|
|
1049
|
+
className: `field${C ? " with-skill" : ""}${j ? " recognizing" : ""}`,
|
|
1050
|
+
"aria-busy": j || void 0,
|
|
1051
|
+
children: [C && /* @__PURE__ */ l("span", {
|
|
697
1052
|
className: "chip skill-chip",
|
|
698
1053
|
children: [
|
|
699
1054
|
/* @__PURE__ */ c(t, {
|
|
700
1055
|
name: "spark",
|
|
701
1056
|
size: 12
|
|
702
1057
|
}),
|
|
703
|
-
|
|
1058
|
+
C,
|
|
704
1059
|
/* @__PURE__ */ c("button", {
|
|
705
1060
|
className: "iconbtn",
|
|
706
1061
|
style: {
|
|
@@ -708,7 +1063,7 @@ function k(n) {
|
|
|
708
1063
|
height: 18
|
|
709
1064
|
},
|
|
710
1065
|
"aria-label": r("remove"),
|
|
711
|
-
onClick: () =>
|
|
1066
|
+
onClick: () => w(null),
|
|
712
1067
|
children: /* @__PURE__ */ c(t, {
|
|
713
1068
|
name: "x",
|
|
714
1069
|
size: 12
|
|
@@ -716,34 +1071,31 @@ function k(n) {
|
|
|
716
1071
|
})
|
|
717
1072
|
]
|
|
718
1073
|
}), /* @__PURE__ */ c("textarea", {
|
|
719
|
-
ref:
|
|
1074
|
+
ref: B,
|
|
720
1075
|
rows: 1,
|
|
721
1076
|
value: o,
|
|
722
|
-
placeholder:
|
|
723
|
-
"aria-label":
|
|
724
|
-
disabled:
|
|
725
|
-
"aria-expanded":
|
|
1077
|
+
placeholder: j ? r("chat.voice.recognizing") : ve,
|
|
1078
|
+
"aria-label": ve,
|
|
1079
|
+
disabled: j,
|
|
1080
|
+
"aria-expanded": $,
|
|
726
1081
|
"aria-autocomplete": n.commands ? "list" : void 0,
|
|
727
1082
|
onChange: (e) => {
|
|
728
|
-
u(e.target.value),
|
|
1083
|
+
u(e.target.value), O(!1), E(0), A(null);
|
|
729
1084
|
},
|
|
730
|
-
onKeyDown:
|
|
1085
|
+
onKeyDown: me
|
|
731
1086
|
})]
|
|
732
1087
|
}),
|
|
733
|
-
n.context && !
|
|
1088
|
+
n.context && !H.recording && /* @__PURE__ */ c(x, {
|
|
734
1089
|
context: n.context,
|
|
735
1090
|
onCompact: n.onCompact,
|
|
736
1091
|
onReset: n.onReset
|
|
737
1092
|
}),
|
|
738
|
-
n.onTranscribe && !
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
title: B.supported ? r("chat.voice.start") : r("chat.voice.unsupported"),
|
|
743
|
-
onClick: () => void B.start(),
|
|
744
|
-
children: /* @__PURE__ */ c(t, { name: "mic" })
|
|
1093
|
+
n.onTranscribe && !H.recording && /* @__PURE__ */ c(oe, {
|
|
1094
|
+
supported: H.supported,
|
|
1095
|
+
recognizing: j,
|
|
1096
|
+
onStart: () => void H.start()
|
|
745
1097
|
}),
|
|
746
|
-
!
|
|
1098
|
+
!H.recording && (n.onCancel && W ? /* @__PURE__ */ c("button", {
|
|
747
1099
|
className: "iconbtn fill",
|
|
748
1100
|
"aria-label": r("chat.stop"),
|
|
749
1101
|
onClick: n.onCancel,
|
|
@@ -751,26 +1103,60 @@ function k(n) {
|
|
|
751
1103
|
}) : /* @__PURE__ */ c("button", {
|
|
752
1104
|
className: "iconbtn fill",
|
|
753
1105
|
"aria-label": r("chat.send"),
|
|
754
|
-
disabled: !o.trim() &&
|
|
755
|
-
onClick: () =>
|
|
1106
|
+
disabled: !o.trim() && g.length === 0 && !C || W || j,
|
|
1107
|
+
onClick: () => fe(o),
|
|
756
1108
|
children: /* @__PURE__ */ c(t, { name: "send" })
|
|
757
1109
|
}))
|
|
758
1110
|
]
|
|
759
1111
|
}),
|
|
760
|
-
|
|
1112
|
+
H.error && /* @__PURE__ */ c("div", {
|
|
761
1113
|
className: "err-text",
|
|
762
1114
|
style: { padding: "0 12px 8px" },
|
|
763
1115
|
children: r("chat.voice.micDenied")
|
|
764
1116
|
})
|
|
765
1117
|
]
|
|
1118
|
+
}),
|
|
1119
|
+
M && I && /* @__PURE__ */ c(te, {
|
|
1120
|
+
a: M,
|
|
1121
|
+
load: I,
|
|
1122
|
+
onClose: () => N(null)
|
|
766
1123
|
})
|
|
767
1124
|
]
|
|
768
1125
|
});
|
|
769
1126
|
}
|
|
1127
|
+
function oe({ supported: e, recognizing: n, onStart: r }) {
|
|
1128
|
+
let i = a();
|
|
1129
|
+
return n ? /* @__PURE__ */ l("span", {
|
|
1130
|
+
className: "voicewait",
|
|
1131
|
+
role: "status",
|
|
1132
|
+
"aria-label": i("chat.voice.recognizing"),
|
|
1133
|
+
title: i("chat.voice.recognizing"),
|
|
1134
|
+
children: [
|
|
1135
|
+
/* @__PURE__ */ c("i", {}),
|
|
1136
|
+
/* @__PURE__ */ c("i", {}),
|
|
1137
|
+
/* @__PURE__ */ c("i", {}),
|
|
1138
|
+
/* @__PURE__ */ c("i", {}),
|
|
1139
|
+
/* @__PURE__ */ c("i", {})
|
|
1140
|
+
]
|
|
1141
|
+
}) : /* @__PURE__ */ c("button", {
|
|
1142
|
+
className: "iconbtn",
|
|
1143
|
+
disabled: !e,
|
|
1144
|
+
"aria-label": i("chat.voice.start"),
|
|
1145
|
+
title: i(e ? "chat.voice.start" : "chat.voice.unsupported"),
|
|
1146
|
+
onClick: r,
|
|
1147
|
+
children: /* @__PURE__ */ c(t, { name: "mic" })
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
function se() {
|
|
1151
|
+
return typeof window < "u" && !!window.matchMedia?.("(hover: none) and (pointer: coarse)").matches;
|
|
1152
|
+
}
|
|
1153
|
+
function ce(e) {
|
|
1154
|
+
e && (e.style.height = "auto", e.style.height = `${e.scrollHeight + e.offsetHeight - e.clientHeight}px`);
|
|
1155
|
+
}
|
|
770
1156
|
//#endregion
|
|
771
1157
|
//#region src/chat/ConversationList.tsx
|
|
772
|
-
function
|
|
773
|
-
let f = a(), [p,
|
|
1158
|
+
function q({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
|
|
1159
|
+
let f = a(), [p, m] = h(!1);
|
|
774
1160
|
d(() => {
|
|
775
1161
|
if (!r) return;
|
|
776
1162
|
let e = (e) => e.key === "Escape" && o();
|
|
@@ -811,7 +1197,7 @@ function A({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
|
|
|
811
1197
|
width: "100%",
|
|
812
1198
|
justifyContent: "center"
|
|
813
1199
|
},
|
|
814
|
-
onClick: () =>
|
|
1200
|
+
onClick: () => m(!0),
|
|
815
1201
|
children: [/* @__PURE__ */ c(t, {
|
|
816
1202
|
name: "plus",
|
|
817
1203
|
size: 15
|
|
@@ -845,20 +1231,20 @@ function A({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
|
|
|
845
1231
|
"aria-label": f("close"),
|
|
846
1232
|
onClick: o
|
|
847
1233
|
}),
|
|
848
|
-
p && u && /* @__PURE__ */ c(
|
|
849
|
-
onClose: () =>
|
|
1234
|
+
p && u && /* @__PURE__ */ c(Y, {
|
|
1235
|
+
onClose: () => m(!1),
|
|
850
1236
|
onCreate: u
|
|
851
1237
|
})
|
|
852
1238
|
] });
|
|
853
1239
|
}
|
|
854
|
-
function
|
|
1240
|
+
function J({ narrow: e, children: t }) {
|
|
855
1241
|
return /* @__PURE__ */ c("div", {
|
|
856
1242
|
className: `nb-app${e ? " narrow" : ""}`,
|
|
857
1243
|
children: t
|
|
858
1244
|
});
|
|
859
1245
|
}
|
|
860
|
-
function
|
|
861
|
-
let r = a(), [i, o] =
|
|
1246
|
+
function Y({ onClose: e, onCreate: t }) {
|
|
1247
|
+
let r = a(), [i, o] = h(""), [u, d] = h(!1), [f, p] = h(null), m = async () => {
|
|
862
1248
|
if (i.trim() && !u) {
|
|
863
1249
|
d(!0), p(null);
|
|
864
1250
|
try {
|
|
@@ -878,7 +1264,7 @@ function M({ onClose: e, onCreate: t }) {
|
|
|
878
1264
|
}), /* @__PURE__ */ c("button", {
|
|
879
1265
|
className: "btn primary",
|
|
880
1266
|
disabled: !i.trim() || u,
|
|
881
|
-
onClick:
|
|
1267
|
+
onClick: m,
|
|
882
1268
|
children: r("create")
|
|
883
1269
|
})] }),
|
|
884
1270
|
children: [/* @__PURE__ */ l("div", {
|
|
@@ -894,7 +1280,7 @@ function M({ onClose: e, onCreate: t }) {
|
|
|
894
1280
|
value: i,
|
|
895
1281
|
maxLength: 120,
|
|
896
1282
|
onChange: (e) => o(e.target.value),
|
|
897
|
-
onKeyDown: (e) => e.key === "Enter" &&
|
|
1283
|
+
onKeyDown: (e) => e.key === "Enter" && m()
|
|
898
1284
|
}),
|
|
899
1285
|
/* @__PURE__ */ c("div", {
|
|
900
1286
|
className: "hint",
|
|
@@ -909,7 +1295,7 @@ function M({ onClose: e, onCreate: t }) {
|
|
|
909
1295
|
}
|
|
910
1296
|
//#endregion
|
|
911
1297
|
//#region src/chat/AgentMenu.tsx
|
|
912
|
-
function
|
|
1298
|
+
function le({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
|
|
913
1299
|
return /* @__PURE__ */ c("button", {
|
|
914
1300
|
type: "button",
|
|
915
1301
|
className: `agentbtn${a ? " s" : ""}`,
|
|
@@ -925,8 +1311,8 @@ function N({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, on
|
|
|
925
1311
|
})
|
|
926
1312
|
});
|
|
927
1313
|
}
|
|
928
|
-
function
|
|
929
|
-
let v = a(), [y, b] =
|
|
1314
|
+
function X({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: m, onPick: g, onClose: _ }) {
|
|
1315
|
+
let v = a(), [y, b] = h(n), x = i(!0, _);
|
|
930
1316
|
return /* @__PURE__ */ l("div", {
|
|
931
1317
|
className: `agentmenu${f ? " narrow" : ""}`,
|
|
932
1318
|
ref: x,
|
|
@@ -946,7 +1332,7 @@ function P({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
946
1332
|
onChange: (e) => b(e.target.value),
|
|
947
1333
|
onBlur: () => {
|
|
948
1334
|
let e = y.trim();
|
|
949
|
-
e && e !== n &&
|
|
1335
|
+
e && e !== n && m(e);
|
|
950
1336
|
},
|
|
951
1337
|
onKeyDown: (e) => e.key === "Enter" && e.target.blur()
|
|
952
1338
|
}),
|
|
@@ -1036,6 +1422,6 @@ function P({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
1036
1422
|
});
|
|
1037
1423
|
}
|
|
1038
1424
|
//#endregion
|
|
1039
|
-
export {
|
|
1425
|
+
export { le as AgentButton, X as AgentMenu, B as AttachmentList, te as AttachmentPreview, K as Chat, J as ChatLayout, v as CommandPalette, x as ContextMeter, q as ConversationList, ne as MessageView, Y as NewTopicModal, oe as VoiceButton, k as fileSize, I as parseTable, D as previewIcon, T as previewKind, b as tokens, ie as useRecorder };
|
|
1040
1426
|
|
|
1041
1427
|
//# sourceMappingURL=chat.js.map
|