@useago/sdk 1.7.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +90 -0
- package/README.md +53 -6
- package/dist/angular.cjs +1 -1
- package/dist/angular.d.cts +89 -5
- package/dist/angular.d.ts +89 -5
- package/dist/angular.js +11 -7
- package/dist/{createConversationSession-Bgvx753t.js → createConversationSession-BaaXBQ5b.js} +3 -3
- package/dist/createConversationSession-CU0b-t1W.cjs +1 -0
- package/dist/{createFormCollector-CM3qjGcM.js → createFormCollector-Cf7kGhCB.js} +1 -1
- package/dist/createFormCollector-DfN1xZBy.cjs +1 -0
- package/dist/{createMockClient-BDLW6tVc.js → createMockClient-5YF-ZbVu.js} +22 -21
- package/dist/createMockClient-BZbOe-23.cjs +1 -0
- package/dist/devtools.cjs +61 -12
- package/dist/devtools.d.cts +90 -5
- package/dist/devtools.d.ts +90 -5
- package/dist/devtools.js +225 -73
- package/dist/errors-BLfjXnLB.js +32 -0
- package/dist/errors-o1IB5fEu.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +100 -3
- package/dist/index.d.ts +100 -3
- package/dist/index.js +77 -75
- package/dist/react.cjs +4 -4
- package/dist/react.d.cts +197 -3
- package/dist/react.d.ts +197 -3
- package/dist/react.js +1034 -752
- package/dist/testing.cjs +1 -1
- package/dist/testing.d.cts +80 -3
- package/dist/testing.d.ts +80 -3
- package/dist/testing.js +1 -1
- package/dist/{AgoClient-BJjLTOw4.js → types-CPga11Of.js} +489 -386
- package/dist/types-D3YQl1jx.cjs +9 -0
- package/dist/vue.cjs +1 -1
- package/dist/vue.d.cts +110 -3
- package/dist/vue.d.ts +110 -3
- package/dist/vue.js +202 -154
- package/dist/widget.cjs +4 -4
- package/dist/widget.d.cts +148 -3
- package/dist/widget.d.ts +148 -3
- package/dist/widget.js +871 -651
- package/llms-full.txt +144 -30
- package/package.json +1 -1
- package/dist/AgoClient-B_u_d-XS.cjs +0 -9
- package/dist/createConversationSession-BCdwAhLF.cjs +0 -1
- package/dist/createFormCollector-ssBP8u0p.cjs +0 -1
- package/dist/createMockClient-BSNuN3ys.cjs +0 -1
package/dist/react.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { t as
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { a as Fe, c as We, g as ze, n as De, o as Pe, s as Le, t as He } from "./types-CPga11Of.js";
|
|
2
|
+
import { n as X } from "./errors-BLfjXnLB.js";
|
|
3
|
+
import { t as Be } from "./autoContinue-CC8K9mBU.js";
|
|
4
|
+
import { n as Lt, r as ge, t as me } from "./createFormCollector-Cf7kGhCB.js";
|
|
5
|
+
import { t as Bt } from "./createMockClient-5YF-ZbVu.js";
|
|
6
|
+
import { C as Oe, S as qe, n as je } from "./sheetController-CBUVOroo.js";
|
|
7
|
+
import $e, { createContext as Ke, forwardRef as Ue, useCallback as _, useContext as he, useEffect as E, useId as Ge, useImperativeHandle as Je, useMemo as B, useRef as D, useState as T, useSyncExternalStore as xe } from "react";
|
|
8
|
+
import { Fragment as be, jsx as a, jsxs as M } from "react/jsx-runtime";
|
|
9
|
+
import Ve from "react-markdown";
|
|
10
|
+
import Ye from "remark-gfm";
|
|
11
|
+
function Xe(e) {
|
|
12
|
+
const [r, t] = T(!1), o = D(null), n = B(() => {
|
|
13
|
+
if (o.current && (o.current.destroy(), o.current = null), !e) return null;
|
|
14
|
+
const l = new De(e);
|
|
15
|
+
return o.current = l, l;
|
|
15
16
|
}, [e?.baseUrl, e?.widgetId]);
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
}), [n]),
|
|
19
|
-
|
|
17
|
+
return E(() => (n && o.current === null && (o.current = n, n.reviveAfterDestroy()), t(!0), () => {
|
|
18
|
+
o.current?.destroy(), o.current = null;
|
|
19
|
+
}), [n]), E(() => {
|
|
20
|
+
o.current && e && o.current.updateConfig({
|
|
20
21
|
agent: e.agent,
|
|
21
22
|
defaultAgentId: e.defaultAgentId,
|
|
22
23
|
permission: e.permission,
|
|
@@ -35,54 +36,54 @@ function Ge(e) {
|
|
|
35
36
|
e?.warnOnEmptyReply
|
|
36
37
|
]), {
|
|
37
38
|
client: n,
|
|
38
|
-
isReady:
|
|
39
|
+
isReady: r
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
|
-
var
|
|
42
|
-
const { client:
|
|
43
|
-
return
|
|
42
|
+
var ee = Ke(null), Ut = ({ children: e, client: r, tools: t, helpers: o, pageContext: n, ...l }) => {
|
|
43
|
+
const { client: s } = Xe(r ? null : l), i = r || s;
|
|
44
|
+
return E(() => {
|
|
44
45
|
if (!(!t || t.length === 0)) {
|
|
45
|
-
for (const
|
|
46
|
+
for (const u of t) i.register(u);
|
|
46
47
|
return () => {
|
|
47
|
-
for (const
|
|
48
|
+
for (const u of t) i.unregisterFunction(u.name);
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
|
-
}, [
|
|
51
|
-
if (!
|
|
52
|
-
const
|
|
53
|
-
return import("./functions-tzyOZNp6.js").then((
|
|
54
|
-
for (const [
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
57
|
-
console.warn(`[AGO] Unknown helper: "${
|
|
51
|
+
}, [i, t]), E(() => {
|
|
52
|
+
if (!o) return;
|
|
53
|
+
const u = [];
|
|
54
|
+
return import("./functions-tzyOZNp6.js").then((c) => c.n).then((c) => {
|
|
55
|
+
for (const [p, v] of Object.entries(o)) {
|
|
56
|
+
const S = c[p];
|
|
57
|
+
if (!S) {
|
|
58
|
+
console.warn(`[AGO] Unknown helper: "${p}"`);
|
|
58
59
|
continue;
|
|
59
60
|
}
|
|
60
|
-
const
|
|
61
|
-
...
|
|
62
|
-
handler:
|
|
61
|
+
const g = v === !0 ? S : {
|
|
62
|
+
...S,
|
|
63
|
+
handler: v
|
|
63
64
|
};
|
|
64
|
-
|
|
65
|
+
i.register(g), u.push(g.name);
|
|
65
66
|
}
|
|
66
67
|
}), () => {
|
|
67
|
-
for (const
|
|
68
|
+
for (const c of u) i.unregisterFunction(c);
|
|
68
69
|
};
|
|
69
|
-
}, [
|
|
70
|
-
n === "auto" &&
|
|
71
|
-
}, [
|
|
72
|
-
value:
|
|
70
|
+
}, [i, o]), E(() => {
|
|
71
|
+
n === "auto" && i.enableAutoPageContext();
|
|
72
|
+
}, [i, n]), /* @__PURE__ */ a(ee.Provider, {
|
|
73
|
+
value: i,
|
|
73
74
|
children: e
|
|
74
75
|
});
|
|
75
76
|
};
|
|
76
77
|
function $() {
|
|
77
|
-
const e =
|
|
78
|
+
const e = he(ee);
|
|
78
79
|
if (!e) throw new Error('useAgoClient must be used within an <AgoProvider>. Wrap your component tree with <AgoProvider baseUrl="...">.');
|
|
79
80
|
return e;
|
|
80
81
|
}
|
|
81
82
|
function O() {
|
|
82
|
-
return
|
|
83
|
+
return he(ee);
|
|
83
84
|
}
|
|
84
|
-
var
|
|
85
|
-
function
|
|
85
|
+
var Ze = /* @__PURE__ */ new Set(["awaiting-approval"]);
|
|
86
|
+
function ye(e) {
|
|
86
87
|
switch (e) {
|
|
87
88
|
case "progress_indicator":
|
|
88
89
|
return "progress";
|
|
@@ -96,22 +97,22 @@ function he(e) {
|
|
|
96
97
|
return "status";
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
-
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" :
|
|
100
|
+
function Qe(e) {
|
|
101
|
+
return e.type === "client_function" ? e.functionName === "navigateToPage" ? "navigation" : "action" : ye(e.type);
|
|
101
102
|
}
|
|
102
|
-
function
|
|
103
|
+
function le(e, r) {
|
|
103
104
|
const t = (e ?? "").toLowerCase();
|
|
104
|
-
return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (
|
|
105
|
+
return t.includes("reject") ? "rejected" : t.includes("error") || t.includes("fail") ? "error" : t.includes("done") || t.includes("complet") ? "done" : (t.includes("waiting") || t.includes("pending")) && (r === "confirmation" || r === "form") ? "awaiting-approval" : "running";
|
|
105
106
|
}
|
|
106
|
-
function
|
|
107
|
-
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (
|
|
107
|
+
function ce(e) {
|
|
108
|
+
return typeof e != "string" || !e ? "page" : e.replace(/[-_]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/\b\w/g, (r) => r.toUpperCase()).trim();
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
+
function et(e) {
|
|
110
111
|
switch (e.kind) {
|
|
111
112
|
case "navigation":
|
|
112
|
-
return `Navigating to ${
|
|
113
|
+
return `Navigating to ${ce(e.arguments?.page)}`;
|
|
113
114
|
case "action":
|
|
114
|
-
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message ||
|
|
115
|
+
return e.functionName === "setPageState" ? "Updating the page" : e.functionName === "openFilteredConversations" ? "Opening conversations" : e.toolDisplayName || e.message || ce(e.functionName) || "Working";
|
|
115
116
|
case "progress":
|
|
116
117
|
return e.message || "Working";
|
|
117
118
|
case "reasoning":
|
|
@@ -124,281 +125,281 @@ function Ye(e) {
|
|
|
124
125
|
return e.message || e.toolDisplayName || e.toolName || "Working";
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
|
-
function
|
|
128
|
-
const { includeReasoning:
|
|
129
|
-
if (!n) throw new
|
|
130
|
-
const [
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
...
|
|
136
|
-
id:
|
|
128
|
+
function tt(e = {}) {
|
|
129
|
+
const { includeReasoning: r = !1, labelFor: t } = e, o = O(), n = e.client || o;
|
|
130
|
+
if (!n) throw new X("useAgoActivity requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
131
|
+
const [l, s] = T([]), i = D(/* @__PURE__ */ new Set()), u = D(void 0), c = D(t);
|
|
132
|
+
c.current = t;
|
|
133
|
+
const p = _((d, w) => {
|
|
134
|
+
s((x) => {
|
|
135
|
+
const f = x.findIndex((y) => y.id === d), h = {
|
|
136
|
+
...f >= 0 ? x[f] : {
|
|
137
|
+
id: d,
|
|
137
138
|
kind: "status",
|
|
138
139
|
label: "",
|
|
139
140
|
status: "running",
|
|
140
141
|
requiresApproval: !1,
|
|
141
142
|
createdAt: /* @__PURE__ */ new Date()
|
|
142
143
|
},
|
|
143
|
-
...
|
|
144
|
+
...w
|
|
144
145
|
};
|
|
145
|
-
return
|
|
146
|
-
...
|
|
147
|
-
|
|
148
|
-
...
|
|
149
|
-
] : [...
|
|
146
|
+
return h.label = c.current?.(h) ?? et(h), f >= 0 ? [
|
|
147
|
+
...x.slice(0, f),
|
|
148
|
+
h,
|
|
149
|
+
...x.slice(f + 1)
|
|
150
|
+
] : [...x, h];
|
|
150
151
|
});
|
|
151
152
|
}, []);
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
},
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
kind:
|
|
159
|
-
status:
|
|
160
|
-
messageId:
|
|
161
|
-
toolName:
|
|
162
|
-
toolDisplayName:
|
|
163
|
-
message:
|
|
164
|
-
data:
|
|
165
|
-
formSchema:
|
|
166
|
-
requiresApproval:
|
|
153
|
+
E(() => {
|
|
154
|
+
const d = (k) => {
|
|
155
|
+
u.current = k.messageId;
|
|
156
|
+
}, w = (k) => {
|
|
157
|
+
const F = ye(k.type);
|
|
158
|
+
F === "reasoning" && !r || p(k.id, {
|
|
159
|
+
kind: F,
|
|
160
|
+
status: le(k.status, F),
|
|
161
|
+
messageId: u.current,
|
|
162
|
+
toolName: k.toolName,
|
|
163
|
+
toolDisplayName: k.toolDisplayName,
|
|
164
|
+
message: k.message,
|
|
165
|
+
data: k.data,
|
|
166
|
+
formSchema: k.formSchema,
|
|
167
|
+
requiresApproval: F === "confirmation" || F === "form"
|
|
167
168
|
});
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
kind:
|
|
169
|
+
}, x = (k) => {
|
|
170
|
+
k.invocationId && p(k.invocationId, {
|
|
171
|
+
kind: k.functionName === "navigateToPage" ? "navigation" : "action",
|
|
171
172
|
status: "running",
|
|
172
|
-
messageId:
|
|
173
|
-
functionName:
|
|
174
|
-
arguments:
|
|
173
|
+
messageId: u.current,
|
|
174
|
+
functionName: k.functionName,
|
|
175
|
+
arguments: k.arguments
|
|
175
176
|
});
|
|
176
|
-
},
|
|
177
|
-
|
|
178
|
-
kind:
|
|
177
|
+
}, f = (k) => {
|
|
178
|
+
k.invocationId && p(k.invocationId, {
|
|
179
|
+
kind: k.functionName === "navigateToPage" ? "navigation" : "action",
|
|
179
180
|
status: "awaiting-approval",
|
|
180
|
-
messageId:
|
|
181
|
-
functionName:
|
|
182
|
-
arguments:
|
|
181
|
+
messageId: u.current,
|
|
182
|
+
functionName: k.functionName,
|
|
183
|
+
arguments: k.arguments,
|
|
183
184
|
requiresApproval: !0
|
|
184
185
|
});
|
|
185
|
-
},
|
|
186
|
-
if (!
|
|
187
|
-
const
|
|
188
|
-
|
|
189
|
-
status:
|
|
186
|
+
}, h = (k) => {
|
|
187
|
+
if (!k.invocationId) return;
|
|
188
|
+
const F = k.result, C = typeof k.result == "object" && F !== null && F.approved === !1 && F.reason === "user_rejected";
|
|
189
|
+
p(k.invocationId, {
|
|
190
|
+
status: k.error ? "error" : C ? "rejected" : "done",
|
|
190
191
|
requiresApproval: !1
|
|
191
192
|
});
|
|
192
|
-
},
|
|
193
|
-
for (const
|
|
194
|
-
if (
|
|
195
|
-
for (const
|
|
196
|
-
const
|
|
197
|
-
|
|
198
|
-
kind:
|
|
199
|
-
status:
|
|
200
|
-
messageId:
|
|
201
|
-
toolName:
|
|
202
|
-
toolDisplayName:
|
|
203
|
-
functionName:
|
|
204
|
-
arguments:
|
|
205
|
-
message:
|
|
206
|
-
data:
|
|
207
|
-
formSchema:
|
|
208
|
-
requiresApproval:
|
|
193
|
+
}, y = (k) => {
|
|
194
|
+
for (const F of k.messages ?? [])
|
|
195
|
+
if (F.role === "assistant")
|
|
196
|
+
for (const C of F.toolCalls ?? []) {
|
|
197
|
+
const I = Qe(C);
|
|
198
|
+
I === "reasoning" && !r || /waiting/i.test(C.status ?? "") || p(C.id, {
|
|
199
|
+
kind: I,
|
|
200
|
+
status: le(C.status, I),
|
|
201
|
+
messageId: F.id,
|
|
202
|
+
toolName: C.toolName,
|
|
203
|
+
toolDisplayName: C.toolDisplayName,
|
|
204
|
+
functionName: C.functionName,
|
|
205
|
+
arguments: C.arguments,
|
|
206
|
+
message: C.message,
|
|
207
|
+
data: C.data,
|
|
208
|
+
formSchema: C.formSchema,
|
|
209
|
+
requiresApproval: I === "confirmation" || I === "form"
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
|
-
},
|
|
212
|
-
|
|
213
|
-
...
|
|
214
|
-
status:
|
|
215
|
-
} :
|
|
216
|
-
},
|
|
217
|
-
return n.on("message:start",
|
|
218
|
-
n.off("message:start",
|
|
212
|
+
}, m = (k) => {
|
|
213
|
+
s((F) => F.map((C) => C.status === "running" || C.status === "awaiting-approval" ? {
|
|
214
|
+
...C,
|
|
215
|
+
status: k
|
|
216
|
+
} : C));
|
|
217
|
+
}, A = () => m("done"), N = () => m("error");
|
|
218
|
+
return n.on("message:start", d), n.on("toolCall:received", w), n.on("function:invoke", x), n.on("function:awaiting-approval", f), n.on("function:result", h), n.on("conversation:loaded", y), n.on("message:complete", A), n.on("message:error", N), () => {
|
|
219
|
+
n.off("message:start", d), n.off("toolCall:received", w), n.off("function:invoke", x), n.off("function:awaiting-approval", f), n.off("function:result", h), n.off("conversation:loaded", y), n.off("message:complete", A), n.off("message:error", N);
|
|
219
220
|
};
|
|
220
221
|
}, [
|
|
221
222
|
n,
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
r,
|
|
224
|
+
p
|
|
224
225
|
]);
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
!
|
|
226
|
+
const v = _(async (d) => {
|
|
227
|
+
const w = l.find((x) => x.id === d);
|
|
228
|
+
!w || w.status !== "awaiting-approval" || i.current.has(d) || w.kind !== "form" && (i.current.add(d), p(d, {
|
|
228
229
|
status: "running",
|
|
229
230
|
requiresApproval: !1
|
|
230
|
-
}),
|
|
231
|
+
}), w.functionName ? await n.approveFunction(d) : await n.confirmToolCall(d));
|
|
231
232
|
}, [
|
|
232
233
|
n,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
]),
|
|
236
|
-
const
|
|
237
|
-
!
|
|
234
|
+
l,
|
|
235
|
+
p
|
|
236
|
+
]), S = _(async (d) => {
|
|
237
|
+
const w = l.find((x) => x.id === d);
|
|
238
|
+
!w || w.status !== "awaiting-approval" || i.current.has(d) || (i.current.add(d), p(d, {
|
|
238
239
|
status: "rejected",
|
|
239
240
|
requiresApproval: !1
|
|
240
|
-
}),
|
|
241
|
+
}), w.functionName ? await n.rejectFunction(d) : await n.rejectToolCall(d));
|
|
241
242
|
}, [
|
|
242
243
|
n,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
]),
|
|
246
|
-
|
|
244
|
+
l,
|
|
245
|
+
p
|
|
246
|
+
]), g = _(async (d, w) => {
|
|
247
|
+
p(d, {
|
|
247
248
|
status: "running",
|
|
248
249
|
requiresApproval: !1
|
|
249
|
-
}), await n.submitToolCallForm(
|
|
250
|
-
}, [n,
|
|
251
|
-
|
|
250
|
+
}), await n.submitToolCallForm(d, w), p(d, { status: "done" });
|
|
251
|
+
}, [n, p]), R = _(() => {
|
|
252
|
+
i.current.clear(), s([]);
|
|
252
253
|
}, []);
|
|
253
254
|
return {
|
|
254
|
-
items:
|
|
255
|
-
latest:
|
|
256
|
-
isAwaitingApproval:
|
|
257
|
-
approve:
|
|
258
|
-
reject:
|
|
259
|
-
submitForm:
|
|
260
|
-
clear:
|
|
255
|
+
items: l,
|
|
256
|
+
latest: l.length > 0 ? l[l.length - 1] : void 0,
|
|
257
|
+
isAwaitingApproval: l.some((d) => Ze.has(d.status)),
|
|
258
|
+
approve: v,
|
|
259
|
+
reject: S,
|
|
260
|
+
submitForm: g,
|
|
261
|
+
clear: R
|
|
261
262
|
};
|
|
262
263
|
}
|
|
263
|
-
function
|
|
264
|
-
const t = O(),
|
|
265
|
-
if (!
|
|
266
|
-
const [n,
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
}, [
|
|
270
|
-
const
|
|
264
|
+
function ve({ client: e, conversationId: r } = {}) {
|
|
265
|
+
const t = O(), o = e || t;
|
|
266
|
+
if (!o) throw new Error("useMessages requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
267
|
+
const [n, l] = T([]), [s, i] = T(r), [u, c] = T(!1), [p, v] = T(null);
|
|
268
|
+
E(() => {
|
|
269
|
+
r && r !== s && (i(r), S(r));
|
|
270
|
+
}, [r]);
|
|
271
|
+
const S = async (g) => {
|
|
271
272
|
try {
|
|
272
|
-
|
|
273
|
-
} catch (
|
|
274
|
-
|
|
273
|
+
l((await o.getMessages(g)).filter((R) => !R.hidden));
|
|
274
|
+
} catch (R) {
|
|
275
|
+
v(R instanceof Error ? R : /* @__PURE__ */ new Error("Failed to load messages"));
|
|
275
276
|
}
|
|
276
277
|
};
|
|
277
|
-
return
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
const
|
|
281
|
-
return
|
|
282
|
-
...
|
|
278
|
+
return E(() => {
|
|
279
|
+
const g = (y) => y === "IN_PROGRESS" || y === "WAITING_CLIENT", R = (y) => {
|
|
280
|
+
s || i(y.conversationId), c(!0), l((m) => {
|
|
281
|
+
const A = m.findIndex((N) => N.id === y.messageId);
|
|
282
|
+
return A >= 0 ? m.map((N, k) => k === A ? {
|
|
283
|
+
...N,
|
|
283
284
|
status: "IN_PROGRESS"
|
|
284
|
-
} :
|
|
285
|
-
id:
|
|
286
|
-
conversationId:
|
|
285
|
+
} : N) : m.some((N) => N.role === "assistant" && g(N.status)) ? m : [...m, {
|
|
286
|
+
id: y.messageId,
|
|
287
|
+
conversationId: y.conversationId,
|
|
287
288
|
content: "",
|
|
288
289
|
role: "assistant",
|
|
289
290
|
status: "IN_PROGRESS",
|
|
290
291
|
createdAt: /* @__PURE__ */ new Date()
|
|
291
292
|
}];
|
|
292
293
|
});
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
return
|
|
297
|
-
...
|
|
298
|
-
content:
|
|
299
|
-
} :
|
|
294
|
+
}, d = (y) => {
|
|
295
|
+
l((m) => {
|
|
296
|
+
const A = m.findIndex((N) => N.id === y.messageId);
|
|
297
|
+
return A < 0 ? m : m.map((N, k) => k === A ? {
|
|
298
|
+
...N,
|
|
299
|
+
content: N.content + y.content
|
|
300
|
+
} : N);
|
|
300
301
|
});
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
let
|
|
304
|
-
for (let
|
|
305
|
-
|
|
302
|
+
}, w = (y) => {
|
|
303
|
+
l((m) => {
|
|
304
|
+
let A = -1;
|
|
305
|
+
for (let N = m.length - 1; N >= 0; N--) if (m[N].role === "assistant" && g(m[N].status)) {
|
|
306
|
+
A = N;
|
|
306
307
|
break;
|
|
307
308
|
}
|
|
308
|
-
return
|
|
309
|
-
...
|
|
309
|
+
return A < 0 ? m : [
|
|
310
|
+
...m.slice(0, A),
|
|
310
311
|
{
|
|
311
|
-
...
|
|
312
|
-
...
|
|
312
|
+
...m[A],
|
|
313
|
+
...y
|
|
313
314
|
},
|
|
314
|
-
...
|
|
315
|
+
...m.slice(A + 1)
|
|
315
316
|
];
|
|
316
317
|
});
|
|
317
|
-
},
|
|
318
|
-
|
|
319
|
-
const
|
|
320
|
-
return
|
|
321
|
-
...
|
|
322
|
-
|
|
323
|
-
...
|
|
324
|
-
] : [...
|
|
325
|
-
}),
|
|
326
|
-
},
|
|
327
|
-
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
let
|
|
331
|
-
for (let
|
|
332
|
-
|
|
318
|
+
}, x = (y) => {
|
|
319
|
+
l((m) => {
|
|
320
|
+
const A = m.findIndex((N) => N.id === y.id);
|
|
321
|
+
return A >= 0 ? [
|
|
322
|
+
...m.slice(0, A),
|
|
323
|
+
y,
|
|
324
|
+
...m.slice(A + 1)
|
|
325
|
+
] : [...m, y];
|
|
326
|
+
}), c(!1);
|
|
327
|
+
}, f = (y) => {
|
|
328
|
+
v(new Error(y.error)), c(!1);
|
|
329
|
+
}, h = () => {
|
|
330
|
+
l((y) => {
|
|
331
|
+
let m = -1;
|
|
332
|
+
for (let A = y.length - 1; A >= 0; A--) if (y[A].role === "assistant" && g(y[A].status)) {
|
|
333
|
+
m = A;
|
|
333
334
|
break;
|
|
334
335
|
}
|
|
335
|
-
return
|
|
336
|
-
...
|
|
336
|
+
return m < 0 ? y : y[m].content ? y.map((A, N) => N === m ? {
|
|
337
|
+
...A,
|
|
337
338
|
status: "CANCELED"
|
|
338
|
-
} :
|
|
339
|
-
}),
|
|
339
|
+
} : A) : y.filter((A, N) => N !== m);
|
|
340
|
+
}), c(!1);
|
|
340
341
|
};
|
|
341
|
-
return
|
|
342
|
-
|
|
342
|
+
return o.on("message:start", R), o.on("message:chunk", d), o.on("message:answer-complete", w), o.on("message:complete", x), o.on("message:error", f), o.on("message:stopped", h), () => {
|
|
343
|
+
o.off("message:start", R), o.off("message:chunk", d), o.off("message:answer-complete", w), o.off("message:complete", x), o.off("message:error", f), o.off("message:stopped", h);
|
|
343
344
|
};
|
|
344
|
-
}, [
|
|
345
|
+
}, [o, s]), {
|
|
345
346
|
messages: n,
|
|
346
|
-
isLoading:
|
|
347
|
-
error:
|
|
348
|
-
sendMessage:
|
|
349
|
-
|
|
350
|
-
const
|
|
347
|
+
isLoading: u,
|
|
348
|
+
error: p,
|
|
349
|
+
sendMessage: _(async (g, R) => {
|
|
350
|
+
c(!0), v(null);
|
|
351
|
+
const d = {
|
|
351
352
|
id: `temp-${Date.now()}`,
|
|
352
|
-
conversationId:
|
|
353
|
-
content:
|
|
353
|
+
conversationId: s || "",
|
|
354
|
+
content: g,
|
|
354
355
|
role: "user",
|
|
355
356
|
status: "DONE",
|
|
356
|
-
attachments:
|
|
357
|
+
attachments: R && R.length > 0 ? Fe(R) : void 0,
|
|
357
358
|
createdAt: /* @__PURE__ */ new Date()
|
|
358
|
-
},
|
|
359
|
+
}, w = {
|
|
359
360
|
id: `temp-assistant-${Date.now()}`,
|
|
360
|
-
conversationId:
|
|
361
|
+
conversationId: s || "",
|
|
361
362
|
content: "",
|
|
362
363
|
role: "assistant",
|
|
363
364
|
status: "IN_PROGRESS",
|
|
364
365
|
createdAt: /* @__PURE__ */ new Date()
|
|
365
366
|
};
|
|
366
|
-
|
|
367
|
-
...
|
|
368
|
-
|
|
369
|
-
|
|
367
|
+
l((x) => [
|
|
368
|
+
...x,
|
|
369
|
+
d,
|
|
370
|
+
w
|
|
370
371
|
]);
|
|
371
372
|
try {
|
|
372
|
-
const
|
|
373
|
-
conversationId:
|
|
374
|
-
files:
|
|
373
|
+
const x = await o.sendMessage(g, {
|
|
374
|
+
conversationId: s,
|
|
375
|
+
files: R
|
|
375
376
|
});
|
|
376
|
-
return
|
|
377
|
-
const
|
|
378
|
-
...
|
|
379
|
-
id:
|
|
380
|
-
conversationId:
|
|
377
|
+
return x.conversationId && !s && i(x.conversationId), l((f) => {
|
|
378
|
+
const h = f.filter((m) => !m.id.startsWith("temp-")), y = {
|
|
379
|
+
...d,
|
|
380
|
+
id: d.id.replace("temp-", "user-"),
|
|
381
|
+
conversationId: x.conversationId
|
|
381
382
|
};
|
|
382
|
-
return
|
|
383
|
-
...
|
|
384
|
-
|
|
385
|
-
|
|
383
|
+
return h.some((m) => m.id === x.id) ? [...h, y].sort((m, A) => new Date(m.createdAt).getTime() - new Date(A.createdAt).getTime()) : [
|
|
384
|
+
...h,
|
|
385
|
+
y,
|
|
386
|
+
x
|
|
386
387
|
];
|
|
387
|
-
}),
|
|
388
|
-
} catch (
|
|
389
|
-
return
|
|
388
|
+
}), x;
|
|
389
|
+
} catch (x) {
|
|
390
|
+
return v(x instanceof Error ? x : /* @__PURE__ */ new Error("Failed to send message")), c(!1), l((f) => f.filter((h) => !h.id.startsWith("temp-"))), null;
|
|
390
391
|
}
|
|
391
|
-
}, [
|
|
392
|
-
stop:
|
|
393
|
-
await
|
|
394
|
-
}, [
|
|
395
|
-
clearMessages:
|
|
396
|
-
|
|
392
|
+
}, [o, s]),
|
|
393
|
+
stop: _(async () => {
|
|
394
|
+
await o.stop();
|
|
395
|
+
}, [o]),
|
|
396
|
+
clearMessages: _(() => {
|
|
397
|
+
l([]), i(void 0), v(null);
|
|
397
398
|
}, []),
|
|
398
|
-
conversationId:
|
|
399
|
+
conversationId: s
|
|
399
400
|
};
|
|
400
401
|
}
|
|
401
|
-
var
|
|
402
|
+
var de = {
|
|
402
403
|
compact: !1,
|
|
403
404
|
state: "peek",
|
|
404
405
|
isModal: !1,
|
|
@@ -406,49 +407,49 @@ var ce = {
|
|
|
406
407
|
style: {},
|
|
407
408
|
attrs: {}
|
|
408
409
|
}
|
|
409
|
-
},
|
|
410
|
-
function
|
|
411
|
-
const
|
|
412
|
-
for (const [t,
|
|
413
|
-
return
|
|
410
|
+
}, nt = { tabindex: "tabIndex" };
|
|
411
|
+
function rt(e) {
|
|
412
|
+
const r = {};
|
|
413
|
+
for (const [t, o] of Object.entries(e)) r[nt[t] ?? t] = o;
|
|
414
|
+
return r;
|
|
414
415
|
}
|
|
415
|
-
function
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
const n =
|
|
419
|
-
if (
|
|
420
|
-
return
|
|
416
|
+
function ot(e) {
|
|
417
|
+
const r = e !== !1, t = r ? e ?? {} : void 0, o = D(t?.onStateChange);
|
|
418
|
+
o.current = t?.onStateChange;
|
|
419
|
+
const n = B(() => {
|
|
420
|
+
if (r)
|
|
421
|
+
return je({
|
|
421
422
|
breakpoint: t?.breakpoint,
|
|
422
423
|
initialState: t?.initialState,
|
|
423
424
|
bottomOffset: t?.bottomOffset,
|
|
424
425
|
peekHeight: t?.peekHeight,
|
|
425
|
-
onStateChange: (
|
|
426
|
+
onStateChange: (s, i) => o.current?.(s, i)
|
|
426
427
|
});
|
|
427
428
|
}, [
|
|
428
|
-
|
|
429
|
+
r,
|
|
429
430
|
t?.breakpoint,
|
|
430
431
|
t?.initialState,
|
|
431
432
|
t?.bottomOffset,
|
|
432
433
|
t?.peekHeight
|
|
433
|
-
]),
|
|
434
|
-
}), [n]),
|
|
434
|
+
]), l = xe(_((s) => n?.subscribe(s) ?? (() => {
|
|
435
|
+
}), [n]), _(() => n?.getSnapshot() ?? de, [n]), _(() => n?.getServerSnapshot() ?? de, [n]));
|
|
435
436
|
return {
|
|
436
|
-
sheet:
|
|
437
|
-
...
|
|
437
|
+
sheet: B(() => ({
|
|
438
|
+
...l,
|
|
438
439
|
surface: {
|
|
439
|
-
...
|
|
440
|
-
attrs:
|
|
440
|
+
...l.surface,
|
|
441
|
+
attrs: rt(l.surface.attrs)
|
|
441
442
|
}
|
|
442
|
-
}), [
|
|
443
|
-
expand:
|
|
444
|
-
collapse:
|
|
445
|
-
toggle:
|
|
443
|
+
}), [l]),
|
|
444
|
+
expand: _((s) => n?.expand(s), [n]),
|
|
445
|
+
collapse: _((s) => n?.collapse(s), [n]),
|
|
446
|
+
toggle: _((s) => n?.toggle(s), [n])
|
|
446
447
|
};
|
|
447
448
|
}
|
|
448
|
-
var
|
|
449
|
-
function
|
|
450
|
-
const
|
|
451
|
-
return
|
|
449
|
+
var at = /(`[^`\n]+`|\*\*[^*\n]+\*\*|\*[^*\n]+\*|_[^_\n]+_)/g;
|
|
450
|
+
function we(e) {
|
|
451
|
+
const r = e.split(at);
|
|
452
|
+
return r.length === 1 ? e : r.map((t, o) => o % 2 === 0 || !t ? t : t.startsWith("`") ? /* @__PURE__ */ a("code", {
|
|
452
453
|
style: {
|
|
453
454
|
fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
|
|
454
455
|
fontSize: "0.92em",
|
|
@@ -457,12 +458,12 @@ function ye(e) {
|
|
|
457
458
|
backgroundColor: "rgba(0, 0, 0, 0.06)"
|
|
458
459
|
},
|
|
459
460
|
children: t.slice(1, -1)
|
|
460
|
-
},
|
|
461
|
+
}, o) : t.startsWith("**") ? /* @__PURE__ */ a("strong", {
|
|
461
462
|
style: { fontWeight: 600 },
|
|
462
463
|
children: t.slice(2, -2)
|
|
463
|
-
},
|
|
464
|
+
}, o) : /* @__PURE__ */ a("em", { children: t.slice(1, -1) }, o));
|
|
464
465
|
}
|
|
465
|
-
var
|
|
466
|
+
var it = `
|
|
466
467
|
@keyframes ago-activity-enter {
|
|
467
468
|
from { opacity: 0; transform: translateY(4px); }
|
|
468
469
|
to { opacity: 1; transform: none; }
|
|
@@ -499,7 +500,7 @@ var nt = `
|
|
|
499
500
|
color: var(--ago-activity-color, #5b5d5f);
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
|
-
`,
|
|
503
|
+
`, st = ({ label: e }) => /* @__PURE__ */ M("div", {
|
|
503
504
|
className: "ago-activity",
|
|
504
505
|
role: "status",
|
|
505
506
|
"aria-live": "polite",
|
|
@@ -520,36 +521,36 @@ var nt = `
|
|
|
520
521
|
},
|
|
521
522
|
children: [/* @__PURE__ */ a("span", {
|
|
522
523
|
className: "ago-activity__label",
|
|
523
|
-
children:
|
|
524
|
-
}, e), /* @__PURE__ */ a("style", { children:
|
|
525
|
-
}),
|
|
526
|
-
const [
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
}, []),
|
|
532
|
-
if (
|
|
533
|
-
const
|
|
534
|
-
|
|
524
|
+
children: we(e)
|
|
525
|
+
}, e), /* @__PURE__ */ a("style", { children: it })]
|
|
526
|
+
}), lt = ({ onSend: e, onStop: r, disabled: t = !1, placeholder: o = "Type a message...", allowFiles: n = !1, className: l = "" }) => {
|
|
527
|
+
const [s, i] = T(""), [u, c] = T([]), p = D(null), v = D(null), S = _(() => {
|
|
528
|
+
const f = v.current;
|
|
529
|
+
if (!f) return;
|
|
530
|
+
const h = 110;
|
|
531
|
+
f.style.height = "auto", f.style.height = `${Math.min(f.scrollHeight + 2, h)}px`, f.style.overflowY = f.scrollHeight + 2 > h ? "auto" : "hidden";
|
|
532
|
+
}, []), g = _(async (f) => {
|
|
533
|
+
if (f.preventDefault(), !s.trim() && u.length === 0) return;
|
|
534
|
+
const h = s.trim(), y = u.length > 0 ? u : void 0;
|
|
535
|
+
i(""), c([]), requestAnimationFrame(S), await e(h, y) === !1 && (i((m) => m.trim() ? m : h), y && c((m) => [...y, ...m]), requestAnimationFrame(S));
|
|
535
536
|
}, [
|
|
536
|
-
|
|
537
|
-
|
|
537
|
+
s,
|
|
538
|
+
u,
|
|
538
539
|
e,
|
|
539
|
-
|
|
540
|
-
]),
|
|
541
|
-
|
|
542
|
-
}, [
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
}, []),
|
|
546
|
-
|
|
547
|
-
}, []),
|
|
548
|
-
return /* @__PURE__ */
|
|
549
|
-
onSubmit: (
|
|
550
|
-
|
|
540
|
+
S
|
|
541
|
+
]), R = _((f) => {
|
|
542
|
+
f.key === "Enter" && !f.shiftKey && (f.preventDefault(), g(f));
|
|
543
|
+
}, [g]), d = _((f) => {
|
|
544
|
+
const h = Array.from(f.target.files || []);
|
|
545
|
+
c((y) => [...y, ...h]);
|
|
546
|
+
}, []), w = _((f) => {
|
|
547
|
+
c((h) => h.filter((y, m) => m !== f));
|
|
548
|
+
}, []), x = s.trim() || u.length > 0;
|
|
549
|
+
return /* @__PURE__ */ M("form", {
|
|
550
|
+
onSubmit: (f) => {
|
|
551
|
+
g(f);
|
|
551
552
|
},
|
|
552
|
-
className: `ago-chat-input ${
|
|
553
|
+
className: `ago-chat-input ${l}`,
|
|
553
554
|
style: {
|
|
554
555
|
display: "flex",
|
|
555
556
|
flexDirection: "column",
|
|
@@ -558,14 +559,14 @@ var nt = `
|
|
|
558
559
|
borderTop: "1px solid #dee3e8",
|
|
559
560
|
backgroundColor: "#fff"
|
|
560
561
|
},
|
|
561
|
-
children: [
|
|
562
|
+
children: [u.length > 0 && /* @__PURE__ */ a("div", {
|
|
562
563
|
className: "ago-chat-input__files",
|
|
563
564
|
style: {
|
|
564
565
|
display: "flex",
|
|
565
566
|
flexWrap: "wrap",
|
|
566
567
|
gap: "6px"
|
|
567
568
|
},
|
|
568
|
-
children:
|
|
569
|
+
children: u.map((f, h) => /* @__PURE__ */ M("div", {
|
|
569
570
|
style: {
|
|
570
571
|
display: "flex",
|
|
571
572
|
alignItems: "center",
|
|
@@ -583,11 +584,11 @@ var nt = `
|
|
|
583
584
|
textOverflow: "ellipsis",
|
|
584
585
|
whiteSpace: "nowrap"
|
|
585
586
|
},
|
|
586
|
-
children:
|
|
587
|
+
children: f.name
|
|
587
588
|
}), /* @__PURE__ */ a("button", {
|
|
588
589
|
type: "button",
|
|
589
|
-
onClick: () =>
|
|
590
|
-
"aria-label": `Remove ${
|
|
590
|
+
onClick: () => w(h),
|
|
591
|
+
"aria-label": `Remove ${f.name}`,
|
|
591
592
|
style: {
|
|
592
593
|
flexShrink: 0,
|
|
593
594
|
width: "44px",
|
|
@@ -606,17 +607,17 @@ var nt = `
|
|
|
606
607
|
},
|
|
607
608
|
children: "×"
|
|
608
609
|
})]
|
|
609
|
-
},
|
|
610
|
-
}), /* @__PURE__ */
|
|
610
|
+
}, h))
|
|
611
|
+
}), /* @__PURE__ */ M("div", {
|
|
611
612
|
style: {
|
|
612
613
|
display: "flex",
|
|
613
614
|
gap: "8px",
|
|
614
615
|
alignItems: "flex-end"
|
|
615
616
|
},
|
|
616
617
|
children: [
|
|
617
|
-
n && /* @__PURE__ */
|
|
618
|
+
n && /* @__PURE__ */ M(be, { children: [/* @__PURE__ */ a("button", {
|
|
618
619
|
type: "button",
|
|
619
|
-
onClick: () =>
|
|
620
|
+
onClick: () => p.current?.click(),
|
|
620
621
|
disabled: t,
|
|
621
622
|
"aria-label": "Attach file",
|
|
622
623
|
style: {
|
|
@@ -637,22 +638,22 @@ var nt = `
|
|
|
637
638
|
},
|
|
638
639
|
children: "+"
|
|
639
640
|
}), /* @__PURE__ */ a("input", {
|
|
640
|
-
ref:
|
|
641
|
+
ref: p,
|
|
641
642
|
type: "file",
|
|
642
643
|
multiple: !0,
|
|
643
|
-
onChange:
|
|
644
|
+
onChange: d,
|
|
644
645
|
style: { display: "none" }
|
|
645
646
|
})] }),
|
|
646
647
|
/* @__PURE__ */ a("textarea", {
|
|
647
|
-
ref:
|
|
648
|
+
ref: v,
|
|
648
649
|
className: "ago-chat-input__field",
|
|
649
|
-
value:
|
|
650
|
-
onChange: (
|
|
651
|
-
|
|
650
|
+
value: s,
|
|
651
|
+
onChange: (f) => {
|
|
652
|
+
i(f.target.value), S();
|
|
652
653
|
},
|
|
653
|
-
onKeyDown:
|
|
654
|
-
placeholder:
|
|
655
|
-
"aria-label":
|
|
654
|
+
onKeyDown: R,
|
|
655
|
+
placeholder: o,
|
|
656
|
+
"aria-label": o,
|
|
656
657
|
disabled: t,
|
|
657
658
|
rows: 1,
|
|
658
659
|
style: {
|
|
@@ -672,16 +673,16 @@ var nt = `
|
|
|
672
673
|
backgroundColor: "#f8f8f8",
|
|
673
674
|
transition: "border-color 0.15s"
|
|
674
675
|
},
|
|
675
|
-
onFocus: (
|
|
676
|
-
|
|
676
|
+
onFocus: (f) => {
|
|
677
|
+
f.currentTarget.style.borderColor = "#1b5fc4";
|
|
677
678
|
},
|
|
678
|
-
onBlur: (
|
|
679
|
-
|
|
679
|
+
onBlur: (f) => {
|
|
680
|
+
f.currentTarget.style.borderColor = "#dee3e8";
|
|
680
681
|
}
|
|
681
682
|
}),
|
|
682
|
-
t &&
|
|
683
|
+
t && r ? /* @__PURE__ */ a("button", {
|
|
683
684
|
type: "button",
|
|
684
|
-
onClick:
|
|
685
|
+
onClick: r,
|
|
685
686
|
"aria-label": "Stop generating",
|
|
686
687
|
style: {
|
|
687
688
|
minHeight: "44px",
|
|
@@ -698,15 +699,15 @@ var nt = `
|
|
|
698
699
|
children: "Stop"
|
|
699
700
|
}) : /* @__PURE__ */ a("button", {
|
|
700
701
|
type: "submit",
|
|
701
|
-
disabled: t || !
|
|
702
|
+
disabled: t || !x,
|
|
702
703
|
style: {
|
|
703
704
|
minHeight: "44px",
|
|
704
705
|
padding: "10px 18px",
|
|
705
706
|
border: "none",
|
|
706
707
|
borderRadius: "20px",
|
|
707
|
-
backgroundColor: t || !
|
|
708
|
+
backgroundColor: t || !x ? "#b5bfc8" : "#03182f",
|
|
708
709
|
color: "#fff",
|
|
709
|
-
cursor: t || !
|
|
710
|
+
cursor: t || !x ? "not-allowed" : "pointer",
|
|
710
711
|
fontWeight: 500,
|
|
711
712
|
fontSize: "16px",
|
|
712
713
|
transition: "background-color 0.15s"
|
|
@@ -716,7 +717,7 @@ var nt = `
|
|
|
716
717
|
]
|
|
717
718
|
})]
|
|
718
719
|
});
|
|
719
|
-
},
|
|
720
|
+
}, ct = ({ href: e, children: r, ...t }) => /* @__PURE__ */ a("a", {
|
|
720
721
|
href: e,
|
|
721
722
|
target: "_blank",
|
|
722
723
|
rel: "noopener noreferrer",
|
|
@@ -725,52 +726,52 @@ var nt = `
|
|
|
725
726
|
textDecoration: "underline"
|
|
726
727
|
},
|
|
727
728
|
...t,
|
|
728
|
-
children:
|
|
729
|
-
}),
|
|
729
|
+
children: r
|
|
730
|
+
}), dt = ({ children: e, ...r }) => /* @__PURE__ */ a("p", {
|
|
730
731
|
style: {
|
|
731
732
|
margin: "0 0 8px 0",
|
|
732
733
|
lineHeight: "1.6"
|
|
733
734
|
},
|
|
734
|
-
...
|
|
735
|
+
...r,
|
|
735
736
|
children: e
|
|
736
|
-
}), j = (e,
|
|
737
|
-
const t = ({ children:
|
|
737
|
+
}), j = (e, r) => {
|
|
738
|
+
const t = ({ children: o, ...n }) => $e.createElement(`h${e}`, {
|
|
738
739
|
style: {
|
|
739
740
|
margin: "16px 0 8px 0",
|
|
740
|
-
fontSize:
|
|
741
|
+
fontSize: r,
|
|
741
742
|
fontWeight: 600,
|
|
742
743
|
lineHeight: "1.3"
|
|
743
744
|
},
|
|
744
745
|
...n
|
|
745
|
-
},
|
|
746
|
+
}, o);
|
|
746
747
|
return t.displayName = `MarkdownHeading${e}`, t;
|
|
747
|
-
},
|
|
748
|
+
}, ut = ({ children: e, ...r }) => /* @__PURE__ */ a("ul", {
|
|
748
749
|
style: {
|
|
749
750
|
margin: "0 0 8px 0",
|
|
750
751
|
paddingLeft: "20px",
|
|
751
752
|
listStyleType: "disc",
|
|
752
753
|
listStylePosition: "outside"
|
|
753
754
|
},
|
|
754
|
-
...
|
|
755
|
+
...r,
|
|
755
756
|
children: e
|
|
756
|
-
}),
|
|
757
|
+
}), pt = ({ children: e, ...r }) => /* @__PURE__ */ a("ol", {
|
|
757
758
|
style: {
|
|
758
759
|
margin: "0 0 8px 0",
|
|
759
760
|
paddingLeft: "20px",
|
|
760
761
|
listStyleType: "decimal",
|
|
761
762
|
listStylePosition: "outside"
|
|
762
763
|
},
|
|
763
|
-
...
|
|
764
|
+
...r,
|
|
764
765
|
children: e
|
|
765
|
-
}),
|
|
766
|
+
}), ft = ({ children: e, ...r }) => /* @__PURE__ */ a("li", {
|
|
766
767
|
style: {
|
|
767
768
|
display: "list-item",
|
|
768
769
|
margin: "2px 0",
|
|
769
770
|
lineHeight: "1.6"
|
|
770
771
|
},
|
|
771
|
-
...
|
|
772
|
+
...r,
|
|
772
773
|
children: e
|
|
773
|
-
}),
|
|
774
|
+
}), gt = ({ className: e, children: r, ...t }) => e !== void 0 || String(r).includes(`
|
|
774
775
|
`) ? /* @__PURE__ */ a("code", {
|
|
775
776
|
style: {
|
|
776
777
|
display: "block",
|
|
@@ -782,7 +783,7 @@ var nt = `
|
|
|
782
783
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
783
784
|
},
|
|
784
785
|
...t,
|
|
785
|
-
children:
|
|
786
|
+
children: r
|
|
786
787
|
}) : /* @__PURE__ */ a("code", {
|
|
787
788
|
style: {
|
|
788
789
|
background: "#f0f2f5",
|
|
@@ -792,12 +793,12 @@ var nt = `
|
|
|
792
793
|
fontFamily: '"IBM Plex Mono", monospace'
|
|
793
794
|
},
|
|
794
795
|
...t,
|
|
795
|
-
children:
|
|
796
|
-
}),
|
|
796
|
+
children: r
|
|
797
|
+
}), mt = ({ children: e, ...r }) => /* @__PURE__ */ a("pre", {
|
|
797
798
|
style: { margin: "0 0 8px 0" },
|
|
798
|
-
...
|
|
799
|
+
...r,
|
|
799
800
|
children: e
|
|
800
|
-
}),
|
|
801
|
+
}), ht = ({ children: e, ...r }) => /* @__PURE__ */ a("blockquote", {
|
|
801
802
|
style: {
|
|
802
803
|
borderLeft: "4px solid #dee3e8",
|
|
803
804
|
paddingLeft: "12px",
|
|
@@ -805,9 +806,9 @@ var nt = `
|
|
|
805
806
|
fontStyle: "italic",
|
|
806
807
|
color: "#6b6d6f"
|
|
807
808
|
},
|
|
808
|
-
...
|
|
809
|
+
...r,
|
|
809
810
|
children: e
|
|
810
|
-
}),
|
|
811
|
+
}), xt = ({ children: e, ...r }) => /* @__PURE__ */ a("div", {
|
|
811
812
|
style: {
|
|
812
813
|
overflowX: "auto",
|
|
813
814
|
margin: "0 0 8px 0"
|
|
@@ -818,10 +819,10 @@ var nt = `
|
|
|
818
819
|
width: "100%",
|
|
819
820
|
fontSize: "13px"
|
|
820
821
|
},
|
|
821
|
-
...
|
|
822
|
+
...r,
|
|
822
823
|
children: e
|
|
823
824
|
})
|
|
824
|
-
}),
|
|
825
|
+
}), bt = ({ children: e, ...r }) => /* @__PURE__ */ a("th", {
|
|
825
826
|
style: {
|
|
826
827
|
border: "1px solid #dee3e8",
|
|
827
828
|
padding: "6px 10px",
|
|
@@ -829,57 +830,57 @@ var nt = `
|
|
|
829
830
|
backgroundColor: "#f5f7fa",
|
|
830
831
|
fontWeight: 600
|
|
831
832
|
},
|
|
832
|
-
...
|
|
833
|
+
...r,
|
|
833
834
|
children: e
|
|
834
|
-
}),
|
|
835
|
+
}), yt = ({ children: e, ...r }) => /* @__PURE__ */ a("td", {
|
|
835
836
|
style: {
|
|
836
837
|
border: "1px solid #dee3e8",
|
|
837
838
|
padding: "6px 10px"
|
|
838
839
|
},
|
|
839
|
-
...
|
|
840
|
+
...r,
|
|
840
841
|
children: e
|
|
841
|
-
}),
|
|
842
|
+
}), vt = ({ alt: e, ...r }) => /* @__PURE__ */ a("img", {
|
|
842
843
|
alt: e ?? "",
|
|
843
844
|
style: {
|
|
844
845
|
maxWidth: "100%",
|
|
845
846
|
borderRadius: "8px",
|
|
846
847
|
margin: "4px 0"
|
|
847
848
|
},
|
|
848
|
-
...
|
|
849
|
-
}),
|
|
849
|
+
...r
|
|
850
|
+
}), wt = (e) => /* @__PURE__ */ a("hr", {
|
|
850
851
|
style: {
|
|
851
852
|
border: "none",
|
|
852
853
|
borderTop: "1px solid #dee3e8",
|
|
853
854
|
margin: "12px 0"
|
|
854
855
|
},
|
|
855
856
|
...e
|
|
856
|
-
}),
|
|
857
|
-
a:
|
|
858
|
-
p:
|
|
857
|
+
}), kt = {
|
|
858
|
+
a: ct,
|
|
859
|
+
p: dt,
|
|
859
860
|
h1: j(1, "20px"),
|
|
860
861
|
h2: j(2, "18px"),
|
|
861
862
|
h3: j(3, "16px"),
|
|
862
863
|
h4: j(4, "15px"),
|
|
863
864
|
h5: j(5, "14px"),
|
|
864
865
|
h6: j(6, "13px"),
|
|
865
|
-
ul:
|
|
866
|
-
ol:
|
|
867
|
-
li:
|
|
868
|
-
code:
|
|
869
|
-
pre:
|
|
870
|
-
blockquote:
|
|
871
|
-
table:
|
|
872
|
-
th:
|
|
873
|
-
td:
|
|
874
|
-
img:
|
|
875
|
-
hr:
|
|
876
|
-
},
|
|
877
|
-
remarkPlugins:
|
|
878
|
-
components:
|
|
866
|
+
ul: ut,
|
|
867
|
+
ol: pt,
|
|
868
|
+
li: ft,
|
|
869
|
+
code: gt,
|
|
870
|
+
pre: mt,
|
|
871
|
+
blockquote: ht,
|
|
872
|
+
table: xt,
|
|
873
|
+
th: bt,
|
|
874
|
+
td: yt,
|
|
875
|
+
img: vt,
|
|
876
|
+
hr: wt
|
|
877
|
+
}, Ct = [Ye], St = ({ content: e }) => /* @__PURE__ */ a(Ve, {
|
|
878
|
+
remarkPlugins: Ct,
|
|
879
|
+
components: kt,
|
|
879
880
|
children: e
|
|
880
|
-
}),
|
|
881
|
+
}), At = ({ attachment: e, isUser: r }) => {
|
|
881
882
|
const t = We(e.url);
|
|
882
|
-
if (
|
|
883
|
+
if (Pe(e)) return /* @__PURE__ */ a("a", {
|
|
883
884
|
href: t,
|
|
884
885
|
target: "_blank",
|
|
885
886
|
rel: "noopener noreferrer",
|
|
@@ -901,7 +902,7 @@ var nt = `
|
|
|
901
902
|
}
|
|
902
903
|
})
|
|
903
904
|
});
|
|
904
|
-
const
|
|
905
|
+
const o = Le(e.fileSize), n = /* @__PURE__ */ M(be, { children: [/* @__PURE__ */ a("span", {
|
|
905
906
|
style: {
|
|
906
907
|
fontSize: "16px",
|
|
907
908
|
lineHeight: 1,
|
|
@@ -909,7 +910,7 @@ var nt = `
|
|
|
909
910
|
},
|
|
910
911
|
"aria-hidden": !0,
|
|
911
912
|
children: "📄"
|
|
912
|
-
}), /* @__PURE__ */
|
|
913
|
+
}), /* @__PURE__ */ M("span", {
|
|
913
914
|
style: {
|
|
914
915
|
display: "flex",
|
|
915
916
|
flexDirection: "column",
|
|
@@ -924,22 +925,22 @@ var nt = `
|
|
|
924
925
|
},
|
|
925
926
|
title: e.name,
|
|
926
927
|
children: e.name
|
|
927
|
-
}),
|
|
928
|
+
}), o && /* @__PURE__ */ a("span", {
|
|
928
929
|
style: {
|
|
929
930
|
fontSize: "11px",
|
|
930
931
|
color: "#6b6d6f"
|
|
931
932
|
},
|
|
932
|
-
children:
|
|
933
|
+
children: o
|
|
933
934
|
})]
|
|
934
|
-
})] }),
|
|
935
|
+
})] }), l = {
|
|
935
936
|
display: "inline-flex",
|
|
936
937
|
alignItems: "center",
|
|
937
938
|
gap: "8px",
|
|
938
939
|
padding: "8px 12px",
|
|
939
940
|
borderRadius: "10px",
|
|
940
941
|
border: "1px solid #dee3e8",
|
|
941
|
-
backgroundColor:
|
|
942
|
-
color:
|
|
942
|
+
backgroundColor: r ? "rgba(255,255,255,0.12)" : "#fff",
|
|
943
|
+
color: r ? "#fff" : "#30373e",
|
|
943
944
|
fontSize: "13px",
|
|
944
945
|
textDecoration: "none",
|
|
945
946
|
maxWidth: "220px"
|
|
@@ -948,14 +949,14 @@ var nt = `
|
|
|
948
949
|
href: t,
|
|
949
950
|
target: "_blank",
|
|
950
951
|
rel: "noopener noreferrer",
|
|
951
|
-
style:
|
|
952
|
+
style: l,
|
|
952
953
|
children: n
|
|
953
954
|
}) : /* @__PURE__ */ a("div", {
|
|
954
|
-
style:
|
|
955
|
+
style: l,
|
|
955
956
|
children: n
|
|
956
957
|
});
|
|
957
|
-
},
|
|
958
|
-
const t = /* @__PURE__ */
|
|
958
|
+
}, It = ({ source: e, index: r }) => {
|
|
959
|
+
const t = /* @__PURE__ */ M("div", {
|
|
959
960
|
style: {
|
|
960
961
|
display: "flex",
|
|
961
962
|
alignItems: "center",
|
|
@@ -978,7 +979,7 @@ var nt = `
|
|
|
978
979
|
justifyContent: "center",
|
|
979
980
|
backgroundColor: "#f0f4ff"
|
|
980
981
|
},
|
|
981
|
-
children:
|
|
982
|
+
children: r + 1
|
|
982
983
|
}), /* @__PURE__ */ a("div", {
|
|
983
984
|
style: {
|
|
984
985
|
fontSize: "12px",
|
|
@@ -990,7 +991,7 @@ var nt = `
|
|
|
990
991
|
title: e.title,
|
|
991
992
|
children: e.title
|
|
992
993
|
})]
|
|
993
|
-
}),
|
|
994
|
+
}), o = {
|
|
994
995
|
display: "flex",
|
|
995
996
|
alignItems: "center",
|
|
996
997
|
padding: "8px 10px",
|
|
@@ -1007,7 +1008,7 @@ var nt = `
|
|
|
1007
1008
|
href: e.url,
|
|
1008
1009
|
target: "_blank",
|
|
1009
1010
|
rel: "noopener noreferrer",
|
|
1010
|
-
style:
|
|
1011
|
+
style: o,
|
|
1011
1012
|
onMouseEnter: (n) => {
|
|
1012
1013
|
n.currentTarget.style.borderColor = "#1b5fc4";
|
|
1013
1014
|
},
|
|
@@ -1016,10 +1017,10 @@ var nt = `
|
|
|
1016
1017
|
},
|
|
1017
1018
|
children: t
|
|
1018
1019
|
}) : /* @__PURE__ */ a("div", {
|
|
1019
|
-
style:
|
|
1020
|
+
style: o,
|
|
1020
1021
|
children: t
|
|
1021
1022
|
});
|
|
1022
|
-
},
|
|
1023
|
+
}, ke = () => /* @__PURE__ */ M("div", {
|
|
1023
1024
|
style: {
|
|
1024
1025
|
display: "flex",
|
|
1025
1026
|
gap: "4px",
|
|
@@ -1043,10 +1044,10 @@ var nt = `
|
|
|
1043
1044
|
40% { opacity: 1; transform: scale(1); }
|
|
1044
1045
|
}
|
|
1045
1046
|
` })]
|
|
1046
|
-
}),
|
|
1047
|
-
const i = e.role === "user",
|
|
1048
|
-
return /* @__PURE__ */
|
|
1049
|
-
className: `ago-message ago-message--${e.role} ${
|
|
1047
|
+
}), Nt = ({ message: e, className: r = "", showAgentName: t = !1, isLast: o = !1, onFollowUpClick: n, showStreamingDots: l = !0, feedback: s }) => {
|
|
1048
|
+
const i = e.role === "user", u = e.status === "IN_PROGRESS" || e.status === "WAITING_CLIENT";
|
|
1049
|
+
return /* @__PURE__ */ M("div", {
|
|
1050
|
+
className: `ago-message ago-message--${e.role} ${r}`,
|
|
1050
1051
|
style: {
|
|
1051
1052
|
display: "flex",
|
|
1052
1053
|
flexDirection: "column",
|
|
@@ -1078,7 +1079,7 @@ var nt = `
|
|
|
1078
1079
|
width: "100%",
|
|
1079
1080
|
maxWidth: "85%"
|
|
1080
1081
|
},
|
|
1081
|
-
children: e.sources.map((c, p) => /* @__PURE__ */ a(
|
|
1082
|
+
children: e.sources.map((c, p) => /* @__PURE__ */ a(It, {
|
|
1082
1083
|
source: c,
|
|
1083
1084
|
index: p
|
|
1084
1085
|
}, c.id))
|
|
@@ -1093,12 +1094,12 @@ var nt = `
|
|
|
1093
1094
|
justifyContent: i ? "flex-end" : "flex-start",
|
|
1094
1095
|
maxWidth: "75%"
|
|
1095
1096
|
},
|
|
1096
|
-
children: e.attachments.map((c) => /* @__PURE__ */ a(
|
|
1097
|
+
children: e.attachments.map((c) => /* @__PURE__ */ a(At, {
|
|
1097
1098
|
attachment: c,
|
|
1098
1099
|
isUser: i
|
|
1099
1100
|
}, c.id))
|
|
1100
1101
|
}),
|
|
1101
|
-
(e.content ||
|
|
1102
|
+
(e.content || u && l) && /* @__PURE__ */ a("div", {
|
|
1102
1103
|
className: "ago-message__content",
|
|
1103
1104
|
style: {
|
|
1104
1105
|
maxWidth: i ? "75%" : "100%",
|
|
@@ -1110,9 +1111,10 @@ var nt = `
|
|
|
1110
1111
|
fontSize: "16px",
|
|
1111
1112
|
lineHeight: "1.6"
|
|
1112
1113
|
},
|
|
1113
|
-
children: e.content ? /* @__PURE__ */ a(
|
|
1114
|
+
children: e.content ? /* @__PURE__ */ a(St, { content: e.content }) : u && l && /* @__PURE__ */ a(ke, {})
|
|
1114
1115
|
}),
|
|
1115
|
-
|
|
1116
|
+
!i && s,
|
|
1117
|
+
o && e.followUpReplies && e.followUpReplies.length > 0 && /* @__PURE__ */ a("div", {
|
|
1116
1118
|
className: "ago-message__followups",
|
|
1117
1119
|
style: {
|
|
1118
1120
|
display: "flex",
|
|
@@ -1136,121 +1138,385 @@ var nt = `
|
|
|
1136
1138
|
cursor: n ? "pointer" : "default",
|
|
1137
1139
|
transition: "border-color 0.15s"
|
|
1138
1140
|
},
|
|
1139
|
-
onMouseEnter: (
|
|
1140
|
-
|
|
1141
|
+
onMouseEnter: (v) => {
|
|
1142
|
+
v.currentTarget.style.borderColor = "#1b5fc4";
|
|
1141
1143
|
},
|
|
1142
|
-
onMouseLeave: (
|
|
1143
|
-
|
|
1144
|
+
onMouseLeave: (v) => {
|
|
1145
|
+
v.currentTarget.style.borderColor = "#dee3e8";
|
|
1144
1146
|
},
|
|
1145
1147
|
children: c
|
|
1146
1148
|
}, p))
|
|
1147
1149
|
})
|
|
1148
1150
|
]
|
|
1149
1151
|
});
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1152
|
+
};
|
|
1153
|
+
function Rt({ client: e } = {}) {
|
|
1154
|
+
const r = O(), t = e || r;
|
|
1155
|
+
if (!t) throw new X("useFeedback requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "missing_client");
|
|
1156
|
+
const [o, n] = T({}), [l, s] = T(!1), [i, u] = T(null), c = D(/* @__PURE__ */ new Map()), p = (S) => {
|
|
1157
|
+
const g = (c.current.get(S) ?? 0) + 1;
|
|
1158
|
+
return c.current.set(S, g), g;
|
|
1159
|
+
}, v = (S, g) => c.current.get(S) === g;
|
|
1160
|
+
return {
|
|
1161
|
+
ratings: o,
|
|
1162
|
+
submitFeedback: _(async (S, g, R) => {
|
|
1163
|
+
const d = p(S);
|
|
1164
|
+
s(!0), u(null);
|
|
1165
|
+
try {
|
|
1166
|
+
await t.submitFeedback(S, g, R), v(S, d) && n((w) => ({
|
|
1167
|
+
...w,
|
|
1168
|
+
[S]: g
|
|
1169
|
+
}));
|
|
1170
|
+
} catch (w) {
|
|
1171
|
+
const x = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
1172
|
+
throw u(x), x;
|
|
1173
|
+
} finally {
|
|
1174
|
+
s(!1);
|
|
1175
|
+
}
|
|
1176
|
+
}, [t]),
|
|
1177
|
+
submitConversationFeedback: _(async (S, g, R) => {
|
|
1178
|
+
const d = p(S);
|
|
1179
|
+
s(!0), u(null);
|
|
1180
|
+
try {
|
|
1181
|
+
const w = await t.submitConversationFeedback(S, g, R);
|
|
1182
|
+
return v(S, d) && n((x) => ({
|
|
1183
|
+
...x,
|
|
1184
|
+
[w]: g
|
|
1185
|
+
})), w;
|
|
1186
|
+
} catch (w) {
|
|
1187
|
+
const x = w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to submit feedback");
|
|
1188
|
+
throw u(x), x;
|
|
1189
|
+
} finally {
|
|
1190
|
+
s(!1);
|
|
1191
|
+
}
|
|
1192
|
+
}, [t]),
|
|
1193
|
+
isSubmitting: l,
|
|
1194
|
+
error: i
|
|
1195
|
+
};
|
|
1196
|
+
}
|
|
1197
|
+
var ue = {
|
|
1198
|
+
helpful: "Helpful",
|
|
1199
|
+
notHelpful: "Not helpful",
|
|
1200
|
+
whatWentWrong: "What went wrong?",
|
|
1201
|
+
reasons: {
|
|
1202
|
+
inaccurate: "Inaccurate",
|
|
1203
|
+
incomplete: "Incomplete",
|
|
1204
|
+
information_not_found: "Information not found",
|
|
1205
|
+
technical_issue: "Technical issue"
|
|
1206
|
+
},
|
|
1207
|
+
commentPlaceholder: "Anything else? (optional)",
|
|
1208
|
+
send: "Send",
|
|
1209
|
+
thanks: "Thanks, this was reported."
|
|
1210
|
+
}, _t = {
|
|
1211
|
+
display: "inline-flex",
|
|
1212
|
+
alignItems: "center",
|
|
1213
|
+
justifyContent: "center",
|
|
1214
|
+
width: "44px",
|
|
1215
|
+
height: "44px",
|
|
1216
|
+
margin: "-8px",
|
|
1217
|
+
padding: 0,
|
|
1218
|
+
border: "none",
|
|
1219
|
+
borderRadius: "8px",
|
|
1220
|
+
background: "transparent",
|
|
1221
|
+
cursor: "pointer",
|
|
1222
|
+
lineHeight: 1
|
|
1223
|
+
}, Et = ({ messageId: e, client: r, askWhy: t = !0, labels: o, onSubmit: n, onError: l, className: s = "" }) => {
|
|
1224
|
+
const i = {
|
|
1225
|
+
...ue,
|
|
1226
|
+
...o,
|
|
1227
|
+
reasons: {
|
|
1228
|
+
...ue.reasons,
|
|
1229
|
+
...o?.reasons
|
|
1230
|
+
}
|
|
1231
|
+
}, { ratings: u, submitFeedback: c } = Rt({ client: r }), p = u[e], [v, S] = T(!1), [g, R] = T([]), [d, w] = T(""), [x, f] = T(!1), [h, y] = T(!1), m = async (C, I) => {
|
|
1232
|
+
try {
|
|
1233
|
+
return await c(e, C, I), n?.({
|
|
1234
|
+
messageId: e,
|
|
1235
|
+
rating: C,
|
|
1236
|
+
reasons: I?.reasons ?? [],
|
|
1237
|
+
comment: I?.comment || void 0
|
|
1238
|
+
}), !0;
|
|
1239
|
+
} catch (L) {
|
|
1240
|
+
return l?.(L instanceof Error ? L : new Error(String(L))), !1;
|
|
1241
|
+
}
|
|
1242
|
+
}, A = (C) => {
|
|
1243
|
+
m(C), S(C === "negative" && t && !x);
|
|
1244
|
+
}, N = (C) => {
|
|
1245
|
+
R((I) => I.includes(C) ? I.filter((L) => L !== C) : [...I, C]);
|
|
1246
|
+
}, k = g.length > 0 || d.trim().length > 0, F = () => {
|
|
1247
|
+
!k || h || (y(!0), m(p ?? "negative", {
|
|
1248
|
+
reasons: g,
|
|
1249
|
+
comment: d.trim()
|
|
1250
|
+
}).then((C) => {
|
|
1251
|
+
y(!1), C && (f(!0), S(!1));
|
|
1252
|
+
}));
|
|
1253
|
+
};
|
|
1254
|
+
return /* @__PURE__ */ M("div", {
|
|
1255
|
+
className: `ago-feedback ${s}`,
|
|
1256
|
+
style: {
|
|
1257
|
+
marginTop: "6px",
|
|
1258
|
+
width: "100%",
|
|
1259
|
+
maxWidth: "85%"
|
|
1260
|
+
},
|
|
1261
|
+
children: [
|
|
1262
|
+
/* @__PURE__ */ M("div", {
|
|
1263
|
+
className: "ago-feedback__actions",
|
|
1264
|
+
style: {
|
|
1265
|
+
display: "flex",
|
|
1266
|
+
alignItems: "center",
|
|
1267
|
+
gap: "2px"
|
|
1268
|
+
},
|
|
1269
|
+
children: [/* @__PURE__ */ a(pe, {
|
|
1270
|
+
direction: "up",
|
|
1271
|
+
label: i.helpful,
|
|
1272
|
+
selected: p === "positive",
|
|
1273
|
+
onClick: () => A("positive")
|
|
1274
|
+
}), /* @__PURE__ */ a(pe, {
|
|
1275
|
+
direction: "down",
|
|
1276
|
+
label: i.notHelpful,
|
|
1277
|
+
selected: p === "negative",
|
|
1278
|
+
onClick: () => A("negative")
|
|
1279
|
+
})]
|
|
1280
|
+
}),
|
|
1281
|
+
x && /* @__PURE__ */ a("div", {
|
|
1282
|
+
className: "ago-feedback__thanks",
|
|
1283
|
+
role: "status",
|
|
1284
|
+
style: {
|
|
1285
|
+
marginTop: "6px",
|
|
1286
|
+
fontSize: "13px",
|
|
1287
|
+
color: "#6b6d6f"
|
|
1288
|
+
},
|
|
1289
|
+
children: i.thanks
|
|
1290
|
+
}),
|
|
1291
|
+
v && !x && /* @__PURE__ */ M("div", {
|
|
1292
|
+
className: "ago-feedback__panel",
|
|
1293
|
+
role: "group",
|
|
1294
|
+
"aria-label": i.whatWentWrong,
|
|
1295
|
+
style: {
|
|
1296
|
+
marginTop: "8px",
|
|
1297
|
+
padding: "12px",
|
|
1298
|
+
border: "1px solid #dee3e8",
|
|
1299
|
+
borderRadius: "16px",
|
|
1300
|
+
backgroundColor: "#fff"
|
|
1301
|
+
},
|
|
1302
|
+
children: [
|
|
1303
|
+
/* @__PURE__ */ a("div", {
|
|
1304
|
+
style: {
|
|
1305
|
+
fontSize: "13px",
|
|
1306
|
+
fontWeight: 500,
|
|
1307
|
+
color: "#30373e",
|
|
1308
|
+
marginBottom: "8px"
|
|
1309
|
+
},
|
|
1310
|
+
children: i.whatWentWrong
|
|
1311
|
+
}),
|
|
1312
|
+
/* @__PURE__ */ a("div", {
|
|
1313
|
+
className: "ago-feedback__reasons",
|
|
1314
|
+
style: {
|
|
1315
|
+
display: "flex",
|
|
1316
|
+
flexWrap: "wrap",
|
|
1317
|
+
gap: "6px",
|
|
1318
|
+
marginBottom: "8px"
|
|
1319
|
+
},
|
|
1320
|
+
children: He.map((C) => {
|
|
1321
|
+
const I = g.includes(C);
|
|
1322
|
+
return /* @__PURE__ */ a("button", {
|
|
1323
|
+
type: "button",
|
|
1324
|
+
className: "ago-feedback__reason",
|
|
1325
|
+
"aria-pressed": I,
|
|
1326
|
+
onClick: () => N(C),
|
|
1327
|
+
style: {
|
|
1328
|
+
minHeight: "44px",
|
|
1329
|
+
padding: "4px 12px",
|
|
1330
|
+
fontSize: "13px",
|
|
1331
|
+
fontFamily: "inherit",
|
|
1332
|
+
borderRadius: "999px",
|
|
1333
|
+
border: `1px solid ${I ? "#1b5fc4" : "#dee3e8"}`,
|
|
1334
|
+
backgroundColor: "transparent",
|
|
1335
|
+
color: I ? "#1b5fc4" : "#30373e",
|
|
1336
|
+
cursor: "pointer"
|
|
1337
|
+
},
|
|
1338
|
+
children: i.reasons[C]
|
|
1339
|
+
}, C);
|
|
1340
|
+
})
|
|
1341
|
+
}),
|
|
1342
|
+
/* @__PURE__ */ a("textarea", {
|
|
1343
|
+
className: "ago-feedback__comment",
|
|
1344
|
+
rows: 2,
|
|
1345
|
+
value: d,
|
|
1346
|
+
placeholder: i.commentPlaceholder,
|
|
1347
|
+
"aria-label": i.commentPlaceholder,
|
|
1348
|
+
onChange: (C) => w(C.target.value),
|
|
1349
|
+
style: {
|
|
1350
|
+
width: "100%",
|
|
1351
|
+
boxSizing: "border-box",
|
|
1352
|
+
padding: "8px 10px",
|
|
1353
|
+
fontSize: "14px",
|
|
1354
|
+
fontFamily: "inherit",
|
|
1355
|
+
color: "#30373e",
|
|
1356
|
+
border: "1px solid #dee3e8",
|
|
1357
|
+
borderRadius: "10px",
|
|
1358
|
+
backgroundColor: "transparent",
|
|
1359
|
+
resize: "vertical"
|
|
1360
|
+
}
|
|
1361
|
+
}),
|
|
1362
|
+
/* @__PURE__ */ a("button", {
|
|
1363
|
+
type: "button",
|
|
1364
|
+
className: "ago-feedback__send",
|
|
1365
|
+
onClick: F,
|
|
1366
|
+
disabled: !k || h,
|
|
1367
|
+
style: {
|
|
1368
|
+
marginTop: "8px",
|
|
1369
|
+
minHeight: "44px",
|
|
1370
|
+
padding: "6px 16px",
|
|
1371
|
+
fontSize: "14px",
|
|
1372
|
+
fontFamily: "inherit",
|
|
1373
|
+
borderRadius: "10px",
|
|
1374
|
+
border: "none",
|
|
1375
|
+
backgroundColor: k ? "#03182f" : "#b5bfc8",
|
|
1376
|
+
color: "#fff",
|
|
1377
|
+
opacity: h ? 0.6 : 1,
|
|
1378
|
+
cursor: k && !h ? "pointer" : "default"
|
|
1379
|
+
},
|
|
1380
|
+
children: i.send
|
|
1381
|
+
})
|
|
1382
|
+
]
|
|
1383
|
+
})
|
|
1384
|
+
]
|
|
1385
|
+
});
|
|
1386
|
+
}, pe = ({ direction: e, label: r, selected: t, onClick: o }) => /* @__PURE__ */ a("button", {
|
|
1387
|
+
type: "button",
|
|
1388
|
+
className: `ago-feedback__thumb ago-feedback__thumb--${e}`,
|
|
1389
|
+
"aria-label": r,
|
|
1390
|
+
"aria-pressed": t,
|
|
1391
|
+
title: r,
|
|
1392
|
+
onClick: o,
|
|
1393
|
+
style: {
|
|
1394
|
+
..._t,
|
|
1395
|
+
color: t ? "#1b5fc4" : "#6b6d6f"
|
|
1396
|
+
},
|
|
1397
|
+
children: /* @__PURE__ */ M("svg", {
|
|
1398
|
+
width: "16",
|
|
1399
|
+
height: "16",
|
|
1400
|
+
viewBox: "0 0 24 24",
|
|
1401
|
+
fill: "none",
|
|
1402
|
+
"aria-hidden": "true",
|
|
1403
|
+
style: e === "down" ? { transform: "rotate(180deg)" } : void 0,
|
|
1404
|
+
children: [/* @__PURE__ */ a("path", {
|
|
1405
|
+
d: "M7 22h9.3a2 2 0 0 0 2-1.7l1.4-9A2 2 0 0 0 17.7 9H14V5a3 3 0 0 0-3-3l-4 10z",
|
|
1406
|
+
stroke: "currentColor",
|
|
1407
|
+
strokeWidth: "1.8",
|
|
1408
|
+
strokeLinejoin: "round"
|
|
1409
|
+
}), /* @__PURE__ */ a("path", {
|
|
1410
|
+
d: "M7 22V12H4.5A1.5 1.5 0 0 0 3 13.5v7A1.5 1.5 0 0 0 4.5 22z",
|
|
1411
|
+
stroke: "currentColor",
|
|
1412
|
+
strokeWidth: "1.8",
|
|
1413
|
+
strokeLinejoin: "round"
|
|
1414
|
+
})]
|
|
1415
|
+
})
|
|
1416
|
+
}), Gt = Ue(function({ client: r, conversationId: t, title: o = "Chat", welcomeMessage: n = "Hello! How can I help you today?", placeholder: l = "Type a message...", allowFiles: s = !1, allowStop: i = !0, height: u = 500, logoUrl: c, showAgentName: p = !1, forms: v, feedback: S = !1, onFollowUpClick: g, className: R = "", onMessageSent: d, onMessageReceived: w, sheet: x = !1, thinkingLabel: f = "Thinking...", functionLabels: h, showReasoning: y = !0 }, m) {
|
|
1417
|
+
const A = D(null), N = D(!0), [k, F] = T(!0), C = D(null), { sheet: I, expand: L, collapse: K, toggle: te } = ot(x), [Ce, Z] = T(!1), Q = I.compact && I.state === "peek", Se = O(), U = r ?? Se, { messages: P, isLoading: Ae, error: ne, sendMessage: Ie, stop: Ne } = ve({
|
|
1418
|
+
client: r,
|
|
1153
1419
|
conversationId: t
|
|
1154
1420
|
});
|
|
1155
|
-
|
|
1156
|
-
if (!
|
|
1157
|
-
let
|
|
1158
|
-
const
|
|
1159
|
-
return Promise.all(
|
|
1160
|
-
if (!
|
|
1161
|
-
for (const
|
|
1421
|
+
E(() => {
|
|
1422
|
+
if (!U || !v || v.length === 0) return;
|
|
1423
|
+
let b = !1;
|
|
1424
|
+
const z = [];
|
|
1425
|
+
return Promise.all(v.map((W) => W.schema != null ? Promise.resolve(me(W)) : ge(U, W))).then((W) => {
|
|
1426
|
+
if (!b)
|
|
1427
|
+
for (const H of W) z.push(H.install(U));
|
|
1162
1428
|
}).catch(() => {
|
|
1163
1429
|
}), () => {
|
|
1164
|
-
|
|
1430
|
+
b = !0, z.forEach((W) => W());
|
|
1165
1431
|
};
|
|
1166
|
-
}, [
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
])) : ""]),
|
|
1172
|
-
const
|
|
1173
|
-
!
|
|
1432
|
+
}, [U, v ? JSON.stringify(v.map((b) => [
|
|
1433
|
+
b.name,
|
|
1434
|
+
b.schema ?? null,
|
|
1435
|
+
b.submit ?? !1,
|
|
1436
|
+
b.description ?? null
|
|
1437
|
+
])) : ""]), E(() => {
|
|
1438
|
+
const b = A.current;
|
|
1439
|
+
!b || !N.current || (b.scrollTop = b.scrollHeight);
|
|
1174
1440
|
}, [P]);
|
|
1175
|
-
const
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1441
|
+
const Re = () => {
|
|
1442
|
+
const b = A.current;
|
|
1443
|
+
b && (N.current = !0, F(!0), b.scrollTop = b.scrollHeight);
|
|
1178
1444
|
};
|
|
1179
|
-
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
id:
|
|
1183
|
-
content:
|
|
1445
|
+
E(() => {
|
|
1446
|
+
const b = P[P.length - 1];
|
|
1447
|
+
b && b.role === "assistant" && b.status === "DONE" && w && w({
|
|
1448
|
+
id: b.id,
|
|
1449
|
+
content: b.content
|
|
1184
1450
|
});
|
|
1185
|
-
}, [P,
|
|
1186
|
-
|
|
1187
|
-
}, [P.length]),
|
|
1188
|
-
const
|
|
1189
|
-
if (!
|
|
1190
|
-
const
|
|
1191
|
-
if (
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1451
|
+
}, [P, w]), E(() => {
|
|
1452
|
+
Z(!!Q);
|
|
1453
|
+
}, [P.length]), E(() => {
|
|
1454
|
+
const b = C.current;
|
|
1455
|
+
if (!I.compact || !b) return;
|
|
1456
|
+
const z = document.documentElement;
|
|
1457
|
+
if (I.state !== "peek") return;
|
|
1458
|
+
const W = () => {
|
|
1459
|
+
z.style.setProperty("--ago-sheet-height", `${Math.round(b.getBoundingClientRect().height)}px`);
|
|
1194
1460
|
};
|
|
1195
|
-
|
|
1196
|
-
const
|
|
1197
|
-
return
|
|
1198
|
-
}, [
|
|
1199
|
-
|
|
1200
|
-
}, [
|
|
1461
|
+
W();
|
|
1462
|
+
const H = typeof ResizeObserver == "function" ? new ResizeObserver(W) : null;
|
|
1463
|
+
return H?.observe(b), () => H?.disconnect();
|
|
1464
|
+
}, [I.compact, I.state]), E(() => {
|
|
1465
|
+
I.compact || document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1466
|
+
}, [I.compact]), E(() => () => {
|
|
1201
1467
|
document.documentElement.style.removeProperty("--ago-sheet-height");
|
|
1202
|
-
}, []),
|
|
1203
|
-
expand:
|
|
1204
|
-
collapse:
|
|
1205
|
-
toggle:
|
|
1206
|
-
state:
|
|
1468
|
+
}, []), Je(m, () => ({
|
|
1469
|
+
expand: L,
|
|
1470
|
+
collapse: K,
|
|
1471
|
+
toggle: te,
|
|
1472
|
+
state: I.state
|
|
1207
1473
|
}), [
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
]),
|
|
1213
|
-
if (!
|
|
1214
|
-
const
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
if (
|
|
1218
|
-
|
|
1474
|
+
L,
|
|
1475
|
+
K,
|
|
1476
|
+
te,
|
|
1477
|
+
I.state
|
|
1478
|
+
]), E(() => {
|
|
1479
|
+
if (!I.isModal) return;
|
|
1480
|
+
const b = /* @__PURE__ */ Symbol("ago-react-sheet");
|
|
1481
|
+
qe(b);
|
|
1482
|
+
const z = (W) => {
|
|
1483
|
+
if (W.key === "Escape") {
|
|
1484
|
+
K("user");
|
|
1219
1485
|
return;
|
|
1220
1486
|
}
|
|
1221
|
-
if (
|
|
1222
|
-
const
|
|
1223
|
-
if (!
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
|
|
1487
|
+
if (W.key !== "Tab") return;
|
|
1488
|
+
const H = C.current;
|
|
1489
|
+
if (!H) return;
|
|
1490
|
+
const V = Array.from(H.querySelectorAll('a[href],button:not([disabled]),textarea:not([disabled]),input:not([disabled]),select:not([disabled]),[tabindex]:not([tabindex="-1"])')).filter((Me) => Me.getClientRects().length > 0);
|
|
1491
|
+
if (V.length === 0) {
|
|
1492
|
+
W.preventDefault();
|
|
1227
1493
|
return;
|
|
1228
1494
|
}
|
|
1229
|
-
const
|
|
1230
|
-
|
|
1495
|
+
const ie = V[0], se = V[V.length - 1], Y = document.activeElement;
|
|
1496
|
+
W.shiftKey && (Y === ie || !H.contains(Y)) ? (W.preventDefault(), se.focus()) : !W.shiftKey && (Y === se || !H.contains(Y)) && (W.preventDefault(), ie.focus());
|
|
1231
1497
|
};
|
|
1232
|
-
return document.addEventListener("keydown",
|
|
1233
|
-
document.removeEventListener("keydown",
|
|
1498
|
+
return document.addEventListener("keydown", z), C.current?.focus({ preventScroll: !0 }), () => {
|
|
1499
|
+
document.removeEventListener("keydown", z), Oe(b);
|
|
1234
1500
|
};
|
|
1235
|
-
}, [
|
|
1236
|
-
const
|
|
1237
|
-
const
|
|
1238
|
-
if (!(!
|
|
1239
|
-
return typeof
|
|
1240
|
-
}, [
|
|
1241
|
-
client:
|
|
1242
|
-
labelFor:
|
|
1501
|
+
}, [I.isModal, K]);
|
|
1502
|
+
const re = async (b, z) => (N.current = !0, F(!0), d?.(b), await Ie(b, z) !== null), q = P[P.length - 1], J = Ae && q?.role === "assistant" && (q.status === "IN_PROGRESS" || q.status === "WAITING_CLIENT"), _e = _((b) => {
|
|
1503
|
+
const z = b.functionName;
|
|
1504
|
+
if (!(!h || !z))
|
|
1505
|
+
return typeof h == "function" ? h(z, b.arguments ?? {}) : h[z];
|
|
1506
|
+
}, [h]), { items: Ee } = tt({
|
|
1507
|
+
client: U ?? void 0,
|
|
1508
|
+
labelFor: _e,
|
|
1243
1509
|
includeReasoning: y
|
|
1244
|
-
}), oe =
|
|
1245
|
-
return /* @__PURE__ */
|
|
1246
|
-
ref:
|
|
1247
|
-
className: `ago-chat-widget ${
|
|
1248
|
-
...
|
|
1249
|
-
"data-ago-sheet-state":
|
|
1510
|
+
}), oe = Ee.filter((b) => q?.id !== void 0 && b.messageId === q.id), G = h === !1 ? void 0 : oe[oe.length - 1]?.label, ae = !!(J && G), Te = g === !1 ? void 0 : g ?? ((b) => re(b));
|
|
1511
|
+
return /* @__PURE__ */ M("div", {
|
|
1512
|
+
ref: C,
|
|
1513
|
+
className: `ago-chat-widget ${R}`,
|
|
1514
|
+
...I.surface.attrs,
|
|
1515
|
+
"data-ago-sheet-state": I.compact ? I.state : void 0,
|
|
1250
1516
|
style: {
|
|
1251
1517
|
display: "flex",
|
|
1252
1518
|
flexDirection: "column",
|
|
1253
|
-
height: typeof
|
|
1519
|
+
height: typeof u == "number" ? `${u}px` : u,
|
|
1254
1520
|
border: "1px solid #dee3e8",
|
|
1255
1521
|
borderRadius: "16px",
|
|
1256
1522
|
overflow: "hidden",
|
|
@@ -1258,10 +1524,10 @@ var nt = `
|
|
|
1258
1524
|
fontFamily: '"IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
1259
1525
|
textAlign: "left",
|
|
1260
1526
|
boxShadow: "rgba(15, 15, 15, 0.08) 0px 2px 16px 0px",
|
|
1261
|
-
...
|
|
1527
|
+
...I.surface.style
|
|
1262
1528
|
},
|
|
1263
1529
|
children: [
|
|
1264
|
-
!
|
|
1530
|
+
!I.compact && /* @__PURE__ */ M("div", {
|
|
1265
1531
|
className: "ago-chat-widget__header",
|
|
1266
1532
|
style: {
|
|
1267
1533
|
padding: "14px 16px",
|
|
@@ -1272,8 +1538,8 @@ var nt = `
|
|
|
1272
1538
|
alignItems: "center",
|
|
1273
1539
|
gap: "10px"
|
|
1274
1540
|
},
|
|
1275
|
-
children: [
|
|
1276
|
-
src:
|
|
1541
|
+
children: [c && /* @__PURE__ */ a("img", {
|
|
1542
|
+
src: c,
|
|
1277
1543
|
alt: "Logo",
|
|
1278
1544
|
style: {
|
|
1279
1545
|
height: "24px",
|
|
@@ -1285,16 +1551,16 @@ var nt = `
|
|
|
1285
1551
|
fontSize: "15px",
|
|
1286
1552
|
fontWeight: 600
|
|
1287
1553
|
},
|
|
1288
|
-
children:
|
|
1554
|
+
children: o
|
|
1289
1555
|
})]
|
|
1290
1556
|
}),
|
|
1291
|
-
|
|
1557
|
+
Q && /* @__PURE__ */ M("button", {
|
|
1292
1558
|
type: "button",
|
|
1293
1559
|
className: "ago-chat-widget__peek",
|
|
1294
1560
|
"aria-expanded": !1,
|
|
1295
1561
|
"aria-label": "Open the conversation",
|
|
1296
1562
|
onClick: () => {
|
|
1297
|
-
|
|
1563
|
+
Z(!1), L("user");
|
|
1298
1564
|
},
|
|
1299
1565
|
style: {
|
|
1300
1566
|
display: "flex",
|
|
@@ -1311,7 +1577,7 @@ var nt = `
|
|
|
1311
1577
|
font: "inherit",
|
|
1312
1578
|
color: "inherit"
|
|
1313
1579
|
},
|
|
1314
|
-
children: [/* @__PURE__ */
|
|
1580
|
+
children: [/* @__PURE__ */ M("span", {
|
|
1315
1581
|
style: {
|
|
1316
1582
|
display: "flex",
|
|
1317
1583
|
alignItems: "center",
|
|
@@ -1324,8 +1590,8 @@ var nt = `
|
|
|
1324
1590
|
opacity: 0.7
|
|
1325
1591
|
},
|
|
1326
1592
|
children: [
|
|
1327
|
-
|
|
1328
|
-
|
|
1593
|
+
o,
|
|
1594
|
+
Ce && /* @__PURE__ */ a("span", {
|
|
1329
1595
|
"aria-label": "New message",
|
|
1330
1596
|
style: {
|
|
1331
1597
|
width: "6px",
|
|
@@ -1343,13 +1609,13 @@ var nt = `
|
|
|
1343
1609
|
children: "↑"
|
|
1344
1610
|
})
|
|
1345
1611
|
]
|
|
1346
|
-
}),
|
|
1612
|
+
}), J && !q?.content ? /* @__PURE__ */ M("span", {
|
|
1347
1613
|
style: {
|
|
1348
1614
|
display: "flex",
|
|
1349
1615
|
alignItems: "center",
|
|
1350
1616
|
gap: "8px"
|
|
1351
1617
|
},
|
|
1352
|
-
children: [!
|
|
1618
|
+
children: [!G && /* @__PURE__ */ a(ke, {}), /* @__PURE__ */ a("span", {
|
|
1353
1619
|
style: {
|
|
1354
1620
|
fontSize: "13px",
|
|
1355
1621
|
opacity: 0.7,
|
|
@@ -1357,7 +1623,7 @@ var nt = `
|
|
|
1357
1623
|
textOverflow: "ellipsis",
|
|
1358
1624
|
whiteSpace: "nowrap"
|
|
1359
1625
|
},
|
|
1360
|
-
children:
|
|
1626
|
+
children: G ? we(G) : f
|
|
1361
1627
|
})]
|
|
1362
1628
|
}) : /* @__PURE__ */ a("span", {
|
|
1363
1629
|
style: {
|
|
@@ -1370,10 +1636,10 @@ var nt = `
|
|
|
1370
1636
|
color: "inherit",
|
|
1371
1637
|
minHeight: "calc(2 * 1.5 * 13px)"
|
|
1372
1638
|
},
|
|
1373
|
-
children:
|
|
1639
|
+
children: q?.content || n
|
|
1374
1640
|
})]
|
|
1375
1641
|
}),
|
|
1376
|
-
|
|
1642
|
+
I.compact && I.state === "full" && /* @__PURE__ */ M("div", {
|
|
1377
1643
|
className: "ago-chat-widget__sheet-header",
|
|
1378
1644
|
style: {
|
|
1379
1645
|
display: "flex",
|
|
@@ -1395,11 +1661,11 @@ var nt = `
|
|
|
1395
1661
|
whiteSpace: "nowrap",
|
|
1396
1662
|
textOverflow: "ellipsis"
|
|
1397
1663
|
},
|
|
1398
|
-
children:
|
|
1664
|
+
children: o
|
|
1399
1665
|
}), /* @__PURE__ */ a("button", {
|
|
1400
1666
|
type: "button",
|
|
1401
1667
|
"aria-label": "Collapse the conversation",
|
|
1402
|
-
onClick: () =>
|
|
1668
|
+
onClick: () => K("user"),
|
|
1403
1669
|
style: {
|
|
1404
1670
|
marginLeft: "auto",
|
|
1405
1671
|
flexShrink: 0,
|
|
@@ -1427,25 +1693,25 @@ var nt = `
|
|
|
1427
1693
|
})
|
|
1428
1694
|
})]
|
|
1429
1695
|
}),
|
|
1430
|
-
/* @__PURE__ */
|
|
1696
|
+
/* @__PURE__ */ M("div", {
|
|
1431
1697
|
style: {
|
|
1432
1698
|
position: "relative",
|
|
1433
1699
|
flex: 1,
|
|
1434
|
-
display:
|
|
1700
|
+
display: Q ? "none" : "flex",
|
|
1435
1701
|
minHeight: 0
|
|
1436
1702
|
},
|
|
1437
|
-
children: [/* @__PURE__ */
|
|
1438
|
-
ref:
|
|
1703
|
+
children: [/* @__PURE__ */ M("div", {
|
|
1704
|
+
ref: A,
|
|
1439
1705
|
className: "ago-chat-widget__messages",
|
|
1440
|
-
onScroll: (
|
|
1441
|
-
const
|
|
1442
|
-
|
|
1706
|
+
onScroll: (b) => {
|
|
1707
|
+
const z = b.currentTarget, W = z.scrollHeight - z.scrollTop - z.clientHeight <= 48;
|
|
1708
|
+
N.current = W, F(W);
|
|
1443
1709
|
},
|
|
1444
1710
|
role: "log",
|
|
1445
1711
|
"aria-live": "polite",
|
|
1446
1712
|
"aria-relevant": "additions text",
|
|
1447
1713
|
"aria-atomic": !1,
|
|
1448
|
-
"aria-busy":
|
|
1714
|
+
"aria-busy": J,
|
|
1449
1715
|
style: {
|
|
1450
1716
|
flex: 1,
|
|
1451
1717
|
overflow: "auto",
|
|
@@ -1463,15 +1729,20 @@ var nt = `
|
|
|
1463
1729
|
lineHeight: "1.5"
|
|
1464
1730
|
},
|
|
1465
1731
|
children: n
|
|
1466
|
-
}) : P.map((
|
|
1467
|
-
message:
|
|
1468
|
-
showAgentName:
|
|
1469
|
-
isLast:
|
|
1470
|
-
onFollowUpClick:
|
|
1471
|
-
showStreamingDots: !
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1732
|
+
}) : P.map((b, z) => /* @__PURE__ */ a(Nt, {
|
|
1733
|
+
message: b,
|
|
1734
|
+
showAgentName: p,
|
|
1735
|
+
isLast: z === P.length - 1,
|
|
1736
|
+
onFollowUpClick: Te,
|
|
1737
|
+
showStreamingDots: !ae,
|
|
1738
|
+
feedback: S && b.role === "assistant" && b.status === "DONE" && b.content ? /* @__PURE__ */ a(Et, {
|
|
1739
|
+
messageId: b.id,
|
|
1740
|
+
client: r,
|
|
1741
|
+
...S === !0 ? {} : S
|
|
1742
|
+
}) : void 0
|
|
1743
|
+
}, b.id)),
|
|
1744
|
+
ae && /* @__PURE__ */ a(st, { label: G ?? "" }),
|
|
1745
|
+
ne && /* @__PURE__ */ a("div", {
|
|
1475
1746
|
role: "alert",
|
|
1476
1747
|
style: {
|
|
1477
1748
|
padding: "10px 14px",
|
|
@@ -1482,15 +1753,15 @@ var nt = `
|
|
|
1482
1753
|
fontSize: "13px",
|
|
1483
1754
|
border: "1px solid #fecaca"
|
|
1484
1755
|
},
|
|
1485
|
-
children:
|
|
1756
|
+
children: ne.message
|
|
1486
1757
|
}),
|
|
1487
1758
|
/* @__PURE__ */ a("div", {})
|
|
1488
1759
|
]
|
|
1489
|
-
}), !
|
|
1760
|
+
}), !k && /* @__PURE__ */ a("button", {
|
|
1490
1761
|
type: "button",
|
|
1491
1762
|
className: "ago-chat-widget__jump",
|
|
1492
1763
|
"aria-label": "Jump to latest message",
|
|
1493
|
-
onClick:
|
|
1764
|
+
onClick: Re,
|
|
1494
1765
|
style: {
|
|
1495
1766
|
position: "absolute",
|
|
1496
1767
|
left: "50%",
|
|
@@ -1523,68 +1794,68 @@ var nt = `
|
|
|
1523
1794
|
})
|
|
1524
1795
|
})]
|
|
1525
1796
|
}),
|
|
1526
|
-
/* @__PURE__ */ a(
|
|
1527
|
-
onSend:
|
|
1528
|
-
onStop:
|
|
1529
|
-
|
|
1797
|
+
/* @__PURE__ */ a(lt, {
|
|
1798
|
+
onSend: re,
|
|
1799
|
+
onStop: i ? () => {
|
|
1800
|
+
Ne();
|
|
1530
1801
|
} : void 0,
|
|
1531
|
-
disabled:
|
|
1532
|
-
placeholder:
|
|
1533
|
-
allowFiles:
|
|
1802
|
+
disabled: J,
|
|
1803
|
+
placeholder: l,
|
|
1804
|
+
allowFiles: s
|
|
1534
1805
|
})
|
|
1535
1806
|
]
|
|
1536
1807
|
});
|
|
1537
1808
|
});
|
|
1538
|
-
function
|
|
1539
|
-
const
|
|
1540
|
-
if (!t) throw new
|
|
1541
|
-
const [
|
|
1542
|
-
|
|
1543
|
-
const
|
|
1544
|
-
return
|
|
1545
|
-
const
|
|
1546
|
-
n(
|
|
1547
|
-
},
|
|
1548
|
-
n((
|
|
1809
|
+
function Tt(e = {}) {
|
|
1810
|
+
const r = O(), t = e.client ?? r;
|
|
1811
|
+
if (!t) throw new X("useProactiveNudge: no AgoClient. Pass one via options.client or wrap your tree with <AgoProvider>.", "proactive_missing_client");
|
|
1812
|
+
const [o, n] = T(null), l = D(o);
|
|
1813
|
+
l.current = o;
|
|
1814
|
+
const s = D(e.onExpand);
|
|
1815
|
+
return s.current = e.onExpand, E(() => {
|
|
1816
|
+
const i = (c) => {
|
|
1817
|
+
n(c), t.proactive?.shown(c);
|
|
1818
|
+
}, u = ({ nudge: c }) => {
|
|
1819
|
+
n((p) => p?.id === c.id ? null : p);
|
|
1549
1820
|
};
|
|
1550
|
-
return t.on("nudge:ready",
|
|
1551
|
-
t.off("nudge:ready",
|
|
1821
|
+
return t.on("nudge:ready", i), t.on("nudge:accepted", u), t.on("nudge:dismissed", u), () => {
|
|
1822
|
+
t.off("nudge:ready", i), t.off("nudge:accepted", u), t.off("nudge:dismissed", u);
|
|
1552
1823
|
};
|
|
1553
1824
|
}, [t]), {
|
|
1554
|
-
nudge:
|
|
1555
|
-
accept:
|
|
1556
|
-
const
|
|
1557
|
-
|
|
1825
|
+
nudge: o,
|
|
1826
|
+
accept: _(async () => {
|
|
1827
|
+
const i = l.current;
|
|
1828
|
+
i && (n(null), await t.proactive?.accept(i), (i.source === "agent" || i.goal) && s.current?.(i));
|
|
1558
1829
|
}, [t]),
|
|
1559
|
-
dismiss:
|
|
1560
|
-
const
|
|
1561
|
-
|
|
1830
|
+
dismiss: _(() => {
|
|
1831
|
+
const i = l.current;
|
|
1832
|
+
i && (n(null), t.proactive?.dismiss(i));
|
|
1562
1833
|
}, [t])
|
|
1563
1834
|
};
|
|
1564
1835
|
}
|
|
1565
|
-
var
|
|
1566
|
-
const { nudge:
|
|
1836
|
+
var Jt = ({ client: e, onExpand: r, autoHideMs: t, position: o = "bottom-right", openChatLabel: n = "Open chat", className: l = "" }) => {
|
|
1837
|
+
const { nudge: s, accept: i, dismiss: u } = Tt({
|
|
1567
1838
|
client: e,
|
|
1568
|
-
onExpand:
|
|
1839
|
+
onExpand: r
|
|
1569
1840
|
});
|
|
1570
|
-
if (
|
|
1571
|
-
if (!
|
|
1572
|
-
const
|
|
1573
|
-
return () => clearTimeout(
|
|
1841
|
+
if (E(() => {
|
|
1842
|
+
if (!s || !t) return;
|
|
1843
|
+
const p = setTimeout(() => u(), t);
|
|
1844
|
+
return () => clearTimeout(p);
|
|
1574
1845
|
}, [
|
|
1575
|
-
|
|
1846
|
+
s,
|
|
1576
1847
|
t,
|
|
1577
|
-
|
|
1578
|
-
]), !
|
|
1579
|
-
const
|
|
1580
|
-
return /* @__PURE__ */
|
|
1581
|
-
className: `ago-nudge ${
|
|
1848
|
+
u
|
|
1849
|
+
]), !s) return null;
|
|
1850
|
+
const c = s.source === "agent" || !!s.goal;
|
|
1851
|
+
return /* @__PURE__ */ M("div", {
|
|
1852
|
+
className: `ago-nudge ${l}`,
|
|
1582
1853
|
role: "status",
|
|
1583
1854
|
"aria-live": "polite",
|
|
1584
1855
|
style: {
|
|
1585
1856
|
position: "fixed",
|
|
1586
1857
|
bottom: "90px",
|
|
1587
|
-
...
|
|
1858
|
+
...o === "bottom-left" ? { left: "20px" } : { right: "20px" },
|
|
1588
1859
|
zIndex: 2147483e3,
|
|
1589
1860
|
maxWidth: "320px",
|
|
1590
1861
|
padding: "14px 16px",
|
|
@@ -1603,7 +1874,7 @@ var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right",
|
|
|
1603
1874
|
type: "button",
|
|
1604
1875
|
className: "ago-nudge__close",
|
|
1605
1876
|
"aria-label": "Dismiss",
|
|
1606
|
-
onClick:
|
|
1877
|
+
onClick: u,
|
|
1607
1878
|
style: {
|
|
1608
1879
|
position: "absolute",
|
|
1609
1880
|
top: "6px",
|
|
@@ -1621,9 +1892,9 @@ var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right",
|
|
|
1621
1892
|
/* @__PURE__ */ a("div", {
|
|
1622
1893
|
className: "ago-nudge__message",
|
|
1623
1894
|
style: { paddingRight: "16px" },
|
|
1624
|
-
children:
|
|
1895
|
+
children: s.message
|
|
1625
1896
|
}),
|
|
1626
|
-
(
|
|
1897
|
+
(s.action || c) && /* @__PURE__ */ M("div", {
|
|
1627
1898
|
className: "ago-nudge__actions",
|
|
1628
1899
|
style: {
|
|
1629
1900
|
display: "flex",
|
|
@@ -1631,11 +1902,11 @@ var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right",
|
|
|
1631
1902
|
marginTop: "10px",
|
|
1632
1903
|
flexWrap: "wrap"
|
|
1633
1904
|
},
|
|
1634
|
-
children: [
|
|
1905
|
+
children: [s.action && /* @__PURE__ */ a("button", {
|
|
1635
1906
|
type: "button",
|
|
1636
1907
|
className: "ago-nudge__action",
|
|
1637
1908
|
onClick: () => {
|
|
1638
|
-
|
|
1909
|
+
i();
|
|
1639
1910
|
},
|
|
1640
1911
|
style: {
|
|
1641
1912
|
border: "none",
|
|
@@ -1647,12 +1918,12 @@ var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right",
|
|
|
1647
1918
|
fontWeight: 600,
|
|
1648
1919
|
cursor: "pointer"
|
|
1649
1920
|
},
|
|
1650
|
-
children:
|
|
1651
|
-
}),
|
|
1921
|
+
children: s.action.label
|
|
1922
|
+
}), c && /* @__PURE__ */ a("button", {
|
|
1652
1923
|
type: "button",
|
|
1653
1924
|
className: "ago-nudge__expand",
|
|
1654
1925
|
onClick: () => {
|
|
1655
|
-
|
|
1926
|
+
i();
|
|
1656
1927
|
},
|
|
1657
1928
|
style: {
|
|
1658
1929
|
border: "1px solid #dee3e8",
|
|
@@ -1670,61 +1941,61 @@ var Bt = ({ client: e, onExpand: o, autoHideMs: t, position: r = "bottom-right",
|
|
|
1670
1941
|
]
|
|
1671
1942
|
});
|
|
1672
1943
|
};
|
|
1673
|
-
function
|
|
1674
|
-
const t = O(),
|
|
1675
|
-
if (!
|
|
1676
|
-
const [n,
|
|
1677
|
-
|
|
1944
|
+
function Mt({ client: e, autoLoad: r = !0 } = {}) {
|
|
1945
|
+
const t = O(), o = e || t;
|
|
1946
|
+
if (!o) throw new Error("useConversation requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1947
|
+
const [n, l] = T([]), [s, i] = T(null), [u, c] = T(!1), [p, v] = T(null), S = _(async () => {
|
|
1948
|
+
c(!0), v(null);
|
|
1678
1949
|
try {
|
|
1679
|
-
const { data:
|
|
1680
|
-
|
|
1681
|
-
} catch (
|
|
1682
|
-
|
|
1950
|
+
const { data: d } = await o.getConversations();
|
|
1951
|
+
l(d);
|
|
1952
|
+
} catch (d) {
|
|
1953
|
+
v(d instanceof Error ? d : /* @__PURE__ */ new Error("Failed to load conversations"));
|
|
1683
1954
|
} finally {
|
|
1684
|
-
|
|
1955
|
+
c(!1);
|
|
1685
1956
|
}
|
|
1686
|
-
}, [
|
|
1687
|
-
|
|
1957
|
+
}, [o]), g = _(async (d) => {
|
|
1958
|
+
c(!0), v(null);
|
|
1688
1959
|
try {
|
|
1689
|
-
|
|
1690
|
-
} catch (
|
|
1691
|
-
|
|
1960
|
+
i(await o.getConversation(d));
|
|
1961
|
+
} catch (w) {
|
|
1962
|
+
v(w instanceof Error ? w : /* @__PURE__ */ new Error("Failed to load conversation"));
|
|
1692
1963
|
} finally {
|
|
1693
|
-
|
|
1964
|
+
c(!1);
|
|
1694
1965
|
}
|
|
1695
|
-
}, [
|
|
1696
|
-
|
|
1966
|
+
}, [o]), R = _(() => {
|
|
1967
|
+
i(null);
|
|
1697
1968
|
}, []);
|
|
1698
|
-
return
|
|
1699
|
-
|
|
1700
|
-
}, [
|
|
1969
|
+
return E(() => {
|
|
1970
|
+
r && S();
|
|
1971
|
+
}, [r, S]), {
|
|
1701
1972
|
conversations: n,
|
|
1702
|
-
currentConversation:
|
|
1703
|
-
isLoading:
|
|
1704
|
-
error:
|
|
1705
|
-
selectConversation:
|
|
1706
|
-
startNewConversation:
|
|
1707
|
-
refreshConversations:
|
|
1973
|
+
currentConversation: s,
|
|
1974
|
+
isLoading: u,
|
|
1975
|
+
error: p,
|
|
1976
|
+
selectConversation: g,
|
|
1977
|
+
startNewConversation: R,
|
|
1978
|
+
refreshConversations: S
|
|
1708
1979
|
};
|
|
1709
1980
|
}
|
|
1710
|
-
function
|
|
1711
|
-
const
|
|
1981
|
+
function Vt(e = {}) {
|
|
1982
|
+
const r = O(), t = e.client || r;
|
|
1712
1983
|
if (!t) throw new Error("useChat requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.");
|
|
1713
|
-
const
|
|
1984
|
+
const o = ve({
|
|
1714
1985
|
client: t,
|
|
1715
1986
|
conversationId: e.conversationId
|
|
1716
|
-
}), n =
|
|
1987
|
+
}), n = Mt({
|
|
1717
1988
|
client: t,
|
|
1718
1989
|
autoLoad: e.autoLoad
|
|
1719
1990
|
});
|
|
1720
1991
|
return {
|
|
1721
|
-
messages:
|
|
1722
|
-
isLoading:
|
|
1723
|
-
error:
|
|
1724
|
-
sendMessage:
|
|
1725
|
-
stop:
|
|
1726
|
-
clearMessages:
|
|
1727
|
-
conversationId:
|
|
1992
|
+
messages: o.messages,
|
|
1993
|
+
isLoading: o.isLoading,
|
|
1994
|
+
error: o.error || n.error,
|
|
1995
|
+
sendMessage: o.sendMessage,
|
|
1996
|
+
stop: o.stop,
|
|
1997
|
+
clearMessages: o.clearMessages,
|
|
1998
|
+
conversationId: o.conversationId,
|
|
1728
1999
|
conversations: n.conversations,
|
|
1729
2000
|
currentConversation: n.currentConversation,
|
|
1730
2001
|
isConversationsLoading: n.isLoading,
|
|
@@ -1733,182 +2004,189 @@ function Ot(e = {}) {
|
|
|
1733
2004
|
refreshConversations: n.refreshConversations
|
|
1734
2005
|
};
|
|
1735
2006
|
}
|
|
1736
|
-
function
|
|
1737
|
-
const t = $(), { name:
|
|
2007
|
+
function Yt(e, r) {
|
|
2008
|
+
const t = $(), { name: o, description: n, parameters: l, handler: s, maxResultBytes: i, requiresApproval: u } = typeof e == "string" ? {
|
|
1738
2009
|
name: e,
|
|
1739
|
-
...
|
|
1740
|
-
} : e,
|
|
1741
|
-
|
|
1742
|
-
const
|
|
1743
|
-
return t.registerFunction(
|
|
2010
|
+
...r
|
|
2011
|
+
} : e, c = D(s);
|
|
2012
|
+
c.current = s, E(() => {
|
|
2013
|
+
const p = (v) => c.current(v);
|
|
2014
|
+
return t.registerFunction(o, p, {
|
|
1744
2015
|
description: n,
|
|
1745
|
-
parameters:
|
|
1746
|
-
maxResultBytes:
|
|
1747
|
-
requiresApproval:
|
|
2016
|
+
parameters: l,
|
|
2017
|
+
maxResultBytes: i,
|
|
2018
|
+
requiresApproval: u
|
|
1748
2019
|
}), () => {
|
|
1749
|
-
t.unregisterFunction(
|
|
2020
|
+
t.unregisterFunction(o);
|
|
1750
2021
|
};
|
|
1751
2022
|
}, [
|
|
1752
2023
|
t,
|
|
1753
|
-
|
|
2024
|
+
o,
|
|
1754
2025
|
n,
|
|
1755
|
-
s,
|
|
1756
2026
|
l,
|
|
1757
|
-
|
|
2027
|
+
i,
|
|
2028
|
+
u
|
|
1758
2029
|
]);
|
|
1759
2030
|
}
|
|
1760
|
-
function
|
|
1761
|
-
const t = $(),
|
|
1762
|
-
|
|
2031
|
+
function Xt(e, r) {
|
|
2032
|
+
const t = $(), o = D(e);
|
|
2033
|
+
o.current = e, E(() => (t.registerNavigationFunction((n) => o.current(n), r), () => {
|
|
1763
2034
|
t.unregisterNavigationFunction();
|
|
1764
|
-
}), [t,
|
|
2035
|
+
}), [t, r]);
|
|
1765
2036
|
}
|
|
1766
|
-
function
|
|
1767
|
-
const t = $(),
|
|
1768
|
-
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1771
|
-
const
|
|
1772
|
-
const
|
|
2037
|
+
function Zt(e, r) {
|
|
2038
|
+
const t = $(), o = r?.functionName ?? "setPageState", n = r?.requiresApproval, l = r?.data !== void 0, s = r?.data?.description, i = r?.data?.maxResultBytes, u = r?.settleTimeoutMs, c = D(e);
|
|
2039
|
+
c.current = e;
|
|
2040
|
+
const p = D(r);
|
|
2041
|
+
p.current = r, E(() => {
|
|
2042
|
+
const v = c.current.map((g) => {
|
|
2043
|
+
const R = () => c.current.find((d) => d.name === g.name) ?? g;
|
|
1773
2044
|
return {
|
|
1774
|
-
name:
|
|
1775
|
-
description:
|
|
1776
|
-
schema:
|
|
1777
|
-
|
|
1778
|
-
|
|
2045
|
+
name: g.name,
|
|
2046
|
+
description: g.description,
|
|
2047
|
+
schema: g.schema,
|
|
2048
|
+
clearable: g.clearable,
|
|
2049
|
+
get: g.get ? () => R().get?.() : void 0,
|
|
2050
|
+
set: (d) => R().set(d)
|
|
1779
2051
|
};
|
|
1780
|
-
}),
|
|
1781
|
-
description:
|
|
1782
|
-
maxResultBytes:
|
|
1783
|
-
get: () =>
|
|
1784
|
-
isLoading: () =>
|
|
2052
|
+
}), S = l ? {
|
|
2053
|
+
description: s ?? "What the page is currently showing.",
|
|
2054
|
+
maxResultBytes: i,
|
|
2055
|
+
get: () => p.current?.data?.get(),
|
|
2056
|
+
isLoading: () => p.current?.data?.isLoading?.() ?? !1
|
|
1785
2057
|
} : void 0;
|
|
1786
|
-
return t.registerPageStateFunction(
|
|
1787
|
-
functionName:
|
|
2058
|
+
return t.registerPageStateFunction(v, {
|
|
2059
|
+
functionName: o,
|
|
1788
2060
|
requiresApproval: n,
|
|
1789
|
-
data:
|
|
1790
|
-
settleTimeoutMs:
|
|
2061
|
+
data: S,
|
|
2062
|
+
settleTimeoutMs: u
|
|
1791
2063
|
}), () => {
|
|
1792
|
-
t.unregisterPageStateFunction(
|
|
2064
|
+
t.unregisterPageStateFunction(o);
|
|
1793
2065
|
};
|
|
1794
2066
|
}, [
|
|
1795
2067
|
t,
|
|
1796
|
-
|
|
2068
|
+
o,
|
|
1797
2069
|
n,
|
|
2070
|
+
l,
|
|
1798
2071
|
s,
|
|
1799
2072
|
i,
|
|
1800
|
-
|
|
1801
|
-
|
|
2073
|
+
u,
|
|
2074
|
+
JSON.stringify(e.map((v) => ({
|
|
2075
|
+
name: v.name,
|
|
2076
|
+
description: v.description,
|
|
2077
|
+
schema: v.schema,
|
|
2078
|
+
clearable: v.clearable
|
|
2079
|
+
})))
|
|
1802
2080
|
]);
|
|
1803
2081
|
}
|
|
1804
|
-
function
|
|
1805
|
-
const
|
|
1806
|
-
t.current = e,
|
|
2082
|
+
function Qt(e) {
|
|
2083
|
+
const r = $(), t = D(e);
|
|
2084
|
+
t.current = e, E(() => Be(r, () => t.current), [r]);
|
|
1807
2085
|
}
|
|
1808
|
-
function
|
|
1809
|
-
const
|
|
1810
|
-
if (!t) throw new
|
|
1811
|
-
const [
|
|
1812
|
-
|
|
2086
|
+
function en(e = {}) {
|
|
2087
|
+
const r = O(), t = e.client || r;
|
|
2088
|
+
if (!t) throw new X("useAgoActivityLog requires an AgoClient. Either pass it as options.client or wrap your app in <AgoProvider>.", "provider_missing_client");
|
|
2089
|
+
const [o, n] = T(() => t.getRecentActivity());
|
|
2090
|
+
E(() => {
|
|
1813
2091
|
n(t.getRecentActivity());
|
|
1814
|
-
const
|
|
1815
|
-
return t.on("activity:recorded",
|
|
2092
|
+
const i = () => n(t.getRecentActivity());
|
|
2093
|
+
return t.on("activity:recorded", i), () => t.off("activity:recorded", i);
|
|
1816
2094
|
}, [t]);
|
|
1817
|
-
const
|
|
2095
|
+
const l = _((i) => t.recordActivity(i), [t]), s = _(() => {
|
|
1818
2096
|
t.clearActivity(), n([]);
|
|
1819
2097
|
}, [t]);
|
|
1820
2098
|
return {
|
|
1821
|
-
entries:
|
|
1822
|
-
latest:
|
|
1823
|
-
record:
|
|
1824
|
-
clear:
|
|
2099
|
+
entries: o,
|
|
2100
|
+
latest: o.length > 0 ? o[o.length - 1] : void 0,
|
|
2101
|
+
record: l,
|
|
2102
|
+
clear: s
|
|
1825
2103
|
};
|
|
1826
2104
|
}
|
|
1827
|
-
function
|
|
1828
|
-
const t = $(),
|
|
1829
|
-
|
|
1830
|
-
const
|
|
1831
|
-
|
|
1832
|
-
if (typeof
|
|
1833
|
-
const
|
|
1834
|
-
return t.addDynamicContext(n,
|
|
2105
|
+
function tn(e, r) {
|
|
2106
|
+
const t = $(), o = Ge(), n = r ?? o, l = D(e);
|
|
2107
|
+
l.current = e;
|
|
2108
|
+
const s = typeof e == "function";
|
|
2109
|
+
E(() => {
|
|
2110
|
+
if (typeof l.current == "function") {
|
|
2111
|
+
const i = () => l.current();
|
|
2112
|
+
return t.addDynamicContext(n, i), () => {
|
|
1835
2113
|
t.removeDynamicContext(n);
|
|
1836
2114
|
};
|
|
1837
2115
|
}
|
|
1838
|
-
return t.setContext(n,
|
|
2116
|
+
return t.setContext(n, l.current), () => {
|
|
1839
2117
|
t.removeContext(n);
|
|
1840
2118
|
};
|
|
1841
2119
|
}, [
|
|
1842
2120
|
t,
|
|
1843
2121
|
n,
|
|
1844
|
-
|
|
1845
|
-
|
|
2122
|
+
s,
|
|
2123
|
+
s ? "" : JSON.stringify(e)
|
|
1846
2124
|
]);
|
|
1847
2125
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return
|
|
2126
|
+
function Ft(e) {
|
|
2127
|
+
return xe(e.subscribe, e.get, e.get);
|
|
1850
2128
|
}
|
|
1851
|
-
var
|
|
2129
|
+
var fe = {
|
|
1852
2130
|
missing: [],
|
|
1853
2131
|
complete: !1
|
|
1854
2132
|
};
|
|
1855
|
-
function
|
|
1856
|
-
const
|
|
2133
|
+
function nn(e) {
|
|
2134
|
+
const r = $(), t = e.schema != null, o = JSON.stringify(e.schema ?? null), n = e.submit, l = n ? typeof n == "string" ? `client:${n}` : n.via === "backend" ? "backend" : "handler" in n ? "client:handler" : `client:${n.url}` : "none", s = JSON.stringify(e.initialValues ?? null), i = B(() => t ? me(e) : null, [
|
|
1857
2135
|
t,
|
|
1858
2136
|
e.name,
|
|
1859
|
-
|
|
2137
|
+
o,
|
|
2138
|
+
l,
|
|
1860
2139
|
s,
|
|
1861
|
-
i,
|
|
1862
2140
|
e.autoSubmit
|
|
1863
|
-
]), [
|
|
2141
|
+
]), [u, c] = T({
|
|
1864
2142
|
collector: null,
|
|
1865
2143
|
loading: !t,
|
|
1866
2144
|
error: null
|
|
1867
2145
|
});
|
|
1868
|
-
|
|
2146
|
+
E(() => {
|
|
1869
2147
|
if (t) return;
|
|
1870
|
-
let
|
|
1871
|
-
return
|
|
2148
|
+
let f = !1;
|
|
2149
|
+
return c({
|
|
1872
2150
|
collector: null,
|
|
1873
2151
|
loading: !0,
|
|
1874
2152
|
error: null
|
|
1875
|
-
}),
|
|
1876
|
-
|
|
1877
|
-
collector:
|
|
2153
|
+
}), ge(r, e).then((h) => {
|
|
2154
|
+
f || c({
|
|
2155
|
+
collector: h,
|
|
1878
2156
|
loading: !1,
|
|
1879
2157
|
error: null
|
|
1880
2158
|
});
|
|
1881
|
-
}).catch((
|
|
1882
|
-
|
|
2159
|
+
}).catch((h) => {
|
|
2160
|
+
f || c({
|
|
1883
2161
|
collector: null,
|
|
1884
2162
|
loading: !1,
|
|
1885
|
-
error:
|
|
2163
|
+
error: h instanceof Error ? h : new Error(String(h))
|
|
1886
2164
|
});
|
|
1887
2165
|
}), () => {
|
|
1888
|
-
|
|
2166
|
+
f = !0;
|
|
1889
2167
|
};
|
|
1890
2168
|
}, [
|
|
1891
|
-
|
|
2169
|
+
r,
|
|
1892
2170
|
t,
|
|
1893
2171
|
e.name,
|
|
2172
|
+
l,
|
|
1894
2173
|
s,
|
|
1895
|
-
i,
|
|
1896
2174
|
e.autoSubmit
|
|
1897
2175
|
]);
|
|
1898
|
-
const
|
|
1899
|
-
|
|
1900
|
-
if (
|
|
1901
|
-
return
|
|
1902
|
-
}, [
|
|
1903
|
-
const
|
|
2176
|
+
const p = t ? i : u.collector, v = t ? !1 : u.loading, S = t ? null : u.error;
|
|
2177
|
+
E(() => {
|
|
2178
|
+
if (p)
|
|
2179
|
+
return p.install(r);
|
|
2180
|
+
}, [r, p]);
|
|
2181
|
+
const g = B(() => ze({
|
|
1904
2182
|
values: e.initialValues ?? {},
|
|
1905
2183
|
submitted: !1
|
|
1906
|
-
}), [
|
|
1907
|
-
...
|
|
1908
|
-
...
|
|
1909
|
-
}), [
|
|
2184
|
+
}), [s]), R = Ft(p?.store ?? g), d = B(() => p?.getStatus() ?? fe, [R, p]), w = B(() => ({
|
|
2185
|
+
...R,
|
|
2186
|
+
...d
|
|
2187
|
+
}), [R, d]), x = B(() => ({
|
|
1910
2188
|
name: e.name,
|
|
1911
|
-
store:
|
|
2189
|
+
store: g,
|
|
1912
2190
|
functions: [],
|
|
1913
2191
|
contextKey: `form:${e.name}`,
|
|
1914
2192
|
contextProvider: () => ({
|
|
@@ -1929,46 +2207,50 @@ function Jt(e) {
|
|
|
1929
2207
|
ok: !1,
|
|
1930
2208
|
error: "Form definition not loaded yet."
|
|
1931
2209
|
}),
|
|
1932
|
-
getValues: () =>
|
|
2210
|
+
getValues: () => g.get().values,
|
|
1933
2211
|
setValues: () => {
|
|
1934
2212
|
},
|
|
1935
2213
|
reset: () => {
|
|
1936
2214
|
},
|
|
1937
|
-
getStatus: () =>
|
|
1938
|
-
}), [e.name,
|
|
2215
|
+
getStatus: () => fe
|
|
2216
|
+
}), [e.name, g]);
|
|
1939
2217
|
return {
|
|
1940
|
-
...
|
|
1941
|
-
state:
|
|
1942
|
-
loading:
|
|
1943
|
-
error:
|
|
2218
|
+
...p ?? x,
|
|
2219
|
+
state: w,
|
|
2220
|
+
loading: v,
|
|
2221
|
+
error: S
|
|
1944
2222
|
};
|
|
1945
2223
|
}
|
|
1946
2224
|
export {
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
Et as
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
2225
|
+
Jt as AgoNudge,
|
|
2226
|
+
Ut as AgoProvider,
|
|
2227
|
+
lt as ChatInput,
|
|
2228
|
+
Gt as ChatWidget,
|
|
2229
|
+
ue as DEFAULT_MESSAGE_FEEDBACK_LABELS,
|
|
2230
|
+
He as FEEDBACK_REASONS,
|
|
2231
|
+
St as Markdown,
|
|
2232
|
+
Nt as Message,
|
|
2233
|
+
Et as MessageFeedback,
|
|
2234
|
+
me as createFormCollector,
|
|
2235
|
+
Bt as createMockClient,
|
|
2236
|
+
Lt as deriveFormStatus,
|
|
2237
|
+
ge as loadFormCollector,
|
|
2238
|
+
Xe as useAgo,
|
|
2239
|
+
tt as useAgoActivity,
|
|
2240
|
+
en as useAgoActivityLog,
|
|
2241
|
+
Qt as useAgoAutoContinueAfterNavigation,
|
|
1961
2242
|
$ as useAgoClient,
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
2243
|
+
tn as useAgoContext,
|
|
2244
|
+
Yt as useAgoFunction,
|
|
2245
|
+
Xt as useAgoNavigation,
|
|
2246
|
+
Zt as useAgoPageState,
|
|
2247
|
+
Ft as useAgoStore,
|
|
2248
|
+
Vt as useChat,
|
|
2249
|
+
Mt as useConversation,
|
|
2250
|
+
Rt as useFeedback,
|
|
2251
|
+
nn as useFormCollector,
|
|
2252
|
+
ve as useMessages,
|
|
1971
2253
|
O as useOptionalAgoClient,
|
|
1972
|
-
|
|
1973
|
-
|
|
2254
|
+
Tt as useProactiveNudge,
|
|
2255
|
+
ot as useSheet
|
|
1974
2256
|
};
|