@green-on-grey/ui-kit 1.4.0 → 1.6.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 +3 -0
- package/dist/chat/ContextMeter.d.ts +4 -2
- package/dist/chat.js +211 -155
- package/dist/chat.js.map +1 -1
- package/dist/components/Icon.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/locales/index.d.ts +5 -0
- package/dist/locales.js +10 -5
- package/dist/locales.js.map +1 -1
- package/dist/manifest.json +3 -1
- package/dist/styles.css +11 -1
- package/dist/{ui-ChXUXoIB.js → ui-DLi5afmc.js} +2 -1
- package/dist/ui-DLi5afmc.js.map +1 -0
- package/package.json +1 -1
- package/dist/ui-ChXUXoIB.js.map +0 -1
package/dist/chat.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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-DLi5afmc.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
4
|
import { useCallback as u, useEffect as d, useLayoutEffect as f, useMemo as p, useRef as m, useState as h } from "react";
|
|
@@ -77,25 +77,25 @@ function b(e, t) {
|
|
|
77
77
|
maximumFractionDigits: 1
|
|
78
78
|
}).format(e);
|
|
79
79
|
}
|
|
80
|
-
function x({ context: e, onCompact:
|
|
81
|
-
let
|
|
80
|
+
function x({ context: e, onCompact: t, onReset: n, busy: r = !1 }) {
|
|
81
|
+
let u = a(), { i18n: d } = g(o), [f, p] = h(!1), m = i(f, () => p(!1)), _ = e.window > 0 ? Math.min(1, e.tokens / e.window) : 0, v = Math.round(_ * 100), y = _ >= .9 ? "full" : _ >= .7 ? "warn" : "", x = 2 * Math.PI * 7, C = d.language;
|
|
82
82
|
return /* @__PURE__ */ l("div", {
|
|
83
83
|
className: "ctxmeter",
|
|
84
|
-
ref:
|
|
84
|
+
ref: m,
|
|
85
85
|
children: [/* @__PURE__ */ c("button", {
|
|
86
86
|
type: "button",
|
|
87
|
-
className: `ctxring ${
|
|
88
|
-
"aria-expanded":
|
|
89
|
-
onClick: () =>
|
|
90
|
-
"aria-label":
|
|
91
|
-
used: b(e.tokens,
|
|
92
|
-
total: b(e.window,
|
|
93
|
-
pct:
|
|
87
|
+
className: `ctxring ${y}`,
|
|
88
|
+
"aria-expanded": f,
|
|
89
|
+
onClick: () => p((e) => !e),
|
|
90
|
+
"aria-label": u("chat.context.meter", {
|
|
91
|
+
used: b(e.tokens, C),
|
|
92
|
+
total: b(e.window, C),
|
|
93
|
+
pct: v
|
|
94
94
|
}),
|
|
95
|
-
title:
|
|
96
|
-
used: b(e.tokens,
|
|
97
|
-
total: b(e.window,
|
|
98
|
-
pct:
|
|
95
|
+
title: u("chat.context.meter", {
|
|
96
|
+
used: b(e.tokens, C),
|
|
97
|
+
total: b(e.window, C),
|
|
98
|
+
pct: v
|
|
99
99
|
}),
|
|
100
100
|
children: /* @__PURE__ */ l("svg", {
|
|
101
101
|
viewBox: "0 0 18 18",
|
|
@@ -110,81 +110,93 @@ function x({ context: e, onCompact: n, onReset: r }) {
|
|
|
110
110
|
cx: "9",
|
|
111
111
|
cy: "9",
|
|
112
112
|
r: 7,
|
|
113
|
-
strokeDasharray: `${(
|
|
113
|
+
strokeDasharray: `${(x * _).toFixed(1)} ${x.toFixed(1)}`,
|
|
114
114
|
transform: "rotate(-90 9 9)"
|
|
115
115
|
})]
|
|
116
116
|
})
|
|
117
|
-
}),
|
|
117
|
+
}), f && /* @__PURE__ */ l("div", {
|
|
118
118
|
className: "ctxtip",
|
|
119
119
|
role: "dialog",
|
|
120
120
|
children: [
|
|
121
|
-
/* @__PURE__ */ c("div", { children:
|
|
122
|
-
used: b(e.tokens,
|
|
123
|
-
total: b(e.window,
|
|
124
|
-
pct:
|
|
121
|
+
/* @__PURE__ */ c("div", { children: u("chat.context.meter", {
|
|
122
|
+
used: b(e.tokens, C),
|
|
123
|
+
total: b(e.window, C),
|
|
124
|
+
pct: v
|
|
125
125
|
}) }),
|
|
126
|
-
|
|
126
|
+
y === "full" && /* @__PURE__ */ c("div", {
|
|
127
127
|
className: "small muted",
|
|
128
128
|
style: { marginTop: 4 },
|
|
129
|
-
children:
|
|
129
|
+
children: u("chat.context.full")
|
|
130
130
|
}),
|
|
131
|
-
|
|
131
|
+
y === "full" && (t || n) && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l("div", {
|
|
132
132
|
className: "row",
|
|
133
133
|
style: {
|
|
134
134
|
marginTop: 8,
|
|
135
135
|
gap: 6
|
|
136
136
|
},
|
|
137
|
-
children: [
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
f(!1), r();
|
|
152
|
-
},
|
|
153
|
-
children: [/* @__PURE__ */ c(t, {
|
|
154
|
-
name: "undo",
|
|
155
|
-
size: 14
|
|
156
|
-
}), s("chat.context.reset")]
|
|
137
|
+
children: [t && /* @__PURE__ */ c(S, {
|
|
138
|
+
icon: "compress",
|
|
139
|
+
label: u("chat.context.compact"),
|
|
140
|
+
busy: r,
|
|
141
|
+
run: () => {
|
|
142
|
+
p(!1), t();
|
|
143
|
+
}
|
|
144
|
+
}), n && /* @__PURE__ */ c(S, {
|
|
145
|
+
icon: "reset",
|
|
146
|
+
label: u("chat.context.reset"),
|
|
147
|
+
busy: r,
|
|
148
|
+
run: () => {
|
|
149
|
+
p(!1), n();
|
|
150
|
+
}
|
|
157
151
|
})]
|
|
158
|
-
})
|
|
152
|
+
}), r && /* @__PURE__ */ c("div", {
|
|
153
|
+
id: "ctx-wait",
|
|
154
|
+
className: "small muted",
|
|
155
|
+
style: { marginTop: 6 },
|
|
156
|
+
children: u("chat.context.waitTurn")
|
|
157
|
+
})] })
|
|
159
158
|
]
|
|
160
159
|
})]
|
|
161
160
|
});
|
|
162
161
|
}
|
|
162
|
+
function S({ icon: e, label: n, busy: r, run: i }) {
|
|
163
|
+
return /* @__PURE__ */ l("button", {
|
|
164
|
+
type: "button",
|
|
165
|
+
className: "btn sm",
|
|
166
|
+
disabled: r,
|
|
167
|
+
"aria-describedby": r ? "ctx-wait" : void 0,
|
|
168
|
+
onClick: i,
|
|
169
|
+
children: [/* @__PURE__ */ c(t, {
|
|
170
|
+
name: e,
|
|
171
|
+
size: 14
|
|
172
|
+
}), n]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
163
175
|
//#endregion
|
|
164
176
|
//#region src/chat/Attachments.tsx
|
|
165
|
-
var
|
|
177
|
+
var C = /* @__PURE__ */ new Set([
|
|
166
178
|
"image/png",
|
|
167
179
|
"image/jpeg",
|
|
168
180
|
"image/gif",
|
|
169
181
|
"image/webp",
|
|
170
182
|
"image/svg+xml"
|
|
171
|
-
]),
|
|
172
|
-
function
|
|
183
|
+
]), w = /\.(png|jpe?g|gif|webp|svg)$/, T = /\.(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 E(e) {
|
|
173
185
|
let t = (e.mimeType ?? "").toLowerCase().split(";")[0].trim(), n = e.fileName.toLowerCase();
|
|
174
|
-
return
|
|
186
|
+
return C.has(t) || (!t || t === "application/octet-stream") && w.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" || T.test(n) ? "text" : null;
|
|
175
187
|
}
|
|
176
|
-
var
|
|
188
|
+
var D = {
|
|
177
189
|
image: "image",
|
|
178
190
|
pdf: "pdf",
|
|
179
191
|
markdown: "markdown",
|
|
180
192
|
table: "table",
|
|
181
193
|
html: "globe",
|
|
182
194
|
text: "source"
|
|
183
|
-
},
|
|
184
|
-
function
|
|
195
|
+
}, O = (e) => D[e];
|
|
196
|
+
function k(e, t) {
|
|
185
197
|
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
198
|
}
|
|
187
|
-
function
|
|
199
|
+
function A(e, t) {
|
|
188
200
|
let n = [
|
|
189
201
|
"byte",
|
|
190
202
|
"kilobyte",
|
|
@@ -199,23 +211,23 @@ function k(e, t) {
|
|
|
199
211
|
maximumFractionDigits: i === 0 ? 0 : 1
|
|
200
212
|
}).format(r);
|
|
201
213
|
}
|
|
202
|
-
var
|
|
203
|
-
function
|
|
204
|
-
let t = `<meta http-equiv="Content-Security-Policy" content="${
|
|
214
|
+
var j = "default-src 'none'; img-src data:; media-src data:; font-src data:; style-src 'unsafe-inline' data:";
|
|
215
|
+
function ee(e) {
|
|
216
|
+
let t = `<meta http-equiv="Content-Security-Policy" content="${j}">`, n = /^\s*<!doctype[^>]*>/i.exec(e)?.[0] ?? "";
|
|
205
217
|
if (typeof DOMParser > "u") return n + t + e.slice(n.length);
|
|
206
218
|
let r = new DOMParser().parseFromString(e, "text/html");
|
|
207
219
|
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
220
|
for (let t of Array.from(e.attributes)) {
|
|
209
221
|
let n = t.name.toLowerCase();
|
|
210
|
-
n.startsWith("on") ||
|
|
222
|
+
n.startsWith("on") || M.has(n) && !N.test(t.value) || n === "srcset" && t.value.split(",").some((e) => !N.test(e)) ? e.removeAttribute(t.name) : n === "style" && e.setAttribute("style", P(t.value));
|
|
211
223
|
}
|
|
212
224
|
}), r.querySelectorAll("style").forEach((e) => {
|
|
213
|
-
e.textContent =
|
|
225
|
+
e.textContent = P(e.textContent ?? "");
|
|
214
226
|
});
|
|
215
227
|
let i = r.createElement("meta");
|
|
216
|
-
return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content",
|
|
228
|
+
return i.setAttribute("http-equiv", "Content-Security-Policy"), i.setAttribute("content", j), r.head.prepend(i), (n ? "<!doctype html>" : "") + r.documentElement.outerHTML;
|
|
217
229
|
}
|
|
218
|
-
var
|
|
230
|
+
var M = /* @__PURE__ */ new Set([
|
|
219
231
|
"src",
|
|
220
232
|
"href",
|
|
221
233
|
"xlink:href",
|
|
@@ -233,11 +245,11 @@ var ee = /* @__PURE__ */ new Set([
|
|
|
233
245
|
"codebase",
|
|
234
246
|
"archive",
|
|
235
247
|
"usemap"
|
|
236
|
-
]),
|
|
237
|
-
function
|
|
238
|
-
return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) =>
|
|
248
|
+
]), N = /^\s*(data:|#|$)/i;
|
|
249
|
+
function P(e) {
|
|
250
|
+
return e.replace(/@import[^;]*;?/gi, "").replace(/url\(\s*(['"]?)(.*?)\1\s*\)/gi, (e, t, n) => N.test(n) && n.trim() !== "" ? e : "none");
|
|
239
251
|
}
|
|
240
|
-
var
|
|
252
|
+
var F = {
|
|
241
253
|
png: "image/png",
|
|
242
254
|
jpg: "image/jpeg",
|
|
243
255
|
jpeg: "image/jpeg",
|
|
@@ -252,11 +264,11 @@ var P = {
|
|
|
252
264
|
html: "text/html",
|
|
253
265
|
htm: "text/html"
|
|
254
266
|
};
|
|
255
|
-
function
|
|
267
|
+
function I(e) {
|
|
256
268
|
let t = (e.mimeType ?? "").split(";")[0].trim().toLowerCase();
|
|
257
|
-
return t && t !== "application/octet-stream" ? t :
|
|
269
|
+
return t && t !== "application/octet-stream" ? t : F[/\.([a-z0-9]+)$/i.exec(e.fileName)?.[1]?.toLowerCase() ?? ""] ?? (t || void 0);
|
|
258
270
|
}
|
|
259
|
-
function
|
|
271
|
+
function L(e, t) {
|
|
260
272
|
if (t) return e.replace(/\r?\n$/, "").split(/\r?\n/).map((e) => e.split(" "));
|
|
261
273
|
let n = [], r = [], i = "", a = !1;
|
|
262
274
|
for (let t = 0; t < e.length; t++) {
|
|
@@ -265,7 +277,7 @@ function I(e, t) {
|
|
|
265
277
|
}
|
|
266
278
|
return (i !== "" || r.length > 0) && (r.push(i), n.push(r)), n;
|
|
267
279
|
}
|
|
268
|
-
function
|
|
280
|
+
function R(e, t, n = !0) {
|
|
269
281
|
let [r, i] = h({}), { id: a, href: o, fileName: s, mimeType: c, size: l } = e;
|
|
270
282
|
return d(() => {
|
|
271
283
|
if (!n) return;
|
|
@@ -278,7 +290,7 @@ function L(e, t, n = !0) {
|
|
|
278
290
|
size: l
|
|
279
291
|
}).then((t) => {
|
|
280
292
|
if (!r) return;
|
|
281
|
-
let n =
|
|
293
|
+
let n = I({
|
|
282
294
|
fileName: s,
|
|
283
295
|
mimeType: c
|
|
284
296
|
}), a = n && t.type !== n ? new Blob([t], { type: n }) : t;
|
|
@@ -299,9 +311,9 @@ function L(e, t, n = !0) {
|
|
|
299
311
|
l
|
|
300
312
|
]), r;
|
|
301
313
|
}
|
|
302
|
-
function
|
|
303
|
-
let r = a(), { url: i, failed: o } =
|
|
304
|
-
return o ? /* @__PURE__ */ c(
|
|
314
|
+
function z({ a: e, load: t, onOpen: n }) {
|
|
315
|
+
let r = a(), { url: i, failed: o } = R(e, t);
|
|
316
|
+
return o ? /* @__PURE__ */ c(B, {
|
|
305
317
|
a: e,
|
|
306
318
|
kind: "image",
|
|
307
319
|
onOpen: n
|
|
@@ -323,16 +335,16 @@ function R({ a: e, load: t, onOpen: n }) {
|
|
|
323
335
|
})]
|
|
324
336
|
});
|
|
325
337
|
}
|
|
326
|
-
function
|
|
338
|
+
function B({ a: e, kind: n, onOpen: r }) {
|
|
327
339
|
let i = a(), { i18n: u } = g(o), d = n !== null && r !== void 0, f = /* @__PURE__ */ l(s, { children: [
|
|
328
340
|
/* @__PURE__ */ l("span", {
|
|
329
341
|
className: "att-ic",
|
|
330
342
|
children: [/* @__PURE__ */ c(t, {
|
|
331
|
-
name: d && n ?
|
|
343
|
+
name: d && n ? D[n] : "download",
|
|
332
344
|
size: 24
|
|
333
345
|
}), /* @__PURE__ */ c("span", {
|
|
334
346
|
className: "att-kl",
|
|
335
|
-
children:
|
|
347
|
+
children: k(e, n)
|
|
336
348
|
})]
|
|
337
349
|
}),
|
|
338
350
|
/* @__PURE__ */ c("span", {
|
|
@@ -341,7 +353,7 @@ function z({ a: e, kind: n, onOpen: r }) {
|
|
|
341
353
|
}),
|
|
342
354
|
e.size != null && /* @__PURE__ */ c("span", {
|
|
343
355
|
className: "att-size",
|
|
344
|
-
children:
|
|
356
|
+
children: A(e.size, u.language)
|
|
345
357
|
})
|
|
346
358
|
] });
|
|
347
359
|
return d ? /* @__PURE__ */ c("button", {
|
|
@@ -360,16 +372,16 @@ function z({ a: e, kind: n, onOpen: r }) {
|
|
|
360
372
|
children: f
|
|
361
373
|
});
|
|
362
374
|
}
|
|
363
|
-
function
|
|
375
|
+
function V({ items: e, load: t, onOpen: n }) {
|
|
364
376
|
return /* @__PURE__ */ c("div", {
|
|
365
377
|
className: "atts",
|
|
366
378
|
children: e.map((e) => {
|
|
367
|
-
let r = t && n ? () => n(e) : void 0, i =
|
|
368
|
-
return t && r && i === "image" ? /* @__PURE__ */ c(
|
|
379
|
+
let r = t && n ? () => n(e) : void 0, i = E(e);
|
|
380
|
+
return t && r && i === "image" ? /* @__PURE__ */ c(z, {
|
|
369
381
|
a: e,
|
|
370
382
|
load: t,
|
|
371
383
|
onOpen: r
|
|
372
|
-
}, e.id) : /* @__PURE__ */ c(
|
|
384
|
+
}, e.id) : /* @__PURE__ */ c(B, {
|
|
373
385
|
a: e,
|
|
374
386
|
kind: i,
|
|
375
387
|
onOpen: r
|
|
@@ -377,8 +389,8 @@ function B({ items: e, load: t, onOpen: n }) {
|
|
|
377
389
|
})
|
|
378
390
|
});
|
|
379
391
|
}
|
|
380
|
-
function
|
|
381
|
-
let n = a(), [r, ...i] =
|
|
392
|
+
function H({ text: e, tab: t }) {
|
|
393
|
+
let n = a(), [r, ...i] = L(e, t), o = i.slice(0, 500);
|
|
382
394
|
return /* @__PURE__ */ l("div", {
|
|
383
395
|
className: "att-table",
|
|
384
396
|
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", {
|
|
@@ -390,23 +402,61 @@ function V({ text: e, tab: t }) {
|
|
|
390
402
|
})]
|
|
391
403
|
});
|
|
392
404
|
}
|
|
405
|
+
var U = 1280;
|
|
406
|
+
function W({ text: e, title: t }) {
|
|
407
|
+
let n = m(null), [r, i] = h(U), [a, o] = h(U);
|
|
408
|
+
d(() => {
|
|
409
|
+
let e = n.current;
|
|
410
|
+
if (!e) return;
|
|
411
|
+
let t = () => i(e.clientWidth);
|
|
412
|
+
if (t(), typeof ResizeObserver > "u") return;
|
|
413
|
+
let r = new ResizeObserver(t);
|
|
414
|
+
return r.observe(e), () => r.disconnect();
|
|
415
|
+
}, []);
|
|
416
|
+
let s = p(() => ee(e), [e]), [l, u] = h(s);
|
|
417
|
+
l !== s && (u(s), o(U));
|
|
418
|
+
let f = (e) => {
|
|
419
|
+
let t = e.currentTarget, n = () => {
|
|
420
|
+
let e = t.contentDocument?.documentElement;
|
|
421
|
+
e && o(Math.max(U, e.scrollWidth));
|
|
422
|
+
};
|
|
423
|
+
n(), t.contentDocument?.fonts?.ready.then(n);
|
|
424
|
+
}, g = Math.min(1, r / a);
|
|
425
|
+
return /* @__PURE__ */ c("div", {
|
|
426
|
+
className: "att-htmlbox",
|
|
427
|
+
ref: n,
|
|
428
|
+
children: /* @__PURE__ */ c("iframe", {
|
|
429
|
+
className: "att-html",
|
|
430
|
+
sandbox: "allow-same-origin",
|
|
431
|
+
srcDoc: s,
|
|
432
|
+
title: t,
|
|
433
|
+
referrerPolicy: "no-referrer",
|
|
434
|
+
onLoad: f,
|
|
435
|
+
style: {
|
|
436
|
+
width: a,
|
|
437
|
+
height: `${100 / g}%`,
|
|
438
|
+
transform: `scale(${g})`
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
});
|
|
442
|
+
}
|
|
393
443
|
function te({ a: e, load: i, onClose: u }) {
|
|
394
|
-
let f = a(), { i18n: p } = g(o), m =
|
|
444
|
+
let f = a(), { i18n: p } = g(o), m = E(e), _ = m === "markdown" || m === "table" || m === "html" || m === "text", [v, y] = h(!1), b = _ && (e.size ?? 0) > 1048576, { url: x, blob: S, failed: C } = R(e, i, !b), [w, T] = h(null), D = b || _ && (S?.size ?? 0) > 1048576;
|
|
395
445
|
d(() => {
|
|
396
446
|
_ && S && !D && S.arrayBuffer().then((e) => {
|
|
397
447
|
try {
|
|
398
|
-
|
|
448
|
+
T({ text: new TextDecoder("utf-8", { fatal: !0 }).decode(e) });
|
|
399
449
|
} catch {
|
|
400
|
-
|
|
450
|
+
T({ text: null });
|
|
401
451
|
}
|
|
402
|
-
}, () =>
|
|
452
|
+
}, () => T({ text: null }));
|
|
403
453
|
}, [
|
|
404
454
|
_,
|
|
405
455
|
S,
|
|
406
456
|
D
|
|
407
457
|
]);
|
|
408
|
-
let O = w?.text,
|
|
409
|
-
return
|
|
458
|
+
let O = w?.text, k;
|
|
459
|
+
return k = C ? /* @__PURE__ */ c("div", {
|
|
410
460
|
className: "att-msg err-text",
|
|
411
461
|
children: f("chat.files.failed")
|
|
412
462
|
}) : D ? /* @__PURE__ */ c("div", {
|
|
@@ -441,15 +491,12 @@ function te({ a: e, load: i, onClose: u }) {
|
|
|
441
491
|
}) : m === "markdown" ? /* @__PURE__ */ c("div", {
|
|
442
492
|
className: "att-md",
|
|
443
493
|
children: /* @__PURE__ */ c(r, { text: O ?? "" })
|
|
444
|
-
}) : m === "table" ? /* @__PURE__ */ c(
|
|
494
|
+
}) : m === "table" ? /* @__PURE__ */ c(H, {
|
|
445
495
|
text: O ?? "",
|
|
446
496
|
tab: /\.tsv$/i.test(e.fileName) || e.mimeType === "text/tab-separated-values"
|
|
447
|
-
}) : m === "html" && !v ? /* @__PURE__ */ c(
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
srcDoc: j(O ?? ""),
|
|
451
|
-
title: e.fileName,
|
|
452
|
-
referrerPolicy: "no-referrer"
|
|
497
|
+
}) : m === "html" && !v ? /* @__PURE__ */ c(W, {
|
|
498
|
+
text: O ?? "",
|
|
499
|
+
title: e.fileName
|
|
453
500
|
}) : /* @__PURE__ */ c("pre", {
|
|
454
501
|
className: "att-text",
|
|
455
502
|
children: O
|
|
@@ -463,7 +510,7 @@ function te({ a: e, load: i, onClose: u }) {
|
|
|
463
510
|
children: e.fileName
|
|
464
511
|
}), e.size != null && /* @__PURE__ */ c("span", {
|
|
465
512
|
className: "muted small",
|
|
466
|
-
children:
|
|
513
|
+
children: A(e.size, p.language)
|
|
467
514
|
})]
|
|
468
515
|
}),
|
|
469
516
|
footer: /* @__PURE__ */ l(s, { children: [
|
|
@@ -502,22 +549,22 @@ function te({ a: e, load: i, onClose: u }) {
|
|
|
502
549
|
] }),
|
|
503
550
|
children: /* @__PURE__ */ c("div", {
|
|
504
551
|
className: `att-view ${m ?? ""}`,
|
|
505
|
-
children:
|
|
552
|
+
children: k
|
|
506
553
|
})
|
|
507
554
|
});
|
|
508
555
|
}
|
|
509
556
|
//#endregion
|
|
510
557
|
//#region src/chat/MessageView.tsx
|
|
511
|
-
function
|
|
558
|
+
function G(e, t) {
|
|
512
559
|
return new Intl.DateTimeFormat(y(t), {
|
|
513
560
|
hour: "2-digit",
|
|
514
561
|
minute: "2-digit"
|
|
515
562
|
}).format(new Date(e));
|
|
516
563
|
}
|
|
517
|
-
function
|
|
564
|
+
function K(e, t) {
|
|
518
565
|
return t || e.length <= 3 ? e : e.slice(-2);
|
|
519
566
|
}
|
|
520
|
-
var
|
|
567
|
+
var q = {
|
|
521
568
|
done: {
|
|
522
569
|
icon: "check",
|
|
523
570
|
cls: "ok"
|
|
@@ -537,7 +584,7 @@ function ne({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u
|
|
|
537
584
|
className: "sysnote",
|
|
538
585
|
children: e.text
|
|
539
586
|
});
|
|
540
|
-
if (e.role === "event" && e.event) return /* @__PURE__ */ c(
|
|
587
|
+
if (e.role === "event" && e.event) return /* @__PURE__ */ c(J, { m: e });
|
|
541
588
|
let _ = e.mark && /* @__PURE__ */ l("div", {
|
|
542
589
|
className: "chan",
|
|
543
590
|
children: [
|
|
@@ -548,9 +595,9 @@ function ne({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u
|
|
|
548
595
|
" ",
|
|
549
596
|
e.mark.text,
|
|
550
597
|
" · ",
|
|
551
|
-
|
|
598
|
+
G(e.createdAt, f.language)
|
|
552
599
|
]
|
|
553
|
-
}), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(
|
|
600
|
+
}), v = e.attachments && e.attachments.length > 0 && /* @__PURE__ */ c(V, {
|
|
554
601
|
items: e.attachments,
|
|
555
602
|
load: a,
|
|
556
603
|
onOpen: u
|
|
@@ -589,13 +636,13 @@ function ne({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u
|
|
|
589
636
|
"aria-expanded": p,
|
|
590
637
|
children: p ? d("chat.hideSteps") : d("chat.moreSteps", { count: y.length - 2 })
|
|
591
638
|
}),
|
|
592
|
-
|
|
639
|
+
K(y, p).map((e) => /* @__PURE__ */ l("div", {
|
|
593
640
|
className: "tool",
|
|
594
641
|
title: e.title,
|
|
595
642
|
children: [/* @__PURE__ */ c(t, {
|
|
596
|
-
name:
|
|
643
|
+
name: q[e.status].icon,
|
|
597
644
|
size: 14,
|
|
598
|
-
className:
|
|
645
|
+
className: q[e.status].cls
|
|
599
646
|
}), /* @__PURE__ */ c("span", {
|
|
600
647
|
className: "tx",
|
|
601
648
|
children: e.text
|
|
@@ -639,7 +686,7 @@ function ne({ m: e, busy: n, onRetry: i, loadAttachment: a, onOpenAttachment: u
|
|
|
639
686
|
]
|
|
640
687
|
});
|
|
641
688
|
}
|
|
642
|
-
function
|
|
689
|
+
function J({ m: e }) {
|
|
643
690
|
let { t: n, i18n: r } = g(o), [i, a] = h(!1), s = e.event;
|
|
644
691
|
return /* @__PURE__ */ l("div", {
|
|
645
692
|
className: "evdiv",
|
|
@@ -655,7 +702,7 @@ function G({ m: e }) {
|
|
|
655
702
|
}),
|
|
656
703
|
s.text,
|
|
657
704
|
" · ",
|
|
658
|
-
|
|
705
|
+
G(e.createdAt, r.language),
|
|
659
706
|
s.details && /* @__PURE__ */ l("button", {
|
|
660
707
|
type: "button",
|
|
661
708
|
className: "textbtn",
|
|
@@ -757,54 +804,54 @@ function ae(e) {
|
|
|
757
804
|
}
|
|
758
805
|
//#endregion
|
|
759
806
|
//#region src/chat/Chat.tsx
|
|
760
|
-
function
|
|
807
|
+
function Y(n) {
|
|
761
808
|
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
809
|
d(() => {
|
|
763
810
|
P.current = n.loadAttachment;
|
|
764
811
|
});
|
|
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
|
|
766
|
-
d(() =>
|
|
767
|
-
let
|
|
812
|
+
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 ve()), { messages: U, busy: W = !1 } = n, G = W || U.some((e) => e.status === "pending" || e.status === "streaming"), K = n.onPendingChange;
|
|
813
|
+
d(() => K?.(g), [g, K]);
|
|
814
|
+
let q = U[0]?.id, J = U[U.length - 1], Y = J?.id, ce = J?.text.length, de = J?.steps?.length, X = m({ height: 0 });
|
|
768
815
|
f(() => {
|
|
769
816
|
let e = R.current;
|
|
770
817
|
if (!e) return;
|
|
771
818
|
let t = X.current;
|
|
772
|
-
e.scrollTop = t.first !== void 0 &&
|
|
773
|
-
first:
|
|
774
|
-
last:
|
|
819
|
+
e.scrollTop = t.first !== void 0 && q !== t.first && Y === t.last ? e.scrollTop + (e.scrollHeight - t.height) : e.scrollHeight, X.current = {
|
|
820
|
+
first: q,
|
|
821
|
+
last: Y,
|
|
775
822
|
height: e.scrollHeight
|
|
776
823
|
};
|
|
777
824
|
}, [
|
|
778
825
|
U.length,
|
|
779
|
-
|
|
780
|
-
J,
|
|
826
|
+
q,
|
|
781
827
|
Y,
|
|
782
|
-
|
|
828
|
+
ce,
|
|
829
|
+
de
|
|
783
830
|
]);
|
|
784
|
-
let Z = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Q = Z === null ? [] : _(n.commands ?? [], Z), $ = Z !== null && !D,
|
|
831
|
+
let Z = n.commands && !C && o.startsWith("/") && !/\s/.test(o) ? o.slice(1) : null, Q = Z === null ? [] : _(n.commands ?? [], Z), $ = Z !== null && !D, fe = () => {
|
|
785
832
|
u(""), y([]), w(null), A(null), L.current = !1;
|
|
786
|
-
},
|
|
833
|
+
}, pe = async (e, t) => {
|
|
787
834
|
if (n.onCommand) try {
|
|
788
|
-
await n.onCommand(e, t),
|
|
835
|
+
await n.onCommand(e, t), fe();
|
|
789
836
|
} catch {}
|
|
790
|
-
},
|
|
837
|
+
}, me = async (e, t = !1) => {
|
|
791
838
|
let r = e.trim();
|
|
792
839
|
if (!(!r && g.length === 0 && !C || W || n.readOnly)) {
|
|
793
840
|
if (!t && !C && n.commands && r.startsWith("/")) {
|
|
794
841
|
let [e, ...t] = r.slice(1).split(/\s+/), i = n.commands.find((t) => t.kind === "command" && t.name === e);
|
|
795
|
-
if (i) return
|
|
842
|
+
if (i) return pe(i.name, t.join(" "));
|
|
796
843
|
if (e && !r.includes("\n")) {
|
|
797
844
|
A("/" + e);
|
|
798
845
|
return;
|
|
799
846
|
}
|
|
800
847
|
}
|
|
801
848
|
try {
|
|
802
|
-
await n.onSend(r, g.map((e) => e.id), L.current, C ?? void 0),
|
|
849
|
+
await n.onSend(r, g.map((e) => e.id), L.current, C ?? void 0), fe();
|
|
803
850
|
} catch {}
|
|
804
851
|
}
|
|
805
|
-
},
|
|
806
|
-
E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") :
|
|
807
|
-
},
|
|
852
|
+
}, he = (e) => {
|
|
853
|
+
E(0), e.kind === "skill" ? (w(e.name), u("")) : e.takesText ? u("/" + e.name + " ") : pe(e.name, ""), B.current?.focus();
|
|
854
|
+
}, ge = (e) => {
|
|
808
855
|
if ($ && Q.length > 0) {
|
|
809
856
|
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
810
857
|
e.preventDefault();
|
|
@@ -813,21 +860,21 @@ function K(n) {
|
|
|
813
860
|
return;
|
|
814
861
|
}
|
|
815
862
|
if (e.key === "Enter" && !e.shiftKey || e.key === "Tab") {
|
|
816
|
-
e.preventDefault(),
|
|
863
|
+
e.preventDefault(), he(Q[Math.min(T, Q.length - 1)]);
|
|
817
864
|
return;
|
|
818
865
|
}
|
|
819
866
|
}
|
|
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(),
|
|
867
|
+
$ && 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(), me(o));
|
|
821
868
|
};
|
|
822
|
-
f(() =>
|
|
869
|
+
f(() => le(R.current, () => ue(B.current)), [o]), d(() => {
|
|
823
870
|
let e = B.current;
|
|
824
871
|
if (!e || typeof ResizeObserver > "u") return;
|
|
825
872
|
let t = e.clientWidth, n = new ResizeObserver(() => {
|
|
826
|
-
e.clientWidth !== t && (t = e.clientWidth,
|
|
873
|
+
e.clientWidth !== t && (t = e.clientWidth, le(R.current, () => ue(e)));
|
|
827
874
|
});
|
|
828
875
|
return n.observe(e), () => n.disconnect();
|
|
829
876
|
}, [H.recording]);
|
|
830
|
-
let
|
|
877
|
+
let _e = async (e) => {
|
|
831
878
|
if (e?.length && n.onUpload) {
|
|
832
879
|
S(!0);
|
|
833
880
|
for (let t of Array.from(e)) {
|
|
@@ -845,7 +892,7 @@ function K(n) {
|
|
|
845
892
|
S(!1), z.current && (z.current.value = "");
|
|
846
893
|
}
|
|
847
894
|
};
|
|
848
|
-
async function
|
|
895
|
+
async function ve() {
|
|
849
896
|
let e = await H.stop();
|
|
850
897
|
e && n.onTranscribe && await re(e, n.onTranscribe, {
|
|
851
898
|
busy: ee,
|
|
@@ -867,9 +914,9 @@ function K(n) {
|
|
|
867
914
|
}
|
|
868
915
|
});
|
|
869
916
|
}
|
|
870
|
-
let
|
|
917
|
+
let ye = (e) => {
|
|
871
918
|
e.key === "Escape" && H.recording && (e.preventDefault(), H.cancel());
|
|
872
|
-
},
|
|
919
|
+
}, be = C ? r("chat.skillPlaceholder") : r("chat.placeholder", { name: n.agentName }), xe = V - H.seconds;
|
|
873
920
|
return /* @__PURE__ */ l("section", {
|
|
874
921
|
className: "nb-chat",
|
|
875
922
|
"aria-label": r("chat.title"),
|
|
@@ -952,7 +999,7 @@ function K(n) {
|
|
|
952
999
|
$ && /* @__PURE__ */ c(v, {
|
|
953
1000
|
items: Q,
|
|
954
1001
|
active: Math.min(T, Math.max(Q.length - 1, 0)),
|
|
955
|
-
onPick:
|
|
1002
|
+
onPick: he,
|
|
956
1003
|
onHover: E
|
|
957
1004
|
}),
|
|
958
1005
|
n.aboveComposer,
|
|
@@ -988,7 +1035,7 @@ function K(n) {
|
|
|
988
1035
|
children: [r("chat.unknownCommand", { name: k }), /* @__PURE__ */ c("button", {
|
|
989
1036
|
type: "button",
|
|
990
1037
|
className: "textbtn",
|
|
991
|
-
onClick: () => void
|
|
1038
|
+
onClick: () => void me(o, !0),
|
|
992
1039
|
children: r("chat.sendAsText")
|
|
993
1040
|
})]
|
|
994
1041
|
}),
|
|
@@ -1007,10 +1054,10 @@ function K(n) {
|
|
|
1007
1054
|
multiple: !0,
|
|
1008
1055
|
hidden: !0,
|
|
1009
1056
|
accept: n.upload?.accept,
|
|
1010
|
-
onChange: (e) =>
|
|
1057
|
+
onChange: (e) => _e(e.target.files)
|
|
1011
1058
|
})] }),
|
|
1012
1059
|
H.recording ? /* @__PURE__ */ l("div", {
|
|
1013
|
-
className: `recbar${
|
|
1060
|
+
className: `recbar${xe <= 15 ? " ending" : ""}`,
|
|
1014
1061
|
role: "status",
|
|
1015
1062
|
"aria-label": r("chat.voice.recordingNow"),
|
|
1016
1063
|
children: [
|
|
@@ -1040,8 +1087,8 @@ function K(n) {
|
|
|
1040
1087
|
/* @__PURE__ */ c("button", {
|
|
1041
1088
|
type: "button",
|
|
1042
1089
|
className: "btn primary sm",
|
|
1043
|
-
onKeyDown:
|
|
1044
|
-
onClick: () => void
|
|
1090
|
+
onKeyDown: ye,
|
|
1091
|
+
onClick: () => void ve(),
|
|
1045
1092
|
children: r("chat.voice.done")
|
|
1046
1093
|
})
|
|
1047
1094
|
]
|
|
@@ -1074,21 +1121,22 @@ function K(n) {
|
|
|
1074
1121
|
ref: B,
|
|
1075
1122
|
rows: 1,
|
|
1076
1123
|
value: o,
|
|
1077
|
-
placeholder: j ? r("chat.voice.recognizing") :
|
|
1078
|
-
"aria-label":
|
|
1124
|
+
placeholder: j ? r("chat.voice.recognizing") : be,
|
|
1125
|
+
"aria-label": be,
|
|
1079
1126
|
disabled: j,
|
|
1080
1127
|
"aria-expanded": $,
|
|
1081
1128
|
"aria-autocomplete": n.commands ? "list" : void 0,
|
|
1082
1129
|
onChange: (e) => {
|
|
1083
1130
|
u(e.target.value), O(!1), E(0), A(null);
|
|
1084
1131
|
},
|
|
1085
|
-
onKeyDown:
|
|
1132
|
+
onKeyDown: ge
|
|
1086
1133
|
})]
|
|
1087
1134
|
}),
|
|
1088
1135
|
n.context && !H.recording && /* @__PURE__ */ c(x, {
|
|
1089
1136
|
context: n.context,
|
|
1090
1137
|
onCompact: n.onCompact,
|
|
1091
|
-
onReset: n.onReset
|
|
1138
|
+
onReset: n.onReset,
|
|
1139
|
+
busy: G
|
|
1092
1140
|
}),
|
|
1093
1141
|
n.onTranscribe && !H.recording && /* @__PURE__ */ c(oe, {
|
|
1094
1142
|
supported: H.supported,
|
|
@@ -1104,7 +1152,7 @@ function K(n) {
|
|
|
1104
1152
|
className: "iconbtn fill",
|
|
1105
1153
|
"aria-label": r("chat.send"),
|
|
1106
1154
|
disabled: !o.trim() && g.length === 0 && !C || W || j,
|
|
1107
|
-
onClick: () =>
|
|
1155
|
+
onClick: () => me(o),
|
|
1108
1156
|
children: /* @__PURE__ */ c(t, { name: "send" })
|
|
1109
1157
|
}))
|
|
1110
1158
|
]
|
|
@@ -1150,12 +1198,20 @@ function oe({ supported: e, recognizing: n, onStart: r }) {
|
|
|
1150
1198
|
function se() {
|
|
1151
1199
|
return typeof window < "u" && !!window.matchMedia?.("(hover: none) and (pointer: coarse)").matches;
|
|
1152
1200
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1201
|
+
var ce = (e) => e.scrollHeight - e.scrollTop - e.clientHeight < 2;
|
|
1202
|
+
function le(e, t) {
|
|
1203
|
+
let n = !!e && ce(e);
|
|
1204
|
+
t(), e && n && (e.scrollTop = e.scrollHeight);
|
|
1205
|
+
}
|
|
1206
|
+
function ue(e) {
|
|
1207
|
+
if (!e) return;
|
|
1208
|
+
e.style.overflowY = "hidden", e.style.height = "auto";
|
|
1209
|
+
let t = e.scrollHeight + e.offsetHeight - e.clientHeight;
|
|
1210
|
+
e.style.height = `${t}px`, e.style.overflowY = e.offsetHeight < t ? "auto" : "hidden";
|
|
1155
1211
|
}
|
|
1156
1212
|
//#endregion
|
|
1157
1213
|
//#region src/chat/ConversationList.tsx
|
|
1158
|
-
function
|
|
1214
|
+
function de({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onCreate: u }) {
|
|
1159
1215
|
let f = a(), [p, m] = h(!1);
|
|
1160
1216
|
d(() => {
|
|
1161
1217
|
if (!r) return;
|
|
@@ -1231,19 +1287,19 @@ function q({ conversations: e, currentId: n, open: r, onPick: i, onClose: o, onC
|
|
|
1231
1287
|
"aria-label": f("close"),
|
|
1232
1288
|
onClick: o
|
|
1233
1289
|
}),
|
|
1234
|
-
p && u && /* @__PURE__ */ c(
|
|
1290
|
+
p && u && /* @__PURE__ */ c(Z, {
|
|
1235
1291
|
onClose: () => m(!1),
|
|
1236
1292
|
onCreate: u
|
|
1237
1293
|
})
|
|
1238
1294
|
] });
|
|
1239
1295
|
}
|
|
1240
|
-
function
|
|
1296
|
+
function X({ narrow: e, children: t }) {
|
|
1241
1297
|
return /* @__PURE__ */ c("div", {
|
|
1242
1298
|
className: `nb-app${e ? " narrow" : ""}`,
|
|
1243
1299
|
children: t
|
|
1244
1300
|
});
|
|
1245
1301
|
}
|
|
1246
|
-
function
|
|
1302
|
+
function Z({ onClose: e, onCreate: t }) {
|
|
1247
1303
|
let r = a(), [i, o] = h(""), [u, d] = h(!1), [f, p] = h(null), m = async () => {
|
|
1248
1304
|
if (i.trim() && !u) {
|
|
1249
1305
|
d(!0), p(null);
|
|
@@ -1295,7 +1351,7 @@ function Y({ onClose: e, onCreate: t }) {
|
|
|
1295
1351
|
}
|
|
1296
1352
|
//#endregion
|
|
1297
1353
|
//#region src/chat/AgentMenu.tsx
|
|
1298
|
-
function
|
|
1354
|
+
function Q({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, onClick: s }) {
|
|
1299
1355
|
return /* @__PURE__ */ c("button", {
|
|
1300
1356
|
type: "button",
|
|
1301
1357
|
className: `agentbtn${a ? " s" : ""}`,
|
|
@@ -1311,7 +1367,7 @@ function le({ icon: e, label: n, title: r, expanded: i, small: a, disabled: o, o
|
|
|
1311
1367
|
})
|
|
1312
1368
|
});
|
|
1313
1369
|
}
|
|
1314
|
-
function
|
|
1370
|
+
function $({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d, narrow: f, models: p, onRename: m, onPick: g, onClose: _ }) {
|
|
1315
1371
|
let v = a(), [y, b] = h(n), x = i(!0, _);
|
|
1316
1372
|
return /* @__PURE__ */ l("div", {
|
|
1317
1373
|
className: `agentmenu${f ? " narrow" : ""}`,
|
|
@@ -1422,6 +1478,6 @@ function X({ label: e, name: n, options: r, value: o, optionsLabel: u, hint: d,
|
|
|
1422
1478
|
});
|
|
1423
1479
|
}
|
|
1424
1480
|
//#endregion
|
|
1425
|
-
export {
|
|
1481
|
+
export { Q as AgentButton, $ as AgentMenu, V as AttachmentList, te as AttachmentPreview, Y as Chat, X as ChatLayout, v as CommandPalette, x as ContextMeter, de as ConversationList, ne as MessageView, Z as NewTopicModal, oe as VoiceButton, A as fileSize, L as parseTable, O as previewIcon, E as previewKind, b as tokens, ie as useRecorder };
|
|
1426
1482
|
|
|
1427
1483
|
//# sourceMappingURL=chat.js.map
|