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