@sveda-ai/react 0.3.1
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/LICENSE +557 -0
- package/README.md +18 -0
- package/dist/appearance.d.ts +12 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/components/SvedaChat.d.ts +14 -0
- package/dist/components/SvedaChat.d.ts.map +1 -0
- package/dist/components/shell/ChatHistoryList.d.ts +10 -0
- package/dist/components/shell/ChatHistoryList.d.ts.map +1 -0
- package/dist/components/shell/ChatMessageList.d.ts +7 -0
- package/dist/components/shell/ChatMessageList.d.ts.map +1 -0
- package/dist/components/shell/SvedaComposer.d.ts +11 -0
- package/dist/components/shell/SvedaComposer.d.ts.map +1 -0
- package/dist/components/shell/SvedaFrameTicks.d.ts +2 -0
- package/dist/components/shell/SvedaFrameTicks.d.ts.map +1 -0
- package/dist/components/shell/SvedaMinimizedTrigger.d.ts +9 -0
- package/dist/components/shell/SvedaMinimizedTrigger.d.ts.map +1 -0
- package/dist/components/shell/SvedaResizeHandles.d.ts +9 -0
- package/dist/components/shell/SvedaResizeHandles.d.ts.map +1 -0
- package/dist/components/shell/SvedaTabs.d.ts +13 -0
- package/dist/components/shell/SvedaTabs.d.ts.map +1 -0
- package/dist/components/shell/SvedaToolbar.d.ts +21 -0
- package/dist/components/shell/SvedaToolbar.d.ts.map +1 -0
- package/dist/hooks/useSvedaChat.d.ts +33 -0
- package/dist/hooks/useSvedaChat.d.ts.map +1 -0
- package/dist/hooks/useSvedaChatLayout.d.ts +25 -0
- package/dist/hooks/useSvedaChatLayout.d.ts.map +1 -0
- package/dist/hooks/useSvedaStreaming.d.ts +43 -0
- package/dist/hooks/useSvedaStreaming.d.ts.map +1 -0
- package/dist/i18n.d.ts +14 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1238 -0
- package/dist/launcherIcons.d.ts +5 -0
- package/dist/launcherIcons.d.ts.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/provider.d.ts +15 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/styles.css +3 -0
- package/dist/types.d.ts +58 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +74 -0
- package/src/appearance.ts +81 -0
- package/src/components/SvedaChat.tsx +428 -0
- package/src/components/shell/ChatHistoryList.tsx +151 -0
- package/src/components/shell/ChatMessageList.tsx +52 -0
- package/src/components/shell/SvedaComposer.tsx +100 -0
- package/src/components/shell/SvedaFrameTicks.tsx +22 -0
- package/src/components/shell/SvedaMinimizedTrigger.tsx +41 -0
- package/src/components/shell/SvedaResizeHandles.tsx +51 -0
- package/src/components/shell/SvedaTabs.tsx +106 -0
- package/src/components/shell/SvedaToolbar.tsx +132 -0
- package/src/hooks/useSvedaChat.ts +91 -0
- package/src/hooks/useSvedaChatLayout.ts +281 -0
- package/src/hooks/useSvedaStreaming.ts +139 -0
- package/src/i18n.ts +51 -0
- package/src/index.ts +116 -0
- package/src/launcherIcons.ts +43 -0
- package/src/lib/utils.ts +6 -0
- package/src/markdown.css +96 -0
- package/src/provider.tsx +179 -0
- package/src/styles.css +6 -0
- package/src/theme.css +137 -0
- package/src/types.ts +70 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1238 @@
|
|
|
1
|
+
import { SvedaClient as $e } from "@sveda-ai/core";
|
|
2
|
+
export * from "@sveda-ai/core";
|
|
3
|
+
import { sanitizeSvedaLauncher as Fe, sanitizeSvedaChrome as Oe, resolveSvedaAppearance as Ze, applySvedaAppearance as Je, ruMessages as Qe, enMessages as et, chatComponentI18nKeys as tt, mergeSvedaAppearance as rt, SVEDA_LAUNCHER_ICON_IDS as nt, SVEDA_DEFAULT_LAUNCHER_ICON as at, getSvedaChatStore as Ue, SVEDA_CHAT_LAYOUT_MIN_HEIGHT as st, SVEDA_CHAT_LAYOUT_MAX_HEIGHT as it, SVEDA_CHAT_LAYOUT_MIN_WIDTH as Ve, SVEDA_CHAT_LAYOUT_MAX_WIDTH as ot, pointerScreenDelta as lt, applyFixedLeftResize as dt, applyFloatingResize as ct, createSvedaStreaming as ht, getUserMessageText as je, buildChatTabTitleMap as mt } from "@sveda-ai/chat";
|
|
4
|
+
import { SVEDA_APPEARANCE_PRESETS as Mr, SVEDA_APPEARANCE_PRESET_IDS as Tr, SVEDA_APPEARANCE_STYLE_ID as Er, SVEDA_CHAT_MINIMIZED_STORAGE_KEY as Ir, SVEDA_DEFAULT_LAUNCHER_ICON as kr, SVEDA_LAUNCHER_ICON_IDS as Ar, SVEDA_LAUNCHER_IMAGE_MAX_BYTES as _r, SVEDA_LAUNCHER_IMAGE_MAX_CHARS as Dr, SVEDA_TOKEN_KEYS as Lr, buildAppearanceCss as Hr, buildChatTabTitleMap as Pr, chatComponentI18nKeys as zr, deriveProvisionalChatTitle as Rr, enMessages as Fr, finalizeMessagesForDisplay as Or, formatRadiusPx as Ur, getSvedaModelDisplayName as Vr, getUserMessageAttachmentNames as jr, getUserMessageText as Wr, hexToHsl as Yr, hslToHex as Br, humanizeModelId as Kr, isChatTitlePlaceholder as qr, isNewChatPlaceholder as Xr, isPersistedSessionChatOpen as Gr, isSvedaAppearanceProvided as $r, isSvedaHsl as Zr, mergeSvedaAppearance as Jr, parseRadiusPx as Qr, readPersistedMinimized as en, readPersistedMinimizedPreference as tn, resolveSvedaAppearance as rn, ruMessages as nn, sanitizeSvedaChrome as an, sanitizeSvedaLauncher as sn, sanitizeSvedaLauncherImage as on, sanitizeSvedaRadius as ln, sanitizeSvedaTheme as dn, userMessageHasVisibleContent as cn, writePersistedMinimized as hn } from "@sveda-ai/chat";
|
|
5
|
+
import { createContext as ut, useMemo as D, createElement as ft, useContext as ie, useSyncExternalStore as xe, useRef as A, useCallback as P, useEffect as F, useState as E } from "react";
|
|
6
|
+
import { Gem as gt, Rocket as pt, CircleHelp as bt, Heart as vt, Star as xt, Zap as Ct, Brain as wt, BotMessageSquare as St, Bot as yt, MessageSquare as We, MessageCircle as Nt, Sparkles as Ye, Search as Mt, SquarePen as Tt, Trash2 as Et, Square as It, Loader2 as Be, Send as kt, X as Ke, Plus as qe, History as At, Minimize2 as _t, Maximize2 as Dt, PanelRight as Lt } from "lucide-react";
|
|
7
|
+
import { jsxs as b, jsx as t, Fragment as Ce } from "react/jsx-runtime";
|
|
8
|
+
import { clsx as Ht } from "clsx";
|
|
9
|
+
import { twMerge as Pt } from "tailwind-merge";
|
|
10
|
+
let oe = Fe(null), le = Oe(null);
|
|
11
|
+
const pe = /* @__PURE__ */ new Set(), zt = () => {
|
|
12
|
+
for (const e of pe)
|
|
13
|
+
e();
|
|
14
|
+
}, Rt = (e) => (pe.add(e), () => {
|
|
15
|
+
pe.delete(e);
|
|
16
|
+
}), Ie = () => oe, ur = () => le, fr = () => oe, gr = () => le, pr = oe, br = le, be = (e) => {
|
|
17
|
+
const n = Ze(e);
|
|
18
|
+
oe = Fe(n == null ? void 0 : n.launcher), le = Oe(n == null ? void 0 : n.chrome), Je(e), zt();
|
|
19
|
+
};
|
|
20
|
+
function Ft(e = {}) {
|
|
21
|
+
let n = e.locale ?? "en";
|
|
22
|
+
const a = e.fallbackLocale ?? "en", i = { ...e.messages ?? {} }, h = (c, m) => m ? c.replace(
|
|
23
|
+
/\{(\w+)\}/g,
|
|
24
|
+
(f, o) => m[o] === void 0 || m[o] === null ? f : String(m[o])
|
|
25
|
+
) : c;
|
|
26
|
+
return {
|
|
27
|
+
get locale() {
|
|
28
|
+
return n;
|
|
29
|
+
},
|
|
30
|
+
t(c, m) {
|
|
31
|
+
var o, g;
|
|
32
|
+
const f = ((o = i[n]) == null ? void 0 : o[c]) ?? ((g = i[a]) == null ? void 0 : g[c]);
|
|
33
|
+
return f === void 0 ? c : h(f, m);
|
|
34
|
+
},
|
|
35
|
+
setLocale(c) {
|
|
36
|
+
n = c;
|
|
37
|
+
},
|
|
38
|
+
extend(c, m) {
|
|
39
|
+
i[c] = { ...i[c] ?? {}, ...m };
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const Ot = "sveda-embed-auth", Ut = {
|
|
44
|
+
brand: { name: "Sveda", logoUrl: null },
|
|
45
|
+
models: [],
|
|
46
|
+
quickPrompts: []
|
|
47
|
+
}, $ = ut(null), Vt = (e) => {
|
|
48
|
+
if (typeof fetch > "u")
|
|
49
|
+
return;
|
|
50
|
+
let n = "";
|
|
51
|
+
try {
|
|
52
|
+
const a = new URL(e);
|
|
53
|
+
if (a.protocol !== "http:" && a.protocol !== "https:")
|
|
54
|
+
return;
|
|
55
|
+
n = a.origin;
|
|
56
|
+
} catch {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
fetch(`${n}/sveda/embed/config`).then((a) => a.ok ? a.json() : null).then((a) => {
|
|
60
|
+
!a || typeof a != "object" || be(
|
|
61
|
+
rt(a.appearance, void 0)
|
|
62
|
+
);
|
|
63
|
+
}).catch(() => {
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
function jt(e) {
|
|
67
|
+
var m, f;
|
|
68
|
+
const n = new $e({
|
|
69
|
+
endpoints: e.endpoints,
|
|
70
|
+
protocolMode: e.protocolMode,
|
|
71
|
+
headers: e.headers,
|
|
72
|
+
credentials: e.credentials
|
|
73
|
+
}), a = {}, i = (o, g) => {
|
|
74
|
+
a[o] = { ...a[o] ?? {}, ...g };
|
|
75
|
+
};
|
|
76
|
+
for (const [o, g] of Object.entries({ en: et, ru: Qe }))
|
|
77
|
+
i(o, g);
|
|
78
|
+
for (const [o, g] of Object.entries(tt))
|
|
79
|
+
i(o, g);
|
|
80
|
+
for (const [o, g] of Object.entries(e.messages ?? {}))
|
|
81
|
+
i(o, g);
|
|
82
|
+
const h = Ft({
|
|
83
|
+
locale: e.locale ?? "en",
|
|
84
|
+
messages: a
|
|
85
|
+
}), c = {
|
|
86
|
+
brand: {
|
|
87
|
+
name: ((m = e.brand) == null ? void 0 : m.name) ?? "Sveda",
|
|
88
|
+
logoUrl: ((f = e.brand) == null ? void 0 : f.logoUrl) ?? null
|
|
89
|
+
},
|
|
90
|
+
models: e.models ?? [],
|
|
91
|
+
quickPrompts: e.quickPrompts ?? []
|
|
92
|
+
};
|
|
93
|
+
return e.appearance !== void 0 || e.theme !== void 0 ? e.appearance === null && e.theme === void 0 ? be(null) : be({
|
|
94
|
+
...e.appearance && typeof e.appearance == "object" ? e.appearance : {},
|
|
95
|
+
...e.theme ? { theme: e.theme } : {}
|
|
96
|
+
}) : Vt(e.endpoints.stream), {
|
|
97
|
+
client: n,
|
|
98
|
+
i18n: h,
|
|
99
|
+
config: c,
|
|
100
|
+
hostEmbed: !!e.hostEmbed,
|
|
101
|
+
fillHost: !!(e.fillHost ?? e.hostEmbed),
|
|
102
|
+
hideLauncher: !!e.hideLauncher,
|
|
103
|
+
beforeSend: e.beforeSend ?? null
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function vr({ children: e, ...n }) {
|
|
107
|
+
var i, h;
|
|
108
|
+
const a = D(() => jt(n), [
|
|
109
|
+
n.endpoints.stream,
|
|
110
|
+
n.endpoints.message,
|
|
111
|
+
n.endpoints.histories,
|
|
112
|
+
n.endpoints.documentsExtract,
|
|
113
|
+
n.protocolMode,
|
|
114
|
+
n.credentials,
|
|
115
|
+
n.locale,
|
|
116
|
+
n.theme,
|
|
117
|
+
n.hostEmbed,
|
|
118
|
+
n.fillHost,
|
|
119
|
+
n.hideLauncher,
|
|
120
|
+
(i = n.brand) == null ? void 0 : i.name,
|
|
121
|
+
(h = n.brand) == null ? void 0 : h.logoUrl,
|
|
122
|
+
n.appearance,
|
|
123
|
+
n.headers,
|
|
124
|
+
n.messages,
|
|
125
|
+
n.models,
|
|
126
|
+
n.quickPrompts,
|
|
127
|
+
n.beforeSend
|
|
128
|
+
]);
|
|
129
|
+
return ft($.Provider, { value: a }, e);
|
|
130
|
+
}
|
|
131
|
+
function xr() {
|
|
132
|
+
const e = ie($);
|
|
133
|
+
if (!e)
|
|
134
|
+
throw new Error("[sveda] SvedaProvider is missing. Wrap your tree in <SvedaProvider> first.");
|
|
135
|
+
return e.client;
|
|
136
|
+
}
|
|
137
|
+
function Wt() {
|
|
138
|
+
const e = ie($);
|
|
139
|
+
return (e == null ? void 0 : e.config) ?? Ut;
|
|
140
|
+
}
|
|
141
|
+
function we() {
|
|
142
|
+
const e = ie($);
|
|
143
|
+
if (!e)
|
|
144
|
+
throw new Error("[sveda] SvedaProvider is missing. Wrap your tree in <SvedaProvider> first.");
|
|
145
|
+
return e;
|
|
146
|
+
}
|
|
147
|
+
function O() {
|
|
148
|
+
const e = ie($);
|
|
149
|
+
return e ? (n, a) => e.i18n.t(n, a) : (n) => n;
|
|
150
|
+
}
|
|
151
|
+
const ke = {
|
|
152
|
+
sparkles: Ye,
|
|
153
|
+
"message-circle": Nt,
|
|
154
|
+
"message-square": We,
|
|
155
|
+
bot: yt,
|
|
156
|
+
"bot-message-square": St,
|
|
157
|
+
brain: wt,
|
|
158
|
+
zap: Ct,
|
|
159
|
+
star: xt,
|
|
160
|
+
heart: vt,
|
|
161
|
+
"circle-help": bt,
|
|
162
|
+
rocket: pt,
|
|
163
|
+
gem: gt
|
|
164
|
+
}, Yt = (e) => nt.includes(e) ? ke[e] : ke[at], u = Ue({ embedAuthEvent: Ot });
|
|
165
|
+
let Ae = !1, Xe = u.getState();
|
|
166
|
+
const Bt = (e) => u.subscribe(() => {
|
|
167
|
+
Xe = u.getState(), e();
|
|
168
|
+
}), _e = () => Xe;
|
|
169
|
+
function Kt() {
|
|
170
|
+
const { client: e } = we(), n = O(), a = xe(Bt, _e, _e), i = A(n);
|
|
171
|
+
i.current = n;
|
|
172
|
+
const h = P((r) => i.current(r), []);
|
|
173
|
+
F(() => {
|
|
174
|
+
u.setClient(e), u.setTranslate(h), Ae || (Ae = !0, u.initAuthListener(), u.loadHistories());
|
|
175
|
+
}, [e, h]);
|
|
176
|
+
const c = D(() => u.sortedHistories(), [a]), m = D(() => u.openChatTabs(), [a]), f = P(() => u.createNewChat(h), [h]), o = P(
|
|
177
|
+
(r) => u.setCurrentChat(r, h),
|
|
178
|
+
[h]
|
|
179
|
+
), g = P((r) => u.deleteChat(r, h), [h]), l = P(
|
|
180
|
+
(r) => u.closeChatTab(r, h),
|
|
181
|
+
[h]
|
|
182
|
+
), s = P(() => u.openChat(h), [h]);
|
|
183
|
+
return {
|
|
184
|
+
chatState: a.chatState,
|
|
185
|
+
currentChat: a.currentChat,
|
|
186
|
+
chatHistories: a.chatHistories,
|
|
187
|
+
sortedHistories: c,
|
|
188
|
+
openChatTabs: m,
|
|
189
|
+
isOpen: a.chatState.isOpen,
|
|
190
|
+
isMinimized: a.chatState.isMinimized,
|
|
191
|
+
isLoading: a.chatState.isLoading,
|
|
192
|
+
isLoadingChatHistory: a.chatState.isLoadingChatHistory,
|
|
193
|
+
hasCurrentChat: !!a.currentChat,
|
|
194
|
+
loadHistories: u.loadHistories.bind(u),
|
|
195
|
+
createNewChat: f,
|
|
196
|
+
setCurrentChat: o,
|
|
197
|
+
addMessage: u.addMessage.bind(u),
|
|
198
|
+
setChatTitle: u.setChatTitle.bind(u),
|
|
199
|
+
refreshChatTitleFromServer: u.refreshChatTitleFromServer.bind(u),
|
|
200
|
+
updateMessage: u.updateMessage.bind(u),
|
|
201
|
+
setChatMessages: u.setChatMessages.bind(u),
|
|
202
|
+
incrementChatTokens: u.incrementChatTokens.bind(u),
|
|
203
|
+
setChatContextWindowTokens: u.setChatContextWindowTokens.bind(u),
|
|
204
|
+
deleteChat: g,
|
|
205
|
+
renameChat: u.renameChat.bind(u),
|
|
206
|
+
closeChatTab: l,
|
|
207
|
+
openChat: s,
|
|
208
|
+
closeChat: u.closeChat.bind(u),
|
|
209
|
+
minimizeChat: u.minimizeChat.bind(u),
|
|
210
|
+
maximizeChat: u.maximizeChat.bind(u),
|
|
211
|
+
setLoading: u.setLoading.bind(u)
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
const ve = "sveda.chat-view-mode", me = "sveda.chat-fixed-width", Ge = "sveda.chat-dimensions", ue = "sveda-chat-fixed-mode", fe = "sveda-chat-immersive-mode", ne = "--sveda-chat-width", ge = "sveda-chat-fixed-resizing", ae = 384, se = 600, qt = 400, Xt = 768, De = (e, n, a) => Math.max(n, Math.min(a, e)), Le = () => {
|
|
215
|
+
if (typeof localStorage > "u")
|
|
216
|
+
return { width: ae, height: se };
|
|
217
|
+
try {
|
|
218
|
+
const e = localStorage.getItem(Ge);
|
|
219
|
+
if (!e)
|
|
220
|
+
return { width: ae, height: se };
|
|
221
|
+
const n = JSON.parse(e);
|
|
222
|
+
return {
|
|
223
|
+
width: De(Number(n.width) || ae, Ve, ot),
|
|
224
|
+
height: De(Number(n.height) || se, st, it)
|
|
225
|
+
};
|
|
226
|
+
} catch {
|
|
227
|
+
return { width: ae, height: se };
|
|
228
|
+
}
|
|
229
|
+
}, Gt = (e) => {
|
|
230
|
+
if (typeof localStorage > "u")
|
|
231
|
+
return e ? "floating" : "fixed";
|
|
232
|
+
const n = localStorage.getItem(ve);
|
|
233
|
+
return n === "floating" || n === "fixed" || n === "immersive" ? n : e ? "floating" : "fixed";
|
|
234
|
+
}, $t = (e, n) => {
|
|
235
|
+
if (typeof localStorage > "u")
|
|
236
|
+
return n;
|
|
237
|
+
const a = Number(localStorage.getItem(e));
|
|
238
|
+
return Number.isFinite(a) && a > 0 ? a : n;
|
|
239
|
+
};
|
|
240
|
+
function Zt(e, n, a) {
|
|
241
|
+
const [i, h] = E(() => Gt(n)), [c, m] = E(
|
|
242
|
+
() => n ? "floating" : "fixed"
|
|
243
|
+
), [f, o] = E(!1), [g, l] = E(() => Le().width), [s, r] = E(() => Le().height), [d, x] = E(() => $t(me, qt)), w = A({ chatWidth: g, chatHeight: s, fixedWidth: d, viewMode: i });
|
|
244
|
+
w.current = { chatWidth: g, chatHeight: s, fixedWidth: d, viewMode: i }, F(() => {
|
|
245
|
+
if (typeof window > "u" || typeof window.matchMedia != "function")
|
|
246
|
+
return;
|
|
247
|
+
const v = window.matchMedia("(max-width: 768px)"), T = () => o(n ? !1 : v.matches);
|
|
248
|
+
return T(), v.addEventListener("change", T), () => v.removeEventListener("change", T);
|
|
249
|
+
}, [n]), F(() => {
|
|
250
|
+
if (typeof document > "u")
|
|
251
|
+
return;
|
|
252
|
+
const v = document.body;
|
|
253
|
+
return v.classList.remove(ue, fe), document.documentElement.style.removeProperty(ne), v.style.removeProperty(ne), !e && !f && i === "fixed" && (v.classList.add(ue), v.style.setProperty(ne, `${d}px`)), !e && !f && i === "immersive" && v.classList.add(fe), () => {
|
|
254
|
+
v.classList.remove(ue, fe), v.style.removeProperty(ne);
|
|
255
|
+
};
|
|
256
|
+
}, [d, e, f, i]);
|
|
257
|
+
const C = (v) => {
|
|
258
|
+
localStorage.setItem(ve, v);
|
|
259
|
+
}, N = () => {
|
|
260
|
+
if (i === "immersive")
|
|
261
|
+
return;
|
|
262
|
+
const v = i === "floating" ? "fixed" : "floating";
|
|
263
|
+
h(v), m(v), C(v);
|
|
264
|
+
}, U = () => {
|
|
265
|
+
f || i === "immersive" || (m(i), h("immersive"), C("immersive"));
|
|
266
|
+
}, S = () => {
|
|
267
|
+
if (i !== "immersive")
|
|
268
|
+
return;
|
|
269
|
+
const v = c === "immersive" ? "fixed" : c;
|
|
270
|
+
h(v), C(v);
|
|
271
|
+
}, M = P((v, T) => {
|
|
272
|
+
T.preventDefault(), T.stopPropagation();
|
|
273
|
+
const J = T.currentTarget, q = T.pointerId;
|
|
274
|
+
try {
|
|
275
|
+
J.setPointerCapture(q);
|
|
276
|
+
} catch {
|
|
277
|
+
}
|
|
278
|
+
const _ = T.screenX, de = T.screenY, y = w.current.viewMode, j = y === "fixed" ? w.current.fixedWidth : w.current.chatWidth, W = w.current.chatHeight;
|
|
279
|
+
let L = j, Q = W, R = !1;
|
|
280
|
+
const X = () => {
|
|
281
|
+
window.removeEventListener("pointermove", ee), window.removeEventListener("pointerup", Y), window.removeEventListener("pointercancel", Y);
|
|
282
|
+
try {
|
|
283
|
+
J.releasePointerCapture(q);
|
|
284
|
+
} catch {
|
|
285
|
+
}
|
|
286
|
+
}, Y = () => {
|
|
287
|
+
R || (R = !0, document.body.classList.remove(ge), y === "floating" && localStorage.setItem(Ge, JSON.stringify({ width: L, height: Q })), y === "fixed" && localStorage.setItem(me, String(L)), X());
|
|
288
|
+
}, ee = (te) => {
|
|
289
|
+
if (R || te.pointerId !== q)
|
|
290
|
+
return;
|
|
291
|
+
const { deltaX: re, deltaY: ce } = lt(te, _, de);
|
|
292
|
+
if (y === "fixed" && v === "fixed-left") {
|
|
293
|
+
document.body.classList.add(ge);
|
|
294
|
+
const k = Math.max(Ve, window.innerWidth - Xt), H = dt(j, re, k);
|
|
295
|
+
L = H.width, x(H.width), H.enterImmersive && (m("fixed"), h("immersive"), localStorage.setItem(ve, "immersive"), localStorage.setItem(me, String(H.width)), R = !0, document.body.classList.remove(ge), X());
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
if (y === "floating") {
|
|
299
|
+
const k = ct(v, j, W, re, ce);
|
|
300
|
+
L = k.width, Q = k.height, l(k.width), r(k.height);
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
window.addEventListener("pointermove", ee), window.addEventListener("pointerup", Y), window.addEventListener("pointercancel", Y);
|
|
304
|
+
}, []), Z = !f && !e && i === "immersive", V = [
|
|
305
|
+
"sveda-chat flex flex-col",
|
|
306
|
+
a && !e ? "relative h-full min-h-0 w-full overflow-hidden" : "",
|
|
307
|
+
!a && e ? "fixed bottom-0 right-0 z-50 min-[1872px]:bottom-4 min-[1872px]:right-4" : "",
|
|
308
|
+
!a && !e && f ? "sveda-chat-surface fixed inset-0 z-50 pb-[env(safe-area-inset-bottom)] pt-[env(safe-area-inset-top)]" : "",
|
|
309
|
+
!a && !e && !f && i === "immersive" ? "sveda-chat-surface fixed right-0 top-0 z-50 h-[100dvh] pb-[env(safe-area-inset-bottom)] pt-[env(safe-area-inset-top)]" : "",
|
|
310
|
+
!a && !e && !f && i === "fixed" ? "sveda-chat-surface fixed right-0 top-0 z-50 h-screen pt-[env(safe-area-inset-top)]" : "",
|
|
311
|
+
!a && !e && !f && i === "floating" ? "fixed bottom-4 right-4 z-50" : "",
|
|
312
|
+
a || f || i === "fixed" || i === "immersive" ? "items-stretch" : "items-end gap-2"
|
|
313
|
+
].filter(Boolean).join(" "), z = a && !e ? { width: "100%", height: "100%" } : !f && !e && i === "immersive" ? { width: "100vw", height: "100dvh" } : !f && !e && i === "fixed" ? { width: "var(--sveda-chat-width)", height: "100dvh" } : void 0, K = f || a ? { width: "100%", height: "100%" } : i === "fixed" ? { width: "var(--sveda-chat-width)", height: "100%" } : i === "floating" ? { width: `${g}px`, height: `${s}px` } : { width: "100%", height: "100%" };
|
|
314
|
+
return {
|
|
315
|
+
isMobile: f,
|
|
316
|
+
viewMode: i,
|
|
317
|
+
fixedWidth: d,
|
|
318
|
+
setFixedWidth: x,
|
|
319
|
+
isImmersiveDesktop: Z,
|
|
320
|
+
chatShellClass: V,
|
|
321
|
+
chatShellStyle: z,
|
|
322
|
+
chatCardStyle: K,
|
|
323
|
+
chatWidth: g,
|
|
324
|
+
chatHeight: s,
|
|
325
|
+
startResize: M,
|
|
326
|
+
toggleViewMode: N,
|
|
327
|
+
enterImmersiveMode: U,
|
|
328
|
+
exitImmersiveMode: S
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
function Jt(e, n, a = {}) {
|
|
332
|
+
var w, C;
|
|
333
|
+
const i = O(), { client: h, beforeSend: c } = we(), m = A(e);
|
|
334
|
+
m.current = e;
|
|
335
|
+
const f = A(n);
|
|
336
|
+
f.current = n;
|
|
337
|
+
const o = A(a);
|
|
338
|
+
o.current = a;
|
|
339
|
+
const g = A(i);
|
|
340
|
+
g.current = i;
|
|
341
|
+
const l = D(() => ht(
|
|
342
|
+
h,
|
|
343
|
+
{
|
|
344
|
+
getCurrentChat: () => m.current.currentChat,
|
|
345
|
+
setChatMessages: (S, M) => m.current.setChatMessages(S, M),
|
|
346
|
+
setChatTitle: (S, M) => m.current.setChatTitle(S, M),
|
|
347
|
+
refreshChatTitleFromServer: (S) => m.current.refreshChatTitleFromServer(S),
|
|
348
|
+
incrementChatTokens: (S, M) => m.current.incrementChatTokens(S, M),
|
|
349
|
+
setChatContextWindowTokens: (S, M) => m.current.setChatContextWindowTokens(S, M)
|
|
350
|
+
},
|
|
351
|
+
(S) => f.current(S),
|
|
352
|
+
{
|
|
353
|
+
get newChatLabel() {
|
|
354
|
+
return o.current.newChatLabel;
|
|
355
|
+
},
|
|
356
|
+
get resolveSendOptions() {
|
|
357
|
+
return o.current.resolveSendOptions;
|
|
358
|
+
},
|
|
359
|
+
get onMaxStepsReached() {
|
|
360
|
+
return o.current.onMaxStepsReached;
|
|
361
|
+
},
|
|
362
|
+
get onToolProgress() {
|
|
363
|
+
return o.current.onToolProgress;
|
|
364
|
+
},
|
|
365
|
+
get onContextUsage() {
|
|
366
|
+
return o.current.onContextUsage;
|
|
367
|
+
},
|
|
368
|
+
get onError() {
|
|
369
|
+
return o.current.onError;
|
|
370
|
+
},
|
|
371
|
+
get onDone() {
|
|
372
|
+
return o.current.onDone;
|
|
373
|
+
},
|
|
374
|
+
translate: (S) => g.current(S),
|
|
375
|
+
beforeSend: c
|
|
376
|
+
}
|
|
377
|
+
), [h, c]), s = A(l.getState()), r = xe(
|
|
378
|
+
(N) => l.subscribe(() => {
|
|
379
|
+
s.current = l.getState(), N();
|
|
380
|
+
}),
|
|
381
|
+
() => s.current,
|
|
382
|
+
() => s.current
|
|
383
|
+
), d = A(() => {
|
|
384
|
+
});
|
|
385
|
+
F(() => (s.current = l.getState(), d.current = l.watchCurrentChatId(() => {
|
|
386
|
+
var N;
|
|
387
|
+
return (N = m.current.currentChat) == null ? void 0 : N.id;
|
|
388
|
+
}), () => {
|
|
389
|
+
l.dispose();
|
|
390
|
+
}), [l]), F(() => {
|
|
391
|
+
d.current();
|
|
392
|
+
}, [(w = e.currentChat) == null ? void 0 : w.id]);
|
|
393
|
+
const x = l.isStreamingFor((C = e.currentChat) == null ? void 0 : C.id);
|
|
394
|
+
return {
|
|
395
|
+
sendMessage: l.sendMessage.bind(l),
|
|
396
|
+
continueAfterMaxSteps: l.continueAfterMaxSteps.bind(l),
|
|
397
|
+
resolveToolConfirmation: l.resolveToolConfirmation.bind(l),
|
|
398
|
+
isStreaming: x,
|
|
399
|
+
isThinking: r.isThinking,
|
|
400
|
+
thinkingMessage: r.thinkingMessage,
|
|
401
|
+
stopStreaming: l.stopStreaming.bind(l),
|
|
402
|
+
streamingChatIds: r.streamingChatIds,
|
|
403
|
+
unreadChatIds: r.unreadChatIds,
|
|
404
|
+
clearChatUnread: l.clearChatUnread.bind(l)
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
function I(...e) {
|
|
408
|
+
return Pt(Ht(e));
|
|
409
|
+
}
|
|
410
|
+
const Qt = (e) => {
|
|
411
|
+
const n = new Date(Number(e) || Date.now()), a = /* @__PURE__ */ new Date(), i = new Date(n.getFullYear(), n.getMonth(), n.getDate()).getTime(), h = new Date(a.getFullYear(), a.getMonth(), a.getDate()).getTime();
|
|
412
|
+
return Math.max(0, Math.floor((h - i) / 864e5));
|
|
413
|
+
};
|
|
414
|
+
function er({
|
|
415
|
+
histories: e,
|
|
416
|
+
currentChatId: n = null,
|
|
417
|
+
onSelectChat: a,
|
|
418
|
+
onDeleteChat: i,
|
|
419
|
+
onRenameChat: h
|
|
420
|
+
}) {
|
|
421
|
+
const c = O(), [m, f] = E(""), o = (s) => {
|
|
422
|
+
var d;
|
|
423
|
+
if (typeof s.preview == "string" && s.preview.trim())
|
|
424
|
+
return s.preview.trim();
|
|
425
|
+
const r = (d = s.messages) == null ? void 0 : d.find((x) => x.role === "user");
|
|
426
|
+
return r ? je(r) : "";
|
|
427
|
+
}, g = D(() => {
|
|
428
|
+
const s = m.trim().toLowerCase();
|
|
429
|
+
return s ? e.filter((r) => {
|
|
430
|
+
const d = o(r);
|
|
431
|
+
return r.title.toLowerCase().includes(s) || d.toLowerCase().includes(s);
|
|
432
|
+
}) : e;
|
|
433
|
+
}, [e, m]), l = D(() => {
|
|
434
|
+
const s = [], r = /* @__PURE__ */ new Map();
|
|
435
|
+
for (const d of g) {
|
|
436
|
+
const x = Qt(d.updatedAt), w = x === 0 ? c("today") : x === 1 ? c("yesterday") : x === 2 ? c("dayBeforeYesterday") : c("daysAgo", { count: x }), C = r.get(w);
|
|
437
|
+
C === void 0 ? (r.set(w, s.length), s.push({ label: w, chats: [d] })) : s[C].chats.push(d);
|
|
438
|
+
}
|
|
439
|
+
return s;
|
|
440
|
+
}, [g, c]);
|
|
441
|
+
return /* @__PURE__ */ b("div", { className: "flex h-full min-h-0 w-full flex-col bg-background", children: [
|
|
442
|
+
/* @__PURE__ */ b("div", { className: "shrink-0 border-b border-border p-3", children: [
|
|
443
|
+
/* @__PURE__ */ t("div", { className: "mb-3 flex items-center justify-between", children: /* @__PURE__ */ t("p", { className: "text-sm font-semibold", children: c("chatHistory") }) }),
|
|
444
|
+
/* @__PURE__ */ b("div", { className: "flex h-10 items-center gap-2 rounded-[var(--sveda-radius)] border border-border bg-input px-3", children: [
|
|
445
|
+
/* @__PURE__ */ t(Mt, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
446
|
+
/* @__PURE__ */ t(
|
|
447
|
+
"input",
|
|
448
|
+
{
|
|
449
|
+
value: m,
|
|
450
|
+
type: "text",
|
|
451
|
+
autoComplete: "off",
|
|
452
|
+
placeholder: c("searchChats"),
|
|
453
|
+
className: "h-full min-w-0 flex-1 border-0 bg-transparent p-0 text-sm text-card-foreground outline-none placeholder:text-muted-foreground",
|
|
454
|
+
onChange: (s) => f(s.target.value)
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
] })
|
|
458
|
+
] }),
|
|
459
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-y-auto p-2", children: l.length === 0 ? /* @__PURE__ */ t("div", { className: "px-2 py-6 text-center text-sm text-muted-foreground", children: c("noChatsFound") }) : l.map((s) => /* @__PURE__ */ b("div", { className: "mb-3 last:mb-1", children: [
|
|
460
|
+
/* @__PURE__ */ t("p", { className: "px-2 pb-1 text-xs font-medium uppercase tracking-wide text-muted-foreground", children: s.label }),
|
|
461
|
+
s.chats.map((r) => /* @__PURE__ */ t(
|
|
462
|
+
"div",
|
|
463
|
+
{
|
|
464
|
+
role: "button",
|
|
465
|
+
tabIndex: 0,
|
|
466
|
+
className: I(
|
|
467
|
+
"group relative cursor-pointer px-2 py-2 transition-colors hover:bg-muted",
|
|
468
|
+
n === r.id ? "bg-primary/10" : ""
|
|
469
|
+
),
|
|
470
|
+
onClick: () => a(r.id),
|
|
471
|
+
onKeyDown: (d) => {
|
|
472
|
+
(d.key === "Enter" || d.key === " ") && (d.preventDefault(), a(r.id));
|
|
473
|
+
},
|
|
474
|
+
children: /* @__PURE__ */ b("div", { className: "flex items-start justify-between gap-2", children: [
|
|
475
|
+
/* @__PURE__ */ b("div", { className: "min-w-0 flex-1", children: [
|
|
476
|
+
/* @__PURE__ */ t("p", { className: "truncate text-sm font-medium", children: r.title }),
|
|
477
|
+
/* @__PURE__ */ t("p", { className: "truncate text-xs text-muted-foreground", children: o(r) })
|
|
478
|
+
] }),
|
|
479
|
+
/* @__PURE__ */ b("div", { className: "flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100", children: [
|
|
480
|
+
/* @__PURE__ */ t(
|
|
481
|
+
"button",
|
|
482
|
+
{
|
|
483
|
+
type: "button",
|
|
484
|
+
className: "inline-flex h-6 w-6 items-center justify-center",
|
|
485
|
+
"aria-label": c("renameChat"),
|
|
486
|
+
onClick: (d) => {
|
|
487
|
+
d.stopPropagation(), h(r.id);
|
|
488
|
+
},
|
|
489
|
+
children: /* @__PURE__ */ t(Tt, { className: "h-3 w-3" })
|
|
490
|
+
}
|
|
491
|
+
),
|
|
492
|
+
/* @__PURE__ */ t(
|
|
493
|
+
"button",
|
|
494
|
+
{
|
|
495
|
+
type: "button",
|
|
496
|
+
className: "inline-flex h-6 w-6 items-center justify-center",
|
|
497
|
+
"aria-label": c("delete"),
|
|
498
|
+
onClick: (d) => {
|
|
499
|
+
d.stopPropagation(), i(r.id);
|
|
500
|
+
},
|
|
501
|
+
children: /* @__PURE__ */ t(Et, { className: "h-3 w-3" })
|
|
502
|
+
}
|
|
503
|
+
)
|
|
504
|
+
] })
|
|
505
|
+
] })
|
|
506
|
+
},
|
|
507
|
+
r.id
|
|
508
|
+
))
|
|
509
|
+
] }, s.label)) })
|
|
510
|
+
] });
|
|
511
|
+
}
|
|
512
|
+
const tr = (e) => Array.isArray(e.parts) ? e.parts.filter((n) => n.type === "text" && typeof n.text == "string").map((n) => n.text).join("") : "";
|
|
513
|
+
function He({ messages: e, className: n }) {
|
|
514
|
+
return /* @__PURE__ */ t(
|
|
515
|
+
"div",
|
|
516
|
+
{
|
|
517
|
+
className: I("flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-4 py-3", n),
|
|
518
|
+
"data-testid": "sveda-message-list",
|
|
519
|
+
children: /* @__PURE__ */ t("div", { className: "mt-auto flex flex-col gap-3", children: e.map((a) => {
|
|
520
|
+
const i = a.role === "user", h = i ? je(a) : tr(a);
|
|
521
|
+
return h.trim() ? /* @__PURE__ */ t(
|
|
522
|
+
"div",
|
|
523
|
+
{
|
|
524
|
+
className: I(
|
|
525
|
+
"max-w-[90%] whitespace-pre-wrap break-words font-sans text-sm leading-relaxed",
|
|
526
|
+
i ? "ml-auto border border-border bg-secondary px-3 py-2 text-secondary-foreground" : "mr-auto text-foreground"
|
|
527
|
+
),
|
|
528
|
+
children: h
|
|
529
|
+
},
|
|
530
|
+
a.id
|
|
531
|
+
) : null;
|
|
532
|
+
}) })
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
function Pe({
|
|
537
|
+
value: e,
|
|
538
|
+
onChange: n,
|
|
539
|
+
onSend: a,
|
|
540
|
+
onStop: i,
|
|
541
|
+
isLoading: h = !1,
|
|
542
|
+
isStreaming: c = !1,
|
|
543
|
+
disabled: m = !1
|
|
544
|
+
}) {
|
|
545
|
+
const f = O(), o = A(null), g = m || h, l = e.trim().length > 0;
|
|
546
|
+
return F(() => {
|
|
547
|
+
const r = o.current;
|
|
548
|
+
if (!r)
|
|
549
|
+
return;
|
|
550
|
+
r.style.height = "60px";
|
|
551
|
+
const d = Math.min(Math.max(r.scrollHeight, 60), 250);
|
|
552
|
+
r.style.height = `${d}px`;
|
|
553
|
+
}, [e]), /* @__PURE__ */ t("div", { className: "flex flex-shrink-0 flex-col bg-background p-3", children: /* @__PURE__ */ b("div", { className: "sveda-chat-frame relative flex flex-col bg-background transition-colors", children: [
|
|
554
|
+
/* @__PURE__ */ t(
|
|
555
|
+
"textarea",
|
|
556
|
+
{
|
|
557
|
+
ref: o,
|
|
558
|
+
value: e,
|
|
559
|
+
onChange: (r) => n(r.target.value),
|
|
560
|
+
onKeyPress: (r) => {
|
|
561
|
+
r.key === "Enter" && !r.shiftKey && (r.preventDefault(), !g && l && !c && a());
|
|
562
|
+
},
|
|
563
|
+
placeholder: f("typeMessage"),
|
|
564
|
+
disabled: g,
|
|
565
|
+
className: "sveda-chat-input-textarea max-h-[250px] min-h-[60px] w-full resize-none border-0 bg-transparent p-3 font-sans text-sm text-foreground shadow-none !outline-none !ring-0 placeholder:font-mono placeholder:text-[11px] placeholder:tracking-[0.08em] placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0",
|
|
566
|
+
style: { height: 60, outline: "none", boxShadow: "none" },
|
|
567
|
+
"data-testid": "sveda-composer"
|
|
568
|
+
}
|
|
569
|
+
),
|
|
570
|
+
/* @__PURE__ */ b("div", { className: "flex items-center justify-between gap-2 border-t border-border/40 px-2 py-1.5", children: [
|
|
571
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1" }),
|
|
572
|
+
/* @__PURE__ */ t("div", { className: "flex items-center gap-1", children: c ? /* @__PURE__ */ t(
|
|
573
|
+
"button",
|
|
574
|
+
{
|
|
575
|
+
type: "button",
|
|
576
|
+
className: "inline-flex h-9 w-9 items-center justify-center text-muted-foreground hover:text-foreground",
|
|
577
|
+
onClick: i,
|
|
578
|
+
"aria-label": "Stop",
|
|
579
|
+
children: /* @__PURE__ */ t(It, { className: "h-4 w-4" })
|
|
580
|
+
}
|
|
581
|
+
) : /* @__PURE__ */ t(
|
|
582
|
+
"button",
|
|
583
|
+
{
|
|
584
|
+
type: "button",
|
|
585
|
+
className: I(
|
|
586
|
+
"inline-flex h-9 w-9 items-center justify-center text-muted-foreground hover:text-foreground",
|
|
587
|
+
g || !l ? "opacity-40" : ""
|
|
588
|
+
),
|
|
589
|
+
disabled: g || !l,
|
|
590
|
+
onClick: a,
|
|
591
|
+
"aria-label": "Send",
|
|
592
|
+
"data-testid": "sveda-send",
|
|
593
|
+
children: h ? /* @__PURE__ */ t(Be, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ t(kt, { className: "h-4 w-4" })
|
|
594
|
+
}
|
|
595
|
+
) })
|
|
596
|
+
] })
|
|
597
|
+
] }) });
|
|
598
|
+
}
|
|
599
|
+
function rr() {
|
|
600
|
+
return /* @__PURE__ */ b(Ce, { children: [
|
|
601
|
+
/* @__PURE__ */ t(
|
|
602
|
+
"span",
|
|
603
|
+
{
|
|
604
|
+
className: "pointer-events-none absolute -left-px -top-px z-10 h-2.5 w-2.5 border-l border-t border-foreground",
|
|
605
|
+
"aria-hidden": "true"
|
|
606
|
+
}
|
|
607
|
+
),
|
|
608
|
+
/* @__PURE__ */ t(
|
|
609
|
+
"span",
|
|
610
|
+
{
|
|
611
|
+
className: "pointer-events-none absolute -right-px -top-px z-10 h-2.5 w-2.5 border-r border-t border-foreground",
|
|
612
|
+
"aria-hidden": "true"
|
|
613
|
+
}
|
|
614
|
+
),
|
|
615
|
+
/* @__PURE__ */ t(
|
|
616
|
+
"span",
|
|
617
|
+
{
|
|
618
|
+
className: "pointer-events-none absolute -bottom-px -left-px z-10 h-2.5 w-2.5 border-b border-l border-foreground",
|
|
619
|
+
"aria-hidden": "true"
|
|
620
|
+
}
|
|
621
|
+
),
|
|
622
|
+
/* @__PURE__ */ t(
|
|
623
|
+
"span",
|
|
624
|
+
{
|
|
625
|
+
className: "pointer-events-none absolute -bottom-px -right-px z-10 h-2.5 w-2.5 border-b border-r border-foreground",
|
|
626
|
+
"aria-hidden": "true"
|
|
627
|
+
}
|
|
628
|
+
)
|
|
629
|
+
] });
|
|
630
|
+
}
|
|
631
|
+
const nr = "inline-flex h-auto min-w-0 items-center justify-center gap-2 rounded-none border border-primary bg-primary px-3.5 py-2 font-mono text-[11px] tracking-[0.14em] text-primary-foreground shadow-none transition-opacity hover:opacity-90 [&_svg]:!h-3.5 [&_svg]:!w-3.5";
|
|
632
|
+
function ar({
|
|
633
|
+
label: e,
|
|
634
|
+
icon: n = "sparkles",
|
|
635
|
+
logoSrc: a = "",
|
|
636
|
+
logoAlt: i = "",
|
|
637
|
+
onOpen: h
|
|
638
|
+
}) {
|
|
639
|
+
const c = Yt(n);
|
|
640
|
+
return /* @__PURE__ */ b("button", { type: "button", className: I(nr), onClick: h, "data-testid": "sveda-launcher", children: [
|
|
641
|
+
a ? /* @__PURE__ */ t(
|
|
642
|
+
"img",
|
|
643
|
+
{
|
|
644
|
+
src: a,
|
|
645
|
+
alt: i,
|
|
646
|
+
className: "h-6 w-6 flex-shrink-0 object-cover min-[1872px]:h-10 min-[1872px]:w-10"
|
|
647
|
+
}
|
|
648
|
+
) : /* @__PURE__ */ t(c, { className: "h-6 w-6 flex-shrink-0" }),
|
|
649
|
+
e ? /* @__PURE__ */ t("span", { className: "font-mono text-[11px] font-normal tracking-[0.14em]", children: e }) : null
|
|
650
|
+
] });
|
|
651
|
+
}
|
|
652
|
+
function sr({ isMobile: e, viewMode: n, onStartResize: a }) {
|
|
653
|
+
return e || n !== "fixed" && n !== "floating" ? null : n === "fixed" ? /* @__PURE__ */ t(
|
|
654
|
+
"div",
|
|
655
|
+
{
|
|
656
|
+
className: "absolute bottom-3 left-0 top-3 z-10 w-1 touch-none cursor-ew-resize hover:bg-primary/30",
|
|
657
|
+
role: "separator",
|
|
658
|
+
"aria-orientation": "vertical",
|
|
659
|
+
"aria-label": "Resize chat",
|
|
660
|
+
onPointerDown: (i) => a("fixed-left", i)
|
|
661
|
+
}
|
|
662
|
+
) : /* @__PURE__ */ b(Ce, { children: [
|
|
663
|
+
/* @__PURE__ */ t(
|
|
664
|
+
"div",
|
|
665
|
+
{
|
|
666
|
+
className: "absolute left-0 top-0 z-10 h-3 w-3 touch-none cursor-nw-resize rounded-br hover:bg-primary/20",
|
|
667
|
+
role: "separator",
|
|
668
|
+
"aria-label": "Resize chat",
|
|
669
|
+
onPointerDown: (i) => a("top-left", i)
|
|
670
|
+
}
|
|
671
|
+
),
|
|
672
|
+
/* @__PURE__ */ t(
|
|
673
|
+
"div",
|
|
674
|
+
{
|
|
675
|
+
className: "absolute left-3 right-3 top-0 z-10 h-1 touch-none cursor-n-resize hover:bg-primary/30",
|
|
676
|
+
role: "separator",
|
|
677
|
+
"aria-orientation": "horizontal",
|
|
678
|
+
"aria-label": "Resize chat height",
|
|
679
|
+
onPointerDown: (i) => a("top", i)
|
|
680
|
+
}
|
|
681
|
+
),
|
|
682
|
+
/* @__PURE__ */ t(
|
|
683
|
+
"div",
|
|
684
|
+
{
|
|
685
|
+
className: "absolute bottom-3 left-0 top-3 z-10 w-1 touch-none cursor-w-resize hover:bg-primary/30",
|
|
686
|
+
role: "separator",
|
|
687
|
+
"aria-orientation": "vertical",
|
|
688
|
+
"aria-label": "Resize chat width",
|
|
689
|
+
onPointerDown: (i) => a("left", i)
|
|
690
|
+
}
|
|
691
|
+
)
|
|
692
|
+
] });
|
|
693
|
+
}
|
|
694
|
+
function ze({
|
|
695
|
+
tabs: e,
|
|
696
|
+
currentChatId: n = null,
|
|
697
|
+
streamingChatIds: a = /* @__PURE__ */ new Set(),
|
|
698
|
+
unreadChatIds: i = /* @__PURE__ */ new Set(),
|
|
699
|
+
compact: h = !1,
|
|
700
|
+
onSelectChat: c,
|
|
701
|
+
onCloseTab: m,
|
|
702
|
+
onNewChat: f
|
|
703
|
+
}) {
|
|
704
|
+
const o = O(), g = D(() => e.filter((d) => d == null ? void 0 : d.id), [e]), l = D(() => mt(g, o), [g, o]);
|
|
705
|
+
if (g.length === 0)
|
|
706
|
+
return null;
|
|
707
|
+
const s = (d) => a.has(d), r = (d) => !s(d) && i.has(d);
|
|
708
|
+
return /* @__PURE__ */ b(
|
|
709
|
+
"div",
|
|
710
|
+
{
|
|
711
|
+
className: I(
|
|
712
|
+
"flex shrink-0 items-stretch border-b border-border bg-card",
|
|
713
|
+
h ? "px-3" : "px-4 md:px-6"
|
|
714
|
+
),
|
|
715
|
+
children: [
|
|
716
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ t("div", { className: "flex h-12 min-w-max items-end gap-px px-1", children: g.map((d) => /* @__PURE__ */ b(
|
|
717
|
+
"div",
|
|
718
|
+
{
|
|
719
|
+
role: "button",
|
|
720
|
+
tabIndex: 0,
|
|
721
|
+
className: I(
|
|
722
|
+
"inline-flex h-10 max-w-56 shrink-0 items-center gap-1.5 whitespace-nowrap border-b border-transparent px-3 py-2 font-mono text-[11px] tracking-[0.12em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none",
|
|
723
|
+
n === d.id ? "border-foreground bg-transparent text-foreground" : ""
|
|
724
|
+
),
|
|
725
|
+
onClick: () => c(d.id),
|
|
726
|
+
onKeyDown: (x) => {
|
|
727
|
+
(x.key === "Enter" || x.key === " ") && (x.preventDefault(), c(d.id));
|
|
728
|
+
},
|
|
729
|
+
children: [
|
|
730
|
+
s(d.id) ? /* @__PURE__ */ t(
|
|
731
|
+
Be,
|
|
732
|
+
{
|
|
733
|
+
className: "h-3.5 w-3.5 shrink-0 animate-spin text-primary",
|
|
734
|
+
"aria-label": o("chatTabRunning")
|
|
735
|
+
}
|
|
736
|
+
) : r(d.id) ? /* @__PURE__ */ t(
|
|
737
|
+
"span",
|
|
738
|
+
{
|
|
739
|
+
className: "h-2 w-2 shrink-0 rounded-full bg-primary",
|
|
740
|
+
"aria-label": o("chatTabUnread")
|
|
741
|
+
}
|
|
742
|
+
) : null,
|
|
743
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 truncate", children: l.get(d.id) }),
|
|
744
|
+
/* @__PURE__ */ t(
|
|
745
|
+
"button",
|
|
746
|
+
{
|
|
747
|
+
type: "button",
|
|
748
|
+
className: "ml-0.5 rounded-sm p-0.5 text-muted-foreground opacity-70 hover:bg-background/80 hover:text-foreground hover:opacity-100",
|
|
749
|
+
"aria-label": o("closeChatTab"),
|
|
750
|
+
onMouseDown: (x) => x.stopPropagation(),
|
|
751
|
+
onClick: (x) => {
|
|
752
|
+
x.stopPropagation(), m(d.id);
|
|
753
|
+
},
|
|
754
|
+
children: /* @__PURE__ */ t(Ke, { className: "h-3 w-3" })
|
|
755
|
+
}
|
|
756
|
+
)
|
|
757
|
+
]
|
|
758
|
+
},
|
|
759
|
+
d.id
|
|
760
|
+
)) }) }),
|
|
761
|
+
/* @__PURE__ */ t("div", { className: "flex shrink-0 items-center border-l border-border/40 pl-1", children: /* @__PURE__ */ t(
|
|
762
|
+
"button",
|
|
763
|
+
{
|
|
764
|
+
type: "button",
|
|
765
|
+
className: "inline-flex h-9 w-9 shrink-0 items-center justify-center text-muted-foreground hover:text-foreground",
|
|
766
|
+
"aria-label": o("newChat"),
|
|
767
|
+
onClick: f,
|
|
768
|
+
children: /* @__PURE__ */ t(qe, { className: "h-4 w-4" })
|
|
769
|
+
}
|
|
770
|
+
) })
|
|
771
|
+
]
|
|
772
|
+
}
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
const G = "inline-flex h-9 w-9 items-center justify-center bg-transparent text-muted-foreground hover:text-foreground";
|
|
776
|
+
function Re({
|
|
777
|
+
title: e,
|
|
778
|
+
isMobile: n,
|
|
779
|
+
viewMode: a,
|
|
780
|
+
isImmersiveDesktop: i,
|
|
781
|
+
showHistorySidebar: h,
|
|
782
|
+
viewModeFloatingLabel: c,
|
|
783
|
+
viewModeFixedLabel: m,
|
|
784
|
+
immersiveEnterLabel: f,
|
|
785
|
+
immersiveExitLabel: o,
|
|
786
|
+
immersiveBrandName: g = "",
|
|
787
|
+
immersiveBrandLogo: l = "",
|
|
788
|
+
onToggleHistory: s,
|
|
789
|
+
onEnterImmersive: r,
|
|
790
|
+
onExitImmersive: d,
|
|
791
|
+
onToggleViewMode: x,
|
|
792
|
+
onMinimize: w
|
|
793
|
+
}) {
|
|
794
|
+
const C = O(), N = I(
|
|
795
|
+
"flex h-12 shrink-0 flex-row items-center justify-between border-b border-border bg-card px-3",
|
|
796
|
+
a === "floating" && !n ? "rounded-t-[var(--sveda-radius)]" : "rounded-none"
|
|
797
|
+
);
|
|
798
|
+
return /* @__PURE__ */ b("header", { className: N, children: [
|
|
799
|
+
i ? /* @__PURE__ */ b("div", { className: "flex min-w-0 flex-1 items-center gap-4", children: [
|
|
800
|
+
/* @__PURE__ */ t("div", { className: "w-[min(20rem,33vw)] min-w-0", children: /* @__PURE__ */ b("div", { className: "flex items-center gap-2", children: [
|
|
801
|
+
l ? /* @__PURE__ */ t("img", { src: l, alt: g, className: "size-7 shrink-0 rounded" }) : /* @__PURE__ */ t(Ye, { className: "size-5 shrink-0 text-primary" }),
|
|
802
|
+
/* @__PURE__ */ t("span", { className: "truncate text-lg font-bold leading-none text-foreground", children: g })
|
|
803
|
+
] }) }),
|
|
804
|
+
/* @__PURE__ */ t("h2", { className: "min-w-0 flex-1 truncate text-left font-mono text-[11px] font-normal uppercase tracking-[0.14em] text-foreground", children: e })
|
|
805
|
+
] }) : /* @__PURE__ */ b("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: [
|
|
806
|
+
/* @__PURE__ */ t(
|
|
807
|
+
"button",
|
|
808
|
+
{
|
|
809
|
+
type: "button",
|
|
810
|
+
className: I(G, h ? "bg-muted/60 text-foreground" : ""),
|
|
811
|
+
"aria-label": C("chatHistory"),
|
|
812
|
+
title: C("chatHistory"),
|
|
813
|
+
onClick: s,
|
|
814
|
+
children: /* @__PURE__ */ t(At, { className: "h-4 w-4" })
|
|
815
|
+
}
|
|
816
|
+
),
|
|
817
|
+
/* @__PURE__ */ t("h2", { className: "min-w-0 flex-1 truncate text-left font-mono text-[11px] font-normal uppercase tracking-[0.14em] text-foreground", children: e })
|
|
818
|
+
] }),
|
|
819
|
+
/* @__PURE__ */ b("div", { className: "flex shrink-0 items-center gap-0.5", children: [
|
|
820
|
+
!n && a === "immersive" ? /* @__PURE__ */ t(
|
|
821
|
+
"button",
|
|
822
|
+
{
|
|
823
|
+
type: "button",
|
|
824
|
+
className: G,
|
|
825
|
+
"aria-label": o,
|
|
826
|
+
title: o,
|
|
827
|
+
onClick: d,
|
|
828
|
+
children: /* @__PURE__ */ t(_t, { className: "h-4 w-4" })
|
|
829
|
+
}
|
|
830
|
+
) : null,
|
|
831
|
+
!n && a !== "immersive" ? /* @__PURE__ */ t(
|
|
832
|
+
"button",
|
|
833
|
+
{
|
|
834
|
+
type: "button",
|
|
835
|
+
className: G,
|
|
836
|
+
"aria-label": f,
|
|
837
|
+
title: f,
|
|
838
|
+
onClick: r,
|
|
839
|
+
children: /* @__PURE__ */ t(Dt, { className: "h-4 w-4" })
|
|
840
|
+
}
|
|
841
|
+
) : null,
|
|
842
|
+
!n && a !== "immersive" ? /* @__PURE__ */ t(
|
|
843
|
+
"button",
|
|
844
|
+
{
|
|
845
|
+
type: "button",
|
|
846
|
+
className: G,
|
|
847
|
+
"aria-label": a === "floating" ? m : c,
|
|
848
|
+
title: a === "floating" ? m : c,
|
|
849
|
+
onClick: x,
|
|
850
|
+
children: a === "floating" ? /* @__PURE__ */ t(Lt, { className: "h-4 w-4" }) : /* @__PURE__ */ t(We, { className: "h-4 w-4" })
|
|
851
|
+
}
|
|
852
|
+
) : null,
|
|
853
|
+
/* @__PURE__ */ t(
|
|
854
|
+
"button",
|
|
855
|
+
{
|
|
856
|
+
type: "button",
|
|
857
|
+
className: G,
|
|
858
|
+
"aria-label": C("toolbarMinimize"),
|
|
859
|
+
title: C("toolbarMinimize"),
|
|
860
|
+
onClick: w,
|
|
861
|
+
children: /* @__PURE__ */ t(Ke, { className: "h-4 w-4" })
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
] })
|
|
865
|
+
] });
|
|
866
|
+
}
|
|
867
|
+
function Cr({
|
|
868
|
+
models: e,
|
|
869
|
+
quickPrompts: n,
|
|
870
|
+
brandName: a,
|
|
871
|
+
brandLogo: i,
|
|
872
|
+
pageUrl: h = "",
|
|
873
|
+
notify: c
|
|
874
|
+
}) {
|
|
875
|
+
var Se, ye, Ne, Me, Te, Ee;
|
|
876
|
+
const m = Wt(), { hideLauncher: f, fillHost: o, hostEmbed: g } = we(), l = O(), s = Kt(), r = Zt(s.isMinimized, g, o), [d, x] = E(""), [w, C] = E(!1), [N, U] = E(null), [S, M] = E(null), [Z, V] = E(""), z = xe(
|
|
877
|
+
Rt,
|
|
878
|
+
Ie,
|
|
879
|
+
Ie
|
|
880
|
+
), K = a ?? m.brand.name, v = i ?? m.brand.logoUrl ?? "", T = z.label.trim() !== "" ? z.label : K, J = z.image.trim() !== "" ? z.image : v, q = P((p) => {
|
|
881
|
+
}, []), _ = A(s);
|
|
882
|
+
_.current = s;
|
|
883
|
+
const de = D(
|
|
884
|
+
() => ({
|
|
885
|
+
get currentChat() {
|
|
886
|
+
return _.current.currentChat;
|
|
887
|
+
},
|
|
888
|
+
setChatMessages: (...p) => _.current.setChatMessages(...p),
|
|
889
|
+
setChatTitle: (...p) => _.current.setChatTitle(...p),
|
|
890
|
+
refreshChatTitleFromServer: (...p) => _.current.refreshChatTitleFromServer(...p),
|
|
891
|
+
incrementChatTokens: (...p) => _.current.incrementChatTokens(...p),
|
|
892
|
+
setChatContextWindowTokens: (...p) => _.current.setChatContextWindowTokens(...p)
|
|
893
|
+
}),
|
|
894
|
+
[]
|
|
895
|
+
), y = Jt(de, q, {
|
|
896
|
+
onError: (p, B) => {
|
|
897
|
+
const he = B instanceof Error ? B.message : l("errorSendingMessage");
|
|
898
|
+
c == null || c("error", he);
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
F(() => {
|
|
902
|
+
s.isMinimized || Ue().getState().currentChat || s.createNewChat();
|
|
903
|
+
}, [s.isMinimized, s.currentChat, s.createNewChat]);
|
|
904
|
+
const j = async () => {
|
|
905
|
+
const p = d.trim();
|
|
906
|
+
p && (x(""), await y.sendMessage(p, h ? { pageUrl: h } : void 0));
|
|
907
|
+
}, W = () => {
|
|
908
|
+
s.createNewChat(), r.isMobile && C(!1);
|
|
909
|
+
}, L = (p) => {
|
|
910
|
+
s.setCurrentChat(p), r.isMobile && C(!1);
|
|
911
|
+
}, Q = () => {
|
|
912
|
+
N && s.deleteChat(N), U(null);
|
|
913
|
+
}, R = () => {
|
|
914
|
+
const p = Z.trim();
|
|
915
|
+
S && p && s.renameChat(S, p), M(null), V("");
|
|
916
|
+
}, X = ((Se = s.currentChat) == null ? void 0 : Se.title) || l("chatTitle"), Y = I(
|
|
917
|
+
"sveda-chat-surface flex min-h-0 w-80 shrink-0 flex-col overflow-hidden bg-background",
|
|
918
|
+
r.isMobile ? "h-full max-w-[88vw] border-r border-border" : o ? "h-full border-r border-border" : r.viewMode === "fixed" ? "absolute right-full top-0 z-10 h-full border-r border-border" : "h-full rounded-[var(--sveda-radius)] border border-border"
|
|
919
|
+
), ee = r.isMobile || r.viewMode === "fixed" ? "relative flex h-full min-h-0 min-w-0 flex-1 flex-row" : o ? "relative flex h-full min-h-0 min-w-0 w-full flex-row items-stretch overflow-hidden" : "relative flex min-h-0 flex-row items-stretch gap-2", te = o ? { height: "100%", minHeight: 0 } : r.isMobile || r.viewMode !== "floating" ? void 0 : { height: `${r.chatHeight}px`, minHeight: 0 }, re = I(
|
|
920
|
+
"sveda-chat-surface relative flex min-h-0 flex-col overflow-visible",
|
|
921
|
+
r.viewMode === "floating" && !r.isMobile && !o && "sveda-chat-frame",
|
|
922
|
+
(o || r.isMobile) && "border-0",
|
|
923
|
+
r.isMobile && "h-full min-w-0 flex-1 rounded-none",
|
|
924
|
+
r.viewMode === "fixed" && !r.isMobile && "h-full min-w-0 flex-1 rounded-none border-b-0 border-l border-r-0 border-t-0 border-border",
|
|
925
|
+
r.viewMode === "floating" && "rounded-[var(--sveda-radius)]",
|
|
926
|
+
(r.isMobile || r.viewMode === "fixed") && "rounded-none",
|
|
927
|
+
r.viewMode === "floating" && !r.isMobile && !o && "min-w-0 shrink-0",
|
|
928
|
+
r.viewMode === "floating" && !r.isMobile && o && "h-full min-w-0 flex-1"
|
|
929
|
+
), ce = /* @__PURE__ */ b(Ce, { children: [
|
|
930
|
+
/* @__PURE__ */ t(
|
|
931
|
+
Re,
|
|
932
|
+
{
|
|
933
|
+
title: X,
|
|
934
|
+
isMobile: r.isMobile,
|
|
935
|
+
viewMode: r.viewMode,
|
|
936
|
+
isImmersiveDesktop: r.isImmersiveDesktop,
|
|
937
|
+
showHistorySidebar: w,
|
|
938
|
+
viewModeFloatingLabel: l("viewModeFloating"),
|
|
939
|
+
viewModeFixedLabel: l("viewModeFixed"),
|
|
940
|
+
immersiveEnterLabel: l("immersiveModeEnter"),
|
|
941
|
+
immersiveExitLabel: l("immersiveModeExit"),
|
|
942
|
+
immersiveBrandName: K,
|
|
943
|
+
immersiveBrandLogo: v,
|
|
944
|
+
onToggleHistory: () => C((p) => !p),
|
|
945
|
+
onEnterImmersive: r.enterImmersiveMode,
|
|
946
|
+
onExitImmersive: r.exitImmersiveMode,
|
|
947
|
+
onToggleViewMode: r.toggleViewMode,
|
|
948
|
+
onMinimize: () => s.minimizeChat()
|
|
949
|
+
}
|
|
950
|
+
),
|
|
951
|
+
/* @__PURE__ */ t(
|
|
952
|
+
ze,
|
|
953
|
+
{
|
|
954
|
+
tabs: s.openChatTabs,
|
|
955
|
+
currentChatId: (ye = s.currentChat) == null ? void 0 : ye.id,
|
|
956
|
+
streamingChatIds: y.streamingChatIds,
|
|
957
|
+
unreadChatIds: y.unreadChatIds,
|
|
958
|
+
compact: !0,
|
|
959
|
+
onSelectChat: L,
|
|
960
|
+
onCloseTab: (p) => {
|
|
961
|
+
s.closeChatTab(p);
|
|
962
|
+
},
|
|
963
|
+
onNewChat: W
|
|
964
|
+
}
|
|
965
|
+
),
|
|
966
|
+
/* @__PURE__ */ t(He, { messages: ((Ne = s.currentChat) == null ? void 0 : Ne.messages) ?? [] }),
|
|
967
|
+
/* @__PURE__ */ t(
|
|
968
|
+
Pe,
|
|
969
|
+
{
|
|
970
|
+
value: d,
|
|
971
|
+
onChange: x,
|
|
972
|
+
onSend: () => {
|
|
973
|
+
j();
|
|
974
|
+
},
|
|
975
|
+
onStop: () => y.stopStreaming(),
|
|
976
|
+
isLoading: s.isLoading || s.isLoadingChatHistory,
|
|
977
|
+
isStreaming: y.isStreaming
|
|
978
|
+
}
|
|
979
|
+
)
|
|
980
|
+
] }), k = /* @__PURE__ */ b(
|
|
981
|
+
"button",
|
|
982
|
+
{
|
|
983
|
+
type: "button",
|
|
984
|
+
className: "inline-flex w-full items-center justify-center gap-2 bg-primary px-3 py-2 font-mono text-[11px] tracking-[0.14em] text-primary-foreground",
|
|
985
|
+
onClick: W,
|
|
986
|
+
children: [
|
|
987
|
+
/* @__PURE__ */ t(qe, { className: "h-4 w-4" }),
|
|
988
|
+
l("newChat")
|
|
989
|
+
]
|
|
990
|
+
}
|
|
991
|
+
), H = /* @__PURE__ */ t(
|
|
992
|
+
er,
|
|
993
|
+
{
|
|
994
|
+
histories: s.sortedHistories,
|
|
995
|
+
currentChatId: (Me = s.currentChat) == null ? void 0 : Me.id,
|
|
996
|
+
onSelectChat: L,
|
|
997
|
+
onDeleteChat: (p) => U(p),
|
|
998
|
+
onRenameChat: (p) => {
|
|
999
|
+
const B = s.sortedHistories.find((he) => he.id === p);
|
|
1000
|
+
M(p), V((B == null ? void 0 : B.title) ?? "");
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
);
|
|
1004
|
+
return /* @__PURE__ */ b(
|
|
1005
|
+
"div",
|
|
1006
|
+
{
|
|
1007
|
+
className: r.chatShellClass,
|
|
1008
|
+
style: r.chatShellStyle,
|
|
1009
|
+
"data-testid": "sveda-chat",
|
|
1010
|
+
children: [
|
|
1011
|
+
s.isMinimized ? null : /* @__PURE__ */ t(
|
|
1012
|
+
"div",
|
|
1013
|
+
{
|
|
1014
|
+
className: r.isMobile || r.viewMode === "fixed" || o ? "flex h-full min-h-0 w-full min-w-0 flex-1" : r.viewMode === "immersive" ? "flex h-full min-h-0 w-full min-w-0 flex-1 flex-col" : "flex gap-2",
|
|
1015
|
+
children: r.isImmersiveDesktop ? /* @__PURE__ */ b("div", { className: "sveda-chat-surface flex h-full min-h-0 w-full flex-1 flex-col", children: [
|
|
1016
|
+
/* @__PURE__ */ t(
|
|
1017
|
+
Re,
|
|
1018
|
+
{
|
|
1019
|
+
title: X,
|
|
1020
|
+
isMobile: r.isMobile,
|
|
1021
|
+
viewMode: r.viewMode,
|
|
1022
|
+
isImmersiveDesktop: !0,
|
|
1023
|
+
showHistorySidebar: w,
|
|
1024
|
+
viewModeFloatingLabel: l("viewModeFloating"),
|
|
1025
|
+
viewModeFixedLabel: l("viewModeFixed"),
|
|
1026
|
+
immersiveEnterLabel: l("immersiveModeEnter"),
|
|
1027
|
+
immersiveExitLabel: l("immersiveModeExit"),
|
|
1028
|
+
immersiveBrandName: K,
|
|
1029
|
+
immersiveBrandLogo: v,
|
|
1030
|
+
onToggleHistory: () => C((p) => !p),
|
|
1031
|
+
onEnterImmersive: r.enterImmersiveMode,
|
|
1032
|
+
onExitImmersive: r.exitImmersiveMode,
|
|
1033
|
+
onToggleViewMode: r.toggleViewMode,
|
|
1034
|
+
onMinimize: () => s.minimizeChat()
|
|
1035
|
+
}
|
|
1036
|
+
),
|
|
1037
|
+
/* @__PURE__ */ b("div", { className: "flex min-h-0 flex-1 flex-row", children: [
|
|
1038
|
+
/* @__PURE__ */ b("aside", { className: "sveda-chat-surface flex w-[min(20rem,33vw)] shrink-0 flex-col border-r border-border", children: [
|
|
1039
|
+
/* @__PURE__ */ t("div", { className: "border-b border-border/50 p-3", children: k }),
|
|
1040
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: H })
|
|
1041
|
+
] }),
|
|
1042
|
+
/* @__PURE__ */ b("div", { className: "sveda-chat-surface flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden", children: [
|
|
1043
|
+
/* @__PURE__ */ t(
|
|
1044
|
+
ze,
|
|
1045
|
+
{
|
|
1046
|
+
tabs: s.openChatTabs,
|
|
1047
|
+
currentChatId: (Te = s.currentChat) == null ? void 0 : Te.id,
|
|
1048
|
+
streamingChatIds: y.streamingChatIds,
|
|
1049
|
+
unreadChatIds: y.unreadChatIds,
|
|
1050
|
+
onSelectChat: L,
|
|
1051
|
+
onCloseTab: (p) => {
|
|
1052
|
+
s.closeChatTab(p);
|
|
1053
|
+
},
|
|
1054
|
+
onNewChat: W
|
|
1055
|
+
}
|
|
1056
|
+
),
|
|
1057
|
+
/* @__PURE__ */ b("div", { className: "mx-auto flex min-h-0 w-full max-w-7xl flex-1 flex-col overflow-hidden px-4 md:px-6", children: [
|
|
1058
|
+
/* @__PURE__ */ t(He, { messages: ((Ee = s.currentChat) == null ? void 0 : Ee.messages) ?? [] }),
|
|
1059
|
+
/* @__PURE__ */ t(
|
|
1060
|
+
Pe,
|
|
1061
|
+
{
|
|
1062
|
+
value: d,
|
|
1063
|
+
onChange: x,
|
|
1064
|
+
onSend: () => {
|
|
1065
|
+
j();
|
|
1066
|
+
},
|
|
1067
|
+
onStop: () => y.stopStreaming(),
|
|
1068
|
+
isLoading: s.isLoading || s.isLoadingChatHistory,
|
|
1069
|
+
isStreaming: y.isStreaming
|
|
1070
|
+
}
|
|
1071
|
+
)
|
|
1072
|
+
] })
|
|
1073
|
+
] })
|
|
1074
|
+
] })
|
|
1075
|
+
] }) : /* @__PURE__ */ b("div", { className: ee, style: te, children: [
|
|
1076
|
+
w && !r.isMobile ? /* @__PURE__ */ b("aside", { className: Y, children: [
|
|
1077
|
+
/* @__PURE__ */ t("div", { className: "border-b border-border/50 p-3", children: k }),
|
|
1078
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: H })
|
|
1079
|
+
] }) : null,
|
|
1080
|
+
/* @__PURE__ */ b("div", { className: re, style: r.chatCardStyle, children: [
|
|
1081
|
+
/* @__PURE__ */ t("div", { className: "sveda-chat-surface relative flex flex-1 flex-col overflow-hidden p-0", children: /* @__PURE__ */ t("div", { className: "flex min-h-0 flex-1 flex-col", children: ce }) }),
|
|
1082
|
+
r.viewMode === "floating" && !r.isMobile && !o ? /* @__PURE__ */ t(rr, {}) : null,
|
|
1083
|
+
/* @__PURE__ */ t(
|
|
1084
|
+
sr,
|
|
1085
|
+
{
|
|
1086
|
+
isMobile: r.isMobile,
|
|
1087
|
+
viewMode: r.viewMode,
|
|
1088
|
+
onStartResize: r.startResize
|
|
1089
|
+
}
|
|
1090
|
+
)
|
|
1091
|
+
] })
|
|
1092
|
+
] })
|
|
1093
|
+
}
|
|
1094
|
+
),
|
|
1095
|
+
r.isMobile && w && !s.isMinimized ? /* @__PURE__ */ t("div", { className: "fixed inset-0 z-[60] flex bg-black/40", onClick: () => C(!1), children: /* @__PURE__ */ b(
|
|
1096
|
+
"aside",
|
|
1097
|
+
{
|
|
1098
|
+
className: "sveda-chat-surface flex h-full w-80 max-w-[88vw] flex-col bg-background",
|
|
1099
|
+
onClick: (p) => p.stopPropagation(),
|
|
1100
|
+
children: [
|
|
1101
|
+
/* @__PURE__ */ t("div", { className: "border-b border-border/50 p-3", children: k }),
|
|
1102
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1", children: H })
|
|
1103
|
+
]
|
|
1104
|
+
}
|
|
1105
|
+
) }) : null,
|
|
1106
|
+
s.isMinimized && !r.isMobile && !f ? /* @__PURE__ */ t(
|
|
1107
|
+
ar,
|
|
1108
|
+
{
|
|
1109
|
+
label: T,
|
|
1110
|
+
icon: z.icon,
|
|
1111
|
+
logoSrc: J,
|
|
1112
|
+
logoAlt: l("assistantLogoAlt"),
|
|
1113
|
+
onOpen: () => {
|
|
1114
|
+
s.openChat();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
) : null,
|
|
1118
|
+
N ? /* @__PURE__ */ t("div", { className: "fixed inset-0 z-[70] flex items-center justify-center bg-black/40 p-4", role: "dialog", "aria-modal": "true", children: /* @__PURE__ */ b("div", { className: "w-full max-w-sm border border-border bg-card p-4 text-card-foreground shadow-lg", children: [
|
|
1119
|
+
/* @__PURE__ */ t("h3", { className: "text-base font-semibold", children: l("commonDelete") }),
|
|
1120
|
+
/* @__PURE__ */ t("p", { className: "mt-2 text-sm text-muted-foreground", children: l("confirmDeleteChat") }),
|
|
1121
|
+
/* @__PURE__ */ b("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
1122
|
+
/* @__PURE__ */ t(
|
|
1123
|
+
"button",
|
|
1124
|
+
{
|
|
1125
|
+
type: "button",
|
|
1126
|
+
className: "border border-border px-3 py-2 text-sm",
|
|
1127
|
+
onClick: () => U(null),
|
|
1128
|
+
children: l("commonCancel")
|
|
1129
|
+
}
|
|
1130
|
+
),
|
|
1131
|
+
/* @__PURE__ */ t("button", { type: "button", className: "bg-primary px-3 py-2 text-sm text-primary-foreground", onClick: Q, children: l("commonDelete") })
|
|
1132
|
+
] })
|
|
1133
|
+
] }) }) : null,
|
|
1134
|
+
S ? /* @__PURE__ */ t("div", { className: "fixed inset-0 z-[70] flex items-center justify-center bg-black/40 p-4", role: "dialog", "aria-modal": "true", children: /* @__PURE__ */ b("div", { className: "w-full max-w-sm border border-border bg-card p-4 text-card-foreground shadow-lg", children: [
|
|
1135
|
+
/* @__PURE__ */ t("h3", { className: "text-base font-semibold", children: l("renameChat") }),
|
|
1136
|
+
/* @__PURE__ */ t(
|
|
1137
|
+
"input",
|
|
1138
|
+
{
|
|
1139
|
+
value: Z,
|
|
1140
|
+
placeholder: l("renameChatPlaceholder"),
|
|
1141
|
+
className: "mt-3 h-10 w-full border border-input bg-input px-3 text-sm outline-none",
|
|
1142
|
+
onChange: (p) => V(p.target.value),
|
|
1143
|
+
onKeyDown: (p) => {
|
|
1144
|
+
p.key === "Enter" && R();
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
),
|
|
1148
|
+
/* @__PURE__ */ b("div", { className: "mt-4 flex justify-end gap-2", children: [
|
|
1149
|
+
/* @__PURE__ */ t(
|
|
1150
|
+
"button",
|
|
1151
|
+
{
|
|
1152
|
+
type: "button",
|
|
1153
|
+
className: "border border-border px-3 py-2 text-sm",
|
|
1154
|
+
onClick: () => {
|
|
1155
|
+
M(null), V("");
|
|
1156
|
+
},
|
|
1157
|
+
children: l("commonCancel")
|
|
1158
|
+
}
|
|
1159
|
+
),
|
|
1160
|
+
/* @__PURE__ */ t("button", { type: "button", className: "bg-primary px-3 py-2 text-sm text-primary-foreground", onClick: R, children: l("commonSave") })
|
|
1161
|
+
] })
|
|
1162
|
+
] }) }) : null
|
|
1163
|
+
]
|
|
1164
|
+
}
|
|
1165
|
+
);
|
|
1166
|
+
}
|
|
1167
|
+
const wr = "0.3.1";
|
|
1168
|
+
export {
|
|
1169
|
+
He as ChatMessageList,
|
|
1170
|
+
Ut as DEFAULT_CONFIG,
|
|
1171
|
+
Mr as SVEDA_APPEARANCE_PRESETS,
|
|
1172
|
+
Tr as SVEDA_APPEARANCE_PRESET_IDS,
|
|
1173
|
+
Er as SVEDA_APPEARANCE_STYLE_ID,
|
|
1174
|
+
Ir as SVEDA_CHAT_MINIMIZED_STORAGE_KEY,
|
|
1175
|
+
kr as SVEDA_DEFAULT_LAUNCHER_ICON,
|
|
1176
|
+
Ot as SVEDA_EMBED_AUTH_EVENT,
|
|
1177
|
+
Ar as SVEDA_LAUNCHER_ICON_IDS,
|
|
1178
|
+
_r as SVEDA_LAUNCHER_IMAGE_MAX_BYTES,
|
|
1179
|
+
Dr as SVEDA_LAUNCHER_IMAGE_MAX_CHARS,
|
|
1180
|
+
wr as SVEDA_REACT_VERSION,
|
|
1181
|
+
Lr as SVEDA_TOKEN_KEYS,
|
|
1182
|
+
Cr as SvedaChat,
|
|
1183
|
+
Pe as SvedaComposer,
|
|
1184
|
+
$ as SvedaContext,
|
|
1185
|
+
ar as SvedaMinimizedTrigger,
|
|
1186
|
+
vr as SvedaProvider,
|
|
1187
|
+
ze as SvedaTabs,
|
|
1188
|
+
Re as SvedaToolbar,
|
|
1189
|
+
be as applySvedaAppearance,
|
|
1190
|
+
Hr as buildAppearanceCss,
|
|
1191
|
+
Pr as buildChatTabTitleMap,
|
|
1192
|
+
zr as chatComponentI18nKeys,
|
|
1193
|
+
jt as createSvedaContextValue,
|
|
1194
|
+
Ft as createSvedaI18n,
|
|
1195
|
+
Rr as deriveProvisionalChatTitle,
|
|
1196
|
+
Fr as enMessages,
|
|
1197
|
+
Or as finalizeMessagesForDisplay,
|
|
1198
|
+
Ur as formatRadiusPx,
|
|
1199
|
+
ur as getSvedaChromeSnapshot,
|
|
1200
|
+
Ie as getSvedaLauncherSnapshot,
|
|
1201
|
+
Vr as getSvedaModelDisplayName,
|
|
1202
|
+
jr as getUserMessageAttachmentNames,
|
|
1203
|
+
Wr as getUserMessageText,
|
|
1204
|
+
Yr as hexToHsl,
|
|
1205
|
+
Br as hslToHex,
|
|
1206
|
+
Kr as humanizeModelId,
|
|
1207
|
+
qr as isChatTitlePlaceholder,
|
|
1208
|
+
Xr as isNewChatPlaceholder,
|
|
1209
|
+
Gr as isPersistedSessionChatOpen,
|
|
1210
|
+
$r as isSvedaAppearanceProvided,
|
|
1211
|
+
Zr as isSvedaHsl,
|
|
1212
|
+
Jr as mergeSvedaAppearance,
|
|
1213
|
+
Qr as parseRadiusPx,
|
|
1214
|
+
en as readPersistedMinimized,
|
|
1215
|
+
tn as readPersistedMinimizedPreference,
|
|
1216
|
+
rn as resolveSvedaAppearance,
|
|
1217
|
+
nn as ruMessages,
|
|
1218
|
+
an as sanitizeSvedaChrome,
|
|
1219
|
+
sn as sanitizeSvedaLauncher,
|
|
1220
|
+
on as sanitizeSvedaLauncherImage,
|
|
1221
|
+
ln as sanitizeSvedaRadius,
|
|
1222
|
+
dn as sanitizeSvedaTheme,
|
|
1223
|
+
Rt as subscribeSvedaAppearance,
|
|
1224
|
+
br as svedaChrome,
|
|
1225
|
+
pr as svedaLauncher,
|
|
1226
|
+
Yt as svedaLauncherIconComponent,
|
|
1227
|
+
ke as svedaLauncherIconMap,
|
|
1228
|
+
Kt as useSvedaChat,
|
|
1229
|
+
gr as useSvedaChrome,
|
|
1230
|
+
xr as useSvedaClient,
|
|
1231
|
+
Wt as useSvedaConfig,
|
|
1232
|
+
we as useSvedaContext,
|
|
1233
|
+
fr as useSvedaLauncher,
|
|
1234
|
+
Jt as useSvedaStreaming,
|
|
1235
|
+
O as useSvedaT,
|
|
1236
|
+
cn as userMessageHasVisibleContent,
|
|
1237
|
+
hn as writePersistedMinimized
|
|
1238
|
+
};
|