@useago/sdk 1.7.2 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/README.md +43 -1
  3. package/dist/angular.cjs +1 -1
  4. package/dist/angular.d.cts +89 -5
  5. package/dist/angular.d.ts +89 -5
  6. package/dist/angular.js +11 -7
  7. package/dist/{createConversationSession-DP90nY71.js → createConversationSession-BaaXBQ5b.js} +3 -3
  8. package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
  9. package/dist/{createFormCollector-BivHRIAe.js → createFormCollector-Cf7kGhCB.js} +1 -1
  10. package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
  11. package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
  12. package/dist/createMockClient-BZbOe-23.cjs +1 -0
  13. package/dist/devtools.cjs +61 -12
  14. package/dist/devtools.d.cts +90 -5
  15. package/dist/devtools.d.ts +90 -5
  16. package/dist/devtools.js +225 -73
  17. package/dist/errors-BLfjXnLB.js +32 -0
  18. package/dist/errors-o1IB5fEu.cjs +1 -0
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.d.cts +100 -3
  21. package/dist/index.d.ts +100 -3
  22. package/dist/index.js +77 -75
  23. package/dist/react.cjs +4 -4
  24. package/dist/react.d.cts +197 -3
  25. package/dist/react.d.ts +197 -3
  26. package/dist/react.js +1034 -752
  27. package/dist/testing.cjs +1 -1
  28. package/dist/testing.d.cts +80 -3
  29. package/dist/testing.d.ts +80 -3
  30. package/dist/testing.js +1 -1
  31. package/dist/{AgoClient-DTkBRGFE.js → types-CPga11Of.js} +489 -386
  32. package/dist/types-D3YQl1jx.cjs +9 -0
  33. package/dist/vue.cjs +1 -1
  34. package/dist/vue.d.cts +110 -3
  35. package/dist/vue.d.ts +110 -3
  36. package/dist/vue.js +202 -154
  37. package/dist/widget.cjs +4 -4
  38. package/dist/widget.d.cts +148 -3
  39. package/dist/widget.d.ts +148 -3
  40. package/dist/widget.js +871 -651
  41. package/llms-full.txt +139 -25
  42. package/package.json +1 -1
  43. package/dist/AgoClient-7yXQ6R3O.cjs +0 -9
  44. package/dist/createConversationSession-Bv6a15E0.cjs +0 -1
  45. package/dist/createFormCollector-CwfiYn0V.cjs +0 -1
  46. package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/widget.js CHANGED
