@brainbase-labs/chat-widget 0.1.11 → 0.1.13
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/embed/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.js +101 -101
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useState as N, useRef as U, useEffect as Z, useCallback as x, useMemo as te } from "react";
|
|
2
2
|
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
3
3
|
const oe = "bb-chat-";
|
|
4
|
-
function
|
|
4
|
+
function le(o) {
|
|
5
5
|
try {
|
|
6
6
|
const t = sessionStorage.getItem(`${oe}${o}`);
|
|
7
7
|
return t ? JSON.parse(t) : null;
|
|
@@ -24,7 +24,7 @@ function re(o) {
|
|
|
24
24
|
} catch {
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function de(o) {
|
|
28
28
|
const {
|
|
29
29
|
config: t,
|
|
30
30
|
apiClient: s,
|
|
@@ -33,25 +33,25 @@ function le(o) {
|
|
|
33
33
|
onSessionEnd: m,
|
|
34
34
|
onMessage: c,
|
|
35
35
|
onError: g
|
|
36
|
-
} = o, [l, n] = N([]), [
|
|
36
|
+
} = o, [l, n] = N([]), [y, M] = N([]), [A, H] = N(!1), [P, z] = N(null), [b, _] = N(null), S = U(0), K = U(!1);
|
|
37
37
|
Z(() => {
|
|
38
38
|
if (K.current) return;
|
|
39
39
|
K.current = !0;
|
|
40
|
-
const p =
|
|
40
|
+
const p = le(t.embedId);
|
|
41
41
|
p && p.status === "active" && (_(p.sessionId), n(p.messages), M(p.toolCalls), S.current = p.startTime);
|
|
42
42
|
}, [t.embedId]), Z(() => {
|
|
43
|
-
|
|
44
|
-
sessionId:
|
|
43
|
+
b && l.length > 0 && se(t.embedId, {
|
|
44
|
+
sessionId: b,
|
|
45
45
|
deploymentId: t.deploymentId,
|
|
46
46
|
workerId: t.workerId,
|
|
47
47
|
flowId: t.flowId,
|
|
48
48
|
startTime: S.current,
|
|
49
49
|
messages: l,
|
|
50
|
-
toolCalls:
|
|
50
|
+
toolCalls: y,
|
|
51
51
|
status: "active"
|
|
52
52
|
});
|
|
53
|
-
}, [
|
|
54
|
-
const
|
|
53
|
+
}, [b, l, y, t]);
|
|
54
|
+
const J = x(async () => (S.current = Date.now(), _(null), n([]), M([]), re(t.embedId), ""), [t.embedId]), j = x(
|
|
55
55
|
(p, I, k) => {
|
|
56
56
|
switch (p.type) {
|
|
57
57
|
case "session": {
|
|
@@ -104,14 +104,14 @@ function le(o) {
|
|
|
104
104
|
case "completed": {
|
|
105
105
|
n(
|
|
106
106
|
(d) => d.map((h) => h.id === I ? { ...h, status: "sent" } : h)
|
|
107
|
-
),
|
|
108
|
-
sessionId:
|
|
107
|
+
), b && se(t.embedId, {
|
|
108
|
+
sessionId: b,
|
|
109
109
|
deploymentId: t.deploymentId,
|
|
110
110
|
workerId: t.workerId,
|
|
111
111
|
flowId: t.flowId,
|
|
112
112
|
startTime: S.current,
|
|
113
113
|
messages: l,
|
|
114
|
-
toolCalls:
|
|
114
|
+
toolCalls: y,
|
|
115
115
|
status: "completed"
|
|
116
116
|
});
|
|
117
117
|
break;
|
|
@@ -131,7 +131,7 @@ function le(o) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
-
[t,
|
|
134
|
+
[t, b, l, y, u]
|
|
135
135
|
), T = x(
|
|
136
136
|
async (p, I, k) => {
|
|
137
137
|
const d = p.getReader(), h = new TextDecoder();
|
|
@@ -143,16 +143,16 @@ function le(o) {
|
|
|
143
143
|
for (a += h.decode(B, { stream: !0 }); a.includes(`
|
|
144
144
|
|
|
145
145
|
`); ) {
|
|
146
|
-
const [v,
|
|
146
|
+
const [v, V] = a.split(`
|
|
147
147
|
|
|
148
148
|
`, 2);
|
|
149
|
-
a =
|
|
149
|
+
a = V;
|
|
150
150
|
for (const ne of v.split(`
|
|
151
151
|
`))
|
|
152
152
|
if (ne.startsWith("data: "))
|
|
153
153
|
try {
|
|
154
|
-
const
|
|
155
|
-
|
|
154
|
+
const ie = JSON.parse(ne.slice(6));
|
|
155
|
+
j(ie, I, k);
|
|
156
156
|
} catch {
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -161,7 +161,7 @@ function le(o) {
|
|
|
161
161
|
d.releaseLock();
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
|
-
[
|
|
164
|
+
[j]
|
|
165
165
|
), ee = x(
|
|
166
166
|
async (p) => {
|
|
167
167
|
if (!p.trim()) return;
|
|
@@ -188,12 +188,12 @@ function le(o) {
|
|
|
188
188
|
if (r) {
|
|
189
189
|
const a = s.sendMessage(p);
|
|
190
190
|
for await (const f of a)
|
|
191
|
-
|
|
191
|
+
j(f, k, h);
|
|
192
192
|
} else {
|
|
193
193
|
const a = await s.sendMessage({
|
|
194
194
|
embedId: t.embedId,
|
|
195
195
|
message: p,
|
|
196
|
-
sessionId:
|
|
196
|
+
sessionId: b ?? void 0
|
|
197
197
|
});
|
|
198
198
|
await T(a, k, h);
|
|
199
199
|
}
|
|
@@ -214,51 +214,51 @@ function le(o) {
|
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
[
|
|
217
|
-
|
|
217
|
+
b,
|
|
218
218
|
s,
|
|
219
219
|
r,
|
|
220
220
|
t.embedId,
|
|
221
|
-
|
|
221
|
+
j,
|
|
222
222
|
T,
|
|
223
223
|
c,
|
|
224
224
|
g
|
|
225
225
|
]
|
|
226
|
-
),
|
|
227
|
-
if (!
|
|
226
|
+
), G = x(async () => {
|
|
227
|
+
if (!b) return;
|
|
228
228
|
const p = {
|
|
229
|
-
sessionId:
|
|
229
|
+
sessionId: b,
|
|
230
230
|
deploymentId: t.deploymentId,
|
|
231
231
|
workerId: t.workerId,
|
|
232
232
|
flowId: t.flowId,
|
|
233
233
|
startTime: S.current,
|
|
234
234
|
messages: l,
|
|
235
|
-
toolCalls:
|
|
235
|
+
toolCalls: y,
|
|
236
236
|
status: "completed"
|
|
237
237
|
};
|
|
238
238
|
m == null || m(p), re(t.embedId), _(null), n([]), M([]);
|
|
239
239
|
}, [
|
|
240
|
-
|
|
240
|
+
b,
|
|
241
241
|
t,
|
|
242
242
|
l,
|
|
243
|
-
|
|
243
|
+
y,
|
|
244
244
|
m
|
|
245
|
-
]),
|
|
245
|
+
]), O = x(() => {
|
|
246
246
|
n([]), M([]);
|
|
247
247
|
}, []);
|
|
248
248
|
return {
|
|
249
249
|
messages: l,
|
|
250
|
-
toolCalls:
|
|
250
|
+
toolCalls: y,
|
|
251
251
|
isLoading: A,
|
|
252
252
|
error: P,
|
|
253
|
-
sessionId:
|
|
253
|
+
sessionId: b,
|
|
254
254
|
sendMessage: ee,
|
|
255
|
-
endSession:
|
|
256
|
-
clearMessages:
|
|
257
|
-
startNewSession:
|
|
255
|
+
endSession: G,
|
|
256
|
+
clearMessages: O,
|
|
257
|
+
startNewSession: J
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
|
-
const
|
|
261
|
-
function ue(o =
|
|
260
|
+
const ce = "https://chat-embed-deployment.onrender.com";
|
|
261
|
+
function ue(o = ce) {
|
|
262
262
|
return {
|
|
263
263
|
async getDeploymentConfig(t) {
|
|
264
264
|
const s = await fetch(`${o}/chat/config/${t}`);
|
|
@@ -356,14 +356,14 @@ const me = {
|
|
|
356
356
|
delay: 1e3
|
|
357
357
|
}
|
|
358
358
|
];
|
|
359
|
-
function
|
|
359
|
+
function F(o) {
|
|
360
360
|
return new Promise((t) => setTimeout(t, o));
|
|
361
361
|
}
|
|
362
362
|
function pe(o, t) {
|
|
363
363
|
const s = { ...me, ...o }, r = t ?? ge, u = `mock-session-${Date.now()}`;
|
|
364
364
|
return {
|
|
365
365
|
async getDeploymentConfig(m) {
|
|
366
|
-
return await
|
|
366
|
+
return await F(300), s;
|
|
367
367
|
},
|
|
368
368
|
async *sendMessage(m) {
|
|
369
369
|
yield {
|
|
@@ -374,7 +374,7 @@ function pe(o, t) {
|
|
|
374
374
|
const c = r.find(
|
|
375
375
|
(n) => typeof n.trigger == "string" ? m.toLowerCase().includes(n.trigger.toLowerCase()) : n.trigger.test(m)
|
|
376
376
|
) ?? r[r.length - 1];
|
|
377
|
-
if (await
|
|
377
|
+
if (await F(c.delay ?? 500), c.toolCalls)
|
|
378
378
|
for (const n of c.toolCalls)
|
|
379
379
|
yield {
|
|
380
380
|
type: "tool_call",
|
|
@@ -383,14 +383,14 @@ function pe(o, t) {
|
|
|
383
383
|
args: n.arguments
|
|
384
384
|
},
|
|
385
385
|
timestamp: Date.now()
|
|
386
|
-
}, await
|
|
386
|
+
}, await F(300), yield {
|
|
387
387
|
type: "tool_call",
|
|
388
388
|
data: {
|
|
389
389
|
function: n.name,
|
|
390
390
|
result: n.result
|
|
391
391
|
},
|
|
392
392
|
timestamp: Date.now()
|
|
393
|
-
}, await
|
|
393
|
+
}, await F(200);
|
|
394
394
|
const g = c.response.split(" ");
|
|
395
395
|
let l = "";
|
|
396
396
|
for (const n of g)
|
|
@@ -398,7 +398,7 @@ function pe(o, t) {
|
|
|
398
398
|
type: "message",
|
|
399
399
|
data: { content: l, role: "assistant" },
|
|
400
400
|
timestamp: Date.now()
|
|
401
|
-
}, await
|
|
401
|
+
}, await F(30 + Math.random() * 40);
|
|
402
402
|
yield {
|
|
403
403
|
type: "done",
|
|
404
404
|
data: { session_id: u },
|
|
@@ -463,12 +463,12 @@ const q = ({
|
|
|
463
463
|
)
|
|
464
464
|
]
|
|
465
465
|
}
|
|
466
|
-
), he = "_header_1p6z5_1", _e = "_compact_1p6z5_9", fe = "_headerBackground_1p6z5_20",
|
|
466
|
+
), he = "_header_1p6z5_1", _e = "_compact_1p6z5_9", fe = "_headerBackground_1p6z5_20", ye = "_headerContent_1p6z5_59", be = "_topRow_1p6z5_64", we = "_agentInfo_1p6z5_79", Ce = "_agentLogo_1p6z5_85", ke = "_agentLogoPlaceholder_1p6z5_102", ve = "_brainbaseLogo_1p6z5_123", Ie = "_agentName_1p6z5_137", Ne = "_actions_1p6z5_144", Le = "_actionButton_1p6z5_149", $e = "_welcomeText_1p6z5_183", Be = "_title_1p6z5_202", xe = "_subtitle_1p6z5_210", w = {
|
|
467
467
|
header: he,
|
|
468
468
|
compact: _e,
|
|
469
469
|
headerBackground: fe,
|
|
470
|
-
headerContent:
|
|
471
|
-
topRow:
|
|
470
|
+
headerContent: ye,
|
|
471
|
+
topRow: be,
|
|
472
472
|
agentInfo: we,
|
|
473
473
|
agentLogo: Ce,
|
|
474
474
|
agentLogoPlaceholder: ke,
|
|
@@ -559,19 +559,19 @@ const q = ({
|
|
|
559
559
|
] })
|
|
560
560
|
] })
|
|
561
561
|
] });
|
|
562
|
-
}, Se = "_messageWrapper_c86gj_1", Te = "_user_c86gj_19", We = "_assistant_c86gj_24", De = "_avatar_c86gj_28", He = "_avatarPlaceholder_c86gj_43", Pe = "_brainbaseLogo_c86gj_53",
|
|
562
|
+
}, Se = "_messageWrapper_c86gj_1", Te = "_user_c86gj_19", We = "_assistant_c86gj_24", De = "_avatar_c86gj_28", He = "_avatarPlaceholder_c86gj_43", Pe = "_brainbaseLogo_c86gj_53", je = "_messageBubble_c86gj_58", Ve = "_error_c86gj_76", Ee = "_content_c86gj_81", Ae = "_cursor_c86gj_88", ze = "_errorIndicator_c86gj_107", L = {
|
|
563
563
|
messageWrapper: Se,
|
|
564
564
|
user: Te,
|
|
565
565
|
assistant: We,
|
|
566
566
|
avatar: De,
|
|
567
567
|
avatarPlaceholder: He,
|
|
568
568
|
brainbaseLogo: Pe,
|
|
569
|
-
messageBubble:
|
|
570
|
-
error:
|
|
571
|
-
content:
|
|
569
|
+
messageBubble: je,
|
|
570
|
+
error: Ve,
|
|
571
|
+
content: Ee,
|
|
572
572
|
cursor: Ae,
|
|
573
573
|
errorIndicator: ze
|
|
574
|
-
},
|
|
574
|
+
}, Oe = ({
|
|
575
575
|
message: o,
|
|
576
576
|
agentName: t,
|
|
577
577
|
agentLogoUrl: s
|
|
@@ -614,15 +614,15 @@ const q = ({
|
|
|
614
614
|
]
|
|
615
615
|
}
|
|
616
616
|
);
|
|
617
|
-
},
|
|
618
|
-
toolCall:
|
|
617
|
+
}, Fe = "_toolCall_1wby1_1", Re = "_iconWrapper_1wby1_24", Ue = "_spinner_1wby1_33", Ze = "_checkIcon_1wby1_48", qe = "_errorIcon_1wby1_54", Ke = "_content_1wby1_60", Je = "_label_1wby1_66", Ge = "_name_1wby1_73", Ye = "_pending_1wby1_78", Xe = "_completed_1wby1_82", Qe = "_error_1wby1_54", $ = {
|
|
618
|
+
toolCall: Fe,
|
|
619
619
|
iconWrapper: Re,
|
|
620
620
|
spinner: Ue,
|
|
621
621
|
checkIcon: Ze,
|
|
622
622
|
errorIcon: qe,
|
|
623
623
|
content: Ke,
|
|
624
|
-
label:
|
|
625
|
-
name:
|
|
624
|
+
label: Je,
|
|
625
|
+
name: Ge,
|
|
626
626
|
pending: Ye,
|
|
627
627
|
completed: Xe,
|
|
628
628
|
error: Qe
|
|
@@ -719,7 +719,7 @@ const q = ({
|
|
|
719
719
|
/* @__PURE__ */ e("p", { className: Y.emptyText, children: "Start a conversation" })
|
|
720
720
|
] }),
|
|
721
721
|
o.map((n) => /* @__PURE__ */ e(
|
|
722
|
-
|
|
722
|
+
Oe,
|
|
723
723
|
{
|
|
724
724
|
message: n,
|
|
725
725
|
agentName: r,
|
|
@@ -737,7 +737,7 @@ const q = ({
|
|
|
737
737
|
textarea: ht,
|
|
738
738
|
sendButton: _t,
|
|
739
739
|
hint: ft
|
|
740
|
-
},
|
|
740
|
+
}, yt = ({
|
|
741
741
|
onSend: o,
|
|
742
742
|
disabled: t = !1,
|
|
743
743
|
placeholder: s = "Send a message..."
|
|
@@ -752,8 +752,8 @@ const q = ({
|
|
|
752
752
|
const g = x(
|
|
753
753
|
(n) => {
|
|
754
754
|
n == null || n.preventDefault();
|
|
755
|
-
const
|
|
756
|
-
|
|
755
|
+
const y = r.trim();
|
|
756
|
+
y && !t && (o(y), u(""), m.current && (m.current.style.height = "auto"));
|
|
757
757
|
},
|
|
758
758
|
[r, t, o]
|
|
759
759
|
), l = x(
|
|
@@ -806,8 +806,8 @@ const q = ({
|
|
|
806
806
|
" for new line"
|
|
807
807
|
] })
|
|
808
808
|
] });
|
|
809
|
-
},
|
|
810
|
-
poweredBy:
|
|
809
|
+
}, bt = "_poweredBy_9jh5q_1", wt = "_logo_9jh5q_20", Ct = "_poweredText_9jh5q_24", kt = "_text_9jh5q_36", X = {
|
|
810
|
+
poweredBy: bt,
|
|
811
811
|
logo: wt,
|
|
812
812
|
poweredText: Ct,
|
|
813
813
|
text: kt
|
|
@@ -896,7 +896,7 @@ const q = ({
|
|
|
896
896
|
onNewChat: c
|
|
897
897
|
}) => {
|
|
898
898
|
var H;
|
|
899
|
-
const [g, l] = N(!1), n = t.length > 0,
|
|
899
|
+
const [g, l] = N(!1), n = t.length > 0, y = () => {
|
|
900
900
|
l(!0);
|
|
901
901
|
}, M = () => {
|
|
902
902
|
l(!1), c == null || c();
|
|
@@ -912,7 +912,7 @@ const q = ({
|
|
|
912
912
|
welcomeTitle: o.welcomeMessage || "Hello there.",
|
|
913
913
|
welcomeSubtitle: o.welcomeMessage ? void 0 : "How can we help?",
|
|
914
914
|
onClose: m,
|
|
915
|
-
onNewChatRequest:
|
|
915
|
+
onNewChatRequest: y,
|
|
916
916
|
showNewChatButton: n,
|
|
917
917
|
compact: n
|
|
918
918
|
}
|
|
@@ -929,7 +929,7 @@ const q = ({
|
|
|
929
929
|
}
|
|
930
930
|
),
|
|
931
931
|
/* @__PURE__ */ e(
|
|
932
|
-
|
|
932
|
+
yt,
|
|
933
933
|
{
|
|
934
934
|
onSend: u,
|
|
935
935
|
disabled: r,
|
|
@@ -962,11 +962,11 @@ const q = ({
|
|
|
962
962
|
] })
|
|
963
963
|
] }) })
|
|
964
964
|
] });
|
|
965
|
-
}, Dt = "_toggleButton_11dqz_1", Ht = "_icon_11dqz_31", Pt = "_agentLogo_11dqz_36",
|
|
965
|
+
}, Dt = "_toggleButton_11dqz_1", Ht = "_icon_11dqz_31", Pt = "_agentLogo_11dqz_36", jt = "_unreadBadge_11dqz_43", Q = {
|
|
966
966
|
toggleButton: Dt,
|
|
967
967
|
icon: Ht,
|
|
968
968
|
agentLogo: Pt,
|
|
969
|
-
unreadBadge:
|
|
969
|
+
unreadBadge: jt
|
|
970
970
|
}, ae = ({
|
|
971
971
|
onClick: o,
|
|
972
972
|
agentLogoUrl: t,
|
|
@@ -1001,20 +1001,20 @@ const q = ({
|
|
|
1001
1001
|
s > 0 && /* @__PURE__ */ e("span", { className: Q.unreadBadge, children: s > 9 ? "9+" : s })
|
|
1002
1002
|
]
|
|
1003
1003
|
}
|
|
1004
|
-
),
|
|
1005
|
-
container:
|
|
1006
|
-
header:
|
|
1004
|
+
), Vt = "_container_kgfgt_1", Et = "_header_kgfgt_25", At = "_logoWrapper_kgfgt_38", zt = "_logo_kgfgt_38", Ot = "_closeButton_kgfgt_51", Ft = "_content_kgfgt_74", Rt = "_iconWrapper_kgfgt_84", Ut = "_errorIcon_kgfgt_95", Zt = "_title_kgfgt_101", qt = "_description_kgfgt_109", Kt = "_retryButton_kgfgt_117", Jt = "_footer_kgfgt_139", Gt = "_poweredBy_kgfgt_146", Yt = "_footerLogo_kgfgt_160", C = {
|
|
1005
|
+
container: Vt,
|
|
1006
|
+
header: Et,
|
|
1007
1007
|
logoWrapper: At,
|
|
1008
1008
|
logo: zt,
|
|
1009
|
-
closeButton:
|
|
1010
|
-
content:
|
|
1009
|
+
closeButton: Ot,
|
|
1010
|
+
content: Ft,
|
|
1011
1011
|
iconWrapper: Rt,
|
|
1012
1012
|
errorIcon: Ut,
|
|
1013
1013
|
title: Zt,
|
|
1014
1014
|
description: qt,
|
|
1015
1015
|
retryButton: Kt,
|
|
1016
|
-
footer:
|
|
1017
|
-
poweredBy:
|
|
1016
|
+
footer: Jt,
|
|
1017
|
+
poweredBy: Gt,
|
|
1018
1018
|
footerLogo: Yt
|
|
1019
1019
|
}, Xt = ({
|
|
1020
1020
|
errorType: o,
|
|
@@ -1148,14 +1148,14 @@ const q = ({
|
|
|
1148
1148
|
}
|
|
1149
1149
|
) })
|
|
1150
1150
|
] });
|
|
1151
|
-
}, Qt = "_widget_1ehud_1", eo = "_inline_1ehud_25",
|
|
1151
|
+
}, Qt = "_widget_1ehud_1", eo = "_inline_1ehud_25", E = {
|
|
1152
1152
|
widget: Qt,
|
|
1153
1153
|
"bottom-right": "_bottom-right_1ehud_10",
|
|
1154
1154
|
"bottom-left": "_bottom-left_1ehud_17",
|
|
1155
1155
|
inline: eo
|
|
1156
|
-
},
|
|
1156
|
+
}, no = ({
|
|
1157
1157
|
embedId: o,
|
|
1158
|
-
apiBaseUrl: t =
|
|
1158
|
+
apiBaseUrl: t = ce,
|
|
1159
1159
|
mockMode: s = !1,
|
|
1160
1160
|
mockResponses: r,
|
|
1161
1161
|
position: u = "bottom-right",
|
|
@@ -1164,19 +1164,19 @@ const q = ({
|
|
|
1164
1164
|
agentName: g,
|
|
1165
1165
|
welcomeMessage: l,
|
|
1166
1166
|
showBranding: n,
|
|
1167
|
-
className:
|
|
1167
|
+
className: y,
|
|
1168
1168
|
onSessionStart: M,
|
|
1169
1169
|
onSessionEnd: A,
|
|
1170
1170
|
onMessage: H,
|
|
1171
1171
|
onError: P
|
|
1172
1172
|
}) => {
|
|
1173
|
-
const [z,
|
|
1173
|
+
const [z, b] = N(m), [_, S] = N(null), [K, J] = N(!0), [j, T] = N(null), [ee, G] = N(), O = te(() => s ? pe(
|
|
1174
1174
|
{ primaryColor: c, agentName: g, welcomeMessage: l },
|
|
1175
1175
|
r
|
|
1176
1176
|
) : ue(t), [s, c, g, l, r, t]), p = x(async () => {
|
|
1177
|
-
|
|
1177
|
+
J(!0), T(null), G(void 0);
|
|
1178
1178
|
try {
|
|
1179
|
-
const v = await
|
|
1179
|
+
const v = await O.getDeploymentConfig(o);
|
|
1180
1180
|
S({
|
|
1181
1181
|
...v,
|
|
1182
1182
|
// Allow prop overrides
|
|
@@ -1189,8 +1189,8 @@ const q = ({
|
|
|
1189
1189
|
}
|
|
1190
1190
|
});
|
|
1191
1191
|
} catch (v) {
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1192
|
+
const V = v instanceof Error ? v : new Error("Failed to load config");
|
|
1193
|
+
V.message.includes("404") ? (T("not_found"), G("The chat widget with this embed ID was not found.")) : V.message.includes("Failed to fetch") || V.message.includes("network") ? T("network") : T("unknown"), s && (S({
|
|
1194
1194
|
embedId: o,
|
|
1195
1195
|
deploymentId: "mock-deployment",
|
|
1196
1196
|
workerId: "mock-worker",
|
|
@@ -1198,11 +1198,11 @@ const q = ({
|
|
|
1198
1198
|
primaryColor: c ?? "#1a1a2e",
|
|
1199
1199
|
agentName: g ?? "AI Assistant",
|
|
1200
1200
|
styling: n !== void 0 ? { showBranding: n } : void 0
|
|
1201
|
-
}), T(null)), P == null || P(
|
|
1201
|
+
}), T(null)), P == null || P(V);
|
|
1202
1202
|
} finally {
|
|
1203
|
-
|
|
1203
|
+
J(!1);
|
|
1204
1204
|
}
|
|
1205
|
-
}, [o, s,
|
|
1205
|
+
}, [o, s, O, c, g, l, P]);
|
|
1206
1206
|
Z(() => {
|
|
1207
1207
|
p();
|
|
1208
1208
|
}, [p]);
|
|
@@ -1217,9 +1217,9 @@ const q = ({
|
|
|
1217
1217
|
styling: n !== void 0 ? {
|
|
1218
1218
|
showBranding: n
|
|
1219
1219
|
} : void 0
|
|
1220
|
-
}, [_, o, c, g, l, n]), k =
|
|
1220
|
+
}, [_, o, c, g, l, n]), k = de({
|
|
1221
1221
|
config: I,
|
|
1222
|
-
apiClient:
|
|
1222
|
+
apiClient: O,
|
|
1223
1223
|
mockMode: s,
|
|
1224
1224
|
onSessionStart: M,
|
|
1225
1225
|
onSessionEnd: A,
|
|
@@ -1233,19 +1233,19 @@ const q = ({
|
|
|
1233
1233
|
), h = () => {
|
|
1234
1234
|
k.endSession(), k.startNewSession();
|
|
1235
1235
|
}, a = () => {
|
|
1236
|
-
|
|
1236
|
+
b(!1);
|
|
1237
1237
|
}, f = () => {
|
|
1238
1238
|
p();
|
|
1239
1239
|
}, B = u === "inline";
|
|
1240
|
-
return K ? null :
|
|
1240
|
+
return K ? null : j && !s ? !B && !z ? /* @__PURE__ */ e(
|
|
1241
1241
|
"div",
|
|
1242
1242
|
{
|
|
1243
|
-
className: `${
|
|
1243
|
+
className: `${E.widget} ${E[u]} ${y ?? ""}`,
|
|
1244
1244
|
style: d,
|
|
1245
1245
|
children: /* @__PURE__ */ e(
|
|
1246
1246
|
ae,
|
|
1247
1247
|
{
|
|
1248
|
-
onClick: () =>
|
|
1248
|
+
onClick: () => b(!0),
|
|
1249
1249
|
agentName: g
|
|
1250
1250
|
}
|
|
1251
1251
|
)
|
|
@@ -1253,12 +1253,12 @@ const q = ({
|
|
|
1253
1253
|
) : /* @__PURE__ */ e(
|
|
1254
1254
|
"div",
|
|
1255
1255
|
{
|
|
1256
|
-
className: `${
|
|
1256
|
+
className: `${E.widget} ${E[u]} ${y ?? ""}`,
|
|
1257
1257
|
style: d,
|
|
1258
1258
|
children: /* @__PURE__ */ e(
|
|
1259
1259
|
Xt,
|
|
1260
1260
|
{
|
|
1261
|
-
errorType:
|
|
1261
|
+
errorType: j,
|
|
1262
1262
|
message: ee,
|
|
1263
1263
|
onRetry: f,
|
|
1264
1264
|
onClose: B ? void 0 : a
|
|
@@ -1268,7 +1268,7 @@ const q = ({
|
|
|
1268
1268
|
) : /* @__PURE__ */ e(
|
|
1269
1269
|
"div",
|
|
1270
1270
|
{
|
|
1271
|
-
className: `${
|
|
1271
|
+
className: `${E.widget} ${E[u]} ${y ?? ""}`,
|
|
1272
1272
|
style: d,
|
|
1273
1273
|
children: z || B ? /* @__PURE__ */ e(
|
|
1274
1274
|
Wt,
|
|
@@ -1283,7 +1283,7 @@ const q = ({
|
|
|
1283
1283
|
) : /* @__PURE__ */ e(
|
|
1284
1284
|
ae,
|
|
1285
1285
|
{
|
|
1286
|
-
onClick: () =>
|
|
1286
|
+
onClick: () => b(!0),
|
|
1287
1287
|
agentName: _ == null ? void 0 : _.agentName,
|
|
1288
1288
|
agentLogoUrl: _ == null ? void 0 : _.agentLogoUrl
|
|
1289
1289
|
}
|
|
@@ -1291,7 +1291,7 @@ const q = ({
|
|
|
1291
1291
|
}
|
|
1292
1292
|
);
|
|
1293
1293
|
};
|
|
1294
|
-
function
|
|
1294
|
+
function so() {
|
|
1295
1295
|
if (typeof crypto < "u" && crypto.randomUUID)
|
|
1296
1296
|
return `bb-${crypto.randomUUID()}`;
|
|
1297
1297
|
const o = Date.now().toString(36), t = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
|
|
@@ -1301,17 +1301,17 @@ export {
|
|
|
1301
1301
|
Wt as ChatContainer,
|
|
1302
1302
|
Me as ChatHeader,
|
|
1303
1303
|
ae as ChatToggleButton,
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1304
|
+
no as ChatWidget,
|
|
1305
|
+
Oe as Message,
|
|
1306
|
+
yt as MessageInput,
|
|
1307
1307
|
mt as MessageList,
|
|
1308
1308
|
et as ToolCallDisplay,
|
|
1309
1309
|
ct as TypingIndicator,
|
|
1310
1310
|
re as clearSession,
|
|
1311
1311
|
ue as createAPIClient,
|
|
1312
1312
|
pe as createMockAPIClient,
|
|
1313
|
-
|
|
1314
|
-
|
|
1313
|
+
so as generateSessionId,
|
|
1314
|
+
le as getStoredSession,
|
|
1315
1315
|
se as storeSession,
|
|
1316
|
-
|
|
1316
|
+
de as useChat
|
|
1317
1317
|
};
|
package/package.json
CHANGED