vpschatbotwidget 1.0.3 → 1.2.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-lib/types/App.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-api.d.ts +14 -3
- package/dist-lib/types/chatbot/api/chatbot-api.test.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-types.d.ts +35 -0
- package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +8 -0
- package/dist-lib/types/chatbot/core/ChatContext.d.ts +6 -1
- package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +3 -2
- package/dist-lib/types/chatbot/core/ChatProvider.d.ts +15 -1
- package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +1 -0
- package/dist-lib/types/chatbot/core/GroundedSources.d.ts +14 -0
- package/dist-lib/types/chatbot/core/grounding.test.d.ts +1 -0
- package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +14 -1
- package/dist-lib/types/chatbot/index.d.ts +1 -1
- package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +14 -1
- package/dist-lib/vps-chatbot.cjs +53 -20
- package/dist-lib/vps-chatbot.js +1552 -980
- package/package.json +1 -1
- package/src/chatbot/api/chatbot-api.test.ts +48 -0
- package/src/chatbot/api/chatbot-api.ts +199 -5
- package/src/chatbot/api/chatbot-types.ts +39 -0
- package/src/chatbot/chatbot.test.tsx +24 -1
- package/src/chatbot/core/AgentReasoning.tsx +65 -0
- package/src/chatbot/core/ChatContext.tsx +6 -0
- package/src/chatbot/core/ChatInput.tsx +14 -1
- package/src/chatbot/core/ChatMarkdown.tsx +288 -54
- package/src/chatbot/core/ChatMessage.tsx +53 -45
- package/src/chatbot/core/ChatMessageList.tsx +1 -1
- package/src/chatbot/core/ChatProvider.tsx +184 -28
- package/src/chatbot/core/ChatTypingIndicator.tsx +11 -5
- package/src/chatbot/core/GroundedSources.tsx +179 -0
- package/src/chatbot/core/grounding.test.tsx +21 -0
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +36 -4
- package/src/chatbot/index.ts +3 -0
- package/src/chatbot/widget/ChatbotWidget.tsx +36 -4
- package/src/index.css +927 -68
package/dist-lib/vps-chatbot.js
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
import { jsx as l, jsxs as w, Fragment as De } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import oe, { createContext as Et, useContext as it, useMemo as ye, useState as U, useRef as re, useCallback as ue, forwardRef as ct, createElement as He, useEffect as ke } from "react";
|
|
4
|
+
const Rt = {};
|
|
5
|
+
function ve(e) {
|
|
6
6
|
return e != null && e.trim() !== "" ? e.trim().replace(/\/+$/, "") : String("").trim().replace(/\/+$/, "");
|
|
7
7
|
}
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
8
|
+
function Pe(e, t) {
|
|
9
|
+
const n = ve(e);
|
|
10
|
+
if (!n)
|
|
11
11
|
return t;
|
|
12
|
-
if (
|
|
13
|
-
return `${
|
|
14
|
-
if (
|
|
15
|
-
const s =
|
|
12
|
+
if (n.endsWith("/api") && t.startsWith("/api/"))
|
|
13
|
+
return `${n}${t.slice(4)}`;
|
|
14
|
+
if (n.endsWith("/api") && t === "/health") {
|
|
15
|
+
const s = n.slice(0, -4);
|
|
16
16
|
return s ? `${s}/health` : "/health";
|
|
17
17
|
}
|
|
18
|
-
const
|
|
19
|
-
return `${
|
|
18
|
+
const r = t.startsWith("/") ? t : `/${t}`;
|
|
19
|
+
return `${n}${r}`;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function Xe(e) {
|
|
22
22
|
return e && typeof e == "object" && "data" in e && e.success !== !1 ? e.data : e;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
var
|
|
26
|
-
const
|
|
27
|
-
return s && !
|
|
28
|
-
code: (a =
|
|
24
|
+
function Ze(e, t, n) {
|
|
25
|
+
var o, a, i;
|
|
26
|
+
const r = e, s = (o = r == null ? void 0 : r.error) == null ? void 0 : o.message;
|
|
27
|
+
return s && !At(s) ? {
|
|
28
|
+
code: (a = r == null ? void 0 : r.error) == null ? void 0 : a.code,
|
|
29
29
|
message: s,
|
|
30
|
-
requestId: (i =
|
|
31
|
-
} :
|
|
30
|
+
requestId: (i = r == null ? void 0 : r.error) == null ? void 0 : i.request_id
|
|
31
|
+
} : n >= 500 ? { message: "I couldn't process that request right now." } : n === 0 ? { message: "Something went wrong while connecting. Please try again." } : { message: t };
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function At(e) {
|
|
34
34
|
return /traceback|sql|exception|stack|api[_ ]?key|password/i.test(e);
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function xe(e) {
|
|
37
37
|
return {
|
|
38
38
|
chunkId: e.chunk_id,
|
|
39
39
|
source: e.source,
|
|
40
|
-
score: e.score
|
|
40
|
+
score: e.score,
|
|
41
|
+
title: e.title,
|
|
42
|
+
snippet: e.snippet
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
|
-
function
|
|
45
|
+
function Le(e) {
|
|
44
46
|
return {
|
|
45
47
|
toolName: e.tool_name,
|
|
46
48
|
arguments: e.arguments ?? {},
|
|
47
49
|
result: e.result ?? {}
|
|
48
50
|
};
|
|
49
51
|
}
|
|
50
|
-
function
|
|
52
|
+
function qe(e) {
|
|
51
53
|
return {
|
|
52
54
|
model: e.model,
|
|
53
55
|
promptTokens: e.prompt_tokens,
|
|
@@ -55,7 +57,7 @@ function Tt(e) {
|
|
|
55
57
|
totalTokens: e.total_tokens
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
|
-
function
|
|
60
|
+
function Nt(e) {
|
|
59
61
|
const t = e.role === "user" || e.role === "system" ? e.role : "assistant";
|
|
60
62
|
return {
|
|
61
63
|
id: String(e.id),
|
|
@@ -71,7 +73,7 @@ function Rt(e) {
|
|
|
71
73
|
} : void 0
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
|
-
async function
|
|
76
|
+
async function Oe(e) {
|
|
75
77
|
const t = await e.text();
|
|
76
78
|
if (!t) return {};
|
|
77
79
|
try {
|
|
@@ -80,13 +82,13 @@ async function At(e) {
|
|
|
80
82
|
return {};
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
function
|
|
84
|
-
const t =
|
|
85
|
-
async function r
|
|
86
|
-
let
|
|
87
|
-
const a =
|
|
85
|
+
function ut(e) {
|
|
86
|
+
const t = ve(e);
|
|
87
|
+
async function n(r, s) {
|
|
88
|
+
let o;
|
|
89
|
+
const a = Pe(t, r);
|
|
88
90
|
try {
|
|
89
|
-
|
|
91
|
+
o = await fetch(a, {
|
|
90
92
|
...s,
|
|
91
93
|
headers: {
|
|
92
94
|
"Content-Type": "application/json",
|
|
@@ -96,55 +98,170 @@ function tt(e) {
|
|
|
96
98
|
} catch {
|
|
97
99
|
throw { message: "Something went wrong while connecting. Please try again." };
|
|
98
100
|
}
|
|
99
|
-
if (
|
|
101
|
+
if (o.status === 204)
|
|
100
102
|
return;
|
|
101
|
-
const i = await
|
|
102
|
-
if (!
|
|
103
|
-
throw
|
|
103
|
+
const i = await Oe(o);
|
|
104
|
+
if (!o.ok)
|
|
105
|
+
throw Ze(
|
|
104
106
|
i,
|
|
105
107
|
"I couldn't process that request right now.",
|
|
106
|
-
|
|
108
|
+
o.status
|
|
107
109
|
);
|
|
108
|
-
return
|
|
110
|
+
return Xe(i);
|
|
109
111
|
}
|
|
110
112
|
return {
|
|
111
113
|
apiBaseUrl: t,
|
|
112
|
-
async
|
|
113
|
-
|
|
114
|
+
async listModels() {
|
|
115
|
+
try {
|
|
116
|
+
const r = await n("/api/v1/models");
|
|
117
|
+
return { defaultModelId: r.default_model_id, complexModelId: r.complex_model_id, models: r.models || [] };
|
|
118
|
+
} catch {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
async createSession(r) {
|
|
123
|
+
const s = await n("/api/v1/sessions", {
|
|
114
124
|
method: "POST",
|
|
125
|
+
signal: r,
|
|
115
126
|
body: JSON.stringify({})
|
|
116
127
|
});
|
|
117
|
-
return { sessionId:
|
|
128
|
+
return { sessionId: s.session_id, createdAt: s.created_at };
|
|
118
129
|
},
|
|
119
|
-
async sendMessage(
|
|
120
|
-
const
|
|
121
|
-
`/api/v1/sessions/${
|
|
130
|
+
async sendMessage(r, s, o, a) {
|
|
131
|
+
const i = await n(
|
|
132
|
+
`/api/v1/sessions/${r}/messages`,
|
|
122
133
|
{
|
|
123
134
|
method: "POST",
|
|
124
|
-
|
|
135
|
+
signal: a,
|
|
136
|
+
body: JSON.stringify({
|
|
137
|
+
message: s,
|
|
138
|
+
...(o == null ? void 0 : o.roleId) !== void 0 ? { role_id: o.roleId } : {},
|
|
139
|
+
...o != null && o.client ? { client: o.client } : {},
|
|
140
|
+
...o != null && o.modelId ? { model_id: o.modelId } : {}
|
|
141
|
+
})
|
|
125
142
|
}
|
|
126
143
|
);
|
|
127
144
|
return {
|
|
128
|
-
requestId:
|
|
129
|
-
sessionId:
|
|
130
|
-
answer:
|
|
131
|
-
sources: (
|
|
132
|
-
toolCalls: (
|
|
133
|
-
usage:
|
|
145
|
+
requestId: i.request_id,
|
|
146
|
+
sessionId: i.session_id,
|
|
147
|
+
answer: i.answer,
|
|
148
|
+
sources: (i.sources || []).map(xe),
|
|
149
|
+
toolCalls: (i.tool_calls || []).map(Le),
|
|
150
|
+
usage: qe(i.usage),
|
|
151
|
+
durationMs: i.duration_ms
|
|
134
152
|
};
|
|
135
153
|
},
|
|
136
|
-
async
|
|
154
|
+
async sendMessageStream(r, s, o, a, i, u) {
|
|
155
|
+
var g, f;
|
|
156
|
+
const h = Pe(t, `/api/v1/sessions/${r}/messages/stream`);
|
|
157
|
+
try {
|
|
158
|
+
const c = await fetch(h, {
|
|
159
|
+
method: "POST",
|
|
160
|
+
signal: u,
|
|
161
|
+
headers: {
|
|
162
|
+
"Content-Type": "application/json"
|
|
163
|
+
},
|
|
164
|
+
body: JSON.stringify({
|
|
165
|
+
message: s,
|
|
166
|
+
...(o == null ? void 0 : o.roleId) !== void 0 ? { role_id: o.roleId } : {},
|
|
167
|
+
...o != null && o.client ? { client: o.client } : {},
|
|
168
|
+
...o != null && o.modelId ? { model_id: o.modelId } : {}
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
if (!c.ok) {
|
|
172
|
+
if (c.status === 404 || c.status === 405)
|
|
173
|
+
return await this.sendMessage(r, s, o, u);
|
|
174
|
+
const T = await Oe(c);
|
|
175
|
+
throw Ze(
|
|
176
|
+
T,
|
|
177
|
+
"I couldn't process that request right now.",
|
|
178
|
+
c.status
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
if (!c.body || (f = (g = c.headers) == null ? void 0 : g.get("content-type")) != null && f.includes("application/json")) {
|
|
182
|
+
const T = Xe(await Oe(c));
|
|
183
|
+
if (typeof T.answer != "string" || !T.usage)
|
|
184
|
+
throw { message: "The response stream ended unexpectedly." };
|
|
185
|
+
return {
|
|
186
|
+
requestId: T.request_id,
|
|
187
|
+
sessionId: T.session_id,
|
|
188
|
+
answer: T.answer,
|
|
189
|
+
sources: (T.sources || []).map(xe),
|
|
190
|
+
toolCalls: (T.tool_calls || []).map(Le),
|
|
191
|
+
usage: qe(T.usage),
|
|
192
|
+
durationMs: T.duration_ms
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
const p = c.body.getReader(), b = new TextDecoder();
|
|
196
|
+
let k = "";
|
|
197
|
+
const v = { value: null }, m = (T) => {
|
|
198
|
+
const x = T.split(/\r?\n/).filter((N) => N.startsWith("data:")).map((N) => N.slice(5).trimStart()).join(`
|
|
199
|
+
`);
|
|
200
|
+
if (!x) return;
|
|
201
|
+
let C = {};
|
|
202
|
+
try {
|
|
203
|
+
const N = JSON.parse(x);
|
|
204
|
+
if (!N || typeof N != "object") return;
|
|
205
|
+
C = N;
|
|
206
|
+
} catch {
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (C.type === "progress" && typeof C.stage == "string")
|
|
210
|
+
a == null || a(C.stage);
|
|
211
|
+
else if (C.type === "token" && typeof C.text == "string")
|
|
212
|
+
i == null || i(C.text);
|
|
213
|
+
else if (C.type === "complete")
|
|
214
|
+
v.value = {
|
|
215
|
+
requestId: C.request_id || "",
|
|
216
|
+
sessionId: C.session_id || r,
|
|
217
|
+
answer: C.answer || "",
|
|
218
|
+
sources: (C.sources || []).map(xe),
|
|
219
|
+
toolCalls: (C.tool_calls || []).map(Le),
|
|
220
|
+
usage: C.usage ? qe(C.usage) : { model: "", promptTokens: 0, completionTokens: 0, totalTokens: 0 },
|
|
221
|
+
durationMs: C.duration_ms
|
|
222
|
+
};
|
|
223
|
+
else if (C.type === "error")
|
|
224
|
+
throw {
|
|
225
|
+
message: C.message || "I couldn't process that request right now.",
|
|
226
|
+
requestId: C.request_id
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
try {
|
|
230
|
+
for (; !v.value; ) {
|
|
231
|
+
const { done: T, value: x } = await p.read();
|
|
232
|
+
if (T) break;
|
|
233
|
+
if (k += b.decode(x, { stream: !0 }), k.length > 1e6)
|
|
234
|
+
throw { message: "The response stream was too large." };
|
|
235
|
+
const C = k.split(/\r?\n\r?\n/);
|
|
236
|
+
k = C.pop() || "";
|
|
237
|
+
for (const N of C)
|
|
238
|
+
if (m(N), v.value) break;
|
|
239
|
+
}
|
|
240
|
+
k += b.decode(), !v.value && k.trim() && m(k);
|
|
241
|
+
} finally {
|
|
242
|
+
await p.cancel().catch(() => {
|
|
243
|
+
}), p.releaseLock();
|
|
244
|
+
}
|
|
245
|
+
const B = v.value;
|
|
246
|
+
if (B)
|
|
247
|
+
return B;
|
|
248
|
+
throw { message: "The response stream ended before the answer was complete." };
|
|
249
|
+
} catch (c) {
|
|
250
|
+
throw !(c instanceof Error) && c && typeof c == "object" && "message" in c ? c : { message: "Something went wrong while connecting. Please try again." };
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
async getHistory(r) {
|
|
137
254
|
try {
|
|
138
|
-
return ((await
|
|
139
|
-
`/api/v1/sessions/${
|
|
140
|
-
)).messages || []).map(
|
|
255
|
+
return ((await n(
|
|
256
|
+
`/api/v1/sessions/${r}/messages`
|
|
257
|
+
)).messages || []).map(Nt);
|
|
141
258
|
} catch {
|
|
142
259
|
return [];
|
|
143
260
|
}
|
|
144
261
|
},
|
|
145
|
-
async closeSession(
|
|
262
|
+
async closeSession(r) {
|
|
146
263
|
try {
|
|
147
|
-
await
|
|
264
|
+
await n(`/api/v1/sessions/${r}`, { method: "DELETE" });
|
|
148
265
|
} catch {
|
|
149
266
|
}
|
|
150
267
|
},
|
|
@@ -153,15 +270,15 @@ function tt(e) {
|
|
|
153
270
|
},
|
|
154
271
|
async checkHealth() {
|
|
155
272
|
try {
|
|
156
|
-
const
|
|
157
|
-
return (await fetch(
|
|
273
|
+
const r = Pe(t, "/health");
|
|
274
|
+
return (await fetch(r)).ok;
|
|
158
275
|
} catch {
|
|
159
276
|
return !1;
|
|
160
277
|
}
|
|
161
278
|
}
|
|
162
279
|
};
|
|
163
280
|
}
|
|
164
|
-
const
|
|
281
|
+
const Sn = ut(), It = [
|
|
165
282
|
{
|
|
166
283
|
label: "How do I access my reports?",
|
|
167
284
|
query: "How do I access my reports in the VPS Customer Portal?"
|
|
@@ -178,20 +295,30 @@ const hn = tt(), Bt = [
|
|
|
178
295
|
label: "How do I contact VPS Support?",
|
|
179
296
|
query: "How can I contact VPS Customer Support?"
|
|
180
297
|
}
|
|
181
|
-
],
|
|
182
|
-
function
|
|
183
|
-
const e =
|
|
298
|
+
], Ve = Et(null);
|
|
299
|
+
function Mt() {
|
|
300
|
+
const e = it(Ve);
|
|
184
301
|
if (!e)
|
|
185
302
|
throw new Error("useChatbot must be used inside ChatProvider.");
|
|
186
303
|
return e;
|
|
187
304
|
}
|
|
188
|
-
function
|
|
189
|
-
return
|
|
190
|
-
}
|
|
191
|
-
|
|
305
|
+
function Ge() {
|
|
306
|
+
return it(Ve);
|
|
307
|
+
}
|
|
308
|
+
const Dt = `Hello! I am your **VPS Veritas assistant**.
|
|
309
|
+
|
|
310
|
+
I can help you with:
|
|
311
|
+
- **Fuel Quality Testing (FQT)** & **Oil Condition Monitoring (OCM)**
|
|
312
|
+
- **Fuel Defect Reporting (FDR)** — report and track bunker defect incidents
|
|
313
|
+
- **Bunker Master** — manage bunkering operations, BDN logs, and surveys
|
|
314
|
+
- **FSC & FSQ E-Forms** — paperless fuel system checks and bunker sample pre-registration
|
|
315
|
+
- **Samplogic** sample logistics, report downloads, and support tickets
|
|
316
|
+
|
|
317
|
+
Feel free to ask a question or select one of the suggested topics below!`;
|
|
318
|
+
function et(e) {
|
|
192
319
|
return `${e}-${crypto.randomUUID()}`;
|
|
193
320
|
}
|
|
194
|
-
function
|
|
321
|
+
function Bt(e) {
|
|
195
322
|
if (e && typeof e == "object" && "message" in e) {
|
|
196
323
|
const t = String(e.message);
|
|
197
324
|
if (t && !/traceback|sql|exception|stack|api[_ ]?key|password/i.test(t))
|
|
@@ -199,133 +326,226 @@ function Mt(e) {
|
|
|
199
326
|
}
|
|
200
327
|
return "I couldn't process that request right now.";
|
|
201
328
|
}
|
|
202
|
-
const
|
|
329
|
+
const dt = ({
|
|
203
330
|
children: e,
|
|
204
331
|
userContext: t = {},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
332
|
+
role: n,
|
|
333
|
+
roleId: r,
|
|
334
|
+
client: s,
|
|
335
|
+
welcomeMessage: o,
|
|
336
|
+
suggestions: a = It,
|
|
337
|
+
disableSuggestions: i = !1,
|
|
338
|
+
initialMessage: u,
|
|
339
|
+
apiBaseUrl: h,
|
|
340
|
+
apiUrl: g,
|
|
341
|
+
proxyUrl: f,
|
|
342
|
+
api: c,
|
|
343
|
+
hideInspectSources: p = !1,
|
|
344
|
+
showGroundedSources: b = !0,
|
|
345
|
+
modelId: k = "auto"
|
|
212
346
|
}) => {
|
|
213
|
-
const
|
|
214
|
-
() =>
|
|
215
|
-
[
|
|
216
|
-
),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}, [
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
347
|
+
const v = h ?? g ?? f, m = ye(
|
|
348
|
+
() => c ?? ut(v),
|
|
349
|
+
[c, v]
|
|
350
|
+
), B = ye(() => ({
|
|
351
|
+
...t,
|
|
352
|
+
...n !== void 0 ? { role: n } : {},
|
|
353
|
+
...r !== void 0 ? { roleId: r } : {},
|
|
354
|
+
...s !== void 0 ? { client: s } : {}
|
|
355
|
+
}), [t, n, r, s]), T = ye(() => o === "" ? null : {
|
|
356
|
+
id: "welcome-default",
|
|
357
|
+
role: "assistant",
|
|
358
|
+
content: o || Dt,
|
|
359
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
360
|
+
status: "complete"
|
|
361
|
+
}, [o]), [x, C] = U(null), [N, I] = U(() => T ? [T] : []), [z, q] = U("idle"), [le, K] = U(null), y = re(null), A = re(!1), M = re(null), D = re(!1), [P, O] = U([]), [L, Y] = U(k);
|
|
362
|
+
oe.useEffect(() => Y(k), [k]), oe.useEffect(() => {
|
|
363
|
+
var S;
|
|
364
|
+
let R = !0;
|
|
365
|
+
return O([]), (S = m.listModels) == null || S.call(m).then((V) => {
|
|
366
|
+
R && O((V == null ? void 0 : V.models) || []);
|
|
367
|
+
}).catch(() => {
|
|
368
|
+
}), () => {
|
|
369
|
+
R = !1;
|
|
370
|
+
};
|
|
371
|
+
}, [m]);
|
|
372
|
+
const ee = ue((R) => {
|
|
373
|
+
!D.current && (R === "auto" || P.some((S) => S.id === R && S.configured)) && Y(R);
|
|
374
|
+
}, [P]);
|
|
375
|
+
oe.useEffect(() => () => {
|
|
376
|
+
var R;
|
|
377
|
+
return (R = M.current) == null ? void 0 : R.abort();
|
|
378
|
+
}, []);
|
|
379
|
+
const de = ue(async (R) => {
|
|
380
|
+
if (x) return x;
|
|
381
|
+
q("connecting");
|
|
382
|
+
const S = await m.createSession(R);
|
|
383
|
+
if (R.aborted) throw new DOMException("Aborted", "AbortError");
|
|
384
|
+
return C(S.sessionId), S.sessionId;
|
|
385
|
+
}, [x, m]), ne = ue(
|
|
386
|
+
async (R) => {
|
|
387
|
+
if (D.current) return;
|
|
388
|
+
D.current = !0;
|
|
389
|
+
const S = new AbortController();
|
|
390
|
+
M.current = S;
|
|
391
|
+
let V, fe = "";
|
|
392
|
+
const me = () => {
|
|
393
|
+
V !== void 0 && cancelAnimationFrame(V), V = void 0;
|
|
394
|
+
};
|
|
395
|
+
y.current = R;
|
|
396
|
+
const ie = {
|
|
397
|
+
id: et("user"),
|
|
226
398
|
role: "user",
|
|
227
|
-
content:
|
|
399
|
+
content: R,
|
|
228
400
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
229
401
|
status: "complete"
|
|
230
|
-
},
|
|
231
|
-
id:
|
|
402
|
+
}, se = et("asst"), ge = {
|
|
403
|
+
id: se,
|
|
232
404
|
role: "assistant",
|
|
233
405
|
content: "",
|
|
234
406
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
235
|
-
status: "pending"
|
|
407
|
+
status: "pending",
|
|
408
|
+
progressText: "Preparing your answer…"
|
|
409
|
+
}, Ee = performance.now();
|
|
410
|
+
I((X) => [...X, ie, ge]), q("awaiting"), K(null);
|
|
411
|
+
const Re = (X) => {
|
|
412
|
+
S.signal.aborted || I(
|
|
413
|
+
(j) => j.map(
|
|
414
|
+
(Z) => Z.id === se ? { ...Z, progressText: X } : Z
|
|
415
|
+
)
|
|
416
|
+
);
|
|
236
417
|
};
|
|
237
|
-
m((A) => [...A, S, B]), _("awaiting"), V(null);
|
|
238
418
|
try {
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
419
|
+
const X = await de(S.signal), j = m.sendMessageStream ? await m.sendMessageStream(
|
|
420
|
+
X,
|
|
421
|
+
R,
|
|
422
|
+
{
|
|
423
|
+
roleId: B.roleId,
|
|
424
|
+
client: B.client,
|
|
425
|
+
modelId: L
|
|
426
|
+
},
|
|
427
|
+
Re,
|
|
428
|
+
(Z) => {
|
|
429
|
+
S.signal.aborted || (fe += Z, V === void 0 && (V = requestAnimationFrame(() => {
|
|
430
|
+
V = void 0, S.signal.aborted || I((Q) => Q.map((be) => be.id === se ? { ...be, content: fe } : be));
|
|
431
|
+
})));
|
|
432
|
+
},
|
|
433
|
+
S.signal
|
|
434
|
+
) : await m.sendMessage(X, R, {
|
|
435
|
+
roleId: B.roleId,
|
|
436
|
+
client: B.client,
|
|
437
|
+
modelId: L
|
|
438
|
+
}, S.signal);
|
|
439
|
+
if (me(), S.signal.aborted) return;
|
|
440
|
+
I(
|
|
441
|
+
(Z) => Z.map(
|
|
442
|
+
(Q) => Q.id === se ? {
|
|
443
|
+
...Q,
|
|
444
|
+
id: j.requestId || se,
|
|
445
|
+
content: j.answer,
|
|
246
446
|
status: "complete",
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
447
|
+
progressText: void 0,
|
|
448
|
+
sources: j.sources,
|
|
449
|
+
toolCalls: j.toolCalls,
|
|
450
|
+
usage: j.usage,
|
|
451
|
+
durationMs: Math.max(
|
|
452
|
+
Math.round(performance.now() - Ee),
|
|
453
|
+
j.durationMs ?? 0
|
|
454
|
+
)
|
|
455
|
+
} : Q
|
|
251
456
|
)
|
|
252
|
-
),
|
|
253
|
-
} catch (
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
457
|
+
), q("idle");
|
|
458
|
+
} catch (X) {
|
|
459
|
+
if (me(), S.signal.aborted) return;
|
|
460
|
+
const j = Bt(X);
|
|
461
|
+
I(
|
|
462
|
+
(Z) => Z.map(
|
|
463
|
+
(Q) => Q.id === se ? { ...Q, content: j, status: "error", progressText: void 0 } : Q
|
|
258
464
|
)
|
|
259
|
-
),
|
|
465
|
+
), K(j), q("error");
|
|
466
|
+
} finally {
|
|
467
|
+
me(), M.current === S && (M.current = null, D.current = !1);
|
|
260
468
|
}
|
|
261
469
|
},
|
|
262
|
-
[
|
|
263
|
-
),
|
|
264
|
-
async (
|
|
265
|
-
const S =
|
|
266
|
-
!S ||
|
|
470
|
+
[de, m, B.client, B.roleId, L]
|
|
471
|
+
), he = ue(
|
|
472
|
+
async (R) => {
|
|
473
|
+
const S = R.trim();
|
|
474
|
+
!S || z === "awaiting" || z === "connecting" || await ne(S);
|
|
267
475
|
},
|
|
268
|
-
[
|
|
269
|
-
),
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
}, []),
|
|
274
|
-
}, []),
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
476
|
+
[ne, z]
|
|
477
|
+
), J = ue(async () => {
|
|
478
|
+
if (D.current) return;
|
|
479
|
+
const R = y.current;
|
|
480
|
+
R && (I((S) => S.filter((V) => V.status !== "error")), await ne(R));
|
|
481
|
+
}, [ne]), ae = ue(async () => {
|
|
482
|
+
}, []), $ = ue(() => {
|
|
483
|
+
}, []), pe = ue(async () => {
|
|
484
|
+
var R;
|
|
485
|
+
(R = M.current) == null || R.abort(), M.current = null, D.current = !1, C(null), I(T ? [T] : []), q("idle"), K(null), y.current = null, x && await m.closeSession(x);
|
|
486
|
+
}, [x, m, T]);
|
|
487
|
+
oe.useEffect(() => {
|
|
488
|
+
!u || A.current || (A.current = !0, he(u));
|
|
489
|
+
}, [u, he]);
|
|
490
|
+
const Te = ye(
|
|
281
491
|
() => ({
|
|
282
|
-
messages:
|
|
283
|
-
status:
|
|
284
|
-
error:
|
|
285
|
-
sessionId:
|
|
492
|
+
messages: N,
|
|
493
|
+
status: z,
|
|
494
|
+
error: le,
|
|
495
|
+
sessionId: x,
|
|
286
496
|
pendingTicket: null,
|
|
287
497
|
ticketBusy: !1,
|
|
288
498
|
lastTicket: null,
|
|
289
|
-
suggestions:
|
|
290
|
-
showSuggestions: !
|
|
291
|
-
suggestionBadgesEnabled: !
|
|
292
|
-
userContext:
|
|
293
|
-
apiBaseUrl:
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
499
|
+
suggestions: a,
|
|
500
|
+
showSuggestions: !i && (N.length === 0 || N.length === 1 && N[0].id === "welcome-default"),
|
|
501
|
+
suggestionBadgesEnabled: !i,
|
|
502
|
+
userContext: B,
|
|
503
|
+
apiBaseUrl: m.apiBaseUrl,
|
|
504
|
+
hideInspectSources: p,
|
|
505
|
+
showGroundedSources: b,
|
|
506
|
+
sendMessage: he,
|
|
507
|
+
retryLast: J,
|
|
508
|
+
confirmTicket: ae,
|
|
509
|
+
cancelTicket: $,
|
|
510
|
+
resetConversation: pe,
|
|
511
|
+
models: P,
|
|
512
|
+
selectedModelId: L,
|
|
513
|
+
selectModel: ee
|
|
299
514
|
}),
|
|
300
515
|
[
|
|
301
|
-
u,
|
|
302
|
-
T,
|
|
303
|
-
D,
|
|
304
|
-
v,
|
|
305
|
-
r,
|
|
306
|
-
n,
|
|
307
|
-
t,
|
|
308
|
-
g.apiBaseUrl,
|
|
309
|
-
R,
|
|
310
|
-
O,
|
|
311
516
|
N,
|
|
312
|
-
|
|
313
|
-
|
|
517
|
+
z,
|
|
518
|
+
le,
|
|
519
|
+
x,
|
|
520
|
+
a,
|
|
521
|
+
i,
|
|
522
|
+
B,
|
|
523
|
+
m.apiBaseUrl,
|
|
524
|
+
p,
|
|
525
|
+
b,
|
|
526
|
+
he,
|
|
527
|
+
J,
|
|
528
|
+
ae,
|
|
529
|
+
$,
|
|
530
|
+
pe,
|
|
531
|
+
P,
|
|
532
|
+
L,
|
|
533
|
+
ee
|
|
314
534
|
]
|
|
315
535
|
);
|
|
316
|
-
return /* @__PURE__ */
|
|
536
|
+
return /* @__PURE__ */ l(Ve.Provider, { value: Te, children: e });
|
|
317
537
|
};
|
|
318
|
-
function
|
|
319
|
-
return
|
|
538
|
+
function Be() {
|
|
539
|
+
return Mt();
|
|
320
540
|
}
|
|
321
|
-
const
|
|
541
|
+
const Pt = ({ message: e, onRetry: t }) => /* @__PURE__ */ w(
|
|
322
542
|
"div",
|
|
323
543
|
{
|
|
324
544
|
className: "chat-error-banner",
|
|
325
545
|
role: "alert",
|
|
326
546
|
children: [
|
|
327
|
-
/* @__PURE__ */
|
|
328
|
-
t && /* @__PURE__ */
|
|
547
|
+
/* @__PURE__ */ l("p", { children: e }),
|
|
548
|
+
t && /* @__PURE__ */ l(
|
|
329
549
|
"button",
|
|
330
550
|
{
|
|
331
551
|
type: "button",
|
|
@@ -343,14 +563,14 @@ const It = ({ message: e, onRetry: t }) => /* @__PURE__ */ k(
|
|
|
343
563
|
* This source code is licensed under the ISC license.
|
|
344
564
|
* See the LICENSE file in the root directory of this source tree.
|
|
345
565
|
*/
|
|
346
|
-
const
|
|
566
|
+
const xt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ht = (...e) => e.filter((t, n, r) => !!t && t.trim() !== "" && r.indexOf(t) === n).join(" ").trim();
|
|
347
567
|
/**
|
|
348
568
|
* @license lucide-react v0.468.0 - ISC
|
|
349
569
|
*
|
|
350
570
|
* This source code is licensed under the ISC license.
|
|
351
571
|
* See the LICENSE file in the root directory of this source tree.
|
|
352
572
|
*/
|
|
353
|
-
var
|
|
573
|
+
var Lt = {
|
|
354
574
|
xmlns: "http://www.w3.org/2000/svg",
|
|
355
575
|
width: 24,
|
|
356
576
|
height: 24,
|
|
@@ -367,31 +587,31 @@ var Pt = {
|
|
|
367
587
|
* This source code is licensed under the ISC license.
|
|
368
588
|
* See the LICENSE file in the root directory of this source tree.
|
|
369
589
|
*/
|
|
370
|
-
const
|
|
590
|
+
const qt = ct(
|
|
371
591
|
({
|
|
372
592
|
color: e = "currentColor",
|
|
373
593
|
size: t = 24,
|
|
374
|
-
strokeWidth:
|
|
375
|
-
absoluteStrokeWidth:
|
|
594
|
+
strokeWidth: n = 2,
|
|
595
|
+
absoluteStrokeWidth: r,
|
|
376
596
|
className: s = "",
|
|
377
|
-
children:
|
|
597
|
+
children: o,
|
|
378
598
|
iconNode: a,
|
|
379
599
|
...i
|
|
380
|
-
},
|
|
600
|
+
}, u) => He(
|
|
381
601
|
"svg",
|
|
382
602
|
{
|
|
383
|
-
ref:
|
|
384
|
-
...
|
|
603
|
+
ref: u,
|
|
604
|
+
...Lt,
|
|
385
605
|
width: t,
|
|
386
606
|
height: t,
|
|
387
607
|
stroke: e,
|
|
388
|
-
strokeWidth:
|
|
389
|
-
className:
|
|
608
|
+
strokeWidth: r ? Number(n) * 24 / Number(t) : n,
|
|
609
|
+
className: ht("lucide", s),
|
|
390
610
|
...i
|
|
391
611
|
},
|
|
392
612
|
[
|
|
393
|
-
...a.map(([h, g]) =>
|
|
394
|
-
...Array.isArray(
|
|
613
|
+
...a.map(([h, g]) => He(h, g)),
|
|
614
|
+
...Array.isArray(o) ? o : [o]
|
|
395
615
|
]
|
|
396
616
|
)
|
|
397
617
|
);
|
|
@@ -402,15 +622,15 @@ const xt = et(
|
|
|
402
622
|
* See the LICENSE file in the root directory of this source tree.
|
|
403
623
|
*/
|
|
404
624
|
const H = (e, t) => {
|
|
405
|
-
const
|
|
406
|
-
({ className:
|
|
407
|
-
ref:
|
|
625
|
+
const n = ct(
|
|
626
|
+
({ className: r, ...s }, o) => He(qt, {
|
|
627
|
+
ref: o,
|
|
408
628
|
iconNode: t,
|
|
409
|
-
className:
|
|
629
|
+
className: ht(`lucide-${xt(e)}`, r),
|
|
410
630
|
...s
|
|
411
631
|
})
|
|
412
632
|
);
|
|
413
|
-
return
|
|
633
|
+
return n.displayName = `${e}`, n;
|
|
414
634
|
};
|
|
415
635
|
/**
|
|
416
636
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -418,7 +638,7 @@ const H = (e, t) => {
|
|
|
418
638
|
* This source code is licensed under the ISC license.
|
|
419
639
|
* See the LICENSE file in the root directory of this source tree.
|
|
420
640
|
*/
|
|
421
|
-
const
|
|
641
|
+
const Ot = H("ArrowDown", [
|
|
422
642
|
["path", { d: "M12 5v14", key: "s699le" }],
|
|
423
643
|
["path", { d: "m19 12-7 7-7-7", key: "1idqje" }]
|
|
424
644
|
]);
|
|
@@ -428,7 +648,7 @@ const Lt = H("ArrowDown", [
|
|
|
428
648
|
* This source code is licensed under the ISC license.
|
|
429
649
|
* See the LICENSE file in the root directory of this source tree.
|
|
430
650
|
*/
|
|
431
|
-
const
|
|
651
|
+
const $t = H("ArrowLeft", [
|
|
432
652
|
["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
|
|
433
653
|
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
434
654
|
]);
|
|
@@ -448,7 +668,23 @@ const Ht = H("ArrowUp", [
|
|
|
448
668
|
* This source code is licensed under the ISC license.
|
|
449
669
|
* See the LICENSE file in the root directory of this source tree.
|
|
450
670
|
*/
|
|
451
|
-
const
|
|
671
|
+
const zt = H("BookOpen", [
|
|
672
|
+
["path", { d: "M12 7v14", key: "1akyts" }],
|
|
673
|
+
[
|
|
674
|
+
"path",
|
|
675
|
+
{
|
|
676
|
+
d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",
|
|
677
|
+
key: "ruj8y"
|
|
678
|
+
}
|
|
679
|
+
]
|
|
680
|
+
]);
|
|
681
|
+
/**
|
|
682
|
+
* @license lucide-react v0.468.0 - ISC
|
|
683
|
+
*
|
|
684
|
+
* This source code is licensed under the ISC license.
|
|
685
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
686
|
+
*/
|
|
687
|
+
const pt = H("BotMessageSquare", [
|
|
452
688
|
["path", { d: "M12 6V2H8", key: "1155em" }],
|
|
453
689
|
["path", { d: "m8 18-4 4V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2Z", key: "w2lp3e" }],
|
|
454
690
|
["path", { d: "M2 12h2", key: "1t8f8n" }],
|
|
@@ -462,14 +698,14 @@ const lt = H("BotMessageSquare", [
|
|
|
462
698
|
* This source code is licensed under the ISC license.
|
|
463
699
|
* See the LICENSE file in the root directory of this source tree.
|
|
464
700
|
*/
|
|
465
|
-
const
|
|
701
|
+
const Wt = H("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
466
702
|
/**
|
|
467
703
|
* @license lucide-react v0.468.0 - ISC
|
|
468
704
|
*
|
|
469
705
|
* This source code is licensed under the ISC license.
|
|
470
706
|
* See the LICENSE file in the root directory of this source tree.
|
|
471
707
|
*/
|
|
472
|
-
const
|
|
708
|
+
const Vt = H("ChevronDown", [
|
|
473
709
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
474
710
|
]);
|
|
475
711
|
/**
|
|
@@ -485,7 +721,17 @@ const Gt = H("ChevronUp", [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]]);
|
|
|
485
721
|
* This source code is licensed under the ISC license.
|
|
486
722
|
* See the LICENSE file in the root directory of this source tree.
|
|
487
723
|
*/
|
|
488
|
-
const
|
|
724
|
+
const Ut = H("CircleCheck", [
|
|
725
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
726
|
+
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
727
|
+
]);
|
|
728
|
+
/**
|
|
729
|
+
* @license lucide-react v0.468.0 - ISC
|
|
730
|
+
*
|
|
731
|
+
* This source code is licensed under the ISC license.
|
|
732
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
733
|
+
*/
|
|
734
|
+
const jt = H("ClipboardCheck", [
|
|
489
735
|
["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
|
|
490
736
|
[
|
|
491
737
|
"path",
|
|
@@ -502,12 +748,10 @@ const Vt = H("ClipboardCheck", [
|
|
|
502
748
|
* This source code is licensed under the ISC license.
|
|
503
749
|
* See the LICENSE file in the root directory of this source tree.
|
|
504
750
|
*/
|
|
505
|
-
const
|
|
506
|
-
["path", { d: "M15
|
|
507
|
-
["path", { d: "
|
|
508
|
-
["path", { d: "
|
|
509
|
-
["path", { d: "M16 13H8", key: "t4e002" }],
|
|
510
|
-
["path", { d: "M16 17H8", key: "z1uh3a" }]
|
|
751
|
+
const Yt = H("ExternalLink", [
|
|
752
|
+
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
753
|
+
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
754
|
+
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
511
755
|
]);
|
|
512
756
|
/**
|
|
513
757
|
* @license lucide-react v0.468.0 - ISC
|
|
@@ -515,7 +759,7 @@ const Wt = H("FileText", [
|
|
|
515
759
|
* This source code is licensed under the ISC license.
|
|
516
760
|
* See the LICENSE file in the root directory of this source tree.
|
|
517
761
|
*/
|
|
518
|
-
const
|
|
762
|
+
const Jt = H("FlaskConical", [
|
|
519
763
|
[
|
|
520
764
|
"path",
|
|
521
765
|
{
|
|
@@ -532,7 +776,16 @@ const $t = H("FlaskConical", [
|
|
|
532
776
|
* This source code is licensed under the ISC license.
|
|
533
777
|
* See the LICENSE file in the root directory of this source tree.
|
|
534
778
|
*/
|
|
535
|
-
const
|
|
779
|
+
const Kt = H("LoaderCircle", [
|
|
780
|
+
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
781
|
+
]);
|
|
782
|
+
/**
|
|
783
|
+
* @license lucide-react v0.468.0 - ISC
|
|
784
|
+
*
|
|
785
|
+
* This source code is licensed under the ISC license.
|
|
786
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
787
|
+
*/
|
|
788
|
+
const ft = H("MessageSquare", [
|
|
536
789
|
["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z", key: "1lielz" }]
|
|
537
790
|
]);
|
|
538
791
|
/**
|
|
@@ -541,7 +794,7 @@ const ot = H("MessageSquare", [
|
|
|
541
794
|
* This source code is licensed under the ISC license.
|
|
542
795
|
* See the LICENSE file in the root directory of this source tree.
|
|
543
796
|
*/
|
|
544
|
-
const
|
|
797
|
+
const Qt = H("Microscope", [
|
|
545
798
|
["path", { d: "M6 18h8", key: "1borvv" }],
|
|
546
799
|
["path", { d: "M3 22h18", key: "8prr45" }],
|
|
547
800
|
["path", { d: "M14 22a7 7 0 1 0 0-14h-1", key: "1jwaiy" }],
|
|
@@ -555,14 +808,14 @@ const Ut = H("Microscope", [
|
|
|
555
808
|
* This source code is licensed under the ISC license.
|
|
556
809
|
* See the LICENSE file in the root directory of this source tree.
|
|
557
810
|
*/
|
|
558
|
-
const
|
|
811
|
+
const Xt = H("Minus", [["path", { d: "M5 12h14", key: "1ays0h" }]]);
|
|
559
812
|
/**
|
|
560
813
|
* @license lucide-react v0.468.0 - ISC
|
|
561
814
|
*
|
|
562
815
|
* This source code is licensed under the ISC license.
|
|
563
816
|
* See the LICENSE file in the root directory of this source tree.
|
|
564
817
|
*/
|
|
565
|
-
const
|
|
818
|
+
const Zt = H("RefreshCw", [
|
|
566
819
|
["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
|
|
567
820
|
["path", { d: "M21 3v5h-5", key: "1q7to0" }],
|
|
568
821
|
["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
|
|
@@ -574,7 +827,23 @@ const Yt = H("RefreshCw", [
|
|
|
574
827
|
* This source code is licensed under the ISC license.
|
|
575
828
|
* See the LICENSE file in the root directory of this source tree.
|
|
576
829
|
*/
|
|
577
|
-
const
|
|
830
|
+
const er = H("ShieldCheck", [
|
|
831
|
+
[
|
|
832
|
+
"path",
|
|
833
|
+
{
|
|
834
|
+
d: "M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",
|
|
835
|
+
key: "oel41y"
|
|
836
|
+
}
|
|
837
|
+
],
|
|
838
|
+
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
839
|
+
]);
|
|
840
|
+
/**
|
|
841
|
+
* @license lucide-react v0.468.0 - ISC
|
|
842
|
+
*
|
|
843
|
+
* This source code is licensed under the ISC license.
|
|
844
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
845
|
+
*/
|
|
846
|
+
const tr = H("TestTubeDiagonal", [
|
|
578
847
|
[
|
|
579
848
|
"path",
|
|
580
849
|
{ d: "M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3", key: "1ub6xw" }
|
|
@@ -588,55 +857,55 @@ const Zt = H("TestTubeDiagonal", [
|
|
|
588
857
|
* This source code is licensed under the ISC license.
|
|
589
858
|
* See the LICENSE file in the root directory of this source tree.
|
|
590
859
|
*/
|
|
591
|
-
const
|
|
860
|
+
const rr = H("X", [
|
|
592
861
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
593
862
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
594
|
-
]),
|
|
863
|
+
]), nr = {
|
|
595
864
|
alpha: {
|
|
596
865
|
label: "Alpha",
|
|
597
|
-
Icon:
|
|
866
|
+
Icon: Jt,
|
|
598
867
|
variant: "env-badge--alpha",
|
|
599
868
|
tooltip: "Alpha build — internal testing only"
|
|
600
869
|
},
|
|
601
870
|
beta: {
|
|
602
871
|
label: "Beta",
|
|
603
|
-
Icon:
|
|
872
|
+
Icon: tr,
|
|
604
873
|
variant: "env-badge--beta",
|
|
605
874
|
tooltip: "Beta build — public pre-release"
|
|
606
875
|
},
|
|
607
876
|
gamma: {
|
|
608
877
|
label: "Gamma",
|
|
609
|
-
Icon:
|
|
878
|
+
Icon: Qt,
|
|
610
879
|
variant: "env-badge--gamma",
|
|
611
880
|
tooltip: "Gamma / Release Candidate"
|
|
612
881
|
},
|
|
613
882
|
qa: {
|
|
614
883
|
label: "QA",
|
|
615
|
-
Icon:
|
|
884
|
+
Icon: jt,
|
|
616
885
|
variant: "env-badge--qa",
|
|
617
886
|
tooltip: "Quality Assurance build"
|
|
618
887
|
}
|
|
619
|
-
},
|
|
888
|
+
}, sr = ({
|
|
620
889
|
stage: e,
|
|
621
890
|
pulse: t = !0,
|
|
622
|
-
className:
|
|
891
|
+
className: n = ""
|
|
623
892
|
}) => {
|
|
624
893
|
if (!e) return null;
|
|
625
|
-
const { label:
|
|
626
|
-
return /* @__PURE__ */
|
|
894
|
+
const { label: r, Icon: s, variant: o, tooltip: a } = nr[e];
|
|
895
|
+
return /* @__PURE__ */ w(
|
|
627
896
|
"span",
|
|
628
897
|
{
|
|
629
|
-
className: `env-badge-inline ${
|
|
898
|
+
className: `env-badge-inline ${o} ${n}`.trim(),
|
|
630
899
|
title: a,
|
|
631
|
-
"aria-label": `${
|
|
900
|
+
"aria-label": `${r} build`,
|
|
632
901
|
role: "status",
|
|
633
902
|
children: [
|
|
634
|
-
/* @__PURE__ */
|
|
635
|
-
/* @__PURE__ */
|
|
903
|
+
/* @__PURE__ */ l(s, { size: 10, className: "env-badge-icon", "aria-hidden": "true" }),
|
|
904
|
+
/* @__PURE__ */ l("span", { className: "env-badge-inline-label", children: r })
|
|
636
905
|
]
|
|
637
906
|
}
|
|
638
907
|
);
|
|
639
|
-
},
|
|
908
|
+
}, or = (e) => /* @__PURE__ */ l(
|
|
640
909
|
"svg",
|
|
641
910
|
{
|
|
642
911
|
width: e.width || "24px",
|
|
@@ -646,97 +915,97 @@ const Jt = H("X", [
|
|
|
646
915
|
xmlns: "http://www.w3.org/2000/svg",
|
|
647
916
|
fill: e.Color || "currentColor",
|
|
648
917
|
...e,
|
|
649
|
-
children: /* @__PURE__ */
|
|
918
|
+
children: /* @__PURE__ */ l("path", { d: "M11.999 0c-2.25 0-4.5.06-6.6.21a5.57 5.57 0 0 0-5.19 5.1c-.24 3.21-.27 6.39-.06 9.6a5.644 5.644 0 0 0 5.7 5.19h3.15v-3.9h-3.15c-.93.03-1.74-.63-1.83-1.56-.18-3-.15-6 .06-9 .06-.84.72-1.47 1.56-1.53 2.04-.15 4.2-.21 6.36-.21s4.32.09 6.36.18c.81.06 1.5.69 1.56 1.53.24 3 .24 6 .06 9-.12.93-.9 1.62-1.83 1.59h-3.15l-6 3.9V24l6-3.9h3.15c2.97.03 5.46-2.25 5.7-5.19.21-3.18.18-6.39-.03-9.57a5.57 5.57 0 0 0-5.19-5.1c-2.13-.18-4.38-.24-6.63-.24zm-5.04 8.76c-.36 0-.66.3-.66.66v2.34c0 .33.18.63.48.78 1.62.78 3.42 1.2 5.22 1.26 1.8-.06 3.6-.48 5.22-1.26.3-.15.48-.45.48-.78V9.42c0-.09-.03-.15-.09-.21a.648.648 0 0 0-.87-.36c-1.5.66-3.12 1.02-4.77 1.05-1.65-.03-3.27-.42-4.77-1.08a.566.566 0 0 0-.24-.06z" })
|
|
650
919
|
}
|
|
651
|
-
),
|
|
920
|
+
), lr = ({
|
|
652
921
|
title: e = "VPS AI Assistant",
|
|
653
922
|
subtitle: t = "Customer portal support",
|
|
654
|
-
onClose:
|
|
655
|
-
onReset:
|
|
923
|
+
onClose: n,
|
|
924
|
+
onReset: r,
|
|
656
925
|
onBack: s,
|
|
657
|
-
showMinimize:
|
|
926
|
+
showMinimize: o = !1,
|
|
658
927
|
envStage: a,
|
|
659
928
|
envPulse: i = !0
|
|
660
|
-
}) => /* @__PURE__ */
|
|
661
|
-
/* @__PURE__ */
|
|
662
|
-
s && /* @__PURE__ */
|
|
929
|
+
}) => /* @__PURE__ */ w("header", { className: "chat-header", children: [
|
|
930
|
+
/* @__PURE__ */ w("div", { className: "chat-header-left", children: [
|
|
931
|
+
s && /* @__PURE__ */ l(
|
|
663
932
|
"button",
|
|
664
933
|
{
|
|
665
934
|
type: "button",
|
|
666
935
|
onClick: s,
|
|
667
936
|
className: "icon-btn-back",
|
|
668
937
|
"aria-label": "Back",
|
|
669
|
-
children: /* @__PURE__ */
|
|
938
|
+
children: /* @__PURE__ */ l($t, { size: 16 })
|
|
670
939
|
}
|
|
671
940
|
),
|
|
672
|
-
/* @__PURE__ */
|
|
941
|
+
/* @__PURE__ */ l(
|
|
673
942
|
"div",
|
|
674
943
|
{
|
|
675
944
|
className: "avatar-circle",
|
|
676
945
|
"aria-hidden": "true",
|
|
677
|
-
children: /* @__PURE__ */
|
|
946
|
+
children: /* @__PURE__ */ l(or, { width: "16px", height: "16px", color: "white" })
|
|
678
947
|
}
|
|
679
948
|
),
|
|
680
|
-
/* @__PURE__ */
|
|
681
|
-
/* @__PURE__ */
|
|
682
|
-
/* @__PURE__ */
|
|
683
|
-
/* @__PURE__ */
|
|
949
|
+
/* @__PURE__ */ w("div", { children: [
|
|
950
|
+
/* @__PURE__ */ w("div", { className: "chat-header-title-row", children: [
|
|
951
|
+
/* @__PURE__ */ l("h2", { className: "chat-header-title", children: e }),
|
|
952
|
+
/* @__PURE__ */ l(sr, { stage: a, pulse: i })
|
|
684
953
|
] }),
|
|
685
|
-
/* @__PURE__ */
|
|
954
|
+
/* @__PURE__ */ l("p", { className: "chat-header-subtitle", children: t || "Customer portal support" })
|
|
686
955
|
] })
|
|
687
956
|
] }),
|
|
688
|
-
/* @__PURE__ */
|
|
689
|
-
|
|
957
|
+
/* @__PURE__ */ w("div", { className: "chat-header-actions", children: [
|
|
958
|
+
r && /* @__PURE__ */ l(
|
|
690
959
|
"button",
|
|
691
960
|
{
|
|
692
961
|
type: "button",
|
|
693
|
-
onClick:
|
|
962
|
+
onClick: r,
|
|
694
963
|
className: "icon-btn-action",
|
|
695
964
|
"aria-label": "Start a new conversation",
|
|
696
965
|
title: "New conversation",
|
|
697
|
-
children: /* @__PURE__ */
|
|
966
|
+
children: /* @__PURE__ */ l(Zt, { size: 15 })
|
|
698
967
|
}
|
|
699
968
|
),
|
|
700
|
-
|
|
969
|
+
n && /* @__PURE__ */ l(
|
|
701
970
|
"button",
|
|
702
971
|
{
|
|
703
972
|
type: "button",
|
|
704
|
-
onClick:
|
|
973
|
+
onClick: n,
|
|
705
974
|
className: "icon-btn-action",
|
|
706
|
-
"aria-label":
|
|
707
|
-
children: /* @__PURE__ */
|
|
975
|
+
"aria-label": o ? "Minimize chat" : "Close chat",
|
|
976
|
+
children: /* @__PURE__ */ l(Xt, { size: 16 })
|
|
708
977
|
}
|
|
709
978
|
)
|
|
710
979
|
] })
|
|
711
980
|
] });
|
|
712
|
-
function
|
|
713
|
-
const
|
|
714
|
-
|
|
715
|
-
var
|
|
716
|
-
|
|
981
|
+
function ar(e, t) {
|
|
982
|
+
const n = re(e);
|
|
983
|
+
ke(() => {
|
|
984
|
+
var r;
|
|
985
|
+
n.current && !e && ((r = t.current) == null || r.focus()), n.current = e;
|
|
717
986
|
}, [e, t]);
|
|
718
987
|
}
|
|
719
|
-
function
|
|
720
|
-
const
|
|
721
|
-
return
|
|
722
|
-
(
|
|
988
|
+
function ir(e, t) {
|
|
989
|
+
const n = t.trim().toLowerCase();
|
|
990
|
+
return n ? e.filter(
|
|
991
|
+
(r) => r.label.toLowerCase().includes(n) || r.query.toLowerCase().includes(n)
|
|
723
992
|
) : e;
|
|
724
993
|
}
|
|
725
|
-
const
|
|
994
|
+
const cr = ({
|
|
726
995
|
suggestions: e,
|
|
727
996
|
onSelect: t,
|
|
728
|
-
disabled:
|
|
729
|
-
variant:
|
|
730
|
-
}) => e.length ?
|
|
997
|
+
disabled: n,
|
|
998
|
+
variant: r = "list"
|
|
999
|
+
}) => e.length ? r === "badge" ? /* @__PURE__ */ l(
|
|
731
1000
|
"ul",
|
|
732
1001
|
{
|
|
733
1002
|
className: "suggestions-badge-list",
|
|
734
1003
|
"aria-label": "Suggested questions",
|
|
735
|
-
children: e.map((s) => /* @__PURE__ */
|
|
1004
|
+
children: e.map((s) => /* @__PURE__ */ l("li", { className: "suggestion-badge-item", children: /* @__PURE__ */ l(
|
|
736
1005
|
"button",
|
|
737
1006
|
{
|
|
738
1007
|
type: "button",
|
|
739
|
-
disabled:
|
|
1008
|
+
disabled: n,
|
|
740
1009
|
onClick: () => t(s),
|
|
741
1010
|
title: s.query,
|
|
742
1011
|
className: "suggestion-badge-btn",
|
|
@@ -744,870 +1013,1145 @@ const nr = ({
|
|
|
744
1013
|
}
|
|
745
1014
|
) }, s.query))
|
|
746
1015
|
}
|
|
747
|
-
) : /* @__PURE__ */
|
|
1016
|
+
) : /* @__PURE__ */ l("div", { className: "suggestions-list", children: e.map((s) => /* @__PURE__ */ l(
|
|
748
1017
|
"button",
|
|
749
1018
|
{
|
|
750
1019
|
type: "button",
|
|
751
|
-
disabled:
|
|
1020
|
+
disabled: n,
|
|
752
1021
|
onClick: () => t(s),
|
|
753
1022
|
className: "suggestion-list-btn",
|
|
754
1023
|
children: s.label
|
|
755
1024
|
},
|
|
756
1025
|
s.query
|
|
757
|
-
)) }) : null,
|
|
1026
|
+
)) }) : null, ur = ({
|
|
758
1027
|
onSend: e,
|
|
759
1028
|
disabled: t = !1,
|
|
760
|
-
placeholder:
|
|
1029
|
+
placeholder: n = "Ask something…"
|
|
761
1030
|
}) => {
|
|
762
|
-
const { suggestions:
|
|
763
|
-
|
|
1031
|
+
const { suggestions: r, showSuggestions: s, suggestionBadgesEnabled: o, models: a, selectedModelId: i, selectModel: u } = Be(), [h, g] = U(""), f = re(null), c = oe.useId(), p = (m) => {
|
|
1032
|
+
m && (m.style.height = "auto", m.style.height = `${Math.min(m.scrollHeight, 96)}px`);
|
|
764
1033
|
};
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
}, [
|
|
768
|
-
const
|
|
769
|
-
if (!
|
|
770
|
-
const
|
|
771
|
-
return
|
|
772
|
-
}, [t, s,
|
|
773
|
-
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
},
|
|
777
|
-
const
|
|
778
|
-
!
|
|
1034
|
+
ar(t, f), ke(() => {
|
|
1035
|
+
p(f.current);
|
|
1036
|
+
}, [h]);
|
|
1037
|
+
const b = ye(() => {
|
|
1038
|
+
if (!o || t) return [];
|
|
1039
|
+
const m = h.trim();
|
|
1040
|
+
return m ? ir(r, m) : s ? r : [];
|
|
1041
|
+
}, [t, s, o, r, h]), k = (m) => {
|
|
1042
|
+
g(m.query);
|
|
1043
|
+
const B = f.current;
|
|
1044
|
+
B == null || B.focus();
|
|
1045
|
+
}, v = () => {
|
|
1046
|
+
const m = h.trim();
|
|
1047
|
+
!m || t || (e(m), g(""), f.current && (f.current.style.height = "auto"));
|
|
779
1048
|
};
|
|
780
|
-
return /* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
|
|
1049
|
+
return /* @__PURE__ */ w("div", { className: "chat-input-wrapper", children: [
|
|
1050
|
+
/* @__PURE__ */ l(
|
|
1051
|
+
cr,
|
|
783
1052
|
{
|
|
784
1053
|
variant: "badge",
|
|
785
|
-
suggestions:
|
|
786
|
-
onSelect:
|
|
1054
|
+
suggestions: b,
|
|
1055
|
+
onSelect: k,
|
|
787
1056
|
disabled: t
|
|
788
1057
|
}
|
|
789
1058
|
),
|
|
790
|
-
/* @__PURE__ */
|
|
791
|
-
/* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */
|
|
1059
|
+
/* @__PURE__ */ l("label", { htmlFor: "vps-chat-input", className: "sr-only", children: "Chat message" }),
|
|
1060
|
+
/* @__PURE__ */ w("div", { className: "chat-input-row", children: [
|
|
1061
|
+
/* @__PURE__ */ l(
|
|
793
1062
|
"textarea",
|
|
794
1063
|
{
|
|
795
1064
|
id: "vps-chat-input",
|
|
796
|
-
ref:
|
|
1065
|
+
ref: f,
|
|
797
1066
|
rows: 1,
|
|
798
|
-
value:
|
|
1067
|
+
value: h,
|
|
799
1068
|
disabled: t,
|
|
800
|
-
placeholder:
|
|
801
|
-
onChange: (
|
|
802
|
-
|
|
1069
|
+
placeholder: n,
|
|
1070
|
+
onChange: (m) => {
|
|
1071
|
+
g(m.target.value), p(m.target);
|
|
803
1072
|
},
|
|
804
|
-
onKeyDown: (
|
|
805
|
-
|
|
1073
|
+
onKeyDown: (m) => {
|
|
1074
|
+
m.key === "Enter" && !m.shiftKey && (m.preventDefault(), v());
|
|
806
1075
|
},
|
|
807
1076
|
className: "chat-textarea"
|
|
808
1077
|
}
|
|
809
1078
|
),
|
|
810
|
-
/* @__PURE__ */
|
|
1079
|
+
/* @__PURE__ */ l(
|
|
811
1080
|
"button",
|
|
812
1081
|
{
|
|
813
1082
|
type: "button",
|
|
814
|
-
onClick:
|
|
815
|
-
disabled: t || !
|
|
1083
|
+
onClick: v,
|
|
1084
|
+
disabled: t || !h.trim(),
|
|
816
1085
|
"aria-label": "Send message",
|
|
817
1086
|
className: "chat-send-btn",
|
|
818
|
-
children: /* @__PURE__ */
|
|
1087
|
+
children: /* @__PURE__ */ l(Ht, { size: 16 })
|
|
1088
|
+
}
|
|
1089
|
+
)
|
|
1090
|
+
] }),
|
|
1091
|
+
a.length > 1 && /* @__PURE__ */ w("div", { className: "chat-model-picker", children: [
|
|
1092
|
+
/* @__PURE__ */ l("label", { htmlFor: c, children: "AI model" }),
|
|
1093
|
+
/* @__PURE__ */ w(
|
|
1094
|
+
"select",
|
|
1095
|
+
{
|
|
1096
|
+
id: c,
|
|
1097
|
+
"aria-label": "AI model",
|
|
1098
|
+
value: i,
|
|
1099
|
+
disabled: t,
|
|
1100
|
+
onChange: (m) => u(m.target.value),
|
|
1101
|
+
children: [
|
|
1102
|
+
/* @__PURE__ */ l("option", { value: "auto", children: "Automatic" }),
|
|
1103
|
+
a.map((m) => /* @__PURE__ */ l("option", { value: m.id, disabled: !m.configured, children: m.label }, m.id))
|
|
1104
|
+
]
|
|
819
1105
|
}
|
|
820
1106
|
)
|
|
821
1107
|
] }),
|
|
822
|
-
/* @__PURE__ */
|
|
1108
|
+
/* @__PURE__ */ w("p", { className: "chat-input-footer", children: [
|
|
823
1109
|
"Powered by ",
|
|
824
|
-
/* @__PURE__ */
|
|
1110
|
+
/* @__PURE__ */ l("span", { className: "chat-input-footer-brand", children: "VPS Veritas AI" })
|
|
825
1111
|
] })
|
|
826
1112
|
] });
|
|
827
1113
|
};
|
|
828
|
-
function
|
|
829
|
-
let
|
|
830
|
-
if (!
|
|
831
|
-
if (typeof
|
|
832
|
-
if (!
|
|
833
|
-
let a =
|
|
834
|
-
return
|
|
835
|
-
}
|
|
836
|
-
function
|
|
1114
|
+
function dr({ defaultTagName: e, props: t, render: n, state: r = {}, stateAttributesMapping: s }) {
|
|
1115
|
+
let o = ze(hr(r, s), t);
|
|
1116
|
+
if (!n) return d.createElement(e, o);
|
|
1117
|
+
if (typeof n == "function") return n(o, r);
|
|
1118
|
+
if (!d.isValidElement(n)) return null;
|
|
1119
|
+
let a = n.props, i = { ...ze(o, a), ref: Se(o.ref, a.ref) };
|
|
1120
|
+
return d.cloneElement(n, i);
|
|
1121
|
+
}
|
|
1122
|
+
function ze(...e) {
|
|
837
1123
|
let t = {};
|
|
838
|
-
for (let
|
|
839
|
-
if (!
|
|
840
|
-
let
|
|
841
|
-
for (let s of Object.keys(
|
|
842
|
-
let
|
|
843
|
-
if (
|
|
1124
|
+
for (let n of e) {
|
|
1125
|
+
if (!n) continue;
|
|
1126
|
+
let r = n;
|
|
1127
|
+
for (let s of Object.keys(r)) {
|
|
1128
|
+
let o = r[s];
|
|
1129
|
+
if (o === void 0) continue;
|
|
844
1130
|
let a = t[s];
|
|
845
|
-
s === "className" ? t[s] = [a,
|
|
1131
|
+
s === "className" ? t[s] = [a, o].filter(Boolean).join(" ") : s === "style" ? t[s] = { ...a, ...o } : s === "ref" ? t[s] = Se(a, o) : fr(s) && typeof a == "function" && typeof o == "function" ? t[s] = pr(o, a) : t[s] = o;
|
|
846
1132
|
}
|
|
847
1133
|
}
|
|
848
1134
|
return t;
|
|
849
1135
|
}
|
|
850
|
-
function
|
|
851
|
-
var
|
|
852
|
-
let
|
|
1136
|
+
function hr(e, t) {
|
|
1137
|
+
var r;
|
|
1138
|
+
let n = {};
|
|
853
1139
|
for (let s of Object.keys(e)) {
|
|
854
|
-
let
|
|
1140
|
+
let o = e[s], a = (r = t == null ? void 0 : t[s]) == null ? void 0 : r.call(t, o);
|
|
855
1141
|
if (a) {
|
|
856
|
-
Object.assign(
|
|
1142
|
+
Object.assign(n, a);
|
|
857
1143
|
continue;
|
|
858
1144
|
}
|
|
859
1145
|
if (s === "slot") {
|
|
860
|
-
|
|
1146
|
+
n["data-slot"] = o;
|
|
861
1147
|
continue;
|
|
862
1148
|
}
|
|
863
|
-
let i = `data-${String(s).replace(/[A-Z]/g, (
|
|
864
|
-
typeof
|
|
1149
|
+
let i = `data-${String(s).replace(/[A-Z]/g, (u) => `-${u.toLowerCase()}`)}`;
|
|
1150
|
+
typeof o == "boolean" ? n[i] = o ? "" : void 0 : o != null && (n[i] = String(o));
|
|
865
1151
|
}
|
|
866
|
-
return
|
|
1152
|
+
return n;
|
|
867
1153
|
}
|
|
868
|
-
function
|
|
869
|
-
return function(
|
|
870
|
-
e(
|
|
1154
|
+
function pr(e, t) {
|
|
1155
|
+
return function(n) {
|
|
1156
|
+
e(n), n.defaultPrevented || t(n);
|
|
871
1157
|
};
|
|
872
1158
|
}
|
|
873
|
-
function
|
|
1159
|
+
function fr(e) {
|
|
874
1160
|
return /^on[A-Z]/.test(e);
|
|
875
1161
|
}
|
|
876
|
-
function
|
|
1162
|
+
function Se(...e) {
|
|
877
1163
|
let t = e.filter(Boolean);
|
|
878
|
-
if (t.length !== 0) return (
|
|
879
|
-
for (let
|
|
1164
|
+
if (t.length !== 0) return (n) => {
|
|
1165
|
+
for (let r of t) typeof r == "function" ? r(n) : r && (r.current = n);
|
|
880
1166
|
};
|
|
881
1167
|
}
|
|
882
|
-
var
|
|
883
|
-
function
|
|
884
|
-
if (!
|
|
885
|
-
let s =
|
|
886
|
-
return { start:
|
|
887
|
-
}
|
|
888
|
-
function
|
|
889
|
-
if (!e || !s) return
|
|
890
|
-
let a = s.getBoundingClientRect(), i = a.top + t +
|
|
891
|
-
for (let
|
|
892
|
-
let
|
|
893
|
-
if (!
|
|
894
|
-
let
|
|
895
|
-
(
|
|
1168
|
+
var mr = 8, gr = 64, br = 0, Ie = 0.5, vr = 180, _r = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "End", "Home", "PageDown", "PageUp", " "]), mt = { start: !1, end: !1 }, wr = [], Me = { currentAnchorId: null, visibleMessageIds: wr };
|
|
1169
|
+
function yr({ content: e, scrollEdgeThreshold: t, spacer: n, viewport: r }) {
|
|
1170
|
+
if (!r || !e) return mt;
|
|
1171
|
+
let s = Ue({ content: e, spacer: n, viewport: r });
|
|
1172
|
+
return { start: r.scrollTop > t, end: s - r.scrollTop - r.clientHeight > t };
|
|
1173
|
+
}
|
|
1174
|
+
function kr({ content: e, scrollMargin: t, scrollPreviousItemPeek: n, spacer: r, viewport: s, visibleMessageIds: o }) {
|
|
1175
|
+
if (!e || !s) return Me;
|
|
1176
|
+
let a = s.getBoundingClientRect(), i = a.top + t + n, u = typeof IntersectionObserver > "u", h = [], g = null;
|
|
1177
|
+
for (let f of Ce(e, r)) {
|
|
1178
|
+
let c = f.dataset.messageId;
|
|
1179
|
+
if (!c) continue;
|
|
1180
|
+
let p = f.dataset.scrollAnchor === "true", b = p || u ? f.getBoundingClientRect() : null;
|
|
1181
|
+
(u && b ? b.bottom > i && b.top < a.bottom : o.has(c)) && h.push(c), p && b && b.top <= i + Ie && (g = c);
|
|
896
1182
|
}
|
|
897
|
-
return h.length === 0 && g === null ?
|
|
1183
|
+
return h.length === 0 && g === null ? Me : { currentAnchorId: g, visibleMessageIds: h };
|
|
898
1184
|
}
|
|
899
|
-
function
|
|
900
|
-
return Array.from(e.children).filter((
|
|
1185
|
+
function Ce(e, t) {
|
|
1186
|
+
return Array.from(e.children).filter((n) => n instanceof HTMLElement && n !== t);
|
|
901
1187
|
}
|
|
902
|
-
function
|
|
903
|
-
for (let
|
|
904
|
-
let
|
|
905
|
-
if ((
|
|
1188
|
+
function Cr(e, t) {
|
|
1189
|
+
for (let n = t; n < e.length; n++) {
|
|
1190
|
+
let r = e[n];
|
|
1191
|
+
if ((r == null ? void 0 : r.dataset.scrollAnchor) === "true") return r;
|
|
906
1192
|
}
|
|
907
1193
|
return null;
|
|
908
1194
|
}
|
|
909
|
-
function
|
|
910
|
-
for (let
|
|
1195
|
+
function Sr(e, t) {
|
|
1196
|
+
for (let n of e) if (n.dataset.scrollAnchor === "true" && !t.has(n)) return n;
|
|
911
1197
|
return null;
|
|
912
1198
|
}
|
|
913
|
-
function
|
|
914
|
-
var
|
|
915
|
-
let
|
|
916
|
-
for (let s = t; s < e.length; s++) if (((
|
|
1199
|
+
function Fr(e, t) {
|
|
1200
|
+
var r;
|
|
1201
|
+
let n = 0;
|
|
1202
|
+
for (let s = t; s < e.length; s++) if (((r = e[s]) == null ? void 0 : r.dataset.scrollAnchor) === "true" && (n += 1, n > 1)) return !0;
|
|
917
1203
|
return !1;
|
|
918
1204
|
}
|
|
919
|
-
function
|
|
1205
|
+
function Tr(e) {
|
|
920
1206
|
for (let t = e.length - 1; t >= 0; t--) {
|
|
921
|
-
let
|
|
922
|
-
if ((
|
|
1207
|
+
let n = e[t];
|
|
1208
|
+
if ((n == null ? void 0 : n.dataset.scrollAnchor) === "true") return n;
|
|
923
1209
|
}
|
|
924
1210
|
return null;
|
|
925
1211
|
}
|
|
926
|
-
function
|
|
927
|
-
let
|
|
928
|
-
for (let s of
|
|
1212
|
+
function Er({ content: e, spacer: t, viewport: n }) {
|
|
1213
|
+
let r = n.getBoundingClientRect();
|
|
1214
|
+
for (let s of Ce(e, t)) {
|
|
929
1215
|
if (!s.dataset.messageId) continue;
|
|
930
|
-
let
|
|
931
|
-
if (
|
|
1216
|
+
let o = s.getBoundingClientRect();
|
|
1217
|
+
if (o.bottom > r.top && o.top < r.bottom) return s;
|
|
932
1218
|
}
|
|
933
1219
|
return null;
|
|
934
1220
|
}
|
|
935
|
-
function
|
|
936
|
-
let
|
|
1221
|
+
function Rr({ align: e, element: t, scrollMargin: n, spacer: r, viewport: s }) {
|
|
1222
|
+
let o = gt(t, s), a = t.getBoundingClientRect().height, i = Ir(r);
|
|
937
1223
|
if (e === "center") {
|
|
938
|
-
let
|
|
939
|
-
return
|
|
1224
|
+
let u = Math.max(0, s.clientHeight - i.start - i.end);
|
|
1225
|
+
return o - i.start - (u - a) / 2 - n;
|
|
940
1226
|
}
|
|
941
|
-
if (e === "end") return
|
|
1227
|
+
if (e === "end") return o - s.clientHeight + a + i.end + n;
|
|
942
1228
|
if (e === "nearest") {
|
|
943
|
-
let
|
|
944
|
-
return
|
|
1229
|
+
let u = o + a, h = s.scrollTop + i.start, g = s.scrollTop + s.clientHeight - i.end;
|
|
1230
|
+
return o >= h && u <= g ? s.scrollTop : o < h ? o - i.start - n : u - s.clientHeight + i.end + n;
|
|
945
1231
|
}
|
|
946
|
-
return
|
|
1232
|
+
return o - i.start - n;
|
|
947
1233
|
}
|
|
948
|
-
function
|
|
949
|
-
let
|
|
950
|
-
return
|
|
1234
|
+
function gt(e, t) {
|
|
1235
|
+
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1236
|
+
return n.top - r.top + t.scrollTop;
|
|
951
1237
|
}
|
|
952
|
-
function
|
|
1238
|
+
function Ae(e, t) {
|
|
953
1239
|
return e.getBoundingClientRect().top - t.getBoundingClientRect().top;
|
|
954
1240
|
}
|
|
955
|
-
function
|
|
956
|
-
let s =
|
|
957
|
-
return t +
|
|
1241
|
+
function Ar({ content: e, scrollTop: t, spacer: n, viewport: r }) {
|
|
1242
|
+
let s = Ue({ content: e, spacer: n, viewport: r });
|
|
1243
|
+
return t + r.clientHeight - s;
|
|
958
1244
|
}
|
|
959
|
-
function
|
|
960
|
-
let
|
|
961
|
-
for (let
|
|
962
|
-
let h =
|
|
963
|
-
i = Math.max(i, h.bottom -
|
|
1245
|
+
function Ue({ content: e, spacer: t, viewport: n }) {
|
|
1246
|
+
let r = Ce(e, t), s = bt(e), o = n.getBoundingClientRect(), a = n.scrollTop, i = s.start + s.end;
|
|
1247
|
+
for (let u of r) {
|
|
1248
|
+
let h = u.getBoundingClientRect();
|
|
1249
|
+
i = Math.max(i, h.bottom - o.top + a + s.end);
|
|
964
1250
|
}
|
|
965
1251
|
return i;
|
|
966
1252
|
}
|
|
967
|
-
function
|
|
1253
|
+
function Nr(e) {
|
|
968
1254
|
return Math.max(0, e.scrollHeight - e.clientHeight);
|
|
969
1255
|
}
|
|
970
|
-
function
|
|
1256
|
+
function bt(e) {
|
|
971
1257
|
let t = window.getComputedStyle(e);
|
|
972
|
-
return { end:
|
|
1258
|
+
return { end: We(t.paddingBlockEnd || t.paddingBottom), start: We(t.paddingBlockStart || t.paddingTop) };
|
|
973
1259
|
}
|
|
974
|
-
function
|
|
1260
|
+
function Ir(e) {
|
|
975
1261
|
let t = e == null ? void 0 : e.parentElement;
|
|
976
|
-
return t ?
|
|
1262
|
+
return t ? bt(t) : { end: 0, start: 0 };
|
|
977
1263
|
}
|
|
978
|
-
function
|
|
1264
|
+
function Mr(e) {
|
|
979
1265
|
if (!e) return 0;
|
|
980
|
-
let t = window.getComputedStyle(e),
|
|
981
|
-
return
|
|
1266
|
+
let t = window.getComputedStyle(e), n = t.rowGap === "normal" ? t.gap : t.rowGap;
|
|
1267
|
+
return We(n);
|
|
982
1268
|
}
|
|
983
|
-
function
|
|
1269
|
+
function We(e) {
|
|
984
1270
|
if (!e) return 0;
|
|
985
1271
|
let t = Number.parseFloat(e);
|
|
986
1272
|
return Number.isFinite(t) ? t : 0;
|
|
987
1273
|
}
|
|
988
|
-
function
|
|
989
|
-
let
|
|
990
|
-
return { getSnapshot: () =>
|
|
991
|
-
t(
|
|
992
|
-
}, subscribe: (s,
|
|
993
|
-
let i =
|
|
994
|
-
return
|
|
995
|
-
|
|
1274
|
+
function vt(e, t) {
|
|
1275
|
+
let n = e, r = /* @__PURE__ */ new Set();
|
|
1276
|
+
return { getSnapshot: () => n, hasListeners: () => r.size > 0, setSnapshot: (s) => {
|
|
1277
|
+
t(n, s) || (n = s, r.forEach((o) => o()));
|
|
1278
|
+
}, subscribe: (s, o, a) => {
|
|
1279
|
+
let i = r.size === 0;
|
|
1280
|
+
return r.add(s), i && (o == null || o()), () => {
|
|
1281
|
+
r.delete(s), r.size === 0 && (a == null || a());
|
|
996
1282
|
};
|
|
997
1283
|
} };
|
|
998
1284
|
}
|
|
999
|
-
function
|
|
1000
|
-
return
|
|
1285
|
+
function tt(e, t) {
|
|
1286
|
+
return vt(e, t);
|
|
1001
1287
|
}
|
|
1002
|
-
function
|
|
1003
|
-
return
|
|
1288
|
+
function Dr() {
|
|
1289
|
+
return vt(Me, Pr);
|
|
1004
1290
|
}
|
|
1005
|
-
function
|
|
1291
|
+
function Br(e, t) {
|
|
1006
1292
|
return e.start === t.start && e.end === t.end;
|
|
1007
1293
|
}
|
|
1008
|
-
function
|
|
1009
|
-
return e.currentAnchorId !== t.currentAnchorId || e.visibleMessageIds.length !== t.visibleMessageIds.length ? !1 : e.visibleMessageIds.every((
|
|
1294
|
+
function Pr(e, t) {
|
|
1295
|
+
return e.currentAnchorId !== t.currentAnchorId || e.visibleMessageIds.length !== t.visibleMessageIds.length ? !1 : e.visibleMessageIds.every((n, r) => n === t.visibleMessageIds[r]);
|
|
1010
1296
|
}
|
|
1011
|
-
function
|
|
1012
|
-
let
|
|
1013
|
-
return
|
|
1297
|
+
function xr({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: n, scrollMargin: r, scrollPreviousItemPeek: s }) {
|
|
1298
|
+
let o = d.useRef(e), a = d.useRef(!1), i = d.useRef(null), u = d.useRef(!1), h = d.useRef(n), g = d.useRef(0), f = d.useRef(null), c = d.useRef(0), p = d.useRef(e ? "following-bottom" : "free-scrolling"), b = d.useRef(/* @__PURE__ */ new Map()), k = d.useRef(null), v = d.useRef(null), m = d.useRef(null), B = d.useRef(s), T = d.useRef(!0), x = d.useRef(null), C = d.useRef(r), N = d.useRef(null), I = d.useRef(0), z = d.useRef(0), q = d.useRef(null), le = d.useRef(null), K = d.useRef(null), y = d.useRef(null), A = d.useRef(null), M = d.useRef(null), D = d.useRef(null), P = d.useRef(null), O = d.useRef(null), L = d.useRef(/* @__PURE__ */ new Set()), Y = d.useRef(/* @__PURE__ */ new WeakSet());
|
|
1299
|
+
return K.current === null && (K.current = tt(t === "end" || t === "last-anchor", (ee, de) => ee === de)), y.current === null && (y.current = tt(mt, Br)), O.current === null && (O.current = Dr()), o.current = e, h.current = n, C.current = r, B.current = s, { autoScrollRef: o, autoscrollingRef: a, autoscrollingTimeoutRef: A, streamingTurnRef: m, contentRef: i, defaultScrollPositionAppliedRef: u, firstItemRef: f, itemCountRef: g, lastScrollTopRef: c, messageElementsRef: b, modeRef: p, pendingScrollFrameRef: N, pendingScrollToMessageRef: k, prependRestoreRef: v, preserveScrollOnPrependRef: T, pendingDefaultScrollStore: K.current, rootRef: x, scrollEdgeThresholdRef: h, scrollMarginRef: C, scrollPreviousItemPeekRef: B, spacerGapRef: I, spacerHeightRef: z, spacerRef: q, stateFrameRef: le, stateStore: y.current, viewportRef: M, visibilityFrameRef: D, visibilityObserverRef: P, visibilityStore: O.current, visibleMessageIdsRef: L, handledScrollAnchorsRef: Y };
|
|
1014
1300
|
}
|
|
1015
|
-
function
|
|
1301
|
+
function _t(e) {
|
|
1016
1302
|
e.pendingDefaultScrollStore.setSnapshot(!1);
|
|
1017
1303
|
}
|
|
1018
|
-
function
|
|
1019
|
-
e.defaultScrollPositionAppliedRef.current = !0,
|
|
1304
|
+
function Ne(e) {
|
|
1305
|
+
e.defaultScrollPositionAppliedRef.current = !0, _t(e);
|
|
1020
1306
|
}
|
|
1021
|
-
function
|
|
1022
|
-
let { streamingTurnRef: s, autoScrollRef:
|
|
1023
|
-
i.current !== null && (window.clearTimeout(i.current), i.current = null), a.current !==
|
|
1307
|
+
function Lr({ refs: e, commitScrollState: t, scheduleStateCommit: n, scheduleVisibilitySync: r }) {
|
|
1308
|
+
let { streamingTurnRef: s, autoScrollRef: o, autoscrollingRef: a, autoscrollingTimeoutRef: i, contentRef: u, itemCountRef: h, messageElementsRef: g, modeRef: f, pendingScrollToMessageRef: c, prependRestoreRef: p, scrollMarginRef: b, scrollPreviousItemPeekRef: k, spacerGapRef: v, spacerHeightRef: m, spacerRef: B, viewportRef: T } = e, x = d.useCallback((y) => {
|
|
1309
|
+
i.current !== null && (window.clearTimeout(i.current), i.current = null), a.current !== y && (a.current = y, t()), y && (i.current = window.setTimeout(() => {
|
|
1024
1310
|
i.current = null, a.current = !1, t();
|
|
1025
|
-
},
|
|
1026
|
-
}, [t]),
|
|
1027
|
-
let
|
|
1028
|
-
if (!
|
|
1029
|
-
let
|
|
1030
|
-
|
|
1031
|
-
}, []),
|
|
1032
|
-
let
|
|
1033
|
-
if (!
|
|
1034
|
-
let
|
|
1035
|
-
if (Math.abs(
|
|
1036
|
-
|
|
1311
|
+
}, vr));
|
|
1312
|
+
}, [t]), C = d.useCallback((y) => {
|
|
1313
|
+
let A = B.current;
|
|
1314
|
+
if (!A) return;
|
|
1315
|
+
let M = Math.max(0, Math.ceil(y));
|
|
1316
|
+
m.current !== M && (m.current = M, A.hidden = M === 0, A.style.height = `${M}px`, A.style.marginTop = M > 0 ? `${-v.current}px` : "");
|
|
1317
|
+
}, []), N = d.useCallback((y, { behavior: A = "auto", autoscrolling: M = !1 } = {}) => {
|
|
1318
|
+
let D = T.current;
|
|
1319
|
+
if (!D) return;
|
|
1320
|
+
let P = Math.max(0, y);
|
|
1321
|
+
if (Math.abs(D.scrollTop - P) <= Ie) {
|
|
1322
|
+
D.scrollTop = P, t();
|
|
1037
1323
|
return;
|
|
1038
1324
|
}
|
|
1039
|
-
|
|
1040
|
-
}, [t,
|
|
1041
|
-
let
|
|
1042
|
-
return
|
|
1043
|
-
}, [
|
|
1044
|
-
let
|
|
1045
|
-
if (!
|
|
1046
|
-
let
|
|
1047
|
-
return
|
|
1048
|
-
}, [
|
|
1049
|
-
let
|
|
1050
|
-
return !
|
|
1051
|
-
}, [
|
|
1052
|
-
let
|
|
1053
|
-
return
|
|
1054
|
-
}, [
|
|
1055
|
-
return { flushPendingScrollToMessage:
|
|
1056
|
-
let
|
|
1057
|
-
if (!
|
|
1058
|
-
let
|
|
1059
|
-
return !
|
|
1060
|
-
}, [
|
|
1061
|
-
}
|
|
1062
|
-
function
|
|
1063
|
-
return
|
|
1064
|
-
e.current =
|
|
1325
|
+
M && x(!0), D.scrollTo({ top: P, behavior: A }), n();
|
|
1326
|
+
}, [t, n, x]), I = d.useCallback(({ behavior: y = "auto" } = {}) => T.current ? (C(0), s.current = null, f.current = "free-scrolling", N(0, { behavior: y }), r(), !0) : !1, [r, N, C]), z = d.useCallback(({ behavior: y = "auto" } = {}) => {
|
|
1327
|
+
let A = T.current;
|
|
1328
|
+
return A ? (C(0), s.current = null, f.current = o.current ? "following-bottom" : "free-scrolling", N(Nr(A), { autoscrolling: !0, behavior: y }), r(), !0) : !1;
|
|
1329
|
+
}, [r, N, C]), q = d.useCallback((y, { align: A = "start", behavior: M = "auto", scrollMargin: D = b.current } = {}, { keepPreviousPeek: P = !1 } = {}) => {
|
|
1330
|
+
let O = u.current, L = T.current;
|
|
1331
|
+
if (!O || !L || !O.contains(y)) return !1;
|
|
1332
|
+
let Y = Rr({ align: A, element: y, scrollMargin: P ? D + k.current : D, spacer: B.current, viewport: L }), ee = Ar({ content: O, scrollTop: Y, spacer: B.current, viewport: L });
|
|
1333
|
+
return C(ee), p.current = { element: y, viewportTop: Ae(y, L) }, f.current = P ? "anchored-to-message" : "settling-jump", s.current = P ? y : null, N(Y, { behavior: M }), r(), !0;
|
|
1334
|
+
}, [r, N, C]), le = d.useCallback(() => {
|
|
1335
|
+
let y = s.current;
|
|
1336
|
+
return !y || !y.isConnected || f.current !== "anchored-to-message" ? !1 : q(y, { align: "start" }, { keepPreviousPeek: !0 });
|
|
1337
|
+
}, [q]), K = d.useCallback((y, A) => {
|
|
1338
|
+
let M = g.current.get(y);
|
|
1339
|
+
return M ? (Ne(e), q(M, A) ? (c.current = null, !0) : (c.current = { messageId: y, options: A }, !0)) : h.current === 0 ? (c.current = { messageId: y, options: A }, Ne(e), !0) : !1;
|
|
1340
|
+
}, [q]);
|
|
1341
|
+
return { flushPendingScrollToMessage: d.useCallback(() => {
|
|
1342
|
+
let y = c.current;
|
|
1343
|
+
if (!y) return !1;
|
|
1344
|
+
let A = g.current.get(y.messageId);
|
|
1345
|
+
return !A || !q(A, y.options) ? !1 : (c.current = null, Ne(e), !0);
|
|
1346
|
+
}, [q]), reanchorToAnchoredMessage: le, scrollToElement: q, scrollToEnd: z, scrollToMessage: K, scrollToStart: I };
|
|
1347
|
+
}
|
|
1348
|
+
function rt(e, t) {
|
|
1349
|
+
return d.useCallback((n) => {
|
|
1350
|
+
e.current = n, n && t();
|
|
1065
1351
|
}, [e, t]);
|
|
1066
1352
|
}
|
|
1067
|
-
function
|
|
1068
|
-
let
|
|
1069
|
-
|
|
1070
|
-
let
|
|
1071
|
-
let
|
|
1072
|
-
for (let G of [
|
|
1073
|
-
}, []),
|
|
1074
|
-
var
|
|
1075
|
-
let
|
|
1076
|
-
|
|
1077
|
-
}, []),
|
|
1078
|
-
let
|
|
1079
|
-
|
|
1080
|
-
let
|
|
1081
|
-
|
|
1082
|
-
}, [
|
|
1083
|
-
|
|
1084
|
-
|
|
1353
|
+
function qr({ autoScroll: e = !1, defaultScrollPosition: t = "end", scrollEdgeThreshold: n = mr, scrollPreviousItemPeek: r = gr, scrollMargin: s = br }) {
|
|
1354
|
+
let o = xr({ autoScroll: e, defaultScrollPosition: t, scrollEdgeThreshold: n, scrollMargin: s, scrollPreviousItemPeek: r }), { streamingTurnRef: a, autoScrollRef: i, autoscrollingRef: u, autoscrollingTimeoutRef: h, contentRef: g, defaultScrollPositionAppliedRef: f, firstItemRef: c, itemCountRef: p, lastScrollTopRef: b, messageElementsRef: k, modeRef: v, pendingScrollFrameRef: m, pendingScrollToMessageRef: B, prependRestoreRef: T, preserveScrollOnPrependRef: x, pendingDefaultScrollStore: C, rootRef: N, scrollEdgeThresholdRef: I, scrollMarginRef: z, scrollPreviousItemPeekRef: q, spacerGapRef: le, spacerHeightRef: K, spacerRef: y, stateFrameRef: A, stateStore: M, viewportRef: D, visibilityFrameRef: P, visibilityObserverRef: O, visibilityStore: L, visibleMessageIdsRef: Y, handledScrollAnchorsRef: ee } = o, de = d.useRef(t);
|
|
1355
|
+
de.current !== t && (de.current = t, f.current = !1);
|
|
1356
|
+
let ne = d.useCallback((_) => {
|
|
1357
|
+
let F = N.current, E = D.current, W = [_.start && "start", _.end && "end"].filter(Boolean).join(" "), ce = u.current;
|
|
1358
|
+
for (let G of [F, E]) G && (W ? G.setAttribute("data-scrollable", W) : G.removeAttribute("data-scrollable"), G.toggleAttribute("data-autoscrolling", ce));
|
|
1359
|
+
}, []), he = d.useCallback((_) => {
|
|
1360
|
+
var W;
|
|
1361
|
+
let F = ((W = D.current) == null ? void 0 : W.scrollTop) ?? 0, E = F < b.current - Ie;
|
|
1362
|
+
b.current = F, i.current && !_.end && v.current !== "settling-jump" && v.current !== "anchored-to-message" ? v.current = "following-bottom" : v.current === "following-bottom" && _.end && E && !u.current && (v.current = "free-scrolling");
|
|
1363
|
+
}, []), J = d.useCallback(() => {
|
|
1364
|
+
let _ = yr({ content: g.current, scrollEdgeThreshold: I.current, spacer: y.current, viewport: D.current });
|
|
1365
|
+
he(_);
|
|
1366
|
+
let F = v.current === "following-bottom" ? { ..._, end: !1 } : _;
|
|
1367
|
+
ne(F), M.setSnapshot(F);
|
|
1368
|
+
}, [he, M, ne]), ae = d.useCallback(() => {
|
|
1369
|
+
A.current === null && (A.current = window.requestAnimationFrame(() => {
|
|
1370
|
+
A.current = null, J();
|
|
1085
1371
|
}));
|
|
1086
|
-
}, [
|
|
1087
|
-
|
|
1088
|
-
|
|
1372
|
+
}, [J]), $ = d.useCallback(() => {
|
|
1373
|
+
L.hasListeners() && P.current === null && (P.current = window.requestAnimationFrame(() => {
|
|
1374
|
+
P.current = null, L.hasListeners() && L.setSnapshot(kr({ content: g.current, scrollMargin: z.current, scrollPreviousItemPeek: q.current, spacer: y.current, viewport: D.current, visibleMessageIds: Y.current }));
|
|
1089
1375
|
}));
|
|
1090
|
-
}, [
|
|
1091
|
-
let
|
|
1092
|
-
if (!
|
|
1093
|
-
let
|
|
1094
|
-
return Math.abs(
|
|
1095
|
-
}, [
|
|
1096
|
-
let
|
|
1097
|
-
if (!
|
|
1098
|
-
|
|
1376
|
+
}, [L]), { flushPendingScrollToMessage: pe, reanchorToAnchoredMessage: Te, scrollToElement: R, scrollToEnd: S, scrollToMessage: V, scrollToStart: fe } = Lr({ refs: o, commitScrollState: J, scheduleStateCommit: ae, scheduleVisibilitySync: $ }), me = d.useCallback(() => {
|
|
1377
|
+
let _ = T.current, F = D.current;
|
|
1378
|
+
if (!_ || !F || !_.element.isConnected) return !1;
|
|
1379
|
+
let E = Ae(_.element, F) - _.viewportTop;
|
|
1380
|
+
return Math.abs(E) <= Ie ? !1 : (F.scrollTop += E, _.viewportTop = Ae(_.element, F), ae(), $(), !0);
|
|
1381
|
+
}, [ae, $]), ie = d.useCallback(() => {
|
|
1382
|
+
let _ = g.current, F = D.current;
|
|
1383
|
+
if (!_ || !F) {
|
|
1384
|
+
T.current = null;
|
|
1099
1385
|
return;
|
|
1100
1386
|
}
|
|
1101
|
-
let
|
|
1102
|
-
|
|
1103
|
-
}, []),
|
|
1104
|
-
|
|
1105
|
-
|
|
1387
|
+
let E = Er({ content: _, spacer: y.current, viewport: F });
|
|
1388
|
+
T.current = E ? { element: E, viewportTop: Ae(E, F) } : null;
|
|
1389
|
+
}, []), se = d.useCallback(() => {
|
|
1390
|
+
m.current === null && (m.current = window.requestAnimationFrame(() => {
|
|
1391
|
+
m.current = null, pe() && ie();
|
|
1106
1392
|
}));
|
|
1107
|
-
}, [
|
|
1108
|
-
if (!t ||
|
|
1109
|
-
let
|
|
1393
|
+
}, [ie, pe]), ge = d.useCallback(() => {
|
|
1394
|
+
if (!t || f.current || p.current === 0) return !1;
|
|
1395
|
+
let _ = !1;
|
|
1110
1396
|
if (t === "last-anchor") {
|
|
1111
|
-
let
|
|
1112
|
-
if (!
|
|
1397
|
+
let F = g.current, E = D.current, W = F && E ? Tr(Ce(F, y.current)) : null;
|
|
1398
|
+
if (!F || !E || !W) _ = S({ behavior: "auto" });
|
|
1113
1399
|
else {
|
|
1114
|
-
let
|
|
1115
|
-
|
|
1400
|
+
let ce = gt(W, E);
|
|
1401
|
+
_ = Ue({ content: F, spacer: y.current, viewport: E }) - ce <= E.clientHeight ? S({ behavior: "auto" }) : R(W, { align: "start" }, { keepPreviousPeek: !0 });
|
|
1116
1402
|
}
|
|
1117
|
-
} else
|
|
1118
|
-
return
|
|
1119
|
-
}, [t,
|
|
1120
|
-
let
|
|
1121
|
-
if (!
|
|
1122
|
-
let
|
|
1123
|
-
|
|
1124
|
-
if (
|
|
1125
|
-
if (
|
|
1126
|
-
if (
|
|
1127
|
-
|
|
1403
|
+
} else _ = t === "end" ? S({ behavior: "auto" }) : fe({ behavior: "auto" });
|
|
1404
|
+
return _ ? (Ne(o), !0) : !1;
|
|
1405
|
+
}, [t, R, S, fe]), Ee = d.useCallback(() => {
|
|
1406
|
+
let _ = g.current;
|
|
1407
|
+
if (!_) return;
|
|
1408
|
+
let F = Ce(_, y.current), E = p.current, W = c.current;
|
|
1409
|
+
p.current = F.length, c.current = F[0] ?? null, (() => {
|
|
1410
|
+
if (pe()) return;
|
|
1411
|
+
if (E === 0) {
|
|
1412
|
+
if (ge() || F.length > 0 && i.current && S({ behavior: "auto" })) return;
|
|
1413
|
+
J(), $();
|
|
1128
1414
|
return;
|
|
1129
1415
|
}
|
|
1130
|
-
let
|
|
1131
|
-
if (
|
|
1132
|
-
|
|
1416
|
+
let ce = W ? F.indexOf(W) : -1;
|
|
1417
|
+
if (x.current && ce > 0) {
|
|
1418
|
+
me();
|
|
1133
1419
|
return;
|
|
1134
1420
|
}
|
|
1135
|
-
if (
|
|
1136
|
-
let G =
|
|
1421
|
+
if (F.length > E) {
|
|
1422
|
+
let G = Cr(F, E);
|
|
1137
1423
|
if (G) {
|
|
1138
|
-
if (i.current &&
|
|
1139
|
-
|
|
1424
|
+
if (i.current && v.current === "following-bottom" && Fr(F, E)) {
|
|
1425
|
+
S({ behavior: "auto" });
|
|
1140
1426
|
return;
|
|
1141
1427
|
}
|
|
1142
|
-
|
|
1428
|
+
R(G, { align: "start" }, { keepPreviousPeek: !0 }), ee.current.add(G);
|
|
1143
1429
|
return;
|
|
1144
1430
|
}
|
|
1145
1431
|
}
|
|
1146
|
-
if (
|
|
1147
|
-
let G =
|
|
1432
|
+
if (F.length === E) {
|
|
1433
|
+
let G = Sr(F, ee.current);
|
|
1148
1434
|
if (G) {
|
|
1149
|
-
|
|
1435
|
+
R(G, { align: "start" }, { keepPreviousPeek: !0 }), ee.current.add(G);
|
|
1150
1436
|
return;
|
|
1151
1437
|
}
|
|
1152
1438
|
}
|
|
1153
|
-
|
|
1154
|
-
})(),
|
|
1155
|
-
}, [
|
|
1156
|
-
if (
|
|
1157
|
-
|
|
1439
|
+
v.current === "following-bottom" && i.current ? S({ behavior: "auto" }) : (J(), $());
|
|
1440
|
+
})(), ie();
|
|
1441
|
+
}, [ge, ie, J, pe, me, $, R, S]), Re = d.useCallback(() => {
|
|
1442
|
+
if (v.current === "following-bottom" && i.current) {
|
|
1443
|
+
S({ behavior: "auto" });
|
|
1158
1444
|
return;
|
|
1159
1445
|
}
|
|
1160
|
-
let
|
|
1161
|
-
if (
|
|
1162
|
-
i.current &&
|
|
1446
|
+
let _ = K.current;
|
|
1447
|
+
if (Te()) {
|
|
1448
|
+
i.current && _ > 0 && K.current === 0 && S({ behavior: "auto" });
|
|
1163
1449
|
return;
|
|
1164
1450
|
}
|
|
1165
|
-
|
|
1166
|
-
}, [
|
|
1167
|
-
let
|
|
1168
|
-
if (!(!
|
|
1451
|
+
ae(), $();
|
|
1452
|
+
}, [Te, ae, $, S]), X = d.useCallback(() => {
|
|
1453
|
+
let _ = D.current;
|
|
1454
|
+
if (!(!_ || !L.hasListeners())) {
|
|
1169
1455
|
if (typeof IntersectionObserver > "u") {
|
|
1170
|
-
|
|
1456
|
+
$();
|
|
1171
1457
|
return;
|
|
1172
1458
|
}
|
|
1173
|
-
|
|
1174
|
-
for (let
|
|
1175
|
-
let
|
|
1176
|
-
|
|
1459
|
+
O.current || (O.current = new IntersectionObserver((F) => {
|
|
1460
|
+
for (let E of F) {
|
|
1461
|
+
let W = E.target.dataset.messageId;
|
|
1462
|
+
W && (E.isIntersecting ? Y.current.add(W) : Y.current.delete(W));
|
|
1177
1463
|
}
|
|
1178
|
-
|
|
1179
|
-
}, { root:
|
|
1180
|
-
var
|
|
1181
|
-
(
|
|
1182
|
-
}),
|
|
1464
|
+
$();
|
|
1465
|
+
}, { root: _, rootMargin: `${-(z.current + q.current)}px 0px 0px 0px`, threshold: [0, 0.01, 0.5, 1] })), k.current.forEach((F) => {
|
|
1466
|
+
var E;
|
|
1467
|
+
(E = O.current) == null || E.observe(F);
|
|
1468
|
+
}), $();
|
|
1183
1469
|
}
|
|
1184
|
-
}, [
|
|
1185
|
-
var
|
|
1186
|
-
|
|
1187
|
-
}, [
|
|
1188
|
-
var
|
|
1189
|
-
if (
|
|
1190
|
-
|
|
1470
|
+
}, [$, L]), j = d.useCallback(() => {
|
|
1471
|
+
var _;
|
|
1472
|
+
P.current !== null && (window.cancelAnimationFrame(P.current), P.current = null), (_ = O.current) == null || _.disconnect(), O.current = null, Y.current.clear(), L.setSnapshot(Me);
|
|
1473
|
+
}, [L]), Z = d.useCallback((_, F, E) => {
|
|
1474
|
+
var W, ce, G;
|
|
1475
|
+
if (F) {
|
|
1476
|
+
k.current.set(_, F), (W = O.current) == null || W.observe(F), $(), ((ce = B.current) == null ? void 0 : ce.messageId) === _ && se();
|
|
1191
1477
|
return;
|
|
1192
1478
|
}
|
|
1193
|
-
|
|
1194
|
-
}, [
|
|
1195
|
-
(
|
|
1196
|
-
}, []),
|
|
1197
|
-
g.current =
|
|
1198
|
-
}, []),
|
|
1199
|
-
|
|
1200
|
-
}, []),
|
|
1201
|
-
|
|
1202
|
-
}, [
|
|
1203
|
-
return
|
|
1204
|
-
|
|
1205
|
-
}, [
|
|
1206
|
-
var
|
|
1207
|
-
|
|
1208
|
-
}, []),
|
|
1209
|
-
if (e &&
|
|
1210
|
-
|
|
1479
|
+
E && k.current.get(_) === E && (k.current.delete(_), Y.current.delete(_), (G = O.current) == null || G.unobserve(E), $());
|
|
1480
|
+
}, [se, $]), Q = d.useCallback(() => {
|
|
1481
|
+
(v.current === "following-bottom" || v.current === "anchored-to-message" || v.current === "settling-jump") && (a.current = null, v.current = "free-scrolling");
|
|
1482
|
+
}, []), be = d.useCallback(() => ne(M.getSnapshot()), [M, ne]), je = rt(N, be), Ye = rt(D, be), Je = d.useCallback((_) => {
|
|
1483
|
+
g.current = _;
|
|
1484
|
+
}, []), Ke = d.useCallback((_) => {
|
|
1485
|
+
y.current = _, le.current = Mr((_ == null ? void 0 : _.parentElement) ?? null);
|
|
1486
|
+
}, []), Qe = d.useCallback(() => {
|
|
1487
|
+
J(), $(), ie();
|
|
1488
|
+
}, [ie, J, $]), Tt = d.useMemo(() => ({ handleContentChange: Ee, handleResize: Re, observeVisibility: X, pendingDefaultScrollStore: C, preserveScrollOnPrependRef: x, scrollToEnd: S, scrollToMessage: V, scrollToStart: fe, setContentElement: Je, setRootElement: je, setSpacerElement: Ke, setViewportElement: Ye, stateStore: M, syncAfterScroll: Qe, unobserveVisibility: j, userScrollIntent: Q, viewportRef: D, visibilityStore: L }), [Ee, Re, X, C, S, V, fe, Je, je, Ke, Ye, M, Qe, j, Q, L]);
|
|
1489
|
+
return d.useLayoutEffect(() => {
|
|
1490
|
+
ge() || p.current === 0 && _t(o);
|
|
1491
|
+
}, [ge]), d.useEffect(() => () => {
|
|
1492
|
+
var _;
|
|
1493
|
+
A.current !== null && (window.cancelAnimationFrame(A.current), A.current = null), P.current !== null && (window.cancelAnimationFrame(P.current), P.current = null), h.current !== null && (window.clearTimeout(h.current), h.current = null), m.current !== null && (window.cancelAnimationFrame(m.current), m.current = null), (_ = O.current) == null || _.disconnect(), O.current = null;
|
|
1494
|
+
}, []), d.useLayoutEffect(() => {
|
|
1495
|
+
if (e && v.current === "following-bottom" && p.current > 0) {
|
|
1496
|
+
S({ behavior: "auto" });
|
|
1211
1497
|
return;
|
|
1212
1498
|
}
|
|
1213
|
-
|
|
1214
|
-
}, [e,
|
|
1499
|
+
J();
|
|
1500
|
+
}, [e, J, S]), { context: Tt, registerMessage: Z };
|
|
1215
1501
|
}
|
|
1216
|
-
function
|
|
1217
|
-
let t =
|
|
1502
|
+
function Or(e) {
|
|
1503
|
+
let t = d.useRef(e);
|
|
1218
1504
|
return t.current = e, t;
|
|
1219
1505
|
}
|
|
1220
|
-
var
|
|
1221
|
-
function
|
|
1222
|
-
let e =
|
|
1506
|
+
var wt = d.createContext(null), yt = d.createContext(null);
|
|
1507
|
+
function Fe() {
|
|
1508
|
+
let e = d.useContext(wt);
|
|
1223
1509
|
if (!e) throw new Error("useMessageScroller must be used within a MessageScroller.");
|
|
1224
1510
|
return e;
|
|
1225
1511
|
}
|
|
1226
|
-
function
|
|
1227
|
-
let e =
|
|
1512
|
+
function $r() {
|
|
1513
|
+
let e = d.useContext(yt);
|
|
1228
1514
|
if (!e) throw new Error("MessageScrollerItem must be used within a MessageScroller.");
|
|
1229
1515
|
return e;
|
|
1230
1516
|
}
|
|
1231
|
-
function
|
|
1232
|
-
let { context: a, registerMessage: i } =
|
|
1233
|
-
return
|
|
1234
|
-
}
|
|
1235
|
-
function
|
|
1236
|
-
let { pendingDefaultScrollStore: e } =
|
|
1237
|
-
return
|
|
1238
|
-
}
|
|
1239
|
-
function
|
|
1240
|
-
let { setRootElement:
|
|
1241
|
-
return
|
|
1242
|
-
}
|
|
1243
|
-
function
|
|
1244
|
-
let { handleResize:
|
|
1245
|
-
|
|
1246
|
-
let
|
|
1247
|
-
var
|
|
1248
|
-
|
|
1249
|
-
}, [i,
|
|
1250
|
-
function
|
|
1251
|
-
|
|
1517
|
+
function Hr({ autoScroll: e = !1, children: t, defaultScrollPosition: n = "end", scrollEdgeThreshold: r, scrollPreviousItemPeek: s, scrollMargin: o }) {
|
|
1518
|
+
let { context: a, registerMessage: i } = qr({ autoScroll: e, defaultScrollPosition: n, scrollEdgeThreshold: r, scrollPreviousItemPeek: s, scrollMargin: o });
|
|
1519
|
+
return l(wt.Provider, { value: a, children: l(yt.Provider, { value: i, children: t }) });
|
|
1520
|
+
}
|
|
1521
|
+
function kt() {
|
|
1522
|
+
let { pendingDefaultScrollStore: e } = Fe();
|
|
1523
|
+
return d.useSyncExternalStore(e.subscribe, e.getSnapshot, e.getSnapshot);
|
|
1524
|
+
}
|
|
1525
|
+
function zr({ children: e, ...t }) {
|
|
1526
|
+
let { setRootElement: n } = Fe(), r = kt();
|
|
1527
|
+
return l("div", { ref: n, ...t, ...r ? { "data-pending-scroll": "" } : null, children: e });
|
|
1528
|
+
}
|
|
1529
|
+
function Wr({ "aria-label": e, children: t, onKeyDown: n, onScroll: r, onTouchMove: s, onWheel: o, preserveScrollOnPrepend: a = !0, ref: i, role: u, tabIndex: h, ...g }) {
|
|
1530
|
+
let { handleResize: f, preserveScrollOnPrependRef: c, setViewportElement: p, syncAfterScroll: b, userScrollIntent: k, viewportRef: v } = Fe(), m = kt();
|
|
1531
|
+
c.current = a;
|
|
1532
|
+
let B = d.useCallback((I) => {
|
|
1533
|
+
var z;
|
|
1534
|
+
p(I), (z = Se(i)) == null || z(I);
|
|
1535
|
+
}, [i, p]);
|
|
1536
|
+
function T(I) {
|
|
1537
|
+
b(), r == null || r(I);
|
|
1252
1538
|
}
|
|
1253
|
-
function
|
|
1254
|
-
|
|
1539
|
+
function x(I) {
|
|
1540
|
+
k(), o == null || o(I);
|
|
1255
1541
|
}
|
|
1256
|
-
function
|
|
1257
|
-
|
|
1542
|
+
function C(I) {
|
|
1543
|
+
k(), s == null || s(I);
|
|
1258
1544
|
}
|
|
1259
|
-
function I
|
|
1260
|
-
|
|
1545
|
+
function N(I) {
|
|
1546
|
+
_r.has(I.key) && k(), n == null || n(I);
|
|
1261
1547
|
}
|
|
1262
|
-
return
|
|
1263
|
-
let
|
|
1264
|
-
if (!
|
|
1265
|
-
let
|
|
1266
|
-
window.cancelAnimationFrame(
|
|
1548
|
+
return d.useEffect(() => {
|
|
1549
|
+
let I = v.current;
|
|
1550
|
+
if (!I || typeof ResizeObserver > "u") return;
|
|
1551
|
+
let z = 0, q = new ResizeObserver(() => {
|
|
1552
|
+
window.cancelAnimationFrame(z), z = window.requestAnimationFrame(f);
|
|
1267
1553
|
});
|
|
1268
|
-
return
|
|
1269
|
-
window.cancelAnimationFrame(
|
|
1554
|
+
return q.observe(I), () => {
|
|
1555
|
+
window.cancelAnimationFrame(z), q.disconnect();
|
|
1270
1556
|
};
|
|
1271
|
-
}, [
|
|
1272
|
-
}
|
|
1273
|
-
function
|
|
1274
|
-
let { handleContentChange: a, handleResize: i, setContentElement:
|
|
1275
|
-
var
|
|
1276
|
-
g.current =
|
|
1277
|
-
}, [
|
|
1278
|
-
return
|
|
1279
|
-
let
|
|
1280
|
-
if (!
|
|
1281
|
-
let
|
|
1557
|
+
}, [f, v]), l("div", { ref: B, role: u ?? "region", "aria-label": e ?? "Messages", tabIndex: h ?? 0, onKeyDown: N, onScroll: T, onTouchMove: C, onWheel: x, ...g, ...m ? { "data-pending-scroll": "" } : null, children: t });
|
|
1558
|
+
}
|
|
1559
|
+
function Vr({ "aria-relevant": e, children: t, ref: n, role: r, spacerClassName: s, ...o }) {
|
|
1560
|
+
let { handleContentChange: a, handleResize: i, setContentElement: u, setSpacerElement: h } = Fe(), g = d.useRef(null), f = d.useCallback((c) => {
|
|
1561
|
+
var p;
|
|
1562
|
+
g.current = c, u(c), (p = Se(n)) == null || p(c);
|
|
1563
|
+
}, [n, u]);
|
|
1564
|
+
return d.useLayoutEffect(() => {
|
|
1565
|
+
let c = g.current;
|
|
1566
|
+
if (!c || (a(), typeof MutationObserver > "u")) return;
|
|
1567
|
+
let p = new MutationObserver(() => {
|
|
1282
1568
|
a();
|
|
1283
1569
|
});
|
|
1284
|
-
return
|
|
1285
|
-
}, [a]),
|
|
1286
|
-
let
|
|
1287
|
-
if (!
|
|
1288
|
-
let
|
|
1289
|
-
window.cancelAnimationFrame(
|
|
1570
|
+
return p.observe(c, { childList: !0 }), () => p.disconnect();
|
|
1571
|
+
}, [a]), d.useEffect(() => {
|
|
1572
|
+
let c = g.current;
|
|
1573
|
+
if (!c || typeof ResizeObserver > "u") return;
|
|
1574
|
+
let p = 0, b = new ResizeObserver(() => {
|
|
1575
|
+
window.cancelAnimationFrame(p), p = window.requestAnimationFrame(i);
|
|
1290
1576
|
});
|
|
1291
|
-
return
|
|
1292
|
-
window.cancelAnimationFrame(
|
|
1577
|
+
return b.observe(c), () => {
|
|
1578
|
+
window.cancelAnimationFrame(p), b.disconnect();
|
|
1293
1579
|
};
|
|
1294
|
-
}, [i]),
|
|
1580
|
+
}, [i]), w("div", { ref: f, role: r ?? "log", "aria-relevant": e ?? "additions", ...o, children: [t, l("div", { ref: h, "aria-hidden": "true", "data-message-scroller-spacer": "", hidden: !0, className: s })] });
|
|
1295
1581
|
}
|
|
1296
|
-
function
|
|
1297
|
-
let s =
|
|
1582
|
+
function Gr({ messageId: e, ref: t, scrollAnchor: n = !1, ...r }) {
|
|
1583
|
+
let s = $r(), o = d.useRef(null), a = d.useCallback((i) => {
|
|
1298
1584
|
var h;
|
|
1299
|
-
let
|
|
1300
|
-
|
|
1585
|
+
let u = o.current;
|
|
1586
|
+
o.current = i, e && s(e, i, u), (h = Se(t)) == null || h(i);
|
|
1301
1587
|
}, [e, t, s]);
|
|
1302
|
-
return
|
|
1303
|
-
}
|
|
1304
|
-
function
|
|
1305
|
-
let { scrollToEnd:
|
|
1306
|
-
let
|
|
1307
|
-
return
|
|
1308
|
-
}, [
|
|
1309
|
-
var
|
|
1310
|
-
|
|
1311
|
-
}, [e,
|
|
1312
|
-
return
|
|
1313
|
-
}
|
|
1314
|
-
var
|
|
1315
|
-
function
|
|
1316
|
-
var t,
|
|
1317
|
-
if (typeof e == "string" || typeof e == "number")
|
|
1588
|
+
return l("div", { ref: a, "data-message-id": e, "data-scroll-anchor": n ? "true" : "false", ...r });
|
|
1589
|
+
}
|
|
1590
|
+
function Ur({ behavior: e = "smooth", children: t, direction: n = "end", onClick: r, render: s, tabIndex: o, type: a = "button", ...i }) {
|
|
1591
|
+
let { scrollToEnd: u, scrollToStart: h, stateStore: g } = Fe(), f = Or(r), c = d.useCallback((v) => g.subscribe(v), [g]), p = d.useCallback(() => {
|
|
1592
|
+
let v = g.getSnapshot();
|
|
1593
|
+
return n === "start" ? v.start : v.end;
|
|
1594
|
+
}, [n, g]), b = d.useSyncExternalStore(c, p, p), k = d.useCallback((v) => {
|
|
1595
|
+
var m;
|
|
1596
|
+
b && ((m = f.current) == null || m.call(f, v), v.defaultPrevented || (v.currentTarget.blur(), n === "start" ? h({ behavior: e }) : u({ behavior: e })));
|
|
1597
|
+
}, [e, n, b, f, u, h]);
|
|
1598
|
+
return dr({ defaultTagName: "button", props: ze({ type: a, inert: !b, tabIndex: b ? o : -1, children: t ?? w("span", { children: ["Scroll to ", n] }), onClick: k }, i), render: s, state: { active: b, direction: n }, stateAttributesMapping: { active: (v) => ({ "data-active": v ? "true" : "false" }) } });
|
|
1599
|
+
}
|
|
1600
|
+
var _e = { Provider: Hr, Root: zr, Viewport: Wr, Content: Vr, Item: Gr, Button: Ur };
|
|
1601
|
+
function Ct(e) {
|
|
1602
|
+
var t, n, r = "";
|
|
1603
|
+
if (typeof e == "string" || typeof e == "number") r += e;
|
|
1318
1604
|
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
1319
1605
|
var s = e.length;
|
|
1320
|
-
for (t = 0; t < s; t++) e[t] && (
|
|
1321
|
-
} else for (
|
|
1322
|
-
return
|
|
1606
|
+
for (t = 0; t < s; t++) e[t] && (n = Ct(e[t])) && (r && (r += " "), r += n);
|
|
1607
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
1608
|
+
return r;
|
|
1323
1609
|
}
|
|
1324
|
-
function
|
|
1325
|
-
for (var e, t,
|
|
1326
|
-
return
|
|
1610
|
+
function jr() {
|
|
1611
|
+
for (var e, t, n = 0, r = "", s = arguments.length; n < s; n++) (e = arguments[n]) && (t = Ct(e)) && (r && (r += " "), r += t);
|
|
1612
|
+
return r;
|
|
1327
1613
|
}
|
|
1328
|
-
function
|
|
1329
|
-
return
|
|
1614
|
+
function we(...e) {
|
|
1615
|
+
return jr(e);
|
|
1330
1616
|
}
|
|
1331
|
-
function
|
|
1332
|
-
return /* @__PURE__ */
|
|
1617
|
+
function Yr(e) {
|
|
1618
|
+
return /* @__PURE__ */ l(_e.Provider, { ...e });
|
|
1333
1619
|
}
|
|
1334
|
-
function
|
|
1620
|
+
function Jr({
|
|
1335
1621
|
className: e,
|
|
1336
1622
|
...t
|
|
1337
1623
|
}) {
|
|
1338
|
-
return /* @__PURE__ */
|
|
1339
|
-
|
|
1624
|
+
return /* @__PURE__ */ l(
|
|
1625
|
+
_e.Root,
|
|
1340
1626
|
{
|
|
1341
1627
|
"data-slot": "message-scroller",
|
|
1342
|
-
className:
|
|
1628
|
+
className: we("msg-scroller-root", e),
|
|
1343
1629
|
...t
|
|
1344
1630
|
}
|
|
1345
1631
|
);
|
|
1346
1632
|
}
|
|
1347
|
-
function
|
|
1633
|
+
function Kr({
|
|
1348
1634
|
className: e,
|
|
1349
1635
|
...t
|
|
1350
1636
|
}) {
|
|
1351
|
-
return /* @__PURE__ */
|
|
1352
|
-
|
|
1637
|
+
return /* @__PURE__ */ l(
|
|
1638
|
+
_e.Viewport,
|
|
1353
1639
|
{
|
|
1354
1640
|
"data-slot": "message-scroller-viewport",
|
|
1355
|
-
className:
|
|
1641
|
+
className: we("msg-scroller-viewport", e),
|
|
1356
1642
|
...t
|
|
1357
1643
|
}
|
|
1358
1644
|
);
|
|
1359
1645
|
}
|
|
1360
|
-
function
|
|
1646
|
+
function Qr({
|
|
1361
1647
|
className: e,
|
|
1362
1648
|
...t
|
|
1363
1649
|
}) {
|
|
1364
|
-
return /* @__PURE__ */
|
|
1365
|
-
|
|
1650
|
+
return /* @__PURE__ */ l(
|
|
1651
|
+
_e.Content,
|
|
1366
1652
|
{
|
|
1367
1653
|
"data-slot": "message-scroller-content",
|
|
1368
|
-
className:
|
|
1654
|
+
className: we("msg-scroller-content", e),
|
|
1369
1655
|
...t
|
|
1370
1656
|
}
|
|
1371
1657
|
);
|
|
1372
1658
|
}
|
|
1373
|
-
function
|
|
1659
|
+
function nt({
|
|
1374
1660
|
className: e,
|
|
1375
1661
|
scrollAnchor: t = !1,
|
|
1376
|
-
...
|
|
1662
|
+
...n
|
|
1377
1663
|
}) {
|
|
1378
|
-
return /* @__PURE__ */
|
|
1379
|
-
|
|
1664
|
+
return /* @__PURE__ */ l(
|
|
1665
|
+
_e.Item,
|
|
1380
1666
|
{
|
|
1381
1667
|
"data-slot": "message-scroller-item",
|
|
1382
1668
|
scrollAnchor: t,
|
|
1383
|
-
className:
|
|
1384
|
-
...
|
|
1669
|
+
className: we("msg-scroller-item", e),
|
|
1670
|
+
...n
|
|
1385
1671
|
}
|
|
1386
1672
|
);
|
|
1387
1673
|
}
|
|
1388
|
-
function
|
|
1674
|
+
function Xr({
|
|
1389
1675
|
direction: e = "end",
|
|
1390
1676
|
className: t,
|
|
1391
|
-
children:
|
|
1392
|
-
...
|
|
1677
|
+
children: n,
|
|
1678
|
+
...r
|
|
1393
1679
|
}) {
|
|
1394
|
-
return /* @__PURE__ */
|
|
1395
|
-
|
|
1680
|
+
return /* @__PURE__ */ l(
|
|
1681
|
+
_e.Button,
|
|
1396
1682
|
{
|
|
1397
1683
|
"data-slot": "message-scroller-button",
|
|
1398
1684
|
direction: e,
|
|
1399
|
-
className:
|
|
1400
|
-
...
|
|
1401
|
-
children:
|
|
1402
|
-
/* @__PURE__ */
|
|
1403
|
-
|
|
1685
|
+
className: we("msg-scroller-btn", t),
|
|
1686
|
+
...r,
|
|
1687
|
+
children: n ?? /* @__PURE__ */ w(De, { children: [
|
|
1688
|
+
/* @__PURE__ */ l(
|
|
1689
|
+
Ot,
|
|
1404
1690
|
{
|
|
1405
1691
|
size: 16,
|
|
1406
1692
|
"aria-hidden": "true",
|
|
1407
1693
|
className: e === "start" ? "rotate-180" : void 0
|
|
1408
1694
|
}
|
|
1409
1695
|
),
|
|
1410
|
-
/* @__PURE__ */
|
|
1696
|
+
/* @__PURE__ */ l("span", { className: "sr-only", children: e === "end" ? "Jump to latest" : "Jump to start" })
|
|
1411
1697
|
] })
|
|
1412
1698
|
}
|
|
1413
1699
|
);
|
|
1414
1700
|
}
|
|
1415
|
-
const
|
|
1416
|
-
/* @__PURE__ */
|
|
1701
|
+
const Zr = () => /* @__PURE__ */ w("div", { className: "chat-empty-row", children: [
|
|
1702
|
+
/* @__PURE__ */ l(
|
|
1417
1703
|
"div",
|
|
1418
1704
|
{
|
|
1419
1705
|
className: "avatar-circle avatar-circle--mt",
|
|
1420
1706
|
"aria-hidden": "true",
|
|
1421
|
-
children: /* @__PURE__ */
|
|
1707
|
+
children: /* @__PURE__ */ l(pt, { size: 15 })
|
|
1422
1708
|
}
|
|
1423
1709
|
),
|
|
1424
|
-
/* @__PURE__ */
|
|
1710
|
+
/* @__PURE__ */ l("div", { className: "chat-empty-bubble", children: /* @__PURE__ */ l("p", { children: "Hello — I am the VPS Veritas assistant. Ask about reports, sample status, registration, or support, or choose a question below the text box." }) })
|
|
1425
1711
|
] });
|
|
1426
|
-
function
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
className: "md-code",
|
|
1431
|
-
children: r.slice(1, -1)
|
|
1432
|
-
},
|
|
1433
|
-
n
|
|
1434
|
-
) : /^https?:\/\//.test(r) ? /* @__PURE__ */ o(
|
|
1435
|
-
"a",
|
|
1436
|
-
{
|
|
1437
|
-
href: r,
|
|
1438
|
-
target: "_blank",
|
|
1439
|
-
rel: "noopener noreferrer",
|
|
1440
|
-
className: "md-link",
|
|
1441
|
-
children: r
|
|
1442
|
-
},
|
|
1443
|
-
n
|
|
1444
|
-
) : /* @__PURE__ */ o(Xe.Fragment, { children: r }, n));
|
|
1712
|
+
function en(e) {
|
|
1713
|
+
const t = e.trim();
|
|
1714
|
+
if (!/[\u0000-\u001f\u007f]/.test(t) && /^(https?:\/\/|mailto:|\/(?!\/)|#)/i.test(t))
|
|
1715
|
+
return t;
|
|
1445
1716
|
}
|
|
1446
|
-
function
|
|
1447
|
-
if (!e) return
|
|
1448
|
-
const t =
|
|
1449
|
-
return
|
|
1450
|
-
if (r
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
const
|
|
1456
|
-
return /* @__PURE__ */
|
|
1457
|
-
|
|
1458
|
-
if (r.startsWith("```")) {
|
|
1459
|
-
const s = r.replace(/^```[a-zA-Z]*\n?/, "").replace(/```$/, "");
|
|
1460
|
-
return /* @__PURE__ */ o(
|
|
1461
|
-
"pre",
|
|
1717
|
+
function te(e) {
|
|
1718
|
+
if (!e) return [];
|
|
1719
|
+
const t = /(\[[^\]]+\]\([^)]+\)|\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|https?:\/\/[^\s]+)/g;
|
|
1720
|
+
return e.split(t).map((r, s) => {
|
|
1721
|
+
if (!r) return null;
|
|
1722
|
+
const o = r.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
|
|
1723
|
+
if (o) {
|
|
1724
|
+
const a = o[1], i = o[2], u = en(i);
|
|
1725
|
+
if (!u) return /* @__PURE__ */ l(oe.Fragment, { children: a }, s);
|
|
1726
|
+
const h = /^https?:\/\//i.test(i);
|
|
1727
|
+
return /* @__PURE__ */ l(
|
|
1728
|
+
"a",
|
|
1462
1729
|
{
|
|
1463
|
-
|
|
1464
|
-
|
|
1730
|
+
href: u,
|
|
1731
|
+
target: h ? "_blank" : void 0,
|
|
1732
|
+
rel: h ? "noopener noreferrer" : void 0,
|
|
1733
|
+
className: "md-link",
|
|
1734
|
+
children: a
|
|
1465
1735
|
},
|
|
1466
|
-
|
|
1736
|
+
s
|
|
1467
1737
|
);
|
|
1468
1738
|
}
|
|
1469
|
-
return /* @__PURE__ */
|
|
1470
|
-
|
|
1739
|
+
return r.startsWith("**") && r.endsWith("**") && r.length >= 4 ? /* @__PURE__ */ l("strong", { children: r.slice(2, -2) }, s) : r.startsWith("*") && r.endsWith("*") && r.length >= 2 ? /* @__PURE__ */ l("em", { children: r.slice(1, -1) }, s) : r.startsWith("`") && r.endsWith("`") && r.length >= 2 ? /* @__PURE__ */ l("code", { className: "md-code", children: r.slice(1, -1) }, s) : /^https?:\/\//i.test(r) ? /* @__PURE__ */ l(
|
|
1740
|
+
"a",
|
|
1741
|
+
{
|
|
1742
|
+
href: r,
|
|
1743
|
+
target: "_blank",
|
|
1744
|
+
rel: "noopener noreferrer",
|
|
1745
|
+
className: "md-link",
|
|
1746
|
+
children: r
|
|
1747
|
+
},
|
|
1748
|
+
s
|
|
1749
|
+
) : /* @__PURE__ */ l(oe.Fragment, { children: r }, s);
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
function tn(e) {
|
|
1753
|
+
const t = e.replace(/\r\n/g, `
|
|
1754
|
+
`).split(`
|
|
1755
|
+
`), n = [];
|
|
1756
|
+
let r = 0;
|
|
1757
|
+
for (; r < t.length; ) {
|
|
1758
|
+
const o = t[r].trim();
|
|
1759
|
+
if (!o) {
|
|
1760
|
+
r++;
|
|
1761
|
+
continue;
|
|
1762
|
+
}
|
|
1763
|
+
if (o.startsWith("```")) {
|
|
1764
|
+
const u = o.slice(3).trim(), h = [];
|
|
1765
|
+
for (r++; r < t.length && !t[r].trim().startsWith("```"); )
|
|
1766
|
+
h.push(t[r]), r++;
|
|
1767
|
+
r < t.length && t[r].trim().startsWith("```") && r++, n.push({ type: "code", lang: u, code: h.join(`
|
|
1768
|
+
`) });
|
|
1769
|
+
continue;
|
|
1770
|
+
}
|
|
1771
|
+
if (/^(---|___|\*\*\*)$/.test(o)) {
|
|
1772
|
+
n.push({ type: "hr" }), r++;
|
|
1773
|
+
continue;
|
|
1774
|
+
}
|
|
1775
|
+
const a = o.match(/^(#{1,4})\s+(.*)$/);
|
|
1776
|
+
if (a) {
|
|
1777
|
+
n.push({
|
|
1778
|
+
type: "h",
|
|
1779
|
+
level: a[1].length,
|
|
1780
|
+
content: a[2]
|
|
1781
|
+
}), r++;
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
if (o.startsWith(">")) {
|
|
1785
|
+
const u = [];
|
|
1786
|
+
for (; r < t.length && t[r].trim().startsWith(">"); )
|
|
1787
|
+
u.push(t[r].trim().replace(/^>\s?/, "")), r++;
|
|
1788
|
+
n.push({ type: "quote", lines: u });
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (/^[-*]\s+/.test(o)) {
|
|
1792
|
+
const u = [];
|
|
1793
|
+
for (; r < t.length && /^[-*]\s+/.test(t[r].trim()); )
|
|
1794
|
+
u.push(t[r].trim().replace(/^[-*]\s+/, "")), r++;
|
|
1795
|
+
n.push({ type: "ul", items: u });
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
if (/^\d+\.\s+/.test(o)) {
|
|
1799
|
+
const u = [];
|
|
1800
|
+
for (; r < t.length && /^\d+\.\s+/.test(t[r].trim()); )
|
|
1801
|
+
u.push(t[r].trim().replace(/^\d+\.\s+/, "")), r++;
|
|
1802
|
+
n.push({ type: "ol", items: u });
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
if (o.startsWith("|") && o.endsWith("|")) {
|
|
1806
|
+
const u = [];
|
|
1807
|
+
for (; r < t.length && t[r].trim().startsWith("|") && t[r].trim().endsWith("|"); )
|
|
1808
|
+
u.push(t[r].trim()), r++;
|
|
1809
|
+
if (u.length >= 2) {
|
|
1810
|
+
const h = (p) => p.slice(1, -1).split("|").map((b) => b.trim()), g = h(u[0]), f = u[1].includes("-") ? 2 : 1, c = u.slice(f).map(h);
|
|
1811
|
+
n.push({ type: "table", headers: g, rows: c });
|
|
1812
|
+
continue;
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
const i = [];
|
|
1816
|
+
for (; r < t.length && t[r].trim() && !t[r].trim().startsWith("```") && !/^(#{1,4})\s+/.test(t[r].trim()) && !/^[-*]\s+/.test(t[r].trim()) && !/^\d+\.\s+/.test(t[r].trim()) && !t[r].trim().startsWith(">") && !/^(---|___|\*\*\*)$/.test(t[r].trim()); )
|
|
1817
|
+
i.push(t[r].trim()), r++;
|
|
1818
|
+
i.length > 0 && n.push({ type: "p", lines: i });
|
|
1819
|
+
}
|
|
1820
|
+
return n;
|
|
1471
1821
|
}
|
|
1472
|
-
const
|
|
1822
|
+
const rn = oe.memo(function({ text: t }) {
|
|
1823
|
+
if (!t) return null;
|
|
1824
|
+
const n = tn(t);
|
|
1825
|
+
return /* @__PURE__ */ l("div", { className: "md-content", children: n.map((r, s) => {
|
|
1826
|
+
switch (r.type) {
|
|
1827
|
+
case "h":
|
|
1828
|
+
return r.level === 1 ? /* @__PURE__ */ l("h2", { className: "md-h1", children: te(r.content) }, s) : r.level === 2 ? /* @__PURE__ */ l("h3", { className: "md-h2", children: te(r.content) }, s) : r.level === 3 ? /* @__PURE__ */ l("h4", { className: "md-h3", children: te(r.content) }, s) : /* @__PURE__ */ l("h5", { className: "md-h4", children: te(r.content) }, s);
|
|
1829
|
+
case "ul":
|
|
1830
|
+
return /* @__PURE__ */ l("ul", { className: "md-ul", children: r.items.map((o, a) => /* @__PURE__ */ l("li", { className: "md-li", children: te(o) }, a)) }, s);
|
|
1831
|
+
case "ol":
|
|
1832
|
+
return /* @__PURE__ */ l("ol", { className: "md-ol", children: r.items.map((o, a) => /* @__PURE__ */ l("li", { className: "md-li", children: te(o) }, a)) }, s);
|
|
1833
|
+
case "code":
|
|
1834
|
+
return /* @__PURE__ */ l("pre", { className: "md-pre", children: /* @__PURE__ */ l("code", { children: r.code }) }, s);
|
|
1835
|
+
case "quote":
|
|
1836
|
+
return /* @__PURE__ */ l("blockquote", { className: "md-quote", children: r.lines.map((o, a) => /* @__PURE__ */ l("p", { children: te(o) }, a)) }, s);
|
|
1837
|
+
case "hr":
|
|
1838
|
+
return /* @__PURE__ */ l("hr", { className: "md-hr" }, s);
|
|
1839
|
+
case "table":
|
|
1840
|
+
return /* @__PURE__ */ l("div", { className: "md-table-wrap", children: /* @__PURE__ */ w("table", { className: "md-table", children: [
|
|
1841
|
+
/* @__PURE__ */ l("thead", { children: /* @__PURE__ */ l("tr", { children: r.headers.map((o, a) => /* @__PURE__ */ l("th", { children: te(o) }, a)) }) }),
|
|
1842
|
+
/* @__PURE__ */ l("tbody", { children: r.rows.map((o, a) => /* @__PURE__ */ l("tr", { children: o.map((i, u) => /* @__PURE__ */ l("td", { children: te(i) }, u)) }, a)) })
|
|
1843
|
+
] }) }, s);
|
|
1844
|
+
case "p":
|
|
1845
|
+
default:
|
|
1846
|
+
return /* @__PURE__ */ l("p", { className: "md-p", children: r.lines.map((o, a) => /* @__PURE__ */ w(oe.Fragment, { children: [
|
|
1847
|
+
te(o),
|
|
1848
|
+
a < r.lines.length - 1 && /* @__PURE__ */ l("br", {})
|
|
1849
|
+
] }, a)) }, s);
|
|
1850
|
+
}
|
|
1851
|
+
}) });
|
|
1852
|
+
}), nn = ({ className: e, text: t }) => /* @__PURE__ */ w(
|
|
1473
1853
|
"div",
|
|
1474
1854
|
{
|
|
1475
|
-
className:
|
|
1855
|
+
className: we("typing-indicator-container", e),
|
|
1476
1856
|
role: "status",
|
|
1477
1857
|
"aria-label": "Assistant is preparing a reply",
|
|
1478
1858
|
children: [
|
|
1479
|
-
/* @__PURE__ */
|
|
1480
|
-
|
|
1481
|
-
|
|
1859
|
+
/* @__PURE__ */ w("div", { className: "typing-indicator", "aria-hidden": "true", children: [
|
|
1860
|
+
/* @__PURE__ */ l("span", { className: "typing-dot" }),
|
|
1861
|
+
/* @__PURE__ */ l("span", { className: "typing-dot" }),
|
|
1862
|
+
/* @__PURE__ */ l("span", { className: "typing-dot" })
|
|
1863
|
+
] }),
|
|
1864
|
+
t && /* @__PURE__ */ l("div", { className: "typing-progress-pill", children: t })
|
|
1482
1865
|
]
|
|
1483
1866
|
}
|
|
1484
|
-
)
|
|
1485
|
-
|
|
1486
|
-
|
|
1867
|
+
), sn = ({
|
|
1868
|
+
status: e = "complete",
|
|
1869
|
+
progressText: t,
|
|
1870
|
+
durationMs: n
|
|
1871
|
+
}) => {
|
|
1872
|
+
const r = e === "pending", [s, o] = U(0);
|
|
1873
|
+
ke(() => {
|
|
1874
|
+
if (!r) return;
|
|
1875
|
+
const i = Date.now(), u = setInterval(() => {
|
|
1876
|
+
o(Number(((Date.now() - i) / 1e3).toFixed(1)));
|
|
1877
|
+
}, 250);
|
|
1878
|
+
return () => clearInterval(u);
|
|
1879
|
+
}, [r]);
|
|
1880
|
+
const a = r ? `${s.toFixed(1)}s` : n === void 0 ? void 0 : `${(n / 1e3).toFixed(1)}s`;
|
|
1881
|
+
return /* @__PURE__ */ l("div", { className: `agent-reasoning-container${r ? " agent-reasoning--active" : ""}`, children: /* @__PURE__ */ l(
|
|
1882
|
+
"div",
|
|
1883
|
+
{
|
|
1884
|
+
className: "agent-reasoning-header",
|
|
1885
|
+
role: "status",
|
|
1886
|
+
"aria-live": "off",
|
|
1887
|
+
children: /* @__PURE__ */ w("div", { className: "agent-reasoning-header-left", children: [
|
|
1888
|
+
r ? /* @__PURE__ */ l(
|
|
1889
|
+
Kt,
|
|
1890
|
+
{
|
|
1891
|
+
size: 13,
|
|
1892
|
+
className: "agent-reasoning-spinner",
|
|
1893
|
+
"aria-hidden": "true"
|
|
1894
|
+
}
|
|
1895
|
+
) : /* @__PURE__ */ l(
|
|
1896
|
+
Ut,
|
|
1897
|
+
{
|
|
1898
|
+
size: 13,
|
|
1899
|
+
className: "agent-reasoning-done-icon",
|
|
1900
|
+
"aria-hidden": "true"
|
|
1901
|
+
}
|
|
1902
|
+
),
|
|
1903
|
+
/* @__PURE__ */ l("span", { className: "agent-reasoning-title", children: r ? `${t || "Working…"} · ${a}` : a ? `Response generated in ${a}` : "Response generated" })
|
|
1904
|
+
] })
|
|
1905
|
+
}
|
|
1906
|
+
) });
|
|
1907
|
+
}, on = {
|
|
1908
|
+
"fuel-defect-reporting": {
|
|
1909
|
+
label: "Fuel Defect Reporting",
|
|
1910
|
+
path: "/dashboard/fuel-Defect-Reporting"
|
|
1911
|
+
},
|
|
1912
|
+
"bunker-master": {
|
|
1913
|
+
label: "Bunker Master",
|
|
1914
|
+
path: "/dashboard/bunker-master"
|
|
1915
|
+
},
|
|
1916
|
+
"fsc-fsq-e-forms": {
|
|
1917
|
+
label: "Pre-Registration & E-Forms",
|
|
1918
|
+
path: "/dashboard/pre-registration"
|
|
1919
|
+
},
|
|
1920
|
+
"pre-registration-ship": {
|
|
1921
|
+
label: "Pre-Registration",
|
|
1922
|
+
path: "/dashboard/pre-registration"
|
|
1923
|
+
},
|
|
1924
|
+
"reports-fuel": {
|
|
1925
|
+
label: "Fuel Reports",
|
|
1926
|
+
path: "/dashboard/reports"
|
|
1927
|
+
},
|
|
1928
|
+
"sample-fuel": {
|
|
1929
|
+
label: "Sample Status",
|
|
1930
|
+
path: "/dashboard/sample-status"
|
|
1931
|
+
}
|
|
1932
|
+
};
|
|
1933
|
+
function ln(e) {
|
|
1934
|
+
const n = (e.split(/[/\\]/).pop() || "").replace(/\.md$/i, "").toLowerCase();
|
|
1935
|
+
for (const [r, s] of Object.entries(on))
|
|
1936
|
+
if (n.includes(r))
|
|
1937
|
+
return s;
|
|
1938
|
+
return null;
|
|
1487
1939
|
}
|
|
1488
|
-
function
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1940
|
+
function st(e) {
|
|
1941
|
+
return e.title ? e.title : (e.source.split(/[/\\]/).pop() || e.source).replace(/\.md$/i, "").replace(/[-_]/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
|
|
1942
|
+
}
|
|
1943
|
+
const an = ({
|
|
1944
|
+
sources: e,
|
|
1945
|
+
hideInspectSources: t = !1,
|
|
1946
|
+
showInspectSources: n = !0,
|
|
1947
|
+
defaultExpanded: r = !1,
|
|
1948
|
+
maxSources: s = 5
|
|
1949
|
+
}) => {
|
|
1950
|
+
const o = t || n === !1, [a, i] = U(r && !o), [u, h] = U(null);
|
|
1951
|
+
if (!e || !e.length) return null;
|
|
1952
|
+
const g = e.slice(0, s);
|
|
1953
|
+
return /* @__PURE__ */ w("div", { className: "grounded-sources-card", children: [
|
|
1954
|
+
/* @__PURE__ */ w("div", { className: "grounded-sources-header", children: [
|
|
1955
|
+
/* @__PURE__ */ w("div", { className: "grounded-sources-badge", children: [
|
|
1956
|
+
/* @__PURE__ */ l(er, { size: 13, className: "grounded-shield-icon" }),
|
|
1957
|
+
/* @__PURE__ */ w("span", { children: [
|
|
1958
|
+
g.length,
|
|
1959
|
+
" retrieved VPS sources"
|
|
1960
|
+
] })
|
|
1961
|
+
] }),
|
|
1962
|
+
!o && /* @__PURE__ */ w(
|
|
1963
|
+
"button",
|
|
1964
|
+
{
|
|
1965
|
+
type: "button",
|
|
1966
|
+
className: "grounded-toggle-btn",
|
|
1967
|
+
onClick: () => i((f) => !f),
|
|
1968
|
+
"aria-expanded": a,
|
|
1969
|
+
children: [
|
|
1970
|
+
/* @__PURE__ */ l("span", { children: a ? "Hide Details" : "Inspect Sources" }),
|
|
1971
|
+
a ? /* @__PURE__ */ l(Gt, { size: 12 }) : /* @__PURE__ */ l(Vt, { size: 12 })
|
|
1972
|
+
]
|
|
1973
|
+
}
|
|
1974
|
+
)
|
|
1975
|
+
] }),
|
|
1976
|
+
/* @__PURE__ */ l("div", { className: "grounded-pills-row", children: g.map((f, c) => {
|
|
1977
|
+
const p = st(f), b = u === c;
|
|
1978
|
+
return /* @__PURE__ */ w(
|
|
1979
|
+
"button",
|
|
1980
|
+
{
|
|
1981
|
+
type: "button",
|
|
1982
|
+
className: `grounded-source-pill${b ? " grounded-source-pill--selected" : ""}`,
|
|
1983
|
+
onClick: () => {
|
|
1984
|
+
o || (i(!0), h(b ? null : c));
|
|
1985
|
+
},
|
|
1986
|
+
title: f.source,
|
|
1987
|
+
children: [
|
|
1988
|
+
/* @__PURE__ */ l(zt, { size: 11, className: "grounded-book-icon" }),
|
|
1989
|
+
/* @__PURE__ */ w("span", { className: "grounded-pill-title", children: [
|
|
1990
|
+
"[S",
|
|
1991
|
+
c + 1,
|
|
1992
|
+
"] ",
|
|
1993
|
+
p
|
|
1994
|
+
] }),
|
|
1995
|
+
/* @__PURE__ */ w("span", { className: "grounded-pill-score", title: "Ranking score, not a probability of correctness", children: [
|
|
1996
|
+
"Score ",
|
|
1997
|
+
f.score.toFixed(2)
|
|
1998
|
+
] })
|
|
1999
|
+
]
|
|
2000
|
+
},
|
|
2001
|
+
`${f.chunkId}-${c}`
|
|
2002
|
+
);
|
|
2003
|
+
}) }),
|
|
2004
|
+
!o && a && /* @__PURE__ */ l("div", { className: "grounded-sources-details-list", children: g.map((f, c) => {
|
|
2005
|
+
const p = st(f), b = ln(f.source);
|
|
2006
|
+
return /* @__PURE__ */ w(
|
|
2007
|
+
"div",
|
|
2008
|
+
{
|
|
2009
|
+
className: `grounded-detail-item${u === c ? " grounded-detail-item--highlighted" : ""}`,
|
|
2010
|
+
children: [
|
|
2011
|
+
/* @__PURE__ */ w("div", { className: "grounded-detail-top", children: [
|
|
2012
|
+
/* @__PURE__ */ w("div", { className: "grounded-detail-title-group", children: [
|
|
2013
|
+
/* @__PURE__ */ w("span", { className: "grounded-detail-index", children: [
|
|
2014
|
+
"[",
|
|
2015
|
+
c + 1,
|
|
2016
|
+
"]"
|
|
2017
|
+
] }),
|
|
2018
|
+
/* @__PURE__ */ l("span", { className: "grounded-detail-title", children: p })
|
|
2019
|
+
] }),
|
|
2020
|
+
/* @__PURE__ */ w("div", { className: "grounded-detail-meta", children: [
|
|
2021
|
+
/* @__PURE__ */ w("span", { className: "grounded-detail-score", children: [
|
|
2022
|
+
"Rank score ",
|
|
2023
|
+
f.score.toFixed(2)
|
|
2024
|
+
] }),
|
|
2025
|
+
b && /* @__PURE__ */ w(
|
|
2026
|
+
"a",
|
|
2027
|
+
{
|
|
2028
|
+
href: b.path,
|
|
2029
|
+
onClick: (v) => {
|
|
2030
|
+
v.preventDefault(), window.location.href = b.path;
|
|
2031
|
+
},
|
|
2032
|
+
className: "grounded-route-link",
|
|
2033
|
+
title: `Navigate to ${b.label}`,
|
|
2034
|
+
children: [
|
|
2035
|
+
/* @__PURE__ */ l("span", { children: b.label }),
|
|
2036
|
+
/* @__PURE__ */ l(Yt, { size: 10 })
|
|
2037
|
+
]
|
|
2038
|
+
}
|
|
2039
|
+
)
|
|
2040
|
+
] })
|
|
2041
|
+
] }),
|
|
2042
|
+
/* @__PURE__ */ l("div", { className: "grounded-detail-path", children: /* @__PURE__ */ l("code", { children: f.source }) }),
|
|
2043
|
+
f.snippet && /* @__PURE__ */ w("p", { className: "grounded-detail-snippet", children: [
|
|
2044
|
+
'"',
|
|
2045
|
+
f.snippet,
|
|
2046
|
+
'"'
|
|
2047
|
+
] })
|
|
2048
|
+
]
|
|
2049
|
+
},
|
|
2050
|
+
`detail-${f.chunkId}-${c}`
|
|
2051
|
+
);
|
|
2052
|
+
}) })
|
|
2053
|
+
] });
|
|
2054
|
+
};
|
|
2055
|
+
function cn(e) {
|
|
2056
|
+
return e === "create_ticket" ? "Support ticket processed" : e === "get_customer" ? "Account verified" : e === "get_ticket" ? "Ticket status loaded" : "Information retrieved";
|
|
1522
2057
|
}
|
|
1523
|
-
function
|
|
1524
|
-
return e.length ? /* @__PURE__ */
|
|
2058
|
+
function un({ toolCalls: e }) {
|
|
2059
|
+
return e.length ? /* @__PURE__ */ l("div", { className: "tool-badges", children: e.map((t, n) => /* @__PURE__ */ l(
|
|
1525
2060
|
"span",
|
|
1526
2061
|
{
|
|
1527
2062
|
className: "tool-badge",
|
|
1528
|
-
children:
|
|
2063
|
+
children: cn(t.toolName)
|
|
1529
2064
|
},
|
|
1530
|
-
`${t.toolName}-${
|
|
2065
|
+
`${t.toolName}-${n}`
|
|
1531
2066
|
)) }) : null;
|
|
1532
2067
|
}
|
|
1533
|
-
const
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
2068
|
+
const dn = ({ message: e }) => {
|
|
2069
|
+
var g;
|
|
2070
|
+
const t = Ge(), n = (t == null ? void 0 : t.hideInspectSources) ?? !1, r = (t == null ? void 0 : t.showGroundedSources) ?? !0, s = e.role === "user", o = e.status === "error", a = e.status === "pending", i = e.id === "welcome-default" || e.id.startsWith("welcome") || e.id === "welcome", u = !!(a || e.durationMs !== void 0 || e.sources && e.sources.length > 0 || e.toolCalls && e.toolCalls.length > 0 || e.usage);
|
|
2071
|
+
return /* @__PURE__ */ w("div", { className: `msg-row${s ? " msg-row--user" : ""}`, children: [
|
|
2072
|
+
!s && /* @__PURE__ */ l(
|
|
1537
2073
|
"div",
|
|
1538
2074
|
{
|
|
1539
2075
|
className: "avatar-circle avatar-circle--mt",
|
|
1540
2076
|
"aria-hidden": "true",
|
|
1541
|
-
children: /* @__PURE__ */
|
|
2077
|
+
children: /* @__PURE__ */ l(pt, { size: 15 })
|
|
1542
2078
|
}
|
|
1543
2079
|
),
|
|
1544
|
-
/* @__PURE__ */
|
|
1545
|
-
/* @__PURE__ */
|
|
2080
|
+
/* @__PURE__ */ w("div", { className: `msg-col${s ? " msg-col--user" : ""}`, children: [
|
|
2081
|
+
/* @__PURE__ */ w(
|
|
1546
2082
|
"div",
|
|
1547
2083
|
{
|
|
1548
|
-
className:
|
|
2084
|
+
className: s ? "msg-bubble msg-bubble--user" : o ? "msg-bubble msg-bubble--error" : "msg-bubble msg-bubble--bot",
|
|
1549
2085
|
children: [
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
2086
|
+
!s && !o && !i && u && /* @__PURE__ */ l(
|
|
2087
|
+
sn,
|
|
2088
|
+
{
|
|
2089
|
+
status: a ? "pending" : "complete",
|
|
2090
|
+
progressText: e.progressText,
|
|
2091
|
+
durationMs: e.durationMs
|
|
2092
|
+
}
|
|
2093
|
+
),
|
|
2094
|
+
a ? e.content ? /* @__PURE__ */ l("div", { className: "msg-content-wrapper msg-content-wrapper--streaming", children: /* @__PURE__ */ l("div", { className: "msg-streaming-text", children: e.content }) }) : /* @__PURE__ */ l(nn, {}) : s ? /* @__PURE__ */ l("p", { className: "msg-user-pre", children: e.content }) : /* @__PURE__ */ l("div", { className: "msg-content-wrapper", children: /* @__PURE__ */ l(rn, { text: e.content }) }),
|
|
2095
|
+
e.toolCalls ? /* @__PURE__ */ l(un, { toolCalls: e.toolCalls }) : null,
|
|
2096
|
+
!s && !a && !o && r && ((g = e.sources) != null && g.length) ? /* @__PURE__ */ l(an, { sources: e.sources, hideInspectSources: n }) : null
|
|
1553
2097
|
]
|
|
1554
2098
|
}
|
|
1555
2099
|
),
|
|
1556
|
-
|
|
2100
|
+
s && e.status !== "error" && /* @__PURE__ */ l(Wt, { size: 13, className: "msg-tick", "aria-hidden": "true" })
|
|
1557
2101
|
] })
|
|
1558
2102
|
] });
|
|
1559
|
-
},
|
|
1560
|
-
const { messages: e, status: t, showSuggestions:
|
|
1561
|
-
return /* @__PURE__ */
|
|
1562
|
-
|
|
2103
|
+
}, hn = () => {
|
|
2104
|
+
const { messages: e, status: t, showSuggestions: n } = Be();
|
|
2105
|
+
return /* @__PURE__ */ l(
|
|
2106
|
+
Yr,
|
|
1563
2107
|
{
|
|
1564
2108
|
autoScroll: !0,
|
|
1565
2109
|
defaultScrollPosition: "last-anchor",
|
|
1566
2110
|
scrollPreviousItemPeek: 64,
|
|
1567
|
-
children: /* @__PURE__ */
|
|
1568
|
-
/* @__PURE__ */
|
|
1569
|
-
|
|
1570
|
-
e.map((s) => /* @__PURE__ */
|
|
1571
|
-
|
|
2111
|
+
children: /* @__PURE__ */ w(Jr, { children: [
|
|
2112
|
+
/* @__PURE__ */ l(Kr, { "aria-label": "Chat messages", children: /* @__PURE__ */ w(Qr, { "aria-busy": t === "awaiting" || t === "connecting", children: [
|
|
2113
|
+
e.length === 0 && /* @__PURE__ */ l(nt, { messageId: "welcome", children: /* @__PURE__ */ l(Zr, {}) }),
|
|
2114
|
+
e.map((s) => /* @__PURE__ */ l(
|
|
2115
|
+
nt,
|
|
1572
2116
|
{
|
|
1573
2117
|
messageId: s.id,
|
|
1574
2118
|
scrollAnchor: s.role === "user",
|
|
1575
|
-
children: /* @__PURE__ */
|
|
2119
|
+
children: /* @__PURE__ */ l(dn, { message: s })
|
|
1576
2120
|
},
|
|
1577
2121
|
s.id
|
|
1578
2122
|
))
|
|
1579
2123
|
] }) }),
|
|
1580
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ l(Xr, {})
|
|
1581
2125
|
] })
|
|
1582
2126
|
}
|
|
1583
2127
|
);
|
|
1584
|
-
},
|
|
1585
|
-
const { pendingTicket: e, ticketBusy: t, userContext:
|
|
1586
|
-
return e ? /* @__PURE__ */
|
|
2128
|
+
}, pn = () => {
|
|
2129
|
+
const { pendingTicket: e, ticketBusy: t, userContext: n, confirmTicket: r, cancelTicket: s } = Be(), o = !n.customerId && !n.email, [a, i] = U("");
|
|
2130
|
+
return e ? /* @__PURE__ */ w(
|
|
1587
2131
|
"div",
|
|
1588
2132
|
{
|
|
1589
2133
|
className: "ticket-card",
|
|
1590
2134
|
role: "region",
|
|
1591
2135
|
"aria-label": "Create support ticket",
|
|
1592
2136
|
children: [
|
|
1593
|
-
/* @__PURE__ */
|
|
1594
|
-
/* @__PURE__ */
|
|
1595
|
-
/* @__PURE__ */
|
|
1596
|
-
|
|
2137
|
+
/* @__PURE__ */ l("h3", { className: "ticket-card-title", children: "Create support ticket?" }),
|
|
2138
|
+
/* @__PURE__ */ l("p", { className: "ticket-card-desc", children: "I can open a support request for you. Nothing is created until you confirm." }),
|
|
2139
|
+
/* @__PURE__ */ l("p", { className: "ticket-card-body", children: e.description }),
|
|
2140
|
+
o && /* @__PURE__ */ w("label", { className: "ticket-id-label", children: [
|
|
1597
2141
|
"Customer ID or email",
|
|
1598
|
-
/* @__PURE__ */
|
|
2142
|
+
/* @__PURE__ */ l(
|
|
1599
2143
|
"input",
|
|
1600
2144
|
{
|
|
1601
2145
|
value: a,
|
|
1602
|
-
onChange: (
|
|
2146
|
+
onChange: (u) => i(u.target.value),
|
|
1603
2147
|
className: "ticket-id-input",
|
|
1604
2148
|
placeholder: "CUST-1001 or you@company.com",
|
|
1605
2149
|
autoComplete: "email"
|
|
1606
2150
|
}
|
|
1607
2151
|
)
|
|
1608
2152
|
] }),
|
|
1609
|
-
/* @__PURE__ */
|
|
1610
|
-
/* @__PURE__ */
|
|
2153
|
+
/* @__PURE__ */ w("div", { className: "ticket-actions", children: [
|
|
2154
|
+
/* @__PURE__ */ l(
|
|
1611
2155
|
"button",
|
|
1612
2156
|
{
|
|
1613
2157
|
type: "button",
|
|
@@ -1617,12 +2161,12 @@ const Qr = ({ message: e }) => {
|
|
|
1617
2161
|
children: "Cancel"
|
|
1618
2162
|
}
|
|
1619
2163
|
),
|
|
1620
|
-
/* @__PURE__ */
|
|
2164
|
+
/* @__PURE__ */ l(
|
|
1621
2165
|
"button",
|
|
1622
2166
|
{
|
|
1623
2167
|
type: "button",
|
|
1624
|
-
onClick: () => void
|
|
1625
|
-
disabled: t ||
|
|
2168
|
+
onClick: () => void r(a),
|
|
2169
|
+
disabled: t || o && !a.trim(),
|
|
1626
2170
|
className: "ticket-confirm-btn",
|
|
1627
2171
|
children: t ? "Creating…" : "Create ticket"
|
|
1628
2172
|
}
|
|
@@ -1631,72 +2175,72 @@ const Qr = ({ message: e }) => {
|
|
|
1631
2175
|
]
|
|
1632
2176
|
}
|
|
1633
2177
|
) : null;
|
|
1634
|
-
},
|
|
2178
|
+
}, St = ({
|
|
1635
2179
|
className: e,
|
|
1636
2180
|
onClose: t,
|
|
1637
|
-
showMinimize:
|
|
1638
|
-
title:
|
|
2181
|
+
showMinimize: n,
|
|
2182
|
+
title: r,
|
|
1639
2183
|
subtitle: s,
|
|
1640
|
-
envStage:
|
|
2184
|
+
envStage: o,
|
|
1641
2185
|
envPulse: a = !0
|
|
1642
2186
|
}) => {
|
|
1643
|
-
const { sendMessage: i, status:
|
|
1644
|
-
return /* @__PURE__ */
|
|
2187
|
+
const { sendMessage: i, status: u, error: h, resetConversation: g, retryLast: f, pendingTicket: c } = Be(), p = u === "awaiting" || u === "connecting" || !!c;
|
|
2188
|
+
return /* @__PURE__ */ w(
|
|
1645
2189
|
"section",
|
|
1646
2190
|
{
|
|
1647
2191
|
className: `chat-panel${e ? ` ${e}` : ""}`,
|
|
1648
2192
|
"aria-label": "VPS AI Assistant",
|
|
1649
2193
|
children: [
|
|
1650
|
-
/* @__PURE__ */
|
|
1651
|
-
|
|
2194
|
+
/* @__PURE__ */ l(
|
|
2195
|
+
lr,
|
|
1652
2196
|
{
|
|
1653
|
-
title:
|
|
2197
|
+
title: r,
|
|
1654
2198
|
subtitle: s,
|
|
1655
2199
|
onClose: t,
|
|
1656
2200
|
onReset: () => void g(),
|
|
1657
|
-
showMinimize:
|
|
1658
|
-
envStage:
|
|
2201
|
+
showMinimize: n,
|
|
2202
|
+
envStage: o,
|
|
1659
2203
|
envPulse: a
|
|
1660
2204
|
}
|
|
1661
2205
|
),
|
|
1662
|
-
/* @__PURE__ */
|
|
1663
|
-
h &&
|
|
1664
|
-
/* @__PURE__ */
|
|
1665
|
-
/* @__PURE__ */
|
|
1666
|
-
|
|
2206
|
+
/* @__PURE__ */ l("div", { className: "chat-panel-body", children: /* @__PURE__ */ l(hn, {}) }),
|
|
2207
|
+
h && u === "error" && /* @__PURE__ */ l(Pt, { message: h, onRetry: () => void f() }),
|
|
2208
|
+
/* @__PURE__ */ l(pn, {}),
|
|
2209
|
+
/* @__PURE__ */ l(
|
|
2210
|
+
ur,
|
|
1667
2211
|
{
|
|
1668
|
-
onSend: (
|
|
1669
|
-
disabled:
|
|
2212
|
+
onSend: (b) => void i(b),
|
|
2213
|
+
disabled: p
|
|
1670
2214
|
}
|
|
1671
2215
|
)
|
|
1672
2216
|
]
|
|
1673
2217
|
}
|
|
1674
2218
|
);
|
|
1675
|
-
},
|
|
2219
|
+
}, fn = ({
|
|
1676
2220
|
open: e,
|
|
1677
2221
|
onClose: t,
|
|
1678
|
-
envStage:
|
|
1679
|
-
envPulse:
|
|
1680
|
-
}) => e ? /* @__PURE__ */
|
|
2222
|
+
envStage: n,
|
|
2223
|
+
envPulse: r = !0
|
|
2224
|
+
}) => e ? /* @__PURE__ */ l(
|
|
1681
2225
|
"div",
|
|
1682
2226
|
{
|
|
1683
2227
|
id: "vps-chatbot-widget-panel",
|
|
1684
2228
|
className: "widget-panel",
|
|
1685
|
-
children: /* @__PURE__ */
|
|
1686
|
-
|
|
2229
|
+
children: /* @__PURE__ */ l(
|
|
2230
|
+
St,
|
|
1687
2231
|
{
|
|
1688
2232
|
onClose: t,
|
|
1689
2233
|
showMinimize: !0,
|
|
1690
2234
|
title: "VPS AI Assistant",
|
|
1691
|
-
envStage:
|
|
1692
|
-
envPulse:
|
|
2235
|
+
envStage: n,
|
|
2236
|
+
envPulse: r
|
|
1693
2237
|
}
|
|
1694
2238
|
)
|
|
1695
2239
|
}
|
|
1696
|
-
) : null,
|
|
2240
|
+
) : null, mn = ({
|
|
1697
2241
|
open: e,
|
|
1698
2242
|
onToggle: t
|
|
1699
|
-
}) => /* @__PURE__ */
|
|
2243
|
+
}) => /* @__PURE__ */ l(
|
|
1700
2244
|
"button",
|
|
1701
2245
|
{
|
|
1702
2246
|
type: "button",
|
|
@@ -1705,61 +2249,75 @@ const Qr = ({ message: e }) => {
|
|
|
1705
2249
|
"aria-controls": "vps-chatbot-widget-panel",
|
|
1706
2250
|
"aria-label": e ? "Close assistant" : "Open assistant",
|
|
1707
2251
|
className: "widget-trigger-btn",
|
|
1708
|
-
children: e ? /* @__PURE__ */
|
|
2252
|
+
children: e ? /* @__PURE__ */ l(rr, { size: 22 }) : /* @__PURE__ */ l(ft, { size: 24 })
|
|
1709
2253
|
}
|
|
1710
|
-
),
|
|
2254
|
+
), ot = ({
|
|
1711
2255
|
defaultOpen: e = !1,
|
|
1712
2256
|
open: t,
|
|
1713
|
-
onOpenChange:
|
|
1714
|
-
envStage:
|
|
2257
|
+
onOpenChange: n,
|
|
2258
|
+
envStage: r,
|
|
1715
2259
|
envPulse: s = !0
|
|
1716
2260
|
}) => {
|
|
1717
|
-
const [
|
|
1718
|
-
|
|
2261
|
+
const [o, a] = U(e), i = t ?? o, u = (h) => {
|
|
2262
|
+
n == null || n(h), t === void 0 && a(h);
|
|
1719
2263
|
};
|
|
1720
|
-
return /* @__PURE__ */
|
|
1721
|
-
/* @__PURE__ */
|
|
1722
|
-
|
|
2264
|
+
return /* @__PURE__ */ w(De, { children: [
|
|
2265
|
+
/* @__PURE__ */ l(
|
|
2266
|
+
fn,
|
|
1723
2267
|
{
|
|
1724
2268
|
open: i,
|
|
1725
|
-
onClose: () =>
|
|
1726
|
-
envStage:
|
|
2269
|
+
onClose: () => u(!1),
|
|
2270
|
+
envStage: r,
|
|
1727
2271
|
envPulse: s
|
|
1728
2272
|
}
|
|
1729
2273
|
),
|
|
1730
|
-
/* @__PURE__ */
|
|
2274
|
+
/* @__PURE__ */ l(mn, { open: i, onToggle: () => u(!i) })
|
|
1731
2275
|
] });
|
|
1732
|
-
},
|
|
2276
|
+
}, Fn = ({
|
|
1733
2277
|
apiBaseUrl: e,
|
|
1734
2278
|
apiUrl: t,
|
|
1735
|
-
proxyUrl:
|
|
1736
|
-
userContext:
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
2279
|
+
proxyUrl: n,
|
|
2280
|
+
userContext: r,
|
|
2281
|
+
role: s,
|
|
2282
|
+
roleId: o,
|
|
2283
|
+
client: a,
|
|
2284
|
+
welcomeMessage: i,
|
|
2285
|
+
suggestions: u,
|
|
2286
|
+
disableSuggestions: h,
|
|
2287
|
+
initialMessage: g,
|
|
2288
|
+
hideInspectSources: f,
|
|
2289
|
+
showGroundedSources: c,
|
|
2290
|
+
modelId: p,
|
|
2291
|
+
...b
|
|
1741
2292
|
}) => {
|
|
1742
|
-
const
|
|
1743
|
-
return !!
|
|
1744
|
-
|
|
2293
|
+
const k = Ge(), v = e ?? t ?? n;
|
|
2294
|
+
return !!k && (!v || ve(v) === ve(k == null ? void 0 : k.apiBaseUrl)) && !r && s === void 0 && o === void 0 && a === void 0 && i === void 0 && !u && h === void 0 && !g && f === void 0 && c === void 0 && p === void 0 ? /* @__PURE__ */ l(ot, { ...b }) : /* @__PURE__ */ l(
|
|
2295
|
+
dt,
|
|
1745
2296
|
{
|
|
1746
|
-
apiBaseUrl:
|
|
1747
|
-
userContext:
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
2297
|
+
apiBaseUrl: v,
|
|
2298
|
+
userContext: r,
|
|
2299
|
+
role: s,
|
|
2300
|
+
roleId: o,
|
|
2301
|
+
client: a,
|
|
2302
|
+
welcomeMessage: i,
|
|
2303
|
+
suggestions: u,
|
|
2304
|
+
disableSuggestions: h,
|
|
2305
|
+
initialMessage: g,
|
|
2306
|
+
hideInspectSources: f,
|
|
2307
|
+
showGroundedSources: c,
|
|
2308
|
+
modelId: p,
|
|
2309
|
+
children: /* @__PURE__ */ l(ot, { ...b })
|
|
1752
2310
|
}
|
|
1753
2311
|
);
|
|
1754
|
-
},
|
|
2312
|
+
}, gn = ({
|
|
1755
2313
|
open: e,
|
|
1756
2314
|
onClose: t,
|
|
1757
|
-
subtitle:
|
|
1758
|
-
title:
|
|
2315
|
+
subtitle: n,
|
|
2316
|
+
title: r,
|
|
1759
2317
|
envStage: s,
|
|
1760
|
-
envPulse:
|
|
1761
|
-
}) => /* @__PURE__ */
|
|
1762
|
-
/* @__PURE__ */
|
|
2318
|
+
envPulse: o = !0
|
|
2319
|
+
}) => /* @__PURE__ */ w(De, { children: [
|
|
2320
|
+
/* @__PURE__ */ l(
|
|
1763
2321
|
"div",
|
|
1764
2322
|
{
|
|
1765
2323
|
className: `embedded-overlay ${e ? "embedded-overlay--open" : "embedded-overlay--closed"}`,
|
|
@@ -1768,38 +2326,38 @@ const Qr = ({ message: e }) => {
|
|
|
1768
2326
|
"aria-hidden": "true"
|
|
1769
2327
|
}
|
|
1770
2328
|
),
|
|
1771
|
-
/* @__PURE__ */
|
|
2329
|
+
/* @__PURE__ */ l(
|
|
1772
2330
|
"aside",
|
|
1773
2331
|
{
|
|
1774
2332
|
id: "vps-embedded-chat-panel",
|
|
1775
2333
|
className: `embedded-panel ${e ? "embedded-panel--open" : "embedded-panel--closed"}`,
|
|
1776
2334
|
"aria-hidden": !e,
|
|
1777
|
-
children: e && /* @__PURE__ */
|
|
1778
|
-
|
|
2335
|
+
children: e && /* @__PURE__ */ l(
|
|
2336
|
+
St,
|
|
1779
2337
|
{
|
|
1780
2338
|
onClose: t,
|
|
1781
|
-
title:
|
|
1782
|
-
subtitle:
|
|
2339
|
+
title: r || "VPS AI Assistant",
|
|
2340
|
+
subtitle: n,
|
|
1783
2341
|
envStage: s,
|
|
1784
|
-
envPulse:
|
|
2342
|
+
envPulse: o
|
|
1785
2343
|
}
|
|
1786
2344
|
)
|
|
1787
2345
|
}
|
|
1788
2346
|
)
|
|
1789
|
-
] }),
|
|
1790
|
-
function
|
|
1791
|
-
return Math.min(
|
|
1792
|
-
}
|
|
1793
|
-
function
|
|
1794
|
-
const
|
|
1795
|
-
|
|
1796
|
-
window.innerHeight - t -
|
|
2347
|
+
] }), bn = 5, $e = 8, Ft = "vps-embedded-assistant-top";
|
|
2348
|
+
function vn(e, t, n) {
|
|
2349
|
+
return Math.min(n, Math.max(t, e));
|
|
2350
|
+
}
|
|
2351
|
+
function lt(e, t) {
|
|
2352
|
+
const n = Math.max(
|
|
2353
|
+
$e,
|
|
2354
|
+
window.innerHeight - t - $e
|
|
1797
2355
|
);
|
|
1798
|
-
return
|
|
2356
|
+
return vn(e, $e, n);
|
|
1799
2357
|
}
|
|
1800
|
-
function
|
|
2358
|
+
function _n() {
|
|
1801
2359
|
try {
|
|
1802
|
-
const e = window.localStorage.getItem(
|
|
2360
|
+
const e = window.localStorage.getItem(Ft);
|
|
1803
2361
|
if (!e) return null;
|
|
1804
2362
|
const t = Number(e);
|
|
1805
2363
|
return Number.isFinite(t) ? t : null;
|
|
@@ -1807,78 +2365,78 @@ function an() {
|
|
|
1807
2365
|
return null;
|
|
1808
2366
|
}
|
|
1809
2367
|
}
|
|
1810
|
-
function
|
|
2368
|
+
function wn(e) {
|
|
1811
2369
|
try {
|
|
1812
|
-
window.localStorage.setItem(
|
|
2370
|
+
window.localStorage.setItem(Ft, String(e));
|
|
1813
2371
|
} catch {
|
|
1814
2372
|
}
|
|
1815
2373
|
}
|
|
1816
|
-
const
|
|
2374
|
+
const yn = ({
|
|
1817
2375
|
onOpen: e
|
|
1818
2376
|
}) => {
|
|
1819
|
-
const t =
|
|
2377
|
+
const t = re(null), n = re({
|
|
1820
2378
|
pointerId: null,
|
|
1821
2379
|
startY: 0,
|
|
1822
2380
|
startTop: 0,
|
|
1823
2381
|
moved: !1
|
|
1824
|
-
}), [
|
|
1825
|
-
() => typeof window > "u" ? null :
|
|
1826
|
-
),
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
}, [
|
|
1830
|
-
const
|
|
1831
|
-
if (!
|
|
1832
|
-
const
|
|
1833
|
-
s((
|
|
1834
|
-
const
|
|
1835
|
-
return
|
|
2382
|
+
}), [r, s] = U(
|
|
2383
|
+
() => typeof window > "u" ? null : _n()
|
|
2384
|
+
), o = re(r), a = re(!1), [i, u] = U(!1);
|
|
2385
|
+
ke(() => {
|
|
2386
|
+
o.current = r;
|
|
2387
|
+
}, [r]), ke(() => {
|
|
2388
|
+
const c = t.current;
|
|
2389
|
+
if (!c) return;
|
|
2390
|
+
const p = () => {
|
|
2391
|
+
s((b) => {
|
|
2392
|
+
const k = b ?? Math.round(window.innerHeight / 2 - c.offsetHeight / 2), v = lt(k, c.offsetHeight);
|
|
2393
|
+
return o.current = v, v;
|
|
1836
2394
|
});
|
|
1837
2395
|
};
|
|
1838
|
-
return
|
|
2396
|
+
return p(), window.addEventListener("resize", p), () => window.removeEventListener("resize", p);
|
|
1839
2397
|
}, []);
|
|
1840
|
-
const h = (
|
|
1841
|
-
if (
|
|
1842
|
-
const
|
|
1843
|
-
|
|
1844
|
-
pointerId:
|
|
1845
|
-
startY:
|
|
1846
|
-
startTop:
|
|
2398
|
+
const h = (c) => {
|
|
2399
|
+
if (c.button !== 0) return;
|
|
2400
|
+
const p = c.currentTarget, b = p.getBoundingClientRect();
|
|
2401
|
+
n.current = {
|
|
2402
|
+
pointerId: c.pointerId,
|
|
2403
|
+
startY: c.clientY,
|
|
2404
|
+
startTop: b.top,
|
|
1847
2405
|
moved: !1
|
|
1848
2406
|
};
|
|
1849
2407
|
try {
|
|
1850
|
-
|
|
2408
|
+
p.setPointerCapture(c.pointerId);
|
|
1851
2409
|
} catch {
|
|
1852
2410
|
}
|
|
1853
|
-
}, g = (
|
|
1854
|
-
if (
|
|
1855
|
-
const
|
|
1856
|
-
if (!
|
|
1857
|
-
|
|
1858
|
-
const
|
|
1859
|
-
|
|
1860
|
-
|
|
2411
|
+
}, g = (c) => {
|
|
2412
|
+
if (n.current.pointerId !== c.pointerId) return;
|
|
2413
|
+
const p = c.clientY - n.current.startY;
|
|
2414
|
+
if (!n.current.moved && Math.abs(p) < bn) return;
|
|
2415
|
+
n.current.moved = !0, u(!0);
|
|
2416
|
+
const b = lt(
|
|
2417
|
+
n.current.startTop + p,
|
|
2418
|
+
c.currentTarget.offsetHeight
|
|
1861
2419
|
);
|
|
1862
|
-
|
|
1863
|
-
},
|
|
1864
|
-
var
|
|
1865
|
-
if (
|
|
2420
|
+
o.current = b, s(b);
|
|
2421
|
+
}, f = (c) => {
|
|
2422
|
+
var b, k;
|
|
2423
|
+
if (n.current.pointerId !== c.pointerId) return;
|
|
1866
2424
|
try {
|
|
1867
|
-
(
|
|
2425
|
+
(k = (b = c.currentTarget).hasPointerCapture) != null && k.call(b, c.pointerId) && c.currentTarget.releasePointerCapture(c.pointerId);
|
|
1868
2426
|
} catch {
|
|
1869
2427
|
}
|
|
1870
|
-
const
|
|
1871
|
-
|
|
2428
|
+
const p = n.current.moved;
|
|
2429
|
+
n.current.pointerId = null, n.current.moved = !1, u(!1), p && (a.current = !0, o.current != null && wn(o.current));
|
|
1872
2430
|
};
|
|
1873
|
-
return /* @__PURE__ */
|
|
2431
|
+
return /* @__PURE__ */ w(
|
|
1874
2432
|
"button",
|
|
1875
2433
|
{
|
|
1876
2434
|
ref: t,
|
|
1877
2435
|
type: "button",
|
|
1878
2436
|
onPointerDown: h,
|
|
1879
2437
|
onPointerMove: g,
|
|
1880
|
-
onPointerUp:
|
|
1881
|
-
onPointerCancel:
|
|
2438
|
+
onPointerUp: f,
|
|
2439
|
+
onPointerCancel: f,
|
|
1882
2440
|
onClick: () => {
|
|
1883
2441
|
if (a.current) {
|
|
1884
2442
|
a.current = !1;
|
|
@@ -1891,61 +2449,75 @@ const un = ({
|
|
|
1891
2449
|
"aria-label": "Assistant",
|
|
1892
2450
|
className: `embedded-trigger-btn ${i ? "embedded-trigger-btn--grabbing" : "embedded-trigger-btn--grab"}`,
|
|
1893
2451
|
style: {
|
|
1894
|
-
top:
|
|
1895
|
-
transform:
|
|
2452
|
+
top: r ?? "50%",
|
|
2453
|
+
transform: r == null ? "translateY(-50%)" : void 0
|
|
1896
2454
|
},
|
|
1897
2455
|
children: [
|
|
1898
|
-
/* @__PURE__ */
|
|
2456
|
+
/* @__PURE__ */ l(ft, { size: 16 }),
|
|
1899
2457
|
"Assistant"
|
|
1900
2458
|
]
|
|
1901
2459
|
}
|
|
1902
2460
|
);
|
|
1903
|
-
},
|
|
2461
|
+
}, at = ({
|
|
1904
2462
|
defaultOpen: e = !1,
|
|
1905
2463
|
open: t,
|
|
1906
|
-
onOpenChange:
|
|
1907
|
-
showTrigger:
|
|
2464
|
+
onOpenChange: n,
|
|
2465
|
+
showTrigger: r = !0,
|
|
1908
2466
|
envStage: s,
|
|
1909
|
-
envPulse:
|
|
2467
|
+
envPulse: o = !0
|
|
1910
2468
|
}) => {
|
|
1911
|
-
const [a, i] =
|
|
1912
|
-
|
|
2469
|
+
const [a, i] = U(e), u = t ?? a, h = (g) => {
|
|
2470
|
+
n == null || n(g), t === void 0 && i(g);
|
|
1913
2471
|
};
|
|
1914
|
-
return /* @__PURE__ */
|
|
1915
|
-
|
|
1916
|
-
/* @__PURE__ */
|
|
1917
|
-
|
|
2472
|
+
return /* @__PURE__ */ w(De, { children: [
|
|
2473
|
+
r && !u && /* @__PURE__ */ l(yn, { onOpen: () => h(!0) }),
|
|
2474
|
+
/* @__PURE__ */ l(
|
|
2475
|
+
gn,
|
|
1918
2476
|
{
|
|
1919
|
-
open:
|
|
2477
|
+
open: u,
|
|
1920
2478
|
onClose: () => h(!1),
|
|
1921
2479
|
envStage: s,
|
|
1922
|
-
envPulse:
|
|
2480
|
+
envPulse: o
|
|
1923
2481
|
}
|
|
1924
2482
|
)
|
|
1925
2483
|
] });
|
|
1926
|
-
},
|
|
2484
|
+
}, Tn = ({
|
|
1927
2485
|
apiBaseUrl: e,
|
|
1928
2486
|
apiUrl: t,
|
|
1929
|
-
proxyUrl:
|
|
1930
|
-
userContext:
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
2487
|
+
proxyUrl: n,
|
|
2488
|
+
userContext: r,
|
|
2489
|
+
role: s,
|
|
2490
|
+
roleId: o,
|
|
2491
|
+
client: a,
|
|
2492
|
+
welcomeMessage: i,
|
|
2493
|
+
suggestions: u,
|
|
2494
|
+
disableSuggestions: h,
|
|
2495
|
+
initialMessage: g,
|
|
2496
|
+
hideInspectSources: f,
|
|
2497
|
+
showGroundedSources: c,
|
|
2498
|
+
modelId: p,
|
|
2499
|
+
...b
|
|
1935
2500
|
}) => {
|
|
1936
|
-
const
|
|
1937
|
-
return !!
|
|
1938
|
-
|
|
2501
|
+
const k = Ge(), v = e ?? t ?? n;
|
|
2502
|
+
return !!k && (!v || ve(v) === ve(k == null ? void 0 : k.apiBaseUrl)) && !r && s === void 0 && o === void 0 && a === void 0 && i === void 0 && !u && h === void 0 && !g && f === void 0 && c === void 0 && p === void 0 ? /* @__PURE__ */ l(at, { ...b }) : /* @__PURE__ */ l(
|
|
2503
|
+
dt,
|
|
1939
2504
|
{
|
|
1940
|
-
apiBaseUrl:
|
|
1941
|
-
userContext:
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2505
|
+
apiBaseUrl: v,
|
|
2506
|
+
userContext: r,
|
|
2507
|
+
role: s,
|
|
2508
|
+
roleId: o,
|
|
2509
|
+
client: a,
|
|
2510
|
+
welcomeMessage: i,
|
|
2511
|
+
suggestions: u,
|
|
2512
|
+
disableSuggestions: h,
|
|
2513
|
+
initialMessage: g,
|
|
2514
|
+
hideInspectSources: f,
|
|
2515
|
+
showGroundedSources: c,
|
|
2516
|
+
modelId: p,
|
|
2517
|
+
children: /* @__PURE__ */ l(at, { ...b })
|
|
1946
2518
|
}
|
|
1947
2519
|
);
|
|
1948
|
-
},
|
|
2520
|
+
}, En = {
|
|
1949
2521
|
Colors: {
|
|
1950
2522
|
VPS_White: "#fff",
|
|
1951
2523
|
VPS_Dark_Blue: "#1A1A31",
|
|
@@ -2110,16 +2682,16 @@ const un = ({
|
|
|
2110
2682
|
}
|
|
2111
2683
|
};
|
|
2112
2684
|
export {
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2685
|
+
St as ChatPanel,
|
|
2686
|
+
dt as ChatProvider,
|
|
2687
|
+
Fn as ChatbotWidget,
|
|
2688
|
+
En as ColorPalette,
|
|
2689
|
+
Tn as EmbeddedChatbot,
|
|
2690
|
+
Pe as buildApiUrl,
|
|
2691
|
+
Sn as chatApi,
|
|
2692
|
+
ut as createChatApi,
|
|
2693
|
+
ve as resolveApiBaseUrl,
|
|
2694
|
+
Mt as useChatContext,
|
|
2695
|
+
Be as useChatbot,
|
|
2696
|
+
Ge as useOptionalChatContext
|
|
2125
2697
|
};
|