@@ -1,73 +1,74 @@
1
- import { a as mn, b as hn, i as gn, o as xn, s as bn, t as yn } from "./AgoClient-DTkBRGFE.js";
2
- import { t as wn } from "./createConversationSession-DP90nY71.js";
3
- import { r as vn, t as Cn } from "./createFormCollector-BivHRIAe.js";
4
- import { C as Qe, S as _t, _ as te, a as T, b as g, c as $e, d as Ot, f as Ye, g as En, h as ne, i as Lt, l as Sn, m as Bt, n as jn, o as Te, p as An, r as Je, s as Me, t as Vn, u as $t, v as Rn, x as kn, y as E } from "./sheetController-CBUVOroo.js";
5
- function In(n) {
6
- let o = [];
7
- const r = document.createElement("form");
8
- E(r, {
1
+ import { a as Cn, c as En, n as Sn, o as kn, s as An, t as _n } from "./types-CPga11Of.js";
2
+ import { n as Rn } from "./errors-BLfjXnLB.js";
3
+ import { t as In } from "./createConversationSession-BaaXBQ5b.js";
4
+ import { r as Nn, t as Ln } from "./createFormCollector-Cf7kGhCB.js";
5
+ import { C as tt, S as Ot, _ as F, a as R, b, c as ze, d as Pt, f as He, g as Tn, h as Q, i as Bt, l as $n, m as he, n as so, o as Ce, p as On, r as fe, s as Ee, t as lo, u as Mt, v as Bn, x as Mn, y as E } from "./sheetController-CBUVOroo.js";
6
+ function zn(r) {
7
+ let t = [];
8
+ const i = document.createElement("form");
9
+ E(i, {
9
10
  display: "flex",
10
11
  flexDirection: "column",
11
12
  gap: "8px",
12
13
  padding: "12px",
13
- borderTop: `1px solid ${T}`,
14
- backgroundColor: ne
15
- }), r.className = "ago-chat-input";
16
- const i = g({
14
+ borderTop: `1px solid ${R}`,
15
+ backgroundColor: Q
16
+ }), i.className = "ago-chat-input";
17
+ const n = b({
17
18
  display: "flex",
18
19
  flexWrap: "wrap",
19
20
  gap: "6px"
20
- }), w = g({
21
+ }), m = b({
21
22
  display: "flex",
22
23
  gap: "8px",
23
24
  alignItems: "flex-end"
24
- }), s = document.createElement("textarea");
25
- s.placeholder = n.placeholder, s.setAttribute("aria-label", n.placeholder), s.rows = 1, E(s, {
25
+ }), a = document.createElement("textarea");
26
+ a.placeholder = r.placeholder, a.setAttribute("aria-label", r.placeholder), a.rows = 1, E(a, {
26
27
  flex: "1",
27
28
  resize: "none",
28
29
  boxSizing: "border-box",
29
30
  padding: "10px 12px",
30
- border: `1px solid ${T}`,
31
+ border: `1px solid ${R}`,
31
32
  borderRadius: "12px",
32
33
  fontSize: "16px",
33
- fontFamily: $e,
34
+ fontFamily: ze,
34
35
  lineHeight: "1.4",
35
36
  maxHeight: "110px",
36
37
  overflowY: "hidden"
37
38
  });
38
- const k = () => {
39
- s.style.height = "auto";
40
- const h = Math.min(s.scrollHeight + 2, 110);
41
- s.style.height = `${h}px`, s.style.overflowY = s.scrollHeight + 2 > 110 ? "auto" : "hidden";
39
+ const x = () => {
40
+ a.style.height = "auto";
41
+ const g = Math.min(a.scrollHeight + 2, 110);
42
+ a.style.height = `${g}px`, a.style.overflowY = a.scrollHeight + 2 > 110 ? "auto" : "hidden";
42
43
  };
43
- s.addEventListener("input", () => {
44
- k(), F();
44
+ a.addEventListener("input", () => {
45
+ x(), I();
45
46
  });
46
- const m = '<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>', v = '<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>', c = document.createElement("button");
47
- c.type = "submit", c.setAttribute("aria-label", "Send"), c.innerHTML = m, E(c, {
47
+ 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>', w = '<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>', d = '<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>', u = document.createElement("button");
48
+ u.type = "submit", u.setAttribute("aria-label", "Send"), u.innerHTML = p, E(u, {
48
49
  flexShrink: "0",
49
50
  width: "44px",
50
51
  height: "44px",
51
52
  padding: "0",
52
53
  border: "none",
53
54
  borderRadius: "50%",
54
- backgroundColor: Te,
55
- color: Me,
55
+ backgroundColor: Ce,
56
+ color: Ee,
56
57
  display: "flex",
57
58
  alignItems: "center",
58
59
  justifyContent: "center",
59
60
  cursor: "pointer"
60
61
  });
61
- let A = !1;
62
- const z = () => A && !!n.onStop, F = () => {
63
- const d = s.value.trim() !== "" || o.length > 0, h = z(), _ = !h && (A || !d);
64
- c.disabled = _, c.type = h ? "button" : "submit", c.setAttribute("aria-label", h ? "Stop generating" : "Send"), c.innerHTML = h ? f : A ? v : m, c.style.opacity = _ && !A ? "0.5" : "1", c.style.cursor = _ ? "default" : "pointer";
62
+ let h = !1;
63
+ const _ = () => h && !!r.onStop, I = () => {
64
+ const c = a.value.trim() !== "" || t.length > 0, g = _(), N = !g && (h || !c);
65
+ u.disabled = N, u.type = g ? "button" : "submit", u.setAttribute("aria-label", g ? "Stop generating" : "Send"), u.innerHTML = g ? d : h ? w : p, u.style.opacity = N && !h ? "0.5" : "1", u.style.cursor = N ? "default" : "pointer";
65
66
  };
66
- c.addEventListener("click", () => {
67
- z() && n.onStop?.();
67
+ u.addEventListener("click", () => {
68
+ _() && r.onStop?.();
68
69
  });
69
- let B = null, I = null;
70
- n.allowFiles && (B = document.createElement("input"), B.type = "file", B.multiple = !0, E(B, { display: "none" }), I = document.createElement("button"), I.type = "button", I.setAttribute("aria-label", "Attach file"), I.textContent = "📎", E(I, {
70
+ let L = null, W = null;
71
+ r.allowFiles && (L = document.createElement("input"), L.type = "file", L.multiple = !0, E(L, { display: "none" }), W = document.createElement("button"), W.type = "button", W.setAttribute("aria-label", "Attach file"), W.textContent = "📎", E(W, {
71
72
  flexShrink: "0",
72
73
  minWidth: "44px",
73
74
  minHeight: "44px",
@@ -75,29 +76,29 @@ function In(n) {
75
76
  alignItems: "center",
76
77
  justifyContent: "center",
77
78
  padding: "0 12px",
78
- border: `1px solid ${T}`,
79
+ border: `1px solid ${R}`,
79
80
  borderRadius: "12px",
80
- backgroundColor: ne,
81
+ backgroundColor: Q,
81
82
  cursor: "pointer",
82
83
  fontSize: "14px"
83
- }), I.addEventListener("click", () => B?.click()), B.addEventListener("change", () => {
84
- o = [...o, ...Array.from(B?.files ?? [])], u();
84
+ }), W.addEventListener("click", () => L?.click()), L.addEventListener("change", () => {
85
+ t = [...t, ...Array.from(L?.files ?? [])], D();
85
86
  }));
86
- function u() {
87
- i.replaceChildren(), o.forEach((d, h) => {
88
- const _ = g({
87
+ function D() {
88
+ n.replaceChildren(), t.forEach((c, g) => {
89
+ const N = b({
89
90
  display: "flex",
90
91
  alignItems: "center",
91
92
  gap: "4px",
92
93
  padding: "4px 8px",
93
94
  backgroundColor: "#f0f4ff",
94
- border: `1px solid ${T}`,
95
+ border: `1px solid ${R}`,
95
96
  borderRadius: "8px",
96
97
  fontSize: "12px"
97
- }), K = document.createElement("span");
98
- K.textContent = d.name;
99
- const D = document.createElement("button");
100
- D.type = "button", D.setAttribute("aria-label", `Remove ${d.name}`), D.textContent = "×", E(D, {
98
+ }), P = document.createElement("span");
99
+ P.textContent = c.name;
100
+ const U = document.createElement("button");
101
+ U.type = "button", U.setAttribute("aria-label", `Remove ${c.name}`), U.textContent = "×", E(U, {
101
102
  flexShrink: "0",
102
103
  width: "44px",
103
104
  height: "44px",
@@ -110,239 +111,423 @@ function In(n) {
110
111
  cursor: "pointer",
111
112
  fontSize: "14px",
112
113
  lineHeight: "1"
113
- }), D.addEventListener("click", () => {
114
- o = o.filter((M, j) => j !== h), u();
115
- }), _.append(K, D), i.appendChild(_);
116
- }), F();
114
+ }), U.addEventListener("click", () => {
115
+ t = t.filter((oe, T) => T !== g), D();
116
+ }), N.append(P, U), n.appendChild(N);
117
+ }), I();
117
118
  }
118
- const x = () => {
119
- const d = s.value, h = o;
120
- return s.value = "", k(), o = [], u(), {
121
- content: d,
122
- files: h
119
+ const v = () => {
120
+ const c = a.value, g = t;
121
+ return a.value = "", x(), t = [], D(), {
122
+ content: c,
123
+ files: g
123
124
  };
124
- }, y = () => {
125
- const { content: d, files: h } = x();
126
- (d.trim() || h.length > 0) && n.onSend(d.trim(), h.length > 0 ? h : void 0);
125
+ }, S = () => {
126
+ const { content: c, files: g } = v();
127
+ (c.trim() || g.length > 0) && r.onSend(c.trim(), g.length > 0 ? g : void 0);
127
128
  };
128
- return r.addEventListener("submit", (d) => {
129
- d.preventDefault(), y();
130
- }), s.addEventListener("keydown", (d) => {
131
- d.key === "Enter" && !d.shiftKey && (d.preventDefault(), y());
132
- }), I && w.appendChild(I), w.append(s, c), B && r.appendChild(B), r.append(i, w), F(), {
133
- inputRow: r,
134
- getValueAndClear: x,
135
- setDisabled: (d) => {
136
- s.disabled = d, A = d, F();
129
+ return i.addEventListener("submit", (c) => {
130
+ c.preventDefault(), S();
131
+ }), a.addEventListener("keydown", (c) => {
132
+ c.key === "Enter" && !c.shiftKey && (c.preventDefault(), S());
133
+ }), W && m.appendChild(W), m.append(a, u), L && i.appendChild(L), i.append(n, m), I(), {
134
+ inputRow: i,
135
+ getValueAndClear: v,
136
+ setDisabled: (c) => {
137
+ a.disabled = c, h = c, I();
137
138
  },
138
- focus: () => s.focus(),
139
- restoreDraft: (d, h) => {
140
- d && !s.value.trim() && (s.value = d, k()), h?.length && (o = [...h, ...o], u()), F();
139
+ focus: () => a.focus(),
140
+ restoreDraft: (c, g) => {
141
+ c && !a.value.trim() && (a.value = c, x()), g?.length && (t = [...g, ...t], D()), I();
141
142
  }
142
143
  };
143
144
  }
144
- var _n = {
145
+ var Dn = {
145
146
  "&": "&amp;",
146
147
  "<": "&lt;",
147
148
  ">": "&gt;",
148
149
  '"': "&quot;",
149
150
  "'": "&#39;"
150
151
  };
151
- function ce(n) {
152
- return n.replace(/[&<>"']/g, (o) => _n[o]);
152
+ function ue(r) {
153
+ return r.replace(/[&<>"']/g, (t) => Dn[t]);
153
154
  }
154
- function Nt(n) {
155
- const o = n.trim();
156
- return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(o) || !/^[a-z][a-z0-9+.-]*:/i.test(o) ? o : null;
155
+ function zt(r) {
156
+ const t = r.trim();
157
+ return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(t) || !/^[a-z][a-z0-9+.-]*:/i.test(t) ? t : null;
157
158
  }
158
- var Dt = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Le = "";
159
- function ie(n) {
160
- const o = [], r = (w) => (o.push(w), `${Le}${o.length - 1}${Le}`);
161
- let i = n;
162
- return i = i.replace(/`([^`]+)`/g, (w, s) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Dt}">${ce(s)}</code>`)), i = i.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (w, s, k) => {
163
- const m = Nt(k);
164
- return m ? r(`<img alt="${ce(s)}" src="${ce(m)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : w;
165
- }), i = i.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (w, s, k) => {
166
- const m = Nt(k);
167
- return m ? r(`<a href="${ce(m)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ie(s)}</a>`) : w;
168
- }), i = ce(i), i = i.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>"), i = i.replace(new RegExp(`${Le}(\\d+)${Le}`, "g"), (w, s) => o[Number(s)]), i;
159
+ var Ut = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Me = "";
160
+ function ie(r) {
161
+ const t = [], i = (m) => (t.push(m), `${Me}${t.length - 1}${Me}`);
162
+ let n = r;
163
+ return n = n.replace(/`([^`]+)`/g, (m, a) => i(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Ut}">${ue(a)}</code>`)), n = n.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (m, a, x) => {
164
+ const p = zt(x);
165
+ return p ? i(`<img alt="${ue(a)}" src="${ue(p)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : m;
166
+ }), n = n.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (m, a, x) => {
167
+ const p = zt(x);
168
+ return p ? i(`<a href="${ue(p)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${ie(a)}</a>`) : m;
169
+ }), n = ue(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(`${Me}(\\d+)${Me}`, "g"), (m, a) => t[Number(a)]), n;
169
170
  }
170
- function P(n, o, r) {
171
- const i = document.createElement(n);
172
- return Object.assign(i.style, o), r !== void 0 && (i.innerHTML = r), i;
171
+ function G(r, t, i) {
172
+ const n = document.createElement(r);
173
+ return Object.assign(n.style, t), i !== void 0 && (n.innerHTML = i), n;
173
174
  }
174
- var Ht = /^ {0,3}([-*_])( *\1){2,} *$/, zt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Ft = /^ {0,3}(```+|~~~+)/, Ne = /^ {0,3}>\s?/, pe = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Ln = [
175
+ var Gt = /^ {0,3}([-*_])( *\1){2,} *$/, jt = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Vt = /^ {0,3}(```+|~~~+)/, De = /^ {0,3}>\s?/, me = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Hn = [
175
176
  "20px",
176
177
  "18px",
177
178
  "16px",
178
179
  "15px",
179
180
  "14px",
180
181
  "13px"
181
- ], Ze = (n) => n.match(/^\s*/)?.[0].length ?? 0;
182
- function $n(n) {
183
- return n.trim() === "" || Ht.test(n) || zt.test(n) || Ft.test(n) || Ne.test(n) || pe.test(n);
182
+ ], nt = (r) => r.match(/^\s*/)?.[0].length ?? 0;
183
+ function Fn(r) {
184
+ return r.trim() === "" || Gt.test(r) || jt.test(r) || Vt.test(r) || De.test(r) || me.test(r);
184
185
  }
185
- function Pt(n) {
186
- const o = n[0].match(pe), r = o[1].length, i = /\d/.test(o[2]), w = P(i ? "ol" : "ul", {
186
+ function qt(r) {
187
+ const t = r[0].match(me), i = t[1].length, n = /\d/.test(t[2]), m = G(n ? "ol" : "ul", {
187
188
  margin: "0 0 8px 0",
188
189
  paddingLeft: "20px",
189
- listStyleType: i ? "decimal" : "disc",
190
+ listStyleType: n ? "decimal" : "disc",
190
191
  listStylePosition: "outside"
191
192
  });
192
- let s = 0;
193
- for (; s < n.length; ) {
194
- const k = n[s].match(pe), m = [];
195
- for (s++; s < n.length && Ze(n[s]) > r; )
196
- m.push(n[s]), s++;
197
- const v = P("li", {
193
+ let a = 0;
194
+ for (; a < r.length; ) {
195
+ const x = r[a].match(me), p = [];
196
+ for (a++; a < r.length && nt(r[a]) > i; )
197
+ p.push(r[a]), a++;
198
+ const w = G("li", {
198
199
  display: "list-item",
199
200
  margin: "2px 0",
200
201
  lineHeight: "1.6"
201
- }), f = k[3].match(/^\[([ xX])\]\s+(.*)$/);
202
- f ? (v.style.listStyleType = "none", v.style.marginLeft = "-20px", v.innerHTML = `<span style="margin-right:6px">${f[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ie(f[2])}`) : v.innerHTML = ie(k[3]), m.filter((c) => pe.test(c)).length > 0 && v.appendChild(Pt(m.filter((c) => c.trim() !== ""))), w.appendChild(v);
202
+ }), d = x[3].match(/^\[([ xX])\]\s+(.*)$/);
203
+ d ? (w.style.listStyleType = "none", w.style.marginLeft = "-20px", w.innerHTML = `<span style="margin-right:6px">${d[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${ie(d[2])}`) : w.innerHTML = ie(x[3]), p.filter((u) => me.test(u)).length > 0 && w.appendChild(qt(p.filter((u) => u.trim() !== ""))), m.appendChild(w);
203
204
  }
204
- return w;
205
+ return m;
205
206
  }
206
- function Nn(n) {
207
- const o = (m) => m.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((v) => v.trim()), r = P("div", {
207
+ function Wn(r) {
208
+ const t = (p) => p.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((w) => w.trim()), i = G("div", {
208
209
  overflowX: "auto",
209
210
  margin: "0 0 8px 0"
210
- }), i = P("table", {
211
+ }), n = G("table", {
211
212
  borderCollapse: "collapse",
212
213
  width: "100%",
213
214
  fontSize: "13px"
214
- }), w = document.createElement("thead"), s = document.createElement("tr");
215
- for (const m of o(n[0])) s.appendChild(P("th", {
215
+ }), m = document.createElement("thead"), a = document.createElement("tr");
216
+ for (const p of t(r[0])) a.appendChild(G("th", {
216
217
  border: "1px solid #dee3e8",
217
218
  padding: "6px 10px",
218
219
  textAlign: "left",
219
220
  backgroundColor: "#f5f7fa",
220
221
  fontWeight: "600"
221
- }, ie(m)));
222
- w.appendChild(s), i.appendChild(w);
223
- const k = document.createElement("tbody");
224
- for (const m of n.slice(2)) {
225
- const v = document.createElement("tr");
226
- for (const f of o(m)) v.appendChild(P("td", {
222
+ }, ie(p)));
223
+ m.appendChild(a), n.appendChild(m);
224
+ const x = document.createElement("tbody");
225
+ for (const p of r.slice(2)) {
226
+ const w = document.createElement("tr");
227
+ for (const d of t(p)) w.appendChild(G("td", {
227
228
  border: "1px solid #dee3e8",
228
229
  padding: "6px 10px"
229
- }, ie(f)));
230
- k.appendChild(v);
230
+ }, ie(d)));
231
+ x.appendChild(w);
231
232
  }
232
- return i.appendChild(k), r.appendChild(i), r;
233
+ return n.appendChild(x), i.appendChild(n), i;
233
234
  }
234
- var Tn = (n) => !!n && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(n);
235
- function et(n) {
236
- const o = document.createDocumentFragment(), r = n.replace(/\r\n?/g, `
235
+ var Pn = (r) => !!r && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(r);
236
+ function rt(r) {
237
+ const t = document.createDocumentFragment(), i = r.replace(/\r\n?/g, `
237
238
  `).split(`
238
239
  `);
239
- let i = 0;
240
- for (; i < r.length; ) {
241
- const s = r[i];
242
- if (s.trim() === "") {
243
- i++;
240
+ let n = 0;
241
+ for (; n < i.length; ) {
242
+ const a = i[n];
243
+ if (a.trim() === "") {
244
+ n++;
244
245
  continue;
245
246
  }
246
- const k = s.match(Ft);
247
- if (k) {
248
- const f = k[1][0], c = [];
249
- for (i++; i < r.length && !new RegExp(`^ {0,3}${f === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(r[i]); )
250
- c.push(r[i]), i++;
251
- i++;
252
- const A = P("pre", { margin: "0 0 8px 0" });
253
- A.appendChild(P("code", {
247
+ const x = a.match(Vt);
248
+ if (x) {
249
+ const d = x[1][0], u = [];
250
+ for (n++; n < i.length && !new RegExp(`^ {0,3}${d === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(i[n]); )
251
+ u.push(i[n]), n++;
252
+ n++;
253
+ const h = G("pre", { margin: "0 0 8px 0" });
254
+ h.appendChild(G("code", {
254
255
  display: "block",
255
256
  background: "#f5f5f5",
256
257
  padding: "8px 12px",
257
258
  borderRadius: "6px",
258
259
  fontSize: "13px",
259
260
  overflowX: "auto",
260
- fontFamily: Dt,
261
+ fontFamily: Ut,
261
262
  whiteSpace: "pre"
262
- }, ce(c.join(`
263
- `)))), o.appendChild(A);
263
+ }, ue(u.join(`
264
+ `)))), t.appendChild(h);
264
265
  continue;
265
266
  }
266
- if (Ht.test(s)) {
267
- o.appendChild(P("hr", {
267
+ if (Gt.test(a)) {
268
+ t.appendChild(G("hr", {
268
269
  border: "none",
269
270
  borderTop: "1px solid #dee3e8",
270
271
  margin: "12px 0"
271
- })), i++;
272
+ })), n++;
272
273
  continue;
273
274
  }
274
- const m = s.match(zt);
275
- if (m) {
276
- const f = m[1].length;
277
- o.appendChild(P(`h${f}`, {
275
+ const p = a.match(jt);
276
+ if (p) {
277
+ const d = p[1].length;
278
+ t.appendChild(G(`h${d}`, {
278
279
  margin: "16px 0 8px 0",
279
- fontSize: Ln[f - 1],
280
+ fontSize: Hn[d - 1],
280
281
  fontWeight: "600",
281
282
  lineHeight: "1.3"
282
- }, ie(m[2]))), i++;
283
+ }, ie(p[2]))), n++;
283
284
  continue;
284
285
  }
285
- if (Ne.test(s)) {
286
- const f = [];
287
- for (; i < r.length && Ne.test(r[i]); )
288
- f.push(r[i].replace(Ne, "")), i++;
289
- const c = P("blockquote", {
286
+ if (De.test(a)) {
287
+ const d = [];
288
+ for (; n < i.length && De.test(i[n]); )
289
+ d.push(i[n].replace(De, "")), n++;
290
+ const u = G("blockquote", {
290
291
  borderLeft: "4px solid #dee3e8",
291
292
  paddingLeft: "12px",
292
293
  margin: "0 0 8px 0",
293
294
  fontStyle: "italic",
294
295
  color: "#6b6d6f"
295
296
  });
296
- c.appendChild(et(f.join(`
297
- `))), o.appendChild(c);
297
+ u.appendChild(rt(d.join(`
298
+ `))), t.appendChild(u);
298
299
  continue;
299
300
  }
300
- if (s.includes("|") && Tn(r[i + 1])) {
301
- const f = [s, r[i + 1]];
302
- for (i += 2; i < r.length && r[i].includes("|") && r[i].trim(); )
303
- f.push(r[i]), i++;
304
- o.appendChild(Nn(f));
301
+ if (a.includes("|") && Pn(i[n + 1])) {
302
+ const d = [a, i[n + 1]];
303
+ for (n += 2; n < i.length && i[n].includes("|") && i[n].trim(); )
304
+ d.push(i[n]), n++;
305
+ t.appendChild(Wn(d));
305
306
  continue;
306
307
  }
307
- if (pe.test(s)) {
308
- const f = [], c = Ze(s);
309
- for (; i < r.length && r[i].trim() !== ""; )
310
- if (pe.test(r[i]) || Ze(r[i]) > c)
311
- f.push(r[i]), i++;
308
+ if (me.test(a)) {
309
+ const d = [], u = nt(a);
310
+ for (; n < i.length && i[n].trim() !== ""; )
311
+ if (me.test(i[n]) || nt(i[n]) > u)
312
+ d.push(i[n]), n++;
312
313
  else break;
313
- o.appendChild(Pt(f));
314
+ t.appendChild(qt(d));
314
315
  continue;
315
316
  }
316
- const v = [s];
317
- for (i++; i < r.length && !$n(r[i]); )
318
- v.push(r[i]), i++;
319
- o.appendChild(P("p", {
317
+ const w = [a];
318
+ for (n++; n < i.length && !Fn(i[n]); )
319
+ w.push(i[n]), n++;
320
+ t.appendChild(G("p", {
320
321
  margin: "0 0 8px 0",
321
322
  lineHeight: "1.6"
322
- }, v.map((f) => ie(f)).join("<br>")));
323
+ }, w.map((d) => ie(d)).join("<br>")));
324
+ }
325
+ const m = t.lastElementChild;
326
+ return m && (m.style.marginBottom = "0"), t;
327
+ }
328
+ var Dt = {
329
+ helpful: "Helpful",
330
+ notHelpful: "Not helpful",
331
+ whatWentWrong: "What went wrong?",
332
+ reasons: {
333
+ inaccurate: "Inaccurate",
334
+ incomplete: "Incomplete",
335
+ information_not_found: "Information not found",
336
+ technical_issue: "Technical issue"
337
+ },
338
+ commentPlaceholder: "Anything else? (optional)",
339
+ send: "Send",
340
+ thanks: "Thanks, this was reported."
341
+ };
342
+ function Un() {
343
+ return {
344
+ detailsOpen: !1,
345
+ reasons: /* @__PURE__ */ new Set(),
346
+ comment: "",
347
+ reported: !1
348
+ };
349
+ }
350
+ var Gn = {
351
+ display: "inline-flex",
352
+ alignItems: "center",
353
+ justifyContent: "center",
354
+ width: "44px",
355
+ height: "44px",
356
+ margin: "-8px",
357
+ padding: "0",
358
+ border: "none",
359
+ borderRadius: "8px",
360
+ background: "transparent",
361
+ color: he,
362
+ cursor: "pointer",
363
+ lineHeight: "1"
364
+ };
365
+ function jn(r) {
366
+ const { state: t, labels: i, askWhy: n, onRate: m, onReport: a } = r, x = b({
367
+ marginTop: "6px",
368
+ width: "100%",
369
+ maxWidth: "85%"
370
+ });
371
+ x.className = "ago-feedback";
372
+ const p = b({
373
+ display: "flex",
374
+ alignItems: "center",
375
+ gap: "2px"
376
+ });
377
+ p.className = "ago-feedback__actions";
378
+ const w = Ht("up", i.helpful, t.rating === "positive");
379
+ w.addEventListener("click", () => {
380
+ t.rating = "positive", t.detailsOpen = !1, h(), _(), m("positive");
381
+ });
382
+ const d = Ht("down", i.notHelpful, t.rating === "negative");
383
+ d.addEventListener("click", () => {
384
+ t.rating = "negative", m("negative"), n && !t.reported && (t.detailsOpen = !0), h(), _();
385
+ }), p.append(w, d), x.appendChild(p);
386
+ const u = b();
387
+ u.className = "ago-feedback__panel-slot", x.appendChild(u);
388
+ function h() {
389
+ ot(w, t.rating === "positive"), ot(d, t.rating === "negative");
390
+ }
391
+ function _() {
392
+ if (u.replaceChildren(), t.reported) {
393
+ u.appendChild(Kn(i.thanks));
394
+ return;
395
+ }
396
+ t.detailsOpen && u.appendChild(qn(t, i, async (I) => await a(t.rating ?? "negative", I) ? (t.reported = !0, t.detailsOpen = !1, _(), !0) : !1));
397
+ }
398
+ return h(), _(), x;
399
+ }
400
+ function Ht(r, t, i) {
401
+ const n = document.createElement("button");
402
+ return n.type = "button", n.className = `ago-feedback__thumb ago-feedback__thumb--${r}`, n.setAttribute("aria-label", t), n.title = t, E(n, Gn), n.appendChild(Vn(r)), ot(n, i), n.addEventListener("mouseenter", () => {
403
+ n.getAttribute("aria-pressed") !== "true" && (n.style.color = F);
404
+ }), n.addEventListener("mouseleave", () => {
405
+ n.getAttribute("aria-pressed") !== "true" && (n.style.color = he);
406
+ }), n;
407
+ }
408
+ function ot(r, t) {
409
+ r.setAttribute("aria-pressed", t ? "true" : "false"), r.style.color = t ? fe : he;
410
+ }
411
+ function Vn(r) {
412
+ const t = "http://www.w3.org/2000/svg", i = document.createElementNS(t, "svg");
413
+ i.setAttribute("width", "16"), i.setAttribute("height", "16"), i.setAttribute("viewBox", "0 0 24 24"), i.setAttribute("fill", "none"), i.setAttribute("aria-hidden", "true");
414
+ const n = document.createElementNS(t, "path");
415
+ n.setAttribute("d", "M7 22h9.3a2 2 0 0 0 2-1.7l1.4-9A2 2 0 0 0 17.7 9H14V5a3 3 0 0 0-3-3l-4 10z"), n.setAttribute("stroke", "currentColor"), n.setAttribute("stroke-width", "1.8"), n.setAttribute("stroke-linejoin", "round");
416
+ const m = document.createElementNS(t, "path");
417
+ return m.setAttribute("d", "M7 22V12H4.5A1.5 1.5 0 0 0 3 13.5v7A1.5 1.5 0 0 0 4.5 22z"), m.setAttribute("stroke", "currentColor"), m.setAttribute("stroke-width", "1.8"), m.setAttribute("stroke-linejoin", "round"), i.append(n, m), r === "down" && (i.style.transform = "rotate(180deg)"), i;
418
+ }
419
+ function qn(r, t, i) {
420
+ const n = b({
421
+ marginTop: "8px",
422
+ padding: "12px",
423
+ border: `1px solid ${R}`,
424
+ borderRadius: He,
425
+ backgroundColor: Q
426
+ });
427
+ n.className = "ago-feedback__panel", n.setAttribute("role", "group"), n.setAttribute("aria-label", t.whatWentWrong);
428
+ const m = b({
429
+ fontSize: "13px",
430
+ fontWeight: "500",
431
+ color: F,
432
+ marginBottom: "8px"
433
+ });
434
+ m.textContent = t.whatWentWrong, n.appendChild(m);
435
+ const a = b({
436
+ display: "flex",
437
+ flexWrap: "wrap",
438
+ gap: "6px",
439
+ marginBottom: "8px"
440
+ });
441
+ a.className = "ago-feedback__reasons";
442
+ for (const d of _n) {
443
+ const u = document.createElement("button");
444
+ u.type = "button", u.className = "ago-feedback__reason", u.textContent = t.reasons[d], E(u, {
445
+ minHeight: "44px",
446
+ padding: "4px 12px",
447
+ fontSize: "13px",
448
+ fontFamily: "inherit",
449
+ borderRadius: "999px",
450
+ border: `1px solid ${R}`,
451
+ backgroundColor: "transparent",
452
+ color: F,
453
+ cursor: "pointer"
454
+ });
455
+ const h = () => {
456
+ const _ = r.reasons.has(d);
457
+ u.setAttribute("aria-pressed", _ ? "true" : "false"), u.style.borderColor = _ ? fe : R, u.style.color = _ ? fe : F;
458
+ };
459
+ u.addEventListener("click", () => {
460
+ r.reasons.has(d) ? r.reasons.delete(d) : r.reasons.add(d), h(), w();
461
+ }), h(), a.appendChild(u);
462
+ }
463
+ n.appendChild(a);
464
+ const x = document.createElement("textarea");
465
+ x.className = "ago-feedback__comment", x.rows = 2, x.placeholder = t.commentPlaceholder, x.value = r.comment, x.setAttribute("aria-label", t.commentPlaceholder), E(x, {
466
+ width: "100%",
467
+ boxSizing: "border-box",
468
+ padding: "8px 10px",
469
+ fontSize: "14px",
470
+ fontFamily: "inherit",
471
+ color: F,
472
+ border: `1px solid ${R}`,
473
+ borderRadius: "10px",
474
+ backgroundColor: "transparent",
475
+ resize: "vertical"
476
+ }), x.addEventListener("input", () => {
477
+ r.comment = x.value, w();
478
+ }), n.appendChild(x);
479
+ const p = document.createElement("button");
480
+ return p.type = "button", p.className = "ago-feedback__send", p.textContent = t.send, E(p, {
481
+ marginTop: "8px",
482
+ minHeight: "44px",
483
+ padding: "6px 16px",
484
+ fontSize: "14px",
485
+ fontFamily: "inherit",
486
+ borderRadius: "10px",
487
+ border: "none",
488
+ backgroundColor: Ce,
489
+ color: Ee,
490
+ cursor: "pointer"
491
+ }), p.addEventListener("click", () => {
492
+ p.disabled || (p.disabled = !0, i({
493
+ reasons: [...r.reasons],
494
+ comment: r.comment.trim()
495
+ }).then((d) => {
496
+ d || w();
497
+ }));
498
+ }), n.appendChild(p), w(), n;
499
+ function w() {
500
+ const d = r.reasons.size > 0 || r.comment.trim().length > 0;
501
+ p.disabled = !d, p.style.opacity = d ? "1" : "0.5", p.style.cursor = d ? "pointer" : "default";
323
502
  }
324
- const w = o.lastElementChild;
325
- return w && (w.style.marginBottom = "0"), o;
326
503
  }
327
- function Tt(n, o) {
328
- const { isLast: r, isLastOfBlock: i, bubbleStyle: w, showAgentName: s, agentBubble: k, followUpEnabled: m, followUpHandler: v, isMobile: f } = o, c = n.role === "user", A = w === "imessage", z = g({
504
+ function Kn(r) {
505
+ const t = b({
506
+ marginTop: "6px",
507
+ fontSize: "13px",
508
+ color: he
509
+ });
510
+ return t.className = "ago-feedback__thanks", t.setAttribute("role", "status"), t.textContent = r, t;
511
+ }
512
+ function Ft(r, t) {
513
+ const { isLast: i, isLastOfBlock: n, bubbleStyle: m, showAgentName: a, agentBubble: x, followUpEnabled: p, followUpHandler: w, isMobile: d, feedbackRow: u } = t, h = r.role === "user", _ = m === "imessage", I = b({
329
514
  display: "flex",
330
515
  flexDirection: "column",
331
- alignItems: c ? "flex-end" : "flex-start",
332
- marginBottom: A && !i ? "2px" : "16px"
516
+ alignItems: h ? "flex-end" : "flex-start",
517
+ marginBottom: _ && !n ? "2px" : "16px"
333
518
  });
334
- if (z.className = `ago-message ago-message--${n.role}`, !c && s && n.agent) {
335
- const u = g({
519
+ if (I.className = `ago-message ago-message--${r.role}`, !h && a && r.agent) {
520
+ const v = b({
336
521
  fontSize: "13px",
337
522
  fontWeight: "500",
338
- color: te,
523
+ color: F,
339
524
  marginBottom: "6px",
340
525
  padding: "0 4px"
341
526
  });
342
- u.className = "ago-message__agent", u.textContent = n.agent.displayName || n.agent.name, z.appendChild(u);
527
+ v.className = "ago-message__agent", v.textContent = r.agent.displayName || r.agent.name, I.appendChild(v);
343
528
  }
344
- if (!c && n.sources && n.sources.length > 0) {
345
- const u = g({
529
+ if (!h && r.sources && r.sources.length > 0) {
530
+ const v = b({
346
531
  display: "grid",
347
532
  gridTemplateColumns: "1fr 1fr",
348
533
  gap: "6px",
@@ -350,28 +535,28 @@ function Tt(n, o) {
350
535
  width: "100%",
351
536
  maxWidth: "85%"
352
537
  });
353
- u.className = "ago-message__sources", n.sources.forEach((x, y) => {
354
- const d = x.url ? document.createElement("a") : document.createElement("div");
355
- x.url && d instanceof HTMLAnchorElement && (d.href = x.url, d.target = "_blank", d.rel = "noopener noreferrer"), E(d, {
538
+ v.className = "ago-message__sources", r.sources.forEach((S, c) => {
539
+ const g = S.url ? document.createElement("a") : document.createElement("div");
540
+ S.url && g instanceof HTMLAnchorElement && (g.href = S.url, g.target = "_blank", g.rel = "noopener noreferrer"), E(g, {
356
541
  display: "flex",
357
542
  alignItems: "center",
358
543
  gap: "8px",
359
544
  padding: "8px 10px",
360
- border: `1px solid ${T}`,
545
+ border: `1px solid ${R}`,
361
546
  borderRadius: "8px",
362
- backgroundColor: ne,
547
+ backgroundColor: Q,
363
548
  textDecoration: "none",
364
- color: te,
549
+ color: F,
365
550
  fontSize: "12px",
366
551
  overflow: "hidden"
367
552
  });
368
- const h = g({
553
+ const N = b({
369
554
  flexShrink: "0",
370
555
  width: "18px",
371
556
  height: "18px",
372
557
  borderRadius: "3px",
373
- border: `1px solid ${Je}`,
374
- color: Je,
558
+ border: `1px solid ${fe}`,
559
+ color: fe,
375
560
  fontSize: "11px",
376
561
  fontWeight: "500",
377
562
  display: "flex",
@@ -379,273 +564,273 @@ function Tt(n, o) {
379
564
  justifyContent: "center",
380
565
  backgroundColor: "#f0f4ff"
381
566
  });
382
- h.textContent = String(y + 1);
383
- const _ = g({
567
+ N.textContent = String(c + 1);
568
+ const P = b({
384
569
  overflow: "hidden",
385
570
  textOverflow: "ellipsis",
386
571
  whiteSpace: "nowrap"
387
572
  });
388
- _.textContent = x.title, _.title = x.title, d.append(h, _), u.appendChild(d);
389
- }), z.appendChild(u);
573
+ P.textContent = S.title, P.title = S.title, g.append(N, P), v.appendChild(g);
574
+ }), I.appendChild(v);
390
575
  }
391
- if (n.attachments && n.attachments.length > 0) {
392
- const u = g({
576
+ if (r.attachments && r.attachments.length > 0) {
577
+ const v = b({
393
578
  display: "flex",
394
579
  flexWrap: "wrap",
395
580
  gap: "6px",
396
581
  marginBottom: "6px",
397
- justifyContent: c ? "flex-end" : "flex-start",
582
+ justifyContent: h ? "flex-end" : "flex-start",
398
583
  maxWidth: "75%"
399
584
  });
400
- u.className = "ago-message__attachments";
401
- for (const x of n.attachments) {
402
- const y = bn(x.url);
403
- if (mn(x) && y) {
404
- const M = document.createElement("a");
405
- M.href = y, M.target = "_blank", M.rel = "noopener noreferrer", E(M, {
585
+ v.className = "ago-message__attachments";
586
+ for (const S of r.attachments) {
587
+ const c = En(S.url);
588
+ if (kn(S) && c) {
589
+ const T = document.createElement("a");
590
+ T.href = c, T.target = "_blank", T.rel = "noopener noreferrer", E(T, {
406
591
  display: "inline-block",
407
592
  textDecoration: "none"
408
593
  });
409
- const j = document.createElement("img");
410
- j.src = y, j.alt = x.name, j.loading = "lazy", E(j, {
594
+ const J = document.createElement("img");
595
+ J.src = c, J.alt = S.name, J.loading = "lazy", E(J, {
411
596
  maxWidth: "180px",
412
597
  maxHeight: "160px",
413
598
  objectFit: "cover",
414
599
  borderRadius: "10px",
415
- border: `1px solid ${T}`,
600
+ border: `1px solid ${R}`,
416
601
  display: "block"
417
- }), M.appendChild(j), u.appendChild(M);
602
+ }), T.appendChild(J), v.appendChild(T);
418
603
  continue;
419
604
  }
420
- const d = y ? document.createElement("a") : document.createElement("div");
421
- y && d instanceof HTMLAnchorElement && (d.href = y, d.target = "_blank", d.rel = "noopener noreferrer"), E(d, {
605
+ const g = c ? document.createElement("a") : document.createElement("div");
606
+ c && g instanceof HTMLAnchorElement && (g.href = c, g.target = "_blank", g.rel = "noopener noreferrer"), E(g, {
422
607
  display: "inline-flex",
423
608
  alignItems: "center",
424
609
  gap: "8px",
425
610
  padding: "8px 12px",
426
611
  borderRadius: "10px",
427
- border: `1px solid ${T}`,
428
- backgroundColor: c ? "rgba(255,255,255,0.12)" : ne,
429
- color: c ? Me : te,
612
+ border: `1px solid ${R}`,
613
+ backgroundColor: h ? "rgba(255,255,255,0.12)" : Q,
614
+ color: h ? Ee : F,
430
615
  fontSize: "13px",
431
616
  textDecoration: "none",
432
617
  maxWidth: "220px"
433
618
  });
434
- const h = document.createElement("span");
435
- h.textContent = "📄", h.setAttribute("aria-hidden", "true"), E(h, {
619
+ const N = document.createElement("span");
620
+ N.textContent = "📄", N.setAttribute("aria-hidden", "true"), E(N, {
436
621
  fontSize: "16px",
437
622
  lineHeight: "1",
438
623
  flexShrink: "0"
439
624
  });
440
- const _ = g({
625
+ const P = b({
441
626
  display: "flex",
442
627
  flexDirection: "column",
443
628
  minWidth: "0"
444
- }), K = g({
629
+ }), U = b({
445
630
  overflow: "hidden",
446
631
  textOverflow: "ellipsis",
447
632
  whiteSpace: "nowrap",
448
633
  maxWidth: "160px"
449
634
  });
450
- K.textContent = x.name, K.title = x.name, _.appendChild(K);
451
- const D = xn(x.fileSize);
452
- if (D) {
453
- const M = g({
635
+ U.textContent = S.name, U.title = S.name, P.appendChild(U);
636
+ const oe = An(S.fileSize);
637
+ if (oe) {
638
+ const T = b({
454
639
  fontSize: "11px",
455
- color: Bt
640
+ color: he
456
641
  });
457
- M.textContent = D, _.appendChild(M);
642
+ T.textContent = oe, P.appendChild(T);
458
643
  }
459
- d.append(h, _), u.appendChild(d);
644
+ g.append(N, P), v.appendChild(g);
460
645
  }
461
- z.appendChild(u);
646
+ I.appendChild(v);
462
647
  }
463
- const F = c || k || A, B = !!n.content || n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT", I = g({
464
- maxWidth: F ? A || c ? f ? "88%" : "75%" : f ? "92%" : "85%" : "100%",
465
- padding: F ? "10px 14px" : "2px 8px",
466
- borderRadius: A ? An : F ? Ye : "0",
467
- backgroundColor: c ? Te : F ? Lt : "transparent",
468
- color: c ? Me : te,
648
+ const L = h || x || _, W = !!r.content || r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT", D = b({
649
+ maxWidth: L ? _ || h ? d ? "88%" : "75%" : d ? "92%" : "85%" : "100%",
650
+ padding: L ? "10px 14px" : "2px 8px",
651
+ borderRadius: _ ? On : L ? He : "0",
652
+ backgroundColor: h ? Ce : L ? Bt : "transparent",
653
+ color: h ? Ee : F,
469
654
  overflowWrap: "break-word",
470
655
  textWrap: "pretty",
471
656
  fontSize: "16px",
472
657
  lineHeight: "1.6"
473
658
  });
474
- if (I.className = "ago-message__content", A && i) {
475
- I.style.position = "relative";
476
- const u = g({
659
+ if (D.className = "ago-message__content", _ && n) {
660
+ D.style.position = "relative";
661
+ const v = b({
477
662
  position: "absolute",
478
663
  zIndex: "0",
479
664
  bottom: "-2px",
480
665
  width: "20px",
481
666
  height: "20px",
482
- background: c ? Te : Lt
667
+ background: h ? Ce : Bt
483
668
  });
484
- u.className = "ago-message__tail";
485
- const x = g({
669
+ v.className = "ago-message__tail";
670
+ const S = b({
486
671
  position: "absolute",
487
672
  zIndex: "1",
488
673
  bottom: "-2px",
489
674
  width: "10px",
490
675
  height: "20px",
491
- background: Ot
676
+ background: Pt
492
677
  });
493
- x.className = "ago-message__tail-mask", c ? (u.style.right = "-8px", u.style.borderBottomLeftRadius = "16px 14px", x.style.right = "-10px", x.style.borderBottomLeftRadius = "10px") : (u.style.left = "-7px", u.style.borderBottomRightRadius = "16px 14px", x.style.left = "-10px", x.style.borderBottomRightRadius = "10px"), I.append(u, x);
678
+ S.className = "ago-message__tail-mask", h ? (v.style.right = "-8px", v.style.borderBottomLeftRadius = "16px 14px", S.style.right = "-10px", S.style.borderBottomLeftRadius = "10px") : (v.style.left = "-7px", v.style.borderBottomRightRadius = "16px 14px", S.style.left = "-10px", S.style.borderBottomRightRadius = "10px"), D.append(v, S);
494
679
  }
495
- if (n.content ? I.appendChild(et(n.content)) : (n.status === "IN_PROGRESS" || n.status === "WAITING_CLIENT") && I.appendChild(On()), B && z.appendChild(I), r && n.followUpReplies && n.followUpReplies.length > 0) {
496
- const u = g({
680
+ if (r.content ? D.appendChild(rt(r.content)) : (r.status === "IN_PROGRESS" || r.status === "WAITING_CLIENT") && D.appendChild(Qn()), W && I.appendChild(D), !h && u && I.appendChild(u), i && r.followUpReplies && r.followUpReplies.length > 0) {
681
+ const v = b({
497
682
  display: "flex",
498
683
  flexWrap: "wrap",
499
684
  gap: "8px",
500
685
  marginTop: "10px"
501
686
  });
502
- u.className = "ago-message__followups";
503
- for (const x of n.followUpReplies) {
504
- const y = document.createElement("button");
505
- y.type = "button", y.className = "ago-message__followup-btn", y.textContent = x, y.disabled = !m, E(y, {
687
+ v.className = "ago-message__followups";
688
+ for (const S of r.followUpReplies) {
689
+ const c = document.createElement("button");
690
+ c.type = "button", c.className = "ago-message__followup-btn", c.textContent = S, c.disabled = !p, E(c, {
506
691
  minHeight: "44px",
507
692
  padding: "6px 14px",
508
693
  fontSize: "14px",
509
- borderRadius: Ye,
510
- border: `1px solid ${T}`,
511
- backgroundColor: ne,
512
- color: te,
513
- cursor: m ? "pointer" : "default",
694
+ borderRadius: He,
695
+ border: `1px solid ${R}`,
696
+ backgroundColor: Q,
697
+ color: F,
698
+ cursor: p ? "pointer" : "default",
514
699
  transition: "border-color 0.15s"
515
- }), v && y.addEventListener("click", () => v(x)), y.addEventListener("mouseenter", () => {
516
- y.style.borderColor = Je;
517
- }), y.addEventListener("mouseleave", () => {
518
- y.style.borderColor = T;
519
- }), u.appendChild(y);
700
+ }), w && c.addEventListener("click", () => w(S)), c.addEventListener("mouseenter", () => {
701
+ c.style.borderColor = fe;
702
+ }), c.addEventListener("mouseleave", () => {
703
+ c.style.borderColor = R;
704
+ }), v.appendChild(c);
520
705
  }
521
- z.appendChild(u);
706
+ I.appendChild(v);
522
707
  }
523
- return z;
708
+ return I;
524
709
  }
525
- function Mn(n) {
526
- const o = g({
710
+ function Xn(r) {
711
+ const t = b({
527
712
  display: "flex",
528
713
  alignItems: "center",
529
714
  gap: "8px",
530
715
  padding: "10px 14px",
531
716
  backgroundColor: "#f0fdf4",
532
717
  color: "#15803d",
533
- borderRadius: Ye,
718
+ borderRadius: He,
534
719
  marginTop: "8px",
535
720
  fontSize: "13px",
536
721
  border: "1px solid #bbf7d0"
537
722
  });
538
- o.className = "ago-form-notice", o.setAttribute("role", "status");
539
- const r = document.createElement("span");
540
- r.textContent = "✓", r.setAttribute("aria-hidden", "true"), E(r, { fontWeight: "700" });
723
+ t.className = "ago-form-notice", t.setAttribute("role", "status");
541
724
  const i = document.createElement("span");
542
- return i.textContent = n, o.append(r, i), o;
725
+ i.textContent = "✓", i.setAttribute("aria-hidden", "true"), E(i, { fontWeight: "700" });
726
+ const n = document.createElement("span");
727
+ return n.textContent = r, t.append(i, n), t;
543
728
  }
544
- function On() {
545
- const n = g({
729
+ function Qn() {
730
+ const r = b({
546
731
  display: "flex",
547
732
  gap: "4px",
548
733
  padding: "4px 0"
549
734
  });
550
- for (let o = 0; o < 3; o++) {
551
- const r = g({
735
+ for (let t = 0; t < 3; t++) {
736
+ const i = b({
552
737
  width: "6px",
553
738
  height: "6px",
554
739
  borderRadius: "50%",
555
740
  backgroundColor: "currentColor",
556
741
  opacity: "0.55",
557
742
  animation: "ago-pulse 1.2s ease-in-out infinite",
558
- animationDelay: `${o * 0.2}s`
743
+ animationDelay: `${t * 0.2}s`
559
744
  });
560
- n.appendChild(r);
745
+ r.appendChild(i);
561
746
  }
562
- return n;
747
+ return r;
563
748
  }
564
- function Bn() {
565
- const n = "http://www.w3.org/2000/svg", o = document.createElementNS(n, "svg");
566
- o.setAttribute("width", "26"), o.setAttribute("height", "26"), o.setAttribute("viewBox", "0 0 24 24"), o.setAttribute("fill", "none");
567
- const r = document.createElementNS(n, "path");
568
- return r.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"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), o.appendChild(r), o;
749
+ function Jn() {
750
+ const r = "http://www.w3.org/2000/svg", t = document.createElementNS(r, "svg");
751
+ t.setAttribute("width", "26"), t.setAttribute("height", "26"), t.setAttribute("viewBox", "0 0 24 24"), t.setAttribute("fill", "none");
752
+ const i = document.createElementNS(r, "path");
753
+ return i.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"), i.setAttribute("stroke", "currentColor"), i.setAttribute("stroke-width", "2"), i.setAttribute("stroke-linecap", "round"), i.setAttribute("stroke-linejoin", "round"), t.appendChild(i), t;
569
754
  }
570
- var Mt = "Form submitted.";
571
- function Dn(n) {
572
- if (typeof n == "string") return n || null;
573
- if (!n || typeof n != "object") return null;
574
- const o = n;
575
- if (typeof o.message == "string" && o.message) return o.message;
576
- const r = o.result;
577
- if (typeof r == "string" && r) return r;
578
- if (r && typeof r == "object") {
579
- const i = r.message;
580
- if (typeof i == "string" && i) return i;
755
+ var Wt = "Form submitted.";
756
+ function Yn(r) {
757
+ if (typeof r == "string") return r || null;
758
+ if (!r || typeof r != "object") return null;
759
+ const t = r;
760
+ if (typeof t.message == "string" && t.message) return t.message;
761
+ const i = t.result;
762
+ if (typeof i == "string" && i) return i;
763
+ if (i && typeof i == "object") {
764
+ const n = i.message;
765
+ if (typeof n == "string" && n) return n;
581
766
  }
582
767
  return null;
583
768
  }
584
- var Hn = 0;
585
- function zn(n) {
586
- const o = typeof n == "string" ? document.querySelector(n) : n;
587
- if (!o) throw new Error(`mountChatWidget: target "${String(n)}" not found.`);
588
- return o;
769
+ var Zn = 0;
770
+ function eo(r) {
771
+ const t = typeof r == "string" ? document.querySelector(r) : r;
772
+ if (!t) throw new Error(`mountChatWidget: target "${String(r)}" not found.`);
773
+ return t;
589
774
  }
590
- function qn(n, o) {
591
- const { title: r = "Chat", welcomeMessage: i = "Hello! How can I help you today?", placeholder: w = "Type a message...", allowFiles: s = !1, allowStop: k = !0, height: m = 500, placement: v = "inline", width: f = 400, defaultOpen: c = !1, logoUrl: A, showAgentName: z = !1, agentBubble: F = !1, bubbleStyle: B = "default", showHeader: I = !0, theme: u, loadThreads: x = !1, forms: y, formSubmittedMessage: d = Mt, onFollowUpClick: h, onMessageSent: _, onMessageReceived: K, onFormSubmitted: D, onFormError: M, onOpen: j, onClose: tt } = o, re = typeof i == "string" ? {
592
- message: i,
775
+ function co(r, t) {
776
+ const { title: i = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: m = "Type a message...", allowFiles: a = !1, allowStop: x = !0, height: p = 500, placement: w = "inline", width: d = 400, defaultOpen: u = !1, logoUrl: h, showAgentName: _ = !1, agentBubble: I = !1, bubbleStyle: L = "default", showHeader: W = !0, theme: D, loadThreads: v = !1, forms: S, formSubmittedMessage: c = Wt, feedback: g = !1, onFollowUpClick: N, onMessageSent: P, onMessageReceived: U, onFormSubmitted: oe, onFormError: T, onOpen: J, onClose: it } = t, ae = typeof n == "string" ? {
777
+ message: n,
593
778
  mode: "static"
594
- } : i, nt = re.message, ot = re.mode ?? "static", Wt = "speed" in re && re.speed || 45, it = "followUpReplies" in re && re.followUpReplies || void 0;
595
- if (!o.client && !o.config?.baseUrl) throw new hn("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
596
- const C = o.client ?? new yn(o.config), rt = zn(n), L = v === "left" || v === "right", Ut = L && (o.launcher ?? !0);
597
- let oe = L ? c : !0, Oe = !1;
598
- const Gt = o.mobile?.breakpoint ?? 768, Be = o.mobile?.trigger ?? "tap", st = typeof window < "u" && !!window.matchMedia, O = st ? window.matchMedia(`(max-width: ${Gt}px), (max-height: 500px) and (orientation: landscape)`) : void 0, jt = st ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Vt = !!O, fe = !L && !!O, ue = /* @__PURE__ */ Symbol("ago-scroll-lock");
779
+ } : n, at = ae.message, st = ae.mode ?? "static", Kt = "speed" in ae && ae.speed || 45, lt = "followUpReplies" in ae && ae.followUpReplies || void 0;
780
+ if (!t.client && !t.config?.baseUrl) throw new Rn("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
781
+ const k = t.client ?? new Sn(t.config), dt = eo(r), $ = w === "left" || w === "right", Xt = $ && (t.launcher ?? !0);
782
+ let re = $ ? u : !0, Fe = !1;
783
+ const Qt = t.mobile?.breakpoint ?? 768, We = t.mobile?.trigger ?? "tap", ct = typeof window < "u" && !!window.matchMedia, z = ct ? window.matchMedia(`(max-width: ${Qt}px), (max-height: 500px) and (orientation: landscape)`) : void 0, Jt = ct ? window.matchMedia("(prefers-reduced-motion: reduce)") : void 0, Yt = !!z, ge = !$ && !!z, be = /* @__PURE__ */ Symbol("ago-scroll-lock");
599
784
  let se = !1;
600
- const De = o.persistConversation, be = De ? wn(De === !0 ? {} : De) : void 0;
601
- let V = o.conversationId ?? be?.getLastActiveThread() ?? void 0, p = [], ye = [], q = !1, ae = null, Q;
602
- const He = [];
603
- function qt(e) {
604
- if (typeof d == "function") {
605
- const l = d(e);
606
- if (typeof l == "string" && l) return l;
785
+ const Pe = t.persistConversation, Se = Pe ? In(Pe === !0 ? {} : Pe) : void 0;
786
+ let q = t.conversationId ?? Se?.getLastActiveThread() ?? void 0, f = [], ke = [], K = !1, le = null, Y;
787
+ const Ue = [];
788
+ function Zt(e) {
789
+ if (typeof c == "function") {
790
+ const s = c(e);
791
+ if (typeof s == "string" && s) return s;
607
792
  }
608
- const t = Dn(e);
609
- return t || (typeof d == "string" ? d : Mt);
793
+ const o = Yn(e);
794
+ return o || (typeof c == "string" ? c : Wt);
610
795
  }
611
- const we = [], a = g({
796
+ const Ae = [], l = b({
612
797
  display: "flex",
613
798
  flexDirection: "column",
614
- height: L ? "100%" : typeof m == "number" ? `${m}px` : m,
615
- border: `1px solid ${T}`,
616
- borderRadius: En,
799
+ height: $ ? "100%" : typeof p == "number" ? `${p}px` : p,
800
+ border: `1px solid ${R}`,
801
+ borderRadius: Tn,
617
802
  overflow: "hidden",
618
- backgroundColor: ne,
619
- fontFamily: $e,
803
+ backgroundColor: Q,
804
+ fontFamily: ze,
620
805
  textAlign: "left",
621
806
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
622
807
  });
623
- a.className = "ago-chat-widget", Rn(a, u);
624
- let W;
625
- if (I) {
626
- if (W = g({
808
+ l.className = "ago-chat-widget", Bn(l, D);
809
+ let j;
810
+ if (W) {
811
+ if (j = b({
627
812
  padding: "14px 16px",
628
- borderBottom: `1px solid ${T}`,
629
- backgroundColor: Sn,
630
- color: $t,
813
+ borderBottom: `1px solid ${R}`,
814
+ backgroundColor: $n,
815
+ color: Mt,
631
816
  display: "flex",
632
817
  alignItems: "center",
633
818
  gap: "10px"
634
- }), W.className = "ago-chat-widget__header", A) {
635
- const t = document.createElement("img");
636
- t.src = A, t.alt = "Logo", E(t, {
819
+ }), j.className = "ago-chat-widget__header", h) {
820
+ const o = document.createElement("img");
821
+ o.src = h, o.alt = "Logo", E(o, {
637
822
  height: "24px",
638
823
  width: "auto"
639
- }), W.appendChild(t);
824
+ }), j.appendChild(o);
640
825
  }
641
826
  const e = document.createElement("h3");
642
- if (e.textContent = r, E(e, {
827
+ if (e.textContent = i, E(e, {
643
828
  margin: "0",
644
829
  fontSize: "15px",
645
830
  fontWeight: "600"
646
- }), W.appendChild(e), L) {
647
- const t = document.createElement("button");
648
- t.type = "button", t.className = "ago-chat-widget__close", t.setAttribute("aria-label", "Close"), t.textContent = "×", E(t, {
831
+ }), j.appendChild(e), $) {
832
+ const o = document.createElement("button");
833
+ o.type = "button", o.className = "ago-chat-widget__close", o.setAttribute("aria-label", "Close"), o.textContent = "×", E(o, {
649
834
  marginLeft: "auto",
650
835
  flexShrink: "0",
651
836
  display: "flex",
@@ -656,40 +841,40 @@ function qn(n, o) {
656
841
  margin: "-10px -10px -10px auto",
657
842
  background: "transparent",
658
843
  border: "none",
659
- color: $t,
844
+ color: Mt,
660
845
  fontSize: "22px",
661
846
  lineHeight: "1",
662
847
  cursor: "pointer",
663
848
  padding: "0"
664
- }), t.addEventListener("click", () => Ie()), W.appendChild(t);
849
+ }), o.addEventListener("click", () => Oe()), j.appendChild(o);
665
850
  }
666
851
  }
667
- const S = g({
852
+ const A = b({
668
853
  flex: "1",
669
854
  overflow: "auto",
670
855
  overscrollBehavior: "contain",
671
856
  padding: "16px",
672
- backgroundColor: Ot
857
+ backgroundColor: Pt
673
858
  });
674
- S.className = "ago-chat-widget__messages", S.setAttribute("role", "log"), S.setAttribute("aria-live", "polite"), S.setAttribute("aria-relevant", "additions text"), S.setAttribute("aria-atomic", "false");
675
- const Xt = 48;
676
- let le = !0, ze = 0;
677
- function ve(e) {
678
- ze++;
859
+ A.className = "ago-chat-widget__messages", A.setAttribute("role", "log"), A.setAttribute("aria-live", "polite"), A.setAttribute("aria-relevant", "additions text"), A.setAttribute("aria-atomic", "false");
860
+ const en = 48;
861
+ let de = !0, Ge = 0;
862
+ function _e(e) {
863
+ Ge++;
679
864
  try {
680
865
  e();
681
866
  } finally {
682
- const t = () => {
683
- ze--;
867
+ const o = () => {
868
+ Ge--;
684
869
  };
685
- typeof queueMicrotask == "function" ? queueMicrotask(t) : t();
870
+ typeof queueMicrotask == "function" ? queueMicrotask(o) : o();
686
871
  }
687
872
  }
688
- function Kt() {
689
- return S.scrollHeight - S.scrollTop - S.clientHeight <= Xt;
873
+ function tn() {
874
+ return A.scrollHeight - A.scrollTop - A.clientHeight <= en;
690
875
  }
691
- const J = document.createElement("button");
692
- J.type = "button", J.className = "ago-chat-widget__jump", J.setAttribute("aria-label", "Jump to latest message"), J.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>', E(J, {
876
+ const Z = document.createElement("button");
877
+ Z.type = "button", Z.className = "ago-chat-widget__jump", Z.setAttribute("aria-label", "Jump to latest message"), Z.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>', E(Z, {
693
878
  position: "absolute",
694
879
  left: "50%",
695
880
  bottom: "12px",
@@ -699,162 +884,196 @@ function qn(n, o) {
699
884
  display: "none",
700
885
  alignItems: "center",
701
886
  justifyContent: "center",
702
- border: `1px solid ${T}`,
887
+ border: `1px solid ${R}`,
703
888
  borderRadius: "50%",
704
- backgroundColor: ne,
705
- color: te,
889
+ backgroundColor: Q,
890
+ color: F,
706
891
  boxShadow: "rgba(15, 15, 15, 0.16) 0px 2px 10px 0px",
707
892
  cursor: "pointer",
708
893
  zIndex: "2"
709
- }), J.addEventListener("click", () => {
710
- le = !0, ve(() => {
711
- S.scrollTop = S.scrollHeight;
712
- }), Fe();
894
+ }), Z.addEventListener("click", () => {
895
+ de = !0, _e(() => {
896
+ A.scrollTop = A.scrollHeight;
897
+ }), je();
713
898
  });
714
- function Fe() {
715
- J.style.display = le ? "none" : "flex";
899
+ function je() {
900
+ Z.style.display = de ? "none" : "flex";
716
901
  }
717
- function Pe() {
718
- le && ve(() => {
719
- S.scrollTop = S.scrollHeight;
720
- }), Fe();
902
+ function Ve() {
903
+ de && _e(() => {
904
+ A.scrollTop = A.scrollHeight;
905
+ }), je();
721
906
  }
722
- S.addEventListener("scroll", () => {
723
- ze > 0 || (le = Kt(), Fe());
907
+ A.addEventListener("scroll", () => {
908
+ Ge > 0 || (de = tn(), je());
724
909
  });
725
- const at = g({
910
+ const pt = b({
726
911
  position: "relative",
727
912
  flex: "1",
728
913
  display: "flex",
729
914
  minHeight: "0"
730
915
  });
731
- at.append(S, J);
732
- const { inputRow: We, setDisabled: Qt, focus: Ce, restoreDraft: Jt } = In({
733
- placeholder: w,
734
- allowFiles: s,
735
- onSend: (e, t) => {
736
- Re(e, t);
916
+ pt.append(A, Z);
917
+ const { inputRow: qe, setDisabled: nn, focus: Re, restoreDraft: on } = zn({
918
+ placeholder: m,
919
+ allowFiles: a,
920
+ onSend: (e, o) => {
921
+ Te(e, o);
737
922
  },
738
- onStop: k ? () => {
739
- vt();
923
+ onStop: x ? () => {
924
+ At();
740
925
  } : void 0
741
926
  });
742
- kn(), a.append(...W ? [W] : [], at, We);
743
- let Ee = a, $, H;
744
- const Se = v === "left" ? "left" : "right";
745
- if (L && ($ = g({
927
+ Mn(), l.append(...j ? [j] : [], pt, qe);
928
+ let Ie = l, O, H;
929
+ const Ne = w === "left" ? "left" : "right";
930
+ if ($ && (O = b({
746
931
  position: "fixed",
747
932
  top: "0",
748
933
  bottom: "0",
749
- [Se]: "0",
750
- width: typeof f == "number" ? `${f}px` : f,
934
+ [Ne]: "0",
935
+ width: typeof d == "number" ? `${d}px` : d,
751
936
  maxWidth: "100vw",
752
937
  display: "flex",
753
938
  zIndex: "2147483000",
754
939
  transition: "transform 0.3s ease",
755
940
  boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
756
- }), $.className = "ago-chat-widget-panel", E(a, {
941
+ }), O.className = "ago-chat-widget-panel", E(l, {
757
942
  height: "100%",
758
943
  width: "100%",
759
944
  borderRadius: "0",
760
945
  border: "none",
761
946
  boxShadow: "none",
762
- [Se === "left" ? "borderRight" : "borderLeft"]: `1px solid ${T}`
763
- }), $.appendChild(a), Ee = $), Ut) {
764
- if (H = document.createElement("button"), H.type = "button", H.className = "ago-chat-widget-launcher", H.setAttribute("aria-label", `Open ${r}`), E(H, {
947
+ [Ne === "left" ? "borderRight" : "borderLeft"]: `1px solid ${R}`
948
+ }), O.appendChild(l), Ie = O), Xt) {
949
+ if (H = document.createElement("button"), H.type = "button", H.className = "ago-chat-widget-launcher", H.setAttribute("aria-label", `Open ${i}`), E(H, {
765
950
  position: "fixed",
766
951
  bottom: "20px",
767
- [Se]: "20px",
952
+ [Ne]: "20px",
768
953
  width: "56px",
769
954
  height: "56px",
770
955
  borderRadius: "50%",
771
956
  border: "none",
772
- backgroundColor: Te,
773
- color: Me,
957
+ backgroundColor: Ce,
958
+ color: Ee,
774
959
  cursor: "pointer",
775
960
  display: "flex",
776
961
  alignItems: "center",
777
962
  justifyContent: "center",
778
963
  zIndex: "2147483000",
779
964
  boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
780
- fontFamily: $e
781
- }), A) {
965
+ fontFamily: ze
966
+ }), h) {
782
967
  const e = document.createElement("img");
783
- e.src = A, e.alt = "", E(e, {
968
+ e.src = h, e.alt = "", E(e, {
784
969
  width: "26px",
785
970
  height: "26px",
786
971
  objectFit: "contain"
787
972
  }), H.appendChild(e);
788
- } else H.appendChild(Bn());
789
- H.addEventListener("click", () => je());
973
+ } else H.appendChild(Jn());
974
+ H.addEventListener("click", () => Qe());
790
975
  }
791
- const me = fe ? `ago-vt-${++Hn}` : "", lt = 52;
792
- let X = !1, Y = 0, de = 0, U, he, Z;
793
- const Ae = {
794
- height: a.style.height,
795
- border: a.style.border,
796
- borderRadius: a.style.borderRadius,
797
- boxShadow: a.style.boxShadow
976
+ const xe = ge ? `ago-vt-${++Zn}` : "", ut = 52;
977
+ let X = !1, ee = 0, ce = 0, V, we, te;
978
+ const Le = {
979
+ height: l.style.height,
980
+ border: l.style.border,
981
+ borderRadius: l.style.borderRadius,
982
+ boxShadow: l.style.boxShadow
798
983
  };
799
- rt.appendChild(Ee), H && rt.appendChild(H), ke(), fe && (U = pn(), a.insertBefore(U, a.firstChild), he = document.createElement("style"), he.id = me, he.textContent = `::view-transition-group(${me}),::view-transition-group(${me}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(he), (Be === "focus" || Be === "tap") && (a.addEventListener("pointerdown", (e) => {
800
- if (X || !O?.matches) return;
801
- const t = We.contains(e.target);
802
- if (Be === "tap") {
984
+ dt.appendChild(Ie), H && dt.appendChild(H), $e(), ge && (V = wn(), l.insertBefore(V, l.firstChild), we = document.createElement("style"), we.id = xe, we.textContent = `::view-transition-group(${xe}),::view-transition-group(${xe}-bar){animation-duration:0.3s;animation-timing-function:cubic-bezier(0.4,0,0.2,1)}`, document.head.appendChild(we), (We === "focus" || We === "tap") && (l.addEventListener("pointerdown", (e) => {
985
+ if (X || !z?.matches) return;
986
+ const o = qe.contains(e.target);
987
+ if (We === "tap") {
803
988
  if ((e.target instanceof Element ? e.target : null)?.closest("button,a[href],[role='button']")) return;
804
- } else if (!t) return;
805
- t && e.preventDefault(), ge();
806
- }, !0), a.addEventListener("focusin", (e) => {
807
- O?.matches && We.contains(e.target) && ge();
808
- }))), Vt && document.addEventListener("keydown", Et), O && O.addEventListener("change", St);
809
- const Yt = h !== !1, Zt = h === !1 ? void 0 : h ?? ((e) => {
810
- fe && O?.matches && !X ? ge().then(() => Re(e)) : Re(e);
811
- });
812
- function dt(e) {
813
- const t = p.length - 1;
989
+ } else if (!o) return;
990
+ o && e.preventDefault(), ye();
991
+ }, !0), l.addEventListener("focusin", (e) => {
992
+ z?.matches && qe.contains(e.target) && ye();
993
+ }))), Yt && document.addEventListener("keydown", Rt), z && z.addEventListener("change", It);
994
+ const rn = N !== !1, an = N === !1 ? void 0 : N ?? ((e) => {
995
+ ge && z?.matches && !X ? ye().then(() => Te(e)) : Te(e);
996
+ }), pe = g === !0 ? {} : g || null, sn = {
997
+ ...Dt,
998
+ ...pe?.labels,
999
+ reasons: {
1000
+ ...Dt.reasons,
1001
+ ...pe?.labels?.reasons
1002
+ }
1003
+ }, ft = /* @__PURE__ */ new Map();
1004
+ function ln(e) {
1005
+ if (!pe || !e.id || !e.conversationId || e.status !== "DONE" || !e.content) return null;
1006
+ let o = ft.get(e.id);
1007
+ o || (o = Un(), ft.set(e.id, o));
1008
+ const s = async (C, y) => {
1009
+ try {
1010
+ return await k.submitFeedback(e.id, C, y), pe.onSubmit?.({
1011
+ messageId: e.id,
1012
+ rating: C,
1013
+ reasons: y?.reasons ?? [],
1014
+ comment: y?.comment || void 0
1015
+ }), !0;
1016
+ } catch (M) {
1017
+ return pe.onError?.(M instanceof Error ? M : new Error(String(M))), !1;
1018
+ }
1019
+ };
1020
+ return jn({
1021
+ state: o,
1022
+ labels: sn,
1023
+ askWhy: pe.askWhy ?? !0,
1024
+ onRate: (C) => {
1025
+ s(C);
1026
+ },
1027
+ onReport: (C, y) => s(C, y)
1028
+ });
1029
+ }
1030
+ function mt(e) {
1031
+ const o = f.length - 1;
814
1032
  return {
815
- isLast: e === t,
816
- isLastOfBlock: e === t || p[e + 1].role !== p[e].role,
817
- bubbleStyle: B,
818
- showAgentName: z,
819
- agentBubble: F,
820
- followUpEnabled: Yt,
821
- followUpHandler: Zt,
822
- isMobile: !!O?.matches
1033
+ isLast: e === o,
1034
+ isLastOfBlock: e === o || f[e + 1].role !== f[e].role,
1035
+ bubbleStyle: L,
1036
+ showAgentName: _,
1037
+ agentBubble: I,
1038
+ followUpEnabled: rn,
1039
+ followUpHandler: an,
1040
+ isMobile: !!z?.matches,
1041
+ feedbackRow: ln(f[e])
823
1042
  };
824
1043
  }
825
- function en() {
826
- if (ae || He.length > 0) return !1;
827
- const e = p.length - 1, t = p[e];
828
- if (!t || t.role !== "assistant") return !1;
829
- const l = ye[e];
830
- if (!l || l.parentNode !== S) return !1;
831
- const R = Tt(t, dt(e));
832
- return ve(() => S.replaceChild(R, l)), ye[e] = R, Pe(), !0;
1044
+ function dn() {
1045
+ if (le || Ue.length > 0) return !1;
1046
+ const e = f.length - 1, o = f[e];
1047
+ if (!o || o.role !== "assistant") return !1;
1048
+ const s = ke[e];
1049
+ if (!s || s.parentNode !== A) return !1;
1050
+ const C = Ft(o, mt(e));
1051
+ return _e(() => A.replaceChild(C, s)), ke[e] = C, Ve(), !0;
833
1052
  }
834
- function N() {
835
- ve(tn), Pe();
836
- const e = p[p.length - 1], t = q && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT");
837
- S.setAttribute("aria-busy", t ? "true" : "false"), Qt(t);
1053
+ function B() {
1054
+ _e(cn), Ve();
1055
+ const e = f[f.length - 1], o = K && e?.role === "assistant" && (e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT");
1056
+ A.setAttribute("aria-busy", o ? "true" : "false"), nn(o);
838
1057
  }
839
- function tn() {
840
- if (S.replaceChildren(), ye = [], p.length === 0) {
841
- if (ot === "static") {
842
- const e = g({
1058
+ function cn() {
1059
+ if (A.replaceChildren(), ke = [], f.length === 0) {
1060
+ if (st === "static") {
1061
+ const e = b({
843
1062
  textAlign: "center",
844
- color: Bt,
1063
+ color: he,
845
1064
  padding: "24px 16px",
846
1065
  fontSize: "16px",
847
1066
  lineHeight: "1.5"
848
1067
  });
849
- e.appendChild(et(nt)), S.appendChild(e);
1068
+ e.appendChild(rt(at)), A.appendChild(e);
850
1069
  }
851
- } else p.forEach((e, t) => {
852
- const l = Tt(e, dt(t));
853
- ye[t] = l, S.appendChild(l);
1070
+ } else f.forEach((e, o) => {
1071
+ const s = Ft(e, mt(o));
1072
+ ke[o] = s, A.appendChild(s);
854
1073
  });
855
- for (const e of He) S.appendChild(Mn(e));
856
- if (ae) {
857
- const e = g({
1074
+ for (const e of Ue) A.appendChild(Xn(e));
1075
+ if (le) {
1076
+ const e = b({
858
1077
  padding: "10px 14px",
859
1078
  backgroundColor: "#fef2f2",
860
1079
  color: "#dc2626",
@@ -863,37 +1082,37 @@ function qn(n, o) {
863
1082
  fontSize: "13px",
864
1083
  border: "1px solid #fecaca"
865
1084
  });
866
- e.setAttribute("role", "alert"), e.textContent = ae, S.appendChild(e);
1085
+ e.setAttribute("role", "alert"), e.textContent = le, A.appendChild(e);
867
1086
  }
868
1087
  }
869
- function ct() {
870
- for (let e = p.length - 1; e >= 0; e--) {
871
- const t = p[e];
872
- if (t.role === "assistant" && (t.status === "IN_PROGRESS" || t.status === "WAITING_CLIENT")) return t;
1088
+ function ht() {
1089
+ for (let e = f.length - 1; e >= 0; e--) {
1090
+ const o = f[e];
1091
+ if (o.role === "assistant" && (o.status === "IN_PROGRESS" || o.status === "WAITING_CLIENT")) return o;
873
1092
  }
874
1093
  }
875
- const pt = (e) => {
876
- V || (V = e.conversationId);
877
- }, ft = (e) => {
878
- const t = ct();
879
- t && (t.content += e.content, en() || N());
880
- }, ut = (e) => {
881
- const t = p.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
882
- t >= 0 ? p[t] = e : p.push(e), N(), Ve() || Ce();
883
- }, mt = (e) => {
884
- const t = p.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
885
- t >= 0 ? p[t] = e : p.push(e), q = !1, N(), e.status === "DONE" && K?.({
1094
+ const gt = (e) => {
1095
+ q || (q = e.conversationId);
1096
+ }, bt = (e) => {
1097
+ const o = ht();
1098
+ o && (o.content += e.content, dn() || B());
1099
+ }, xt = (e) => {
1100
+ const o = f.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
1101
+ o >= 0 ? f[o] = e : f.push(e), B(), Je() || Re();
1102
+ }, wt = (e) => {
1103
+ const o = f.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
1104
+ o >= 0 ? f[o] = e : f.push(e), K = !1, B(), e.status === "DONE" && U?.({
886
1105
  id: e.id,
887
1106
  content: e.content
888
1107
  });
889
- }, ht = () => {
890
- const e = ct();
891
- e && (e.content ? e.status = "CANCELED" : p = p.filter((t) => t !== e)), q = !1, N();
892
- }, gt = (e) => {
893
- ae = e.error, q = !1, p = p.filter((t) => !t.id.startsWith("temp-")), N();
1108
+ }, yt = () => {
1109
+ const e = ht();
1110
+ e && (e.content ? e.status = "CANCELED" : f = f.filter((o) => o !== e)), K = !1, B();
1111
+ }, vt = (e) => {
1112
+ le = e.error, K = !1, f = f.filter((o) => !o.id.startsWith("temp-")), B();
894
1113
  };
895
- function nn(e) {
896
- const t = {
1114
+ function pn(e) {
1115
+ const o = {
897
1116
  id: `ago-intro-${Date.now()}`,
898
1117
  conversationId: "",
899
1118
  content: "",
@@ -901,232 +1120,232 @@ function qn(n, o) {
901
1120
  status: "IN_PROGRESS",
902
1121
  createdAt: /* @__PURE__ */ new Date()
903
1122
  };
904
- p.push(t), N();
905
- const l = e.match(/\S+\s*/g) ?? [e];
906
- let R = 0;
907
- Q = setInterval(() => {
908
- if (R >= l.length) {
909
- clearInterval(Q), Q = void 0, t.status = "DONE", it && (t.followUpReplies = it), N();
1123
+ f.push(o), B();
1124
+ const s = e.match(/\S+\s*/g) ?? [e];
1125
+ let C = 0;
1126
+ Y = setInterval(() => {
1127
+ if (C >= s.length) {
1128
+ clearInterval(Y), Y = void 0, o.status = "DONE", lt && (o.followUpReplies = lt), B();
910
1129
  return;
911
1130
  }
912
- t.content += l[R], R++, N();
913
- }, Wt);
1131
+ o.content += s[C], C++, B();
1132
+ }, Kt);
914
1133
  }
915
- C.on("message:start", pt), C.on("message:chunk", ft), C.on("message:answer-complete", ut), C.on("message:complete", mt), C.on("message:stopped", ht), C.on("message:error", gt);
916
- const xt = (e) => D?.(e), bt = (e) => M?.(e);
917
- D && C.on("form:submitted", xt), M && C.on("form:error", bt);
918
- const Ue = [];
919
- let yt = !1;
920
- const wt = (e) => {
921
- if (yt) return;
922
- Ue.push(e.install(C));
923
- let t = e.store.get().submitted;
924
- const l = e.store.subscribe((R) => {
925
- R.submitted && !t && (He.push(qt(R.submitResult)), N()), t = R.submitted;
1134
+ k.on("message:start", gt), k.on("message:chunk", bt), k.on("message:answer-complete", xt), k.on("message:complete", wt), k.on("message:stopped", yt), k.on("message:error", vt);
1135
+ const Ct = (e) => oe?.(e), Et = (e) => T?.(e);
1136
+ oe && k.on("form:submitted", Ct), T && k.on("form:error", Et);
1137
+ const Ke = [];
1138
+ let St = !1;
1139
+ const kt = (e) => {
1140
+ if (St) return;
1141
+ Ke.push(e.install(k));
1142
+ let o = e.store.get().submitted;
1143
+ const s = e.store.subscribe((C) => {
1144
+ C.submitted && !o && (Ue.push(Zt(C.submitResult)), B()), o = C.submitted;
926
1145
  });
927
- Ue.push(l);
1146
+ Ke.push(s);
928
1147
  };
929
- for (const e of y ?? []) e.schema != null ? wt(Cn(e)) : vn(C, e).then((t) => wt(t)).catch(() => {
1148
+ for (const e of S ?? []) e.schema != null ? kt(Ln(e)) : Nn(k, e).then((o) => kt(o)).catch(() => {
930
1149
  });
931
- async function Re(e, t) {
932
- const l = e.trim();
933
- if (!l && !t?.length || q) return;
934
- if (_?.(l), q = !0, ae = null, le = !0, Q) {
935
- clearInterval(Q), Q = void 0;
936
- const b = p.find((G) => G.id.startsWith("ago-intro-"));
937
- b && !b.content ? p = p.filter((G) => G !== b) : b && (b.status = "DONE");
1150
+ async function Te(e, o) {
1151
+ const s = e.trim();
1152
+ if (!s && !o?.length || K) return;
1153
+ if (P?.(s), K = !0, le = null, de = !0, Y) {
1154
+ clearInterval(Y), Y = void 0;
1155
+ const y = f.find((M) => M.id.startsWith("ago-intro-"));
1156
+ y && !y.content ? f = f.filter((M) => M !== y) : y && (y.status = "DONE");
938
1157
  }
939
- const R = Date.now();
940
- p.push({
941
- id: `temp-user-${R}`,
942
- conversationId: V || "",
943
- content: l,
1158
+ const C = Date.now();
1159
+ f.push({
1160
+ id: `temp-user-${C}`,
1161
+ conversationId: q || "",
1162
+ content: s,
944
1163
  role: "user",
945
1164
  status: "DONE",
946
- attachments: t && t.length > 0 ? gn(t) : void 0,
1165
+ attachments: o && o.length > 0 ? Cn(o) : void 0,
947
1166
  createdAt: /* @__PURE__ */ new Date()
948
- }), p.push({
949
- id: `temp-assistant-${R}`,
950
- conversationId: V || "",
1167
+ }), f.push({
1168
+ id: `temp-assistant-${C}`,
1169
+ conversationId: q || "",
951
1170
  content: "",
952
1171
  role: "assistant",
953
1172
  status: "IN_PROGRESS",
954
1173
  createdAt: /* @__PURE__ */ new Date()
955
- }), N();
1174
+ }), B();
956
1175
  try {
957
- const b = await C.sendMessage(l, {
958
- conversationId: V,
959
- files: t
1176
+ const y = await k.sendMessage(s, {
1177
+ conversationId: q,
1178
+ files: o
960
1179
  });
961
- b.conversationId && (V || (V = b.conversationId), be?.setActiveThread(b.conversationId, b.createdAt));
962
- const G = p.find((ee) => ee.id === `temp-user-${R}`);
963
- if (G && (G.id = `user-${R}`, G.conversationId = b.conversationId), b.id && !p.some((ee) => ee.id === b.id)) {
964
- const ee = p.findIndex((un) => un.id === `temp-assistant-${R}`);
965
- ee >= 0 ? p[ee] = b : p.push(b);
1180
+ y.conversationId && (q || (q = y.conversationId), Se?.setActiveThread(y.conversationId, y.createdAt));
1181
+ const M = f.find((ne) => ne.id === `temp-user-${C}`);
1182
+ if (M && (M.id = `user-${C}`, M.conversationId = y.conversationId), y.id && !f.some((ne) => ne.id === y.id)) {
1183
+ const ne = f.findIndex((vn) => vn.id === `temp-assistant-${C}`);
1184
+ ne >= 0 ? f[ne] = y : f.push(y);
966
1185
  }
967
- p = p.filter((ee) => !ee.id.startsWith("temp-")), b.status !== "WAITING_CLIENT" && (q = !1), N(), x && Ge();
968
- } catch (b) {
969
- ae = b instanceof Error ? b.message : "Failed to send message", q = !1, p = p.filter((G) => !G.id.startsWith("temp-")), Jt(l, t), N();
1186
+ f = f.filter((ne) => !ne.id.startsWith("temp-")), y.status !== "WAITING_CLIENT" && (K = !1), B(), v && Xe();
1187
+ } catch (y) {
1188
+ le = y instanceof Error ? y.message : "Failed to send message", K = !1, f = f.filter((M) => !M.id.startsWith("temp-")), on(s, o), B();
970
1189
  }
971
1190
  }
972
- async function vt() {
973
- q && await C.stop();
1191
+ async function At() {
1192
+ K && await k.stop();
974
1193
  }
975
- async function Ge() {
1194
+ async function Xe() {
976
1195
  try {
977
- const { data: e } = await C.getConversations();
978
- we.splice(0, we.length, ...e);
1196
+ const { data: e } = await k.getConversations();
1197
+ Ae.splice(0, Ae.length, ...e);
979
1198
  } catch {
980
1199
  }
981
- return we;
1200
+ return Ae;
982
1201
  }
983
- async function on(e) {
1202
+ async function un(e) {
984
1203
  try {
985
- const t = (await C.getConversation(e))?.messages ?? [];
986
- t.length > 0 && p.length === 0 && (p = t, N());
1204
+ const o = (await k.getConversation(e))?.messages ?? [];
1205
+ o.length > 0 && f.length === 0 && (f = o, B());
987
1206
  } catch {
988
- p.length === 0 && (be?.clear(), V = void 0);
1207
+ f.length === 0 && (Se?.clear(), q = void 0);
989
1208
  }
990
1209
  }
991
- return N(), fe && O?.matches || Ce(), V ? on(V) : ot === "streaming" && nn(nt), x && Ge(), {
992
- client: C,
993
- element: Ee,
994
- sendMessage: Re,
995
- stop: vt,
996
- ...L || fe ? {
997
- open: sn,
998
- close: an,
999
- toggle: ln
1210
+ return B(), ge && z?.matches || Re(), q ? un(q) : st === "streaming" && pn(at), v && Xe(), {
1211
+ client: k,
1212
+ element: Ie,
1213
+ sendMessage: Te,
1214
+ stop: At,
1215
+ ...$ || ge ? {
1216
+ open: mn,
1217
+ close: hn,
1218
+ toggle: gn
1000
1219
  } : {},
1001
- session: be,
1002
- threads: we,
1003
- refreshThreads: Ge,
1220
+ session: Se,
1221
+ threads: Ae,
1222
+ refreshThreads: Xe,
1004
1223
  destroy() {
1005
- se || (se = !0, Q && clearInterval(Q), C.off("message:start", pt), C.off("message:chunk", ft), C.off("message:answer-complete", ut), C.off("message:complete", mt), C.off("message:stopped", ht), C.off("message:error", gt), D && C.off("form:submitted", xt), M && C.off("form:error", bt), yt = !0, Ue.forEach((e) => e()), Ee.remove(), H?.remove(), U?.remove(), he?.remove(), Z?.remove(), O?.removeEventListener("change", St), document.removeEventListener("keydown", Et), Ke(), Oe = !1, Qe(ue), o.client || C.destroy());
1224
+ se || (se = !0, Y && clearInterval(Y), k.off("message:start", gt), k.off("message:chunk", bt), k.off("message:answer-complete", xt), k.off("message:complete", wt), k.off("message:stopped", yt), k.off("message:error", vt), oe && k.off("form:submitted", Ct), T && k.off("form:error", Et), St = !0, Ke.forEach((e) => e()), Ie.remove(), H?.remove(), V?.remove(), we?.remove(), te?.remove(), z?.removeEventListener("change", It), document.removeEventListener("keydown", Rt), et(), Fe = !1, tt(be), t.client || k.destroy());
1006
1225
  }
1007
1226
  };
1008
- function ke() {
1009
- if (!$) return;
1227
+ function $e() {
1228
+ if (!O) return;
1010
1229
  {
1011
- const l = Se === "left" ? "border-right" : "border-left";
1012
- O?.matches ? ($.style.width = "100%", a.style.borderRadius = "0", a.style.removeProperty(l)) : ($.style.width = typeof f == "number" ? `${f}px` : f, a.style.setProperty(l, `1px solid ${T}`));
1230
+ const s = Ne === "left" ? "border-right" : "border-left";
1231
+ z?.matches ? (O.style.width = "100%", l.style.borderRadius = "0", l.style.removeProperty(s)) : (O.style.width = typeof d == "number" ? `${d}px` : d, l.style.setProperty(s, `1px solid ${R}`));
1013
1232
  }
1014
- const e = v === "left" ? "translateX(-100%)" : "translateX(100%)";
1015
- $.style.transform = oe ? "translateX(0)" : e, $.setAttribute("aria-hidden", oe ? "false" : "true"), H && (H.style.display = oe ? "none" : "flex");
1016
- const t = Ct();
1017
- t !== Oe && (Oe = t, t ? (a.setAttribute("role", "dialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-label", r), a.tabIndex = -1, a.style.paddingBottom = "env(safe-area-inset-bottom)", _t(ue), Y = qe(), Xe(), At()) : (Ke(), cn(), Y = 0, a.removeAttribute("role"), a.removeAttribute("aria-modal"), a.removeAttribute("aria-label"), a.style.removeProperty("padding-bottom"), Qe(ue)));
1233
+ const e = w === "left" ? "translateX(-100%)" : "translateX(100%)";
1234
+ O.style.transform = re ? "translateX(0)" : e, O.setAttribute("aria-hidden", re ? "false" : "true"), H && (H.style.display = re ? "none" : "flex");
1235
+ const o = _t();
1236
+ o !== Fe && (Fe = o, o ? (l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "true"), l.setAttribute("aria-label", i), l.tabIndex = -1, l.style.paddingBottom = "env(safe-area-inset-bottom)", Ot(be), ee = Ye(), Ze(), Nt()) : (et(), xn(), ee = 0, l.removeAttribute("role"), l.removeAttribute("aria-modal"), l.removeAttribute("aria-label"), l.style.removeProperty("padding-bottom"), tt(be)));
1018
1237
  }
1019
- function je() {
1020
- oe = !0, ke(), Ve() ? a.focus({ preventScroll: !0 }) : Ce(), j?.();
1238
+ function Qe() {
1239
+ re = !0, $e(), Je() ? l.focus({ preventScroll: !0 }) : Re(), J?.();
1021
1240
  }
1022
- function Ie() {
1023
- oe = !1, ke(), tt?.();
1241
+ function Oe() {
1242
+ re = !1, $e(), it?.();
1024
1243
  }
1025
- function rn() {
1026
- oe ? Ie() : je();
1244
+ function fn() {
1245
+ re ? Oe() : Qe();
1027
1246
  }
1028
- function sn() {
1029
- L ? je() : ge();
1247
+ function mn() {
1248
+ $ ? Qe() : ye();
1030
1249
  }
1031
- function an() {
1032
- L ? Ie() : xe();
1250
+ function hn() {
1251
+ $ ? Oe() : ve();
1033
1252
  }
1034
- function ln() {
1035
- L ? rn() : X ? xe() : ge();
1253
+ function gn() {
1254
+ $ ? fn() : X ? ve() : ye();
1036
1255
  }
1037
- function Ve() {
1038
- return !!O?.matches;
1256
+ function Je() {
1257
+ return !!z?.matches;
1039
1258
  }
1040
- function Ct() {
1041
- return Ve() && (L ? oe : X);
1259
+ function _t() {
1260
+ return Je() && ($ ? re : X);
1042
1261
  }
1043
- function dn() {
1044
- return Array.from(a.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
1262
+ function bn() {
1263
+ return Array.from(l.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((e) => e.getClientRects().length > 0);
1045
1264
  }
1046
- function Et(e) {
1047
- if (!Ct()) return;
1265
+ function Rt(e) {
1266
+ if (!_t()) return;
1048
1267
  if (e.key === "Escape") {
1049
- L ? Ie() : xe();
1268
+ $ ? Oe() : ve();
1050
1269
  return;
1051
1270
  }
1052
1271
  if (e.key !== "Tab") return;
1053
- const t = dn();
1054
- if (t.length === 0) {
1272
+ const o = bn();
1273
+ if (o.length === 0) {
1055
1274
  e.preventDefault();
1056
1275
  return;
1057
1276
  }
1058
- const l = t[0], R = t[t.length - 1], b = document.activeElement;
1059
- e.shiftKey && (b === l || !a.contains(b)) ? (e.preventDefault(), R.focus()) : !e.shiftKey && (b === R || !a.contains(b)) && (e.preventDefault(), l.focus());
1277
+ const s = o[0], C = o[o.length - 1], y = document.activeElement;
1278
+ e.shiftKey && (y === s || !l.contains(y)) ? (e.preventDefault(), C.focus()) : !e.shiftKey && (y === C || !l.contains(y)) && (e.preventDefault(), s.focus());
1060
1279
  }
1061
- function St(e) {
1062
- L ? ke() : !e.matches && X && xe(), N();
1280
+ function It(e) {
1281
+ $ ? $e() : !e.matches && X && ve(), B();
1063
1282
  }
1064
- function qe() {
1283
+ function Ye() {
1065
1284
  return window.visualViewport?.height ?? window.innerHeight;
1066
1285
  }
1067
- function Xe() {
1068
- const e = window.visualViewport, t = e?.offsetTop ?? 0, l = e?.height ?? Y;
1069
- if (L) {
1070
- if (!$) return;
1071
- const b = window.innerHeight || Y, G = Math.max(0, b - (t + l));
1072
- $.style.bottom = `${G}px`, $.style.top = `${t}px`;
1286
+ function Ze() {
1287
+ const e = window.visualViewport, o = e?.offsetTop ?? 0, s = e?.height ?? ee;
1288
+ if ($) {
1289
+ if (!O) return;
1290
+ const y = window.innerHeight || ee, M = Math.max(0, y - (o + s));
1291
+ O.style.bottom = `${M}px`, O.style.top = `${o}px`;
1073
1292
  return;
1074
1293
  }
1075
- const R = Math.min(0, t + l - Y);
1076
- a.style.top = `${R}px`, U && (U.style.top = `${t}px`);
1294
+ const C = Math.min(0, o + s - ee);
1295
+ l.style.top = `${C}px`, V && (V.style.top = `${o}px`);
1077
1296
  }
1078
- function cn() {
1079
- L && $ && ($.style.removeProperty("bottom"), $.style.removeProperty("top"));
1297
+ function xn() {
1298
+ $ && O && (O.style.removeProperty("bottom"), O.style.removeProperty("top"));
1080
1299
  }
1081
- function _e() {
1082
- de || (de = requestAnimationFrame(() => {
1083
- de = 0, !se && Xe();
1300
+ function Be() {
1301
+ ce || (ce = requestAnimationFrame(() => {
1302
+ ce = 0, !se && Ze();
1084
1303
  }));
1085
1304
  }
1086
- function At() {
1087
- window.visualViewport?.addEventListener("resize", _e), window.visualViewport?.addEventListener("scroll", _e);
1305
+ function Nt() {
1306
+ window.visualViewport?.addEventListener("resize", Be), window.visualViewport?.addEventListener("scroll", Be);
1088
1307
  }
1089
- function Ke() {
1090
- window.visualViewport?.removeEventListener("resize", _e), window.visualViewport?.removeEventListener("scroll", _e), de && (cancelAnimationFrame(de), de = 0);
1308
+ function et() {
1309
+ window.visualViewport?.removeEventListener("resize", Be), window.visualViewport?.removeEventListener("scroll", Be), ce && (cancelAnimationFrame(ce), ce = 0);
1091
1310
  }
1092
- function Rt() {
1093
- le = !0, Pe();
1311
+ function Lt() {
1312
+ de = !0, Ve();
1094
1313
  }
1095
- function pn() {
1096
- const e = g({
1314
+ function wn() {
1315
+ const e = b({
1097
1316
  position: "fixed",
1098
1317
  top: "0",
1099
1318
  left: "0",
1100
1319
  right: "0",
1101
- height: `calc(${lt}px + env(safe-area-inset-top))`,
1320
+ height: `calc(${ut}px + env(safe-area-inset-top))`,
1102
1321
  display: "none",
1103
1322
  alignItems: "center",
1104
1323
  justifyContent: "space-between",
1105
1324
  padding: "env(safe-area-inset-top) 14px 0",
1106
- backgroundColor: ne,
1107
- borderBottom: `1px solid ${T}`,
1325
+ backgroundColor: Q,
1326
+ borderBottom: `1px solid ${R}`,
1108
1327
  zIndex: "2147483001",
1109
- fontFamily: $e
1328
+ fontFamily: ze
1110
1329
  });
1111
- if (e.className = "ago-chat-widget-mobile-bar", A) {
1112
- const l = document.createElement("img");
1113
- l.src = A, l.alt = "", E(l, {
1330
+ if (e.className = "ago-chat-widget-mobile-bar", h) {
1331
+ const s = document.createElement("img");
1332
+ s.src = h, s.alt = "", E(s, {
1114
1333
  height: "28px",
1115
1334
  width: "auto"
1116
- }), e.appendChild(l);
1117
- } else if (r) {
1118
- const l = document.createElement("span");
1119
- l.textContent = r, E(l, {
1335
+ }), e.appendChild(s);
1336
+ } else if (i) {
1337
+ const s = document.createElement("span");
1338
+ s.textContent = i, E(s, {
1120
1339
  fontSize: "15px",
1121
1340
  fontWeight: "600",
1122
- color: te,
1341
+ color: F,
1123
1342
  overflow: "hidden",
1124
1343
  whiteSpace: "nowrap",
1125
1344
  textOverflow: "ellipsis"
1126
- }), e.appendChild(l);
1127
- } else e.appendChild(g({}));
1128
- const t = document.createElement("button");
1129
- return t.type = "button", t.setAttribute("aria-label", "Close"), t.textContent = "×", E(t, {
1345
+ }), e.appendChild(s);
1346
+ } else e.appendChild(b({}));
1347
+ const o = document.createElement("button");
1348
+ return o.type = "button", o.setAttribute("aria-label", "Close"), o.textContent = "×", E(o, {
1130
1349
  flexShrink: "0",
1131
1350
  width: "44px",
1132
1351
  height: "44px",
@@ -1138,30 +1357,30 @@ function qn(n, o) {
1138
1357
  background: "transparent",
1139
1358
  fontSize: "26px",
1140
1359
  lineHeight: "1",
1141
- color: te,
1360
+ color: F,
1142
1361
  cursor: "pointer",
1143
1362
  padding: "0"
1144
- }), t.addEventListener("click", () => {
1145
- xe();
1146
- }), e.appendChild(t), e;
1363
+ }), o.addEventListener("click", () => {
1364
+ ve();
1365
+ }), e.appendChild(o), e;
1147
1366
  }
1148
- function fn() {
1149
- return typeof document.startViewTransition == "function" && !jt?.matches && !!O?.matches;
1367
+ function yn() {
1368
+ return typeof document.startViewTransition == "function" && !Jt?.matches && !!z?.matches;
1150
1369
  }
1151
- function kt(e) {
1152
- const t = document;
1153
- if (fn() && t.startViewTransition) {
1154
- a.style.setProperty("view-transition-name", me), U?.style.setProperty("view-transition-name", `${me}-bar`);
1155
- const l = () => {
1156
- a.style.removeProperty("view-transition-name"), U?.style.removeProperty("view-transition-name");
1370
+ function Tt(e) {
1371
+ const o = document;
1372
+ if (yn() && o.startViewTransition) {
1373
+ l.style.setProperty("view-transition-name", xe), V?.style.setProperty("view-transition-name", `${xe}-bar`);
1374
+ const s = () => {
1375
+ l.style.removeProperty("view-transition-name"), V?.style.removeProperty("view-transition-name");
1157
1376
  };
1158
- return t.startViewTransition(e).finished.then(l, l);
1377
+ return o.startViewTransition(e).finished.then(s, s);
1159
1378
  }
1160
1379
  return e(), Promise.resolve();
1161
1380
  }
1162
- function It(e) {
1381
+ function $t(e) {
1163
1382
  if (e)
1164
- Z && a.parentElement?.insertBefore(Z, a), E(a, {
1383
+ te && l.parentElement?.insertBefore(te, l), E(l, {
1165
1384
  position: "fixed",
1166
1385
  top: "0",
1167
1386
  left: "0",
@@ -1172,12 +1391,12 @@ function qn(n, o) {
1172
1391
  border: "none",
1173
1392
  borderRadius: "0",
1174
1393
  boxShadow: "none",
1175
- paddingTop: `calc(${lt}px + env(safe-area-inset-top))`,
1394
+ paddingTop: `calc(${ut}px + env(safe-area-inset-top))`,
1176
1395
  paddingBottom: "env(safe-area-inset-bottom)"
1177
- }), a.setAttribute("role", "dialog"), a.setAttribute("aria-modal", "true"), a.setAttribute("aria-label", r), W && (W.style.display = "none"), U && (U.style.display = "flex");
1396
+ }), l.setAttribute("role", "dialog"), l.setAttribute("aria-modal", "true"), l.setAttribute("aria-label", i), j && (j.style.display = "none"), V && (V.style.display = "flex");
1178
1397
  else {
1179
- Z?.remove(), Z = void 0;
1180
- for (const t of [
1398
+ te?.remove(), te = void 0;
1399
+ for (const o of [
1181
1400
  "position",
1182
1401
  "top",
1183
1402
  "left",
@@ -1186,35 +1405,36 @@ function qn(n, o) {
1186
1405
  "z-index",
1187
1406
  "padding-top",
1188
1407
  "padding-bottom"
1189
- ]) a.style.removeProperty(t);
1190
- a.style.height = Ae.height, a.style.border = Ae.border, a.style.borderRadius = Ae.borderRadius, a.style.boxShadow = Ae.boxShadow, a.removeAttribute("role"), a.removeAttribute("aria-modal"), a.removeAttribute("aria-label"), W && (W.style.display = "flex"), U && (U.style.display = "none");
1408
+ ]) l.style.removeProperty(o);
1409
+ l.style.height = Le.height, l.style.border = Le.border, l.style.borderRadius = Le.borderRadius, l.style.boxShadow = Le.boxShadow, l.removeAttribute("role"), l.removeAttribute("aria-modal"), l.removeAttribute("aria-label"), j && (j.style.display = "flex"), V && (V.style.display = "none");
1191
1410
  }
1192
1411
  }
1193
- function ge() {
1194
- if (se || X || !O?.matches) return Promise.resolve();
1195
- const e = a.getBoundingClientRect();
1196
- if (e.height >= qe() * 0.8) return Promise.resolve();
1197
- X = !0, Z = g({
1412
+ function ye() {
1413
+ if (se || X || !z?.matches) return Promise.resolve();
1414
+ const e = l.getBoundingClientRect();
1415
+ if (e.height >= Ye() * 0.8) return Promise.resolve();
1416
+ X = !0, te = b({
1198
1417
  width: `${e.width}px`,
1199
1418
  height: `${e.height}px`
1200
- }), Z.className = "ago-chat-widget-spacer", Z.setAttribute("aria-hidden", "true"), Y = qe(), a.style.setProperty("--ago-vh", `${Y}px`), Xe(), At(), _t(ue);
1201
- const t = kt(() => It(!0));
1202
- return t.then(() => {
1203
- se || (Rt(), Ce());
1204
- }), Rt(), j?.(), t;
1419
+ }), te.className = "ago-chat-widget-spacer", te.setAttribute("aria-hidden", "true"), ee = Ye(), l.style.setProperty("--ago-vh", `${ee}px`), Ze(), Nt(), Ot(be);
1420
+ const o = Tt(() => $t(!0));
1421
+ return o.then(() => {
1422
+ se || (Lt(), Re());
1423
+ }), Lt(), J?.(), o;
1205
1424
  }
1206
- function xe() {
1425
+ function ve() {
1207
1426
  if (!X) return Promise.resolve();
1208
- X = !1, Ke(), Qe(ue), a.querySelector("textarea")?.blur();
1209
- const e = kt(() => It(!1));
1427
+ X = !1, et(), tt(be), l.querySelector("textarea")?.blur();
1428
+ const e = Tt(() => $t(!1));
1210
1429
  return e.then(() => {
1211
- se || a.style.removeProperty("--ago-vh");
1212
- }), Y = 0, tt?.(), e;
1430
+ se || l.style.removeProperty("--ago-vh");
1431
+ }), ee = 0, it?.(), e;
1213
1432
  }
1214
1433
  }
1215
1434
  export {
1216
- Vn as compactMediaQuery,
1217
- jn as createSheetController,
1218
- qn as mountChatWidget,
1219
- et as renderMarkdown
1435
+ Dt as DEFAULT_FEEDBACK_LABELS,
1436
+ lo as compactMediaQuery,
1437
+ so as createSheetController,
1438
+ co as mountChatWidget,
1439
+ rt as renderMarkdown
1220
1440
  };