@useago/sdk 1.4.3 → 1.5.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/CHANGELOG.md +15 -1
- package/dist/{AgoClient-S8oeNnAE.js → AgoClient-q39FIjSC.js} +105 -81
- package/dist/AgoClient-wcPRaIMs.cjs +8 -0
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +75 -5
- package/dist/angular.d.ts +75 -5
- package/dist/angular.js +5 -1
- package/dist/autoContinue-CcCTva-D.cjs +1 -0
- package/dist/autoContinue-D3Mmaaca.js +63 -0
- package/dist/{createConversationSession-CmBq7uGi.cjs → createConversationSession-BBYfQLLS.cjs} +1 -1
- package/dist/{createConversationSession-DoUHdVNR.js → createConversationSession-DCSWShaW.js} +1 -1
- package/dist/{createFormCollector-Bz_0IJ0Q.cjs → createFormCollector-eimwwWEi.cjs} +1 -1
- package/dist/{createFormCollector-vy-QvFja.js → createFormCollector-sB6rMccD.js} +1 -1
- package/dist/devtools.d.cts +32 -4
- package/dist/devtools.d.ts +32 -4
- package/dist/helpers.cjs +1 -1
- package/dist/helpers.d.cts +6 -0
- package/dist/helpers.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +101 -5
- package/dist/index.d.ts +101 -5
- package/dist/index.js +45 -43
- package/dist/react.cjs +3 -3
- package/dist/react.d.cts +40 -18
- package/dist/react.d.ts +40 -18
- package/dist/react.js +415 -471
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +32 -4
- package/dist/testing.d.ts +32 -4
- package/dist/testing.js +1 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +38 -4
- package/dist/vue.d.ts +38 -4
- package/dist/vue.js +22 -21
- package/dist/widget.cjs +1 -1
- package/dist/widget.d.cts +32 -4
- package/dist/widget.d.ts +32 -4
- package/dist/widget.js +3 -3
- package/llms-full.txt +1932 -0
- package/package.json +5 -3
- package/dist/AgoClient-CMDVqNaH.cjs +0 -8
- /package/dist/{createMockClient-bAZ9KBHC.js → createMockClient-BUc9PSbo.js} +0 -0
- /package/dist/{createMockClient-BSr-UV8R.cjs → createMockClient-CjdCqixj.cjs} +0 -0
- /package/dist/{functions-Djnq-JAo.cjs → functions-IGSjjvF4.cjs} +0 -0
package/dist/react.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { a as q, i as J, o as j, s as V, t as Y } from "./AgoClient-q39FIjSC.js";
|
|
2
|
+
import { t as X } from "./autoContinue-D3Mmaaca.js";
|
|
3
|
+
import { i as Q, n as _e, r as H, t as O } from "./createFormCollector-sB6rMccD.js";
|
|
4
|
+
import { t as Pe } from "./createMockClient-BUc9PSbo.js";
|
|
5
|
+
import Z, { createContext as ee, useCallback as A, useContext as $, useEffect as k, useId as te, useMemo as T, useRef as E, useState as M, useSyncExternalStore as ne } from "react";
|
|
6
|
+
import { Fragment as B, jsx as a, jsxs as R } from "react/jsx-runtime";
|
|
6
7
|
import re from "react-markdown";
|
|
7
8
|
import oe from "remark-gfm";
|
|
8
9
|
function ae(e) {
|
|
9
|
-
const [
|
|
10
|
-
if (
|
|
11
|
-
const
|
|
12
|
-
return
|
|
10
|
+
const [t, r] = M(!1), n = E(null), o = T(() => {
|
|
11
|
+
if (n.current && (n.current.destroy(), n.current = null), !e) return null;
|
|
12
|
+
const i = new Y(e);
|
|
13
|
+
return n.current = i, i;
|
|
13
14
|
}, [e?.baseUrl, e?.widgetId]);
|
|
14
15
|
return k(() => (r(!0), () => {
|
|
15
|
-
|
|
16
|
+
n.current?.destroy(), n.current = null;
|
|
16
17
|
}), [o]), k(() => {
|
|
17
|
-
|
|
18
|
+
n.current && e && n.current.updateConfig({
|
|
18
19
|
agent: e.agent,
|
|
19
20
|
defaultAgentId: e.defaultAgentId,
|
|
20
21
|
permission: e.permission,
|
|
@@ -33,136 +34,136 @@ function ae(e) {
|
|
|
33
34
|
e?.warnOnEmptyReply
|
|
34
35
|
]), {
|
|
35
36
|
client: o,
|
|
36
|
-
isReady:
|
|
37
|
+
isReady: t
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
|
-
var L = ee(null), He = ({ children: e, client:
|
|
40
|
-
const { client: c } = ae(
|
|
40
|
+
var L = ee(null), He = ({ children: e, client: t, tools: r, helpers: n, pageContext: o, ...i }) => {
|
|
41
|
+
const { client: c } = ae(t ? null : i), l = t || c;
|
|
41
42
|
return k(() => {
|
|
42
43
|
if (!(!r || r.length === 0)) {
|
|
43
|
-
for (const
|
|
44
|
+
for (const f of r) l.register(f);
|
|
44
45
|
return () => {
|
|
45
|
-
for (const
|
|
46
|
+
for (const f of r) l.unregisterFunction(f.name);
|
|
46
47
|
};
|
|
47
48
|
}
|
|
48
49
|
}, [l, r]), k(() => {
|
|
49
|
-
if (!
|
|
50
|
-
const
|
|
51
|
-
return import("./functions-CApuQZ2b.js").then((
|
|
52
|
-
for (const [
|
|
53
|
-
const I =
|
|
50
|
+
if (!n) return;
|
|
51
|
+
const f = [];
|
|
52
|
+
return import("./functions-CApuQZ2b.js").then((u) => u.n).then((u) => {
|
|
53
|
+
for (const [y, v] of Object.entries(n)) {
|
|
54
|
+
const I = u[y];
|
|
54
55
|
if (!I) {
|
|
55
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
56
|
+
console.warn(`[AGO] Unknown helper: "${y}"`);
|
|
56
57
|
continue;
|
|
57
58
|
}
|
|
58
|
-
const
|
|
59
|
+
const x = v === !0 ? I : {
|
|
59
60
|
...I,
|
|
60
|
-
handler:
|
|
61
|
+
handler: v
|
|
61
62
|
};
|
|
62
|
-
l.register(
|
|
63
|
+
l.register(x), f.push(x.name);
|
|
63
64
|
}
|
|
64
65
|
}), () => {
|
|
65
|
-
for (const
|
|
66
|
+
for (const u of f) l.unregisterFunction(u);
|
|
66
67
|
};
|
|
67
|
-
}, [l,
|
|
68
|
+
}, [l, n]), k(() => {
|
|
68
69
|
o === "auto" && l.enableAutoPageContext();
|
|
69
|
-
}, [l, o]), /* @__PURE__ */
|
|
70
|
+
}, [l, o]), /* @__PURE__ */ a(L.Provider, {
|
|
70
71
|
value: l,
|
|
71
72
|
children: e
|
|
72
73
|
});
|
|
73
74
|
};
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
75
|
+
function P() {
|
|
76
|
+
const e = $(L);
|
|
76
77
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
77
78
|
return e;
|
|
78
79
|
}
|
|
79
|
-
function
|
|
80
|
-
return
|
|
80
|
+
function z() {
|
|
81
|
+
return $(L);
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
-
const r =
|
|
84
|
-
if (!
|
|
85
|
-
const [o,
|
|
83
|
+
function G({ client: e, conversationId: t } = {}) {
|
|
84
|
+
const r = z(), n = e || r;
|
|
85
|
+
if (!n) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
86
|
+
const [o, i] = M([]), [c, l] = M(t), [f, u] = M(!1), [y, v] = M(null);
|
|
86
87
|
k(() => {
|
|
87
|
-
|
|
88
|
-
}, [
|
|
89
|
-
const I = async (
|
|
88
|
+
t && t !== c && (l(t), I(t));
|
|
89
|
+
}, [t]);
|
|
90
|
+
const I = async (x) => {
|
|
90
91
|
try {
|
|
91
|
-
|
|
92
|
-
} catch (
|
|
93
|
-
|
|
92
|
+
i((await n.getMessages(x)).filter((h) => !h.hidden));
|
|
93
|
+
} catch (h) {
|
|
94
|
+
v(h instanceof Error ? h : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
94
95
|
}
|
|
95
96
|
};
|
|
96
97
|
return k(() => {
|
|
97
|
-
const
|
|
98
|
-
c || l(
|
|
99
|
-
const
|
|
100
|
-
return
|
|
101
|
-
...
|
|
98
|
+
const x = (d) => d === "IN_PROGRESS" || d === "WAITING_CLIENT", h = (d) => {
|
|
99
|
+
c || l(d.conversationId), u(!0), i((p) => {
|
|
100
|
+
const m = p.findIndex((g) => g.id === d.messageId);
|
|
101
|
+
return m >= 0 ? p.map((g, W) => W === m ? {
|
|
102
|
+
...g,
|
|
102
103
|
status: "IN_PROGRESS"
|
|
103
|
-
} :
|
|
104
|
-
id:
|
|
105
|
-
conversationId:
|
|
104
|
+
} : g) : p.some((g) => g.role === "assistant" && x(g.status)) ? p : [...p, {
|
|
105
|
+
id: d.messageId,
|
|
106
|
+
conversationId: d.conversationId,
|
|
106
107
|
content: "",
|
|
107
108
|
role: "assistant",
|
|
108
109
|
status: "IN_PROGRESS",
|
|
109
110
|
createdAt: /* @__PURE__ */ new Date()
|
|
110
111
|
}];
|
|
111
112
|
});
|
|
112
|
-
},
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
return
|
|
116
|
-
...
|
|
117
|
-
content:
|
|
118
|
-
} :
|
|
113
|
+
}, C = (d) => {
|
|
114
|
+
i((p) => {
|
|
115
|
+
const m = p.findIndex((g) => g.id === d.messageId);
|
|
116
|
+
return m < 0 ? p : p.map((g, W) => W === m ? {
|
|
117
|
+
...g,
|
|
118
|
+
content: g.content + d.content
|
|
119
|
+
} : g);
|
|
119
120
|
});
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
let
|
|
123
|
-
for (let
|
|
124
|
-
|
|
121
|
+
}, S = (d) => {
|
|
122
|
+
i((p) => {
|
|
123
|
+
let m = -1;
|
|
124
|
+
for (let g = p.length - 1; g >= 0; g--) if (p[g].role === "assistant" && x(p[g].status)) {
|
|
125
|
+
m = g;
|
|
125
126
|
break;
|
|
126
127
|
}
|
|
127
|
-
return
|
|
128
|
-
...p.slice(0,
|
|
128
|
+
return m < 0 ? p : [
|
|
129
|
+
...p.slice(0, m),
|
|
129
130
|
{
|
|
130
|
-
...p[
|
|
131
|
-
...
|
|
131
|
+
...p[m],
|
|
132
|
+
...d
|
|
132
133
|
},
|
|
133
|
-
...p.slice(
|
|
134
|
+
...p.slice(m + 1)
|
|
134
135
|
];
|
|
135
136
|
});
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
const
|
|
139
|
-
return
|
|
140
|
-
...p.slice(0,
|
|
141
|
-
|
|
142
|
-
...p.slice(
|
|
143
|
-
] : [...p,
|
|
144
|
-
}),
|
|
145
|
-
},
|
|
146
|
-
|
|
137
|
+
}, s = (d) => {
|
|
138
|
+
i((p) => {
|
|
139
|
+
const m = p.findIndex((g) => g.id === d.id);
|
|
140
|
+
return m >= 0 ? [
|
|
141
|
+
...p.slice(0, m),
|
|
142
|
+
d,
|
|
143
|
+
...p.slice(m + 1)
|
|
144
|
+
] : [...p, d];
|
|
145
|
+
}), u(!1);
|
|
146
|
+
}, b = (d) => {
|
|
147
|
+
v(new Error(d.error)), u(!1);
|
|
147
148
|
};
|
|
148
|
-
return
|
|
149
|
-
|
|
149
|
+
return n.on("message:start", h), n.on("message:chunk", C), n.on("message:answer-complete", S), n.on("message:complete", s), n.on("message:error", b), () => {
|
|
150
|
+
n.off("message:start", h), n.off("message:chunk", C), n.off("message:answer-complete", S), n.off("message:complete", s), n.off("message:error", b);
|
|
150
151
|
};
|
|
151
|
-
}, [
|
|
152
|
+
}, [n, c]), {
|
|
152
153
|
messages: o,
|
|
153
|
-
isLoading:
|
|
154
|
-
error:
|
|
155
|
-
sendMessage:
|
|
156
|
-
|
|
157
|
-
const
|
|
154
|
+
isLoading: f,
|
|
155
|
+
error: y,
|
|
156
|
+
sendMessage: A(async (x, h) => {
|
|
157
|
+
u(!0), v(null);
|
|
158
|
+
const C = {
|
|
158
159
|
id: `temp-${Date.now()}`,
|
|
159
160
|
conversationId: c || "",
|
|
160
|
-
content:
|
|
161
|
+
content: x,
|
|
161
162
|
role: "user",
|
|
162
163
|
status: "DONE",
|
|
163
|
-
attachments:
|
|
164
|
+
attachments: h && h.length > 0 ? J(h) : void 0,
|
|
164
165
|
createdAt: /* @__PURE__ */ new Date()
|
|
165
|
-
},
|
|
166
|
+
}, S = {
|
|
166
167
|
id: `temp-assistant-${Date.now()}`,
|
|
167
168
|
conversationId: c || "",
|
|
168
169
|
content: "",
|
|
@@ -170,60 +171,60 @@ function U({ client: e, conversationId: n } = {}) {
|
|
|
170
171
|
status: "IN_PROGRESS",
|
|
171
172
|
createdAt: /* @__PURE__ */ new Date()
|
|
172
173
|
};
|
|
173
|
-
|
|
174
|
-
...
|
|
175
|
-
|
|
176
|
-
|
|
174
|
+
i((s) => [
|
|
175
|
+
...s,
|
|
176
|
+
C,
|
|
177
|
+
S
|
|
177
178
|
]);
|
|
178
179
|
try {
|
|
179
|
-
const
|
|
180
|
+
const s = await n.sendMessage(x, {
|
|
180
181
|
conversationId: c,
|
|
181
|
-
files:
|
|
182
|
+
files: h
|
|
182
183
|
});
|
|
183
|
-
return
|
|
184
|
-
const
|
|
185
|
-
...
|
|
186
|
-
id:
|
|
187
|
-
conversationId:
|
|
184
|
+
return s.conversationId && !c && l(s.conversationId), i((b) => {
|
|
185
|
+
const d = b.filter((m) => !m.id.startsWith("temp-")), p = {
|
|
186
|
+
...C,
|
|
187
|
+
id: C.id.replace("temp-", "user-"),
|
|
188
|
+
conversationId: s.conversationId
|
|
188
189
|
};
|
|
189
|
-
return
|
|
190
|
-
...
|
|
190
|
+
return d.some((m) => m.id === s.id) ? [...d, p].sort((m, g) => new Date(m.createdAt).getTime() - new Date(g.createdAt).getTime()) : [
|
|
191
|
+
...d,
|
|
191
192
|
p,
|
|
192
|
-
|
|
193
|
+
s
|
|
193
194
|
];
|
|
194
|
-
}),
|
|
195
|
-
} catch (
|
|
196
|
-
return
|
|
195
|
+
}), s;
|
|
196
|
+
} catch (s) {
|
|
197
|
+
return v(s instanceof Error ? s : /* @__PURE__ */ new Error("Failed to send message")), u(!1), i((b) => b.filter((d) => !d.id.startsWith("temp-"))), null;
|
|
197
198
|
}
|
|
198
|
-
}, [
|
|
199
|
-
clearMessages:
|
|
200
|
-
|
|
199
|
+
}, [n, c]),
|
|
200
|
+
clearMessages: A(() => {
|
|
201
|
+
i([]), l(void 0), v(null);
|
|
201
202
|
}, []),
|
|
202
203
|
conversationId: c
|
|
203
204
|
};
|
|
204
205
|
}
|
|
205
|
-
var se = ({ onSend: e, disabled:
|
|
206
|
-
const [
|
|
207
|
-
const
|
|
208
|
-
if (!
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
}, []), I =
|
|
212
|
-
|
|
206
|
+
var se = ({ onSend: e, disabled: t = !1, placeholder: r = "Type a message...", allowFiles: n = !1, className: o = "" }) => {
|
|
207
|
+
const [i, c] = M(""), [l, f] = M([]), u = E(null), y = E(null), v = A(() => {
|
|
208
|
+
const s = y.current;
|
|
209
|
+
if (!s) return;
|
|
210
|
+
const b = 110;
|
|
211
|
+
s.style.height = "auto", s.style.height = `${Math.min(s.scrollHeight + 2, b)}px`, s.style.overflowY = s.scrollHeight + 2 > b ? "auto" : "hidden";
|
|
212
|
+
}, []), I = A((s) => {
|
|
213
|
+
s.preventDefault(), (i.trim() || l.length > 0) && (e(i.trim(), l.length > 0 ? l : void 0), c(""), f([]), requestAnimationFrame(v));
|
|
213
214
|
}, [
|
|
214
|
-
|
|
215
|
+
i,
|
|
215
216
|
l,
|
|
216
217
|
e,
|
|
217
|
-
|
|
218
|
-
]),
|
|
219
|
-
|
|
220
|
-
}, [I]),
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
}, []),
|
|
224
|
-
|
|
225
|
-
}, []),
|
|
226
|
-
return /* @__PURE__ */
|
|
218
|
+
v
|
|
219
|
+
]), x = A((s) => {
|
|
220
|
+
s.key === "Enter" && !s.shiftKey && (s.preventDefault(), I(s));
|
|
221
|
+
}, [I]), h = A((s) => {
|
|
222
|
+
const b = Array.from(s.target.files || []);
|
|
223
|
+
f((d) => [...d, ...b]);
|
|
224
|
+
}, []), C = A((s) => {
|
|
225
|
+
f((b) => b.filter((d, p) => p !== s));
|
|
226
|
+
}, []), S = i.trim() || l.length > 0;
|
|
227
|
+
return /* @__PURE__ */ R("form", {
|
|
227
228
|
onSubmit: I,
|
|
228
229
|
className: `ago-chat-input ${o}`,
|
|
229
230
|
style: {
|
|
@@ -234,14 +235,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
234
235
|
borderTop: "1px solid #dee3e8",
|
|
235
236
|
backgroundColor: "#fff"
|
|
236
237
|
},
|
|
237
|
-
children: [l.length > 0 && /* @__PURE__ */
|
|
238
|
+
children: [l.length > 0 && /* @__PURE__ */ a("div", {
|
|
238
239
|
className: "ago-chat-input__files",
|
|
239
240
|
style: {
|
|
240
241
|
display: "flex",
|
|
241
242
|
flexWrap: "wrap",
|
|
242
243
|
gap: "6px"
|
|
243
244
|
},
|
|
244
|
-
children: l.map((
|
|
245
|
+
children: l.map((s, b) => /* @__PURE__ */ R("div", {
|
|
245
246
|
style: {
|
|
246
247
|
display: "flex",
|
|
247
248
|
alignItems: "center",
|
|
@@ -252,18 +253,18 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
252
253
|
fontSize: "12px",
|
|
253
254
|
color: "#30373e"
|
|
254
255
|
},
|
|
255
|
-
children: [/* @__PURE__ */
|
|
256
|
+
children: [/* @__PURE__ */ a("span", {
|
|
256
257
|
style: {
|
|
257
258
|
maxWidth: "120px",
|
|
258
259
|
overflow: "hidden",
|
|
259
260
|
textOverflow: "ellipsis",
|
|
260
261
|
whiteSpace: "nowrap"
|
|
261
262
|
},
|
|
262
|
-
children:
|
|
263
|
-
}), /* @__PURE__ */
|
|
263
|
+
children: s.name
|
|
264
|
+
}), /* @__PURE__ */ a("button", {
|
|
264
265
|
type: "button",
|
|
265
|
-
onClick: () =>
|
|
266
|
-
"aria-label": `Remove ${
|
|
266
|
+
onClick: () => C(b),
|
|
267
|
+
"aria-label": `Remove ${s.name}`,
|
|
267
268
|
style: {
|
|
268
269
|
border: "none",
|
|
269
270
|
background: "none",
|
|
@@ -275,47 +276,47 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
275
276
|
},
|
|
276
277
|
children: "×"
|
|
277
278
|
})]
|
|
278
|
-
},
|
|
279
|
-
}), /* @__PURE__ */
|
|
279
|
+
}, b))
|
|
280
|
+
}), /* @__PURE__ */ R("div", {
|
|
280
281
|
style: {
|
|
281
282
|
display: "flex",
|
|
282
283
|
gap: "8px",
|
|
283
284
|
alignItems: "flex-end"
|
|
284
285
|
},
|
|
285
286
|
children: [
|
|
286
|
-
|
|
287
|
+
n && /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("button", {
|
|
287
288
|
type: "button",
|
|
288
|
-
onClick: () =>
|
|
289
|
-
disabled:
|
|
289
|
+
onClick: () => u.current?.click(),
|
|
290
|
+
disabled: t,
|
|
290
291
|
"aria-label": "Attach file",
|
|
291
292
|
style: {
|
|
292
293
|
padding: "8px",
|
|
293
294
|
border: "1px solid #dee3e8",
|
|
294
295
|
borderRadius: "8px",
|
|
295
296
|
backgroundColor: "#fff",
|
|
296
|
-
cursor:
|
|
297
|
+
cursor: t ? "not-allowed" : "pointer",
|
|
297
298
|
color: "#6b6d6f",
|
|
298
299
|
fontSize: "16px",
|
|
299
300
|
lineHeight: 1
|
|
300
301
|
},
|
|
301
302
|
children: "+"
|
|
302
|
-
}), /* @__PURE__ */
|
|
303
|
-
ref:
|
|
303
|
+
}), /* @__PURE__ */ a("input", {
|
|
304
|
+
ref: u,
|
|
304
305
|
type: "file",
|
|
305
306
|
multiple: !0,
|
|
306
|
-
onChange:
|
|
307
|
+
onChange: h,
|
|
307
308
|
style: { display: "none" }
|
|
308
309
|
})] }),
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
ref:
|
|
311
|
-
value:
|
|
312
|
-
onChange: (
|
|
313
|
-
c(
|
|
310
|
+
/* @__PURE__ */ a("textarea", {
|
|
311
|
+
ref: y,
|
|
312
|
+
value: i,
|
|
313
|
+
onChange: (s) => {
|
|
314
|
+
c(s.target.value), v();
|
|
314
315
|
},
|
|
315
|
-
onKeyDown:
|
|
316
|
+
onKeyDown: x,
|
|
316
317
|
placeholder: r,
|
|
317
318
|
"aria-label": r,
|
|
318
|
-
disabled:
|
|
319
|
+
disabled: t,
|
|
319
320
|
rows: 1,
|
|
320
321
|
style: {
|
|
321
322
|
flex: 1,
|
|
@@ -334,23 +335,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
334
335
|
backgroundColor: "#f8f8f8",
|
|
335
336
|
transition: "border-color 0.15s"
|
|
336
337
|
},
|
|
337
|
-
onFocus: (
|
|
338
|
-
|
|
338
|
+
onFocus: (s) => {
|
|
339
|
+
s.currentTarget.style.borderColor = "#1b5fc4";
|
|
339
340
|
},
|
|
340
|
-
onBlur: (
|
|
341
|
-
|
|
341
|
+
onBlur: (s) => {
|
|
342
|
+
s.currentTarget.style.borderColor = "#dee3e8";
|
|
342
343
|
}
|
|
343
344
|
}),
|
|
344
|
-
/* @__PURE__ */
|
|
345
|
+
/* @__PURE__ */ a("button", {
|
|
345
346
|
type: "submit",
|
|
346
|
-
disabled:
|
|
347
|
+
disabled: t || !S,
|
|
347
348
|
style: {
|
|
348
349
|
padding: "10px 18px",
|
|
349
350
|
border: "none",
|
|
350
351
|
borderRadius: "20px",
|
|
351
|
-
backgroundColor:
|
|
352
|
+
backgroundColor: t || !S ? "#b5bfc8" : "#03182f",
|
|
352
353
|
color: "#fff",
|
|
353
|
-
cursor:
|
|
354
|
+
cursor: t || !S ? "not-allowed" : "pointer",
|
|
354
355
|
fontWeight: 500,
|
|
355
356
|
fontSize: "16px",
|
|
356
357
|
transition: "background-color 0.15s"
|
|
@@ -360,7 +361,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
360
361
|
]
|
|
361
362
|
})]
|
|
362
363
|
});
|
|
363
|
-
}, ie = ({ href: e, children:
|
|
364
|
+
}, ie = ({ href: e, children: t, ...r }) => /* @__PURE__ */ a("a", {
|
|
364
365
|
href: e,
|
|
365
366
|
target: "_blank",
|
|
366
367
|
rel: "noopener noreferrer",
|
|
@@ -369,53 +370,53 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
369
370
|
textDecoration: "underline"
|
|
370
371
|
},
|
|
371
372
|
...r,
|
|
372
|
-
children:
|
|
373
|
-
}), le = ({ children: e, ...
|
|
373
|
+
children: t
|
|
374
|
+
}), le = ({ children: e, ...t }) => /* @__PURE__ */ a("p", {
|
|
374
375
|
style: {
|
|
375
376
|
margin: "0 0 8px 0",
|
|
376
377
|
lineHeight: "1.6"
|
|
377
378
|
},
|
|
378
|
-
...
|
|
379
|
+
...t,
|
|
379
380
|
children: e
|
|
380
|
-
}),
|
|
381
|
-
const r = ({ children:
|
|
381
|
+
}), _ = (e, t) => {
|
|
382
|
+
const r = ({ children: n, ...o }) => Z.createElement(`h${e}`, {
|
|
382
383
|
style: {
|
|
383
384
|
margin: "16px 0 8px 0",
|
|
384
|
-
fontSize:
|
|
385
|
+
fontSize: t,
|
|
385
386
|
fontWeight: 600,
|
|
386
387
|
lineHeight: "1.3"
|
|
387
388
|
},
|
|
388
389
|
...o
|
|
389
|
-
},
|
|
390
|
+
}, n);
|
|
390
391
|
return r.displayName = `MarkdownHeading${e}`, r;
|
|
391
|
-
}, ce = ({ children: e, ...
|
|
392
|
+
}, ce = ({ children: e, ...t }) => /* @__PURE__ */ a("ul", {
|
|
392
393
|
style: {
|
|
393
394
|
margin: "0 0 8px 0",
|
|
394
395
|
paddingLeft: "20px",
|
|
395
396
|
listStyleType: "disc",
|
|
396
397
|
listStylePosition: "outside"
|
|
397
398
|
},
|
|
398
|
-
...
|
|
399
|
+
...t,
|
|
399
400
|
children: e
|
|
400
|
-
}), de = ({ children: e, ...
|
|
401
|
+
}), de = ({ children: e, ...t }) => /* @__PURE__ */ a("ol", {
|
|
401
402
|
style: {
|
|
402
403
|
margin: "0 0 8px 0",
|
|
403
404
|
paddingLeft: "20px",
|
|
404
405
|
listStyleType: "decimal",
|
|
405
406
|
listStylePosition: "outside"
|
|
406
407
|
},
|
|
407
|
-
...
|
|
408
|
+
...t,
|
|
408
409
|
children: e
|
|
409
|
-
}), ue = ({ children: e, ...
|
|
410
|
+
}), ue = ({ children: e, ...t }) => /* @__PURE__ */ a("li", {
|
|
410
411
|
style: {
|
|
411
412
|
display: "list-item",
|
|
412
413
|
margin: "2px 0",
|
|
413
414
|
lineHeight: "1.6"
|
|
414
415
|
},
|
|
415
|
-
...
|
|
416
|
+
...t,
|
|
416
417
|
children: e
|
|
417
|
-
}), fe = ({ className: e, children:
|
|
418
|
-
`) ? /* @__PURE__ */
|
|
418
|
+
}), fe = ({ className: e, children: t, ...r }) => e !== void 0 || String(t).includes(`
|
|
419
|
+
`) ? /* @__PURE__ */ a("code", {
|
|
419
420
|
style: {
|
|
420
421
|
display: "block",
|
|
421
422
|
background: "#f5f5f5",
|
|
@@ -426,8 +427,8 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
426
427
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
427
428
|
},
|
|
428
429
|
...r,
|
|
429
|
-
children:
|
|
430
|
-
}) : /* @__PURE__ */
|
|
430
|
+
children: t
|
|
431
|
+
}) : /* @__PURE__ */ a("code", {
|
|
431
432
|
style: {
|
|
432
433
|
background: "#f0f2f5",
|
|
433
434
|
padding: "2px 5px",
|
|
@@ -436,12 +437,12 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
436
437
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
437
438
|
},
|
|
438
439
|
...r,
|
|
439
|
-
children:
|
|
440
|
-
}),
|
|
440
|
+
children: t
|
|
441
|
+
}), pe = ({ children: e, ...t }) => /* @__PURE__ */ a("pre", {
|
|
441
442
|
style: { margin: "0 0 8px 0" },
|
|
442
|
-
...
|
|
443
|
+
...t,
|
|
443
444
|
children: e
|
|
444
|
-
}),
|
|
445
|
+
}), ge = ({ children: e, ...t }) => /* @__PURE__ */ a("blockquote", {
|
|
445
446
|
style: {
|
|
446
447
|
borderLeft: "4px solid #dee3e8",
|
|
447
448
|
paddingLeft: "12px",
|
|
@@ -449,23 +450,23 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
449
450
|
fontStyle: "italic",
|
|
450
451
|
color: "#6b6d6f"
|
|
451
452
|
},
|
|
452
|
-
...
|
|
453
|
+
...t,
|
|
453
454
|
children: e
|
|
454
|
-
}), me = ({ children: e, ...
|
|
455
|
+
}), me = ({ children: e, ...t }) => /* @__PURE__ */ a("div", {
|
|
455
456
|
style: {
|
|
456
457
|
overflowX: "auto",
|
|
457
458
|
margin: "0 0 8px 0"
|
|
458
459
|
},
|
|
459
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ a("table", {
|
|
460
461
|
style: {
|
|
461
462
|
borderCollapse: "collapse",
|
|
462
463
|
width: "100%",
|
|
463
464
|
fontSize: "13px"
|
|
464
465
|
},
|
|
465
|
-
...
|
|
466
|
+
...t,
|
|
466
467
|
children: e
|
|
467
468
|
})
|
|
468
|
-
}),
|
|
469
|
+
}), xe = ({ children: e, ...t }) => /* @__PURE__ */ a("th", {
|
|
469
470
|
style: {
|
|
470
471
|
border: "1px solid #dee3e8",
|
|
471
472
|
padding: "6px 10px",
|
|
@@ -473,24 +474,24 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
473
474
|
backgroundColor: "#f5f7fa",
|
|
474
475
|
fontWeight: 600
|
|
475
476
|
},
|
|
476
|
-
...
|
|
477
|
+
...t,
|
|
477
478
|
children: e
|
|
478
|
-
}),
|
|
479
|
+
}), he = ({ children: e, ...t }) => /* @__PURE__ */ a("td", {
|
|
479
480
|
style: {
|
|
480
481
|
border: "1px solid #dee3e8",
|
|
481
482
|
padding: "6px 10px"
|
|
482
483
|
},
|
|
483
|
-
...
|
|
484
|
+
...t,
|
|
484
485
|
children: e
|
|
485
|
-
}), ye = ({ alt: e, ...
|
|
486
|
+
}), ye = ({ alt: e, ...t }) => /* @__PURE__ */ a("img", {
|
|
486
487
|
alt: e ?? "",
|
|
487
488
|
style: {
|
|
488
489
|
maxWidth: "100%",
|
|
489
490
|
borderRadius: "8px",
|
|
490
491
|
margin: "4px 0"
|
|
491
492
|
},
|
|
492
|
-
...
|
|
493
|
-
}), be = (e) => /* @__PURE__ */
|
|
493
|
+
...t
|
|
494
|
+
}), be = (e) => /* @__PURE__ */ a("hr", {
|
|
494
495
|
style: {
|
|
495
496
|
border: "none",
|
|
496
497
|
borderTop: "1px solid #dee3e8",
|
|
@@ -500,30 +501,30 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
500
501
|
}), ve = {
|
|
501
502
|
a: ie,
|
|
502
503
|
p: le,
|
|
503
|
-
h1:
|
|
504
|
-
h2:
|
|
505
|
-
h3:
|
|
506
|
-
h4:
|
|
507
|
-
h5:
|
|
508
|
-
h6:
|
|
504
|
+
h1: _(1, "20px"),
|
|
505
|
+
h2: _(2, "18px"),
|
|
506
|
+
h3: _(3, "16px"),
|
|
507
|
+
h4: _(4, "15px"),
|
|
508
|
+
h5: _(5, "14px"),
|
|
509
|
+
h6: _(6, "13px"),
|
|
509
510
|
ul: ce,
|
|
510
511
|
ol: de,
|
|
511
512
|
li: ue,
|
|
512
513
|
code: fe,
|
|
513
|
-
pre:
|
|
514
|
-
blockquote:
|
|
514
|
+
pre: pe,
|
|
515
|
+
blockquote: ge,
|
|
515
516
|
table: me,
|
|
516
|
-
th:
|
|
517
|
-
td:
|
|
517
|
+
th: xe,
|
|
518
|
+
td: he,
|
|
518
519
|
img: ye,
|
|
519
520
|
hr: be
|
|
520
|
-
}, we = [oe],
|
|
521
|
+
}, we = [oe], Ce = ({ content: e }) => /* @__PURE__ */ a(re, {
|
|
521
522
|
remarkPlugins: we,
|
|
522
523
|
components: ve,
|
|
523
524
|
children: e
|
|
524
|
-
}),
|
|
525
|
-
const r =
|
|
526
|
-
if (
|
|
525
|
+
}), Se = ({ attachment: e, isUser: t }) => {
|
|
526
|
+
const r = V(e.url);
|
|
527
|
+
if (q(e)) return /* @__PURE__ */ a("a", {
|
|
527
528
|
href: r,
|
|
528
529
|
target: "_blank",
|
|
529
530
|
rel: "noopener noreferrer",
|
|
@@ -531,7 +532,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
531
532
|
display: "inline-block",
|
|
532
533
|
textDecoration: "none"
|
|
533
534
|
},
|
|
534
|
-
children: /* @__PURE__ */
|
|
535
|
+
children: /* @__PURE__ */ a("img", {
|
|
535
536
|
src: r,
|
|
536
537
|
alt: e.name,
|
|
537
538
|
loading: "lazy",
|
|
@@ -545,7 +546,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
545
546
|
}
|
|
546
547
|
})
|
|
547
548
|
});
|
|
548
|
-
const
|
|
549
|
+
const n = j(e.fileSize), o = /* @__PURE__ */ R(B, { children: [/* @__PURE__ */ a("span", {
|
|
549
550
|
style: {
|
|
550
551
|
fontSize: "16px",
|
|
551
552
|
lineHeight: 1,
|
|
@@ -553,13 +554,13 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
553
554
|
},
|
|
554
555
|
"aria-hidden": !0,
|
|
555
556
|
children: "📄"
|
|
556
|
-
}), /* @__PURE__ */
|
|
557
|
+
}), /* @__PURE__ */ R("span", {
|
|
557
558
|
style: {
|
|
558
559
|
display: "flex",
|
|
559
560
|
flexDirection: "column",
|
|
560
561
|
minWidth: 0
|
|
561
562
|
},
|
|
562
|
-
children: [/* @__PURE__ */
|
|
563
|
+
children: [/* @__PURE__ */ a("span", {
|
|
563
564
|
style: {
|
|
564
565
|
overflow: "hidden",
|
|
565
566
|
textOverflow: "ellipsis",
|
|
@@ -568,38 +569,38 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
568
569
|
},
|
|
569
570
|
title: e.name,
|
|
570
571
|
children: e.name
|
|
571
|
-
}),
|
|
572
|
+
}), n && /* @__PURE__ */ a("span", {
|
|
572
573
|
style: {
|
|
573
574
|
fontSize: "11px",
|
|
574
575
|
color: "#6b6d6f"
|
|
575
576
|
},
|
|
576
|
-
children:
|
|
577
|
+
children: n
|
|
577
578
|
})]
|
|
578
|
-
})] }),
|
|
579
|
+
})] }), i = {
|
|
579
580
|
display: "inline-flex",
|
|
580
581
|
alignItems: "center",
|
|
581
582
|
gap: "8px",
|
|
582
583
|
padding: "8px 12px",
|
|
583
584
|
borderRadius: "10px",
|
|
584
585
|
border: "1px solid #dee3e8",
|
|
585
|
-
backgroundColor:
|
|
586
|
-
color:
|
|
586
|
+
backgroundColor: t ? "rgba(255,255,255,0.12)" : "#fff",
|
|
587
|
+
color: t ? "#fff" : "#30373e",
|
|
587
588
|
fontSize: "13px",
|
|
588
589
|
textDecoration: "none",
|
|
589
590
|
maxWidth: "220px"
|
|
590
591
|
};
|
|
591
|
-
return r ? /* @__PURE__ */
|
|
592
|
+
return r ? /* @__PURE__ */ a("a", {
|
|
592
593
|
href: r,
|
|
593
594
|
target: "_blank",
|
|
594
595
|
rel: "noopener noreferrer",
|
|
595
|
-
style:
|
|
596
|
+
style: i,
|
|
596
597
|
children: o
|
|
597
|
-
}) : /* @__PURE__ */
|
|
598
|
-
style:
|
|
598
|
+
}) : /* @__PURE__ */ a("div", {
|
|
599
|
+
style: i,
|
|
599
600
|
children: o
|
|
600
601
|
});
|
|
601
|
-
},
|
|
602
|
-
const r = /* @__PURE__ */
|
|
602
|
+
}, ke = ({ source: e, index: t }) => {
|
|
603
|
+
const r = /* @__PURE__ */ R("div", {
|
|
603
604
|
style: {
|
|
604
605
|
display: "flex",
|
|
605
606
|
alignItems: "center",
|
|
@@ -607,7 +608,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
607
608
|
width: "100%",
|
|
608
609
|
minWidth: 0
|
|
609
610
|
},
|
|
610
|
-
children: [/* @__PURE__ */
|
|
611
|
+
children: [/* @__PURE__ */ a("div", {
|
|
611
612
|
style: {
|
|
612
613
|
flexShrink: 0,
|
|
613
614
|
width: "18px",
|
|
@@ -622,8 +623,8 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
622
623
|
justifyContent: "center",
|
|
623
624
|
backgroundColor: "#f0f4ff"
|
|
624
625
|
},
|
|
625
|
-
children:
|
|
626
|
-
}), /* @__PURE__ */
|
|
626
|
+
children: t + 1
|
|
627
|
+
}), /* @__PURE__ */ a("div", {
|
|
627
628
|
style: {
|
|
628
629
|
fontSize: "12px",
|
|
629
630
|
overflow: "hidden",
|
|
@@ -634,7 +635,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
634
635
|
title: e.title,
|
|
635
636
|
children: e.title
|
|
636
637
|
})]
|
|
637
|
-
}),
|
|
638
|
+
}), n = {
|
|
638
639
|
display: "flex",
|
|
639
640
|
alignItems: "center",
|
|
640
641
|
padding: "8px 10px",
|
|
@@ -647,11 +648,11 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
647
648
|
minWidth: 0,
|
|
648
649
|
transition: "border-color 0.15s"
|
|
649
650
|
};
|
|
650
|
-
return e.url ? /* @__PURE__ */
|
|
651
|
+
return e.url ? /* @__PURE__ */ a("a", {
|
|
651
652
|
href: e.url,
|
|
652
653
|
target: "_blank",
|
|
653
654
|
rel: "noopener noreferrer",
|
|
654
|
-
style:
|
|
655
|
+
style: n,
|
|
655
656
|
onMouseEnter: (o) => {
|
|
656
657
|
o.currentTarget.style.borderColor = "#1b5fc4";
|
|
657
658
|
},
|
|
@@ -659,11 +660,11 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
659
660
|
o.currentTarget.style.borderColor = "#dee3e8";
|
|
660
661
|
},
|
|
661
662
|
children: r
|
|
662
|
-
}) : /* @__PURE__ */
|
|
663
|
-
style:
|
|
663
|
+
}) : /* @__PURE__ */ a("div", {
|
|
664
|
+
style: n,
|
|
664
665
|
children: r
|
|
665
666
|
});
|
|
666
|
-
},
|
|
667
|
+
}, Ie = () => /* @__PURE__ */ R("div", {
|
|
667
668
|
style: {
|
|
668
669
|
display: "flex",
|
|
669
670
|
gap: "4px",
|
|
@@ -673,31 +674,31 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
673
674
|
0,
|
|
674
675
|
1,
|
|
675
676
|
2
|
|
676
|
-
].map((e) => /* @__PURE__ */
|
|
677
|
+
].map((e) => /* @__PURE__ */ a("div", { style: {
|
|
677
678
|
width: "6px",
|
|
678
679
|
height: "6px",
|
|
679
680
|
borderRadius: "50%",
|
|
680
681
|
backgroundColor: "#b5bfc8",
|
|
681
682
|
animation: "ago-pulse 1.2s ease-in-out infinite",
|
|
682
683
|
animationDelay: `${e * 0.2}s`
|
|
683
|
-
} }, e)), /* @__PURE__ */
|
|
684
|
+
} }, e)), /* @__PURE__ */ a("style", { children: `
|
|
684
685
|
@keyframes ago-pulse {
|
|
685
686
|
0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
|
|
686
687
|
40% { opacity: 1; transform: scale(1); }
|
|
687
688
|
}
|
|
688
689
|
` })]
|
|
689
|
-
}), Me = ({ message: e, className:
|
|
690
|
-
const
|
|
691
|
-
return /* @__PURE__ */
|
|
692
|
-
className: `ago-message ago-message--${e.role} ${
|
|
690
|
+
}), Me = ({ message: e, className: t = "", showAgentName: r = !1, isLast: n = !1, onFollowUpClick: o }) => {
|
|
691
|
+
const i = e.role === "user", c = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
692
|
+
return /* @__PURE__ */ R("div", {
|
|
693
|
+
className: `ago-message ago-message--${e.role} ${t}`,
|
|
693
694
|
style: {
|
|
694
695
|
display: "flex",
|
|
695
696
|
flexDirection: "column",
|
|
696
|
-
alignItems:
|
|
697
|
+
alignItems: i ? "flex-end" : "flex-start",
|
|
697
698
|
marginBottom: "16px"
|
|
698
699
|
},
|
|
699
700
|
children: [
|
|
700
|
-
!
|
|
701
|
+
!i && r && e.agent && /* @__PURE__ */ a("div", {
|
|
701
702
|
className: "ago-message__agent",
|
|
702
703
|
style: {
|
|
703
704
|
display: "flex",
|
|
@@ -711,7 +712,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
711
712
|
},
|
|
712
713
|
children: e.agent.displayName || e.agent.name
|
|
713
714
|
}),
|
|
714
|
-
!
|
|
715
|
+
!i && e.sources && e.sources.length > 0 && /* @__PURE__ */ a("div", {
|
|
715
716
|
className: "ago-message__sources",
|
|
716
717
|
style: {
|
|
717
718
|
display: "grid",
|
|
@@ -721,41 +722,41 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
721
722
|
width: "100%",
|
|
722
723
|
maxWidth: "85%"
|
|
723
724
|
},
|
|
724
|
-
children: e.sources.map((l,
|
|
725
|
+
children: e.sources.map((l, f) => /* @__PURE__ */ a(ke, {
|
|
725
726
|
source: l,
|
|
726
|
-
index:
|
|
727
|
+
index: f
|
|
727
728
|
}, l.id))
|
|
728
729
|
}),
|
|
729
|
-
e.attachments && e.attachments.length > 0 && /* @__PURE__ */
|
|
730
|
+
e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
|
|
730
731
|
className: "ago-message__attachments",
|
|
731
732
|
style: {
|
|
732
733
|
display: "flex",
|
|
733
734
|
flexWrap: "wrap",
|
|
734
735
|
gap: "6px",
|
|
735
736
|
marginBottom: "6px",
|
|
736
|
-
justifyContent:
|
|
737
|
+
justifyContent: i ? "flex-end" : "flex-start",
|
|
737
738
|
maxWidth: "75%"
|
|
738
739
|
},
|
|
739
|
-
children: e.attachments.map((l) => /* @__PURE__ */
|
|
740
|
+
children: e.attachments.map((l) => /* @__PURE__ */ a(Se, {
|
|
740
741
|
attachment: l,
|
|
741
|
-
isUser:
|
|
742
|
+
isUser: i
|
|
742
743
|
}, l.id))
|
|
743
744
|
}),
|
|
744
|
-
(e.content || c) && /* @__PURE__ */
|
|
745
|
+
(e.content || c) && /* @__PURE__ */ a("div", {
|
|
745
746
|
className: "ago-message__content",
|
|
746
747
|
style: {
|
|
747
|
-
maxWidth:
|
|
748
|
-
padding:
|
|
749
|
-
borderRadius:
|
|
750
|
-
backgroundColor:
|
|
751
|
-
color:
|
|
748
|
+
maxWidth: i ? "75%" : "100%",
|
|
749
|
+
padding: i ? "10px 14px" : "2px 8px",
|
|
750
|
+
borderRadius: i ? "16px" : "0",
|
|
751
|
+
backgroundColor: i ? "#03182f" : "transparent",
|
|
752
|
+
color: i ? "#fff" : "#30373e",
|
|
752
753
|
wordBreak: "break-word",
|
|
753
754
|
fontSize: "16px",
|
|
754
755
|
lineHeight: "1.6"
|
|
755
756
|
},
|
|
756
|
-
children: e.content ? /* @__PURE__ */
|
|
757
|
+
children: e.content ? /* @__PURE__ */ a(Ce, { content: e.content }) : c && /* @__PURE__ */ a(Ie, {})
|
|
757
758
|
}),
|
|
758
|
-
|
|
759
|
+
n && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
|
|
759
760
|
className: "ago-message__followups",
|
|
760
761
|
style: {
|
|
761
762
|
display: "flex",
|
|
@@ -763,7 +764,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
763
764
|
gap: "8px",
|
|
764
765
|
marginTop: "10px"
|
|
765
766
|
},
|
|
766
|
-
children: e.followUpReplies.map((l,
|
|
767
|
+
children: e.followUpReplies.map((l, f) => /* @__PURE__ */ a("button", {
|
|
767
768
|
type: "button",
|
|
768
769
|
className: "ago-message__followup-btn",
|
|
769
770
|
disabled: !o,
|
|
@@ -779,52 +780,52 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
779
780
|
cursor: o ? "pointer" : "default",
|
|
780
781
|
transition: "border-color 0.15s"
|
|
781
782
|
},
|
|
782
|
-
onMouseEnter: (
|
|
783
|
-
|
|
783
|
+
onMouseEnter: (u) => {
|
|
784
|
+
u.currentTarget.style.borderColor = "#1b5fc4";
|
|
784
785
|
},
|
|
785
|
-
onMouseLeave: (
|
|
786
|
-
|
|
786
|
+
onMouseLeave: (u) => {
|
|
787
|
+
u.currentTarget.style.borderColor = "#dee3e8";
|
|
787
788
|
},
|
|
788
789
|
children: l
|
|
789
|
-
},
|
|
790
|
+
}, f))
|
|
790
791
|
})
|
|
791
792
|
]
|
|
792
793
|
});
|
|
793
|
-
}, Oe = ({ client: e, conversationId:
|
|
794
|
-
const
|
|
794
|
+
}, Oe = ({ client: e, conversationId: t, title: r = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: o = "Type a message...", allowFiles: i = !1, height: c = 500, logoUrl: l, showAgentName: f = !1, forms: u, onFollowUpClick: y, className: v = "", onMessageSent: I, onMessageReceived: x }) => {
|
|
795
|
+
const h = E(null), C = z(), S = e ?? C, { messages: s, isLoading: b, error: d, sendMessage: p } = G({
|
|
795
796
|
client: e,
|
|
796
|
-
conversationId:
|
|
797
|
+
conversationId: t
|
|
797
798
|
});
|
|
798
799
|
k(() => {
|
|
799
|
-
if (!
|
|
800
|
-
let
|
|
801
|
-
const
|
|
802
|
-
return Promise.all(
|
|
803
|
-
if (!
|
|
804
|
-
for (const
|
|
800
|
+
if (!S || !u || u.length === 0) return;
|
|
801
|
+
let w = !1;
|
|
802
|
+
const F = [];
|
|
803
|
+
return Promise.all(u.map((N) => N.schema != null ? Promise.resolve(O(N)) : H(S, N))).then((N) => {
|
|
804
|
+
if (!w)
|
|
805
|
+
for (const U of N) F.push(U.install(S));
|
|
805
806
|
}).catch(() => {
|
|
806
807
|
}), () => {
|
|
807
|
-
|
|
808
|
+
w = !0, F.forEach((N) => N());
|
|
808
809
|
};
|
|
809
|
-
}, [
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
810
|
+
}, [S, u ? JSON.stringify(u.map((w) => [
|
|
811
|
+
w.name,
|
|
812
|
+
w.schema ?? null,
|
|
813
|
+
w.submit ?? !1,
|
|
814
|
+
w.description ?? null
|
|
814
815
|
])) : ""]), k(() => {
|
|
815
|
-
|
|
816
|
-
}, [
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
id:
|
|
820
|
-
content:
|
|
816
|
+
h.current?.scrollIntoView({ behavior: "smooth" });
|
|
817
|
+
}, [s]), k(() => {
|
|
818
|
+
const w = s[s.length - 1];
|
|
819
|
+
w && w.role === "assistant" && w.status === "DONE" && x && x({
|
|
820
|
+
id: w.id,
|
|
821
|
+
content: w.content
|
|
821
822
|
});
|
|
822
|
-
}, [
|
|
823
|
-
const
|
|
824
|
-
I?.(
|
|
825
|
-
},
|
|
826
|
-
return /* @__PURE__ */
|
|
827
|
-
className: `ago-chat-widget ${
|
|
823
|
+
}, [s, x]);
|
|
824
|
+
const m = async (w, F) => {
|
|
825
|
+
I?.(w), await p(w, F);
|
|
826
|
+
}, g = s[s.length - 1], W = b && g?.role === "assistant" && (g.status === "IN_PROGRESS" || g.status === "WAITING_CLIENT"), K = y === !1 ? void 0 : y ?? ((w) => m(w));
|
|
827
|
+
return /* @__PURE__ */ R("div", {
|
|
828
|
+
className: `ago-chat-widget ${v}`,
|
|
828
829
|
style: {
|
|
829
830
|
display: "flex",
|
|
830
831
|
flexDirection: "column",
|
|
@@ -838,7 +839,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
838
839
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px"
|
|
839
840
|
},
|
|
840
841
|
children: [
|
|
841
|
-
/* @__PURE__ */
|
|
842
|
+
/* @__PURE__ */ R("div", {
|
|
842
843
|
className: "ago-chat-widget__header",
|
|
843
844
|
style: {
|
|
844
845
|
padding: "14px 16px",
|
|
@@ -849,14 +850,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
849
850
|
alignItems: "center",
|
|
850
851
|
gap: "10px"
|
|
851
852
|
},
|
|
852
|
-
children: [l && /* @__PURE__ */
|
|
853
|
+
children: [l && /* @__PURE__ */ a("img", {
|
|
853
854
|
src: l,
|
|
854
855
|
alt: "Logo",
|
|
855
856
|
style: {
|
|
856
857
|
height: "24px",
|
|
857
858
|
width: "auto"
|
|
858
859
|
}
|
|
859
|
-
}), /* @__PURE__ */
|
|
860
|
+
}), /* @__PURE__ */ a("h3", {
|
|
860
861
|
style: {
|
|
861
862
|
margin: 0,
|
|
862
863
|
fontSize: "15px",
|
|
@@ -865,7 +866,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
865
866
|
children: r
|
|
866
867
|
})]
|
|
867
868
|
}),
|
|
868
|
-
/* @__PURE__ */
|
|
869
|
+
/* @__PURE__ */ R("div", {
|
|
869
870
|
className: "ago-chat-widget__messages",
|
|
870
871
|
role: "log",
|
|
871
872
|
"aria-live": "polite",
|
|
@@ -878,7 +879,7 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
878
879
|
backgroundColor: "#fbfbfb"
|
|
879
880
|
},
|
|
880
881
|
children: [
|
|
881
|
-
|
|
882
|
+
s.length === 0 ? /* @__PURE__ */ a("div", {
|
|
882
883
|
style: {
|
|
883
884
|
textAlign: "center",
|
|
884
885
|
color: "#6b6d6f",
|
|
@@ -886,14 +887,14 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
886
887
|
fontSize: "16px",
|
|
887
888
|
lineHeight: "1.5"
|
|
888
889
|
},
|
|
889
|
-
children:
|
|
890
|
-
}) :
|
|
891
|
-
message:
|
|
892
|
-
showAgentName:
|
|
893
|
-
isLast:
|
|
890
|
+
children: n
|
|
891
|
+
}) : s.map((w, F) => /* @__PURE__ */ a(Me, {
|
|
892
|
+
message: w,
|
|
893
|
+
showAgentName: f,
|
|
894
|
+
isLast: F === s.length - 1,
|
|
894
895
|
onFollowUpClick: K
|
|
895
|
-
},
|
|
896
|
-
|
|
896
|
+
}, w.id)),
|
|
897
|
+
d && /* @__PURE__ */ a("div", {
|
|
897
898
|
role: "alert",
|
|
898
899
|
style: {
|
|
899
900
|
padding: "10px 14px",
|
|
@@ -904,73 +905,73 @@ var se = ({ onSend: e, disabled: n = !1, placeholder: r = "Type a message...", a
|
|
|
904
905
|
fontSize: "13px",
|
|
905
906
|
border: "1px solid #fecaca"
|
|
906
907
|
},
|
|
907
|
-
children:
|
|
908
|
+
children: d.message
|
|
908
909
|
}),
|
|
909
|
-
/* @__PURE__ */
|
|
910
|
+
/* @__PURE__ */ a("div", { ref: h })
|
|
910
911
|
]
|
|
911
912
|
}),
|
|
912
|
-
/* @__PURE__ */
|
|
913
|
-
onSend:
|
|
914
|
-
disabled:
|
|
913
|
+
/* @__PURE__ */ a(se, {
|
|
914
|
+
onSend: m,
|
|
915
|
+
disabled: W,
|
|
915
916
|
placeholder: o,
|
|
916
|
-
allowFiles:
|
|
917
|
+
allowFiles: i
|
|
917
918
|
})
|
|
918
919
|
]
|
|
919
920
|
});
|
|
920
921
|
};
|
|
921
|
-
function
|
|
922
|
-
const r =
|
|
923
|
-
if (!
|
|
924
|
-
const [o,
|
|
925
|
-
|
|
922
|
+
function Re({ client: e, autoLoad: t = !0 } = {}) {
|
|
923
|
+
const r = z(), n = e || r;
|
|
924
|
+
if (!n) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
925
|
+
const [o, i] = M([]), [c, l] = M(null), [f, u] = M(!1), [y, v] = M(null), I = A(async () => {
|
|
926
|
+
u(!0), v(null);
|
|
926
927
|
try {
|
|
927
|
-
|
|
928
|
-
} catch (
|
|
929
|
-
|
|
928
|
+
i(await n.getConversations());
|
|
929
|
+
} catch (C) {
|
|
930
|
+
v(C instanceof Error ? C : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
930
931
|
} finally {
|
|
931
|
-
|
|
932
|
+
u(!1);
|
|
932
933
|
}
|
|
933
|
-
}, [
|
|
934
|
-
|
|
934
|
+
}, [n]), x = A(async (C) => {
|
|
935
|
+
u(!0), v(null);
|
|
935
936
|
try {
|
|
936
|
-
l(await
|
|
937
|
-
} catch (
|
|
938
|
-
|
|
937
|
+
l(await n.getConversation(C));
|
|
938
|
+
} catch (S) {
|
|
939
|
+
v(S instanceof Error ? S : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
939
940
|
} finally {
|
|
940
|
-
|
|
941
|
+
u(!1);
|
|
941
942
|
}
|
|
942
|
-
}, [
|
|
943
|
+
}, [n]), h = A(() => {
|
|
943
944
|
l(null);
|
|
944
945
|
}, []);
|
|
945
946
|
return k(() => {
|
|
946
|
-
|
|
947
|
-
}, [
|
|
947
|
+
t && I();
|
|
948
|
+
}, [t, I]), {
|
|
948
949
|
conversations: o,
|
|
949
950
|
currentConversation: c,
|
|
950
|
-
isLoading:
|
|
951
|
-
error:
|
|
952
|
-
selectConversation:
|
|
953
|
-
startNewConversation:
|
|
951
|
+
isLoading: f,
|
|
952
|
+
error: y,
|
|
953
|
+
selectConversation: x,
|
|
954
|
+
startNewConversation: h,
|
|
954
955
|
refreshConversations: I
|
|
955
956
|
};
|
|
956
957
|
}
|
|
957
958
|
function $e(e = {}) {
|
|
958
|
-
const
|
|
959
|
+
const t = z(), r = e.client || t;
|
|
959
960
|
if (!r) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
960
|
-
const
|
|
961
|
+
const n = G({
|
|
961
962
|
client: r,
|
|
962
963
|
conversationId: e.conversationId
|
|
963
|
-
}), o =
|
|
964
|
+
}), o = Re({
|
|
964
965
|
client: r,
|
|
965
966
|
autoLoad: e.autoLoad
|
|
966
967
|
});
|
|
967
968
|
return {
|
|
968
|
-
messages:
|
|
969
|
-
isLoading:
|
|
970
|
-
error:
|
|
971
|
-
sendMessage:
|
|
972
|
-
clearMessages:
|
|
973
|
-
conversationId:
|
|
969
|
+
messages: n.messages,
|
|
970
|
+
isLoading: n.isLoading,
|
|
971
|
+
error: n.error || o.error,
|
|
972
|
+
sendMessage: n.sendMessage,
|
|
973
|
+
clearMessages: n.clearMessages,
|
|
974
|
+
conversationId: n.conversationId,
|
|
974
975
|
conversations: o.conversations,
|
|
975
976
|
currentConversation: o.currentConversation,
|
|
976
977
|
isConversationsLoading: o.isLoading,
|
|
@@ -979,125 +980,68 @@ function $e(e = {}) {
|
|
|
979
980
|
refreshConversations: o.refreshConversations
|
|
980
981
|
};
|
|
981
982
|
}
|
|
982
|
-
function
|
|
983
|
-
const r =
|
|
983
|
+
function Be(e, t) {
|
|
984
|
+
const r = P(), { name: n, description: o, parameters: i, handler: c, maxResultBytes: l } = typeof e == "string" ? {
|
|
984
985
|
name: e,
|
|
985
|
-
...
|
|
986
|
-
} : e,
|
|
987
|
-
|
|
988
|
-
const
|
|
989
|
-
return r.registerFunction(
|
|
986
|
+
...t
|
|
987
|
+
} : e, f = E(c);
|
|
988
|
+
f.current = c, k(() => {
|
|
989
|
+
const u = (y) => f.current(y);
|
|
990
|
+
return r.registerFunction(n, u, {
|
|
990
991
|
description: o,
|
|
991
|
-
parameters:
|
|
992
|
+
parameters: i,
|
|
993
|
+
maxResultBytes: l
|
|
992
994
|
}), () => {
|
|
993
|
-
r.unregisterFunction(
|
|
995
|
+
r.unregisterFunction(n);
|
|
994
996
|
};
|
|
995
997
|
}, [
|
|
996
998
|
r,
|
|
997
|
-
|
|
999
|
+
n,
|
|
998
1000
|
o,
|
|
999
|
-
|
|
1001
|
+
i,
|
|
1002
|
+
l
|
|
1000
1003
|
]);
|
|
1001
1004
|
}
|
|
1002
|
-
function
|
|
1003
|
-
const r =
|
|
1004
|
-
|
|
1005
|
+
function Ge(e, t) {
|
|
1006
|
+
const r = P(), n = E(e);
|
|
1007
|
+
n.current = e, k(() => (r.registerNavigationFunction((o) => n.current(o), t), () => {
|
|
1005
1008
|
r.unregisterNavigationFunction();
|
|
1006
|
-
}), [r,
|
|
1009
|
+
}), [r, t]);
|
|
1007
1010
|
}
|
|
1008
|
-
function
|
|
1009
|
-
const r =
|
|
1011
|
+
function Ke(e, t) {
|
|
1012
|
+
const r = P(), n = t?.functionName ?? "setPageState", o = E(e);
|
|
1010
1013
|
o.current = e, k(() => {
|
|
1011
|
-
const
|
|
1012
|
-
const l = () => o.current.find((
|
|
1014
|
+
const i = o.current.map((c) => {
|
|
1015
|
+
const l = () => o.current.find((f) => f.name === c.name) ?? c;
|
|
1013
1016
|
return {
|
|
1014
1017
|
name: c.name,
|
|
1015
1018
|
description: c.description,
|
|
1016
1019
|
schema: c.schema,
|
|
1017
1020
|
get: c.get ? () => l().get?.() : void 0,
|
|
1018
|
-
set: (
|
|
1021
|
+
set: (f) => l().set(f)
|
|
1019
1022
|
};
|
|
1020
1023
|
});
|
|
1021
|
-
return r.registerPageStateFunction(
|
|
1022
|
-
r.unregisterPageStateFunction(
|
|
1024
|
+
return r.registerPageStateFunction(i, { functionName: n }), () => {
|
|
1025
|
+
r.unregisterPageStateFunction(n);
|
|
1023
1026
|
};
|
|
1024
|
-
}, [r,
|
|
1027
|
+
}, [r, n]);
|
|
1025
1028
|
}
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
navigationFunctions: e?.navigationFunctions ?? ["navigateToPage"],
|
|
1030
|
-
pageStateFunctionName: e?.pageStateFunctionName ?? "setPageState",
|
|
1031
|
-
continuationPrompt: e?.continuationPrompt ?? Re,
|
|
1032
|
-
maxDepth: e?.maxDepth ?? 1,
|
|
1033
|
-
readinessTimeoutMs: e?.readinessTimeoutMs ?? 4e3,
|
|
1034
|
-
settleMs: e?.settleMs ?? 150,
|
|
1035
|
-
enabled: e?.enabled ?? !0
|
|
1036
|
-
};
|
|
1029
|
+
function Ue(e) {
|
|
1030
|
+
const t = P(), r = E(e);
|
|
1031
|
+
r.current = e, k(() => X(t, () => r.current), [t]);
|
|
1037
1032
|
}
|
|
1038
|
-
function
|
|
1039
|
-
const n =
|
|
1040
|
-
|
|
1041
|
-
const t = {
|
|
1042
|
-
navigated: !1,
|
|
1043
|
-
pausedTurnNavigated: !1,
|
|
1044
|
-
depth: 0,
|
|
1045
|
-
runId: 0,
|
|
1046
|
-
ourSendPending: !1
|
|
1047
|
-
}, o = () => n.getRegisteredFunctions().some((f) => f.name === r.current.pageStateFunctionName), s = (f) => new Promise((m) => {
|
|
1048
|
-
let S = !1;
|
|
1049
|
-
const w = (p) => {
|
|
1050
|
-
S || (S = !0, clearTimeout(u), n.off("context:changed", x), m(p));
|
|
1051
|
-
}, a = () => setTimeout(() => w(f === t.runId && o()), r.current.settleMs), x = () => {
|
|
1052
|
-
if (f !== t.runId) return w(!1);
|
|
1053
|
-
o() && (n.off("context:changed", x), a());
|
|
1054
|
-
}, u = setTimeout(() => w(!1), r.current.readinessTimeoutMs);
|
|
1055
|
-
o() ? a() : n.on("context:changed", x);
|
|
1056
|
-
}), c = async (f) => {
|
|
1057
|
-
const m = ++t.runId;
|
|
1058
|
-
if (!(!await s(m) || m !== t.runId)) {
|
|
1059
|
-
t.depth += 1, t.ourSendPending = !0;
|
|
1060
|
-
try {
|
|
1061
|
-
await n.sendMessage(r.current.continuationPrompt, {
|
|
1062
|
-
conversationId: f,
|
|
1063
|
-
hidden: !0
|
|
1064
|
-
});
|
|
1065
|
-
} catch {
|
|
1066
|
-
t.ourSendPending = !1;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
}, l = (f) => {
|
|
1070
|
-
r.current.navigationFunctions.includes(f.functionName) && (t.navigated = !0);
|
|
1071
|
-
}, g = n.registerResumeGate(async () => {
|
|
1072
|
-
r.current.enabled && t.pausedTurnNavigated && (t.pausedTurnNavigated = !1, await s(++t.runId));
|
|
1073
|
-
}), d = () => {
|
|
1074
|
-
t.pausedTurnNavigated = t.navigated, t.navigated = !1;
|
|
1075
|
-
}, v = () => {
|
|
1076
|
-
t.ourSendPending || (t.depth = 0, t.runId += 1);
|
|
1077
|
-
}, y = (f) => {
|
|
1078
|
-
t.ourSendPending = !1;
|
|
1079
|
-
const m = t.navigated;
|
|
1080
|
-
t.navigated = !1, r.current.enabled && m && (t.depth >= r.current.maxDepth || c(f.conversationId));
|
|
1081
|
-
}, I = () => {
|
|
1082
|
-
t.ourSendPending = !1;
|
|
1083
|
-
};
|
|
1084
|
-
return n.on("function:invoke", l), n.on("message:start", v), n.on("message:waiting-client", d), n.on("message:complete", y), n.on("message:error", I), () => {
|
|
1085
|
-
t.runId += 1, g(), n.off("function:invoke", l), n.off("message:start", v), n.off("message:waiting-client", d), n.off("message:complete", y), n.off("message:error", I);
|
|
1086
|
-
};
|
|
1087
|
-
}, [n]);
|
|
1088
|
-
}
|
|
1089
|
-
function qe(e, n) {
|
|
1090
|
-
const r = _(), t = te(), o = n ?? t, s = A(e);
|
|
1091
|
-
s.current = e;
|
|
1033
|
+
function qe(e, t) {
|
|
1034
|
+
const r = P(), n = te(), o = t ?? n, i = E(e);
|
|
1035
|
+
i.current = e;
|
|
1092
1036
|
const c = typeof e == "function";
|
|
1093
1037
|
k(() => {
|
|
1094
|
-
if (typeof
|
|
1095
|
-
const l = () =>
|
|
1038
|
+
if (typeof i.current == "function") {
|
|
1039
|
+
const l = () => i.current();
|
|
1096
1040
|
return r.addDynamicContext(o, l), () => {
|
|
1097
1041
|
r.removeDynamicContext(o);
|
|
1098
1042
|
};
|
|
1099
1043
|
}
|
|
1100
|
-
return r.setContext(o,
|
|
1044
|
+
return r.setContext(o, i.current), () => {
|
|
1101
1045
|
r.removeContext(o);
|
|
1102
1046
|
};
|
|
1103
1047
|
}, [
|
|
@@ -1110,67 +1054,67 @@ function qe(e, n) {
|
|
|
1110
1054
|
function Ae(e) {
|
|
1111
1055
|
return ne(e.subscribe, e.get, e.get);
|
|
1112
1056
|
}
|
|
1113
|
-
var
|
|
1057
|
+
var D = {
|
|
1114
1058
|
missing: [],
|
|
1115
1059
|
complete: !1
|
|
1116
1060
|
};
|
|
1117
1061
|
function Je(e) {
|
|
1118
|
-
const
|
|
1062
|
+
const t = P(), r = e.schema != null, n = JSON.stringify(e.schema ?? null), o = e.submit, i = o ? typeof o == "string" ? `client:${o}` : o.via === "backend" ? "backend" : "handler" in o ? "client:handler" : `client:${o.url}` : "none", c = JSON.stringify(e.initialValues ?? null), l = T(() => r ? O(e) : null, [
|
|
1119
1063
|
r,
|
|
1120
1064
|
e.name,
|
|
1121
|
-
|
|
1122
|
-
|
|
1065
|
+
n,
|
|
1066
|
+
i,
|
|
1123
1067
|
c,
|
|
1124
1068
|
e.autoSubmit
|
|
1125
|
-
]), [
|
|
1069
|
+
]), [f, u] = M({
|
|
1126
1070
|
collector: null,
|
|
1127
1071
|
loading: !r,
|
|
1128
1072
|
error: null
|
|
1129
1073
|
});
|
|
1130
1074
|
k(() => {
|
|
1131
1075
|
if (r) return;
|
|
1132
|
-
let
|
|
1133
|
-
return
|
|
1076
|
+
let b = !1;
|
|
1077
|
+
return u({
|
|
1134
1078
|
collector: null,
|
|
1135
1079
|
loading: !0,
|
|
1136
1080
|
error: null
|
|
1137
|
-
}),
|
|
1138
|
-
|
|
1139
|
-
collector:
|
|
1081
|
+
}), H(t, e).then((d) => {
|
|
1082
|
+
b || u({
|
|
1083
|
+
collector: d,
|
|
1140
1084
|
loading: !1,
|
|
1141
1085
|
error: null
|
|
1142
1086
|
});
|
|
1143
|
-
}).catch((
|
|
1144
|
-
|
|
1087
|
+
}).catch((d) => {
|
|
1088
|
+
b || u({
|
|
1145
1089
|
collector: null,
|
|
1146
1090
|
loading: !1,
|
|
1147
|
-
error:
|
|
1091
|
+
error: d instanceof Error ? d : new Error(String(d))
|
|
1148
1092
|
});
|
|
1149
1093
|
}), () => {
|
|
1150
|
-
|
|
1094
|
+
b = !0;
|
|
1151
1095
|
};
|
|
1152
1096
|
}, [
|
|
1153
|
-
|
|
1097
|
+
t,
|
|
1154
1098
|
r,
|
|
1155
1099
|
e.name,
|
|
1156
|
-
|
|
1100
|
+
i,
|
|
1157
1101
|
c,
|
|
1158
1102
|
e.autoSubmit
|
|
1159
1103
|
]);
|
|
1160
|
-
const
|
|
1104
|
+
const y = r ? l : f.collector, v = r ? !1 : f.loading, I = r ? null : f.error;
|
|
1161
1105
|
k(() => {
|
|
1162
|
-
if (
|
|
1163
|
-
return
|
|
1164
|
-
}, [
|
|
1165
|
-
const
|
|
1106
|
+
if (y)
|
|
1107
|
+
return y.install(t);
|
|
1108
|
+
}, [t, y]);
|
|
1109
|
+
const x = T(() => Q({
|
|
1166
1110
|
values: e.initialValues ?? {},
|
|
1167
1111
|
submitted: !1
|
|
1168
|
-
}), [c]),
|
|
1169
|
-
...
|
|
1170
|
-
...
|
|
1171
|
-
}), [
|
|
1112
|
+
}), [c]), h = Ae(y?.store ?? x), C = T(() => y?.getStatus() ?? D, [h, y]), S = T(() => ({
|
|
1113
|
+
...h,
|
|
1114
|
+
...C
|
|
1115
|
+
}), [h, C]), s = T(() => ({
|
|
1172
1116
|
name: e.name,
|
|
1173
|
-
store:
|
|
1117
|
+
store: x,
|
|
1174
1118
|
functions: [],
|
|
1175
1119
|
contextKey: `form:${e.name}`,
|
|
1176
1120
|
contextProvider: () => ({
|
|
@@ -1185,17 +1129,17 @@ function Je(e) {
|
|
|
1185
1129
|
ok: !1,
|
|
1186
1130
|
error: "Form definition not loaded yet."
|
|
1187
1131
|
}),
|
|
1188
|
-
getValues: () =>
|
|
1132
|
+
getValues: () => x.get().values,
|
|
1189
1133
|
setValues: () => {
|
|
1190
1134
|
},
|
|
1191
1135
|
reset: () => {
|
|
1192
1136
|
},
|
|
1193
|
-
getStatus: () =>
|
|
1194
|
-
}), [e.name,
|
|
1137
|
+
getStatus: () => D
|
|
1138
|
+
}), [e.name, x]);
|
|
1195
1139
|
return {
|
|
1196
|
-
...
|
|
1197
|
-
state:
|
|
1198
|
-
loading:
|
|
1140
|
+
...y ?? s,
|
|
1141
|
+
state: S,
|
|
1142
|
+
loading: v,
|
|
1199
1143
|
error: I
|
|
1200
1144
|
};
|
|
1201
1145
|
}
|
|
@@ -1203,23 +1147,23 @@ export {
|
|
|
1203
1147
|
He as AgoProvider,
|
|
1204
1148
|
se as ChatInput,
|
|
1205
1149
|
Oe as ChatWidget,
|
|
1206
|
-
|
|
1150
|
+
Ce as Markdown,
|
|
1207
1151
|
Me as Message,
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1152
|
+
O as createFormCollector,
|
|
1153
|
+
Pe as createMockClient,
|
|
1154
|
+
_e as deriveFormStatus,
|
|
1155
|
+
H as loadFormCollector,
|
|
1212
1156
|
ae as useAgo,
|
|
1213
|
-
|
|
1214
|
-
|
|
1157
|
+
Ue as useAgoAutoContinueAfterNavigation,
|
|
1158
|
+
P as useAgoClient,
|
|
1215
1159
|
qe as useAgoContext,
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1160
|
+
Be as useAgoFunction,
|
|
1161
|
+
Ge as useAgoNavigation,
|
|
1162
|
+
Ke as useAgoPageState,
|
|
1219
1163
|
Ae as useAgoStore,
|
|
1220
1164
|
$e as useChat,
|
|
1221
|
-
|
|
1165
|
+
Re as useConversation,
|
|
1222
1166
|
Je as useFormCollector,
|
|
1223
|
-
|
|
1224
|
-
|
|
1167
|
+
G as useMessages,
|
|
1168
|
+
z as useOptionalAgoClient
|
|
1225
1169
|
};
|