@useago/sdk 1.0.11 → 1.2.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.
- package/dist/{AgoClient-QcTtrN7u.js → AgoClient-Cwx_eYSu.js} +182 -131
- package/dist/AgoClient-CzSmJQxl.cjs +6 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +23 -0
- package/dist/angular.d.ts +23 -0
- package/dist/angular.js +1 -1
- package/dist/{createConversationSession-CR-71aLR.js → createConversationSession-B3h567tt.js} +1 -1
- package/dist/{createConversationSession-C0diFTUk.cjs → createConversationSession-DV0Xp_3O.cjs} +1 -1
- package/dist/{createFormCollector-BI3DXaew.cjs → createFormCollector-BB3Uscuo.cjs} +1 -1
- package/dist/{createFormCollector-CFt1_QSL.js → createFormCollector-CyWisAkI.js} +1 -1
- package/dist/devtools.d.cts +23 -0
- package/dist/devtools.d.ts +23 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +43 -11
- package/dist/index.d.ts +43 -11
- package/dist/index.js +58 -55
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +23 -0
- package/dist/react.d.ts +23 -0
- package/dist/react.js +388 -295
- package/dist/testing.d.cts +23 -0
- package/dist/testing.d.ts +23 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +119 -0
- package/dist/vue.d.ts +119 -0
- package/dist/vue.js +1 -1
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +65 -16
- package/dist/widget.d.ts +65 -16
- package/dist/widget.js +865 -617
- package/package.json +1 -1
- package/dist/AgoClient-B3-WGVne.cjs +0 -6
package/dist/react.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { i as
|
|
3
|
-
import { t as
|
|
4
|
-
import
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
function
|
|
9
|
-
const [t, r] = M(!1), n = A(null),
|
|
1
|
+
import { a as J, i as j, o as G, s as V, t as Y } from "./AgoClient-Cwx_eYSu.js";
|
|
2
|
+
import { i as X, n as Fe, r as H, t as L } from "./createFormCollector-CyWisAkI.js";
|
|
3
|
+
import { t as _e } from "./createMockClient-DwdxNwEn.js";
|
|
4
|
+
import Q, { createContext as Z, useCallback as R, useContext as $, useEffect as k, useId as ee, useMemo as _, useRef as A, useState as M, useSyncExternalStore as te } from "react";
|
|
5
|
+
import { Fragment as O, jsx as o, jsxs as I } from "react/jsx-runtime";
|
|
6
|
+
import ne from "react-markdown";
|
|
7
|
+
import re from "remark-gfm";
|
|
8
|
+
function oe(e) {
|
|
9
|
+
const [t, r] = M(!1), n = A(null), a = _(() => {
|
|
10
10
|
if (n.current && (n.current.destroy(), n.current = null), !e) return null;
|
|
11
|
-
const i = new
|
|
11
|
+
const i = new Y(e);
|
|
12
12
|
return n.current = i, i;
|
|
13
13
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
14
|
return k(() => (r(!0), () => {
|
|
15
15
|
n.current?.destroy(), n.current = null;
|
|
16
|
-
}), [
|
|
16
|
+
}), [a]), k(() => {
|
|
17
17
|
n.current && e && n.current.updateConfig({
|
|
18
18
|
agent: e.agent,
|
|
19
19
|
defaultAgentId: e.defaultAgentId,
|
|
@@ -32,12 +32,12 @@ function ee(e) {
|
|
|
32
32
|
e?.debug,
|
|
33
33
|
e?.warnOnEmptyReply
|
|
34
34
|
]), {
|
|
35
|
-
client:
|
|
35
|
+
client: a,
|
|
36
36
|
isReady: t
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
var D =
|
|
40
|
-
const { client: u } =
|
|
39
|
+
var D = Z(null), Pe = ({ children: e, client: t, tools: r, helpers: n, pageContext: a, ...i }) => {
|
|
40
|
+
const { client: u } = oe(t ? null : i), l = t || u;
|
|
41
41
|
return k(() => {
|
|
42
42
|
if (!(!r || r.length === 0)) {
|
|
43
43
|
for (const f of r) l.register(f);
|
|
@@ -48,11 +48,11 @@ var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageConte
|
|
|
48
48
|
}, [l, r]), k(() => {
|
|
49
49
|
if (!n) return;
|
|
50
50
|
const f = [];
|
|
51
|
-
return import("./functions-CApuQZ2b.js").then((
|
|
52
|
-
for (const [
|
|
53
|
-
const C =
|
|
51
|
+
return import("./functions-CApuQZ2b.js").then((c) => c.n).then((c) => {
|
|
52
|
+
for (const [b, m] of Object.entries(n)) {
|
|
53
|
+
const C = c[b];
|
|
54
54
|
if (!C) {
|
|
55
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
55
|
+
console.warn(`[AGO] Unknown helper: "${b}"`);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
58
|
const g = m === !0 ? C : {
|
|
@@ -62,91 +62,92 @@ var D = V(null), Te = ({ children: e, client: t, tools: r, helpers: n, pageConte
|
|
|
62
62
|
l.register(g), f.push(g.name);
|
|
63
63
|
}
|
|
64
64
|
}), () => {
|
|
65
|
-
for (const
|
|
65
|
+
for (const c of f) l.unregisterFunction(c);
|
|
66
66
|
};
|
|
67
67
|
}, [l, n]), k(() => {
|
|
68
|
-
|
|
69
|
-
}, [l,
|
|
68
|
+
a === "auto" && l.enableAutoPageContext();
|
|
69
|
+
}, [l, a]), /* @__PURE__ */ o(D.Provider, {
|
|
70
70
|
value: l,
|
|
71
71
|
children: e
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
|
-
function
|
|
74
|
+
function T() {
|
|
75
75
|
const e = $(D);
|
|
76
76
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
77
77
|
return e;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function W() {
|
|
80
80
|
return $(D);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const r =
|
|
82
|
+
function B({ client: e, conversationId: t } = {}) {
|
|
83
|
+
const r = W(), n = e || r;
|
|
84
84
|
if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
85
|
-
const [
|
|
85
|
+
const [a, i] = M([]), [u, l] = M(t), [f, c] = M(!1), [b, m] = M(null);
|
|
86
86
|
k(() => {
|
|
87
87
|
t && t !== u && (l(t), C(t));
|
|
88
88
|
}, [t]);
|
|
89
89
|
const C = async (g) => {
|
|
90
90
|
try {
|
|
91
91
|
i(await n.getMessages(g));
|
|
92
|
-
} catch (
|
|
93
|
-
m(
|
|
92
|
+
} catch (x) {
|
|
93
|
+
m(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
96
|
return k(() => {
|
|
97
97
|
const g = (p) => {
|
|
98
98
|
u || l(p.conversationId);
|
|
99
|
-
},
|
|
100
|
-
i((
|
|
101
|
-
const
|
|
102
|
-
return
|
|
103
|
-
...
|
|
104
|
-
content:
|
|
105
|
-
}] :
|
|
99
|
+
}, x = (p) => {
|
|
100
|
+
i((d) => {
|
|
101
|
+
const h = d[d.length - 1];
|
|
102
|
+
return h && h.id === p.messageId ? [...d.slice(0, -1), {
|
|
103
|
+
...h,
|
|
104
|
+
content: h.content + p.content
|
|
105
|
+
}] : d;
|
|
106
106
|
});
|
|
107
107
|
}, v = (p) => {
|
|
108
|
-
i((
|
|
109
|
-
let
|
|
110
|
-
for (let S =
|
|
111
|
-
|
|
108
|
+
i((d) => {
|
|
109
|
+
let h = -1;
|
|
110
|
+
for (let S = d.length - 1; S >= 0; S--) if (d[S].role === "assistant" && d[S].status === "IN_PROGRESS") {
|
|
111
|
+
h = S;
|
|
112
112
|
break;
|
|
113
113
|
}
|
|
114
|
-
return
|
|
115
|
-
...
|
|
114
|
+
return h < 0 ? d : [
|
|
115
|
+
...d.slice(0, h),
|
|
116
116
|
{
|
|
117
|
-
...
|
|
117
|
+
...d[h],
|
|
118
118
|
...p
|
|
119
119
|
},
|
|
120
|
-
...
|
|
120
|
+
...d.slice(h + 1)
|
|
121
121
|
];
|
|
122
122
|
});
|
|
123
123
|
}, w = (p) => {
|
|
124
|
-
i((
|
|
125
|
-
const
|
|
126
|
-
return
|
|
127
|
-
...
|
|
124
|
+
i((d) => {
|
|
125
|
+
const h = d.findIndex((S) => S.id === p.id);
|
|
126
|
+
return h >= 0 ? [
|
|
127
|
+
...d.slice(0, h),
|
|
128
128
|
p,
|
|
129
|
-
...
|
|
130
|
-
] : [...
|
|
131
|
-
}),
|
|
132
|
-
},
|
|
133
|
-
m(new Error(p.error)),
|
|
129
|
+
...d.slice(h + 1)
|
|
130
|
+
] : [...d, p];
|
|
131
|
+
}), c(!1);
|
|
132
|
+
}, s = (p) => {
|
|
133
|
+
m(new Error(p.error)), c(!1);
|
|
134
134
|
};
|
|
135
|
-
return n.on("message:start", g), n.on("message:chunk",
|
|
136
|
-
n.off("message:start", g), n.off("message:chunk",
|
|
135
|
+
return n.on("message:start", g), n.on("message:chunk", x), n.on("message:answer-complete", v), n.on("message:complete", w), n.on("message:error", s), () => {
|
|
136
|
+
n.off("message:start", g), n.off("message:chunk", x), n.off("message:answer-complete", v), n.off("message:complete", w), n.off("message:error", s);
|
|
137
137
|
};
|
|
138
138
|
}, [n, u]), {
|
|
139
|
-
messages:
|
|
139
|
+
messages: a,
|
|
140
140
|
isLoading: f,
|
|
141
|
-
error:
|
|
142
|
-
sendMessage:
|
|
143
|
-
|
|
141
|
+
error: b,
|
|
142
|
+
sendMessage: R(async (g, x) => {
|
|
143
|
+
c(!0), m(null);
|
|
144
144
|
const v = {
|
|
145
145
|
id: `temp-${Date.now()}`,
|
|
146
146
|
conversationId: u || "",
|
|
147
147
|
content: g,
|
|
148
148
|
role: "user",
|
|
149
149
|
status: "DONE",
|
|
150
|
+
attachments: x && x.length > 0 ? j(x) : void 0,
|
|
150
151
|
createdAt: /* @__PURE__ */ new Date()
|
|
151
152
|
}, w = {
|
|
152
153
|
id: `temp-assistant-${Date.now()}`,
|
|
@@ -156,62 +157,62 @@ function O({ client: e, conversationId: t } = {}) {
|
|
|
156
157
|
status: "IN_PROGRESS",
|
|
157
158
|
createdAt: /* @__PURE__ */ new Date()
|
|
158
159
|
};
|
|
159
|
-
i((
|
|
160
|
-
...
|
|
160
|
+
i((s) => [
|
|
161
|
+
...s,
|
|
161
162
|
v,
|
|
162
163
|
w
|
|
163
164
|
]);
|
|
164
165
|
try {
|
|
165
|
-
const
|
|
166
|
+
const s = await n.sendMessage(g, {
|
|
166
167
|
conversationId: u,
|
|
167
|
-
files:
|
|
168
|
+
files: x
|
|
168
169
|
});
|
|
169
|
-
return
|
|
170
|
-
const
|
|
170
|
+
return s.conversationId && !u && l(s.conversationId), i((p) => {
|
|
171
|
+
const d = p.filter((S) => !S.id.startsWith("temp-")), h = {
|
|
171
172
|
...v,
|
|
172
173
|
id: v.id.replace("temp-", "user-"),
|
|
173
|
-
conversationId:
|
|
174
|
+
conversationId: s.conversationId
|
|
174
175
|
};
|
|
175
|
-
return
|
|
176
|
-
...
|
|
177
|
-
|
|
178
|
-
|
|
176
|
+
return d.some((S) => S.id === s.id) ? [...d, h].sort((S, z) => new Date(S.createdAt).getTime() - new Date(z.createdAt).getTime()) : [
|
|
177
|
+
...d,
|
|
178
|
+
h,
|
|
179
|
+
s
|
|
179
180
|
];
|
|
180
|
-
}),
|
|
181
|
-
} catch (
|
|
182
|
-
return m(
|
|
181
|
+
}), s;
|
|
182
|
+
} catch (s) {
|
|
183
|
+
return m(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), c(!1), i((p) => p.filter((d) => !d.id.startsWith("temp-"))), null;
|
|
183
184
|
}
|
|
184
185
|
}, [n, u]),
|
|
185
|
-
clearMessages:
|
|
186
|
+
clearMessages: R(() => {
|
|
186
187
|
i([]), l(void 0), m(null);
|
|
187
188
|
}, []),
|
|
188
189
|
conversationId: u
|
|
189
190
|
};
|
|
190
191
|
}
|
|
191
|
-
var
|
|
192
|
-
const [i, u] = M(""), [l, f] = M([]),
|
|
193
|
-
const
|
|
194
|
-
if (!
|
|
192
|
+
var ae = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: a = "" }) => {
|
|
193
|
+
const [i, u] = M(""), [l, f] = M([]), c = A(null), b = A(null), m = R(() => {
|
|
194
|
+
const s = b.current;
|
|
195
|
+
if (!s) return;
|
|
195
196
|
const p = 110;
|
|
196
|
-
|
|
197
|
-
}, []), C =
|
|
198
|
-
|
|
197
|
+
s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, p)}px`, s.style.overflowY = s.scrollHeight + 2 > p ? "auto" : "hidden";
|
|
198
|
+
}, []), C = R((s) => {
|
|
199
|
+
s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), u(""), f([]), requestAnimationFrame(m));
|
|
199
200
|
}, [
|
|
200
201
|
i,
|
|
201
202
|
l,
|
|
202
203
|
e,
|
|
203
204
|
m
|
|
204
|
-
]), g =
|
|
205
|
-
|
|
206
|
-
}, [C]),
|
|
207
|
-
const p = Array.from(
|
|
208
|
-
f((
|
|
209
|
-
}, []), v =
|
|
210
|
-
f((p) => p.filter((
|
|
205
|
+
]), g = R((s) => {
|
|
206
|
+
s.key === "Enter" && !s.shiftKey && (s.preventDefault(), C(s));
|
|
207
|
+
}, [C]), x = R((s) => {
|
|
208
|
+
const p = Array.from(s.target.files || []);
|
|
209
|
+
f((d) => [...d, ...p]);
|
|
210
|
+
}, []), v = R((s) => {
|
|
211
|
+
f((p) => p.filter((d, h) => h !== s));
|
|
211
212
|
}, []), w = i.trim() || l.length > 0;
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
+
return /* @__PURE__ */ I("form", {
|
|
213
214
|
onSubmit: C,
|
|
214
|
-
className: `ago-chat-input ${
|
|
215
|
+
className: `ago-chat-input ${a}`,
|
|
215
216
|
style: {
|
|
216
217
|
display: "flex",
|
|
217
218
|
flexDirection: "column",
|
|
@@ -220,14 +221,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
220
221
|
borderTop: "1px solid #dee3e8",
|
|
221
222
|
backgroundColor: "#fff"
|
|
222
223
|
},
|
|
223
|
-
children: [l.length > 0 && /* @__PURE__ */
|
|
224
|
+
children: [l.length > 0 && /* @__PURE__ */ o("div", {
|
|
224
225
|
className: "ago-chat-input__files",
|
|
225
226
|
style: {
|
|
226
227
|
display: "flex",
|
|
227
228
|
flexWrap: "wrap",
|
|
228
229
|
gap: "6px"
|
|
229
230
|
},
|
|
230
|
-
children: l.map((
|
|
231
|
+
children: l.map((s, p) => /* @__PURE__ */ I("div", {
|
|
231
232
|
style: {
|
|
232
233
|
display: "flex",
|
|
233
234
|
alignItems: "center",
|
|
@@ -238,18 +239,18 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
238
239
|
fontSize: "12px",
|
|
239
240
|
color: "#30373e"
|
|
240
241
|
},
|
|
241
|
-
children: [/* @__PURE__ */
|
|
242
|
+
children: [/* @__PURE__ */ o("span", {
|
|
242
243
|
style: {
|
|
243
244
|
maxWidth: "120px",
|
|
244
245
|
overflow: "hidden",
|
|
245
246
|
textOverflow: "ellipsis",
|
|
246
247
|
whiteSpace: "nowrap"
|
|
247
248
|
},
|
|
248
|
-
children:
|
|
249
|
-
}), /* @__PURE__ */
|
|
249
|
+
children: s.name
|
|
250
|
+
}), /* @__PURE__ */ o("button", {
|
|
250
251
|
type: "button",
|
|
251
252
|
onClick: () => v(p),
|
|
252
|
-
"aria-label": `Remove ${
|
|
253
|
+
"aria-label": `Remove ${s.name}`,
|
|
253
254
|
style: {
|
|
254
255
|
border: "none",
|
|
255
256
|
background: "none",
|
|
@@ -262,16 +263,16 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
262
263
|
children: "×"
|
|
263
264
|
})]
|
|
264
265
|
}, p))
|
|
265
|
-
}), /* @__PURE__ */
|
|
266
|
+
}), /* @__PURE__ */ I("div", {
|
|
266
267
|
style: {
|
|
267
268
|
display: "flex",
|
|
268
269
|
gap: "8px",
|
|
269
270
|
alignItems: "flex-end"
|
|
270
271
|
},
|
|
271
272
|
children: [
|
|
272
|
-
n && /* @__PURE__ */
|
|
273
|
+
n && /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("button", {
|
|
273
274
|
type: "button",
|
|
274
|
-
onClick: () =>
|
|
275
|
+
onClick: () => c.current?.click(),
|
|
275
276
|
disabled: t,
|
|
276
277
|
"aria-label": "Attach file",
|
|
277
278
|
style: {
|
|
@@ -285,18 +286,18 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
285
286
|
lineHeight: 1
|
|
286
287
|
},
|
|
287
288
|
children: "+"
|
|
288
|
-
}), /* @__PURE__ */
|
|
289
|
-
ref:
|
|
289
|
+
}), /* @__PURE__ */ o("input", {
|
|
290
|
+
ref: c,
|
|
290
291
|
type: "file",
|
|
291
292
|
multiple: !0,
|
|
292
|
-
onChange:
|
|
293
|
+
onChange: x,
|
|
293
294
|
style: { display: "none" }
|
|
294
295
|
})] }),
|
|
295
|
-
/* @__PURE__ */
|
|
296
|
-
ref:
|
|
296
|
+
/* @__PURE__ */ o("textarea", {
|
|
297
|
+
ref: b,
|
|
297
298
|
value: i,
|
|
298
|
-
onChange: (
|
|
299
|
-
u(
|
|
299
|
+
onChange: (s) => {
|
|
300
|
+
u(s.target.value), m();
|
|
300
301
|
},
|
|
301
302
|
onKeyDown: g,
|
|
302
303
|
placeholder: r,
|
|
@@ -320,14 +321,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
320
321
|
backgroundColor: "#f8f8f8",
|
|
321
322
|
transition: "border-color 0.15s"
|
|
322
323
|
},
|
|
323
|
-
onFocus: (
|
|
324
|
-
|
|
324
|
+
onFocus: (s) => {
|
|
325
|
+
s.currentTarget.style.borderColor = "#1b5fc4";
|
|
325
326
|
},
|
|
326
|
-
onBlur: (
|
|
327
|
-
|
|
327
|
+
onBlur: (s) => {
|
|
328
|
+
s.currentTarget.style.borderColor = "#dee3e8";
|
|
328
329
|
}
|
|
329
330
|
}),
|
|
330
|
-
/* @__PURE__ */
|
|
331
|
+
/* @__PURE__ */ o("button", {
|
|
331
332
|
type: "submit",
|
|
332
333
|
disabled: t || !w,
|
|
333
334
|
style: {
|
|
@@ -346,7 +347,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
346
347
|
]
|
|
347
348
|
})]
|
|
348
349
|
});
|
|
349
|
-
},
|
|
350
|
+
}, se = ({ href: e, children: t, ...r }) => /* @__PURE__ */ o("a", {
|
|
350
351
|
href: e,
|
|
351
352
|
target: "_blank",
|
|
352
353
|
rel: "noopener noreferrer",
|
|
@@ -356,7 +357,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
356
357
|
},
|
|
357
358
|
...r,
|
|
358
359
|
children: t
|
|
359
|
-
}),
|
|
360
|
+
}), ie = ({ children: e, ...t }) => /* @__PURE__ */ o("p", {
|
|
360
361
|
style: {
|
|
361
362
|
margin: "0 0 8px 0",
|
|
362
363
|
lineHeight: "1.6"
|
|
@@ -364,17 +365,17 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
364
365
|
...t,
|
|
365
366
|
children: e
|
|
366
367
|
}), N = (e, t) => {
|
|
367
|
-
const r = ({ children: n, ...
|
|
368
|
+
const r = ({ children: n, ...a }) => Q.createElement(`h${e}`, {
|
|
368
369
|
style: {
|
|
369
370
|
margin: "16px 0 8px 0",
|
|
370
371
|
fontSize: t,
|
|
371
372
|
fontWeight: 600,
|
|
372
373
|
lineHeight: "1.3"
|
|
373
374
|
},
|
|
374
|
-
...
|
|
375
|
+
...a
|
|
375
376
|
}, n);
|
|
376
377
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
377
|
-
},
|
|
378
|
+
}, le = ({ children: e, ...t }) => /* @__PURE__ */ o("ul", {
|
|
378
379
|
style: {
|
|
379
380
|
margin: "0 0 8px 0",
|
|
380
381
|
paddingLeft: "20px",
|
|
@@ -383,7 +384,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
383
384
|
},
|
|
384
385
|
...t,
|
|
385
386
|
children: e
|
|
386
|
-
}),
|
|
387
|
+
}), de = ({ children: e, ...t }) => /* @__PURE__ */ o("ol", {
|
|
387
388
|
style: {
|
|
388
389
|
margin: "0 0 8px 0",
|
|
389
390
|
paddingLeft: "20px",
|
|
@@ -392,7 +393,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
392
393
|
},
|
|
393
394
|
...t,
|
|
394
395
|
children: e
|
|
395
|
-
}),
|
|
396
|
+
}), ce = ({ children: e, ...t }) => /* @__PURE__ */ o("li", {
|
|
396
397
|
style: {
|
|
397
398
|
display: "list-item",
|
|
398
399
|
margin: "2px 0",
|
|
@@ -400,8 +401,8 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
400
401
|
},
|
|
401
402
|
...t,
|
|
402
403
|
children: e
|
|
403
|
-
}),
|
|
404
|
-
`) ? /* @__PURE__ */
|
|
404
|
+
}), ue = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
|
|
405
|
+
`) ? /* @__PURE__ */ o("code", {
|
|
405
406
|
style: {
|
|
406
407
|
display: "block",
|
|
407
408
|
background: "#f5f5f5",
|
|
@@ -413,7 +414,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
413
414
|
},
|
|
414
415
|
...r,
|
|
415
416
|
children: t
|
|
416
|
-
}) : /* @__PURE__ */
|
|
417
|
+
}) : /* @__PURE__ */ o("code", {
|
|
417
418
|
style: {
|
|
418
419
|
background: "#f0f2f5",
|
|
419
420
|
padding: "2px 5px",
|
|
@@ -423,11 +424,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
423
424
|
},
|
|
424
425
|
...r,
|
|
425
426
|
children: t
|
|
426
|
-
}),
|
|
427
|
+
}), pe = ({ children: e, ...t }) => /* @__PURE__ */ o("pre", {
|
|
427
428
|
style: { margin: "0 0 8px 0" },
|
|
428
429
|
...t,
|
|
429
430
|
children: e
|
|
430
|
-
}),
|
|
431
|
+
}), fe = ({ children: e, ...t }) => /* @__PURE__ */ o("blockquote", {
|
|
431
432
|
style: {
|
|
432
433
|
borderLeft: "4px solid #dee3e8",
|
|
433
434
|
paddingLeft: "12px",
|
|
@@ -437,12 +438,12 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
437
438
|
},
|
|
438
439
|
...t,
|
|
439
440
|
children: e
|
|
440
|
-
}),
|
|
441
|
+
}), ge = ({ children: e, ...t }) => /* @__PURE__ */ o("div", {
|
|
441
442
|
style: {
|
|
442
443
|
overflowX: "auto",
|
|
443
444
|
margin: "0 0 8px 0"
|
|
444
445
|
},
|
|
445
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ o("table", {
|
|
446
447
|
style: {
|
|
447
448
|
borderCollapse: "collapse",
|
|
448
449
|
width: "100%",
|
|
@@ -451,7 +452,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
451
452
|
...t,
|
|
452
453
|
children: e
|
|
453
454
|
})
|
|
454
|
-
}),
|
|
455
|
+
}), me = ({ children: e, ...t }) => /* @__PURE__ */ o("th", {
|
|
455
456
|
style: {
|
|
456
457
|
border: "1px solid #dee3e8",
|
|
457
458
|
padding: "6px 10px",
|
|
@@ -461,14 +462,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
461
462
|
},
|
|
462
463
|
...t,
|
|
463
464
|
children: e
|
|
464
|
-
}),
|
|
465
|
+
}), xe = ({ children: e, ...t }) => /* @__PURE__ */ o("td", {
|
|
465
466
|
style: {
|
|
466
467
|
border: "1px solid #dee3e8",
|
|
467
468
|
padding: "6px 10px"
|
|
468
469
|
},
|
|
469
470
|
...t,
|
|
470
471
|
children: e
|
|
471
|
-
}),
|
|
472
|
+
}), he = ({ alt: e, ...t }) => /* @__PURE__ */ o("img", {
|
|
472
473
|
alt: e ?? "",
|
|
473
474
|
style: {
|
|
474
475
|
maxWidth: "100%",
|
|
@@ -476,39 +477,116 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
476
477
|
margin: "4px 0"
|
|
477
478
|
},
|
|
478
479
|
...t
|
|
479
|
-
}),
|
|
480
|
+
}), ye = (e) => /* @__PURE__ */ o("hr", {
|
|
480
481
|
style: {
|
|
481
482
|
border: "none",
|
|
482
483
|
borderTop: "1px solid #dee3e8",
|
|
483
484
|
margin: "12px 0"
|
|
484
485
|
},
|
|
485
486
|
...e
|
|
486
|
-
}),
|
|
487
|
-
a:
|
|
488
|
-
p:
|
|
487
|
+
}), be = {
|
|
488
|
+
a: se,
|
|
489
|
+
p: ie,
|
|
489
490
|
h1: N(1, "20px"),
|
|
490
491
|
h2: N(2, "18px"),
|
|
491
492
|
h3: N(3, "16px"),
|
|
492
493
|
h4: N(4, "15px"),
|
|
493
494
|
h5: N(5, "14px"),
|
|
494
495
|
h6: N(6, "13px"),
|
|
495
|
-
ul:
|
|
496
|
-
ol:
|
|
497
|
-
li:
|
|
498
|
-
code:
|
|
499
|
-
pre:
|
|
500
|
-
blockquote:
|
|
501
|
-
table:
|
|
502
|
-
th:
|
|
503
|
-
td:
|
|
504
|
-
img:
|
|
505
|
-
hr:
|
|
506
|
-
},
|
|
507
|
-
remarkPlugins:
|
|
508
|
-
components:
|
|
496
|
+
ul: le,
|
|
497
|
+
ol: de,
|
|
498
|
+
li: ce,
|
|
499
|
+
code: ue,
|
|
500
|
+
pre: pe,
|
|
501
|
+
blockquote: fe,
|
|
502
|
+
table: ge,
|
|
503
|
+
th: me,
|
|
504
|
+
td: xe,
|
|
505
|
+
img: he,
|
|
506
|
+
hr: ye
|
|
507
|
+
}, ve = [re], we = ({ content: e }) => /* @__PURE__ */ o(ne, {
|
|
508
|
+
remarkPlugins: ve,
|
|
509
|
+
components: be,
|
|
509
510
|
children: e
|
|
510
|
-
}),
|
|
511
|
-
const r =
|
|
511
|
+
}), Ce = ({ attachment: e, isUser: t }) => {
|
|
512
|
+
const r = V(e.url);
|
|
513
|
+
if (J(e)) return /* @__PURE__ */ o("a", {
|
|
514
|
+
href: r,
|
|
515
|
+
target: "_blank",
|
|
516
|
+
rel: "noopener noreferrer",
|
|
517
|
+
style: {
|
|
518
|
+
display: "inline-block",
|
|
519
|
+
textDecoration: "none"
|
|
520
|
+
},
|
|
521
|
+
children: /* @__PURE__ */ o("img", {
|
|
522
|
+
src: r,
|
|
523
|
+
alt: e.name,
|
|
524
|
+
loading: "lazy",
|
|
525
|
+
style: {
|
|
526
|
+
maxWidth: "180px",
|
|
527
|
+
maxHeight: "160px",
|
|
528
|
+
objectFit: "cover",
|
|
529
|
+
borderRadius: "10px",
|
|
530
|
+
border: "1px solid #dee3e8",
|
|
531
|
+
display: "block"
|
|
532
|
+
}
|
|
533
|
+
})
|
|
534
|
+
});
|
|
535
|
+
const n = G(e.fileSize), a = /* @__PURE__ */ I(O, { children: [/* @__PURE__ */ o("span", {
|
|
536
|
+
style: {
|
|
537
|
+
fontSize: "16px",
|
|
538
|
+
lineHeight: 1,
|
|
539
|
+
flexShrink: 0
|
|
540
|
+
},
|
|
541
|
+
"aria-hidden": !0,
|
|
542
|
+
children: "📄"
|
|
543
|
+
}), /* @__PURE__ */ I("span", {
|
|
544
|
+
style: {
|
|
545
|
+
display: "flex",
|
|
546
|
+
flexDirection: "column",
|
|
547
|
+
minWidth: 0
|
|
548
|
+
},
|
|
549
|
+
children: [/* @__PURE__ */ o("span", {
|
|
550
|
+
style: {
|
|
551
|
+
overflow: "hidden",
|
|
552
|
+
textOverflow: "ellipsis",
|
|
553
|
+
whiteSpace: "nowrap",
|
|
554
|
+
maxWidth: "160px"
|
|
555
|
+
},
|
|
556
|
+
title: e.name,
|
|
557
|
+
children: e.name
|
|
558
|
+
}), n && /* @__PURE__ */ o("span", {
|
|
559
|
+
style: {
|
|
560
|
+
fontSize: "11px",
|
|
561
|
+
color: "#6b6d6f"
|
|
562
|
+
},
|
|
563
|
+
children: n
|
|
564
|
+
})]
|
|
565
|
+
})] }), i = {
|
|
566
|
+
display: "inline-flex",
|
|
567
|
+
alignItems: "center",
|
|
568
|
+
gap: "8px",
|
|
569
|
+
padding: "8px 12px",
|
|
570
|
+
borderRadius: "10px",
|
|
571
|
+
border: "1px solid #dee3e8",
|
|
572
|
+
backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
|
|
573
|
+
color: t ? "#fff" : "#30373e",
|
|
574
|
+
fontSize: "13px",
|
|
575
|
+
textDecoration: "none",
|
|
576
|
+
maxWidth: "220px"
|
|
577
|
+
};
|
|
578
|
+
return r ? /* @__PURE__ */ o("a", {
|
|
579
|
+
href: r,
|
|
580
|
+
target: "_blank",
|
|
581
|
+
rel: "noopener noreferrer",
|
|
582
|
+
style: i,
|
|
583
|
+
children: a
|
|
584
|
+
}) : /* @__PURE__ */ o("div", {
|
|
585
|
+
style: i,
|
|
586
|
+
children: a
|
|
587
|
+
});
|
|
588
|
+
}, Se = ({ source: e, index: t }) => {
|
|
589
|
+
const r = /* @__PURE__ */ I("div", {
|
|
512
590
|
style: {
|
|
513
591
|
display: "flex",
|
|
514
592
|
alignItems: "center",
|
|
@@ -516,7 +594,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
516
594
|
width: "100%",
|
|
517
595
|
minWidth: 0
|
|
518
596
|
},
|
|
519
|
-
children: [/* @__PURE__ */
|
|
597
|
+
children: [/* @__PURE__ */ o("div", {
|
|
520
598
|
style: {
|
|
521
599
|
flexShrink: 0,
|
|
522
600
|
width: "18px",
|
|
@@ -532,7 +610,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
532
610
|
backgroundColor: "#f0f4ff"
|
|
533
611
|
},
|
|
534
612
|
children: t + 1
|
|
535
|
-
}), /* @__PURE__ */
|
|
613
|
+
}), /* @__PURE__ */ o("div", {
|
|
536
614
|
style: {
|
|
537
615
|
fontSize: "12px",
|
|
538
616
|
overflow: "hidden",
|
|
@@ -556,23 +634,23 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
556
634
|
minWidth: 0,
|
|
557
635
|
transition: "border-color 0.15s"
|
|
558
636
|
};
|
|
559
|
-
return e.url ? /* @__PURE__ */
|
|
637
|
+
return e.url ? /* @__PURE__ */ o("a", {
|
|
560
638
|
href: e.url,
|
|
561
639
|
target: "_blank",
|
|
562
640
|
rel: "noopener noreferrer",
|
|
563
641
|
style: n,
|
|
564
|
-
onMouseEnter: (
|
|
565
|
-
|
|
642
|
+
onMouseEnter: (a) => {
|
|
643
|
+
a.currentTarget.style.borderColor = "#1b5fc4";
|
|
566
644
|
},
|
|
567
|
-
onMouseLeave: (
|
|
568
|
-
|
|
645
|
+
onMouseLeave: (a) => {
|
|
646
|
+
a.currentTarget.style.borderColor = "#dee3e8";
|
|
569
647
|
},
|
|
570
648
|
children: r
|
|
571
|
-
}) : /* @__PURE__ */
|
|
649
|
+
}) : /* @__PURE__ */ o("div", {
|
|
572
650
|
style: n,
|
|
573
651
|
children: r
|
|
574
652
|
});
|
|
575
|
-
},
|
|
653
|
+
}, ke = () => /* @__PURE__ */ I("div", {
|
|
576
654
|
style: {
|
|
577
655
|
display: "flex",
|
|
578
656
|
gap: "4px",
|
|
@@ -582,22 +660,22 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
582
660
|
0,
|
|
583
661
|
1,
|
|
584
662
|
2
|
|
585
|
-
].map((e) => /* @__PURE__ */
|
|
663
|
+
].map((e) => /* @__PURE__ */ o("div", { style: {
|
|
586
664
|
width: "6px",
|
|
587
665
|
height: "6px",
|
|
588
666
|
borderRadius: "50%",
|
|
589
667
|
backgroundColor: "#b5bfc8",
|
|
590
668
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
591
669
|
animationDelay: `${e * 0.2}s`
|
|
592
|
-
} }, e)), /* @__PURE__ */
|
|
670
|
+
} }, e)), /* @__PURE__ */ o("style", { children: `
|
|
593
671
|
@keyframes ago-pulse {
|
|
594
672
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
595
673
|
40% { opacity: 1; transform: scale(1); }
|
|
596
674
|
}
|
|
597
675
|
` })]
|
|
598
|
-
}),
|
|
676
|
+
}), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: a }) => {
|
|
599
677
|
const i = e.role === "user", u = e.status === "IN_PROGRESS";
|
|
600
|
-
return /* @__PURE__ */
|
|
678
|
+
return /* @__PURE__ */ I("div", {
|
|
601
679
|
className: `ago-message ago-message--${e.role} ${t}`,
|
|
602
680
|
style: {
|
|
603
681
|
display: "flex",
|
|
@@ -606,7 +684,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
606
684
|
marginBottom: "16px"
|
|
607
685
|
},
|
|
608
686
|
children: [
|
|
609
|
-
!i && r && e.agent && /* @__PURE__ */
|
|
687
|
+
!i && r && e.agent && /* @__PURE__ */ o("div", {
|
|
610
688
|
className: "ago-message__agent",
|
|
611
689
|
style: {
|
|
612
690
|
display: "flex",
|
|
@@ -620,7 +698,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
620
698
|
},
|
|
621
699
|
children: e.agent.displayName || e.agent.name
|
|
622
700
|
}),
|
|
623
|
-
!i && e.sources && e.sources.length > 0 && /* @__PURE__ */
|
|
701
|
+
!i && e.sources && e.sources.length > 0 && /* @__PURE__ */ o("div", {
|
|
624
702
|
className: "ago-message__sources",
|
|
625
703
|
style: {
|
|
626
704
|
display: "grid",
|
|
@@ -630,12 +708,27 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
630
708
|
width: "100%",
|
|
631
709
|
maxWidth: "85%"
|
|
632
710
|
},
|
|
633
|
-
children: e.sources.map((l, f) => /* @__PURE__ */
|
|
711
|
+
children: e.sources.map((l, f) => /* @__PURE__ */ o(Se, {
|
|
634
712
|
source: l,
|
|
635
713
|
index: f
|
|
636
714
|
}, l.id))
|
|
637
715
|
}),
|
|
638
|
-
/* @__PURE__ */
|
|
716
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ o("div", {
|
|
717
|
+
className: "ago-message__attachments",
|
|
718
|
+
style: {
|
|
719
|
+
display: "flex",
|
|
720
|
+
flexWrap: "wrap",
|
|
721
|
+
gap: "6px",
|
|
722
|
+
marginBottom: "6px",
|
|
723
|
+
justifyContent: i ? "flex-end" : "flex-start",
|
|
724
|
+
maxWidth: "75%"
|
|
725
|
+
},
|
|
726
|
+
children: e.attachments.map((l) => /* @__PURE__ */ o(Ce, {
|
|
727
|
+
attachment: l,
|
|
728
|
+
isUser: i
|
|
729
|
+
}, l.id))
|
|
730
|
+
}),
|
|
731
|
+
(e.content || u) && /* @__PURE__ */ o("div", {
|
|
639
732
|
className: "ago-message__content",
|
|
640
733
|
style: {
|
|
641
734
|
maxWidth: i ? "75%" : "100%",
|
|
@@ -647,9 +740,9 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
647
740
|
fontSize: "16px",
|
|
648
741
|
lineHeight: "1.6"
|
|
649
742
|
},
|
|
650
|
-
children: e.content ? /* @__PURE__ */
|
|
743
|
+
children: e.content ? /* @__PURE__ */ o(we, { content: e.content }) : u && /* @__PURE__ */ o(ke, {})
|
|
651
744
|
}),
|
|
652
|
-
n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */
|
|
745
|
+
n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ o("div", {
|
|
653
746
|
className: "ago-message__followups",
|
|
654
747
|
style: {
|
|
655
748
|
display: "flex",
|
|
@@ -657,11 +750,11 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
657
750
|
gap: "8px",
|
|
658
751
|
marginTop: "10px"
|
|
659
752
|
},
|
|
660
|
-
children: e.followUpReplies.map((l, f) => /* @__PURE__ */
|
|
753
|
+
children: e.followUpReplies.map((l, f) => /* @__PURE__ */ o("button", {
|
|
661
754
|
type: "button",
|
|
662
755
|
className: "ago-message__followup-btn",
|
|
663
|
-
disabled: !
|
|
664
|
-
onClick:
|
|
756
|
+
disabled: !a,
|
|
757
|
+
onClick: a ? () => a(l) : void 0,
|
|
665
758
|
style: {
|
|
666
759
|
minHeight: "36px",
|
|
667
760
|
padding: "6px 14px",
|
|
@@ -670,54 +763,54 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
670
763
|
border: "1px solid #dee3e8",
|
|
671
764
|
backgroundColor: "#fff",
|
|
672
765
|
color: "#30373e",
|
|
673
|
-
cursor:
|
|
766
|
+
cursor: a ? "pointer" : "default",
|
|
674
767
|
transition: "border-color 0.15s"
|
|
675
768
|
},
|
|
676
|
-
onMouseEnter: (
|
|
677
|
-
|
|
769
|
+
onMouseEnter: (c) => {
|
|
770
|
+
c.currentTarget.style.borderColor = "#1b5fc4";
|
|
678
771
|
},
|
|
679
|
-
onMouseLeave: (
|
|
680
|
-
|
|
772
|
+
onMouseLeave: (c) => {
|
|
773
|
+
c.currentTarget.style.borderColor = "#dee3e8";
|
|
681
774
|
},
|
|
682
775
|
children: l
|
|
683
776
|
}, f))
|
|
684
777
|
})
|
|
685
778
|
]
|
|
686
779
|
});
|
|
687
|
-
},
|
|
688
|
-
const
|
|
780
|
+
}, He = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: a = "Type a message...", allowFiles: i = !1, height: u = 500, logoUrl: l, showAgentName: f = !1, forms: c, onFollowUpClick: b, className: m = "", onMessageSent: C, onMessageReceived: g }) => {
|
|
781
|
+
const x = A(null), v = W(), w = e ?? v, { messages: s, isLoading: p, error: d, sendMessage: h } = B({
|
|
689
782
|
client: e,
|
|
690
783
|
conversationId: t
|
|
691
784
|
});
|
|
692
785
|
k(() => {
|
|
693
|
-
if (!w || !
|
|
694
|
-
let
|
|
786
|
+
if (!w || !c || c.length === 0) return;
|
|
787
|
+
let y = !1;
|
|
695
788
|
const F = [];
|
|
696
|
-
return Promise.all(
|
|
697
|
-
if (!
|
|
698
|
-
for (const
|
|
789
|
+
return Promise.all(c.map((E) => E.schema != null ? Promise.resolve(L(E)) : H(w, E))).then((E) => {
|
|
790
|
+
if (!y)
|
|
791
|
+
for (const q of E) F.push(q.install(w));
|
|
699
792
|
}).catch(() => {
|
|
700
793
|
}), () => {
|
|
701
|
-
|
|
794
|
+
y = !0, F.forEach((E) => E());
|
|
702
795
|
};
|
|
703
|
-
}, [w,
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
796
|
+
}, [w, c ? JSON.stringify(c.map((y) => [
|
|
797
|
+
y.name,
|
|
798
|
+
y.schema ?? null,
|
|
799
|
+
y.submit ?? !1,
|
|
800
|
+
y.description ?? null
|
|
708
801
|
])) : ""]), k(() => {
|
|
709
|
-
|
|
710
|
-
}, [
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
id:
|
|
714
|
-
content:
|
|
802
|
+
x.current?.scrollIntoView({ behavior: "smooth" });
|
|
803
|
+
}, [s]), k(() => {
|
|
804
|
+
const y = s[s.length - 1];
|
|
805
|
+
y && y.role === "assistant" && y.status === "DONE" && g && g({
|
|
806
|
+
id: y.id,
|
|
807
|
+
content: y.content
|
|
715
808
|
});
|
|
716
|
-
}, [
|
|
717
|
-
const S = async (
|
|
718
|
-
C?.(
|
|
719
|
-
},
|
|
720
|
-
return /* @__PURE__ */
|
|
809
|
+
}, [s, g]);
|
|
810
|
+
const S = async (y, F) => {
|
|
811
|
+
C?.(y), await h(y, F);
|
|
812
|
+
}, z = s[s.length - 1], K = p && z?.role === "assistant" && z.status === "IN_PROGRESS", U = b === !1 ? void 0 : b ?? ((y) => S(y));
|
|
813
|
+
return /* @__PURE__ */ I("div", {
|
|
721
814
|
className: `ago-chat-widget ${m}`,
|
|
722
815
|
style: {
|
|
723
816
|
display: "flex",
|
|
@@ -732,7 +825,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
732
825
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
733
826
|
},
|
|
734
827
|
children: [
|
|
735
|
-
/* @__PURE__ */
|
|
828
|
+
/* @__PURE__ */ I("div", {
|
|
736
829
|
className: "ago-chat-widget__header",
|
|
737
830
|
style: {
|
|
738
831
|
padding: "14px 16px",
|
|
@@ -743,14 +836,14 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
743
836
|
alignItems: "center",
|
|
744
837
|
gap: "10px"
|
|
745
838
|
},
|
|
746
|
-
children: [l && /* @__PURE__ */
|
|
839
|
+
children: [l && /* @__PURE__ */ o("img", {
|
|
747
840
|
src: l,
|
|
748
841
|
alt: "Logo",
|
|
749
842
|
style: {
|
|
750
843
|
height: "24px",
|
|
751
844
|
width: "auto"
|
|
752
845
|
}
|
|
753
|
-
}), /* @__PURE__ */
|
|
846
|
+
}), /* @__PURE__ */ o("h3", {
|
|
754
847
|
style: {
|
|
755
848
|
margin: 0,
|
|
756
849
|
fontSize: "15px",
|
|
@@ -759,7 +852,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
759
852
|
children: r
|
|
760
853
|
})]
|
|
761
854
|
}),
|
|
762
|
-
/* @__PURE__ */
|
|
855
|
+
/* @__PURE__ */ I("div", {
|
|
763
856
|
className: "ago-chat-widget__messages",
|
|
764
857
|
role: "log",
|
|
765
858
|
"aria-live": "polite",
|
|
@@ -772,7 +865,7 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
772
865
|
backgroundColor: "#fbfbfb"
|
|
773
866
|
},
|
|
774
867
|
children: [
|
|
775
|
-
|
|
868
|
+
s.length === 0 ? /* @__PURE__ */ o("div", {
|
|
776
869
|
style: {
|
|
777
870
|
textAlign: "center",
|
|
778
871
|
color: "#6b6d6f",
|
|
@@ -781,13 +874,13 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
781
874
|
lineHeight: "1.5"
|
|
782
875
|
},
|
|
783
876
|
children: n
|
|
784
|
-
}) :
|
|
785
|
-
message:
|
|
877
|
+
}) : s.map((y, F) => /* @__PURE__ */ o(Me, {
|
|
878
|
+
message: y,
|
|
786
879
|
showAgentName: f,
|
|
787
|
-
isLast: F ===
|
|
788
|
-
onFollowUpClick:
|
|
789
|
-
},
|
|
790
|
-
|
|
880
|
+
isLast: F === s.length - 1,
|
|
881
|
+
onFollowUpClick: U
|
|
882
|
+
}, y.id)),
|
|
883
|
+
d && /* @__PURE__ */ o("div", {
|
|
791
884
|
role: "alert",
|
|
792
885
|
style: {
|
|
793
886
|
padding: "10px 14px",
|
|
@@ -798,90 +891,90 @@ var te = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", a
|
|
|
798
891
|
fontSize: "13px",
|
|
799
892
|
border: "1px solid #fecaca"
|
|
800
893
|
},
|
|
801
|
-
children:
|
|
894
|
+
children: d.message
|
|
802
895
|
}),
|
|
803
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ o("div", { ref: x })
|
|
804
897
|
]
|
|
805
898
|
}),
|
|
806
|
-
/* @__PURE__ */
|
|
899
|
+
/* @__PURE__ */ o(ae, {
|
|
807
900
|
onSend: S,
|
|
808
|
-
disabled:
|
|
809
|
-
placeholder:
|
|
901
|
+
disabled: K,
|
|
902
|
+
placeholder: a,
|
|
810
903
|
allowFiles: i
|
|
811
904
|
})
|
|
812
905
|
]
|
|
813
906
|
});
|
|
814
907
|
};
|
|
815
|
-
function
|
|
816
|
-
const r =
|
|
908
|
+
function Ie({ client: e, autoLoad: t = !0 } = {}) {
|
|
909
|
+
const r = W(), n = e || r;
|
|
817
910
|
if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
818
|
-
const [
|
|
819
|
-
|
|
911
|
+
const [a, i] = M([]), [u, l] = M(null), [f, c] = M(!1), [b, m] = M(null), C = R(async () => {
|
|
912
|
+
c(!0), m(null);
|
|
820
913
|
try {
|
|
821
914
|
i(await n.getConversations());
|
|
822
915
|
} catch (v) {
|
|
823
916
|
m(v instanceof Error ? v : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
824
917
|
} finally {
|
|
825
|
-
|
|
918
|
+
c(!1);
|
|
826
919
|
}
|
|
827
|
-
}, [n]), g =
|
|
828
|
-
|
|
920
|
+
}, [n]), g = R(async (v) => {
|
|
921
|
+
c(!0), m(null);
|
|
829
922
|
try {
|
|
830
923
|
l(await n.getConversation(v));
|
|
831
924
|
} catch (w) {
|
|
832
925
|
m(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
833
926
|
} finally {
|
|
834
|
-
|
|
927
|
+
c(!1);
|
|
835
928
|
}
|
|
836
|
-
}, [n]),
|
|
929
|
+
}, [n]), x = R(() => {
|
|
837
930
|
l(null);
|
|
838
931
|
}, []);
|
|
839
932
|
return k(() => {
|
|
840
933
|
t && C();
|
|
841
934
|
}, [t, C]), {
|
|
842
|
-
conversations:
|
|
935
|
+
conversations: a,
|
|
843
936
|
currentConversation: u,
|
|
844
937
|
isLoading: f,
|
|
845
|
-
error:
|
|
938
|
+
error: b,
|
|
846
939
|
selectConversation: g,
|
|
847
|
-
startNewConversation:
|
|
940
|
+
startNewConversation: x,
|
|
848
941
|
refreshConversations: C
|
|
849
942
|
};
|
|
850
943
|
}
|
|
851
|
-
function
|
|
852
|
-
const t =
|
|
944
|
+
function Le(e = {}) {
|
|
945
|
+
const t = W(), r = e.client || t;
|
|
853
946
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
854
|
-
const n =
|
|
947
|
+
const n = B({
|
|
855
948
|
client: r,
|
|
856
949
|
conversationId: e.conversationId
|
|
857
|
-
}),
|
|
950
|
+
}), a = Ie({
|
|
858
951
|
client: r,
|
|
859
952
|
autoLoad: e.autoLoad
|
|
860
953
|
});
|
|
861
954
|
return {
|
|
862
955
|
messages: n.messages,
|
|
863
956
|
isLoading: n.isLoading,
|
|
864
|
-
error: n.error ||
|
|
957
|
+
error: n.error || a.error,
|
|
865
958
|
sendMessage: n.sendMessage,
|
|
866
959
|
clearMessages: n.clearMessages,
|
|
867
960
|
conversationId: n.conversationId,
|
|
868
|
-
conversations:
|
|
869
|
-
currentConversation:
|
|
870
|
-
isConversationsLoading:
|
|
871
|
-
selectConversation:
|
|
872
|
-
startNewConversation:
|
|
873
|
-
refreshConversations:
|
|
961
|
+
conversations: a.conversations,
|
|
962
|
+
currentConversation: a.currentConversation,
|
|
963
|
+
isConversationsLoading: a.isLoading,
|
|
964
|
+
selectConversation: a.selectConversation,
|
|
965
|
+
startNewConversation: a.startNewConversation,
|
|
966
|
+
refreshConversations: a.refreshConversations
|
|
874
967
|
};
|
|
875
968
|
}
|
|
876
|
-
function
|
|
877
|
-
const r =
|
|
969
|
+
function $e(e, t) {
|
|
970
|
+
const r = T(), { name: n, description: a, parameters: i, handler: u } = typeof e == "string" ? {
|
|
878
971
|
name: e,
|
|
879
972
|
...t
|
|
880
973
|
} : e, l = A(u);
|
|
881
974
|
l.current = u, k(() => {
|
|
882
|
-
const f = (
|
|
975
|
+
const f = (c) => l.current(c);
|
|
883
976
|
return r.registerFunction(n, f, {
|
|
884
|
-
description:
|
|
977
|
+
description: a,
|
|
885
978
|
parameters: i
|
|
886
979
|
}), () => {
|
|
887
980
|
r.unregisterFunction(n);
|
|
@@ -889,53 +982,53 @@ function Le(e, t) {
|
|
|
889
982
|
}, [
|
|
890
983
|
r,
|
|
891
984
|
n,
|
|
892
|
-
|
|
985
|
+
a,
|
|
893
986
|
i
|
|
894
987
|
]);
|
|
895
988
|
}
|
|
896
|
-
function
|
|
897
|
-
const r =
|
|
898
|
-
n.current = e, k(() => (r.registerNavigationFunction((
|
|
989
|
+
function Oe(e, t) {
|
|
990
|
+
const r = T(), n = A(e);
|
|
991
|
+
n.current = e, k(() => (r.registerNavigationFunction((a) => n.current(a), t), () => {
|
|
899
992
|
r.unregisterFunction("navigateToPage");
|
|
900
993
|
}), [r, t]);
|
|
901
994
|
}
|
|
902
|
-
function
|
|
903
|
-
const r =
|
|
995
|
+
function Be(e, t) {
|
|
996
|
+
const r = T(), n = ee(), a = t ?? n, i = A(e);
|
|
904
997
|
i.current = e;
|
|
905
998
|
const u = typeof e == "function";
|
|
906
999
|
k(() => {
|
|
907
1000
|
if (typeof i.current == "function") {
|
|
908
1001
|
const l = () => i.current();
|
|
909
|
-
return r.addDynamicContext(
|
|
910
|
-
r.removeDynamicContext(
|
|
1002
|
+
return r.addDynamicContext(a, l), () => {
|
|
1003
|
+
r.removeDynamicContext(a);
|
|
911
1004
|
};
|
|
912
1005
|
}
|
|
913
|
-
return r.setContext(
|
|
914
|
-
r.removeContext(
|
|
1006
|
+
return r.setContext(a, i.current), () => {
|
|
1007
|
+
r.removeContext(a);
|
|
915
1008
|
};
|
|
916
1009
|
}, [
|
|
917
1010
|
r,
|
|
918
|
-
|
|
1011
|
+
a,
|
|
919
1012
|
u,
|
|
920
1013
|
u ? "" : JSON.stringify(e)
|
|
921
1014
|
]);
|
|
922
1015
|
}
|
|
923
|
-
function
|
|
924
|
-
return
|
|
1016
|
+
function Re(e) {
|
|
1017
|
+
return te(e.subscribe, e.get, e.get);
|
|
925
1018
|
}
|
|
926
|
-
var
|
|
1019
|
+
var P = {
|
|
927
1020
|
missing: [],
|
|
928
1021
|
complete: !1
|
|
929
1022
|
};
|
|
930
|
-
function
|
|
931
|
-
const t =
|
|
1023
|
+
function Ke(e) {
|
|
1024
|
+
const t = T(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), a = e.submit, i = a ? typeof a == "string" ? `client:${a}` : a.via === "backend" ? "backend" : "handler" in a ? "client:handler" : `client:${a.url}` : "none", u = JSON.stringify(e.initialValues ?? null), l = _(() => r ? L(e) : null, [
|
|
932
1025
|
r,
|
|
933
1026
|
e.name,
|
|
934
1027
|
n,
|
|
935
1028
|
i,
|
|
936
1029
|
u,
|
|
937
1030
|
e.autoSubmit
|
|
938
|
-
]), [f,
|
|
1031
|
+
]), [f, c] = M({
|
|
939
1032
|
collector: null,
|
|
940
1033
|
loading: !r,
|
|
941
1034
|
error: null
|
|
@@ -943,21 +1036,21 @@ function ze(e) {
|
|
|
943
1036
|
k(() => {
|
|
944
1037
|
if (r) return;
|
|
945
1038
|
let p = !1;
|
|
946
|
-
return
|
|
1039
|
+
return c({
|
|
947
1040
|
collector: null,
|
|
948
1041
|
loading: !0,
|
|
949
1042
|
error: null
|
|
950
|
-
}),
|
|
951
|
-
p ||
|
|
952
|
-
collector:
|
|
1043
|
+
}), H(t, e).then((d) => {
|
|
1044
|
+
p || c({
|
|
1045
|
+
collector: d,
|
|
953
1046
|
loading: !1,
|
|
954
1047
|
error: null
|
|
955
1048
|
});
|
|
956
|
-
}).catch((
|
|
957
|
-
p ||
|
|
1049
|
+
}).catch((d) => {
|
|
1050
|
+
p || c({
|
|
958
1051
|
collector: null,
|
|
959
1052
|
loading: !1,
|
|
960
|
-
error:
|
|
1053
|
+
error: d instanceof Error ? d : new Error(String(d))
|
|
961
1054
|
});
|
|
962
1055
|
}), () => {
|
|
963
1056
|
p = !0;
|
|
@@ -970,18 +1063,18 @@ function ze(e) {
|
|
|
970
1063
|
u,
|
|
971
1064
|
e.autoSubmit
|
|
972
1065
|
]);
|
|
973
|
-
const
|
|
1066
|
+
const b = r ? l : f.collector, m = r ? !1 : f.loading, C = r ? null : f.error;
|
|
974
1067
|
k(() => {
|
|
975
|
-
if (
|
|
976
|
-
return
|
|
977
|
-
}, [t,
|
|
978
|
-
const g =
|
|
1068
|
+
if (b)
|
|
1069
|
+
return b.install(t);
|
|
1070
|
+
}, [t, b]);
|
|
1071
|
+
const g = _(() => X({
|
|
979
1072
|
values: e.initialValues ?? {},
|
|
980
1073
|
submitted: !1
|
|
981
|
-
}), [u]),
|
|
982
|
-
...
|
|
1074
|
+
}), [u]), x = Re(b?.store ?? g), v = _(() => b?.getStatus() ?? P, [x, b]), w = _(() => ({
|
|
1075
|
+
...x,
|
|
983
1076
|
...v
|
|
984
|
-
}), [
|
|
1077
|
+
}), [x, v]), s = _(() => ({
|
|
985
1078
|
name: e.name,
|
|
986
1079
|
store: g,
|
|
987
1080
|
functions: [],
|
|
@@ -1003,34 +1096,34 @@ function ze(e) {
|
|
|
1003
1096
|
},
|
|
1004
1097
|
reset: () => {
|
|
1005
1098
|
},
|
|
1006
|
-
getStatus: () =>
|
|
1099
|
+
getStatus: () => P
|
|
1007
1100
|
}), [e.name, g]);
|
|
1008
1101
|
return {
|
|
1009
|
-
...
|
|
1102
|
+
...b ?? s,
|
|
1010
1103
|
state: w,
|
|
1011
1104
|
loading: m,
|
|
1012
1105
|
error: C
|
|
1013
1106
|
};
|
|
1014
1107
|
}
|
|
1015
1108
|
export {
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1109
|
+
Pe as AgoProvider,
|
|
1110
|
+
ae as ChatInput,
|
|
1111
|
+
He as ChatWidget,
|
|
1112
|
+
we as Markdown,
|
|
1113
|
+
Me as Message,
|
|
1114
|
+
L as createFormCollector,
|
|
1115
|
+
_e as createMockClient,
|
|
1116
|
+
Fe as deriveFormStatus,
|
|
1117
|
+
H as loadFormCollector,
|
|
1118
|
+
oe as useAgo,
|
|
1119
|
+
T as useAgoClient,
|
|
1120
|
+
Be as useAgoContext,
|
|
1121
|
+
$e as useAgoFunction,
|
|
1122
|
+
Oe as useAgoNavigation,
|
|
1123
|
+
Re as useAgoStore,
|
|
1124
|
+
Le as useChat,
|
|
1125
|
+
Ie as useConversation,
|
|
1126
|
+
Ke as useFormCollector,
|
|
1127
|
+
B as useMessages,
|
|
1128
|
+
W as useOptionalAgoClient
|
|
1036
1129
|
};
|