claudius-chat-widget 1.12.0 → 1.13.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/claudius.cjs +6 -6
- package/dist/claudius.css +1 -1
- package/dist/claudius.iife.js +14 -14
- package/dist/claudius.js +852 -739
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/package.json +1 -1
package/dist/claudius.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { jsx as a, jsxs as
|
|
5
|
-
import { useMemo as
|
|
6
|
-
class
|
|
1
|
+
var Ce = Object.defineProperty;
|
|
2
|
+
var Ne = (e, t, r) => t in e ? Ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var X = (e, t, r) => Ne(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { jsx as a, jsxs as g, Fragment as xe } from "react/jsx-runtime";
|
|
5
|
+
import { useMemo as se, useState as L, useRef as I, useCallback as O, useEffect as z, forwardRef as ke, memo as de, useId as Le } from "react";
|
|
6
|
+
class j extends Error {
|
|
7
7
|
/**
|
|
8
8
|
* Create a {@link ChatApiError}.
|
|
9
9
|
*
|
|
@@ -12,11 +12,11 @@ class H extends Error {
|
|
|
12
12
|
* @param code - Optional machine-readable error code (e.g. `"TIMEOUT"`, `"NETWORK_ERROR"`).
|
|
13
13
|
* @param retryAfter - Seconds to wait before retrying, from the `Retry-After` header.
|
|
14
14
|
*/
|
|
15
|
-
constructor(
|
|
16
|
-
super(
|
|
15
|
+
constructor(t, r, n, s) {
|
|
16
|
+
super(t), this.status = r, this.code = n, this.retryAfter = s, this.name = "ChatApiError";
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
class
|
|
19
|
+
class le extends Error {
|
|
20
20
|
/** Creates a `DebounceError` with a fixed message. */
|
|
21
21
|
constructor() {
|
|
22
22
|
super("Request debounced"), this.name = "DebounceError";
|
|
@@ -30,13 +30,13 @@ class Oe {
|
|
|
30
30
|
* @param baseUrl - Base URL of the Worker. Requests post to `${baseUrl}/api/chat`.
|
|
31
31
|
* @param options - Optional retry, debounce, and timeout settings.
|
|
32
32
|
*/
|
|
33
|
-
constructor(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
this.baseUrl =
|
|
33
|
+
constructor(t, r) {
|
|
34
|
+
X(this, "baseUrl");
|
|
35
|
+
X(this, "maxRetries");
|
|
36
|
+
X(this, "debounceMs");
|
|
37
|
+
X(this, "timeoutMs");
|
|
38
|
+
X(this, "lastSendTime", 0);
|
|
39
|
+
this.baseUrl = t, this.maxRetries = (r == null ? void 0 : r.maxRetries) ?? 2, this.debounceMs = (r == null ? void 0 : r.debounceMs) ?? 300, this.timeoutMs = (r == null ? void 0 : r.timeoutMs) ?? Ae;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Send the conversation to the chat endpoint and return the assistant's
|
|
@@ -48,22 +48,22 @@ class Oe {
|
|
|
48
48
|
* @throws {@link DebounceError} when called within the debounce window.
|
|
49
49
|
* @throws {@link ChatApiError} when the request fails after all retries.
|
|
50
50
|
*/
|
|
51
|
-
async sendMessage(
|
|
51
|
+
async sendMessage(t) {
|
|
52
52
|
if (this.debounceMs > 0 && Date.now() - this.lastSendTime < this.debounceMs)
|
|
53
|
-
throw new
|
|
53
|
+
throw new le();
|
|
54
54
|
this.lastSendTime = Date.now();
|
|
55
55
|
let r;
|
|
56
56
|
for (let n = 0; n <= this.maxRetries; n++)
|
|
57
57
|
try {
|
|
58
|
-
const s = await this.fetchWithTimeout(
|
|
58
|
+
const s = await this.fetchWithTimeout(t);
|
|
59
59
|
if (s.ok)
|
|
60
60
|
return await s.json();
|
|
61
|
-
const o = await s.json().catch(() => ({})), i = s.headers.get("Retry-After"),
|
|
62
|
-
if (r = new
|
|
61
|
+
const o = await s.json().catch(() => ({})), i = s.headers.get("Retry-After"), l = i ? Number(i) : void 0;
|
|
62
|
+
if (r = new j(
|
|
63
63
|
o.error ?? `Request failed with status ${s.status}`,
|
|
64
64
|
s.status,
|
|
65
65
|
o.code,
|
|
66
|
-
|
|
66
|
+
l
|
|
67
67
|
), !this.isRetryable(s.status))
|
|
68
68
|
throw r;
|
|
69
69
|
if (n < this.maxRetries) {
|
|
@@ -71,14 +71,14 @@ class Oe {
|
|
|
71
71
|
await this.delay(c);
|
|
72
72
|
}
|
|
73
73
|
} catch (s) {
|
|
74
|
-
if (s instanceof
|
|
74
|
+
if (s instanceof j) {
|
|
75
75
|
if (!this.isRetryable(s.status, s.code))
|
|
76
76
|
throw s;
|
|
77
77
|
if (r = s, n < this.maxRetries) {
|
|
78
78
|
const o = this.getRetryDelay(null, n);
|
|
79
79
|
await this.delay(o);
|
|
80
80
|
}
|
|
81
|
-
} else if (r = new
|
|
81
|
+
} else if (r = new j(
|
|
82
82
|
"Failed to connect. Please try again.",
|
|
83
83
|
0,
|
|
84
84
|
"NETWORK_ERROR"
|
|
@@ -109,22 +109,22 @@ class Oe {
|
|
|
109
109
|
* @throws {@link ChatApiError} when the request fails after all retries, or
|
|
110
110
|
* the stream errors or is interrupted mid-reply (code `"STREAM_ERROR"`).
|
|
111
111
|
*/
|
|
112
|
-
async streamMessage(
|
|
112
|
+
async streamMessage(t, r = {}) {
|
|
113
113
|
var s;
|
|
114
114
|
if (typeof ReadableStream > "u")
|
|
115
|
-
return this.sendMessage(
|
|
115
|
+
return this.sendMessage(t);
|
|
116
116
|
if (this.debounceMs > 0 && Date.now() - this.lastSendTime < this.debounceMs)
|
|
117
|
-
throw new
|
|
117
|
+
throw new le();
|
|
118
118
|
this.lastSendTime = Date.now();
|
|
119
119
|
let n;
|
|
120
120
|
for (let o = 0; o <= this.maxRetries; o++) {
|
|
121
121
|
let i;
|
|
122
122
|
try {
|
|
123
|
-
i = await this.fetchStream(
|
|
123
|
+
i = await this.fetchStream(t, r.signal);
|
|
124
124
|
} catch (c) {
|
|
125
125
|
if ((s = r.signal) != null && s.aborted)
|
|
126
126
|
return { reply: "", aborted: !0 };
|
|
127
|
-
if (n = c instanceof
|
|
127
|
+
if (n = c instanceof j ? c : new j(
|
|
128
128
|
"Failed to connect. Please try again.",
|
|
129
129
|
0,
|
|
130
130
|
"NETWORK_ERROR"
|
|
@@ -134,14 +134,14 @@ class Oe {
|
|
|
134
134
|
continue;
|
|
135
135
|
}
|
|
136
136
|
if (i.status === 404 || i.status === 405)
|
|
137
|
-
return this.lastSendTime = 0, this.sendMessage(
|
|
137
|
+
return this.lastSendTime = 0, this.sendMessage(t);
|
|
138
138
|
if (!i.ok) {
|
|
139
|
-
const c = await i.json().catch(() => ({})),
|
|
140
|
-
if (n = new
|
|
139
|
+
const c = await i.json().catch(() => ({})), u = i.headers.get("Retry-After");
|
|
140
|
+
if (n = new j(
|
|
141
141
|
c.error ?? `Request failed with status ${i.status}`,
|
|
142
142
|
i.status,
|
|
143
143
|
c.code,
|
|
144
|
-
|
|
144
|
+
u ? Number(u) : void 0
|
|
145
145
|
), !this.isRetryable(i.status))
|
|
146
146
|
throw n;
|
|
147
147
|
o < this.maxRetries && await this.delay(this.getRetryDelay(i, o));
|
|
@@ -151,9 +151,9 @@ class Oe {
|
|
|
151
151
|
try {
|
|
152
152
|
return await i.json();
|
|
153
153
|
} catch {
|
|
154
|
-
return this.lastSendTime = 0, this.sendMessage(
|
|
154
|
+
return this.lastSendTime = 0, this.sendMessage(t);
|
|
155
155
|
}
|
|
156
|
-
return i.body ? this.readSseStream(i.body, r) : (this.lastSendTime = 0, this.sendMessage(
|
|
156
|
+
return i.body ? this.readSseStream(i.body, r) : (this.lastSendTime = 0, this.sendMessage(t));
|
|
157
157
|
}
|
|
158
158
|
throw n;
|
|
159
159
|
}
|
|
@@ -162,45 +162,54 @@ class Oe {
|
|
|
162
162
|
* `done`, throwing on `error` events or an interrupted connection, and
|
|
163
163
|
* resolving with the partial text when the caller aborts.
|
|
164
164
|
*/
|
|
165
|
-
async readSseStream(
|
|
166
|
-
var
|
|
167
|
-
const n =
|
|
168
|
-
let o = "", i = ""
|
|
169
|
-
const
|
|
165
|
+
async readSseStream(t, r) {
|
|
166
|
+
var d, x, N, R, T, p, v;
|
|
167
|
+
const n = t.getReader(), s = new TextDecoder();
|
|
168
|
+
let o = "", i = "";
|
|
169
|
+
const l = [];
|
|
170
|
+
let c;
|
|
171
|
+
const u = () => {
|
|
170
172
|
n.cancel().catch(() => {
|
|
171
173
|
});
|
|
172
174
|
};
|
|
173
|
-
(
|
|
175
|
+
(d = r.signal) == null || d.addEventListener("abort", u, { once: !0 });
|
|
174
176
|
try {
|
|
175
177
|
for (; ; ) {
|
|
176
|
-
let
|
|
178
|
+
let k;
|
|
177
179
|
try {
|
|
178
|
-
|
|
179
|
-
} catch (
|
|
180
|
-
if ((
|
|
181
|
-
throw
|
|
180
|
+
k = await n.read();
|
|
181
|
+
} catch (w) {
|
|
182
|
+
if ((x = r.signal) != null && x.aborted) break;
|
|
183
|
+
throw w;
|
|
182
184
|
}
|
|
183
|
-
if ((
|
|
184
|
-
o += s.decode(
|
|
185
|
-
let
|
|
186
|
-
for (; (
|
|
185
|
+
if ((N = r.signal) != null && N.aborted || k.done) break;
|
|
186
|
+
o += s.decode(k.value, { stream: !0 });
|
|
187
|
+
let H;
|
|
188
|
+
for (; (H = o.indexOf(`
|
|
187
189
|
|
|
188
190
|
`)) !== -1; ) {
|
|
189
|
-
const
|
|
190
|
-
o = o.slice(
|
|
191
|
-
const
|
|
192
|
-
if (
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
} else if (
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
191
|
+
const w = o.slice(0, H);
|
|
192
|
+
o = o.slice(H + 2);
|
|
193
|
+
const f = Ie(w);
|
|
194
|
+
if (f) {
|
|
195
|
+
if (f.event === "chunk") {
|
|
196
|
+
const E = typeof f.data.text == "string" ? f.data.text : "";
|
|
197
|
+
E && (i += E, (R = r.onChunk) == null || R.call(r, E, i));
|
|
198
|
+
} else if (f.event === "tool") {
|
|
199
|
+
if (typeof f.data.name == "string") {
|
|
200
|
+
const E = f.data;
|
|
201
|
+
l.push(E), (T = r.onToolUse) == null || T.call(r, E, l);
|
|
202
|
+
}
|
|
203
|
+
} else if (f.event === "done") {
|
|
204
|
+
const E = Array.isArray(f.data.toolUses) ? f.data.toolUses : l;
|
|
205
|
+
c = {
|
|
206
|
+
reply: typeof f.data.reply == "string" ? f.data.reply : i,
|
|
207
|
+
sources: f.data.sources,
|
|
208
|
+
...E.length > 0 ? { toolUses: E } : {}
|
|
200
209
|
};
|
|
201
|
-
else if (
|
|
202
|
-
throw new
|
|
203
|
-
typeof
|
|
210
|
+
} else if (f.event === "error")
|
|
211
|
+
throw new j(
|
|
212
|
+
typeof f.data.error == "string" ? f.data.error : "Something went wrong. Please try again.",
|
|
204
213
|
0,
|
|
205
214
|
"STREAM_ERROR"
|
|
206
215
|
);
|
|
@@ -208,18 +217,22 @@ class Oe {
|
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
219
|
} finally {
|
|
211
|
-
(
|
|
220
|
+
(p = r.signal) == null || p.removeEventListener("abort", u), n.releaseLock();
|
|
212
221
|
}
|
|
213
|
-
if ((
|
|
214
|
-
return {
|
|
215
|
-
|
|
216
|
-
|
|
222
|
+
if ((v = r.signal) != null && v.aborted)
|
|
223
|
+
return {
|
|
224
|
+
reply: i,
|
|
225
|
+
aborted: !0,
|
|
226
|
+
...l.length > 0 ? { toolUses: l } : {}
|
|
227
|
+
};
|
|
228
|
+
if (c) return c;
|
|
229
|
+
throw new j(
|
|
217
230
|
"Connection interrupted. Please try again.",
|
|
218
231
|
0,
|
|
219
232
|
"STREAM_ERROR"
|
|
220
233
|
);
|
|
221
234
|
}
|
|
222
|
-
async fetchStream(
|
|
235
|
+
async fetchStream(t, r) {
|
|
223
236
|
const n = new AbortController(), s = () => n.abort();
|
|
224
237
|
r == null || r.addEventListener("abort", s, { once: !0 });
|
|
225
238
|
let o = !1;
|
|
@@ -230,36 +243,36 @@ class Oe {
|
|
|
230
243
|
return await fetch(`${this.baseUrl}/api/chat/stream`, {
|
|
231
244
|
method: "POST",
|
|
232
245
|
headers: { "Content-Type": "application/json" },
|
|
233
|
-
body: JSON.stringify({ messages:
|
|
246
|
+
body: JSON.stringify({ messages: t }),
|
|
234
247
|
signal: n.signal
|
|
235
248
|
});
|
|
236
|
-
} catch (
|
|
237
|
-
throw o ? new
|
|
249
|
+
} catch (l) {
|
|
250
|
+
throw o ? new j(
|
|
238
251
|
"Request timed out. Please try again.",
|
|
239
252
|
0,
|
|
240
253
|
"TIMEOUT"
|
|
241
|
-
) :
|
|
254
|
+
) : l;
|
|
242
255
|
} finally {
|
|
243
256
|
i !== void 0 && clearTimeout(i), r == null || r.removeEventListener("abort", s);
|
|
244
257
|
}
|
|
245
258
|
}
|
|
246
|
-
async fetchWithTimeout(
|
|
259
|
+
async fetchWithTimeout(t) {
|
|
247
260
|
if (this.timeoutMs <= 0)
|
|
248
261
|
return fetch(`${this.baseUrl}/api/chat`, {
|
|
249
262
|
method: "POST",
|
|
250
263
|
headers: { "Content-Type": "application/json" },
|
|
251
|
-
body: JSON.stringify({ messages:
|
|
264
|
+
body: JSON.stringify({ messages: t })
|
|
252
265
|
});
|
|
253
266
|
const r = new AbortController(), n = setTimeout(() => r.abort(), this.timeoutMs);
|
|
254
267
|
try {
|
|
255
268
|
return await fetch(`${this.baseUrl}/api/chat`, {
|
|
256
269
|
method: "POST",
|
|
257
270
|
headers: { "Content-Type": "application/json" },
|
|
258
|
-
body: JSON.stringify({ messages:
|
|
271
|
+
body: JSON.stringify({ messages: t }),
|
|
259
272
|
signal: r.signal
|
|
260
273
|
});
|
|
261
274
|
} catch (s) {
|
|
262
|
-
throw r.signal.aborted ? new
|
|
275
|
+
throw r.signal.aborted ? new j(
|
|
263
276
|
"Request timed out. Please try again.",
|
|
264
277
|
0,
|
|
265
278
|
"TIMEOUT"
|
|
@@ -268,12 +281,12 @@ class Oe {
|
|
|
268
281
|
clearTimeout(n);
|
|
269
282
|
}
|
|
270
283
|
}
|
|
271
|
-
isRetryable(
|
|
272
|
-
return r === "TIMEOUT" || r === "NETWORK_ERROR" ? !0 :
|
|
284
|
+
isRetryable(t, r) {
|
|
285
|
+
return r === "TIMEOUT" || r === "NETWORK_ERROR" ? !0 : t === 429 || t === 503;
|
|
273
286
|
}
|
|
274
|
-
getRetryDelay(
|
|
275
|
-
if (
|
|
276
|
-
const n =
|
|
287
|
+
getRetryDelay(t, r) {
|
|
288
|
+
if (t && t.status === 429) {
|
|
289
|
+
const n = t.headers.get("Retry-After");
|
|
277
290
|
if (n) {
|
|
278
291
|
const s = Number(n);
|
|
279
292
|
return Math.min(s * 1e3, 6e4);
|
|
@@ -281,111 +294,111 @@ class Oe {
|
|
|
281
294
|
}
|
|
282
295
|
return r === 0 ? 1e3 : 3e3;
|
|
283
296
|
}
|
|
284
|
-
delay(
|
|
285
|
-
return new Promise((r) => setTimeout(r,
|
|
297
|
+
delay(t) {
|
|
298
|
+
return new Promise((r) => setTimeout(r, t));
|
|
286
299
|
}
|
|
287
300
|
}
|
|
288
|
-
function Ie(
|
|
289
|
-
let
|
|
301
|
+
function Ie(e) {
|
|
302
|
+
let t = "message";
|
|
290
303
|
const r = [];
|
|
291
|
-
for (const n of
|
|
304
|
+
for (const n of e.split(`
|
|
292
305
|
`))
|
|
293
|
-
n.startsWith("event:") ?
|
|
306
|
+
n.startsWith("event:") ? t = n.slice(6).trim() : n.startsWith("data:") && r.push(n.slice(5).trimStart());
|
|
294
307
|
if (r.length === 0) return null;
|
|
295
308
|
try {
|
|
296
309
|
const n = JSON.parse(r.join(`
|
|
297
310
|
`));
|
|
298
|
-
return typeof n != "object" || n === null ? null : { event:
|
|
311
|
+
return typeof n != "object" || n === null ? null : { event: t, data: n };
|
|
299
312
|
} catch {
|
|
300
313
|
return null;
|
|
301
314
|
}
|
|
302
315
|
}
|
|
303
|
-
function
|
|
304
|
-
return typeof
|
|
316
|
+
function we(e) {
|
|
317
|
+
return typeof e == "string" ? { content: e } : e;
|
|
305
318
|
}
|
|
306
|
-
function
|
|
307
|
-
console.error(`[claudius] plugin "${
|
|
319
|
+
function fe(e, t, r) {
|
|
320
|
+
console.error(`[claudius] plugin "${e.name}" failed in ${t}:`, r);
|
|
308
321
|
}
|
|
309
|
-
async function De(
|
|
310
|
-
let n =
|
|
311
|
-
for (const s of
|
|
322
|
+
async function De(e, t, r) {
|
|
323
|
+
let n = t;
|
|
324
|
+
for (const s of e) {
|
|
312
325
|
if (!s.onBeforeSend) continue;
|
|
313
326
|
let o = null;
|
|
314
327
|
const i = {
|
|
315
328
|
...r,
|
|
316
|
-
respondWith(
|
|
329
|
+
respondWith(l) {
|
|
317
330
|
o = {
|
|
318
331
|
type: "respond",
|
|
319
332
|
message: n,
|
|
320
|
-
reply:
|
|
333
|
+
reply: we(l)
|
|
321
334
|
};
|
|
322
335
|
},
|
|
323
|
-
abort(
|
|
324
|
-
o = { type: "abort", reason:
|
|
336
|
+
abort(l) {
|
|
337
|
+
o = { type: "abort", reason: l };
|
|
325
338
|
}
|
|
326
339
|
};
|
|
327
340
|
try {
|
|
328
|
-
const
|
|
341
|
+
const l = await s.onBeforeSend(n, i);
|
|
329
342
|
if (o) return o;
|
|
330
|
-
|
|
331
|
-
} catch (
|
|
332
|
-
|
|
343
|
+
l && (n = l);
|
|
344
|
+
} catch (l) {
|
|
345
|
+
fe(s, "onBeforeSend", l);
|
|
333
346
|
}
|
|
334
347
|
}
|
|
335
348
|
return { type: "send", message: n };
|
|
336
349
|
}
|
|
337
|
-
async function _e(
|
|
338
|
-
let n =
|
|
339
|
-
for (const s of
|
|
350
|
+
async function _e(e, t, r) {
|
|
351
|
+
let n = t;
|
|
352
|
+
for (const s of e)
|
|
340
353
|
if (s.onAfterReceive)
|
|
341
354
|
try {
|
|
342
355
|
const o = await s.onAfterReceive(n, r);
|
|
343
356
|
o && (n = o);
|
|
344
357
|
} catch (o) {
|
|
345
|
-
|
|
358
|
+
fe(s, "onAfterReceive", o);
|
|
346
359
|
}
|
|
347
360
|
return n;
|
|
348
361
|
}
|
|
349
|
-
async function
|
|
350
|
-
for (const n of
|
|
362
|
+
async function je(e, t, r) {
|
|
363
|
+
for (const n of e) {
|
|
351
364
|
if (!n.onError) continue;
|
|
352
365
|
let s = null;
|
|
353
366
|
const o = {
|
|
354
367
|
...r,
|
|
355
368
|
respondWith(i) {
|
|
356
|
-
s =
|
|
369
|
+
s = we(i);
|
|
357
370
|
}
|
|
358
371
|
};
|
|
359
372
|
try {
|
|
360
|
-
if (await n.onError(
|
|
373
|
+
if (await n.onError(t, o), s) return s;
|
|
361
374
|
} catch (i) {
|
|
362
|
-
|
|
375
|
+
fe(n, "onError", i);
|
|
363
376
|
}
|
|
364
377
|
}
|
|
365
378
|
return null;
|
|
366
379
|
}
|
|
367
|
-
const
|
|
368
|
-
function $e(
|
|
380
|
+
const He = 200, Be = "claudius:messages";
|
|
381
|
+
function $e(e, t) {
|
|
369
382
|
let r;
|
|
370
383
|
try {
|
|
371
|
-
r = new URL(
|
|
384
|
+
r = new URL(t).host;
|
|
372
385
|
} catch {
|
|
373
|
-
r =
|
|
386
|
+
r = t;
|
|
374
387
|
}
|
|
375
|
-
return `${
|
|
388
|
+
return `${e}:${r}`;
|
|
376
389
|
}
|
|
377
|
-
function
|
|
390
|
+
function ue() {
|
|
378
391
|
try {
|
|
379
392
|
return typeof sessionStorage < "u" ? sessionStorage : null;
|
|
380
393
|
} catch {
|
|
381
394
|
return null;
|
|
382
395
|
}
|
|
383
396
|
}
|
|
384
|
-
function Pe(
|
|
385
|
-
const
|
|
386
|
-
if (!
|
|
397
|
+
function Pe(e) {
|
|
398
|
+
const t = ue();
|
|
399
|
+
if (!t) return [];
|
|
387
400
|
try {
|
|
388
|
-
const r =
|
|
401
|
+
const r = t.getItem(e);
|
|
389
402
|
if (!r) return [];
|
|
390
403
|
const n = JSON.parse(r);
|
|
391
404
|
return Array.isArray(n) ? n : [];
|
|
@@ -393,270 +406,279 @@ function Pe(t) {
|
|
|
393
406
|
return [];
|
|
394
407
|
}
|
|
395
408
|
}
|
|
396
|
-
function
|
|
397
|
-
apiUrl:
|
|
398
|
-
persistMessages:
|
|
409
|
+
function Ue({
|
|
410
|
+
apiUrl: e,
|
|
411
|
+
persistMessages: t = !0,
|
|
399
412
|
storageKeyPrefix: r = Be,
|
|
400
413
|
timeoutMs: n,
|
|
401
414
|
translations: s,
|
|
402
415
|
plugins: o,
|
|
403
416
|
streaming: i = !0
|
|
404
417
|
}) {
|
|
405
|
-
const
|
|
406
|
-
() => new Oe(
|
|
407
|
-
[
|
|
408
|
-
), c = $e(r,
|
|
418
|
+
const l = se(
|
|
419
|
+
() => new Oe(e, { debounceMs: 0, timeoutMs: n }),
|
|
420
|
+
[e, n]
|
|
421
|
+
), c = $e(r, e), u = t ? Pe(c) : [], [d, x] = L(u), [N, R] = L(!1), [T, p] = L(!1), [v, k] = L(
|
|
409
422
|
null
|
|
410
|
-
), [
|
|
423
|
+
), [H, w] = L(null), [f, E] = L(!1), F = I(u.length), W = I(!1), y = I(u), K = I(null), B = I(o ?? []);
|
|
411
424
|
B.current = o ?? [];
|
|
412
|
-
const _ =
|
|
413
|
-
(
|
|
414
|
-
if (!
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
425
|
+
const _ = O(
|
|
426
|
+
(h) => {
|
|
427
|
+
if (!t) return;
|
|
428
|
+
const A = ue();
|
|
429
|
+
if (A)
|
|
417
430
|
try {
|
|
418
|
-
const
|
|
419
|
-
|
|
431
|
+
const S = h.slice(-He);
|
|
432
|
+
A.setItem(c, JSON.stringify(S));
|
|
420
433
|
} catch {
|
|
421
434
|
}
|
|
422
435
|
},
|
|
423
|
-
[
|
|
424
|
-
),
|
|
425
|
-
(
|
|
436
|
+
[t, c]
|
|
437
|
+
), m = () => (F.current += 1, `msg-${F.current}`), V = O(
|
|
438
|
+
(h, A) => {
|
|
426
439
|
if (!s)
|
|
427
|
-
return
|
|
428
|
-
switch (
|
|
440
|
+
return A ?? "Something went wrong. Please try again.";
|
|
441
|
+
switch (h) {
|
|
429
442
|
case "TIMEOUT":
|
|
430
443
|
return s.errorTimeout;
|
|
431
444
|
case "NETWORK_ERROR":
|
|
432
445
|
return s.errorConnection;
|
|
433
446
|
case "RATE_LIMITED":
|
|
434
|
-
return
|
|
447
|
+
return A != null && A.includes("minute") ? s.errorRateLimitMinute : s.errorRateLimitHour;
|
|
435
448
|
case "VALIDATION_ERROR":
|
|
436
449
|
case "CONFIG_ERROR":
|
|
437
450
|
case "SERVICE_ERROR":
|
|
438
451
|
case "UNKNOWN_ERROR":
|
|
439
452
|
default:
|
|
440
|
-
return
|
|
453
|
+
return A ?? s.errorGeneric;
|
|
441
454
|
}
|
|
442
455
|
},
|
|
443
456
|
[s]
|
|
444
|
-
),
|
|
445
|
-
async (
|
|
446
|
-
|
|
447
|
-
const
|
|
448
|
-
let
|
|
449
|
-
const
|
|
450
|
-
if (
|
|
451
|
-
|
|
452
|
-
const
|
|
453
|
-
...
|
|
454
|
-
{ id:
|
|
457
|
+
), ee = O((h) => !(h instanceof j) || h.code === "TIMEOUT" || h.code === "NETWORK_ERROR" || h.code === "RATE_LIMITED" || h.code === "SERVICE_ERROR" || h.code === "UNKNOWN_ERROR" || h.status >= 500 || h.status === 0, []), J = O(
|
|
458
|
+
async (h) => {
|
|
459
|
+
R(!0), W.current = !0, w(null), E(!1);
|
|
460
|
+
const A = i && typeof l.streamMessage == "function";
|
|
461
|
+
let S = null;
|
|
462
|
+
const Y = (b) => {
|
|
463
|
+
if (S === null) {
|
|
464
|
+
S = m(), k(S);
|
|
465
|
+
const C = [
|
|
466
|
+
...y.current,
|
|
467
|
+
{ id: S, role: "assistant", content: "", ...b }
|
|
455
468
|
];
|
|
456
|
-
|
|
469
|
+
y.current = C, x(C);
|
|
457
470
|
} else {
|
|
458
|
-
const
|
|
459
|
-
(
|
|
471
|
+
const C = S, M = y.current.map(
|
|
472
|
+
(P) => P.id === C ? { ...P, ...b } : P
|
|
460
473
|
);
|
|
461
|
-
|
|
474
|
+
y.current = M, x(M);
|
|
462
475
|
}
|
|
476
|
+
}, $ = () => {
|
|
477
|
+
if (S === null) return;
|
|
478
|
+
const b = S, C = y.current.filter((M) => M.id !== b);
|
|
479
|
+
y.current = C, x(C);
|
|
463
480
|
};
|
|
464
481
|
try {
|
|
465
|
-
let
|
|
466
|
-
if (
|
|
467
|
-
const
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
signal:
|
|
471
|
-
onChunk: (
|
|
482
|
+
let b, C, M, P = !1;
|
|
483
|
+
if (A) {
|
|
484
|
+
const G = new AbortController();
|
|
485
|
+
K.current = G, p(!0);
|
|
486
|
+
const q = await l.streamMessage(h, {
|
|
487
|
+
signal: G.signal,
|
|
488
|
+
onChunk: (ae, D) => Y({ content: D }),
|
|
489
|
+
onToolUse: (ae, D) => Y({ toolUses: [...D] })
|
|
472
490
|
});
|
|
473
|
-
|
|
491
|
+
b = q.reply, C = q.sources, M = q.toolUses, P = q.aborted ?? !1;
|
|
474
492
|
} else {
|
|
475
|
-
const
|
|
476
|
-
|
|
493
|
+
const G = await l.sendMessage(h);
|
|
494
|
+
b = G.reply, C = G.sources, M = G.toolUses;
|
|
495
|
+
}
|
|
496
|
+
if (P && !b) {
|
|
497
|
+
$();
|
|
498
|
+
return;
|
|
477
499
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
id: k ?? h(),
|
|
500
|
+
let U = {
|
|
501
|
+
id: S ?? m(),
|
|
481
502
|
role: "assistant",
|
|
482
|
-
content:
|
|
483
|
-
sources:
|
|
503
|
+
content: b,
|
|
504
|
+
sources: C,
|
|
505
|
+
toolUses: M
|
|
484
506
|
};
|
|
485
|
-
B.current.length > 0 && !
|
|
507
|
+
B.current.length > 0 && !P && (U = await _e(
|
|
486
508
|
B.current,
|
|
487
|
-
|
|
488
|
-
{ messages:
|
|
509
|
+
U,
|
|
510
|
+
{ messages: h, apiUrl: e }
|
|
489
511
|
));
|
|
490
|
-
const
|
|
491
|
-
(
|
|
492
|
-
) : [...
|
|
493
|
-
|
|
494
|
-
} catch (
|
|
495
|
-
if (
|
|
496
|
-
if (
|
|
497
|
-
_(
|
|
512
|
+
const Z = S !== null ? y.current.map(
|
|
513
|
+
(G) => G.id === U.id ? U : G
|
|
514
|
+
) : [...h, U];
|
|
515
|
+
y.current = Z, x(Z), _(Z);
|
|
516
|
+
} catch (b) {
|
|
517
|
+
if (b instanceof le) return;
|
|
518
|
+
if (S !== null) {
|
|
519
|
+
_(y.current), b instanceof j ? w(V(b.code, b.message)) : w(
|
|
498
520
|
(s == null ? void 0 : s.errorConnection) ?? "Failed to connect. Please try again."
|
|
499
|
-
),
|
|
521
|
+
), E(!1);
|
|
500
522
|
return;
|
|
501
523
|
}
|
|
502
524
|
if (B.current.length > 0) {
|
|
503
|
-
const
|
|
504
|
-
messages:
|
|
505
|
-
apiUrl:
|
|
525
|
+
const C = b instanceof Error ? b : new Error(String(b)), M = await je(B.current, C, {
|
|
526
|
+
messages: h,
|
|
527
|
+
apiUrl: e
|
|
506
528
|
});
|
|
507
|
-
if (
|
|
508
|
-
const
|
|
509
|
-
id:
|
|
529
|
+
if (M) {
|
|
530
|
+
const P = {
|
|
531
|
+
id: m(),
|
|
510
532
|
role: "assistant",
|
|
511
|
-
content:
|
|
512
|
-
sources:
|
|
513
|
-
},
|
|
514
|
-
|
|
533
|
+
content: M.content,
|
|
534
|
+
sources: M.sources
|
|
535
|
+
}, U = [...h, P];
|
|
536
|
+
y.current = U, x(U), _(U), w(null), E(!1);
|
|
515
537
|
return;
|
|
516
538
|
}
|
|
517
539
|
}
|
|
518
|
-
|
|
540
|
+
b instanceof j ? w(V(b.code, b.message)) : w(
|
|
519
541
|
(s == null ? void 0 : s.errorConnection) ?? "Failed to connect. Please try again."
|
|
520
|
-
),
|
|
542
|
+
), E(ee(b));
|
|
521
543
|
} finally {
|
|
522
|
-
|
|
544
|
+
R(!1), W.current = !1, p(!1), k(null), K.current = null;
|
|
523
545
|
}
|
|
524
546
|
},
|
|
525
547
|
[
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
548
|
+
e,
|
|
549
|
+
l,
|
|
550
|
+
V,
|
|
551
|
+
ee,
|
|
530
552
|
_,
|
|
531
553
|
i,
|
|
532
554
|
s
|
|
533
555
|
]
|
|
534
|
-
),
|
|
535
|
-
var
|
|
536
|
-
(
|
|
537
|
-
}, []),
|
|
538
|
-
async (
|
|
539
|
-
const
|
|
540
|
-
if (!
|
|
541
|
-
const
|
|
542
|
-
id:
|
|
556
|
+
), oe = O(() => {
|
|
557
|
+
var h;
|
|
558
|
+
(h = K.current) == null || h.abort();
|
|
559
|
+
}, []), ie = O(
|
|
560
|
+
async (h) => {
|
|
561
|
+
const A = h.trim();
|
|
562
|
+
if (!A || W.current) return;
|
|
563
|
+
const S = {
|
|
564
|
+
id: m(),
|
|
543
565
|
role: "user",
|
|
544
|
-
content:
|
|
566
|
+
content: A
|
|
545
567
|
};
|
|
546
|
-
let
|
|
568
|
+
let Y = S;
|
|
547
569
|
if (B.current.length > 0) {
|
|
548
|
-
const
|
|
549
|
-
messages:
|
|
550
|
-
apiUrl:
|
|
570
|
+
const b = await De(B.current, S, {
|
|
571
|
+
messages: y.current,
|
|
572
|
+
apiUrl: e
|
|
551
573
|
});
|
|
552
|
-
if (
|
|
553
|
-
if (
|
|
554
|
-
const
|
|
555
|
-
id:
|
|
574
|
+
if (b.type === "abort") return;
|
|
575
|
+
if (b.type === "respond") {
|
|
576
|
+
const C = {
|
|
577
|
+
id: m(),
|
|
556
578
|
role: "assistant",
|
|
557
|
-
content:
|
|
558
|
-
sources:
|
|
579
|
+
content: b.reply.content,
|
|
580
|
+
sources: b.reply.sources
|
|
559
581
|
}, M = [
|
|
560
|
-
...
|
|
561
|
-
|
|
562
|
-
|
|
582
|
+
...y.current,
|
|
583
|
+
b.message,
|
|
584
|
+
C
|
|
563
585
|
];
|
|
564
|
-
|
|
586
|
+
y.current = M, x(M), _(M), w(null), E(!1);
|
|
565
587
|
return;
|
|
566
588
|
}
|
|
567
|
-
|
|
589
|
+
Y = b.message;
|
|
568
590
|
}
|
|
569
|
-
const
|
|
570
|
-
|
|
591
|
+
const $ = [...y.current, Y];
|
|
592
|
+
y.current = $, x($), _($), await J($);
|
|
571
593
|
},
|
|
572
|
-
[
|
|
573
|
-
),
|
|
574
|
-
if (
|
|
575
|
-
const
|
|
576
|
-
!
|
|
577
|
-
}, [
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
594
|
+
[e, _, J]
|
|
595
|
+
), te = O(async () => {
|
|
596
|
+
if (W.current) return;
|
|
597
|
+
const h = y.current[y.current.length - 1];
|
|
598
|
+
!h || h.role !== "user" || await J(y.current);
|
|
599
|
+
}, [J]), re = O(() => {
|
|
600
|
+
if (y.current = [], x([]), w(null), E(!1), t) {
|
|
601
|
+
const h = ue();
|
|
602
|
+
if (!h) return;
|
|
581
603
|
try {
|
|
582
|
-
|
|
604
|
+
h.removeItem(c);
|
|
583
605
|
} catch {
|
|
584
606
|
}
|
|
585
607
|
}
|
|
586
|
-
}, [
|
|
608
|
+
}, [t, c]);
|
|
587
609
|
return {
|
|
588
|
-
messages:
|
|
589
|
-
isLoading:
|
|
610
|
+
messages: d,
|
|
611
|
+
isLoading: N,
|
|
590
612
|
isStreaming: T,
|
|
591
|
-
streamingMessageId:
|
|
592
|
-
error:
|
|
593
|
-
canRetry:
|
|
594
|
-
sendMessage:
|
|
595
|
-
stop:
|
|
596
|
-
retry:
|
|
597
|
-
clearMessages:
|
|
613
|
+
streamingMessageId: v,
|
|
614
|
+
error: H,
|
|
615
|
+
canRetry: f,
|
|
616
|
+
sendMessage: ie,
|
|
617
|
+
stop: oe,
|
|
618
|
+
retry: te,
|
|
619
|
+
clearMessages: re
|
|
598
620
|
};
|
|
599
621
|
}
|
|
600
|
-
function
|
|
601
|
-
const [
|
|
602
|
-
return
|
|
603
|
-
const n = window.matchMedia(
|
|
622
|
+
function Ge(e) {
|
|
623
|
+
const [t, r] = L(() => typeof window > "u" ? !1 : window.matchMedia(e).matches);
|
|
624
|
+
return z(() => {
|
|
625
|
+
const n = window.matchMedia(e);
|
|
604
626
|
r(n.matches);
|
|
605
627
|
const s = (o) => r(o.matches);
|
|
606
628
|
return n.addEventListener("change", s), () => n.removeEventListener("change", s);
|
|
607
|
-
}, [
|
|
629
|
+
}, [e]), t;
|
|
608
630
|
}
|
|
609
|
-
function
|
|
610
|
-
return
|
|
631
|
+
function ne(e, t) {
|
|
632
|
+
return e instanceof RegExp ? e.test(t) : t.toLowerCase().includes(e.toLowerCase());
|
|
611
633
|
}
|
|
612
634
|
function We() {
|
|
613
|
-
const
|
|
635
|
+
const e = document.documentElement, t = document.body, r = e.scrollTop || t.scrollTop || 0, n = Math.max(e.scrollHeight, t.scrollHeight), s = e.clientHeight || window.innerHeight, o = n - s;
|
|
614
636
|
return o <= 0 ? 100 : r / o * 100;
|
|
615
637
|
}
|
|
616
638
|
function ze({
|
|
617
|
-
triggers:
|
|
618
|
-
enabled:
|
|
639
|
+
triggers: e,
|
|
640
|
+
enabled: t,
|
|
619
641
|
onOpen: r,
|
|
620
642
|
onGreeting: n
|
|
621
643
|
}) {
|
|
622
|
-
|
|
623
|
-
if (!
|
|
624
|
-
const s = /* @__PURE__ */ new Set(), o = [], i = typeof window < "u" ? window.location.href : "",
|
|
625
|
-
s.has(c) || (s.add(c),
|
|
644
|
+
z(() => {
|
|
645
|
+
if (!t || !e || e.length === 0) return;
|
|
646
|
+
const s = /* @__PURE__ */ new Set(), o = [], i = typeof window < "u" ? window.location.href : "", l = (c, u) => {
|
|
647
|
+
s.has(c) || (s.add(c), u === "open" ? r() : n(u.greeting));
|
|
626
648
|
};
|
|
627
|
-
return
|
|
649
|
+
return e.forEach((c, u) => {
|
|
628
650
|
switch (c.on) {
|
|
629
651
|
case "url": {
|
|
630
|
-
|
|
652
|
+
ne(c.pattern, i) && l(u, c.action);
|
|
631
653
|
break;
|
|
632
654
|
}
|
|
633
655
|
case "time": {
|
|
634
|
-
if (c.matchUrl && !
|
|
656
|
+
if (c.matchUrl && !ne(c.matchUrl, i))
|
|
635
657
|
return;
|
|
636
|
-
const
|
|
637
|
-
() => u
|
|
658
|
+
const d = window.setTimeout(
|
|
659
|
+
() => l(u, c.action),
|
|
638
660
|
Math.max(0, c.seconds * 1e3)
|
|
639
661
|
);
|
|
640
|
-
o.push(() => window.clearTimeout(
|
|
662
|
+
o.push(() => window.clearTimeout(d));
|
|
641
663
|
break;
|
|
642
664
|
}
|
|
643
665
|
case "scroll": {
|
|
644
|
-
if (c.matchUrl && !
|
|
666
|
+
if (c.matchUrl && !ne(c.matchUrl, i))
|
|
645
667
|
return;
|
|
646
|
-
const
|
|
647
|
-
We() >= c.percent && u
|
|
668
|
+
const d = () => {
|
|
669
|
+
We() >= c.percent && l(u, c.action);
|
|
648
670
|
};
|
|
649
|
-
|
|
671
|
+
d(), window.addEventListener("scroll", d, { passive: !0 }), o.push(() => window.removeEventListener("scroll", d));
|
|
650
672
|
break;
|
|
651
673
|
}
|
|
652
674
|
case "exit-intent": {
|
|
653
|
-
if (c.matchUrl && !
|
|
675
|
+
if (c.matchUrl && !ne(c.matchUrl, i))
|
|
654
676
|
return;
|
|
655
|
-
const
|
|
656
|
-
|
|
677
|
+
const d = (x) => {
|
|
678
|
+
x.clientY <= 0 && l(u, c.action);
|
|
657
679
|
};
|
|
658
|
-
document.addEventListener("mouseleave",
|
|
659
|
-
() => document.removeEventListener("mouseleave",
|
|
680
|
+
document.addEventListener("mouseleave", d), o.push(
|
|
681
|
+
() => document.removeEventListener("mouseleave", d)
|
|
660
682
|
);
|
|
661
683
|
break;
|
|
662
684
|
}
|
|
@@ -664,15 +686,15 @@ function ze({
|
|
|
664
686
|
}), () => {
|
|
665
687
|
o.forEach((c) => c());
|
|
666
688
|
};
|
|
667
|
-
}, [
|
|
689
|
+
}, [e, t, r, n]);
|
|
668
690
|
}
|
|
669
691
|
const Fe = {
|
|
670
692
|
"bottom-right": "bottom-6 right-6",
|
|
671
693
|
"bottom-left": "bottom-6 left-6",
|
|
672
694
|
"top-right": "top-6 right-6",
|
|
673
695
|
"top-left": "top-6 left-6"
|
|
674
|
-
},
|
|
675
|
-
const i =
|
|
696
|
+
}, Ve = ke(function({ isOpen: t, onClick: r, position: n = "bottom-right", translations: s }, o) {
|
|
697
|
+
const i = t ? (s == null ? void 0 : s.closeChat) ?? "Close chat" : (s == null ? void 0 : s.openChat) ?? "Open chat";
|
|
676
698
|
return /* @__PURE__ */ a(
|
|
677
699
|
"button",
|
|
678
700
|
{
|
|
@@ -680,7 +702,7 @@ const Fe = {
|
|
|
680
702
|
onClick: r,
|
|
681
703
|
"aria-label": i,
|
|
682
704
|
className: `fixed ${Fe[n]} z-50 flex h-14 w-14 items-center justify-center rounded-claudius-full bg-claudius-accent text-claudius-accent-text shadow-claudius-floating transition-transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-claudius-accent focus:ring-offset-2`,
|
|
683
|
-
children:
|
|
705
|
+
children: t ? /* @__PURE__ */ g(
|
|
684
706
|
"svg",
|
|
685
707
|
{
|
|
686
708
|
width: "24",
|
|
@@ -714,12 +736,12 @@ const Fe = {
|
|
|
714
736
|
)
|
|
715
737
|
}
|
|
716
738
|
);
|
|
717
|
-
}),
|
|
718
|
-
count:
|
|
739
|
+
}), Ye = de(function({
|
|
740
|
+
count: t,
|
|
719
741
|
isActive: r,
|
|
720
742
|
onClick: n
|
|
721
743
|
}) {
|
|
722
|
-
return /* @__PURE__ */
|
|
744
|
+
return /* @__PURE__ */ g(
|
|
723
745
|
"button",
|
|
724
746
|
{
|
|
725
747
|
onClick: n,
|
|
@@ -727,7 +749,7 @@ const Fe = {
|
|
|
727
749
|
title: "View sources",
|
|
728
750
|
className: `group relative flex h-7 w-7 items-center justify-center rounded-claudius-full transition-colors ${r ? "bg-claudius-accent text-claudius-accent-text" : "text-claudius-text-muted hover:bg-claudius-surface-muted hover:text-claudius-text"}`,
|
|
729
751
|
children: [
|
|
730
|
-
/* @__PURE__ */
|
|
752
|
+
/* @__PURE__ */ g(
|
|
731
753
|
"svg",
|
|
732
754
|
{
|
|
733
755
|
width: "14",
|
|
@@ -747,65 +769,130 @@ const Fe = {
|
|
|
747
769
|
]
|
|
748
770
|
}
|
|
749
771
|
),
|
|
750
|
-
/* @__PURE__ */ a("span", { className: "absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-claudius-full bg-claudius-accent px-1 text-[10px] font-bold text-claudius-accent-text", children:
|
|
772
|
+
/* @__PURE__ */ a("span", { className: "absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-claudius-full bg-claudius-accent px-1 text-[10px] font-bold text-claudius-accent-text", children: t })
|
|
751
773
|
]
|
|
752
774
|
}
|
|
753
775
|
);
|
|
754
776
|
}), Ke = ["http:", "https:"];
|
|
755
|
-
function
|
|
756
|
-
if (!
|
|
777
|
+
function ve(e) {
|
|
778
|
+
if (!e || typeof e != "string")
|
|
757
779
|
return null;
|
|
758
|
-
const
|
|
759
|
-
if (!
|
|
780
|
+
const t = e.trim();
|
|
781
|
+
if (!t)
|
|
760
782
|
return null;
|
|
761
783
|
try {
|
|
762
|
-
const r = new URL(
|
|
763
|
-
return Ke.includes(r.protocol) ?
|
|
784
|
+
const r = new URL(t);
|
|
785
|
+
return Ke.includes(r.protocol) ? t : null;
|
|
764
786
|
} catch {
|
|
765
787
|
return null;
|
|
766
788
|
}
|
|
767
789
|
}
|
|
768
|
-
function qe(
|
|
769
|
-
const
|
|
770
|
-
`), r =
|
|
771
|
-
let n =
|
|
790
|
+
function qe(e) {
|
|
791
|
+
const t = e.lastIndexOf(`
|
|
792
|
+
`), r = t === -1 ? "" : e.slice(0, t + 1);
|
|
793
|
+
let n = t === -1 ? e : e.slice(t + 1);
|
|
772
794
|
return n = Ze(n), n = Qe(n), r + n;
|
|
773
795
|
}
|
|
774
|
-
function Je(
|
|
775
|
-
const
|
|
776
|
-
for (let r = 0; r <
|
|
777
|
-
|
|
778
|
-
return
|
|
796
|
+
function Je(e) {
|
|
797
|
+
const t = [];
|
|
798
|
+
for (let r = 0; r < e.length - 1; r++)
|
|
799
|
+
e[r] === "*" && e[r + 1] === "*" && (t.push(r), r++);
|
|
800
|
+
return t;
|
|
779
801
|
}
|
|
780
|
-
function Xe(
|
|
781
|
-
const
|
|
782
|
-
for (let r = 0; r <
|
|
783
|
-
if (
|
|
784
|
-
if (
|
|
802
|
+
function Xe(e) {
|
|
803
|
+
const t = [];
|
|
804
|
+
for (let r = 0; r < e.length; r++)
|
|
805
|
+
if (e[r] === "*") {
|
|
806
|
+
if (e[r + 1] === "*") {
|
|
785
807
|
r++;
|
|
786
808
|
continue;
|
|
787
809
|
}
|
|
788
|
-
|
|
810
|
+
t.push(r);
|
|
789
811
|
}
|
|
790
|
-
return
|
|
812
|
+
return t;
|
|
791
813
|
}
|
|
792
|
-
function Ze(
|
|
793
|
-
const
|
|
794
|
-
if (
|
|
795
|
-
const r =
|
|
796
|
-
return n.trim() === "" ?
|
|
814
|
+
function Ze(e) {
|
|
815
|
+
const t = Je(e);
|
|
816
|
+
if (t.length % 2 === 0) return e;
|
|
817
|
+
const r = t[t.length - 1], n = e.slice(r + 2);
|
|
818
|
+
return n.trim() === "" ? e.slice(0, r) + n : e + "**";
|
|
797
819
|
}
|
|
798
|
-
function Qe(
|
|
799
|
-
const
|
|
800
|
-
if (
|
|
801
|
-
const r =
|
|
802
|
-
return n.trim() === "" ?
|
|
820
|
+
function Qe(e) {
|
|
821
|
+
const t = Xe(e);
|
|
822
|
+
if (t.length % 2 === 0) return e;
|
|
823
|
+
const r = t[t.length - 1], n = e.slice(r + 1);
|
|
824
|
+
return n.trim() === "" ? e.slice(0, r) + n : e + "*";
|
|
825
|
+
}
|
|
826
|
+
function et({
|
|
827
|
+
toolUse: e,
|
|
828
|
+
usedLabel: t,
|
|
829
|
+
detailsLabel: r
|
|
830
|
+
}) {
|
|
831
|
+
const [n, s] = L(!1), o = e.input !== void 0 || e.result !== void 0;
|
|
832
|
+
return /* @__PURE__ */ g("div", { className: "text-xs text-claudius-text-muted", children: [
|
|
833
|
+
/* @__PURE__ */ g(
|
|
834
|
+
"button",
|
|
835
|
+
{
|
|
836
|
+
type: "button",
|
|
837
|
+
disabled: !o,
|
|
838
|
+
onClick: () => s((i) => !i),
|
|
839
|
+
"aria-expanded": o ? n : void 0,
|
|
840
|
+
className: "flex items-center gap-1.5 rounded-claudius-full border border-claudius-border bg-claudius-surface px-2 py-0.5 hover:opacity-80 disabled:cursor-default disabled:hover:opacity-100",
|
|
841
|
+
children: [
|
|
842
|
+
/* @__PURE__ */ a(
|
|
843
|
+
"svg",
|
|
844
|
+
{
|
|
845
|
+
width: "11",
|
|
846
|
+
height: "11",
|
|
847
|
+
viewBox: "0 0 24 24",
|
|
848
|
+
fill: "none",
|
|
849
|
+
stroke: "currentColor",
|
|
850
|
+
strokeWidth: "2",
|
|
851
|
+
strokeLinecap: "round",
|
|
852
|
+
strokeLinejoin: "round",
|
|
853
|
+
"aria-hidden": "true",
|
|
854
|
+
children: /* @__PURE__ */ a("path", { d: "M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z" })
|
|
855
|
+
}
|
|
856
|
+
),
|
|
857
|
+
/* @__PURE__ */ g("span", { children: [
|
|
858
|
+
t,
|
|
859
|
+
" ",
|
|
860
|
+
/* @__PURE__ */ a("span", { className: "font-mono text-claudius-text", children: e.name }),
|
|
861
|
+
e.isError && /* @__PURE__ */ a("span", { className: "text-claudius-error", children: " ✕" })
|
|
862
|
+
] }),
|
|
863
|
+
o && /* @__PURE__ */ g(xe, { children: [
|
|
864
|
+
/* @__PURE__ */ a("span", { className: "sr-only", children: r }),
|
|
865
|
+
/* @__PURE__ */ a(
|
|
866
|
+
"svg",
|
|
867
|
+
{
|
|
868
|
+
width: "10",
|
|
869
|
+
height: "10",
|
|
870
|
+
viewBox: "0 0 24 24",
|
|
871
|
+
fill: "none",
|
|
872
|
+
stroke: "currentColor",
|
|
873
|
+
strokeWidth: "2",
|
|
874
|
+
strokeLinecap: "round",
|
|
875
|
+
strokeLinejoin: "round",
|
|
876
|
+
"aria-hidden": "true",
|
|
877
|
+
className: n ? "rotate-180" : void 0,
|
|
878
|
+
children: /* @__PURE__ */ a("polyline", { points: "6 9 12 15 18 9" })
|
|
879
|
+
}
|
|
880
|
+
)
|
|
881
|
+
] })
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
n && o && /* @__PURE__ */ g("div", { className: "mt-1 overflow-x-auto rounded-claudius-sm border border-claudius-border bg-claudius-field p-2 font-mono", children: [
|
|
886
|
+
e.input !== void 0 && /* @__PURE__ */ a("pre", { className: "whitespace-pre-wrap break-all", children: JSON.stringify(e.input, null, 2) }),
|
|
887
|
+
e.result !== void 0 && /* @__PURE__ */ a("pre", { className: "mt-1 whitespace-pre-wrap break-all border-t border-claudius-border pt-1", children: e.result })
|
|
888
|
+
] })
|
|
889
|
+
] });
|
|
803
890
|
}
|
|
804
|
-
const
|
|
805
|
-
function
|
|
806
|
-
const r =
|
|
807
|
-
return o ? /* @__PURE__ */
|
|
808
|
-
/* @__PURE__ */
|
|
891
|
+
const me = /(https?:\/\/[^\s)]+)/, ge = /(\*\*[^*]+\*\*)/, pe = /(\*[^*]+\*)/;
|
|
892
|
+
function tt(e, t) {
|
|
893
|
+
const r = e.match(/[.,;:!?'"]+$/), n = r ? e.slice(0, -r[0].length) : e, s = r ? r[0] : "", o = ve(n);
|
|
894
|
+
return o ? /* @__PURE__ */ g(xe, { children: [
|
|
895
|
+
/* @__PURE__ */ g(
|
|
809
896
|
"a",
|
|
810
897
|
{
|
|
811
898
|
href: o,
|
|
@@ -817,107 +904,119 @@ function et(t, e) {
|
|
|
817
904
|
/* @__PURE__ */ a("span", { className: "sr-only", children: " (opens in a new tab)" })
|
|
818
905
|
]
|
|
819
906
|
},
|
|
820
|
-
|
|
907
|
+
t
|
|
821
908
|
),
|
|
822
909
|
s
|
|
823
|
-
] }) :
|
|
910
|
+
] }) : e;
|
|
824
911
|
}
|
|
825
|
-
function
|
|
826
|
-
const r =
|
|
912
|
+
function rt(e, t) {
|
|
913
|
+
const r = e.split(ge), n = [];
|
|
827
914
|
return r.forEach((s, o) => {
|
|
828
|
-
if (
|
|
915
|
+
if (ge.test(s)) {
|
|
829
916
|
const i = s.slice(2, -2);
|
|
830
|
-
n.push(/* @__PURE__ */ a("strong", { children: i }, `${
|
|
917
|
+
n.push(/* @__PURE__ */ a("strong", { children: i }, `${t}-b${o}`));
|
|
831
918
|
} else
|
|
832
|
-
s.split(
|
|
833
|
-
if (
|
|
834
|
-
const
|
|
835
|
-
n.push(/* @__PURE__ */ a("em", { children:
|
|
919
|
+
s.split(pe).forEach((l, c) => {
|
|
920
|
+
if (pe.test(l)) {
|
|
921
|
+
const u = l.slice(1, -1);
|
|
922
|
+
n.push(/* @__PURE__ */ a("em", { children: u }, `${t}-b${o}-i${c}`));
|
|
836
923
|
} else
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
) :
|
|
924
|
+
l.split(me).forEach((d, x) => {
|
|
925
|
+
me.test(d) ? n.push(
|
|
926
|
+
tt(d, `${t}-b${o}-i${c}-u${x}`)
|
|
927
|
+
) : d && n.push(d);
|
|
841
928
|
});
|
|
842
929
|
});
|
|
843
930
|
}), n;
|
|
844
931
|
}
|
|
845
|
-
function
|
|
846
|
-
const
|
|
932
|
+
function nt(e) {
|
|
933
|
+
const t = e.split(`
|
|
847
934
|
`);
|
|
848
|
-
return
|
|
849
|
-
|
|
850
|
-
n <
|
|
935
|
+
return t.map((r, n) => /* @__PURE__ */ g("span", { children: [
|
|
936
|
+
rt(r, `l${n}`),
|
|
937
|
+
n < t.length - 1 && /* @__PURE__ */ a("br", {})
|
|
851
938
|
] }, n));
|
|
852
939
|
}
|
|
853
|
-
const
|
|
854
|
-
role:
|
|
940
|
+
const st = de(function({
|
|
941
|
+
role: t,
|
|
855
942
|
content: r,
|
|
856
943
|
isStreaming: n = !1,
|
|
857
944
|
sources: s,
|
|
858
|
-
|
|
859
|
-
|
|
945
|
+
toolUses: o,
|
|
946
|
+
toolUsedLabel: i = "Used tool:",
|
|
947
|
+
toolDetailsLabel: l = "Tool details",
|
|
948
|
+
onSourceClick: c,
|
|
949
|
+
isSourceActive: u
|
|
860
950
|
}) {
|
|
861
|
-
const
|
|
862
|
-
return /* @__PURE__ */
|
|
863
|
-
/* @__PURE__ */ a(
|
|
951
|
+
const d = t === "user", x = n ? qe(r) : r, N = d || r !== "" || !(o != null && o.length);
|
|
952
|
+
return /* @__PURE__ */ g("div", { className: `${d ? "ml-auto" : "mr-auto"} max-w-[85%]`, children: [
|
|
953
|
+
N && /* @__PURE__ */ a(
|
|
864
954
|
"div",
|
|
865
955
|
{
|
|
866
|
-
className: `rounded-claudius-bubble px-4 py-2.5 text-sm leading-relaxed font-body ${
|
|
867
|
-
children:
|
|
956
|
+
className: `rounded-claudius-bubble px-4 py-2.5 text-sm leading-relaxed font-body ${d ? "bg-claudius-user-bubble text-claudius-user-bubble-text rounded-br-claudius-tail" : "bg-claudius-assistant-bubble text-claudius-assistant-bubble-text rounded-bl-claudius-tail"}`,
|
|
957
|
+
children: nt(x)
|
|
868
958
|
}
|
|
869
959
|
),
|
|
870
|
-
!
|
|
871
|
-
|
|
960
|
+
!d && o && o.length > 0 && /* @__PURE__ */ a("div", { className: "mt-1 space-y-1", children: o.map((R, T) => /* @__PURE__ */ a(
|
|
961
|
+
et,
|
|
962
|
+
{
|
|
963
|
+
toolUse: R,
|
|
964
|
+
usedLabel: i,
|
|
965
|
+
detailsLabel: l
|
|
966
|
+
},
|
|
967
|
+
`${R.name}-${T}`
|
|
968
|
+
)) }),
|
|
969
|
+
!d && s && s.length > 0 && c && /* @__PURE__ */ a("div", { className: "mt-1", children: /* @__PURE__ */ a(
|
|
970
|
+
Ye,
|
|
872
971
|
{
|
|
873
972
|
count: s.length,
|
|
874
|
-
isActive:
|
|
875
|
-
onClick:
|
|
973
|
+
isActive: u ?? !1,
|
|
974
|
+
onClick: c
|
|
876
975
|
}
|
|
877
976
|
) })
|
|
878
977
|
] });
|
|
879
|
-
}),
|
|
880
|
-
function
|
|
881
|
-
onSend:
|
|
882
|
-
isLoading:
|
|
978
|
+
}), ce = 2e3, ot = 1800;
|
|
979
|
+
function it({
|
|
980
|
+
onSend: e,
|
|
981
|
+
isLoading: t,
|
|
883
982
|
isStreaming: r = !1,
|
|
884
983
|
onStop: n,
|
|
885
984
|
placeholder: s,
|
|
886
985
|
translations: o
|
|
887
986
|
}) {
|
|
888
|
-
const [i,
|
|
889
|
-
return
|
|
890
|
-
var
|
|
891
|
-
|
|
892
|
-
}, [
|
|
987
|
+
const [i, l] = L(""), c = I(null), u = i.length, d = u >= ot, x = u >= ce, N = s ?? (o == null ? void 0 : o.placeholder) ?? "Type your message...", R = (o == null ? void 0 : o.sendMessage) ?? "Send message", T = (o == null ? void 0 : o.stopGenerating) ?? "Stop generating", p = (o == null ? void 0 : o.typeYourMessage) ?? "Type your message", v = r && !!n;
|
|
988
|
+
return z(() => {
|
|
989
|
+
var w;
|
|
990
|
+
t || (w = c.current) == null || w.focus();
|
|
991
|
+
}, [t]), /* @__PURE__ */ g(
|
|
893
992
|
"form",
|
|
894
993
|
{
|
|
895
|
-
onSubmit: (
|
|
896
|
-
|
|
897
|
-
const
|
|
898
|
-
!
|
|
994
|
+
onSubmit: (w) => {
|
|
995
|
+
w.preventDefault();
|
|
996
|
+
const f = i.trim();
|
|
997
|
+
!f || x || (e(f), l(""));
|
|
899
998
|
},
|
|
900
999
|
className: "border-t border-claudius-border bg-claudius-surface p-3",
|
|
901
1000
|
children: [
|
|
902
|
-
/* @__PURE__ */
|
|
1001
|
+
/* @__PURE__ */ g("div", { className: "flex gap-2", children: [
|
|
903
1002
|
/* @__PURE__ */ a(
|
|
904
1003
|
"input",
|
|
905
1004
|
{
|
|
906
1005
|
ref: c,
|
|
907
1006
|
type: "text",
|
|
908
1007
|
value: i,
|
|
909
|
-
onChange: (
|
|
910
|
-
const
|
|
911
|
-
|
|
1008
|
+
onChange: (w) => {
|
|
1009
|
+
const f = w.target.value;
|
|
1010
|
+
f.length <= ce && l(f);
|
|
912
1011
|
},
|
|
913
|
-
placeholder:
|
|
914
|
-
disabled:
|
|
915
|
-
"aria-label":
|
|
916
|
-
"aria-describedby":
|
|
1012
|
+
placeholder: N,
|
|
1013
|
+
disabled: t,
|
|
1014
|
+
"aria-label": p,
|
|
1015
|
+
"aria-describedby": d ? "char-count" : void 0,
|
|
917
1016
|
className: "flex-1 rounded-claudius-sm border border-claudius-border bg-claudius-field px-3 py-2 text-sm font-body text-claudius-text placeholder:text-claudius-text-muted focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50"
|
|
918
1017
|
}
|
|
919
1018
|
),
|
|
920
|
-
|
|
1019
|
+
v ? /* @__PURE__ */ a(
|
|
921
1020
|
"button",
|
|
922
1021
|
{
|
|
923
1022
|
type: "button",
|
|
@@ -940,10 +1039,10 @@ function ot({
|
|
|
940
1039
|
"button",
|
|
941
1040
|
{
|
|
942
1041
|
type: "submit",
|
|
943
|
-
disabled:
|
|
944
|
-
"aria-label":
|
|
1042
|
+
disabled: t || x,
|
|
1043
|
+
"aria-label": R,
|
|
945
1044
|
className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm bg-claudius-accent text-claudius-accent-text transition-colors hover:opacity-90 disabled:opacity-50",
|
|
946
|
-
children: /* @__PURE__ */
|
|
1045
|
+
children: /* @__PURE__ */ g(
|
|
947
1046
|
"svg",
|
|
948
1047
|
{
|
|
949
1048
|
width: "16",
|
|
@@ -964,16 +1063,16 @@ function ot({
|
|
|
964
1063
|
}
|
|
965
1064
|
)
|
|
966
1065
|
] }),
|
|
967
|
-
|
|
1066
|
+
d && /* @__PURE__ */ g(
|
|
968
1067
|
"div",
|
|
969
1068
|
{
|
|
970
1069
|
id: "char-count",
|
|
971
|
-
className: `mt-1 text-xs text-right ${
|
|
1070
|
+
className: `mt-1 text-xs text-right ${x ? "text-claudius-error" : "text-claudius-text-muted"}`,
|
|
972
1071
|
"aria-live": "polite",
|
|
973
1072
|
children: [
|
|
974
|
-
|
|
1073
|
+
u,
|
|
975
1074
|
"/",
|
|
976
|
-
|
|
1075
|
+
ce
|
|
977
1076
|
]
|
|
978
1077
|
}
|
|
979
1078
|
)
|
|
@@ -981,30 +1080,30 @@ function ot({
|
|
|
981
1080
|
}
|
|
982
1081
|
);
|
|
983
1082
|
}
|
|
984
|
-
const
|
|
1083
|
+
const at = ["blog", "page", "external"], ct = {
|
|
985
1084
|
blog: "Blog",
|
|
986
1085
|
page: "Page",
|
|
987
1086
|
external: "External"
|
|
988
1087
|
};
|
|
989
|
-
function
|
|
1088
|
+
function lt(e) {
|
|
990
1089
|
try {
|
|
991
|
-
return new URL(
|
|
1090
|
+
return new URL(e).hostname;
|
|
992
1091
|
} catch {
|
|
993
|
-
return
|
|
1092
|
+
return e;
|
|
994
1093
|
}
|
|
995
1094
|
}
|
|
996
|
-
const ut =
|
|
997
|
-
sources:
|
|
1095
|
+
const ut = de(function({
|
|
1096
|
+
sources: t,
|
|
998
1097
|
onClose: r
|
|
999
1098
|
}) {
|
|
1000
|
-
const n =
|
|
1099
|
+
const n = at.map((o) => ({
|
|
1001
1100
|
type: o,
|
|
1002
|
-
label:
|
|
1003
|
-
items:
|
|
1004
|
-
})).filter((o) => o.items.length > 0), s =
|
|
1005
|
-
return /* @__PURE__ */
|
|
1006
|
-
/* @__PURE__ */
|
|
1007
|
-
/* @__PURE__ */
|
|
1101
|
+
label: ct[o],
|
|
1102
|
+
items: t.filter((i) => i.type === o)
|
|
1103
|
+
})).filter((o) => o.items.length > 0), s = t.length === 1 ? "1 source found" : `${t.length} sources found`;
|
|
1104
|
+
return /* @__PURE__ */ g("div", { className: "absolute inset-y-0 left-0 z-10 flex w-[280px] flex-col border-r-2 border-claudius-border bg-claudius-surface rounded-r-claudius-lg transition-transform duration-200 ease-out", children: [
|
|
1105
|
+
/* @__PURE__ */ g("div", { className: "flex items-center justify-between border-b border-claudius-border px-4 py-3", children: [
|
|
1106
|
+
/* @__PURE__ */ g("div", { children: [
|
|
1008
1107
|
/* @__PURE__ */ a("h3", { className: "text-sm font-heading font-semibold text-claudius-text", children: "Sources" }),
|
|
1009
1108
|
/* @__PURE__ */ a("p", { className: "text-xs text-claudius-text-muted", children: s })
|
|
1010
1109
|
] }),
|
|
@@ -1014,7 +1113,7 @@ const ut = ue(function({
|
|
|
1014
1113
|
onClick: r,
|
|
1015
1114
|
"aria-label": "Close sources",
|
|
1016
1115
|
className: "flex h-7 w-7 items-center justify-center rounded-claudius-full text-claudius-text-muted transition-colors hover:bg-claudius-surface-muted hover:text-claudius-text",
|
|
1017
|
-
children: /* @__PURE__ */
|
|
1116
|
+
children: /* @__PURE__ */ g(
|
|
1018
1117
|
"svg",
|
|
1019
1118
|
{
|
|
1020
1119
|
width: "14",
|
|
@@ -1035,54 +1134,54 @@ const ut = ue(function({
|
|
|
1035
1134
|
}
|
|
1036
1135
|
)
|
|
1037
1136
|
] }),
|
|
1038
|
-
/* @__PURE__ */ a("div", { className: "flex-1 overflow-y-auto px-3 py-3 space-y-4", children: n.map((o) => /* @__PURE__ */
|
|
1137
|
+
/* @__PURE__ */ a("div", { className: "flex-1 overflow-y-auto px-3 py-3 space-y-4", children: n.map((o) => /* @__PURE__ */ g("div", { children: [
|
|
1039
1138
|
/* @__PURE__ */ a("h4", { className: "mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted", children: o.label }),
|
|
1040
1139
|
/* @__PURE__ */ a("div", { className: "space-y-2", children: o.items.map((i) => {
|
|
1041
|
-
const
|
|
1042
|
-
return
|
|
1140
|
+
const l = ve(i.url);
|
|
1141
|
+
return l ? /* @__PURE__ */ g(
|
|
1043
1142
|
"a",
|
|
1044
1143
|
{
|
|
1045
|
-
href:
|
|
1144
|
+
href: l,
|
|
1046
1145
|
target: "_blank",
|
|
1047
1146
|
rel: "noopener noreferrer",
|
|
1048
1147
|
className: "block rounded-claudius-md border-2 border-claudius-border bg-claudius-surface-muted p-3 transition-colors hover:bg-claudius-border",
|
|
1049
1148
|
children: [
|
|
1050
1149
|
/* @__PURE__ */ a("p", { className: "truncate text-sm font-medium text-claudius-text", children: i.title }),
|
|
1051
|
-
/* @__PURE__ */ a("p", { className: "mt-0.5 text-xs text-claudius-text-muted", children:
|
|
1150
|
+
/* @__PURE__ */ a("p", { className: "mt-0.5 text-xs text-claudius-text-muted", children: lt(l) })
|
|
1052
1151
|
]
|
|
1053
1152
|
},
|
|
1054
|
-
|
|
1153
|
+
l
|
|
1055
1154
|
) : null;
|
|
1056
1155
|
}) })
|
|
1057
1156
|
] }, o.type)) })
|
|
1058
1157
|
] });
|
|
1059
1158
|
});
|
|
1060
|
-
function
|
|
1061
|
-
title:
|
|
1062
|
-
subtitle:
|
|
1159
|
+
function dt({
|
|
1160
|
+
title: e,
|
|
1161
|
+
subtitle: t,
|
|
1063
1162
|
titleId: r,
|
|
1064
1163
|
closeLabel: n,
|
|
1065
1164
|
onClose: s
|
|
1066
1165
|
}) {
|
|
1067
|
-
return /* @__PURE__ */
|
|
1166
|
+
return /* @__PURE__ */ g("div", { className: "flex items-center gap-3 bg-claudius-accent px-5 py-4", children: [
|
|
1068
1167
|
/* @__PURE__ */ a(
|
|
1069
1168
|
"div",
|
|
1070
1169
|
{
|
|
1071
1170
|
"aria-hidden": "true",
|
|
1072
1171
|
className: "flex h-8 w-8 items-center justify-center rounded-claudius-full bg-claudius-accent-soft text-sm font-bold text-claudius-accent-text",
|
|
1073
|
-
children:
|
|
1172
|
+
children: e.charAt(0).toUpperCase()
|
|
1074
1173
|
}
|
|
1075
1174
|
),
|
|
1076
|
-
/* @__PURE__ */
|
|
1175
|
+
/* @__PURE__ */ g("div", { className: "flex-1", children: [
|
|
1077
1176
|
/* @__PURE__ */ a(
|
|
1078
1177
|
"h2",
|
|
1079
1178
|
{
|
|
1080
1179
|
id: r,
|
|
1081
1180
|
className: "text-sm font-heading font-semibold text-claudius-accent-text",
|
|
1082
|
-
children:
|
|
1181
|
+
children: e
|
|
1083
1182
|
}
|
|
1084
1183
|
),
|
|
1085
|
-
/* @__PURE__ */ a("p", { className: "text-xs text-claudius-accent-text", children:
|
|
1184
|
+
/* @__PURE__ */ a("p", { className: "text-xs text-claudius-accent-text", children: t })
|
|
1086
1185
|
] }),
|
|
1087
1186
|
/* @__PURE__ */ a(
|
|
1088
1187
|
"button",
|
|
@@ -1090,7 +1189,7 @@ function lt({
|
|
|
1090
1189
|
onClick: s,
|
|
1091
1190
|
"aria-label": n,
|
|
1092
1191
|
className: "flex h-10 w-10 items-center justify-center rounded-claudius-full text-claudius-accent-text-muted transition-colors hover:bg-claudius-accent-soft hover:text-claudius-accent-text",
|
|
1093
|
-
children: /* @__PURE__ */
|
|
1192
|
+
children: /* @__PURE__ */ g(
|
|
1094
1193
|
"svg",
|
|
1095
1194
|
{
|
|
1096
1195
|
width: "18",
|
|
@@ -1112,40 +1211,40 @@ function lt({
|
|
|
1112
1211
|
)
|
|
1113
1212
|
] });
|
|
1114
1213
|
}
|
|
1115
|
-
function
|
|
1116
|
-
message:
|
|
1117
|
-
retryLabel:
|
|
1214
|
+
function ft({
|
|
1215
|
+
message: e,
|
|
1216
|
+
retryLabel: t,
|
|
1118
1217
|
onRetry: r
|
|
1119
1218
|
}) {
|
|
1120
|
-
return /* @__PURE__ */
|
|
1219
|
+
return /* @__PURE__ */ g(
|
|
1121
1220
|
"div",
|
|
1122
1221
|
{
|
|
1123
1222
|
role: "alert",
|
|
1124
1223
|
className: "mx-auto flex max-w-[90%] flex-col items-center gap-2 rounded-claudius-sm bg-claudius-error-surface px-3 py-2 text-center text-xs text-claudius-error",
|
|
1125
1224
|
children: [
|
|
1126
|
-
/* @__PURE__ */ a("span", { children:
|
|
1225
|
+
/* @__PURE__ */ a("span", { children: e }),
|
|
1127
1226
|
r && /* @__PURE__ */ a(
|
|
1128
1227
|
"button",
|
|
1129
1228
|
{
|
|
1130
1229
|
type: "button",
|
|
1131
1230
|
onClick: r,
|
|
1132
1231
|
className: "rounded-claudius-md bg-claudius-error px-3 py-1 text-xs font-semibold text-claudius-error-text transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-claudius-error focus-visible:ring-offset-1",
|
|
1133
|
-
children:
|
|
1232
|
+
children: t
|
|
1134
1233
|
}
|
|
1135
1234
|
)
|
|
1136
1235
|
]
|
|
1137
1236
|
}
|
|
1138
1237
|
);
|
|
1139
1238
|
}
|
|
1140
|
-
function
|
|
1239
|
+
function ht({ label: e }) {
|
|
1141
1240
|
return /* @__PURE__ */ a(
|
|
1142
1241
|
"div",
|
|
1143
1242
|
{
|
|
1144
1243
|
role: "status",
|
|
1145
1244
|
"aria-live": "polite",
|
|
1146
|
-
"aria-label":
|
|
1245
|
+
"aria-label": e,
|
|
1147
1246
|
className: "mr-auto flex max-w-[85%]",
|
|
1148
|
-
children: /* @__PURE__ */
|
|
1247
|
+
children: /* @__PURE__ */ g("div", { className: "flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3", children: [
|
|
1149
1248
|
/* @__PURE__ */ a("span", { className: "h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]" }),
|
|
1150
1249
|
/* @__PURE__ */ a("span", { className: "h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]" }),
|
|
1151
1250
|
/* @__PURE__ */ a("span", { className: "h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]" })
|
|
@@ -1153,168 +1252,174 @@ function ft({ label: t }) {
|
|
|
1153
1252
|
}
|
|
1154
1253
|
);
|
|
1155
1254
|
}
|
|
1156
|
-
function
|
|
1157
|
-
const [n, s] =
|
|
1158
|
-
return
|
|
1159
|
-
const
|
|
1160
|
-
if (!r || !
|
|
1161
|
-
const
|
|
1162
|
-
if (
|
|
1255
|
+
function mt(e, t, r) {
|
|
1256
|
+
const [n, s] = L(0), o = I(0), i = I(0), l = I(0), c = I(!1);
|
|
1257
|
+
return z(() => {
|
|
1258
|
+
const u = e.current;
|
|
1259
|
+
if (!r || !u) return;
|
|
1260
|
+
const d = (R) => {
|
|
1261
|
+
if (u.scrollTop > 0) {
|
|
1163
1262
|
c.current = !1;
|
|
1164
1263
|
return;
|
|
1165
1264
|
}
|
|
1166
|
-
c.current = !0, i.current =
|
|
1167
|
-
},
|
|
1265
|
+
c.current = !0, i.current = R.touches[0].clientY, l.current = Date.now();
|
|
1266
|
+
}, x = (R) => {
|
|
1168
1267
|
if (!c.current) return;
|
|
1169
|
-
let T =
|
|
1268
|
+
let T = R.touches[0].clientY - i.current;
|
|
1170
1269
|
T < 0 && (T = T * 0.3), o.current = T, s(T);
|
|
1171
|
-
},
|
|
1270
|
+
}, N = () => {
|
|
1172
1271
|
if (!c.current) return;
|
|
1173
1272
|
c.current = !1;
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1273
|
+
const R = o.current, T = (Date.now() - l.current) / 1e3, p = u.getBoundingClientRect().height, v = T > 0.05 && R > 0 && R / T > 500, k = R > p * 0.3;
|
|
1274
|
+
v || k ? t() : (o.current = 0, s(0));
|
|
1176
1275
|
};
|
|
1177
|
-
return
|
|
1178
|
-
|
|
1276
|
+
return u.addEventListener("touchstart", d, { passive: !0 }), u.addEventListener("touchmove", x, { passive: !0 }), u.addEventListener("touchend", N), () => {
|
|
1277
|
+
u.removeEventListener("touchstart", d), u.removeEventListener("touchmove", x), u.removeEventListener("touchend", N);
|
|
1179
1278
|
};
|
|
1180
|
-
}, [
|
|
1279
|
+
}, [e, t, r]), { offsetY: n };
|
|
1181
1280
|
}
|
|
1182
|
-
const
|
|
1183
|
-
function
|
|
1184
|
-
|
|
1185
|
-
const r =
|
|
1281
|
+
const gt = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
1282
|
+
function pt(e, t) {
|
|
1283
|
+
z(() => {
|
|
1284
|
+
const r = e.current;
|
|
1186
1285
|
if (!r) return;
|
|
1187
1286
|
const n = (s) => {
|
|
1188
1287
|
if (s.key !== "Tab") return;
|
|
1189
1288
|
const o = Array.from(
|
|
1190
|
-
r.querySelectorAll(
|
|
1191
|
-
).filter((
|
|
1289
|
+
r.querySelectorAll(gt)
|
|
1290
|
+
).filter((u) => !u.hasAttribute("aria-hidden"));
|
|
1192
1291
|
if (o.length === 0) return;
|
|
1193
|
-
const i = o[0],
|
|
1194
|
-
s.shiftKey && c === i ? (s.preventDefault(),
|
|
1292
|
+
const i = o[0], l = o[o.length - 1], c = document.activeElement;
|
|
1293
|
+
s.shiftKey && c === i ? (s.preventDefault(), l.focus()) : !s.shiftKey && c === l && (s.preventDefault(), i.focus());
|
|
1195
1294
|
};
|
|
1196
1295
|
return r.addEventListener("keydown", n), () => r.removeEventListener("keydown", n);
|
|
1197
|
-
}, [
|
|
1296
|
+
}, [e, t]);
|
|
1198
1297
|
}
|
|
1199
|
-
const
|
|
1200
|
-
function
|
|
1201
|
-
return
|
|
1298
|
+
const bt = /\*\*([^*]+)\*\*/g, yt = /\*([^*]+)\*/g, xt = /https?:\/\/[^\s)]+/g;
|
|
1299
|
+
function wt(e) {
|
|
1300
|
+
return e.replace(bt, "$1").replace(yt, "$1").replace(xt, (t) => {
|
|
1202
1301
|
try {
|
|
1203
|
-
return new URL(
|
|
1302
|
+
return new URL(t).hostname;
|
|
1204
1303
|
} catch {
|
|
1205
|
-
return
|
|
1304
|
+
return t;
|
|
1206
1305
|
}
|
|
1207
1306
|
});
|
|
1208
1307
|
}
|
|
1209
|
-
const
|
|
1308
|
+
const vt = {
|
|
1210
1309
|
"bottom-right": "bottom-24 right-3 sm:right-6",
|
|
1211
1310
|
"bottom-left": "bottom-24 left-3 sm:left-6",
|
|
1212
1311
|
"top-right": "top-24 right-3 sm:right-6",
|
|
1213
1312
|
"top-left": "top-24 left-3 sm:left-6"
|
|
1214
1313
|
};
|
|
1215
|
-
function
|
|
1216
|
-
messages:
|
|
1217
|
-
isLoading:
|
|
1314
|
+
function Rt({
|
|
1315
|
+
messages: e,
|
|
1316
|
+
isLoading: t,
|
|
1218
1317
|
isStreaming: r = !1,
|
|
1219
1318
|
streamingMessageId: n = null,
|
|
1220
1319
|
error: s,
|
|
1221
1320
|
canRetry: o = !1,
|
|
1222
1321
|
onSend: i,
|
|
1223
|
-
onStop:
|
|
1322
|
+
onStop: l,
|
|
1224
1323
|
onRetry: c,
|
|
1225
|
-
onClose:
|
|
1226
|
-
title:
|
|
1227
|
-
subtitle:
|
|
1228
|
-
welcomeMessage:
|
|
1229
|
-
placeholder:
|
|
1324
|
+
onClose: u,
|
|
1325
|
+
title: d = "Chat",
|
|
1326
|
+
subtitle: x = "Ask me anything",
|
|
1327
|
+
welcomeMessage: N = "Hi! How can I help you today?",
|
|
1328
|
+
placeholder: R,
|
|
1230
1329
|
position: T = "bottom-right",
|
|
1231
|
-
translations:
|
|
1232
|
-
isMobile:
|
|
1330
|
+
translations: p,
|
|
1331
|
+
isMobile: v = !1
|
|
1233
1332
|
}) {
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1236
|
-
const { offsetY:
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
),
|
|
1241
|
-
|
|
1242
|
-
const
|
|
1243
|
-
|
|
1244
|
-
}, [
|
|
1245
|
-
const
|
|
1246
|
-
|
|
1333
|
+
const k = Le(), H = I(null), w = I(null), [f, E] = L(null);
|
|
1334
|
+
pt(H, !0);
|
|
1335
|
+
const { offsetY: F } = mt(
|
|
1336
|
+
w,
|
|
1337
|
+
u,
|
|
1338
|
+
v
|
|
1339
|
+
), W = F !== 0, y = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : !1;
|
|
1340
|
+
z(() => {
|
|
1341
|
+
const m = w.current;
|
|
1342
|
+
m && (m.scrollTop = m.scrollHeight);
|
|
1343
|
+
}, [e, t]), z(() => {
|
|
1344
|
+
const m = (V) => {
|
|
1345
|
+
V.key === "Escape" && !V.isComposing && u();
|
|
1247
1346
|
};
|
|
1248
|
-
return document.addEventListener("keydown",
|
|
1249
|
-
}, [
|
|
1250
|
-
const
|
|
1251
|
-
return /* @__PURE__ */
|
|
1347
|
+
return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
|
|
1348
|
+
}, [u]);
|
|
1349
|
+
const K = (p == null ? void 0 : p.closeChat) ?? "Close chat", B = (p == null ? void 0 : p.chatMessages) ?? "Chat messages", _ = [...e].reverse().find((m) => m.role === "assistant");
|
|
1350
|
+
return /* @__PURE__ */ g(
|
|
1252
1351
|
"div",
|
|
1253
1352
|
{
|
|
1254
|
-
ref:
|
|
1353
|
+
ref: H,
|
|
1255
1354
|
role: "dialog",
|
|
1256
|
-
"aria-modal":
|
|
1257
|
-
"aria-labelledby":
|
|
1258
|
-
className:
|
|
1259
|
-
style:
|
|
1260
|
-
"data-dragging":
|
|
1355
|
+
"aria-modal": v ? "true" : void 0,
|
|
1356
|
+
"aria-labelledby": k,
|
|
1357
|
+
className: v ? "claudius-bottom-sheet fixed inset-x-0 bottom-0 z-50 flex h-[90vh] w-full flex-col overflow-hidden rounded-t-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body" : `fixed ${vt[T]} z-50 flex h-[min(500px,calc(100vh-7rem))] w-[calc(100vw-1.5rem)] max-w-[380px] sm:max-w-[400px] md:max-w-[440px] flex-col overflow-hidden rounded-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body`,
|
|
1358
|
+
style: v && !y ? { transform: `translateY(${Math.max(0, F)}px)` } : void 0,
|
|
1359
|
+
"data-dragging": W || void 0,
|
|
1261
1360
|
children: [
|
|
1262
|
-
|
|
1361
|
+
v && /* @__PURE__ */ a("div", { className: "flex justify-center py-2", "aria-hidden": "true", children: /* @__PURE__ */ a("div", { className: "h-1 w-8 rounded-claudius-full bg-claudius-border" }) }),
|
|
1263
1362
|
/* @__PURE__ */ a(
|
|
1264
|
-
|
|
1363
|
+
dt,
|
|
1265
1364
|
{
|
|
1266
|
-
title:
|
|
1267
|
-
subtitle:
|
|
1268
|
-
titleId:
|
|
1269
|
-
closeLabel:
|
|
1270
|
-
onClose:
|
|
1365
|
+
title: d,
|
|
1366
|
+
subtitle: x,
|
|
1367
|
+
titleId: k,
|
|
1368
|
+
closeLabel: K,
|
|
1369
|
+
onClose: u
|
|
1271
1370
|
}
|
|
1272
1371
|
),
|
|
1273
|
-
/* @__PURE__ */
|
|
1274
|
-
|
|
1372
|
+
/* @__PURE__ */ g("div", { className: "relative flex-1 overflow-hidden", children: [
|
|
1373
|
+
f && /* @__PURE__ */ a(
|
|
1275
1374
|
ut,
|
|
1276
1375
|
{
|
|
1277
|
-
sources:
|
|
1278
|
-
onClose: () =>
|
|
1376
|
+
sources: f.sources,
|
|
1377
|
+
onClose: () => E(null)
|
|
1279
1378
|
}
|
|
1280
1379
|
),
|
|
1281
|
-
/* @__PURE__ */
|
|
1380
|
+
/* @__PURE__ */ g(
|
|
1282
1381
|
"div",
|
|
1283
1382
|
{
|
|
1284
|
-
ref:
|
|
1383
|
+
ref: w,
|
|
1285
1384
|
role: "log",
|
|
1286
1385
|
"aria-label": B,
|
|
1287
1386
|
className: "h-full space-y-3 overflow-y-auto px-4 py-4",
|
|
1288
1387
|
children: [
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1388
|
+
e.length === 0 && !s && /* @__PURE__ */ a("div", { className: "mr-auto flex max-w-[85%]", children: /* @__PURE__ */ a("div", { className: "rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-2.5 text-sm leading-relaxed text-claudius-assistant-bubble-text", children: N }) }),
|
|
1389
|
+
e.map((m) => /* @__PURE__ */ a(
|
|
1390
|
+
st,
|
|
1292
1391
|
{
|
|
1293
|
-
role:
|
|
1294
|
-
content:
|
|
1295
|
-
isStreaming:
|
|
1296
|
-
sources:
|
|
1297
|
-
|
|
1392
|
+
role: m.role,
|
|
1393
|
+
content: m.content,
|
|
1394
|
+
isStreaming: m.id === n,
|
|
1395
|
+
sources: m.sources,
|
|
1396
|
+
toolUses: m.toolUses,
|
|
1397
|
+
toolUsedLabel: p == null ? void 0 : p.toolUsed,
|
|
1398
|
+
toolDetailsLabel: p == null ? void 0 : p.toolDetails,
|
|
1399
|
+
isSourceActive: (f == null ? void 0 : f.messageId) === m.id,
|
|
1298
1400
|
onSourceClick: () => {
|
|
1299
|
-
(
|
|
1401
|
+
(f == null ? void 0 : f.messageId) === m.id ? E(null) : m.sources && m.sources.length > 0 && E({ messageId: m.id, sources: m.sources });
|
|
1300
1402
|
}
|
|
1301
1403
|
},
|
|
1302
|
-
|
|
1404
|
+
m.id
|
|
1303
1405
|
)),
|
|
1304
|
-
|
|
1305
|
-
indicator is redundant — show it only until the first token.
|
|
1306
|
-
|
|
1307
|
-
|
|
1406
|
+
t && /* Once streamed tokens are rendering in a bubble, the typing
|
|
1407
|
+
indicator is redundant — show it only until the first token.
|
|
1408
|
+
A tool-only placeholder (no text yet) keeps the indicator. */
|
|
1409
|
+
!(n !== null && e.some(
|
|
1410
|
+
(m) => m.id === n && m.content.length > 0
|
|
1411
|
+
)) && /* @__PURE__ */ a(
|
|
1412
|
+
ht,
|
|
1308
1413
|
{
|
|
1309
|
-
label: (
|
|
1414
|
+
label: (p == null ? void 0 : p.typingIndicator) ?? "Assistant is typing"
|
|
1310
1415
|
}
|
|
1311
1416
|
),
|
|
1312
1417
|
s && /* @__PURE__ */ a(
|
|
1313
|
-
|
|
1418
|
+
ft,
|
|
1314
1419
|
{
|
|
1315
1420
|
message: s,
|
|
1316
|
-
retryLabel: (
|
|
1317
|
-
onRetry: o && c && !
|
|
1421
|
+
retryLabel: (p == null ? void 0 : p.errorRetry) ?? "Retry",
|
|
1422
|
+
onRetry: o && c && !t ? c : void 0
|
|
1318
1423
|
}
|
|
1319
1424
|
)
|
|
1320
1425
|
]
|
|
@@ -1328,45 +1433,45 @@ function vt({
|
|
|
1328
1433
|
"aria-live": "polite",
|
|
1329
1434
|
"aria-atomic": "true",
|
|
1330
1435
|
className: "sr-only",
|
|
1331
|
-
children: _ && _.id !== n ?
|
|
1436
|
+
children: _ && _.id !== n ? wt(_.content) : ""
|
|
1332
1437
|
}
|
|
1333
1438
|
),
|
|
1334
1439
|
/* @__PURE__ */ a(
|
|
1335
|
-
|
|
1440
|
+
it,
|
|
1336
1441
|
{
|
|
1337
1442
|
onSend: i,
|
|
1338
|
-
isLoading:
|
|
1443
|
+
isLoading: t,
|
|
1339
1444
|
isStreaming: r,
|
|
1340
|
-
onStop:
|
|
1341
|
-
placeholder:
|
|
1342
|
-
translations:
|
|
1445
|
+
onStop: l,
|
|
1446
|
+
placeholder: R,
|
|
1447
|
+
translations: p
|
|
1343
1448
|
}
|
|
1344
1449
|
)
|
|
1345
1450
|
]
|
|
1346
1451
|
}
|
|
1347
1452
|
);
|
|
1348
1453
|
}
|
|
1349
|
-
function
|
|
1350
|
-
message:
|
|
1351
|
-
position:
|
|
1454
|
+
function Et({
|
|
1455
|
+
message: e,
|
|
1456
|
+
position: t,
|
|
1352
1457
|
onOpen: r,
|
|
1353
1458
|
onDismiss: n,
|
|
1354
1459
|
dismissLabel: s
|
|
1355
1460
|
}) {
|
|
1356
|
-
const o =
|
|
1461
|
+
const o = t.startsWith("bottom"), i = t.endsWith("right"), l = [
|
|
1357
1462
|
"claudius-greeting-bubble",
|
|
1358
1463
|
"fixed z-40 max-w-xs",
|
|
1359
1464
|
o ? "bottom-20" : "top-20",
|
|
1360
1465
|
i ? "right-4" : "left-4"
|
|
1361
1466
|
].join(" ");
|
|
1362
|
-
return /* @__PURE__ */
|
|
1467
|
+
return /* @__PURE__ */ g("div", { className: l, role: "status", "aria-live": "polite", children: [
|
|
1363
1468
|
/* @__PURE__ */ a(
|
|
1364
1469
|
"button",
|
|
1365
1470
|
{
|
|
1366
1471
|
type: "button",
|
|
1367
1472
|
onClick: r,
|
|
1368
1473
|
className: "block w-full rounded-claudius-lg bg-claudius-surface p-4 pr-8 text-left text-sm font-body text-claudius-text shadow-claudius-floating ring-1 ring-claudius-border transition hover:shadow-claudius-floating-hover focus:outline-none focus:ring-2 focus:ring-claudius-accent",
|
|
1369
|
-
children:
|
|
1474
|
+
children: e
|
|
1370
1475
|
}
|
|
1371
1476
|
),
|
|
1372
1477
|
/* @__PURE__ */ a(
|
|
@@ -1383,7 +1488,7 @@ function Rt({
|
|
|
1383
1488
|
)
|
|
1384
1489
|
] });
|
|
1385
1490
|
}
|
|
1386
|
-
const
|
|
1491
|
+
const Re = {
|
|
1387
1492
|
// ChatWindow
|
|
1388
1493
|
title: "Chat",
|
|
1389
1494
|
subtitle: "Ask me anything",
|
|
@@ -1395,6 +1500,8 @@ const we = {
|
|
|
1395
1500
|
placeholder: "Type your message...",
|
|
1396
1501
|
sendMessage: "Send message",
|
|
1397
1502
|
stopGenerating: "Stop generating",
|
|
1503
|
+
toolUsed: "Used tool:",
|
|
1504
|
+
toolDetails: "Tool details",
|
|
1398
1505
|
typeYourMessage: "Type your message",
|
|
1399
1506
|
// ChatToggleButton
|
|
1400
1507
|
openChat: "Open chat",
|
|
@@ -1407,11 +1514,11 @@ const we = {
|
|
|
1407
1514
|
errorRateLimitMinute: "Too many requests. Please wait a minute.",
|
|
1408
1515
|
errorRateLimitHour: "Hourly limit reached. Please try again later.",
|
|
1409
1516
|
errorRetry: "Retry"
|
|
1410
|
-
},
|
|
1411
|
-
function
|
|
1412
|
-
return { ...
|
|
1517
|
+
}, Tt = Re;
|
|
1518
|
+
function qt(e) {
|
|
1519
|
+
return { ...Tt, ...e };
|
|
1413
1520
|
}
|
|
1414
|
-
const
|
|
1521
|
+
const Mt = {
|
|
1415
1522
|
// ChatWindow
|
|
1416
1523
|
title: "Chat",
|
|
1417
1524
|
subtitle: "Pregúntame lo que quieras",
|
|
@@ -1423,6 +1530,8 @@ const Tt = {
|
|
|
1423
1530
|
placeholder: "Escribe tu mensaje...",
|
|
1424
1531
|
sendMessage: "Enviar mensaje",
|
|
1425
1532
|
stopGenerating: "Detener la respuesta",
|
|
1533
|
+
toolUsed: "Herramienta usada:",
|
|
1534
|
+
toolDetails: "Detalles de la herramienta",
|
|
1426
1535
|
typeYourMessage: "Escribe tu mensaje",
|
|
1427
1536
|
// ChatToggleButton
|
|
1428
1537
|
openChat: "Abrir chat",
|
|
@@ -1435,7 +1544,7 @@ const Tt = {
|
|
|
1435
1544
|
errorRateLimitMinute: "Demasiadas solicitudes. Espera un minuto.",
|
|
1436
1545
|
errorRateLimitHour: "Has alcanzado el límite por hora. Inténtalo más tarde.",
|
|
1437
1546
|
errorRetry: "Reintentar"
|
|
1438
|
-
},
|
|
1547
|
+
}, St = {
|
|
1439
1548
|
// ChatWindow
|
|
1440
1549
|
title: "Chat",
|
|
1441
1550
|
subtitle: "Posez-moi vos questions",
|
|
@@ -1447,6 +1556,8 @@ const Tt = {
|
|
|
1447
1556
|
placeholder: "Saisissez votre message...",
|
|
1448
1557
|
sendMessage: "Envoyer le message",
|
|
1449
1558
|
stopGenerating: "Arrêter la génération",
|
|
1559
|
+
toolUsed: "Outil utilisé :",
|
|
1560
|
+
toolDetails: "Détails de l'outil",
|
|
1450
1561
|
typeYourMessage: "Saisissez votre message",
|
|
1451
1562
|
// ChatToggleButton
|
|
1452
1563
|
openChat: "Ouvrir le chat",
|
|
@@ -1459,7 +1570,7 @@ const Tt = {
|
|
|
1459
1570
|
errorRateLimitMinute: "Trop de requêtes. Veuillez patienter une minute.",
|
|
1460
1571
|
errorRateLimitHour: "Limite horaire atteinte. Veuillez réessayer plus tard.",
|
|
1461
1572
|
errorRetry: "Réessayer"
|
|
1462
|
-
},
|
|
1573
|
+
}, Ct = {
|
|
1463
1574
|
// ChatWindow
|
|
1464
1575
|
title: "Chat",
|
|
1465
1576
|
subtitle: "Fragen Sie mich alles",
|
|
@@ -1471,6 +1582,8 @@ const Tt = {
|
|
|
1471
1582
|
placeholder: "Geben Sie Ihre Nachricht ein...",
|
|
1472
1583
|
sendMessage: "Nachricht senden",
|
|
1473
1584
|
stopGenerating: "Generierung stoppen",
|
|
1585
|
+
toolUsed: "Verwendetes Tool:",
|
|
1586
|
+
toolDetails: "Tool-Details",
|
|
1474
1587
|
typeYourMessage: "Geben Sie Ihre Nachricht ein",
|
|
1475
1588
|
// ChatToggleButton
|
|
1476
1589
|
openChat: "Chat öffnen",
|
|
@@ -1483,28 +1596,28 @@ const Tt = {
|
|
|
1483
1596
|
errorRateLimitMinute: "Zu viele Anfragen. Bitte warten Sie eine Minute.",
|
|
1484
1597
|
errorRateLimitHour: "Stündliches Limit erreicht. Bitte versuchen Sie es später erneut.",
|
|
1485
1598
|
errorRetry: "Erneut versuchen"
|
|
1486
|
-
},
|
|
1487
|
-
en:
|
|
1488
|
-
es:
|
|
1489
|
-
fr:
|
|
1490
|
-
de:
|
|
1599
|
+
}, Ee = {
|
|
1600
|
+
en: Re,
|
|
1601
|
+
es: Mt,
|
|
1602
|
+
fr: St,
|
|
1603
|
+
de: Ct
|
|
1491
1604
|
};
|
|
1492
|
-
function
|
|
1493
|
-
if (!
|
|
1494
|
-
const
|
|
1495
|
-
return Object.prototype.hasOwnProperty.call(
|
|
1605
|
+
function be(e) {
|
|
1606
|
+
if (!e) return;
|
|
1607
|
+
const t = e.toLowerCase().split("-")[0];
|
|
1608
|
+
return Object.prototype.hasOwnProperty.call(Ee, t) ? t : void 0;
|
|
1496
1609
|
}
|
|
1497
|
-
function
|
|
1498
|
-
const
|
|
1499
|
-
if (
|
|
1500
|
-
const
|
|
1501
|
-
return
|
|
1610
|
+
function Nt() {
|
|
1611
|
+
const e = typeof document < "u" ? be(document.documentElement.lang) : void 0;
|
|
1612
|
+
if (e) return e;
|
|
1613
|
+
const t = typeof navigator < "u" ? be(navigator.language) : void 0;
|
|
1614
|
+
return t || "en";
|
|
1502
1615
|
}
|
|
1503
|
-
function
|
|
1504
|
-
const { locale:
|
|
1616
|
+
function kt(e = {}) {
|
|
1617
|
+
const { locale: t, translations: r } = e, n = Ee[t ?? Nt()];
|
|
1505
1618
|
return r ? { ...n, ...r } : { ...n };
|
|
1506
1619
|
}
|
|
1507
|
-
const
|
|
1620
|
+
const ye = [
|
|
1508
1621
|
"accent",
|
|
1509
1622
|
"accentText",
|
|
1510
1623
|
"accentSoft",
|
|
@@ -1524,11 +1637,11 @@ const be = [
|
|
|
1524
1637
|
"errorText",
|
|
1525
1638
|
"link",
|
|
1526
1639
|
"scrim"
|
|
1527
|
-
],
|
|
1640
|
+
], Lt = ["sm", "md", "lg", "full", "tail"], At = [
|
|
1528
1641
|
"elevated",
|
|
1529
1642
|
"floating",
|
|
1530
1643
|
"floatingHover"
|
|
1531
|
-
],
|
|
1644
|
+
], Ot = ["heading", "body"], Te = {
|
|
1532
1645
|
default: {
|
|
1533
1646
|
name: "default"
|
|
1534
1647
|
},
|
|
@@ -1613,87 +1726,87 @@ const be = [
|
|
|
1613
1726
|
}
|
|
1614
1727
|
}
|
|
1615
1728
|
};
|
|
1616
|
-
function
|
|
1617
|
-
return Object.prototype.hasOwnProperty.call(
|
|
1729
|
+
function It(e) {
|
|
1730
|
+
return Object.prototype.hasOwnProperty.call(Te, e);
|
|
1618
1731
|
}
|
|
1619
|
-
const
|
|
1620
|
-
function
|
|
1621
|
-
if (
|
|
1732
|
+
const Dt = /* @__PURE__ */ new Set(["light", "dark", "auto"]);
|
|
1733
|
+
function _t(e) {
|
|
1734
|
+
if (e === void 0)
|
|
1622
1735
|
return { mode: "light" };
|
|
1623
|
-
if (typeof
|
|
1624
|
-
if (
|
|
1625
|
-
return { mode:
|
|
1626
|
-
if (
|
|
1627
|
-
const
|
|
1628
|
-
return { mode:
|
|
1736
|
+
if (typeof e == "string") {
|
|
1737
|
+
if (Dt.has(e))
|
|
1738
|
+
return { mode: e };
|
|
1739
|
+
if (It(e)) {
|
|
1740
|
+
const t = Te[e];
|
|
1741
|
+
return { mode: t.colorScheme ?? "light", theme: t };
|
|
1629
1742
|
}
|
|
1630
|
-
return { mode: "light", url:
|
|
1743
|
+
return { mode: "light", url: e };
|
|
1631
1744
|
}
|
|
1632
|
-
return { mode:
|
|
1745
|
+
return { mode: e.colorScheme ?? "light", theme: e };
|
|
1633
1746
|
}
|
|
1634
|
-
function
|
|
1635
|
-
return
|
|
1747
|
+
function jt(e) {
|
|
1748
|
+
return e.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
|
|
1636
1749
|
}
|
|
1637
|
-
function Ht(
|
|
1750
|
+
function Ht(e, t) {
|
|
1638
1751
|
console.warn(
|
|
1639
|
-
`[Claudius] Ignoring unknown theme token "${
|
|
1752
|
+
`[Claudius] Ignoring unknown theme token "${t}" in "${e}"`
|
|
1640
1753
|
);
|
|
1641
1754
|
}
|
|
1642
|
-
function
|
|
1755
|
+
function Q(e, t, r, n, s, o = "") {
|
|
1643
1756
|
if (s)
|
|
1644
|
-
for (const [i,
|
|
1757
|
+
for (const [i, l] of Object.entries(s)) {
|
|
1645
1758
|
if (!n.includes(i)) {
|
|
1646
|
-
Ht(
|
|
1759
|
+
Ht(t, i);
|
|
1647
1760
|
continue;
|
|
1648
1761
|
}
|
|
1649
|
-
typeof
|
|
1762
|
+
typeof l == "string" && (e[`${r}${jt(i)}${o}`] = l);
|
|
1650
1763
|
}
|
|
1651
1764
|
}
|
|
1652
|
-
function
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
for (const [r, n] of Object.entries({ ...
|
|
1656
|
-
|
|
1657
|
-
return
|
|
1658
|
-
|
|
1765
|
+
function Bt(e) {
|
|
1766
|
+
const t = {};
|
|
1767
|
+
Q(t, "colors", "--cl-color-", ye, e.colors);
|
|
1768
|
+
for (const [r, n] of Object.entries({ ...t }))
|
|
1769
|
+
t[`${r}-dark`] = n;
|
|
1770
|
+
return Q(
|
|
1771
|
+
t,
|
|
1659
1772
|
"colorsDark",
|
|
1660
1773
|
"--cl-color-",
|
|
1661
|
-
|
|
1662
|
-
|
|
1774
|
+
ye,
|
|
1775
|
+
e.colorsDark,
|
|
1663
1776
|
"-dark"
|
|
1664
|
-
),
|
|
1777
|
+
), Q(t, "radii", "--cl-radius-", Lt, e.radii), Q(t, "shadows", "--cl-shadow-", At, e.shadows), Q(t, "fonts", "--cl-font-", Ot, e.fonts), t;
|
|
1665
1778
|
}
|
|
1666
|
-
function
|
|
1667
|
-
return typeof
|
|
1779
|
+
function $t(e) {
|
|
1780
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
1668
1781
|
}
|
|
1669
|
-
function
|
|
1670
|
-
const
|
|
1671
|
-
|
|
1782
|
+
function Pt(e) {
|
|
1783
|
+
const t = se(() => _t(e), [e]), [r, n] = L(null), s = t.url;
|
|
1784
|
+
z(() => {
|
|
1672
1785
|
if (n(null), !s) return;
|
|
1673
1786
|
const c = new AbortController();
|
|
1674
|
-
return fetch(s, { signal: c.signal }).then((
|
|
1675
|
-
if (!
|
|
1676
|
-
throw new Error(`HTTP ${
|
|
1677
|
-
return
|
|
1678
|
-
}).then((
|
|
1679
|
-
if (
|
|
1787
|
+
return fetch(s, { signal: c.signal }).then((u) => {
|
|
1788
|
+
if (!u.ok)
|
|
1789
|
+
throw new Error(`HTTP ${u.status}`);
|
|
1790
|
+
return u.json();
|
|
1791
|
+
}).then((u) => {
|
|
1792
|
+
if (!$t(u))
|
|
1680
1793
|
throw new Error("theme JSON must be an object");
|
|
1681
|
-
n(
|
|
1682
|
-
}).catch((
|
|
1683
|
-
c.signal.aborted || console.error(`[Claudius] Failed to load theme from ${s}:`,
|
|
1794
|
+
n(u);
|
|
1795
|
+
}).catch((u) => {
|
|
1796
|
+
c.signal.aborted || console.error(`[Claudius] Failed to load theme from ${s}:`, u);
|
|
1684
1797
|
}), () => c.abort();
|
|
1685
1798
|
}, [s]);
|
|
1686
|
-
const o =
|
|
1687
|
-
() => o ?
|
|
1799
|
+
const o = t.theme ?? r ?? null, i = (r == null ? void 0 : r.colorScheme) ?? t.mode, l = se(
|
|
1800
|
+
() => o ? Bt(o) : {},
|
|
1688
1801
|
[o]
|
|
1689
1802
|
);
|
|
1690
|
-
return { mode: i, cssVars:
|
|
1803
|
+
return { mode: i, cssVars: l };
|
|
1691
1804
|
}
|
|
1692
|
-
const
|
|
1693
|
-
function
|
|
1805
|
+
const Me = "claudius:triggers:dismissed";
|
|
1806
|
+
function Ut() {
|
|
1694
1807
|
if (typeof window > "u") return !1;
|
|
1695
1808
|
try {
|
|
1696
|
-
return window.sessionStorage.getItem(
|
|
1809
|
+
return window.sessionStorage.getItem(Me) === "1";
|
|
1697
1810
|
} catch {
|
|
1698
1811
|
return !1;
|
|
1699
1812
|
}
|
|
@@ -1701,152 +1814,152 @@ function Pt() {
|
|
|
1701
1814
|
function Gt() {
|
|
1702
1815
|
if (!(typeof window > "u"))
|
|
1703
1816
|
try {
|
|
1704
|
-
window.sessionStorage.setItem(
|
|
1817
|
+
window.sessionStorage.setItem(Me, "1");
|
|
1705
1818
|
} catch {
|
|
1706
1819
|
}
|
|
1707
1820
|
}
|
|
1708
|
-
function
|
|
1709
|
-
apiUrl:
|
|
1710
|
-
title:
|
|
1821
|
+
function Jt({
|
|
1822
|
+
apiUrl: e,
|
|
1823
|
+
title: t,
|
|
1711
1824
|
subtitle: r,
|
|
1712
1825
|
welcomeMessage: n,
|
|
1713
1826
|
placeholder: s,
|
|
1714
1827
|
persistMessages: o,
|
|
1715
1828
|
storageKeyPrefix: i,
|
|
1716
|
-
requestTimeoutMs:
|
|
1829
|
+
requestTimeoutMs: l,
|
|
1717
1830
|
theme: c = "light",
|
|
1718
|
-
accentColor:
|
|
1719
|
-
position:
|
|
1720
|
-
locale:
|
|
1721
|
-
translations:
|
|
1722
|
-
triggers:
|
|
1831
|
+
accentColor: u,
|
|
1832
|
+
position: d = "bottom-right",
|
|
1833
|
+
locale: x,
|
|
1834
|
+
translations: N,
|
|
1835
|
+
triggers: R,
|
|
1723
1836
|
plugins: T,
|
|
1724
|
-
streaming:
|
|
1837
|
+
streaming: p = !0
|
|
1725
1838
|
}) {
|
|
1726
|
-
const [
|
|
1727
|
-
() =>
|
|
1728
|
-
[
|
|
1839
|
+
const [v, k] = L(!1), [H, w] = L(null), [f, E] = L(Ut), F = I(!1), W = Ge("(max-width: 639px)"), y = se(
|
|
1840
|
+
() => kt({ locale: x, translations: N }),
|
|
1841
|
+
[x, N]
|
|
1729
1842
|
), {
|
|
1730
|
-
messages:
|
|
1843
|
+
messages: K,
|
|
1731
1844
|
isLoading: B,
|
|
1732
1845
|
isStreaming: _,
|
|
1733
|
-
streamingMessageId:
|
|
1734
|
-
error:
|
|
1735
|
-
canRetry:
|
|
1736
|
-
sendMessage:
|
|
1737
|
-
stop:
|
|
1738
|
-
retry:
|
|
1739
|
-
} =
|
|
1740
|
-
apiUrl:
|
|
1846
|
+
streamingMessageId: m,
|
|
1847
|
+
error: V,
|
|
1848
|
+
canRetry: ee,
|
|
1849
|
+
sendMessage: J,
|
|
1850
|
+
stop: oe,
|
|
1851
|
+
retry: ie
|
|
1852
|
+
} = Ue({
|
|
1853
|
+
apiUrl: e,
|
|
1741
1854
|
persistMessages: o,
|
|
1742
1855
|
storageKeyPrefix: i,
|
|
1743
|
-
timeoutMs:
|
|
1744
|
-
translations:
|
|
1856
|
+
timeoutMs: l,
|
|
1857
|
+
translations: y,
|
|
1745
1858
|
plugins: T,
|
|
1746
|
-
streaming:
|
|
1747
|
-
}),
|
|
1748
|
-
|
|
1749
|
-
if (
|
|
1750
|
-
const
|
|
1751
|
-
|
|
1752
|
-
const
|
|
1753
|
-
return
|
|
1754
|
-
}, [
|
|
1755
|
-
var
|
|
1756
|
-
|
|
1757
|
-
}, [
|
|
1758
|
-
const
|
|
1759
|
-
|
|
1760
|
-
}, []),
|
|
1761
|
-
|
|
1762
|
-
}, [
|
|
1763
|
-
|
|
1764
|
-
}, []), M =
|
|
1765
|
-
|
|
1766
|
-
}, []),
|
|
1767
|
-
|
|
1768
|
-
}, []),
|
|
1769
|
-
|
|
1770
|
-
}, [M]),
|
|
1771
|
-
|
|
1772
|
-
}, [
|
|
1859
|
+
streaming: p
|
|
1860
|
+
}), te = I(null), re = I(v), { mode: h, cssVars: A } = Pt(c), [S, Y] = L(!1);
|
|
1861
|
+
z(() => {
|
|
1862
|
+
if (h !== "auto") return;
|
|
1863
|
+
const D = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1864
|
+
Y(D.matches);
|
|
1865
|
+
const he = (Se) => Y(Se.matches);
|
|
1866
|
+
return D.addEventListener("change", he), () => D.removeEventListener("change", he);
|
|
1867
|
+
}, [h]), z(() => {
|
|
1868
|
+
var D;
|
|
1869
|
+
re.current && !v && ((D = te.current) == null || D.focus()), re.current = v;
|
|
1870
|
+
}, [v]);
|
|
1871
|
+
const $ = O(() => {
|
|
1872
|
+
E(!0), Gt();
|
|
1873
|
+
}, []), b = O(() => {
|
|
1874
|
+
k(!1), F.current && (F.current = !1, $());
|
|
1875
|
+
}, [$]), C = O(() => {
|
|
1876
|
+
k((D) => !D);
|
|
1877
|
+
}, []), M = O(() => {
|
|
1878
|
+
F.current = !0, w(null), k(!0);
|
|
1879
|
+
}, []), P = O((D) => {
|
|
1880
|
+
w(D);
|
|
1881
|
+
}, []), U = O(() => {
|
|
1882
|
+
w(null), M();
|
|
1883
|
+
}, [M]), Z = O(() => {
|
|
1884
|
+
w(null), $();
|
|
1885
|
+
}, [$]);
|
|
1773
1886
|
ze({
|
|
1774
|
-
triggers:
|
|
1775
|
-
enabled: !
|
|
1887
|
+
triggers: R,
|
|
1888
|
+
enabled: !f && !v,
|
|
1776
1889
|
onOpen: M,
|
|
1777
|
-
onGreeting:
|
|
1890
|
+
onGreeting: P
|
|
1778
1891
|
});
|
|
1779
|
-
const
|
|
1780
|
-
...
|
|
1781
|
-
...
|
|
1782
|
-
"--cl-color-accent":
|
|
1783
|
-
"--cl-color-accent-dark":
|
|
1892
|
+
const G = h === "dark" || h === "auto" && S, q = {
|
|
1893
|
+
...A,
|
|
1894
|
+
...u ? {
|
|
1895
|
+
"--cl-color-accent": u,
|
|
1896
|
+
"--cl-color-accent-dark": u
|
|
1784
1897
|
} : {}
|
|
1785
|
-
},
|
|
1898
|
+
}, ae = Object.keys(q).length > 0 ? q : void 0;
|
|
1786
1899
|
return (
|
|
1787
1900
|
// Outer div carries theme token vars; the inner div carries the dark-mode
|
|
1788
1901
|
// attribute so the [data-claudius-dark] token reassignments in styles.css
|
|
1789
1902
|
// beat inherited (inline) light values.
|
|
1790
|
-
/* @__PURE__ */ a("div", { className: "claudius-root", style:
|
|
1791
|
-
|
|
1903
|
+
/* @__PURE__ */ a("div", { className: "claudius-root", style: ae, children: /* @__PURE__ */ g("div", { "data-claudius-dark": G ? "true" : "false", children: [
|
|
1904
|
+
v && W && /* @__PURE__ */ a(
|
|
1792
1905
|
"div",
|
|
1793
1906
|
{
|
|
1794
1907
|
className: "claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",
|
|
1795
|
-
onClick:
|
|
1908
|
+
onClick: b,
|
|
1796
1909
|
"aria-hidden": "true"
|
|
1797
1910
|
}
|
|
1798
1911
|
),
|
|
1799
|
-
|
|
1800
|
-
|
|
1912
|
+
v && /* @__PURE__ */ a(
|
|
1913
|
+
Rt,
|
|
1801
1914
|
{
|
|
1802
|
-
messages:
|
|
1915
|
+
messages: K,
|
|
1803
1916
|
isLoading: B,
|
|
1804
1917
|
isStreaming: _,
|
|
1805
|
-
streamingMessageId:
|
|
1806
|
-
error:
|
|
1807
|
-
canRetry:
|
|
1808
|
-
onSend:
|
|
1809
|
-
onStop:
|
|
1810
|
-
onRetry:
|
|
1811
|
-
onClose:
|
|
1812
|
-
title:
|
|
1813
|
-
subtitle: r ??
|
|
1814
|
-
welcomeMessage: n ??
|
|
1815
|
-
placeholder: s ??
|
|
1816
|
-
position:
|
|
1817
|
-
translations:
|
|
1818
|
-
isMobile:
|
|
1918
|
+
streamingMessageId: m,
|
|
1919
|
+
error: V,
|
|
1920
|
+
canRetry: ee,
|
|
1921
|
+
onSend: J,
|
|
1922
|
+
onStop: oe,
|
|
1923
|
+
onRetry: ie,
|
|
1924
|
+
onClose: b,
|
|
1925
|
+
title: t ?? y.title,
|
|
1926
|
+
subtitle: r ?? y.subtitle,
|
|
1927
|
+
welcomeMessage: n ?? y.welcomeMessage,
|
|
1928
|
+
placeholder: s ?? y.placeholder,
|
|
1929
|
+
position: d,
|
|
1930
|
+
translations: y,
|
|
1931
|
+
isMobile: W
|
|
1819
1932
|
}
|
|
1820
1933
|
),
|
|
1821
|
-
!(
|
|
1822
|
-
|
|
1934
|
+
!(v && W) && /* @__PURE__ */ a(
|
|
1935
|
+
Ve,
|
|
1823
1936
|
{
|
|
1824
|
-
ref:
|
|
1825
|
-
isOpen:
|
|
1826
|
-
onClick:
|
|
1827
|
-
position:
|
|
1828
|
-
translations:
|
|
1937
|
+
ref: te,
|
|
1938
|
+
isOpen: v,
|
|
1939
|
+
onClick: C,
|
|
1940
|
+
position: d,
|
|
1941
|
+
translations: y
|
|
1829
1942
|
}
|
|
1830
1943
|
),
|
|
1831
|
-
!
|
|
1832
|
-
|
|
1944
|
+
!v && H && /* @__PURE__ */ a(
|
|
1945
|
+
Et,
|
|
1833
1946
|
{
|
|
1834
|
-
message:
|
|
1835
|
-
position:
|
|
1836
|
-
onOpen:
|
|
1837
|
-
onDismiss:
|
|
1838
|
-
dismissLabel:
|
|
1947
|
+
message: H,
|
|
1948
|
+
position: d,
|
|
1949
|
+
onOpen: U,
|
|
1950
|
+
onDismiss: Z,
|
|
1951
|
+
dismissLabel: y.dismissGreeting
|
|
1839
1952
|
}
|
|
1840
1953
|
)
|
|
1841
1954
|
] }) })
|
|
1842
1955
|
);
|
|
1843
1956
|
}
|
|
1844
|
-
function
|
|
1845
|
-
const { onEvent:
|
|
1957
|
+
function Xt(e) {
|
|
1958
|
+
const { onEvent: t, includeContent: r = !0 } = e, n = (s) => r ? s : "";
|
|
1846
1959
|
return {
|
|
1847
1960
|
name: "analytics",
|
|
1848
1961
|
onBeforeSend(s) {
|
|
1849
|
-
|
|
1962
|
+
t({
|
|
1850
1963
|
type: "message_sent",
|
|
1851
1964
|
role: "user",
|
|
1852
1965
|
content: n(s.content),
|
|
@@ -1854,7 +1967,7 @@ function Jt(t) {
|
|
|
1854
1967
|
});
|
|
1855
1968
|
},
|
|
1856
1969
|
onAfterReceive(s) {
|
|
1857
|
-
|
|
1970
|
+
t({
|
|
1858
1971
|
type: "message_received",
|
|
1859
1972
|
role: "assistant",
|
|
1860
1973
|
content: n(s.content),
|
|
@@ -1862,7 +1975,7 @@ function Jt(t) {
|
|
|
1862
1975
|
});
|
|
1863
1976
|
},
|
|
1864
1977
|
onError(s) {
|
|
1865
|
-
|
|
1978
|
+
t({
|
|
1866
1979
|
type: "chat_error",
|
|
1867
1980
|
message: s.message,
|
|
1868
1981
|
code: s.code
|
|
@@ -1870,7 +1983,7 @@ function Jt(t) {
|
|
|
1870
1983
|
}
|
|
1871
1984
|
};
|
|
1872
1985
|
}
|
|
1873
|
-
const
|
|
1986
|
+
const Wt = [
|
|
1874
1987
|
// Email
|
|
1875
1988
|
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,
|
|
1876
1989
|
// US SSN (before the looser card pattern so it wins on 9-digit groups)
|
|
@@ -1880,20 +1993,20 @@ const Ut = [
|
|
|
1880
1993
|
// Phone: optional +1, area code, 7 digits with common separators
|
|
1881
1994
|
/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g
|
|
1882
1995
|
];
|
|
1883
|
-
function
|
|
1884
|
-
return
|
|
1996
|
+
function zt(e, t, r) {
|
|
1997
|
+
return t.reduce(
|
|
1885
1998
|
// Reset lastIndex defensively: a shared global regex is stateful.
|
|
1886
1999
|
(n, s) => (s.lastIndex = 0, n.replace(s, r)),
|
|
1887
|
-
|
|
2000
|
+
e
|
|
1888
2001
|
);
|
|
1889
2002
|
}
|
|
1890
|
-
function
|
|
2003
|
+
function Zt(e = {}) {
|
|
1891
2004
|
const {
|
|
1892
|
-
patterns:
|
|
2005
|
+
patterns: t = Wt,
|
|
1893
2006
|
replacement: r = "[redacted]",
|
|
1894
2007
|
redactReplies: n = !1
|
|
1895
|
-
} =
|
|
1896
|
-
const i =
|
|
2008
|
+
} = e, s = (o) => {
|
|
2009
|
+
const i = zt(o.content, t, r);
|
|
1897
2010
|
if (i !== o.content)
|
|
1898
2011
|
return { ...o, content: i };
|
|
1899
2012
|
};
|
|
@@ -1903,16 +2016,16 @@ function Xt(t = {}) {
|
|
|
1903
2016
|
onAfterReceive: n ? s : void 0
|
|
1904
2017
|
};
|
|
1905
2018
|
}
|
|
1906
|
-
function
|
|
1907
|
-
return typeof
|
|
2019
|
+
function Ft(e, t, r) {
|
|
2020
|
+
return typeof e == "function" ? e(t) : e instanceof RegExp ? e.test(t) : r ? t.includes(e) : t.toLowerCase().includes(e.toLowerCase());
|
|
1908
2021
|
}
|
|
1909
|
-
function
|
|
1910
|
-
const { rules:
|
|
2022
|
+
function Qt(e) {
|
|
2023
|
+
const { rules: t, caseSensitive: r = !1 } = e;
|
|
1911
2024
|
return {
|
|
1912
2025
|
name: "canned-responses",
|
|
1913
2026
|
onBeforeSend(n, s) {
|
|
1914
|
-
for (const o of
|
|
1915
|
-
if (
|
|
2027
|
+
for (const o of t)
|
|
2028
|
+
if (Ft(o.match, n.content, r)) {
|
|
1916
2029
|
s.respondWith(o.reply);
|
|
1917
2030
|
return;
|
|
1918
2031
|
}
|
|
@@ -1921,18 +2034,18 @@ function Zt(t) {
|
|
|
1921
2034
|
}
|
|
1922
2035
|
export {
|
|
1923
2036
|
Oe as ChatApiClient,
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
2037
|
+
j as ChatApiError,
|
|
2038
|
+
Jt as ChatWidget,
|
|
2039
|
+
Wt as DEFAULT_PII_PATTERNS,
|
|
2040
|
+
le as DebounceError,
|
|
2041
|
+
Te as builtinThemes,
|
|
2042
|
+
qt as createTranslations,
|
|
2043
|
+
Tt as defaultTranslations,
|
|
2044
|
+
Nt as detectLocale,
|
|
2045
|
+
Ee as locales,
|
|
2046
|
+
Xt as pluginAnalytics,
|
|
2047
|
+
Qt as pluginCannedResponses,
|
|
2048
|
+
Zt as pluginRedactPII,
|
|
2049
|
+
zt as redactText,
|
|
2050
|
+
kt as resolveTranslations
|
|
1938
2051
|
};
|