@useago/sdk 1.4.2 → 1.4.4
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/README.md +4 -1
- package/dist/AgoClient-CLmtYTJx.cjs +8 -0
- package/dist/{AgoClient-BdtuHX7k.js → AgoClient-Ozz2b1dQ.js} +301 -161
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +151 -6
- package/dist/angular.d.ts +151 -6
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-B8zfTL78.cjs → createConversationSession-CUkNp6mZ.cjs} +1 -1
- package/dist/{createConversationSession-CWpf4u6I.js → createConversationSession-QIBN0gLx.js} +1 -1
- package/dist/{createFormCollector-BB_l0Sia.cjs → createFormCollector-DHT1ObOb.cjs} +1 -1
- package/dist/{createFormCollector-B4n0_diV.js → createFormCollector-F3YJfsbg.js} +1 -1
- package/dist/createMockClient-BSr-UV8R.cjs +1 -0
- package/dist/{createMockClient-d-arlmCq.js → createMockClient-bAZ9KBHC.js} +18 -15
- package/dist/devtools.d.cts +149 -4
- package/dist/devtools.d.ts +149 -4
- package/dist/helpers.d.cts +6 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +181 -5
- package/dist/index.d.ts +181 -5
- package/dist/index.js +4 -4
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +169 -10
- package/dist/react.d.ts +169 -10
- package/dist/react.js +441 -428
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +149 -4
- package/dist/testing.d.ts +149 -4
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +162 -5
- package/dist/vue.d.ts +162 -5
- package/dist/vue.js +22 -21
- package/dist/widget.cjs +3 -3
- package/dist/widget.d.cts +149 -4
- package/dist/widget.d.ts +149 -4
- package/dist/widget.js +120 -120
- package/llms-full.txt +1910 -0
- package/package.json +5 -3
- package/dist/AgoClient-CRAnT4qE.cjs +0 -8
- package/dist/createMockClient-ucPENDzz.cjs +0 -1
package/dist/widget.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { r as Kt, t as Xt } from "./createFormCollector-
|
|
3
|
-
import { t as Qt } from "./createConversationSession-
|
|
1
|
+
import { a as Wt, i as Ut, m as Gt, o as Vt, s as jt, t as qt } from "./AgoClient-Ozz2b1dQ.js";
|
|
2
|
+
import { r as Kt, t as Xt } from "./createFormCollector-F3YJfsbg.js";
|
|
3
|
+
import { t as Qt } from "./createConversationSession-QIBN0gLx.js";
|
|
4
4
|
var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', Se = `var(--ago-font, ${Yt})`, dt = {
|
|
5
5
|
font: "--ago-font",
|
|
6
6
|
radius: "--ago-radius",
|
|
@@ -16,7 +16,7 @@ var Yt = '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto
|
|
|
16
16
|
border: "--ago-border-color",
|
|
17
17
|
accent: "--ago-accent-color",
|
|
18
18
|
agentBubbleBg: "--ago-agent-bubble-background"
|
|
19
|
-
},
|
|
19
|
+
}, Ie = "var(--ago-brand-color, #03182f)", Ae = "var(--ago-brand-text-color, #fff)", Zt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", ct = "var(--ago-header-text-color, #e8f0fe)", ee = "var(--ago-panel-background, #fff)", gt = "var(--ago-messages-background, #fbfbfb)", J = "var(--ago-text-color, #30373e)", ht = "var(--ago-muted-text-color, #6b6d6f)", L = "var(--ago-border-color, #dee3e8)", Me = "var(--ago-accent-color, #1b5fc4)", pt = "var(--ago-agent-bubble-background, #f1f3f5)", Jt = "var(--ago-radius, 16px)", Oe = "var(--ago-message-radius, 16px)", en = "var(--ago-message-radius, 20px)";
|
|
20
20
|
function tn(n, o) {
|
|
21
21
|
if (o)
|
|
22
22
|
for (const i of Object.keys(dt)) {
|
|
@@ -86,7 +86,7 @@ function on(n) {
|
|
|
86
86
|
padding: "0",
|
|
87
87
|
border: "none",
|
|
88
88
|
borderRadius: "50%",
|
|
89
|
-
backgroundColor:
|
|
89
|
+
backgroundColor: Ie,
|
|
90
90
|
color: Ae,
|
|
91
91
|
display: "flex",
|
|
92
92
|
alignItems: "center",
|
|
@@ -98,20 +98,20 @@ function on(n) {
|
|
|
98
98
|
const s = a.value.trim() !== "" || o.length > 0, c = f || !s;
|
|
99
99
|
p.disabled = c, p.innerHTML = f ? x : m, p.style.opacity = c && !f ? "0.5" : "1", p.style.cursor = c ? "default" : "pointer";
|
|
100
100
|
};
|
|
101
|
-
let R = null,
|
|
102
|
-
n.allowFiles && (R = document.createElement("input"), R.type = "file", R.multiple = !0, v(R, { display: "none" }),
|
|
101
|
+
let R = null, k = null;
|
|
102
|
+
n.allowFiles && (R = document.createElement("input"), R.type = "file", R.multiple = !0, v(R, { display: "none" }), k = document.createElement("button"), k.type = "button", k.setAttribute("aria-label", "Attach file"), k.textContent = "📎", v(k, {
|
|
103
103
|
padding: "10px 12px",
|
|
104
104
|
border: `1px solid ${L}`,
|
|
105
105
|
borderRadius: "12px",
|
|
106
106
|
backgroundColor: ee,
|
|
107
107
|
cursor: "pointer",
|
|
108
108
|
fontSize: "14px"
|
|
109
|
-
}),
|
|
109
|
+
}), k.addEventListener("click", () => R?.click()), R.addEventListener("change", () => {
|
|
110
110
|
o = [...o, ...Array.from(R?.files ?? [])], Y();
|
|
111
111
|
}));
|
|
112
112
|
function Y() {
|
|
113
113
|
r.replaceChildren(), o.forEach((s, c) => {
|
|
114
|
-
const
|
|
114
|
+
const w = h({
|
|
115
115
|
display: "flex",
|
|
116
116
|
alignItems: "center",
|
|
117
117
|
gap: "4px",
|
|
@@ -120,18 +120,18 @@ function on(n) {
|
|
|
120
120
|
border: `1px solid ${L}`,
|
|
121
121
|
borderRadius: "8px",
|
|
122
122
|
fontSize: "12px"
|
|
123
|
-
}),
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
123
|
+
}), $ = document.createElement("span");
|
|
124
|
+
$.textContent = s.name;
|
|
125
|
+
const I = document.createElement("button");
|
|
126
|
+
I.type = "button", I.setAttribute("aria-label", `Remove ${s.name}`), I.textContent = "×", v(I, {
|
|
127
127
|
border: "none",
|
|
128
128
|
background: "transparent",
|
|
129
129
|
cursor: "pointer",
|
|
130
130
|
fontSize: "14px",
|
|
131
131
|
lineHeight: "1"
|
|
132
|
-
}),
|
|
132
|
+
}), I.addEventListener("click", () => {
|
|
133
133
|
o = o.filter((V, j) => j !== c), Y();
|
|
134
|
-
}),
|
|
134
|
+
}), w.append($, I), r.appendChild(w);
|
|
135
135
|
}), A();
|
|
136
136
|
}
|
|
137
137
|
const D = () => {
|
|
@@ -148,7 +148,7 @@ function on(n) {
|
|
|
148
148
|
s.preventDefault(), g();
|
|
149
149
|
}), a.addEventListener("keydown", (s) => {
|
|
150
150
|
s.key === "Enter" && !s.shiftKey && (s.preventDefault(), g());
|
|
151
|
-
}),
|
|
151
|
+
}), k && b.appendChild(k), b.append(a, p), R && i.appendChild(R), i.append(r, b), A(), {
|
|
152
152
|
inputRow: i,
|
|
153
153
|
getValueAndClear: D,
|
|
154
154
|
setDisabled: (s) => {
|
|
@@ -367,8 +367,8 @@ function cn(n, o) {
|
|
|
367
367
|
maxWidth: "85%"
|
|
368
368
|
});
|
|
369
369
|
g.className = "ago-message__sources", n.sources.forEach((s, c) => {
|
|
370
|
-
const
|
|
371
|
-
s.url &&
|
|
370
|
+
const w = s.url ? document.createElement("a") : document.createElement("div");
|
|
371
|
+
s.url && w instanceof HTMLAnchorElement && (w.href = s.url, w.target = "_blank", w.rel = "noopener noreferrer"), v(w, {
|
|
372
372
|
display: "flex",
|
|
373
373
|
alignItems: "center",
|
|
374
374
|
gap: "8px",
|
|
@@ -381,7 +381,7 @@ function cn(n, o) {
|
|
|
381
381
|
fontSize: "12px",
|
|
382
382
|
overflow: "hidden"
|
|
383
383
|
});
|
|
384
|
-
const
|
|
384
|
+
const $ = h({
|
|
385
385
|
flexShrink: "0",
|
|
386
386
|
width: "18px",
|
|
387
387
|
height: "18px",
|
|
@@ -395,13 +395,13 @@ function cn(n, o) {
|
|
|
395
395
|
justifyContent: "center",
|
|
396
396
|
backgroundColor: "#f0f4ff"
|
|
397
397
|
});
|
|
398
|
-
|
|
399
|
-
const
|
|
398
|
+
$.textContent = String(c + 1);
|
|
399
|
+
const I = h({
|
|
400
400
|
overflow: "hidden",
|
|
401
401
|
textOverflow: "ellipsis",
|
|
402
402
|
whiteSpace: "nowrap"
|
|
403
403
|
});
|
|
404
|
-
|
|
404
|
+
I.textContent = s.title, I.title = s.title, w.append($, I), g.appendChild(w);
|
|
405
405
|
}), R.appendChild(g);
|
|
406
406
|
}
|
|
407
407
|
if (n.attachments && n.attachments.length > 0) {
|
|
@@ -416,7 +416,7 @@ function cn(n, o) {
|
|
|
416
416
|
g.className = "ago-message__attachments";
|
|
417
417
|
for (const s of n.attachments) {
|
|
418
418
|
const c = jt(s.url);
|
|
419
|
-
if (
|
|
419
|
+
if (Wt(s) && c) {
|
|
420
420
|
const B = document.createElement("a");
|
|
421
421
|
B.href = c, B.target = "_blank", B.rel = "noopener noreferrer", v(B, {
|
|
422
422
|
display: "inline-block",
|
|
@@ -433,8 +433,8 @@ function cn(n, o) {
|
|
|
433
433
|
}), B.appendChild(q), g.appendChild(B);
|
|
434
434
|
continue;
|
|
435
435
|
}
|
|
436
|
-
const
|
|
437
|
-
c &&
|
|
436
|
+
const w = c ? document.createElement("a") : document.createElement("div");
|
|
437
|
+
c && w instanceof HTMLAnchorElement && (w.href = c, w.target = "_blank", w.rel = "noopener noreferrer"), v(w, {
|
|
438
438
|
display: "inline-flex",
|
|
439
439
|
alignItems: "center",
|
|
440
440
|
gap: "8px",
|
|
@@ -447,13 +447,13 @@ function cn(n, o) {
|
|
|
447
447
|
textDecoration: "none",
|
|
448
448
|
maxWidth: "220px"
|
|
449
449
|
});
|
|
450
|
-
const
|
|
451
|
-
|
|
450
|
+
const $ = document.createElement("span");
|
|
451
|
+
$.textContent = "📄", $.setAttribute("aria-hidden", "true"), v($, {
|
|
452
452
|
fontSize: "16px",
|
|
453
453
|
lineHeight: "1",
|
|
454
454
|
flexShrink: "0"
|
|
455
455
|
});
|
|
456
|
-
const
|
|
456
|
+
const I = h({
|
|
457
457
|
display: "flex",
|
|
458
458
|
flexDirection: "column",
|
|
459
459
|
minWidth: "0"
|
|
@@ -463,24 +463,24 @@ function cn(n, o) {
|
|
|
463
463
|
whiteSpace: "nowrap",
|
|
464
464
|
maxWidth: "160px"
|
|
465
465
|
});
|
|
466
|
-
V.textContent = s.name, V.title = s.name,
|
|
466
|
+
V.textContent = s.name, V.title = s.name, I.appendChild(V);
|
|
467
467
|
const j = Vt(s.fileSize);
|
|
468
468
|
if (j) {
|
|
469
469
|
const B = h({
|
|
470
470
|
fontSize: "11px",
|
|
471
471
|
color: ht
|
|
472
472
|
});
|
|
473
|
-
B.textContent = j,
|
|
473
|
+
B.textContent = j, I.appendChild(B);
|
|
474
474
|
}
|
|
475
|
-
|
|
475
|
+
w.append($, I), g.appendChild(w);
|
|
476
476
|
}
|
|
477
477
|
R.appendChild(g);
|
|
478
478
|
}
|
|
479
|
-
const
|
|
480
|
-
maxWidth:
|
|
481
|
-
padding:
|
|
482
|
-
borderRadius: A ? en :
|
|
483
|
-
backgroundColor: f ?
|
|
479
|
+
const k = f || C || A, Y = !!n.content || n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT", D = h({
|
|
480
|
+
maxWidth: k ? A || f ? p ? "88%" : "75%" : p ? "92%" : "85%" : "100%",
|
|
481
|
+
padding: k ? "10px 14px" : "2px 8px",
|
|
482
|
+
borderRadius: A ? en : k ? Oe : "0",
|
|
483
|
+
backgroundColor: f ? Ie : k ? pt : "transparent",
|
|
484
484
|
color: f ? Ae : J,
|
|
485
485
|
overflowWrap: "break-word",
|
|
486
486
|
textWrap: "pretty",
|
|
@@ -495,7 +495,7 @@ function cn(n, o) {
|
|
|
495
495
|
bottom: "-2px",
|
|
496
496
|
width: "20px",
|
|
497
497
|
height: "20px",
|
|
498
|
-
background: f ?
|
|
498
|
+
background: f ? Ie : pt
|
|
499
499
|
});
|
|
500
500
|
g.className = "ago-message__tail";
|
|
501
501
|
const s = h({
|
|
@@ -508,7 +508,7 @@ function cn(n, o) {
|
|
|
508
508
|
});
|
|
509
509
|
s.className = "ago-message__tail-mask", f ? (g.style.right = "-8px", g.style.borderBottomLeftRadius = "16px 14px", s.style.right = "-10px", s.style.borderBottomLeftRadius = "10px") : (g.style.left = "-7px", g.style.borderBottomRightRadius = "16px 14px", s.style.left = "-10px", s.style.borderBottomRightRadius = "10px"), D.append(g, s);
|
|
510
510
|
}
|
|
511
|
-
if (n.content ? D.appendChild(ze(n.content)) : n.status === "IN_PROGRESS" && D.appendChild(fn()), Y && R.appendChild(D), i && n.followUpReplies && n.followUpReplies.length > 0) {
|
|
511
|
+
if (n.content ? D.appendChild(ze(n.content)) : (n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT") && D.appendChild(fn()), Y && R.appendChild(D), i && n.followUpReplies && n.followUpReplies.length > 0) {
|
|
512
512
|
const g = h({
|
|
513
513
|
display: "flex",
|
|
514
514
|
flexWrap: "wrap",
|
|
@@ -603,17 +603,17 @@ function hn(n) {
|
|
|
603
603
|
return o;
|
|
604
604
|
}
|
|
605
605
|
function wn(n, o) {
|
|
606
|
-
const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: A = !1, agentBubble: R = !1, bubbleStyle:
|
|
606
|
+
const { title: i = "Chat", welcomeMessage: r = "Hello! How can I help you today?", placeholder: b = "Type a message...", allowFiles: a = !1, height: C = 500, placement: m = "inline", width: x = 400, defaultOpen: p = !1, logoUrl: f, showAgentName: A = !1, agentBubble: R = !1, bubbleStyle: k = "default", showHeader: Y = !0, theme: D, loadThreads: g = !1, forms: s, formSubmittedMessage: c = mt, onFollowUpClick: w, onMessageSent: $, onMessageReceived: I, onFormSubmitted: V, onFormError: j, onOpen: B, onClose: q } = o, ne = typeof r == "string" ? {
|
|
607
607
|
message: r,
|
|
608
608
|
mode: "static"
|
|
609
609
|
} : r, Fe = ne.message, He = ne.mode ?? "static", Ct = "speed" in ne && ne.speed || 45, Pe = "followUpReplies" in ne && ne.followUpReplies || void 0;
|
|
610
610
|
if (!o.client && !o.config?.baseUrl) throw new Gt("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
|
|
611
|
-
const E = o.client ?? new qt(o.config),
|
|
611
|
+
const E = o.client ?? new qt(o.config), We = hn(n), z = m === "left" || m === "right", Et = z && (o.launcher ?? !0);
|
|
612
612
|
let oe = z ? p : !0;
|
|
613
|
-
const St = o.mobile?.breakpoint ?? 768,
|
|
613
|
+
const St = o.mobile?.breakpoint ?? 768, ke = o.mobile?.trigger ?? "tap", Ue = typeof window < "u" && !!window.matchMedia, M = Ue ? window.matchMedia(`(max-width: ${St}px)`) : void 0, Rt = Ue ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, re = !z && !!M, _e = o.persistConversation, me = _e ? Qt(_e === !0 ? {} : _e) : void 0;
|
|
614
614
|
let P = o.conversationId ?? me?.getLastActiveThread() ?? void 0, u = [], Z = !1, le = null, K;
|
|
615
615
|
const Ge = [];
|
|
616
|
-
function
|
|
616
|
+
function It(e) {
|
|
617
617
|
if (typeof c == "function") {
|
|
618
618
|
const l = c(e);
|
|
619
619
|
if (typeof l == "string" && l) return l;
|
|
@@ -670,24 +670,24 @@ function wn(n, o) {
|
|
|
670
670
|
}), t.addEventListener("click", () => Be()), F.appendChild(t);
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
|
-
const
|
|
673
|
+
const _ = h({
|
|
674
674
|
flex: "1",
|
|
675
675
|
overflow: "auto",
|
|
676
676
|
padding: "16px",
|
|
677
677
|
backgroundColor: gt
|
|
678
678
|
});
|
|
679
|
-
|
|
680
|
-
const { inputRow:
|
|
679
|
+
_.className = "ago-chat-widget__messages", _.setAttribute("role", "log"), _.setAttribute("aria-live", "polite"), _.setAttribute("aria-relevant", "additions text"), _.setAttribute("aria-atomic", "false");
|
|
680
|
+
const { inputRow: Ne, setDisabled: At, focus: he } = on({
|
|
681
681
|
placeholder: b,
|
|
682
682
|
allowFiles: a,
|
|
683
683
|
onSend: (e, t) => {
|
|
684
684
|
ye(e, t);
|
|
685
685
|
}
|
|
686
686
|
});
|
|
687
|
-
nn(), d.append(...F ? [F] : [],
|
|
688
|
-
let xe = d,
|
|
687
|
+
nn(), d.append(...F ? [F] : [], _, Ne);
|
|
688
|
+
let xe = d, W, T;
|
|
689
689
|
const be = m === "left" ? "left" : "right";
|
|
690
|
-
if (z && (
|
|
690
|
+
if (z && (W = h({
|
|
691
691
|
position: "fixed",
|
|
692
692
|
top: "0",
|
|
693
693
|
bottom: "0",
|
|
@@ -698,15 +698,15 @@ function wn(n, o) {
|
|
|
698
698
|
zIndex: "2147483000",
|
|
699
699
|
transition: "transform 0.3s ease",
|
|
700
700
|
boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
|
|
701
|
-
}),
|
|
701
|
+
}), W.className = "ago-chat-widget-panel", v(d, {
|
|
702
702
|
height: "100%",
|
|
703
703
|
width: "100%",
|
|
704
704
|
borderRadius: "0",
|
|
705
705
|
border: "none",
|
|
706
706
|
boxShadow: "none",
|
|
707
707
|
[be === "left" ? "borderRight" : "borderLeft"]: `1px solid ${L}`
|
|
708
|
-
}),
|
|
709
|
-
if (
|
|
708
|
+
}), W.appendChild(d), xe = W), Et) {
|
|
709
|
+
if (T = document.createElement("button"), T.type = "button", T.className = "ago-chat-widget-launcher", T.setAttribute("aria-label", `Open ${i}`), v(T, {
|
|
710
710
|
position: "fixed",
|
|
711
711
|
bottom: "20px",
|
|
712
712
|
[be]: "20px",
|
|
@@ -714,7 +714,7 @@ function wn(n, o) {
|
|
|
714
714
|
height: "56px",
|
|
715
715
|
borderRadius: "50%",
|
|
716
716
|
border: "none",
|
|
717
|
-
backgroundColor:
|
|
717
|
+
backgroundColor: Ie,
|
|
718
718
|
color: Ae,
|
|
719
719
|
cursor: "pointer",
|
|
720
720
|
display: "flex",
|
|
@@ -729,33 +729,33 @@ function wn(n, o) {
|
|
|
729
729
|
width: "26px",
|
|
730
730
|
height: "26px",
|
|
731
731
|
objectFit: "contain"
|
|
732
|
-
}),
|
|
733
|
-
} else
|
|
734
|
-
|
|
732
|
+
}), T.appendChild(e);
|
|
733
|
+
} else T.appendChild(un());
|
|
734
|
+
T.addEventListener("click", () => $e());
|
|
735
735
|
}
|
|
736
736
|
const de = re ? `ago-vt-${++gn}` : "", Ve = 52;
|
|
737
|
-
let
|
|
737
|
+
let U = !1, ce = 0, ie = 0, H, pe, X;
|
|
738
738
|
const ve = {
|
|
739
739
|
height: d.style.height,
|
|
740
740
|
border: d.style.border,
|
|
741
741
|
borderRadius: d.style.borderRadius,
|
|
742
742
|
boxShadow: d.style.boxShadow
|
|
743
743
|
};
|
|
744
|
-
|
|
745
|
-
if (
|
|
746
|
-
const t =
|
|
747
|
-
if (
|
|
744
|
+
We.appendChild(xe), T && We.appendChild(T), we(), re && (H = Ft(), d.insertBefore(H, d.firstChild), pe = document.createElement("style"), pe.id = de, pe.textContent = `::view-transition-group(${de}),::view-transition-group(${de}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(pe), (ke === "focus" || ke === "tap") && (d.addEventListener("pointerdown", (e) => {
|
|
745
|
+
if (U || !M?.matches) return;
|
|
746
|
+
const t = Ne.contains(e.target);
|
|
747
|
+
if (ke === "tap") {
|
|
748
748
|
if ((e.target instanceof Element ? e.target : null)?.closest("button,a[href],[role='button']")) return;
|
|
749
749
|
} else if (!t) return;
|
|
750
750
|
t && e.preventDefault(), fe();
|
|
751
751
|
}, !0), d.addEventListener("focusin", (e) => {
|
|
752
|
-
M?.matches &&
|
|
752
|
+
M?.matches && Ne.contains(e.target) && fe();
|
|
753
753
|
})), document.addEventListener("keydown", tt)), M && M.addEventListener("change", nt);
|
|
754
|
-
const
|
|
755
|
-
re && M?.matches && !
|
|
754
|
+
const kt = w !== !1, _t = w === !1 ? void 0 : w ?? ((e) => {
|
|
755
|
+
re && M?.matches && !U ? fe().then(() => ye(e)) : ye(e);
|
|
756
756
|
});
|
|
757
|
-
function
|
|
758
|
-
if (
|
|
757
|
+
function N() {
|
|
758
|
+
if (_.replaceChildren(), u.length === 0) {
|
|
759
759
|
if (He === "static") {
|
|
760
760
|
const t = h({
|
|
761
761
|
textAlign: "center",
|
|
@@ -764,22 +764,22 @@ function wn(n, o) {
|
|
|
764
764
|
fontSize: "16px",
|
|
765
765
|
lineHeight: "1.5"
|
|
766
766
|
});
|
|
767
|
-
t.appendChild(ze(Fe)),
|
|
767
|
+
t.appendChild(ze(Fe)), _.appendChild(t);
|
|
768
768
|
}
|
|
769
769
|
} else u.forEach((t, l) => {
|
|
770
770
|
const S = l === u.length - 1 || u[l + 1].role !== t.role;
|
|
771
|
-
|
|
771
|
+
_.appendChild(cn(t, {
|
|
772
772
|
isLast: l === u.length - 1,
|
|
773
773
|
isLastOfBlock: S,
|
|
774
|
-
bubbleStyle:
|
|
774
|
+
bubbleStyle: k,
|
|
775
775
|
showAgentName: A,
|
|
776
776
|
agentBubble: R,
|
|
777
|
-
followUpEnabled:
|
|
778
|
-
followUpHandler:
|
|
777
|
+
followUpEnabled: kt,
|
|
778
|
+
followUpHandler: _t,
|
|
779
779
|
isMobile: !!M?.matches
|
|
780
780
|
}));
|
|
781
781
|
});
|
|
782
|
-
for (const t of Ge)
|
|
782
|
+
for (const t of Ge) _.appendChild(pn(t));
|
|
783
783
|
if (le) {
|
|
784
784
|
const t = h({
|
|
785
785
|
padding: "10px 14px",
|
|
@@ -790,34 +790,34 @@ function wn(n, o) {
|
|
|
790
790
|
fontSize: "13px",
|
|
791
791
|
border: "1px solid #fecaca"
|
|
792
792
|
});
|
|
793
|
-
t.setAttribute("role", "alert"), t.textContent = le,
|
|
793
|
+
t.setAttribute("role", "alert"), t.textContent = le, _.appendChild(t);
|
|
794
794
|
}
|
|
795
|
-
|
|
795
|
+
_.scrollTop = _.scrollHeight;
|
|
796
796
|
const e = u[u.length - 1];
|
|
797
|
-
At(Z && e?.role === "assistant" && e.status === "IN_PROGRESS");
|
|
797
|
+
At(Z && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT"));
|
|
798
798
|
}
|
|
799
|
-
function
|
|
799
|
+
function Nt() {
|
|
800
800
|
for (let e = u.length - 1; e >= 0; e--) {
|
|
801
801
|
const t = u[e];
|
|
802
|
-
if (t.role === "assistant" && t.status === "IN_PROGRESS") return t;
|
|
802
|
+
if (t.role === "assistant" && (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT")) return t;
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
805
|
const je = (e) => {
|
|
806
806
|
P || (P = e.conversationId);
|
|
807
807
|
}, qe = (e) => {
|
|
808
|
-
const t =
|
|
809
|
-
t && (t.content += e.content,
|
|
808
|
+
const t = Nt();
|
|
809
|
+
t && (t.content += e.content, N());
|
|
810
810
|
}, Ke = (e) => {
|
|
811
811
|
const t = u.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
|
|
812
|
-
t >= 0 ? u[t] = e : u.push(e),
|
|
812
|
+
t >= 0 ? u[t] = e : u.push(e), N(), he();
|
|
813
813
|
}, Xe = (e) => {
|
|
814
814
|
const t = u.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
|
|
815
|
-
t >= 0 ? u[t] = e : u.push(e), Z = !1,
|
|
815
|
+
t >= 0 ? u[t] = e : u.push(e), Z = !1, N(), e.status === "DONE" && I?.({
|
|
816
816
|
id: e.id,
|
|
817
817
|
content: e.content
|
|
818
818
|
});
|
|
819
819
|
}, Qe = (e) => {
|
|
820
|
-
le = e.error, Z = !1, u = u.filter((t) => !t.id.startsWith("temp-")),
|
|
820
|
+
le = e.error, Z = !1, u = u.filter((t) => !t.id.startsWith("temp-")), N();
|
|
821
821
|
};
|
|
822
822
|
function Lt(e) {
|
|
823
823
|
const t = {
|
|
@@ -828,15 +828,15 @@ function wn(n, o) {
|
|
|
828
828
|
status: "IN_PROGRESS",
|
|
829
829
|
createdAt: /* @__PURE__ */ new Date()
|
|
830
830
|
};
|
|
831
|
-
u.push(t),
|
|
831
|
+
u.push(t), N();
|
|
832
832
|
const l = e.match(/\S+\s*/g) ?? [e];
|
|
833
833
|
let S = 0;
|
|
834
834
|
K = setInterval(() => {
|
|
835
835
|
if (S >= l.length) {
|
|
836
|
-
clearInterval(K), K = void 0, t.status = "DONE", Pe && (t.followUpReplies = Pe),
|
|
836
|
+
clearInterval(K), K = void 0, t.status = "DONE", Pe && (t.followUpReplies = Pe), N();
|
|
837
837
|
return;
|
|
838
838
|
}
|
|
839
|
-
t.content += l[S], S++,
|
|
839
|
+
t.content += l[S], S++, N();
|
|
840
840
|
}, Ct);
|
|
841
841
|
}
|
|
842
842
|
E.on("message:start", je), E.on("message:chunk", qe), E.on("message:answer-complete", Ke), E.on("message:complete", Xe), E.on("message:error", Qe);
|
|
@@ -849,7 +849,7 @@ function wn(n, o) {
|
|
|
849
849
|
Le.push(e.install(E));
|
|
850
850
|
let t = e.store.get().submitted;
|
|
851
851
|
const l = e.store.subscribe((S) => {
|
|
852
|
-
S.submitted && !t && (Ge.push(
|
|
852
|
+
S.submitted && !t && (Ge.push(It(S.submitResult)), N()), t = S.submitted;
|
|
853
853
|
});
|
|
854
854
|
Le.push(l);
|
|
855
855
|
};
|
|
@@ -858,10 +858,10 @@ function wn(n, o) {
|
|
|
858
858
|
async function ye(e, t) {
|
|
859
859
|
const l = e.trim();
|
|
860
860
|
if (!l && !t?.length || Z) return;
|
|
861
|
-
if (
|
|
861
|
+
if ($?.(l), Z = !0, le = null, K) {
|
|
862
862
|
clearInterval(K), K = void 0;
|
|
863
|
-
const
|
|
864
|
-
|
|
863
|
+
const y = u.find((G) => G.id.startsWith("ago-intro-"));
|
|
864
|
+
y && !y.content ? u = u.filter((G) => G !== y) : y && (y.status = "DONE");
|
|
865
865
|
}
|
|
866
866
|
const S = Date.now();
|
|
867
867
|
u.push({
|
|
@@ -870,7 +870,7 @@ function wn(n, o) {
|
|
|
870
870
|
content: l,
|
|
871
871
|
role: "user",
|
|
872
872
|
status: "DONE",
|
|
873
|
-
attachments: t && t.length > 0 ?
|
|
873
|
+
attachments: t && t.length > 0 ? Ut(t) : void 0,
|
|
874
874
|
createdAt: /* @__PURE__ */ new Date()
|
|
875
875
|
}), u.push({
|
|
876
876
|
id: `temp-assistant-${S}`,
|
|
@@ -879,24 +879,24 @@ function wn(n, o) {
|
|
|
879
879
|
role: "assistant",
|
|
880
880
|
status: "IN_PROGRESS",
|
|
881
881
|
createdAt: /* @__PURE__ */ new Date()
|
|
882
|
-
}),
|
|
882
|
+
}), N();
|
|
883
883
|
try {
|
|
884
|
-
const
|
|
884
|
+
const y = await E.sendMessage(l, {
|
|
885
885
|
conversationId: P,
|
|
886
886
|
files: t
|
|
887
887
|
});
|
|
888
|
-
|
|
888
|
+
y.conversationId && (P || (P = y.conversationId), me?.setActiveThread(y.conversationId, y.createdAt));
|
|
889
889
|
const G = u.find((Q) => Q.id === `temp-user-${S}`);
|
|
890
|
-
if (G && (G.id = `user-${S}`, G.conversationId =
|
|
890
|
+
if (G && (G.id = `user-${S}`, G.conversationId = y.conversationId), !u.some((Q) => Q.id === y.id)) {
|
|
891
891
|
const Q = u.findIndex((Pt) => Pt.id === `temp-assistant-${S}`);
|
|
892
|
-
Q >= 0 ? u[Q] =
|
|
892
|
+
Q >= 0 ? u[Q] = y : u.push(y);
|
|
893
893
|
}
|
|
894
|
-
u = u.filter((Q) => !Q.id.startsWith("temp-")), Z = !1,
|
|
895
|
-
} catch (
|
|
896
|
-
le =
|
|
894
|
+
u = u.filter((Q) => !Q.id.startsWith("temp-")), y.status !== "WAITING_CLIENT" && (Z = !1), N(), g && Te();
|
|
895
|
+
} catch (y) {
|
|
896
|
+
le = y instanceof Error ? y.message : "Failed to send message", Z = !1, u = u.filter((G) => !G.id.startsWith("temp-")), N();
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
|
-
async function
|
|
899
|
+
async function Te() {
|
|
900
900
|
try {
|
|
901
901
|
const e = await E.getConversations();
|
|
902
902
|
ge.splice(0, ge.length, ...e);
|
|
@@ -904,15 +904,15 @@ function wn(n, o) {
|
|
|
904
904
|
}
|
|
905
905
|
return ge;
|
|
906
906
|
}
|
|
907
|
-
async function
|
|
907
|
+
async function Tt(e) {
|
|
908
908
|
try {
|
|
909
909
|
const t = (await E.getConversation(e))?.messages ?? [];
|
|
910
|
-
t.length > 0 && u.length === 0 && (u = t,
|
|
910
|
+
t.length > 0 && u.length === 0 && (u = t, N());
|
|
911
911
|
} catch {
|
|
912
912
|
u.length === 0 && (me?.clear(), P = void 0);
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
-
return
|
|
915
|
+
return N(), re && M?.matches || he(), P ? Tt(P) : He === "streaming" && Lt(Fe), g && Te(), {
|
|
916
916
|
client: E,
|
|
917
917
|
element: xe,
|
|
918
918
|
sendMessage: ye,
|
|
@@ -923,43 +923,43 @@ function wn(n, o) {
|
|
|
923
923
|
} : {},
|
|
924
924
|
session: me,
|
|
925
925
|
threads: ge,
|
|
926
|
-
refreshThreads:
|
|
926
|
+
refreshThreads: Te,
|
|
927
927
|
destroy() {
|
|
928
|
-
K && clearInterval(K), E.off("message:start", je), E.off("message:chunk", qe), E.off("message:answer-complete", Ke), E.off("message:complete", Xe), E.off("message:error", Qe), V && E.off("form:submitted", Ye), j && E.off("form:error", Ze), Je = !0, Le.forEach((e) => e()), xe.remove(),
|
|
928
|
+
K && clearInterval(K), E.off("message:start", je), E.off("message:chunk", qe), E.off("message:answer-complete", Ke), E.off("message:complete", Xe), E.off("message:error", Qe), V && E.off("form:submitted", Ye), j && E.off("form:error", Ze), Je = !0, Le.forEach((e) => e()), xe.remove(), T?.remove(), H?.remove(), pe?.remove(), X?.remove(), M?.removeEventListener("change", nt), re && (document.removeEventListener("keydown", tt), it(), document.documentElement.style.removeProperty("overflow")), o.client || E.destroy();
|
|
929
929
|
}
|
|
930
930
|
};
|
|
931
931
|
function we() {
|
|
932
|
-
if (!
|
|
932
|
+
if (!W) return;
|
|
933
933
|
{
|
|
934
934
|
const t = be === "left" ? "border-right" : "border-left";
|
|
935
|
-
M?.matches ? (
|
|
935
|
+
M?.matches ? (W.style.width = "100%", d.style.borderRadius = "0", d.style.removeProperty(t)) : (W.style.width = typeof x == "number" ? `${x}px` : x, d.style.setProperty(t, `1px solid ${L}`));
|
|
936
936
|
}
|
|
937
937
|
const e = m === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
938
|
-
|
|
938
|
+
W.style.transform = oe ? "translateX(0)" : e, W.setAttribute("aria-hidden", oe ? "false" : "true"), T && (T.style.display = oe ? "none" : "flex");
|
|
939
939
|
}
|
|
940
|
-
function
|
|
940
|
+
function $e() {
|
|
941
941
|
oe = !0, we(), he(), B?.();
|
|
942
942
|
}
|
|
943
943
|
function Be() {
|
|
944
944
|
oe = !1, we(), q?.();
|
|
945
945
|
}
|
|
946
|
-
function
|
|
947
|
-
oe ? Be() :
|
|
946
|
+
function $t() {
|
|
947
|
+
oe ? Be() : $e();
|
|
948
948
|
}
|
|
949
949
|
function Bt() {
|
|
950
|
-
z ?
|
|
950
|
+
z ? $e() : fe();
|
|
951
951
|
}
|
|
952
952
|
function Mt() {
|
|
953
953
|
z ? Be() : ue();
|
|
954
954
|
}
|
|
955
955
|
function Ot() {
|
|
956
|
-
z ?
|
|
956
|
+
z ? $t() : U ? ue() : fe();
|
|
957
957
|
}
|
|
958
958
|
function Dt() {
|
|
959
959
|
return Array.from(d.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
|
|
960
960
|
}
|
|
961
961
|
function tt(e) {
|
|
962
|
-
if (!
|
|
962
|
+
if (!U) return;
|
|
963
963
|
if (e.key === "Escape") {
|
|
964
964
|
ue();
|
|
965
965
|
return;
|
|
@@ -970,11 +970,11 @@ function wn(n, o) {
|
|
|
970
970
|
e.preventDefault();
|
|
971
971
|
return;
|
|
972
972
|
}
|
|
973
|
-
const l = t[0], S = t[t.length - 1],
|
|
974
|
-
e.shiftKey && (
|
|
973
|
+
const l = t[0], S = t[t.length - 1], y = document.activeElement;
|
|
974
|
+
e.shiftKey && (y === l || !d.contains(y)) ? (e.preventDefault(), S.focus()) : !e.shiftKey && (y === S || !d.contains(y)) && (e.preventDefault(), l.focus());
|
|
975
975
|
}
|
|
976
976
|
function nt(e) {
|
|
977
|
-
z ? we() : !e.matches &&
|
|
977
|
+
z ? we() : !e.matches && U && ue(), N();
|
|
978
978
|
}
|
|
979
979
|
function ot() {
|
|
980
980
|
return window.visualViewport?.height ?? window.innerHeight;
|
|
@@ -995,7 +995,7 @@ function wn(n, o) {
|
|
|
995
995
|
window.visualViewport?.removeEventListener("resize", Ce), window.visualViewport?.removeEventListener("scroll", Ce), ie && (cancelAnimationFrame(ie), ie = 0);
|
|
996
996
|
}
|
|
997
997
|
function at() {
|
|
998
|
-
|
|
998
|
+
_.scrollTop = _.scrollHeight;
|
|
999
999
|
}
|
|
1000
1000
|
function Ft() {
|
|
1001
1001
|
const e = h({
|
|
@@ -1089,10 +1089,10 @@ function wn(n, o) {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
}
|
|
1091
1091
|
function fe() {
|
|
1092
|
-
if (
|
|
1092
|
+
if (U || !M?.matches) return Promise.resolve();
|
|
1093
1093
|
const e = d.getBoundingClientRect();
|
|
1094
1094
|
if (e.height >= ot() * 0.8) return Promise.resolve();
|
|
1095
|
-
|
|
1095
|
+
U = !0, X = h({
|
|
1096
1096
|
width: `${e.width}px`,
|
|
1097
1097
|
height: `${e.height}px`
|
|
1098
1098
|
}), X.className = "ago-chat-widget-spacer", X.setAttribute("aria-hidden", "true"), ce = ot(), d.style.setProperty("--ago-vh", `${ce}px`), rt(), zt();
|
|
@@ -1102,8 +1102,8 @@ function wn(n, o) {
|
|
|
1102
1102
|
}), at(), B?.(), t;
|
|
1103
1103
|
}
|
|
1104
1104
|
function ue() {
|
|
1105
|
-
if (!
|
|
1106
|
-
|
|
1105
|
+
if (!U) return Promise.resolve();
|
|
1106
|
+
U = !1, it(), d.querySelector("textarea")?.blur();
|
|
1107
1107
|
const e = st(() => lt(!1));
|
|
1108
1108
|
return e.then(() => d.style.removeProperty("--ago-vh")), ce = 0, q?.(), e;
|
|
1109
1109
|
}
|