@useago/sdk 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/widget.js CHANGED
@@ -1,7 +1,7 @@
1
- import { t as Xe, u as Ke } from "./AgoClient-DYdIe_R4.js";
2
- import { r as qe, t as Ve } from "./createFormCollector-BUqSA2Qw.js";
3
- import { t as Qe } from "./createConversationSession-Boi0PjDU.js";
4
- var Ye = {
1
+ import { t as nt, u as ot } from "./AgoClient-QcTtrN7u.js";
2
+ import { r as rt, t as at } from "./createFormCollector-QyojCH_-.js";
3
+ import { t as st } from "./createConversationSession-DrCMdwkV.js";
4
+ var it = {
5
5
  "&": "&",
6
6
  "<": "&lt;",
7
7
  ">": "&gt;",
@@ -9,41 +9,41 @@ var Ye = {
9
9
  "'": "&#39;"
10
10
  };
11
11
  function U(o) {
12
- return o.replace(/[&<>"']/g, (n) => Ye[n]);
12
+ return o.replace(/[&<>"']/g, (n) => it[n]);
13
13
  }
14
- function ke(o) {
14
+ function De(o) {
15
15
  const n = o.trim();
16
16
  return /^(https?:|mailto:|tel:|#|\/|\.\/|\.\.\/)/i.test(n) || !/^[a-z][a-z0-9+.-]*:/i.test(n) ? n : null;
17
17
  }
18
- var Ne = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Q = "";
19
- function M(o) {
20
- const n = [], r = (u) => (n.push(u), `${Q}${n.length - 1}${Q}`);
18
+ var He = '"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace', Q = "";
19
+ function F(o) {
20
+ const n = [], a = (u) => (n.push(u), `${Q}${n.length - 1}${Q}`);
21
21
  let t = o;
22
- return t = t.replace(/`([^`]+)`/g, (u, i) => r(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${Ne}">${U(i)}</code>`)), t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (u, i, f) => {
23
- const s = ke(f);
24
- return s ? r(`<img alt="${U(i)}" src="${U(s)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : u;
22
+ return t = t.replace(/`([^`]+)`/g, (u, i) => a(`<code style="background:#f0f2f5;padding:2px 5px;border-radius:4px;font-size:13px;font-family:${He}">${U(i)}</code>`)), t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (u, i, f) => {
23
+ const l = De(f);
24
+ return l ? a(`<img alt="${U(i)}" src="${U(l)}" style="max-width:100%;border-radius:8px;margin:4px 0" />`) : u;
25
25
  }), t = t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (u, i, f) => {
26
- const s = ke(f);
27
- return s ? r(`<a href="${U(s)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${M(i)}</a>`) : u;
26
+ const l = De(f);
27
+ return l ? a(`<a href="${U(l)}" target="_blank" rel="noopener noreferrer" style="color:#1b5fc4;text-decoration:underline">${F(i)}</a>`) : u;
28
28
  }), t = U(t), t = t.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>"), t = t.replace(new RegExp(`${Q}(\\d+)${Q}`, "g"), (u, i) => n[Number(i)]), t;
29
29
  }
30
- function R(o, n, r) {
30
+ function R(o, n, a) {
31
31
  const t = document.createElement(o);
32
- return Object.assign(t.style, n), r !== void 0 && (t.innerHTML = r), t;
32
+ return Object.assign(t.style, n), a !== void 0 && (t.innerHTML = a), t;
33
33
  }
34
- var Oe = /^ {0,3}([-*_])( *\1){2,} *$/, Te = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, De = /^ {0,3}(```+|~~~+)/, Z = /^ {0,3}>\s?/, P = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, Ze = [
34
+ var Ue = /^ {0,3}([-*_])( *\1){2,} *$/, We = /^ {0,3}(#{1,6})\s+(.*?)\s*#*\s*$/, Pe = /^ {0,3}(```+|~~~+)/, Z = /^ {0,3}>\s?/, W = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/, lt = [
35
35
  "20px",
36
36
  "18px",
37
37
  "16px",
38
38
  "15px",
39
39
  "14px",
40
40
  "13px"
41
- ], pe = (o) => o.match(/^\s*/)?.[0].length ?? 0;
42
- function Je(o) {
43
- return o.trim() === "" || Oe.test(o) || Te.test(o) || De.test(o) || Z.test(o) || P.test(o);
41
+ ], me = (o) => o.match(/^\s*/)?.[0].length ?? 0;
42
+ function dt(o) {
43
+ return o.trim() === "" || Ue.test(o) || We.test(o) || Pe.test(o) || Z.test(o) || W.test(o);
44
44
  }
45
- function Me(o) {
46
- const n = o[0].match(P), r = n[1].length, t = /\d/.test(n[2]), u = R(t ? "ol" : "ul", {
45
+ function Ge(o) {
46
+ const n = o[0].match(W), a = n[1].length, t = /\d/.test(n[2]), u = R(t ? "ol" : "ul", {
47
47
  margin: "0 0 8px 0",
48
48
  paddingLeft: "20px",
49
49
  listStyleType: t ? "decimal" : "disc",
@@ -51,20 +51,20 @@ function Me(o) {
51
51
  });
52
52
  let i = 0;
53
53
  for (; i < o.length; ) {
54
- const f = o[i].match(P), s = [];
55
- for (i++; i < o.length && pe(o[i]) > r; )
56
- s.push(o[i]), i++;
54
+ const f = o[i].match(W), l = [];
55
+ for (i++; i < o.length && me(o[i]) > a; )
56
+ l.push(o[i]), i++;
57
57
  const p = R("li", {
58
58
  display: "list-item",
59
59
  margin: "2px 0",
60
60
  lineHeight: "1.6"
61
61
  }), c = f[3].match(/^\[([ xX])\]\s+(.*)$/);
62
- c ? (p.style.listStyleType = "none", p.style.marginLeft = "-20px", p.innerHTML = `<span style="margin-right:6px">${c[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${M(c[2])}`) : p.innerHTML = M(f[3]), s.filter((h) => P.test(h)).length > 0 && p.appendChild(Me(s.filter((h) => h.trim() !== ""))), u.appendChild(p);
62
+ c ? (p.style.listStyleType = "none", p.style.marginLeft = "-20px", p.innerHTML = `<span style="margin-right:6px">${c[1].toLowerCase() === "x" ? "☑" : "☐"}</span>${F(c[2])}`) : p.innerHTML = F(f[3]), l.filter((m) => W.test(m)).length > 0 && p.appendChild(Ge(l.filter((m) => m.trim() !== ""))), u.appendChild(p);
63
63
  }
64
64
  return u;
65
65
  }
66
- function et(o) {
67
- const n = (s) => s.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((p) => p.trim()), r = R("div", {
66
+ function ct(o) {
67
+ const n = (l) => l.replace(/^\s*\|?/, "").replace(/\|?\s*$/, "").split("|").map((p) => p.trim()), a = R("div", {
68
68
  overflowX: "auto",
69
69
  margin: "0 0 8px 0"
70
70
  }), t = R("table", {
@@ -72,58 +72,58 @@ function et(o) {
72
72
  width: "100%",
73
73
  fontSize: "13px"
74
74
  }), u = document.createElement("thead"), i = document.createElement("tr");
75
- for (const s of n(o[0])) i.appendChild(R("th", {
75
+ for (const l of n(o[0])) i.appendChild(R("th", {
76
76
  border: "1px solid #dee3e8",
77
77
  padding: "6px 10px",
78
78
  textAlign: "left",
79
79
  backgroundColor: "#f5f7fa",
80
80
  fontWeight: "600"
81
- }, M(s)));
81
+ }, F(l)));
82
82
  u.appendChild(i), t.appendChild(u);
83
83
  const f = document.createElement("tbody");
84
- for (const s of o.slice(2)) {
84
+ for (const l of o.slice(2)) {
85
85
  const p = document.createElement("tr");
86
- for (const c of n(s)) p.appendChild(R("td", {
86
+ for (const c of n(l)) p.appendChild(R("td", {
87
87
  border: "1px solid #dee3e8",
88
88
  padding: "6px 10px"
89
- }, M(c)));
89
+ }, F(c)));
90
90
  f.appendChild(p);
91
91
  }
92
- return t.appendChild(f), r.appendChild(t), r;
92
+ return t.appendChild(f), a.appendChild(t), a;
93
93
  }
94
- var tt = (o) => !!o && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);
95
- function fe(o) {
96
- const n = document.createDocumentFragment(), r = o.replace(/\r\n?/g, `
94
+ var pt = (o) => !!o && /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(o);
95
+ function he(o) {
96
+ const n = document.createDocumentFragment(), a = o.replace(/\r\n?/g, `
97
97
  `).split(`
98
98
  `);
99
99
  let t = 0;
100
- for (; t < r.length; ) {
101
- const i = r[t];
100
+ for (; t < a.length; ) {
101
+ const i = a[t];
102
102
  if (i.trim() === "") {
103
103
  t++;
104
104
  continue;
105
105
  }
106
- const f = i.match(De);
106
+ const f = i.match(Pe);
107
107
  if (f) {
108
- const c = f[1][0], h = [];
109
- for (t++; t < r.length && !new RegExp(`^ {0,3}${c === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(r[t]); )
110
- h.push(r[t]), t++;
108
+ const c = f[1][0], m = [];
109
+ for (t++; t < a.length && !new RegExp(`^ {0,3}${c === "`" ? "`{3,}" : "~{3,}"}\\s*$`).test(a[t]); )
110
+ m.push(a[t]), t++;
111
111
  t++;
112
- const L = R("pre", { margin: "0 0 8px 0" });
113
- L.appendChild(R("code", {
112
+ const T = R("pre", { margin: "0 0 8px 0" });
113
+ T.appendChild(R("code", {
114
114
  display: "block",
115
115
  background: "#f5f5f5",
116
116
  padding: "8px 12px",
117
117
  borderRadius: "6px",
118
118
  fontSize: "13px",
119
119
  overflowX: "auto",
120
- fontFamily: Ne,
120
+ fontFamily: He,
121
121
  whiteSpace: "pre"
122
- }, U(h.join(`
123
- `)))), n.appendChild(L);
122
+ }, U(m.join(`
123
+ `)))), n.appendChild(T);
124
124
  continue;
125
125
  }
126
- if (Oe.test(i)) {
126
+ if (Ue.test(i)) {
127
127
  n.appendChild(R("hr", {
128
128
  border: "none",
129
129
  borderTop: "1px solid #dee3e8",
@@ -131,60 +131,60 @@ function fe(o) {
131
131
  })), t++;
132
132
  continue;
133
133
  }
134
- const s = i.match(Te);
135
- if (s) {
136
- const c = s[1].length;
134
+ const l = i.match(We);
135
+ if (l) {
136
+ const c = l[1].length;
137
137
  n.appendChild(R(`h${c}`, {
138
138
  margin: "16px 0 8px 0",
139
- fontSize: Ze[c - 1],
139
+ fontSize: lt[c - 1],
140
140
  fontWeight: "600",
141
141
  lineHeight: "1.3"
142
- }, M(s[2]))), t++;
142
+ }, F(l[2]))), t++;
143
143
  continue;
144
144
  }
145
145
  if (Z.test(i)) {
146
146
  const c = [];
147
- for (; t < r.length && Z.test(r[t]); )
148
- c.push(r[t].replace(Z, "")), t++;
149
- const h = R("blockquote", {
147
+ for (; t < a.length && Z.test(a[t]); )
148
+ c.push(a[t].replace(Z, "")), t++;
149
+ const m = R("blockquote", {
150
150
  borderLeft: "4px solid #dee3e8",
151
151
  paddingLeft: "12px",
152
152
  margin: "0 0 8px 0",
153
153
  fontStyle: "italic",
154
154
  color: "#6b6d6f"
155
155
  });
156
- h.appendChild(fe(c.join(`
157
- `))), n.appendChild(h);
156
+ m.appendChild(he(c.join(`
157
+ `))), n.appendChild(m);
158
158
  continue;
159
159
  }
160
- if (i.includes("|") && tt(r[t + 1])) {
161
- const c = [i, r[t + 1]];
162
- for (t += 2; t < r.length && r[t].includes("|") && r[t].trim(); )
163
- c.push(r[t]), t++;
164
- n.appendChild(et(c));
160
+ if (i.includes("|") && pt(a[t + 1])) {
161
+ const c = [i, a[t + 1]];
162
+ for (t += 2; t < a.length && a[t].includes("|") && a[t].trim(); )
163
+ c.push(a[t]), t++;
164
+ n.appendChild(ct(c));
165
165
  continue;
166
166
  }
167
- if (P.test(i)) {
168
- const c = [], h = pe(i);
169
- for (; t < r.length && r[t].trim() !== ""; )
170
- if (P.test(r[t]) || pe(r[t]) > h)
171
- c.push(r[t]), t++;
167
+ if (W.test(i)) {
168
+ const c = [], m = me(i);
169
+ for (; t < a.length && a[t].trim() !== ""; )
170
+ if (W.test(a[t]) || me(a[t]) > m)
171
+ c.push(a[t]), t++;
172
172
  else break;
173
- n.appendChild(Me(c));
173
+ n.appendChild(Ge(c));
174
174
  continue;
175
175
  }
176
176
  const p = [i];
177
- for (t++; t < r.length && !Je(r[t]); )
178
- p.push(r[t]), t++;
177
+ for (t++; t < a.length && !dt(a[t]); )
178
+ p.push(a[t]), t++;
179
179
  n.appendChild(R("p", {
180
180
  margin: "0 0 8px 0",
181
181
  lineHeight: "1.6"
182
- }, p.map((c) => M(c)).join("<br>")));
182
+ }, p.map((c) => F(c)).join("<br>")));
183
183
  }
184
184
  const u = n.lastElementChild;
185
185
  return u && (u.style.marginBottom = "0"), n;
186
186
  }
187
- var ue = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)', $e = {
187
+ var xe = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif)', Me = {
188
188
  font: "--ago-font",
189
189
  radius: "--ago-radius",
190
190
  messageRadius: "--ago-message-radius",
@@ -198,172 +198,195 @@ var ue = 'var(--ago-font, "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "S
198
198
  mutedText: "--ago-muted-text-color",
199
199
  border: "--ago-border-color",
200
200
  accent: "--ago-accent-color"
201
- }, ge = "var(--ago-brand-color, #03182f)", he = "var(--ago-brand-text-color, #fff)", nt = "var(--ago-header-background, var(--ago-brand-color, #03182f))", Ie = "var(--ago-header-text-color, #e8f0fe)", j = "var(--ago-panel-background, #fff)", ot = "var(--ago-messages-background, #fbfbfb)", Y = "var(--ago-text-color, #30373e)", rt = "var(--ago-muted-text-color, #6b6d6f)", $ = "var(--ago-border-color, #dee3e8)", ce = "var(--ago-accent-color, #1b5fc4)", at = "var(--ago-radius, 16px)", Ae = "var(--ago-message-radius, 16px)";
202
- function it(o, n) {
201
+ }, be = "var(--ago-brand-color, #03182f)", Ce = "var(--ago-brand-text-color, #fff)", ft = "var(--ago-header-background, var(--ago-brand-color, #03182f))", Fe = "var(--ago-header-text-color, #e8f0fe)", j = "var(--ago-panel-background, #fff)", ut = "var(--ago-messages-background, #fbfbfb)", Y = "var(--ago-text-color, #30373e)", gt = "var(--ago-muted-text-color, #6b6d6f)", I = "var(--ago-border-color, #dee3e8)", ue = "var(--ago-accent-color, #1b5fc4)", mt = "var(--ago-radius, 16px)", ge = "var(--ago-message-radius, 16px)";
202
+ function ht(o, n) {
203
203
  if (n)
204
- for (const r of Object.keys($e)) {
205
- const t = n[r];
206
- t != null && o.style.setProperty($e[r], t);
204
+ for (const a of Object.keys(Me)) {
205
+ const t = n[a];
206
+ t != null && o.style.setProperty(Me[a], t);
207
207
  }
208
208
  }
209
- function y(o, n) {
209
+ function E(o, n) {
210
210
  Object.assign(o.style, n);
211
211
  }
212
- function x(o = {}) {
212
+ function b(o = {}) {
213
213
  const n = document.createElement("div");
214
- return y(n, o), n;
214
+ return E(n, o), n;
215
+ }
216
+ var Be = "Form submitted.";
217
+ function xt(o) {
218
+ if (typeof o == "string") return o || null;
219
+ if (!o || typeof o != "object") return null;
220
+ const n = o;
221
+ if (typeof n.message == "string" && n.message) return n.message;
222
+ const a = n.result;
223
+ if (typeof a == "string" && a) return a;
224
+ if (a && typeof a == "object") {
225
+ const t = a.message;
226
+ if (typeof t == "string" && t) return t;
227
+ }
228
+ return null;
215
229
  }
216
- var Le = "ago-chat-widget-keyframes";
217
- function st() {
218
- if (typeof document > "u" || document.getElementById(Le)) return;
230
+ var ze = "ago-chat-widget-keyframes";
231
+ function bt() {
232
+ if (typeof document > "u" || document.getElementById(ze)) return;
219
233
  const o = document.createElement("style");
220
- o.id = Le, o.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(o);
234
+ o.id = ze, o.textContent = "@keyframes ago-pulse { 0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1); } }", document.head.appendChild(o);
221
235
  }
222
- function lt(o) {
236
+ function Ct(o) {
223
237
  const n = typeof o == "string" ? document.querySelector(o) : o;
224
238
  if (!n) throw new Error(`mountChatWidget: target "${String(o)}" not found.`);
225
239
  return n;
226
240
  }
227
- function ut(o, n) {
228
- const { title: r = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: u = "Type a message...", allowFiles: i = !1, height: f = 500, placement: s = "inline", width: p = 400, defaultOpen: c = !1, logoUrl: h, showAgentName: L = !1, theme: m, loadThreads: _ = !1, forms: X, onFollowUpClick: B, onMessageSent: N, onMessageReceived: me } = n;
229
- if (!n.client && !n.config?.baseUrl) throw new Ke("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
230
- const g = n.client ?? new Xe(n.config), xe = lt(o), z = s === "left" || s === "right", Be = z && (n.launcher ?? !0);
231
- let H = z ? c : !0;
232
- const J = n.persistConversation, K = J ? Qe(J === !0 ? {} : J) : void 0;
233
- let k = n.conversationId ?? K?.getLastActiveThread() ?? void 0, d = [], O = !1, W = null;
234
- const q = [], F = x({
241
+ function St(o, n) {
242
+ const { title: a = "Chat", welcomeMessage: t = "Hello! How can I help you today?", placeholder: u = "Type a message...", allowFiles: i = !1, height: f = 500, placement: l = "inline", width: p = 400, defaultOpen: c = !1, logoUrl: m, showAgentName: T = !1, theme: h, loadThreads: _ = !1, forms: X, formSubmittedMessage: L = Be, onFollowUpClick: $, onMessageSent: ye, onMessageReceived: J, onFormSubmitted: ee, onFormError: te } = n;
243
+ if (!n.client && !n.config?.baseUrl) throw new ot("mountChatWidget requires either `client` or `config` (with a baseUrl).", "config_missing_base_url");
244
+ const g = n.client ?? new nt(n.config), ve = Ct(o), B = l === "left" || l === "right", je = B && (n.launcher ?? !0);
245
+ let z = B ? c : !0;
246
+ const ne = n.persistConversation, K = ne ? st(ne === !0 ? {} : ne) : void 0;
247
+ let k = n.conversationId ?? K?.getLastActiveThread() ?? void 0, d = [], O = !1, P = null;
248
+ const Ee = [];
249
+ function Xe(e) {
250
+ if (typeof L == "function") {
251
+ const s = L(e);
252
+ if (typeof s == "string" && s) return s;
253
+ }
254
+ const r = xt(e);
255
+ return r || (typeof L == "string" ? L : Be);
256
+ }
257
+ const q = [], H = b({
235
258
  display: "flex",
236
259
  flexDirection: "column",
237
- height: z ? "100%" : typeof f == "number" ? `${f}px` : f,
238
- border: `1px solid ${$}`,
239
- borderRadius: at,
260
+ height: B ? "100%" : typeof f == "number" ? `${f}px` : f,
261
+ border: `1px solid ${I}`,
262
+ borderRadius: mt,
240
263
  overflow: "hidden",
241
264
  backgroundColor: j,
242
- fontFamily: ue,
265
+ fontFamily: xe,
243
266
  textAlign: "left",
244
267
  boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
245
268
  });
246
- F.className = "ago-chat-widget", it(F, m);
247
- const G = x({
269
+ H.className = "ago-chat-widget", ht(H, h);
270
+ const G = b({
248
271
  padding: "14px 16px",
249
- borderBottom: `1px solid ${$}`,
250
- backgroundColor: nt,
251
- color: Ie,
272
+ borderBottom: `1px solid ${I}`,
273
+ backgroundColor: ft,
274
+ color: Fe,
252
275
  display: "flex",
253
276
  alignItems: "center",
254
277
  gap: "10px"
255
278
  });
256
- if (G.className = "ago-chat-widget__header", h) {
279
+ if (G.className = "ago-chat-widget__header", m) {
257
280
  const e = document.createElement("img");
258
- e.src = h, e.alt = "Logo", y(e, {
281
+ e.src = m, e.alt = "Logo", E(e, {
259
282
  height: "24px",
260
283
  width: "auto"
261
284
  }), G.appendChild(e);
262
285
  }
263
- const ee = document.createElement("h3");
264
- if (ee.textContent = r, y(ee, {
286
+ const oe = document.createElement("h3");
287
+ if (oe.textContent = a, E(oe, {
265
288
  margin: "0",
266
289
  fontSize: "15px",
267
290
  fontWeight: "600"
268
- }), G.appendChild(ee), z) {
291
+ }), G.appendChild(oe), B) {
269
292
  const e = document.createElement("button");
270
- e.type = "button", e.className = "ago-chat-widget__close", e.setAttribute("aria-label", "Close"), e.textContent = "×", y(e, {
293
+ e.type = "button", e.className = "ago-chat-widget__close", e.setAttribute("aria-label", "Close"), e.textContent = "×", E(e, {
271
294
  marginLeft: "auto",
272
295
  background: "transparent",
273
296
  border: "none",
274
- color: Ie,
297
+ color: Fe,
275
298
  fontSize: "22px",
276
299
  lineHeight: "1",
277
300
  cursor: "pointer",
278
301
  padding: "0 2px"
279
- }), e.addEventListener("click", () => le()), G.appendChild(e);
302
+ }), e.addEventListener("click", () => pe()), G.appendChild(e);
280
303
  }
281
- const A = x({
304
+ const N = b({
282
305
  flex: "1",
283
306
  overflow: "auto",
284
307
  padding: "16px",
285
- backgroundColor: ot
308
+ backgroundColor: ut
286
309
  });
287
- A.className = "ago-chat-widget__messages";
288
- const { inputRow: ze, setDisabled: He, focus: te } = dt({
310
+ N.className = "ago-chat-widget__messages";
311
+ const { inputRow: Ke, setDisabled: qe, focus: re } = yt({
289
312
  placeholder: u,
290
313
  allowFiles: i,
291
- onSend: (e, a) => {
292
- re(e, a);
314
+ onSend: (e, r) => {
315
+ ie(e, r);
293
316
  }
294
317
  });
295
- st(), F.append(G, A, ze);
296
- let V = F, T, E;
297
- const ne = s === "left" ? "left" : "right";
298
- if (z && (T = x({
318
+ bt(), H.append(G, N, Ke);
319
+ let V = H, D, S;
320
+ const ae = l === "left" ? "left" : "right";
321
+ if (B && (D = b({
299
322
  position: "fixed",
300
323
  top: "0",
301
324
  bottom: "0",
302
- [ne]: "0",
325
+ [ae]: "0",
303
326
  width: typeof p == "number" ? `${p}px` : p,
304
327
  maxWidth: "100vw",
305
328
  display: "flex",
306
329
  zIndex: "2147483000",
307
330
  transition: "transform 0.3s ease",
308
331
  boxShadow: "rgba(15, 15, 15, 0.18) 0px 0px 24px 0px"
309
- }), T.className = "ago-chat-widget-panel", y(F, {
332
+ }), D.className = "ago-chat-widget-panel", E(H, {
310
333
  height: "100%",
311
334
  width: "100%",
312
335
  borderRadius: "0",
313
336
  border: "none",
314
337
  boxShadow: "none",
315
- [ne === "left" ? "borderRight" : "borderLeft"]: `1px solid ${$}`
316
- }), T.appendChild(F), V = T), Be) {
317
- if (E = document.createElement("button"), E.type = "button", E.className = "ago-chat-widget-launcher", E.setAttribute("aria-label", `Open ${r}`), y(E, {
338
+ [ae === "left" ? "borderRight" : "borderLeft"]: `1px solid ${I}`
339
+ }), D.appendChild(H), V = D), je) {
340
+ if (S = document.createElement("button"), S.type = "button", S.className = "ago-chat-widget-launcher", S.setAttribute("aria-label", `Open ${a}`), E(S, {
318
341
  position: "fixed",
319
342
  bottom: "20px",
320
- [ne]: "20px",
343
+ [ae]: "20px",
321
344
  width: "56px",
322
345
  height: "56px",
323
346
  borderRadius: "50%",
324
347
  border: "none",
325
- backgroundColor: ge,
326
- color: he,
348
+ backgroundColor: be,
349
+ color: Ce,
327
350
  cursor: "pointer",
328
351
  display: "flex",
329
352
  alignItems: "center",
330
353
  justifyContent: "center",
331
354
  zIndex: "2147483000",
332
355
  boxShadow: "rgba(15, 15, 15, 0.2) 0px 4px 14px 0px",
333
- fontFamily: ue
334
- }), h) {
356
+ fontFamily: xe
357
+ }), m) {
335
358
  const e = document.createElement("img");
336
- e.src = h, e.alt = "", y(e, {
359
+ e.src = m, e.alt = "", E(e, {
337
360
  width: "26px",
338
361
  height: "26px",
339
362
  objectFit: "contain"
340
- }), E.appendChild(e);
341
- } else E.appendChild(Ge());
342
- E.addEventListener("click", () => se());
363
+ }), S.appendChild(e);
364
+ } else S.appendChild(et());
365
+ S.addEventListener("click", () => ce());
343
366
  }
344
- xe.appendChild(V), E && xe.appendChild(E), ie();
345
- const be = B !== !1, Ce = B === !1 ? void 0 : B ?? ((e) => {
346
- re(e);
367
+ ve.appendChild(V), S && ve.appendChild(S), de();
368
+ const we = $ !== !1, Se = $ === !1 ? void 0 : $ ?? ((e) => {
369
+ ie(e);
347
370
  });
348
- function Fe(e, a) {
349
- const l = e.role === "user", S = x({
371
+ function Ve(e, r) {
372
+ const s = e.role === "user", x = b({
350
373
  display: "flex",
351
374
  flexDirection: "column",
352
- alignItems: l ? "flex-end" : "flex-start",
375
+ alignItems: s ? "flex-end" : "flex-start",
353
376
  marginBottom: "16px"
354
377
  });
355
- if (S.className = `ago-message ago-message--${e.role}`, !l && L && e.agent) {
356
- const b = x({
378
+ if (x.className = `ago-message ago-message--${e.role}`, !s && T && e.agent) {
379
+ const C = b({
357
380
  fontSize: "13px",
358
381
  fontWeight: "500",
359
382
  color: Y,
360
383
  marginBottom: "6px",
361
384
  padding: "0 4px"
362
385
  });
363
- b.className = "ago-message__agent", b.textContent = e.agent.displayName || e.agent.name, S.appendChild(b);
386
+ C.className = "ago-message__agent", C.textContent = e.agent.displayName || e.agent.name, x.appendChild(C);
364
387
  }
365
- if (!l && e.sources && e.sources.length > 0) {
366
- const b = x({
388
+ if (!s && e.sources && e.sources.length > 0) {
389
+ const C = b({
367
390
  display: "grid",
368
391
  gridTemplateColumns: "1fr 1fr",
369
392
  gap: "6px",
@@ -371,14 +394,14 @@ function ut(o, n) {
371
394
  width: "100%",
372
395
  maxWidth: "85%"
373
396
  });
374
- b.className = "ago-message__sources", e.sources.forEach((C, w) => {
375
- const D = C.url ? document.createElement("a") : document.createElement("div");
376
- C.url && D instanceof HTMLAnchorElement && (D.href = C.url, D.target = "_blank", D.rel = "noopener noreferrer"), y(D, {
397
+ C.className = "ago-message__sources", e.sources.forEach((y, w) => {
398
+ const M = y.url ? document.createElement("a") : document.createElement("div");
399
+ y.url && M instanceof HTMLAnchorElement && (M.href = y.url, M.target = "_blank", M.rel = "noopener noreferrer"), E(M, {
377
400
  display: "flex",
378
401
  alignItems: "center",
379
402
  gap: "8px",
380
403
  padding: "8px 10px",
381
- border: `1px solid ${$}`,
404
+ border: `1px solid ${I}`,
382
405
  borderRadius: "8px",
383
406
  backgroundColor: j,
384
407
  textDecoration: "none",
@@ -386,13 +409,13 @@ function ut(o, n) {
386
409
  fontSize: "12px",
387
410
  overflow: "hidden"
388
411
  });
389
- const _e = x({
412
+ const Oe = b({
390
413
  flexShrink: "0",
391
414
  width: "18px",
392
415
  height: "18px",
393
416
  borderRadius: "3px",
394
- border: `1px solid ${ce}`,
395
- color: ce,
417
+ border: `1px solid ${ue}`,
418
+ color: ue,
396
419
  fontSize: "11px",
397
420
  fontWeight: "500",
398
421
  display: "flex",
@@ -400,69 +423,89 @@ function ut(o, n) {
400
423
  justifyContent: "center",
401
424
  backgroundColor: "#f0f4ff"
402
425
  });
403
- _e.textContent = String(w + 1);
404
- const de = x({
426
+ Oe.textContent = String(w + 1);
427
+ const fe = b({
405
428
  overflow: "hidden",
406
429
  textOverflow: "ellipsis",
407
430
  whiteSpace: "nowrap"
408
431
  });
409
- de.textContent = C.title, de.title = C.title, D.append(_e, de), b.appendChild(D);
410
- }), S.appendChild(b);
432
+ fe.textContent = y.title, fe.title = y.title, M.append(Oe, fe), C.appendChild(M);
433
+ }), x.appendChild(C);
411
434
  }
412
- const v = x({
413
- maxWidth: l ? "75%" : "100%",
414
- padding: l ? "10px 14px" : "2px 8px",
415
- borderRadius: l ? Ae : "0",
416
- backgroundColor: l ? ge : "transparent",
417
- color: l ? he : Y,
435
+ const v = b({
436
+ maxWidth: s ? "75%" : "100%",
437
+ padding: s ? "10px 14px" : "2px 8px",
438
+ borderRadius: s ? ge : "0",
439
+ backgroundColor: s ? be : "transparent",
440
+ color: s ? Ce : Y,
418
441
  wordBreak: "break-word",
419
- fontSize: "14px",
442
+ fontSize: "16px",
420
443
  lineHeight: "1.6"
421
444
  });
422
- if (v.className = "ago-message__content", e.content ? v.appendChild(fe(e.content)) : e.status === "IN_PROGRESS" && v.appendChild(je()), S.appendChild(v), a && e.followUpReplies && e.followUpReplies.length > 0) {
423
- const b = x({
445
+ if (v.className = "ago-message__content", e.content ? v.appendChild(he(e.content)) : e.status === "IN_PROGRESS" && v.appendChild(tt()), x.appendChild(v), r && e.followUpReplies && e.followUpReplies.length > 0) {
446
+ const C = b({
424
447
  display: "flex",
425
448
  flexWrap: "wrap",
426
449
  gap: "8px",
427
450
  marginTop: "10px"
428
451
  });
429
- b.className = "ago-message__followups";
430
- for (const C of e.followUpReplies) {
452
+ C.className = "ago-message__followups";
453
+ for (const y of e.followUpReplies) {
431
454
  const w = document.createElement("button");
432
- w.type = "button", w.className = "ago-message__followup-btn", w.textContent = C, w.disabled = !be, y(w, {
455
+ w.type = "button", w.className = "ago-message__followup-btn", w.textContent = y, w.disabled = !we, E(w, {
433
456
  padding: "6px 14px",
434
457
  fontSize: "14px",
435
- borderRadius: Ae,
436
- border: `1px solid ${$}`,
458
+ borderRadius: ge,
459
+ border: `1px solid ${I}`,
437
460
  backgroundColor: j,
438
461
  color: Y,
439
- cursor: be ? "pointer" : "default",
462
+ cursor: we ? "pointer" : "default",
440
463
  transition: "border-color 0.15s"
441
- }), Ce && w.addEventListener("click", () => Ce(C)), w.addEventListener("mouseenter", () => {
442
- w.style.borderColor = ce;
464
+ }), Se && w.addEventListener("click", () => Se(y)), w.addEventListener("mouseenter", () => {
465
+ w.style.borderColor = ue;
443
466
  }), w.addEventListener("mouseleave", () => {
444
- w.style.borderColor = $;
445
- }), b.appendChild(w);
467
+ w.style.borderColor = I;
468
+ }), C.appendChild(w);
446
469
  }
447
- S.appendChild(b);
470
+ x.appendChild(C);
448
471
  }
449
- return S;
472
+ return x;
450
473
  }
451
- function I() {
452
- if (A.replaceChildren(), d.length === 0) {
453
- const a = x({
474
+ function Qe(e) {
475
+ const r = b({
476
+ display: "flex",
477
+ alignItems: "center",
478
+ gap: "8px",
479
+ padding: "10px 14px",
480
+ backgroundColor: "#f0fdf4",
481
+ color: "#15803d",
482
+ borderRadius: ge,
483
+ marginTop: "8px",
484
+ fontSize: "13px",
485
+ border: "1px solid #bbf7d0"
486
+ });
487
+ r.className = "ago-form-notice", r.setAttribute("role", "status");
488
+ const s = document.createElement("span");
489
+ s.textContent = "✓", s.setAttribute("aria-hidden", "true"), E(s, { fontWeight: "700" });
490
+ const x = document.createElement("span");
491
+ return x.textContent = e, r.append(s, x), r;
492
+ }
493
+ function A() {
494
+ if (N.replaceChildren(), d.length === 0) {
495
+ const r = b({
454
496
  textAlign: "center",
455
- color: rt,
497
+ color: gt,
456
498
  padding: "24px 16px",
457
- fontSize: "14px",
499
+ fontSize: "16px",
458
500
  lineHeight: "1.5"
459
501
  });
460
- a.appendChild(fe(t)), A.appendChild(a);
461
- } else d.forEach((a, l) => {
462
- A.appendChild(Fe(a, l === d.length - 1));
502
+ r.appendChild(he(t)), N.appendChild(r);
503
+ } else d.forEach((r, s) => {
504
+ N.appendChild(Ve(r, s === d.length - 1));
463
505
  });
464
- if (W) {
465
- const a = x({
506
+ for (const r of Ee) N.appendChild(Qe(r));
507
+ if (P) {
508
+ const r = b({
466
509
  padding: "10px 14px",
467
510
  backgroundColor: "#fef2f2",
468
511
  color: "#dc2626",
@@ -471,79 +514,88 @@ function ut(o, n) {
471
514
  fontSize: "13px",
472
515
  border: "1px solid #fecaca"
473
516
  });
474
- a.textContent = W, A.appendChild(a);
517
+ r.textContent = P, N.appendChild(r);
475
518
  }
476
- A.scrollTop = A.scrollHeight;
519
+ N.scrollTop = N.scrollHeight;
477
520
  const e = d[d.length - 1];
478
- He(O && e?.role === "assistant" && e.status === "IN_PROGRESS");
521
+ qe(O && e?.role === "assistant" && e.status === "IN_PROGRESS");
479
522
  }
480
- function Ue() {
523
+ function Ye() {
481
524
  for (let e = d.length - 1; e >= 0; e--) {
482
- const a = d[e];
483
- if (a.role === "assistant" && a.status === "IN_PROGRESS") return a;
525
+ const r = d[e];
526
+ if (r.role === "assistant" && r.status === "IN_PROGRESS") return r;
484
527
  }
485
528
  }
486
- const ve = (e) => {
529
+ const Re = (e) => {
487
530
  k || (k = e.conversationId);
488
- }, we = (e) => {
489
- const a = Ue();
490
- a && (a.content += e.content, I());
491
- }, ye = (e) => {
492
- const a = d.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
493
- a >= 0 ? d[a] = e : d.push(e), I(), te();
494
- }, Ee = (e) => {
495
- const a = d.findIndex((l) => l.id === e.id || l.role === "assistant" && l.status === "IN_PROGRESS");
496
- a >= 0 ? d[a] = e : d.push(e), O = !1, I(), e.status === "DONE" && me?.({
531
+ }, _e = (e) => {
532
+ const r = Ye();
533
+ r && (r.content += e.content, A());
534
+ }, ke = (e) => {
535
+ const r = d.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
536
+ r >= 0 ? d[r] = e : d.push(e), A(), re();
537
+ }, Ae = (e) => {
538
+ const r = d.findIndex((s) => s.id === e.id || s.role === "assistant" && s.status === "IN_PROGRESS");
539
+ r >= 0 ? d[r] = e : d.push(e), O = !1, A(), e.status === "DONE" && J?.({
497
540
  id: e.id,
498
541
  content: e.content
499
542
  });
500
- }, Se = (e) => {
501
- W = e.error, O = !1, d = d.filter((a) => !a.id.startsWith("temp-")), I();
543
+ }, Ie = (e) => {
544
+ P = e.error, O = !1, d = d.filter((r) => !r.id.startsWith("temp-")), A();
502
545
  };
503
- g.on("message:start", ve), g.on("message:chunk", we), g.on("message:answer-complete", ye), g.on("message:complete", Ee), g.on("message:error", Se);
504
- const oe = [];
505
- let Re = !1;
506
- for (const e of X ?? []) e.schema != null ? oe.push(Ve(e).install(g)) : qe(g, e).then((a) => {
507
- Re || oe.push(a.install(g));
508
- }).catch(() => {
546
+ g.on("message:start", Re), g.on("message:chunk", _e), g.on("message:answer-complete", ke), g.on("message:complete", Ae), g.on("message:error", Ie);
547
+ const $e = (e) => ee?.(e), Ne = (e) => te?.(e);
548
+ ee && g.on("form:submitted", $e), te && g.on("form:error", Ne);
549
+ const se = [];
550
+ let Te = !1;
551
+ const Le = (e) => {
552
+ if (Te) return;
553
+ se.push(e.install(g));
554
+ let r = e.store.get().submitted;
555
+ const s = e.store.subscribe((x) => {
556
+ x.submitted && !r && (Ee.push(Xe(x.submitResult)), A()), r = x.submitted;
557
+ });
558
+ se.push(s);
559
+ };
560
+ for (const e of X ?? []) e.schema != null ? Le(at(e)) : rt(g, e).then((r) => Le(r)).catch(() => {
509
561
  });
510
- async function re(e, a) {
511
- const l = e.trim();
512
- if (!l && !a?.length || O) return;
513
- N?.(l), O = !0, W = null;
514
- const S = Date.now();
562
+ async function ie(e, r) {
563
+ const s = e.trim();
564
+ if (!s && !r?.length || O) return;
565
+ ye?.(s), O = !0, P = null;
566
+ const x = Date.now();
515
567
  d.push({
516
- id: `temp-user-${S}`,
568
+ id: `temp-user-${x}`,
517
569
  conversationId: k || "",
518
- content: l,
570
+ content: s,
519
571
  role: "user",
520
572
  status: "DONE",
521
573
  createdAt: /* @__PURE__ */ new Date()
522
574
  }), d.push({
523
- id: `temp-assistant-${S}`,
575
+ id: `temp-assistant-${x}`,
524
576
  conversationId: k || "",
525
577
  content: "",
526
578
  role: "assistant",
527
579
  status: "IN_PROGRESS",
528
580
  createdAt: /* @__PURE__ */ new Date()
529
- }), I();
581
+ }), A();
530
582
  try {
531
- const v = await g.sendMessage(l, {
583
+ const v = await g.sendMessage(s, {
532
584
  conversationId: k,
533
- files: a
585
+ files: r
534
586
  });
535
587
  v.conversationId && (k || (k = v.conversationId), K?.setActiveThread(v.conversationId, v.createdAt));
536
- const b = d.find((C) => C.id === `temp-user-${S}`);
537
- if (b && (b.id = `user-${S}`, b.conversationId = v.conversationId), !d.some((C) => C.id === v.id)) {
538
- const C = d.findIndex((w) => w.id === `temp-assistant-${S}`);
539
- C >= 0 ? d[C] = v : d.push(v);
588
+ const C = d.find((y) => y.id === `temp-user-${x}`);
589
+ if (C && (C.id = `user-${x}`, C.conversationId = v.conversationId), !d.some((y) => y.id === v.id)) {
590
+ const y = d.findIndex((w) => w.id === `temp-assistant-${x}`);
591
+ y >= 0 ? d[y] = v : d.push(v);
540
592
  }
541
- d = d.filter((C) => !C.id.startsWith("temp-")), O = !1, I(), _ && ae();
593
+ d = d.filter((y) => !y.id.startsWith("temp-")), O = !1, A(), _ && le();
542
594
  } catch (v) {
543
- W = v instanceof Error ? v.message : "Failed to send message", O = !1, d = d.filter((b) => !b.id.startsWith("temp-")), I();
595
+ P = v instanceof Error ? v.message : "Failed to send message", O = !1, d = d.filter((C) => !C.id.startsWith("temp-")), A();
544
596
  }
545
597
  }
546
- async function ae() {
598
+ async function le() {
547
599
  try {
548
600
  const e = await g.getConversations();
549
601
  q.splice(0, q.length, ...e);
@@ -551,173 +603,173 @@ function ut(o, n) {
551
603
  }
552
604
  return q;
553
605
  }
554
- async function Pe(e) {
606
+ async function Ze(e) {
555
607
  try {
556
- const a = (await g.getConversation(e))?.messages ?? [];
557
- a.length > 0 && d.length === 0 && (d = a, I());
608
+ const r = (await g.getConversation(e))?.messages ?? [];
609
+ r.length > 0 && d.length === 0 && (d = r, A());
558
610
  } catch {
559
611
  d.length === 0 && (K?.clear(), k = void 0);
560
612
  }
561
613
  }
562
- return I(), te(), k && Pe(k), _ && ae(), {
614
+ return A(), re(), k && Ze(k), _ && le(), {
563
615
  client: g,
564
616
  element: V,
565
- sendMessage: re,
566
- ...z ? {
567
- open: se,
568
- close: le,
569
- toggle: We
617
+ sendMessage: ie,
618
+ ...B ? {
619
+ open: ce,
620
+ close: pe,
621
+ toggle: Je
570
622
  } : {},
571
623
  session: K,
572
624
  threads: q,
573
- refreshThreads: ae,
625
+ refreshThreads: le,
574
626
  destroy() {
575
- g.off("message:start", ve), g.off("message:chunk", we), g.off("message:answer-complete", ye), g.off("message:complete", Ee), g.off("message:error", Se), Re = !0, oe.forEach((e) => e()), V.remove(), E?.remove(), n.client || g.destroy();
627
+ g.off("message:start", Re), g.off("message:chunk", _e), g.off("message:answer-complete", ke), g.off("message:complete", Ae), g.off("message:error", Ie), ee && g.off("form:submitted", $e), te && g.off("form:error", Ne), Te = !0, se.forEach((e) => e()), V.remove(), S?.remove(), n.client || g.destroy();
576
628
  }
577
629
  };
578
- function ie() {
579
- if (!T) return;
580
- const e = s === "left" ? "translateX(-100%)" : "translateX(100%)";
581
- T.style.transform = H ? "translateX(0)" : e, T.setAttribute("aria-hidden", H ? "false" : "true"), E && (E.style.display = H ? "none" : "flex");
630
+ function de() {
631
+ if (!D) return;
632
+ const e = l === "left" ? "translateX(-100%)" : "translateX(100%)";
633
+ D.style.transform = z ? "translateX(0)" : e, D.setAttribute("aria-hidden", z ? "false" : "true"), S && (S.style.display = z ? "none" : "flex");
582
634
  }
583
- function se() {
584
- H = !0, ie(), te();
635
+ function ce() {
636
+ z = !0, de(), re();
585
637
  }
586
- function le() {
587
- H = !1, ie();
638
+ function pe() {
639
+ z = !1, de();
588
640
  }
589
- function We() {
590
- H ? le() : se();
641
+ function Je() {
642
+ z ? pe() : ce();
591
643
  }
592
- function Ge() {
593
- const e = "http://www.w3.org/2000/svg", a = document.createElementNS(e, "svg");
594
- a.setAttribute("width", "26"), a.setAttribute("height", "26"), a.setAttribute("viewBox", "0 0 24 24"), a.setAttribute("fill", "none");
595
- const l = document.createElementNS(e, "path");
596
- return l.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"), l.setAttribute("stroke", "currentColor"), l.setAttribute("stroke-width", "2"), l.setAttribute("stroke-linecap", "round"), l.setAttribute("stroke-linejoin", "round"), a.appendChild(l), a;
644
+ function et() {
645
+ const e = "http://www.w3.org/2000/svg", r = document.createElementNS(e, "svg");
646
+ r.setAttribute("width", "26"), r.setAttribute("height", "26"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none");
647
+ const s = document.createElementNS(e, "path");
648
+ return s.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"), s.setAttribute("stroke", "currentColor"), s.setAttribute("stroke-width", "2"), s.setAttribute("stroke-linecap", "round"), s.setAttribute("stroke-linejoin", "round"), r.appendChild(s), r;
597
649
  }
598
- function je() {
599
- const e = x({
650
+ function tt() {
651
+ const e = b({
600
652
  display: "flex",
601
653
  gap: "4px",
602
654
  padding: "4px 0"
603
655
  });
604
- for (let a = 0; a < 3; a++) {
605
- const l = x({
656
+ for (let r = 0; r < 3; r++) {
657
+ const s = b({
606
658
  width: "6px",
607
659
  height: "6px",
608
660
  borderRadius: "50%",
609
661
  backgroundColor: "#b5bfc8",
610
662
  animation: "ago-pulse 1.2s ease-in-out infinite",
611
- animationDelay: `${a * 0.2}s`
663
+ animationDelay: `${r * 0.2}s`
612
664
  });
613
- e.appendChild(l);
665
+ e.appendChild(s);
614
666
  }
615
667
  return e;
616
668
  }
617
669
  }
618
- function dt(o) {
670
+ function yt(o) {
619
671
  let n = [];
620
- const r = document.createElement("form");
621
- y(r, {
672
+ const a = document.createElement("form");
673
+ E(a, {
622
674
  display: "flex",
623
675
  flexDirection: "column",
624
676
  gap: "8px",
625
677
  padding: "12px",
626
- borderTop: `1px solid ${$}`,
678
+ borderTop: `1px solid ${I}`,
627
679
  backgroundColor: j
628
- }), r.className = "ago-chat-input";
629
- const t = x({
680
+ }), a.className = "ago-chat-input";
681
+ const t = b({
630
682
  display: "flex",
631
683
  flexWrap: "wrap",
632
684
  gap: "6px"
633
- }), u = x({
685
+ }), u = b({
634
686
  display: "flex",
635
687
  gap: "8px",
636
688
  alignItems: "flex-end"
637
689
  }), i = document.createElement("textarea");
638
- i.placeholder = o.placeholder, i.rows = 1, y(i, {
690
+ i.placeholder = o.placeholder, i.rows = 1, E(i, {
639
691
  flex: "1",
640
692
  resize: "none",
641
693
  padding: "10px 12px",
642
- border: `1px solid ${$}`,
694
+ border: `1px solid ${I}`,
643
695
  borderRadius: "12px",
644
- fontSize: "14px",
645
- fontFamily: ue,
696
+ fontSize: "16px",
697
+ fontFamily: xe,
646
698
  lineHeight: "1.4",
647
699
  maxHeight: "120px",
648
700
  outline: "none"
649
701
  });
650
702
  const f = document.createElement("button");
651
- f.type = "submit", f.textContent = "Send", y(f, {
703
+ f.type = "submit", f.textContent = "Send", E(f, {
652
704
  padding: "10px 16px",
653
705
  border: "none",
654
706
  borderRadius: "12px",
655
- backgroundColor: ge,
656
- color: he,
657
- fontSize: "14px",
707
+ backgroundColor: be,
708
+ color: Ce,
709
+ fontSize: "16px",
658
710
  fontWeight: "500",
659
711
  cursor: "pointer"
660
712
  });
661
- let s = null, p = null;
662
- o.allowFiles && (s = document.createElement("input"), s.type = "file", s.multiple = !0, y(s, { display: "none" }), p = document.createElement("button"), p.type = "button", p.textContent = "📎", y(p, {
713
+ let l = null, p = null;
714
+ o.allowFiles && (l = document.createElement("input"), l.type = "file", l.multiple = !0, E(l, { display: "none" }), p = document.createElement("button"), p.type = "button", p.textContent = "📎", E(p, {
663
715
  padding: "10px 12px",
664
- border: `1px solid ${$}`,
716
+ border: `1px solid ${I}`,
665
717
  borderRadius: "12px",
666
718
  backgroundColor: j,
667
719
  cursor: "pointer",
668
720
  fontSize: "14px"
669
- }), p.addEventListener("click", () => s?.click()), s.addEventListener("change", () => {
670
- n = [...n, ...Array.from(s?.files ?? [])], c();
721
+ }), p.addEventListener("click", () => l?.click()), l.addEventListener("change", () => {
722
+ n = [...n, ...Array.from(l?.files ?? [])], c();
671
723
  }));
672
724
  function c() {
673
- t.replaceChildren(), n.forEach((m, _) => {
674
- const X = x({
725
+ t.replaceChildren(), n.forEach((h, _) => {
726
+ const X = b({
675
727
  display: "flex",
676
728
  alignItems: "center",
677
729
  gap: "4px",
678
730
  padding: "4px 8px",
679
731
  backgroundColor: "#f0f4ff",
680
- border: `1px solid ${$}`,
732
+ border: `1px solid ${I}`,
681
733
  borderRadius: "8px",
682
734
  fontSize: "12px"
683
- }), B = document.createElement("span");
684
- B.textContent = m.name;
685
- const N = document.createElement("button");
686
- N.type = "button", N.textContent = "×", y(N, {
735
+ }), L = document.createElement("span");
736
+ L.textContent = h.name;
737
+ const $ = document.createElement("button");
738
+ $.type = "button", $.textContent = "×", E($, {
687
739
  border: "none",
688
740
  background: "transparent",
689
741
  cursor: "pointer",
690
742
  fontSize: "14px",
691
743
  lineHeight: "1"
692
- }), N.addEventListener("click", () => {
693
- n = n.filter((me, g) => g !== _), c();
694
- }), X.append(B, N), t.appendChild(X);
744
+ }), $.addEventListener("click", () => {
745
+ n = n.filter((ye, J) => J !== _), c();
746
+ }), X.append(L, $), t.appendChild(X);
695
747
  });
696
748
  }
697
- const h = () => {
698
- const m = i.value, _ = n;
749
+ const m = () => {
750
+ const h = i.value, _ = n;
699
751
  return i.value = "", n = [], c(), {
700
- content: m,
752
+ content: h,
701
753
  files: _
702
754
  };
703
- }, L = () => {
704
- const { content: m, files: _ } = h();
705
- (m.trim() || _.length > 0) && o.onSend(m.trim(), _.length > 0 ? _ : void 0);
755
+ }, T = () => {
756
+ const { content: h, files: _ } = m();
757
+ (h.trim() || _.length > 0) && o.onSend(h.trim(), _.length > 0 ? _ : void 0);
706
758
  };
707
- return r.addEventListener("submit", (m) => {
708
- m.preventDefault(), L();
709
- }), i.addEventListener("keydown", (m) => {
710
- m.key === "Enter" && !m.shiftKey && (m.preventDefault(), L());
711
- }), p && u.appendChild(p), u.append(i, f), s && r.appendChild(s), r.append(t, u), {
712
- inputRow: r,
713
- getValueAndClear: h,
714
- setDisabled: (m) => {
715
- i.disabled = m, f.disabled = m, f.style.opacity = m ? "0.6" : "1", f.style.cursor = m ? "not-allowed" : "pointer";
759
+ return a.addEventListener("submit", (h) => {
760
+ h.preventDefault(), T();
761
+ }), i.addEventListener("keydown", (h) => {
762
+ h.key === "Enter" && !h.shiftKey && (h.preventDefault(), T());
763
+ }), p && u.appendChild(p), u.append(i, f), l && a.appendChild(l), a.append(t, u), {
764
+ inputRow: a,
765
+ getValueAndClear: m,
766
+ setDisabled: (h) => {
767
+ i.disabled = h, f.disabled = h, f.style.opacity = h ? "0.6" : "1", f.style.cursor = h ? "not-allowed" : "pointer";
716
768
  },
717
769
  focus: () => i.focus()
718
770
  };
719
771
  }
720
772
  export {
721
- ut as mountChatWidget,
722
- fe as renderMarkdown
773
+ St as mountChatWidget,
774
+ he as renderMarkdown
723
775
  };