@useago/sdk 1.14.0 → 1.14.1
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/CHANGELOG.md +7 -0
- package/dist/widget.cjs +6 -5
- package/dist/widget.js +1370 -1346
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as
|
|
3
|
-
import { t as
|
|
4
|
-
import { r as
|
|
5
|
-
import { $ as ne, A as
|
|
6
|
-
var
|
|
7
|
-
var
|
|
1
|
+
import { a as nr, c as ni, n as or, o as oi, s as ii, t as ir } from "./types-C39MJUE3.js";
|
|
2
|
+
import { n as rr } from "./errors-BLfjXnLB.js";
|
|
3
|
+
import { t as ar } from "./createConversationSession-CybQdMpK.js";
|
|
4
|
+
import { r as sr, t as lr } from "./createFormCollector-DJjms78E.js";
|
|
5
|
+
import { $ as ne, A as On, B as cr, C as cs, D as Q, E as dr, F as Hn, G as Mo, H as ri, I as pr, J as ur, K as Bn, L as fr, M as $n, N as Re, O as ve, P as ai, Q as en, R as si, S as ds, T as Dn, U as Ee, V as st, W as Mn, X as mr, Y as jo, Z as li, _ as gr, a as hr, at as d, b as br, c as xr, ct as yr, d as ci, dt as Nn, et as Cr, f as di, ft as We, g as wr, h as vr, i as Er, it as u, j as kr, k as lt, l as Sr, lt as _r, m as Tr, mt as Gn, n as Ar, nt as In, o as Fr, ot as Lr, p as Nr, pt as Me, q as pi, r as Xn, rt as Ir, s as Rr, st as zr, t as ps, tt as Or, u as Hr, ut as Wo, v as Br, w as ct, x as $r, y as Dr, z as on } from "./speechToText-BLvTis4S.js";
|
|
6
|
+
var Mr = 10 * 1024 * 1024;
|
|
7
|
+
var Uo = [
|
|
8
8
|
"image/jpeg",
|
|
9
9
|
"image/png",
|
|
10
10
|
"image/gif",
|
|
@@ -27,19 +27,19 @@ var Wo = [
|
|
|
27
27
|
"text/html",
|
|
28
28
|
"application/epub+zip"
|
|
29
29
|
];
|
|
30
|
-
function
|
|
30
|
+
function Po(t) {
|
|
31
31
|
return t < 1024 ? `${t} B` : t < 1024 * 1024 ? `${(t / 1024).toFixed(1)} KB` : `${(t / (1024 * 1024)).toFixed(1)} MB`;
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function jr(t) {
|
|
34
34
|
const e = t.look === "embed";
|
|
35
35
|
let o = [];
|
|
36
36
|
const n = /* @__PURE__ */ new Map(), i = document.createElement("form");
|
|
37
37
|
i.className = e ? "ago-chat-input ago-chat-input--embed" : "ago-chat-input", e ? u(i, {
|
|
38
38
|
width: "100%",
|
|
39
39
|
borderRadius: "24px",
|
|
40
|
-
border: `2px solid ${
|
|
40
|
+
border: `2px solid ${pi}`,
|
|
41
41
|
backgroundColor: "#fff",
|
|
42
|
-
boxShadow:
|
|
42
|
+
boxShadow: mr,
|
|
43
43
|
position: "relative",
|
|
44
44
|
boxSizing: "border-box",
|
|
45
45
|
display: "block",
|
|
@@ -74,12 +74,12 @@ function Mr(t) {
|
|
|
74
74
|
alignItems: "flex-end"
|
|
75
75
|
}), c = document.createElement("textarea");
|
|
76
76
|
c.placeholder = t.placeholder, c.setAttribute("aria-label", t.placeholder), c.rows = 1, c.autocapitalize = "off", c.setAttribute("autocorrect", "off");
|
|
77
|
-
const
|
|
77
|
+
const x = e ? 208 : 110;
|
|
78
78
|
e ? u(c, {
|
|
79
79
|
display: "block",
|
|
80
80
|
width: "100%",
|
|
81
81
|
minHeight: "40px",
|
|
82
|
-
maxHeight: `${
|
|
82
|
+
maxHeight: `${x}px`,
|
|
83
83
|
overflowY: "auto",
|
|
84
84
|
resize: "none",
|
|
85
85
|
border: "none",
|
|
@@ -102,34 +102,34 @@ function Mr(t) {
|
|
|
102
102
|
fontSize: "16px",
|
|
103
103
|
fontFamily: Re,
|
|
104
104
|
lineHeight: "1.4",
|
|
105
|
-
maxHeight: `${
|
|
105
|
+
maxHeight: `${x}px`,
|
|
106
106
|
overflowY: "hidden"
|
|
107
107
|
});
|
|
108
|
-
const
|
|
109
|
-
const
|
|
108
|
+
const f = () => {
|
|
109
|
+
const g = e ? 0 : 2;
|
|
110
110
|
c.style.height = "auto";
|
|
111
|
-
const
|
|
112
|
-
c.style.height = `${
|
|
111
|
+
const B = Math.min(c.scrollHeight + g, x);
|
|
112
|
+
c.style.height = `${B}px`, c.style.overflowY = c.scrollHeight + g > x ? "auto" : "hidden";
|
|
113
113
|
};
|
|
114
114
|
c.addEventListener("input", () => {
|
|
115
|
-
|
|
115
|
+
f(), _();
|
|
116
116
|
});
|
|
117
|
-
const p = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>',
|
|
118
|
-
|
|
117
|
+
const p = '<svg width="18" height="18" viewBox="0 -960 960 960" fill="currentColor" aria-hidden="true"><path d="M440-160v-487L216-423l-56-57 320-320 320 320-56 57-224-224v487h-80Z"/></svg>', b = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" style="animation: ago-spin 0.8s linear infinite"><path d="M21 12a9 9 0 1 1-6.219-8.56"/></svg>', F = '<svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true"><rect x="5" y="5" width="14" height="14" rx="2"/></svg>', y = document.createElement("button");
|
|
118
|
+
y.type = "submit", y.className = "ago-chat-input__send", y.setAttribute("aria-label", t.labels?.send ?? "Send"), e ? u(y, {
|
|
119
119
|
flexShrink: "0",
|
|
120
120
|
width: "40px",
|
|
121
121
|
height: "40px",
|
|
122
122
|
padding: "0",
|
|
123
123
|
border: "none",
|
|
124
124
|
borderRadius: "50%",
|
|
125
|
-
backgroundColor:
|
|
125
|
+
backgroundColor: jo,
|
|
126
126
|
color: "#fafafa",
|
|
127
127
|
display: "flex",
|
|
128
128
|
alignItems: "center",
|
|
129
129
|
justifyContent: "center",
|
|
130
130
|
cursor: "pointer",
|
|
131
131
|
transition: "background-color 0.15s, color 0.15s"
|
|
132
|
-
}) : (
|
|
132
|
+
}) : (y.innerHTML = p, u(y, {
|
|
133
133
|
flexShrink: "0",
|
|
134
134
|
width: "44px",
|
|
135
135
|
height: "44px",
|
|
@@ -137,27 +137,27 @@ function Mr(t) {
|
|
|
137
137
|
border: "none",
|
|
138
138
|
borderRadius: "50%",
|
|
139
139
|
backgroundColor: ve,
|
|
140
|
-
color:
|
|
140
|
+
color: lt,
|
|
141
141
|
display: "flex",
|
|
142
142
|
alignItems: "center",
|
|
143
143
|
justifyContent: "center",
|
|
144
144
|
cursor: "pointer"
|
|
145
145
|
}));
|
|
146
|
-
let
|
|
147
|
-
const
|
|
148
|
-
const
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
const D = P && !
|
|
152
|
-
|
|
146
|
+
let m = !1, k = !1;
|
|
147
|
+
const N = () => m && !!t.onStop, _ = () => {
|
|
148
|
+
const g = c.value.trim() !== "", B = N(), P = !B && (m || k || !g);
|
|
149
|
+
if (y.disabled = P, y.type = B ? "button" : "submit", y.setAttribute("aria-label", B ? t.labels?.stop ?? "Stop generating" : t.labels?.send ?? "Send"), e) {
|
|
150
|
+
y.replaceChildren(B ? Dr({ size: 16 }) : Rr({ size: 16 }));
|
|
151
|
+
const D = P && !m;
|
|
152
|
+
y.style.backgroundColor = D ? "#f1f5f9" : jo, y.style.color = D ? "#cbd5e1" : "#fafafa", y.style.pointerEvents = P ? "none" : "auto", y.style.cursor = P ? "default" : "pointer", ee.style.opacity = m ? "0.5" : "1";
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
|
-
|
|
155
|
+
y.innerHTML = B ? F : m ? b : p, y.style.opacity = P && !m ? "0.5" : "1", y.style.cursor = P ? "default" : "pointer";
|
|
156
156
|
};
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
y.addEventListener("click", () => {
|
|
158
|
+
N() && t.onStop?.();
|
|
159
159
|
});
|
|
160
|
-
const
|
|
160
|
+
const I = d({
|
|
161
161
|
display: "none",
|
|
162
162
|
alignItems: "flex-start",
|
|
163
163
|
justifyContent: "space-between",
|
|
@@ -171,9 +171,9 @@ function Mr(t) {
|
|
|
171
171
|
fontSize: "14px",
|
|
172
172
|
lineHeight: "20px"
|
|
173
173
|
});
|
|
174
|
-
|
|
175
|
-
const j = document.createElement("span"),
|
|
176
|
-
|
|
174
|
+
I.className = "ago-chat-input__error", I.setAttribute("role", "alert");
|
|
175
|
+
const j = document.createElement("span"), w = document.createElement("button");
|
|
176
|
+
w.type = "button", w.textContent = t.labels?.dismiss ?? "Dismiss", u(w, {
|
|
177
177
|
border: "none",
|
|
178
178
|
background: "transparent",
|
|
179
179
|
color: "inherit",
|
|
@@ -183,33 +183,33 @@ function Mr(t) {
|
|
|
183
183
|
padding: "0",
|
|
184
184
|
minHeight: "20px"
|
|
185
185
|
});
|
|
186
|
-
let
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}),
|
|
190
|
-
const
|
|
191
|
-
j.textContent =
|
|
192
|
-
},
|
|
193
|
-
if (!e) return
|
|
194
|
-
const
|
|
195
|
-
G?.clearError(),
|
|
186
|
+
let O;
|
|
187
|
+
w.addEventListener("click", () => {
|
|
188
|
+
O = void 0, G?.clearError(), I.style.display = "none";
|
|
189
|
+
}), I.append(j, w);
|
|
190
|
+
const E = (g) => {
|
|
191
|
+
j.textContent = g, I.style.display = "flex";
|
|
192
|
+
}, S = (g, B) => g.replace(/\{(\w+)\}/g, (P, D) => Object.prototype.hasOwnProperty.call(B, D) ? B[D] : P), R = (g) => {
|
|
193
|
+
if (!e) return g;
|
|
194
|
+
const B = (D, oe) => {
|
|
195
|
+
G?.clearError(), O = {
|
|
196
196
|
key: D,
|
|
197
197
|
values: oe
|
|
198
|
-
},
|
|
198
|
+
}, E(S(t.labels?.[D] ?? We("en").widget[D], oe));
|
|
199
199
|
}, P = [];
|
|
200
|
-
for (const D of
|
|
200
|
+
for (const D of g) {
|
|
201
201
|
if (o.length + P.length >= 5) {
|
|
202
|
-
|
|
202
|
+
B("tooManyFiles", { max: String(5) });
|
|
203
203
|
break;
|
|
204
204
|
}
|
|
205
|
-
if (D.type && !
|
|
206
|
-
|
|
205
|
+
if (D.type && !Uo.includes(D.type)) {
|
|
206
|
+
B("invalidFileType", { name: D.name });
|
|
207
207
|
continue;
|
|
208
208
|
}
|
|
209
209
|
if (D.size > 10485760) {
|
|
210
|
-
|
|
210
|
+
B("fileTooLarge", {
|
|
211
211
|
name: D.name,
|
|
212
|
-
max:
|
|
212
|
+
max: Po(Mr)
|
|
213
213
|
});
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
@@ -217,8 +217,8 @@ function Mr(t) {
|
|
|
217
217
|
}
|
|
218
218
|
return P;
|
|
219
219
|
};
|
|
220
|
-
let
|
|
221
|
-
t.allowFiles && (
|
|
220
|
+
let H = null, $ = null;
|
|
221
|
+
t.allowFiles && (H = document.createElement("input"), H.type = "file", H.multiple = !0, e && (H.accept = Uo.join(",")), u(H, { display: "none" }), $ = document.createElement("button"), $.type = "button", $.className = "ago-chat-input__attach", $.setAttribute("aria-label", t.labels?.attachFiles ?? "Attach file"), e ? ($.appendChild(xr({ size: 16 })), u($, {
|
|
222
222
|
height: "40px",
|
|
223
223
|
padding: "8px",
|
|
224
224
|
display: "flex",
|
|
@@ -243,21 +243,21 @@ function Mr(t) {
|
|
|
243
243
|
backgroundColor: Ee,
|
|
244
244
|
cursor: "pointer",
|
|
245
245
|
fontSize: "14px"
|
|
246
|
-
})), $.addEventListener("click", () =>
|
|
247
|
-
const
|
|
248
|
-
o = [...o, ...
|
|
246
|
+
})), $.addEventListener("click", () => H?.click()), H.addEventListener("change", () => {
|
|
247
|
+
const g = Array.from(H?.files ?? []);
|
|
248
|
+
o = [...o, ...R(g)], H && (H.value = ""), v();
|
|
249
249
|
}));
|
|
250
|
-
function W(
|
|
251
|
-
if (!e || !
|
|
252
|
-
let
|
|
253
|
-
return
|
|
250
|
+
function W(g) {
|
|
251
|
+
if (!e || !g.type.startsWith("image/") || typeof URL > "u" || typeof URL.createObjectURL != "function") return null;
|
|
252
|
+
let B = n.get(g);
|
|
253
|
+
return B || (B = URL.createObjectURL(g), n.set(g, B)), B;
|
|
254
254
|
}
|
|
255
|
-
function q(
|
|
256
|
-
const
|
|
257
|
-
|
|
255
|
+
function q(g) {
|
|
256
|
+
const B = n.get(g);
|
|
257
|
+
B && (URL.revokeObjectURL(B), n.delete(g));
|
|
258
258
|
}
|
|
259
|
-
function
|
|
260
|
-
a.replaceChildren(), e && (a.style.display = o.length > 0 ? "flex" : "none"), o.forEach((
|
|
259
|
+
function v() {
|
|
260
|
+
a.replaceChildren(), e && (a.style.display = o.length > 0 ? "flex" : "none"), o.forEach((g, B) => {
|
|
261
261
|
const P = d(e ? {
|
|
262
262
|
display: "flex",
|
|
263
263
|
alignItems: "center",
|
|
@@ -278,34 +278,34 @@ function Mr(t) {
|
|
|
278
278
|
fontSize: "12px"
|
|
279
279
|
});
|
|
280
280
|
if (P.className = "ago-chat-input__file", e) {
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
283
|
-
const
|
|
284
|
-
|
|
281
|
+
const ge = W(g);
|
|
282
|
+
if (ge) {
|
|
283
|
+
const ae = document.createElement("img");
|
|
284
|
+
ae.src = ge, ae.alt = "", u(ae, {
|
|
285
285
|
width: "32px",
|
|
286
286
|
height: "32px",
|
|
287
287
|
objectFit: "cover",
|
|
288
288
|
borderRadius: "4px",
|
|
289
289
|
flexShrink: "0"
|
|
290
|
-
}), P.appendChild(
|
|
291
|
-
} else P.appendChild(
|
|
290
|
+
}), P.appendChild(ae);
|
|
291
|
+
} else P.appendChild(Nr({ size: 20 }));
|
|
292
292
|
}
|
|
293
293
|
const D = document.createElement("span");
|
|
294
|
-
if (D.textContent =
|
|
294
|
+
if (D.textContent = g.name, D.title = g.name, e && u(D, {
|
|
295
295
|
maxWidth: "150px",
|
|
296
296
|
overflow: "hidden",
|
|
297
297
|
textOverflow: "ellipsis",
|
|
298
298
|
whiteSpace: "nowrap"
|
|
299
299
|
}), P.appendChild(D), e) {
|
|
300
|
-
const
|
|
301
|
-
|
|
300
|
+
const ge = document.createElement("span");
|
|
301
|
+
ge.textContent = Po(g.size), u(ge, {
|
|
302
302
|
fontSize: "12px",
|
|
303
303
|
lineHeight: "16px",
|
|
304
304
|
color: "#6b7280"
|
|
305
|
-
}), P.appendChild(
|
|
305
|
+
}), P.appendChild(ge);
|
|
306
306
|
}
|
|
307
307
|
const oe = document.createElement("button");
|
|
308
|
-
oe.type = "button", oe.setAttribute("aria-label", (t.labels?.removeFile ?? "Remove {filename}").replace("{filename}", () =>
|
|
308
|
+
oe.type = "button", oe.setAttribute("aria-label", (t.labels?.removeFile ?? "Remove {filename}").replace("{filename}", () => g.name)), e ? oe.appendChild(ci({ size: 16 })) : oe.textContent = "×", u(oe, {
|
|
309
309
|
flexShrink: "0",
|
|
310
310
|
width: "44px",
|
|
311
311
|
height: "44px",
|
|
@@ -320,44 +320,44 @@ function Mr(t) {
|
|
|
320
320
|
lineHeight: "1",
|
|
321
321
|
color: "inherit"
|
|
322
322
|
}), oe.addEventListener("click", () => {
|
|
323
|
-
q(
|
|
323
|
+
q(g), o = o.filter((ge, ae) => ae !== B), v();
|
|
324
324
|
}), P.appendChild(oe), a.appendChild(P);
|
|
325
|
-
}),
|
|
325
|
+
}), _();
|
|
326
326
|
}
|
|
327
|
-
const
|
|
327
|
+
const z = () => {
|
|
328
328
|
G?.cancel();
|
|
329
|
-
const
|
|
330
|
-
c.value = "",
|
|
331
|
-
for (const P of
|
|
332
|
-
return
|
|
333
|
-
content:
|
|
334
|
-
files:
|
|
329
|
+
const g = c.value, B = o;
|
|
330
|
+
c.value = "", f(), o = [];
|
|
331
|
+
for (const P of B) q(P);
|
|
332
|
+
return v(), {
|
|
333
|
+
content: g,
|
|
334
|
+
files: B
|
|
335
335
|
};
|
|
336
336
|
}, K = () => {
|
|
337
|
-
if (
|
|
338
|
-
const { content:
|
|
339
|
-
t.onSend(
|
|
337
|
+
if (m || k || !c.value.trim()) return;
|
|
338
|
+
const { content: g, files: B } = z();
|
|
339
|
+
t.onSend(g.trim(), B.length > 0 ? B : void 0), e && typeof window < "u" && window.innerWidth < (t.blurOnSubmitBelow ?? 600) && c.blur();
|
|
340
340
|
};
|
|
341
|
-
i.addEventListener("submit", (
|
|
342
|
-
|
|
343
|
-
}), c.addEventListener("keydown", (
|
|
344
|
-
if (
|
|
345
|
-
if (
|
|
346
|
-
|
|
341
|
+
i.addEventListener("submit", (g) => {
|
|
342
|
+
g.preventDefault(), K();
|
|
343
|
+
}), c.addEventListener("keydown", (g) => {
|
|
344
|
+
if (g.key === "Enter" && !g.shiftKey) {
|
|
345
|
+
if (g.isComposing || g.keyCode === 229) return;
|
|
346
|
+
g.preventDefault(), K();
|
|
347
347
|
}
|
|
348
348
|
});
|
|
349
|
-
const G = t.transcribeAudio ?
|
|
349
|
+
const G = t.transcribeAudio ? Ar({
|
|
350
350
|
transcribe: t.transcribeAudio,
|
|
351
351
|
labels: t.speechToTextLabels,
|
|
352
|
-
onBusy: (
|
|
353
|
-
const
|
|
354
|
-
|
|
352
|
+
onBusy: (g) => {
|
|
353
|
+
const B = k && !g && !m && i.contains(document.activeElement);
|
|
354
|
+
k = g, c.disabled = m || g, e ? (ee.style.display = g ? "none" : "", Y.style.display = g ? "none" : "flex", s.style.padding = g ? "8px" : "16px", G && (g ? s.append(G.el) : Y.prepend(G.el))) : (c.style.display = g ? "none" : "", y.style.display = g ? "none" : "flex", $ && ($.style.display = g ? "none" : "flex")), _(), B && c.focus();
|
|
355
355
|
},
|
|
356
|
-
onText: (
|
|
357
|
-
c.value += `${c.value && !/\s$/.test(c.value) ? " " : ""}${
|
|
356
|
+
onText: (g) => {
|
|
357
|
+
c.value += `${c.value && !/\s$/.test(c.value) ? " " : ""}${g}`, f(), _(), c.focus();
|
|
358
358
|
},
|
|
359
|
-
onError: (
|
|
360
|
-
|
|
359
|
+
onError: (g) => {
|
|
360
|
+
O = void 0, E(g);
|
|
361
361
|
}
|
|
362
362
|
}) : void 0, ee = d({
|
|
363
363
|
flex: "1",
|
|
@@ -371,43 +371,43 @@ function Mr(t) {
|
|
|
371
371
|
gap: "4px"
|
|
372
372
|
});
|
|
373
373
|
if (e) {
|
|
374
|
-
ee.append(
|
|
375
|
-
const
|
|
374
|
+
ee.append(I, a, c);
|
|
375
|
+
const g = d({
|
|
376
376
|
display: "flex",
|
|
377
377
|
alignItems: "center"
|
|
378
378
|
});
|
|
379
|
-
|
|
380
|
-
(
|
|
379
|
+
g.className = "ago-chat-input__toolbar", $ && g.appendChild($), $ && ee.appendChild(g), G && Y.appendChild(G.el), Y.appendChild(y), s.append(ee, Y), H && i.appendChild(H), i.appendChild(s), i.addEventListener("click", (B) => {
|
|
380
|
+
(B.target instanceof Element ? B.target : null)?.closest("button,a,input,textarea") || c.focus();
|
|
381
381
|
});
|
|
382
382
|
} else
|
|
383
|
-
$ && s.appendChild($), s.append(c), G && s.appendChild(G.el), s.append(
|
|
384
|
-
return
|
|
383
|
+
$ && s.appendChild($), s.append(c), G && s.appendChild(G.el), s.append(y), H && i.appendChild(H), i.append(I, a, s);
|
|
384
|
+
return _(), {
|
|
385
385
|
inputRow: i,
|
|
386
|
-
getValueAndClear:
|
|
387
|
-
setDisabled: (
|
|
388
|
-
|
|
386
|
+
getValueAndClear: z,
|
|
387
|
+
setDisabled: (g) => {
|
|
388
|
+
m = g, G?.setDisabled(g), c.disabled = g || k, _();
|
|
389
389
|
},
|
|
390
390
|
focus: () => c.focus(),
|
|
391
391
|
blur: () => c.blur(),
|
|
392
|
-
restoreDraft: (
|
|
393
|
-
|
|
392
|
+
restoreDraft: (g, B) => {
|
|
393
|
+
g && !c.value.trim() && (c.value = g, f()), B?.length && (o = [...B, ...o], v()), _();
|
|
394
394
|
},
|
|
395
|
-
setPlaceholder: (
|
|
396
|
-
c.placeholder =
|
|
395
|
+
setPlaceholder: (g) => {
|
|
396
|
+
c.placeholder = g, g && c.setAttribute("aria-label", g);
|
|
397
397
|
},
|
|
398
|
-
setLabels: (
|
|
399
|
-
t.labels =
|
|
398
|
+
setLabels: (g, B) => {
|
|
399
|
+
t.labels = g, $?.setAttribute("aria-label", g.attachFiles), w.textContent = g.dismiss, w.setAttribute("aria-label", g.dismiss), O && I.style.display !== "none" && (j.textContent = S(g[O.key], O.values)), G?.setLabels(B ?? We("en").speech), v(), _();
|
|
400
400
|
},
|
|
401
|
-
setSpeechToTextEnabled: (
|
|
401
|
+
setSpeechToTextEnabled: (g) => G?.setEnabled(g),
|
|
402
402
|
cancelRecording: () => G?.cancel(),
|
|
403
403
|
destroy: () => {
|
|
404
404
|
G?.destroy();
|
|
405
|
-
for (const
|
|
405
|
+
for (const g of n.keys()) q(g);
|
|
406
406
|
}
|
|
407
407
|
};
|
|
408
408
|
}
|
|
409
|
-
var
|
|
410
|
-
function
|
|
409
|
+
var Rn = "rgba(3, 24, 47, 0.07)";
|
|
410
|
+
function Wr(t) {
|
|
411
411
|
const e = document.createElement("footer");
|
|
412
412
|
e.className = "ago-chat-widget__footer", u(e, {
|
|
413
413
|
padding: "12px",
|
|
@@ -423,7 +423,7 @@ function jr(t) {
|
|
|
423
423
|
});
|
|
424
424
|
const n = /* @__PURE__ */ new Map();
|
|
425
425
|
let i = "home";
|
|
426
|
-
function a(c,
|
|
426
|
+
function a(c, x, f) {
|
|
427
427
|
const p = document.createElement("button");
|
|
428
428
|
p.type = "button", p.className = "ago-chat-widget__tab", p.dataset.agoScreen = c, u(p, {
|
|
429
429
|
flex: "1",
|
|
@@ -442,28 +442,28 @@ function jr(t) {
|
|
|
442
442
|
transition: "background-color 0.15s",
|
|
443
443
|
font: "inherit"
|
|
444
444
|
});
|
|
445
|
-
const
|
|
446
|
-
return
|
|
445
|
+
const b = document.createElement("span");
|
|
446
|
+
return b.textContent = x, u(b, {
|
|
447
447
|
fontSize: "12px",
|
|
448
448
|
lineHeight: "16px",
|
|
449
449
|
maxWidth: "100%",
|
|
450
450
|
whiteSpace: "nowrap",
|
|
451
451
|
overflow: "hidden",
|
|
452
452
|
textOverflow: "ellipsis"
|
|
453
|
-
}), p.append(
|
|
454
|
-
p.style.backgroundColor =
|
|
453
|
+
}), p.append(f, b), p.addEventListener("mouseenter", () => {
|
|
454
|
+
p.style.backgroundColor = Rn;
|
|
455
455
|
}), p.addEventListener("mouseleave", () => {
|
|
456
|
-
p.style.backgroundColor = i === c ?
|
|
456
|
+
p.style.backgroundColor = i === c ? Rn : "transparent";
|
|
457
457
|
}), p.addEventListener("click", () => t.onNavigate(c)), n.set(c, p), p;
|
|
458
458
|
}
|
|
459
|
-
o.append(a("home", t.labels.home,
|
|
459
|
+
o.append(a("home", t.labels.home, vr({ size: 24 })), a("history", t.labels.chats, di({ size: 24 }))), e.appendChild(o);
|
|
460
460
|
const s = (c) => {
|
|
461
461
|
i = c === "history" ? "history" : "home";
|
|
462
|
-
for (const [
|
|
463
|
-
const p =
|
|
464
|
-
p && (p.textContent =
|
|
465
|
-
const
|
|
466
|
-
|
|
462
|
+
for (const [x, f] of n) {
|
|
463
|
+
const p = f.querySelector("span");
|
|
464
|
+
p && (p.textContent = x === "home" ? t.labels.home : t.labels.chats);
|
|
465
|
+
const b = x === i;
|
|
466
|
+
f.style.color = b ? Bn : ve, f.style.backgroundColor = b ? Rn : "transparent", b ? f.setAttribute("aria-current", "page") : f.removeAttribute("aria-current");
|
|
467
467
|
}
|
|
468
468
|
};
|
|
469
469
|
return s("home"), {
|
|
@@ -474,7 +474,7 @@ function jr(t) {
|
|
|
474
474
|
}
|
|
475
475
|
};
|
|
476
476
|
}
|
|
477
|
-
function
|
|
477
|
+
function zn(t, e, o, n) {
|
|
478
478
|
const i = document.createElement("button");
|
|
479
479
|
return i.type = "button", i.className = t, i.setAttribute("aria-label", e), i.title = e, u(i, {
|
|
480
480
|
display: "flex",
|
|
@@ -497,7 +497,7 @@ function In(t, e, o, n) {
|
|
|
497
497
|
i.style.opacity = "0.8";
|
|
498
498
|
}), i.addEventListener("click", n), i.appendChild(o), i;
|
|
499
499
|
}
|
|
500
|
-
function
|
|
500
|
+
function Ur(t) {
|
|
501
501
|
const e = document.createElement("header");
|
|
502
502
|
e.className = "ago-chat-widget__header", u(e, {
|
|
503
503
|
display: "flex",
|
|
@@ -506,10 +506,10 @@ function Wr(t) {
|
|
|
506
506
|
height: "56px",
|
|
507
507
|
padding: "0 16px",
|
|
508
508
|
boxSizing: "border-box",
|
|
509
|
-
background:
|
|
510
|
-
color:
|
|
509
|
+
background: ai,
|
|
510
|
+
color: Hn,
|
|
511
511
|
borderBottom: "1px solid #e5e7eb",
|
|
512
|
-
boxShadow:
|
|
512
|
+
boxShadow: en,
|
|
513
513
|
flexShrink: "0"
|
|
514
514
|
});
|
|
515
515
|
const o = d({
|
|
@@ -517,7 +517,7 @@ function Wr(t) {
|
|
|
517
517
|
alignItems: "center",
|
|
518
518
|
gap: "12px",
|
|
519
519
|
minWidth: "0"
|
|
520
|
-
}), n =
|
|
520
|
+
}), n = zn("ago-chat-widget__back", t.labels.back, Sr({ size: 20 }), t.onBack);
|
|
521
521
|
n.style.marginRight = "-8px";
|
|
522
522
|
const i = document.createElement("span");
|
|
523
523
|
i.className = "ago-chat-widget__title", u(i, {
|
|
@@ -534,88 +534,103 @@ function Wr(t) {
|
|
|
534
534
|
alignItems: "center",
|
|
535
535
|
gap: "8px",
|
|
536
536
|
flexShrink: "0"
|
|
537
|
-
}), s =
|
|
537
|
+
}), s = zn("ago-chat-widget__new", t.labels.newChat, Xn({ size: 20 }), t.onNewChat), c = zn("ago-chat-widget__close", t.labels.close, ci({ size: 20 }), t.onClose);
|
|
538
538
|
return a.append(s, c), e.append(o, a), {
|
|
539
539
|
el: e,
|
|
540
|
-
update: ({ screen:
|
|
541
|
-
n.setAttribute("aria-label", t.labels.back), s.setAttribute("aria-label", t.labels.newChat), c.setAttribute("aria-label", t.labels.close), n.style.display =
|
|
540
|
+
update: ({ screen: x }) => {
|
|
541
|
+
n.setAttribute("aria-label", t.labels.back), s.setAttribute("aria-label", t.labels.newChat), c.setAttribute("aria-label", t.labels.close), n.style.display = x === "chat" ? "flex" : "none", s.style.display = x === "home" ? "none" : "flex", i.textContent = x === "history" ? t.labels.history : t.title;
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
|
-
var
|
|
546
|
-
...
|
|
547
|
-
timeAgo:
|
|
545
|
+
var us = {
|
|
546
|
+
...We("en").widget,
|
|
547
|
+
timeAgo: We("en").timeAgo
|
|
548
548
|
};
|
|
549
|
-
function
|
|
549
|
+
function Vo(t, e) {
|
|
550
550
|
return {
|
|
551
|
-
...Me(
|
|
552
|
-
timeAgo: Me(
|
|
551
|
+
...Me(We(e).widget, t),
|
|
552
|
+
timeAgo: Me(We(e).timeAgo, t?.timeAgo)
|
|
553
553
|
};
|
|
554
554
|
}
|
|
555
|
-
var
|
|
555
|
+
var Pr = {
|
|
556
556
|
"&": "&",
|
|
557
557
|
"<": "<",
|
|
558
558
|
">": ">",
|
|
559
559
|
'"': """,
|
|
560
560
|
"'": "'"
|
|
561
561
|
};
|
|
562
|
-
function
|
|
563
|
-
return t.replace(/[&<>"']/g, (e) =>
|
|
562
|
+
function it(t) {
|
|
563
|
+
return t.replace(/[&<>"']/g, (e) => Pr[e]);
|
|
564
564
|
}
|
|
565
|
-
function
|
|
565
|
+
function qo(t) {
|
|
566
566
|
const e = t.trim();
|
|
567
567
|
return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(e) || !/^[a-z][a-z0-9+.-]*:/i.test(e) ? e : null;
|
|
568
568
|
}
|
|
569
|
-
var
|
|
570
|
-
function
|
|
571
|
-
const e = [], o = (i) => (e.push(i), `${
|
|
569
|
+
var ui = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Qt = "";
|
|
570
|
+
function je(t) {
|
|
571
|
+
const e = [], o = (i) => (e.push(i), `${Qt}${e.length - 1}${Qt}`);
|
|
572
572
|
let n = t;
|
|
573
|
-
return n = n.replace(/`([^`]+)`/g, (i, a) => o(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${
|
|
574
|
-
const c =
|
|
575
|
-
return c ? o(`<img alt="${
|
|
573
|
+
return n = n.replace(/`([^`]+)`/g, (i, a) => o(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${ui}">${it(a)}</code>`)), n = n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (i, a, s) => {
|
|
574
|
+
const c = qo(s);
|
|
575
|
+
return c ? o(`<img alt="${it(a)}" src="${it(c)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : i;
|
|
576
576
|
}), n = n.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (i, a, s) => {
|
|
577
|
-
const c =
|
|
578
|
-
return c ? o(`<a href="${
|
|
579
|
-
}), n =
|
|
577
|
+
const c = qo(s);
|
|
578
|
+
return c ? o(`<a href="${it(c)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${je(a)}</a>`) : i;
|
|
579
|
+
}), n = it(n), n = n.replace(/\*\*([^*]+?)\*\*/g, "<strong>$1</strong>").replace(/__([^_]+?)__/g, "<strong>$1</strong>").replace(/~~([^~]+?)~~/g, "<del>$1</del>").replace(/(^|[^*])\*(?!\s)([^*]+?)\*/g, "$1<em>$2</em>").replace(/(^|[^\w_])_(?!\s)([^_]+?)_/g, "$1<em>$2</em>"), n = n.replace(new RegExp(`${Qt}(\\d+)${Qt}`, "g"), (i, a) => e[Number(a)]), n;
|
|
580
580
|
}
|
|
581
581
|
function we(t, e, o) {
|
|
582
582
|
const n = document.createElement(t);
|
|
583
583
|
return Object.assign(n.style, e), o !== void 0 && (n.innerHTML = o), n;
|
|
584
584
|
}
|
|
585
|
-
var
|
|
585
|
+
var fi = /^ {0,3}([-*_])( *\1){2,} *$/, mi = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, gi = /^ {0,3}(```+|~~~+)/, Zt = /^ {0,3}>\s?/, Ke = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Vr = [
|
|
586
586
|
"20px",
|
|
587
587
|
"18px",
|
|
588
588
|
"16px",
|
|
589
589
|
"15px",
|
|
590
590
|
"14px",
|
|
591
591
|
"13px"
|
|
592
|
-
],
|
|
593
|
-
function
|
|
594
|
-
return t.trim() === "" ||
|
|
592
|
+
], at = (t) => t.match(/^\s*/)?.[0].length ?? 0;
|
|
593
|
+
function hi(t) {
|
|
594
|
+
return t.trim() === "" || fi.test(t) || mi.test(t) || gi.test(t) || Zt.test(t) || Ke.test(t);
|
|
595
|
+
}
|
|
596
|
+
var jn = (t) => /\d/.test(t);
|
|
597
|
+
function qr(t) {
|
|
598
|
+
const e = t.filter((n) => n.trim() !== "").map(at), o = e.length > 0 ? Math.min(...e) : 0;
|
|
599
|
+
return t.map((n) => n.slice(Math.min(o, at(n))));
|
|
595
600
|
}
|
|
596
|
-
function
|
|
597
|
-
const e = t[0].match(
|
|
601
|
+
function Gr(t) {
|
|
602
|
+
const e = t[0].match(Ke), o = e[1].length, n = jn(e[2]), i = we(n ? "ol" : "ul", {
|
|
598
603
|
margin: "0 0 8px 0",
|
|
599
604
|
paddingLeft: "20px",
|
|
600
605
|
listStyleType: n ? "decimal" : "disc",
|
|
601
606
|
listStylePosition: "outside"
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
const
|
|
607
|
+
}), a = parseInt(e[2], 10);
|
|
608
|
+
n && a !== 1 && i.setAttribute("start", String(a));
|
|
609
|
+
let s = 0;
|
|
610
|
+
for (; s < t.length; ) {
|
|
611
|
+
const c = t[s].match(Ke);
|
|
612
|
+
if (s++, !c) continue;
|
|
613
|
+
const x = [];
|
|
614
|
+
for (; s < t.length && (t[s].trim() === "" || at(t[s]) > o); )
|
|
615
|
+
x.push(t[s]), s++;
|
|
616
|
+
const f = we("li", {
|
|
609
617
|
display: "list-item",
|
|
610
618
|
margin: "2px 0",
|
|
611
619
|
lineHeight: "1.6"
|
|
612
|
-
}),
|
|
613
|
-
|
|
620
|
+
}), p = c[3].match(/^\[([ xX])\]\s+(.*)$/);
|
|
621
|
+
p ? (f.style.listStyleType = "none", f.style.marginLeft = "-20px", f.innerHTML = `<span style="margin-right:6px">${p[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${je(p[2])}`) : f.innerHTML = je(c[3]);
|
|
622
|
+
const b = qr(x);
|
|
623
|
+
let F = 0;
|
|
624
|
+
for (; F < b.length && !hi(b[F]); )
|
|
625
|
+
f.innerHTML += `<br>${je(b[F])}`, F++;
|
|
626
|
+
const y = b.slice(F);
|
|
627
|
+
y.some((m) => m.trim() !== "") && f.appendChild(Ye(y.join(`
|
|
628
|
+
`))), i.appendChild(f);
|
|
614
629
|
}
|
|
615
630
|
return i;
|
|
616
631
|
}
|
|
617
|
-
function
|
|
618
|
-
const e = (c) => c.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((
|
|
632
|
+
function Xr(t) {
|
|
633
|
+
const e = (c) => c.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((x) => x.trim()), o = we("div", {
|
|
619
634
|
overflowX: "auto",
|
|
620
635
|
margin: "0 0 8px 0"
|
|
621
636
|
}), n = we("table", {
|
|
@@ -629,21 +644,21 @@ function qr(t) {
|
|
|
629
644
|
textAlign: "left",
|
|
630
645
|
backgroundColor: "#f5f7fa",
|
|
631
646
|
fontWeight: "600"
|
|
632
|
-
},
|
|
647
|
+
}, je(c)));
|
|
633
648
|
i.appendChild(a), n.appendChild(i);
|
|
634
649
|
const s = document.createElement("tbody");
|
|
635
650
|
for (const c of t.slice(2)) {
|
|
636
|
-
const
|
|
637
|
-
for (const
|
|
651
|
+
const x = document.createElement("tr");
|
|
652
|
+
for (const f of e(c)) x.appendChild(we("td", {
|
|
638
653
|
border: "1px solid #dee3e8",
|
|
639
654
|
padding: "6px 10px"
|
|
640
|
-
},
|
|
641
|
-
s.appendChild(
|
|
655
|
+
}, je(f)));
|
|
656
|
+
s.appendChild(x);
|
|
642
657
|
}
|
|
643
658
|
return n.appendChild(s), o.appendChild(n), o;
|
|
644
659
|
}
|
|
645
|
-
var
|
|
646
|
-
function
|
|
660
|
+
var Kr = (t) => !!t && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(t);
|
|
661
|
+
function Ye(t) {
|
|
647
662
|
const e = document.createDocumentFragment(), o = t.replace(/\r\n?/g, `
|
|
648
663
|
`).split(`
|
|
649
664
|
`);
|
|
@@ -654,27 +669,27 @@ function lt(t) {
|
|
|
654
669
|
n++;
|
|
655
670
|
continue;
|
|
656
671
|
}
|
|
657
|
-
const s = a.match(
|
|
672
|
+
const s = a.match(gi);
|
|
658
673
|
if (s) {
|
|
659
|
-
const
|
|
660
|
-
for (n++; n < o.length && !new RegExp(`^ {0,3}${
|
|
674
|
+
const f = s[1][0], p = [];
|
|
675
|
+
for (n++; n < o.length && !new RegExp(`^ {0,3}${f === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(o[n]); )
|
|
661
676
|
p.push(o[n]), n++;
|
|
662
677
|
n++;
|
|
663
|
-
const
|
|
664
|
-
|
|
678
|
+
const b = we("pre", { margin: "0 0 8px 0" });
|
|
679
|
+
b.appendChild(we("code", {
|
|
665
680
|
display: "block",
|
|
666
681
|
background: "#f5f5f5",
|
|
667
682
|
padding: "8px 12px",
|
|
668
683
|
borderRadius: "6px",
|
|
669
684
|
fontSize: "13px",
|
|
670
685
|
overflowX: "auto",
|
|
671
|
-
fontFamily:
|
|
686
|
+
fontFamily: ui,
|
|
672
687
|
whiteSpace: "pre"
|
|
673
|
-
},
|
|
674
|
-
`)))), e.appendChild(
|
|
688
|
+
}, it(p.join(`
|
|
689
|
+
`)))), e.appendChild(b);
|
|
675
690
|
continue;
|
|
676
691
|
}
|
|
677
|
-
if (
|
|
692
|
+
if (fi.test(a)) {
|
|
678
693
|
e.appendChild(we("hr", {
|
|
679
694
|
border: "none",
|
|
680
695
|
borderTop: "1px solid #dee3e8",
|
|
@@ -682,21 +697,21 @@ function lt(t) {
|
|
|
682
697
|
})), n++;
|
|
683
698
|
continue;
|
|
684
699
|
}
|
|
685
|
-
const c = a.match(
|
|
700
|
+
const c = a.match(mi);
|
|
686
701
|
if (c) {
|
|
687
|
-
const
|
|
688
|
-
e.appendChild(we(`h${
|
|
702
|
+
const f = c[1].length;
|
|
703
|
+
e.appendChild(we(`h${f}`, {
|
|
689
704
|
margin: "16px 0 8px 0",
|
|
690
|
-
fontSize:
|
|
705
|
+
fontSize: Vr[f - 1],
|
|
691
706
|
fontWeight: "600",
|
|
692
707
|
lineHeight: "1.3"
|
|
693
|
-
},
|
|
708
|
+
}, je(c[2]))), n++;
|
|
694
709
|
continue;
|
|
695
710
|
}
|
|
696
|
-
if (
|
|
697
|
-
const
|
|
698
|
-
for (; n < o.length &&
|
|
699
|
-
|
|
711
|
+
if (Zt.test(a)) {
|
|
712
|
+
const f = [];
|
|
713
|
+
for (; n < o.length && Zt.test(o[n]); )
|
|
714
|
+
f.push(o[n].replace(Zt, "")), n++;
|
|
700
715
|
const p = we("blockquote", {
|
|
701
716
|
borderLeft: "4px solid #dee3e8",
|
|
702
717
|
paddingLeft: "12px",
|
|
@@ -704,38 +719,47 @@ function lt(t) {
|
|
|
704
719
|
fontStyle: "italic",
|
|
705
720
|
color: "#6b6d6f"
|
|
706
721
|
});
|
|
707
|
-
p.appendChild(
|
|
722
|
+
p.appendChild(Ye(f.join(`
|
|
708
723
|
`))), e.appendChild(p);
|
|
709
724
|
continue;
|
|
710
725
|
}
|
|
711
|
-
if (a.includes("|") &&
|
|
712
|
-
const
|
|
726
|
+
if (a.includes("|") && Kr(o[n + 1])) {
|
|
727
|
+
const f = [a, o[n + 1]];
|
|
713
728
|
for (n += 2; n < o.length && o[n].includes("|") && o[n].trim(); )
|
|
714
|
-
|
|
715
|
-
e.appendChild(
|
|
729
|
+
f.push(o[n]), n++;
|
|
730
|
+
e.appendChild(Xr(f));
|
|
716
731
|
continue;
|
|
717
732
|
}
|
|
718
|
-
if (
|
|
719
|
-
const
|
|
720
|
-
for (; n < o.length
|
|
721
|
-
if (
|
|
722
|
-
|
|
733
|
+
if (Ke.test(a)) {
|
|
734
|
+
const f = [], p = at(a), b = jn(a.match(Ke)[2]);
|
|
735
|
+
for (; n < o.length; ) {
|
|
736
|
+
if (o[n].trim() === "") {
|
|
737
|
+
let F = n + 1;
|
|
738
|
+
for (; F < o.length && o[F].trim() === ""; ) F++;
|
|
739
|
+
const y = o[F], m = y?.match(Ke);
|
|
740
|
+
if (!(y !== void 0 && (at(y) > p || m && jn(m[2]) === b))) break;
|
|
741
|
+
f.push(...o.slice(n, F)), n = F;
|
|
742
|
+
continue;
|
|
743
|
+
}
|
|
744
|
+
if (Ke.test(o[n]) || at(o[n]) > p)
|
|
745
|
+
f.push(o[n]), n++;
|
|
723
746
|
else break;
|
|
724
|
-
|
|
747
|
+
}
|
|
748
|
+
e.appendChild(Gr(f));
|
|
725
749
|
continue;
|
|
726
750
|
}
|
|
727
|
-
const
|
|
728
|
-
for (n++; n < o.length && !
|
|
729
|
-
|
|
751
|
+
const x = [a];
|
|
752
|
+
for (n++; n < o.length && !hi(o[n]); )
|
|
753
|
+
x.push(o[n]), n++;
|
|
730
754
|
e.appendChild(we("p", {
|
|
731
755
|
margin: "0 0 8px 0",
|
|
732
756
|
lineHeight: "1.6"
|
|
733
|
-
},
|
|
757
|
+
}, x.map((f) => je(f)).join("<br>")));
|
|
734
758
|
}
|
|
735
759
|
const i = e.lastElementChild;
|
|
736
760
|
return i && (i.style.marginBottom = "0"), e;
|
|
737
761
|
}
|
|
738
|
-
function
|
|
762
|
+
function Yr(t, e) {
|
|
739
763
|
const o = d({
|
|
740
764
|
display: "flex",
|
|
741
765
|
flexWrap: "wrap",
|
|
@@ -746,22 +770,22 @@ function Xr(t, e) {
|
|
|
746
770
|
});
|
|
747
771
|
o.className = "ago-message__attachments";
|
|
748
772
|
for (const n of t) {
|
|
749
|
-
const i =
|
|
750
|
-
if (
|
|
773
|
+
const i = ni(n.url);
|
|
774
|
+
if (oi(n) && i) {
|
|
751
775
|
const p = document.createElement("a");
|
|
752
776
|
p.href = i, p.target = "_blank", p.rel = "noopener noreferrer", u(p, {
|
|
753
777
|
display: "inline-block",
|
|
754
778
|
textDecoration: "none"
|
|
755
779
|
});
|
|
756
|
-
const
|
|
757
|
-
|
|
780
|
+
const b = document.createElement("img");
|
|
781
|
+
b.src = i, b.alt = n.name, b.loading = "lazy", u(b, {
|
|
758
782
|
maxWidth: "180px",
|
|
759
783
|
maxHeight: "160px",
|
|
760
784
|
objectFit: "cover",
|
|
761
785
|
borderRadius: "10px",
|
|
762
786
|
border: `1px solid ${Q}`,
|
|
763
787
|
display: "block"
|
|
764
|
-
}), p.appendChild(
|
|
788
|
+
}), p.appendChild(b), o.appendChild(p);
|
|
765
789
|
continue;
|
|
766
790
|
}
|
|
767
791
|
const a = i ? document.createElement("a") : document.createElement("div");
|
|
@@ -788,26 +812,26 @@ function Xr(t, e) {
|
|
|
788
812
|
display: "flex",
|
|
789
813
|
flexDirection: "column",
|
|
790
814
|
minWidth: "0"
|
|
791
|
-
}),
|
|
815
|
+
}), x = d({
|
|
792
816
|
overflow: "hidden",
|
|
793
817
|
textOverflow: "ellipsis",
|
|
794
818
|
whiteSpace: "nowrap",
|
|
795
819
|
maxWidth: "160px"
|
|
796
820
|
});
|
|
797
|
-
|
|
798
|
-
const
|
|
799
|
-
if (
|
|
821
|
+
x.textContent = n.name, x.title = n.name, c.appendChild(x);
|
|
822
|
+
const f = ii(n.fileSize);
|
|
823
|
+
if (f) {
|
|
800
824
|
const p = d({
|
|
801
825
|
fontSize: "11px",
|
|
802
|
-
color:
|
|
826
|
+
color: st
|
|
803
827
|
});
|
|
804
|
-
p.textContent =
|
|
828
|
+
p.textContent = f, c.appendChild(p);
|
|
805
829
|
}
|
|
806
830
|
a.append(s, c), o.appendChild(a);
|
|
807
831
|
}
|
|
808
832
|
return o;
|
|
809
833
|
}
|
|
810
|
-
function
|
|
834
|
+
function bi(t, e) {
|
|
811
835
|
const o = e.look === "embed", n = d({
|
|
812
836
|
display: "flex",
|
|
813
837
|
flexWrap: "wrap",
|
|
@@ -835,7 +859,7 @@ function hi(t, e) {
|
|
|
835
859
|
minHeight: "44px",
|
|
836
860
|
padding: "6px 14px",
|
|
837
861
|
fontSize: "14px",
|
|
838
|
-
borderRadius:
|
|
862
|
+
borderRadius: on,
|
|
839
863
|
border: `1px solid ${Q}`,
|
|
840
864
|
backgroundColor: Ee,
|
|
841
865
|
color: ne,
|
|
@@ -846,32 +870,32 @@ function hi(t, e) {
|
|
|
846
870
|
a.addEventListener("click", () => s(i));
|
|
847
871
|
}
|
|
848
872
|
a.addEventListener("mouseenter", () => {
|
|
849
|
-
o ? a.style.backgroundColor = "#fafafa" : a.style.borderColor =
|
|
873
|
+
o ? a.style.backgroundColor = "#fafafa" : a.style.borderColor = ct;
|
|
850
874
|
}), a.addEventListener("mouseleave", () => {
|
|
851
875
|
o ? a.style.backgroundColor = "#fff" : a.style.borderColor = Q;
|
|
852
876
|
}), n.appendChild(a);
|
|
853
877
|
}
|
|
854
878
|
return n;
|
|
855
879
|
}
|
|
856
|
-
function
|
|
857
|
-
const { isLast: o, isLastOfBlock: n, bubbleStyle: i, showAgentName: a, agentBubble: s, followUpEnabled: c, followUpHandler:
|
|
880
|
+
function Qr(t, e) {
|
|
881
|
+
const { isLast: o, isLastOfBlock: n, bubbleStyle: i, showAgentName: a, agentBubble: s, followUpEnabled: c, followUpHandler: x, isMobile: f, feedbackRow: p } = e, b = t.role === "user", F = i === "imessage", y = d({
|
|
858
882
|
display: "flex",
|
|
859
883
|
flexDirection: "column",
|
|
860
|
-
alignItems:
|
|
861
|
-
marginBottom:
|
|
884
|
+
alignItems: b ? "flex-end" : "flex-start",
|
|
885
|
+
marginBottom: F && !n ? "2px" : "16px"
|
|
862
886
|
});
|
|
863
|
-
if (
|
|
864
|
-
const
|
|
887
|
+
if (y.className = `ago-message ago-message--${t.role}`, !b && a && t.agent) {
|
|
888
|
+
const _ = d({
|
|
865
889
|
fontSize: "13px",
|
|
866
890
|
fontWeight: "500",
|
|
867
891
|
color: ne,
|
|
868
892
|
marginBottom: "6px",
|
|
869
893
|
padding: "0 4px"
|
|
870
894
|
});
|
|
871
|
-
|
|
895
|
+
_.className = "ago-message__agent", _.textContent = t.agent.displayName || t.agent.name, y.appendChild(_);
|
|
872
896
|
}
|
|
873
|
-
if (!
|
|
874
|
-
const
|
|
897
|
+
if (!b && t.sources && t.sources.length > 0) {
|
|
898
|
+
const _ = d({
|
|
875
899
|
display: "grid",
|
|
876
900
|
gridTemplateColumns: "1fr 1fr",
|
|
877
901
|
gap: "6px",
|
|
@@ -879,9 +903,9 @@ function Kr(t, e) {
|
|
|
879
903
|
width: "100%",
|
|
880
904
|
maxWidth: "85%"
|
|
881
905
|
});
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
|
|
906
|
+
_.className = "ago-message__sources", t.sources.forEach((I, j) => {
|
|
907
|
+
const w = I.url ? document.createElement("a") : document.createElement("div");
|
|
908
|
+
I.url && w instanceof HTMLAnchorElement && (w.href = I.url, w.target = "_blank", w.rel = "noopener noreferrer"), u(w, {
|
|
885
909
|
display: "flex",
|
|
886
910
|
alignItems: "center",
|
|
887
911
|
gap: "8px",
|
|
@@ -894,13 +918,13 @@ function Kr(t, e) {
|
|
|
894
918
|
fontSize: "12px",
|
|
895
919
|
overflow: "hidden"
|
|
896
920
|
});
|
|
897
|
-
const
|
|
921
|
+
const O = d({
|
|
898
922
|
flexShrink: "0",
|
|
899
923
|
width: "18px",
|
|
900
924
|
height: "18px",
|
|
901
925
|
borderRadius: "3px",
|
|
902
|
-
border: `1px solid ${
|
|
903
|
-
color:
|
|
926
|
+
border: `1px solid ${ct}`,
|
|
927
|
+
color: ct,
|
|
904
928
|
fontSize: "11px",
|
|
905
929
|
fontWeight: "500",
|
|
906
930
|
display: "flex",
|
|
@@ -908,62 +932,62 @@ function Kr(t, e) {
|
|
|
908
932
|
justifyContent: "center",
|
|
909
933
|
backgroundColor: "#f0f4ff"
|
|
910
934
|
});
|
|
911
|
-
|
|
912
|
-
const
|
|
935
|
+
O.textContent = String(j + 1);
|
|
936
|
+
const E = d({
|
|
913
937
|
overflow: "hidden",
|
|
914
938
|
textOverflow: "ellipsis",
|
|
915
939
|
whiteSpace: "nowrap"
|
|
916
940
|
});
|
|
917
|
-
|
|
918
|
-
}),
|
|
941
|
+
E.textContent = I.title, E.title = I.title, w.append(O, E), _.appendChild(w);
|
|
942
|
+
}), y.appendChild(_);
|
|
919
943
|
}
|
|
920
|
-
if (t.attachments && t.attachments.length > 0 &&
|
|
921
|
-
isUser:
|
|
922
|
-
cardBackground:
|
|
923
|
-
cardColor:
|
|
924
|
-
})), !
|
|
925
|
-
const
|
|
926
|
-
|
|
944
|
+
if (t.attachments && t.attachments.length > 0 && y.appendChild(Yr(t.attachments, {
|
|
945
|
+
isUser: b,
|
|
946
|
+
cardBackground: b ? "rgba(255,255,255,0.12)" : Ee,
|
|
947
|
+
cardColor: b ? lt : ne
|
|
948
|
+
})), !b && e.renderToolCall && t.toolCalls?.length) for (const _ of t.toolCalls) {
|
|
949
|
+
const I = e.renderToolCall(_, t);
|
|
950
|
+
I && y.appendChild(I);
|
|
927
951
|
}
|
|
928
|
-
const
|
|
929
|
-
maxWidth:
|
|
930
|
-
padding:
|
|
931
|
-
borderRadius:
|
|
932
|
-
backgroundColor:
|
|
933
|
-
color:
|
|
952
|
+
const m = b || s || F, k = !!t.content || t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", N = d({
|
|
953
|
+
maxWidth: m ? F || b ? f ? "88%" : "75%" : f ? "92%" : "85%" : "100%",
|
|
954
|
+
padding: m ? "10px 14px" : "2px 8px",
|
|
955
|
+
borderRadius: F ? cr : m ? on : "0",
|
|
956
|
+
backgroundColor: b ? ve : m ? Dn : "transparent",
|
|
957
|
+
color: b ? lt : ne,
|
|
934
958
|
overflowWrap: "break-word",
|
|
935
959
|
textWrap: "pretty",
|
|
936
960
|
fontSize: "16px",
|
|
937
961
|
lineHeight: "1.6"
|
|
938
962
|
});
|
|
939
|
-
if (
|
|
940
|
-
|
|
941
|
-
const
|
|
963
|
+
if (N.className = "ago-message__content", F && n) {
|
|
964
|
+
N.style.position = "relative";
|
|
965
|
+
const _ = d({
|
|
942
966
|
position: "absolute",
|
|
943
967
|
zIndex: "0",
|
|
944
968
|
bottom: "-2px",
|
|
945
969
|
width: "20px",
|
|
946
970
|
height: "20px",
|
|
947
|
-
background:
|
|
971
|
+
background: b ? ve : Dn
|
|
948
972
|
});
|
|
949
|
-
|
|
950
|
-
const
|
|
973
|
+
_.className = "ago-message__tail";
|
|
974
|
+
const I = d({
|
|
951
975
|
position: "absolute",
|
|
952
976
|
zIndex: "1",
|
|
953
977
|
bottom: "-2px",
|
|
954
978
|
width: "10px",
|
|
955
979
|
height: "20px",
|
|
956
|
-
background:
|
|
980
|
+
background: si
|
|
957
981
|
});
|
|
958
|
-
|
|
982
|
+
I.className = "ago-message__tail-mask", b ? (_.style.right = "-8px", _.style.borderBottomLeftRadius = "16px 14px", I.style.right = "-10px", I.style.borderBottomLeftRadius = "10px") : (_.style.left = "-7px", _.style.borderBottomRightRadius = "16px 14px", I.style.left = "-10px", I.style.borderBottomRightRadius = "10px"), N.append(_, I);
|
|
959
983
|
}
|
|
960
|
-
return t.content ?
|
|
984
|
+
return t.content ? N.appendChild(Ye(t.content)) : (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT") && N.appendChild(Jr()), k && y.appendChild(N), !b && p && y.appendChild(p), o && t.followUpReplies && t.followUpReplies.length > 0 && y.appendChild(bi(t.followUpReplies, {
|
|
961
985
|
enabled: c,
|
|
962
|
-
handler:
|
|
986
|
+
handler: x,
|
|
963
987
|
look: "classic"
|
|
964
|
-
})),
|
|
988
|
+
})), y;
|
|
965
989
|
}
|
|
966
|
-
function
|
|
990
|
+
function Zr(t) {
|
|
967
991
|
const e = d({
|
|
968
992
|
display: "flex",
|
|
969
993
|
alignItems: "center",
|
|
@@ -971,7 +995,7 @@ function Yr(t) {
|
|
|
971
995
|
padding: "10px 14px",
|
|
972
996
|
backgroundColor: "#f0fdf4",
|
|
973
997
|
color: "#15803d",
|
|
974
|
-
borderRadius:
|
|
998
|
+
borderRadius: on,
|
|
975
999
|
marginTop: "8px",
|
|
976
1000
|
fontSize: "13px",
|
|
977
1001
|
border: "1px solid #bbf7d0"
|
|
@@ -982,7 +1006,7 @@ function Yr(t) {
|
|
|
982
1006
|
const n = document.createElement("span");
|
|
983
1007
|
return n.textContent = t, e.append(o, n), e;
|
|
984
1008
|
}
|
|
985
|
-
function
|
|
1009
|
+
function Jr() {
|
|
986
1010
|
const t = d({
|
|
987
1011
|
display: "flex",
|
|
988
1012
|
gap: "4px",
|
|
@@ -1002,13 +1026,13 @@ function Qr() {
|
|
|
1002
1026
|
}
|
|
1003
1027
|
return t;
|
|
1004
1028
|
}
|
|
1005
|
-
function
|
|
1029
|
+
function ea() {
|
|
1006
1030
|
const t = "http://www.w3.org/2000/svg", e = document.createElementNS(t, "svg");
|
|
1007
1031
|
e.setAttribute("width", "26"), e.setAttribute("height", "26"), e.setAttribute("viewBox", "0 0 24 24"), e.setAttribute("fill", "none");
|
|
1008
1032
|
const o = document.createElementNS(t, "path");
|
|
1009
1033
|
return o.setAttribute("d", "M21 11.5a8.38 8.38 0 0 1-8.5 8.5 8.5 8.5 0 0 1-3.8-.9L3 21l1.9-5.7a8.5 8.5 0 0 1-.9-3.8 8.38 8.38 0 0 1 8.5-8.5 8.38 8.38 0 0 1 8.5 8.5z"), o.setAttribute("stroke", "currentColor"), o.setAttribute("stroke-width", "2"), o.setAttribute("stroke-linecap", "round"), o.setAttribute("stroke-linejoin", "round"), e.appendChild(o), e;
|
|
1010
1034
|
}
|
|
1011
|
-
function
|
|
1035
|
+
function ta(t) {
|
|
1012
1036
|
const e = document.createElement("button");
|
|
1013
1037
|
if (e.type = "button", e.className = "ago-chat-widget-launcher", e.setAttribute("aria-label", t.labels?.open ?? `Open ${t.title}`), e.setAttribute("aria-expanded", "false"), t.look === "classic") {
|
|
1014
1038
|
if (u(e, {
|
|
@@ -1020,7 +1044,7 @@ function Jr(t) {
|
|
|
1020
1044
|
borderRadius: "50%",
|
|
1021
1045
|
border: "none",
|
|
1022
1046
|
backgroundColor: ve,
|
|
1023
|
-
color:
|
|
1047
|
+
color: lt,
|
|
1024
1048
|
cursor: "pointer",
|
|
1025
1049
|
display: "flex",
|
|
1026
1050
|
alignItems: "center",
|
|
@@ -1035,7 +1059,7 @@ function Jr(t) {
|
|
|
1035
1059
|
height: "26px",
|
|
1036
1060
|
objectFit: "contain"
|
|
1037
1061
|
}), e.appendChild(i);
|
|
1038
|
-
} else e.appendChild(
|
|
1062
|
+
} else e.appendChild(ea());
|
|
1039
1063
|
return e.addEventListener("click", t.onClick), {
|
|
1040
1064
|
el: e,
|
|
1041
1065
|
setOpen: (i) => {
|
|
@@ -1054,8 +1078,8 @@ function Jr(t) {
|
|
|
1054
1078
|
boxSizing: "border-box",
|
|
1055
1079
|
border: "none",
|
|
1056
1080
|
borderRadius: "50%",
|
|
1057
|
-
backgroundColor:
|
|
1058
|
-
color:
|
|
1081
|
+
backgroundColor: pr,
|
|
1082
|
+
color: fr,
|
|
1059
1083
|
display: "flex",
|
|
1060
1084
|
alignItems: "center",
|
|
1061
1085
|
justifyContent: "center",
|
|
@@ -1080,9 +1104,9 @@ function Jr(t) {
|
|
|
1080
1104
|
width: "32px",
|
|
1081
1105
|
height: "32px",
|
|
1082
1106
|
objectFit: "contain"
|
|
1083
|
-
}), o = i, n =
|
|
1107
|
+
}), o = i, n = wr(), e.append(i, n);
|
|
1084
1108
|
} else {
|
|
1085
|
-
const i =
|
|
1109
|
+
const i = gr();
|
|
1086
1110
|
o = i.querySelector('[data-ago-path="open"]'), n = i.querySelector('[data-ago-path="close"]'), e.appendChild(i);
|
|
1087
1111
|
}
|
|
1088
1112
|
return n.style.display = "none", e.addEventListener("click", t.onClick), {
|
|
@@ -1092,7 +1116,7 @@ function Jr(t) {
|
|
|
1092
1116
|
}
|
|
1093
1117
|
};
|
|
1094
1118
|
}
|
|
1095
|
-
function
|
|
1119
|
+
function na(t) {
|
|
1096
1120
|
const e = d({
|
|
1097
1121
|
marginBottom: "12px",
|
|
1098
1122
|
display: "flex",
|
|
@@ -1101,7 +1125,7 @@ function ea(t) {
|
|
|
1101
1125
|
});
|
|
1102
1126
|
e.className = "ago-message__attachments";
|
|
1103
1127
|
for (const o of t.attachments ?? []) {
|
|
1104
|
-
const n =
|
|
1128
|
+
const n = ni(o.url), i = d({
|
|
1105
1129
|
display: "flex",
|
|
1106
1130
|
alignItems: "center",
|
|
1107
1131
|
gap: "8px",
|
|
@@ -1113,7 +1137,7 @@ function ea(t) {
|
|
|
1113
1137
|
maxWidth: "100%",
|
|
1114
1138
|
boxSizing: "border-box"
|
|
1115
1139
|
});
|
|
1116
|
-
if (
|
|
1140
|
+
if (oi(o) && n) {
|
|
1117
1141
|
const a = document.createElement("a");
|
|
1118
1142
|
a.href = n, a.target = "_blank", a.rel = "noopener noreferrer", u(a, {
|
|
1119
1143
|
display: "flex",
|
|
@@ -1156,15 +1180,15 @@ function ea(t) {
|
|
|
1156
1180
|
overflow: "hidden",
|
|
1157
1181
|
textOverflow: "ellipsis",
|
|
1158
1182
|
whiteSpace: "nowrap"
|
|
1159
|
-
}), a.append(
|
|
1160
|
-
const c =
|
|
1183
|
+
}), a.append(Tr({ size: 20 }), s);
|
|
1184
|
+
const c = ii(o.fileSize);
|
|
1161
1185
|
if (c) {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1186
|
+
const x = document.createElement("span");
|
|
1187
|
+
x.textContent = c, u(x, {
|
|
1164
1188
|
fontSize: "12px",
|
|
1165
1189
|
lineHeight: "16px",
|
|
1166
1190
|
color: "#6b7280"
|
|
1167
|
-
}), a.appendChild(
|
|
1191
|
+
}), a.appendChild(x);
|
|
1168
1192
|
}
|
|
1169
1193
|
i.appendChild(a);
|
|
1170
1194
|
}
|
|
@@ -1172,7 +1196,7 @@ function ea(t) {
|
|
|
1172
1196
|
}
|
|
1173
1197
|
return e;
|
|
1174
1198
|
}
|
|
1175
|
-
function
|
|
1199
|
+
function oa(t) {
|
|
1176
1200
|
const e = d({
|
|
1177
1201
|
display: "flex",
|
|
1178
1202
|
justifyContent: "flex-end"
|
|
@@ -1181,20 +1205,20 @@ function ta(t) {
|
|
|
1181
1205
|
borderRadius: "16px",
|
|
1182
1206
|
marginBottom: "16px",
|
|
1183
1207
|
padding: "16px",
|
|
1184
|
-
backgroundColor:
|
|
1185
|
-
color:
|
|
1208
|
+
backgroundColor: Cr,
|
|
1209
|
+
color: Or,
|
|
1186
1210
|
boxSizing: "border-box",
|
|
1187
1211
|
fontSize: "14px",
|
|
1188
1212
|
lineHeight: "24px"
|
|
1189
1213
|
});
|
|
1190
|
-
o.className = "ago-message__content", t.attachments?.length && o.appendChild(
|
|
1214
|
+
o.className = "ago-message__content", t.attachments?.length && o.appendChild(na(t));
|
|
1191
1215
|
const n = d({
|
|
1192
1216
|
whiteSpace: "pre-wrap",
|
|
1193
1217
|
overflowWrap: "break-word"
|
|
1194
1218
|
});
|
|
1195
1219
|
return n.textContent = t.content, o.appendChild(n), e.appendChild(o), e;
|
|
1196
1220
|
}
|
|
1197
|
-
function
|
|
1221
|
+
function ia(t) {
|
|
1198
1222
|
const e = d({
|
|
1199
1223
|
display: "grid",
|
|
1200
1224
|
gridTemplateColumns: "1fr 1fr",
|
|
@@ -1209,10 +1233,10 @@ function na(t) {
|
|
|
1209
1233
|
height: "48px",
|
|
1210
1234
|
justifyContent: "flex-start",
|
|
1211
1235
|
padding: "8px 16px",
|
|
1212
|
-
border: `1px solid ${
|
|
1236
|
+
border: `1px solid ${ri}`,
|
|
1213
1237
|
backgroundColor: "#fff",
|
|
1214
1238
|
borderRadius: "6px",
|
|
1215
|
-
boxShadow:
|
|
1239
|
+
boxShadow: en,
|
|
1216
1240
|
fontSize: "14px",
|
|
1217
1241
|
fontWeight: "500",
|
|
1218
1242
|
color: ne,
|
|
@@ -1236,9 +1260,9 @@ function na(t) {
|
|
|
1236
1260
|
width: "16px",
|
|
1237
1261
|
height: "16px",
|
|
1238
1262
|
borderRadius: "4px",
|
|
1239
|
-
border: `1px solid ${
|
|
1240
|
-
color:
|
|
1241
|
-
backgroundColor:
|
|
1263
|
+
border: `1px solid ${Bn}`,
|
|
1264
|
+
color: Bn,
|
|
1265
|
+
backgroundColor: pi,
|
|
1242
1266
|
fontSize: "12px",
|
|
1243
1267
|
lineHeight: "1",
|
|
1244
1268
|
display: "flex",
|
|
@@ -1257,13 +1281,13 @@ function na(t) {
|
|
|
1257
1281
|
c.textContent = o.title, c.title = o.title, a.append(s, c), i.appendChild(a), e.appendChild(i);
|
|
1258
1282
|
}), e;
|
|
1259
1283
|
}
|
|
1260
|
-
function
|
|
1261
|
-
return
|
|
1284
|
+
function Go(t, e) {
|
|
1285
|
+
return xi({
|
|
1262
1286
|
errorTitle: t,
|
|
1263
1287
|
errorDescription: e
|
|
1264
1288
|
});
|
|
1265
1289
|
}
|
|
1266
|
-
function
|
|
1290
|
+
function xi(t) {
|
|
1267
1291
|
const e = d({
|
|
1268
1292
|
position: "relative",
|
|
1269
1293
|
width: "100%",
|
|
@@ -1277,7 +1301,7 @@ function bi(t) {
|
|
|
1277
1301
|
boxSizing: "border-box"
|
|
1278
1302
|
});
|
|
1279
1303
|
e.className = "ago-message__error", e.setAttribute("role", "alert");
|
|
1280
|
-
const o =
|
|
1304
|
+
const o = Er({ size: 16 });
|
|
1281
1305
|
u(o, {
|
|
1282
1306
|
position: "absolute",
|
|
1283
1307
|
left: "16px",
|
|
@@ -1297,7 +1321,7 @@ function bi(t) {
|
|
|
1297
1321
|
});
|
|
1298
1322
|
return i.textContent = t.errorDescription, e.append(o, n, i), e;
|
|
1299
1323
|
}
|
|
1300
|
-
function
|
|
1324
|
+
function ra() {
|
|
1301
1325
|
const t = d({
|
|
1302
1326
|
marginTop: "4px",
|
|
1303
1327
|
animation: "ago-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"
|
|
@@ -1312,7 +1336,7 @@ function oa() {
|
|
|
1312
1336
|
});
|
|
1313
1337
|
return t.appendChild(e), t;
|
|
1314
1338
|
}
|
|
1315
|
-
function
|
|
1339
|
+
function aa() {
|
|
1316
1340
|
const t = d({
|
|
1317
1341
|
display: "flex",
|
|
1318
1342
|
alignItems: "center",
|
|
@@ -1320,13 +1344,13 @@ function ia() {
|
|
|
1320
1344
|
gap: "8px"
|
|
1321
1345
|
});
|
|
1322
1346
|
t.className = "ago-message__spinner";
|
|
1323
|
-
const e =
|
|
1347
|
+
const e = Br({ size: 20 });
|
|
1324
1348
|
return u(e, {
|
|
1325
1349
|
color: "#a1a1aa",
|
|
1326
1350
|
animation: "ago-spin 1s linear infinite"
|
|
1327
1351
|
}), t.appendChild(e), t;
|
|
1328
1352
|
}
|
|
1329
|
-
function
|
|
1353
|
+
function sa(t, e) {
|
|
1330
1354
|
const o = t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT", n = d({
|
|
1331
1355
|
position: "relative",
|
|
1332
1356
|
display: "flex",
|
|
@@ -1336,7 +1360,7 @@ function ra(t, e) {
|
|
|
1336
1360
|
marginBottom: "16px",
|
|
1337
1361
|
boxSizing: "border-box"
|
|
1338
1362
|
});
|
|
1339
|
-
n.className = "ago-message__row", e.agentRowTinted && (n.style.backgroundColor =
|
|
1363
|
+
n.className = "ago-message__row", e.agentRowTinted && (n.style.backgroundColor = Dn), e.agentRowTextTinted && (n.style.color = dr);
|
|
1340
1364
|
const i = d({
|
|
1341
1365
|
flex: "1",
|
|
1342
1366
|
minWidth: "0",
|
|
@@ -1345,47 +1369,47 @@ function ra(t, e) {
|
|
|
1345
1369
|
fontSize: "14px",
|
|
1346
1370
|
lineHeight: "24px"
|
|
1347
1371
|
});
|
|
1348
|
-
if (i.className = "ago-message__body", o && i.appendChild(
|
|
1372
|
+
if (i.className = "ago-message__body", o && i.appendChild(aa()), t.sources?.length && i.appendChild(ia(t)), e.renderToolCall && t.toolCalls?.length) for (const a of t.toolCalls) {
|
|
1349
1373
|
const s = e.renderToolCall(a, t);
|
|
1350
1374
|
s && i.appendChild(s);
|
|
1351
1375
|
}
|
|
1352
|
-
if (t.status === "ERROR") i.appendChild(
|
|
1376
|
+
if (t.status === "ERROR") i.appendChild(xi(e.labels));
|
|
1353
1377
|
else if (t.content) {
|
|
1354
1378
|
const a = d({});
|
|
1355
|
-
a.className = "ago-message__markdown ago-message__content", a.appendChild(
|
|
1356
|
-
} else o && i.appendChild(
|
|
1357
|
-
return e.isLast && t.status === "DONE" && t.followUpReplies?.length && i.appendChild(
|
|
1379
|
+
a.className = "ago-message__markdown ago-message__content", a.appendChild(Ye(t.content)), i.appendChild(a);
|
|
1380
|
+
} else o && i.appendChild(ra());
|
|
1381
|
+
return e.isLast && t.status === "DONE" && t.followUpReplies?.length && i.appendChild(bi(t.followUpReplies, {
|
|
1358
1382
|
enabled: e.followUpEnabled,
|
|
1359
1383
|
handler: e.followUpHandler,
|
|
1360
1384
|
look: "embed"
|
|
1361
1385
|
})), e.actionsRow && !o && i.appendChild(e.actionsRow), n.appendChild(i), n;
|
|
1362
1386
|
}
|
|
1363
|
-
function
|
|
1387
|
+
function la(t, e) {
|
|
1364
1388
|
const o = d({});
|
|
1365
|
-
return o.className = `ago-message ago-message--${t.role}`, o.dataset.messageId = t.id, o.dataset.messageRole = t.role, o.appendChild(t.role === "user" ?
|
|
1389
|
+
return o.className = `ago-message ago-message--${t.role}`, o.dataset.messageId = t.id, o.dataset.messageRole = t.role, o.appendChild(t.role === "user" ? oa(t) : sa(t, e)), o;
|
|
1366
1390
|
}
|
|
1367
|
-
var
|
|
1368
|
-
function
|
|
1391
|
+
var Wn = "ago-hs-form-ready";
|
|
1392
|
+
function ca(t, e) {
|
|
1369
1393
|
const o = t.tagName === "TEXTAREA" ? Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value") : Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value"), n = t._valueTracker;
|
|
1370
1394
|
n && n.setValue(""), t.focus(), t.dispatchEvent(new Event("focus", { bubbles: !0 })), o?.set ? o.set.call(t, e) : t.value = e, t.setAttribute("value", e), t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 })), t.dispatchEvent(new Event("blur", { bubbles: !0 }));
|
|
1371
1395
|
}
|
|
1372
|
-
function
|
|
1396
|
+
function tn(t, e) {
|
|
1373
1397
|
const o = t.querySelectorAll("input, textarea, select");
|
|
1374
1398
|
let n = !1;
|
|
1375
1399
|
for (const i of o) {
|
|
1376
1400
|
if (i.type === "hidden" || i.type === "submit" || i.type === "button") continue;
|
|
1377
1401
|
const a = e[i.name] ?? (i.name.includes("/") ? e[i.name.split("/").pop()] : void 0);
|
|
1378
|
-
a && !i.value && (
|
|
1402
|
+
a && !i.value && (ca(i, a), n = !0);
|
|
1379
1403
|
}
|
|
1380
1404
|
return n;
|
|
1381
1405
|
}
|
|
1382
|
-
function
|
|
1383
|
-
return `function($f){document.dispatchEvent(new CustomEvent(${JSON.stringify(
|
|
1406
|
+
function da(t) {
|
|
1407
|
+
return `function($f){document.dispatchEvent(new CustomEvent(${JSON.stringify(Wn)},{detail:{token:${JSON.stringify(t)},form:$f}}))}`;
|
|
1384
1408
|
}
|
|
1385
|
-
function
|
|
1386
|
-
return !t || !e || Object.keys(e).length === 0 ? t : /hbspt\.forms\.create\s*\(\s*\{/.test(t) && !/onFormReady/.test(t) ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormReady:${
|
|
1409
|
+
function pa(t, e, o) {
|
|
1410
|
+
return !t || !e || Object.keys(e).length === 0 ? t : /hbspt\.forms\.create\s*\(\s*\{/.test(t) && !/onFormReady/.test(t) ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormReady:${da(o)},`) : t;
|
|
1387
1411
|
}
|
|
1388
|
-
function
|
|
1412
|
+
function ua(t, e) {
|
|
1389
1413
|
if (!t || Object.keys(t).length === 0) return () => {
|
|
1390
1414
|
};
|
|
1391
1415
|
const o = {};
|
|
@@ -1393,25 +1417,25 @@ function da(t, e) {
|
|
|
1393
1417
|
const n = [], i = [], a = (s) => {
|
|
1394
1418
|
const c = s.detail;
|
|
1395
1419
|
if (!c || c.token !== e) return;
|
|
1396
|
-
const
|
|
1397
|
-
if (!
|
|
1398
|
-
|
|
1420
|
+
const x = c.form, f = x && typeof x == "object" && "jquery" in x && x.jquery ? x[0] : x;
|
|
1421
|
+
if (!f || typeof f.querySelectorAll != "function") return;
|
|
1422
|
+
tn(f, o);
|
|
1399
1423
|
const p = new MutationObserver(() => {
|
|
1400
|
-
|
|
1424
|
+
tn(f, o);
|
|
1401
1425
|
});
|
|
1402
|
-
p.observe(
|
|
1426
|
+
p.observe(f, {
|
|
1403
1427
|
childList: !0,
|
|
1404
1428
|
subtree: !0
|
|
1405
1429
|
}), n.push(p), i.push(setTimeout(() => p.disconnect(), 1e4));
|
|
1406
1430
|
};
|
|
1407
|
-
return document.addEventListener(
|
|
1408
|
-
document.removeEventListener(
|
|
1431
|
+
return document.addEventListener(Wn, a), () => {
|
|
1432
|
+
document.removeEventListener(Wn, a), n.forEach((s) => s.disconnect()), i.forEach((s) => clearTimeout(s));
|
|
1409
1433
|
};
|
|
1410
1434
|
}
|
|
1411
|
-
function
|
|
1435
|
+
function yi() {
|
|
1412
1436
|
return globalThis.HubSpotFormsV4;
|
|
1413
1437
|
}
|
|
1414
|
-
async function
|
|
1438
|
+
async function Ci(t, e) {
|
|
1415
1439
|
let o = null;
|
|
1416
1440
|
if (t.getFormFieldValues) try {
|
|
1417
1441
|
const n = await t.getFormFieldValues();
|
|
@@ -1434,28 +1458,28 @@ async function yi(t, e) {
|
|
|
1434
1458
|
}
|
|
1435
1459
|
}
|
|
1436
1460
|
}
|
|
1437
|
-
function
|
|
1461
|
+
function Xo(t) {
|
|
1438
1462
|
if (!t || Object.keys(t).length === 0) return () => {
|
|
1439
1463
|
};
|
|
1440
1464
|
const e = (o) => {
|
|
1441
1465
|
try {
|
|
1442
|
-
const n =
|
|
1466
|
+
const n = yi()?.getFormFromEvent?.(o);
|
|
1443
1467
|
if (!n?.setFieldValue) return;
|
|
1444
|
-
|
|
1468
|
+
Ci(n, t);
|
|
1445
1469
|
} catch {
|
|
1446
1470
|
}
|
|
1447
1471
|
};
|
|
1448
1472
|
return window.addEventListener("hs-form-event:on-ready", e), () => window.removeEventListener("hs-form-event:on-ready", e);
|
|
1449
1473
|
}
|
|
1450
|
-
function
|
|
1451
|
-
const e =
|
|
1474
|
+
function fa(t) {
|
|
1475
|
+
const e = yi()?.getForms?.();
|
|
1452
1476
|
if (!Array.isArray(e) || e.length === 0) return !1;
|
|
1453
1477
|
for (const o of e)
|
|
1454
|
-
o?.setFieldValue &&
|
|
1478
|
+
o?.setFieldValue && Ci(o, t);
|
|
1455
1479
|
return !0;
|
|
1456
1480
|
}
|
|
1457
|
-
var
|
|
1458
|
-
function
|
|
1481
|
+
var Un = "ago-hs-form-submit", Pn = "ago-hs-form-submitted";
|
|
1482
|
+
function Jt(t) {
|
|
1459
1483
|
if (!t || typeof t != "object") return t;
|
|
1460
1484
|
let e;
|
|
1461
1485
|
if (Array.isArray(t)) {
|
|
@@ -1469,7 +1493,7 @@ function Zt(t) {
|
|
|
1469
1493
|
}
|
|
1470
1494
|
return Object.keys(o).length > 0 ? o : null;
|
|
1471
1495
|
}
|
|
1472
|
-
function
|
|
1496
|
+
function ma(t) {
|
|
1473
1497
|
try {
|
|
1474
1498
|
const e = new FormData(t), o = {};
|
|
1475
1499
|
return e.forEach((n, i) => {
|
|
@@ -1479,131 +1503,131 @@ function ua(t) {
|
|
|
1479
1503
|
return null;
|
|
1480
1504
|
}
|
|
1481
1505
|
}
|
|
1482
|
-
function
|
|
1506
|
+
function Ko(t, e, o) {
|
|
1483
1507
|
const n = o ? `{token:${JSON.stringify(e)},form:$f}` : `{token:${JSON.stringify(e)}}`;
|
|
1484
1508
|
return `function(${o ? "$f" : ""}){document.dispatchEvent(new CustomEvent(${JSON.stringify(t)},{detail:${n}}))}`;
|
|
1485
1509
|
}
|
|
1486
|
-
function
|
|
1487
|
-
return t && (/hbspt\.forms\.create\s*\(\s*\{/.test(t) && !t.includes("ago-hs-form-submitted") ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormSubmit:${
|
|
1510
|
+
function ga(t, e) {
|
|
1511
|
+
return t && (/hbspt\.forms\.create\s*\(\s*\{/.test(t) && !t.includes("ago-hs-form-submitted") ? t.replace(/hbspt\.forms\.create\s*\(\s*\{/g, `hbspt.forms.create({onFormSubmit:${Ko(Un, e, !0)},onFormSubmitted:${Ko(Pn, e, !1)},`) : t);
|
|
1488
1512
|
}
|
|
1489
|
-
function
|
|
1513
|
+
function ha(t, e, o, n) {
|
|
1490
1514
|
let i = !1, a = null;
|
|
1491
1515
|
function s() {
|
|
1492
|
-
i || (i = !0, e(
|
|
1516
|
+
i || (i = !0, e(Jt(a)));
|
|
1493
1517
|
}
|
|
1494
|
-
function c(
|
|
1495
|
-
if (a || (a =
|
|
1518
|
+
function c(m) {
|
|
1519
|
+
if (a || (a = ma(m)), m.closest(".hs-form, .hbspt-form, [data-hs-forms]")) {
|
|
1496
1520
|
o?.();
|
|
1497
1521
|
return;
|
|
1498
1522
|
}
|
|
1499
1523
|
s();
|
|
1500
1524
|
}
|
|
1501
|
-
const
|
|
1502
|
-
const
|
|
1503
|
-
|
|
1525
|
+
const x = (m) => {
|
|
1526
|
+
const k = m.target;
|
|
1527
|
+
k?.tagName === "FORM" && c(k);
|
|
1504
1528
|
};
|
|
1505
|
-
t.addEventListener("submit",
|
|
1506
|
-
const
|
|
1507
|
-
function p(
|
|
1508
|
-
|
|
1529
|
+
t.addEventListener("submit", x, !0);
|
|
1530
|
+
const f = /* @__PURE__ */ new WeakSet();
|
|
1531
|
+
function p(m) {
|
|
1532
|
+
f.has(m) || (f.add(m), m.addEventListener("submit", () => c(m)));
|
|
1509
1533
|
}
|
|
1510
|
-
for (const
|
|
1511
|
-
const
|
|
1512
|
-
for (const
|
|
1534
|
+
for (const m of t.querySelectorAll("form")) p(m);
|
|
1535
|
+
const b = new MutationObserver(() => {
|
|
1536
|
+
for (const m of t.querySelectorAll("form")) p(m);
|
|
1513
1537
|
});
|
|
1514
|
-
|
|
1538
|
+
b.observe(t, {
|
|
1515
1539
|
childList: !0,
|
|
1516
1540
|
subtree: !0
|
|
1517
1541
|
});
|
|
1518
|
-
const
|
|
1519
|
-
const
|
|
1520
|
-
if (!(!
|
|
1542
|
+
const F = (m) => {
|
|
1543
|
+
const k = m.detail;
|
|
1544
|
+
if (!(!k || k.token !== n))
|
|
1521
1545
|
try {
|
|
1522
|
-
const
|
|
1523
|
-
if (
|
|
1524
|
-
const
|
|
1525
|
-
for (const
|
|
1546
|
+
const N = k.form, _ = N && typeof N == "object" && "jquery" in N && N.jquery ? N[0] : N;
|
|
1547
|
+
if (_?.querySelectorAll) {
|
|
1548
|
+
const I = _.querySelectorAll("input, textarea, select"), j = {};
|
|
1549
|
+
for (const w of I) w.name && w.type !== "submit" && w.type !== "button" && (j[w.name] = w.value || "");
|
|
1526
1550
|
Object.keys(j).length > 0 && (a = j);
|
|
1527
1551
|
}
|
|
1528
1552
|
} catch {
|
|
1529
1553
|
}
|
|
1530
|
-
},
|
|
1531
|
-
const
|
|
1532
|
-
!
|
|
1554
|
+
}, y = (m) => {
|
|
1555
|
+
const k = m.detail;
|
|
1556
|
+
!k || k.token !== n || s();
|
|
1533
1557
|
};
|
|
1534
|
-
return document.addEventListener(
|
|
1535
|
-
t.removeEventListener("submit",
|
|
1558
|
+
return document.addEventListener(Un, F), document.addEventListener(Pn, y), () => {
|
|
1559
|
+
t.removeEventListener("submit", x, !0), b.disconnect(), document.removeEventListener(Un, F), document.removeEventListener(Pn, y);
|
|
1536
1560
|
};
|
|
1537
1561
|
}
|
|
1538
|
-
function
|
|
1562
|
+
function me(t) {
|
|
1539
1563
|
return t.externalId || t.id;
|
|
1540
1564
|
}
|
|
1541
|
-
function
|
|
1565
|
+
function wi(t) {
|
|
1542
1566
|
return t.conditionalFieldValues?.length ? t.conditionalFieldValues : t.conditionalFieldValue?.split(",").map((e) => e.trim()).filter(Boolean) ?? [];
|
|
1543
1567
|
}
|
|
1544
|
-
function
|
|
1568
|
+
function vi(t, e) {
|
|
1545
1569
|
return !t.priorityTypologies?.length || !e || t.priorityTypologies.includes(e);
|
|
1546
1570
|
}
|
|
1547
|
-
function
|
|
1571
|
+
function Ei(t, e, o, n, i, a) {
|
|
1548
1572
|
if (!e || !o.length) return !0;
|
|
1549
1573
|
const s = t.fields.find((c) => c.id === e || c.externalId === e);
|
|
1550
|
-
return s ?
|
|
1574
|
+
return s ? rn(t, s, n, i, a) && o.includes(n[me(s)]) : !0;
|
|
1551
1575
|
}
|
|
1552
|
-
function
|
|
1576
|
+
function rn(t, e, o, n = "", i = /* @__PURE__ */ new Set()) {
|
|
1553
1577
|
if (e.active === !1 || i.has(e.id)) return !1;
|
|
1554
1578
|
const a = new Set(i).add(e.id);
|
|
1555
|
-
return
|
|
1579
|
+
return Ei(t, e.conditionalFieldId, wi(e), o, n, a);
|
|
1556
1580
|
}
|
|
1557
|
-
function
|
|
1558
|
-
return e.options.filter((i) =>
|
|
1581
|
+
function ki(t, e, o, n = "") {
|
|
1582
|
+
return e.options.filter((i) => Ei(t, i.conditionalFieldId, i.conditionalFieldValues ?? [], o, n, /* @__PURE__ */ new Set())).sort((i, a) => (i.position ?? 0) - (a.position ?? 0));
|
|
1559
1583
|
}
|
|
1560
|
-
function
|
|
1584
|
+
function rt(t, e, o = "") {
|
|
1561
1585
|
let n;
|
|
1562
1586
|
do {
|
|
1563
1587
|
n = !1;
|
|
1564
1588
|
for (const i of t.fields) {
|
|
1565
|
-
const a =
|
|
1589
|
+
const a = me(i);
|
|
1566
1590
|
if (!(a in e)) continue;
|
|
1567
|
-
const s = !i.options.length || !e[a] ||
|
|
1568
|
-
(!
|
|
1591
|
+
const s = !i.options.length || !e[a] || ki(t, i, e, o).some((c) => (c.value ?? c.name ?? "") === e[a]);
|
|
1592
|
+
(!rn(t, i, e, o) || !s) && (delete e[a], n = !0);
|
|
1569
1593
|
}
|
|
1570
1594
|
} while (n);
|
|
1571
1595
|
}
|
|
1572
|
-
function
|
|
1573
|
-
const n = [...t.fields].sort((i, a) => i.position - a.position).filter((i) => !i.hidden &&
|
|
1596
|
+
function ba(t, e, o = "") {
|
|
1597
|
+
const n = [...t.fields].sort((i, a) => i.position - a.position).filter((i) => !i.hidden && rn(t, i, e, o));
|
|
1574
1598
|
return n.filter((i, a) => {
|
|
1575
|
-
if (a === 0 || i.alwaysVisible || i.conditionalFieldId &&
|
|
1599
|
+
if (a === 0 || i.alwaysVisible || i.conditionalFieldId && wi(i).length) return !0;
|
|
1576
1600
|
const s = n[a - 1];
|
|
1577
|
-
return s.type === "checkbox" || !!e[
|
|
1601
|
+
return s.type === "checkbox" || !!e[me(s)]?.trim();
|
|
1578
1602
|
});
|
|
1579
1603
|
}
|
|
1580
|
-
var
|
|
1581
|
-
function
|
|
1582
|
-
return Me(Me(
|
|
1604
|
+
var xa = Gn.form;
|
|
1605
|
+
function Yo(t, e) {
|
|
1606
|
+
return Me(Me(xa, t), e);
|
|
1583
1607
|
}
|
|
1584
|
-
function
|
|
1608
|
+
function nn(t, e) {
|
|
1585
1609
|
return t.replace(/(?<!\{)\{(\w+)\}(?!\})/g, (o, n) => Object.prototype.hasOwnProperty.call(e, n) ? e[n] : o);
|
|
1586
1610
|
}
|
|
1587
|
-
var
|
|
1588
|
-
function
|
|
1611
|
+
var ya = "var(--ago-send-button-background, var(--ago-accent-color, #003edf))", Ca = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z]{2,}$/;
|
|
1612
|
+
function wa(t) {
|
|
1589
1613
|
return t.toLowerCase().trim().replace(/[^a-z0-9_]/g, "_");
|
|
1590
1614
|
}
|
|
1591
|
-
function
|
|
1615
|
+
function Kn(t, e, o) {
|
|
1592
1616
|
const n = {};
|
|
1593
1617
|
if (e) {
|
|
1594
1618
|
for (const i of e.fields) {
|
|
1595
1619
|
if (i.active === !1) continue;
|
|
1596
1620
|
const a = i.options.find((s) => s.default);
|
|
1597
|
-
a && (n[
|
|
1621
|
+
a && (n[me(i)] = a.value ?? a.name ?? "");
|
|
1598
1622
|
}
|
|
1599
1623
|
if (t?.tag)
|
|
1600
|
-
for (const i of e.fields) i.type === "tagger" && (n[
|
|
1624
|
+
for (const i of e.fields) i.type === "tagger" && (n[me(i)] = t.tag);
|
|
1601
1625
|
if (t?.custom_fields) for (const [i, a] of Object.entries(t.custom_fields)) {
|
|
1602
|
-
const s = e.fields.find((c) => c.externalId === i || c.id === i || (c.prefillAliases?.length ? c.prefillAliases.includes(i) : c.title ?
|
|
1603
|
-
s && (n[
|
|
1626
|
+
const s = e.fields.find((c) => c.externalId === i || c.id === i || (c.prefillAliases?.length ? c.prefillAliases.includes(i) : c.title ? wa(c.title) === i : !1));
|
|
1627
|
+
s && (n[me(s)] = a);
|
|
1604
1628
|
}
|
|
1605
1629
|
}
|
|
1606
|
-
return e &&
|
|
1630
|
+
return e && rt(e, n, t?.typology ?? "Question"), {
|
|
1607
1631
|
ticket: {
|
|
1608
1632
|
subject: t?.subject ?? "",
|
|
1609
1633
|
typology: t?.typology ?? "Question",
|
|
@@ -1620,27 +1644,27 @@ function Gn(t, e, o) {
|
|
|
1620
1644
|
submitError: null
|
|
1621
1645
|
};
|
|
1622
1646
|
}
|
|
1623
|
-
function
|
|
1647
|
+
function va(t, e, o) {
|
|
1624
1648
|
t.customFields = {
|
|
1625
|
-
...
|
|
1649
|
+
...Kn(e, o, t.email).customFields,
|
|
1626
1650
|
...t.customFields
|
|
1627
|
-
},
|
|
1651
|
+
}, rt(o, t.customFields, t.ticket.typology);
|
|
1628
1652
|
}
|
|
1629
|
-
function
|
|
1653
|
+
function Ea(t, e, o, n) {
|
|
1630
1654
|
const i = {}, a = e.ticket;
|
|
1631
|
-
t.showSubject && !a.subject.trim() && (i.subject = o.subjectRequired), t.showTypology && !a.typology.trim() && (i.typology = o.typologyRequired), t.showPriority &&
|
|
1655
|
+
t.showSubject && !a.subject.trim() && (i.subject = o.subjectRequired), t.showTypology && !a.typology.trim() && (i.typology = o.typologyRequired), t.showPriority && vi(t, a.typology) && !a.priority.trim() && (i.priority = o.priorityRequired), t.showBody && !a.body.trim() && (i.body = o.detailedContextRequired);
|
|
1632
1656
|
for (const s of t.fields) {
|
|
1633
|
-
if (s.hidden || !
|
|
1634
|
-
const c = e.customFields[
|
|
1635
|
-
if (s.required && !c?.trim()) i[
|
|
1657
|
+
if (s.hidden || !rn(t, s, e.customFields, a.typology)) continue;
|
|
1658
|
+
const c = e.customFields[me(s)];
|
|
1659
|
+
if (s.required && !c?.trim()) i[me(s)] = nn(o.fieldRequired, { fieldTitle: s.title ?? "" });
|
|
1636
1660
|
else if (s.regexpForValidation && c?.trim()) try {
|
|
1637
|
-
new RegExp(s.regexpForValidation).test(c) || (i[
|
|
1661
|
+
new RegExp(s.regexpForValidation).test(c) || (i[me(s)] = nn(o.fieldFormatInvalid, { fieldTitle: s.title ?? "" }));
|
|
1638
1662
|
} catch {
|
|
1639
1663
|
}
|
|
1640
1664
|
}
|
|
1641
|
-
return n && (e.email.trim() ?
|
|
1665
|
+
return n && (e.email.trim() ? Ca.test(e.email) || (i.userEmail = o.emailInvalid) : i.userEmail = o.emailRequired), i;
|
|
1642
1666
|
}
|
|
1643
|
-
var
|
|
1667
|
+
var ka = {
|
|
1644
1668
|
border: `1px solid ${Q}`,
|
|
1645
1669
|
borderRadius: "4px",
|
|
1646
1670
|
width: "100%",
|
|
@@ -1652,7 +1676,7 @@ var va = {
|
|
|
1652
1676
|
color: ne,
|
|
1653
1677
|
backgroundColor: Ee
|
|
1654
1678
|
};
|
|
1655
|
-
function
|
|
1679
|
+
function qe(t, e) {
|
|
1656
1680
|
const o = document.createElement("label");
|
|
1657
1681
|
return o.htmlFor = e, o.textContent = t, u(o, {
|
|
1658
1682
|
display: "block",
|
|
@@ -1668,7 +1692,7 @@ function Te(t) {
|
|
|
1668
1692
|
margin: "0"
|
|
1669
1693
|
}), e;
|
|
1670
1694
|
}
|
|
1671
|
-
function
|
|
1695
|
+
function Ge() {
|
|
1672
1696
|
const t = d({
|
|
1673
1697
|
display: "flex",
|
|
1674
1698
|
flexDirection: "column",
|
|
@@ -1676,14 +1700,14 @@ function qe() {
|
|
|
1676
1700
|
});
|
|
1677
1701
|
return t.className = "ago-ticket-form__field", t;
|
|
1678
1702
|
}
|
|
1679
|
-
function
|
|
1680
|
-
u(t,
|
|
1703
|
+
function Xe(t, e, o) {
|
|
1704
|
+
u(t, ka), e && (t.style.borderColor = "#ef4444"), t.disabled = o, o && (t.style.opacity = "0.5", t.style.cursor = "not-allowed"), t.addEventListener("focus", () => {
|
|
1681
1705
|
t.style.outline = "2px solid var(--ago-accent-color, #003edf)", t.style.outlineOffset = "1px";
|
|
1682
1706
|
}), t.addEventListener("blur", () => {
|
|
1683
1707
|
t.style.outline = "", t.style.outlineOffset = "";
|
|
1684
1708
|
});
|
|
1685
1709
|
}
|
|
1686
|
-
function
|
|
1710
|
+
function Si(t) {
|
|
1687
1711
|
const e = d({
|
|
1688
1712
|
padding: "16px",
|
|
1689
1713
|
borderRadius: "4px",
|
|
@@ -1714,7 +1738,7 @@ function ki(t) {
|
|
|
1714
1738
|
}
|
|
1715
1739
|
return e;
|
|
1716
1740
|
}
|
|
1717
|
-
function
|
|
1741
|
+
function Qo(t) {
|
|
1718
1742
|
const e = d({
|
|
1719
1743
|
width: "100%",
|
|
1720
1744
|
padding: "16px",
|
|
@@ -1747,9 +1771,9 @@ function Yo(t) {
|
|
|
1747
1771
|
lineHeight: "1"
|
|
1748
1772
|
});
|
|
1749
1773
|
const n = d({ minWidth: "0" });
|
|
1750
|
-
return n.appendChild(
|
|
1774
|
+
return n.appendChild(Ye(t)), e.append(o, n), e;
|
|
1751
1775
|
}
|
|
1752
|
-
function
|
|
1776
|
+
function Sa(t) {
|
|
1753
1777
|
const { state: e, labels: o } = t;
|
|
1754
1778
|
let n = t.ticketForm, i = 0, a = t.allowFiles;
|
|
1755
1779
|
const s = d({
|
|
@@ -1766,95 +1790,95 @@ function Ea(t) {
|
|
|
1766
1790
|
});
|
|
1767
1791
|
s.className = "ago-ticket-form";
|
|
1768
1792
|
function c() {
|
|
1769
|
-
return n ? (e.errors =
|
|
1793
|
+
return n ? (e.errors = Ea(n, e, o, t.requireEmail), Object.keys(e.errors).length === 0) : !1;
|
|
1770
1794
|
}
|
|
1771
|
-
async function
|
|
1795
|
+
async function x() {
|
|
1772
1796
|
if (e.loading || e.submitted || !n) return;
|
|
1773
|
-
if (
|
|
1797
|
+
if (rt(n, e.customFields, e.ticket.typology), e.submittedOnce = !0, e.submitError = null, !c()) {
|
|
1774
1798
|
e.submitError = {
|
|
1775
1799
|
title: "validationFailed",
|
|
1776
1800
|
description: "pleaseCheckFields"
|
|
1777
|
-
},
|
|
1801
|
+
}, y();
|
|
1778
1802
|
return;
|
|
1779
1803
|
}
|
|
1780
1804
|
e.loading = !0;
|
|
1781
|
-
const
|
|
1782
|
-
|
|
1805
|
+
const m = i;
|
|
1806
|
+
y();
|
|
1783
1807
|
try {
|
|
1784
|
-
const
|
|
1808
|
+
const k = await t.createTicket({
|
|
1785
1809
|
subject: e.ticket.subject,
|
|
1786
1810
|
typology: e.ticket.typology || "Question",
|
|
1787
1811
|
priority: e.ticket.priority || "Normal",
|
|
1788
1812
|
body: e.ticket.body,
|
|
1789
1813
|
files: e.files,
|
|
1790
|
-
customFields: Object.entries(e.customFields).map(([
|
|
1791
|
-
id:
|
|
1792
|
-
value:
|
|
1814
|
+
customFields: Object.entries(e.customFields).map(([N, _]) => ({
|
|
1815
|
+
id: N,
|
|
1816
|
+
value: _
|
|
1793
1817
|
})),
|
|
1794
1818
|
email: t.requireEmail ? e.email : void 0,
|
|
1795
1819
|
ticketFormId: n.id
|
|
1796
1820
|
});
|
|
1797
|
-
if (
|
|
1821
|
+
if (m !== i) return;
|
|
1798
1822
|
e.loading = !1, e.submitted = {
|
|
1799
|
-
ticketId:
|
|
1800
|
-
ticketUrl:
|
|
1801
|
-
},
|
|
1802
|
-
} catch (
|
|
1803
|
-
if (
|
|
1823
|
+
ticketId: k.id,
|
|
1824
|
+
ticketUrl: k.url
|
|
1825
|
+
}, y(), t.onCreated(k, e);
|
|
1826
|
+
} catch (k) {
|
|
1827
|
+
if (m !== i) return;
|
|
1804
1828
|
e.loading = !1;
|
|
1805
|
-
const
|
|
1829
|
+
const N = k instanceof Error ? k : new Error(String(k)), _ = N.statusCode ?? N.status;
|
|
1806
1830
|
e.submitError = {
|
|
1807
|
-
title:
|
|
1808
|
-
description:
|
|
1809
|
-
detail:
|
|
1810
|
-
},
|
|
1831
|
+
title: _ === 413 ? "fileTooLarge" : _ === 403 ? "permissionDenied" : _ === 422 ? "validationFailed" : "submissionFailed",
|
|
1832
|
+
description: _ === 422 ? "pleaseCheckFields" : "submissionFailedDescription",
|
|
1833
|
+
detail: _ === 413 || _ === 403 ? void 0 : N.message
|
|
1834
|
+
}, y(), t.onError?.(N);
|
|
1811
1835
|
}
|
|
1812
1836
|
}
|
|
1813
|
-
function m
|
|
1814
|
-
const
|
|
1815
|
-
e.customFields[
|
|
1837
|
+
function f(m, k) {
|
|
1838
|
+
const N = me(m);
|
|
1839
|
+
e.customFields[N] = k, n && rt(n, e.customFields, e.ticket.typology), e.submittedOnce && c(), y();
|
|
1816
1840
|
}
|
|
1817
1841
|
function p() {
|
|
1818
1842
|
e.submittedOnce && c();
|
|
1819
1843
|
}
|
|
1820
|
-
function
|
|
1821
|
-
const
|
|
1822
|
-
if (
|
|
1823
|
-
const
|
|
1844
|
+
function b(m) {
|
|
1845
|
+
const k = me(m), N = `ago-ticket-field-${k}`, _ = e.customFields[k] ?? "", I = e.loading, j = e.errors[k];
|
|
1846
|
+
if (m.type === "checkbox") {
|
|
1847
|
+
const S = d({
|
|
1824
1848
|
display: "flex",
|
|
1825
1849
|
alignItems: "center",
|
|
1826
1850
|
gap: "8px",
|
|
1827
1851
|
flexWrap: "wrap"
|
|
1828
1852
|
});
|
|
1829
|
-
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1853
|
+
S.className = "ago-ticket-form__field";
|
|
1854
|
+
const R = document.createElement("input");
|
|
1855
|
+
R.type = "checkbox", R.id = N, R.checked = _ === "true", R.disabled = I, u(R, {
|
|
1832
1856
|
width: "16px",
|
|
1833
1857
|
height: "16px",
|
|
1834
1858
|
margin: "0"
|
|
1835
|
-
}),
|
|
1836
|
-
const
|
|
1837
|
-
return
|
|
1859
|
+
}), R.addEventListener("change", () => f(m, R.checked ? "true" : "false"));
|
|
1860
|
+
const H = document.createElement("label");
|
|
1861
|
+
return H.htmlFor = N, H.textContent = m.title ?? "", H.style.fontWeight = "600", S.append(R, H), j && S.appendChild(Te(j)), S;
|
|
1838
1862
|
}
|
|
1839
|
-
const
|
|
1840
|
-
|
|
1841
|
-
const
|
|
1842
|
-
if (
|
|
1843
|
-
const
|
|
1844
|
-
|
|
1845
|
-
const
|
|
1846
|
-
|
|
1847
|
-
const
|
|
1848
|
-
for (const W of
|
|
1863
|
+
const w = Ge();
|
|
1864
|
+
w.appendChild(qe(m.title ?? "", N));
|
|
1865
|
+
const O = ki(n, m, e.customFields, e.ticket.typology).filter((S) => !S.noDisplay);
|
|
1866
|
+
if (m.options.length > 0) {
|
|
1867
|
+
const S = document.createElement("select");
|
|
1868
|
+
S.id = N;
|
|
1869
|
+
const R = document.createElement("option");
|
|
1870
|
+
R.value = "", R.textContent = "----", S.appendChild(R);
|
|
1871
|
+
const H = /* @__PURE__ */ new Map();
|
|
1872
|
+
for (const W of O) {
|
|
1849
1873
|
const q = document.createElement("option");
|
|
1850
1874
|
if (q.value = W.value ?? W.name ?? "", q.textContent = W.name ?? W.value ?? "", W.group) {
|
|
1851
|
-
let
|
|
1852
|
-
|
|
1853
|
-
} else
|
|
1875
|
+
let v = H.get(W.group);
|
|
1876
|
+
v || (v = document.createElement("optgroup"), v.label = W.group, H.set(W.group, v), S.appendChild(v)), v.appendChild(q);
|
|
1877
|
+
} else S.appendChild(q);
|
|
1854
1878
|
}
|
|
1855
|
-
|
|
1856
|
-
const $ =
|
|
1857
|
-
if (j &&
|
|
1879
|
+
S.value = _, Xe(S, !!j, I), S.addEventListener("change", () => f(m, S.value)), w.appendChild(S);
|
|
1880
|
+
const $ = O.find((W) => (W.value ?? W.name) === _);
|
|
1881
|
+
if (j && w.appendChild(Te(j)), $?.message) {
|
|
1858
1882
|
const W = {
|
|
1859
1883
|
info: {
|
|
1860
1884
|
bg: "#eff6ff",
|
|
@@ -1882,34 +1906,34 @@ function Ea(t) {
|
|
|
1882
1906
|
padding: "8px",
|
|
1883
1907
|
whiteSpace: "pre-line",
|
|
1884
1908
|
margin: "0"
|
|
1885
|
-
}),
|
|
1909
|
+
}), w.appendChild(q);
|
|
1886
1910
|
}
|
|
1887
|
-
return
|
|
1911
|
+
return w;
|
|
1888
1912
|
}
|
|
1889
|
-
const
|
|
1890
|
-
return
|
|
1891
|
-
e.customFields[
|
|
1892
|
-
}),
|
|
1913
|
+
const E = document.createElement("input");
|
|
1914
|
+
return E.type = "text", E.id = N, E.value = _, Xe(E, !!j, I), E.addEventListener("input", () => {
|
|
1915
|
+
e.customFields[k] = E.value, n && rt(n, e.customFields, e.ticket.typology), e.submittedOnce && (c(), F());
|
|
1916
|
+
}), E.addEventListener("change", () => y()), w.appendChild(E), j && w.appendChild(Te(j)), w;
|
|
1893
1917
|
}
|
|
1894
|
-
function
|
|
1895
|
-
for (const
|
|
1896
|
-
const
|
|
1897
|
-
|
|
1918
|
+
function F() {
|
|
1919
|
+
for (const m of s.querySelectorAll("[data-ago-error-for]")) {
|
|
1920
|
+
const k = m.dataset.agoErrorFor, N = m.querySelector(".ago-ticket-form__error"), _ = e.errors[k], I = m.querySelector("input, select, textarea");
|
|
1921
|
+
I && (I.style.borderColor = _ ? "#ef4444" : ""), I && !_ && (I.style.border = `1px solid ${Q}`), _ && !N ? m.appendChild(Te(_)) : _ && N ? N.textContent = _ : !_ && N && N.remove();
|
|
1898
1922
|
}
|
|
1899
1923
|
}
|
|
1900
|
-
function
|
|
1924
|
+
function y() {
|
|
1901
1925
|
if (s.replaceChildren(), t.message) {
|
|
1902
|
-
const
|
|
1926
|
+
const v = d({
|
|
1903
1927
|
fontWeight: "500",
|
|
1904
1928
|
color: "#1e40af",
|
|
1905
1929
|
backgroundColor: "#eff6ff",
|
|
1906
1930
|
padding: "12px",
|
|
1907
1931
|
borderRadius: "4px"
|
|
1908
1932
|
});
|
|
1909
|
-
|
|
1933
|
+
v.className = "ago-ticket-form__message", v.textContent = t.message, s.appendChild(v);
|
|
1910
1934
|
}
|
|
1911
1935
|
if (e.submitted) {
|
|
1912
|
-
s.appendChild(
|
|
1936
|
+
s.appendChild(Si({
|
|
1913
1937
|
text: t.successMessage || n?.successMessageText || o.ticketSubmitted,
|
|
1914
1938
|
ticketUrl: e.submitted.ticketUrl,
|
|
1915
1939
|
urlLabel: t.successUrlLabel || n?.successMessageUrlLabel || o.findTicketHere
|
|
@@ -1917,18 +1941,18 @@ function Ea(t) {
|
|
|
1917
1941
|
return;
|
|
1918
1942
|
}
|
|
1919
1943
|
if (!n) {
|
|
1920
|
-
const
|
|
1944
|
+
const v = d({
|
|
1921
1945
|
backgroundColor: "#fee2e2",
|
|
1922
1946
|
color: "#991b1b",
|
|
1923
1947
|
padding: "16px",
|
|
1924
1948
|
borderRadius: "4px"
|
|
1925
1949
|
});
|
|
1926
|
-
|
|
1950
|
+
v.className = "ago-ticket-form__missing", v.textContent = o.noTicketForm, s.appendChild(v);
|
|
1927
1951
|
return;
|
|
1928
1952
|
}
|
|
1929
|
-
const
|
|
1953
|
+
const m = n, k = e.loading;
|
|
1930
1954
|
if (e.loading) {
|
|
1931
|
-
const
|
|
1955
|
+
const v = d({
|
|
1932
1956
|
position: "absolute",
|
|
1933
1957
|
inset: "0",
|
|
1934
1958
|
display: "flex",
|
|
@@ -1940,36 +1964,36 @@ function Ea(t) {
|
|
|
1940
1964
|
fontSize: "20px",
|
|
1941
1965
|
fontWeight: "700"
|
|
1942
1966
|
});
|
|
1943
|
-
|
|
1967
|
+
v.className = "ago-ticket-form__loading", v.setAttribute("role", "status"), v.textContent = o.loading, s.appendChild(v);
|
|
1944
1968
|
}
|
|
1945
|
-
const
|
|
1969
|
+
const N = d({
|
|
1946
1970
|
fontWeight: "600",
|
|
1947
1971
|
backgroundColor: "#bfdbfe",
|
|
1948
1972
|
padding: "16px",
|
|
1949
1973
|
borderRadius: "4px"
|
|
1950
1974
|
});
|
|
1951
|
-
if (
|
|
1952
|
-
const
|
|
1953
|
-
|
|
1954
|
-
const
|
|
1955
|
-
|
|
1956
|
-
e.email =
|
|
1957
|
-
}),
|
|
1975
|
+
if (N.className = "ago-ticket-form__intro", N.textContent = o.useFormToCreateTicket, s.appendChild(N), t.requireEmail) {
|
|
1976
|
+
const v = Ge();
|
|
1977
|
+
v.dataset.agoErrorFor = "userEmail", v.appendChild(qe(`${o.yourEmail} *`, "ago-ticket-email"));
|
|
1978
|
+
const z = document.createElement("input");
|
|
1979
|
+
z.type = "email", z.id = "ago-ticket-email", z.placeholder = o.emailPlaceholder, z.value = e.email, Xe(z, !!e.errors.userEmail, k), z.addEventListener("input", () => {
|
|
1980
|
+
e.email = z.value, e.submittedOnce && (c(), F());
|
|
1981
|
+
}), v.appendChild(z), e.errors.userEmail && v.appendChild(Te(e.errors.userEmail)), s.appendChild(v);
|
|
1958
1982
|
}
|
|
1959
|
-
const
|
|
1960
|
-
if (
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1963
|
-
const
|
|
1964
|
-
|
|
1965
|
-
e.ticket.subject =
|
|
1966
|
-
}),
|
|
1983
|
+
const _ = m.showSubject && !!e.ticket.subject || !m.showSubject, I = _ && (!!e.ticket.typology || !m.showTypology), j = m.showPriority && vi(m, e.ticket.typology), w = I && (!!e.ticket.priority || !j);
|
|
1984
|
+
if (m.showSubject) {
|
|
1985
|
+
const v = Ge();
|
|
1986
|
+
v.dataset.agoErrorFor = "subject", v.appendChild(qe(o.subject, "ago-ticket-subject"));
|
|
1987
|
+
const z = document.createElement("input");
|
|
1988
|
+
z.type = "text", z.id = "ago-ticket-subject", z.value = e.ticket.subject, Xe(z, !!e.errors.subject, k), z.addEventListener("input", () => {
|
|
1989
|
+
e.ticket.subject = z.value, p(), F();
|
|
1990
|
+
}), z.addEventListener("change", () => y()), v.appendChild(z), e.errors.subject && v.appendChild(Te(e.errors.subject)), s.appendChild(v);
|
|
1967
1991
|
}
|
|
1968
|
-
if (
|
|
1969
|
-
const
|
|
1970
|
-
|
|
1971
|
-
const
|
|
1972
|
-
|
|
1992
|
+
if (_ && m.showTypology) {
|
|
1993
|
+
const v = Ge();
|
|
1994
|
+
v.dataset.agoErrorFor = "typology", v.appendChild(qe(o.typology, "ago-ticket-typology"));
|
|
1995
|
+
const z = document.createElement("select");
|
|
1996
|
+
z.id = "ago-ticket-typology";
|
|
1973
1997
|
for (const [K, G] of [
|
|
1974
1998
|
["", o.selectTypology],
|
|
1975
1999
|
["Question", o.question],
|
|
@@ -1977,17 +2001,17 @@ function Ea(t) {
|
|
|
1977
2001
|
["Incident", o.incident]
|
|
1978
2002
|
]) {
|
|
1979
2003
|
const ee = document.createElement("option");
|
|
1980
|
-
ee.value = K, ee.textContent = G,
|
|
2004
|
+
ee.value = K, ee.textContent = G, z.appendChild(ee);
|
|
1981
2005
|
}
|
|
1982
|
-
|
|
1983
|
-
e.ticket.typology =
|
|
1984
|
-
}),
|
|
2006
|
+
z.value = e.ticket.typology, Xe(z, !!e.errors.typology, k), z.addEventListener("change", () => {
|
|
2007
|
+
e.ticket.typology = z.value, rt(m, e.customFields, e.ticket.typology), p(), y();
|
|
2008
|
+
}), v.appendChild(z), e.errors.typology && v.appendChild(Te(e.errors.typology)), s.appendChild(v);
|
|
1985
2009
|
}
|
|
1986
|
-
if (
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
const
|
|
1990
|
-
|
|
2010
|
+
if (I && j) {
|
|
2011
|
+
const v = Ge();
|
|
2012
|
+
v.dataset.agoErrorFor = "priority", v.appendChild(qe(o.priority, "ago-ticket-priority"));
|
|
2013
|
+
const z = document.createElement("select");
|
|
2014
|
+
z.id = "ago-ticket-priority";
|
|
1991
2015
|
for (const [K, G] of [
|
|
1992
2016
|
["", o.selectPriority],
|
|
1993
2017
|
["Low", o.low],
|
|
@@ -1996,49 +2020,49 @@ function Ea(t) {
|
|
|
1996
2020
|
["Urgent", o.urgent]
|
|
1997
2021
|
]) {
|
|
1998
2022
|
const ee = document.createElement("option");
|
|
1999
|
-
ee.value = K, ee.textContent = G,
|
|
2023
|
+
ee.value = K, ee.textContent = G, z.appendChild(ee);
|
|
2000
2024
|
}
|
|
2001
|
-
|
|
2002
|
-
e.ticket.priority =
|
|
2003
|
-
}),
|
|
2025
|
+
z.value = e.ticket.priority, Xe(z, !!e.errors.priority, k), z.addEventListener("change", () => {
|
|
2026
|
+
e.ticket.priority = z.value, p(), y();
|
|
2027
|
+
}), v.appendChild(z), e.errors.priority && v.appendChild(Te(e.errors.priority)), s.appendChild(v);
|
|
2004
2028
|
}
|
|
2005
|
-
if (
|
|
2006
|
-
const
|
|
2007
|
-
for (const
|
|
2008
|
-
if (!
|
|
2009
|
-
const K =
|
|
2010
|
-
K.dataset.agoErrorFor =
|
|
2029
|
+
if (w) {
|
|
2030
|
+
const v = new Set(ba(m, e.customFields, e.ticket.typology));
|
|
2031
|
+
for (const z of [...m.fields].sort((K, G) => K.position - G.position)) {
|
|
2032
|
+
if (!v.has(z) && !e.errors[me(z)]) continue;
|
|
2033
|
+
const K = b(z);
|
|
2034
|
+
K.dataset.agoErrorFor = me(z), s.appendChild(K);
|
|
2011
2035
|
}
|
|
2012
2036
|
}
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
const
|
|
2016
|
-
|
|
2037
|
+
const O = Ge();
|
|
2038
|
+
O.dataset.agoErrorFor = "body", O.appendChild(qe(o.detailedContext, "ago-ticket-body"));
|
|
2039
|
+
const E = document.createElement("textarea");
|
|
2040
|
+
E.id = "ago-ticket-body", E.rows = 4, E.value = e.ticket.body, Xe(E, !!e.errors.body, k), u(E, {
|
|
2017
2041
|
resize: "vertical",
|
|
2018
2042
|
maxHeight: "240px",
|
|
2019
2043
|
overflowY: "auto"
|
|
2020
2044
|
});
|
|
2021
|
-
const
|
|
2045
|
+
const S = d({
|
|
2022
2046
|
fontSize: "14px",
|
|
2023
2047
|
lineHeight: "20px",
|
|
2024
2048
|
marginTop: "4px",
|
|
2025
2049
|
textAlign: "right",
|
|
2026
2050
|
display: "none"
|
|
2027
2051
|
});
|
|
2028
|
-
|
|
2029
|
-
const
|
|
2030
|
-
const
|
|
2031
|
-
|
|
2032
|
-
},
|
|
2033
|
-
|
|
2052
|
+
S.className = "ago-ticket-form__counter";
|
|
2053
|
+
const R = () => {
|
|
2054
|
+
const v = e.ticket.body.length;
|
|
2055
|
+
S.style.display = v > 6e4 ? "block" : "none", S.style.color = v > 65535 ? "#dc2626" : "#d97706", S.textContent = `${v} / 65,535 · ${o.maxCharacters}`;
|
|
2056
|
+
}, H = () => {
|
|
2057
|
+
E.style.height = "auto", E.style.height = `${E.scrollHeight}px`;
|
|
2034
2058
|
};
|
|
2035
|
-
if (
|
|
2036
|
-
e.ticket.body =
|
|
2037
|
-
}),
|
|
2038
|
-
const
|
|
2039
|
-
|
|
2040
|
-
const
|
|
2041
|
-
|
|
2059
|
+
if (E.addEventListener("input", () => {
|
|
2060
|
+
e.ticket.body = E.value, p(), F(), R(), H();
|
|
2061
|
+
}), O.append(E, S), R(), e.errors.body && O.appendChild(Te(e.errors.body)), s.appendChild(O), a) {
|
|
2062
|
+
const v = Ge();
|
|
2063
|
+
v.className = "ago-ticket-form__field ago-ticket-form__attachments", v.appendChild(qe(o.attachments, "ago-ticket-files"));
|
|
2064
|
+
const z = document.createElement("label");
|
|
2065
|
+
z.htmlFor = "ago-ticket-files", z.textContent = o.selectFile, u(z, {
|
|
2042
2066
|
display: "inline-block",
|
|
2043
2067
|
alignSelf: "flex-start",
|
|
2044
2068
|
backgroundColor: "#e5e7eb",
|
|
@@ -2049,26 +2073,26 @@ function Ea(t) {
|
|
|
2049
2073
|
minHeight: "24px"
|
|
2050
2074
|
});
|
|
2051
2075
|
const K = document.createElement("input");
|
|
2052
|
-
K.type = "file", K.id = "ago-ticket-files", K.multiple = !0, K.disabled =
|
|
2053
|
-
e.files = [...e.files, ...Array.from(K.files ?? [])], K.value = "",
|
|
2054
|
-
}),
|
|
2076
|
+
K.type = "file", K.id = "ago-ticket-files", K.multiple = !0, K.disabled = k, u(K, { display: "none" }), K.addEventListener("change", () => {
|
|
2077
|
+
e.files = [...e.files, ...Array.from(K.files ?? [])], K.value = "", y();
|
|
2078
|
+
}), v.append(z, K);
|
|
2055
2079
|
const G = d({
|
|
2056
2080
|
display: "flex",
|
|
2057
2081
|
flexDirection: "column",
|
|
2058
2082
|
gap: "4px"
|
|
2059
2083
|
});
|
|
2060
2084
|
e.files.forEach((ee, Y) => {
|
|
2061
|
-
const
|
|
2085
|
+
const g = d({
|
|
2062
2086
|
display: "flex",
|
|
2063
2087
|
alignItems: "center",
|
|
2064
2088
|
justifyContent: "space-between",
|
|
2065
2089
|
backgroundColor: "#f3f4f6",
|
|
2066
2090
|
padding: "4px 8px",
|
|
2067
2091
|
borderRadius: "4px"
|
|
2068
|
-
}),
|
|
2069
|
-
|
|
2092
|
+
}), B = document.createElement("span");
|
|
2093
|
+
B.textContent = `${ee.name} - ${nn(o.fileSize, { size: (ee.size / 1024).toFixed(1) })}`;
|
|
2070
2094
|
const P = document.createElement("button");
|
|
2071
|
-
P.type = "button", P.textContent = "×", P.setAttribute("aria-label",
|
|
2095
|
+
P.type = "button", P.textContent = "×", P.setAttribute("aria-label", nn(o.removeFile, { filename: ee.name })), P.disabled = k, u(P, {
|
|
2072
2096
|
color: "#dc2626",
|
|
2073
2097
|
fontWeight: "700",
|
|
2074
2098
|
background: "none",
|
|
@@ -2080,19 +2104,19 @@ function Ea(t) {
|
|
|
2080
2104
|
height: "44px",
|
|
2081
2105
|
margin: "-10px -12px -10px 0"
|
|
2082
2106
|
}), P.addEventListener("click", () => {
|
|
2083
|
-
e.files = e.files.filter((D, oe) => oe !== Y),
|
|
2084
|
-
}),
|
|
2085
|
-
}),
|
|
2107
|
+
e.files = e.files.filter((D, oe) => oe !== Y), y();
|
|
2108
|
+
}), g.append(B, P), G.appendChild(g);
|
|
2109
|
+
}), v.appendChild(G), s.appendChild(v);
|
|
2086
2110
|
}
|
|
2087
2111
|
if (e.submitError) {
|
|
2088
|
-
const { title:
|
|
2112
|
+
const { title: v, description: z, detail: K } = e.submitError, G = Te(`${o[v]}: ${K || o[z]}`);
|
|
2089
2113
|
G.setAttribute("role", "alert"), G.className = "ago-ticket-form__error ago-ticket-form__submit-error", s.appendChild(G);
|
|
2090
2114
|
}
|
|
2091
2115
|
const $ = document.createElement("button");
|
|
2092
|
-
$.type = "button", $.className = "ago-ticket-form__submit", $.disabled =
|
|
2116
|
+
$.type = "button", $.className = "ago-ticket-form__submit", $.disabled = k, u($, {
|
|
2093
2117
|
width: "100%",
|
|
2094
|
-
backgroundColor:
|
|
2095
|
-
color:
|
|
2118
|
+
backgroundColor: ya,
|
|
2119
|
+
color: lt,
|
|
2096
2120
|
padding: "8px 16px",
|
|
2097
2121
|
borderRadius: "4px",
|
|
2098
2122
|
border: "none",
|
|
@@ -2100,7 +2124,7 @@ function Ea(t) {
|
|
|
2100
2124
|
alignItems: "center",
|
|
2101
2125
|
justifyContent: "center",
|
|
2102
2126
|
gap: "8px",
|
|
2103
|
-
cursor:
|
|
2127
|
+
cursor: k ? "default" : "pointer",
|
|
2104
2128
|
fontSize: "16px",
|
|
2105
2129
|
lineHeight: "24px",
|
|
2106
2130
|
minHeight: "44px",
|
|
@@ -2119,22 +2143,22 @@ function Ea(t) {
|
|
|
2119
2143
|
}), $.addEventListener("mouseleave", () => {
|
|
2120
2144
|
$.style.filter = "", q.style.transform = "";
|
|
2121
2145
|
}), $.addEventListener("click", () => {
|
|
2122
|
-
|
|
2146
|
+
x();
|
|
2123
2147
|
}), s.appendChild($);
|
|
2124
2148
|
}
|
|
2125
|
-
return
|
|
2149
|
+
return y(), {
|
|
2126
2150
|
el: s,
|
|
2127
|
-
rebuild: (
|
|
2128
|
-
if (
|
|
2129
|
-
const
|
|
2130
|
-
n && n.id !==
|
|
2151
|
+
rebuild: (m) => {
|
|
2152
|
+
if (m && "ticketForm" in m) {
|
|
2153
|
+
const k = m.ticketForm ?? null;
|
|
2154
|
+
n && n.id !== k?.id && (i += 1, Object.assign(e, Kn(void 0, k, e.email), { submitted: void 0 })), n = k, e.submittedOnce && !e.submitted && c();
|
|
2131
2155
|
}
|
|
2132
|
-
|
|
2156
|
+
m && "allowFiles" in m && (a = !!m.allowFiles), y();
|
|
2133
2157
|
}
|
|
2134
2158
|
};
|
|
2135
2159
|
}
|
|
2136
|
-
var
|
|
2137
|
-
async function
|
|
2160
|
+
var _a = 0;
|
|
2161
|
+
async function Ta(t) {
|
|
2138
2162
|
const e = Array.from(t.querySelectorAll("script"));
|
|
2139
2163
|
for (const o of e) {
|
|
2140
2164
|
const n = document.createElement("script");
|
|
@@ -2144,7 +2168,7 @@ async function Sa(t) {
|
|
|
2144
2168
|
}) : (n.textContent = o.textContent, o.parentNode?.replaceChild(n, o));
|
|
2145
2169
|
}
|
|
2146
2170
|
}
|
|
2147
|
-
function
|
|
2171
|
+
function Aa(t, e) {
|
|
2148
2172
|
const o = {};
|
|
2149
2173
|
if (t)
|
|
2150
2174
|
for (const [n, i] of Object.entries(t)) if (n === "custom_fields" && i && typeof i == "object")
|
|
@@ -2152,7 +2176,7 @@ function _a(t, e) {
|
|
|
2152
2176
|
else typeof i == "string" && i && (o[n] = i);
|
|
2153
2177
|
return e && (o.email = e), Object.keys(o).length > 0 ? o : null;
|
|
2154
2178
|
}
|
|
2155
|
-
function
|
|
2179
|
+
function Fa(t) {
|
|
2156
2180
|
const e = d({
|
|
2157
2181
|
fontWeight: "500",
|
|
2158
2182
|
color: "#1e40af",
|
|
@@ -2164,13 +2188,13 @@ function Ta(t) {
|
|
|
2164
2188
|
});
|
|
2165
2189
|
return e.className = "ago-ticket-form__message", e.textContent = t, e;
|
|
2166
2190
|
}
|
|
2167
|
-
function
|
|
2168
|
-
const { state: e, labels: o } = t, n = `ago-embed-${Date.now().toString(36)}-${++
|
|
2191
|
+
function La(t) {
|
|
2192
|
+
const { state: e, labels: o } = t, n = `ago-embed-${Date.now().toString(36)}-${++_a}`, i = d({
|
|
2169
2193
|
display: "flex",
|
|
2170
2194
|
flexDirection: "column",
|
|
2171
2195
|
gap: "16px"
|
|
2172
2196
|
});
|
|
2173
|
-
i.className = "ago-embed-form", t.message && i.appendChild(
|
|
2197
|
+
i.className = "ago-embed-form", t.message && i.appendChild(Fa(t.message));
|
|
2174
2198
|
const a = d({
|
|
2175
2199
|
display: "flex",
|
|
2176
2200
|
flexDirection: "column",
|
|
@@ -2178,80 +2202,80 @@ function Aa(t) {
|
|
|
2178
2202
|
});
|
|
2179
2203
|
a.className = "ago-embed-form__body", i.appendChild(a);
|
|
2180
2204
|
const s = [];
|
|
2181
|
-
let c,
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
},
|
|
2185
|
-
|
|
2186
|
-
|
|
2205
|
+
let c, x = !1, f = e.status === "submitted", p = null;
|
|
2206
|
+
const b = Aa(t.ticket, t.email), F = (E) => {
|
|
2207
|
+
f || x || (f = !0, c && (clearTimeout(c), c = void 0), e.status = "submitted", e.captured = E ?? null, O(), t.onSubmitted(E ?? null));
|
|
2208
|
+
}, y = () => {
|
|
2209
|
+
f || c || (x = !1, c = setTimeout(() => {
|
|
2210
|
+
f || (c = void 0, e.status = "timeout", O());
|
|
2187
2211
|
}, 3e4));
|
|
2188
|
-
},
|
|
2212
|
+
}, m = () => {
|
|
2189
2213
|
try {
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2192
|
-
const
|
|
2193
|
-
Promise.race([
|
|
2214
|
+
const E = globalThis.HubSpotFormsV4?.getForms?.()?.[0];
|
|
2215
|
+
if (E?.getFormFieldValues) {
|
|
2216
|
+
const S = new Promise((R, H) => setTimeout(() => H(/* @__PURE__ */ new Error("timeout")), 3e3));
|
|
2217
|
+
Promise.race([E.getFormFieldValues(), S]).then((R) => F(Jt(R))).catch(() => F(p));
|
|
2194
2218
|
return;
|
|
2195
2219
|
}
|
|
2196
2220
|
} catch {
|
|
2197
2221
|
}
|
|
2198
|
-
|
|
2222
|
+
F(p);
|
|
2199
2223
|
};
|
|
2200
|
-
window.addEventListener("hs-form-event:on-submission:success",
|
|
2201
|
-
const
|
|
2202
|
-
const
|
|
2203
|
-
if (
|
|
2224
|
+
window.addEventListener("hs-form-event:on-submission:success", m), s.push(() => window.removeEventListener("hs-form-event:on-submission:success", m));
|
|
2225
|
+
const k = [], N = (E) => {
|
|
2226
|
+
const S = E.data;
|
|
2227
|
+
if (S?.type === "hsFormCallback" && S.eventName === "onFormSubmit") {
|
|
2204
2228
|
try {
|
|
2205
|
-
const
|
|
2206
|
-
if (Array.isArray(
|
|
2207
|
-
const
|
|
2208
|
-
for (const W of
|
|
2209
|
-
const $ =
|
|
2229
|
+
const R = S.data;
|
|
2230
|
+
if (Array.isArray(R)) {
|
|
2231
|
+
const H = {};
|
|
2232
|
+
for (const W of R) W?.name && W.value !== void 0 && (H[W.name] = W.value);
|
|
2233
|
+
const $ = Jt(H);
|
|
2210
2234
|
$ && (p = $);
|
|
2211
2235
|
}
|
|
2212
2236
|
} catch {
|
|
2213
2237
|
}
|
|
2214
2238
|
return;
|
|
2215
2239
|
}
|
|
2216
|
-
if (
|
|
2217
|
-
|
|
2240
|
+
if (S?.type === "hsFormCallback" && S.eventName === "onFormSubmitted") {
|
|
2241
|
+
F(p);
|
|
2218
2242
|
return;
|
|
2219
2243
|
}
|
|
2220
|
-
if (
|
|
2221
|
-
const
|
|
2244
|
+
if (S?.type === "HS_CTA_PARENT_INIT" && E.ports?.[0]) {
|
|
2245
|
+
const R = E.ports[0], H = ($) => {
|
|
2222
2246
|
const W = $.data;
|
|
2223
2247
|
if (W?.type === "HS_SEND_FORM_FIELD_VALUES") {
|
|
2224
2248
|
const q = W.payload?.formFieldValues;
|
|
2225
2249
|
if (q && typeof q == "object") {
|
|
2226
|
-
const
|
|
2227
|
-
|
|
2250
|
+
const v = Jt(q);
|
|
2251
|
+
v && (p = v);
|
|
2228
2252
|
}
|
|
2229
2253
|
}
|
|
2230
|
-
W?.type === "HS_SEND_FORM_SUBMISSION_SUCCESS" &&
|
|
2254
|
+
W?.type === "HS_SEND_FORM_SUBMISSION_SUCCESS" && F(p);
|
|
2231
2255
|
};
|
|
2232
|
-
|
|
2256
|
+
R.addEventListener("message", H), R.start(), k.push(() => R.removeEventListener("message", H));
|
|
2233
2257
|
}
|
|
2234
2258
|
};
|
|
2235
|
-
window.addEventListener("message",
|
|
2236
|
-
window.removeEventListener("message",
|
|
2259
|
+
window.addEventListener("message", N), s.push(() => {
|
|
2260
|
+
window.removeEventListener("message", N), k.forEach((E) => E());
|
|
2237
2261
|
});
|
|
2238
|
-
let
|
|
2239
|
-
function
|
|
2262
|
+
let _;
|
|
2263
|
+
function I(E) {
|
|
2240
2264
|
if (!t.embedHtml) return;
|
|
2241
|
-
let
|
|
2242
|
-
|
|
2243
|
-
const
|
|
2244
|
-
|
|
2245
|
-
const $ =
|
|
2246
|
-
let W, q,
|
|
2247
|
-
|
|
2265
|
+
let S = pa(t.embedHtml, b, n);
|
|
2266
|
+
S = ga(S, n);
|
|
2267
|
+
const R = ua(b, n), H = Xo(b);
|
|
2268
|
+
E.innerHTML = S;
|
|
2269
|
+
const $ = ha(E, F, y, n);
|
|
2270
|
+
let W, q, v;
|
|
2271
|
+
Ta(E).catch(() => {
|
|
2248
2272
|
}).then(() => {
|
|
2249
|
-
e.status === "loading" && (e.status = "ready", j.style.display = "none",
|
|
2273
|
+
e.status === "loading" && (e.status = "ready", j.style.display = "none", b && (tn(E, b), fa(b), v = Xo(b), W = new MutationObserver(() => tn(E, b)), W.observe(E, {
|
|
2250
2274
|
childList: !0,
|
|
2251
2275
|
subtree: !0
|
|
2252
2276
|
}), q = setTimeout(() => W?.disconnect(), 1e4)));
|
|
2253
|
-
}),
|
|
2254
|
-
|
|
2277
|
+
}), _ = () => {
|
|
2278
|
+
R(), H(), $(), W?.disconnect(), q && clearTimeout(q), v?.(), E.innerHTML = "";
|
|
2255
2279
|
};
|
|
2256
2280
|
}
|
|
2257
2281
|
const j = d({
|
|
@@ -2264,18 +2288,18 @@ function Aa(t) {
|
|
|
2264
2288
|
zIndex: "10"
|
|
2265
2289
|
});
|
|
2266
2290
|
j.className = "ago-embed-form__loading";
|
|
2267
|
-
const
|
|
2291
|
+
const w = d({
|
|
2268
2292
|
width: "24px",
|
|
2269
2293
|
height: "24px",
|
|
2270
2294
|
borderRadius: "50%",
|
|
2271
|
-
border: `2px solid ${
|
|
2295
|
+
border: `2px solid ${$n}`,
|
|
2272
2296
|
borderTopColor: "transparent",
|
|
2273
2297
|
animation: "ago-spin 1s linear infinite"
|
|
2274
2298
|
});
|
|
2275
|
-
|
|
2276
|
-
function
|
|
2299
|
+
w.setAttribute("role", "status"), w.setAttribute("aria-label", o.loading), j.appendChild(w);
|
|
2300
|
+
function O() {
|
|
2277
2301
|
if (a.replaceChildren(), e.status === "timeout") {
|
|
2278
|
-
const
|
|
2302
|
+
const S = d({
|
|
2279
2303
|
borderRadius: "8px",
|
|
2280
2304
|
border: "1px solid #fef08a",
|
|
2281
2305
|
backgroundColor: "#fefce8",
|
|
@@ -2284,16 +2308,16 @@ function Aa(t) {
|
|
|
2284
2308
|
flexDirection: "column",
|
|
2285
2309
|
gap: "12px"
|
|
2286
2310
|
});
|
|
2287
|
-
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2311
|
+
S.className = "ago-embed-form__timeout";
|
|
2312
|
+
const R = document.createElement("p");
|
|
2313
|
+
R.textContent = o.embedSubmitTimeout, u(R, {
|
|
2290
2314
|
fontSize: "14px",
|
|
2291
2315
|
lineHeight: "20px",
|
|
2292
2316
|
color: "#854d0e",
|
|
2293
2317
|
margin: "0"
|
|
2294
2318
|
});
|
|
2295
|
-
const
|
|
2296
|
-
|
|
2319
|
+
const H = document.createElement("button");
|
|
2320
|
+
H.type = "button", H.textContent = o.tryAgain, u(H, {
|
|
2297
2321
|
alignSelf: "flex-start",
|
|
2298
2322
|
fontSize: "14px",
|
|
2299
2323
|
fontWeight: "500",
|
|
@@ -2305,98 +2329,98 @@ function Aa(t) {
|
|
|
2305
2329
|
cursor: "pointer",
|
|
2306
2330
|
minHeight: "44px",
|
|
2307
2331
|
font: "inherit"
|
|
2308
|
-
}),
|
|
2309
|
-
|
|
2310
|
-
}),
|
|
2332
|
+
}), H.addEventListener("click", () => {
|
|
2333
|
+
x = !0, f = !1, c = void 0, e.status = "ready", O();
|
|
2334
|
+
}), S.append(R, H), a.appendChild(S);
|
|
2311
2335
|
return;
|
|
2312
2336
|
}
|
|
2313
2337
|
if (e.status === "submitted") {
|
|
2314
|
-
a.appendChild(
|
|
2338
|
+
a.appendChild(Si({
|
|
2315
2339
|
text: t.successMessage || o.embeddedFormSubmitted,
|
|
2316
2340
|
urlLabel: o.findTicketHere
|
|
2317
2341
|
}));
|
|
2318
2342
|
return;
|
|
2319
2343
|
}
|
|
2320
2344
|
if (t.description) {
|
|
2321
|
-
const
|
|
2322
|
-
|
|
2345
|
+
const S = document.createElement("p");
|
|
2346
|
+
S.className = "ago-embed-form__description", S.textContent = t.description, u(S, {
|
|
2323
2347
|
fontSize: "14px",
|
|
2324
2348
|
lineHeight: "20px",
|
|
2325
2349
|
margin: "0"
|
|
2326
|
-
}), a.appendChild(
|
|
2350
|
+
}), a.appendChild(S);
|
|
2327
2351
|
}
|
|
2328
|
-
const
|
|
2352
|
+
const E = d({
|
|
2329
2353
|
position: "relative",
|
|
2330
2354
|
borderRadius: "8px",
|
|
2331
2355
|
border: `1px solid ${Q}`,
|
|
2332
2356
|
overflow: "hidden"
|
|
2333
2357
|
});
|
|
2334
|
-
if (
|
|
2335
|
-
j.style.display = e.status === "loading" ? "flex" : "none",
|
|
2336
|
-
const
|
|
2358
|
+
if (E.className = "ago-embed-form__frame", t.embedHtml) {
|
|
2359
|
+
j.style.display = e.status === "loading" ? "flex" : "none", E.appendChild(j);
|
|
2360
|
+
const S = d({
|
|
2337
2361
|
width: "100%",
|
|
2338
2362
|
minHeight: "200px"
|
|
2339
2363
|
});
|
|
2340
|
-
|
|
2364
|
+
S.className = "ago-embed-form__host", E.appendChild(S), _?.(), I(S);
|
|
2341
2365
|
} else {
|
|
2342
|
-
const
|
|
2366
|
+
const S = d({
|
|
2343
2367
|
padding: "24px",
|
|
2344
2368
|
textAlign: "center",
|
|
2345
|
-
color:
|
|
2369
|
+
color: $n,
|
|
2346
2370
|
fontSize: "14px"
|
|
2347
2371
|
});
|
|
2348
|
-
|
|
2372
|
+
S.className = "ago-embed-form__empty", S.textContent = o.noEmbedConfigured, E.appendChild(S);
|
|
2349
2373
|
}
|
|
2350
|
-
a.appendChild(
|
|
2374
|
+
a.appendChild(E);
|
|
2351
2375
|
}
|
|
2352
|
-
return
|
|
2376
|
+
return O(), {
|
|
2353
2377
|
el: i,
|
|
2354
|
-
updateText: (
|
|
2355
|
-
if (Object.assign(t,
|
|
2356
|
-
|
|
2378
|
+
updateText: (E) => {
|
|
2379
|
+
if (Object.assign(t, E), w.setAttribute("aria-label", o.loading), e.status === "submitted" || e.status === "timeout") {
|
|
2380
|
+
O();
|
|
2357
2381
|
return;
|
|
2358
2382
|
}
|
|
2359
|
-
const
|
|
2360
|
-
if (
|
|
2383
|
+
const S = a.querySelector(".ago-embed-form__description");
|
|
2384
|
+
if (S) S.textContent = t.description ?? "";
|
|
2361
2385
|
else if (t.description) {
|
|
2362
|
-
const
|
|
2363
|
-
|
|
2386
|
+
const H = document.createElement("p");
|
|
2387
|
+
H.className = "ago-embed-form__description", H.textContent = t.description, u(H, {
|
|
2364
2388
|
fontSize: "14px",
|
|
2365
2389
|
lineHeight: "20px",
|
|
2366
2390
|
margin: "0"
|
|
2367
|
-
}), a.prepend(
|
|
2391
|
+
}), a.prepend(H);
|
|
2368
2392
|
}
|
|
2369
|
-
const
|
|
2370
|
-
|
|
2393
|
+
const R = a.querySelector(".ago-embed-form__empty");
|
|
2394
|
+
R && (R.textContent = o.noEmbedConfigured);
|
|
2371
2395
|
},
|
|
2372
2396
|
destroy: () => {
|
|
2373
|
-
c && clearTimeout(c),
|
|
2397
|
+
c && clearTimeout(c), _?.(), s.forEach((E) => E());
|
|
2374
2398
|
}
|
|
2375
2399
|
};
|
|
2376
2400
|
}
|
|
2377
|
-
function
|
|
2401
|
+
function Zo(t) {
|
|
2378
2402
|
return t.type === "form" && t.toolName === "ago_ticketing";
|
|
2379
2403
|
}
|
|
2380
|
-
function
|
|
2404
|
+
function Jo(t) {
|
|
2381
2405
|
let e = null;
|
|
2382
2406
|
for (const o of t) for (const n of o.toolCalls ?? []) n.type === "form" && (e = n.id);
|
|
2383
2407
|
return e;
|
|
2384
2408
|
}
|
|
2385
|
-
function
|
|
2409
|
+
function Na(t) {
|
|
2386
2410
|
return t.some((e) => (e.toolCalls ?? []).some((o) => {
|
|
2387
2411
|
if (o.type !== "form") return !1;
|
|
2388
2412
|
const n = o.data;
|
|
2389
2413
|
return n?.success === !0 && !!n.ticket?.ticket_id;
|
|
2390
2414
|
}));
|
|
2391
2415
|
}
|
|
2392
|
-
function
|
|
2416
|
+
function ei(t) {
|
|
2393
2417
|
const e = t.data;
|
|
2394
2418
|
return e?.success !== !0 || !e.ticket?.ticket_id ? null : {
|
|
2395
2419
|
ticketId: String(e.ticket.ticket_id),
|
|
2396
2420
|
ticketUrl: typeof e.ticket.ticket_url == "string" && e.ticket.ticket_url ? e.ticket.ticket_url : void 0
|
|
2397
2421
|
};
|
|
2398
2422
|
}
|
|
2399
|
-
var
|
|
2423
|
+
var Ia = {
|
|
2400
2424
|
info: {
|
|
2401
2425
|
border: "#bfdbfe",
|
|
2402
2426
|
bg: "#eff6ff",
|
|
@@ -2418,8 +2442,8 @@ var La = {
|
|
|
2418
2442
|
text: "#991b1b"
|
|
2419
2443
|
}
|
|
2420
2444
|
};
|
|
2421
|
-
function
|
|
2422
|
-
const n =
|
|
2445
|
+
function Ra(t, e = "info", o) {
|
|
2446
|
+
const n = Ia[e], i = d({
|
|
2423
2447
|
margin: "8px 0",
|
|
2424
2448
|
padding: "12px 16px",
|
|
2425
2449
|
border: `1px solid ${n.border}`,
|
|
@@ -2444,7 +2468,7 @@ function Na(t, e = "info", o) {
|
|
|
2444
2468
|
const a = document.createElement("span");
|
|
2445
2469
|
return a.textContent = t, a.style.whiteSpace = "pre-wrap", i.appendChild(a), i;
|
|
2446
2470
|
}
|
|
2447
|
-
function
|
|
2471
|
+
function za(t, e) {
|
|
2448
2472
|
const o = d({
|
|
2449
2473
|
margin: "8px 0",
|
|
2450
2474
|
padding: "12px 16px",
|
|
@@ -2492,8 +2516,8 @@ function Ia(t, e) {
|
|
|
2492
2516
|
}
|
|
2493
2517
|
return o.appendChild(i), o;
|
|
2494
2518
|
}
|
|
2495
|
-
var
|
|
2496
|
-
function
|
|
2519
|
+
var fs = Gn.feedback;
|
|
2520
|
+
function Oa() {
|
|
2497
2521
|
return {
|
|
2498
2522
|
detailsOpen: !1,
|
|
2499
2523
|
reasons: /* @__PURE__ */ new Set(),
|
|
@@ -2501,7 +2525,7 @@ function Ra() {
|
|
|
2501
2525
|
reported: !1
|
|
2502
2526
|
};
|
|
2503
2527
|
}
|
|
2504
|
-
var
|
|
2528
|
+
var Ha = {
|
|
2505
2529
|
display: "inline-flex",
|
|
2506
2530
|
alignItems: "center",
|
|
2507
2531
|
justifyContent: "center",
|
|
@@ -2512,20 +2536,20 @@ var za = {
|
|
|
2512
2536
|
border: "none",
|
|
2513
2537
|
borderRadius: "8px",
|
|
2514
2538
|
background: "transparent",
|
|
2515
|
-
color:
|
|
2539
|
+
color: st,
|
|
2516
2540
|
cursor: "pointer",
|
|
2517
2541
|
lineHeight: "1"
|
|
2518
2542
|
};
|
|
2519
|
-
function
|
|
2543
|
+
function Ba(t) {
|
|
2520
2544
|
const { state: e, labels: o, askWhy: n, onRate: i, onReport: a } = t, s = t.look === "embed", c = s ? {
|
|
2521
2545
|
idle: "#78716c",
|
|
2522
2546
|
hover: "#1c1917",
|
|
2523
2547
|
active: "#1c1917"
|
|
2524
2548
|
} : {
|
|
2525
|
-
idle:
|
|
2549
|
+
idle: st,
|
|
2526
2550
|
hover: ne,
|
|
2527
|
-
active:
|
|
2528
|
-
},
|
|
2551
|
+
active: ct
|
|
2552
|
+
}, x = d(s ? {
|
|
2529
2553
|
display: "flex",
|
|
2530
2554
|
justifyContent: "space-between",
|
|
2531
2555
|
alignItems: "center",
|
|
@@ -2536,47 +2560,47 @@ function Oa(t) {
|
|
|
2536
2560
|
width: "100%",
|
|
2537
2561
|
maxWidth: "85%"
|
|
2538
2562
|
});
|
|
2539
|
-
|
|
2540
|
-
const
|
|
2563
|
+
x.className = "ago-feedback";
|
|
2564
|
+
const f = d({
|
|
2541
2565
|
display: "flex",
|
|
2542
2566
|
alignItems: "center",
|
|
2543
2567
|
gap: s ? "8px" : "2px"
|
|
2544
2568
|
});
|
|
2545
|
-
|
|
2546
|
-
const p =
|
|
2569
|
+
f.className = "ago-feedback__actions";
|
|
2570
|
+
const p = ti("up", o.helpful, e.rating === "positive", c, s);
|
|
2547
2571
|
p.addEventListener("click", () => {
|
|
2548
|
-
e.rating = "positive", e.detailsOpen = !1,
|
|
2572
|
+
e.rating = "positive", e.detailsOpen = !1, y(), m(), i("positive");
|
|
2549
2573
|
});
|
|
2550
|
-
const
|
|
2551
|
-
|
|
2552
|
-
e.rating = "negative", i("negative"), n && !e.reported && (e.detailsOpen = !0),
|
|
2553
|
-
}),
|
|
2554
|
-
const
|
|
2555
|
-
|
|
2556
|
-
function
|
|
2557
|
-
|
|
2574
|
+
const b = ti("down", o.notHelpful, e.rating === "negative", c, s);
|
|
2575
|
+
b.addEventListener("click", () => {
|
|
2576
|
+
e.rating = "negative", i("negative"), n && !e.reported && (e.detailsOpen = !0), y(), m();
|
|
2577
|
+
}), f.append(p, b), s && x.appendChild(d({ flex: "1" })), x.appendChild(f);
|
|
2578
|
+
const F = d();
|
|
2579
|
+
F.className = "ago-feedback__panel-slot", s && (F.style.flexBasis = "100%"), x.appendChild(F);
|
|
2580
|
+
function y() {
|
|
2581
|
+
Vn(p, e.rating === "positive", c), Vn(b, e.rating === "negative", c);
|
|
2558
2582
|
}
|
|
2559
|
-
function
|
|
2560
|
-
if (
|
|
2561
|
-
|
|
2583
|
+
function m() {
|
|
2584
|
+
if (F.replaceChildren(), e.reported) {
|
|
2585
|
+
F.appendChild(Ma(o.thanks));
|
|
2562
2586
|
return;
|
|
2563
2587
|
}
|
|
2564
|
-
e.detailsOpen &&
|
|
2588
|
+
e.detailsOpen && F.appendChild(Da(e, o, async (k) => await a(e.rating ?? "negative", k) ? (e.reported = !0, e.detailsOpen = !1, m(), !0) : !1));
|
|
2565
2589
|
}
|
|
2566
|
-
return
|
|
2590
|
+
return y(), m(), x;
|
|
2567
2591
|
}
|
|
2568
|
-
function
|
|
2592
|
+
function ti(t, e, o, n, i = !1) {
|
|
2569
2593
|
const a = document.createElement("button");
|
|
2570
|
-
return a.type = "button", a.className = `ago-feedback__thumb ago-feedback__thumb--${t}`, a.setAttribute("aria-label", e), a.title = e, u(a,
|
|
2594
|
+
return a.type = "button", a.className = `ago-feedback__thumb ago-feedback__thumb--${t}`, a.setAttribute("aria-label", e), a.title = e, u(a, Ha), i ? (a.style.margin = "-14px", a.appendChild(t === "up" ? $r({ size: 18 }) : br({ size: 18 }))) : a.appendChild($a(t)), Vn(a, o, n), a.addEventListener("mouseenter", () => {
|
|
2571
2595
|
a.getAttribute("aria-pressed") !== "true" && (a.style.color = n.hover);
|
|
2572
2596
|
}), a.addEventListener("mouseleave", () => {
|
|
2573
2597
|
a.getAttribute("aria-pressed") !== "true" && (a.style.color = n.idle);
|
|
2574
2598
|
}), a;
|
|
2575
2599
|
}
|
|
2576
|
-
function
|
|
2600
|
+
function Vn(t, e, o) {
|
|
2577
2601
|
t.setAttribute("aria-pressed", e ? "true" : "false"), t.style.color = e ? o.active : o.idle;
|
|
2578
2602
|
}
|
|
2579
|
-
function
|
|
2603
|
+
function $a(t) {
|
|
2580
2604
|
const e = "http://www.w3.org/2000/svg", o = document.createElementNS(e, "svg");
|
|
2581
2605
|
o.setAttribute("width", "16"), o.setAttribute("height", "16"), o.setAttribute("viewBox", "0 0 24 24"), o.setAttribute("fill", "none"), o.setAttribute("aria-hidden", "true");
|
|
2582
2606
|
const n = document.createElementNS(e, "path");
|
|
@@ -2584,12 +2608,12 @@ function Ha(t) {
|
|
|
2584
2608
|
const i = document.createElementNS(e, "path");
|
|
2585
2609
|
return i.setAttribute("d", "M7 22V12H4.5A1.5 1.5 0 0 0 3 13.5v7A1.5 1.5 0 0 0 4.5 22z"), i.setAttribute("stroke", "currentColor"), i.setAttribute("stroke-width", "1.8"), i.setAttribute("stroke-linejoin", "round"), o.append(n, i), t === "down" && (o.style.transform = "rotate(180deg)"), o;
|
|
2586
2610
|
}
|
|
2587
|
-
function
|
|
2611
|
+
function Da(t, e, o) {
|
|
2588
2612
|
const n = d({
|
|
2589
2613
|
marginTop: "8px",
|
|
2590
2614
|
padding: "12px",
|
|
2591
2615
|
border: `1px solid ${Q}`,
|
|
2592
|
-
borderRadius:
|
|
2616
|
+
borderRadius: on,
|
|
2593
2617
|
backgroundColor: Ee
|
|
2594
2618
|
});
|
|
2595
2619
|
n.className = "ago-feedback__panel", n.setAttribute("role", "group"), n.setAttribute("aria-label", e.whatWentWrong);
|
|
@@ -2607,9 +2631,9 @@ function Ba(t, e, o) {
|
|
|
2607
2631
|
marginBottom: "8px"
|
|
2608
2632
|
});
|
|
2609
2633
|
a.className = "ago-feedback__reasons";
|
|
2610
|
-
for (const
|
|
2634
|
+
for (const f of ir) {
|
|
2611
2635
|
const p = document.createElement("button");
|
|
2612
|
-
p.type = "button", p.className = "ago-feedback__reason", p.textContent = e.reasons[
|
|
2636
|
+
p.type = "button", p.className = "ago-feedback__reason", p.textContent = e.reasons[f], u(p, {
|
|
2613
2637
|
minHeight: "44px",
|
|
2614
2638
|
padding: "4px 12px",
|
|
2615
2639
|
fontSize: "13px",
|
|
@@ -2620,13 +2644,13 @@ function Ba(t, e, o) {
|
|
|
2620
2644
|
color: ne,
|
|
2621
2645
|
cursor: "pointer"
|
|
2622
2646
|
});
|
|
2623
|
-
const
|
|
2624
|
-
const
|
|
2625
|
-
p.setAttribute("aria-pressed",
|
|
2647
|
+
const b = () => {
|
|
2648
|
+
const F = t.reasons.has(f);
|
|
2649
|
+
p.setAttribute("aria-pressed", F ? "true" : "false"), p.style.borderColor = F ? ct : Q, p.style.color = F ? ct : ne;
|
|
2626
2650
|
};
|
|
2627
2651
|
p.addEventListener("click", () => {
|
|
2628
|
-
t.reasons.has(
|
|
2629
|
-
}),
|
|
2652
|
+
t.reasons.has(f) ? t.reasons.delete(f) : t.reasons.add(f), b(), x();
|
|
2653
|
+
}), b(), a.appendChild(p);
|
|
2630
2654
|
}
|
|
2631
2655
|
n.appendChild(a);
|
|
2632
2656
|
const s = document.createElement("textarea");
|
|
@@ -2642,7 +2666,7 @@ function Ba(t, e, o) {
|
|
|
2642
2666
|
backgroundColor: "transparent",
|
|
2643
2667
|
resize: "vertical"
|
|
2644
2668
|
}), s.addEventListener("input", () => {
|
|
2645
|
-
t.comment = s.value,
|
|
2669
|
+
t.comment = s.value, x();
|
|
2646
2670
|
}), n.appendChild(s);
|
|
2647
2671
|
const c = document.createElement("button");
|
|
2648
2672
|
return c.type = "button", c.className = "ago-feedback__send", c.textContent = e.send, u(c, {
|
|
@@ -2654,30 +2678,30 @@ function Ba(t, e, o) {
|
|
|
2654
2678
|
borderRadius: "10px",
|
|
2655
2679
|
border: "none",
|
|
2656
2680
|
backgroundColor: ve,
|
|
2657
|
-
color:
|
|
2681
|
+
color: lt,
|
|
2658
2682
|
cursor: "pointer"
|
|
2659
2683
|
}), c.addEventListener("click", () => {
|
|
2660
2684
|
c.disabled || (c.disabled = !0, o({
|
|
2661
2685
|
reasons: [...t.reasons],
|
|
2662
2686
|
comment: t.comment.trim()
|
|
2663
|
-
}).then((
|
|
2664
|
-
|
|
2687
|
+
}).then((f) => {
|
|
2688
|
+
f || x();
|
|
2665
2689
|
}));
|
|
2666
|
-
}), n.appendChild(c),
|
|
2667
|
-
function
|
|
2668
|
-
const
|
|
2669
|
-
c.disabled = !
|
|
2690
|
+
}), n.appendChild(c), x(), n;
|
|
2691
|
+
function x() {
|
|
2692
|
+
const f = t.reasons.size > 0 || t.comment.trim().length > 0;
|
|
2693
|
+
c.disabled = !f, c.style.opacity = f ? "1" : "0.5", c.style.cursor = f ? "pointer" : "default";
|
|
2670
2694
|
}
|
|
2671
2695
|
}
|
|
2672
|
-
function
|
|
2696
|
+
function Ma(t) {
|
|
2673
2697
|
const e = d({
|
|
2674
2698
|
marginTop: "6px",
|
|
2675
2699
|
fontSize: "13px",
|
|
2676
|
-
color:
|
|
2700
|
+
color: st
|
|
2677
2701
|
});
|
|
2678
2702
|
return e.className = "ago-feedback__thanks", e.setAttribute("role", "status"), e.textContent = t, e;
|
|
2679
2703
|
}
|
|
2680
|
-
function
|
|
2704
|
+
function ja(t) {
|
|
2681
2705
|
const e = d({
|
|
2682
2706
|
display: "flex",
|
|
2683
2707
|
flexDirection: "column",
|
|
@@ -2713,28 +2737,28 @@ function Da(t) {
|
|
|
2713
2737
|
composerSlot: n
|
|
2714
2738
|
};
|
|
2715
2739
|
}
|
|
2716
|
-
var
|
|
2717
|
-
function
|
|
2718
|
-
const n = t instanceof Date ? t.getTime() : new Date(t).getTime(), i = (p,
|
|
2740
|
+
var Wa = Gn.timeAgo, Ua = 60 * 1e3;
|
|
2741
|
+
function Pa(t, e = Date.now(), o = Wa) {
|
|
2742
|
+
const n = t instanceof Date ? t.getTime() : new Date(t).getTime(), i = (p, b) => p.replace("{n}", String(b));
|
|
2719
2743
|
if (!Number.isFinite(n)) return i(o.minutes, 0);
|
|
2720
|
-
const a = Math.max(0, Math.floor((e - n) /
|
|
2721
|
-
return a < 60 ? i(o.minutes, a) : s < 24 ? i(o.hours, s) : c < 7 ? i(o.days, c) :
|
|
2744
|
+
const a = Math.max(0, Math.floor((e - n) / Ua)), s = Math.floor(a / 60), c = Math.floor(s / 24), x = Math.floor(c / 7), f = Math.max(1, Math.floor(c / 30));
|
|
2745
|
+
return a < 60 ? i(o.minutes, a) : s < 24 ? i(o.hours, s) : c < 7 ? i(o.days, c) : x < 4 ? i(o.weeks, x) : i(o.months, f);
|
|
2722
2746
|
}
|
|
2723
|
-
var
|
|
2724
|
-
function
|
|
2747
|
+
var Va = 7200 * 1e3;
|
|
2748
|
+
function qn(t) {
|
|
2725
2749
|
const e = t.lastMessageDate instanceof Date ? t.lastMessageDate.getTime() : new Date(t.lastMessageDate).getTime();
|
|
2726
2750
|
return Number.isFinite(e) ? e : Number.NEGATIVE_INFINITY;
|
|
2727
2751
|
}
|
|
2728
|
-
function
|
|
2729
|
-
return [...t].sort((e, o) =>
|
|
2752
|
+
function _i(t) {
|
|
2753
|
+
return [...t].sort((e, o) => qn(o) - qn(e));
|
|
2730
2754
|
}
|
|
2731
|
-
function
|
|
2732
|
-
const n =
|
|
2755
|
+
function qa(t, e = Date.now(), o = Va) {
|
|
2756
|
+
const n = _i(t)[0];
|
|
2733
2757
|
if (!n) return null;
|
|
2734
|
-
const i =
|
|
2758
|
+
const i = qn(n);
|
|
2735
2759
|
return Number.isFinite(i) && e - i < o ? n : null;
|
|
2736
2760
|
}
|
|
2737
|
-
function
|
|
2761
|
+
function Ga(t) {
|
|
2738
2762
|
const e = d({
|
|
2739
2763
|
position: "relative",
|
|
2740
2764
|
display: "flex",
|
|
@@ -2758,7 +2782,7 @@ function Va(t) {
|
|
|
2758
2782
|
bottom: "0",
|
|
2759
2783
|
zIndex: "10",
|
|
2760
2784
|
padding: "32px 16px 16px",
|
|
2761
|
-
backgroundImage: `linear-gradient(to top, ${
|
|
2785
|
+
backgroundImage: `linear-gradient(to top, ${On} 72px, transparent 104px)`
|
|
2762
2786
|
});
|
|
2763
2787
|
n.className = "ago-chat-widget__new-strip";
|
|
2764
2788
|
const i = document.createElement("button");
|
|
@@ -2783,9 +2807,9 @@ function Va(t) {
|
|
|
2783
2807
|
fontSize: "14px",
|
|
2784
2808
|
lineHeight: "20px",
|
|
2785
2809
|
fontWeight: "500"
|
|
2786
|
-
}), i.append(
|
|
2810
|
+
}), i.append(Xn({ size: 16 }), a), i.addEventListener("click", t.onNew), n.appendChild(i), e.append(o, n);
|
|
2787
2811
|
const s = (p) => {
|
|
2788
|
-
t.customFont ? p.style.opacity = "0.7" : p.style.color =
|
|
2812
|
+
t.customFont ? p.style.opacity = "0.7" : p.style.color = $n;
|
|
2789
2813
|
};
|
|
2790
2814
|
function c() {
|
|
2791
2815
|
const p = d({
|
|
@@ -2796,16 +2820,16 @@ function Va(t) {
|
|
|
2796
2820
|
paddingBottom: "112px"
|
|
2797
2821
|
});
|
|
2798
2822
|
p.className = "ago-chat-widget__history-loading";
|
|
2799
|
-
const
|
|
2823
|
+
const b = d({
|
|
2800
2824
|
width: "32px",
|
|
2801
2825
|
height: "32px",
|
|
2802
2826
|
borderRadius: "50%",
|
|
2803
2827
|
borderBottom: `2px solid ${ve}`,
|
|
2804
2828
|
animation: "ago-spin 1s linear infinite"
|
|
2805
2829
|
});
|
|
2806
|
-
|
|
2830
|
+
b.setAttribute("role", "status"), p.appendChild(b), o.replaceChildren(p);
|
|
2807
2831
|
}
|
|
2808
|
-
function
|
|
2832
|
+
function x() {
|
|
2809
2833
|
const p = d({
|
|
2810
2834
|
display: "flex",
|
|
2811
2835
|
flex: "1",
|
|
@@ -2814,27 +2838,27 @@ function Va(t) {
|
|
|
2814
2838
|
justifyContent: "center"
|
|
2815
2839
|
});
|
|
2816
2840
|
p.className = "ago-chat-widget__history-empty", s(p);
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2819
|
-
const
|
|
2820
|
-
|
|
2841
|
+
const b = di({ size: 36 });
|
|
2842
|
+
b.style.marginBottom = "8px";
|
|
2843
|
+
const F = document.createElement("p");
|
|
2844
|
+
F.textContent = t.labels.noHistory, u(F, {
|
|
2821
2845
|
fontSize: "14px",
|
|
2822
2846
|
lineHeight: "20px",
|
|
2823
2847
|
margin: "0"
|
|
2824
|
-
}), p.append(
|
|
2848
|
+
}), p.append(b, F), o.replaceChildren(p);
|
|
2825
2849
|
}
|
|
2826
|
-
function
|
|
2827
|
-
const
|
|
2850
|
+
function f(p) {
|
|
2851
|
+
const b = d({
|
|
2828
2852
|
flex: "1",
|
|
2829
2853
|
overflowY: "auto",
|
|
2830
2854
|
padding: "0 16px 112px",
|
|
2831
2855
|
minHeight: "0"
|
|
2832
2856
|
});
|
|
2833
|
-
|
|
2834
|
-
const
|
|
2835
|
-
|
|
2836
|
-
const
|
|
2837
|
-
if (
|
|
2857
|
+
b.className = "ago-chat-widget__history-list";
|
|
2858
|
+
const F = _i(p);
|
|
2859
|
+
F.forEach((y, m) => {
|
|
2860
|
+
const k = document.createElement("button");
|
|
2861
|
+
if (k.type = "button", k.className = "ago-chat-widget__thread", k.dataset.agoConversationId = y.id, u(k, {
|
|
2838
2862
|
display: "flex",
|
|
2839
2863
|
alignItems: "center",
|
|
2840
2864
|
gap: "8px",
|
|
@@ -2843,26 +2867,26 @@ function Va(t) {
|
|
|
2843
2867
|
textAlign: "left",
|
|
2844
2868
|
backgroundColor: "transparent",
|
|
2845
2869
|
border: "none",
|
|
2846
|
-
borderBottom:
|
|
2870
|
+
borderBottom: m === F.length - 1 ? "none" : `1px solid ${kr}`,
|
|
2847
2871
|
cursor: "pointer",
|
|
2848
2872
|
font: "inherit",
|
|
2849
2873
|
color: "inherit"
|
|
2850
2874
|
}), t.hoverBackground) {
|
|
2851
|
-
const
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
}),
|
|
2855
|
-
|
|
2875
|
+
const w = t.hoverBackground;
|
|
2876
|
+
k.addEventListener("mouseenter", () => {
|
|
2877
|
+
k.style.backgroundColor = w;
|
|
2878
|
+
}), k.addEventListener("mouseleave", () => {
|
|
2879
|
+
k.style.backgroundColor = "transparent";
|
|
2856
2880
|
});
|
|
2857
2881
|
}
|
|
2858
|
-
const
|
|
2882
|
+
const N = d({
|
|
2859
2883
|
flex: "1",
|
|
2860
2884
|
minWidth: "0",
|
|
2861
2885
|
display: "flex",
|
|
2862
2886
|
flexDirection: "column",
|
|
2863
2887
|
gap: "4px"
|
|
2864
|
-
}),
|
|
2865
|
-
|
|
2888
|
+
}), _ = document.createElement("h3");
|
|
2889
|
+
_.textContent = y.title || t.labels.newConversation, u(_, {
|
|
2866
2890
|
margin: "0",
|
|
2867
2891
|
fontSize: "14px",
|
|
2868
2892
|
lineHeight: "20px",
|
|
@@ -2872,23 +2896,23 @@ function Va(t) {
|
|
|
2872
2896
|
overflow: "hidden",
|
|
2873
2897
|
textOverflow: "ellipsis"
|
|
2874
2898
|
});
|
|
2875
|
-
const
|
|
2876
|
-
|
|
2899
|
+
const I = document.createElement("span");
|
|
2900
|
+
I.textContent = Pa(y.lastMessageDate, Date.now(), t.labels.timeAgo), u(I, {
|
|
2877
2901
|
fontSize: "12px",
|
|
2878
2902
|
lineHeight: "16px"
|
|
2879
|
-
}), s(
|
|
2880
|
-
const j =
|
|
2881
|
-
t.customFont ? j.style.opacity = "0.6" : j.style.color = ve,
|
|
2882
|
-
}), o.replaceChildren(
|
|
2903
|
+
}), s(I), N.append(_, I);
|
|
2904
|
+
const j = Hr({ size: 16 });
|
|
2905
|
+
t.customFont ? j.style.opacity = "0.6" : j.style.color = ve, k.append(N, j), k.addEventListener("click", () => t.onSelect(y)), b.appendChild(k);
|
|
2906
|
+
}), o.replaceChildren(b);
|
|
2883
2907
|
}
|
|
2884
2908
|
return {
|
|
2885
2909
|
el: e,
|
|
2886
|
-
render: ({ threads: p, loading:
|
|
2887
|
-
a.textContent = t.labels.newConversation,
|
|
2910
|
+
render: ({ threads: p, loading: b }) => {
|
|
2911
|
+
a.textContent = t.labels.newConversation, b ? c() : p.length === 0 ? x() : f(p);
|
|
2888
2912
|
}
|
|
2889
2913
|
};
|
|
2890
2914
|
}
|
|
2891
|
-
function
|
|
2915
|
+
function Xa(t) {
|
|
2892
2916
|
const e = d({
|
|
2893
2917
|
position: "relative",
|
|
2894
2918
|
display: "flex",
|
|
@@ -2935,18 +2959,18 @@ function qa(t) {
|
|
|
2935
2959
|
maxWidth: "512px"
|
|
2936
2960
|
});
|
|
2937
2961
|
a.className = "ago-chat-widget__home-subtitle", n.appendChild(a);
|
|
2938
|
-
const s = (
|
|
2962
|
+
const s = (w) => {
|
|
2939
2963
|
i.replaceChildren();
|
|
2940
|
-
for (const
|
|
2964
|
+
for (const O of w.split(`
|
|
2941
2965
|
`)) {
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2966
|
+
const E = d({});
|
|
2967
|
+
E.textContent = O, i.appendChild(E);
|
|
2944
2968
|
}
|
|
2945
|
-
}, c = (
|
|
2946
|
-
a.replaceChildren(), a.style.display =
|
|
2969
|
+
}, c = (w) => {
|
|
2970
|
+
a.replaceChildren(), a.style.display = w ? "" : "none", w && a.appendChild(Ye(w));
|
|
2947
2971
|
};
|
|
2948
2972
|
s(t.title), c(t.subtitle);
|
|
2949
|
-
const
|
|
2973
|
+
const x = d({
|
|
2950
2974
|
flex: "1",
|
|
2951
2975
|
display: "flex",
|
|
2952
2976
|
flexDirection: "column",
|
|
@@ -2954,7 +2978,7 @@ function qa(t) {
|
|
|
2954
2978
|
justifyContent: "center",
|
|
2955
2979
|
width: "100%",
|
|
2956
2980
|
position: "relative"
|
|
2957
|
-
}),
|
|
2981
|
+
}), f = d({
|
|
2958
2982
|
display: "grid",
|
|
2959
2983
|
gridTemplateColumns: "1fr",
|
|
2960
2984
|
gap: "12px",
|
|
@@ -2964,35 +2988,35 @@ function qa(t) {
|
|
|
2964
2988
|
padding: "0 16px",
|
|
2965
2989
|
boxSizing: "border-box"
|
|
2966
2990
|
});
|
|
2967
|
-
|
|
2991
|
+
f.className = "ago-chat-widget__starters";
|
|
2968
2992
|
const p = [];
|
|
2969
|
-
let
|
|
2970
|
-
const
|
|
2971
|
-
|
|
2972
|
-
for (const
|
|
2973
|
-
|
|
2993
|
+
let b = null;
|
|
2994
|
+
const F = (w) => {
|
|
2995
|
+
f.replaceChildren(), p.length = 0;
|
|
2996
|
+
for (const O of w) y(O);
|
|
2997
|
+
w.length > 0 ? f.parentNode || x.insertBefore(f, m) : f.remove();
|
|
2974
2998
|
};
|
|
2975
|
-
function
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2999
|
+
function y(w) {
|
|
3000
|
+
const O = document.createElement("button");
|
|
3001
|
+
O.type = "button", O.className = "ago-chat-widget__starter", u(O, {
|
|
2978
3002
|
textAlign: "left",
|
|
2979
3003
|
borderRadius: "12px",
|
|
2980
3004
|
border: "1px solid rgba(228, 228, 231, 0.6)",
|
|
2981
3005
|
backgroundColor: "#fff",
|
|
2982
3006
|
padding: "14px 16px",
|
|
2983
|
-
boxShadow:
|
|
3007
|
+
boxShadow: en,
|
|
2984
3008
|
transition: "all 0.2s",
|
|
2985
3009
|
cursor: "pointer",
|
|
2986
3010
|
font: "inherit",
|
|
2987
3011
|
color: ne,
|
|
2988
3012
|
position: "relative"
|
|
2989
3013
|
});
|
|
2990
|
-
const
|
|
3014
|
+
const E = d({
|
|
2991
3015
|
display: "flex",
|
|
2992
3016
|
alignItems: "flex-start",
|
|
2993
3017
|
justifyContent: "space-between",
|
|
2994
3018
|
gap: "8px"
|
|
2995
|
-
}),
|
|
3019
|
+
}), S = d({
|
|
2996
3020
|
minWidth: "0",
|
|
2997
3021
|
flex: "1",
|
|
2998
3022
|
fontSize: "14px",
|
|
@@ -3000,52 +3024,52 @@ function qa(t) {
|
|
|
3000
3024
|
display: "-webkit-box",
|
|
3001
3025
|
overflow: "hidden"
|
|
3002
3026
|
});
|
|
3003
|
-
|
|
3004
|
-
const
|
|
3005
|
-
u(
|
|
3027
|
+
S.style.setProperty("-webkit-line-clamp", "2"), S.style.setProperty("-webkit-box-orient", "vertical"), S.textContent = w.label;
|
|
3028
|
+
const R = Fr({ size: 16 });
|
|
3029
|
+
u(R, {
|
|
3006
3030
|
marginTop: "2px",
|
|
3007
3031
|
color: "rgba(113, 113, 122, 0.5)",
|
|
3008
3032
|
transition: "all 0.15s"
|
|
3009
|
-
}),
|
|
3010
|
-
|
|
3011
|
-
}),
|
|
3012
|
-
|
|
3013
|
-
}),
|
|
3014
|
-
|
|
3033
|
+
}), E.append(S, R), O.appendChild(E), O.addEventListener("mouseenter", () => {
|
|
3034
|
+
O.disabled || (O.style.borderColor = "#e4e4e7", O.style.boxShadow = li, O.style.transform = "translateY(-2px)", R.style.color = ne, R.style.transform = "translate(2px, -2px)");
|
|
3035
|
+
}), O.addEventListener("mouseleave", () => {
|
|
3036
|
+
O.style.borderColor = "rgba(228, 228, 231, 0.6)", O.style.boxShadow = en, O.style.transform = "", R.style.color = "rgba(113, 113, 122, 0.5)", R.style.transform = "";
|
|
3037
|
+
}), O.addEventListener("click", () => {
|
|
3038
|
+
b || t.onStarter(w);
|
|
3015
3039
|
}), p.push({
|
|
3016
|
-
starter:
|
|
3017
|
-
btn:
|
|
3018
|
-
}),
|
|
3040
|
+
starter: w,
|
|
3041
|
+
btn: O
|
|
3042
|
+
}), f.appendChild(O);
|
|
3019
3043
|
}
|
|
3020
|
-
const
|
|
3021
|
-
|
|
3022
|
-
const
|
|
3023
|
-
o.append(n,
|
|
3024
|
-
const
|
|
3025
|
-
const
|
|
3026
|
-
|
|
3044
|
+
const m = d({ width: "100%" });
|
|
3045
|
+
m.className = "ago-chat-widget__home-composer", x.appendChild(m), F(t.starters);
|
|
3046
|
+
const k = d({ flex: "1" });
|
|
3047
|
+
o.append(n, x, k), e.appendChild(o);
|
|
3048
|
+
const N = t.twoColumnsFrom ?? 640, _ = () => {
|
|
3049
|
+
const w = typeof window < "u" && window.innerWidth >= N;
|
|
3050
|
+
f.style.gridTemplateColumns = w ? "1fr 1fr" : "1fr";
|
|
3027
3051
|
};
|
|
3028
|
-
|
|
3029
|
-
const
|
|
3030
|
-
|
|
3031
|
-
for (const { starter:
|
|
3032
|
-
const
|
|
3033
|
-
|
|
3034
|
-
const
|
|
3035
|
-
|
|
3052
|
+
_();
|
|
3053
|
+
const I = (w) => {
|
|
3054
|
+
b = w;
|
|
3055
|
+
for (const { starter: O, btn: E } of p) {
|
|
3056
|
+
const S = O === w;
|
|
3057
|
+
E.disabled = !!w, E.style.opacity = w ? "0.6" : "", E.style.cursor = w ? "not-allowed" : "pointer";
|
|
3058
|
+
const R = E.querySelector("svg");
|
|
3059
|
+
R && (R.style.animation = S ? "ago-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite" : "");
|
|
3036
3060
|
}
|
|
3037
3061
|
};
|
|
3038
3062
|
return {
|
|
3039
3063
|
el: e,
|
|
3040
|
-
composerSlot:
|
|
3041
|
-
syncColumns:
|
|
3042
|
-
setPending:
|
|
3043
|
-
setContent: (
|
|
3044
|
-
|
|
3064
|
+
composerSlot: m,
|
|
3065
|
+
syncColumns: _,
|
|
3066
|
+
setPending: I,
|
|
3067
|
+
setContent: (w) => {
|
|
3068
|
+
w.title !== void 0 && s(w.title), w.subtitle !== void 0 && c(w.subtitle), w.starters && (F(w.starters), _(), b && I(b));
|
|
3045
3069
|
}
|
|
3046
3070
|
};
|
|
3047
3071
|
}
|
|
3048
|
-
function
|
|
3072
|
+
function Ka(t) {
|
|
3049
3073
|
const e = d({
|
|
3050
3074
|
position: "fixed",
|
|
3051
3075
|
bottom: "80px",
|
|
@@ -3066,7 +3090,7 @@ function Ga(t) {
|
|
|
3066
3090
|
background: "#fff",
|
|
3067
3091
|
border: "1px solid #efefef",
|
|
3068
3092
|
borderRadius: "50%",
|
|
3069
|
-
boxShadow:
|
|
3093
|
+
boxShadow: Mn,
|
|
3070
3094
|
color: "#333",
|
|
3071
3095
|
cursor: "pointer",
|
|
3072
3096
|
display: "inline-block",
|
|
@@ -3085,7 +3109,7 @@ function Ga(t) {
|
|
|
3085
3109
|
alignItems: "center",
|
|
3086
3110
|
backgroundColor: "#fff",
|
|
3087
3111
|
borderRadius: "16px",
|
|
3088
|
-
boxShadow:
|
|
3112
|
+
boxShadow: Mn,
|
|
3089
3113
|
color: "#333",
|
|
3090
3114
|
display: "flex",
|
|
3091
3115
|
fontFamily: "Arial, Helvetica, sans-serif",
|
|
@@ -3120,7 +3144,7 @@ function Ga(t) {
|
|
|
3120
3144
|
remove: a
|
|
3121
3145
|
};
|
|
3122
3146
|
}
|
|
3123
|
-
function
|
|
3147
|
+
function Ya(t) {
|
|
3124
3148
|
if (typeof t == "string") return t || null;
|
|
3125
3149
|
if (!t || typeof t != "object") return null;
|
|
3126
3150
|
const e = t;
|
|
@@ -3133,94 +3157,94 @@ function Xa(t) {
|
|
|
3133
3157
|
}
|
|
3134
3158
|
return null;
|
|
3135
3159
|
}
|
|
3136
|
-
var
|
|
3137
|
-
function
|
|
3160
|
+
var Qa = 0, Za = 6, Ja = 800, es = /^(?:\d+(?:\.\d+)?(?:px|rem|em|vw|vmin|vmax|%)|(?:min|max|clamp|calc)\([^;{}]+\))$/i;
|
|
3161
|
+
function ts(t) {
|
|
3138
3162
|
const e = typeof t == "number" ? `${t}px` : String(t).trim();
|
|
3139
|
-
return !
|
|
3163
|
+
return !es.test(e) || typeof CSS < "u" && typeof CSS.supports == "function" && !CSS.supports("width", `min(max(400px, ${e}), 100% - 40px)`) ? null : e;
|
|
3140
3164
|
}
|
|
3141
|
-
function
|
|
3165
|
+
function ns(t) {
|
|
3142
3166
|
const e = typeof t == "string" ? document.querySelector(t) : t;
|
|
3143
3167
|
if (!e) throw new Error(`mountChatWidget: target "${String(t)}" not found.`);
|
|
3144
3168
|
return e;
|
|
3145
3169
|
}
|
|
3146
|
-
function
|
|
3170
|
+
function ms(t, e) {
|
|
3147
3171
|
const o = e.placement ?? "inline", n = o === "bubble";
|
|
3148
|
-
if (!e.client && !e.config?.baseUrl) throw new
|
|
3149
|
-
const i = e.client ?? new
|
|
3150
|
-
let a = i.getLanguage?.() ?? null, s =
|
|
3151
|
-
const { welcomeMessage: c = s.common.welcome, allowFiles:
|
|
3172
|
+
if (!e.client && !e.config?.baseUrl) throw new rr("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
|
|
3173
|
+
const i = e.client ?? new or(e.config);
|
|
3174
|
+
let a = i.getLanguage?.() ?? null, s = We(a);
|
|
3175
|
+
const { welcomeMessage: c = s.common.welcome, allowFiles: x = !1, allowStop: f = !0, autoScroll: p = !0, height: b = 500, defaultOpen: F = !1, logoUrl: y, showAgentName: m = !1, agentBubble: k = !1, bubbleStyle: N = "default", showHeader: _ = !0, forms: I, formSubmittedMessage: j, onFollowUpClick: w, onMessageSent: O, onMessageReceived: E, onFormSubmitting: S, onFormSubmitted: R, onFormError: H, onOpen: $, onClose: W, icon: q, subtitle: v, conversationStarters: z = [], autoResume: K = !0, hideFooter: G = !1, loadHomeConfig: ee = !1 } = e;
|
|
3152
3176
|
let Y = e.title ?? (n ? "AGO Chatbot" : s.common.chat);
|
|
3153
|
-
const
|
|
3154
|
-
let oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder),
|
|
3155
|
-
const
|
|
3156
|
-
...
|
|
3177
|
+
const g = e.width ?? (n ? 550 : 400), B = e.loadThreads ?? n, P = e.feedback ?? n, D = Vo(e.labels, a);
|
|
3178
|
+
let oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), ge = e.prompt === void 0 ? s.common.prompt : e.prompt;
|
|
3179
|
+
const ae = n ? {
|
|
3180
|
+
...Ir(e.colors),
|
|
3157
3181
|
...e.theme
|
|
3158
|
-
} : e.theme,
|
|
3182
|
+
} : e.theme, Qe = typeof c == "string" ? {
|
|
3159
3183
|
message: c,
|
|
3160
3184
|
mode: "static"
|
|
3161
3185
|
} : c;
|
|
3162
|
-
let
|
|
3163
|
-
const
|
|
3164
|
-
let ie =
|
|
3165
|
-
const
|
|
3186
|
+
let an = Qe.message;
|
|
3187
|
+
const Yn = Qe.mode ?? "static", Ti = "speed" in Qe && Qe.speed || 45, Qn = "followUpReplies" in Qe && Qe.followUpReplies || void 0, sn = ns(t), It = o === "left" || o === "right", he = It || n, Ai = he && (e.launcher ?? !0);
|
|
3188
|
+
let ie = he ? F : !0, ln = !1;
|
|
3189
|
+
const Fi = e.mobile?.breakpoint ?? (n ? 450 : 768), cn = e.mobile?.trigger ?? "tap", Zn = typeof window < "u" && !!window.matchMedia, ce = Zn ? window.matchMedia(`(max-width: ${Fi}px), (max-height: 500px) and (orientation: landscape)`) : void 0, Li = Zn ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Ni = !!ce, dt = !he && !!ce, pt = /* @__PURE__ */ Symbol("ago-scroll-lock");
|
|
3166
3190
|
let re = !1;
|
|
3167
|
-
const
|
|
3168
|
-
let J = e.conversationId ??
|
|
3169
|
-
const
|
|
3170
|
-
function
|
|
3191
|
+
const dn = e.persistConversation ?? (n ? !0 : void 0), Ze = dn ? ar(dn === !0 ? {} : dn) : void 0;
|
|
3192
|
+
let J = e.conversationId ?? Ze?.getLastActiveThread() ?? void 0, L = [], Rt = [], be = !1, Ae = null, ze;
|
|
3193
|
+
const ut = [];
|
|
3194
|
+
function Ii(r) {
|
|
3171
3195
|
if (typeof j == "function") {
|
|
3172
|
-
const
|
|
3173
|
-
if (typeof
|
|
3196
|
+
const h = j(r);
|
|
3197
|
+
if (typeof h == "string" && h) return h;
|
|
3174
3198
|
}
|
|
3175
|
-
const l =
|
|
3199
|
+
const l = Ya(r);
|
|
3176
3200
|
return l || (typeof j == "string" ? j : null);
|
|
3177
3201
|
}
|
|
3178
3202
|
const ke = [], A = d({
|
|
3179
3203
|
display: "flex",
|
|
3180
3204
|
flexDirection: "column",
|
|
3181
|
-
height:
|
|
3205
|
+
height: It ? "100%" : typeof b == "number" ? `${b}px` : b,
|
|
3182
3206
|
border: `1px solid ${Q}`,
|
|
3183
|
-
borderRadius:
|
|
3207
|
+
borderRadius: ur,
|
|
3184
3208
|
overflow: "hidden",
|
|
3185
3209
|
backgroundColor: Ee,
|
|
3186
3210
|
fontFamily: Re,
|
|
3187
3211
|
textAlign: "left",
|
|
3188
3212
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
3189
3213
|
});
|
|
3190
|
-
A.className = "ago-chat-widget",
|
|
3214
|
+
A.className = "ago-chat-widget", In(A, ae), n && (u(A, {
|
|
3191
3215
|
height: "100%",
|
|
3192
3216
|
width: "100%",
|
|
3193
3217
|
border: "none",
|
|
3194
3218
|
borderRadius: "0",
|
|
3195
3219
|
boxShadow: "none",
|
|
3196
|
-
backgroundColor:
|
|
3220
|
+
backgroundColor: On,
|
|
3197
3221
|
color: ne,
|
|
3198
3222
|
fontSize: "14px",
|
|
3199
3223
|
lineHeight: "24px"
|
|
3200
|
-
}),
|
|
3201
|
-
let
|
|
3202
|
-
if (
|
|
3203
|
-
if (
|
|
3224
|
+
}), ae?.headerText || A.style.setProperty("--ago-header-text-color", _r(ae?.headerBg ?? ae?.brand ?? "#03182f")));
|
|
3225
|
+
let xe;
|
|
3226
|
+
if (_ && !n) {
|
|
3227
|
+
if (xe = d({
|
|
3204
3228
|
padding: "14px 16px",
|
|
3205
3229
|
borderBottom: `1px solid ${Q}`,
|
|
3206
|
-
backgroundColor:
|
|
3207
|
-
color:
|
|
3230
|
+
backgroundColor: ai,
|
|
3231
|
+
color: Hn,
|
|
3208
3232
|
display: "flex",
|
|
3209
3233
|
alignItems: "center",
|
|
3210
3234
|
gap: "10px"
|
|
3211
|
-
}),
|
|
3235
|
+
}), xe.className = "ago-chat-widget__header", y) {
|
|
3212
3236
|
const l = document.createElement("img");
|
|
3213
|
-
l.src =
|
|
3237
|
+
l.src = y, l.alt = "Logo", u(l, {
|
|
3214
3238
|
height: "24px",
|
|
3215
3239
|
width: "auto"
|
|
3216
|
-
}),
|
|
3240
|
+
}), xe.appendChild(l);
|
|
3217
3241
|
}
|
|
3218
3242
|
const r = document.createElement("h3");
|
|
3219
3243
|
if (r.className = "ago-chat-widget__title", r.textContent = Y, u(r, {
|
|
3220
3244
|
margin: "0",
|
|
3221
3245
|
fontSize: "15px",
|
|
3222
3246
|
fontWeight: "600"
|
|
3223
|
-
}),
|
|
3247
|
+
}), xe.appendChild(r), It) {
|
|
3224
3248
|
const l = document.createElement("button");
|
|
3225
3249
|
l.type = "button", l.className = "ago-chat-widget__close", l.setAttribute("aria-label", s.common.close), l.textContent = "×", u(l, {
|
|
3226
3250
|
marginLeft: "auto",
|
|
@@ -3233,12 +3257,12 @@ function us(t, e) {
|
|
|
3233
3257
|
margin: "-10px -10px -10px auto",
|
|
3234
3258
|
background: "transparent",
|
|
3235
3259
|
border: "none",
|
|
3236
|
-
color:
|
|
3260
|
+
color: Hn,
|
|
3237
3261
|
fontSize: "22px",
|
|
3238
3262
|
lineHeight: "1",
|
|
3239
3263
|
cursor: "pointer",
|
|
3240
3264
|
padding: "0"
|
|
3241
|
-
}), l.addEventListener("click", () =>
|
|
3265
|
+
}), l.addEventListener("click", () => ot()), xe.appendChild(l);
|
|
3242
3266
|
}
|
|
3243
3267
|
}
|
|
3244
3268
|
const te = d({
|
|
@@ -3247,10 +3271,10 @@ function us(t, e) {
|
|
|
3247
3271
|
overflowAnchor: p ? "auto" : "none",
|
|
3248
3272
|
overscrollBehavior: "contain",
|
|
3249
3273
|
padding: "16px",
|
|
3250
|
-
backgroundColor:
|
|
3274
|
+
backgroundColor: si
|
|
3251
3275
|
});
|
|
3252
3276
|
te.className = "ago-chat-widget__messages", te.setAttribute("role", "log"), te.setAttribute("aria-live", "polite"), te.setAttribute("aria-relevant", "additions text"), te.setAttribute("aria-atomic", "false");
|
|
3253
|
-
const
|
|
3277
|
+
const ye = n ? d({
|
|
3254
3278
|
maxWidth: "768px",
|
|
3255
3279
|
margin: "0 auto",
|
|
3256
3280
|
padding: "0 8px",
|
|
@@ -3259,22 +3283,22 @@ function us(t, e) {
|
|
|
3259
3283
|
n && (u(te, {
|
|
3260
3284
|
padding: "16px 0",
|
|
3261
3285
|
backgroundColor: "transparent"
|
|
3262
|
-
}),
|
|
3263
|
-
const
|
|
3264
|
-
let Oe = !0,
|
|
3265
|
-
function
|
|
3266
|
-
|
|
3286
|
+
}), ye.className = "ago-chat-widget__list", te.appendChild(ye));
|
|
3287
|
+
const Ri = 48;
|
|
3288
|
+
let Oe = !0, pn = 0;
|
|
3289
|
+
function un(r) {
|
|
3290
|
+
pn++;
|
|
3267
3291
|
try {
|
|
3268
3292
|
r();
|
|
3269
3293
|
} finally {
|
|
3270
3294
|
const l = () => {
|
|
3271
|
-
|
|
3295
|
+
pn--;
|
|
3272
3296
|
};
|
|
3273
3297
|
typeof queueMicrotask == "function" ? queueMicrotask(l) : l();
|
|
3274
3298
|
}
|
|
3275
3299
|
}
|
|
3276
|
-
function
|
|
3277
|
-
return te.scrollHeight - te.scrollTop - te.clientHeight <=
|
|
3300
|
+
function Jn() {
|
|
3301
|
+
return te.scrollHeight - te.scrollTop - te.clientHeight <= Ri;
|
|
3278
3302
|
}
|
|
3279
3303
|
const le = document.createElement("button");
|
|
3280
3304
|
le.type = "button", le.className = "ago-chat-widget__jump", le.setAttribute("aria-label", s.common.jumpToLatest), le.innerHTML = '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 5v14M19 12l-7 7-7-7"/></svg>', u(le, {
|
|
@@ -3294,64 +3318,64 @@ function us(t, e) {
|
|
|
3294
3318
|
boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
|
|
3295
3319
|
cursor: "pointer",
|
|
3296
3320
|
zIndex: "2"
|
|
3297
|
-
}), n && (le.setAttribute("aria-label", D.scrollToBottom), le.replaceChildren(
|
|
3321
|
+
}), n && (le.setAttribute("aria-label", D.scrollToBottom), le.replaceChildren(hr({ size: 20 })), u(le, {
|
|
3298
3322
|
display: "flex",
|
|
3299
3323
|
width: "36px",
|
|
3300
3324
|
height: "36px",
|
|
3301
3325
|
padding: "8px",
|
|
3302
3326
|
boxSizing: "border-box",
|
|
3303
|
-
border: `1px solid ${
|
|
3327
|
+
border: `1px solid ${ri}`,
|
|
3304
3328
|
backgroundColor: "#fff",
|
|
3305
|
-
boxShadow:
|
|
3329
|
+
boxShadow: li,
|
|
3306
3330
|
transition: "opacity 0.3s",
|
|
3307
3331
|
opacity: "0",
|
|
3308
3332
|
pointerEvents: "none"
|
|
3309
3333
|
}));
|
|
3310
|
-
function
|
|
3311
|
-
Oe = !0,
|
|
3334
|
+
function eo() {
|
|
3335
|
+
Oe = !0, un(() => {
|
|
3312
3336
|
te.scrollTop = te.scrollHeight;
|
|
3313
|
-
}),
|
|
3337
|
+
}), fn();
|
|
3314
3338
|
}
|
|
3315
|
-
le.addEventListener("click",
|
|
3316
|
-
function
|
|
3317
|
-
const r = p ? Oe :
|
|
3339
|
+
le.addEventListener("click", eo);
|
|
3340
|
+
function fn() {
|
|
3341
|
+
const r = p ? Oe : Jn();
|
|
3318
3342
|
if (n) {
|
|
3319
3343
|
le.style.opacity = r ? "0" : "1", le.style.pointerEvents = r ? "none" : "auto";
|
|
3320
3344
|
return;
|
|
3321
3345
|
}
|
|
3322
3346
|
le.style.display = r ? "none" : "flex";
|
|
3323
3347
|
}
|
|
3324
|
-
function
|
|
3325
|
-
p && Oe &&
|
|
3348
|
+
function mn() {
|
|
3349
|
+
p && Oe && un(() => {
|
|
3326
3350
|
te.scrollTop = te.scrollHeight;
|
|
3327
|
-
}),
|
|
3351
|
+
}), fn();
|
|
3328
3352
|
}
|
|
3329
|
-
function
|
|
3330
|
-
|
|
3353
|
+
function to(r) {
|
|
3354
|
+
un(() => {
|
|
3331
3355
|
const l = te.scrollTop;
|
|
3332
3356
|
r(), (!p || !Oe) && (te.scrollTop = l);
|
|
3333
|
-
}),
|
|
3357
|
+
}), mn();
|
|
3334
3358
|
}
|
|
3335
3359
|
te.addEventListener("scroll", () => {
|
|
3336
|
-
|
|
3360
|
+
pn > 0 || (Oe = Jn(), fn());
|
|
3337
3361
|
});
|
|
3338
|
-
const
|
|
3362
|
+
const gn = d({
|
|
3339
3363
|
position: "relative",
|
|
3340
3364
|
flex: "1",
|
|
3341
3365
|
display: "flex",
|
|
3342
3366
|
minHeight: "0"
|
|
3343
3367
|
});
|
|
3344
|
-
|
|
3345
|
-
const { inputRow: Se, setDisabled:
|
|
3368
|
+
gn.append(te, le);
|
|
3369
|
+
const { inputRow: Se, setDisabled: zi, focus: zt, restoreDraft: Oi, setPlaceholder: hn, getValueAndClear: Hi, setSpeechToTextEnabled: Bi, setLabels: $i, cancelRecording: ft, destroy: Di } = jr({
|
|
3346
3370
|
placeholder: oe,
|
|
3347
|
-
allowFiles:
|
|
3371
|
+
allowFiles: x,
|
|
3348
3372
|
transcribeAudio: e.speechToText ? (r, l) => i.transcribeAudio(r, l) : void 0,
|
|
3349
3373
|
speechToTextLabels: Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0),
|
|
3350
3374
|
onSend: (r, l) => {
|
|
3351
|
-
|
|
3375
|
+
nt(r, l);
|
|
3352
3376
|
},
|
|
3353
|
-
onStop:
|
|
3354
|
-
|
|
3377
|
+
onStop: f ? () => {
|
|
3378
|
+
Vt();
|
|
3355
3379
|
} : void 0,
|
|
3356
3380
|
look: n ? "embed" : "classic",
|
|
3357
3381
|
labels: {
|
|
@@ -3362,76 +3386,76 @@ function us(t, e) {
|
|
|
3362
3386
|
removeFile: s.form.removeFile
|
|
3363
3387
|
}
|
|
3364
3388
|
});
|
|
3365
|
-
|
|
3366
|
-
re ||
|
|
3389
|
+
Lr(), e.speechToText && i.getConfig().then((r) => {
|
|
3390
|
+
re || Bi(r.permissions.some((l) => l.speechToTextEnabled));
|
|
3367
3391
|
}).catch(() => {
|
|
3368
|
-
}), n || A.append(...
|
|
3369
|
-
let
|
|
3370
|
-
const
|
|
3371
|
-
let
|
|
3392
|
+
}), n || A.append(...xe ? [xe] : [], gn, Se);
|
|
3393
|
+
let mt = A, U, pe, Ot;
|
|
3394
|
+
const gt = o === "left" ? "left" : "right";
|
|
3395
|
+
let Ht, ht, Fe, Ue, Bt, bt, de, Pe, Je, ue = "home", $t = "home", et = !1, xt = B, yt = !1, Ct = !1, bn;
|
|
3372
3396
|
if (n) {
|
|
3373
3397
|
if (U = d({
|
|
3374
3398
|
position: "fixed",
|
|
3375
3399
|
right: "20px",
|
|
3376
3400
|
bottom: "80px",
|
|
3377
3401
|
top: "max(40px, calc(100% - 880px))",
|
|
3378
|
-
width: `min(max(400px, ${
|
|
3402
|
+
width: `min(max(400px, ${Mo}), var(--ago-panel-max, calc(100% - 40px)))`,
|
|
3379
3403
|
height: "auto",
|
|
3380
3404
|
borderRadius: "16px",
|
|
3381
|
-
boxShadow:
|
|
3405
|
+
boxShadow: Mn,
|
|
3382
3406
|
overflow: "hidden",
|
|
3383
3407
|
transformOrigin: "right bottom",
|
|
3384
3408
|
zIndex: "2147483000",
|
|
3385
|
-
backgroundColor:
|
|
3409
|
+
backgroundColor: On,
|
|
3386
3410
|
display: "none",
|
|
3387
3411
|
fontFamily: Re
|
|
3388
|
-
}), U.className = "ago-chat-widget-bubble", U.dataset.agoLayout = "panel",
|
|
3389
|
-
const l =
|
|
3390
|
-
l ? U.style.setProperty("--ago-panel-width", l) : console.warn(`[AGO] mountChatWidget width "${String(
|
|
3412
|
+
}), U.className = "ago-chat-widget-bubble", U.dataset.agoLayout = "panel", In(U, ae), !ae?.panelWidth) {
|
|
3413
|
+
const l = ts(g);
|
|
3414
|
+
l ? U.style.setProperty("--ago-panel-width", l) : console.warn(`[AGO] mountChatWidget width "${String(g)}" is not a valid CSS length, ignoring. Expected e.g. 700 or "45rem". Falling back to 550px.`);
|
|
3391
3415
|
}
|
|
3392
|
-
|
|
3416
|
+
_ && (Ht = Ur({
|
|
3393
3417
|
title: Y,
|
|
3394
3418
|
labels: D,
|
|
3395
|
-
onBack: () => De(
|
|
3396
|
-
onNewChat: () =>
|
|
3397
|
-
onClose: () =>
|
|
3398
|
-
}), A.appendChild(
|
|
3419
|
+
onBack: () => De($t, { byUser: !0 }),
|
|
3420
|
+
onNewChat: () => qt(),
|
|
3421
|
+
onClose: () => ot()
|
|
3422
|
+
}), A.appendChild(Ht.el)), bt = d({
|
|
3399
3423
|
flex: "1",
|
|
3400
3424
|
display: "flex",
|
|
3401
3425
|
flexDirection: "column",
|
|
3402
3426
|
minHeight: "0",
|
|
3403
3427
|
overflow: "hidden"
|
|
3404
|
-
}),
|
|
3428
|
+
}), bt.className = "ago-chat-widget__main", A.appendChild(bt), G || (ht = Wr({
|
|
3405
3429
|
labels: D,
|
|
3406
3430
|
onNavigate: (l) => De(l, { byUser: !0 })
|
|
3407
|
-
}), A.appendChild(
|
|
3431
|
+
}), A.appendChild(ht.el)), Fe = Xa({
|
|
3408
3432
|
title: Y,
|
|
3409
|
-
subtitle:
|
|
3410
|
-
starters:
|
|
3433
|
+
subtitle: v,
|
|
3434
|
+
starters: z,
|
|
3411
3435
|
onStarter: (l) => {
|
|
3412
|
-
Fe?.setPending(l),
|
|
3436
|
+
Fe?.setPending(l), nt(l.message ?? l.label, void 0, { agentId: l.agentId }).finally(() => Fe?.setPending(null));
|
|
3413
3437
|
}
|
|
3414
3438
|
});
|
|
3415
3439
|
const r = e.colors?.background;
|
|
3416
|
-
|
|
3440
|
+
Ue = Ga({
|
|
3417
3441
|
labels: D,
|
|
3418
3442
|
onSelect: (l) => {
|
|
3419
|
-
|
|
3443
|
+
et = !0, $t = "history", Tt(l.id);
|
|
3420
3444
|
},
|
|
3421
|
-
onNew: () =>
|
|
3422
|
-
hoverBackground: r &&
|
|
3445
|
+
onNew: () => qt(),
|
|
3446
|
+
hoverBackground: r && zr(r) ? yr(r, 10) : void 0,
|
|
3423
3447
|
customFont: !!e.colors?.font
|
|
3424
|
-
}),
|
|
3425
|
-
messagesWrap:
|
|
3448
|
+
}), Bt = ja({
|
|
3449
|
+
messagesWrap: gn,
|
|
3426
3450
|
jumpBtn: le
|
|
3427
|
-
}), U.appendChild(A),
|
|
3451
|
+
}), U.appendChild(A), mt = U;
|
|
3428
3452
|
}
|
|
3429
|
-
|
|
3453
|
+
It && (U = d({
|
|
3430
3454
|
position: "fixed",
|
|
3431
3455
|
top: "0",
|
|
3432
3456
|
bottom: "0",
|
|
3433
|
-
[
|
|
3434
|
-
width: typeof
|
|
3457
|
+
[gt]: "0",
|
|
3458
|
+
width: typeof g == "number" ? `${g}px` : g,
|
|
3435
3459
|
maxWidth: "100vw",
|
|
3436
3460
|
display: "flex",
|
|
3437
3461
|
zIndex: "2147483000",
|
|
@@ -3443,57 +3467,57 @@ function us(t, e) {
|
|
|
3443
3467
|
borderRadius: "0",
|
|
3444
3468
|
border: "none",
|
|
3445
3469
|
boxShadow: "none",
|
|
3446
|
-
[
|
|
3447
|
-
}), U.appendChild(A),
|
|
3448
|
-
const
|
|
3470
|
+
[gt === "left" ? "borderRight" : "borderLeft"]: `1px solid ${Q}`
|
|
3471
|
+
}), U.appendChild(A), mt = U);
|
|
3472
|
+
const wt = {
|
|
3449
3473
|
open: s.common.openTitle.replace("{title}", () => Y),
|
|
3450
3474
|
close: s.common.closeTitle.replace("{title}", () => Y)
|
|
3451
3475
|
};
|
|
3452
|
-
|
|
3476
|
+
Ai && (Ot = ta({
|
|
3453
3477
|
look: n ? "bubble" : "classic",
|
|
3454
|
-
labels:
|
|
3455
|
-
edge:
|
|
3478
|
+
labels: wt,
|
|
3479
|
+
edge: gt,
|
|
3456
3480
|
title: Y,
|
|
3457
|
-
icon: n ? q :
|
|
3458
|
-
onClick: () => n ?
|
|
3459
|
-
}),
|
|
3460
|
-
const
|
|
3461
|
-
let Le = !1, He = 0,
|
|
3462
|
-
const
|
|
3481
|
+
icon: n ? q : y,
|
|
3482
|
+
onClick: () => n ? Ro() : Kt()
|
|
3483
|
+
}), pe = Ot.el, In(pe, ae));
|
|
3484
|
+
const vt = dt ? `ago-vt-${++Qa}` : "", no = 52;
|
|
3485
|
+
let Le = !1, He = 0, tt = 0, fe, Et, Be;
|
|
3486
|
+
const Dt = {
|
|
3463
3487
|
height: A.style.height,
|
|
3464
3488
|
border: A.style.border,
|
|
3465
3489
|
borderRadius: A.style.borderRadius,
|
|
3466
3490
|
boxShadow: A.style.boxShadow
|
|
3467
3491
|
};
|
|
3468
|
-
|
|
3492
|
+
sn.appendChild(mt), pe && sn.appendChild(pe), Xt(), n && (ge !== !1 && !ie && (Pe = setTimeout(Ao, 1e3)), document.addEventListener("keydown", Fo), window.addEventListener("resize", Lo)), dt && (fe = Ji(), A.insertBefore(fe, A.firstChild), Et = document.createElement("style"), Et.id = vt, Et.textContent = `::view-transition-group(${vt}),::view-transition-group(${vt}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(Et), (cn === "focus" || cn === "tap") && (A.addEventListener("pointerdown", (r) => {
|
|
3469
3493
|
if (Le || !ce?.matches) return;
|
|
3470
3494
|
const l = Se.contains(r.target);
|
|
3471
|
-
if (
|
|
3495
|
+
if (cn === "tap") {
|
|
3472
3496
|
if ((r.target instanceof Element ? r.target : null)?.closest("button,a[href],[role='button']")) return;
|
|
3473
3497
|
} else if (!l) return;
|
|
3474
|
-
l && r.preventDefault(),
|
|
3498
|
+
l && r.preventDefault(), Ft();
|
|
3475
3499
|
}, !0), A.addEventListener("focusin", (r) => {
|
|
3476
|
-
ce?.matches && Se.contains(r.target) &&
|
|
3477
|
-
}))),
|
|
3478
|
-
const
|
|
3479
|
-
|
|
3480
|
-
}), $e = P === !0 ? {} : P || null,
|
|
3500
|
+
ce?.matches && Se.contains(r.target) && Ft();
|
|
3501
|
+
}))), Ni && document.addEventListener("keydown", zo), ce && ce.addEventListener("change", Oo);
|
|
3502
|
+
const oo = w !== !1, io = w === !1 ? void 0 : w ?? ((r) => {
|
|
3503
|
+
dt && ce?.matches && !Le ? Ft().then(() => nt(r)) : nt(r);
|
|
3504
|
+
}), $e = P === !0 ? {} : P || null, xn = {
|
|
3481
3505
|
...s.feedback,
|
|
3482
3506
|
...$e?.labels,
|
|
3483
3507
|
reasons: {
|
|
3484
3508
|
...s.feedback.reasons,
|
|
3485
3509
|
...$e?.labels?.reasons
|
|
3486
3510
|
}
|
|
3487
|
-
},
|
|
3488
|
-
function
|
|
3511
|
+
}, Mt = /* @__PURE__ */ new Map();
|
|
3512
|
+
function ro(r) {
|
|
3489
3513
|
if (!$e || !r.id || !r.conversationId || r.status !== "DONE" || !r.content) return null;
|
|
3490
|
-
let l =
|
|
3491
|
-
l || (l =
|
|
3492
|
-
const
|
|
3514
|
+
let l = Mt.get(r.id);
|
|
3515
|
+
l || (l = Oa(), Mt.set(r.id, l));
|
|
3516
|
+
const h = async (C, T) => {
|
|
3493
3517
|
try {
|
|
3494
|
-
return await i.submitFeedback(r.id,
|
|
3518
|
+
return await i.submitFeedback(r.id, C, T), $e.onSubmit?.({
|
|
3495
3519
|
messageId: r.id,
|
|
3496
|
-
rating:
|
|
3520
|
+
rating: C,
|
|
3497
3521
|
reasons: T?.reasons ?? [],
|
|
3498
3522
|
comment: T?.comment || void 0
|
|
3499
3523
|
}), !0;
|
|
@@ -3501,128 +3525,128 @@ function us(t, e) {
|
|
|
3501
3525
|
return $e.onError?.(M instanceof Error ? M : new Error(String(M))), !1;
|
|
3502
3526
|
}
|
|
3503
3527
|
};
|
|
3504
|
-
return
|
|
3528
|
+
return Ba({
|
|
3505
3529
|
state: l,
|
|
3506
|
-
labels:
|
|
3530
|
+
labels: xn,
|
|
3507
3531
|
askWhy: $e.askWhy ?? !n,
|
|
3508
|
-
onRate: (
|
|
3509
|
-
|
|
3532
|
+
onRate: (C) => {
|
|
3533
|
+
h(C);
|
|
3510
3534
|
},
|
|
3511
|
-
onReport: (
|
|
3535
|
+
onReport: (C, T) => h(C, T),
|
|
3512
3536
|
look: n ? "embed" : "classic"
|
|
3513
3537
|
});
|
|
3514
3538
|
}
|
|
3515
|
-
const
|
|
3516
|
-
let
|
|
3517
|
-
const
|
|
3518
|
-
let Ce = null, Ne = !1,
|
|
3519
|
-
const
|
|
3520
|
-
function
|
|
3521
|
-
if (
|
|
3522
|
-
const r = ++
|
|
3523
|
-
|
|
3524
|
-
if (re || r !==
|
|
3525
|
-
|
|
3526
|
-
const
|
|
3527
|
-
Ce =
|
|
3528
|
-
for (const T of
|
|
3539
|
+
const se = e.toolCallForm ?? {}, _e = Yo(s.form, e.toolCallForm?.labels);
|
|
3540
|
+
let kt = !1;
|
|
3541
|
+
const ao = i.getUserIdentity(), yn = se.userEmail ?? ao.email, so = !yn && !ao.hasJwt;
|
|
3542
|
+
let Ce = null, Ne = !1, St, jt = 0, Cn = !1;
|
|
3543
|
+
const Ve = /* @__PURE__ */ new Map(), Wt = /* @__PURE__ */ new Set();
|
|
3544
|
+
function wn() {
|
|
3545
|
+
if (St || Ne) return;
|
|
3546
|
+
const r = ++jt, l = a;
|
|
3547
|
+
St = i.getConfig().then((h) => {
|
|
3548
|
+
if (re || r !== jt) return;
|
|
3549
|
+
kt = !0, lo(l);
|
|
3550
|
+
const C = h.permissions[0];
|
|
3551
|
+
Ce = C?.ticketForm ?? null, Cn = !!C?.fileAttachmentsEnabled, Ne = !1;
|
|
3552
|
+
for (const T of Ve.values()) {
|
|
3529
3553
|
if (T.kind === "embed") {
|
|
3530
3554
|
T.view.updateText({
|
|
3531
3555
|
description: Ce?.embedDescription ?? T.call.embedDescription,
|
|
3532
|
-
successMessage:
|
|
3556
|
+
successMessage: se.successMessage || se.labels?.embeddedFormSubmitted || Ce?.successMessageText
|
|
3533
3557
|
});
|
|
3534
3558
|
continue;
|
|
3535
3559
|
}
|
|
3536
|
-
T.kind !== "static" && (Ce && !T.hydrated && (
|
|
3560
|
+
T.kind !== "static" && (Ce && !T.hydrated && (va(T.state, T.call.ticket, Ce), T.hydrated = !0), T.view.rebuild({
|
|
3537
3561
|
ticketForm: Ce,
|
|
3538
|
-
allowFiles:
|
|
3562
|
+
allowFiles: x || Cn
|
|
3539
3563
|
}));
|
|
3540
3564
|
}
|
|
3541
3565
|
X();
|
|
3542
|
-
}).catch((
|
|
3543
|
-
if (re || r !==
|
|
3544
|
-
|
|
3545
|
-
const
|
|
3546
|
-
if (Ne = !0,
|
|
3547
|
-
Ce = null,
|
|
3548
|
-
for (const T of
|
|
3549
|
-
|
|
3566
|
+
}).catch((h) => {
|
|
3567
|
+
if (re || r !== jt) return;
|
|
3568
|
+
St = void 0;
|
|
3569
|
+
const C = h.statusCode ?? h.status;
|
|
3570
|
+
if (Ne = !0, C === 401 || C === 403) {
|
|
3571
|
+
Ce = null, kt = !1;
|
|
3572
|
+
for (const T of Ve.values()) T.kind === "ticket" && T.view.rebuild({ ticketForm: null });
|
|
3573
|
+
Pt();
|
|
3550
3574
|
}
|
|
3551
|
-
|
|
3575
|
+
_t() && X();
|
|
3552
3576
|
});
|
|
3553
3577
|
}
|
|
3554
|
-
function
|
|
3555
|
-
s =
|
|
3556
|
-
for (const
|
|
3557
|
-
Object.assign(
|
|
3578
|
+
function lo(r) {
|
|
3579
|
+
s = We(r), Object.assign(D, Vo(e.labels, r)), Object.assign(_e, Yo(s.form, se.labels));
|
|
3580
|
+
for (const C of Ve.values()) C.kind === "static" && C.el.replaceChildren(Qo(_e.notAllowed));
|
|
3581
|
+
Object.assign(xn, Me(s.feedback, $e?.labels)), xn.reasons = Me(s.feedback.reasons, $e?.labels?.reasons), oe = e.placeholder ?? (n ? D.askQuestion : s.common.placeholder), e.welcomeMessage === void 0 && (an = s.common.welcome), e.title === void 0 && !n && (Y = s.common.chat), e.prompt === void 0 && (ge = s.common.prompt), $i({
|
|
3558
3582
|
...D,
|
|
3559
3583
|
attachFiles: n ? D.attachFiles : e.labels?.attachFiles ?? s.common.attachFile,
|
|
3560
3584
|
send: s.common.send,
|
|
3561
3585
|
stop: s.common.stop,
|
|
3562
3586
|
removeFile: s.form.removeFile
|
|
3563
|
-
}, Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0)),
|
|
3587
|
+
}, Me(s.speech, typeof e.speechToText == "object" ? e.speechToText.labels : void 0)), hn(n && ue === "chat" ? "" : oe), le.setAttribute("aria-label", D.scrollToBottom), Ht?.update({ screen: ue }), ht?.setActive(ue), ue === "history" && Ue?.render({
|
|
3564
3588
|
threads: ke,
|
|
3565
|
-
loading:
|
|
3589
|
+
loading: xt
|
|
3566
3590
|
});
|
|
3567
|
-
for (const
|
|
3568
|
-
const l =
|
|
3591
|
+
for (const C of A.querySelectorAll(".ago-chat-widget__close")) C.setAttribute("aria-label", n ? D.close : s.common.close);
|
|
3592
|
+
const l = xe?.querySelector(".ago-chat-widget__title");
|
|
3569
3593
|
l && (l.textContent = Y);
|
|
3570
|
-
const
|
|
3571
|
-
|
|
3572
|
-
}
|
|
3573
|
-
function so({ language: r }) {
|
|
3574
|
-
a = r, Mt += 1, kt = void 0, Ne = !1, St() ? Cn() : (Et = !1, ao(a), X());
|
|
3594
|
+
const h = fe?.querySelector(".ago-chat-widget__title");
|
|
3595
|
+
h && (h.textContent = Y), fe?.querySelector("button")?.setAttribute("aria-label", s.common.close), A.hasAttribute("aria-label") && A.setAttribute("aria-label", Y), wt.open = s.common.openTitle.replace("{title}", () => Y), wt.close = s.common.closeTitle.replace("{title}", () => Y), Ot?.setOpen(ie), de && (de.remove(), de = void 0, ie || Ao());
|
|
3575
3596
|
}
|
|
3576
|
-
function
|
|
3577
|
-
St()
|
|
3597
|
+
function co({ language: r }) {
|
|
3598
|
+
a = r, jt += 1, St = void 0, Ne = !1, _t() ? wn() : (kt = !1, lo(a), X());
|
|
3578
3599
|
}
|
|
3579
3600
|
function Ut() {
|
|
3580
|
-
|
|
3581
|
-
Pe.clear(), jt.clear();
|
|
3601
|
+
_t() && !St && (Ne = !1, wn(), X());
|
|
3582
3602
|
}
|
|
3583
|
-
function
|
|
3584
|
-
for (const
|
|
3585
|
-
|
|
3586
|
-
|
|
3603
|
+
function Pt() {
|
|
3604
|
+
for (const r of Ve.values()) r.kind === "embed" && r.view.destroy();
|
|
3605
|
+
Ve.clear(), Wt.clear();
|
|
3606
|
+
}
|
|
3607
|
+
function po(r) {
|
|
3608
|
+
for (const l of L) {
|
|
3609
|
+
const h = l.toolCalls?.find((C) => C.id === r);
|
|
3610
|
+
if (h) return h;
|
|
3587
3611
|
}
|
|
3588
3612
|
}
|
|
3589
|
-
function
|
|
3590
|
-
const
|
|
3591
|
-
if (
|
|
3592
|
-
let
|
|
3613
|
+
function Mi(r, l) {
|
|
3614
|
+
const h = Ve.get(r.id);
|
|
3615
|
+
if (h) return h;
|
|
3616
|
+
let C;
|
|
3593
3617
|
if (r.allowedToCreateTicket === !1) {
|
|
3594
3618
|
const T = d({
|
|
3595
3619
|
display: "flex",
|
|
3596
3620
|
flexDirection: "column",
|
|
3597
3621
|
gap: "16px"
|
|
3598
3622
|
});
|
|
3599
|
-
T.className = "ago-ticket-form ago-ticket-form--denied", T.appendChild(
|
|
3623
|
+
T.className = "ago-ticket-form ago-ticket-form--denied", T.appendChild(Qo(l.notAllowed)), C = {
|
|
3600
3624
|
kind: "static",
|
|
3601
3625
|
el: T
|
|
3602
3626
|
};
|
|
3603
3627
|
} else if (r.mode === "embed") {
|
|
3604
|
-
const T = { status:
|
|
3605
|
-
|
|
3628
|
+
const T = { status: ei(r) ? "submitted" : "loading" };
|
|
3629
|
+
C = {
|
|
3606
3630
|
kind: "embed",
|
|
3607
3631
|
state: T,
|
|
3608
|
-
view:
|
|
3632
|
+
view: La({
|
|
3609
3633
|
state: T,
|
|
3610
3634
|
embedHtml: r.embedHtml,
|
|
3611
3635
|
description: Ce?.embedDescription ?? r.embedDescription,
|
|
3612
3636
|
ticket: r.ticket,
|
|
3613
|
-
email:
|
|
3637
|
+
email: yn,
|
|
3614
3638
|
labels: l,
|
|
3615
3639
|
message: r.message,
|
|
3616
|
-
successMessage:
|
|
3640
|
+
successMessage: se.successMessage || se.labels?.embeddedFormSubmitted || Ce?.successMessageText,
|
|
3617
3641
|
onSubmitted: (M) => {
|
|
3618
|
-
|
|
3642
|
+
Wt.add(r.id), i.submitToolCallForm(r.id, {
|
|
3619
3643
|
success: !0,
|
|
3620
3644
|
source: "embed",
|
|
3621
3645
|
thread_id: J,
|
|
3622
3646
|
captured_form_data: M
|
|
3623
3647
|
}).then((V) => {
|
|
3624
3648
|
const Z = V.ticket ?? V.result?.ticket;
|
|
3625
|
-
|
|
3649
|
+
se.onSubmitted?.({
|
|
3626
3650
|
toolCallId: r.id,
|
|
3627
3651
|
toolName: r.toolName,
|
|
3628
3652
|
mode: "embed",
|
|
@@ -3633,7 +3657,7 @@ function us(t, e) {
|
|
|
3633
3657
|
values: M ?? {}
|
|
3634
3658
|
});
|
|
3635
3659
|
}).catch((V) => {
|
|
3636
|
-
|
|
3660
|
+
se.onError?.(V instanceof Error ? V : new Error(String(V)));
|
|
3637
3661
|
}).finally(() => {
|
|
3638
3662
|
re || X();
|
|
3639
3663
|
});
|
|
@@ -3642,19 +3666,19 @@ function us(t, e) {
|
|
|
3642
3666
|
call: r
|
|
3643
3667
|
};
|
|
3644
3668
|
} else {
|
|
3645
|
-
const T =
|
|
3646
|
-
M && (T.submitted = M),
|
|
3669
|
+
const T = Kn(r.ticket, Ce, yn ?? ""), M = ei(r);
|
|
3670
|
+
M && (T.submitted = M), C = {
|
|
3647
3671
|
kind: "ticket",
|
|
3648
3672
|
state: T,
|
|
3649
|
-
view:
|
|
3673
|
+
view: Sa({
|
|
3650
3674
|
state: T,
|
|
3651
3675
|
ticketForm: Ce,
|
|
3652
3676
|
labels: l,
|
|
3653
3677
|
message: r.message,
|
|
3654
|
-
requireEmail:
|
|
3655
|
-
allowFiles:
|
|
3656
|
-
successMessage:
|
|
3657
|
-
successUrlLabel:
|
|
3678
|
+
requireEmail: so,
|
|
3679
|
+
allowFiles: x || Cn,
|
|
3680
|
+
successMessage: se.successMessage || se.labels?.ticketSubmitted,
|
|
3681
|
+
successUrlLabel: se.successUrlLabel || se.labels?.findTicketHere,
|
|
3658
3682
|
createTicket: (V) => i.createTicket({
|
|
3659
3683
|
subject: V.subject,
|
|
3660
3684
|
body: V.body,
|
|
@@ -3667,10 +3691,10 @@ function us(t, e) {
|
|
|
3667
3691
|
ticketFormId: V.ticketFormId
|
|
3668
3692
|
}),
|
|
3669
3693
|
onCreated: (V, Z) => {
|
|
3670
|
-
|
|
3671
|
-
const
|
|
3672
|
-
id:
|
|
3673
|
-
value:
|
|
3694
|
+
Wt.add(r.id);
|
|
3695
|
+
const Ln = Object.entries(Z.customFields).map(([Nt, tr]) => ({
|
|
3696
|
+
id: Nt,
|
|
3697
|
+
value: tr
|
|
3674
3698
|
}));
|
|
3675
3699
|
i.submitToolCallForm(r.id, {
|
|
3676
3700
|
success: !0,
|
|
@@ -3681,12 +3705,12 @@ function us(t, e) {
|
|
|
3681
3705
|
priority: Z.ticket.priority,
|
|
3682
3706
|
body: Z.ticket.body,
|
|
3683
3707
|
tag: Z.ticket.tag,
|
|
3684
|
-
custom_fields:
|
|
3708
|
+
custom_fields: Ln,
|
|
3685
3709
|
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
3686
|
-
}).catch((
|
|
3687
|
-
|
|
3710
|
+
}).catch((Nt) => {
|
|
3711
|
+
se.onError?.(Nt instanceof Error ? Nt : new Error(String(Nt)));
|
|
3688
3712
|
}).finally(() => {
|
|
3689
|
-
|
|
3713
|
+
se.onSubmitted?.({
|
|
3690
3714
|
toolCallId: r.id,
|
|
3691
3715
|
toolName: r.toolName,
|
|
3692
3716
|
mode: "form",
|
|
@@ -3697,48 +3721,48 @@ function us(t, e) {
|
|
|
3697
3721
|
values: {
|
|
3698
3722
|
...Z.ticket,
|
|
3699
3723
|
custom_fields: Z.customFields,
|
|
3700
|
-
email:
|
|
3724
|
+
email: so ? Z.email : void 0
|
|
3701
3725
|
}
|
|
3702
3726
|
}), re || X();
|
|
3703
3727
|
});
|
|
3704
3728
|
},
|
|
3705
|
-
onError:
|
|
3729
|
+
onError: se.onError
|
|
3706
3730
|
}),
|
|
3707
3731
|
call: r,
|
|
3708
3732
|
hydrated: !!Ce
|
|
3709
3733
|
};
|
|
3710
3734
|
}
|
|
3711
|
-
return
|
|
3735
|
+
return Ve.set(r.id, C), C;
|
|
3712
3736
|
}
|
|
3713
|
-
function
|
|
3737
|
+
function uo(r) {
|
|
3714
3738
|
if (r.type !== "form" || r.displayMode === "collapsible") return null;
|
|
3715
|
-
const l =
|
|
3739
|
+
const l = Jo(L);
|
|
3716
3740
|
if (l && l !== r.id) {
|
|
3717
|
-
const
|
|
3718
|
-
return
|
|
3741
|
+
const C = po(l), T = !!C?.askToTalkToHuman && C.allowedToCreateTicket === !1;
|
|
3742
|
+
return Ra(T ? _e.contactFormRejected : _e.contactFormCreated, T ? "warning" : "info");
|
|
3719
3743
|
}
|
|
3720
|
-
if (!
|
|
3721
|
-
if (r.allowedToCreateTicket !== !1 && (
|
|
3744
|
+
if (!Zo(r)) return za(r, _e);
|
|
3745
|
+
if (r.allowedToCreateTicket !== !1 && (wn(), !kt)) {
|
|
3722
3746
|
if (Ne) return null;
|
|
3723
|
-
const
|
|
3747
|
+
const C = d({
|
|
3724
3748
|
padding: "16px",
|
|
3725
3749
|
textAlign: "center",
|
|
3726
3750
|
fontWeight: "700",
|
|
3727
3751
|
fontSize: "20px"
|
|
3728
3752
|
});
|
|
3729
|
-
return
|
|
3753
|
+
return C.className = "ago-ticket-form__config-loading", C.setAttribute("role", "status"), C.textContent = _e.loading, C;
|
|
3730
3754
|
}
|
|
3731
|
-
const
|
|
3732
|
-
return
|
|
3755
|
+
const h = Mi(r, _e);
|
|
3756
|
+
return h.kind === "static" ? h.el : h.view.el;
|
|
3733
3757
|
}
|
|
3734
3758
|
let Ie;
|
|
3735
|
-
function
|
|
3736
|
-
const r =
|
|
3759
|
+
function ji() {
|
|
3760
|
+
const r = L.some((C) => C.toolCalls?.some((T) => T.type === "form")), l = Wt.size > 0 || Na(L);
|
|
3737
3761
|
if (!r && !l) {
|
|
3738
3762
|
Se.style.display = "", Ie?.remove();
|
|
3739
3763
|
return;
|
|
3740
3764
|
}
|
|
3741
|
-
if (!
|
|
3765
|
+
if (!kt && _t()) {
|
|
3742
3766
|
Se.style.display = "none", Ie?.remove();
|
|
3743
3767
|
return;
|
|
3744
3768
|
}
|
|
@@ -3756,16 +3780,16 @@ function us(t, e) {
|
|
|
3756
3780
|
textAlign: "center",
|
|
3757
3781
|
fontFamily: Re
|
|
3758
3782
|
}), Ie.className = "ago-chat-blocked"), Ie.replaceChildren();
|
|
3759
|
-
const
|
|
3760
|
-
if (
|
|
3761
|
-
color:
|
|
3783
|
+
const h = document.createElement("p");
|
|
3784
|
+
if (h.textContent = l ? _e.ticketCreatedBlocked : _e.formPending, u(h, {
|
|
3785
|
+
color: st,
|
|
3762
3786
|
lineHeight: "1.625",
|
|
3763
3787
|
fontSize: "16px",
|
|
3764
3788
|
margin: "0",
|
|
3765
3789
|
whiteSpace: "pre-line"
|
|
3766
|
-
}), Ie.appendChild(
|
|
3767
|
-
const
|
|
3768
|
-
|
|
3790
|
+
}), Ie.appendChild(h), l) {
|
|
3791
|
+
const C = document.createElement("button");
|
|
3792
|
+
C.type = "button", C.className = "ago-chat-blocked__new", u(C, {
|
|
3769
3793
|
display: "inline-flex",
|
|
3770
3794
|
alignItems: "center",
|
|
3771
3795
|
gap: "8px",
|
|
@@ -3779,66 +3803,66 @@ function us(t, e) {
|
|
|
3779
3803
|
font: "inherit",
|
|
3780
3804
|
fontSize: "14px",
|
|
3781
3805
|
fontWeight: "500"
|
|
3782
|
-
}),
|
|
3806
|
+
}), C.append(Xn({ size: 18 }));
|
|
3783
3807
|
const T = document.createElement("span");
|
|
3784
|
-
T.textContent = _e.newConversation,
|
|
3785
|
-
|
|
3786
|
-
}), Ie.appendChild(
|
|
3808
|
+
T.textContent = _e.newConversation, C.appendChild(T), C.addEventListener("click", () => {
|
|
3809
|
+
qt(), se.onNewConversation?.();
|
|
3810
|
+
}), Ie.appendChild(C);
|
|
3787
3811
|
}
|
|
3788
3812
|
Se.style.display = "none", Se.parentElement?.insertBefore(Ie, Se);
|
|
3789
3813
|
}
|
|
3790
|
-
function
|
|
3791
|
-
const r =
|
|
3792
|
-
return !!l &&
|
|
3814
|
+
function _t() {
|
|
3815
|
+
const r = Jo(L), l = r ? po(r) : void 0;
|
|
3816
|
+
return !!l && Zo(l) && l.displayMode !== "collapsible" && l.allowedToCreateTicket !== !1;
|
|
3793
3817
|
}
|
|
3794
|
-
function
|
|
3795
|
-
const l =
|
|
3796
|
-
return n ?
|
|
3797
|
-
isLast: r ===
|
|
3798
|
-
followUpEnabled:
|
|
3799
|
-
followUpHandler:
|
|
3800
|
-
agentRowTinted: !!
|
|
3801
|
-
agentRowTextTinted: !!
|
|
3818
|
+
function fo(r) {
|
|
3819
|
+
const l = L[r];
|
|
3820
|
+
return n ? la(l, {
|
|
3821
|
+
isLast: r === L.length - 1,
|
|
3822
|
+
followUpEnabled: oo,
|
|
3823
|
+
followUpHandler: io,
|
|
3824
|
+
agentRowTinted: !!ae?.agentBubbleBg,
|
|
3825
|
+
agentRowTextTinted: !!ae?.agentBubbleText,
|
|
3802
3826
|
labels: D,
|
|
3803
|
-
actionsRow:
|
|
3804
|
-
renderToolCall:
|
|
3805
|
-
}) :
|
|
3806
|
-
...
|
|
3807
|
-
renderToolCall:
|
|
3827
|
+
actionsRow: ro(l),
|
|
3828
|
+
renderToolCall: uo
|
|
3829
|
+
}) : Qr(l, {
|
|
3830
|
+
...Wi(r),
|
|
3831
|
+
renderToolCall: uo
|
|
3808
3832
|
});
|
|
3809
3833
|
}
|
|
3810
|
-
function
|
|
3811
|
-
const l =
|
|
3834
|
+
function Wi(r) {
|
|
3835
|
+
const l = L.length - 1;
|
|
3812
3836
|
return {
|
|
3813
3837
|
isLast: r === l,
|
|
3814
|
-
isLastOfBlock: r === l ||
|
|
3815
|
-
bubbleStyle:
|
|
3816
|
-
showAgentName:
|
|
3817
|
-
agentBubble:
|
|
3818
|
-
followUpEnabled:
|
|
3819
|
-
followUpHandler:
|
|
3838
|
+
isLastOfBlock: r === l || L[r + 1].role !== L[r].role,
|
|
3839
|
+
bubbleStyle: N,
|
|
3840
|
+
showAgentName: m,
|
|
3841
|
+
agentBubble: k,
|
|
3842
|
+
followUpEnabled: oo,
|
|
3843
|
+
followUpHandler: io,
|
|
3820
3844
|
isMobile: !!ce?.matches,
|
|
3821
|
-
feedbackRow:
|
|
3845
|
+
feedbackRow: ro(L[r])
|
|
3822
3846
|
};
|
|
3823
3847
|
}
|
|
3824
|
-
function
|
|
3825
|
-
if (Ae ||
|
|
3826
|
-
const r =
|
|
3848
|
+
function Ui() {
|
|
3849
|
+
if (Ae || ut.length > 0) return !1;
|
|
3850
|
+
const r = L.length - 1, l = L[r];
|
|
3827
3851
|
if (!l || l.role !== "assistant") return !1;
|
|
3828
|
-
const
|
|
3829
|
-
if (!
|
|
3830
|
-
const
|
|
3831
|
-
return
|
|
3852
|
+
const h = Rt[r];
|
|
3853
|
+
if (!h || h.parentNode !== ye) return !1;
|
|
3854
|
+
const C = fo(r), T = document.activeElement, M = T instanceof HTMLElement && h.contains(T) ? T : null;
|
|
3855
|
+
return to(() => ye.replaceChild(C, h)), M && C.contains(M) && M.focus({ preventScroll: !0 }), Rt[r] = C, !0;
|
|
3832
3856
|
}
|
|
3833
3857
|
function X() {
|
|
3834
|
-
|
|
3835
|
-
const r =
|
|
3836
|
-
te.setAttribute("aria-busy", l ? "true" : "false"),
|
|
3858
|
+
to(Pi);
|
|
3859
|
+
const r = L[L.length - 1], l = be && r?.role === "assistant" && (r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT");
|
|
3860
|
+
te.setAttribute("aria-busy", l ? "true" : "false"), zi(l), ji();
|
|
3837
3861
|
}
|
|
3838
|
-
function
|
|
3839
|
-
if (
|
|
3862
|
+
function Pi() {
|
|
3863
|
+
if (ye.replaceChildren(), Rt = [], L.length === 0) {
|
|
3840
3864
|
if (n) {
|
|
3841
|
-
if (
|
|
3865
|
+
if (yt) {
|
|
3842
3866
|
const r = d({
|
|
3843
3867
|
display: "flex",
|
|
3844
3868
|
justifyContent: "center",
|
|
@@ -3852,30 +3876,30 @@ function us(t, e) {
|
|
|
3852
3876
|
borderBottom: "2px solid var(--ago-brand-color, #03182f)",
|
|
3853
3877
|
animation: "ago-spin 1s linear infinite"
|
|
3854
3878
|
});
|
|
3855
|
-
l.setAttribute("role", "status"), r.appendChild(l),
|
|
3879
|
+
l.setAttribute("role", "status"), r.appendChild(l), ye.appendChild(r);
|
|
3856
3880
|
}
|
|
3857
|
-
} else if (
|
|
3881
|
+
} else if (Yn === "static") {
|
|
3858
3882
|
const r = d({
|
|
3859
3883
|
textAlign: "center",
|
|
3860
|
-
color:
|
|
3884
|
+
color: st,
|
|
3861
3885
|
padding: "24px 16px",
|
|
3862
3886
|
fontSize: "16px",
|
|
3863
3887
|
lineHeight: "1.5"
|
|
3864
3888
|
});
|
|
3865
|
-
r.appendChild(
|
|
3889
|
+
r.appendChild(Ye(an)), ye.appendChild(r);
|
|
3866
3890
|
}
|
|
3867
|
-
} else
|
|
3868
|
-
const
|
|
3869
|
-
|
|
3891
|
+
} else L.forEach((r, l) => {
|
|
3892
|
+
const h = fo(l);
|
|
3893
|
+
Rt[l] = h, ye.appendChild(h);
|
|
3870
3894
|
});
|
|
3871
|
-
for (const r of
|
|
3872
|
-
if (Ne &&
|
|
3873
|
-
const r =
|
|
3874
|
-
r.classList.add("ago-ticket-form-config-error"),
|
|
3895
|
+
for (const r of ut) ye.appendChild(Zr(r ?? s.common.formSubmitted));
|
|
3896
|
+
if (Ne && _t()) {
|
|
3897
|
+
const r = Go(D.errorTitle, "");
|
|
3898
|
+
r.classList.add("ago-ticket-form-config-error"), ye.appendChild(r);
|
|
3875
3899
|
}
|
|
3876
3900
|
if (Ae) {
|
|
3877
3901
|
if (n) {
|
|
3878
|
-
|
|
3902
|
+
ye.appendChild(Go(D.errorTitle, Ae));
|
|
3879
3903
|
return;
|
|
3880
3904
|
}
|
|
3881
3905
|
const r = d({
|
|
@@ -3887,36 +3911,36 @@ function us(t, e) {
|
|
|
3887
3911
|
fontSize: "13px",
|
|
3888
3912
|
border: "1px solid #fecaca"
|
|
3889
3913
|
});
|
|
3890
|
-
r.setAttribute("role", "alert"), r.textContent = Ae,
|
|
3914
|
+
r.setAttribute("role", "alert"), r.textContent = Ae, ye.appendChild(r);
|
|
3891
3915
|
}
|
|
3892
3916
|
}
|
|
3893
|
-
function
|
|
3894
|
-
for (let r =
|
|
3895
|
-
const l =
|
|
3917
|
+
function vn() {
|
|
3918
|
+
for (let r = L.length - 1; r >= 0; r--) {
|
|
3919
|
+
const l = L[r];
|
|
3896
3920
|
if (l.role === "assistant" && (l.status === "IN_PROGRESS" || l.status === "WAITING_CLIENT")) return l;
|
|
3897
3921
|
}
|
|
3898
3922
|
}
|
|
3899
|
-
const
|
|
3923
|
+
const mo = (r) => {
|
|
3900
3924
|
J || (J = r.conversationId);
|
|
3901
|
-
}, fo = (r) => {
|
|
3902
|
-
const l = wn();
|
|
3903
|
-
l && (l.content += r.content, Wi() || X());
|
|
3904
|
-
}, mo = (r) => {
|
|
3905
|
-
const l = F.findIndex((g) => g.id === r.id || g.role === "assistant" && g.status === "IN_PROGRESS");
|
|
3906
|
-
l >= 0 ? F[l] = r : F.push(r), X(), Tt() || Rt();
|
|
3907
3925
|
}, go = (r) => {
|
|
3908
|
-
const l =
|
|
3909
|
-
l
|
|
3926
|
+
const l = vn();
|
|
3927
|
+
l && (l.content += r.content, Ui() || X());
|
|
3928
|
+
}, ho = (r) => {
|
|
3929
|
+
const l = L.findIndex((h) => h.id === r.id || h.role === "assistant" && h.status === "IN_PROGRESS");
|
|
3930
|
+
l >= 0 ? L[l] = r : L.push(r), X(), At() || zt();
|
|
3931
|
+
}, bo = (r) => {
|
|
3932
|
+
const l = L.findIndex((h) => h.id === r.id || h.role === "assistant" && h.status === "IN_PROGRESS");
|
|
3933
|
+
l >= 0 ? L[l] = r : L.push(r), be = !1, X(), r.status === "DONE" && E?.({
|
|
3910
3934
|
id: r.id,
|
|
3911
3935
|
content: r.content
|
|
3912
3936
|
});
|
|
3913
|
-
},
|
|
3914
|
-
const r =
|
|
3915
|
-
r && (r.content ? r.status = "CANCELED" :
|
|
3916
|
-
},
|
|
3917
|
-
Ae = r.error,
|
|
3937
|
+
}, xo = () => {
|
|
3938
|
+
const r = vn();
|
|
3939
|
+
r && (r.content ? r.status = "CANCELED" : L = L.filter((l) => l !== r)), be = !1, X();
|
|
3940
|
+
}, yo = (r) => {
|
|
3941
|
+
Ae = r.error, be = !1, L = L.filter((l) => !l.id.startsWith("temp-")), X();
|
|
3918
3942
|
};
|
|
3919
|
-
function
|
|
3943
|
+
function Vi(r) {
|
|
3920
3944
|
const l = {
|
|
3921
3945
|
id: `ago-intro-${Date.now()}`,
|
|
3922
3946
|
conversationId: "",
|
|
@@ -3925,139 +3949,139 @@ function us(t, e) {
|
|
|
3925
3949
|
status: "IN_PROGRESS",
|
|
3926
3950
|
createdAt: /* @__PURE__ */ new Date()
|
|
3927
3951
|
};
|
|
3928
|
-
|
|
3929
|
-
const
|
|
3930
|
-
let
|
|
3952
|
+
L.push(l), X();
|
|
3953
|
+
const h = r.match(/\S+\s*/g) ?? [r];
|
|
3954
|
+
let C = 0;
|
|
3931
3955
|
ze = setInterval(() => {
|
|
3932
|
-
if (
|
|
3933
|
-
clearInterval(ze), ze = void 0, l.status = "DONE",
|
|
3956
|
+
if (C >= h.length) {
|
|
3957
|
+
clearInterval(ze), ze = void 0, l.status = "DONE", Qn && (l.followUpReplies = Qn), X();
|
|
3934
3958
|
return;
|
|
3935
3959
|
}
|
|
3936
|
-
l.content +=
|
|
3937
|
-
},
|
|
3960
|
+
l.content += h[C], C++, X();
|
|
3961
|
+
}, Ti);
|
|
3938
3962
|
}
|
|
3939
|
-
const
|
|
3940
|
-
const l = ke.find((
|
|
3941
|
-
l && (l.title = r.title), n &&
|
|
3963
|
+
const Co = (r) => {
|
|
3964
|
+
const l = ke.find((h) => h.id === r.conversationId);
|
|
3965
|
+
l && (l.title = r.title), n && ue === "history" && Ue?.render({
|
|
3942
3966
|
threads: ke,
|
|
3943
|
-
loading:
|
|
3967
|
+
loading: xt
|
|
3944
3968
|
});
|
|
3945
|
-
},
|
|
3969
|
+
}, wo = (r) => {
|
|
3946
3970
|
if (r.type !== "form") return;
|
|
3947
|
-
const l =
|
|
3971
|
+
const l = vn() ?? [...L].reverse().find((T) => T.role === "assistant");
|
|
3948
3972
|
if (!l) return;
|
|
3949
|
-
const
|
|
3950
|
-
|
|
3973
|
+
const h = l.toolCalls ?? [], C = h.findIndex((T) => T.id === r.id);
|
|
3974
|
+
C >= 0 ? h[C] = r : h.push(r), l.toolCalls = h, X();
|
|
3951
3975
|
};
|
|
3952
|
-
i.on("config:changed",
|
|
3953
|
-
const
|
|
3954
|
-
|
|
3955
|
-
const
|
|
3956
|
-
let
|
|
3957
|
-
const
|
|
3958
|
-
if (
|
|
3959
|
-
|
|
3976
|
+
i.on("config:changed", co), window.addEventListener("online", Ut), window.addEventListener("focus", Ut), i.on("message:start", mo), i.on("message:chunk", go), i.on("message:answer-complete", ho), i.on("message:complete", bo), i.on("message:stopped", xo), i.on("message:error", yo), i.on("conversation:title", Co), i.on("toolCall:received", wo);
|
|
3977
|
+
const vo = (r) => S?.(r), Eo = (r) => R?.(r), ko = (r) => H?.(r);
|
|
3978
|
+
S && i.on("form:submitting", vo), R && i.on("form:submitted", Eo), H && i.on("form:error", ko);
|
|
3979
|
+
const En = [];
|
|
3980
|
+
let So = !1;
|
|
3981
|
+
const _o = (r) => {
|
|
3982
|
+
if (So) return;
|
|
3983
|
+
En.push(r.install(i));
|
|
3960
3984
|
let l = r.store.get().submitted;
|
|
3961
|
-
const
|
|
3962
|
-
|
|
3985
|
+
const h = r.store.subscribe((C) => {
|
|
3986
|
+
C.submitted && !l && (ut.push(Ii(C.submitResult)), X()), l = C.submitted;
|
|
3963
3987
|
});
|
|
3964
|
-
|
|
3988
|
+
En.push(h);
|
|
3965
3989
|
};
|
|
3966
|
-
for (const r of
|
|
3990
|
+
for (const r of I ?? []) r.schema != null ? _o(lr(r)) : sr(i, r).then((l) => _o(l)).catch(() => {
|
|
3967
3991
|
});
|
|
3968
|
-
async function
|
|
3969
|
-
const
|
|
3970
|
-
if (!
|
|
3971
|
-
if (n &&
|
|
3992
|
+
async function nt(r, l, h) {
|
|
3993
|
+
const C = r.trim();
|
|
3994
|
+
if (!C || be) return;
|
|
3995
|
+
if (n && ue !== "chat" && ($t = "home", De("chat", { byUser: !0 })), O?.(C), be = !0, Ae = null, Ne = !1, Oe = !0, ze) {
|
|
3972
3996
|
clearInterval(ze), ze = void 0;
|
|
3973
|
-
const M =
|
|
3974
|
-
M && !M.content ?
|
|
3997
|
+
const M = L.find((V) => V.id.startsWith("ago-intro-"));
|
|
3998
|
+
M && !M.content ? L = L.filter((V) => V !== M) : M && (M.status = "DONE");
|
|
3975
3999
|
}
|
|
3976
4000
|
const T = Date.now();
|
|
3977
|
-
|
|
4001
|
+
L.push({
|
|
3978
4002
|
id: `temp-user-${T}`,
|
|
3979
4003
|
conversationId: J || "",
|
|
3980
|
-
content:
|
|
4004
|
+
content: C,
|
|
3981
4005
|
role: "user",
|
|
3982
4006
|
status: "DONE",
|
|
3983
|
-
attachments: l && l.length > 0 ?
|
|
4007
|
+
attachments: l && l.length > 0 ? nr(l) : void 0,
|
|
3984
4008
|
createdAt: /* @__PURE__ */ new Date()
|
|
3985
|
-
}),
|
|
4009
|
+
}), L.push({
|
|
3986
4010
|
id: `temp-assistant-${T}`,
|
|
3987
4011
|
conversationId: J || "",
|
|
3988
4012
|
content: "",
|
|
3989
4013
|
role: "assistant",
|
|
3990
4014
|
status: "IN_PROGRESS",
|
|
3991
4015
|
createdAt: /* @__PURE__ */ new Date()
|
|
3992
|
-
}), X(), p ||
|
|
4016
|
+
}), X(), p || eo();
|
|
3993
4017
|
try {
|
|
3994
|
-
const M = await i.sendMessage(
|
|
4018
|
+
const M = await i.sendMessage(C, {
|
|
3995
4019
|
conversationId: J,
|
|
3996
4020
|
files: l,
|
|
3997
|
-
...
|
|
4021
|
+
...h?.agentId ? { agentId: h.agentId } : {}
|
|
3998
4022
|
});
|
|
3999
|
-
M.conversationId && (J || (J = M.conversationId),
|
|
4000
|
-
const V =
|
|
4001
|
-
if (V && (V.id = `user-${T}`, V.conversationId = M.conversationId), M.id && !
|
|
4002
|
-
const Z =
|
|
4003
|
-
Z >= 0 ?
|
|
4023
|
+
M.conversationId && (J || (J = M.conversationId), Ze?.setActiveThread(M.conversationId, M.createdAt));
|
|
4024
|
+
const V = L.find((Z) => Z.id === `temp-user-${T}`);
|
|
4025
|
+
if (V && (V.id = `user-${T}`, V.conversationId = M.conversationId), M.id && !L.some((Z) => Z.id === M.id)) {
|
|
4026
|
+
const Z = L.findIndex((Ln) => Ln.id === `temp-assistant-${T}`);
|
|
4027
|
+
Z >= 0 ? L[Z] = M : L.push(M);
|
|
4004
4028
|
}
|
|
4005
|
-
|
|
4029
|
+
L = L.filter((Z) => !Z.id.startsWith("temp-")), M.status !== "WAITING_CLIENT" && (be = !1), X(), B && kn();
|
|
4006
4030
|
} catch (M) {
|
|
4007
|
-
Ae = M instanceof Error ? M.message : s.common.sendFailed,
|
|
4031
|
+
Ae = M instanceof Error ? M.message : s.common.sendFailed, be = !1, L = L.filter((V) => !V.id.startsWith("temp-")), Oi(C, l), X();
|
|
4008
4032
|
}
|
|
4009
4033
|
}
|
|
4010
|
-
async function
|
|
4011
|
-
|
|
4034
|
+
async function Vt() {
|
|
4035
|
+
be && await i.stop();
|
|
4012
4036
|
}
|
|
4013
|
-
async function
|
|
4037
|
+
async function kn() {
|
|
4014
4038
|
try {
|
|
4015
4039
|
const { data: r } = await i.getConversations();
|
|
4016
4040
|
ke.splice(0, ke.length, ...r);
|
|
4017
4041
|
} catch {
|
|
4018
4042
|
}
|
|
4019
|
-
return
|
|
4043
|
+
return xt = !1, n && !re && (ue === "history" && Ue?.render({
|
|
4020
4044
|
threads: ke,
|
|
4021
4045
|
loading: !1
|
|
4022
|
-
}),
|
|
4046
|
+
}), qi()), ke;
|
|
4023
4047
|
}
|
|
4024
|
-
async function
|
|
4048
|
+
async function To(r) {
|
|
4025
4049
|
Ne = !1;
|
|
4026
4050
|
try {
|
|
4027
4051
|
const l = await i.getConversation(r);
|
|
4028
4052
|
if (J !== r) return;
|
|
4029
|
-
const
|
|
4030
|
-
|
|
4053
|
+
const h = l?.messages ?? [];
|
|
4054
|
+
yt = !1, h.length > 0 && L.length === 0 ? (L = h, X()) : n && X(), n && Ze?.setActiveThread(r, l.lastMessageDate);
|
|
4031
4055
|
} catch {
|
|
4032
4056
|
if (J !== r) return;
|
|
4033
|
-
|
|
4057
|
+
yt = !1, L.length === 0 && (Ze?.clear(), J = void 0, n && (ue === "chat" && De("home"), X()));
|
|
4034
4058
|
}
|
|
4035
4059
|
}
|
|
4036
4060
|
function De(r, l) {
|
|
4037
|
-
if (!n || !
|
|
4038
|
-
l?.byUser && (
|
|
4039
|
-
const
|
|
4040
|
-
|
|
4061
|
+
if (!n || !bt || !Fe || !Bt || !Ue) return;
|
|
4062
|
+
l?.byUser && (et = !0), ue !== r && ft(), ue = r, r === "home" ? (Fe.composerSlot.appendChild(Se), hn(oe)) : r === "chat" && (Bt.composerSlot.appendChild(Se), hn(""));
|
|
4063
|
+
const h = r === "home" ? Fe.el : r === "chat" ? Bt.el : Ue.el;
|
|
4064
|
+
bt.replaceChildren(h), r === "history" && Ue.render({
|
|
4041
4065
|
threads: ke,
|
|
4042
|
-
loading:
|
|
4043
|
-
}), r === "chat" && (Oe = !0,
|
|
4066
|
+
loading: xt
|
|
4067
|
+
}), r === "chat" && (Oe = !0, mn()), Ht?.update({ screen: r }), ht?.setActive(r), ht?.setVisible(r !== "chat");
|
|
4044
4068
|
}
|
|
4045
|
-
async function
|
|
4046
|
-
n && (
|
|
4069
|
+
async function Tt(r) {
|
|
4070
|
+
n && (ft(), be && await Vt(), J = r, L = [], Ae = null, ut.length = 0, Mt.clear(), Pt(), yt = !0, De("chat"), X(), await To(r));
|
|
4047
4071
|
}
|
|
4048
|
-
function
|
|
4049
|
-
|
|
4072
|
+
function qt() {
|
|
4073
|
+
be && Vt(), J = void 0, L = [], Ae = null, ut.length = 0, Mt.clear(), Pt(), yt = !1, Ze?.clear(), Hi(), Fe?.setPending(null), $t = "home", n && De("home", { byUser: !0 }), X();
|
|
4050
4074
|
}
|
|
4051
|
-
function
|
|
4052
|
-
if (!n ||
|
|
4053
|
-
if (
|
|
4054
|
-
|
|
4075
|
+
function qi() {
|
|
4076
|
+
if (!n || Ct) return;
|
|
4077
|
+
if (Ct = !0, !K || et || ue !== "home" || L.length > 0 || J) {
|
|
4078
|
+
Gt();
|
|
4055
4079
|
return;
|
|
4056
4080
|
}
|
|
4057
|
-
const r =
|
|
4058
|
-
r &&
|
|
4081
|
+
const r = qa(ke);
|
|
4082
|
+
r && Tt(r.id), Gt();
|
|
4059
4083
|
}
|
|
4060
|
-
async function
|
|
4084
|
+
async function Gi() {
|
|
4061
4085
|
let r;
|
|
4062
4086
|
try {
|
|
4063
4087
|
r = (await i.getConfig()).permissions[0]?.homePage;
|
|
@@ -4072,86 +4096,86 @@ function us(t, e) {
|
|
|
4072
4096
|
message: l.message,
|
|
4073
4097
|
agentId: l.agentId
|
|
4074
4098
|
})) : void 0
|
|
4075
|
-
}), r.widgetStarter && (
|
|
4099
|
+
}), r.widgetStarter && (bn = r.widgetStarter, Gt()));
|
|
4076
4100
|
}
|
|
4077
|
-
function
|
|
4078
|
-
const r =
|
|
4079
|
-
!r || re || ie && (
|
|
4101
|
+
function Gt() {
|
|
4102
|
+
const r = bn;
|
|
4103
|
+
!r || re || ie && (xt && !Ct || (bn = void 0, !(et || J || L.length > 0 || be || ue !== "home") && nt(r.message, void 0, { agentId: r.agentId })));
|
|
4080
4104
|
}
|
|
4081
|
-
function
|
|
4082
|
-
|
|
4083
|
-
text:
|
|
4105
|
+
function Ao() {
|
|
4106
|
+
Pe = void 0, !(re || ie || ge === !1 || de) && (de = Ka({
|
|
4107
|
+
text: ge,
|
|
4084
4108
|
dismissLabel: D.dismiss,
|
|
4085
|
-
edge:
|
|
4086
|
-
onOpen: () =>
|
|
4109
|
+
edge: gt,
|
|
4110
|
+
onOpen: () => Kt(),
|
|
4087
4111
|
onDismiss: () => {
|
|
4088
4112
|
de = void 0;
|
|
4089
4113
|
}
|
|
4090
|
-
}),
|
|
4114
|
+
}), sn.appendChild(de.el), Sn());
|
|
4091
4115
|
}
|
|
4092
|
-
function
|
|
4093
|
-
if (!n || !U || !
|
|
4094
|
-
const r = getComputedStyle(
|
|
4095
|
-
if (Number.isNaN(l) || Number.isNaN(
|
|
4096
|
-
const
|
|
4116
|
+
function Sn() {
|
|
4117
|
+
if (!n || !U || !pe || At() || !pe.offsetHeight) return;
|
|
4118
|
+
const r = getComputedStyle(pe), l = parseFloat(r.bottom), h = parseFloat(r.right);
|
|
4119
|
+
if (Number.isNaN(l) || Number.isNaN(h)) return;
|
|
4120
|
+
const C = Math.round(l + pe.offsetHeight) + Za, T = Math.round(h), M = [U];
|
|
4097
4121
|
de && M.push(de.el);
|
|
4098
4122
|
for (const V of M)
|
|
4099
|
-
V.style.setProperty("bottom", `${
|
|
4100
|
-
U.style.setProperty("top", `max(40px, calc(100% - ${
|
|
4123
|
+
V.style.setProperty("bottom", `${C}px`, "important"), V.style.setProperty("right", `${T}px`, "important");
|
|
4124
|
+
U.style.setProperty("top", `max(40px, calc(100% - ${C + Ja}px))`, "important"), U.style.setProperty("--ago-panel-max", `calc(100% - ${T + 20}px)`);
|
|
4101
4125
|
}
|
|
4102
|
-
function
|
|
4103
|
-
r.key !== "Escape" || !ie || r.defaultPrevented || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement ||
|
|
4126
|
+
function Fo(r) {
|
|
4127
|
+
r.key !== "Escape" || !ie || r.defaultPrevented || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement || _n() || ot();
|
|
4104
4128
|
}
|
|
4105
|
-
function
|
|
4106
|
-
|
|
4107
|
-
|
|
4129
|
+
function Lo() {
|
|
4130
|
+
Je && clearTimeout(Je), Je = setTimeout(() => {
|
|
4131
|
+
Je = void 0, !re && (Sn(), Fe?.syncColumns());
|
|
4108
4132
|
}, 150);
|
|
4109
4133
|
}
|
|
4110
|
-
n ? (De("home"), X(), ee &&
|
|
4111
|
-
const
|
|
4134
|
+
n ? (De("home"), X(), ee && Gi(), e.conversationId ? (et = !0, Ct = !0, Tt(e.conversationId)) : J && K ? (Ct = !0, Tt(J)) : J = void 0) : (X(), dt && ce?.matches || zt(), J ? To(J) : Yn === "streaming" && Vi(an)), B && kn();
|
|
4135
|
+
const No = {
|
|
4112
4136
|
client: i,
|
|
4113
|
-
element:
|
|
4114
|
-
sendMessage:
|
|
4115
|
-
stop:
|
|
4116
|
-
...
|
|
4117
|
-
open:
|
|
4118
|
-
close:
|
|
4119
|
-
toggle:
|
|
4137
|
+
element: mt,
|
|
4138
|
+
sendMessage: nt,
|
|
4139
|
+
stop: Vt,
|
|
4140
|
+
...he || dt ? {
|
|
4141
|
+
open: Xi,
|
|
4142
|
+
close: Ki,
|
|
4143
|
+
toggle: Yi
|
|
4120
4144
|
} : {},
|
|
4121
|
-
newConversation:
|
|
4145
|
+
newConversation: qt,
|
|
4122
4146
|
...n ? {
|
|
4123
4147
|
showScreen: (r) => De(r, { byUser: !0 }),
|
|
4124
|
-
openConversation: (r) => (
|
|
4148
|
+
openConversation: (r) => (et = !0, Tt(r))
|
|
4125
4149
|
} : {},
|
|
4126
|
-
session:
|
|
4150
|
+
session: Ze,
|
|
4127
4151
|
threads: ke,
|
|
4128
|
-
refreshThreads:
|
|
4152
|
+
refreshThreads: kn,
|
|
4129
4153
|
destroy() {
|
|
4130
|
-
re || (re = !0,
|
|
4154
|
+
re || (re = !0, Di(), ze && clearInterval(ze), Pe && clearTimeout(Pe), Je && clearTimeout(Je), de?.remove(), i.off("config:changed", co), window.removeEventListener("online", Ut), window.removeEventListener("focus", Ut), i.off("message:start", mo), i.off("message:chunk", go), i.off("message:answer-complete", ho), i.off("message:complete", bo), i.off("message:stopped", xo), i.off("message:error", yo), i.off("conversation:title", Co), i.off("toolCall:received", wo), Pt(), S && i.off("form:submitting", vo), R && i.off("form:submitted", Eo), H && i.off("form:error", ko), So = !0, En.forEach((r) => r()), mt.remove(), pe?.remove(), fe?.remove(), document.removeEventListener("keydown", Fo), window.removeEventListener("resize", Lo), Et?.remove(), Be?.remove(), ce?.removeEventListener("change", Oo), document.removeEventListener("keydown", zo), Fn(), ln = !1, Nn(pt), e.client || i.destroy());
|
|
4131
4155
|
}
|
|
4132
4156
|
};
|
|
4133
|
-
return n && Object.defineProperty(
|
|
4134
|
-
get: () =>
|
|
4157
|
+
return n && Object.defineProperty(No, "screen", {
|
|
4158
|
+
get: () => ue,
|
|
4135
4159
|
enumerable: !0
|
|
4136
|
-
}),
|
|
4137
|
-
function
|
|
4160
|
+
}), No;
|
|
4161
|
+
function Xt() {
|
|
4138
4162
|
if (!U) return;
|
|
4139
|
-
if (n)
|
|
4163
|
+
if (n) Io();
|
|
4140
4164
|
else {
|
|
4141
|
-
const l =
|
|
4142
|
-
ce?.matches ? (U.style.width = "100%", A.style.borderRadius = "0", A.style.removeProperty(l)) : (U.style.width = typeof
|
|
4143
|
-
const
|
|
4144
|
-
U.style.transform = ie ? "translateX(0)" :
|
|
4165
|
+
const l = gt === "left" ? "border-right" : "border-left";
|
|
4166
|
+
ce?.matches ? (U.style.width = "100%", A.style.borderRadius = "0", A.style.removeProperty(l)) : (U.style.width = typeof g == "number" ? `${g}px` : g, A.style.setProperty(l, `1px solid ${Q}`));
|
|
4167
|
+
const h = o === "left" ? "translateX(-100%)" : "translateX(100%)";
|
|
4168
|
+
U.style.transform = ie ? "translateX(0)" : h, pe && (pe.style.display = ie ? "none" : "flex");
|
|
4145
4169
|
}
|
|
4146
4170
|
U.setAttribute("aria-hidden", ie ? "false" : "true");
|
|
4147
|
-
const r =
|
|
4148
|
-
r !==
|
|
4171
|
+
const r = _n();
|
|
4172
|
+
r !== ln && (ln = r, r ? (A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), A.tabIndex = -1, A.style.paddingBottom = "env(safe-area-inset-bottom)", Wo(pt), He = Tn(), An(), Ho()) : (Fn(), Zi(), He = 0, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), A.style.removeProperty("padding-bottom"), Nn(pt)));
|
|
4149
4173
|
}
|
|
4150
|
-
function
|
|
4174
|
+
function Io() {
|
|
4151
4175
|
if (!U) return;
|
|
4152
|
-
U.style.display = ie ? "block" : "none",
|
|
4153
|
-
const r =
|
|
4154
|
-
if (
|
|
4176
|
+
U.style.display = ie ? "block" : "none", wt.open = s.common.openTitle.replace("{title}", () => Y), wt.close = s.common.closeTitle.replace("{title}", () => Y), Ot?.setOpen(ie);
|
|
4177
|
+
const r = At();
|
|
4178
|
+
if (pe && (pe.style.display = r && ie ? "none" : "flex"), r) {
|
|
4155
4179
|
for (const l of [
|
|
4156
4180
|
"bottom",
|
|
4157
4181
|
"right",
|
|
@@ -4186,95 +4210,95 @@ function us(t, e) {
|
|
|
4186
4210
|
right: "20px",
|
|
4187
4211
|
bottom: "80px",
|
|
4188
4212
|
top: "max(40px, calc(100% - 880px))",
|
|
4189
|
-
width: `min(max(400px, ${
|
|
4213
|
+
width: `min(max(400px, ${Mo}), var(--ago-panel-max, calc(100% - 40px)))`,
|
|
4190
4214
|
height: "auto",
|
|
4191
4215
|
borderRadius: "16px"
|
|
4192
|
-
}), U.dataset.agoLayout = "panel",
|
|
4216
|
+
}), U.dataset.agoLayout = "panel", Sn();
|
|
4193
4217
|
}
|
|
4194
4218
|
}
|
|
4195
|
-
function
|
|
4196
|
-
ie = !0,
|
|
4197
|
-
}
|
|
4198
|
-
function tt() {
|
|
4199
|
-
ut(), ie = !1, Gt(), W?.();
|
|
4219
|
+
function Kt() {
|
|
4220
|
+
ie = !0, Pe && (clearTimeout(Pe), Pe = void 0), de?.remove(), de = void 0, Xt(), At() ? A.focus({ preventScroll: !0 }) : zt(), Gt(), $?.();
|
|
4200
4221
|
}
|
|
4201
|
-
function
|
|
4202
|
-
ie
|
|
4222
|
+
function ot() {
|
|
4223
|
+
ft(), ie = !1, Xt(), W?.();
|
|
4203
4224
|
}
|
|
4204
|
-
function
|
|
4205
|
-
|
|
4225
|
+
function Ro() {
|
|
4226
|
+
ie ? ot() : Kt();
|
|
4206
4227
|
}
|
|
4207
4228
|
function Xi() {
|
|
4208
|
-
|
|
4229
|
+
he ? Kt() : Ft();
|
|
4209
4230
|
}
|
|
4210
4231
|
function Ki() {
|
|
4211
|
-
|
|
4232
|
+
ft(), he ? ot() : Lt();
|
|
4233
|
+
}
|
|
4234
|
+
function Yi() {
|
|
4235
|
+
he ? Ro() : Le ? Lt() : Ft();
|
|
4212
4236
|
}
|
|
4213
|
-
function
|
|
4237
|
+
function At() {
|
|
4214
4238
|
return !!ce?.matches;
|
|
4215
4239
|
}
|
|
4216
|
-
function
|
|
4217
|
-
return
|
|
4240
|
+
function _n() {
|
|
4241
|
+
return At() && (he ? ie : Le);
|
|
4218
4242
|
}
|
|
4219
|
-
function
|
|
4243
|
+
function Qi() {
|
|
4220
4244
|
return Array.from(A.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((r) => r.getClientRects().length > 0);
|
|
4221
4245
|
}
|
|
4222
|
-
function
|
|
4223
|
-
if (!
|
|
4246
|
+
function zo(r) {
|
|
4247
|
+
if (!_n()) return;
|
|
4224
4248
|
if (r.key === "Escape") {
|
|
4225
|
-
|
|
4249
|
+
he ? ot() : Lt();
|
|
4226
4250
|
return;
|
|
4227
4251
|
}
|
|
4228
4252
|
if (r.key !== "Tab") return;
|
|
4229
|
-
const l =
|
|
4253
|
+
const l = Qi();
|
|
4230
4254
|
if (l.length === 0) {
|
|
4231
4255
|
r.preventDefault();
|
|
4232
4256
|
return;
|
|
4233
4257
|
}
|
|
4234
|
-
const
|
|
4235
|
-
r.shiftKey && (T ===
|
|
4258
|
+
const h = l[0], C = l[l.length - 1], T = document.activeElement;
|
|
4259
|
+
r.shiftKey && (T === h || !A.contains(T)) ? (r.preventDefault(), C.focus()) : !r.shiftKey && (T === C || !A.contains(T)) && (r.preventDefault(), h.focus());
|
|
4236
4260
|
}
|
|
4237
|
-
function
|
|
4238
|
-
|
|
4261
|
+
function Oo(r) {
|
|
4262
|
+
he ? Xt() : !r.matches && Le && Lt(), X();
|
|
4239
4263
|
}
|
|
4240
|
-
function
|
|
4264
|
+
function Tn() {
|
|
4241
4265
|
return window.visualViewport?.height ?? window.innerHeight;
|
|
4242
4266
|
}
|
|
4243
|
-
function
|
|
4244
|
-
const r = window.visualViewport, l = r?.offsetTop ?? 0,
|
|
4245
|
-
if (
|
|
4267
|
+
function An() {
|
|
4268
|
+
const r = window.visualViewport, l = r?.offsetTop ?? 0, h = r?.height ?? He;
|
|
4269
|
+
if (he) {
|
|
4246
4270
|
if (!U) return;
|
|
4247
|
-
const T = window.innerHeight || He, M = Math.max(0, T - (l +
|
|
4271
|
+
const T = window.innerHeight || He, M = Math.max(0, T - (l + h));
|
|
4248
4272
|
U.style.bottom = `${M}px`, U.style.top = `${l}px`;
|
|
4249
4273
|
return;
|
|
4250
4274
|
}
|
|
4251
|
-
const
|
|
4252
|
-
A.style.top = `${
|
|
4275
|
+
const C = Math.min(0, l + h - He);
|
|
4276
|
+
A.style.top = `${C}px`, fe && (fe.style.top = `${l}px`);
|
|
4253
4277
|
}
|
|
4254
|
-
function
|
|
4255
|
-
|
|
4278
|
+
function Zi() {
|
|
4279
|
+
he && U && (U.style.removeProperty("bottom"), U.style.removeProperty("top"), n && !re && Io());
|
|
4256
4280
|
}
|
|
4257
|
-
function
|
|
4258
|
-
|
|
4259
|
-
|
|
4281
|
+
function Yt() {
|
|
4282
|
+
tt || (tt = requestAnimationFrame(() => {
|
|
4283
|
+
tt = 0, !re && An();
|
|
4260
4284
|
}));
|
|
4261
4285
|
}
|
|
4262
|
-
function
|
|
4263
|
-
window.visualViewport?.addEventListener("resize",
|
|
4286
|
+
function Ho() {
|
|
4287
|
+
window.visualViewport?.addEventListener("resize", Yt), window.visualViewport?.addEventListener("scroll", Yt);
|
|
4264
4288
|
}
|
|
4265
|
-
function
|
|
4266
|
-
window.visualViewport?.removeEventListener("resize",
|
|
4289
|
+
function Fn() {
|
|
4290
|
+
window.visualViewport?.removeEventListener("resize", Yt), window.visualViewport?.removeEventListener("scroll", Yt), tt && (cancelAnimationFrame(tt), tt = 0);
|
|
4267
4291
|
}
|
|
4268
|
-
function
|
|
4269
|
-
Oe = !0,
|
|
4292
|
+
function Bo() {
|
|
4293
|
+
Oe = !0, mn();
|
|
4270
4294
|
}
|
|
4271
|
-
function
|
|
4295
|
+
function Ji() {
|
|
4272
4296
|
const r = d({
|
|
4273
4297
|
position: "fixed",
|
|
4274
4298
|
top: "0",
|
|
4275
4299
|
left: "0",
|
|
4276
4300
|
right: "0",
|
|
4277
|
-
height: `calc(${
|
|
4301
|
+
height: `calc(${no}px + env(safe-area-inset-top))`,
|
|
4278
4302
|
display: "none",
|
|
4279
4303
|
alignItems: "center",
|
|
4280
4304
|
justifyContent: "space-between",
|
|
@@ -4284,22 +4308,22 @@ function us(t, e) {
|
|
|
4284
4308
|
zIndex: "2147483001",
|
|
4285
4309
|
fontFamily: Re
|
|
4286
4310
|
});
|
|
4287
|
-
if (r.className = "ago-chat-widget-mobile-bar",
|
|
4288
|
-
const
|
|
4289
|
-
|
|
4311
|
+
if (r.className = "ago-chat-widget-mobile-bar", y) {
|
|
4312
|
+
const h = document.createElement("img");
|
|
4313
|
+
h.src = y, h.alt = "", u(h, {
|
|
4290
4314
|
height: "28px",
|
|
4291
4315
|
width: "auto"
|
|
4292
|
-
}), r.appendChild(
|
|
4316
|
+
}), r.appendChild(h);
|
|
4293
4317
|
} else if (Y) {
|
|
4294
|
-
const
|
|
4295
|
-
|
|
4318
|
+
const h = document.createElement("span");
|
|
4319
|
+
h.className = "ago-chat-widget__title", h.textContent = Y, u(h, {
|
|
4296
4320
|
fontSize: "15px",
|
|
4297
4321
|
fontWeight: "600",
|
|
4298
4322
|
color: ne,
|
|
4299
4323
|
overflow: "hidden",
|
|
4300
4324
|
whiteSpace: "nowrap",
|
|
4301
4325
|
textOverflow: "ellipsis"
|
|
4302
|
-
}), r.appendChild(
|
|
4326
|
+
}), r.appendChild(h);
|
|
4303
4327
|
} else r.appendChild(d({}));
|
|
4304
4328
|
const l = document.createElement("button");
|
|
4305
4329
|
return l.type = "button", l.setAttribute("aria-label", s.common.close), l.textContent = "×", u(l, {
|
|
@@ -4318,24 +4342,24 @@ function us(t, e) {
|
|
|
4318
4342
|
cursor: "pointer",
|
|
4319
4343
|
padding: "0"
|
|
4320
4344
|
}), l.addEventListener("click", () => {
|
|
4321
|
-
|
|
4345
|
+
Lt();
|
|
4322
4346
|
}), r.appendChild(l), r;
|
|
4323
4347
|
}
|
|
4324
|
-
function
|
|
4325
|
-
return typeof document.startViewTransition == "function" && !
|
|
4348
|
+
function er() {
|
|
4349
|
+
return typeof document.startViewTransition == "function" && !Li?.matches && !!ce?.matches;
|
|
4326
4350
|
}
|
|
4327
|
-
function
|
|
4351
|
+
function $o(r) {
|
|
4328
4352
|
const l = document;
|
|
4329
|
-
if (
|
|
4330
|
-
A.style.setProperty("view-transition-name",
|
|
4331
|
-
const
|
|
4332
|
-
A.style.removeProperty("view-transition-name"),
|
|
4353
|
+
if (er() && l.startViewTransition) {
|
|
4354
|
+
A.style.setProperty("view-transition-name", vt), fe?.style.setProperty("view-transition-name", `${vt}-bar`);
|
|
4355
|
+
const h = () => {
|
|
4356
|
+
A.style.removeProperty("view-transition-name"), fe?.style.removeProperty("view-transition-name");
|
|
4333
4357
|
};
|
|
4334
|
-
return l.startViewTransition(r).finished.then(
|
|
4358
|
+
return l.startViewTransition(r).finished.then(h, h);
|
|
4335
4359
|
}
|
|
4336
4360
|
return r(), Promise.resolve();
|
|
4337
4361
|
}
|
|
4338
|
-
function
|
|
4362
|
+
function Do(r) {
|
|
4339
4363
|
if (r)
|
|
4340
4364
|
Be && A.parentElement?.insertBefore(Be, A), u(A, {
|
|
4341
4365
|
position: "fixed",
|
|
@@ -4348,9 +4372,9 @@ function us(t, e) {
|
|
|
4348
4372
|
border: "none",
|
|
4349
4373
|
borderRadius: "0",
|
|
4350
4374
|
boxShadow: "none",
|
|
4351
|
-
paddingTop: `calc(${
|
|
4375
|
+
paddingTop: `calc(${no}px + env(safe-area-inset-top))`,
|
|
4352
4376
|
paddingBottom: "env(safe-area-inset-bottom)"
|
|
4353
|
-
}), A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y),
|
|
4377
|
+
}), A.setAttribute("role", "dialog"), A.setAttribute("aria-modal", "true"), A.setAttribute("aria-label", Y), xe && (xe.style.display = "none"), fe && (fe.style.display = "flex");
|
|
4354
4378
|
else {
|
|
4355
4379
|
Be?.remove(), Be = void 0;
|
|
4356
4380
|
for (const l of [
|
|
@@ -4363,40 +4387,40 @@ function us(t, e) {
|
|
|
4363
4387
|
"padding-top",
|
|
4364
4388
|
"padding-bottom"
|
|
4365
4389
|
]) A.style.removeProperty(l);
|
|
4366
|
-
A.style.height =
|
|
4390
|
+
A.style.height = Dt.height, A.style.border = Dt.border, A.style.borderRadius = Dt.borderRadius, A.style.boxShadow = Dt.boxShadow, A.removeAttribute("role"), A.removeAttribute("aria-modal"), A.removeAttribute("aria-label"), xe && (xe.style.display = "flex"), fe && (fe.style.display = "none");
|
|
4367
4391
|
}
|
|
4368
4392
|
}
|
|
4369
|
-
function
|
|
4393
|
+
function Ft() {
|
|
4370
4394
|
if (re || Le || !ce?.matches) return Promise.resolve();
|
|
4371
4395
|
const r = A.getBoundingClientRect();
|
|
4372
|
-
if (r.height >=
|
|
4396
|
+
if (r.height >= Tn() * 0.8) return Promise.resolve();
|
|
4373
4397
|
Le = !0, Be = d({
|
|
4374
4398
|
width: `${r.width}px`,
|
|
4375
4399
|
height: `${r.height}px`
|
|
4376
|
-
}), Be.className = "ago-chat-widget-spacer", Be.setAttribute("aria-hidden", "true"), He =
|
|
4377
|
-
const l =
|
|
4400
|
+
}), Be.className = "ago-chat-widget-spacer", Be.setAttribute("aria-hidden", "true"), He = Tn(), A.style.setProperty("--ago-vh", `${He}px`), An(), Ho(), Wo(pt);
|
|
4401
|
+
const l = $o(() => Do(!0));
|
|
4378
4402
|
return l.then(() => {
|
|
4379
|
-
re || (
|
|
4380
|
-
}),
|
|
4403
|
+
re || (Bo(), zt());
|
|
4404
|
+
}), Bo(), $?.(), l;
|
|
4381
4405
|
}
|
|
4382
|
-
function
|
|
4406
|
+
function Lt() {
|
|
4383
4407
|
if (!Le) return Promise.resolve();
|
|
4384
|
-
|
|
4385
|
-
const r =
|
|
4408
|
+
ft(), Le = !1, Fn(), Nn(pt), A.querySelector("textarea")?.blur();
|
|
4409
|
+
const r = $o(() => Do(!1));
|
|
4386
4410
|
return r.then(() => {
|
|
4387
4411
|
re || A.style.removeProperty("--ago-vh");
|
|
4388
4412
|
}), He = 0, W?.(), r;
|
|
4389
4413
|
}
|
|
4390
4414
|
}
|
|
4391
4415
|
export {
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4395
|
-
|
|
4396
|
-
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4400
|
-
|
|
4401
|
-
|
|
4416
|
+
fs as DEFAULT_FEEDBACK_LABELS,
|
|
4417
|
+
ps as DEFAULT_SPEECH_TO_TEXT_LABELS,
|
|
4418
|
+
xa as DEFAULT_TOOL_CALL_FORM_LABELS,
|
|
4419
|
+
us as DEFAULT_WIDGET_LABELS,
|
|
4420
|
+
Ir as colorsToTheme,
|
|
4421
|
+
ds as compactMediaQuery,
|
|
4422
|
+
cs as createSheetController,
|
|
4423
|
+
ms as mountChatWidget,
|
|
4424
|
+
_r as readableTextColor,
|
|
4425
|
+
Ye as renderMarkdown
|
|
4402
4426
|
};
|