@singlebase/elements 0.5.0 → 0.7.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/{authui-display-BCZBP7HR.js → authui-display-BM_F3-5e.js} +426 -436
- package/dist/authui-display-BM_F3-5e.js.map +1 -0
- package/dist/{authui-display-CLGFSqRi.cjs → authui-display-CMVHTNFz.cjs} +45 -65
- package/dist/authui-display-CMVHTNFz.cjs.map +1 -0
- package/dist/authui.cjs +1 -1
- package/dist/authui.js +2 -2
- package/dist/{chat-bXaRWel7.js → chat-BH_3e1jT.js} +2081 -1121
- package/dist/chat-BH_3e1jT.js.map +1 -0
- package/dist/chat-ezUmd9II.cjs +3281 -0
- package/dist/chat-ezUmd9II.cjs.map +1 -0
- package/dist/chat-messages.d.ts +19 -6
- package/dist/chat.cjs +1 -1
- package/dist/chat.d.ts +4 -3
- package/dist/chat.js +8 -6
- package/dist/elements/authui-base.d.ts +2 -0
- package/dist/elements/authui-buttons.d.ts +1 -1
- package/dist/elements/authui-display.d.ts +1 -1
- package/dist/elements/authui.d.ts +1 -1
- package/dist/elements/chat.d.ts +192 -11
- package/dist/elements/uploader.d.ts +8 -0
- package/dist/files-4T62wkwj.cjs +77 -0
- package/dist/files-4T62wkwj.cjs.map +1 -0
- package/dist/{files-BOwtpYyQ.js → files-DS-H-3yN.js} +93 -47
- package/dist/files-DS-H-3yN.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +24 -22
- package/dist/messages.d.ts +0 -2
- package/dist/singlebase-elements.min.js +3838 -2844
- package/dist/singlebase-elements.min.js.map +1 -1
- package/dist/styles/branding.d.ts +5 -0
- package/dist/styles/tokens.d.ts +2 -0
- package/dist/upload-messages.d.ts +0 -1
- package/dist/{uploader-DGV2y9uT.cjs → uploader-COP8PkJ6.cjs} +53 -76
- package/dist/uploader-COP8PkJ6.cjs.map +1 -0
- package/dist/{uploader-abQoem5q.js → uploader-tdMU9Gxv.js} +249 -253
- package/dist/uploader-tdMU9Gxv.js.map +1 -0
- package/dist/uploader.cjs +1 -1
- package/dist/uploader.js +2 -2
- package/dist/utils/branding.d.ts +8 -0
- package/dist/utils/markdown.d.ts +69 -12
- package/dist/utils/svg.d.ts +10 -0
- package/package.json +3 -3
- package/dist/authui-display-BCZBP7HR.js.map +0 -1
- package/dist/authui-display-CLGFSqRi.cjs.map +0 -1
- package/dist/chat-DRenTJlI.cjs +0 -3001
- package/dist/chat-DRenTJlI.cjs.map +0 -1
- package/dist/chat-bXaRWel7.js.map +0 -1
- package/dist/files-BOwtpYyQ.js.map +0 -1
- package/dist/files-DW8A4Jl-.cjs +0 -38
- package/dist/files-DW8A4Jl-.cjs.map +0 -1
- package/dist/uploader-DGV2y9uT.cjs.map +0 -1
- package/dist/uploader-abQoem5q.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var Ut = Object.defineProperty;
|
|
2
|
+
var wt = (n) => {
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var p = (n, e, t) => (
|
|
8
|
-
import { css as
|
|
9
|
-
import { property as
|
|
10
|
-
import { repeat as
|
|
11
|
-
import { getDefaultClient as
|
|
12
|
-
import {
|
|
5
|
+
var Wt = (n, e, t) => e in n ? Ut(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
+
var M = (n, e, t) => Wt(n, typeof e != "symbol" ? e + "" : e, t), yt = (n, e, t) => e.has(n) || wt("Cannot " + t);
|
|
7
|
+
var p = (n, e, t) => (yt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), h = (n, e, t) => e.has(n) ? wt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), u = (n, e, t, s) => (yt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
|
|
8
|
+
import { css as Ht, LitElement as Jt, html as o, nothing as m, svg as O } from "lit";
|
|
9
|
+
import { property as v, state as y, customElement as Gt } from "lit/decorators.js";
|
|
10
|
+
import { repeat as qt } from "lit/directives/repeat.js";
|
|
11
|
+
import { getDefaultClient as Vt } from "@singlebase/core";
|
|
12
|
+
import { a as _, e as kt, j as Xt, t as Yt, b as Qt } from "./files-DS-H-3yN.js";
|
|
13
13
|
if (typeof CSS < "u" && "registerProperty" in CSS)
|
|
14
14
|
try {
|
|
15
15
|
CSS.registerProperty({
|
|
@@ -20,7 +20,7 @@ if (typeof CSS < "u" && "registerProperty" in CSS)
|
|
|
20
20
|
});
|
|
21
21
|
} catch {
|
|
22
22
|
}
|
|
23
|
-
const
|
|
23
|
+
const Zt = Ht`
|
|
24
24
|
:host {
|
|
25
25
|
--c-ink: var(--sb-ink, #16181a);
|
|
26
26
|
--c-ink2: var(--sb-ink-2, #41464b);
|
|
@@ -37,7 +37,7 @@ const wt = bt`
|
|
|
37
37
|
--c-danger: var(--sb-danger, #b4231a);
|
|
38
38
|
--c-ok: var(--sb-ok, #0f6b4a);
|
|
39
39
|
--c-mono: var(--sb-mono, "Geist Mono", ui-monospace, monospace);
|
|
40
|
-
--c-r: var(--sb-radius, 4px);
|
|
40
|
+
--c-r: calc(var(--sb-radius, 4px) * var(--sb-radius-scale, 1));
|
|
41
41
|
--c-r2: calc(var(--c-r) * 1.5);
|
|
42
42
|
--c-r3: calc(var(--c-r) * 2);
|
|
43
43
|
--c-r4: calc(var(--c-r) * 3);
|
|
@@ -482,6 +482,17 @@ const wt = bt`
|
|
|
482
482
|
outline: none;
|
|
483
483
|
}
|
|
484
484
|
|
|
485
|
+
.side-extra {
|
|
486
|
+
display: none;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
.side-extra.filled {
|
|
490
|
+
display: block;
|
|
491
|
+
padding: 12px 16px;
|
|
492
|
+
border-top: 1px solid var(--c-line);
|
|
493
|
+
font-size: 12.5px;
|
|
494
|
+
}
|
|
495
|
+
|
|
485
496
|
.side-note {
|
|
486
497
|
font-size: 12.5px;
|
|
487
498
|
color: var(--c-muted);
|
|
@@ -654,6 +665,21 @@ const wt = bt`
|
|
|
654
665
|
|
|
655
666
|
/* ── welcome ──────────────────────────────────────────── */
|
|
656
667
|
|
|
668
|
+
.welcome-slot {
|
|
669
|
+
min-height: 100%;
|
|
670
|
+
display: flex;
|
|
671
|
+
flex-direction: column;
|
|
672
|
+
justify-content: center;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
::slotted([slot="welcome"]) {
|
|
676
|
+
box-sizing: border-box;
|
|
677
|
+
width: 100%;
|
|
678
|
+
max-width: 640px;
|
|
679
|
+
margin: 0 auto;
|
|
680
|
+
padding: 28px 18px;
|
|
681
|
+
}
|
|
682
|
+
|
|
657
683
|
.welcome {
|
|
658
684
|
max-width: 640px;
|
|
659
685
|
min-height: 100%;
|
|
@@ -1050,6 +1076,168 @@ const wt = bt`
|
|
|
1050
1076
|
padding: 1px 5px;
|
|
1051
1077
|
}
|
|
1052
1078
|
|
|
1079
|
+
.answer h3.h1 {
|
|
1080
|
+
font-size: 18px;
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
.answer h3.h2 {
|
|
1084
|
+
font-size: 16.5px;
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
.answer h3.h4 {
|
|
1088
|
+
font-size: 14.5px;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.answer hr {
|
|
1092
|
+
width: 100%;
|
|
1093
|
+
border: none;
|
|
1094
|
+
border-top: 1px solid var(--c-line);
|
|
1095
|
+
margin: 4px 0;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
.answer li.task {
|
|
1099
|
+
list-style: none;
|
|
1100
|
+
margin-left: -18px;
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
.answer li.task input {
|
|
1104
|
+
margin: 0 6px 0 0;
|
|
1105
|
+
vertical-align: -1px;
|
|
1106
|
+
accent-color: var(--c-brand);
|
|
1107
|
+
}
|
|
1108
|
+
|
|
1109
|
+
.callout {
|
|
1110
|
+
display: flex;
|
|
1111
|
+
flex-direction: column;
|
|
1112
|
+
gap: 4px;
|
|
1113
|
+
font-size: 13.5px;
|
|
1114
|
+
line-height: 1.6;
|
|
1115
|
+
padding: 10px 14px;
|
|
1116
|
+
border: 1px solid var(--c-line);
|
|
1117
|
+
border-left: 3px solid var(--callout, var(--c-ink));
|
|
1118
|
+
border-radius: var(--c-r2);
|
|
1119
|
+
background: color-mix(in srgb, var(--callout, var(--c-ink)) 7%, var(--c-bg));
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
.callout-title {
|
|
1123
|
+
font-weight: 600;
|
|
1124
|
+
color: var(--callout, var(--c-ink));
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
.callout.note {
|
|
1128
|
+
--callout: oklch(0.55 0.15 255);
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
.callout.tip {
|
|
1132
|
+
--callout: oklch(0.55 0.12 160);
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
.callout.important {
|
|
1136
|
+
--callout: oklch(0.52 0.17 300);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
.callout.warning {
|
|
1140
|
+
--callout: oklch(0.6 0.14 70);
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
.callout.caution {
|
|
1144
|
+
--callout: var(--c-danger);
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
.jtree {
|
|
1148
|
+
padding: 10px 14px;
|
|
1149
|
+
overflow-x: auto;
|
|
1150
|
+
font-family: var(--c-mono);
|
|
1151
|
+
font-size: 12.5px;
|
|
1152
|
+
line-height: 1.7;
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
.jtree summary {
|
|
1156
|
+
cursor: pointer;
|
|
1157
|
+
list-style-position: outside;
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
.jkids {
|
|
1161
|
+
padding-left: 16px;
|
|
1162
|
+
border-left: 1px solid var(--c-line);
|
|
1163
|
+
margin-left: 4px;
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
.jkey {
|
|
1167
|
+
color: var(--c-ink2);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
.jmeta {
|
|
1171
|
+
color: var(--c-muted);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
.jv.string {
|
|
1175
|
+
color: oklch(0.52 0.12 160);
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
.jv.number {
|
|
1179
|
+
color: oklch(0.55 0.15 255);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
.jv.boolean,
|
|
1183
|
+
.jv.null {
|
|
1184
|
+
color: oklch(0.52 0.17 300);
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
.table th button.sort {
|
|
1188
|
+
display: inline-flex;
|
|
1189
|
+
align-items: center;
|
|
1190
|
+
gap: 4px;
|
|
1191
|
+
font: inherit;
|
|
1192
|
+
color: inherit;
|
|
1193
|
+
background: none;
|
|
1194
|
+
border: none;
|
|
1195
|
+
padding: 0;
|
|
1196
|
+
cursor: pointer;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
.table th .arrow {
|
|
1200
|
+
font-size: 10px;
|
|
1201
|
+
opacity: 0.5;
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
.table th[aria-sort="ascending"] .arrow,
|
|
1205
|
+
.table th[aria-sort="descending"] .arrow {
|
|
1206
|
+
opacity: 1;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
.table-note {
|
|
1210
|
+
padding: 7px 12px;
|
|
1211
|
+
font-size: 12px;
|
|
1212
|
+
color: var(--c-muted);
|
|
1213
|
+
border-top: 1px solid var(--c-line2);
|
|
1214
|
+
background: var(--c-bg2);
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
figure.svg {
|
|
1218
|
+
margin: 0;
|
|
1219
|
+
display: flex;
|
|
1220
|
+
flex-direction: column;
|
|
1221
|
+
gap: 6px;
|
|
1222
|
+
align-items: flex-start;
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
figure.svg img {
|
|
1226
|
+
display: block;
|
|
1227
|
+
width: min(100%, 480px);
|
|
1228
|
+
height: auto;
|
|
1229
|
+
max-height: 420px;
|
|
1230
|
+
object-fit: contain;
|
|
1231
|
+
padding: 12px;
|
|
1232
|
+
border: 1px solid var(--c-line);
|
|
1233
|
+
border-radius: var(--c-r2);
|
|
1234
|
+
background: #ffffff;
|
|
1235
|
+
}
|
|
1236
|
+
|
|
1237
|
+
.custom-block {
|
|
1238
|
+
min-width: 0;
|
|
1239
|
+
}
|
|
1240
|
+
|
|
1053
1241
|
.quote {
|
|
1054
1242
|
font-size: 13.5px;
|
|
1055
1243
|
line-height: 1.6;
|
|
@@ -1707,6 +1895,10 @@ const wt = bt`
|
|
|
1707
1895
|
padding: 0 12px 12px;
|
|
1708
1896
|
}
|
|
1709
1897
|
|
|
1898
|
+
.composer-wrap.reader {
|
|
1899
|
+
padding-top: 10px;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1710
1902
|
.composer-col {
|
|
1711
1903
|
max-width: 760px;
|
|
1712
1904
|
margin: 0 auto;
|
|
@@ -1864,6 +2056,11 @@ const wt = bt`
|
|
|
1864
2056
|
min-width: 0;
|
|
1865
2057
|
}
|
|
1866
2058
|
|
|
2059
|
+
.pending-file.kept {
|
|
2060
|
+
background: var(--c-bg);
|
|
2061
|
+
border-style: dashed;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
1867
2064
|
.pending-file .name {
|
|
1868
2065
|
max-width: 160px;
|
|
1869
2066
|
overflow: hidden;
|
|
@@ -1891,8 +2088,7 @@ const wt = bt`
|
|
|
1891
2088
|
color: var(--c-danger);
|
|
1892
2089
|
}
|
|
1893
2090
|
|
|
1894
|
-
.footnote
|
|
1895
|
-
.branding {
|
|
2091
|
+
.footnote {
|
|
1896
2092
|
text-align: center;
|
|
1897
2093
|
font-size: 11.5px;
|
|
1898
2094
|
color: var(--c-muted);
|
|
@@ -1903,19 +2099,6 @@ const wt = bt`
|
|
|
1903
2099
|
margin-top: -4px;
|
|
1904
2100
|
}
|
|
1905
2101
|
|
|
1906
|
-
.branding a {
|
|
1907
|
-
font-family: var(--c-mono);
|
|
1908
|
-
font-size: 10.5px;
|
|
1909
|
-
letter-spacing: 0.06em;
|
|
1910
|
-
text-transform: uppercase;
|
|
1911
|
-
color: var(--c-muted);
|
|
1912
|
-
text-decoration: none;
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
.branding a:hover {
|
|
1916
|
-
color: var(--c-ink);
|
|
1917
|
-
}
|
|
1918
|
-
|
|
1919
2102
|
.toast {
|
|
1920
2103
|
position: absolute;
|
|
1921
2104
|
left: 50%;
|
|
@@ -2273,29 +2456,31 @@ const wt = bt`
|
|
|
2273
2456
|
height: auto;
|
|
2274
2457
|
}
|
|
2275
2458
|
}
|
|
2276
|
-
`,
|
|
2459
|
+
`, es = {
|
|
2277
2460
|
eyebrowChat: "Chat",
|
|
2278
2461
|
eyebrowRag: "Grounded answers",
|
|
2279
|
-
eyebrowRich: "Charts · tables · images",
|
|
2280
2462
|
headingChat: "What can I help with?",
|
|
2281
2463
|
headingRag: "Ask your knowledge base",
|
|
2282
|
-
headingRich: "Ask for a chart or a table",
|
|
2283
2464
|
descriptionChat: "Ask anything. Attach text files to give it more context.",
|
|
2284
2465
|
descriptionRag: "Answers are grounded in your sources, with a citation for every claim. Attach text files to search them too.",
|
|
2285
|
-
|
|
2466
|
+
eyebrowKb: "Knowledge base",
|
|
2467
|
+
headingKb: "Ask the knowledge base",
|
|
2468
|
+
descriptionKb: "Answers come only from the knowledge base, with a citation for every claim.",
|
|
2286
2469
|
placeholderChat: "Message {name}…",
|
|
2287
2470
|
placeholderRag: "Ask about your sources…",
|
|
2288
|
-
|
|
2471
|
+
placeholderKb: "Ask the knowledge base…",
|
|
2289
2472
|
footnote: "{name} can make mistakes. Check important details.",
|
|
2290
2473
|
attach: "Attach files",
|
|
2291
2474
|
send: "Send message",
|
|
2292
2475
|
stop: "Stop generating",
|
|
2293
2476
|
removeFile: "Remove file",
|
|
2477
|
+
inThisChat: "In this chat",
|
|
2478
|
+
removeFromChat: "Remove from this chat",
|
|
2479
|
+
attachmentFailed: "Couldn't read {name}.",
|
|
2294
2480
|
dropTitle: "Drop files to attach",
|
|
2295
2481
|
dropSub: "Text, Markdown, CSV and JSON files are added as context.",
|
|
2296
2482
|
thinking: "Thinking",
|
|
2297
2483
|
searching: "Searching sources",
|
|
2298
|
-
building: "Building charts and tables",
|
|
2299
2484
|
chats: "Chats",
|
|
2300
2485
|
newChat: "New chat",
|
|
2301
2486
|
searchChats: "Search chats",
|
|
@@ -2350,6 +2535,17 @@ const wt = bt`
|
|
|
2350
2535
|
copyReference: "Copy passage with reference",
|
|
2351
2536
|
alsoCited: "Also cited",
|
|
2352
2537
|
close: "Close",
|
|
2538
|
+
renderingChart: "Rendering chart",
|
|
2539
|
+
renderingSvg: "Rendering drawing",
|
|
2540
|
+
copySvg: "Copy SVG",
|
|
2541
|
+
showRaw: "View raw",
|
|
2542
|
+
showFormatted: "View formatted",
|
|
2543
|
+
showingRows: "Showing {n} of {total} rows",
|
|
2544
|
+
calloutNote: "Note",
|
|
2545
|
+
calloutTip: "Tip",
|
|
2546
|
+
calloutImportant: "Important",
|
|
2547
|
+
calloutWarning: "Warning",
|
|
2548
|
+
calloutCaution: "Caution",
|
|
2353
2549
|
undo: "Undo",
|
|
2354
2550
|
chatDeleted: "Chat deleted",
|
|
2355
2551
|
messageDeleted: "Message deleted",
|
|
@@ -2364,6 +2560,7 @@ const wt = bt`
|
|
|
2364
2560
|
tooManyFiles: "Attach up to {n} files at a time.",
|
|
2365
2561
|
errGeneric: "Something went wrong.",
|
|
2366
2562
|
errNotFound: "This chat no longer exists. Retry to start a new one.",
|
|
2563
|
+
errKbSource: "No knowledge base is set up for this chat.",
|
|
2367
2564
|
errNoClient: "Chat isn't connected. Create a SinglebaseClient() on this page.",
|
|
2368
2565
|
errLoad: "Couldn't load this chat.",
|
|
2369
2566
|
retry: "Retry",
|
|
@@ -2371,73 +2568,130 @@ const wt = bt`
|
|
|
2371
2568
|
bubbleText: "Hi! Questions? Ask me here.",
|
|
2372
2569
|
openChat: "Open chat",
|
|
2373
2570
|
closeChat: "Close chat",
|
|
2374
|
-
dismiss: "Dismiss"
|
|
2375
|
-
brandingLabel: "Chat by Singlebase"
|
|
2571
|
+
dismiss: "Dismiss"
|
|
2376
2572
|
};
|
|
2377
|
-
function
|
|
2378
|
-
return {
|
|
2573
|
+
function ts(n) {
|
|
2574
|
+
return { ...es, ...n ?? {} };
|
|
2379
2575
|
}
|
|
2380
|
-
const
|
|
2381
|
-
function
|
|
2576
|
+
const ss = /^\|.*\|$/, $t = /^\|[\s:|-]+\|$/, Ct = /^!\[([^\]]*)\]\(([^)]*)\)$/, Tt = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, St = /^\[( |x|X)\]\s+/, is = /^(-{3,}|\*{3,}|_{3,})$/, as = /^\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]\s*(.*)$/i, rs = ["note", "tip", "important", "warning", "caution"];
|
|
2577
|
+
function os(n) {
|
|
2382
2578
|
const e = [], t = (n ?? "").replace(/\r/g, "").split("```");
|
|
2383
|
-
return t.forEach((
|
|
2384
|
-
if (
|
|
2385
|
-
const a =
|
|
2386
|
-
`),
|
|
2387
|
-
|
|
2388
|
-
const x = c ? null : Ot(l);
|
|
2389
|
-
e.push(x ? { type: "chart", spec: x } : { type: "chartPending" });
|
|
2390
|
-
} else
|
|
2391
|
-
e.push({ type: "code", lang: o || "code", text: l });
|
|
2579
|
+
return t.forEach((s, i) => {
|
|
2580
|
+
if (i % 2 === 1) {
|
|
2581
|
+
const a = s.indexOf(`
|
|
2582
|
+
`), r = (a > -1 ? s.slice(0, a) : s).trim(), c = (a > -1 ? s.slice(a + 1) : "").replace(/\n$/, "");
|
|
2583
|
+
e.push(ns(r, c, i === t.length - 1));
|
|
2392
2584
|
return;
|
|
2393
2585
|
}
|
|
2394
|
-
for (const a of
|
|
2395
|
-
|
|
2396
|
-
o && e.push(...pt(o));
|
|
2397
|
-
}
|
|
2586
|
+
for (const a of s.split(/\n{2,}/))
|
|
2587
|
+
a.trim() && e.push(...Kt(a));
|
|
2398
2588
|
}), e;
|
|
2399
2589
|
}
|
|
2400
|
-
function
|
|
2590
|
+
function ns(n, e, t) {
|
|
2591
|
+
const [s = "", ...i] = n.split(/\s+/), a = s.toLowerCase();
|
|
2592
|
+
if (a === "chart") {
|
|
2593
|
+
const r = t ? null : cs(e);
|
|
2594
|
+
return r ? { type: "chart", spec: r } : { type: "pending", kind: "chart" };
|
|
2595
|
+
}
|
|
2596
|
+
if (a === "svg")
|
|
2597
|
+
return t || !/<svg[\s>]/i.test(e) ? { type: "pending", kind: "svg" } : { type: "svg", source: e.trim() };
|
|
2598
|
+
if (!t && (a === "csv" || a === "tsv")) {
|
|
2599
|
+
const r = ls(e, a === "tsv" ? " " : ",");
|
|
2600
|
+
if (r.length > 1)
|
|
2601
|
+
return { type: "table", head: r[0], rows: r.slice(1), align: r[0].map(() => null) };
|
|
2602
|
+
}
|
|
2603
|
+
if (!t && a === "json")
|
|
2604
|
+
try {
|
|
2605
|
+
return { type: "json", value: JSON.parse(e), source: e };
|
|
2606
|
+
} catch {
|
|
2607
|
+
}
|
|
2608
|
+
if (a === "callout") {
|
|
2609
|
+
const r = (i[0] ?? "").toLowerCase(), c = rs.includes(r);
|
|
2610
|
+
return {
|
|
2611
|
+
type: "callout",
|
|
2612
|
+
kind: c ? r : "note",
|
|
2613
|
+
title: (c ? i.slice(1) : i).join(" "),
|
|
2614
|
+
text: e.trim()
|
|
2615
|
+
};
|
|
2616
|
+
}
|
|
2617
|
+
return { type: "code", lang: a || "code", text: e };
|
|
2618
|
+
}
|
|
2619
|
+
function Kt(n) {
|
|
2401
2620
|
const e = n.split(`
|
|
2402
|
-
`).
|
|
2403
|
-
if (
|
|
2404
|
-
const i =
|
|
2405
|
-
(
|
|
2406
|
-
);
|
|
2407
|
-
return [
|
|
2621
|
+
`).filter((i) => i.trim()), t = e.map((i) => i.trim());
|
|
2622
|
+
if (t.length > 1 && t.every((i) => ss.test(i))) {
|
|
2623
|
+
const i = (f) => f.replace(/^\||\|$/g, "").split("|").map((b) => b.trim()), a = t.findIndex((f) => $t.test(f)), r = a > -1 ? i(t[a]).map(
|
|
2624
|
+
(f) => /^:-+:$/.test(f) ? "center" : /^-+:$/.test(f) ? "right" : /^:-+$/.test(f) ? "left" : null
|
|
2625
|
+
) : [], c = t.filter((f) => !$t.test(f)).map(i), l = c[0] ?? [];
|
|
2626
|
+
return [
|
|
2627
|
+
{ type: "table", head: l, rows: c.slice(1), align: l.map((f, b) => r[b] ?? null) }
|
|
2628
|
+
];
|
|
2408
2629
|
}
|
|
2409
|
-
if (
|
|
2630
|
+
if (t.length === 1 && is.test(t[0])) return [{ type: "hr" }];
|
|
2631
|
+
if (t.every((i) => Ct.test(i)))
|
|
2410
2632
|
return [
|
|
2411
2633
|
{
|
|
2412
2634
|
type: "img",
|
|
2413
|
-
images:
|
|
2414
|
-
const
|
|
2415
|
-
return { alt:
|
|
2635
|
+
images: t.map((i) => {
|
|
2636
|
+
const a = i.match(Ct);
|
|
2637
|
+
return { alt: a[1], src: a[2] };
|
|
2416
2638
|
})
|
|
2417
2639
|
}
|
|
2418
2640
|
];
|
|
2419
|
-
if (
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
return [
|
|
2641
|
+
if (t.every((i) => i.startsWith(">"))) {
|
|
2642
|
+
const i = t.map((r) => r.replace(/^>\s?/, "")), a = i[0].match(as);
|
|
2643
|
+
return a ? [
|
|
2423
2644
|
{
|
|
2424
|
-
type: "
|
|
2425
|
-
|
|
2426
|
-
|
|
2645
|
+
type: "callout",
|
|
2646
|
+
kind: a[1].toLowerCase(),
|
|
2647
|
+
title: a[2].trim(),
|
|
2648
|
+
text: i.slice(1).join(`
|
|
2649
|
+
`).trim()
|
|
2427
2650
|
}
|
|
2428
|
-
];
|
|
2429
|
-
|
|
2430
|
-
if (
|
|
2651
|
+
] : [{ type: "quote", text: i.join(" ") }];
|
|
2652
|
+
}
|
|
2653
|
+
if (Tt.test(e[0])) {
|
|
2654
|
+
const i = [];
|
|
2655
|
+
for (const a of e) {
|
|
2656
|
+
const r = a.match(Tt);
|
|
2657
|
+
if (r) {
|
|
2658
|
+
const c = r[3].match(St);
|
|
2659
|
+
i.push({
|
|
2660
|
+
text: c ? r[3].replace(St, "") : r[3],
|
|
2661
|
+
depth: Math.min(3, Math.floor(r[1].replace(/\t/g, " ").length / 2)),
|
|
2662
|
+
checked: c ? c[1] !== " " : null
|
|
2663
|
+
});
|
|
2664
|
+
} else
|
|
2665
|
+
i[i.length - 1].text += ` ${a.trim()}`;
|
|
2666
|
+
}
|
|
2667
|
+
return [{ type: "list", ordered: /^\s*\d/.test(e[0]), items: i }];
|
|
2668
|
+
}
|
|
2669
|
+
const s = t[0].match(/^(#{1,4})\s+(.*)$/);
|
|
2670
|
+
if (s) {
|
|
2431
2671
|
const i = e.slice(1).join(`
|
|
2432
2672
|
`);
|
|
2433
2673
|
return [
|
|
2434
|
-
{ type: "h", level:
|
|
2435
|
-
...i ?
|
|
2674
|
+
{ type: "h", level: s[1].length, text: s[2] },
|
|
2675
|
+
...i ? Kt(i) : []
|
|
2436
2676
|
];
|
|
2437
2677
|
}
|
|
2438
|
-
return [{ type: "p", text:
|
|
2678
|
+
return [{ type: "p", text: t.join(" ") }];
|
|
2439
2679
|
}
|
|
2440
|
-
function
|
|
2680
|
+
function ls(n, e = ",") {
|
|
2681
|
+
var l;
|
|
2682
|
+
const t = [];
|
|
2683
|
+
let s = [], i = "", a = !1;
|
|
2684
|
+
const r = n.replace(/\r/g, "");
|
|
2685
|
+
for (let f = 0; f < r.length; f++) {
|
|
2686
|
+
const b = r[f];
|
|
2687
|
+
a ? b === '"' && r[f + 1] === '"' ? (i += '"', f++) : b === '"' ? a = !1 : i += b : b === '"' && i === "" ? a = !0 : b === e ? (s.push(i.trim()), i = "") : b === `
|
|
2688
|
+
` ? (s.push(i.trim()), s.some(Boolean) && t.push(s), s = [], i = "") : i += b;
|
|
2689
|
+
}
|
|
2690
|
+
s.push(i.trim()), s.some(Boolean) && t.push(s);
|
|
2691
|
+
const c = ((l = t[0]) == null ? void 0 : l.length) ?? 0;
|
|
2692
|
+
return t.map((f) => f.length < c ? [...f, ...Array(c - f.length).fill("")] : f);
|
|
2693
|
+
}
|
|
2694
|
+
function cs(n) {
|
|
2441
2695
|
let e;
|
|
2442
2696
|
try {
|
|
2443
2697
|
e = JSON.parse(n);
|
|
@@ -2445,136 +2699,226 @@ function Ot(n) {
|
|
|
2445
2699
|
return null;
|
|
2446
2700
|
}
|
|
2447
2701
|
if (!e || typeof e != "object") return null;
|
|
2448
|
-
const t = (Array.isArray(e.series) ? e.series : []).filter((
|
|
2449
|
-
name: String(
|
|
2450
|
-
values:
|
|
2702
|
+
const t = (Array.isArray(e.series) ? e.series : []).filter((i) => i && Array.isArray(i.values)).map((i, a) => ({
|
|
2703
|
+
name: String(i.name ?? `Series ${a + 1}`),
|
|
2704
|
+
values: i.values.map((r) => Number(r) || 0)
|
|
2451
2705
|
}));
|
|
2452
2706
|
if (!t.length) return null;
|
|
2453
|
-
const
|
|
2707
|
+
const s = Array.isArray(e.labels) ? e.labels.map(String) : t[0].values.map((i, a) => String(a + 1));
|
|
2454
2708
|
return {
|
|
2455
2709
|
type: e.type === "line" ? "line" : "bar",
|
|
2456
2710
|
title: String(e.title ?? ""),
|
|
2457
2711
|
unit: String(e.unit ?? ""),
|
|
2458
|
-
labels:
|
|
2712
|
+
labels: s,
|
|
2459
2713
|
series: t
|
|
2460
2714
|
};
|
|
2461
2715
|
}
|
|
2462
|
-
const
|
|
2463
|
-
|
|
2716
|
+
const It = new RegExp(
|
|
2717
|
+
[
|
|
2718
|
+
/\*\*([^*]+)\*\*/.source,
|
|
2719
|
+
// 1 bold
|
|
2720
|
+
/~~([^~]+)~~/.source,
|
|
2721
|
+
// 2 strike
|
|
2722
|
+
/`([^`]+)`/.source,
|
|
2723
|
+
// 3 code
|
|
2724
|
+
/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/.source,
|
|
2725
|
+
// 4, 5 link
|
|
2726
|
+
/(https?:\/\/[^\s<>()]*[^\s<>().,;:!?'"\]])/.source,
|
|
2727
|
+
// 6 bare link
|
|
2728
|
+
new RegExp("(?<![\\w*])\\*(?![\\s*])([^*\\n]+?)\\*(?![\\w*])").source,
|
|
2729
|
+
// 7 *italic*
|
|
2730
|
+
new RegExp("(?<![\\w_])_(?![\\s_])([^_\\n]+?)_(?![\\w_])").source,
|
|
2731
|
+
// 8 _italic_
|
|
2732
|
+
/\s?\[(\d+(?:\s*,\s*\d+)*)\]/.source
|
|
2733
|
+
// 9 citation
|
|
2734
|
+
].join("|"),
|
|
2735
|
+
"g"
|
|
2736
|
+
);
|
|
2737
|
+
function ds(n, e = 0) {
|
|
2464
2738
|
const t = [];
|
|
2465
|
-
let
|
|
2466
|
-
|
|
2467
|
-
const a = (
|
|
2468
|
-
if (!
|
|
2469
|
-
const
|
|
2470
|
-
(
|
|
2739
|
+
let s = 0, i;
|
|
2740
|
+
It.lastIndex = 0;
|
|
2741
|
+
const a = (r) => {
|
|
2742
|
+
if (!r) return;
|
|
2743
|
+
const c = t[t.length - 1];
|
|
2744
|
+
(c == null ? void 0 : c.type) === "text" ? c.text += r : t.push({ type: "text", text: r });
|
|
2471
2745
|
};
|
|
2472
|
-
for (;
|
|
2473
|
-
if (a(n.slice(
|
|
2474
|
-
else if (
|
|
2475
|
-
else if (
|
|
2746
|
+
for (; i = It.exec(n); ) {
|
|
2747
|
+
if (a(n.slice(s, i.index)), i[1] !== void 0) t.push({ type: "bold", text: i[1] });
|
|
2748
|
+
else if (i[2] !== void 0) t.push({ type: "strike", text: i[2] });
|
|
2749
|
+
else if (i[3] !== void 0) t.push({ type: "code", text: i[3] });
|
|
2750
|
+
else if (i[4] !== void 0) t.push({ type: "link", text: i[4], href: i[5] });
|
|
2751
|
+
else if (i[6] !== void 0) t.push({ type: "link", text: i[6], href: i[6] });
|
|
2752
|
+
else if (i[7] !== void 0) t.push({ type: "italic", text: i[7] });
|
|
2753
|
+
else if (i[8] !== void 0) t.push({ type: "italic", text: i[8] });
|
|
2476
2754
|
else {
|
|
2477
|
-
const
|
|
2478
|
-
e ?
|
|
2755
|
+
const c = i[9].split(",").map((l) => Number(l.trim())).filter((l) => l >= 1 && l <= e);
|
|
2756
|
+
e ? c.forEach((l) => t.push({ type: "cite", n: l })) : a(i[0]);
|
|
2479
2757
|
}
|
|
2480
|
-
|
|
2758
|
+
s = i.index + i[0].length;
|
|
2481
2759
|
}
|
|
2482
|
-
return a(n.slice(
|
|
2760
|
+
return a(n.slice(s)), t;
|
|
2761
|
+
}
|
|
2762
|
+
function ps(n) {
|
|
2763
|
+
if (((n ?? "").match(/```/g) ?? []).length % 2 === 1) return n;
|
|
2764
|
+
const e = n.lastIndexOf(`
|
|
2765
|
+
|
|
2766
|
+
`), t = e > -1 ? n.slice(0, e + 2) : "";
|
|
2767
|
+
let s = e > -1 ? n.slice(e + 2) : n;
|
|
2768
|
+
const i = s.split(`
|
|
2769
|
+
`), a = i[i.length - 1];
|
|
2770
|
+
a.trimStart().startsWith("|") && !a.trimEnd().endsWith("|") && i.pop(), s = i.join(`
|
|
2771
|
+
`), s = s.replace(/!?\[[^\]\n]*(\]\([^)\n]*)?$/, "");
|
|
2772
|
+
for (const r of ["**", "~~", "`"])
|
|
2773
|
+
if ((s.split(r).length - 1) % 2 === 1) {
|
|
2774
|
+
const l = s.lastIndexOf(r);
|
|
2775
|
+
s = s.slice(0, l) + s.slice(l + r.length);
|
|
2776
|
+
}
|
|
2777
|
+
return t + s;
|
|
2483
2778
|
}
|
|
2484
|
-
function
|
|
2779
|
+
function Ot(n) {
|
|
2485
2780
|
const e = /* @__PURE__ */ new Set();
|
|
2486
2781
|
for (const t of (n ?? "").match(/\[(\d+(?:\s*,\s*\d+)*)\]/g) ?? [])
|
|
2487
|
-
t.replace(/[[\]]/g, "").split(",").forEach((
|
|
2782
|
+
t.replace(/[[\]]/g, "").split(",").forEach((s) => e.add(Number(s.trim())));
|
|
2488
2783
|
return e;
|
|
2489
2784
|
}
|
|
2490
|
-
function
|
|
2491
|
-
return
|
|
2492
|
-
|
|
2493
|
-
|
|
2785
|
+
function hs(n) {
|
|
2786
|
+
return [
|
|
2787
|
+
["", ...n.series.map((e) => e.name)],
|
|
2788
|
+
...n.labels.map((e, t) => [
|
|
2494
2789
|
e,
|
|
2495
|
-
...n.series.map((
|
|
2790
|
+
...n.series.map((s) => s.values[t] === void 0 ? "" : `${s.values[t]}${n.unit}`)
|
|
2496
2791
|
])
|
|
2497
|
-
|
|
2792
|
+
];
|
|
2498
2793
|
}
|
|
2499
|
-
const
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
return "";
|
|
2525
|
-
case "img":
|
|
2526
|
-
return i.images.map((s) => `Image: ${s.alt || "untitled"}`).join(`
|
|
2527
|
-
`);
|
|
2528
|
-
case "table":
|
|
2529
|
-
return [i.head, ...i.rows].map((s) => s.map(He).join(" · ")).join(`
|
|
2530
|
-
`);
|
|
2531
|
-
case "list":
|
|
2532
|
-
return i.items.map((s) => `- ${He(s)}`).join(`
|
|
2533
|
-
`);
|
|
2534
|
-
case "code":
|
|
2535
|
-
case "raw":
|
|
2536
|
-
return i.text;
|
|
2537
|
-
default:
|
|
2538
|
-
return He(i.text);
|
|
2794
|
+
const Mt = (n) => n.map((e) => e.join(" · ")).join(`
|
|
2795
|
+
`), us = {
|
|
2796
|
+
note: "Note",
|
|
2797
|
+
tip: "Tip",
|
|
2798
|
+
important: "Important",
|
|
2799
|
+
warning: "Warning",
|
|
2800
|
+
caution: "Caution"
|
|
2801
|
+
};
|
|
2802
|
+
function gs(n, e) {
|
|
2803
|
+
if (e === "rich") return n;
|
|
2804
|
+
const t = e === "plain";
|
|
2805
|
+
return n.map((s) => {
|
|
2806
|
+
switch (s.type) {
|
|
2807
|
+
case "chart": {
|
|
2808
|
+
const [i, ...a] = hs(s.spec);
|
|
2809
|
+
return t ? {
|
|
2810
|
+
type: "raw",
|
|
2811
|
+
text: [s.spec.title, Mt([i, ...a])].filter(Boolean).join(`
|
|
2812
|
+
`)
|
|
2813
|
+
} : {
|
|
2814
|
+
type: "table",
|
|
2815
|
+
head: s.spec.title ? [s.spec.title, ...i.slice(1)] : i,
|
|
2816
|
+
rows: a,
|
|
2817
|
+
align: i.map(() => null)
|
|
2818
|
+
};
|
|
2539
2819
|
}
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2820
|
+
case "pending":
|
|
2821
|
+
return s.kind === "svg" && !t ? s : { type: "raw", text: "" };
|
|
2822
|
+
case "callout":
|
|
2823
|
+
return {
|
|
2824
|
+
type: "quote",
|
|
2825
|
+
text: `**${s.title || us[s.kind]}** ${s.text}`.trim()
|
|
2826
|
+
};
|
|
2827
|
+
case "img":
|
|
2828
|
+
return {
|
|
2829
|
+
type: "p",
|
|
2830
|
+
text: s.images.map((i) => `Image: ${i.alt || "untitled"}`).join(" · ")
|
|
2831
|
+
};
|
|
2832
|
+
case "table":
|
|
2833
|
+
return t ? { type: "raw", text: Mt([s.head, ...s.rows]) } : s;
|
|
2834
|
+
case "json":
|
|
2835
|
+
return t ? { type: "code", lang: "json", text: s.source } : s;
|
|
2836
|
+
case "svg":
|
|
2837
|
+
return t ? { type: "code", lang: "svg", text: s.source } : s;
|
|
2838
|
+
default:
|
|
2839
|
+
return s;
|
|
2840
|
+
}
|
|
2841
|
+
});
|
|
2546
2842
|
}
|
|
2547
|
-
function
|
|
2843
|
+
function zt(n) {
|
|
2548
2844
|
const e = n ?? "", t = e.search(/FOLLOWUPS:/i);
|
|
2549
2845
|
if (t < 0) return { text: e.trim(), followups: [] };
|
|
2550
|
-
const
|
|
2551
|
-
return { text: e.slice(0, t).trim(), followups:
|
|
2846
|
+
const i = e.slice(t).replace(/^FOLLOWUPS:/i, "").split(/\||\n/).map((a) => a.replace(/^\s*(?:[-*↳→]|\d+[.)])\s*/, "").trim()).filter(Boolean).slice(0, 3);
|
|
2847
|
+
return { text: e.slice(0, t).trim(), followups: i };
|
|
2552
2848
|
}
|
|
2553
|
-
function
|
|
2554
|
-
return (n ?? "").replace(
|
|
2849
|
+
function ms(n) {
|
|
2850
|
+
return (n ?? "").replace(
|
|
2851
|
+
/```(\w*)[\s\S]*?(```|$)/g,
|
|
2852
|
+
(e, t) => t === "chart" ? "[Chart] " : t === "svg" ? "[Drawing] " : "[Code] "
|
|
2853
|
+
).replace(/!\[([^\]]*)\]\([^)]*\)/g, "[Image: $1]").replace(/\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g, "$1").replace(/\[!(NOTE|TIP|IMPORTANT|WARNING|CAUTION)\]/gi, "").replace(/[*#>`~]/g, "").replace(/\|/g, " ").replace(/\s?\[\d+(?:\s*,\s*\d+)*\]/g, "").replace(/\s+/g, " ").trim();
|
|
2555
2854
|
}
|
|
2556
|
-
function
|
|
2557
|
-
const t =
|
|
2855
|
+
function fs(n, e = 48) {
|
|
2856
|
+
const t = ms(n);
|
|
2558
2857
|
if (t.length <= e) return t;
|
|
2559
|
-
const
|
|
2560
|
-
return (
|
|
2858
|
+
const s = t.slice(0, e), i = s.lastIndexOf(" ");
|
|
2859
|
+
return (i > e / 2 ? s.slice(0, i) : s).trim();
|
|
2561
2860
|
}
|
|
2562
|
-
function
|
|
2861
|
+
function bs(n) {
|
|
2563
2862
|
return String(n ?? "").split(`
|
|
2564
2863
|
`)[0].trim().replace(/^["'“”‘’]+|["'“”‘’]+$/g, "").replace(/^title:\s*/i, "").replace(/[.!?:;,]+$/, "").trim().slice(0, 80);
|
|
2565
2864
|
}
|
|
2566
|
-
function
|
|
2865
|
+
function _t(n, e = !1) {
|
|
2567
2866
|
return /^https?:\/\//i.test(n) ? !0 : e && /^(blob:|data:image\/)/i.test(n);
|
|
2568
2867
|
}
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2868
|
+
const xs = 2e5, vs = /* @__PURE__ */ new Set([
|
|
2869
|
+
"script",
|
|
2870
|
+
"foreignobject",
|
|
2871
|
+
"iframe",
|
|
2872
|
+
"object",
|
|
2873
|
+
"embed",
|
|
2874
|
+
"image",
|
|
2875
|
+
"audio",
|
|
2876
|
+
"video",
|
|
2877
|
+
"animate",
|
|
2878
|
+
"set",
|
|
2879
|
+
"animatemotion",
|
|
2880
|
+
"animatetransform",
|
|
2881
|
+
"handler",
|
|
2882
|
+
"listener"
|
|
2883
|
+
]);
|
|
2884
|
+
function ws(n) {
|
|
2885
|
+
if (!n || n.length > xs || typeof DOMParser > "u") return null;
|
|
2886
|
+
const e = new DOMParser().parseFromString(n, "image/svg+xml"), t = e.documentElement;
|
|
2887
|
+
if (!t || t.nodeName.toLowerCase() !== "svg" || e.querySelector("parsererror"))
|
|
2888
|
+
return null;
|
|
2889
|
+
const s = (a) => {
|
|
2890
|
+
for (const r of Array.from(a.children)) {
|
|
2891
|
+
const c = r.nodeName.toLowerCase();
|
|
2892
|
+
if (vs.has(c)) r.remove();
|
|
2893
|
+
else if (c === "a") {
|
|
2894
|
+
const l = Array.from(r.childNodes);
|
|
2895
|
+
r.replaceWith(...l), l.forEach((f) => f instanceof Element && s(f));
|
|
2896
|
+
} else s(r);
|
|
2897
|
+
}
|
|
2898
|
+
for (const r of Array.from(a.attributes)) {
|
|
2899
|
+
const c = r.name.toLowerCase(), l = r.value.trim().toLowerCase(), f = (c === "href" || c.endsWith(":href")) && !l.startsWith("#"), b = l.includes("javascript:") || /url\(\s*['"]?(?!#)/.test(l);
|
|
2900
|
+
(c.startsWith("on") || f || b) && a.removeAttribute(r.name);
|
|
2901
|
+
}
|
|
2902
|
+
};
|
|
2903
|
+
s(t);
|
|
2904
|
+
for (const a of Array.from(t.querySelectorAll("style")))
|
|
2905
|
+
a.textContent = (a.textContent ?? "").replace(/@import[^;]*;?/gi, "").replace(/url\(\s*['"]?(?!#)[^)]*\)/gi, "none");
|
|
2906
|
+
t.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
2907
|
+
const i = new XMLSerializer().serializeToString(t);
|
|
2908
|
+
return `data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`;
|
|
2909
|
+
}
|
|
2910
|
+
var Pt = Object.defineProperty, ys = Object.getOwnPropertyDescriptor, ks = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, g = (n, e, t, s) => {
|
|
2911
|
+
for (var i = s > 1 ? void 0 : s ? ys(e, t) : e, a = n.length - 1, r; a >= 0; a--)
|
|
2912
|
+
(r = n[a]) && (i = (s ? r(e, t, i) : r(i)) || i);
|
|
2913
|
+
return s && i && Pt(e, t, i), i;
|
|
2914
|
+
}, $s = (n, e, t) => ks(n, e + "", t);
|
|
2915
|
+
const Lt = [
|
|
2575
2916
|
"embed",
|
|
2576
2917
|
"mode",
|
|
2577
|
-
"
|
|
2918
|
+
"format",
|
|
2919
|
+
"renderers",
|
|
2920
|
+
"beforeSend",
|
|
2921
|
+
"afterParse",
|
|
2578
2922
|
"glow",
|
|
2579
2923
|
"position",
|
|
2580
2924
|
"sidebar",
|
|
@@ -2583,14 +2927,33 @@ const st = [
|
|
|
2583
2927
|
"logoUrl",
|
|
2584
2928
|
"heading",
|
|
2585
2929
|
"description",
|
|
2930
|
+
"eyebrow",
|
|
2586
2931
|
"prompts",
|
|
2587
2932
|
"bubbleText",
|
|
2588
2933
|
"greetingBubble",
|
|
2589
2934
|
"unreadBadge",
|
|
2590
2935
|
"allowUpload",
|
|
2591
2936
|
"allowExport",
|
|
2937
|
+
"allowRaw",
|
|
2938
|
+
"allowCopy",
|
|
2939
|
+
"allowRegenerate",
|
|
2940
|
+
"allowBookmark",
|
|
2941
|
+
"allowDelete",
|
|
2942
|
+
"allowRename",
|
|
2943
|
+
"allowFeedback",
|
|
2944
|
+
"showTime",
|
|
2945
|
+
"showComposer",
|
|
2946
|
+
"footnote",
|
|
2592
2947
|
"branding",
|
|
2593
2948
|
"followups",
|
|
2949
|
+
"docsets",
|
|
2950
|
+
"attachmentsMode",
|
|
2951
|
+
"saveAttachments",
|
|
2952
|
+
"showFollowups",
|
|
2953
|
+
"showSources",
|
|
2954
|
+
"showNewChat",
|
|
2955
|
+
"showBookmarked",
|
|
2956
|
+
"allowSearch",
|
|
2594
2957
|
"autoTitle",
|
|
2595
2958
|
"model",
|
|
2596
2959
|
"params",
|
|
@@ -2598,8 +2961,9 @@ const st = [
|
|
|
2598
2961
|
"retrieval",
|
|
2599
2962
|
"metadata",
|
|
2600
2963
|
"messages",
|
|
2601
|
-
"theme"
|
|
2602
|
-
|
|
2964
|
+
"theme",
|
|
2965
|
+
"radius"
|
|
2966
|
+
], vt = {
|
|
2603
2967
|
fromAttribute: (n) => {
|
|
2604
2968
|
if (n)
|
|
2605
2969
|
try {
|
|
@@ -2613,19 +2977,30 @@ const st = [
|
|
|
2613
2977
|
}, I = {
|
|
2614
2978
|
fromAttribute: (n) => n === null ? !0 : n !== "false",
|
|
2615
2979
|
toAttribute: (n) => n ? null : "false"
|
|
2616
|
-
},
|
|
2617
|
-
fromAttribute: (n) => n === null ?
|
|
2618
|
-
toAttribute: (n) => n ===
|
|
2619
|
-
},
|
|
2980
|
+
}, Cs = {
|
|
2981
|
+
fromAttribute: (n) => n === null ? "auto" : n === "" || n === "true" ? "open" : n === "false" ? "closed" : ["auto", "open", "closed", "none"].includes(n) ? n : "auto",
|
|
2982
|
+
toAttribute: (n) => n === "auto" ? null : n
|
|
2983
|
+
}, Ts = 272, Ss = 820, Is = 940, At = 5, jt = 512 * 1024, Os = /\.(md|markdown|txt|csv|tsv|json|html?|ya?ml|xml|log)$/i, Ms = 5e3, zs = 200, Nt = 2e3, _s = {
|
|
2984
|
+
note: "calloutNote",
|
|
2985
|
+
tip: "calloutTip",
|
|
2986
|
+
important: "calloutImportant",
|
|
2987
|
+
warning: "calloutWarning",
|
|
2988
|
+
caution: "calloutCaution"
|
|
2989
|
+
}, Ls = 2600, j = [
|
|
2620
2990
|
"var(--c-ink)",
|
|
2621
2991
|
"oklch(0.58 0.13 255)",
|
|
2622
2992
|
"oklch(0.63 0.1 175)",
|
|
2623
2993
|
"oklch(0.74 0.12 70)"
|
|
2624
|
-
],
|
|
2994
|
+
], Rt = {
|
|
2625
2995
|
chat: "Be helpful and concise. Use Markdown when it helps: headings, lists, **bold**, code blocks and tables.",
|
|
2626
|
-
rag: "
|
|
2627
|
-
|
|
2628
|
-
},
|
|
2996
|
+
rag: "Prefer the sources provided with each message, numbered in the order given, and put a citation like [1] right after each claim they support. If they don't cover the question, you may answer from general knowledge, but say clearly that it isn't from the sources.",
|
|
2997
|
+
kb: "Answer ONLY from the sources provided with each message, numbered in the order given. Put a citation like [1] right after each claim. Do not use outside knowledge. If the sources don't contain the answer, say that you can't find it in the available sources."
|
|
2998
|
+
}, As = {
|
|
2999
|
+
raw: "Reply in plain text. Don't use Markdown or any other markup.",
|
|
3000
|
+
plain: "Format with light Markdown only: short paragraphs, lists, **bold**, *italics*, `inline code`, code blocks and links. Don't use tables, charts, callouts, images or other special blocks.",
|
|
3001
|
+
advanced: `You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. Don't use charts, callouts or images.`,
|
|
3002
|
+
rich: 'When the answer is about data, lead with one sentence stating the key finding, with key numbers in **bold**, then show the data visually. You can use Markdown: headings, lists, task lists, **bold**, *italics*, links, code blocks and pipe tables. For data, use a fenced "csv" block or a fenced "json" block. For a diagram or illustration, write a self-contained fenced "svg" block with a viewBox, and no scripts, links or external images. For trends and comparisons, use a fenced "chart" block containing only JSON: {"type":"bar"|"line","title":string,"unit":string,"labels":[string],"series":[{"name":string,"values":[number]}]}. For notes and warnings, use callouts: a quote starting with [!NOTE], [!TIP], [!IMPORTANT], [!WARNING] or [!CAUTION]. Images use .'
|
|
3003
|
+
}, js = "After the answer, on a final line write FOLLOWUPS: followed by three short follow-up questions the user might ask next, separated by |.", Et = {
|
|
2629
3004
|
chat: [
|
|
2630
3005
|
["Write", "Draft a short welcome email for new users"],
|
|
2631
3006
|
["Explain", "Explain how refresh tokens work, simply"],
|
|
@@ -2638,26 +3013,27 @@ const st = [
|
|
|
2638
3013
|
["Find", "Where is the refund policy described?"],
|
|
2639
3014
|
["Explain", "Explain the setup steps in plain language"]
|
|
2640
3015
|
],
|
|
2641
|
-
|
|
2642
|
-
["
|
|
2643
|
-
["
|
|
2644
|
-
["
|
|
2645
|
-
["
|
|
3016
|
+
kb: [
|
|
3017
|
+
["Find", "Where is the refund policy described?"],
|
|
3018
|
+
["How to", "How do I reset my password?"],
|
|
3019
|
+
["Limits", "What are the plan limits?"],
|
|
3020
|
+
["Policy", "What happens when my account is deleted?"]
|
|
2646
3021
|
]
|
|
2647
|
-
},
|
|
2648
|
-
sidebar: () =>
|
|
2649
|
-
|
|
3022
|
+
}, z = (n, e = "") => o`<svg class="i ${e}" viewBox="0 0 16 16" aria-hidden="true">${n}</svg>`, k = {
|
|
3023
|
+
sidebar: () => z(
|
|
3024
|
+
O`<rect x="2" y="2.5" width="12" height="11" rx="1.5"></rect><path d="M6 2.5v11"></path>`
|
|
2650
3025
|
),
|
|
2651
|
-
plus: () =>
|
|
2652
|
-
bookmark: (n = !1) =>
|
|
2653
|
-
download: () =>
|
|
2654
|
-
trash: () =>
|
|
2655
|
-
pencil: () =>
|
|
2656
|
-
copy: () =>
|
|
2657
|
-
|
|
3026
|
+
plus: () => z(O`<path d="M8 3v10M3 8h10"></path>`),
|
|
3027
|
+
bookmark: (n = !1) => z(O`<path d="M4.5 2.5h7v11L8 11l-3.5 2.5z"></path>`, n ? "filled" : ""),
|
|
3028
|
+
download: () => z(O`<path d="M8 2.5v8M4.5 7.5L8 11l3.5-3.5M2.5 13.5h11"></path>`),
|
|
3029
|
+
trash: () => z(O`<path d="M2.5 4.5h11M6.5 4.5v-2h3v2M4 4.5l.7 9h6.6l.7-9"></path>`),
|
|
3030
|
+
pencil: () => z(O`<path d="M10.5 2.5l3 3L6 13H3v-3z"></path>`),
|
|
3031
|
+
copy: () => z(
|
|
3032
|
+
O`<rect x="5.5" y="5.5" width="8" height="8" rx="1.5"></rect><path d="M10.5 5.5v-2a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2"></path>`
|
|
2658
3033
|
),
|
|
2659
|
-
|
|
2660
|
-
|
|
3034
|
+
raw: () => z(O`<path d="M5.5 4.5L2 8l3.5 3.5M10.5 4.5L14 8l-3.5 3.5"></path>`),
|
|
3035
|
+
refresh: () => z(O`<path d="M13.5 8A5.5 5.5 0 1 1 11.9 4.1M13.5 2v3.5H10"></path>`),
|
|
3036
|
+
thumb: (n = !1) => o`<svg
|
|
2661
3037
|
class="i"
|
|
2662
3038
|
viewBox="0 0 16 16"
|
|
2663
3039
|
aria-hidden="true"
|
|
@@ -2667,16 +3043,16 @@ const st = [
|
|
|
2667
3043
|
d="M5 7v6.5H2.5V7zM5 7l2.5-4.5a1.3 1.3 0 0 1 1.9 1.4L9 6.5h3.6a1 1 0 0 1 1 1.2l-1 4.8a1 1 0 0 1-1 .8H5"
|
|
2668
3044
|
></path>
|
|
2669
3045
|
</svg>`,
|
|
2670
|
-
expand: () =>
|
|
2671
|
-
restore: () =>
|
|
2672
|
-
minimize: () =>
|
|
2673
|
-
close: () =>
|
|
2674
|
-
clip: () =>
|
|
2675
|
-
|
|
3046
|
+
expand: () => z(O`<path d="M9.5 2.5h4v4M13.5 2.5L9 7M6.5 13.5h-4v-4M2.5 13.5L7 9"></path>`),
|
|
3047
|
+
restore: () => z(O`<path d="M13.5 6.5h-4v-4M9.5 6.5l4-4M2.5 9.5h4v4M6.5 9.5l-4 4"></path>`),
|
|
3048
|
+
minimize: () => z(O`<path d="M4 8h8"></path>`),
|
|
3049
|
+
close: () => z(O`<path d="M4 4l8 8M12 4l-8 8"></path>`),
|
|
3050
|
+
clip: () => z(
|
|
3051
|
+
O`<path d="M13 7.5l-5.3 5.3a3 3 0 0 1-4.3-4.3L9 2.9a2 2 0 0 1 2.9 2.9L6.4 11.3a1 1 0 0 1-1.4-1.4L10 5"></path>`
|
|
2676
3052
|
),
|
|
2677
|
-
up: () =>
|
|
2678
|
-
stop: () =>
|
|
2679
|
-
chat: () =>
|
|
3053
|
+
up: () => z(O`<path d="M8 13V3M3.5 7.5L8 3l4.5 4.5"></path>`),
|
|
3054
|
+
stop: () => z(O`<rect x="4.5" y="4.5" width="7" height="7" rx="1"></rect>`),
|
|
3055
|
+
chat: () => o`<svg
|
|
2680
3056
|
width="22"
|
|
2681
3057
|
height="22"
|
|
2682
3058
|
viewBox="0 0 22 22"
|
|
@@ -2687,7 +3063,7 @@ const st = [
|
|
|
2687
3063
|
d="M4 5.5A2.5 2.5 0 0 1 6.5 3h9A2.5 2.5 0 0 1 18 5.5v7a2.5 2.5 0 0 1-2.5 2.5H9l-4 3.5V15H6.5"
|
|
2688
3064
|
></path>
|
|
2689
3065
|
</svg>`,
|
|
2690
|
-
chevronDown: () =>
|
|
3066
|
+
chevronDown: () => o`<svg
|
|
2691
3067
|
width="20"
|
|
2692
3068
|
height="20"
|
|
2693
3069
|
viewBox="0 0 20 20"
|
|
@@ -2697,150 +3073,189 @@ const st = [
|
|
|
2697
3073
|
<path d="M5 8l5 5 5-5"></path>
|
|
2698
3074
|
</svg>`
|
|
2699
3075
|
};
|
|
2700
|
-
let
|
|
2701
|
-
const
|
|
2702
|
-
function
|
|
3076
|
+
let Ns = 0;
|
|
3077
|
+
const bt = () => `m${Date.now().toString(36)}${(Ns++).toString(36)}`;
|
|
3078
|
+
function Bt(n) {
|
|
2703
3079
|
var t;
|
|
2704
3080
|
const e = n;
|
|
2705
3081
|
return (e == null ? void 0 : e.message) === "NOT_FOUND" || (e == null ? void 0 : e.code) === "NOT_FOUND" || ((t = e == null ? void 0 : e.details) == null ? void 0 : t.status) === 404;
|
|
2706
3082
|
}
|
|
2707
|
-
function
|
|
3083
|
+
function Rs(n) {
|
|
2708
3084
|
const e = n;
|
|
2709
3085
|
return (e == null ? void 0 : e.code) || (e == null ? void 0 : e.message) || "UNKNOWN";
|
|
2710
3086
|
}
|
|
2711
|
-
const
|
|
3087
|
+
const Es = () => typeof matchMedia < "u" && matchMedia("(prefers-reduced-motion: reduce)").matches, mt = (n, e) => (Number.isInteger(n) ? n.toLocaleString("en-US") : n.toFixed(1)) + e, xt = (n) => {
|
|
2712
3088
|
const e = n.lastIndexOf(".");
|
|
2713
3089
|
return e > 0 ? n.slice(e + 1, e + 5).toUpperCase() : "FILE";
|
|
2714
3090
|
};
|
|
2715
|
-
function
|
|
2716
|
-
const t = n ?? {},
|
|
3091
|
+
function ft(n, e) {
|
|
3092
|
+
const t = n ?? {}, s = t.metadata && typeof t.metadata == "object" ? t.metadata : {}, i = (...l) => l.find((f) => typeof f == "string" && f.trim()), a = i(t.content, t.text, t.page_content, t.body, t.snippet, t.chunk, s.content) ?? JSON.stringify(t, null, 2), r = [t.score, t.relevance, t._score, s.score].find((l) => typeof l == "number"), c = typeof t.n == "number" && t.n > 0 ? t.n : e;
|
|
2717
3093
|
return {
|
|
2718
|
-
n:
|
|
2719
|
-
title:
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
3094
|
+
n: c,
|
|
3095
|
+
title: i(t.title, t.name, t.filename, s.title, s.name) ?? `Source ${c}`,
|
|
3096
|
+
section: i(t.section, t.heading, s.section) ?? "",
|
|
3097
|
+
path: i(t.path, t.url, t.key, s.path, s.url) ?? "",
|
|
3098
|
+
collection: i(t.collection, t.namespace, t.dbname, s.collection) ?? "",
|
|
3099
|
+
updated: i(t.updated, t._modified_at, s.updated) ?? "",
|
|
2723
3100
|
text: a,
|
|
2724
|
-
score:
|
|
3101
|
+
score: r === void 0 ? null : Math.max(0, Math.min(1, r))
|
|
2725
3102
|
};
|
|
2726
3103
|
}
|
|
2727
|
-
function
|
|
3104
|
+
function Dt(n) {
|
|
3105
|
+
return Array.isArray(n) ? n.filter((e) => e && typeof e == "object" && (e._id || e.id)).filter((e) => e.saved !== !1 && e.status !== "failed").map((e) => ({
|
|
3106
|
+
id: String(e._id ?? e.id),
|
|
3107
|
+
name: String(e.name ?? "file"),
|
|
3108
|
+
type: e.type,
|
|
3109
|
+
mime: e.mime,
|
|
3110
|
+
size: typeof e.size == "number" ? e.size : void 0,
|
|
3111
|
+
status: e.status
|
|
3112
|
+
})) : [];
|
|
3113
|
+
}
|
|
3114
|
+
function Bs(n) {
|
|
2728
3115
|
const e = [], t = [];
|
|
2729
|
-
for (const
|
|
2730
|
-
if (/\.csv$/i.test(
|
|
2731
|
-
else if (/\.json$/i.test(
|
|
3116
|
+
for (const s of n)
|
|
3117
|
+
if (/\.csv$/i.test(s.name)) e.push({ type: "csv", data: s.content });
|
|
3118
|
+
else if (/\.json$/i.test(s.name))
|
|
2732
3119
|
try {
|
|
2733
|
-
e.push({ type: "json", data: JSON.parse(
|
|
3120
|
+
e.push({ type: "json", data: JSON.parse(s.content) });
|
|
2734
3121
|
} catch {
|
|
2735
|
-
t.push({ title:
|
|
3122
|
+
t.push({ title: s.name, content: s.content });
|
|
2736
3123
|
}
|
|
2737
|
-
else t.push({ title:
|
|
3124
|
+
else t.push({ title: s.name, content: s.content });
|
|
2738
3125
|
return t.length && e.push({ type: "docs", payload: { documents: t } }), e;
|
|
2739
3126
|
}
|
|
2740
|
-
function
|
|
3127
|
+
function Ds(n) {
|
|
2741
3128
|
const e = n ? Date.parse(n) : NaN;
|
|
2742
3129
|
if (Number.isNaN(e)) return "older";
|
|
2743
3130
|
const t = /* @__PURE__ */ new Date();
|
|
2744
3131
|
t.setHours(0, 0, 0, 0);
|
|
2745
|
-
const
|
|
2746
|
-
return e >= t.getTime() ? "today" : e >= t.getTime() -
|
|
3132
|
+
const s = 864e5;
|
|
3133
|
+
return e >= t.getTime() ? "today" : e >= t.getTime() - s ? "yesterday" : e >= t.getTime() - 7 * s ? "week" : "older";
|
|
2747
3134
|
}
|
|
2748
|
-
var
|
|
2749
|
-
let d = (
|
|
3135
|
+
var N, R, E, B, D, F, K, P, U, W, H, J, G, q, V, X, Y, Q, Z, ee, te, se, ie, ae, re, oe, ne, le, ce, de, pe, he, ue, ge, me, fe, be, xe, ve, we, ye, ke, $e, Ce, Te, Se, Ie, Oe, Me, ze, _e, Le, Ae, je, Ne, Re, Ee, Be, De, Fe, Ke, Pe, Ue, We, He, Je, Ge, qe, Ve, Xe, Ye, Qe, Ze, et, tt, st, it, at, rt, ot, nt, lt, ct, dt, pt, ht, ut, gt, Ft;
|
|
3136
|
+
let d = (Ft = class extends Jt {
|
|
2750
3137
|
constructor() {
|
|
2751
3138
|
super(...arguments);
|
|
2752
|
-
h(this,
|
|
2753
|
-
h(this,
|
|
3139
|
+
h(this, N, null);
|
|
3140
|
+
h(this, R, {});
|
|
2754
3141
|
h(this, E);
|
|
2755
|
-
h(this,
|
|
2756
|
-
h(this,
|
|
2757
|
-
h(this,
|
|
2758
|
-
h(this, R, !0);
|
|
2759
|
-
h(this, U, !0);
|
|
2760
|
-
h(this, F, "");
|
|
3142
|
+
h(this, B);
|
|
3143
|
+
h(this, D, "chat");
|
|
3144
|
+
h(this, F, "advanced");
|
|
2761
3145
|
h(this, K, {});
|
|
2762
|
-
h(this, P,
|
|
2763
|
-
h(this,
|
|
2764
|
-
h(this,
|
|
2765
|
-
h(this,
|
|
2766
|
-
h(this,
|
|
2767
|
-
h(this, G);
|
|
3146
|
+
h(this, P, null);
|
|
3147
|
+
h(this, U, null);
|
|
3148
|
+
h(this, W, "subtle");
|
|
3149
|
+
h(this, H, "");
|
|
3150
|
+
h(this, J, "retrieval");
|
|
3151
|
+
h(this, G, !0);
|
|
3152
|
+
h(this, q, !0);
|
|
2768
3153
|
h(this, V, !0);
|
|
2769
|
-
h(this, X,
|
|
2770
|
-
h(this, Y,
|
|
2771
|
-
h(this, Q,
|
|
2772
|
-
h(this, Z,
|
|
2773
|
-
h(this, ee,
|
|
3154
|
+
h(this, X, !0);
|
|
3155
|
+
h(this, Y, !0);
|
|
3156
|
+
h(this, Q, !0);
|
|
3157
|
+
h(this, Z, !0);
|
|
3158
|
+
h(this, ee, !0);
|
|
2774
3159
|
h(this, te, "");
|
|
3160
|
+
h(this, se, {});
|
|
2775
3161
|
h(this, ie, "");
|
|
2776
|
-
h(this,
|
|
2777
|
-
h(this,
|
|
2778
|
-
h(this,
|
|
2779
|
-
h(this, ne,
|
|
2780
|
-
h(this,
|
|
2781
|
-
h(this,
|
|
2782
|
-
h(this,
|
|
2783
|
-
h(this,
|
|
2784
|
-
h(this,
|
|
2785
|
-
h(this,
|
|
2786
|
-
h(this,
|
|
2787
|
-
h(this,
|
|
2788
|
-
h(this, me, "");
|
|
2789
|
-
h(this, be, !1);
|
|
3162
|
+
h(this, ae, []);
|
|
3163
|
+
h(this, re, {});
|
|
3164
|
+
h(this, oe, "page");
|
|
3165
|
+
h(this, ne, "right");
|
|
3166
|
+
h(this, le, "auto");
|
|
3167
|
+
h(this, ce, !0);
|
|
3168
|
+
h(this, de, "");
|
|
3169
|
+
h(this, pe, "Assistant");
|
|
3170
|
+
h(this, he, "");
|
|
3171
|
+
h(this, ue, "");
|
|
3172
|
+
h(this, ge, "");
|
|
3173
|
+
h(this, me);
|
|
2790
3174
|
h(this, fe, "");
|
|
2791
|
-
h(this,
|
|
2792
|
-
h(this,
|
|
2793
|
-
h(this,
|
|
2794
|
-
h(this,
|
|
2795
|
-
h(this,
|
|
2796
|
-
h(this,
|
|
2797
|
-
h(this,
|
|
2798
|
-
h(this, Ce,
|
|
2799
|
-
h(this,
|
|
2800
|
-
h(this,
|
|
2801
|
-
h(this,
|
|
2802
|
-
h(this,
|
|
2803
|
-
h(this,
|
|
2804
|
-
h(this,
|
|
2805
|
-
h(this,
|
|
2806
|
-
h(this,
|
|
2807
|
-
h(this, Ae,
|
|
3175
|
+
h(this, be, "");
|
|
3176
|
+
h(this, xe, !1);
|
|
3177
|
+
h(this, ve, !1);
|
|
3178
|
+
h(this, we, !0);
|
|
3179
|
+
h(this, ye, !0);
|
|
3180
|
+
h(this, ke, !0);
|
|
3181
|
+
h(this, $e, !0);
|
|
3182
|
+
h(this, Ce, !0);
|
|
3183
|
+
h(this, Te, !0);
|
|
3184
|
+
h(this, Se, !0);
|
|
3185
|
+
h(this, Ie, !0);
|
|
3186
|
+
h(this, Oe, !0);
|
|
3187
|
+
h(this, Me, !0);
|
|
3188
|
+
h(this, ze);
|
|
3189
|
+
h(this, _e, !1);
|
|
3190
|
+
h(this, Le, !0);
|
|
3191
|
+
h(this, Ae, []);
|
|
3192
|
+
h(this, je, "idle");
|
|
3193
|
+
h(this, Ne, null);
|
|
3194
|
+
h(this, Re, "");
|
|
2808
3195
|
h(this, Ee, !1);
|
|
2809
|
-
h(this,
|
|
2810
|
-
h(this, Be, !1);
|
|
3196
|
+
h(this, Be, []);
|
|
2811
3197
|
h(this, De, !1);
|
|
2812
|
-
h(this,
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
3198
|
+
h(this, Fe, "");
|
|
3199
|
+
h(this, Ke, !1);
|
|
3200
|
+
h(this, Pe, "");
|
|
3201
|
+
h(this, Ue, []);
|
|
3202
|
+
h(this, We, "");
|
|
3203
|
+
h(this, He, null);
|
|
3204
|
+
h(this, Je, 0);
|
|
3205
|
+
h(this, Ge, null);
|
|
3206
|
+
h(this, qe, !1);
|
|
3207
|
+
h(this, Ve, "");
|
|
3208
|
+
h(this, Xe, "");
|
|
3209
|
+
h(this, Ye, !1);
|
|
3210
|
+
h(this, Qe, "");
|
|
3211
|
+
h(this, Ze, null);
|
|
3212
|
+
h(this, et, "");
|
|
3213
|
+
h(this, tt, /* @__PURE__ */ new Set());
|
|
3214
|
+
h(this, st, /* @__PURE__ */ new Set());
|
|
3215
|
+
h(this, it, []);
|
|
3216
|
+
h(this, at, !1);
|
|
3217
|
+
h(this, rt, /* @__PURE__ */ new Map());
|
|
3218
|
+
h(this, ot, "");
|
|
3219
|
+
h(this, nt, !1);
|
|
3220
|
+
h(this, lt, !1);
|
|
3221
|
+
h(this, ct, !1);
|
|
3222
|
+
h(this, dt, !1);
|
|
3223
|
+
h(this, pt, !1);
|
|
3224
|
+
h(this, ht, !1);
|
|
3225
|
+
h(this, ut, !1);
|
|
3226
|
+
h(this, gt, !1);
|
|
3227
|
+
M(this, "run", 0);
|
|
3228
|
+
M(this, "abort", null);
|
|
3229
|
+
M(this, "revealTimer");
|
|
3230
|
+
M(this, "timers", /* @__PURE__ */ new Set());
|
|
3231
|
+
M(this, "toastTimer");
|
|
3232
|
+
M(this, "stick", !0);
|
|
3233
|
+
M(this, "renamed", /* @__PURE__ */ new Set());
|
|
3234
|
+
M(this, "observer", null);
|
|
3235
|
+
M(this, "observed", null);
|
|
3236
|
+
M(this, "media", null);
|
|
3237
|
+
M(this, "focusNext", "");
|
|
3238
|
+
M(this, "bubbleScheduled", !1);
|
|
3239
|
+
M(this, "pendingChatId", "");
|
|
3240
|
+
M(this, "onNetwork", () => {
|
|
2826
3241
|
this.offline = navigator.onLine === !1;
|
|
2827
3242
|
});
|
|
2828
|
-
|
|
3243
|
+
M(this, "onMedia", () => {
|
|
2829
3244
|
var e;
|
|
2830
3245
|
this.mobile = !!((e = this.media) != null && e.matches);
|
|
2831
3246
|
});
|
|
2832
3247
|
}
|
|
2833
3248
|
get client() {
|
|
2834
|
-
return p(this,
|
|
3249
|
+
return p(this, N);
|
|
2835
3250
|
}
|
|
2836
3251
|
set client(e) {
|
|
2837
|
-
u(this,
|
|
3252
|
+
u(this, N, e);
|
|
2838
3253
|
}
|
|
2839
3254
|
get messages() {
|
|
2840
|
-
return p(this,
|
|
3255
|
+
return p(this, R);
|
|
2841
3256
|
}
|
|
2842
3257
|
set messages(e) {
|
|
2843
|
-
u(this,
|
|
3258
|
+
u(this, R, e);
|
|
2844
3259
|
}
|
|
2845
3260
|
get theme() {
|
|
2846
3261
|
return p(this, E);
|
|
@@ -2848,360 +3263,522 @@ let d = (dt = class extends ft {
|
|
|
2848
3263
|
set theme(e) {
|
|
2849
3264
|
u(this, E, e);
|
|
2850
3265
|
}
|
|
2851
|
-
get
|
|
2852
|
-
return p(this, N);
|
|
2853
|
-
}
|
|
2854
|
-
set mode(e) {
|
|
2855
|
-
u(this, N, e);
|
|
2856
|
-
}
|
|
2857
|
-
get renderAs() {
|
|
3266
|
+
get radius() {
|
|
2858
3267
|
return p(this, B);
|
|
2859
3268
|
}
|
|
2860
|
-
set
|
|
3269
|
+
set radius(e) {
|
|
2861
3270
|
u(this, B, e);
|
|
2862
3271
|
}
|
|
2863
|
-
get
|
|
3272
|
+
get mode() {
|
|
2864
3273
|
return p(this, D);
|
|
2865
3274
|
}
|
|
2866
|
-
set
|
|
3275
|
+
set mode(e) {
|
|
2867
3276
|
u(this, D, e);
|
|
2868
3277
|
}
|
|
2869
|
-
get
|
|
2870
|
-
return p(this, R);
|
|
2871
|
-
}
|
|
2872
|
-
set followups(e) {
|
|
2873
|
-
u(this, R, e);
|
|
2874
|
-
}
|
|
2875
|
-
get autoTitle() {
|
|
2876
|
-
return p(this, U);
|
|
2877
|
-
}
|
|
2878
|
-
set autoTitle(e) {
|
|
2879
|
-
u(this, U, e);
|
|
2880
|
-
}
|
|
2881
|
-
get model() {
|
|
3278
|
+
get format() {
|
|
2882
3279
|
return p(this, F);
|
|
2883
3280
|
}
|
|
2884
|
-
set
|
|
3281
|
+
set format(e) {
|
|
2885
3282
|
u(this, F, e);
|
|
2886
3283
|
}
|
|
2887
|
-
get
|
|
3284
|
+
get renderers() {
|
|
2888
3285
|
return p(this, K);
|
|
2889
3286
|
}
|
|
2890
|
-
set
|
|
3287
|
+
set renderers(e) {
|
|
2891
3288
|
u(this, K, e);
|
|
2892
3289
|
}
|
|
2893
|
-
get
|
|
3290
|
+
get beforeSend() {
|
|
2894
3291
|
return p(this, P);
|
|
2895
3292
|
}
|
|
2896
|
-
set
|
|
3293
|
+
set beforeSend(e) {
|
|
2897
3294
|
u(this, P, e);
|
|
2898
3295
|
}
|
|
2899
|
-
get
|
|
3296
|
+
get afterParse() {
|
|
3297
|
+
return p(this, U);
|
|
3298
|
+
}
|
|
3299
|
+
set afterParse(e) {
|
|
3300
|
+
u(this, U, e);
|
|
3301
|
+
}
|
|
3302
|
+
get glow() {
|
|
3303
|
+
return p(this, W);
|
|
3304
|
+
}
|
|
3305
|
+
set glow(e) {
|
|
3306
|
+
u(this, W, e);
|
|
3307
|
+
}
|
|
3308
|
+
get docsets() {
|
|
2900
3309
|
return p(this, H);
|
|
2901
3310
|
}
|
|
2902
|
-
set
|
|
3311
|
+
set docsets(e) {
|
|
2903
3312
|
u(this, H, e);
|
|
2904
3313
|
}
|
|
2905
|
-
get
|
|
3314
|
+
get attachmentsMode() {
|
|
2906
3315
|
return p(this, J);
|
|
2907
3316
|
}
|
|
2908
|
-
set
|
|
3317
|
+
set attachmentsMode(e) {
|
|
2909
3318
|
u(this, J, e);
|
|
2910
3319
|
}
|
|
2911
|
-
get
|
|
2912
|
-
return p(this,
|
|
3320
|
+
get saveAttachments() {
|
|
3321
|
+
return p(this, G);
|
|
2913
3322
|
}
|
|
2914
|
-
set
|
|
2915
|
-
u(this,
|
|
3323
|
+
set saveAttachments(e) {
|
|
3324
|
+
u(this, G, e);
|
|
2916
3325
|
}
|
|
2917
|
-
get
|
|
3326
|
+
get followups() {
|
|
2918
3327
|
return p(this, q);
|
|
2919
3328
|
}
|
|
2920
|
-
set
|
|
3329
|
+
set followups(e) {
|
|
2921
3330
|
u(this, q, e);
|
|
2922
3331
|
}
|
|
3332
|
+
get showSources() {
|
|
3333
|
+
return p(this, V);
|
|
3334
|
+
}
|
|
3335
|
+
set showSources(e) {
|
|
3336
|
+
u(this, V, e);
|
|
3337
|
+
}
|
|
3338
|
+
get showNewChat() {
|
|
3339
|
+
return p(this, X);
|
|
3340
|
+
}
|
|
3341
|
+
set showNewChat(e) {
|
|
3342
|
+
u(this, X, e);
|
|
3343
|
+
}
|
|
3344
|
+
get showBookmarked() {
|
|
3345
|
+
return p(this, Y);
|
|
3346
|
+
}
|
|
3347
|
+
set showBookmarked(e) {
|
|
3348
|
+
u(this, Y, e);
|
|
3349
|
+
}
|
|
3350
|
+
get showFollowups() {
|
|
3351
|
+
return p(this, Q);
|
|
3352
|
+
}
|
|
3353
|
+
set showFollowups(e) {
|
|
3354
|
+
u(this, Q, e);
|
|
3355
|
+
}
|
|
3356
|
+
get allowSearch() {
|
|
3357
|
+
return p(this, Z);
|
|
3358
|
+
}
|
|
3359
|
+
set allowSearch(e) {
|
|
3360
|
+
u(this, Z, e);
|
|
3361
|
+
}
|
|
3362
|
+
get autoTitle() {
|
|
3363
|
+
return p(this, ee);
|
|
3364
|
+
}
|
|
3365
|
+
set autoTitle(e) {
|
|
3366
|
+
u(this, ee, e);
|
|
3367
|
+
}
|
|
3368
|
+
get model() {
|
|
3369
|
+
return p(this, te);
|
|
3370
|
+
}
|
|
3371
|
+
set model(e) {
|
|
3372
|
+
u(this, te, e);
|
|
3373
|
+
}
|
|
3374
|
+
get params() {
|
|
3375
|
+
return p(this, se);
|
|
3376
|
+
}
|
|
3377
|
+
set params(e) {
|
|
3378
|
+
u(this, se, e);
|
|
3379
|
+
}
|
|
3380
|
+
get systemMessage() {
|
|
3381
|
+
return p(this, ie);
|
|
3382
|
+
}
|
|
3383
|
+
set systemMessage(e) {
|
|
3384
|
+
u(this, ie, e);
|
|
3385
|
+
}
|
|
3386
|
+
get retrieval() {
|
|
3387
|
+
return p(this, ae);
|
|
3388
|
+
}
|
|
3389
|
+
set retrieval(e) {
|
|
3390
|
+
u(this, ae, e);
|
|
3391
|
+
}
|
|
3392
|
+
get metadata() {
|
|
3393
|
+
return p(this, re);
|
|
3394
|
+
}
|
|
3395
|
+
set metadata(e) {
|
|
3396
|
+
u(this, re, e);
|
|
3397
|
+
}
|
|
3398
|
+
get embed() {
|
|
3399
|
+
return p(this, oe);
|
|
3400
|
+
}
|
|
3401
|
+
set embed(e) {
|
|
3402
|
+
u(this, oe, e);
|
|
3403
|
+
}
|
|
3404
|
+
get position() {
|
|
3405
|
+
return p(this, ne);
|
|
3406
|
+
}
|
|
3407
|
+
set position(e) {
|
|
3408
|
+
u(this, ne, e);
|
|
3409
|
+
}
|
|
2923
3410
|
get sidebar() {
|
|
2924
|
-
return p(this,
|
|
3411
|
+
return p(this, le);
|
|
2925
3412
|
}
|
|
2926
3413
|
set sidebar(e) {
|
|
2927
|
-
u(this,
|
|
3414
|
+
u(this, le, e);
|
|
2928
3415
|
}
|
|
2929
3416
|
get showTitle() {
|
|
2930
|
-
return p(this,
|
|
3417
|
+
return p(this, ce);
|
|
2931
3418
|
}
|
|
2932
3419
|
set showTitle(e) {
|
|
2933
|
-
u(this,
|
|
3420
|
+
u(this, ce, e);
|
|
2934
3421
|
}
|
|
2935
3422
|
get chatIdAttr() {
|
|
2936
|
-
return p(this,
|
|
3423
|
+
return p(this, de);
|
|
2937
3424
|
}
|
|
2938
3425
|
set chatIdAttr(e) {
|
|
2939
|
-
u(this,
|
|
3426
|
+
u(this, de, e);
|
|
2940
3427
|
}
|
|
2941
3428
|
get assistantName() {
|
|
2942
|
-
return p(this,
|
|
3429
|
+
return p(this, pe);
|
|
2943
3430
|
}
|
|
2944
3431
|
set assistantName(e) {
|
|
2945
|
-
u(this,
|
|
3432
|
+
u(this, pe, e);
|
|
2946
3433
|
}
|
|
2947
3434
|
get logoUrl() {
|
|
2948
|
-
return p(this,
|
|
3435
|
+
return p(this, he);
|
|
2949
3436
|
}
|
|
2950
3437
|
set logoUrl(e) {
|
|
2951
|
-
u(this,
|
|
3438
|
+
u(this, he, e);
|
|
2952
3439
|
}
|
|
2953
3440
|
get heading() {
|
|
2954
|
-
return p(this,
|
|
3441
|
+
return p(this, ue);
|
|
2955
3442
|
}
|
|
2956
3443
|
set heading(e) {
|
|
2957
|
-
u(this,
|
|
3444
|
+
u(this, ue, e);
|
|
2958
3445
|
}
|
|
2959
3446
|
get description() {
|
|
2960
|
-
return p(this,
|
|
3447
|
+
return p(this, ge);
|
|
2961
3448
|
}
|
|
2962
3449
|
set description(e) {
|
|
2963
|
-
u(this,
|
|
3450
|
+
u(this, ge, e);
|
|
3451
|
+
}
|
|
3452
|
+
get eyebrow() {
|
|
3453
|
+
return p(this, me);
|
|
3454
|
+
}
|
|
3455
|
+
set eyebrow(e) {
|
|
3456
|
+
u(this, me, e);
|
|
2964
3457
|
}
|
|
2965
3458
|
get prompts() {
|
|
2966
|
-
return p(this,
|
|
3459
|
+
return p(this, fe);
|
|
2967
3460
|
}
|
|
2968
3461
|
set prompts(e) {
|
|
2969
|
-
u(this,
|
|
3462
|
+
u(this, fe, e);
|
|
2970
3463
|
}
|
|
2971
3464
|
get bubbleText() {
|
|
2972
|
-
return p(this,
|
|
3465
|
+
return p(this, be);
|
|
2973
3466
|
}
|
|
2974
3467
|
set bubbleText(e) {
|
|
2975
|
-
u(this,
|
|
3468
|
+
u(this, be, e);
|
|
2976
3469
|
}
|
|
2977
3470
|
get greetingBubble() {
|
|
2978
|
-
return p(this,
|
|
3471
|
+
return p(this, xe);
|
|
2979
3472
|
}
|
|
2980
3473
|
set greetingBubble(e) {
|
|
2981
|
-
u(this,
|
|
3474
|
+
u(this, xe, e);
|
|
2982
3475
|
}
|
|
2983
3476
|
get unreadBadge() {
|
|
2984
|
-
return p(this,
|
|
3477
|
+
return p(this, ve);
|
|
2985
3478
|
}
|
|
2986
3479
|
set unreadBadge(e) {
|
|
2987
|
-
u(this,
|
|
3480
|
+
u(this, ve, e);
|
|
2988
3481
|
}
|
|
2989
3482
|
get allowUpload() {
|
|
2990
|
-
return p(this,
|
|
3483
|
+
return p(this, we);
|
|
2991
3484
|
}
|
|
2992
3485
|
set allowUpload(e) {
|
|
2993
|
-
u(this,
|
|
3486
|
+
u(this, we, e);
|
|
2994
3487
|
}
|
|
2995
3488
|
get allowExport() {
|
|
2996
|
-
return p(this,
|
|
3489
|
+
return p(this, ye);
|
|
2997
3490
|
}
|
|
2998
3491
|
set allowExport(e) {
|
|
2999
|
-
u(this,
|
|
3492
|
+
u(this, ye, e);
|
|
3493
|
+
}
|
|
3494
|
+
get allowCopy() {
|
|
3495
|
+
return p(this, ke);
|
|
3496
|
+
}
|
|
3497
|
+
set allowCopy(e) {
|
|
3498
|
+
u(this, ke, e);
|
|
3499
|
+
}
|
|
3500
|
+
get allowRegenerate() {
|
|
3501
|
+
return p(this, $e);
|
|
3502
|
+
}
|
|
3503
|
+
set allowRegenerate(e) {
|
|
3504
|
+
u(this, $e, e);
|
|
3505
|
+
}
|
|
3506
|
+
get allowBookmark() {
|
|
3507
|
+
return p(this, Ce);
|
|
3508
|
+
}
|
|
3509
|
+
set allowBookmark(e) {
|
|
3510
|
+
u(this, Ce, e);
|
|
3511
|
+
}
|
|
3512
|
+
get allowDelete() {
|
|
3513
|
+
return p(this, Te);
|
|
3514
|
+
}
|
|
3515
|
+
set allowDelete(e) {
|
|
3516
|
+
u(this, Te, e);
|
|
3517
|
+
}
|
|
3518
|
+
get allowRename() {
|
|
3519
|
+
return p(this, Se);
|
|
3520
|
+
}
|
|
3521
|
+
set allowRename(e) {
|
|
3522
|
+
u(this, Se, e);
|
|
3523
|
+
}
|
|
3524
|
+
get allowFeedback() {
|
|
3525
|
+
return p(this, Ie);
|
|
3526
|
+
}
|
|
3527
|
+
set allowFeedback(e) {
|
|
3528
|
+
u(this, Ie, e);
|
|
3529
|
+
}
|
|
3530
|
+
get showComposer() {
|
|
3531
|
+
return p(this, Oe);
|
|
3532
|
+
}
|
|
3533
|
+
set showComposer(e) {
|
|
3534
|
+
u(this, Oe, e);
|
|
3535
|
+
}
|
|
3536
|
+
get showTime() {
|
|
3537
|
+
return p(this, Me);
|
|
3538
|
+
}
|
|
3539
|
+
set showTime(e) {
|
|
3540
|
+
u(this, Me, e);
|
|
3541
|
+
}
|
|
3542
|
+
get footnote() {
|
|
3543
|
+
return p(this, ze);
|
|
3544
|
+
}
|
|
3545
|
+
set footnote(e) {
|
|
3546
|
+
u(this, ze, e);
|
|
3547
|
+
}
|
|
3548
|
+
get allowRaw() {
|
|
3549
|
+
return p(this, _e);
|
|
3550
|
+
}
|
|
3551
|
+
set allowRaw(e) {
|
|
3552
|
+
u(this, _e, e);
|
|
3000
3553
|
}
|
|
3001
3554
|
get branding() {
|
|
3002
|
-
return p(this,
|
|
3555
|
+
return p(this, Le);
|
|
3003
3556
|
}
|
|
3004
3557
|
set branding(e) {
|
|
3005
|
-
u(this,
|
|
3558
|
+
u(this, Le, e);
|
|
3006
3559
|
}
|
|
3007
3560
|
get chatList() {
|
|
3008
|
-
return p(this,
|
|
3561
|
+
return p(this, Ae);
|
|
3009
3562
|
}
|
|
3010
3563
|
set chatList(e) {
|
|
3011
|
-
u(this,
|
|
3564
|
+
u(this, Ae, e);
|
|
3012
3565
|
}
|
|
3013
3566
|
get listState() {
|
|
3014
|
-
return p(this,
|
|
3567
|
+
return p(this, je);
|
|
3015
3568
|
}
|
|
3016
3569
|
set listState(e) {
|
|
3017
|
-
u(this,
|
|
3570
|
+
u(this, je, e);
|
|
3018
3571
|
}
|
|
3019
3572
|
get activeId() {
|
|
3020
|
-
return p(this,
|
|
3573
|
+
return p(this, Ne);
|
|
3021
3574
|
}
|
|
3022
3575
|
set activeId(e) {
|
|
3023
|
-
u(this,
|
|
3576
|
+
u(this, Ne, e);
|
|
3024
3577
|
}
|
|
3025
3578
|
get chatTitle() {
|
|
3026
|
-
return p(this,
|
|
3579
|
+
return p(this, Re);
|
|
3027
3580
|
}
|
|
3028
3581
|
set chatTitle(e) {
|
|
3029
|
-
u(this,
|
|
3582
|
+
u(this, Re, e);
|
|
3030
3583
|
}
|
|
3031
3584
|
get bookmarked() {
|
|
3032
|
-
return p(this,
|
|
3585
|
+
return p(this, Ee);
|
|
3033
3586
|
}
|
|
3034
3587
|
set bookmarked(e) {
|
|
3035
|
-
u(this,
|
|
3588
|
+
u(this, Ee, e);
|
|
3036
3589
|
}
|
|
3037
3590
|
get msgs() {
|
|
3038
|
-
return p(this,
|
|
3591
|
+
return p(this, Be);
|
|
3039
3592
|
}
|
|
3040
3593
|
set msgs(e) {
|
|
3041
|
-
u(this,
|
|
3594
|
+
u(this, Be, e);
|
|
3042
3595
|
}
|
|
3043
3596
|
get loadingThread() {
|
|
3044
|
-
return p(this,
|
|
3597
|
+
return p(this, De);
|
|
3045
3598
|
}
|
|
3046
3599
|
set loadingThread(e) {
|
|
3047
|
-
u(this,
|
|
3600
|
+
u(this, De, e);
|
|
3048
3601
|
}
|
|
3049
3602
|
get threadError() {
|
|
3050
|
-
return p(this,
|
|
3603
|
+
return p(this, Fe);
|
|
3051
3604
|
}
|
|
3052
3605
|
set threadError(e) {
|
|
3053
|
-
u(this,
|
|
3606
|
+
u(this, Fe, e);
|
|
3054
3607
|
}
|
|
3055
3608
|
get busy() {
|
|
3056
|
-
return p(this,
|
|
3609
|
+
return p(this, Ke);
|
|
3057
3610
|
}
|
|
3058
3611
|
set busy(e) {
|
|
3059
|
-
u(this,
|
|
3612
|
+
u(this, Ke, e);
|
|
3060
3613
|
}
|
|
3061
3614
|
get draft() {
|
|
3062
|
-
return p(this,
|
|
3615
|
+
return p(this, Pe);
|
|
3063
3616
|
}
|
|
3064
3617
|
set draft(e) {
|
|
3065
|
-
u(this,
|
|
3618
|
+
u(this, Pe, e);
|
|
3066
3619
|
}
|
|
3067
3620
|
get files() {
|
|
3068
|
-
return p(this,
|
|
3621
|
+
return p(this, Ue);
|
|
3069
3622
|
}
|
|
3070
3623
|
set files(e) {
|
|
3071
|
-
u(this,
|
|
3624
|
+
u(this, Ue, e);
|
|
3072
3625
|
}
|
|
3073
3626
|
get search() {
|
|
3074
|
-
return p(this,
|
|
3627
|
+
return p(this, We);
|
|
3075
3628
|
}
|
|
3076
3629
|
set search(e) {
|
|
3077
|
-
u(this,
|
|
3630
|
+
u(this, We, e);
|
|
3078
3631
|
}
|
|
3079
3632
|
get sidebarOpen() {
|
|
3080
|
-
return p(this,
|
|
3633
|
+
return p(this, He);
|
|
3081
3634
|
}
|
|
3082
3635
|
set sidebarOpen(e) {
|
|
3083
|
-
u(this,
|
|
3636
|
+
u(this, He, e);
|
|
3084
3637
|
}
|
|
3085
3638
|
get width() {
|
|
3086
|
-
return p(this,
|
|
3639
|
+
return p(this, Je);
|
|
3087
3640
|
}
|
|
3088
3641
|
set width(e) {
|
|
3089
|
-
u(this,
|
|
3642
|
+
u(this, Je, e);
|
|
3090
3643
|
}
|
|
3091
3644
|
get panel() {
|
|
3092
|
-
return p(this,
|
|
3645
|
+
return p(this, Ge);
|
|
3093
3646
|
}
|
|
3094
3647
|
set panel(e) {
|
|
3095
|
-
u(this,
|
|
3648
|
+
u(this, Ge, e);
|
|
3096
3649
|
}
|
|
3097
3650
|
get menuOpen() {
|
|
3098
|
-
return p(this,
|
|
3651
|
+
return p(this, qe);
|
|
3099
3652
|
}
|
|
3100
3653
|
set menuOpen(e) {
|
|
3101
|
-
u(this,
|
|
3654
|
+
u(this, qe, e);
|
|
3102
3655
|
}
|
|
3103
3656
|
get editingKey() {
|
|
3104
|
-
return p(this,
|
|
3657
|
+
return p(this, Ve);
|
|
3105
3658
|
}
|
|
3106
3659
|
set editingKey(e) {
|
|
3107
|
-
u(this,
|
|
3660
|
+
u(this, Ve, e);
|
|
3108
3661
|
}
|
|
3109
3662
|
get editDraft() {
|
|
3110
|
-
return p(this,
|
|
3663
|
+
return p(this, Xe);
|
|
3111
3664
|
}
|
|
3112
3665
|
set editDraft(e) {
|
|
3113
|
-
u(this,
|
|
3666
|
+
u(this, Xe, e);
|
|
3114
3667
|
}
|
|
3115
3668
|
get editingTitle() {
|
|
3116
|
-
return p(this,
|
|
3669
|
+
return p(this, Ye);
|
|
3117
3670
|
}
|
|
3118
3671
|
set editingTitle(e) {
|
|
3119
|
-
u(this,
|
|
3672
|
+
u(this, Ye, e);
|
|
3120
3673
|
}
|
|
3121
3674
|
get renamingId() {
|
|
3122
|
-
return p(this,
|
|
3675
|
+
return p(this, Qe);
|
|
3123
3676
|
}
|
|
3124
3677
|
set renamingId(e) {
|
|
3125
|
-
u(this,
|
|
3678
|
+
u(this, Qe, e);
|
|
3126
3679
|
}
|
|
3127
3680
|
get toast() {
|
|
3128
|
-
return p(this,
|
|
3681
|
+
return p(this, Ze);
|
|
3129
3682
|
}
|
|
3130
3683
|
set toast(e) {
|
|
3131
|
-
u(this,
|
|
3684
|
+
u(this, Ze, e);
|
|
3132
3685
|
}
|
|
3133
3686
|
get copiedKey() {
|
|
3134
|
-
return p(this,
|
|
3687
|
+
return p(this, et);
|
|
3135
3688
|
}
|
|
3136
3689
|
set copiedKey(e) {
|
|
3137
|
-
u(this,
|
|
3690
|
+
u(this, et, e);
|
|
3138
3691
|
}
|
|
3139
3692
|
get retrievalOpen() {
|
|
3140
|
-
return p(this,
|
|
3693
|
+
return p(this, tt);
|
|
3141
3694
|
}
|
|
3142
3695
|
set retrievalOpen(e) {
|
|
3143
|
-
u(this,
|
|
3696
|
+
u(this, tt, e);
|
|
3697
|
+
}
|
|
3698
|
+
get rawKeys() {
|
|
3699
|
+
return p(this, st);
|
|
3700
|
+
}
|
|
3701
|
+
set rawKeys(e) {
|
|
3702
|
+
u(this, st, e);
|
|
3703
|
+
}
|
|
3704
|
+
get savedFiles() {
|
|
3705
|
+
return p(this, it);
|
|
3706
|
+
}
|
|
3707
|
+
set savedFiles(e) {
|
|
3708
|
+
u(this, it, e);
|
|
3709
|
+
}
|
|
3710
|
+
get hasSidebarContent() {
|
|
3711
|
+
return p(this, at);
|
|
3712
|
+
}
|
|
3713
|
+
set hasSidebarContent(e) {
|
|
3714
|
+
u(this, at, e);
|
|
3715
|
+
}
|
|
3716
|
+
get sorts() {
|
|
3717
|
+
return p(this, rt);
|
|
3718
|
+
}
|
|
3719
|
+
set sorts(e) {
|
|
3720
|
+
u(this, rt, e);
|
|
3144
3721
|
}
|
|
3145
3722
|
get arrivedKey() {
|
|
3146
|
-
return p(this,
|
|
3723
|
+
return p(this, ot);
|
|
3147
3724
|
}
|
|
3148
3725
|
set arrivedKey(e) {
|
|
3149
|
-
u(this,
|
|
3726
|
+
u(this, ot, e);
|
|
3150
3727
|
}
|
|
3151
3728
|
get dragging() {
|
|
3152
|
-
return p(this,
|
|
3729
|
+
return p(this, nt);
|
|
3153
3730
|
}
|
|
3154
3731
|
set dragging(e) {
|
|
3155
|
-
u(this,
|
|
3732
|
+
u(this, nt, e);
|
|
3156
3733
|
}
|
|
3157
3734
|
get showJump() {
|
|
3158
|
-
return p(this,
|
|
3735
|
+
return p(this, lt);
|
|
3159
3736
|
}
|
|
3160
3737
|
set showJump(e) {
|
|
3161
|
-
u(this,
|
|
3738
|
+
u(this, lt, e);
|
|
3162
3739
|
}
|
|
3163
3740
|
get offline() {
|
|
3164
|
-
return p(this,
|
|
3741
|
+
return p(this, ct);
|
|
3165
3742
|
}
|
|
3166
3743
|
set offline(e) {
|
|
3167
|
-
u(this,
|
|
3744
|
+
u(this, ct, e);
|
|
3168
3745
|
}
|
|
3169
3746
|
get isOpen() {
|
|
3170
|
-
return p(this,
|
|
3747
|
+
return p(this, dt);
|
|
3171
3748
|
}
|
|
3172
3749
|
set isOpen(e) {
|
|
3173
|
-
u(this,
|
|
3750
|
+
u(this, dt, e);
|
|
3174
3751
|
}
|
|
3175
3752
|
get expanded() {
|
|
3176
|
-
return p(this,
|
|
3753
|
+
return p(this, pt);
|
|
3177
3754
|
}
|
|
3178
3755
|
set expanded(e) {
|
|
3179
|
-
u(this,
|
|
3756
|
+
u(this, pt, e);
|
|
3180
3757
|
}
|
|
3181
3758
|
get bubble() {
|
|
3182
|
-
return p(this,
|
|
3759
|
+
return p(this, ht);
|
|
3183
3760
|
}
|
|
3184
3761
|
set bubble(e) {
|
|
3185
|
-
u(this,
|
|
3762
|
+
u(this, ht, e);
|
|
3186
3763
|
}
|
|
3187
3764
|
get seen() {
|
|
3188
|
-
return p(this,
|
|
3765
|
+
return p(this, ut);
|
|
3189
3766
|
}
|
|
3190
3767
|
set seen(e) {
|
|
3191
|
-
u(this,
|
|
3768
|
+
u(this, ut, e);
|
|
3192
3769
|
}
|
|
3193
3770
|
get mobile() {
|
|
3194
|
-
return p(this,
|
|
3771
|
+
return p(this, gt);
|
|
3195
3772
|
}
|
|
3196
3773
|
set mobile(e) {
|
|
3197
|
-
u(this,
|
|
3774
|
+
u(this, gt, e);
|
|
3198
3775
|
}
|
|
3199
3776
|
get msg() {
|
|
3200
|
-
return
|
|
3777
|
+
return ts(this.messages);
|
|
3201
3778
|
}
|
|
3202
3779
|
/** An explicit `.client`, else the page default. */
|
|
3203
3780
|
get resolvedClient() {
|
|
3204
|
-
return this.client ??
|
|
3781
|
+
return this.client ?? Vt() ?? null;
|
|
3205
3782
|
}
|
|
3206
3783
|
/** The open conversation's id, or null for a new chat. */
|
|
3207
3784
|
get chatId() {
|
|
@@ -3211,18 +3788,55 @@ let d = (dt = class extends ft {
|
|
|
3211
3788
|
get thread() {
|
|
3212
3789
|
return this.msgs;
|
|
3213
3790
|
}
|
|
3791
|
+
/** `format`, falling back to the default for anything unknown. */
|
|
3792
|
+
/** `docsets` as a clean list of ids. */
|
|
3793
|
+
get docsetIds() {
|
|
3794
|
+
const e = this.docsets, t = Array.isArray(e) ? e : String(e ?? "").split(/[\s,]+/);
|
|
3795
|
+
return [...new Set(t.map((s) => String(s).trim()).filter(Boolean))];
|
|
3796
|
+
}
|
|
3797
|
+
/** The files this chat keeps on the service. */
|
|
3798
|
+
get attachments() {
|
|
3799
|
+
return this.savedFiles;
|
|
3800
|
+
}
|
|
3801
|
+
get formatLevel() {
|
|
3802
|
+
return ["raw", "plain", "advanced", "rich"].includes(this.format) ? this.format : "advanced";
|
|
3803
|
+
}
|
|
3214
3804
|
/** The loaded chat list. */
|
|
3215
3805
|
get chats() {
|
|
3216
3806
|
return this.chatList;
|
|
3217
3807
|
}
|
|
3808
|
+
/**
|
|
3809
|
+
* Every setting in one object, keyed by property name:
|
|
3810
|
+
*
|
|
3811
|
+
* chat.config = { client, mode: "rag", format: "rich", retrieval: [...], chatId: "…" };
|
|
3812
|
+
*
|
|
3813
|
+
* Unknown keys are ignored. `chatId` opens that chat; reading `config`
|
|
3814
|
+
* returns the current settings with `chatId` as the open chat.
|
|
3815
|
+
*/
|
|
3218
3816
|
set config(e) {
|
|
3817
|
+
if (!e) return;
|
|
3219
3818
|
const t = this;
|
|
3220
|
-
|
|
3221
|
-
|
|
3819
|
+
"client" in e && (this.client = e.client ?? null);
|
|
3820
|
+
for (const s of Lt)
|
|
3821
|
+
s in e && (t[s] = e[s]);
|
|
3822
|
+
e.chatId && e.chatId !== this.activeId && (this.hasUpdated ? this.openChat(e.chatId) : this.chatIdAttr = e.chatId);
|
|
3823
|
+
}
|
|
3824
|
+
/**
|
|
3825
|
+
* Changes settings on the fly. Only the keys you pass change; the chat keeps
|
|
3826
|
+
* its conversation and re-renders in place. Returns the element, so calls chain.
|
|
3827
|
+
*
|
|
3828
|
+
* chat.configure({ format: "rich" }).configure({ theme: "dark" });
|
|
3829
|
+
*/
|
|
3830
|
+
configure(e) {
|
|
3831
|
+
return this.config = e, this;
|
|
3222
3832
|
}
|
|
3223
3833
|
get config() {
|
|
3224
3834
|
const e = this;
|
|
3225
|
-
return
|
|
3835
|
+
return {
|
|
3836
|
+
client: this.client,
|
|
3837
|
+
chatId: this.activeId ?? "",
|
|
3838
|
+
...Object.fromEntries(Lt.map((t) => [t, e[t]]))
|
|
3839
|
+
};
|
|
3226
3840
|
}
|
|
3227
3841
|
// ── lifecycle ─────────────────────────────────────────────
|
|
3228
3842
|
connectedCallback() {
|
|
@@ -3238,7 +3852,7 @@ let d = (dt = class extends ft {
|
|
|
3238
3852
|
const t = this.retrieval;
|
|
3239
3853
|
this.retrieval = t && typeof t == "object" ? [t] : [];
|
|
3240
3854
|
}
|
|
3241
|
-
e.has("params") && (!this.params || typeof this.params != "object") && (this.params = {}), e.has("metadata") && (!this.metadata || typeof this.metadata != "object") && (this.metadata = {}), e.has("sidebar") && this.sidebar
|
|
3855
|
+
e.has("params") && (!this.params || typeof this.params != "object") && (this.params = {}), e.has("metadata") && (!this.metadata || typeof this.metadata != "object") && (this.metadata = {}), e.has("sidebar") && (this.sidebar === "open" ? this.sidebarOpen = !0 : this.sidebar === "closed" || this.sidebar === "none" ? this.sidebarOpen = !1 : this.width && (this.sidebarOpen = this.docked)), this.embed === "launcher" && this.greetingBubble && !this.bubbleScheduled && (this.bubbleScheduled = !0, this.later(() => {
|
|
3242
3856
|
!this.isOpen && !this.seen && (this.bubble = !0);
|
|
3243
3857
|
}, 1200));
|
|
3244
3858
|
}
|
|
@@ -3248,70 +3862,70 @@ let d = (dt = class extends ft {
|
|
|
3248
3862
|
updated() {
|
|
3249
3863
|
var t;
|
|
3250
3864
|
const e = this.renderRoot.querySelector(".root");
|
|
3251
|
-
if (e !== this.observed && ((t = this.observer) == null || t.disconnect(), this.observed = e, e && typeof ResizeObserver < "u" && (this.observer ?? (this.observer = new ResizeObserver(([
|
|
3252
|
-
const
|
|
3253
|
-
|
|
3254
|
-
})), this.observer.observe(e))), this.sidebarOpen && this.listState === "idle" && this.resolvedClient && this.loadChats(), this.focusNext) {
|
|
3255
|
-
const
|
|
3865
|
+
if (e !== this.observed && ((t = this.observer) == null || t.disconnect(), this.observed = e, e && typeof ResizeObserver < "u" && (this.observer ?? (this.observer = new ResizeObserver(([s]) => {
|
|
3866
|
+
const i = Math.round(s.contentRect.width);
|
|
3867
|
+
i !== this.width && (this.width = i, this.sidebarOpen === null && (this.sidebarOpen = this.sidebar === "auto" && this.docked));
|
|
3868
|
+
})), this.observer.observe(e))), this.sidebarOpen && this.listState === "idle" && this.resolvedClient && this.loadChats(), this.pendingChatId && this.resolvedClient && this.openChat(this.pendingChatId), this.focusNext) {
|
|
3869
|
+
const s = this.renderRoot.querySelector(
|
|
3256
3870
|
this.focusNext
|
|
3257
3871
|
);
|
|
3258
|
-
this.focusNext = "",
|
|
3872
|
+
this.focusNext = "", s && (s.focus(), "select" in s && s.tagName === "INPUT" && s.select());
|
|
3259
3873
|
}
|
|
3260
3874
|
}
|
|
3261
3875
|
later(e, t) {
|
|
3262
|
-
const
|
|
3263
|
-
this.timers.delete(
|
|
3876
|
+
const s = setTimeout(() => {
|
|
3877
|
+
this.timers.delete(s), e();
|
|
3264
3878
|
}, t);
|
|
3265
|
-
this.timers.add(
|
|
3879
|
+
this.timers.add(s);
|
|
3266
3880
|
}
|
|
3267
3881
|
emit(e, t) {
|
|
3268
3882
|
this.dispatchEvent(new CustomEvent(e, { detail: t, bubbles: !0, composed: !0 }));
|
|
3269
3883
|
}
|
|
3270
3884
|
get docked() {
|
|
3271
|
-
return this.embed === "page" && this.width >=
|
|
3885
|
+
return this.embed === "page" && this.width >= Ss;
|
|
3272
3886
|
}
|
|
3273
3887
|
get panelDocked() {
|
|
3274
|
-
const e = this.docked && this.sidebarOpen ?
|
|
3275
|
-
return this.width - e >=
|
|
3888
|
+
const e = this.docked && this.sidebarOpen ? Ts : 0;
|
|
3889
|
+
return this.width - e >= Is;
|
|
3276
3890
|
}
|
|
3277
3891
|
// ── public API ────────────────────────────────────────────
|
|
3278
3892
|
/** Starts a new, empty conversation. */
|
|
3279
3893
|
newChat() {
|
|
3280
|
-
this.halt(), this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
|
|
3894
|
+
this.halt(), this.pendingChatId = "", this.savedFiles = [], this.loadingThread = !1, this.activeId = null, this.chatTitle = "", this.bookmarked = !1, this.msgs = [], this.threadError = "", this.resetViewState(), this.focusNext = "textarea.input";
|
|
3281
3895
|
}
|
|
3282
3896
|
/** Opens a saved conversation. */
|
|
3283
3897
|
async openChat(e) {
|
|
3284
3898
|
const t = this.resolvedClient;
|
|
3285
3899
|
if (!e) return;
|
|
3286
|
-
this.halt();
|
|
3287
|
-
const
|
|
3288
|
-
if (this.activeId = e, this.chatTitle = (
|
|
3289
|
-
this.
|
|
3900
|
+
this.halt(), this.savedFiles = [];
|
|
3901
|
+
const s = this.chatList.find((a) => a._id === e);
|
|
3902
|
+
if (this.activeId = e, this.chatTitle = (s == null ? void 0 : s.title) ?? "", this.bookmarked = !!(s != null && s.bookmarked), this.msgs = [], this.threadError = "", this.resetViewState(), !t) {
|
|
3903
|
+
this.pendingChatId = e, this.loadingThread = !0;
|
|
3290
3904
|
return;
|
|
3291
3905
|
}
|
|
3292
|
-
const
|
|
3293
|
-
this.loadingThread = !0;
|
|
3906
|
+
const i = ++this.run;
|
|
3907
|
+
this.pendingChatId = "", this.loadingThread = !0;
|
|
3294
3908
|
try {
|
|
3295
3909
|
const a = await t.llm.call("get_chat", {
|
|
3296
3910
|
_id: e
|
|
3297
3911
|
});
|
|
3298
|
-
if (
|
|
3299
|
-
this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((
|
|
3912
|
+
if (i !== this.run) return;
|
|
3913
|
+
this.chatTitle = (a == null ? void 0 : a.title) ?? "", this.bookmarked = !!(a != null && a.bookmarked), this.msgs = ((a == null ? void 0 : a.messages) ?? []).filter((r) => r && (r.role === "user" || r.role === "assistant")).map((r) => this.fromServer(r)), this.savedFiles = Dt(a == null ? void 0 : a.attachments), this.upsertChat({ ...s, ...a, _id: e }), this.stick = !0, this.scrollToBottom();
|
|
3300
3914
|
} catch (a) {
|
|
3301
|
-
if (
|
|
3302
|
-
|
|
3915
|
+
if (i !== this.run) return;
|
|
3916
|
+
Bt(a) ? (this.chatList = this.chatList.filter((r) => r._id !== e), this.newChat(), this.showToast(this.msg.errNotFound)) : this.threadError = this.msg.errLoad;
|
|
3303
3917
|
} finally {
|
|
3304
|
-
|
|
3918
|
+
i === this.run && (this.loadingThread = !1);
|
|
3305
3919
|
}
|
|
3306
3920
|
}
|
|
3307
3921
|
/** Sends a message; with no argument, sends the composer's text. */
|
|
3308
3922
|
async send(e) {
|
|
3309
3923
|
const t = (typeof e == "string" ? e : this.draft).trim();
|
|
3310
3924
|
if (!t || this.busy) return;
|
|
3311
|
-
const
|
|
3925
|
+
const s = this.files;
|
|
3312
3926
|
this.draft = "", this.files = [];
|
|
3313
|
-
const
|
|
3314
|
-
|
|
3927
|
+
const i = this.renderRoot.querySelector("textarea.input");
|
|
3928
|
+
i && (i.style.height = "auto"), await this.runTurn(this.userMessage(t, s));
|
|
3315
3929
|
}
|
|
3316
3930
|
/** Stops waiting for, or revealing, the current reply. */
|
|
3317
3931
|
stop() {
|
|
@@ -3321,57 +3935,57 @@ let d = (dt = class extends ft {
|
|
|
3321
3935
|
}
|
|
3322
3936
|
/** Downloads the open conversation, or copies it as Markdown. */
|
|
3323
3937
|
exportChat(e = "md") {
|
|
3324
|
-
var
|
|
3938
|
+
var L;
|
|
3325
3939
|
if (!this.msgs.length) return;
|
|
3326
3940
|
this.menuOpen = !1;
|
|
3327
|
-
const t = this.chatTitle || this.msg.untitled,
|
|
3328
|
-
const
|
|
3329
|
-
return `[${
|
|
3330
|
-
}),
|
|
3331
|
-
let
|
|
3332
|
-
if (e === "json" ? (
|
|
3941
|
+
const t = this.chatTitle || this.msg.untitled, s = (x) => x.role === "user" ? this.msg.you : this.assistantName, i = (x) => new Date(x || Date.now()).toLocaleString(), a = (x) => x.sources.map((S, $) => {
|
|
3942
|
+
const A = ft(S, $ + 1);
|
|
3943
|
+
return `[${A.n}] ${A.title}${A.path ? ` — ${A.path}` : ""}`;
|
|
3944
|
+
}), r = (x) => (x.attachments ?? []).map((S) => S.name);
|
|
3945
|
+
let c, l = "text/markdown", f = "md";
|
|
3946
|
+
if (e === "json" ? (c = JSON.stringify(
|
|
3333
3947
|
{
|
|
3334
3948
|
exportedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
3335
3949
|
id: this.activeId,
|
|
3336
3950
|
title: t,
|
|
3337
3951
|
mode: this.mode,
|
|
3338
3952
|
bookmarked: this.bookmarked,
|
|
3339
|
-
messages: this.msgs.map((
|
|
3340
|
-
role:
|
|
3341
|
-
text:
|
|
3342
|
-
at: new Date(
|
|
3343
|
-
bookmarked:
|
|
3344
|
-
attachments:
|
|
3345
|
-
sources: a(
|
|
3953
|
+
messages: this.msgs.map((x) => ({
|
|
3954
|
+
role: x.role,
|
|
3955
|
+
text: x.content,
|
|
3956
|
+
at: new Date(x.at || Date.now()).toISOString(),
|
|
3957
|
+
bookmarked: x.bookmarked,
|
|
3958
|
+
attachments: r(x),
|
|
3959
|
+
sources: a(x)
|
|
3346
3960
|
}))
|
|
3347
3961
|
},
|
|
3348
3962
|
null,
|
|
3349
3963
|
2
|
|
3350
|
-
),
|
|
3964
|
+
), l = "application/json", f = "json") : e === "txt" ? (c = `${t}
|
|
3351
3965
|
${"=".repeat(t.length)}
|
|
3352
3966
|
|
|
3353
3967
|
` + this.msgs.map(
|
|
3354
|
-
(
|
|
3355
|
-
`${
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
a(
|
|
3359
|
-
${a(
|
|
3968
|
+
(x) => [
|
|
3969
|
+
`${s(x)} · ${i(x.at)}`,
|
|
3970
|
+
r(x).length ? `Attachments: ${r(x).join(", ")}` : "",
|
|
3971
|
+
x.content,
|
|
3972
|
+
a(x).length ? `Sources:
|
|
3973
|
+
${a(x).join(`
|
|
3360
3974
|
`)}` : ""
|
|
3361
3975
|
].filter(Boolean).join(`
|
|
3362
3976
|
`)
|
|
3363
3977
|
).join(`
|
|
3364
3978
|
|
|
3365
|
-
`),
|
|
3979
|
+
`), l = "text/plain", f = "txt") : c = `# ${t}
|
|
3366
3980
|
|
|
3367
3981
|
` + this.msgs.map(
|
|
3368
|
-
(
|
|
3369
|
-
`### ${
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
a(
|
|
3982
|
+
(x) => [
|
|
3983
|
+
`### ${s(x)} · ${i(x.at)}`,
|
|
3984
|
+
r(x).length ? `Attachments: ${r(x).join(", ")}` : "",
|
|
3985
|
+
x.content,
|
|
3986
|
+
a(x).length ? `**Sources**
|
|
3373
3987
|
|
|
3374
|
-
${a(
|
|
3988
|
+
${a(x).map((S) => `- ${S}`).join(`
|
|
3375
3989
|
`)}` : ""
|
|
3376
3990
|
].filter(Boolean).join(`
|
|
3377
3991
|
|
|
@@ -3382,12 +3996,12 @@ ${a(k).map((L) => `- ${L}`).join(`
|
|
|
3382
3996
|
|
|
3383
3997
|
`) + `
|
|
3384
3998
|
`, this.emit("singlebase-chat-export", { chatId: this.activeId, format: e }), e === "copy") {
|
|
3385
|
-
(
|
|
3999
|
+
(L = navigator.clipboard) == null || L.writeText(c).catch(() => {
|
|
3386
4000
|
}), this.showToast(this.msg.copiedMarkdown);
|
|
3387
4001
|
return;
|
|
3388
4002
|
}
|
|
3389
|
-
const
|
|
3390
|
-
|
|
4003
|
+
const C = `${t.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "") || "chat"}-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 10)}.${f}`, T = URL.createObjectURL(new Blob([c], { type: l })), w = document.createElement("a");
|
|
4004
|
+
w.href = T, w.download = C, document.body.appendChild(w), w.click(), w.remove(), setTimeout(() => URL.revokeObjectURL(T), 2e3), this.showToast(_(this.msg.exported, { name: C }));
|
|
3391
4005
|
}
|
|
3392
4006
|
/** Inline and launcher: fill the window. */
|
|
3393
4007
|
expand() {
|
|
@@ -3407,7 +4021,7 @@ ${a(k).map((L) => `- ${L}`).join(`
|
|
|
3407
4021
|
// ── turns ─────────────────────────────────────────────────
|
|
3408
4022
|
userMessage(e, t = []) {
|
|
3409
4023
|
return {
|
|
3410
|
-
key:
|
|
4024
|
+
key: bt(),
|
|
3411
4025
|
id: null,
|
|
3412
4026
|
role: "user",
|
|
3413
4027
|
content: e,
|
|
@@ -3422,23 +4036,37 @@ ${a(k).map((L) => `- ${L}`).join(`
|
|
|
3422
4036
|
systemPrompt() {
|
|
3423
4037
|
return [
|
|
3424
4038
|
this.systemMessage,
|
|
3425
|
-
|
|
3426
|
-
this.
|
|
4039
|
+
Rt[this.mode] ?? Rt.chat,
|
|
4040
|
+
As[this.formatLevel],
|
|
4041
|
+
this.followups ? js : ""
|
|
3427
4042
|
].filter(Boolean).join(`
|
|
3428
4043
|
|
|
3429
4044
|
`);
|
|
3430
4045
|
}
|
|
3431
4046
|
payloadFor(e) {
|
|
3432
4047
|
const t = { message: e.content, format: "markdown" };
|
|
3433
|
-
this.activeId ? t._id = this.activeId : (t.title =
|
|
3434
|
-
const
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
4048
|
+
this.activeId ? t._id = this.activeId : (t.title = fs(e.content), t.system_message = this.systemPrompt()), t.mode = this.mode, this.model && (t.model = this.model), Object.keys(this.params ?? {}).length && (t.params = this.params);
|
|
4049
|
+
const s = e.attachments ?? [], i = this.attachmentsMode === "payload";
|
|
4050
|
+
i && s.length && (t.attachments = s.map((l) => ({
|
|
4051
|
+
type: "content",
|
|
4052
|
+
content: l.content,
|
|
4053
|
+
name: l.name,
|
|
4054
|
+
...l.mime ? { mime: l.mime } : {},
|
|
4055
|
+
size: l.size,
|
|
4056
|
+
save_attachment: this.saveAttachments
|
|
4057
|
+
})));
|
|
4058
|
+
const a = i ? [] : s.map((l) => l.name);
|
|
4059
|
+
(Object.keys(this.metadata ?? {}).length || a.length) && (t.metadata = { ...this.metadata, ...a.length ? { attachments: a } : {} });
|
|
4060
|
+
const r = this.docsetIds, c = [
|
|
4061
|
+
...r.length ? [{ source: "docset", ids: r }] : [],
|
|
4062
|
+
...this.retrieval ?? [],
|
|
4063
|
+
...i ? [] : Bs(s)
|
|
4064
|
+
];
|
|
4065
|
+
return c.length && (t.retrieval = c), t;
|
|
3438
4066
|
}
|
|
3439
4067
|
async runTurn(e) {
|
|
3440
4068
|
const t = {
|
|
3441
|
-
key:
|
|
4069
|
+
key: bt(),
|
|
3442
4070
|
id: null,
|
|
3443
4071
|
role: "assistant",
|
|
3444
4072
|
content: "",
|
|
@@ -3449,66 +4077,90 @@ ${a(k).map((L) => `- ${L}`).join(`
|
|
|
3449
4077
|
phase: "pending"
|
|
3450
4078
|
};
|
|
3451
4079
|
this.msgs = [...this.msgs, e, t], this.busy = !0, this.panel = null, this.stick = !0, this.scrollToBottom(), this.emit("singlebase-chat-send", { chatId: this.activeId, text: e.content });
|
|
3452
|
-
const
|
|
3453
|
-
if (!
|
|
4080
|
+
const s = this.resolvedClient;
|
|
4081
|
+
if (!s) {
|
|
3454
4082
|
this.failTurn(t, this.msg.errNoClient, "NO_CLIENT"), this.busy = !1;
|
|
3455
4083
|
return;
|
|
3456
4084
|
}
|
|
3457
|
-
const
|
|
4085
|
+
const i = ++this.run, a = new AbortController();
|
|
3458
4086
|
this.abort = a;
|
|
3459
|
-
const
|
|
4087
|
+
const r = !this.activeId;
|
|
4088
|
+
let c = this.payloadFor(e);
|
|
4089
|
+
if (this.beforeSend) {
|
|
4090
|
+
let l;
|
|
4091
|
+
try {
|
|
4092
|
+
l = await this.beforeSend(c, { chatId: this.activeId, isNew: r, message: e });
|
|
4093
|
+
} catch (b) {
|
|
4094
|
+
l = b;
|
|
4095
|
+
}
|
|
4096
|
+
if (i !== this.run) return;
|
|
4097
|
+
if (l === !1) {
|
|
4098
|
+
this.msgs = this.msgs.filter((b) => b !== e && b !== t), this.draft = e.content, this.busy = !1, this.abort = null;
|
|
4099
|
+
return;
|
|
4100
|
+
}
|
|
4101
|
+
if (!(!!l && typeof l == "object" && typeof l.message == "string") || !l.message.trim()) {
|
|
4102
|
+
console.error(
|
|
4103
|
+
"[singlebase-chat] beforeSend must return the request object (with a message) or false to cancel; the message was not sent.",
|
|
4104
|
+
l
|
|
4105
|
+
), this.failTurn(t, this.msg.errGeneric, "BEFORE_SEND_INVALID"), this.busy = !1, this.abort = null;
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
c = l;
|
|
4109
|
+
}
|
|
3460
4110
|
try {
|
|
3461
|
-
const
|
|
3462
|
-
if (
|
|
3463
|
-
_id:
|
|
3464
|
-
title: (
|
|
3465
|
-
bookmarked: !!(
|
|
4111
|
+
const l = await s.llm.call("chat", c, { signal: a.signal }), f = (l == null ? void 0 : l._id) || (l == null ? void 0 : l.chat_id) || this.activeId;
|
|
4112
|
+
if (r && f && this.upsertChat({
|
|
4113
|
+
_id: f,
|
|
4114
|
+
title: (l == null ? void 0 : l.title) || c.title,
|
|
4115
|
+
bookmarked: !!(l != null && l.bookmarked),
|
|
3466
4116
|
_modified_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3467
|
-
}),
|
|
3468
|
-
|
|
3469
|
-
const
|
|
3470
|
-
e.id =
|
|
3471
|
-
id:
|
|
3472
|
-
content:
|
|
3473
|
-
sources: Array.isArray(
|
|
3474
|
-
followups:
|
|
3475
|
-
execTime: typeof
|
|
3476
|
-
model:
|
|
4117
|
+
}), i !== this.run) return;
|
|
4118
|
+
f && (this.activeId = f), r && (this.chatTitle = (l == null ? void 0 : l.title) || c.title, this.bookmarked = !!(l != null && l.bookmarked));
|
|
4119
|
+
const b = (l == null ? void 0 : l.message) ?? {}, C = typeof b.content == "string" ? b.content : (l == null ? void 0 : l.json) !== void 0 ? JSON.stringify(l.json, null, 2) : "", { text: T, followups: w } = zt(C);
|
|
4120
|
+
e.id = b.reply_to ?? null, this.applyAttachmentResults(l == null ? void 0 : l.attachments), Object.assign(t, {
|
|
4121
|
+
id: b._id ?? null,
|
|
4122
|
+
content: T,
|
|
4123
|
+
sources: Array.isArray(b.sources) ? b.sources : [],
|
|
4124
|
+
followups: w,
|
|
4125
|
+
execTime: typeof b.exec_time == "number" ? b.exec_time : void 0,
|
|
4126
|
+
model: b.model,
|
|
3477
4127
|
at: Date.now()
|
|
3478
|
-
}), this.emit("singlebase-chat-response", { chatId:
|
|
3479
|
-
} catch (
|
|
3480
|
-
if (
|
|
3481
|
-
const
|
|
3482
|
-
|
|
4128
|
+
}), this.emit("singlebase-chat-response", { chatId: f, message: t }), await this.reveal(t, i), r && f && this.autoTitle && this.retitle(f, e.content, t.content);
|
|
4129
|
+
} catch (l) {
|
|
4130
|
+
if (i !== this.run) return;
|
|
4131
|
+
const f = Bt(l);
|
|
4132
|
+
f && (this.chatList = this.chatList.filter((T) => T._id !== this.activeId), this.activeId = null);
|
|
4133
|
+
const b = Rs(l), C = f ? this.msg.errNotFound : b === "KB_SOURCE_REQUIRED" ? this.msg.errKbSource : this.msg.errGeneric;
|
|
4134
|
+
this.failTurn(t, C, b);
|
|
3483
4135
|
} finally {
|
|
3484
|
-
|
|
4136
|
+
i === this.run && (this.busy = !1, this.abort = null, this.stick && this.scrollToBottom());
|
|
3485
4137
|
}
|
|
3486
4138
|
}
|
|
3487
|
-
failTurn(e, t,
|
|
3488
|
-
e.phase = "error", e.error = t, this.msgs = [...this.msgs], this.emit("singlebase-chat-error", { chatId: this.activeId, code:
|
|
4139
|
+
failTurn(e, t, s) {
|
|
4140
|
+
e.phase = "error", e.error = t, this.msgs = [...this.msgs], this.emit("singlebase-chat-error", { chatId: this.activeId, code: s, message: t });
|
|
3489
4141
|
}
|
|
3490
4142
|
/**
|
|
3491
4143
|
* The service answers in one piece; this reveals it progressively so it
|
|
3492
4144
|
* reads like a stream. Capped at about a second and a half.
|
|
3493
4145
|
*/
|
|
3494
4146
|
reveal(e, t) {
|
|
3495
|
-
const
|
|
4147
|
+
const s = e.content.length, i = () => {
|
|
3496
4148
|
e.phase = "done", this.msgs = [...this.msgs], this.arrivedKey = e.key, this.later(() => {
|
|
3497
4149
|
this.arrivedKey === e.key && (this.arrivedKey = "");
|
|
3498
|
-
},
|
|
4150
|
+
}, Ls), this.stick ? this.scrollToBottom() : this.showJump = !0;
|
|
3499
4151
|
};
|
|
3500
|
-
if (!
|
|
3501
|
-
return
|
|
3502
|
-
const a = e.content,
|
|
3503
|
-
let
|
|
3504
|
-
return e.phase = "streaming", e.content = "", new Promise((
|
|
4152
|
+
if (!s || Es())
|
|
4153
|
+
return i(), Promise.resolve();
|
|
4154
|
+
const a = e.content, r = Math.max(4, Math.ceil(s / 90));
|
|
4155
|
+
let c = 0;
|
|
4156
|
+
return e.phase = "streaming", e.content = "", new Promise((l) => {
|
|
3505
4157
|
this.revealTimer = setInterval(() => {
|
|
3506
4158
|
if (t !== this.run) {
|
|
3507
|
-
clearInterval(this.revealTimer),
|
|
4159
|
+
clearInterval(this.revealTimer), l();
|
|
3508
4160
|
return;
|
|
3509
4161
|
}
|
|
3510
|
-
if (
|
|
3511
|
-
clearInterval(this.revealTimer),
|
|
4162
|
+
if (c = Math.min(s, c + r), e.content = a.slice(0, c), c >= s) {
|
|
4163
|
+
clearInterval(this.revealTimer), i(), l();
|
|
3512
4164
|
return;
|
|
3513
4165
|
}
|
|
3514
4166
|
this.msgs = [...this.msgs], this.stick && this.scrollToBottom();
|
|
@@ -3520,23 +4172,23 @@ ${a(k).map((L) => `- ${L}`).join(`
|
|
|
3520
4172
|
var e;
|
|
3521
4173
|
this.run++, (e = this.abort) == null || e.abort(), this.abort = null, clearInterval(this.revealTimer), this.busy = !1;
|
|
3522
4174
|
}
|
|
3523
|
-
async retitle(e, t,
|
|
3524
|
-
const
|
|
3525
|
-
if (!(!
|
|
4175
|
+
async retitle(e, t, s) {
|
|
4176
|
+
const i = this.resolvedClient;
|
|
4177
|
+
if (!(!i || this.renamed.has(e)))
|
|
3526
4178
|
try {
|
|
3527
|
-
const a = await
|
|
4179
|
+
const a = await i.llm.call("generate", {
|
|
3528
4180
|
user_input: `user: ${t}
|
|
3529
|
-
assistant: ${
|
|
4181
|
+
assistant: ${s.slice(0, 1500)}`,
|
|
3530
4182
|
custom_instructions: "Write a concise title (3–6 words, sentence case, no quotes, no trailing punctuation) for this conversation.",
|
|
3531
4183
|
format: "text"
|
|
3532
|
-
}),
|
|
3533
|
-
if (!
|
|
3534
|
-
await
|
|
4184
|
+
}), r = bs(a == null ? void 0 : a.result);
|
|
4185
|
+
if (!r || this.renamed.has(e)) return;
|
|
4186
|
+
await i.llm.call("update_chat", { _id: e, title: r }), this.applyTitle(e, r, !0);
|
|
3535
4187
|
} catch {
|
|
3536
4188
|
}
|
|
3537
4189
|
}
|
|
3538
|
-
applyTitle(e, t,
|
|
3539
|
-
this.chatList = this.chatList.map((
|
|
4190
|
+
applyTitle(e, t, s) {
|
|
4191
|
+
this.chatList = this.chatList.map((i) => i._id === e ? { ...i, title: t } : i), this.activeId === e && (this.chatTitle = t), this.emit("singlebase-chat-title", { chatId: e, title: t, auto: s });
|
|
3540
4192
|
}
|
|
3541
4193
|
/**
|
|
3542
4194
|
* Enter and blur both land here. Saving on Enter directly (not via blur())
|
|
@@ -3549,28 +4201,28 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3549
4201
|
this.renamingId === e && (this.renamingId = "", this.renameChat(e, t));
|
|
3550
4202
|
}
|
|
3551
4203
|
async renameChat(e, t) {
|
|
3552
|
-
var a,
|
|
3553
|
-
const
|
|
3554
|
-
if (!(!
|
|
3555
|
-
this.renamed.add(e), this.applyTitle(e,
|
|
4204
|
+
var a, r;
|
|
4205
|
+
const s = t.trim().slice(0, 80), i = ((a = this.chatList.find((c) => c._id === e)) == null ? void 0 : a.title) ?? this.chatTitle;
|
|
4206
|
+
if (!(!s || s === i)) {
|
|
4207
|
+
this.renamed.add(e), this.applyTitle(e, s, !1);
|
|
3556
4208
|
try {
|
|
3557
|
-
await ((
|
|
4209
|
+
await ((r = this.resolvedClient) == null ? void 0 : r.llm.call("update_chat", { _id: e, title: s }));
|
|
3558
4210
|
} catch {
|
|
3559
|
-
this.applyTitle(e,
|
|
4211
|
+
this.applyTitle(e, i ?? "", !1), this.showToast(this.msg.errGeneric);
|
|
3560
4212
|
}
|
|
3561
4213
|
}
|
|
3562
4214
|
}
|
|
3563
4215
|
fromServer(e) {
|
|
3564
|
-
const t = e.role === "assistant", { text:
|
|
4216
|
+
const t = e.role === "assistant", { text: s, followups: i } = t ? zt(String(e.content ?? "")) : { text: String(e.content ?? ""), followups: [] };
|
|
3565
4217
|
return {
|
|
3566
|
-
key:
|
|
4218
|
+
key: bt(),
|
|
3567
4219
|
id: e._id ?? null,
|
|
3568
4220
|
role: t ? "assistant" : "user",
|
|
3569
|
-
content:
|
|
4221
|
+
content: s,
|
|
3570
4222
|
at: Date.parse(e._created_at ?? "") || 0,
|
|
3571
4223
|
bookmarked: !!e.bookmarked,
|
|
3572
4224
|
sources: Array.isArray(e.sources) ? e.sources : [],
|
|
3573
|
-
followups:
|
|
4225
|
+
followups: i,
|
|
3574
4226
|
phase: "done",
|
|
3575
4227
|
execTime: typeof e.exec_time == "number" ? e.exec_time : void 0,
|
|
3576
4228
|
model: e.model
|
|
@@ -3589,57 +4241,96 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3589
4241
|
}
|
|
3590
4242
|
}
|
|
3591
4243
|
}
|
|
4244
|
+
/**
|
|
4245
|
+
* A new chat goes on top. A chat already in the list is updated where it is,
|
|
4246
|
+
* keeping its dates, so opening or using a chat never reorders the list; the
|
|
4247
|
+
* next load from the server brings the fresh order.
|
|
4248
|
+
*/
|
|
3592
4249
|
upsertChat(e) {
|
|
3593
|
-
const t = this.chatList.
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
4250
|
+
const t = this.chatList.findIndex((a) => a._id === e._id);
|
|
4251
|
+
if (t < 0) {
|
|
4252
|
+
this.chatList = [e, ...this.chatList];
|
|
4253
|
+
return;
|
|
4254
|
+
}
|
|
4255
|
+
const s = this.chatList[t], i = [...this.chatList];
|
|
4256
|
+
i[t] = {
|
|
4257
|
+
...s,
|
|
4258
|
+
...e,
|
|
4259
|
+
_created_at: s._created_at ?? e._created_at,
|
|
4260
|
+
_modified_at: s._modified_at ?? e._modified_at
|
|
4261
|
+
}, this.chatList = i;
|
|
3599
4262
|
}
|
|
3600
4263
|
// ── actions ───────────────────────────────────────────────
|
|
3601
4264
|
resetViewState() {
|
|
3602
4265
|
this.panel = null, this.menuOpen = !1, this.editingKey = "", this.editingTitle = !1, this.showJump = !1, this.retrievalOpen = /* @__PURE__ */ new Set(), this.sidebarOpen && !this.docked && (this.sidebarOpen = !1);
|
|
3603
4266
|
}
|
|
3604
4267
|
async deleteOnServer(e) {
|
|
3605
|
-
const t = this.resolvedClient,
|
|
3606
|
-
if (!(!t || !
|
|
3607
|
-
for (const
|
|
3608
|
-
|
|
4268
|
+
const t = this.resolvedClient, s = this.activeId;
|
|
4269
|
+
if (!(!t || !s))
|
|
4270
|
+
for (const i of e)
|
|
4271
|
+
i && await t.llm.call("delete_chat_message", { _id: s, message_id: i }).catch(() => {
|
|
3609
4272
|
});
|
|
3610
4273
|
}
|
|
3611
4274
|
async regenerate() {
|
|
3612
4275
|
if (this.busy) return;
|
|
3613
|
-
const e = this.msgs.map((
|
|
4276
|
+
const e = this.msgs.map((i) => i.role).lastIndexOf("assistant"), t = this.msgs[e - 1];
|
|
3614
4277
|
if (e < 1 || (t == null ? void 0 : t.role) !== "user") return;
|
|
3615
|
-
const
|
|
3616
|
-
this.msgs = this.msgs.slice(0, e - 1), await this.deleteOnServer(
|
|
4278
|
+
const s = this.msgs.slice(e - 1);
|
|
4279
|
+
this.msgs = this.msgs.slice(0, e - 1), await this.deleteOnServer(s.map((i) => i.id)), await this.runTurn(this.userMessage(t.content, t.attachments));
|
|
3617
4280
|
}
|
|
3618
4281
|
async retry(e) {
|
|
3619
4282
|
if (this.busy) return;
|
|
3620
|
-
const t = this.msgs.indexOf(e),
|
|
3621
|
-
(
|
|
4283
|
+
const t = this.msgs.indexOf(e), s = this.msgs[t - 1];
|
|
4284
|
+
(s == null ? void 0 : s.role) === "user" && (this.msgs = this.msgs.slice(0, t - 1), await this.runTurn(this.userMessage(s.content, s.attachments)));
|
|
3622
4285
|
}
|
|
3623
4286
|
async saveEdit(e) {
|
|
3624
|
-
const t = this.editDraft.trim(),
|
|
3625
|
-
if (this.editingKey = "", !t ||
|
|
3626
|
-
const
|
|
3627
|
-
this.msgs = this.msgs.slice(0,
|
|
4287
|
+
const t = this.editDraft.trim(), s = this.msgs.indexOf(e);
|
|
4288
|
+
if (this.editingKey = "", !t || s < 0 || this.busy) return;
|
|
4289
|
+
const i = this.msgs.slice(s);
|
|
4290
|
+
this.msgs = this.msgs.slice(0, s), await this.deleteOnServer(i.map((a) => a.id)), await this.runTurn(this.userMessage(t, e.attachments));
|
|
4291
|
+
}
|
|
4292
|
+
toggleRaw(e) {
|
|
4293
|
+
const t = new Set(this.rawKeys);
|
|
4294
|
+
t.has(e) ? t.delete(e) : t.add(e), this.rawKeys = t;
|
|
4295
|
+
}
|
|
4296
|
+
/** Adds newly saved files, and says which ones the service couldn't read. */
|
|
4297
|
+
applyAttachmentResults(e) {
|
|
4298
|
+
if (!Array.isArray(e)) return;
|
|
4299
|
+
const t = Dt(e).filter((i) => !this.savedFiles.some((a) => a.id === i.id));
|
|
4300
|
+
t.length && (this.savedFiles = [...this.savedFiles, ...t]);
|
|
4301
|
+
const s = e.filter((i) => (i == null ? void 0 : i.status) === "failed").map((i) => String(i.name ?? "file"));
|
|
4302
|
+
s.length && this.showToast(_(this.msg.attachmentFailed, { name: s.join(", ") }));
|
|
4303
|
+
}
|
|
4304
|
+
/** Removes a file the service keeps on this chat. */
|
|
4305
|
+
async removeSavedFile(e) {
|
|
4306
|
+
var i;
|
|
4307
|
+
const t = this.activeId;
|
|
4308
|
+
if (!t) return;
|
|
4309
|
+
const s = this.savedFiles;
|
|
4310
|
+
this.savedFiles = s.filter((a) => a !== e);
|
|
4311
|
+
try {
|
|
4312
|
+
await ((i = this.resolvedClient) == null ? void 0 : i.llm.call("remove_chat_attachment", {
|
|
4313
|
+
_id: t,
|
|
4314
|
+
attachment_id: e.id
|
|
4315
|
+
}));
|
|
4316
|
+
} catch {
|
|
4317
|
+
this.activeId === t && (this.savedFiles = s), this.showToast(this.msg.errGeneric);
|
|
4318
|
+
}
|
|
3628
4319
|
}
|
|
3629
4320
|
copy(e, t) {
|
|
3630
|
-
var
|
|
3631
|
-
(
|
|
4321
|
+
var s;
|
|
4322
|
+
(s = navigator.clipboard) == null || s.writeText(t).catch(() => {
|
|
3632
4323
|
}), this.copiedKey = e, this.later(() => {
|
|
3633
4324
|
this.copiedKey === e && (this.copiedKey = "");
|
|
3634
4325
|
}, 1400);
|
|
3635
4326
|
}
|
|
3636
4327
|
async toggleMessageBookmark(e) {
|
|
3637
|
-
var
|
|
4328
|
+
var s;
|
|
3638
4329
|
const t = this.activeId;
|
|
3639
4330
|
if (!(!t || !e.id)) {
|
|
3640
4331
|
e.bookmarked = !e.bookmarked, this.msgs = [...this.msgs], this.showToast(e.bookmarked ? this.msg.messageBookmarked : this.msg.bookmarkRemoved), this.emit("singlebase-chat-bookmark", { chatId: t, messageId: e.id, bookmarked: e.bookmarked });
|
|
3641
4332
|
try {
|
|
3642
|
-
await ((
|
|
4333
|
+
await ((s = this.resolvedClient) == null ? void 0 : s.llm.call("bookmark_chat_message", {
|
|
3643
4334
|
_id: t,
|
|
3644
4335
|
message_id: e.id,
|
|
3645
4336
|
bookmarked: e.bookmarked
|
|
@@ -3650,28 +4341,28 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3650
4341
|
}
|
|
3651
4342
|
}
|
|
3652
4343
|
async toggleChatBookmark(e) {
|
|
3653
|
-
var a,
|
|
3654
|
-
const t = ((a = this.chatList.find((
|
|
4344
|
+
var a, r;
|
|
4345
|
+
const t = ((a = this.chatList.find((c) => c._id === e)) == null ? void 0 : a.bookmarked) ?? (e === this.activeId ? this.bookmarked : !1), s = !t, i = (c) => {
|
|
3655
4346
|
this.chatList = this.chatList.map(
|
|
3656
|
-
(
|
|
3657
|
-
), e === this.activeId && (this.bookmarked =
|
|
4347
|
+
(l) => l._id === e ? { ...l, bookmarked: c } : l
|
|
4348
|
+
), e === this.activeId && (this.bookmarked = c);
|
|
3658
4349
|
};
|
|
3659
|
-
s
|
|
4350
|
+
i(s), this.showToast(s ? this.msg.chatBookmarked : this.msg.chatUnbookmarked), this.emit("singlebase-chat-bookmark", { chatId: e, bookmarked: s });
|
|
3660
4351
|
try {
|
|
3661
|
-
await ((
|
|
4352
|
+
await ((r = this.resolvedClient) == null ? void 0 : r.llm.call("bookmark_chat", { _id: e, bookmarked: s }));
|
|
3662
4353
|
} catch {
|
|
3663
|
-
|
|
4354
|
+
i(t), this.showToast(this.msg.errGeneric);
|
|
3664
4355
|
}
|
|
3665
4356
|
}
|
|
3666
4357
|
/** Removed at once; the server call waits out the undo window. */
|
|
3667
4358
|
deleteMessage(e) {
|
|
3668
|
-
var
|
|
3669
|
-
const t = this.activeId,
|
|
3670
|
-
|
|
4359
|
+
var i;
|
|
4360
|
+
const t = this.activeId, s = this.msgs.indexOf(e);
|
|
4361
|
+
s < 0 || (this.msgs = this.msgs.filter((a) => a !== e), ((i = this.panel) == null ? void 0 : i.key) === e.key && (this.panel = null), this.showToast(this.msg.messageDeleted, {
|
|
3671
4362
|
undo: () => {
|
|
3672
4363
|
if (this.activeId !== t) return;
|
|
3673
4364
|
const a = [...this.msgs];
|
|
3674
|
-
a.splice(
|
|
4365
|
+
a.splice(s, 0, e), this.msgs = a;
|
|
3675
4366
|
},
|
|
3676
4367
|
commit: () => {
|
|
3677
4368
|
var a;
|
|
@@ -3681,19 +4372,19 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3681
4372
|
}));
|
|
3682
4373
|
}
|
|
3683
4374
|
deleteChat(e) {
|
|
3684
|
-
const t = this.chatList.findIndex((
|
|
4375
|
+
const t = this.chatList.findIndex((r) => r._id === e), s = this.chatList[t] ?? {
|
|
3685
4376
|
_id: e,
|
|
3686
4377
|
title: this.chatTitle,
|
|
3687
4378
|
bookmarked: this.bookmarked
|
|
3688
|
-
},
|
|
3689
|
-
this.chatList = this.chatList.filter((
|
|
4379
|
+
}, i = e === this.activeId, a = i ? { title: this.chatTitle, bookmarked: this.bookmarked, msgs: this.msgs } : null;
|
|
4380
|
+
this.chatList = this.chatList.filter((r) => r._id !== e), i && this.newChat(), this.showToast(this.msg.chatDeleted, {
|
|
3690
4381
|
undo: () => {
|
|
3691
|
-
const
|
|
3692
|
-
|
|
4382
|
+
const r = [...this.chatList];
|
|
4383
|
+
r.splice(Math.max(0, t), 0, s), this.chatList = r, a && !this.activeId && !this.msgs.length && (this.activeId = e, this.chatTitle = a.title, this.bookmarked = a.bookmarked, this.msgs = a.msgs);
|
|
3693
4384
|
},
|
|
3694
4385
|
commit: () => {
|
|
3695
|
-
var
|
|
3696
|
-
this.emit("singlebase-chat-delete", { chatId: e }), (
|
|
4386
|
+
var r;
|
|
4387
|
+
this.emit("singlebase-chat-delete", { chatId: e }), (r = this.resolvedClient) == null || r.llm.call("delete_chat", { _id: e }).catch(() => {
|
|
3697
4388
|
});
|
|
3698
4389
|
}
|
|
3699
4390
|
});
|
|
@@ -3709,10 +4400,10 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3709
4400
|
// ── toasts ────────────────────────────────────────────────
|
|
3710
4401
|
showToast(e, t = {}) {
|
|
3711
4402
|
this.flushToast();
|
|
3712
|
-
const
|
|
3713
|
-
this.toast =
|
|
3714
|
-
this.toast ===
|
|
3715
|
-
},
|
|
4403
|
+
const s = { key: Date.now(), text: e, ...t };
|
|
4404
|
+
this.toast = s, this.toastTimer = setTimeout(() => {
|
|
4405
|
+
this.toast === s && this.flushToast();
|
|
4406
|
+
}, Ms);
|
|
3716
4407
|
}
|
|
3717
4408
|
/** Ends the current toast, committing whatever it was holding back. */
|
|
3718
4409
|
flushToast() {
|
|
@@ -3729,26 +4420,31 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3729
4420
|
async addFiles(e) {
|
|
3730
4421
|
const t = Array.from(e ?? []);
|
|
3731
4422
|
if (!t.length) return;
|
|
3732
|
-
const
|
|
3733
|
-
for (const
|
|
3734
|
-
if (this.files.length +
|
|
3735
|
-
this.showToast(
|
|
4423
|
+
const s = [];
|
|
4424
|
+
for (const i of t) {
|
|
4425
|
+
if (this.files.length + s.length >= At) {
|
|
4426
|
+
this.showToast(_(this.msg.tooManyFiles, { n: At }));
|
|
3736
4427
|
break;
|
|
3737
4428
|
}
|
|
3738
|
-
if (!
|
|
3739
|
-
this.showToast(
|
|
4429
|
+
if (!Os.test(i.name) && !i.type.startsWith("text/")) {
|
|
4430
|
+
this.showToast(_(this.msg.fileType, { name: i.name }));
|
|
3740
4431
|
continue;
|
|
3741
4432
|
}
|
|
3742
|
-
if (
|
|
4433
|
+
if (i.size > jt) {
|
|
3743
4434
|
this.showToast(
|
|
3744
|
-
|
|
4435
|
+
_(this.msg.fileTooLarge, { name: i.name, size: kt(jt) })
|
|
3745
4436
|
);
|
|
3746
4437
|
continue;
|
|
3747
4438
|
}
|
|
3748
|
-
|
|
4439
|
+
s.push({
|
|
4440
|
+
name: i.name,
|
|
4441
|
+
size: i.size,
|
|
4442
|
+
content: await i.text(),
|
|
4443
|
+
...i.type ? { mime: i.type } : {}
|
|
4444
|
+
});
|
|
3749
4445
|
}
|
|
3750
|
-
|
|
3751
|
-
files:
|
|
4446
|
+
s.length && (this.files = [...this.files, ...s], this.emit("singlebase-chat-files", {
|
|
4447
|
+
files: s.map(({ name: i, size: a }) => ({ name: i, size: a }))
|
|
3752
4448
|
}));
|
|
3753
4449
|
}
|
|
3754
4450
|
// ── scrolling ─────────────────────────────────────────────
|
|
@@ -3786,7 +4482,7 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3786
4482
|
// ── drag and drop ─────────────────────────────────────────
|
|
3787
4483
|
onDragEnter(e) {
|
|
3788
4484
|
var t;
|
|
3789
|
-
!this.allowUpload || !Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files")
|
|
4485
|
+
!this.allowUpload || !this.showComposer || Array.from(((t = e.dataTransfer) == null ? void 0 : t.types) ?? []).includes("Files") && (e.preventDefault(), this.dragging = !0);
|
|
3790
4486
|
}
|
|
3791
4487
|
onDragLeave(e) {
|
|
3792
4488
|
e.currentTarget.contains(e.relatedTarget) || (this.dragging = !1);
|
|
@@ -3803,16 +4499,16 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3803
4499
|
this.embed === "inline" ? "inline boxed" : "",
|
|
3804
4500
|
this.expanded ? "expanded boxed" : ""
|
|
3805
4501
|
].join(" ");
|
|
3806
|
-
return
|
|
4502
|
+
return o`<div class=${e} part="frame">${this.renderWorkspace()}</div>`;
|
|
3807
4503
|
}
|
|
3808
4504
|
renderLauncher() {
|
|
3809
4505
|
const e = this.msg, t = [
|
|
3810
4506
|
"frame launcher boxed",
|
|
3811
4507
|
this.expanded ? "expanded" : "",
|
|
3812
4508
|
this.mobile ? "full" : ""
|
|
3813
|
-
].join(" "),
|
|
4509
|
+
].join(" "), s = this.isOpen ? o`<div class=${t} role="dialog" aria-label=${this.assistantName} part="frame">
|
|
3814
4510
|
${this.renderWorkspace()}
|
|
3815
|
-
</div>` : m,
|
|
4511
|
+
</div>` : m, i = this.bubble && !this.isOpen ? o`<div class="bubble" part="bubble">
|
|
3816
4512
|
<button type="button" class="bubble-text" @click=${() => this.open()}>
|
|
3817
4513
|
${this.bubbleText || e.bubbleText}
|
|
3818
4514
|
</button>
|
|
@@ -3823,9 +4519,9 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3823
4519
|
title=${e.dismiss}
|
|
3824
4520
|
@click=${() => this.bubble = !1}
|
|
3825
4521
|
>
|
|
3826
|
-
${
|
|
4522
|
+
${k.close()}
|
|
3827
4523
|
</button>
|
|
3828
|
-
</div>` : m,
|
|
4524
|
+
</div>` : m, r = this.isOpen && (this.expanded || this.mobile) ? m : o`<button
|
|
3829
4525
|
type="button"
|
|
3830
4526
|
class="launcher-btn"
|
|
3831
4527
|
part="launcher"
|
|
@@ -3833,23 +4529,23 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3833
4529
|
aria-expanded=${this.isOpen ? "true" : "false"}
|
|
3834
4530
|
@click=${() => this.isOpen ? this.close() : this.open()}
|
|
3835
4531
|
>
|
|
3836
|
-
${this.isOpen ?
|
|
3837
|
-
${this.unreadBadge && !this.seen && !this.isOpen ?
|
|
4532
|
+
${this.isOpen ? k.chevronDown() : k.chat()}
|
|
4533
|
+
${this.unreadBadge && !this.seen && !this.isOpen ? o`<span class="badge"></span>` : m}
|
|
3838
4534
|
</button>`;
|
|
3839
|
-
return
|
|
4535
|
+
return o`${s}${i}${r}`;
|
|
3840
4536
|
}
|
|
3841
4537
|
renderWorkspace() {
|
|
3842
4538
|
const e = !this.docked;
|
|
3843
|
-
return
|
|
3844
|
-
${this.sidebarOpen && e ?
|
|
3845
|
-
${this.sidebarOpen ? this.renderSidebar(e) : m}
|
|
4539
|
+
return o`<div class="root" @keydown=${this.onKeydown}>
|
|
4540
|
+
${this.sidebarOpen && e ? o`<div class="scrim" @click=${() => this.sidebarOpen = !1}></div>` : m}
|
|
4541
|
+
${this.sidebarOpen && this.sidebar !== "none" ? this.renderSidebar(e) : m}
|
|
3846
4542
|
<main
|
|
3847
4543
|
class="main"
|
|
3848
4544
|
@dragenter=${this.onDragEnter}
|
|
3849
4545
|
@dragover=${(t) => t.preventDefault()}
|
|
3850
4546
|
>
|
|
3851
4547
|
${this.renderHeader()}
|
|
3852
|
-
${this.offline ?
|
|
4548
|
+
${this.offline ? o`<div class="banner" role="status">${this.msg.offline}</div>` : m}
|
|
3853
4549
|
<div
|
|
3854
4550
|
class="scroller"
|
|
3855
4551
|
role="log"
|
|
@@ -3860,20 +4556,15 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3860
4556
|
>
|
|
3861
4557
|
${this.msgs.length || this.loadingThread || this.threadError ? this.renderThread() : this.renderWelcome()}
|
|
3862
4558
|
</div>
|
|
3863
|
-
${this.showJump ?
|
|
4559
|
+
${this.showJump ? o`<button type="button" class="jump" @click=${this.jumpToLatest}>
|
|
3864
4560
|
↓ ${this.msg.newReply}
|
|
3865
4561
|
</button>` : m}
|
|
3866
|
-
${this.renderComposer()}
|
|
3867
|
-
${this.
|
|
3868
|
-
<a href="https://singlebase.cloud" target="_blank" rel="noopener noreferrer"
|
|
3869
|
-
>${this.msg.brandingLabel}</a
|
|
3870
|
-
>
|
|
3871
|
-
</div>` : m}
|
|
3872
|
-
${this.toast ? r`<div class="toast" role="status">
|
|
4562
|
+
${this.renderComposer()} ${Xt(this.branding, "Chat")}
|
|
4563
|
+
${this.toast ? o`<div class="toast" role="status">
|
|
3873
4564
|
<span>${this.toast.text}</span>
|
|
3874
|
-
${this.toast.undo ?
|
|
4565
|
+
${this.toast.undo ? o`<button type="button" @click=${this.undo}>${this.msg.undo}</button>` : m}
|
|
3875
4566
|
</div>` : m}
|
|
3876
|
-
${this.dragging ?
|
|
4567
|
+
${this.dragging ? o`<div
|
|
3877
4568
|
class="drop"
|
|
3878
4569
|
@dragover=${(t) => t.preventDefault()}
|
|
3879
4570
|
@dragleave=${this.onDragLeave}
|
|
@@ -3886,38 +4577,24 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3886
4577
|
</div>`;
|
|
3887
4578
|
}
|
|
3888
4579
|
renderSidebar(e) {
|
|
3889
|
-
const t = this.msg,
|
|
3890
|
-
(
|
|
3891
|
-
), a = [
|
|
3892
|
-
[t.groupBookmarked,
|
|
3893
|
-
[
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
]
|
|
3897
|
-
[
|
|
3898
|
-
t.groupYesterday,
|
|
3899
|
-
s.filter(
|
|
3900
|
-
(l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "yesterday"
|
|
3901
|
-
)
|
|
3902
|
-
],
|
|
3903
|
-
[
|
|
3904
|
-
t.groupWeek,
|
|
3905
|
-
s.filter((l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "week")
|
|
3906
|
-
],
|
|
3907
|
-
[
|
|
3908
|
-
t.groupOlder,
|
|
3909
|
-
s.filter((l) => !l.bookmarked && Pe(l._modified_at ?? l._created_at) === "older")
|
|
3910
|
-
]
|
|
4580
|
+
const t = this.msg, s = this.allowSearch ? this.search.trim().toLowerCase() : "", i = this.chatList.filter(
|
|
4581
|
+
(f) => !s || (f.title ?? "").toLowerCase().includes(s)
|
|
4582
|
+
), a = (f) => this.showBookmarked && !!f.bookmarked, r = (f) => i.filter((b) => !a(b) && Ds(b._modified_at ?? b._created_at) === f), c = [
|
|
4583
|
+
[t.groupBookmarked, i.filter(a)],
|
|
4584
|
+
[t.groupToday, r("today")],
|
|
4585
|
+
[t.groupYesterday, r("yesterday")],
|
|
4586
|
+
[t.groupWeek, r("week")],
|
|
4587
|
+
[t.groupOlder, r("older")]
|
|
3911
4588
|
];
|
|
3912
|
-
let
|
|
3913
|
-
return this.listState === "loading" && !this.chatList.length ?
|
|
3914
|
-
${[1, 2, 3, 4].map(() =>
|
|
3915
|
-
</div>` :
|
|
3916
|
-
([
|
|
3917
|
-
${
|
|
3918
|
-
) :
|
|
3919
|
-
>${
|
|
3920
|
-
>`,
|
|
4589
|
+
let l;
|
|
4590
|
+
return this.listState === "loading" && !this.chatList.length ? l = o`<div aria-label=${t.loadingChats}>
|
|
4591
|
+
${[1, 2, 3, 4].map(() => o`<div class="skeleton"></div>`)}
|
|
4592
|
+
</div>` : i.length ? l = c.filter(([, f]) => f.length).map(
|
|
4593
|
+
([f, b]) => o`<div class="group">${f}</div>
|
|
4594
|
+
${b.map((C) => this.renderThreadRow(C))}`
|
|
4595
|
+
) : l = o`<span class="side-note"
|
|
4596
|
+
>${s ? _(t.noMatch, { query: this.search.trim() }) : t.noChats}</span
|
|
4597
|
+
>`, o`<aside
|
|
3921
4598
|
class="sidebar ${e ? "overlay" : "docked"}"
|
|
3922
4599
|
part="sidebar"
|
|
3923
4600
|
aria-label=${t.chats}
|
|
@@ -3931,133 +4608,149 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
3931
4608
|
aria-label=${t.hideSidebar}
|
|
3932
4609
|
@click=${() => this.sidebarOpen = !1}
|
|
3933
4610
|
>
|
|
3934
|
-
${
|
|
4611
|
+
${k.sidebar()}
|
|
3935
4612
|
</button>
|
|
3936
4613
|
</div>
|
|
3937
4614
|
<div class="side-tools">
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
4615
|
+
${this.showNewChat ? o`<button type="button" class="new-chat" @click=${() => this.newChat()}>
|
|
4616
|
+
${k.plus()}<span>${t.newChat}</span>
|
|
4617
|
+
</button>` : m}
|
|
4618
|
+
${this.allowSearch ? o`<input
|
|
4619
|
+
class="search"
|
|
4620
|
+
type="search"
|
|
4621
|
+
placeholder=${t.searchChats}
|
|
4622
|
+
aria-label=${t.searchChats}
|
|
4623
|
+
.value=${this.search}
|
|
4624
|
+
@input=${(f) => this.search = f.target.value}
|
|
4625
|
+
/>` : m}
|
|
4626
|
+
</div>
|
|
4627
|
+
<div class="threads">${l}</div>
|
|
4628
|
+
<div class="side-extra ${this.hasSidebarContent ? "filled" : ""}" part="sidebar-extra">
|
|
4629
|
+
<slot
|
|
4630
|
+
name="sidebar"
|
|
4631
|
+
@slotchange=${(f) => this.hasSidebarContent = f.target.assignedNodes().length > 0}
|
|
4632
|
+
></slot>
|
|
3949
4633
|
</div>
|
|
3950
|
-
<div class="threads">${o}</div>
|
|
3951
4634
|
</aside>`;
|
|
3952
4635
|
}
|
|
3953
4636
|
renderThreadRow(e) {
|
|
3954
|
-
const t = this.msg,
|
|
4637
|
+
const t = this.msg, s = e._id === this.activeId, i = e.title || t.untitled;
|
|
3955
4638
|
if (this.renamingId === e._id)
|
|
3956
|
-
return
|
|
4639
|
+
return o`<div class="thread active">
|
|
3957
4640
|
<input
|
|
3958
4641
|
class="thread-rename"
|
|
3959
4642
|
maxlength="80"
|
|
3960
|
-
.value=${
|
|
4643
|
+
.value=${i}
|
|
3961
4644
|
aria-label=${t.renameChat}
|
|
3962
|
-
@keydown=${(
|
|
3963
|
-
|
|
4645
|
+
@keydown=${(r) => {
|
|
4646
|
+
r.key === "Enter" && this.commitRename(e._id, r.target.value), r.key === "Escape" && (r.stopPropagation(), this.renamingId = "");
|
|
3964
4647
|
}}
|
|
3965
|
-
@blur=${(
|
|
4648
|
+
@blur=${(r) => this.commitRename(e._id, r.target.value)}
|
|
3966
4649
|
/>
|
|
3967
4650
|
</div>`;
|
|
3968
|
-
const a = (
|
|
3969
|
-
|
|
4651
|
+
const a = (r) => (c) => {
|
|
4652
|
+
c.stopPropagation(), r();
|
|
3970
4653
|
};
|
|
3971
|
-
return
|
|
3972
|
-
class="thread ${
|
|
4654
|
+
return o`<div
|
|
4655
|
+
class="thread ${s ? "active" : ""}"
|
|
3973
4656
|
role="button"
|
|
3974
4657
|
tabindex="0"
|
|
3975
|
-
aria-current=${
|
|
4658
|
+
aria-current=${s ? "true" : "false"}
|
|
3976
4659
|
@click=${() => this.openChat(e._id)}
|
|
3977
|
-
@keydown=${(
|
|
4660
|
+
@keydown=${(r) => r.key === "Enter" && this.openChat(e._id)}
|
|
3978
4661
|
>
|
|
3979
|
-
<span class="thread-title">${
|
|
4662
|
+
<span class="thread-title">${i}</span>
|
|
3980
4663
|
<span class="thread-actions">
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
4664
|
+
${this.allowBookmark ? o`<button
|
|
4665
|
+
type="button"
|
|
4666
|
+
class="icon sm ${e.bookmarked ? "on" : ""}"
|
|
4667
|
+
title=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
|
|
4668
|
+
aria-label=${e.bookmarked ? t.unbookmarkChat : t.bookmarkChat}
|
|
4669
|
+
@click=${a(() => this.toggleChatBookmark(e._id))}
|
|
4670
|
+
>
|
|
4671
|
+
${k.bookmark(!!e.bookmarked)}
|
|
4672
|
+
</button>` : m}
|
|
4673
|
+
${this.allowRename ? o`<button
|
|
4674
|
+
type="button"
|
|
4675
|
+
class="icon sm"
|
|
4676
|
+
title=${t.renameChat}
|
|
4677
|
+
aria-label=${t.renameChat}
|
|
4678
|
+
@click=${a(() => {
|
|
3996
4679
|
this.renamingId = e._id, this.focusNext = "input.thread-rename";
|
|
3997
4680
|
})}
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4681
|
+
>
|
|
4682
|
+
${k.pencil()}
|
|
4683
|
+
</button>` : m}
|
|
4684
|
+
${this.allowDelete ? o`<button
|
|
4685
|
+
type="button"
|
|
4686
|
+
class="icon sm danger"
|
|
4687
|
+
title=${t.deleteChat}
|
|
4688
|
+
aria-label=${t.deleteChat}
|
|
4689
|
+
@click=${a(() => this.deleteChat(e._id))}
|
|
4690
|
+
>
|
|
4691
|
+
${k.trash()}
|
|
4692
|
+
</button>` : m}
|
|
4010
4693
|
</span>
|
|
4011
4694
|
</div>`;
|
|
4012
4695
|
}
|
|
4013
4696
|
renderHeader() {
|
|
4014
|
-
const e = this.msg, t = !!this.activeId,
|
|
4697
|
+
const e = this.msg, t = !!this.activeId, s = (this.embed === "inline" || this.embed === "launcher") && !this.mobile, i = this.embed === "launcher" ? () => this.close() : this.expanded ? () => this.collapse() : null;
|
|
4015
4698
|
let a = m;
|
|
4016
|
-
return this.showTitle && (a = this.editingTitle ?
|
|
4699
|
+
return this.showTitle && (a = this.editingTitle ? o`<input
|
|
4017
4700
|
class="title-input"
|
|
4018
4701
|
maxlength="80"
|
|
4019
4702
|
.value=${this.chatTitle}
|
|
4020
4703
|
aria-label=${e.renameChat}
|
|
4021
|
-
@keydown=${(
|
|
4022
|
-
|
|
4704
|
+
@keydown=${(r) => {
|
|
4705
|
+
r.key === "Enter" && this.commitTitle(r.target.value), r.key === "Escape" && (r.stopPropagation(), this.editingTitle = !1);
|
|
4023
4706
|
}}
|
|
4024
|
-
@blur=${(
|
|
4025
|
-
/>` :
|
|
4707
|
+
@blur=${(r) => this.commitTitle(r.target.value)}
|
|
4708
|
+
/>` : o`<button
|
|
4026
4709
|
type="button"
|
|
4027
4710
|
class="title"
|
|
4028
4711
|
part="title"
|
|
4029
|
-
?disabled=${!t}
|
|
4030
|
-
title=${t ? e.renameChat : ""}
|
|
4712
|
+
?disabled=${!t || !this.allowRename}
|
|
4713
|
+
title=${t && this.allowRename ? e.renameChat : ""}
|
|
4031
4714
|
@click=${() => {
|
|
4032
4715
|
this.editingTitle = !0, this.focusNext = "input.title-input";
|
|
4033
4716
|
}}
|
|
4034
4717
|
>
|
|
4035
4718
|
${this.chatTitle || e.untitled}
|
|
4036
|
-
</button>`),
|
|
4719
|
+
</button>`), o`<header class="header" part="header">
|
|
4037
4720
|
<div class="header-left">
|
|
4038
|
-
${this.sidebarOpen && this.docked ? m :
|
|
4721
|
+
${this.sidebar === "none" || this.sidebarOpen && this.docked ? m : o`<button
|
|
4039
4722
|
type="button"
|
|
4040
4723
|
class="icon"
|
|
4041
4724
|
title=${e.showChats}
|
|
4042
4725
|
aria-label=${e.showChats}
|
|
4043
4726
|
@click=${() => this.sidebarOpen = !0}
|
|
4044
4727
|
>
|
|
4045
|
-
${
|
|
4728
|
+
${k.sidebar()}
|
|
4046
4729
|
</button>`}
|
|
4047
4730
|
${a}
|
|
4048
4731
|
</div>
|
|
4049
4732
|
<div class="header-right">
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4056
|
-
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
${this.
|
|
4733
|
+
${this.sidebar === "none" && this.showNewChat ? o`<button
|
|
4734
|
+
type="button"
|
|
4735
|
+
class="icon"
|
|
4736
|
+
?disabled=${!this.msgs.length && !t}
|
|
4737
|
+
title=${e.newChat}
|
|
4738
|
+
aria-label=${e.newChat}
|
|
4739
|
+
@click=${() => this.newChat()}
|
|
4740
|
+
>
|
|
4741
|
+
${k.plus()}
|
|
4742
|
+
</button>` : m}
|
|
4743
|
+
${this.allowBookmark ? o`<button
|
|
4744
|
+
type="button"
|
|
4745
|
+
class="icon ${this.bookmarked ? "on" : ""}"
|
|
4746
|
+
?disabled=${!t}
|
|
4747
|
+
title=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
|
|
4748
|
+
aria-label=${this.bookmarked ? e.unbookmarkChat : e.bookmarkChat}
|
|
4749
|
+
@click=${() => this.activeId && this.toggleChatBookmark(this.activeId)}
|
|
4750
|
+
>
|
|
4751
|
+
${k.bookmark(this.bookmarked)}
|
|
4752
|
+
</button>` : m}
|
|
4753
|
+
${this.allowExport ? o`<div class="menu-wrap">
|
|
4061
4754
|
<button
|
|
4062
4755
|
type="button"
|
|
4063
4756
|
class="icon ${this.menuOpen ? "on" : ""}"
|
|
@@ -4068,37 +4761,37 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
4068
4761
|
aria-expanded=${this.menuOpen ? "true" : "false"}
|
|
4069
4762
|
@click=${() => this.menuOpen = !this.menuOpen}
|
|
4070
4763
|
>
|
|
4071
|
-
${
|
|
4764
|
+
${k.download()}
|
|
4072
4765
|
</button>
|
|
4073
4766
|
${this.menuOpen ? this.renderExportMenu() : m}
|
|
4074
4767
|
</div>` : m}
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4084
|
-
|
|
4085
|
-
${
|
|
4768
|
+
${this.allowDelete ? o`<button
|
|
4769
|
+
type="button"
|
|
4770
|
+
class="icon danger"
|
|
4771
|
+
?disabled=${!t}
|
|
4772
|
+
title=${e.deleteChat}
|
|
4773
|
+
aria-label=${e.deleteChat}
|
|
4774
|
+
@click=${() => this.activeId && this.deleteChat(this.activeId)}
|
|
4775
|
+
>
|
|
4776
|
+
${k.trash()}
|
|
4777
|
+
</button>` : m}
|
|
4778
|
+
${s || i ? o`<span class="divider"></span> ${s ? o`<button
|
|
4086
4779
|
type="button"
|
|
4087
4780
|
class="icon"
|
|
4088
4781
|
title=${this.expanded ? e.restore : e.expand}
|
|
4089
4782
|
aria-label=${this.expanded ? e.restore : e.expand}
|
|
4090
4783
|
@click=${() => this.expanded ? this.collapse() : this.expand()}
|
|
4091
4784
|
>
|
|
4092
|
-
${this.expanded ?
|
|
4785
|
+
${this.expanded ? k.restore() : k.expand()}
|
|
4093
4786
|
</button>` : m}
|
|
4094
|
-
${
|
|
4787
|
+
${i ? o`<button
|
|
4095
4788
|
type="button"
|
|
4096
4789
|
class="icon"
|
|
4097
4790
|
title=${e.minimize}
|
|
4098
4791
|
aria-label=${e.minimize}
|
|
4099
|
-
@click=${
|
|
4792
|
+
@click=${i}
|
|
4100
4793
|
>
|
|
4101
|
-
${
|
|
4794
|
+
${k.minimize()}
|
|
4102
4795
|
</button>` : m}` : m}
|
|
4103
4796
|
</div>
|
|
4104
4797
|
</header>`;
|
|
@@ -4110,58 +4803,63 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
4110
4803
|
[e.exportText, ".txt", "txt"],
|
|
4111
4804
|
[e.exportCopy, "", "copy"]
|
|
4112
4805
|
];
|
|
4113
|
-
return
|
|
4806
|
+
return o`<div class="menu-scrim" @click=${() => this.menuOpen = !1}></div>
|
|
4114
4807
|
<div class="menu" role="menu">
|
|
4115
4808
|
<span class="label">${e.exportHeading}</span>
|
|
4116
4809
|
${t.map(
|
|
4117
|
-
([
|
|
4810
|
+
([s, i, a]) => o`<button
|
|
4118
4811
|
type="button"
|
|
4119
4812
|
role="menuitem"
|
|
4120
4813
|
class="menu-item"
|
|
4121
4814
|
@click=${() => this.exportChat(a)}
|
|
4122
4815
|
>
|
|
4123
|
-
<span>${
|
|
4816
|
+
<span>${s}</span><span class="ext">${i}</span>
|
|
4124
4817
|
</button>`
|
|
4125
4818
|
)}
|
|
4126
4819
|
</div>`;
|
|
4127
4820
|
}
|
|
4821
|
+
/** The suggestion cards. `[]` or `"none"` shows none; unset uses the mode's. */
|
|
4128
4822
|
promptList() {
|
|
4129
4823
|
const e = this.prompts;
|
|
4130
|
-
return Array.isArray(e)
|
|
4824
|
+
return Array.isArray(e) ? e.map((t) => typeof t == "string" ? { text: t } : t).filter((t) => t == null ? void 0 : t.text).slice(0, 4) : typeof e == "string" && e.trim().toLowerCase() === "none" ? [] : typeof e == "string" && e.trim() ? e.split("|").map((t) => t.trim()).filter(Boolean).slice(0, 4).map((t) => ({ text: t })) : (Et[this.mode] ?? Et.chat).map(([t, s]) => ({
|
|
4131
4825
|
label: t,
|
|
4132
|
-
text:
|
|
4826
|
+
text: s
|
|
4133
4827
|
}));
|
|
4134
4828
|
}
|
|
4135
4829
|
renderWelcome() {
|
|
4136
|
-
const e = this.msg, t = this.mode === "rag" ? "Rag" : this.mode === "
|
|
4137
|
-
return
|
|
4138
|
-
<
|
|
4139
|
-
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
|
|
4144
|
-
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4830
|
+
const e = this.msg, t = this.mode === "rag" ? "Rag" : this.mode === "kb" ? "Kb" : "Chat", s = (r) => e[`${r}${t}`], i = this.eyebrow ?? s("eyebrow"), a = this.promptList();
|
|
4831
|
+
return o`<div class="welcome-slot">
|
|
4832
|
+
<slot name="welcome"
|
|
4833
|
+
><div class="welcome" part="welcome">
|
|
4834
|
+
<div class="welcome-head">
|
|
4835
|
+
${this.logoUrl && _t(this.logoUrl, !0) ? o`<img class="welcome-logo" src=${this.logoUrl} alt="" />` : m}
|
|
4836
|
+
${i ? o`<span class="label">${i}</span>` : m}
|
|
4837
|
+
<h2>${this.heading || s("heading")}</h2>
|
|
4838
|
+
<p>${this.description || s("description")}</p>
|
|
4839
|
+
</div>
|
|
4840
|
+
${a.length ? o`<div class="prompts">
|
|
4841
|
+
${a.map(
|
|
4842
|
+
(r) => o`<button
|
|
4843
|
+
type="button"
|
|
4844
|
+
class="prompt"
|
|
4845
|
+
part="prompt"
|
|
4846
|
+
@click=${() => this.send(r.text)}
|
|
4847
|
+
>
|
|
4848
|
+
<span class="label">${r.label || "Suggested"}</span>
|
|
4849
|
+
<span class="prompt-text">${r.text}</span>
|
|
4850
|
+
</button>`
|
|
4155
4851
|
)}
|
|
4156
|
-
|
|
4852
|
+
</div>` : m}
|
|
4853
|
+
</div></slot
|
|
4854
|
+
>
|
|
4157
4855
|
</div>`;
|
|
4158
4856
|
}
|
|
4159
4857
|
renderThread() {
|
|
4160
4858
|
const e = this.msgs.map((t) => t.role).lastIndexOf("assistant");
|
|
4161
|
-
return
|
|
4162
|
-
${this.threadError ?
|
|
4859
|
+
return o`<div class="thread-view">
|
|
4860
|
+
${this.threadError ? o`<div class="error-card" role="alert">
|
|
4163
4861
|
<span>${this.threadError}</span>
|
|
4164
|
-
${this.activeId ?
|
|
4862
|
+
${this.activeId ? o`<button
|
|
4165
4863
|
type="button"
|
|
4166
4864
|
class="btn"
|
|
4167
4865
|
@click=${() => this.openChat(this.activeId)}
|
|
@@ -4169,21 +4867,21 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
4169
4867
|
${this.msg.retry}
|
|
4170
4868
|
</button>` : m}
|
|
4171
4869
|
</div>` : m}
|
|
4172
|
-
${this.loadingThread ?
|
|
4173
|
-
${
|
|
4870
|
+
${this.loadingThread ? o`${[1, 2].map(() => o`<div class="skeleton" style="height:48px"></div>`)}` : m}
|
|
4871
|
+
${qt(
|
|
4174
4872
|
this.msgs,
|
|
4175
4873
|
(t) => t.key,
|
|
4176
|
-
(t,
|
|
4874
|
+
(t, s) => t.role === "user" ? this.renderUser(t) : this.renderBot(t, s === e)
|
|
4177
4875
|
)}
|
|
4178
4876
|
</div>`;
|
|
4179
4877
|
}
|
|
4180
4878
|
renderUser(e) {
|
|
4181
|
-
const t = this.msg,
|
|
4182
|
-
return
|
|
4183
|
-
${
|
|
4184
|
-
${
|
|
4879
|
+
const t = this.msg, s = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", i = e.attachments ?? [];
|
|
4880
|
+
return o`<div class="msg user" part="message user">
|
|
4881
|
+
${i.length ? o`<div class="attachments">
|
|
4882
|
+
${i.map((a) => o`<span class="doc-chip"><span class="ext">${xt(a.name)}</span><span class="name">${a.name}</span></span>`)}
|
|
4185
4883
|
</div>` : m}
|
|
4186
|
-
${this.editingKey === e.key ?
|
|
4884
|
+
${this.editingKey === e.key ? o`<div class="edit-box">
|
|
4187
4885
|
<textarea
|
|
4188
4886
|
rows="3"
|
|
4189
4887
|
class="edit-input"
|
|
@@ -4201,11 +4899,11 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
4201
4899
|
${t.saveResend}
|
|
4202
4900
|
</button>
|
|
4203
4901
|
</div>
|
|
4204
|
-
</div>` :
|
|
4902
|
+
</div>` : o`<div class="bubble-user">${e.content}</div>
|
|
4205
4903
|
<div class="toolbar">
|
|
4206
|
-
${e.bookmarked ?
|
|
4207
|
-
|
|
4208
|
-
${this.busy ? m :
|
|
4904
|
+
${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${t.saved}</span>` : m}
|
|
4905
|
+
${this.showTime ? o`<span class="time">${s}</span>` : m}
|
|
4906
|
+
${this.busy ? m : o`<button
|
|
4209
4907
|
type="button"
|
|
4210
4908
|
class="icon"
|
|
4211
4909
|
title=${t.edit}
|
|
@@ -4214,192 +4912,203 @@ assistant: ${i.slice(0, 1500)}`,
|
|
|
4214
4912
|
this.editingKey = e.key, this.editDraft = e.content, this.focusNext = "textarea.edit-input";
|
|
4215
4913
|
}}
|
|
4216
4914
|
>
|
|
4217
|
-
${
|
|
4915
|
+
${k.pencil()}
|
|
4218
4916
|
</button>`}
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
|
-
|
|
4228
|
-
${e.id ?
|
|
4917
|
+
${this.allowCopy ? o`<button
|
|
4918
|
+
type="button"
|
|
4919
|
+
class="icon"
|
|
4920
|
+
title=${this.copiedKey === e.key ? t.copied : t.copy}
|
|
4921
|
+
aria-label=${t.copy}
|
|
4922
|
+
@click=${() => this.copy(e.key, e.content)}
|
|
4923
|
+
>
|
|
4924
|
+
${k.copy()}
|
|
4925
|
+
</button>` : m}
|
|
4926
|
+
${this.allowBookmark && e.id ? o`<button
|
|
4229
4927
|
type="button"
|
|
4230
4928
|
class="icon ${e.bookmarked ? "on" : ""}"
|
|
4231
4929
|
title=${e.bookmarked ? t.unbookmarkMessage : t.bookmarkMessage}
|
|
4232
4930
|
aria-label=${e.bookmarked ? t.unbookmarkMessage : t.bookmarkMessage}
|
|
4233
4931
|
@click=${() => this.toggleMessageBookmark(e)}
|
|
4234
4932
|
>
|
|
4235
|
-
${
|
|
4933
|
+
${k.bookmark(e.bookmarked)}
|
|
4934
|
+
</button>` : m}
|
|
4935
|
+
${this.allowDelete ? o`<button
|
|
4936
|
+
type="button"
|
|
4937
|
+
class="icon danger"
|
|
4938
|
+
title=${t.deleteMessage}
|
|
4939
|
+
aria-label=${t.deleteMessage}
|
|
4940
|
+
@click=${() => this.deleteMessage(e)}
|
|
4941
|
+
>
|
|
4942
|
+
${k.trash()}
|
|
4236
4943
|
</button>` : m}
|
|
4237
|
-
<button
|
|
4238
|
-
type="button"
|
|
4239
|
-
class="icon danger"
|
|
4240
|
-
title=${t.deleteMessage}
|
|
4241
|
-
aria-label=${t.deleteMessage}
|
|
4242
|
-
@click=${() => this.deleteMessage(e)}
|
|
4243
|
-
>
|
|
4244
|
-
${y.trash()}
|
|
4245
|
-
</button>
|
|
4246
4944
|
</div>`}
|
|
4247
4945
|
</div>`;
|
|
4248
4946
|
}
|
|
4249
4947
|
pillLabel() {
|
|
4250
|
-
return this.mode === "rag"
|
|
4948
|
+
return this.mode === "rag" || this.mode === "kb" ? this.msg.searching : this.msg.thinking;
|
|
4251
4949
|
}
|
|
4252
4950
|
renderBot(e, t) {
|
|
4253
|
-
const
|
|
4951
|
+
const s = this.msg, i = e.phase === "pending", a = e.phase === "done", r = e.sources.length, c = Ot(e.content), l = e.sources.map((w, L) => ft(w, L + 1)), f = c.size ? l.filter((w) => c.has(w.n)) : l, b = e.at ? new Date(e.at).toLocaleTimeString([], { hour: "numeric", minute: "2-digit" }) : "", C = e.content + (f.length ? `
|
|
4254
4952
|
|
|
4255
4953
|
Sources:
|
|
4256
|
-
${
|
|
4257
|
-
`)}` : ""),
|
|
4258
|
-
return
|
|
4259
|
-
${
|
|
4260
|
-
${this.arrivedKey === e.key ?
|
|
4954
|
+
${f.map((w) => `[${w.n}] ${w.title}`).join(`
|
|
4955
|
+
`)}` : ""), T = this.retrievalOpen.has(e.key);
|
|
4956
|
+
return o`<div class="msg bot" part="message assistant">
|
|
4957
|
+
${i ? o`<div class="halo"></div>` : m}
|
|
4958
|
+
${this.arrivedKey === e.key ? o`<div class="arrived">
|
|
4261
4959
|
<div class="wash"></div>
|
|
4262
4960
|
<div class="ring"></div>
|
|
4263
4961
|
<div class="sweep"></div>
|
|
4264
4962
|
</div>` : m}
|
|
4265
4963
|
<div class="bot-body">
|
|
4266
|
-
${e.bookmarked ?
|
|
4267
|
-
${
|
|
4964
|
+
${this.allowBookmark && e.bookmarked ? o`<span class="saved">${k.bookmark(!0)}${s.saved}</span>` : m}
|
|
4965
|
+
${i ? o`<div class="pill" role="status">
|
|
4268
4966
|
<span class="ring"></span><span class="dot"></span>
|
|
4269
4967
|
<span class="shimmer">${this.pillLabel()}</span>
|
|
4270
4968
|
</div>` : m}
|
|
4271
|
-
${
|
|
4969
|
+
${this.showSources && r && !i ? o`<div class="retrieval">
|
|
4272
4970
|
<button
|
|
4273
4971
|
type="button"
|
|
4274
4972
|
class="retrieval-toggle"
|
|
4275
|
-
aria-expanded=${
|
|
4973
|
+
aria-expanded=${T ? "true" : "false"}
|
|
4276
4974
|
@click=${() => {
|
|
4277
|
-
const
|
|
4278
|
-
|
|
4975
|
+
const w = new Set(this.retrievalOpen);
|
|
4976
|
+
w.has(e.key) ? w.delete(e.key) : w.add(e.key), this.retrievalOpen = w;
|
|
4279
4977
|
}}
|
|
4280
4978
|
>
|
|
4281
|
-
<span class="chev">${
|
|
4282
|
-
<span style="flex:1">${
|
|
4283
|
-
${e.execTime !== void 0 ?
|
|
4979
|
+
<span class="chev">${T ? "▾" : "▸"}</span>
|
|
4980
|
+
<span style="flex:1">${_(s.searchedSources, { n: r })}</span>
|
|
4981
|
+
${e.execTime !== void 0 ? o`<span class="ms">${e.execTime.toFixed(1)}s</span>` : m}
|
|
4284
4982
|
</button>
|
|
4285
|
-
${
|
|
4286
|
-
${
|
|
4287
|
-
(
|
|
4983
|
+
${T ? o`<div class="retrieval-list">
|
|
4984
|
+
${l.map(
|
|
4985
|
+
(w) => o`<button
|
|
4288
4986
|
type="button"
|
|
4289
4987
|
class="passage"
|
|
4290
|
-
@click=${() => this.panel = { key: e.key, n:
|
|
4988
|
+
@click=${() => this.panel = { key: e.key, n: w.n }}
|
|
4291
4989
|
>
|
|
4292
|
-
<span class="n">${
|
|
4990
|
+
<span class="n">${w.n}</span>
|
|
4293
4991
|
<span class="what"
|
|
4294
|
-
><span>${
|
|
4992
|
+
><span>${w.title}${w.section ? ` · ${w.section}` : ""}</span
|
|
4993
|
+
><span>${w.collection || w.path}</span></span
|
|
4295
4994
|
>
|
|
4296
|
-
${
|
|
4297
|
-
><span class="score">${
|
|
4995
|
+
${w.score !== null ? o`<span class="relevance"
|
|
4996
|
+
><span class="score">${w.score.toFixed(2)}</span>
|
|
4298
4997
|
<span class="relevance-track"
|
|
4299
4998
|
><span
|
|
4300
4999
|
class="relevance-fill"
|
|
4301
|
-
style="width:${Math.round(
|
|
5000
|
+
style="width:${Math.round(w.score * 100)}%"
|
|
4302
5001
|
></span></span
|
|
4303
|
-
></span>` :
|
|
5002
|
+
></span>` : o`<span></span>`}
|
|
4304
5003
|
</button>`
|
|
4305
5004
|
)}
|
|
4306
5005
|
</div>` : m}
|
|
4307
5006
|
</div>` : m}
|
|
4308
|
-
${
|
|
4309
|
-
${e.phase === "streaming" ?
|
|
4310
|
-
${e.phase === "error" ?
|
|
5007
|
+
${i ? m : this.renderAnswer(e)}
|
|
5008
|
+
${e.phase === "streaming" ? o`<span class="caret"></span>` : m}
|
|
5009
|
+
${e.phase === "error" ? o`<div class="error-card" role="alert">
|
|
4311
5010
|
<span>${e.error}</span>
|
|
4312
5011
|
<button type="button" class="btn" @click=${() => this.retry(e)}>
|
|
4313
|
-
${
|
|
5012
|
+
${s.retry}
|
|
4314
5013
|
</button>
|
|
4315
5014
|
</div>` : m}
|
|
4316
|
-
${a &&
|
|
4317
|
-
<span class="label">${
|
|
5015
|
+
${this.showSources && a && f.length ? o`<div class="cards">
|
|
5016
|
+
<span class="label">${c.size ? s.sourcesCited : s.sourcesRetrieved}</span>
|
|
4318
5017
|
<div class="card-grid">
|
|
4319
|
-
${
|
|
4320
|
-
(
|
|
4321
|
-
var
|
|
4322
|
-
return
|
|
5018
|
+
${f.map(
|
|
5019
|
+
(w) => {
|
|
5020
|
+
var L;
|
|
5021
|
+
return o`<button
|
|
4323
5022
|
type="button"
|
|
4324
|
-
class="source-card ${((
|
|
4325
|
-
@click=${() => this.panel = { key: e.key, n:
|
|
5023
|
+
class="source-card ${((L = this.panel) == null ? void 0 : L.key) === e.key && this.panel.n === w.n ? "active" : ""}"
|
|
5024
|
+
@click=${() => this.panel = { key: e.key, n: w.n }}
|
|
4326
5025
|
>
|
|
4327
5026
|
<span class="top"
|
|
4328
|
-
><span class="num">${
|
|
4329
|
-
>${
|
|
5027
|
+
><span class="num">${w.n}</span
|
|
5028
|
+
>${w.collection ? o`<span class="label">${w.collection}</span>` : m}</span
|
|
4330
5029
|
>
|
|
4331
|
-
<span class="t">${
|
|
4332
|
-
<span class="s">${
|
|
5030
|
+
<span class="t">${w.title}${w.section ? ` · ${w.section}` : ""}</span>
|
|
5031
|
+
<span class="s">${w.text}</span>
|
|
4333
5032
|
</button>`;
|
|
4334
5033
|
}
|
|
4335
5034
|
)}
|
|
4336
5035
|
</div>
|
|
4337
5036
|
</div>` : m}
|
|
4338
|
-
${a ?
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
${
|
|
5037
|
+
${a ? o`<div class="toolbar ${t ? "pinned" : ""}">
|
|
5038
|
+
${this.allowCopy ? o`<button
|
|
5039
|
+
type="button"
|
|
5040
|
+
class="icon"
|
|
5041
|
+
title=${this.copiedKey === e.key ? s.copied : s.copy}
|
|
5042
|
+
aria-label=${s.copy}
|
|
5043
|
+
@click=${() => this.copy(e.key, C)}
|
|
5044
|
+
>
|
|
5045
|
+
${k.copy()}
|
|
5046
|
+
</button>` : m}
|
|
5047
|
+
${this.allowRaw && this.formatLevel !== "raw" && e.content ? o`<button
|
|
5048
|
+
type="button"
|
|
5049
|
+
class="icon ${this.rawKeys.has(e.key) ? "on" : ""}"
|
|
5050
|
+
title=${this.rawKeys.has(e.key) ? s.showFormatted : s.showRaw}
|
|
5051
|
+
aria-label=${s.showRaw}
|
|
5052
|
+
aria-pressed=${this.rawKeys.has(e.key) ? "true" : "false"}
|
|
5053
|
+
@click=${() => this.toggleRaw(e.key)}
|
|
5054
|
+
>
|
|
5055
|
+
${k.raw()}
|
|
5056
|
+
</button>` : m}
|
|
5057
|
+
${this.allowRegenerate && t && !this.busy ? o`<button
|
|
4349
5058
|
type="button"
|
|
4350
5059
|
class="icon"
|
|
4351
|
-
title=${
|
|
4352
|
-
aria-label=${
|
|
5060
|
+
title=${s.regenerate}
|
|
5061
|
+
aria-label=${s.regenerate}
|
|
4353
5062
|
@click=${() => this.regenerate()}
|
|
4354
5063
|
>
|
|
4355
|
-
${
|
|
5064
|
+
${k.refresh()}
|
|
4356
5065
|
</button>` : m}
|
|
4357
|
-
${e.id ?
|
|
5066
|
+
${this.allowBookmark && e.id ? o`<button
|
|
4358
5067
|
type="button"
|
|
4359
5068
|
class="icon ${e.bookmarked ? "on" : ""}"
|
|
4360
|
-
title=${e.bookmarked ?
|
|
4361
|
-
aria-label=${e.bookmarked ?
|
|
5069
|
+
title=${e.bookmarked ? s.unbookmarkMessage : s.bookmarkMessage}
|
|
5070
|
+
aria-label=${e.bookmarked ? s.unbookmarkMessage : s.bookmarkMessage}
|
|
4362
5071
|
@click=${() => this.toggleMessageBookmark(e)}
|
|
4363
5072
|
>
|
|
4364
|
-
${
|
|
5073
|
+
${k.bookmark(e.bookmarked)}
|
|
4365
5074
|
</button>` : m}
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
${e.stopped ?
|
|
5075
|
+
${this.allowDelete ? o`<button
|
|
5076
|
+
type="button"
|
|
5077
|
+
class="icon danger"
|
|
5078
|
+
title=${s.deleteMessage}
|
|
5079
|
+
aria-label=${s.deleteMessage}
|
|
5080
|
+
@click=${() => this.deleteMessage(e)}
|
|
5081
|
+
>
|
|
5082
|
+
${k.trash()}
|
|
5083
|
+
</button>` : m}
|
|
5084
|
+
${this.showTime ? o`<span class="time">${b}</span>` : m}
|
|
5085
|
+
${e.stopped ? o`<span class="note">${s.stopped}</span>` : m}
|
|
4377
5086
|
<span class="spacer"></span>
|
|
4378
|
-
${e.feedback ?
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
5087
|
+
${this.allowFeedback ? e.feedback ? o`<span class="note"
|
|
5088
|
+
>${e.feedback === "up" ? s.markedHelpful : s.thanksFeedback}</span
|
|
5089
|
+
>` : o`<button
|
|
5090
|
+
type="button"
|
|
5091
|
+
class="icon"
|
|
5092
|
+
title=${s.helpful}
|
|
5093
|
+
aria-label=${s.helpful}
|
|
5094
|
+
@click=${() => this.feedback(e, "up")}
|
|
5095
|
+
>
|
|
5096
|
+
${k.thumb()}
|
|
5097
|
+
</button>
|
|
5098
|
+
<button
|
|
5099
|
+
type="button"
|
|
5100
|
+
class="icon"
|
|
5101
|
+
title=${s.notHelpful}
|
|
5102
|
+
aria-label=${s.notHelpful}
|
|
5103
|
+
@click=${() => this.feedback(e, "down")}
|
|
5104
|
+
>
|
|
5105
|
+
${k.thumb(!0)}
|
|
5106
|
+
</button>` : m}
|
|
4398
5107
|
</div>` : m}
|
|
4399
|
-
${a && t && !this.busy && e.followups.length ?
|
|
5108
|
+
${this.showFollowups && a && t && !this.busy && e.followups.length ? o`<div class="followups">
|
|
4400
5109
|
${e.followups.map(
|
|
4401
|
-
(
|
|
4402
|
-
<span class="arrow">↳</span><span>${
|
|
5110
|
+
(w) => o`<button type="button" class="followup" @click=${() => this.send(w)}>
|
|
5111
|
+
<span class="arrow">↳</span><span>${w}</span>
|
|
4403
5112
|
</button>`
|
|
4404
5113
|
)}
|
|
4405
5114
|
</div>` : m}
|
|
@@ -4409,97 +5118,121 @@ ${x.map((b) => `[${b.n}] ${b.title}`).join(`
|
|
|
4409
5118
|
renderAnswer(e) {
|
|
4410
5119
|
if (e.phase === "error" && !e.content) return m;
|
|
4411
5120
|
if (e.phase === "done" && !e.content)
|
|
4412
|
-
return e.stopped ? m :
|
|
4413
|
-
const t =
|
|
4414
|
-
|
|
4415
|
-
|
|
5121
|
+
return e.stopped ? m : o`<div class="answer"><p class="note">${this.msg.emptyReply}</p></div>`;
|
|
5122
|
+
const t = this.formatLevel;
|
|
5123
|
+
if (t === "raw" || this.allowRaw && this.rawKeys.has(e.key))
|
|
5124
|
+
return o`<div class="answer" part="answer"><p class="raw">${e.content}</p></div>`;
|
|
5125
|
+
const s = e.phase === "streaming" ? ps(e.content) : e.content;
|
|
5126
|
+
let i = gs(os(s), t);
|
|
5127
|
+
if (this.afterParse)
|
|
5128
|
+
try {
|
|
5129
|
+
const r = this.afterParse(i, { message: e, format: t });
|
|
5130
|
+
Array.isArray(r) ? i = r : console.warn(
|
|
5131
|
+
"[singlebase-chat] afterParse must return an array of blocks; showing the original."
|
|
5132
|
+
);
|
|
5133
|
+
} catch (r) {
|
|
5134
|
+
console.warn("[singlebase-chat] afterParse failed; showing the original.", r);
|
|
5135
|
+
}
|
|
5136
|
+
const a = e.sources.reduce(
|
|
5137
|
+
(r, c, l) => Math.max(r, ft(c, l + 1).n),
|
|
5138
|
+
0
|
|
5139
|
+
);
|
|
5140
|
+
return o`<div class="answer" part="answer">
|
|
5141
|
+
${i.map((r, c) => this.renderBlock(r, e, a, c))}
|
|
4416
5142
|
</div>`;
|
|
4417
5143
|
}
|
|
4418
|
-
renderInline(e, t,
|
|
4419
|
-
return
|
|
5144
|
+
renderInline(e, t, s) {
|
|
5145
|
+
return ds(e, s).map((i) => {
|
|
4420
5146
|
var a;
|
|
4421
|
-
switch (
|
|
5147
|
+
switch (i.type) {
|
|
4422
5148
|
case "bold":
|
|
4423
|
-
return
|
|
5149
|
+
return o`<strong>${i.text}</strong>`;
|
|
5150
|
+
case "italic":
|
|
5151
|
+
return o`<em>${i.text}</em>`;
|
|
5152
|
+
case "strike":
|
|
5153
|
+
return o`<s>${i.text}</s>`;
|
|
4424
5154
|
case "code":
|
|
4425
|
-
return
|
|
5155
|
+
return o`<code class="inline">${i.text}</code>`;
|
|
4426
5156
|
case "link":
|
|
4427
|
-
return
|
|
4428
|
-
>${
|
|
5157
|
+
return o`<a href=${i.href} target="_blank" rel="noopener noreferrer nofollow"
|
|
5158
|
+
>${i.text}</a
|
|
4429
5159
|
>`;
|
|
4430
5160
|
case "cite": {
|
|
4431
|
-
const
|
|
4432
|
-
return
|
|
5161
|
+
const r = ((a = this.panel) == null ? void 0 : a.key) === t.key && this.panel.n === i.n ? "cite active" : "cite", c = _(this.msg.openSource, { n: i.n });
|
|
5162
|
+
return o`<button type="button" class=${r} aria-label=${c} @click=${() => this.panel = { key: t.key, n: i.n }}>${i.n}</button>`;
|
|
4433
5163
|
}
|
|
4434
5164
|
default:
|
|
4435
|
-
return
|
|
5165
|
+
return i.text;
|
|
4436
5166
|
}
|
|
4437
5167
|
});
|
|
4438
5168
|
}
|
|
4439
|
-
renderBlock(e, t,
|
|
5169
|
+
renderBlock(e, t, s, i) {
|
|
4440
5170
|
switch (e.type) {
|
|
4441
5171
|
case "p":
|
|
4442
|
-
return
|
|
5172
|
+
return o`<p>${this.renderInline(e.text, t, s)}</p>`;
|
|
4443
5173
|
case "raw":
|
|
4444
|
-
return
|
|
5174
|
+
return o`<p class="raw">${e.text}</p>`;
|
|
4445
5175
|
case "h":
|
|
4446
|
-
return
|
|
4447
|
-
case "
|
|
4448
|
-
|
|
4449
|
-
|
|
4450
|
-
);
|
|
4451
|
-
return e.ordered ? r`<ol>
|
|
4452
|
-
${a}
|
|
4453
|
-
</ol>` : r`<ul>
|
|
4454
|
-
${a}
|
|
4455
|
-
</ul>`;
|
|
4456
|
-
}
|
|
5176
|
+
return o`<h3 class="h${e.level}">${this.renderInline(e.text, t, s)}</h3>`;
|
|
5177
|
+
case "hr":
|
|
5178
|
+
return o`<hr />`;
|
|
5179
|
+
case "list":
|
|
5180
|
+
return this.renderList(e.ordered, e.items, t, s);
|
|
4457
5181
|
case "quote":
|
|
4458
|
-
return
|
|
4459
|
-
case "
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
</button>
|
|
4467
|
-
</div>
|
|
4468
|
-
<pre><code>${e.text}</code></pre>
|
|
5182
|
+
return o`<div class="quote">${this.renderInline(e.text, t, s)}</div>`;
|
|
5183
|
+
case "callout":
|
|
5184
|
+
return o`<div class="callout ${e.kind}" role="note" part="callout">
|
|
5185
|
+
<strong class="callout-title"
|
|
5186
|
+
>${e.title || this.msg[_s[e.kind]]}</strong
|
|
5187
|
+
>
|
|
5188
|
+
${e.text.split(`
|
|
5189
|
+
`).filter((a) => a.trim()).map((a) => o`<p>${this.renderInline(a, t, s)}</p>`)}
|
|
4469
5190
|
</div>`;
|
|
4470
|
-
|
|
5191
|
+
case "code":
|
|
5192
|
+
return this.renderCustom(e.lang, e.text, t) ?? this.renderCode(e.lang, e.text, `${t.key}:${i}`);
|
|
4471
5193
|
case "table":
|
|
4472
|
-
return
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
)}
|
|
4485
|
-
|
|
4486
|
-
|
|
5194
|
+
return this.renderTable(
|
|
5195
|
+
e.head,
|
|
5196
|
+
e.rows,
|
|
5197
|
+
e.align,
|
|
5198
|
+
t,
|
|
5199
|
+
s,
|
|
5200
|
+
`${t.key}:${i}`
|
|
5201
|
+
);
|
|
5202
|
+
case "json":
|
|
5203
|
+
return this.renderJsonBlock(e.value, e.source, `${t.key}:${i}`);
|
|
5204
|
+
case "svg": {
|
|
5205
|
+
const a = ws(e.source);
|
|
5206
|
+
if (!a) return this.renderCode("svg", e.source, `${t.key}:${i}`);
|
|
5207
|
+
const r = `${t.key}:${i}`;
|
|
5208
|
+
return o`<figure class="svg" part="svg">
|
|
5209
|
+
<img src=${a} alt="Drawing" />
|
|
5210
|
+
<figcaption>
|
|
5211
|
+
<button type="button" class="text-btn" @click=${() => this.copy(r, e.source)}>
|
|
5212
|
+
${this.copiedKey === r ? this.msg.copied : this.msg.copySvg}
|
|
5213
|
+
</button>
|
|
5214
|
+
</figcaption>
|
|
5215
|
+
</figure>`;
|
|
5216
|
+
}
|
|
5217
|
+
case "pending":
|
|
5218
|
+
return o`<div class="chart-pending">
|
|
5219
|
+
<span class="label"
|
|
5220
|
+
>${e.kind === "svg" ? this.msg.renderingSvg : this.msg.renderingChart}</span
|
|
5221
|
+
>
|
|
4487
5222
|
</div>`;
|
|
4488
5223
|
case "chart":
|
|
4489
5224
|
return this.renderChart(e.spec);
|
|
4490
|
-
case "chartPending":
|
|
4491
|
-
return r`<div class="chart-pending"><span class="label">Rendering chart</span></div>`;
|
|
4492
5225
|
case "img":
|
|
4493
|
-
return
|
|
5226
|
+
return o`<div class="gallery ${e.images.length > 1 ? "many" : ""}">
|
|
4494
5227
|
${e.images.map(
|
|
4495
|
-
(a) =>
|
|
4496
|
-
${a.src &&
|
|
5228
|
+
(a) => o`<figure>
|
|
5229
|
+
${a.src && _t(a.src, !0) ? o`<img
|
|
4497
5230
|
src=${a.src}
|
|
4498
5231
|
alt=${a.alt}
|
|
4499
5232
|
loading="lazy"
|
|
4500
5233
|
referrerpolicy="no-referrer"
|
|
4501
|
-
/>` :
|
|
4502
|
-
${a.alt ?
|
|
5234
|
+
/>` : o`<div class="img-missing"><span class="label">Image</span></div>`}
|
|
5235
|
+
${a.alt ? o`<figcaption>${a.alt}</figcaption>` : m}
|
|
4503
5236
|
</figure>`
|
|
4504
5237
|
)}
|
|
4505
5238
|
</div>`;
|
|
@@ -4507,29 +5240,147 @@ ${x.map((b) => `[${b.n}] ${b.title}`).join(`
|
|
|
4507
5240
|
return m;
|
|
4508
5241
|
}
|
|
4509
5242
|
}
|
|
5243
|
+
renderList(e, t, s, i) {
|
|
5244
|
+
const a = t.map(
|
|
5245
|
+
(r) => o`<li
|
|
5246
|
+
class=${r.checked === null ? "" : "task"}
|
|
5247
|
+
style=${r.depth ? `margin-left:${r.depth * 20}px` : ""}
|
|
5248
|
+
>
|
|
5249
|
+
${r.checked === null ? m : o`<input type="checkbox" disabled .checked=${r.checked} aria-hidden="true" />`}
|
|
5250
|
+
${this.renderInline(r.text, s, i)}
|
|
5251
|
+
</li>`
|
|
5252
|
+
);
|
|
5253
|
+
return e ? o`<ol>
|
|
5254
|
+
${a}
|
|
5255
|
+
</ol>` : o`<ul>
|
|
5256
|
+
${a}
|
|
5257
|
+
</ul>`;
|
|
5258
|
+
}
|
|
5259
|
+
renderCode(e, t, s) {
|
|
5260
|
+
return o`<div class="code">
|
|
5261
|
+
<div class="code-head">
|
|
5262
|
+
<span class="label">${e}</span>
|
|
5263
|
+
<button type="button" class="text-btn" @click=${() => this.copy(s, t)}>
|
|
5264
|
+
${this.copiedKey === s ? this.msg.copied : this.msg.copy}
|
|
5265
|
+
</button>
|
|
5266
|
+
</div>
|
|
5267
|
+
<pre><code>${t}</code></pre>
|
|
5268
|
+
</div>`;
|
|
5269
|
+
}
|
|
5270
|
+
/** A host renderer for this language, at the rich level only. */
|
|
5271
|
+
renderCustom(e, t, s) {
|
|
5272
|
+
var a;
|
|
5273
|
+
const i = this.formatLevel === "rich" ? (a = this.renderers) == null ? void 0 : a[e] : void 0;
|
|
5274
|
+
if (typeof i != "function" || s.phase === "streaming") return null;
|
|
5275
|
+
try {
|
|
5276
|
+
const r = i(t, { lang: e, message: s });
|
|
5277
|
+
return r == null ? null : o`<div class="custom-block">${r}</div>`;
|
|
5278
|
+
} catch (r) {
|
|
5279
|
+
return console.warn(`[singlebase-chat] the "${e}" renderer failed; showing the source`, r), null;
|
|
5280
|
+
}
|
|
5281
|
+
}
|
|
5282
|
+
renderTable(e, t, s, i, a, r) {
|
|
5283
|
+
const c = (x) => /^[-+]?[$€£¥]?\s?[\d,.]+\s?%?$/.test(x.trim()) && /\d/.test(x), l = (x) => Number(x.replace(/[^\d.+-]/g, "")), f = e.map((x, S) => {
|
|
5284
|
+
if (s[S]) return s[S];
|
|
5285
|
+
const $ = t.map((A) => A[S] ?? "").filter(Boolean);
|
|
5286
|
+
return $.length && $.filter(c).length / $.length >= 0.8 ? "right" : null;
|
|
5287
|
+
}), b = this.sorts.get(r);
|
|
5288
|
+
let C = t;
|
|
5289
|
+
b && (C = [...t].sort((x, S) => {
|
|
5290
|
+
const $ = x[b.col] ?? "", A = S[b.col] ?? "";
|
|
5291
|
+
return (c($) && c(A) ? l($) - l(A) : $.localeCompare(A, void 0, { numeric: !0 })) * b.dir;
|
|
5292
|
+
}));
|
|
5293
|
+
const T = C.length;
|
|
5294
|
+
C = C.slice(0, zs);
|
|
5295
|
+
const w = (x) => {
|
|
5296
|
+
const S = new Map(this.sorts), $ = S.get(r);
|
|
5297
|
+
($ == null ? void 0 : $.col) === x && $.dir === -1 ? S.delete(r) : S.set(r, { col: x, dir: ($ == null ? void 0 : $.col) === x ? -1 : 1 }), this.sorts = S;
|
|
5298
|
+
}, L = (x) => f[x] ? `text-align:${f[x]}` : "";
|
|
5299
|
+
return o`<div class="table" part="table">
|
|
5300
|
+
<table>
|
|
5301
|
+
<thead>
|
|
5302
|
+
<tr>
|
|
5303
|
+
${e.map((x, S) => {
|
|
5304
|
+
const $ = (b == null ? void 0 : b.col) === S ? b.dir === 1 ? "ascending" : "descending" : "none";
|
|
5305
|
+
return o`<th style=${L(S)} aria-sort=${$}>
|
|
5306
|
+
${t.length > 1 ? o`<button type="button" class="sort" @click=${() => w(S)}>
|
|
5307
|
+
${this.renderInline(x, i, a)}<span class="arrow"
|
|
5308
|
+
>${$ === "ascending" ? "↑" : $ === "descending" ? "↓" : "↕"}</span
|
|
5309
|
+
>
|
|
5310
|
+
</button>` : this.renderInline(x, i, a)}
|
|
5311
|
+
</th>`;
|
|
5312
|
+
})}
|
|
5313
|
+
</tr>
|
|
5314
|
+
</thead>
|
|
5315
|
+
<tbody>
|
|
5316
|
+
${C.map(
|
|
5317
|
+
(x) => o`<tr>
|
|
5318
|
+
${e.map(
|
|
5319
|
+
(S, $) => o`<td style=${L($)}>
|
|
5320
|
+
${this.renderInline(x[$] ?? "", i, a)}
|
|
5321
|
+
</td>`
|
|
5322
|
+
)}
|
|
5323
|
+
</tr>`
|
|
5324
|
+
)}
|
|
5325
|
+
</tbody>
|
|
5326
|
+
</table>
|
|
5327
|
+
${T > C.length ? o`<div class="table-note">
|
|
5328
|
+
${_(this.msg.showingRows, { n: C.length, total: T })}
|
|
5329
|
+
</div>` : m}
|
|
5330
|
+
</div>`;
|
|
5331
|
+
}
|
|
5332
|
+
renderJsonBlock(e, t, s) {
|
|
5333
|
+
let i = 0;
|
|
5334
|
+
const a = (c) => {
|
|
5335
|
+
i++, i <= Nt && c && typeof c == "object" && Object.values(c).forEach(a);
|
|
5336
|
+
};
|
|
5337
|
+
if (a(e), i > Nt) return this.renderCode("json", t, s);
|
|
5338
|
+
const r = (c, l, f) => {
|
|
5339
|
+
const b = f === void 0 ? m : o`<span class="jkey">${f}</span>: `;
|
|
5340
|
+
if (c && typeof c == "object") {
|
|
5341
|
+
const T = Object.entries(c), w = Array.isArray(c) ? `[${T.length}]` : `{${T.length}}`;
|
|
5342
|
+
return o`<details class="jnode" ?open=${l < 2}>
|
|
5343
|
+
<summary>${b}<span class="jmeta">${w}</span></summary>
|
|
5344
|
+
<div class="jkids">${T.map(([L, x]) => r(x, l + 1, L))}</div>
|
|
5345
|
+
</details>`;
|
|
5346
|
+
}
|
|
5347
|
+
return o`<div class="jleaf">
|
|
5348
|
+
${b}<span class="jv ${c === null ? "null" : typeof c}">${JSON.stringify(c)}</span>
|
|
5349
|
+
</div>`;
|
|
5350
|
+
};
|
|
5351
|
+
return o`<div class="code json" part="json">
|
|
5352
|
+
<div class="code-head">
|
|
5353
|
+
<span class="label">json</span>
|
|
5354
|
+
<button type="button" class="text-btn" @click=${() => this.copy(s, t)}>
|
|
5355
|
+
${this.copiedKey === s ? this.msg.copied : this.msg.copy}
|
|
5356
|
+
</button>
|
|
5357
|
+
</div>
|
|
5358
|
+
<div class="jtree">${r(e, 0)}</div>
|
|
5359
|
+
</div>`;
|
|
5360
|
+
}
|
|
4510
5361
|
renderChart(e) {
|
|
4511
|
-
const t = e.series.length > 1 ?
|
|
5362
|
+
const t = e.series.length > 1 ? o`<span class="legend">
|
|
4512
5363
|
${e.series.map(
|
|
4513
|
-
(
|
|
5364
|
+
(r, c) => o`<span
|
|
4514
5365
|
><span
|
|
4515
5366
|
class="swatch"
|
|
4516
|
-
style="background:${
|
|
5367
|
+
style="background:${j[c % j.length]}"
|
|
4517
5368
|
></span
|
|
4518
|
-
>${
|
|
5369
|
+
>${r.name}</span
|
|
4519
5370
|
>`
|
|
4520
5371
|
)}
|
|
4521
|
-
</span>` : m,
|
|
5372
|
+
</span>` : m, s = o`<div class="chart-head">
|
|
4522
5373
|
<span class="chart-title">${e.title}</span>${t}
|
|
4523
5374
|
</div>`;
|
|
4524
5375
|
if (e.type === "line") {
|
|
4525
|
-
const
|
|
4526
|
-
return
|
|
4527
|
-
${
|
|
5376
|
+
const r = Math.max(0, ...e.series.flatMap((b) => b.values)), c = Math.pow(10, Math.floor(Math.log10(r || 1))), l = Math.ceil(r / c * 2) / 2 * c || 1, f = Math.max(e.labels.length, ...e.series.map((b) => b.values.length));
|
|
5377
|
+
return o`<figure class="chart" part="chart" aria-label=${e.title}>
|
|
5378
|
+
${s}
|
|
4528
5379
|
<div class="line-chart">
|
|
4529
5380
|
<div class="plot">
|
|
4530
5381
|
${[1, 0.5, 0].map(
|
|
4531
|
-
(
|
|
4532
|
-
<span>${
|
|
5382
|
+
(b) => o`<div class="tick ${b === 0 ? "base" : ""}" style="top:${(1 - b) * 100}%">
|
|
5383
|
+
<span>${mt(Math.round(l * b), e.unit)}</span>
|
|
4533
5384
|
</div>`
|
|
4534
5385
|
)}
|
|
4535
5386
|
<svg
|
|
@@ -4539,38 +5390,38 @@ ${x.map((b) => `[${b.n}] ${b.title}`).join(`
|
|
|
4539
5390
|
aria-label=${e.title}
|
|
4540
5391
|
>
|
|
4541
5392
|
${e.series.map(
|
|
4542
|
-
(
|
|
4543
|
-
points=${
|
|
4544
|
-
(
|
|
5393
|
+
(b, C) => O`<polyline pathLength="1" stroke=${j[C % j.length]}
|
|
5394
|
+
points=${b.values.map(
|
|
5395
|
+
(T, w) => `${(f > 1 ? w / (f - 1) * 600 : 300).toFixed(1)},${(170 - T / l * 170).toFixed(1)}`
|
|
4545
5396
|
).join(
|
|
4546
5397
|
" "
|
|
4547
|
-
)}><title>${
|
|
5398
|
+
)}><title>${b.name}: ${b.values.map((T) => mt(T, e.unit)).join(", ")}</title></polyline>`
|
|
4548
5399
|
)}
|
|
4549
5400
|
</svg>
|
|
4550
5401
|
</div>
|
|
4551
|
-
<div class="x-labels">${e.labels.map((
|
|
5402
|
+
<div class="x-labels">${e.labels.map((b) => o`<span>${b}</span>`)}</div>
|
|
4552
5403
|
</div>
|
|
4553
5404
|
</figure>`;
|
|
4554
5405
|
}
|
|
4555
|
-
const
|
|
4556
|
-
(
|
|
4557
|
-
), a = Math.max(0, ...
|
|
4558
|
-
return
|
|
4559
|
-
${
|
|
5406
|
+
const i = e.labels.map(
|
|
5407
|
+
(r, c) => e.series.reduce((l, f) => l + (f.values[c] || 0), 0)
|
|
5408
|
+
), a = Math.max(0, ...i) || 1;
|
|
5409
|
+
return o`<figure class="chart" part="chart" aria-label=${e.title}>
|
|
5410
|
+
${s}
|
|
4560
5411
|
<div class="bars">
|
|
4561
5412
|
${e.labels.map(
|
|
4562
|
-
(
|
|
4563
|
-
<span class="bar-label">${
|
|
5413
|
+
(r, c) => o`<div class="bar-row" title="${r}: ${mt(i[c], e.unit)}">
|
|
5414
|
+
<span class="bar-label">${r}</span>
|
|
4564
5415
|
<span class="bar-track"
|
|
4565
|
-
><span class="bar-fill" style="width:${Math.max(0,
|
|
5416
|
+
><span class="bar-fill" style="width:${Math.max(0, i[c]) / a * 100}%">
|
|
4566
5417
|
${e.series.map(
|
|
4567
|
-
(
|
|
4568
|
-
style="flex:${Math.max(0,
|
|
5418
|
+
(l, f) => o`<span
|
|
5419
|
+
style="flex:${Math.max(0, l.values[c] || 0)};background:${e.series.length > 1 ? j[f % j.length] : "var(--c-ink)"}"
|
|
4569
5420
|
></span>`
|
|
4570
5421
|
)}
|
|
4571
5422
|
</span></span
|
|
4572
5423
|
>
|
|
4573
|
-
<span class="bar-value">${
|
|
5424
|
+
<span class="bar-value">${mt(i[c], e.unit)}</span>
|
|
4574
5425
|
</div>`
|
|
4575
5426
|
)}
|
|
4576
5427
|
</div>
|
|
@@ -4578,23 +5429,25 @@ ${x.map((b) => `[${b.n}] ${b.title}`).join(`
|
|
|
4578
5429
|
}
|
|
4579
5430
|
renderPanel() {
|
|
4580
5431
|
if (!this.panel) return m;
|
|
4581
|
-
const e = this.msgs.find((
|
|
4582
|
-
if (!e
|
|
4583
|
-
const
|
|
5432
|
+
const e = this.msgs.find((b) => b.key === this.panel.key);
|
|
5433
|
+
if (!e) return m;
|
|
5434
|
+
const t = e.sources.map((b, C) => ft(b, C + 1)), s = t.find((b) => b.n === this.panel.n);
|
|
5435
|
+
if (!s) return m;
|
|
5436
|
+
const i = this.msg, a = Ot(e.content), r = t.filter((b) => b.n !== s.n && (!a.size || a.has(b.n))), c = `ref:${e.key}:${s.n}`, l = `"${s.text}"
|
|
4584
5437
|
— ${s.title} [${s.n}]${s.path ? `
|
|
4585
|
-
${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`,
|
|
5438
|
+
${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, f = [
|
|
4586
5439
|
s.updated ? `Updated ${s.updated}` : "",
|
|
4587
5440
|
s.score !== null ? `Relevance ${s.score.toFixed(2)}` : ""
|
|
4588
5441
|
].filter(Boolean).join(" · ");
|
|
4589
|
-
return
|
|
5442
|
+
return o`<aside
|
|
4590
5443
|
class="panel ${this.panelDocked ? "docked" : "overlay"}"
|
|
4591
5444
|
part="panel"
|
|
4592
5445
|
role="region"
|
|
4593
|
-
aria-label=${
|
|
5446
|
+
aria-label=${_(i.sourceLabel, { n: s.n })}
|
|
4594
5447
|
>
|
|
4595
5448
|
<div class="panel-head">
|
|
4596
5449
|
<span class="label"
|
|
4597
|
-
>${
|
|
5450
|
+
>${_(i.sourceLabel, { n: s.n })}${s.collection ? ` · ${s.collection}` : ""}</span
|
|
4598
5451
|
>
|
|
4599
5452
|
<button type="button" class="text-btn underline" @click=${() => this.panel = null}>
|
|
4600
5453
|
${i.close}
|
|
@@ -4603,8 +5456,9 @@ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
|
|
|
4603
5456
|
<div class="panel-body">
|
|
4604
5457
|
<div class="panel-meta">
|
|
4605
5458
|
<h3>${s.title}</h3>
|
|
4606
|
-
${s.
|
|
4607
|
-
${
|
|
5459
|
+
${s.section ? o`<span class="meta">${s.section}</span>` : m}
|
|
5460
|
+
${s.path ? o`<span class="path">${s.path}</span>` : m}
|
|
5461
|
+
${f ? o`<span class="meta">${f}</span>` : m}
|
|
4608
5462
|
</div>
|
|
4609
5463
|
<div class="passage-box">
|
|
4610
5464
|
<span class="text">${s.text}</span>
|
|
@@ -4615,23 +5469,23 @@ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
|
|
|
4615
5469
|
class="copy-ref"
|
|
4616
5470
|
title=${i.copyReference}
|
|
4617
5471
|
aria-label=${i.copyReference}
|
|
4618
|
-
@click=${() => this.copy(
|
|
5472
|
+
@click=${() => this.copy(c, l)}
|
|
4619
5473
|
>
|
|
4620
|
-
${
|
|
5474
|
+
${k.copy()}<span>${this.copiedKey === c ? i.copied : i.copy}</span>
|
|
4621
5475
|
</button>
|
|
4622
5476
|
</div>
|
|
4623
5477
|
</div>
|
|
4624
5478
|
</div>
|
|
4625
|
-
${
|
|
5479
|
+
${r.length ? o`<div class="panel-foot">
|
|
4626
5480
|
<span class="label">${i.alsoCited}</span>
|
|
4627
5481
|
<div class="chips">
|
|
4628
|
-
${
|
|
4629
|
-
(
|
|
5482
|
+
${r.map(
|
|
5483
|
+
(b) => o`<button
|
|
4630
5484
|
type="button"
|
|
4631
5485
|
class="chip"
|
|
4632
|
-
@click=${() => this.panel = { key: e.key, n:
|
|
5486
|
+
@click=${() => this.panel = { key: e.key, n: b.n }}
|
|
4633
5487
|
>
|
|
4634
|
-
${
|
|
5488
|
+
${b.n} · ${b.title}
|
|
4635
5489
|
</button>`
|
|
4636
5490
|
)}
|
|
4637
5491
|
</div>
|
|
@@ -4639,35 +5493,56 @@ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
|
|
|
4639
5493
|
</aside>`;
|
|
4640
5494
|
}
|
|
4641
5495
|
renderComposer() {
|
|
4642
|
-
const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : this.mode === "
|
|
4643
|
-
|
|
5496
|
+
const e = this.msg, t = this.mode === "rag" ? e.placeholderRag : this.mode === "kb" ? e.placeholderKb : _(e.placeholderChat, { name: this.assistantName }), s = !this.draft.trim(), i = this.footnote === "" ? m : o`<span class="footnote" part="footnote"
|
|
5497
|
+
>${this.footnote ?? _(e.footnote, { name: this.assistantName })}</span
|
|
5498
|
+
>`;
|
|
5499
|
+
return this.showComposer ? o`<div class="composer-wrap">
|
|
4644
5500
|
<div class="composer-col">
|
|
4645
5501
|
<input
|
|
4646
5502
|
type="file"
|
|
4647
5503
|
multiple
|
|
4648
5504
|
hidden
|
|
4649
5505
|
accept=".md,.markdown,.txt,.csv,.tsv,.json,.html,.htm,.yaml,.yml,.xml,.log,text/*"
|
|
4650
|
-
@change=${(
|
|
4651
|
-
const
|
|
4652
|
-
this.addFiles(
|
|
5506
|
+
@change=${(a) => {
|
|
5507
|
+
const r = a.target;
|
|
5508
|
+
this.addFiles(r.files).then(() => r.value = "");
|
|
4653
5509
|
}}
|
|
4654
5510
|
/>
|
|
4655
5511
|
<div class="composer-box">
|
|
4656
|
-
${this.busy ?
|
|
5512
|
+
${this.busy ? o`<div class="composer-glow"></div>` : m}
|
|
4657
5513
|
<div class="composer ${this.busy ? "busy" : ""}" part="composer">
|
|
4658
|
-
${this.
|
|
5514
|
+
${this.savedFiles.length ? o`<div class="pending-files" part="saved-files">
|
|
5515
|
+
${this.savedFiles.map(
|
|
5516
|
+
(a) => o`<div class="pending-file kept">
|
|
5517
|
+
<span class="ext">${xt(a.name)}</span>
|
|
5518
|
+
<span class="meta"
|
|
5519
|
+
><span class="name">${a.name}</span
|
|
5520
|
+
><span class="size">${e.inThisChat}</span></span
|
|
5521
|
+
>
|
|
5522
|
+
<button
|
|
5523
|
+
type="button"
|
|
5524
|
+
aria-label=${e.removeFromChat}
|
|
5525
|
+
title=${e.removeFromChat}
|
|
5526
|
+
@click=${() => this.removeSavedFile(a)}
|
|
5527
|
+
>
|
|
5528
|
+
×
|
|
5529
|
+
</button>
|
|
5530
|
+
</div>`
|
|
5531
|
+
)}
|
|
5532
|
+
</div>` : m}
|
|
5533
|
+
${this.files.length ? o`<div class="pending-files">
|
|
4659
5534
|
${this.files.map(
|
|
4660
|
-
(
|
|
4661
|
-
<span class="ext">${
|
|
5535
|
+
(a) => o`<div class="pending-file">
|
|
5536
|
+
<span class="ext">${xt(a.name)}</span>
|
|
4662
5537
|
<span class="meta"
|
|
4663
|
-
><span class="name">${
|
|
4664
|
-
><span class="size">${
|
|
5538
|
+
><span class="name">${a.name}</span
|
|
5539
|
+
><span class="size">${kt(a.size)}</span></span
|
|
4665
5540
|
>
|
|
4666
5541
|
<button
|
|
4667
5542
|
type="button"
|
|
4668
5543
|
aria-label=${e.removeFile}
|
|
4669
5544
|
title=${e.removeFile}
|
|
4670
|
-
@click=${() => this.files = this.files.filter((
|
|
5545
|
+
@click=${() => this.files = this.files.filter((r) => r !== a)}
|
|
4671
5546
|
>
|
|
4672
5547
|
×
|
|
4673
5548
|
</button>
|
|
@@ -4685,242 +5560,327 @@ ${s.path}` : ""}${s.updated ? ` · Updated ${s.updated}` : ""}`, x = [
|
|
|
4685
5560
|
></textarea>
|
|
4686
5561
|
<div class="composer-row">
|
|
4687
5562
|
<div>
|
|
4688
|
-
${this.allowUpload ?
|
|
5563
|
+
${this.allowUpload ? o`<button
|
|
4689
5564
|
type="button"
|
|
4690
5565
|
class="attach"
|
|
4691
5566
|
title=${e.attach}
|
|
4692
5567
|
aria-label=${e.attach}
|
|
4693
5568
|
@click=${() => {
|
|
4694
|
-
var
|
|
4695
|
-
return (
|
|
5569
|
+
var a;
|
|
5570
|
+
return (a = this.renderRoot.querySelector("input[type=file]")) == null ? void 0 : a.click();
|
|
4696
5571
|
}}
|
|
4697
5572
|
>
|
|
4698
|
-
${
|
|
5573
|
+
${k.clip()}
|
|
4699
5574
|
</button>` : m}
|
|
4700
5575
|
</div>
|
|
4701
|
-
${this.busy ?
|
|
5576
|
+
${this.busy ? o`<button
|
|
4702
5577
|
type="button"
|
|
4703
5578
|
class="send stop"
|
|
4704
5579
|
title=${e.stop}
|
|
4705
5580
|
aria-label=${e.stop}
|
|
4706
5581
|
@click=${() => this.stop()}
|
|
4707
5582
|
>
|
|
4708
|
-
${
|
|
4709
|
-
</button>` :
|
|
5583
|
+
${k.stop()}
|
|
5584
|
+
</button>` : o`<button
|
|
4710
5585
|
type="button"
|
|
4711
5586
|
class="send"
|
|
4712
5587
|
title=${e.send}
|
|
4713
5588
|
aria-label=${e.send}
|
|
4714
|
-
?disabled=${
|
|
5589
|
+
?disabled=${s}
|
|
4715
5590
|
@click=${() => this.send()}
|
|
4716
5591
|
>
|
|
4717
|
-
${
|
|
5592
|
+
${k.up()}
|
|
4718
5593
|
</button>`}
|
|
4719
5594
|
</div>
|
|
4720
5595
|
</div>
|
|
4721
|
-
${this.busy ?
|
|
5596
|
+
${this.busy ? o`<div class="composer-ring"><div class="ring"></div></div>` : m}
|
|
4722
5597
|
</div>
|
|
4723
|
-
|
|
5598
|
+
${i}
|
|
4724
5599
|
</div>
|
|
4725
|
-
</div
|
|
5600
|
+
</div>` : o`<div class="composer-wrap reader">
|
|
5601
|
+
<div class="composer-col">${i}</div>
|
|
5602
|
+
</div>`;
|
|
4726
5603
|
}
|
|
4727
|
-
},
|
|
4728
|
-
|
|
5604
|
+
}, N = new WeakMap(), R = new WeakMap(), E = new WeakMap(), B = new WeakMap(), D = new WeakMap(), F = new WeakMap(), K = new WeakMap(), P = new WeakMap(), U = new WeakMap(), W = new WeakMap(), H = new WeakMap(), J = new WeakMap(), G = new WeakMap(), q = new WeakMap(), V = new WeakMap(), X = new WeakMap(), Y = new WeakMap(), Q = new WeakMap(), Z = new WeakMap(), ee = new WeakMap(), te = new WeakMap(), se = new WeakMap(), ie = new WeakMap(), ae = new WeakMap(), re = new WeakMap(), oe = new WeakMap(), ne = new WeakMap(), le = new WeakMap(), ce = new WeakMap(), de = new WeakMap(), pe = new WeakMap(), he = new WeakMap(), ue = new WeakMap(), ge = new WeakMap(), me = new WeakMap(), fe = new WeakMap(), be = new WeakMap(), xe = new WeakMap(), ve = new WeakMap(), we = new WeakMap(), ye = new WeakMap(), ke = new WeakMap(), $e = new WeakMap(), Ce = new WeakMap(), Te = new WeakMap(), Se = new WeakMap(), Ie = new WeakMap(), Oe = new WeakMap(), Me = new WeakMap(), ze = new WeakMap(), _e = new WeakMap(), Le = new WeakMap(), Ae = new WeakMap(), je = new WeakMap(), Ne = new WeakMap(), Re = new WeakMap(), Ee = new WeakMap(), Be = new WeakMap(), De = new WeakMap(), Fe = new WeakMap(), Ke = new WeakMap(), Pe = new WeakMap(), Ue = new WeakMap(), We = new WeakMap(), He = new WeakMap(), Je = new WeakMap(), Ge = new WeakMap(), qe = new WeakMap(), Ve = new WeakMap(), Xe = new WeakMap(), Ye = new WeakMap(), Qe = new WeakMap(), Ze = new WeakMap(), et = new WeakMap(), tt = new WeakMap(), st = new WeakMap(), it = new WeakMap(), at = new WeakMap(), rt = new WeakMap(), ot = new WeakMap(), nt = new WeakMap(), lt = new WeakMap(), ct = new WeakMap(), dt = new WeakMap(), pt = new WeakMap(), ht = new WeakMap(), ut = new WeakMap(), gt = new WeakMap(), Ft);
|
|
5605
|
+
$s(d, "styles", [Yt, Qt, Zt]);
|
|
4729
5606
|
g([
|
|
4730
|
-
|
|
5607
|
+
v({ attribute: !1 })
|
|
4731
5608
|
], d.prototype, "client", 1);
|
|
4732
5609
|
g([
|
|
4733
|
-
|
|
5610
|
+
v({ attribute: !1 })
|
|
4734
5611
|
], d.prototype, "messages", 1);
|
|
4735
5612
|
g([
|
|
4736
|
-
|
|
5613
|
+
v({ reflect: !0 })
|
|
4737
5614
|
], d.prototype, "theme", 1);
|
|
4738
5615
|
g([
|
|
4739
|
-
|
|
5616
|
+
v({ reflect: !0 })
|
|
5617
|
+
], d.prototype, "radius", 1);
|
|
5618
|
+
g([
|
|
5619
|
+
v({ reflect: !0 })
|
|
4740
5620
|
], d.prototype, "mode", 1);
|
|
4741
5621
|
g([
|
|
4742
|
-
|
|
4743
|
-
], d.prototype, "
|
|
5622
|
+
v({ reflect: !0 })
|
|
5623
|
+
], d.prototype, "format", 1);
|
|
5624
|
+
g([
|
|
5625
|
+
v({ attribute: !1 })
|
|
5626
|
+
], d.prototype, "renderers", 1);
|
|
4744
5627
|
g([
|
|
4745
|
-
|
|
5628
|
+
v({ attribute: !1 })
|
|
5629
|
+
], d.prototype, "beforeSend", 1);
|
|
5630
|
+
g([
|
|
5631
|
+
v({ attribute: !1 })
|
|
5632
|
+
], d.prototype, "afterParse", 1);
|
|
5633
|
+
g([
|
|
5634
|
+
v({ reflect: !0 })
|
|
4746
5635
|
], d.prototype, "glow", 1);
|
|
4747
5636
|
g([
|
|
4748
|
-
|
|
5637
|
+
v()
|
|
5638
|
+
], d.prototype, "docsets", 1);
|
|
5639
|
+
g([
|
|
5640
|
+
v({ attribute: "attachments-mode" })
|
|
5641
|
+
], d.prototype, "attachmentsMode", 1);
|
|
5642
|
+
g([
|
|
5643
|
+
v({ converter: I, attribute: "save-attachments" })
|
|
5644
|
+
], d.prototype, "saveAttachments", 1);
|
|
5645
|
+
g([
|
|
5646
|
+
v({ converter: I })
|
|
4749
5647
|
], d.prototype, "followups", 1);
|
|
4750
5648
|
g([
|
|
4751
|
-
|
|
5649
|
+
v({ converter: I, attribute: "show-sources" })
|
|
5650
|
+
], d.prototype, "showSources", 1);
|
|
5651
|
+
g([
|
|
5652
|
+
v({ converter: I, attribute: "show-new-chat" })
|
|
5653
|
+
], d.prototype, "showNewChat", 1);
|
|
5654
|
+
g([
|
|
5655
|
+
v({ converter: I, attribute: "show-bookmarked" })
|
|
5656
|
+
], d.prototype, "showBookmarked", 1);
|
|
5657
|
+
g([
|
|
5658
|
+
v({ converter: I, attribute: "show-followups" })
|
|
5659
|
+
], d.prototype, "showFollowups", 1);
|
|
5660
|
+
g([
|
|
5661
|
+
v({ converter: I, attribute: "allow-search" })
|
|
5662
|
+
], d.prototype, "allowSearch", 1);
|
|
5663
|
+
g([
|
|
5664
|
+
v({ converter: I, attribute: "auto-title" })
|
|
4752
5665
|
], d.prototype, "autoTitle", 1);
|
|
4753
5666
|
g([
|
|
4754
|
-
|
|
5667
|
+
v()
|
|
4755
5668
|
], d.prototype, "model", 1);
|
|
4756
5669
|
g([
|
|
4757
|
-
|
|
5670
|
+
v({ converter: vt })
|
|
4758
5671
|
], d.prototype, "params", 1);
|
|
4759
5672
|
g([
|
|
4760
|
-
|
|
5673
|
+
v({ attribute: "system-message" })
|
|
4761
5674
|
], d.prototype, "systemMessage", 1);
|
|
4762
5675
|
g([
|
|
4763
|
-
|
|
5676
|
+
v({ converter: vt })
|
|
4764
5677
|
], d.prototype, "retrieval", 1);
|
|
4765
5678
|
g([
|
|
4766
|
-
|
|
5679
|
+
v({ converter: vt })
|
|
4767
5680
|
], d.prototype, "metadata", 1);
|
|
4768
5681
|
g([
|
|
4769
|
-
|
|
5682
|
+
v({ reflect: !0 })
|
|
4770
5683
|
], d.prototype, "embed", 1);
|
|
4771
5684
|
g([
|
|
4772
|
-
|
|
5685
|
+
v({ reflect: !0 })
|
|
4773
5686
|
], d.prototype, "position", 1);
|
|
4774
5687
|
g([
|
|
4775
|
-
|
|
5688
|
+
v({ converter: Cs })
|
|
4776
5689
|
], d.prototype, "sidebar", 1);
|
|
4777
5690
|
g([
|
|
4778
|
-
|
|
5691
|
+
v({ converter: I, attribute: "show-title" })
|
|
4779
5692
|
], d.prototype, "showTitle", 1);
|
|
4780
5693
|
g([
|
|
4781
|
-
|
|
5694
|
+
v({ attribute: "chat-id" })
|
|
4782
5695
|
], d.prototype, "chatIdAttr", 1);
|
|
4783
5696
|
g([
|
|
4784
|
-
|
|
5697
|
+
v({ attribute: "assistant-name" })
|
|
4785
5698
|
], d.prototype, "assistantName", 1);
|
|
4786
5699
|
g([
|
|
4787
|
-
|
|
5700
|
+
v({ attribute: "logo-url" })
|
|
4788
5701
|
], d.prototype, "logoUrl", 1);
|
|
4789
5702
|
g([
|
|
4790
|
-
|
|
5703
|
+
v()
|
|
4791
5704
|
], d.prototype, "heading", 1);
|
|
4792
5705
|
g([
|
|
4793
|
-
|
|
5706
|
+
v()
|
|
4794
5707
|
], d.prototype, "description", 1);
|
|
4795
5708
|
g([
|
|
4796
|
-
|
|
5709
|
+
v()
|
|
5710
|
+
], d.prototype, "eyebrow", 1);
|
|
5711
|
+
g([
|
|
5712
|
+
v()
|
|
4797
5713
|
], d.prototype, "prompts", 1);
|
|
4798
5714
|
g([
|
|
4799
|
-
|
|
5715
|
+
v({ attribute: "bubble-text" })
|
|
4800
5716
|
], d.prototype, "bubbleText", 1);
|
|
4801
5717
|
g([
|
|
4802
|
-
|
|
5718
|
+
v({ type: Boolean, attribute: "greeting-bubble" })
|
|
4803
5719
|
], d.prototype, "greetingBubble", 1);
|
|
4804
5720
|
g([
|
|
4805
|
-
|
|
5721
|
+
v({ type: Boolean, attribute: "unread-badge" })
|
|
4806
5722
|
], d.prototype, "unreadBadge", 1);
|
|
4807
5723
|
g([
|
|
4808
|
-
|
|
5724
|
+
v({ converter: I, attribute: "allow-upload" })
|
|
4809
5725
|
], d.prototype, "allowUpload", 1);
|
|
4810
5726
|
g([
|
|
4811
|
-
|
|
5727
|
+
v({ converter: I, attribute: "allow-export" })
|
|
4812
5728
|
], d.prototype, "allowExport", 1);
|
|
4813
5729
|
g([
|
|
4814
|
-
|
|
4815
|
-
], d.prototype, "
|
|
5730
|
+
v({ converter: I, attribute: "allow-copy" })
|
|
5731
|
+
], d.prototype, "allowCopy", 1);
|
|
5732
|
+
g([
|
|
5733
|
+
v({ converter: I, attribute: "allow-regenerate" })
|
|
5734
|
+
], d.prototype, "allowRegenerate", 1);
|
|
5735
|
+
g([
|
|
5736
|
+
v({ converter: I, attribute: "allow-bookmark" })
|
|
5737
|
+
], d.prototype, "allowBookmark", 1);
|
|
5738
|
+
g([
|
|
5739
|
+
v({ converter: I, attribute: "allow-delete" })
|
|
5740
|
+
], d.prototype, "allowDelete", 1);
|
|
5741
|
+
g([
|
|
5742
|
+
v({ converter: I, attribute: "allow-rename" })
|
|
5743
|
+
], d.prototype, "allowRename", 1);
|
|
5744
|
+
g([
|
|
5745
|
+
v({ converter: I, attribute: "allow-feedback" })
|
|
5746
|
+
], d.prototype, "allowFeedback", 1);
|
|
5747
|
+
g([
|
|
5748
|
+
v({ converter: I, attribute: "show-composer" })
|
|
5749
|
+
], d.prototype, "showComposer", 1);
|
|
5750
|
+
g([
|
|
5751
|
+
v({ converter: I, attribute: "show-time" })
|
|
5752
|
+
], d.prototype, "showTime", 1);
|
|
4816
5753
|
g([
|
|
4817
5754
|
v()
|
|
5755
|
+
], d.prototype, "footnote", 1);
|
|
5756
|
+
g([
|
|
5757
|
+
v({ type: Boolean, attribute: "allow-raw" })
|
|
5758
|
+
], d.prototype, "allowRaw", 1);
|
|
5759
|
+
g([
|
|
5760
|
+
v({ converter: I })
|
|
5761
|
+
], d.prototype, "branding", 1);
|
|
5762
|
+
g([
|
|
5763
|
+
y()
|
|
4818
5764
|
], d.prototype, "chatList", 1);
|
|
4819
5765
|
g([
|
|
4820
|
-
|
|
5766
|
+
y()
|
|
4821
5767
|
], d.prototype, "listState", 1);
|
|
4822
5768
|
g([
|
|
4823
|
-
|
|
5769
|
+
y()
|
|
4824
5770
|
], d.prototype, "activeId", 1);
|
|
4825
5771
|
g([
|
|
4826
|
-
|
|
5772
|
+
y()
|
|
4827
5773
|
], d.prototype, "chatTitle", 1);
|
|
4828
5774
|
g([
|
|
4829
|
-
|
|
5775
|
+
y()
|
|
4830
5776
|
], d.prototype, "bookmarked", 1);
|
|
4831
5777
|
g([
|
|
4832
|
-
|
|
5778
|
+
y()
|
|
4833
5779
|
], d.prototype, "msgs", 1);
|
|
4834
5780
|
g([
|
|
4835
|
-
|
|
5781
|
+
y()
|
|
4836
5782
|
], d.prototype, "loadingThread", 1);
|
|
4837
5783
|
g([
|
|
4838
|
-
|
|
5784
|
+
y()
|
|
4839
5785
|
], d.prototype, "threadError", 1);
|
|
4840
5786
|
g([
|
|
4841
|
-
|
|
5787
|
+
y()
|
|
4842
5788
|
], d.prototype, "busy", 1);
|
|
4843
5789
|
g([
|
|
4844
|
-
|
|
5790
|
+
y()
|
|
4845
5791
|
], d.prototype, "draft", 1);
|
|
4846
5792
|
g([
|
|
4847
|
-
|
|
5793
|
+
y()
|
|
4848
5794
|
], d.prototype, "files", 1);
|
|
4849
5795
|
g([
|
|
4850
|
-
|
|
5796
|
+
y()
|
|
4851
5797
|
], d.prototype, "search", 1);
|
|
4852
5798
|
g([
|
|
4853
|
-
|
|
5799
|
+
y()
|
|
4854
5800
|
], d.prototype, "sidebarOpen", 1);
|
|
4855
5801
|
g([
|
|
4856
|
-
|
|
5802
|
+
y()
|
|
4857
5803
|
], d.prototype, "width", 1);
|
|
4858
5804
|
g([
|
|
4859
|
-
|
|
5805
|
+
y()
|
|
4860
5806
|
], d.prototype, "panel", 1);
|
|
4861
5807
|
g([
|
|
4862
|
-
|
|
5808
|
+
y()
|
|
4863
5809
|
], d.prototype, "menuOpen", 1);
|
|
4864
5810
|
g([
|
|
4865
|
-
|
|
5811
|
+
y()
|
|
4866
5812
|
], d.prototype, "editingKey", 1);
|
|
4867
5813
|
g([
|
|
4868
|
-
|
|
5814
|
+
y()
|
|
4869
5815
|
], d.prototype, "editDraft", 1);
|
|
4870
5816
|
g([
|
|
4871
|
-
|
|
5817
|
+
y()
|
|
4872
5818
|
], d.prototype, "editingTitle", 1);
|
|
4873
5819
|
g([
|
|
4874
|
-
|
|
5820
|
+
y()
|
|
4875
5821
|
], d.prototype, "renamingId", 1);
|
|
4876
5822
|
g([
|
|
4877
|
-
|
|
5823
|
+
y()
|
|
4878
5824
|
], d.prototype, "toast", 1);
|
|
4879
5825
|
g([
|
|
4880
|
-
|
|
5826
|
+
y()
|
|
4881
5827
|
], d.prototype, "copiedKey", 1);
|
|
4882
5828
|
g([
|
|
4883
|
-
|
|
5829
|
+
y()
|
|
4884
5830
|
], d.prototype, "retrievalOpen", 1);
|
|
4885
5831
|
g([
|
|
4886
|
-
|
|
5832
|
+
y()
|
|
5833
|
+
], d.prototype, "rawKeys", 1);
|
|
5834
|
+
g([
|
|
5835
|
+
y()
|
|
5836
|
+
], d.prototype, "savedFiles", 1);
|
|
5837
|
+
g([
|
|
5838
|
+
y()
|
|
5839
|
+
], d.prototype, "hasSidebarContent", 1);
|
|
5840
|
+
g([
|
|
5841
|
+
y()
|
|
5842
|
+
], d.prototype, "sorts", 1);
|
|
5843
|
+
g([
|
|
5844
|
+
y()
|
|
4887
5845
|
], d.prototype, "arrivedKey", 1);
|
|
4888
5846
|
g([
|
|
4889
|
-
|
|
5847
|
+
y()
|
|
4890
5848
|
], d.prototype, "dragging", 1);
|
|
4891
5849
|
g([
|
|
4892
|
-
|
|
5850
|
+
y()
|
|
4893
5851
|
], d.prototype, "showJump", 1);
|
|
4894
5852
|
g([
|
|
4895
|
-
|
|
5853
|
+
y()
|
|
4896
5854
|
], d.prototype, "offline", 1);
|
|
4897
5855
|
g([
|
|
4898
|
-
|
|
5856
|
+
y()
|
|
4899
5857
|
], d.prototype, "isOpen", 1);
|
|
4900
5858
|
g([
|
|
4901
|
-
|
|
5859
|
+
y()
|
|
4902
5860
|
], d.prototype, "expanded", 1);
|
|
4903
5861
|
g([
|
|
4904
|
-
|
|
5862
|
+
y()
|
|
4905
5863
|
], d.prototype, "bubble", 1);
|
|
4906
5864
|
g([
|
|
4907
|
-
|
|
5865
|
+
y()
|
|
4908
5866
|
], d.prototype, "seen", 1);
|
|
4909
5867
|
g([
|
|
4910
|
-
|
|
5868
|
+
y()
|
|
4911
5869
|
], d.prototype, "mobile", 1);
|
|
4912
5870
|
d = g([
|
|
4913
|
-
|
|
5871
|
+
Gt("singlebase-chat")
|
|
4914
5872
|
], d);
|
|
4915
5873
|
export {
|
|
4916
5874
|
d as S,
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
5875
|
+
gs as a,
|
|
5876
|
+
ft as b,
|
|
5877
|
+
Ot as c,
|
|
5878
|
+
es as d,
|
|
5879
|
+
os as e,
|
|
5880
|
+
zt as f,
|
|
5881
|
+
ws as g,
|
|
5882
|
+
ds as p,
|
|
5883
|
+
ts as r,
|
|
5884
|
+
ps as s
|
|
4925
5885
|
};
|
|
4926
|
-
//# sourceMappingURL=chat-
|
|
5886
|
+
//# sourceMappingURL=chat-BH_3e1jT.js.map
|