@brainbase-labs/chat-widget 0.1.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/index.js ADDED
@@ -0,0 +1,1212 @@
1
+ import { useState as k, useRef as A, useEffect as W, useCallback as x, useMemo as J } from "react";
2
+ import { jsxs as l, jsx as e } from "react/jsx-runtime";
3
+ const Y = "bb-chat-";
4
+ function re(n) {
5
+ try {
6
+ const t = sessionStorage.getItem(`${Y}${n}`);
7
+ return t ? JSON.parse(t) : null;
8
+ } catch {
9
+ return null;
10
+ }
11
+ }
12
+ function Q(n, t) {
13
+ try {
14
+ sessionStorage.setItem(
15
+ `${Y}${n}`,
16
+ JSON.stringify(t)
17
+ );
18
+ } catch {
19
+ }
20
+ }
21
+ function ee(n) {
22
+ try {
23
+ sessionStorage.removeItem(`${Y}${n}`);
24
+ } catch {
25
+ }
26
+ }
27
+ function ae(n) {
28
+ const {
29
+ config: t,
30
+ apiClient: s,
31
+ mockMode: r,
32
+ onSessionStart: h,
33
+ onSessionEnd: d,
34
+ onMessage: i,
35
+ onError: p
36
+ } = n, [u, o] = k([]), [C, L] = k([]), [V, N] = k(!1), [q, D] = k(null), [m, S] = k(null), B = A(0), Z = A(!1);
37
+ W(() => {
38
+ if (Z.current) return;
39
+ Z.current = !0;
40
+ const _ = re(t.embedId);
41
+ _ && _.status === "active" && (S(_.sessionId), o(_.messages), L(_.toolCalls), B.current = _.startTime);
42
+ }, [t.embedId]), W(() => {
43
+ m && u.length > 0 && Q(t.embedId, {
44
+ sessionId: m,
45
+ deploymentId: t.deploymentId,
46
+ workerId: t.workerId,
47
+ flowId: t.flowId,
48
+ startTime: B.current,
49
+ messages: u,
50
+ toolCalls: C,
51
+ status: "active"
52
+ });
53
+ }, [m, u, C, t]);
54
+ const K = x(async () => (B.current = Date.now(), S(null), o([]), L([]), ee(t.embedId), ""), [t.embedId]), H = x(
55
+ (_, y, b) => {
56
+ switch (_.type) {
57
+ case "session": {
58
+ const g = _.data;
59
+ g.session_id && (b(g.session_id), g.is_new && (B.current = Date.now(), h == null || h(g.session_id)));
60
+ break;
61
+ }
62
+ case "message": {
63
+ const g = _.data;
64
+ g.content && o(
65
+ (c) => c.map(
66
+ (a) => a.id === y ? { ...a, content: g.content, status: "streaming" } : a
67
+ )
68
+ );
69
+ break;
70
+ }
71
+ case "tool_call": {
72
+ const g = _.data;
73
+ L((c) => {
74
+ const a = c.findIndex(
75
+ (w) => w.name === g.function && w.status === "pending"
76
+ );
77
+ return a !== -1 && g.result !== void 0 ? c.map(
78
+ (w, j) => j === a ? { ...w, result: g.result, status: "completed" } : w
79
+ ) : a === -1 ? [
80
+ ...c,
81
+ {
82
+ id: `tc-${Date.now()}-${Math.random().toString(36).slice(2)}`,
83
+ name: g.function,
84
+ arguments: g.args ?? {},
85
+ status: "pending",
86
+ timestamp: Date.now()
87
+ }
88
+ ] : c;
89
+ }), g.content && o(
90
+ (c) => c.map(
91
+ (a) => a.id === y ? { ...a, content: g.content, status: "streaming" } : a
92
+ )
93
+ );
94
+ break;
95
+ }
96
+ case "waiting":
97
+ break;
98
+ case "done": {
99
+ o(
100
+ (g) => g.map((c) => c.id === y ? { ...c, status: "sent" } : c)
101
+ );
102
+ break;
103
+ }
104
+ case "completed": {
105
+ o(
106
+ (g) => g.map((c) => c.id === y ? { ...c, status: "sent" } : c)
107
+ ), m && Q(t.embedId, {
108
+ sessionId: m,
109
+ deploymentId: t.deploymentId,
110
+ workerId: t.workerId,
111
+ flowId: t.flowId,
112
+ startTime: B.current,
113
+ messages: u,
114
+ toolCalls: C,
115
+ status: "completed"
116
+ });
117
+ break;
118
+ }
119
+ case "error": {
120
+ const g = _.data;
121
+ o(
122
+ (c) => c.map(
123
+ (a) => a.id === y ? {
124
+ ...a,
125
+ status: "error",
126
+ content: g.error ?? "An error occurred"
127
+ } : a
128
+ )
129
+ );
130
+ break;
131
+ }
132
+ }
133
+ },
134
+ [t, m, u, C, h]
135
+ ), T = x(
136
+ async (_, y, b) => {
137
+ const g = _.getReader(), c = new TextDecoder();
138
+ let a = "";
139
+ try {
140
+ for (; ; ) {
141
+ const { done: w, value: j } = await g.read();
142
+ if (w) break;
143
+ for (a += c.decode(j, { stream: !0 }); a.includes(`
144
+
145
+ `); ) {
146
+ const [P, oe] = a.split(`
147
+
148
+ `, 2);
149
+ a = oe;
150
+ for (const X of P.split(`
151
+ `))
152
+ if (X.startsWith("data: "))
153
+ try {
154
+ const se = JSON.parse(X.slice(6));
155
+ H(se, y, b);
156
+ } catch {
157
+ }
158
+ }
159
+ }
160
+ } finally {
161
+ g.releaseLock();
162
+ }
163
+ },
164
+ [H]
165
+ ), O = x(
166
+ async (_) => {
167
+ if (!_.trim()) return;
168
+ const y = {
169
+ id: `user-${Date.now()}`,
170
+ role: "user",
171
+ content: _,
172
+ timestamp: Date.now(),
173
+ status: "sent"
174
+ };
175
+ o((a) => [...a, y]), i == null || i(y);
176
+ const b = `assistant-${Date.now()}`, g = {
177
+ id: b,
178
+ role: "assistant",
179
+ content: "",
180
+ timestamp: Date.now(),
181
+ status: "streaming"
182
+ };
183
+ o((a) => [...a, g]), N(!0), D(null);
184
+ const c = (a) => {
185
+ S(a);
186
+ };
187
+ try {
188
+ if (r) {
189
+ const a = s.sendMessage(_);
190
+ for await (const w of a)
191
+ H(w, b, c);
192
+ } else {
193
+ const a = await s.sendMessage({
194
+ embedId: t.embedId,
195
+ message: _,
196
+ sessionId: m ?? void 0
197
+ });
198
+ await T(a, b, c);
199
+ }
200
+ o(
201
+ (a) => a.map(
202
+ (w) => w.id === b && w.status === "streaming" ? { ...w, status: "sent" } : w
203
+ )
204
+ );
205
+ } catch (a) {
206
+ const w = a instanceof Error ? a : new Error("Failed to send message");
207
+ D(w), p == null || p(w), o(
208
+ (j) => j.map(
209
+ (P) => P.id === b ? { ...P, status: "error", content: "Failed to get response" } : P
210
+ )
211
+ );
212
+ } finally {
213
+ N(!1);
214
+ }
215
+ },
216
+ [
217
+ m,
218
+ s,
219
+ r,
220
+ t.embedId,
221
+ H,
222
+ T,
223
+ i,
224
+ p
225
+ ]
226
+ ), $ = x(async () => {
227
+ if (!m) return;
228
+ const _ = {
229
+ sessionId: m,
230
+ deploymentId: t.deploymentId,
231
+ workerId: t.workerId,
232
+ flowId: t.flowId,
233
+ startTime: B.current,
234
+ messages: u,
235
+ toolCalls: C,
236
+ status: "completed"
237
+ };
238
+ d == null || d(_), ee(t.embedId), S(null), o([]), L([]);
239
+ }, [
240
+ m,
241
+ t,
242
+ u,
243
+ C,
244
+ d
245
+ ]), G = x(() => {
246
+ o([]), L([]);
247
+ }, []);
248
+ return {
249
+ messages: u,
250
+ toolCalls: C,
251
+ isLoading: V,
252
+ error: q,
253
+ sessionId: m,
254
+ sendMessage: O,
255
+ endSession: $,
256
+ clearMessages: G,
257
+ startNewSession: K
258
+ };
259
+ }
260
+ const ie = "https://whatsapp-based-server.onrender.com";
261
+ function ce(n = ie) {
262
+ return {
263
+ async getDeploymentConfig(t) {
264
+ const s = await fetch(`${n}/chat/config/${t}`);
265
+ if (!s.ok)
266
+ throw new Error(`Failed to fetch deployment config: ${s.status}`);
267
+ const r = await s.json();
268
+ return {
269
+ embedId: r.embedId,
270
+ // Note: The public config endpoint doesn't expose internal IDs
271
+ // These will be resolved server-side when sending messages
272
+ deploymentId: "",
273
+ workerId: "",
274
+ flowId: "",
275
+ welcomeMessage: r.welcomeMessage,
276
+ agentName: r.agentName,
277
+ agentLogoUrl: r.agentLogoUrl,
278
+ primaryColor: r.primaryColor,
279
+ styling: r.styling
280
+ };
281
+ },
282
+ async sendMessage(t) {
283
+ const s = await fetch(`${n}/chat/message`, {
284
+ method: "POST",
285
+ headers: { "Content-Type": "application/json" },
286
+ body: JSON.stringify({
287
+ embed_id: t.embedId,
288
+ message: t.message,
289
+ session_id: t.sessionId || void 0,
290
+ metadata: t.metadata
291
+ })
292
+ });
293
+ if (!s.ok) {
294
+ const r = await s.text();
295
+ throw new Error(`Failed to send message: ${s.status} - ${r}`);
296
+ }
297
+ if (!s.body)
298
+ throw new Error("No response stream available");
299
+ return s.body;
300
+ }
301
+ };
302
+ }
303
+ const le = {
304
+ embedId: "mock-embed-id",
305
+ deploymentId: "mock-deployment-id",
306
+ workerId: "mock-worker-id",
307
+ flowId: "mock-flow-id",
308
+ // Note: welcomeMessage is handled by the engine, not the widget
309
+ agentName: "AI Assistant",
310
+ agentLogoUrl: void 0,
311
+ primaryColor: "#1a1a2e",
312
+ styling: {}
313
+ }, de = [
314
+ {
315
+ trigger: /hello|hi|hey/i,
316
+ response: "Hello! I'm a demo AI assistant. How can I help you today?",
317
+ delay: 500
318
+ },
319
+ {
320
+ trigger: /weather/i,
321
+ response: "I'd check the weather for you, but I'm in mock mode! In production, I could use a weather API.",
322
+ delay: 800,
323
+ toolCalls: [
324
+ {
325
+ name: "get_weather",
326
+ arguments: { location: "San Francisco" },
327
+ result: { temperature: 72, condition: "sunny" }
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ trigger: /help|support/i,
333
+ response: "I'm here to help! You can ask me questions, and I'll do my best to assist you. In production, I'd be connected to your Brainbase AI agent with full capabilities.",
334
+ delay: 600
335
+ },
336
+ {
337
+ trigger: /pricing|cost|price/i,
338
+ response: "For pricing information, I'd typically check our database or connect you with the sales team. This is a mock response demonstrating how I'd handle pricing questions.",
339
+ delay: 700,
340
+ toolCalls: [
341
+ {
342
+ name: "lookup_pricing",
343
+ arguments: { plan: "all" },
344
+ result: {
345
+ plans: [
346
+ { name: "Starter", price: "$29/mo" },
347
+ { name: "Pro", price: "$99/mo" }
348
+ ]
349
+ }
350
+ }
351
+ ]
352
+ },
353
+ {
354
+ trigger: /.*/,
355
+ response: "I'm running in mock mode. This is a simulated response to demonstrate the chat UI. In production, I'd be connected to your Brainbase AI agent!",
356
+ delay: 1e3
357
+ }
358
+ ];
359
+ function z(n) {
360
+ return new Promise((t) => setTimeout(t, n));
361
+ }
362
+ function ue(n, t) {
363
+ const s = { ...le, ...n }, r = t ?? de, h = `mock-session-${Date.now()}`;
364
+ return {
365
+ async getDeploymentConfig(d) {
366
+ return await z(300), s;
367
+ },
368
+ async *sendMessage(d) {
369
+ yield {
370
+ type: "session",
371
+ data: { session_id: h, is_new: !0 },
372
+ timestamp: Date.now()
373
+ };
374
+ const i = r.find(
375
+ (o) => typeof o.trigger == "string" ? d.toLowerCase().includes(o.trigger.toLowerCase()) : o.trigger.test(d)
376
+ ) ?? r[r.length - 1];
377
+ if (await z(i.delay ?? 500), i.toolCalls)
378
+ for (const o of i.toolCalls)
379
+ yield {
380
+ type: "tool_call",
381
+ data: {
382
+ function: o.name,
383
+ args: o.arguments
384
+ },
385
+ timestamp: Date.now()
386
+ }, await z(300), yield {
387
+ type: "tool_call",
388
+ data: {
389
+ function: o.name,
390
+ result: o.result
391
+ },
392
+ timestamp: Date.now()
393
+ }, await z(200);
394
+ const p = i.response.split(" ");
395
+ let u = "";
396
+ for (const o of p)
397
+ u += (u ? " " : "") + o, yield {
398
+ type: "message",
399
+ data: { content: u, role: "assistant" },
400
+ timestamp: Date.now()
401
+ }, await z(30 + Math.random() * 40);
402
+ yield {
403
+ type: "done",
404
+ data: { session_id: h },
405
+ timestamp: Date.now()
406
+ };
407
+ }
408
+ };
409
+ }
410
+ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerContent_tzm7g_40", pe = "_topRow_tzm7g_45", _e = "_agentInfo_tzm7g_52", fe = "_agentLogo_tzm7g_58", we = "_agentLogoPlaceholder_tzm7g_66", Ce = "_brainbaseLogo_tzm7g_77", be = "_agentName_tzm7g_82", ye = "_actions_tzm7g_89", Ie = "_actionButton_tzm7g_94", ve = "_welcomeText_tzm7g_122", ke = "_title_tzm7g_126", Ne = "_subtitle_tzm7g_134", Le = "_confirmationOverlay_tzm7g_142", xe = "_confirmationDialog_tzm7g_163", Be = "_confirmationText_tzm7g_184", $e = "_confirmationButtons_tzm7g_192", Me = "_cancelButton_tzm7g_197", Se = "_confirmButton_tzm7g_198", f = {
411
+ header: me,
412
+ headerBackground: ge,
413
+ headerContent: he,
414
+ topRow: pe,
415
+ agentInfo: _e,
416
+ agentLogo: fe,
417
+ agentLogoPlaceholder: we,
418
+ brainbaseLogo: Ce,
419
+ agentName: be,
420
+ actions: ye,
421
+ actionButton: Ie,
422
+ welcomeText: ve,
423
+ title: ke,
424
+ subtitle: Ne,
425
+ confirmationOverlay: Le,
426
+ confirmationDialog: xe,
427
+ confirmationText: Be,
428
+ confirmationButtons: $e,
429
+ cancelButton: Me,
430
+ confirmButton: Se
431
+ }, He = ({ className: n }) => /* @__PURE__ */ l(
432
+ "svg",
433
+ {
434
+ className: n,
435
+ viewBox: "0 0 800 800",
436
+ fill: "none",
437
+ xmlns: "http://www.w3.org/2000/svg",
438
+ children: [
439
+ /* @__PURE__ */ e(
440
+ "path",
441
+ {
442
+ d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
443
+ fill: "currentColor"
444
+ }
445
+ ),
446
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
447
+ /* @__PURE__ */ e(
448
+ "path",
449
+ {
450
+ d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
451
+ fill: "currentColor"
452
+ }
453
+ ),
454
+ /* @__PURE__ */ e(
455
+ "path",
456
+ {
457
+ d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
458
+ fill: "currentColor"
459
+ }
460
+ ),
461
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
462
+ /* @__PURE__ */ e(
463
+ "path",
464
+ {
465
+ d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
466
+ fill: "currentColor"
467
+ }
468
+ ),
469
+ /* @__PURE__ */ e(
470
+ "rect",
471
+ {
472
+ x: "399.919",
473
+ y: "209",
474
+ width: "270",
475
+ height: "270",
476
+ rx: "12",
477
+ transform: "rotate(45 399.919 209)",
478
+ fill: "white"
479
+ }
480
+ )
481
+ ]
482
+ }
483
+ ), Te = ({
484
+ agentName: n = "AI Assistant",
485
+ agentLogoUrl: t,
486
+ welcomeTitle: s,
487
+ welcomeSubtitle: r,
488
+ onClose: h,
489
+ onNewChat: d,
490
+ showNewChatButton: i = !1
491
+ }) => {
492
+ const [p, u] = k(!1), o = s || "Hello there.", C = r || "How can we help?", L = () => {
493
+ i && u(!0);
494
+ }, V = () => {
495
+ u(!1), d == null || d();
496
+ }, N = () => {
497
+ u(!1);
498
+ };
499
+ return /* @__PURE__ */ l("div", { className: f.header, children: [
500
+ /* @__PURE__ */ e("div", { className: f.headerBackground }),
501
+ /* @__PURE__ */ l("div", { className: f.headerContent, children: [
502
+ /* @__PURE__ */ l("div", { className: f.topRow, children: [
503
+ /* @__PURE__ */ l("div", { className: f.agentInfo, children: [
504
+ t ? /* @__PURE__ */ e(
505
+ "img",
506
+ {
507
+ src: t,
508
+ alt: n,
509
+ className: f.agentLogo
510
+ }
511
+ ) : /* @__PURE__ */ e("div", { className: f.agentLogoPlaceholder, children: /* @__PURE__ */ e(He, { className: f.brainbaseLogo }) }),
512
+ /* @__PURE__ */ e("span", { className: f.agentName, children: n })
513
+ ] }),
514
+ /* @__PURE__ */ l("div", { className: f.actions, children: [
515
+ i && d && /* @__PURE__ */ e(
516
+ "button",
517
+ {
518
+ className: f.actionButton,
519
+ onClick: L,
520
+ "aria-label": "Start new chat",
521
+ type: "button",
522
+ children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
523
+ "path",
524
+ {
525
+ d: "M12 5V19M5 12H19",
526
+ stroke: "currentColor",
527
+ strokeWidth: "2",
528
+ strokeLinecap: "round",
529
+ strokeLinejoin: "round"
530
+ }
531
+ ) })
532
+ }
533
+ ),
534
+ h && /* @__PURE__ */ e(
535
+ "button",
536
+ {
537
+ className: f.actionButton,
538
+ onClick: h,
539
+ "aria-label": "Close chat",
540
+ type: "button",
541
+ children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
542
+ "path",
543
+ {
544
+ d: "M6 18L18 6M6 6L18 18",
545
+ stroke: "currentColor",
546
+ strokeWidth: "2",
547
+ strokeLinecap: "round",
548
+ strokeLinejoin: "round"
549
+ }
550
+ ) })
551
+ }
552
+ )
553
+ ] })
554
+ ] }),
555
+ /* @__PURE__ */ l("div", { className: f.welcomeText, children: [
556
+ /* @__PURE__ */ e("h1", { className: f.title, children: o }),
557
+ /* @__PURE__ */ e("p", { className: f.subtitle, children: C })
558
+ ] })
559
+ ] }),
560
+ p && /* @__PURE__ */ e("div", { className: f.confirmationOverlay, children: /* @__PURE__ */ l("div", { className: f.confirmationDialog, children: [
561
+ /* @__PURE__ */ e("p", { className: f.confirmationText, children: "End current chat and start a new conversation?" }),
562
+ /* @__PURE__ */ l("div", { className: f.confirmationButtons, children: [
563
+ /* @__PURE__ */ e(
564
+ "button",
565
+ {
566
+ className: f.cancelButton,
567
+ onClick: N,
568
+ type: "button",
569
+ children: "Cancel"
570
+ }
571
+ ),
572
+ /* @__PURE__ */ e(
573
+ "button",
574
+ {
575
+ className: f.confirmButton,
576
+ onClick: V,
577
+ type: "button",
578
+ children: "End Chat"
579
+ }
580
+ )
581
+ ] })
582
+ ] }) })
583
+ ] });
584
+ }, Ve = "_messageWrapper_c86gj_1", De = "_user_c86gj_19", je = "_assistant_c86gj_24", Pe = "_avatar_c86gj_28", ze = "_avatarPlaceholder_c86gj_43", Ee = "_brainbaseLogo_c86gj_53", Ae = "_messageBubble_c86gj_58", We = "_error_c86gj_76", Ze = "_content_c86gj_81", Oe = "_cursor_c86gj_88", Fe = "_errorIndicator_c86gj_107", I = {
585
+ messageWrapper: Ve,
586
+ user: De,
587
+ assistant: je,
588
+ avatar: Pe,
589
+ avatarPlaceholder: ze,
590
+ brainbaseLogo: Ee,
591
+ messageBubble: Ae,
592
+ error: We,
593
+ content: Ze,
594
+ cursor: Oe,
595
+ errorIndicator: Fe
596
+ }, Re = ({ className: n }) => /* @__PURE__ */ l(
597
+ "svg",
598
+ {
599
+ className: n,
600
+ viewBox: "0 0 800 800",
601
+ fill: "none",
602
+ xmlns: "http://www.w3.org/2000/svg",
603
+ children: [
604
+ /* @__PURE__ */ e(
605
+ "path",
606
+ {
607
+ d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
608
+ fill: "currentColor"
609
+ }
610
+ ),
611
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
612
+ /* @__PURE__ */ e(
613
+ "path",
614
+ {
615
+ d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
616
+ fill: "currentColor"
617
+ }
618
+ ),
619
+ /* @__PURE__ */ e(
620
+ "path",
621
+ {
622
+ d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
623
+ fill: "currentColor"
624
+ }
625
+ ),
626
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
627
+ /* @__PURE__ */ e(
628
+ "path",
629
+ {
630
+ d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
631
+ fill: "currentColor"
632
+ }
633
+ ),
634
+ /* @__PURE__ */ e(
635
+ "rect",
636
+ {
637
+ x: "399.919",
638
+ y: "209",
639
+ width: "270",
640
+ height: "270",
641
+ rx: "12",
642
+ transform: "rotate(45 399.919 209)",
643
+ fill: "white"
644
+ }
645
+ )
646
+ ]
647
+ }
648
+ ), Ue = ({
649
+ message: n,
650
+ agentName: t,
651
+ agentLogoUrl: s
652
+ }) => {
653
+ const r = n.role === "user", h = n.status === "streaming", d = n.status === "error";
654
+ return /* @__PURE__ */ l(
655
+ "div",
656
+ {
657
+ className: `${I.messageWrapper} ${r ? I.user : I.assistant}`,
658
+ children: [
659
+ !r && /* @__PURE__ */ e("div", { className: I.avatar, children: s ? /* @__PURE__ */ e("img", { src: s, alt: t || "AI" }) : /* @__PURE__ */ e("div", { className: I.avatarPlaceholder, children: /* @__PURE__ */ e(Re, { className: I.brainbaseLogo }) }) }),
660
+ /* @__PURE__ */ l(
661
+ "div",
662
+ {
663
+ className: `${I.messageBubble} ${d ? I.error : ""}`,
664
+ role: "article",
665
+ "aria-label": `${r ? "Your message" : `${t || "AI"} says`}`,
666
+ children: [
667
+ /* @__PURE__ */ l("div", { className: I.content, children: [
668
+ n.content,
669
+ h && /* @__PURE__ */ e("span", { className: I.cursor })
670
+ ] }),
671
+ d && /* @__PURE__ */ l("div", { className: I.errorIndicator, children: [
672
+ /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", fill: "none", children: [
673
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2" }),
674
+ /* @__PURE__ */ e("path", { d: "M12 8V12M12 16H12.01", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
675
+ ] }),
676
+ /* @__PURE__ */ e("span", { children: "Failed to send" })
677
+ ] })
678
+ ]
679
+ }
680
+ )
681
+ ]
682
+ }
683
+ );
684
+ }, qe = "_toolCall_1wby1_1", Ke = "_iconWrapper_1wby1_24", Ge = "_spinner_1wby1_33", Je = "_checkIcon_1wby1_48", Ye = "_errorIcon_1wby1_54", Xe = "_content_1wby1_60", Qe = "_label_1wby1_66", et = "_name_1wby1_73", tt = "_pending_1wby1_78", nt = "_completed_1wby1_82", ot = "_error_1wby1_54", v = {
685
+ toolCall: qe,
686
+ iconWrapper: Ke,
687
+ spinner: Ge,
688
+ checkIcon: Je,
689
+ errorIcon: Ye,
690
+ content: Xe,
691
+ label: Qe,
692
+ name: et,
693
+ pending: tt,
694
+ completed: nt,
695
+ error: ot
696
+ }, st = ({ toolCall: n }) => {
697
+ const t = n.status === "pending" || n.status === "executing", s = n.status === "completed", r = n.status === "error", h = (d) => d.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().toLowerCase().replace(/^./, (i) => i.toUpperCase());
698
+ return /* @__PURE__ */ l(
699
+ "div",
700
+ {
701
+ className: `${v.toolCall} ${t ? v.pending : ""} ${s ? v.completed : ""} ${r ? v.error : ""}`,
702
+ children: [
703
+ /* @__PURE__ */ e("div", { className: v.iconWrapper, children: t ? /* @__PURE__ */ e("div", { className: v.spinner }) : s ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: v.checkIcon, children: /* @__PURE__ */ e(
704
+ "path",
705
+ {
706
+ d: "M20 6L9 17L4 12",
707
+ stroke: "currentColor",
708
+ strokeWidth: "2",
709
+ strokeLinecap: "round",
710
+ strokeLinejoin: "round"
711
+ }
712
+ ) }) : /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: v.errorIcon, children: /* @__PURE__ */ e(
713
+ "path",
714
+ {
715
+ d: "M6 18L18 6M6 6L18 18",
716
+ stroke: "currentColor",
717
+ strokeWidth: "2",
718
+ strokeLinecap: "round",
719
+ strokeLinejoin: "round"
720
+ }
721
+ ) }) }),
722
+ /* @__PURE__ */ l("div", { className: v.content, children: [
723
+ /* @__PURE__ */ e("span", { className: v.label, children: t ? "Running" : s ? "Completed" : "Failed" }),
724
+ /* @__PURE__ */ e("span", { className: v.name, children: h(n.name) })
725
+ ] })
726
+ ]
727
+ }
728
+ );
729
+ }, rt = "_wrapper_10rss_2", at = "_avatar_10rss_22", it = "_avatarPlaceholder_10rss_37", ct = "_brainbaseLogo_10rss_47", lt = "_bubble_10rss_52", dt = "_dot_10rss_63", M = {
730
+ wrapper: rt,
731
+ avatar: at,
732
+ avatarPlaceholder: it,
733
+ brainbaseLogo: ct,
734
+ bubble: lt,
735
+ dot: dt
736
+ }, ut = ({ className: n }) => /* @__PURE__ */ l(
737
+ "svg",
738
+ {
739
+ className: n,
740
+ viewBox: "0 0 800 800",
741
+ fill: "none",
742
+ xmlns: "http://www.w3.org/2000/svg",
743
+ children: [
744
+ /* @__PURE__ */ e(
745
+ "path",
746
+ {
747
+ d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
748
+ fill: "currentColor"
749
+ }
750
+ ),
751
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
752
+ /* @__PURE__ */ e(
753
+ "path",
754
+ {
755
+ d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
756
+ fill: "currentColor"
757
+ }
758
+ ),
759
+ /* @__PURE__ */ e(
760
+ "path",
761
+ {
762
+ d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
763
+ fill: "currentColor"
764
+ }
765
+ ),
766
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
767
+ /* @__PURE__ */ e(
768
+ "path",
769
+ {
770
+ d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
771
+ fill: "currentColor"
772
+ }
773
+ ),
774
+ /* @__PURE__ */ e(
775
+ "rect",
776
+ {
777
+ x: "399.919",
778
+ y: "209",
779
+ width: "270",
780
+ height: "270",
781
+ rx: "12",
782
+ transform: "rotate(45 399.919 209)",
783
+ fill: "white"
784
+ }
785
+ )
786
+ ]
787
+ }
788
+ ), mt = ({
789
+ agentName: n = "AI",
790
+ agentLogoUrl: t
791
+ }) => /* @__PURE__ */ l("div", { className: M.wrapper, role: "status", "aria-label": `${n} is typing`, children: [
792
+ /* @__PURE__ */ e("div", { className: M.avatar, children: t ? /* @__PURE__ */ e("img", { src: t, alt: n }) : /* @__PURE__ */ e("div", { className: M.avatarPlaceholder, children: /* @__PURE__ */ e(ut, { className: M.brainbaseLogo }) }) }),
793
+ /* @__PURE__ */ l("div", { className: M.bubble, children: [
794
+ /* @__PURE__ */ e("span", { className: M.dot }),
795
+ /* @__PURE__ */ e("span", { className: M.dot }),
796
+ /* @__PURE__ */ e("span", { className: M.dot })
797
+ ] })
798
+ ] }), gt = "_messageList_241kk_1", ht = "_emptyState_241kk_29", pt = "_emptyIcon_241kk_40", _t = "_emptyText_241kk_52", F = {
799
+ messageList: gt,
800
+ emptyState: ht,
801
+ emptyIcon: pt,
802
+ emptyText: _t
803
+ }, ft = ({
804
+ messages: n,
805
+ toolCalls: t,
806
+ isLoading: s,
807
+ agentName: r,
808
+ agentLogoUrl: h
809
+ }) => {
810
+ var u;
811
+ const d = A(null), i = A(null);
812
+ W(() => {
813
+ var o;
814
+ (o = i.current) == null || o.scrollIntoView({ behavior: "smooth" });
815
+ }, [n, t, s]);
816
+ const p = t.filter(
817
+ (o) => o.status === "pending" || o.status === "executing"
818
+ );
819
+ return /* @__PURE__ */ l("div", { className: F.messageList, ref: d, role: "log", "aria-live": "polite", children: [
820
+ n.length === 0 && !s && /* @__PURE__ */ l("div", { className: F.emptyState, children: [
821
+ /* @__PURE__ */ e("div", { className: F.emptyIcon, children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
822
+ "path",
823
+ {
824
+ d: "M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",
825
+ stroke: "currentColor",
826
+ strokeWidth: "1.5",
827
+ strokeLinecap: "round",
828
+ strokeLinejoin: "round"
829
+ }
830
+ ) }) }),
831
+ /* @__PURE__ */ e("p", { className: F.emptyText, children: "Start a conversation" })
832
+ ] }),
833
+ n.map((o) => /* @__PURE__ */ e(
834
+ Ue,
835
+ {
836
+ message: o,
837
+ agentName: r,
838
+ agentLogoUrl: h
839
+ },
840
+ o.id
841
+ )),
842
+ p.map((o) => /* @__PURE__ */ e(st, { toolCall: o }, o.id)),
843
+ s && ((u = n[n.length - 1]) == null ? void 0 : u.role) === "user" && /* @__PURE__ */ e(mt, { agentName: r, agentLogoUrl: h }),
844
+ /* @__PURE__ */ e("div", { ref: i })
845
+ ] });
846
+ }, wt = "_inputWrapper_5lgg7_1", Ct = "_inputContainer_5lgg7_7", bt = "_textarea_5lgg7_23", yt = "_sendButton_5lgg7_50", It = "_hint_5lgg7_89", E = {
847
+ inputWrapper: wt,
848
+ inputContainer: Ct,
849
+ textarea: bt,
850
+ sendButton: yt,
851
+ hint: It
852
+ }, vt = ({
853
+ onSend: n,
854
+ disabled: t = !1,
855
+ placeholder: s = "Send a message..."
856
+ }) => {
857
+ const [r, h] = k(""), d = A(null), i = x(() => {
858
+ const o = d.current;
859
+ o && (o.style.height = "auto", o.style.height = `${Math.min(o.scrollHeight, 150)}px`);
860
+ }, []);
861
+ W(() => {
862
+ i();
863
+ }, [r, i]);
864
+ const p = x(
865
+ (o) => {
866
+ o == null || o.preventDefault();
867
+ const C = r.trim();
868
+ C && !t && (n(C), h(""), d.current && (d.current.style.height = "auto"));
869
+ },
870
+ [r, t, n]
871
+ ), u = x(
872
+ (o) => {
873
+ o.key === "Enter" && !o.shiftKey && (o.preventDefault(), p());
874
+ },
875
+ [p]
876
+ );
877
+ return /* @__PURE__ */ l("form", { className: E.inputWrapper, onSubmit: p, children: [
878
+ /* @__PURE__ */ l("div", { className: E.inputContainer, children: [
879
+ /* @__PURE__ */ e(
880
+ "textarea",
881
+ {
882
+ ref: d,
883
+ className: E.textarea,
884
+ value: r,
885
+ onChange: (o) => h(o.target.value),
886
+ onKeyDown: u,
887
+ placeholder: s,
888
+ disabled: t,
889
+ rows: 1,
890
+ "aria-label": "Message input"
891
+ }
892
+ ),
893
+ /* @__PURE__ */ e(
894
+ "button",
895
+ {
896
+ type: "submit",
897
+ className: E.sendButton,
898
+ disabled: t || !r.trim(),
899
+ "aria-label": "Send message",
900
+ children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
901
+ "path",
902
+ {
903
+ d: "M22 2L11 13M22 2L15 22L11 13M22 2L2 9L11 13",
904
+ stroke: "currentColor",
905
+ strokeWidth: "2",
906
+ strokeLinecap: "round",
907
+ strokeLinejoin: "round"
908
+ }
909
+ ) })
910
+ }
911
+ )
912
+ ] }),
913
+ /* @__PURE__ */ l("div", { className: E.hint, children: [
914
+ "Press ",
915
+ /* @__PURE__ */ e("kbd", { children: "Enter" }),
916
+ " to send, ",
917
+ /* @__PURE__ */ e("kbd", { children: "Shift + Enter" }),
918
+ " for new line"
919
+ ] })
920
+ ] });
921
+ }, kt = "_poweredBy_9jh5q_1", Nt = "_logo_9jh5q_20", Lt = "_poweredText_9jh5q_24", xt = "_text_9jh5q_36", R = {
922
+ poweredBy: kt,
923
+ logo: Nt,
924
+ poweredText: Lt,
925
+ text: xt
926
+ }, Bt = ({ className: n }) => /* @__PURE__ */ l(
927
+ "svg",
928
+ {
929
+ className: n,
930
+ viewBox: "0 0 800 800",
931
+ fill: "none",
932
+ xmlns: "http://www.w3.org/2000/svg",
933
+ children: [
934
+ /* @__PURE__ */ e(
935
+ "path",
936
+ {
937
+ d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
938
+ fill: "currentColor"
939
+ }
940
+ ),
941
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
942
+ /* @__PURE__ */ e(
943
+ "path",
944
+ {
945
+ d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
946
+ fill: "currentColor"
947
+ }
948
+ ),
949
+ /* @__PURE__ */ e(
950
+ "path",
951
+ {
952
+ d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
953
+ fill: "currentColor"
954
+ }
955
+ ),
956
+ /* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
957
+ /* @__PURE__ */ e(
958
+ "path",
959
+ {
960
+ d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
961
+ fill: "currentColor"
962
+ }
963
+ ),
964
+ /* @__PURE__ */ e(
965
+ "rect",
966
+ {
967
+ x: "399.919",
968
+ y: "209",
969
+ width: "270",
970
+ height: "270",
971
+ rx: "12",
972
+ transform: "rotate(45 399.919 209)",
973
+ fill: "var(--bb-surface-bg, #ffffff)"
974
+ }
975
+ )
976
+ ]
977
+ }
978
+ ), $t = () => /* @__PURE__ */ l(
979
+ "a",
980
+ {
981
+ href: "https://brainbaselabs.com/",
982
+ target: "_blank",
983
+ rel: "noopener noreferrer",
984
+ className: R.poweredBy,
985
+ "aria-label": "Powered by Brainbase Labs",
986
+ children: [
987
+ /* @__PURE__ */ e("span", { className: R.poweredText, children: "Powered by" }),
988
+ /* @__PURE__ */ e(Bt, { className: R.logo }),
989
+ /* @__PURE__ */ e("span", { className: R.text, children: "Brainbase Labs" })
990
+ ]
991
+ }
992
+ ), Mt = "_container_14ilx_1", St = "_body_14ilx_25", te = {
993
+ container: Mt,
994
+ body: St
995
+ }, Ht = ({
996
+ config: n,
997
+ messages: t,
998
+ toolCalls: s,
999
+ isLoading: r,
1000
+ onSendMessage: h,
1001
+ onClose: d,
1002
+ onNewChat: i
1003
+ }) => {
1004
+ const p = t.length > 0;
1005
+ return /* @__PURE__ */ l("div", { className: te.container, role: "dialog", "aria-label": "Chat window", children: [
1006
+ /* @__PURE__ */ e(
1007
+ Te,
1008
+ {
1009
+ agentName: n.agentName,
1010
+ agentLogoUrl: n.agentLogoUrl,
1011
+ welcomeTitle: "Hello there.",
1012
+ welcomeSubtitle: "How can we help?",
1013
+ onClose: d,
1014
+ onNewChat: i,
1015
+ showNewChatButton: p
1016
+ }
1017
+ ),
1018
+ /* @__PURE__ */ l("div", { className: te.body, children: [
1019
+ /* @__PURE__ */ e(
1020
+ ft,
1021
+ {
1022
+ messages: t,
1023
+ toolCalls: s,
1024
+ isLoading: r,
1025
+ agentName: n.agentName,
1026
+ agentLogoUrl: n.agentLogoUrl
1027
+ }
1028
+ ),
1029
+ /* @__PURE__ */ e(
1030
+ vt,
1031
+ {
1032
+ onSend: h,
1033
+ disabled: r,
1034
+ placeholder: "Ask a question..."
1035
+ }
1036
+ )
1037
+ ] }),
1038
+ /* @__PURE__ */ e($t, {})
1039
+ ] });
1040
+ }, Tt = "_toggleButton_11dqz_1", Vt = "_icon_11dqz_31", Dt = "_agentLogo_11dqz_36", jt = "_unreadBadge_11dqz_43", U = {
1041
+ toggleButton: Tt,
1042
+ icon: Vt,
1043
+ agentLogo: Dt,
1044
+ unreadBadge: jt
1045
+ }, Pt = ({
1046
+ onClick: n,
1047
+ agentLogoUrl: t,
1048
+ unreadCount: s = 0
1049
+ }) => /* @__PURE__ */ l(
1050
+ "button",
1051
+ {
1052
+ className: U.toggleButton,
1053
+ onClick: n,
1054
+ "aria-label": "Open chat",
1055
+ type: "button",
1056
+ children: [
1057
+ t ? /* @__PURE__ */ e("img", { src: t, alt: "", className: U.agentLogo }) : /* @__PURE__ */ e(
1058
+ "svg",
1059
+ {
1060
+ className: U.icon,
1061
+ viewBox: "0 0 24 24",
1062
+ fill: "none",
1063
+ xmlns: "http://www.w3.org/2000/svg",
1064
+ children: /* @__PURE__ */ e(
1065
+ "path",
1066
+ {
1067
+ d: "M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",
1068
+ stroke: "currentColor",
1069
+ strokeWidth: "2",
1070
+ strokeLinecap: "round",
1071
+ strokeLinejoin: "round"
1072
+ }
1073
+ )
1074
+ }
1075
+ ),
1076
+ s > 0 && /* @__PURE__ */ e("span", { className: U.unreadBadge, children: s > 9 ? "9+" : s })
1077
+ ]
1078
+ }
1079
+ ), zt = "_widget_1ehud_1", Et = "_inline_1ehud_25", ne = {
1080
+ widget: zt,
1081
+ "bottom-right": "_bottom-right_1ehud_10",
1082
+ "bottom-left": "_bottom-left_1ehud_17",
1083
+ inline: Et
1084
+ }, At = "https://whatsapp-based-server.onrender.com", Ot = ({
1085
+ embedId: n,
1086
+ apiBaseUrl: t = At,
1087
+ mockMode: s = !1,
1088
+ mockResponses: r,
1089
+ position: h = "bottom-right",
1090
+ defaultOpen: d = !1,
1091
+ primaryColor: i,
1092
+ agentName: p,
1093
+ welcomeMessage: u,
1094
+ className: o,
1095
+ onSessionStart: C,
1096
+ onSessionEnd: L,
1097
+ onMessage: V,
1098
+ onError: N
1099
+ }) => {
1100
+ const [q, D] = k(d), [m, S] = k(null), [B, Z] = k(!0), [K, H] = k(null), T = J(() => s ? ue(
1101
+ { primaryColor: i, agentName: p, welcomeMessage: u },
1102
+ r
1103
+ ) : ce(t), [s, i, p, u, r, t]);
1104
+ W(() => {
1105
+ let b = !0;
1106
+ async function g() {
1107
+ try {
1108
+ const c = await T.getDeploymentConfig(n);
1109
+ b && (S({
1110
+ ...c,
1111
+ // Allow prop overrides
1112
+ primaryColor: i ?? c.primaryColor,
1113
+ agentName: p ?? c.agentName,
1114
+ welcomeMessage: u ?? c.welcomeMessage
1115
+ }), H(null));
1116
+ } catch (c) {
1117
+ const a = c instanceof Error ? c : new Error("Failed to load config");
1118
+ b && (H(a), s && S({
1119
+ embedId: n,
1120
+ deploymentId: "mock-deployment",
1121
+ workerId: "mock-worker",
1122
+ flowId: "mock-flow",
1123
+ primaryColor: i ?? "#1a1a2e",
1124
+ agentName: p ?? "AI Assistant"
1125
+ // Note: welcomeMessage is handled by the engine
1126
+ })), N == null || N(a);
1127
+ } finally {
1128
+ b && Z(!1);
1129
+ }
1130
+ }
1131
+ return g(), () => {
1132
+ b = !1;
1133
+ };
1134
+ }, [n, s, T, i, p, u, N]);
1135
+ const O = J(() => m || {
1136
+ embedId: n,
1137
+ deploymentId: "",
1138
+ workerId: "",
1139
+ flowId: "",
1140
+ primaryColor: i,
1141
+ agentName: p,
1142
+ welcomeMessage: u
1143
+ }, [m, n, i, p, u]), $ = ae({
1144
+ config: O,
1145
+ apiClient: T,
1146
+ mockMode: s,
1147
+ onSessionStart: C,
1148
+ onSessionEnd: L,
1149
+ onMessage: V,
1150
+ onError: N
1151
+ }), G = J(
1152
+ () => ({
1153
+ "--bb-primary-color": (m == null ? void 0 : m.primaryColor) ?? i ?? "#1a1a2e"
1154
+ }),
1155
+ [m == null ? void 0 : m.primaryColor, i]
1156
+ ), _ = () => {
1157
+ $.endSession(), $.startNewSession();
1158
+ };
1159
+ if (B || K && !s)
1160
+ return null;
1161
+ const y = h === "inline";
1162
+ return /* @__PURE__ */ e(
1163
+ "div",
1164
+ {
1165
+ className: `${ne.widget} ${ne[h]} ${o ?? ""}`,
1166
+ style: G,
1167
+ children: q || y ? /* @__PURE__ */ e(
1168
+ Ht,
1169
+ {
1170
+ config: O,
1171
+ messages: $.messages,
1172
+ toolCalls: $.toolCalls,
1173
+ isLoading: $.isLoading,
1174
+ onSendMessage: $.sendMessage,
1175
+ onClose: y ? void 0 : () => D(!1),
1176
+ onNewChat: _
1177
+ }
1178
+ ) : /* @__PURE__ */ e(
1179
+ Pt,
1180
+ {
1181
+ onClick: () => D(!0),
1182
+ agentName: m == null ? void 0 : m.agentName,
1183
+ agentLogoUrl: m == null ? void 0 : m.agentLogoUrl
1184
+ }
1185
+ )
1186
+ }
1187
+ );
1188
+ };
1189
+ function Ft() {
1190
+ if (typeof crypto < "u" && crypto.randomUUID)
1191
+ return `bb-${crypto.randomUUID()}`;
1192
+ const n = Date.now().toString(36), t = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
1193
+ return `bb-${n}-${t}${s}`;
1194
+ }
1195
+ export {
1196
+ Ht as ChatContainer,
1197
+ Te as ChatHeader,
1198
+ Pt as ChatToggleButton,
1199
+ Ot as ChatWidget,
1200
+ Ue as Message,
1201
+ vt as MessageInput,
1202
+ ft as MessageList,
1203
+ st as ToolCallDisplay,
1204
+ mt as TypingIndicator,
1205
+ ee as clearSession,
1206
+ ce as createAPIClient,
1207
+ ue as createMockAPIClient,
1208
+ Ft as generateSessionId,
1209
+ re as getStoredSession,
1210
+ Q as storeSession,
1211
+ ae as useChat
1212
+ };