@green-on-grey/ui-kit 1.8.0 → 1.10.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 +29 -8
- package/dist/chat/MessageView.d.ts +6 -2
- package/dist/chat/index.d.ts +3 -3
- package/dist/chat/types.d.ts +42 -0
- package/dist/chat.js +728 -515
- package/dist/chat.js.map +1 -1
- package/dist/index.js +32 -56
- package/dist/index.js.map +1 -1
- package/dist/locales/index.d.ts +95 -0
- package/dist/locales.js +100 -5
- package/dist/locales.js.map +1 -1
- package/dist/manifest.json +13 -1
- package/dist/styles.css +20 -0
- package/dist/{ui-DvmjcG-d.js → ui-sV5t0cp1.js} +38 -14
- package/dist/ui-sV5t0cp1.js.map +1 -0
- package/package.json +1 -1
- package/dist/ui-DvmjcG-d.js.map +0 -1
package/dist/chat.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { c as e,
|
|
2
|
-
import { n as
|
|
3
|
-
import { Fragment as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { useTranslation as
|
|
1
|
+
import { c as e, f as t, i as n, l as r, s as i, u as a } from "./ui-sV5t0cp1.js";
|
|
2
|
+
import { n as o, t as s } from "./i18n-BJ8rsBp6.js";
|
|
3
|
+
import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
4
|
+
import { useCallback as d, useEffect as f, useLayoutEffect as p, useMemo as m, useRef as h, useState as g } from "react";
|
|
5
|
+
import { useTranslation as _ } from "react-i18next";
|
|
6
6
|
//#region src/chat/CommandPalette.tsx
|
|
7
|
-
function
|
|
7
|
+
function v(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
|
|
12
|
-
let
|
|
11
|
+
function y({ items: e, active: n, onPick: r, onHover: i }) {
|
|
12
|
+
let a = o(), s = e.filter((e) => e.kind === "command"), c = e.filter((e) => e.kind === "skill"), d = (e, a) => /* @__PURE__ */ u("button", {
|
|
13
13
|
type: "button",
|
|
14
14
|
role: "option",
|
|
15
15
|
"aria-selected": a === n,
|
|
@@ -19,154 +19,154 @@ function v({ items: e, active: n, onPick: r, onHover: i }) {
|
|
|
19
19
|
},
|
|
20
20
|
onMouseEnter: () => i(a),
|
|
21
21
|
children: [
|
|
22
|
-
e.kind === "skill" ? /* @__PURE__ */
|
|
22
|
+
e.kind === "skill" ? /* @__PURE__ */ l(t, {
|
|
23
23
|
name: "spark",
|
|
24
24
|
size: 14
|
|
25
|
-
}) : /* @__PURE__ */
|
|
25
|
+
}) : /* @__PURE__ */ l("span", {
|
|
26
26
|
className: "slash",
|
|
27
27
|
"aria-hidden": "true"
|
|
28
28
|
}),
|
|
29
|
-
/* @__PURE__ */
|
|
29
|
+
/* @__PURE__ */ l("span", {
|
|
30
30
|
className: "nm",
|
|
31
31
|
children: e.kind === "command" ? "/" + e.name : e.name
|
|
32
32
|
}),
|
|
33
|
-
/* @__PURE__ */
|
|
33
|
+
/* @__PURE__ */ l("span", {
|
|
34
34
|
className: "ds",
|
|
35
35
|
children: e.description
|
|
36
36
|
}),
|
|
37
|
-
e.source && /* @__PURE__ */
|
|
37
|
+
e.source && /* @__PURE__ */ l("span", {
|
|
38
38
|
className: "src",
|
|
39
39
|
children: e.source
|
|
40
40
|
})
|
|
41
41
|
]
|
|
42
42
|
}, e.kind + e.name);
|
|
43
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ u("div", {
|
|
44
44
|
className: "palette",
|
|
45
45
|
role: "listbox",
|
|
46
|
-
"aria-label":
|
|
46
|
+
"aria-label": a("chat.palette.title"),
|
|
47
47
|
children: [
|
|
48
|
-
e.length === 0 && /* @__PURE__ */
|
|
48
|
+
e.length === 0 && /* @__PURE__ */ l("div", {
|
|
49
49
|
className: "palette-empty",
|
|
50
|
-
children:
|
|
50
|
+
children: a("chat.palette.empty")
|
|
51
51
|
}),
|
|
52
|
-
s.length > 0 && /* @__PURE__ */
|
|
52
|
+
s.length > 0 && /* @__PURE__ */ l("div", {
|
|
53
53
|
className: "palette-h",
|
|
54
|
-
children:
|
|
54
|
+
children: a("chat.palette.commands")
|
|
55
55
|
}),
|
|
56
56
|
s.map((t) => d(t, e.indexOf(t))),
|
|
57
|
-
e.length > 0 && /* @__PURE__ */
|
|
57
|
+
e.length > 0 && /* @__PURE__ */ l("div", {
|
|
58
58
|
className: "palette-h",
|
|
59
|
-
children:
|
|
59
|
+
children: a("chat.palette.skills")
|
|
60
60
|
}),
|
|
61
|
-
|
|
61
|
+
c.length === 0 && e.length > 0 && /* @__PURE__ */ l("div", {
|
|
62
62
|
className: "palette-empty",
|
|
63
|
-
children:
|
|
63
|
+
children: a("chat.palette.noSkills")
|
|
64
64
|
}),
|
|
65
|
-
|
|
65
|
+
c.map((t) => d(t, e.indexOf(t)))
|
|
66
66
|
]
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
//#endregion
|
|
70
70
|
//#region src/chat/intl.ts
|
|
71
|
-
var
|
|
71
|
+
var b = (e) => e === "zh" ? "zh-CN" : e;
|
|
72
72
|
//#endregion
|
|
73
73
|
//#region src/chat/ContextMeter.tsx
|
|
74
|
-
function
|
|
75
|
-
return new Intl.NumberFormat(
|
|
74
|
+
function x(e, t) {
|
|
75
|
+
return new Intl.NumberFormat(b(t), {
|
|
76
76
|
notation: "compact",
|
|
77
77
|
maximumFractionDigits: 1
|
|
78
78
|
}).format(e);
|
|
79
79
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
82
|
-
return /* @__PURE__ */
|
|
80
|
+
function S({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
|
|
81
|
+
let a = o(), { i18n: d } = _(s), [f, p] = g(!1), m = i(f, () => p(!1)), h = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, v = Math.round(h * 100), y = h >= .9 ? "full" : h >= .7 ? "warn" : "", b = 2 * Math.PI * 7, S = d.language;
|
|
82
|
+
return /* @__PURE__ */ u("div", {
|
|
83
83
|
className: "ctxmeter",
|
|
84
84
|
ref: m,
|
|
85
|
-
children: [/* @__PURE__ */
|
|
85
|
+
children: [/* @__PURE__ */ l("button", {
|
|
86
86
|
type: "button",
|
|
87
87
|
className: `ctxring ${y}`,
|
|
88
88
|
"aria-expanded": f,
|
|
89
89
|
onClick: () => p((e) => !e),
|
|
90
|
-
"aria-label":
|
|
91
|
-
used:
|
|
92
|
-
total:
|
|
90
|
+
"aria-label": a("chat.context.meter", {
|
|
91
|
+
used: x(e.tokens, S),
|
|
92
|
+
total: x(e.window, S),
|
|
93
93
|
pct: v
|
|
94
94
|
}),
|
|
95
|
-
title:
|
|
96
|
-
used:
|
|
97
|
-
total:
|
|
95
|
+
title: a("chat.context.meter", {
|
|
96
|
+
used: x(e.tokens, S),
|
|
97
|
+
total: x(e.window, S),
|
|
98
98
|
pct: v
|
|
99
99
|
}),
|
|
100
|
-
children: /* @__PURE__ */
|
|
100
|
+
children: /* @__PURE__ */ u("svg", {
|
|
101
101
|
viewBox: "0 0 18 18",
|
|
102
102
|
"aria-hidden": "true",
|
|
103
|
-
children: [/* @__PURE__ */
|
|
103
|
+
children: [/* @__PURE__ */ l("circle", {
|
|
104
104
|
className: "bg",
|
|
105
105
|
cx: "9",
|
|
106
106
|
cy: "9",
|
|
107
107
|
r: 7
|
|
108
|
-
}), /* @__PURE__ */
|
|
108
|
+
}), /* @__PURE__ */ l("circle", {
|
|
109
109
|
className: "fg",
|
|
110
110
|
cx: "9",
|
|
111
111
|
cy: "9",
|
|
112
112
|
r: 7,
|
|
113
|
-
strokeDasharray: `${(
|
|
113
|
+
strokeDasharray: `${(b * h).toFixed(1)} ${b.toFixed(1)}`,
|
|
114
114
|
transform: "rotate(-90 9 9)"
|
|
115
115
|
})]
|
|
116
116
|
})
|
|
117
|
-
}), f && /* @__PURE__ */
|
|
117
|
+
}), f && /* @__PURE__ */ u("div", {
|
|
118
118
|
className: "ctxtip",
|
|
119
119
|
role: "dialog",
|
|
120
120
|
children: [
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
-
used:
|
|
123
|
-
total:
|
|
121
|
+
/* @__PURE__ */ l("div", { children: a("chat.context.meter", {
|
|
122
|
+
used: x(e.tokens, S),
|
|
123
|
+
total: x(e.window, S),
|
|
124
124
|
pct: v
|
|
125
125
|
}) }),
|
|
126
|
-
y === "full" && /* @__PURE__ */
|
|
126
|
+
y === "full" && /* @__PURE__ */ l("div", {
|
|
127
127
|
className: "small muted",
|
|
128
128
|
style: { marginTop: 4 },
|
|
129
|
-
children:
|
|
129
|
+
children: a("chat.context.full")
|
|
130
130
|
}),
|
|
131
|
-
y === "full" && (t || n) && /* @__PURE__ */
|
|
131
|
+
y === "full" && (t || n) && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
|
|
132
132
|
className: "row",
|
|
133
133
|
style: {
|
|
134
134
|
marginTop: 8,
|
|
135
135
|
gap: 6
|
|
136
136
|
},
|
|
137
|
-
children: [t && /* @__PURE__ */
|
|
137
|
+
children: [t && /* @__PURE__ */ l(C, {
|
|
138
138
|
icon: "compress",
|
|
139
|
-
label:
|
|
139
|
+
label: a("chat.context.compact"),
|
|
140
140
|
busy: r,
|
|
141
141
|
run: () => {
|
|
142
142
|
p(!1), t();
|
|
143
143
|
}
|
|
144
|
-
}), n && /* @__PURE__ */
|
|
144
|
+
}), n && /* @__PURE__ */ l(C, {
|
|
145
145
|
icon: "reset",
|
|
146
|
-
label:
|
|
146
|
+
label: a("chat.context.reset"),
|
|
147
147
|
busy: r,
|
|
148
148
|
run: () => {
|
|
149
149
|
p(!1), n();
|
|
150
150
|
}
|
|
151
151
|
})]
|
|
152
|
-
}), r && /* @__PURE__ */
|
|
152
|
+
}), r && /* @__PURE__ */ l("div", {
|
|
153
153
|
id: "ctx-wait",
|
|
154
154
|
className: "small muted",
|
|
155
155
|
style: { marginTop: 6 },
|
|
156
|
-
children:
|
|
156
|
+
children: a("chat.context.waitTurn")
|
|
157
157
|
})] })
|
|
158
158
|
]
|
|
159
159
|
})]
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
function
|
|
163
|
-
return /* @__PURE__ */
|
|
162
|
+
function C({ icon: e, label: n, busy: r, run: i }) {
|
|
163
|
+
return /* @__PURE__ */ u("button", {
|
|
164
164
|
type: "button",
|
|
165
165
|
className: "btn sm",
|
|
166
166
|
disabled: r,
|
|
167
167
|
"aria-describedby": r ? "ctx-wait" : void 0,
|
|
168
168
|
onClick: i,
|
|
169
|
-
children: [/* @__PURE__ */
|
|
169
|
+
children: [/* @__PURE__ */ l(t, {
|
|
170
170
|
name: e,
|
|
171
171
|
size: 14
|
|
172
172
|
}), n]
|
|
@@ -174,29 +174,31 @@ function S({ icon: e, label: n, busy: r, run: i }) {
|
|
|
174
174
|
}
|
|
175
175
|
//#endregion
|
|
176
176
|
//#region src/chat/Attachments.tsx
|
|
177
|
-
var
|
|
177
|
+
var w = /\.(docx|doc|docm|odt|rtf|pptx|ppt|pptm|odp)$/, T = /\.(xlsx|xlsm|xls|ods)$/, E = /* @__PURE__ */ new Set([
|
|
178
178
|
"image/png",
|
|
179
179
|
"image/jpeg",
|
|
180
180
|
"image/gif",
|
|
181
181
|
"image/webp",
|
|
182
182
|
"image/svg+xml"
|
|
183
|
-
]),
|
|
184
|
-
function
|
|
185
|
-
let
|
|
186
|
-
return
|
|
183
|
+
]), D = /\.(png|jpe?g|gif|webp|svg)$/, O = /\.(txt|log|json|ya?ml|xml|ini|toml|sql|sh|py|go|js|ts|tsx|java|kt|rb|rs|c|cpp|h|css)$/;
|
|
184
|
+
function k(e, t = !1) {
|
|
185
|
+
let n = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), r = e.fileName.toLowerCase();
|
|
186
|
+
return t && w.test(r) ? "office-doc" : t && T.test(r) ? "office-sheet" : E.has(n) || (!n || n === "application/octet-stream") && D.test(r) ? "image" : n === "application/pdf" || r.endsWith(".pdf") ? "pdf" : n === "text/markdown" || /\.(md|markdown)$/.test(r) ? "markdown" : n === "text/csv" || n === "text/tab-separated-values" || /\.(csv|tsv)$/.test(r) ? "table" : n === "text/html" || /\.html?$/.test(r) ? "html" : n.startsWith("text/") || n === "application/json" || n === "application/xml" || O.test(r) ? "text" : null;
|
|
187
187
|
}
|
|
188
|
-
var
|
|
188
|
+
var A = {
|
|
189
189
|
image: "image",
|
|
190
190
|
pdf: "pdf",
|
|
191
191
|
markdown: "markdown",
|
|
192
192
|
table: "table",
|
|
193
193
|
html: "globe",
|
|
194
|
-
text: "source"
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
text: "source",
|
|
195
|
+
"office-doc": "files",
|
|
196
|
+
"office-sheet": "table"
|
|
197
|
+
}, j = (e) => A[e];
|
|
198
|
+
function ee(e, t) {
|
|
197
199
|
return t === "pdf" ? "PDF" : t === "markdown" ? "MD" : t === "html" ? "HTML" : /\.([a-z0-9]{1,5})$/i.exec(e.fileName)?.[1]?.toUpperCase() ?? (t ? "TXT" : "FILE");
|
|
198
200
|
}
|
|
199
|
-
function
|
|
201
|
+
function M(e, t) {
|
|
200
202
|
let n = [
|
|
201
203
|
"byte",
|
|
202
204
|
"kilobyte",
|
|
@@ -204,30 +206,30 @@ function A(e, t) {
|
|
|
204
206
|
"gigabyte"
|
|
205
207
|
], r = e, i = 0;
|
|
206
208
|
for (; r >= 1024 && i < n.length - 1;) r /= 1024, i++;
|
|
207
|
-
return new Intl.NumberFormat(
|
|
209
|
+
return new Intl.NumberFormat(b(t), {
|
|
208
210
|
style: "unit",
|
|
209
211
|
unit: n[i],
|
|
210
212
|
unitDisplay: "short",
|
|
211
213
|
maximumFractionDigits: i === 0 ? 0 : 1
|
|
212
214
|
}).format(r);
|
|
213
215
|
}
|
|
214
|
-
var
|
|
215
|
-
function
|
|
216
|
-
let t = `<meta http-equiv="Content-Security-Policy" content="${
|
|
216
|
+
var N = "default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:";
|
|
217
|
+
function P(e) {
|
|
218
|
+
let t = `<meta http-equiv="Content-Security-Policy" content="${N}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
|
|
217
219
|
if (typeof DOMParser > "u") return n + t + e.slice(n.length);
|
|
218
220
|
let r = new DOMParser().parseFromString(e, "text/html");
|
|
219
221
|
r.querySelectorAll("script, noscript, iframe, frame, frameset, object, embed, applet, base, link, meta[http-equiv], portal").forEach((e) => e.remove()), r.querySelectorAll("*").forEach((e) => {
|
|
220
222
|
for (let t of Array.from(e.attributes)) {
|
|
221
223
|
let n = t.name.toLowerCase();
|
|
222
|
-
n.startsWith("on") ||
|
|
224
|
+
n.startsWith("on") || F.has(n) && !I.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !I.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", L(t.value));
|
|
223
225
|
}
|
|
224
226
|
}), r.querySelectorAll("style").forEach((e) => {
|
|
225
|
-
e.textContent =
|
|
227
|
+
e.textContent = L(e.textContent ?? "");
|
|
226
228
|
});
|
|
227
229
|
let i = r.createElement("meta");
|
|
228
|
-
return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content",
|
|
230
|
+
return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", N), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
|
|
229
231
|
}
|
|
230
|
-
var
|
|
232
|
+
var F = /* @__PURE__ */ new Set([
|
|
231
233
|
"src",
|
|
232
234
|
"href",
|
|
233
235
|
"xlink:href",
|
|
@@ -245,11 +247,11 @@ var M = /* @__PURE__ */ new Set([
|
|
|
245
247
|
"codebase",
|
|
246
248
|
"archive",
|
|
247
249
|
"usemap"
|
|
248
|
-
]),
|
|
249
|
-
function
|
|
250
|
-
return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) =>
|
|
250
|
+
]), I = /^\s*(data:|#|$)/i;
|
|
251
|
+
function L(e) {
|
|
252
|
+
return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => I.test(n) && n.trim() !== "" ? e : "none");
|
|
251
253
|
}
|
|
252
|
-
var
|
|
254
|
+
var R = {
|
|
253
255
|
png: "image/png",
|
|
254
256
|
jpg: "image/jpeg",
|
|
255
257
|
jpeg: "image/jpeg",
|
|
@@ -264,11 +266,11 @@ var F = {
|
|
|
264
266
|
html: "text/html",
|
|
265
267
|
htm: "text/html"
|
|
266
268
|
};
|
|
267
|
-
function
|
|
269
|
+
function z(e) {
|
|
268
270
|
let t = (e.mimeType ?? "").split(";")[0].trim().toLowerCase();
|
|
269
|
-
return t && t !== "application/octet-stream" ? t :
|
|
271
|
+
return t && t !== "application/octet-stream" ? t : R[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
|
|
270
272
|
}
|
|
271
|
-
function
|
|
273
|
+
function B(e, t) {
|
|
272
274
|
if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
|
|
273
275
|
let n = [], r = [], i = "", a = !1;
|
|
274
276
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -277,9 +279,9 @@ function L(e, t) {
|
|
|
277
279
|
}
|
|
278
280
|
return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
|
|
279
281
|
}
|
|
280
|
-
function
|
|
281
|
-
let [r, i] =
|
|
282
|
-
return
|
|
282
|
+
function V(e, t, n = !0) {
|
|
283
|
+
let [r, i] = g({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
|
|
284
|
+
return f(() => {
|
|
283
285
|
if (!n) return;
|
|
284
286
|
let e, r = !0;
|
|
285
287
|
return t({
|
|
@@ -290,7 +292,7 @@ function R(e, t, n = !0) {
|
|
|
290
292
|
size: l
|
|
291
293
|
}).then((t) => {
|
|
292
294
|
if (!r) return;
|
|
293
|
-
let n =
|
|
295
|
+
let n = z({
|
|
294
296
|
fileName: s,
|
|
295
297
|
mimeType: c
|
|
296
298
|
}), a = n && t.type !== n ? new Blob([t], { type: n }) : t;
|
|
@@ -311,59 +313,59 @@ function R(e, t, n = !0) {
|
|
|
311
313
|
l
|
|
312
314
|
]), r;
|
|
313
315
|
}
|
|
314
|
-
function
|
|
315
|
-
let r =
|
|
316
|
-
return
|
|
316
|
+
function H({ a: e, load: t, onOpen: n }) {
|
|
317
|
+
let r = o(), { url: i, failed: a } = V(e, t);
|
|
318
|
+
return a ? /* @__PURE__ */ l(te, {
|
|
317
319
|
a: e,
|
|
318
320
|
kind: "image",
|
|
319
321
|
onOpen: n
|
|
320
|
-
}) : /* @__PURE__ */
|
|
322
|
+
}) : /* @__PURE__ */ u("button", {
|
|
321
323
|
type: "button",
|
|
322
324
|
className: "att-thumb",
|
|
323
325
|
onClick: n,
|
|
324
326
|
"aria-label": r("chat.files.open", { name: e.fileName }),
|
|
325
327
|
title: e.fileName,
|
|
326
|
-
children: [i ? /* @__PURE__ */
|
|
328
|
+
children: [i ? /* @__PURE__ */ l("img", {
|
|
327
329
|
src: i,
|
|
328
330
|
alt: ""
|
|
329
|
-
}) : /* @__PURE__ */
|
|
331
|
+
}) : /* @__PURE__ */ l("span", {
|
|
330
332
|
className: "spin",
|
|
331
333
|
"aria-hidden": "true"
|
|
332
|
-
}), /* @__PURE__ */
|
|
334
|
+
}), /* @__PURE__ */ l("span", {
|
|
333
335
|
className: "att-cap",
|
|
334
336
|
children: e.fileName
|
|
335
337
|
})]
|
|
336
338
|
});
|
|
337
339
|
}
|
|
338
|
-
function
|
|
339
|
-
let i =
|
|
340
|
-
/* @__PURE__ */
|
|
340
|
+
function te({ a: e, kind: n, onOpen: r }) {
|
|
341
|
+
let i = o(), { i18n: a } = _(s), d = n !== null && r !== void 0, f = /* @__PURE__ */ u(c, { children: [
|
|
342
|
+
/* @__PURE__ */ u("span", {
|
|
341
343
|
className: "att-ic",
|
|
342
|
-
children: [/* @__PURE__ */
|
|
343
|
-
name: d && n ?
|
|
344
|
+
children: [/* @__PURE__ */ l(t, {
|
|
345
|
+
name: d && n ? A[n] : "download",
|
|
344
346
|
size: 24
|
|
345
|
-
}), /* @__PURE__ */
|
|
347
|
+
}), /* @__PURE__ */ l("span", {
|
|
346
348
|
className: "att-kl",
|
|
347
|
-
children:
|
|
349
|
+
children: ee(e, n)
|
|
348
350
|
})]
|
|
349
351
|
}),
|
|
350
|
-
/* @__PURE__ */
|
|
352
|
+
/* @__PURE__ */ l("span", {
|
|
351
353
|
className: "att-name",
|
|
352
354
|
children: e.fileName
|
|
353
355
|
}),
|
|
354
|
-
e.size != null && /* @__PURE__ */
|
|
356
|
+
e.size != null && /* @__PURE__ */ l("span", {
|
|
355
357
|
className: "att-size",
|
|
356
|
-
children:
|
|
358
|
+
children: M(e.size, a.language)
|
|
357
359
|
})
|
|
358
360
|
] });
|
|
359
|
-
return d ? /* @__PURE__ */
|
|
361
|
+
return d ? /* @__PURE__ */ l("button", {
|
|
360
362
|
type: "button",
|
|
361
363
|
className: `att-tile ${n}`,
|
|
362
364
|
onClick: r,
|
|
363
365
|
"aria-label": i("chat.files.open", { name: e.fileName }),
|
|
364
366
|
title: e.fileName,
|
|
365
367
|
children: f
|
|
366
|
-
}) : /* @__PURE__ */
|
|
368
|
+
}) : /* @__PURE__ */ l("a", {
|
|
367
369
|
className: "att-tile dl",
|
|
368
370
|
href: e.href,
|
|
369
371
|
download: e.fileName,
|
|
@@ -372,40 +374,40 @@ function B({ a: e, kind: n, onOpen: r }) {
|
|
|
372
374
|
children: f
|
|
373
375
|
});
|
|
374
376
|
}
|
|
375
|
-
function
|
|
376
|
-
return /* @__PURE__ */
|
|
377
|
+
function U({ items: e, load: t, onOpen: n, office: r = !1 }) {
|
|
378
|
+
return /* @__PURE__ */ l("div", {
|
|
377
379
|
className: "atts",
|
|
378
380
|
children: e.map((e) => {
|
|
379
|
-
let
|
|
380
|
-
return t &&
|
|
381
|
+
let i = t && n ? () => n(e) : void 0, a = k(e, r);
|
|
382
|
+
return t && i && a === "image" ? /* @__PURE__ */ l(H, {
|
|
381
383
|
a: e,
|
|
382
384
|
load: t,
|
|
383
|
-
onOpen:
|
|
384
|
-
}, e.id) : /* @__PURE__ */
|
|
385
|
+
onOpen: i
|
|
386
|
+
}, e.id) : /* @__PURE__ */ l(te, {
|
|
385
387
|
a: e,
|
|
386
|
-
kind:
|
|
387
|
-
onOpen:
|
|
388
|
+
kind: a,
|
|
389
|
+
onOpen: i
|
|
388
390
|
}, e.id);
|
|
389
391
|
})
|
|
390
392
|
});
|
|
391
393
|
}
|
|
392
|
-
function
|
|
393
|
-
let n =
|
|
394
|
-
return /* @__PURE__ */
|
|
394
|
+
function W({ text: e, tab: t }) {
|
|
395
|
+
let n = o(), [r, ...i] = B(e, t), a = i.slice(0, 500);
|
|
396
|
+
return /* @__PURE__ */ u("div", {
|
|
395
397
|
className: "att-table",
|
|
396
|
-
children: [/* @__PURE__ */
|
|
398
|
+
children: [/* @__PURE__ */ u("table", { children: [r && /* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: r.map((e, t) => /* @__PURE__ */ l("th", { children: e }, t)) }) }), /* @__PURE__ */ l("tbody", { children: a.map((e, t) => /* @__PURE__ */ l("tr", { children: e.map((e, t) => /* @__PURE__ */ l("td", { children: e }, t)) }, t)) })] }), i.length > a.length && /* @__PURE__ */ l("div", {
|
|
397
399
|
className: "att-more",
|
|
398
400
|
children: n("chat.files.rows", {
|
|
399
|
-
shown:
|
|
401
|
+
shown: a.length,
|
|
400
402
|
total: i.length
|
|
401
403
|
})
|
|
402
404
|
})]
|
|
403
405
|
});
|
|
404
406
|
}
|
|
405
|
-
var
|
|
406
|
-
function
|
|
407
|
-
let n =
|
|
408
|
-
|
|
407
|
+
var G = 1280;
|
|
408
|
+
function K({ text: e, title: t }) {
|
|
409
|
+
let n = h(null), [r, i] = g(G), [a, o] = g(G);
|
|
410
|
+
f(() => {
|
|
409
411
|
let e = n.current;
|
|
410
412
|
if (!e) return;
|
|
411
413
|
let t = () => i(e.clientWidth);
|
|
@@ -413,158 +415,336 @@ function W({ text: e, title: t }) {
|
|
|
413
415
|
let r = new ResizeObserver(t);
|
|
414
416
|
return r.observe(e), () => r.disconnect();
|
|
415
417
|
}, []);
|
|
416
|
-
let s =
|
|
417
|
-
|
|
418
|
-
let
|
|
418
|
+
let s = m(() => P(e), [e]), [c, u] = g(s);
|
|
419
|
+
c !== s && (u(s), o(G));
|
|
420
|
+
let d = (e) => {
|
|
419
421
|
let t = e.currentTarget, n = () => {
|
|
420
422
|
let e = t.contentDocument?.documentElement;
|
|
421
|
-
e && o(Math.max(
|
|
423
|
+
e && o(Math.max(G, e.scrollWidth));
|
|
422
424
|
};
|
|
423
425
|
n(), t.contentDocument?.fonts?.ready.then(n);
|
|
424
|
-
},
|
|
425
|
-
return /* @__PURE__ */
|
|
426
|
+
}, p = Math.min(1, r / a);
|
|
427
|
+
return /* @__PURE__ */ l("div", {
|
|
426
428
|
className: "att-htmlbox",
|
|
427
429
|
ref: n,
|
|
428
|
-
children: /* @__PURE__ */
|
|
430
|
+
children: /* @__PURE__ */ l("iframe", {
|
|
429
431
|
className: "att-html",
|
|
430
432
|
sandbox: "allow-same-origin",
|
|
431
433
|
srcDoc: s,
|
|
432
434
|
title: t,
|
|
433
435
|
referrerPolicy: "no-referrer",
|
|
434
|
-
onLoad:
|
|
436
|
+
onLoad: d,
|
|
435
437
|
style: {
|
|
436
438
|
width: a,
|
|
437
|
-
height: `${100 /
|
|
438
|
-
transform: `scale(${
|
|
439
|
+
height: `${100 / p}%`,
|
|
440
|
+
transform: `scale(${p})`
|
|
439
441
|
}
|
|
440
442
|
})
|
|
441
443
|
});
|
|
442
444
|
}
|
|
443
|
-
function
|
|
444
|
-
let
|
|
445
|
-
|
|
446
|
-
|
|
445
|
+
function ne({ a: e, load: r, loadPreview: i, onClose: d }) {
|
|
446
|
+
let p = o(), { i18n: m } = _(s), h = k(e, !!i), v = h === "office-doc" || h === "office-sheet", y = h === "markdown" || h === "table" || h === "html" || h === "text", [b, x] = g(!1), S = y && (e.size ?? 0) > 1048576, { url: C, blob: w, failed: T } = V(e, r, !S && !v), [E, D] = g(null), O = S || y && (w?.size ?? 0) > 1048576;
|
|
447
|
+
f(() => {
|
|
448
|
+
y && w && !O && w.arrayBuffer().then((e) => {
|
|
447
449
|
try {
|
|
448
|
-
|
|
450
|
+
D({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
|
|
449
451
|
} catch {
|
|
450
|
-
|
|
452
|
+
D({ text: null });
|
|
451
453
|
}
|
|
452
|
-
}, () =>
|
|
454
|
+
}, () => D({ text: null }));
|
|
453
455
|
}, [
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
456
|
+
y,
|
|
457
|
+
w,
|
|
458
|
+
O
|
|
457
459
|
]);
|
|
458
|
-
let
|
|
459
|
-
return
|
|
460
|
+
let A = E?.text, j;
|
|
461
|
+
return j = v && i ? /* @__PURE__ */ l(Y, {
|
|
462
|
+
a: e,
|
|
463
|
+
load: i
|
|
464
|
+
}) : T ? /* @__PURE__ */ l("div", {
|
|
460
465
|
className: "att-msg err-text",
|
|
461
|
-
children:
|
|
462
|
-
}) :
|
|
466
|
+
children: p("chat.files.failed")
|
|
467
|
+
}) : O ? /* @__PURE__ */ l("div", {
|
|
463
468
|
className: "att-msg",
|
|
464
|
-
children:
|
|
465
|
-
}) :
|
|
469
|
+
children: p("chat.files.tooLarge")
|
|
470
|
+
}) : E && A === null ? /* @__PURE__ */ l("div", {
|
|
466
471
|
className: "att-msg",
|
|
467
|
-
children:
|
|
468
|
-
}) : !
|
|
472
|
+
children: p("chat.files.notUtf8")
|
|
473
|
+
}) : !C || y && A == null ? /* @__PURE__ */ u("div", {
|
|
469
474
|
className: "att-msg",
|
|
470
475
|
children: [
|
|
471
|
-
/* @__PURE__ */
|
|
476
|
+
/* @__PURE__ */ l("span", {
|
|
472
477
|
className: "spin",
|
|
473
478
|
"aria-hidden": "true"
|
|
474
479
|
}),
|
|
475
480
|
" ",
|
|
476
|
-
|
|
481
|
+
p("loading")
|
|
477
482
|
]
|
|
478
|
-
}) :
|
|
483
|
+
}) : h === "image" ? /* @__PURE__ */ l("img", {
|
|
479
484
|
className: "att-img",
|
|
480
|
-
src:
|
|
485
|
+
src: C,
|
|
481
486
|
alt: e.fileName
|
|
482
|
-
}) :
|
|
487
|
+
}) : h === "pdf" ? /* @__PURE__ */ l("object", {
|
|
483
488
|
className: "att-pdf",
|
|
484
|
-
data:
|
|
489
|
+
data: C,
|
|
485
490
|
type: "application/pdf",
|
|
486
491
|
"aria-label": e.fileName,
|
|
487
|
-
children: /* @__PURE__ */
|
|
492
|
+
children: /* @__PURE__ */ l("div", {
|
|
488
493
|
className: "att-msg",
|
|
489
|
-
children:
|
|
494
|
+
children: p("chat.files.failed")
|
|
490
495
|
})
|
|
491
|
-
}) :
|
|
496
|
+
}) : h === "markdown" ? /* @__PURE__ */ l("div", {
|
|
492
497
|
className: "att-md",
|
|
493
|
-
children: /* @__PURE__ */
|
|
494
|
-
}) :
|
|
495
|
-
text:
|
|
498
|
+
children: /* @__PURE__ */ l(a, { text: A ?? "" })
|
|
499
|
+
}) : h === "table" ? /* @__PURE__ */ l(W, {
|
|
500
|
+
text: A ?? "",
|
|
496
501
|
tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
|
|
497
|
-
}) :
|
|
498
|
-
text:
|
|
502
|
+
}) : h === "html" && !b ? /* @__PURE__ */ l(K, {
|
|
503
|
+
text: A ?? "",
|
|
499
504
|
title: e.fileName
|
|
500
|
-
}) : /* @__PURE__ */
|
|
505
|
+
}) : /* @__PURE__ */ l("pre", {
|
|
501
506
|
className: "att-text",
|
|
502
|
-
children:
|
|
503
|
-
}), /* @__PURE__ */
|
|
507
|
+
children: A
|
|
508
|
+
}), /* @__PURE__ */ l(n, {
|
|
504
509
|
wide: !0,
|
|
505
|
-
onClose:
|
|
506
|
-
title: /* @__PURE__ */
|
|
510
|
+
onClose: d,
|
|
511
|
+
title: /* @__PURE__ */ u("span", {
|
|
507
512
|
className: "att-title",
|
|
508
|
-
children: [/* @__PURE__ */
|
|
513
|
+
children: [/* @__PURE__ */ l("span", {
|
|
509
514
|
className: "att-name",
|
|
510
515
|
children: e.fileName
|
|
511
|
-
}), e.size != null && /* @__PURE__ */
|
|
516
|
+
}), e.size != null && /* @__PURE__ */ l("span", {
|
|
512
517
|
className: "muted small",
|
|
513
|
-
children:
|
|
518
|
+
children: M(e.size, m.language)
|
|
514
519
|
})]
|
|
515
520
|
}),
|
|
516
|
-
footer: /* @__PURE__ */
|
|
517
|
-
|
|
521
|
+
footer: /* @__PURE__ */ u(c, { children: [
|
|
522
|
+
h === "html" && /* @__PURE__ */ u("button", {
|
|
518
523
|
type: "button",
|
|
519
524
|
className: "btn ghost",
|
|
520
|
-
onClick: () =>
|
|
525
|
+
onClick: () => x((e) => !e),
|
|
521
526
|
children: [
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
name:
|
|
527
|
+
/* @__PURE__ */ l(t, {
|
|
528
|
+
name: b ? "globe" : "code",
|
|
524
529
|
size: 14
|
|
525
530
|
}),
|
|
526
531
|
" ",
|
|
527
|
-
|
|
532
|
+
p(b ? "chat.files.page" : "chat.files.source")
|
|
528
533
|
]
|
|
529
534
|
}),
|
|
530
|
-
/* @__PURE__ */
|
|
535
|
+
/* @__PURE__ */ u("a", {
|
|
531
536
|
className: "btn ghost",
|
|
532
|
-
href:
|
|
537
|
+
href: C ?? e.href,
|
|
533
538
|
download: e.fileName,
|
|
534
539
|
children: [
|
|
535
|
-
/* @__PURE__ */
|
|
540
|
+
/* @__PURE__ */ l(t, {
|
|
536
541
|
name: "download",
|
|
537
542
|
size: 14
|
|
538
543
|
}),
|
|
539
544
|
" ",
|
|
540
|
-
|
|
545
|
+
p("chat.files.download")
|
|
541
546
|
]
|
|
542
547
|
}),
|
|
543
|
-
/* @__PURE__ */
|
|
548
|
+
/* @__PURE__ */ l("button", {
|
|
544
549
|
type: "button",
|
|
545
550
|
className: "btn primary",
|
|
546
|
-
onClick:
|
|
547
|
-
children:
|
|
551
|
+
onClick: d,
|
|
552
|
+
children: p("close")
|
|
548
553
|
})
|
|
549
554
|
] }),
|
|
550
|
-
children: /* @__PURE__ */
|
|
551
|
-
className: `att-view ${
|
|
552
|
-
children:
|
|
555
|
+
children: /* @__PURE__ */ l("div", {
|
|
556
|
+
className: `att-view ${h ?? ""}`,
|
|
557
|
+
children: j
|
|
553
558
|
})
|
|
554
559
|
});
|
|
555
560
|
}
|
|
561
|
+
var re = 4e4, ie = 2e3, q = 25, J = 50;
|
|
562
|
+
function Y({ a: e, load: n }) {
|
|
563
|
+
let r = o(), [i, a] = g({ state: "loading" }), { id: s, href: c, fileName: d, mimeType: p, size: m } = e;
|
|
564
|
+
return f(() => {
|
|
565
|
+
let e = !0, t, r = Date.now(), i = () => {
|
|
566
|
+
n({
|
|
567
|
+
id: s,
|
|
568
|
+
href: c,
|
|
569
|
+
fileName: d,
|
|
570
|
+
mimeType: p,
|
|
571
|
+
size: m
|
|
572
|
+
}).then((n) => {
|
|
573
|
+
e && (n.state === "pending" ? Date.now() - r > re ? a({
|
|
574
|
+
state: "error",
|
|
575
|
+
reason: "timeout"
|
|
576
|
+
}) : (a(n), t = setTimeout(i, ie)) : a(n));
|
|
577
|
+
}, () => e && a({ state: "failed" }));
|
|
578
|
+
};
|
|
579
|
+
return i(), () => {
|
|
580
|
+
e = !1, t && clearTimeout(t);
|
|
581
|
+
};
|
|
582
|
+
}, [
|
|
583
|
+
n,
|
|
584
|
+
s,
|
|
585
|
+
c,
|
|
586
|
+
d,
|
|
587
|
+
p,
|
|
588
|
+
m
|
|
589
|
+
]), i.state === "loading" || i.state === "pending" ? /* @__PURE__ */ u("div", {
|
|
590
|
+
className: "att-msg att-wait",
|
|
591
|
+
children: [
|
|
592
|
+
/* @__PURE__ */ l("span", {
|
|
593
|
+
className: "spin",
|
|
594
|
+
"aria-hidden": "true"
|
|
595
|
+
}),
|
|
596
|
+
/* @__PURE__ */ l("b", { children: r("chat.files.preparing") }),
|
|
597
|
+
/* @__PURE__ */ l("span", {
|
|
598
|
+
className: "muted small",
|
|
599
|
+
children: r("chat.files.preparingHint")
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
}) : i.state === "failed" ? /* @__PURE__ */ l("div", {
|
|
603
|
+
className: "att-msg err-text",
|
|
604
|
+
children: r("chat.files.failed")
|
|
605
|
+
}) : i.state === "error" ? /* @__PURE__ */ u("div", {
|
|
606
|
+
className: "att-msg att-wait",
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ l(t, {
|
|
609
|
+
name: "alert",
|
|
610
|
+
size: 28
|
|
611
|
+
}),
|
|
612
|
+
/* @__PURE__ */ l("b", { children: r("chat.files.unavailable") }),
|
|
613
|
+
/* @__PURE__ */ l("span", {
|
|
614
|
+
className: "muted small",
|
|
615
|
+
children: r(`chat.files.reasons.${i.reason}`, { limit: i.limitMb ?? q })
|
|
616
|
+
})
|
|
617
|
+
]
|
|
618
|
+
}) : i.state === "doc" ? /* @__PURE__ */ l(X, {
|
|
619
|
+
blob: i.blob,
|
|
620
|
+
shown: i.shown,
|
|
621
|
+
total: i.total,
|
|
622
|
+
from: i.from,
|
|
623
|
+
name: e.fileName
|
|
624
|
+
}) : /* @__PURE__ */ l(se, { sheets: i.sheets });
|
|
625
|
+
}
|
|
626
|
+
function X({ blob: e, shown: t, total: n, from: r, name: i }) {
|
|
627
|
+
let a = o(), s = m(() => URL.createObjectURL(e.type === "application/pdf" ? e : new Blob([e], { type: "application/pdf" })), [e]);
|
|
628
|
+
return f(() => () => URL.revokeObjectURL(s), [s]), /* @__PURE__ */ u("div", {
|
|
629
|
+
className: "att-office",
|
|
630
|
+
children: [
|
|
631
|
+
/* @__PURE__ */ l("div", {
|
|
632
|
+
className: "att-converted",
|
|
633
|
+
children: a("chat.files.converted", { format: r })
|
|
634
|
+
}),
|
|
635
|
+
/* @__PURE__ */ l("object", {
|
|
636
|
+
className: "att-pdf",
|
|
637
|
+
data: s,
|
|
638
|
+
type: "application/pdf",
|
|
639
|
+
"aria-label": i,
|
|
640
|
+
children: /* @__PURE__ */ l("div", {
|
|
641
|
+
className: "att-msg",
|
|
642
|
+
children: a("chat.files.failed")
|
|
643
|
+
})
|
|
644
|
+
}),
|
|
645
|
+
n != null && n > t && /* @__PURE__ */ l("div", {
|
|
646
|
+
className: "att-more",
|
|
647
|
+
children: a("chat.files.pagesShown", {
|
|
648
|
+
shown: t,
|
|
649
|
+
total: n
|
|
650
|
+
})
|
|
651
|
+
}),
|
|
652
|
+
n == null && t >= J && /* @__PURE__ */ l("div", {
|
|
653
|
+
className: "att-more",
|
|
654
|
+
children: a("chat.files.firstPages", { shown: t })
|
|
655
|
+
})
|
|
656
|
+
]
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
function ae(e) {
|
|
660
|
+
let t = /^([A-Z]+)(\d+)$/.exec(e);
|
|
661
|
+
if (!t) return null;
|
|
662
|
+
let n = 0;
|
|
663
|
+
for (let e of t[1]) n = n * 26 + e.charCodeAt(0) - 64;
|
|
664
|
+
return [Number(t[2]) - 1, n - 1];
|
|
665
|
+
}
|
|
666
|
+
function oe(e) {
|
|
667
|
+
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
|
|
668
|
+
for (let r of e) {
|
|
669
|
+
let [e, i] = r.split(":").map(ae);
|
|
670
|
+
if (e && i) {
|
|
671
|
+
t.set(`${e[0]}:${e[1]}`, [i[0] - e[0] + 1, i[1] - e[1] + 1]);
|
|
672
|
+
for (let t = e[0]; t <= i[0]; t++) for (let r = e[1]; r <= i[1]; r++) (t !== e[0] || r !== e[1]) && n.add(`${t}:${r}`);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
spans: t,
|
|
677
|
+
covered: n
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function Z(e) {
|
|
681
|
+
let t = "";
|
|
682
|
+
for (let n = e; n > 0; n = Math.floor((n - 1) / 26)) t = String.fromCharCode(65 + (n - 1) % 26) + t;
|
|
683
|
+
return t;
|
|
684
|
+
}
|
|
685
|
+
function se({ sheets: e }) {
|
|
686
|
+
let t = o(), [n, i] = g(0), a = e[Math.min(n, e.length - 1)];
|
|
687
|
+
if (!a) return /* @__PURE__ */ l("div", {
|
|
688
|
+
className: "att-msg",
|
|
689
|
+
children: t("chat.files.failed")
|
|
690
|
+
});
|
|
691
|
+
let s = Math.max(0, ...a.cells.map((e) => e.length)), d = Array.from({ length: s }, (e, t) => Z(t + 1)), { spans: f, covered: p } = oe(a.merges), m = a.rows > a.cells.length, h = a.cols > s;
|
|
692
|
+
return /* @__PURE__ */ u("div", {
|
|
693
|
+
className: "att-office",
|
|
694
|
+
children: [
|
|
695
|
+
e.length > 1 && /* @__PURE__ */ l(r, {
|
|
696
|
+
label: t("chat.files.sheets"),
|
|
697
|
+
items: e.map((e, t) => ({
|
|
698
|
+
key: String(t),
|
|
699
|
+
label: e.name
|
|
700
|
+
})),
|
|
701
|
+
value: String(n),
|
|
702
|
+
onChange: (e) => i(Number(e))
|
|
703
|
+
}),
|
|
704
|
+
/* @__PURE__ */ l("div", {
|
|
705
|
+
className: "att-table att-sheet",
|
|
706
|
+
children: /* @__PURE__ */ u("table", { children: [/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ u("tr", { children: [/* @__PURE__ */ l("th", {}), d.map((e) => /* @__PURE__ */ l("th", { children: e }, e))] }) }), /* @__PURE__ */ l("tbody", { children: a.cells.map((e, n) => /* @__PURE__ */ u("tr", { children: [/* @__PURE__ */ l("th", { children: n + 1 }), e.map((e, r) => {
|
|
707
|
+
if (p.has(`${n}:${r}`)) return null;
|
|
708
|
+
let [i, a] = f.get(`${n}:${r}`) ?? [1, 1], o = i > 1 ? i : void 0, s = a > 1 ? a : void 0;
|
|
709
|
+
return e.f ? /* @__PURE__ */ l("td", {
|
|
710
|
+
rowSpan: o,
|
|
711
|
+
colSpan: s,
|
|
712
|
+
className: "att-formula",
|
|
713
|
+
title: t("chat.files.formulaHint"),
|
|
714
|
+
children: e.f
|
|
715
|
+
}, r) : /* @__PURE__ */ l("td", {
|
|
716
|
+
rowSpan: o,
|
|
717
|
+
colSpan: s,
|
|
718
|
+
className: e.n == null ? void 0 : "att-num",
|
|
719
|
+
children: e.v ?? ""
|
|
720
|
+
}, r);
|
|
721
|
+
})] }, n)) })] })
|
|
722
|
+
}),
|
|
723
|
+
(m || h) && /* @__PURE__ */ u("div", {
|
|
724
|
+
className: "att-more",
|
|
725
|
+
children: [t("chat.files.rows", {
|
|
726
|
+
shown: a.cells.length,
|
|
727
|
+
total: a.rows
|
|
728
|
+
}), h && /* @__PURE__ */ u(c, { children: [" ", t("chat.files.cols", {
|
|
729
|
+
shown: s,
|
|
730
|
+
total: a.cols
|
|
731
|
+
})] })]
|
|
732
|
+
})
|
|
733
|
+
]
|
|
734
|
+
});
|
|
735
|
+
}
|
|
556
736
|
//#endregion
|
|
557
737
|
//#region src/chat/MessageView.tsx
|
|
558
|
-
function
|
|
559
|
-
return new Intl.DateTimeFormat(
|
|
738
|
+
function ce(e, t) {
|
|
739
|
+
return new Intl.DateTimeFormat(b(t), {
|
|
560
740
|
hour: "2-digit",
|
|
561
741
|
minute: "2-digit"
|
|
562
742
|
}).format(new Date(e));
|
|
563
743
|
}
|
|
564
|
-
function
|
|
744
|
+
function le(e, t) {
|
|
565
745
|
return t || e.length <= 3 ? e : e.slice(-2);
|
|
566
746
|
}
|
|
567
|
-
var
|
|
747
|
+
var Q = {
|
|
568
748
|
done: {
|
|
569
749
|
icon: "check",
|
|
570
750
|
cls: "ok"
|
|
@@ -578,132 +758,159 @@ var G = {
|
|
|
578
758
|
cls: "run"
|
|
579
759
|
}
|
|
580
760
|
};
|
|
581
|
-
function
|
|
582
|
-
let { t:
|
|
583
|
-
if (e.role === "note") return /* @__PURE__ */
|
|
761
|
+
function ue({ m: e, busy: n, onRetry: r, loadAttachment: i, loadPreview: o, onOpenAttachment: d }) {
|
|
762
|
+
let { t: f, i18n: p } = _(s), [m, h] = g(!1);
|
|
763
|
+
if (e.role === "note") return /* @__PURE__ */ l("div", {
|
|
584
764
|
className: "sysnote",
|
|
585
765
|
children: e.text
|
|
586
766
|
});
|
|
587
|
-
if (e.role === "event" && e.event) return /* @__PURE__ */
|
|
588
|
-
let
|
|
767
|
+
if (e.role === "event" && e.event) return /* @__PURE__ */ l(pe, { m: e });
|
|
768
|
+
let v = e.mark && /* @__PURE__ */ u("div", {
|
|
589
769
|
className: "chan",
|
|
590
770
|
children: [
|
|
591
|
-
/* @__PURE__ */
|
|
771
|
+
/* @__PURE__ */ l(t, {
|
|
592
772
|
name: e.mark.icon,
|
|
593
773
|
size: 12
|
|
594
774
|
}),
|
|
595
775
|
" ",
|
|
596
776
|
e.mark.text,
|
|
597
777
|
" · ",
|
|
598
|
-
|
|
778
|
+
ce(e.createdAt, p.language)
|
|
599
779
|
]
|
|
600
|
-
}),
|
|
780
|
+
}), y = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ l(U, {
|
|
601
781
|
items: e.attachments,
|
|
602
|
-
load:
|
|
603
|
-
|
|
782
|
+
load: i,
|
|
783
|
+
office: !!o,
|
|
784
|
+
onOpen: d
|
|
604
785
|
});
|
|
605
|
-
if (e.role === "user") return /* @__PURE__ */
|
|
786
|
+
if (e.role === "user") return /* @__PURE__ */ u("div", {
|
|
606
787
|
className: "m u",
|
|
607
788
|
children: [
|
|
608
|
-
|
|
789
|
+
v,
|
|
609
790
|
e.content,
|
|
610
|
-
e.text && /* @__PURE__ */
|
|
791
|
+
e.text && /* @__PURE__ */ l("div", {
|
|
611
792
|
className: "bub",
|
|
612
793
|
children: e.text
|
|
613
794
|
}),
|
|
614
|
-
|
|
615
|
-
e.wait && /* @__PURE__ */
|
|
795
|
+
y,
|
|
796
|
+
e.wait && /* @__PURE__ */ l("div", {
|
|
616
797
|
className: `turnstate${e.wait.state === "queued" ? " q" : ""}`,
|
|
617
798
|
role: "status",
|
|
618
|
-
children: e.wait.state === "queued" ? /* @__PURE__ */
|
|
799
|
+
children: e.wait.state === "queued" ? /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l(t, {
|
|
619
800
|
name: "clock",
|
|
620
801
|
size: 12
|
|
621
|
-
}),
|
|
802
|
+
}), f("chat.wait.queued", { count: e.wait.position })] }) : /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("span", {
|
|
622
803
|
className: "spin",
|
|
623
804
|
"aria-hidden": "true"
|
|
624
|
-
}),
|
|
805
|
+
}), f("chat.wait.starting")] })
|
|
625
806
|
})
|
|
626
807
|
]
|
|
627
808
|
});
|
|
628
|
-
|
|
629
|
-
|
|
809
|
+
if (e.variant === "notice") return /* @__PURE__ */ l(fe, {
|
|
810
|
+
m: e,
|
|
811
|
+
mark: v,
|
|
812
|
+
atts: y
|
|
813
|
+
});
|
|
814
|
+
let b = e.steps ?? [], x = (e.status === "streaming" || e.status === "pending") && !e.text && !e.content;
|
|
815
|
+
return /* @__PURE__ */ u("div", {
|
|
630
816
|
className: "m a",
|
|
631
817
|
children: [
|
|
632
|
-
|
|
633
|
-
|
|
818
|
+
v,
|
|
819
|
+
b.length > 3 && /* @__PURE__ */ l("button", {
|
|
634
820
|
className: "tools-fold",
|
|
635
|
-
onClick: () =>
|
|
636
|
-
"aria-expanded":
|
|
637
|
-
children:
|
|
821
|
+
onClick: () => h((e) => !e),
|
|
822
|
+
"aria-expanded": m,
|
|
823
|
+
children: m ? f("chat.hideSteps") : f("chat.moreSteps", { count: b.length - 2 })
|
|
638
824
|
}),
|
|
639
|
-
|
|
825
|
+
le(b, m).map((e) => /* @__PURE__ */ u("div", {
|
|
640
826
|
className: "tool",
|
|
641
827
|
title: e.title,
|
|
642
|
-
children: [/* @__PURE__ */
|
|
643
|
-
name:
|
|
828
|
+
children: [/* @__PURE__ */ l(t, {
|
|
829
|
+
name: Q[e.status].icon,
|
|
644
830
|
size: 14,
|
|
645
|
-
className:
|
|
646
|
-
}), /* @__PURE__ */
|
|
831
|
+
className: Q[e.status].cls
|
|
832
|
+
}), /* @__PURE__ */ l("span", {
|
|
647
833
|
className: "tx",
|
|
648
834
|
children: e.text
|
|
649
835
|
})]
|
|
650
836
|
}, e.id)),
|
|
651
|
-
|
|
837
|
+
x && /* @__PURE__ */ l("div", {
|
|
652
838
|
className: "bub",
|
|
653
|
-
children: /* @__PURE__ */
|
|
839
|
+
children: /* @__PURE__ */ u("span", {
|
|
654
840
|
className: "typing",
|
|
655
|
-
"aria-label":
|
|
841
|
+
"aria-label": f("chat.typing"),
|
|
656
842
|
children: [
|
|
657
|
-
/* @__PURE__ */
|
|
658
|
-
/* @__PURE__ */
|
|
659
|
-
/* @__PURE__ */
|
|
843
|
+
/* @__PURE__ */ l("i", {}),
|
|
844
|
+
/* @__PURE__ */ l("i", {}),
|
|
845
|
+
/* @__PURE__ */ l("i", {})
|
|
660
846
|
]
|
|
661
847
|
})
|
|
662
848
|
}),
|
|
663
|
-
e.content ?? (e.text && /* @__PURE__ */
|
|
849
|
+
e.content ?? (e.text && /* @__PURE__ */ l("div", {
|
|
664
850
|
className: "bub",
|
|
665
851
|
title: e.hint,
|
|
666
|
-
children: /* @__PURE__ */
|
|
852
|
+
children: /* @__PURE__ */ l(a, { text: e.text })
|
|
667
853
|
})),
|
|
668
|
-
|
|
669
|
-
e.error && /* @__PURE__ */
|
|
854
|
+
y,
|
|
855
|
+
e.error && /* @__PURE__ */ u("div", {
|
|
670
856
|
className: `llmerr${e.error.transient ? " amber" : ""}`,
|
|
671
857
|
role: "alert",
|
|
672
858
|
style: { marginTop: 6 },
|
|
673
|
-
children: [/* @__PURE__ */
|
|
859
|
+
children: [/* @__PURE__ */ l("span", { children: e.error.text }), r && /* @__PURE__ */ l("div", {
|
|
674
860
|
className: "row",
|
|
675
|
-
children: /* @__PURE__ */
|
|
861
|
+
children: /* @__PURE__ */ u("button", {
|
|
676
862
|
className: "btn sm",
|
|
677
863
|
disabled: n,
|
|
678
|
-
onClick:
|
|
679
|
-
children: [/* @__PURE__ */
|
|
864
|
+
onClick: r,
|
|
865
|
+
children: [/* @__PURE__ */ l(t, {
|
|
680
866
|
name: "refresh",
|
|
681
867
|
size: 14
|
|
682
|
-
}),
|
|
868
|
+
}), f("chat.retry")]
|
|
683
869
|
})
|
|
684
870
|
})]
|
|
685
871
|
})
|
|
686
872
|
]
|
|
687
873
|
});
|
|
688
874
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
875
|
+
var de = 12;
|
|
876
|
+
function fe({ m: e, mark: t, atts: n }) {
|
|
877
|
+
let { t: r } = _(s), [i, o] = g(!1), c = !e.content && e.text.split("\n").length > 12;
|
|
878
|
+
return /* @__PURE__ */ u("div", {
|
|
879
|
+
className: "m a notice",
|
|
880
|
+
children: [
|
|
881
|
+
t,
|
|
882
|
+
e.content ?? /* @__PURE__ */ u("div", {
|
|
883
|
+
className: `bub${c && !i ? " folded" : ""}`,
|
|
884
|
+
children: [/* @__PURE__ */ l(a, { text: e.text }), c && /* @__PURE__ */ l("button", {
|
|
885
|
+
type: "button",
|
|
886
|
+
className: "textbtn",
|
|
887
|
+
"aria-expanded": i,
|
|
888
|
+
onClick: () => o((e) => !e),
|
|
889
|
+
children: r(i ? "chat.notice.less" : "chat.notice.more")
|
|
890
|
+
})]
|
|
891
|
+
}),
|
|
892
|
+
n
|
|
893
|
+
]
|
|
894
|
+
});
|
|
895
|
+
}
|
|
896
|
+
function pe({ m: e }) {
|
|
897
|
+
let { t: n, i18n: r } = _(s), [i, a] = g(!1), o = e.event;
|
|
898
|
+
return /* @__PURE__ */ u("div", {
|
|
692
899
|
className: "evdiv",
|
|
693
|
-
children: [/* @__PURE__ */
|
|
900
|
+
children: [/* @__PURE__ */ l("div", {
|
|
694
901
|
className: "evline",
|
|
695
902
|
role: "separator",
|
|
696
|
-
children: /* @__PURE__ */
|
|
903
|
+
children: /* @__PURE__ */ u("span", {
|
|
697
904
|
className: "evchip",
|
|
698
905
|
children: [
|
|
699
|
-
/* @__PURE__ */
|
|
700
|
-
name:
|
|
906
|
+
/* @__PURE__ */ l(t, {
|
|
907
|
+
name: o.icon,
|
|
701
908
|
size: 12
|
|
702
909
|
}),
|
|
703
|
-
|
|
910
|
+
o.text,
|
|
704
911
|
" · ",
|
|
705
|
-
|
|
706
|
-
|
|
912
|
+
ce(e.createdAt, r.language),
|
|
913
|
+
o.details && /* @__PURE__ */ u("button", {
|
|
707
914
|
type: "button",
|
|
708
915
|
className: "textbtn",
|
|
709
916
|
"aria-expanded": i,
|
|
@@ -716,41 +923,41 @@ function K({ m: e }) {
|
|
|
716
923
|
})
|
|
717
924
|
]
|
|
718
925
|
})
|
|
719
|
-
}), i &&
|
|
926
|
+
}), i && o.details && /* @__PURE__ */ l("div", {
|
|
720
927
|
className: "evdetails",
|
|
721
|
-
children:
|
|
928
|
+
children: o.details
|
|
722
929
|
})]
|
|
723
930
|
});
|
|
724
931
|
}
|
|
725
932
|
//#endregion
|
|
726
933
|
//#region src/chat/transcription.ts
|
|
727
|
-
async function
|
|
934
|
+
async function me(e, t, n) {
|
|
728
935
|
n.busy(!0);
|
|
729
936
|
let r;
|
|
730
937
|
try {
|
|
731
938
|
r = await t(e);
|
|
732
939
|
} catch (r) {
|
|
733
|
-
n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void
|
|
940
|
+
n.busy(!1), n.failed(r instanceof Error && r.message ? r.message : void 0, () => void me(e, t, n));
|
|
734
941
|
return;
|
|
735
942
|
}
|
|
736
943
|
n.busy(!1), r !== null && (r ? n.text(r) : n.empty());
|
|
737
944
|
}
|
|
738
945
|
//#endregion
|
|
739
946
|
//#region src/chat/useRecorder.ts
|
|
740
|
-
function
|
|
741
|
-
let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] =
|
|
742
|
-
|
|
947
|
+
function he(e = 300, t) {
|
|
948
|
+
let n = typeof window < "u" && "MediaRecorder" in window && !!navigator.mediaDevices?.getUserMedia, [r, i] = g(!1), [a, o] = g(0), [s, c] = g(0), [l, u] = g(!1), p = h(null), m = h([]), _ = h(void 0), v = h(null), y = h(null), b = h(!1), x = h(t);
|
|
949
|
+
f(() => {
|
|
743
950
|
x.current = t;
|
|
744
951
|
});
|
|
745
|
-
let S =
|
|
952
|
+
let S = d(() => {
|
|
746
953
|
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);
|
|
747
|
-
}, []), C =
|
|
954
|
+
}, []), C = d(async () => {
|
|
748
955
|
if (n && !p.current) {
|
|
749
|
-
|
|
956
|
+
u(!1);
|
|
750
957
|
try {
|
|
751
958
|
let t = await navigator.mediaDevices.getUserMedia({ audio: !0 }), n = new MediaRecorder(t);
|
|
752
|
-
|
|
753
|
-
let e = !b.current &&
|
|
959
|
+
m.current = [], b.current = !1, n.ondataavailable = (e) => e.data.size > 0 && m.current.push(e.data), n.onstop = () => {
|
|
960
|
+
let e = !b.current && m.current.length ? new Blob(m.current, { type: n.mimeType || "audio/webm" }) : null;
|
|
754
961
|
S(), y.current?.(e), y.current = null;
|
|
755
962
|
};
|
|
756
963
|
let r = null;
|
|
@@ -774,21 +981,21 @@ function oe(e = 300, t) {
|
|
|
774
981
|
t >= e && !l && (l = !0, x.current?.());
|
|
775
982
|
}, 100);
|
|
776
983
|
} catch {
|
|
777
|
-
|
|
984
|
+
u(!0), S();
|
|
778
985
|
}
|
|
779
986
|
}
|
|
780
987
|
}, [
|
|
781
988
|
n,
|
|
782
989
|
S,
|
|
783
990
|
e
|
|
784
|
-
]), w =
|
|
991
|
+
]), w = d(() => new Promise((e) => {
|
|
785
992
|
let t = p.current;
|
|
786
993
|
if (!t || t.state === "inactive") return e(null);
|
|
787
994
|
y.current = e, t.stop();
|
|
788
|
-
}), []), T =
|
|
995
|
+
}), []), T = d(() => {
|
|
789
996
|
b.current = !0, w();
|
|
790
997
|
}, [w]);
|
|
791
|
-
return
|
|
998
|
+
return f(() => () => S(), [S]), {
|
|
792
999
|
supported: n,
|
|
793
1000
|
recording: r,
|
|
794
1001
|
seconds: a,
|
|
@@ -799,84 +1006,80 @@ function oe(e = 300, t) {
|
|
|
799
1006
|
cancel: T
|
|
800
1007
|
};
|
|
801
1008
|
}
|
|
802
|
-
function
|
|
1009
|
+
function ge(e) {
|
|
803
1010
|
return `${Math.floor(e / 60)}:${String(e % 60).padStart(2, "0")}`;
|
|
804
1011
|
}
|
|
805
1012
|
//#endregion
|
|
806
1013
|
//#region src/chat/Chat.tsx
|
|
807
|
-
function
|
|
808
|
-
let r =
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
d(() => re?.(g), [g, re]);
|
|
814
|
-
let G = U[0]?.id, K = U[U.length - 1], q = K?.id, ue = K?.text.length, pe = K?.steps?.length, me = m({ height: 0 });
|
|
815
|
-
f(() => {
|
|
816
|
-
let e = R.current;
|
|
1014
|
+
function _e(n) {
|
|
1015
|
+
let r = o(), i = e(), [a, s] = g(""), [d, m] = g([]), [_, b] = g(!1), [x, C] = g(null), [w, T] = g(0), [E, D] = g(!1), [O, k] = g(null), [A, j] = g(!1), [ee, M] = g(null), N = Ce(n.loadAttachment), P = Ce(n.loadPreview), F = h(!1), I = h(null), L = h(null), R = h(null), z = n.voiceMaxSeconds ?? 300, B = he(z, () => void Q()), { messages: V, busy: H = !1 } = n, te = H || V.some((e) => e.status === "pending" || e.status === "streaming"), U = n.onPendingChange;
|
|
1016
|
+
f(() => U?.(d), [d, U]);
|
|
1017
|
+
let W = V[0]?.id, G = V[V.length - 1], K = G?.id, re = G?.text.length, ie = G?.steps?.length, q = h({ height: 0 });
|
|
1018
|
+
p(() => {
|
|
1019
|
+
let e = I.current;
|
|
817
1020
|
if (!e) return;
|
|
818
|
-
let t =
|
|
819
|
-
e.scrollTop = t.first !== void 0 &&
|
|
820
|
-
first:
|
|
821
|
-
last:
|
|
1021
|
+
let t = q.current;
|
|
1022
|
+
e.scrollTop = t.first !== void 0 && W !== t.first && K === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, q.current = {
|
|
1023
|
+
first: W,
|
|
1024
|
+
last: K,
|
|
822
1025
|
height: e.scrollHeight
|
|
823
1026
|
};
|
|
824
1027
|
}, [
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
1028
|
+
V.length,
|
|
1029
|
+
W,
|
|
1030
|
+
K,
|
|
1031
|
+
re,
|
|
1032
|
+
ie
|
|
830
1033
|
]);
|
|
831
|
-
let J = n.commands && !
|
|
832
|
-
|
|
833
|
-
},
|
|
1034
|
+
let J = n.commands && !x && a.startsWith("/") && !/\s/.test(a) ? a.slice(1) : null, Y = J === null ? [] : v(n.commands ?? [], J), X = J !== null && !E, ae = () => {
|
|
1035
|
+
s(""), m([]), C(null), k(null), F.current = !1;
|
|
1036
|
+
}, oe = async (e, t) => {
|
|
834
1037
|
if (n.onCommand) try {
|
|
835
|
-
await n.onCommand(e, t),
|
|
1038
|
+
await n.onCommand(e, t), ae();
|
|
836
1039
|
} catch {}
|
|
837
|
-
},
|
|
1040
|
+
}, Z = async (e, t = !1) => {
|
|
838
1041
|
let r = e.trim();
|
|
839
|
-
if (!(!r &&
|
|
840
|
-
if (!t && !
|
|
1042
|
+
if (!(!r && d.length === 0 && !x || H || n.readOnly)) {
|
|
1043
|
+
if (!t && !x && n.commands && r.startsWith("/")) {
|
|
841
1044
|
let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
|
|
842
|
-
if (i) return
|
|
1045
|
+
if (i) return oe(i.name, t.join(" "));
|
|
843
1046
|
if (e && !r.includes("\n")) {
|
|
844
|
-
|
|
1047
|
+
k("/" + e);
|
|
845
1048
|
return;
|
|
846
1049
|
}
|
|
847
1050
|
}
|
|
848
1051
|
try {
|
|
849
|
-
await n.onSend(r,
|
|
1052
|
+
await n.onSend(r, d.map((e) => e.id), F.current, x ?? void 0), ae();
|
|
850
1053
|
} catch {}
|
|
851
1054
|
}
|
|
852
|
-
},
|
|
853
|
-
|
|
854
|
-
},
|
|
1055
|
+
}, se = (e) => {
|
|
1056
|
+
T(0), e.kind === "skill" ? (C(e.name), s("")) : e.takesText ? s("/" + e.name + " ") : oe(e.name, ""), R.current?.focus();
|
|
1057
|
+
}, ce = (e) => {
|
|
855
1058
|
if (X && Y.length > 0) {
|
|
856
1059
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
857
1060
|
e.preventDefault();
|
|
858
1061
|
let t = e.key === "ArrowDown" ? 1 : -1;
|
|
859
|
-
|
|
1062
|
+
T((e) => (e + t + Y.length) % Y.length);
|
|
860
1063
|
return;
|
|
861
1064
|
}
|
|
862
1065
|
if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
|
|
863
|
-
e.preventDefault(),
|
|
1066
|
+
e.preventDefault(), se(Y[Math.min(w, Y.length - 1)]);
|
|
864
1067
|
return;
|
|
865
1068
|
}
|
|
866
1069
|
}
|
|
867
|
-
X && e.key === "Escape" ? (e.preventDefault(),
|
|
1070
|
+
X && e.key === "Escape" ? (e.preventDefault(), D(!0)) : e.key === "Backspace" && x && a === "" ? C(null) : e.key === "Enter" && !e.shiftKey && !e.nativeEvent.isComposing && !ye() && (e.preventDefault(), Z(a));
|
|
868
1071
|
};
|
|
869
|
-
|
|
870
|
-
let e =
|
|
1072
|
+
p(() => xe(I.current, () => Se(R.current)), [a]), f(() => {
|
|
1073
|
+
let e = R.current;
|
|
871
1074
|
if (!e || typeof ResizeObserver > "u") return;
|
|
872
1075
|
let t = e.clientWidth, n = new ResizeObserver(() => {
|
|
873
|
-
e.clientWidth !== t && (t = e.clientWidth,
|
|
1076
|
+
e.clientWidth !== t && (t = e.clientWidth, xe(I.current, () => Se(e)));
|
|
874
1077
|
});
|
|
875
1078
|
return n.observe(e), () => n.disconnect();
|
|
876
|
-
}, [
|
|
877
|
-
let
|
|
1079
|
+
}, [B.recording]);
|
|
1080
|
+
let le = async (e) => {
|
|
878
1081
|
if (e?.length && n.onUpload) {
|
|
879
|
-
|
|
1082
|
+
b(!0);
|
|
880
1083
|
for (let t of Array.from(e)) {
|
|
881
1084
|
if (n.upload && t.size > n.upload.maxBytes) {
|
|
882
1085
|
i({
|
|
@@ -887,15 +1090,15 @@ function q(n) {
|
|
|
887
1090
|
continue;
|
|
888
1091
|
}
|
|
889
1092
|
let e = await n.onUpload(t).catch(() => null);
|
|
890
|
-
e &&
|
|
1093
|
+
e && m((t) => [...t, e]);
|
|
891
1094
|
}
|
|
892
|
-
|
|
1095
|
+
b(!1), L.current && (L.current.value = "");
|
|
893
1096
|
}
|
|
894
1097
|
};
|
|
895
|
-
async function
|
|
896
|
-
let e = await
|
|
897
|
-
e && n.onTranscribe && await
|
|
898
|
-
busy:
|
|
1098
|
+
async function Q() {
|
|
1099
|
+
let e = await B.stop();
|
|
1100
|
+
e && n.onTranscribe && await me(e, n.onTranscribe, {
|
|
1101
|
+
busy: j,
|
|
899
1102
|
empty: () => i({
|
|
900
1103
|
kind: "error",
|
|
901
1104
|
title: r("chat.voice.notRecognized")
|
|
@@ -910,73 +1113,74 @@ function q(n) {
|
|
|
910
1113
|
}]
|
|
911
1114
|
}),
|
|
912
1115
|
text: (e) => {
|
|
913
|
-
|
|
1116
|
+
F.current = !0, s((t) => t.trim() ? t.trimEnd() + " " + e : e), R.current?.focus();
|
|
914
1117
|
}
|
|
915
1118
|
});
|
|
916
1119
|
}
|
|
917
|
-
let
|
|
918
|
-
e.key === "Escape" &&
|
|
919
|
-
},
|
|
920
|
-
return /* @__PURE__ */
|
|
1120
|
+
let de = (e) => {
|
|
1121
|
+
e.key === "Escape" && B.recording && (e.preventDefault(), B.cancel());
|
|
1122
|
+
}, fe = x ? r("chat.skillPlaceholder") : n.placeholder ?? r("chat.placeholder", { name: n.agentName }), pe = z - B.seconds;
|
|
1123
|
+
return /* @__PURE__ */ u("section", {
|
|
921
1124
|
className: "nb-chat",
|
|
922
1125
|
"aria-label": r("chat.title"),
|
|
923
1126
|
children: [
|
|
924
1127
|
n.header,
|
|
925
|
-
/* @__PURE__ */
|
|
1128
|
+
/* @__PURE__ */ u("div", {
|
|
926
1129
|
className: "msgs",
|
|
927
|
-
ref:
|
|
1130
|
+
ref: I,
|
|
928
1131
|
"aria-live": "polite",
|
|
929
1132
|
children: [
|
|
930
|
-
n.hasOlder && n.onLoadOlder && /* @__PURE__ */
|
|
1133
|
+
n.hasOlder && n.onLoadOlder && /* @__PURE__ */ l("button", {
|
|
931
1134
|
className: "btn ghost sm",
|
|
932
1135
|
style: { alignSelf: "center" },
|
|
933
1136
|
disabled: n.loadingOlder,
|
|
934
1137
|
onClick: n.onLoadOlder,
|
|
935
1138
|
children: r("chat.loadOlder")
|
|
936
1139
|
}),
|
|
937
|
-
n.historyError && /* @__PURE__ */
|
|
1140
|
+
n.historyError && /* @__PURE__ */ l("div", {
|
|
938
1141
|
className: "err-text",
|
|
939
1142
|
children: n.historyError
|
|
940
1143
|
}),
|
|
941
|
-
|
|
1144
|
+
V.length === 0 && !n.loading && !n.historyError && (n.empty ?? /* @__PURE__ */ u("div", {
|
|
942
1145
|
className: "empty",
|
|
943
1146
|
children: [
|
|
944
|
-
/* @__PURE__ */
|
|
1147
|
+
/* @__PURE__ */ l("div", {
|
|
945
1148
|
className: "ic",
|
|
946
|
-
children: /* @__PURE__ */
|
|
1149
|
+
children: /* @__PURE__ */ l(t, { name: "spark" })
|
|
947
1150
|
}),
|
|
948
|
-
/* @__PURE__ */
|
|
1151
|
+
/* @__PURE__ */ l("b", { children: r("chat.emptyTitle", { name: n.agentName }) }),
|
|
949
1152
|
n.emptyHint
|
|
950
1153
|
]
|
|
951
|
-
}),
|
|
952
|
-
|
|
1154
|
+
})),
|
|
1155
|
+
V.map((e) => /* @__PURE__ */ l(ue, {
|
|
953
1156
|
m: e,
|
|
954
|
-
busy:
|
|
1157
|
+
busy: H,
|
|
955
1158
|
onRetry: n.onRetry && (() => n.onRetry?.(e.id)),
|
|
956
|
-
loadAttachment:
|
|
957
|
-
|
|
1159
|
+
loadAttachment: N,
|
|
1160
|
+
loadPreview: P,
|
|
1161
|
+
onOpenAttachment: M
|
|
958
1162
|
}, e.id)),
|
|
959
|
-
n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */
|
|
1163
|
+
n.onConfirm && (n.confirmations ?? []).map((e) => /* @__PURE__ */ u("div", {
|
|
960
1164
|
className: "confirm",
|
|
961
1165
|
role: "group",
|
|
962
1166
|
"aria-label": r("chat.confirm.title"),
|
|
963
1167
|
children: [
|
|
964
|
-
/* @__PURE__ */
|
|
1168
|
+
/* @__PURE__ */ u("div", {
|
|
965
1169
|
className: "h",
|
|
966
|
-
children: [/* @__PURE__ */
|
|
1170
|
+
children: [/* @__PURE__ */ l(t, {
|
|
967
1171
|
name: "alert",
|
|
968
1172
|
size: 16
|
|
969
1173
|
}), r("chat.confirm.title")]
|
|
970
1174
|
}),
|
|
971
|
-
/* @__PURE__ */
|
|
972
|
-
e.preview !== void 0 && /* @__PURE__ */
|
|
973
|
-
/* @__PURE__ */
|
|
1175
|
+
/* @__PURE__ */ l("div", { children: r("chat.confirm.text", { action: e.summary }) }),
|
|
1176
|
+
e.preview !== void 0 && /* @__PURE__ */ l("pre", { children: e.preview }),
|
|
1177
|
+
/* @__PURE__ */ u("div", {
|
|
974
1178
|
className: "acts",
|
|
975
|
-
children: [/* @__PURE__ */
|
|
1179
|
+
children: [/* @__PURE__ */ l("button", {
|
|
976
1180
|
className: "btn sm primary",
|
|
977
1181
|
onClick: () => n.onConfirm?.(e.id, !0),
|
|
978
1182
|
children: r("chat.confirm.approve")
|
|
979
|
-
}), /* @__PURE__ */
|
|
1183
|
+
}), /* @__PURE__ */ l("button", {
|
|
980
1184
|
className: "btn sm",
|
|
981
1185
|
onClick: () => n.onConfirm?.(e.id, !1),
|
|
982
1186
|
children: r("chat.confirm.reject")
|
|
@@ -986,42 +1190,42 @@ function q(n) {
|
|
|
986
1190
|
}, e.id))
|
|
987
1191
|
]
|
|
988
1192
|
}),
|
|
989
|
-
n.readOnly ? /* @__PURE__ */
|
|
1193
|
+
n.readOnly ? /* @__PURE__ */ l("div", {
|
|
990
1194
|
className: "composer",
|
|
991
1195
|
style: {
|
|
992
1196
|
justifyContent: "space-between",
|
|
993
1197
|
alignItems: "center"
|
|
994
1198
|
},
|
|
995
1199
|
children: n.readOnly
|
|
996
|
-
}) : /* @__PURE__ */
|
|
1200
|
+
}) : /* @__PURE__ */ u("div", {
|
|
997
1201
|
className: "composer-wrap",
|
|
998
1202
|
children: [
|
|
999
|
-
X && /* @__PURE__ */
|
|
1203
|
+
X && /* @__PURE__ */ l(y, {
|
|
1000
1204
|
items: Y,
|
|
1001
|
-
active: Math.min(
|
|
1002
|
-
onPick:
|
|
1003
|
-
onHover:
|
|
1205
|
+
active: Math.min(w, Math.max(Y.length - 1, 0)),
|
|
1206
|
+
onPick: se,
|
|
1207
|
+
onHover: T
|
|
1004
1208
|
}),
|
|
1005
1209
|
n.aboveComposer,
|
|
1006
|
-
|
|
1210
|
+
d.length > 0 && /* @__PURE__ */ l("div", {
|
|
1007
1211
|
className: "pending-files",
|
|
1008
|
-
children:
|
|
1212
|
+
children: d.map((e) => /* @__PURE__ */ u("span", {
|
|
1009
1213
|
className: "chip",
|
|
1010
1214
|
children: [
|
|
1011
|
-
/* @__PURE__ */
|
|
1215
|
+
/* @__PURE__ */ l(t, {
|
|
1012
1216
|
name: "clip",
|
|
1013
1217
|
size: 12
|
|
1014
1218
|
}),
|
|
1015
1219
|
e.fileName,
|
|
1016
|
-
/* @__PURE__ */
|
|
1220
|
+
/* @__PURE__ */ l("button", {
|
|
1017
1221
|
className: "iconbtn",
|
|
1018
1222
|
style: {
|
|
1019
1223
|
width: 18,
|
|
1020
1224
|
height: 18
|
|
1021
1225
|
},
|
|
1022
1226
|
"aria-label": r("remove"),
|
|
1023
|
-
onClick: () =>
|
|
1024
|
-
children: /* @__PURE__ */
|
|
1227
|
+
onClick: () => m((t) => t.filter((t) => t.id !== e.id)),
|
|
1228
|
+
children: /* @__PURE__ */ l(t, {
|
|
1025
1229
|
name: "x",
|
|
1026
1230
|
size: 12
|
|
1027
1231
|
})
|
|
@@ -1029,279 +1233,288 @@ function q(n) {
|
|
|
1029
1233
|
]
|
|
1030
1234
|
}, e.id))
|
|
1031
1235
|
}),
|
|
1032
|
-
|
|
1236
|
+
O && /* @__PURE__ */ u("div", {
|
|
1033
1237
|
className: "cmd-unknown",
|
|
1034
1238
|
role: "status",
|
|
1035
|
-
children: [r("chat.unknownCommand", { name:
|
|
1239
|
+
children: [r("chat.unknownCommand", { name: O }), /* @__PURE__ */ l("button", {
|
|
1036
1240
|
type: "button",
|
|
1037
1241
|
className: "textbtn",
|
|
1038
|
-
onClick: () => void
|
|
1242
|
+
onClick: () => void Z(a, !0),
|
|
1039
1243
|
children: r("chat.sendAsText")
|
|
1040
1244
|
})]
|
|
1041
1245
|
}),
|
|
1042
|
-
/* @__PURE__ */
|
|
1246
|
+
/* @__PURE__ */ u("div", {
|
|
1043
1247
|
className: "composer",
|
|
1044
1248
|
children: [
|
|
1045
|
-
n.onUpload && !
|
|
1249
|
+
n.onUpload && !B.recording && /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
|
|
1046
1250
|
className: "iconbtn",
|
|
1047
1251
|
"aria-label": r("chat.attach"),
|
|
1048
|
-
disabled:
|
|
1049
|
-
onClick: () =>
|
|
1050
|
-
children: /* @__PURE__ */
|
|
1051
|
-
}), /* @__PURE__ */
|
|
1052
|
-
ref:
|
|
1252
|
+
disabled: _,
|
|
1253
|
+
onClick: () => L.current?.click(),
|
|
1254
|
+
children: /* @__PURE__ */ l(t, { name: "clip" })
|
|
1255
|
+
}), /* @__PURE__ */ l("input", {
|
|
1256
|
+
ref: L,
|
|
1053
1257
|
type: "file",
|
|
1054
1258
|
multiple: !0,
|
|
1055
1259
|
hidden: !0,
|
|
1056
1260
|
accept: n.upload?.accept,
|
|
1057
|
-
onChange: (e) =>
|
|
1261
|
+
onChange: (e) => le(e.target.files)
|
|
1058
1262
|
})] }),
|
|
1059
|
-
|
|
1060
|
-
className: `recbar${
|
|
1263
|
+
B.recording ? /* @__PURE__ */ u("div", {
|
|
1264
|
+
className: `recbar${pe <= 15 ? " ending" : ""}`,
|
|
1061
1265
|
role: "status",
|
|
1062
1266
|
"aria-label": r("chat.voice.recordingNow"),
|
|
1063
1267
|
children: [
|
|
1064
|
-
/* @__PURE__ */
|
|
1268
|
+
/* @__PURE__ */ l("span", {
|
|
1065
1269
|
className: "dot",
|
|
1066
1270
|
"aria-hidden": "true"
|
|
1067
1271
|
}),
|
|
1068
|
-
/* @__PURE__ */
|
|
1272
|
+
/* @__PURE__ */ u("span", {
|
|
1069
1273
|
className: "tm",
|
|
1070
1274
|
children: [
|
|
1071
|
-
|
|
1275
|
+
ge(B.seconds),
|
|
1072
1276
|
" / ",
|
|
1073
|
-
|
|
1277
|
+
ge(z)
|
|
1074
1278
|
]
|
|
1075
1279
|
}),
|
|
1076
|
-
/* @__PURE__ */
|
|
1280
|
+
/* @__PURE__ */ l("span", {
|
|
1077
1281
|
className: "lvl",
|
|
1078
1282
|
"aria-hidden": "true",
|
|
1079
|
-
children: /* @__PURE__ */
|
|
1283
|
+
children: /* @__PURE__ */ l("i", { style: { transform: `scaleX(${Math.max(.04, B.level)})` } })
|
|
1080
1284
|
}),
|
|
1081
|
-
/* @__PURE__ */
|
|
1285
|
+
/* @__PURE__ */ l("button", {
|
|
1082
1286
|
type: "button",
|
|
1083
1287
|
className: "btn ghost sm",
|
|
1084
|
-
onClick:
|
|
1288
|
+
onClick: B.cancel,
|
|
1085
1289
|
children: r("cancel")
|
|
1086
1290
|
}),
|
|
1087
|
-
/* @__PURE__ */
|
|
1291
|
+
/* @__PURE__ */ l("button", {
|
|
1088
1292
|
type: "button",
|
|
1089
1293
|
className: "btn primary sm",
|
|
1090
|
-
onKeyDown:
|
|
1091
|
-
onClick: () => void
|
|
1294
|
+
onKeyDown: de,
|
|
1295
|
+
onClick: () => void Q(),
|
|
1092
1296
|
children: r("chat.voice.done")
|
|
1093
1297
|
})
|
|
1094
1298
|
]
|
|
1095
|
-
}) : /* @__PURE__ */
|
|
1096
|
-
className: `field${
|
|
1097
|
-
"aria-busy":
|
|
1098
|
-
children: [
|
|
1299
|
+
}) : /* @__PURE__ */ u("div", {
|
|
1300
|
+
className: `field${x ? " with-skill" : ""}${A ? " recognizing" : ""}`,
|
|
1301
|
+
"aria-busy": A || void 0,
|
|
1302
|
+
children: [x && /* @__PURE__ */ u("span", {
|
|
1099
1303
|
className: "chip skill-chip",
|
|
1100
1304
|
children: [
|
|
1101
|
-
/* @__PURE__ */
|
|
1305
|
+
/* @__PURE__ */ l(t, {
|
|
1102
1306
|
name: "spark",
|
|
1103
1307
|
size: 12
|
|
1104
1308
|
}),
|
|
1105
|
-
|
|
1106
|
-
/* @__PURE__ */
|
|
1309
|
+
x,
|
|
1310
|
+
/* @__PURE__ */ l("button", {
|
|
1107
1311
|
className: "iconbtn",
|
|
1108
1312
|
style: {
|
|
1109
1313
|
width: 18,
|
|
1110
1314
|
height: 18
|
|
1111
1315
|
},
|
|
1112
1316
|
"aria-label": r("remove"),
|
|
1113
|
-
onClick: () =>
|
|
1114
|
-
children: /* @__PURE__ */
|
|
1317
|
+
onClick: () => C(null),
|
|
1318
|
+
children: /* @__PURE__ */ l(t, {
|
|
1115
1319
|
name: "x",
|
|
1116
1320
|
size: 12
|
|
1117
1321
|
})
|
|
1118
1322
|
})
|
|
1119
1323
|
]
|
|
1120
|
-
}), /* @__PURE__ */
|
|
1121
|
-
ref:
|
|
1324
|
+
}), /* @__PURE__ */ l("textarea", {
|
|
1325
|
+
ref: R,
|
|
1122
1326
|
rows: 1,
|
|
1123
|
-
value:
|
|
1124
|
-
placeholder:
|
|
1125
|
-
"aria-label":
|
|
1126
|
-
disabled:
|
|
1327
|
+
value: a,
|
|
1328
|
+
placeholder: A ? r("chat.voice.recognizing") : fe,
|
|
1329
|
+
"aria-label": fe,
|
|
1330
|
+
disabled: A,
|
|
1127
1331
|
"aria-expanded": X,
|
|
1128
1332
|
"aria-autocomplete": n.commands ? "list" : void 0,
|
|
1129
1333
|
onChange: (e) => {
|
|
1130
|
-
|
|
1334
|
+
s(e.target.value), D(!1), T(0), k(null);
|
|
1131
1335
|
},
|
|
1132
|
-
onKeyDown:
|
|
1336
|
+
onKeyDown: ce
|
|
1133
1337
|
})]
|
|
1134
1338
|
}),
|
|
1135
|
-
n.context && !
|
|
1339
|
+
n.context && !B.recording && /* @__PURE__ */ l(S, {
|
|
1136
1340
|
context: n.context,
|
|
1137
1341
|
onCompact: n.onCompact,
|
|
1138
1342
|
onReset: n.onReset,
|
|
1139
|
-
busy:
|
|
1343
|
+
busy: te
|
|
1140
1344
|
}),
|
|
1141
|
-
n.onTranscribe && !
|
|
1142
|
-
supported:
|
|
1143
|
-
recognizing:
|
|
1144
|
-
onStart: () => void
|
|
1345
|
+
n.onTranscribe && !B.recording && /* @__PURE__ */ l(ve, {
|
|
1346
|
+
supported: B.supported,
|
|
1347
|
+
recognizing: A,
|
|
1348
|
+
onStart: () => void B.start()
|
|
1145
1349
|
}),
|
|
1146
|
-
!
|
|
1350
|
+
!B.recording && (n.onCancel && H ? /* @__PURE__ */ l("button", {
|
|
1147
1351
|
className: "iconbtn fill",
|
|
1148
1352
|
"aria-label": r("chat.stop"),
|
|
1149
1353
|
onClick: n.onCancel,
|
|
1150
|
-
children: /* @__PURE__ */
|
|
1151
|
-
}) : /* @__PURE__ */
|
|
1354
|
+
children: /* @__PURE__ */ l(t, { name: "stop" })
|
|
1355
|
+
}) : /* @__PURE__ */ l("button", {
|
|
1152
1356
|
className: "iconbtn fill",
|
|
1153
1357
|
"aria-label": r("chat.send"),
|
|
1154
|
-
disabled: !
|
|
1155
|
-
onClick: () =>
|
|
1156
|
-
children: /* @__PURE__ */
|
|
1358
|
+
disabled: !a.trim() && d.length === 0 && !x || H || A,
|
|
1359
|
+
onClick: () => Z(a),
|
|
1360
|
+
children: /* @__PURE__ */ l(t, { name: "send" })
|
|
1157
1361
|
}))
|
|
1158
1362
|
]
|
|
1159
1363
|
}),
|
|
1160
|
-
|
|
1364
|
+
B.error && /* @__PURE__ */ l("div", {
|
|
1161
1365
|
className: "err-text",
|
|
1162
1366
|
style: { padding: "0 12px 8px" },
|
|
1163
1367
|
children: r("chat.voice.micDenied")
|
|
1164
1368
|
})
|
|
1165
1369
|
]
|
|
1166
1370
|
}),
|
|
1167
|
-
|
|
1168
|
-
a:
|
|
1169
|
-
load:
|
|
1170
|
-
|
|
1371
|
+
ee && N && /* @__PURE__ */ l(ne, {
|
|
1372
|
+
a: ee,
|
|
1373
|
+
load: N,
|
|
1374
|
+
loadPreview: P,
|
|
1375
|
+
onClose: () => M(null)
|
|
1171
1376
|
})
|
|
1172
1377
|
]
|
|
1173
1378
|
});
|
|
1174
1379
|
}
|
|
1175
|
-
function
|
|
1176
|
-
let i =
|
|
1177
|
-
return n ? /* @__PURE__ */
|
|
1380
|
+
function ve({ supported: e, recognizing: n, onStart: r }) {
|
|
1381
|
+
let i = o();
|
|
1382
|
+
return n ? /* @__PURE__ */ u("span", {
|
|
1178
1383
|
className: "voicewait",
|
|
1179
1384
|
role: "status",
|
|
1180
1385
|
"aria-label": i("chat.voice.recognizing"),
|
|
1181
1386
|
title: i("chat.voice.recognizing"),
|
|
1182
1387
|
children: [
|
|
1183
|
-
/* @__PURE__ */
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
/* @__PURE__ */
|
|
1187
|
-
/* @__PURE__ */
|
|
1388
|
+
/* @__PURE__ */ l("i", {}),
|
|
1389
|
+
/* @__PURE__ */ l("i", {}),
|
|
1390
|
+
/* @__PURE__ */ l("i", {}),
|
|
1391
|
+
/* @__PURE__ */ l("i", {}),
|
|
1392
|
+
/* @__PURE__ */ l("i", {})
|
|
1188
1393
|
]
|
|
1189
|
-
}) : /* @__PURE__ */
|
|
1394
|
+
}) : /* @__PURE__ */ l("button", {
|
|
1190
1395
|
className: "iconbtn",
|
|
1191
1396
|
disabled: !e,
|
|
1192
1397
|
"aria-label": i("chat.voice.start"),
|
|
1193
1398
|
title: i(e ? "chat.voice.start" : "chat.voice.unsupported"),
|
|
1194
1399
|
onClick: r,
|
|
1195
|
-
children: /* @__PURE__ */
|
|
1400
|
+
children: /* @__PURE__ */ l(t, { name: "mic" })
|
|
1196
1401
|
});
|
|
1197
1402
|
}
|
|
1198
|
-
function
|
|
1403
|
+
function ye() {
|
|
1199
1404
|
return typeof window < "u" && !!window.matchMedia?.("(hover: none) and (pointer: coarse)").matches;
|
|
1200
1405
|
}
|
|
1201
|
-
var
|
|
1202
|
-
function
|
|
1203
|
-
let n = !!e &&
|
|
1406
|
+
var be = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
|
|
1407
|
+
function xe(e, t) {
|
|
1408
|
+
let n = !!e && be(e);
|
|
1204
1409
|
t(), e && n && (e.scrollTop = e.scrollHeight);
|
|
1205
1410
|
}
|
|
1206
|
-
function
|
|
1411
|
+
function Se(e) {
|
|
1207
1412
|
if (!e) return;
|
|
1208
1413
|
e.style.overflowY = "hidden", e.style.height = "auto";
|
|
1209
1414
|
let t = e.scrollHeight + e.offsetHeight - e.clientHeight;
|
|
1210
1415
|
e.style.height = `${t}px`, e.style.overflowY = e.offsetHeight < t ? "auto" : "hidden";
|
|
1211
1416
|
}
|
|
1417
|
+
function Ce(e) {
|
|
1418
|
+
let t = h(e);
|
|
1419
|
+
f(() => {
|
|
1420
|
+
t.current = e;
|
|
1421
|
+
});
|
|
1422
|
+
let n = !!e;
|
|
1423
|
+
return m(() => n ? (e) => t.current ? t.current(e) : Promise.reject(/* @__PURE__ */ Error("no loader")) : void 0, [n]);
|
|
1424
|
+
}
|
|
1212
1425
|
//#endregion
|
|
1213
1426
|
//#region src/chat/ConversationList.tsx
|
|
1214
|
-
function
|
|
1215
|
-
let
|
|
1216
|
-
|
|
1427
|
+
function we({ conversations: e, currentId: n, open: r, onPick: i, onClose: a, onCreate: s }) {
|
|
1428
|
+
let d = o(), [p, m] = g(!1);
|
|
1429
|
+
f(() => {
|
|
1217
1430
|
if (!r) return;
|
|
1218
|
-
let e = (e) => e.key === "Escape" &&
|
|
1431
|
+
let e = (e) => e.key === "Escape" && a();
|
|
1219
1432
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
1220
|
-
}, [r,
|
|
1221
|
-
let
|
|
1433
|
+
}, [r, a]);
|
|
1434
|
+
let h = (e) => /* @__PURE__ */ u("button", {
|
|
1222
1435
|
className: `it${e.id === n ? " on" : ""}${e.group === "archive" ? " arch" : ""}`,
|
|
1223
1436
|
onClick: () => i(e.id),
|
|
1224
1437
|
"aria-current": e.id === n,
|
|
1225
1438
|
children: [
|
|
1226
|
-
/* @__PURE__ */
|
|
1439
|
+
/* @__PURE__ */ l(t, {
|
|
1227
1440
|
name: e.icon ?? "msg2",
|
|
1228
1441
|
size: 16
|
|
1229
1442
|
}),
|
|
1230
|
-
/* @__PURE__ */
|
|
1443
|
+
/* @__PURE__ */ l("span", {
|
|
1231
1444
|
className: "nm",
|
|
1232
1445
|
children: e.title
|
|
1233
1446
|
}),
|
|
1234
|
-
!!e.unread && /* @__PURE__ */
|
|
1447
|
+
!!e.unread && /* @__PURE__ */ l("span", {
|
|
1235
1448
|
className: "unread",
|
|
1236
|
-
"aria-label":
|
|
1449
|
+
"aria-label": d("chat.unread", { count: e.unread }),
|
|
1237
1450
|
children: e.unread
|
|
1238
1451
|
}),
|
|
1239
|
-
/* @__PURE__ */
|
|
1452
|
+
/* @__PURE__ */ l("span", {
|
|
1240
1453
|
className: "sub",
|
|
1241
1454
|
children: e.when
|
|
1242
1455
|
})
|
|
1243
1456
|
]
|
|
1244
1457
|
}, e.id), _ = (t) => e.filter((e) => e.group === t), v = _("topic"), y = _("archive");
|
|
1245
|
-
return /* @__PURE__ */
|
|
1246
|
-
/* @__PURE__ */
|
|
1458
|
+
return /* @__PURE__ */ u(c, { children: [
|
|
1459
|
+
/* @__PURE__ */ u("nav", {
|
|
1247
1460
|
className: `nb-side${r ? " open" : ""}`,
|
|
1248
|
-
"aria-label":
|
|
1461
|
+
"aria-label": d("chat.conversations"),
|
|
1249
1462
|
children: [
|
|
1250
|
-
|
|
1463
|
+
s && /* @__PURE__ */ u("button", {
|
|
1251
1464
|
className: "btn sm",
|
|
1252
1465
|
style: {
|
|
1253
1466
|
width: "100%",
|
|
1254
1467
|
justifyContent: "center"
|
|
1255
1468
|
},
|
|
1256
1469
|
onClick: () => m(!0),
|
|
1257
|
-
children: [/* @__PURE__ */
|
|
1470
|
+
children: [/* @__PURE__ */ l(t, {
|
|
1258
1471
|
name: "plus",
|
|
1259
1472
|
size: 15
|
|
1260
|
-
}),
|
|
1473
|
+
}), d("chat.newTopic")]
|
|
1261
1474
|
}),
|
|
1262
|
-
/* @__PURE__ */
|
|
1475
|
+
/* @__PURE__ */ l("div", {
|
|
1263
1476
|
className: "h",
|
|
1264
|
-
children:
|
|
1477
|
+
children: d("chat.conversation")
|
|
1265
1478
|
}),
|
|
1266
|
-
_("main").map(
|
|
1267
|
-
/* @__PURE__ */
|
|
1479
|
+
_("main").map(h),
|
|
1480
|
+
/* @__PURE__ */ l("div", {
|
|
1268
1481
|
className: "h",
|
|
1269
|
-
children:
|
|
1482
|
+
children: d("chat.topics")
|
|
1270
1483
|
}),
|
|
1271
|
-
v.length === 0 && /* @__PURE__ */
|
|
1484
|
+
v.length === 0 && /* @__PURE__ */ l("div", {
|
|
1272
1485
|
className: "small muted",
|
|
1273
1486
|
style: { padding: "0 10px" },
|
|
1274
|
-
children:
|
|
1487
|
+
children: d("chat.noTopics")
|
|
1275
1488
|
}),
|
|
1276
|
-
v.map(
|
|
1277
|
-
y.length > 0 && /* @__PURE__ */
|
|
1489
|
+
v.map(h),
|
|
1490
|
+
y.length > 0 && /* @__PURE__ */ l("div", {
|
|
1278
1491
|
className: "h",
|
|
1279
|
-
children:
|
|
1492
|
+
children: d("chat.archive")
|
|
1280
1493
|
}),
|
|
1281
|
-
y.map(
|
|
1494
|
+
y.map(h)
|
|
1282
1495
|
]
|
|
1283
1496
|
}),
|
|
1284
|
-
r && /* @__PURE__ */
|
|
1497
|
+
r && /* @__PURE__ */ l("button", {
|
|
1285
1498
|
type: "button",
|
|
1286
1499
|
className: "nb-scrim",
|
|
1287
|
-
"aria-label":
|
|
1288
|
-
onClick:
|
|
1500
|
+
"aria-label": d("close"),
|
|
1501
|
+
onClick: a
|
|
1289
1502
|
}),
|
|
1290
|
-
p &&
|
|
1503
|
+
p && s && /* @__PURE__ */ l(Ee, {
|
|
1291
1504
|
onClose: () => m(!1),
|
|
1292
|
-
onCreate:
|
|
1505
|
+
onCreate: s
|
|
1293
1506
|
})
|
|
1294
1507
|
] });
|
|
1295
1508
|
}
|
|
1296
|
-
function
|
|
1297
|
-
return /* @__PURE__ */
|
|
1509
|
+
function Te({ narrow: e, children: t }) {
|
|
1510
|
+
return /* @__PURE__ */ l("div", {
|
|
1298
1511
|
className: `nb-app${e ? " narrow" : ""}`,
|
|
1299
1512
|
children: t
|
|
1300
1513
|
});
|
|
1301
1514
|
}
|
|
1302
|
-
function
|
|
1303
|
-
let r =
|
|
1304
|
-
if (i.trim() && !
|
|
1515
|
+
function Ee({ onClose: e, onCreate: t }) {
|
|
1516
|
+
let r = o(), [i, a] = g(""), [s, d] = g(!1), [f, p] = g(null), m = async () => {
|
|
1517
|
+
if (i.trim() && !s) {
|
|
1305
1518
|
d(!0), p(null);
|
|
1306
1519
|
try {
|
|
1307
1520
|
await t(i.trim()), e();
|
|
@@ -1310,40 +1523,40 @@ function J({ onClose: e, onCreate: t }) {
|
|
|
1310
1523
|
}
|
|
1311
1524
|
}
|
|
1312
1525
|
};
|
|
1313
|
-
return /* @__PURE__ */
|
|
1526
|
+
return /* @__PURE__ */ u(n, {
|
|
1314
1527
|
title: r("chat.newTopic"),
|
|
1315
1528
|
onClose: e,
|
|
1316
|
-
footer: /* @__PURE__ */
|
|
1529
|
+
footer: /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ l("button", {
|
|
1317
1530
|
className: "btn ghost",
|
|
1318
1531
|
onClick: e,
|
|
1319
1532
|
children: r("cancel")
|
|
1320
|
-
}), /* @__PURE__ */
|
|
1533
|
+
}), /* @__PURE__ */ l("button", {
|
|
1321
1534
|
className: "btn primary",
|
|
1322
|
-
disabled: !i.trim() ||
|
|
1535
|
+
disabled: !i.trim() || s,
|
|
1323
1536
|
onClick: m,
|
|
1324
1537
|
children: r("create")
|
|
1325
1538
|
})] }),
|
|
1326
|
-
children: [/* @__PURE__ */
|
|
1539
|
+
children: [/* @__PURE__ */ u("div", {
|
|
1327
1540
|
className: "field",
|
|
1328
1541
|
children: [
|
|
1329
|
-
/* @__PURE__ */
|
|
1542
|
+
/* @__PURE__ */ l("label", {
|
|
1330
1543
|
htmlFor: "topic-title",
|
|
1331
1544
|
children: r("chat.topicTitle")
|
|
1332
1545
|
}),
|
|
1333
|
-
/* @__PURE__ */
|
|
1546
|
+
/* @__PURE__ */ l("input", {
|
|
1334
1547
|
id: "topic-title",
|
|
1335
1548
|
className: "inp",
|
|
1336
1549
|
value: i,
|
|
1337
1550
|
maxLength: 120,
|
|
1338
|
-
onChange: (e) =>
|
|
1551
|
+
onChange: (e) => a(e.target.value),
|
|
1339
1552
|
onKeyDown: (e) => e.key === "Enter" && m()
|
|
1340
1553
|
}),
|
|
1341
|
-
/* @__PURE__ */
|
|
1554
|
+
/* @__PURE__ */ l("div", {
|
|
1342
1555
|
className: "hint",
|
|
1343
1556
|
children: r("chat.topicHint")
|
|
1344
1557
|
})
|
|
1345
1558
|
]
|
|
1346
|
-
}), f && /* @__PURE__ */
|
|
1559
|
+
}), f && /* @__PURE__ */ l("div", {
|
|
1347
1560
|
className: "err-text",
|
|
1348
1561
|
children: f
|
|
1349
1562
|
})]
|
|
@@ -1351,8 +1564,8 @@ function J({ onClose: e, onCreate: t }) {
|
|
|
1351
1564
|
}
|
|
1352
1565
|
//#endregion
|
|
1353
1566
|
//#region src/chat/AgentMenu.tsx
|
|
1354
|
-
function
|
|
1355
|
-
return /* @__PURE__ */
|
|
1567
|
+
function De({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
|
|
1568
|
+
return /* @__PURE__ */ l("button", {
|
|
1356
1569
|
type: "button",
|
|
1357
1570
|
className: `agentbtn${a ? " s" : ""}`,
|
|
1358
1571
|
disabled: o,
|
|
@@ -1361,25 +1574,25 @@ function Y({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, on
|
|
|
1361
1574
|
title: r,
|
|
1362
1575
|
onMouseDown: (e) => i && e.stopPropagation(),
|
|
1363
1576
|
onClick: s,
|
|
1364
|
-
children: /* @__PURE__ */
|
|
1577
|
+
children: /* @__PURE__ */ l(t, {
|
|
1365
1578
|
name: e,
|
|
1366
1579
|
size: a ? 15 : 18
|
|
1367
1580
|
})
|
|
1368
1581
|
});
|
|
1369
1582
|
}
|
|
1370
|
-
function
|
|
1371
|
-
let v =
|
|
1372
|
-
return /* @__PURE__ */
|
|
1583
|
+
function Oe({ label: e, name: n, options: r, value: a, optionsLabel: s, hint: d, narrow: f, models: p, onRename: m, onPick: h, onClose: _ }) {
|
|
1584
|
+
let v = o(), [y, b] = g(n), x = i(!0, _);
|
|
1585
|
+
return /* @__PURE__ */ u("div", {
|
|
1373
1586
|
className: `agentmenu${f ? " narrow" : ""}`,
|
|
1374
1587
|
ref: x,
|
|
1375
1588
|
role: "dialog",
|
|
1376
1589
|
"aria-label": e,
|
|
1377
1590
|
children: [
|
|
1378
|
-
/* @__PURE__ */
|
|
1591
|
+
/* @__PURE__ */ l("div", {
|
|
1379
1592
|
className: "lab",
|
|
1380
1593
|
children: v("agentName")
|
|
1381
1594
|
}),
|
|
1382
|
-
/* @__PURE__ */
|
|
1595
|
+
/* @__PURE__ */ l("input", {
|
|
1383
1596
|
className: "inp",
|
|
1384
1597
|
value: y,
|
|
1385
1598
|
maxLength: 40,
|
|
@@ -1392,74 +1605,74 @@ function X({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
1392
1605
|
},
|
|
1393
1606
|
onKeyDown: (e) => e.key === "Enter" && e.target.blur()
|
|
1394
1607
|
}),
|
|
1395
|
-
/* @__PURE__ */
|
|
1608
|
+
/* @__PURE__ */ l("div", {
|
|
1396
1609
|
className: "lab",
|
|
1397
1610
|
style: { marginTop: 14 },
|
|
1398
|
-
children:
|
|
1611
|
+
children: s
|
|
1399
1612
|
}),
|
|
1400
|
-
/* @__PURE__ */
|
|
1613
|
+
/* @__PURE__ */ l("div", {
|
|
1401
1614
|
className: "agentoptions",
|
|
1402
|
-
children: r.map((e) => /* @__PURE__ */
|
|
1615
|
+
children: r.map((e) => /* @__PURE__ */ u("button", {
|
|
1403
1616
|
type: "button",
|
|
1404
|
-
className: `agentoption${
|
|
1405
|
-
"aria-pressed":
|
|
1406
|
-
onClick: () =>
|
|
1407
|
-
children: [/* @__PURE__ */
|
|
1617
|
+
className: `agentoption${a === e.key ? " on" : ""}`,
|
|
1618
|
+
"aria-pressed": a === e.key,
|
|
1619
|
+
onClick: () => h(e.key),
|
|
1620
|
+
children: [/* @__PURE__ */ l("span", {
|
|
1408
1621
|
className: "ic",
|
|
1409
|
-
children: /* @__PURE__ */
|
|
1622
|
+
children: /* @__PURE__ */ l(t, {
|
|
1410
1623
|
name: e.icon,
|
|
1411
1624
|
size: 15
|
|
1412
1625
|
})
|
|
1413
1626
|
}), e.label]
|
|
1414
1627
|
}, e.key))
|
|
1415
1628
|
}),
|
|
1416
|
-
p && /* @__PURE__ */
|
|
1417
|
-
/* @__PURE__ */
|
|
1629
|
+
p && /* @__PURE__ */ u(c, { children: [
|
|
1630
|
+
/* @__PURE__ */ l("div", {
|
|
1418
1631
|
className: "lab",
|
|
1419
1632
|
style: { marginTop: 14 },
|
|
1420
1633
|
children: p.label
|
|
1421
1634
|
}),
|
|
1422
|
-
p.options.length === 0 && /* @__PURE__ */
|
|
1635
|
+
p.options.length === 0 && /* @__PURE__ */ l("div", {
|
|
1423
1636
|
className: "hint",
|
|
1424
1637
|
children: p.empty
|
|
1425
1638
|
}),
|
|
1426
|
-
/* @__PURE__ */
|
|
1639
|
+
/* @__PURE__ */ l("div", {
|
|
1427
1640
|
className: "agentmodels",
|
|
1428
1641
|
role: "radiogroup",
|
|
1429
1642
|
children: p.options.map((e) => {
|
|
1430
1643
|
let n = p.options.length === 1, r = n || p.value === e.key;
|
|
1431
|
-
return /* @__PURE__ */
|
|
1644
|
+
return /* @__PURE__ */ u("button", {
|
|
1432
1645
|
type: "button",
|
|
1433
1646
|
role: "radio",
|
|
1434
1647
|
"aria-checked": r,
|
|
1435
1648
|
disabled: n,
|
|
1436
1649
|
className: `agentmodel${r ? " on" : ""}`,
|
|
1437
1650
|
onClick: () => !r && p.onPick(e.key),
|
|
1438
|
-
children: [!n && /* @__PURE__ */
|
|
1651
|
+
children: [!n && /* @__PURE__ */ l("span", {
|
|
1439
1652
|
className: `radio${r ? " on" : ""}`,
|
|
1440
1653
|
"aria-hidden": "true"
|
|
1441
|
-
}), /* @__PURE__ */
|
|
1654
|
+
}), /* @__PURE__ */ u("span", {
|
|
1442
1655
|
className: "body",
|
|
1443
1656
|
children: [
|
|
1444
|
-
/* @__PURE__ */
|
|
1657
|
+
/* @__PURE__ */ l("span", {
|
|
1445
1658
|
className: "nm",
|
|
1446
1659
|
children: e.label
|
|
1447
1660
|
}),
|
|
1448
|
-
e.sub && /* @__PURE__ */
|
|
1661
|
+
e.sub && /* @__PURE__ */ l("span", {
|
|
1449
1662
|
className: "sub",
|
|
1450
1663
|
children: e.sub
|
|
1451
1664
|
}),
|
|
1452
|
-
e.badges && e.badges.length > 0 && /* @__PURE__ */
|
|
1665
|
+
e.badges && e.badges.length > 0 && /* @__PURE__ */ l("span", {
|
|
1453
1666
|
className: "badges",
|
|
1454
|
-
children: e.badges.map((e) => /* @__PURE__ */
|
|
1667
|
+
children: e.badges.map((e) => /* @__PURE__ */ u("span", {
|
|
1455
1668
|
className: "cap",
|
|
1456
|
-
children: [e.icon && /* @__PURE__ */
|
|
1669
|
+
children: [e.icon && /* @__PURE__ */ l(t, {
|
|
1457
1670
|
name: e.icon,
|
|
1458
1671
|
size: 11
|
|
1459
1672
|
}), e.text]
|
|
1460
1673
|
}, e.text))
|
|
1461
1674
|
}),
|
|
1462
|
-
r && e.warn && /* @__PURE__ */
|
|
1675
|
+
r && e.warn && /* @__PURE__ */ l("span", {
|
|
1463
1676
|
className: "warn",
|
|
1464
1677
|
children: e.warn
|
|
1465
1678
|
})
|
|
@@ -1469,7 +1682,7 @@ function X({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
1469
1682
|
})
|
|
1470
1683
|
})
|
|
1471
1684
|
] }),
|
|
1472
|
-
d && /* @__PURE__ */
|
|
1685
|
+
d && /* @__PURE__ */ l("div", {
|
|
1473
1686
|
className: "hint",
|
|
1474
1687
|
style: { marginTop: 10 },
|
|
1475
1688
|
children: d
|
|
@@ -1479,8 +1692,8 @@ function X({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
1479
1692
|
}
|
|
1480
1693
|
//#endregion
|
|
1481
1694
|
//#region src/chat/AgentSettingsMenu.tsx
|
|
1482
|
-
var
|
|
1483
|
-
function
|
|
1695
|
+
var $ = (e) => `${e.connectionId}/${e.model}`;
|
|
1696
|
+
function ke(e, t, n) {
|
|
1484
1697
|
let r = (n) => [
|
|
1485
1698
|
...n.caps.image ? [{
|
|
1486
1699
|
icon: "image",
|
|
@@ -1490,9 +1703,9 @@ function Q(e, t, n) {
|
|
|
1490
1703
|
icon: "brain",
|
|
1491
1704
|
text: e("agent.capReasoning")
|
|
1492
1705
|
}] : [],
|
|
1493
|
-
...n.caps.contextWindow > 0 ? [{ text:
|
|
1706
|
+
...n.caps.contextWindow > 0 ? [{ text: x(n.caps.contextWindow, t) }] : []
|
|
1494
1707
|
], i = (t) => t.caps.contextWindow > 0 && n.contextTokens > .8 * t.caps.contextWindow ? e("agent.modelCompactWarn") : void 0, a = n.available.length > 1, o = n.available.map((e) => ({
|
|
1495
|
-
key:
|
|
1708
|
+
key: $(e),
|
|
1496
1709
|
label: e.name,
|
|
1497
1710
|
sub: e.connection,
|
|
1498
1711
|
badges: r(e),
|
|
@@ -1505,12 +1718,12 @@ function Q(e, t, n) {
|
|
|
1505
1718
|
sub: n.defaultModel?.name ?? "—",
|
|
1506
1719
|
warn: n.defaultModel ? i(n.defaultModel) : void 0
|
|
1507
1720
|
}, ...o] : o,
|
|
1508
|
-
value: n.chosen && n.model ?
|
|
1721
|
+
value: n.chosen && n.model ? $(n.model) : a ? "" : n.model ? $(n.model) : ""
|
|
1509
1722
|
};
|
|
1510
1723
|
}
|
|
1511
|
-
function
|
|
1512
|
-
let d =
|
|
1513
|
-
return /* @__PURE__ */
|
|
1724
|
+
function Ae({ name: e, value: t, options: n, models: r, hint: i, onRename: a, onPick: s, onModel: c, onClose: u }) {
|
|
1725
|
+
let d = o(), { i18n: f } = _(), p = r && c ? ke(d, f.language, r) : null;
|
|
1726
|
+
return /* @__PURE__ */ l(Oe, {
|
|
1514
1727
|
label: d("agent.menu"),
|
|
1515
1728
|
name: e,
|
|
1516
1729
|
value: t,
|
|
@@ -1522,22 +1735,22 @@ function $({ name: e, value: t, options: n, models: r, hint: i, onRename: o, onP
|
|
|
1522
1735
|
options: p.options,
|
|
1523
1736
|
value: p.value,
|
|
1524
1737
|
onPick: (e) => {
|
|
1525
|
-
if (!r || !
|
|
1526
|
-
if (!e) return
|
|
1527
|
-
let t = r.available.find((t) =>
|
|
1528
|
-
t &&
|
|
1738
|
+
if (!r || !c) return;
|
|
1739
|
+
if (!e) return c(null);
|
|
1740
|
+
let t = r.available.find((t) => $(t) === e);
|
|
1741
|
+
t && c({
|
|
1529
1742
|
connectionId: t.connectionId,
|
|
1530
1743
|
model: t.model
|
|
1531
1744
|
});
|
|
1532
1745
|
},
|
|
1533
1746
|
empty: d("agent.noModels")
|
|
1534
1747
|
} : void 0,
|
|
1535
|
-
onRename:
|
|
1748
|
+
onRename: a,
|
|
1536
1749
|
onPick: s,
|
|
1537
1750
|
onClose: u
|
|
1538
1751
|
});
|
|
1539
1752
|
}
|
|
1540
1753
|
//#endregion
|
|
1541
|
-
export {
|
|
1754
|
+
export { De as AgentButton, Oe as AgentMenu, Ae as AgentSettingsMenu, U as AttachmentList, ne as AttachmentPreview, _e as Chat, Te as ChatLayout, y as CommandPalette, S as ContextMeter, we as ConversationList, ue as MessageView, de as NOTICE_LINES, Ee as NewTopicModal, ve as VoiceButton, $ as agentModelKey, ke as agentModelOptions, Z as columnName, M as fileSize, B as parseTable, j as previewIcon, k as previewKind, x as tokens, he as useRecorder };
|
|
1542
1755
|
|
|
1543
1756
|
//# sourceMappingURL=chat.js.map
|