@fencyai/react 0.1.106 → 0.1.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/index.css +1 -1
- package/dist/chat/AgentTaskProgress.d.ts +3 -2
- package/dist/chat/ChatResponse.d.ts +3 -2
- package/dist/chat/ChatResponseComplete.d.ts +3 -2
- package/dist/hooks/useFencyEventSource/index.d.ts +1 -0
- package/dist/hooks/usePaginatedQuery/index.d.ts +10 -4
- package/dist/index.d.ts +1 -5
- package/dist/index.js +567 -1178
- package/dist/types/FencyContext.d.ts +3 -2
- package/dist/types/UseAgentTasksProps.d.ts +5 -4
- package/dist/types/UseStreamProps.d.ts +3 -2
- package/dist/types/index.d.ts +0 -24
- package/package.json +7 -4
- package/dist/chat/Chat.d.ts +0 -20
- package/dist/chat/MentionCategory.d.ts +0 -5
- package/dist/chat/MentionInput.d.ts +0 -24
- package/dist/chat/MentionOption.d.ts +0 -5
- package/dist/chat/MentionPopover.d.ts +0 -14
- package/dist/chat/hooks/useKeyboardNavigation.d.ts +0 -10
- package/dist/hooks/useListMemoryTypes/index.d.ts +0 -2
- package/dist/hooks/useSearchMemories/index.d.ts +0 -2
- package/dist/types/AiModel.d.ts +0 -2
- package/dist/types/BasicChatCompletion.d.ts +0 -8
- package/dist/types/BasicChatCompletionData.d.ts +0 -5
- package/dist/types/BasicChatCompletionResponse.d.ts +0 -9
- package/dist/types/CreateBasicChatCompletionParams.d.ts +0 -10
- package/dist/types/CreateClaudeChatCompletionParams.d.ts +0 -9
- package/dist/types/CreateGeminiChatCompletionParams.d.ts +0 -9
- package/dist/types/CreateGenericChatCompletionParams.d.ts +0 -14
- package/dist/types/CreateOpenAiChatCompletionParams.d.ts +0 -7
- package/dist/types/CreateStreamingChatCompletionParams.d.ts +0 -10
- package/dist/types/CreateStreamingChatCompletionResponse.d.ts +0 -9
- package/dist/types/CreateStructuredChatCompletionParams.d.ts +0 -12
- package/dist/types/ListMemoryTypesPage.d.ts +0 -7
- package/dist/types/ListMemoryTypesParams.d.ts +0 -5
- package/dist/types/ListMemoryTypesResult.d.ts +0 -9
- package/dist/types/SearchMemoriesParams.d.ts +0 -7
- package/dist/types/SearchMemoriesResult.d.ts +0 -8
- package/dist/types/StreamingChatCompletion.d.ts +0 -23
- package/dist/types/StreamingChatCompletionData.d.ts +0 -5
- package/dist/types/StructuredChatCompletion.d.ts +0 -9
- package/dist/types/StructuredChatCompletionData.d.ts +0 -7
- package/dist/types/StructuredChatCompletionResponse.d.ts +0 -10
- package/dist/types/UseBasicChatCompletions.d.ts +0 -8
- package/dist/types/UseListMemoryTypes.d.ts +0 -10
- package/dist/types/UseListMemoryTypesProps.d.ts +0 -3
- package/dist/types/UseSearchMemories.d.ts +0 -5
- package/dist/types/UseStreamingChatCompletions.d.ts +0 -8
- package/dist/types/UseStreamingChatCompletionsProps.d.ts +0 -12
- package/dist/types/UseStructuredChatCompletions.d.ts +0 -9
package/dist/index.js
CHANGED
|
@@ -1,106 +1,243 @@
|
|
|
1
|
-
import { createAgentTask as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { jsxs as
|
|
4
|
-
import { motion as
|
|
5
|
-
import
|
|
6
|
-
import { Prism as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import './assets/index.css';const we = Me(
|
|
1
|
+
import { createAgentTask as K, createFileDownloadLink as q, AgentTaskProgressItemType as F, createStream as G } from "@fencyai/js";
|
|
2
|
+
import { createContext as V, useContext as X, useState as k, useEffect as P, useMemo as B, useCallback as D, useRef as R } from "react";
|
|
3
|
+
import { jsxs as S, jsx as g } from "react/jsx-runtime";
|
|
4
|
+
import { motion as v, useInView as Y, AnimatePresence as _ } from "motion/react";
|
|
5
|
+
import W from "react-markdown";
|
|
6
|
+
import { Prism as j } from "react-syntax-highlighter";
|
|
7
|
+
import p from "remark-gfm";
|
|
8
|
+
import './assets/index.css';const L = V(
|
|
10
9
|
void 0
|
|
11
10
|
);
|
|
12
|
-
function
|
|
13
|
-
const e =
|
|
11
|
+
function U() {
|
|
12
|
+
const e = X(L);
|
|
14
13
|
if (e === void 0)
|
|
15
14
|
throw new Error("useFencyContext must be used within a FencyProvider");
|
|
16
15
|
return e;
|
|
17
16
|
}
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
async function J(e, t) {
|
|
18
|
+
const o = e.getReader();
|
|
19
|
+
let i;
|
|
20
|
+
for (; !(i = await o.read()).done; )
|
|
21
|
+
t(i.value);
|
|
22
|
+
}
|
|
23
|
+
function Q(e) {
|
|
24
|
+
let t, o, i, s = !1;
|
|
25
|
+
return function(u) {
|
|
26
|
+
t === void 0 ? (t = u, o = 0, i = -1) : t = ee(t, u);
|
|
27
|
+
const a = t.length;
|
|
28
|
+
let n = 0;
|
|
29
|
+
for (; o < a; ) {
|
|
30
|
+
s && (t[o] === 10 && (n = ++o), s = !1);
|
|
31
|
+
let d = -1;
|
|
32
|
+
for (; o < a && d === -1; ++o)
|
|
33
|
+
switch (t[o]) {
|
|
34
|
+
case 58:
|
|
35
|
+
i === -1 && (i = o - n);
|
|
36
|
+
break;
|
|
37
|
+
case 13:
|
|
38
|
+
s = !0;
|
|
39
|
+
case 10:
|
|
40
|
+
d = o;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
if (d === -1)
|
|
44
|
+
break;
|
|
45
|
+
e(t.subarray(n, d), i), n = o, i = -1;
|
|
46
|
+
}
|
|
47
|
+
n === a ? t = void 0 : n !== 0 && (t = t.subarray(n), o -= n);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function Z(e, t, o) {
|
|
51
|
+
let i = z();
|
|
52
|
+
const s = new TextDecoder();
|
|
53
|
+
return function(u, a) {
|
|
54
|
+
if (u.length === 0)
|
|
55
|
+
o == null || o(i), i = z();
|
|
56
|
+
else if (a > 0) {
|
|
57
|
+
const n = s.decode(u.subarray(0, a)), d = a + (u[a + 1] === 32 ? 2 : 1), l = s.decode(u.subarray(d));
|
|
58
|
+
switch (n) {
|
|
59
|
+
case "data":
|
|
60
|
+
i.data = i.data ? i.data + `
|
|
61
|
+
` + l : l;
|
|
62
|
+
break;
|
|
63
|
+
case "event":
|
|
64
|
+
i.event = l;
|
|
65
|
+
break;
|
|
66
|
+
case "id":
|
|
67
|
+
e(i.id = l);
|
|
68
|
+
break;
|
|
69
|
+
case "retry":
|
|
70
|
+
const c = parseInt(l, 10);
|
|
71
|
+
isNaN(c) || t(i.retry = c);
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function ee(e, t) {
|
|
78
|
+
const o = new Uint8Array(e.length + t.length);
|
|
79
|
+
return o.set(e), o.set(t, e.length), o;
|
|
80
|
+
}
|
|
81
|
+
function z() {
|
|
82
|
+
return {
|
|
83
|
+
data: "",
|
|
84
|
+
event: "",
|
|
85
|
+
id: "",
|
|
86
|
+
retry: void 0
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var te = function(e, t) {
|
|
90
|
+
var o = {};
|
|
91
|
+
for (var i in e) Object.prototype.hasOwnProperty.call(e, i) && t.indexOf(i) < 0 && (o[i] = e[i]);
|
|
92
|
+
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
93
|
+
for (var s = 0, i = Object.getOwnPropertySymbols(e); s < i.length; s++)
|
|
94
|
+
t.indexOf(i[s]) < 0 && Object.prototype.propertyIsEnumerable.call(e, i[s]) && (o[i[s]] = e[i[s]]);
|
|
95
|
+
return o;
|
|
96
|
+
};
|
|
97
|
+
const O = "text/event-stream", ne = 1e3, H = "last-event-id";
|
|
98
|
+
function re(e, t) {
|
|
99
|
+
var { signal: o, headers: i, onopen: s, onmessage: m, onclose: u, onerror: a, openWhenHidden: n, fetch: d } = t, l = te(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
|
|
100
|
+
return new Promise((c, r) => {
|
|
101
|
+
const f = Object.assign({}, i);
|
|
102
|
+
f.accept || (f.accept = O);
|
|
103
|
+
let h;
|
|
104
|
+
function C() {
|
|
105
|
+
h.abort(), document.hidden || A();
|
|
106
|
+
}
|
|
107
|
+
n || document.addEventListener("visibilitychange", C);
|
|
108
|
+
let b = ne, y = 0;
|
|
109
|
+
function w() {
|
|
110
|
+
document.removeEventListener("visibilitychange", C), window.clearTimeout(y), h.abort();
|
|
111
|
+
}
|
|
112
|
+
o == null || o.addEventListener("abort", () => {
|
|
113
|
+
w(), c();
|
|
114
|
+
});
|
|
115
|
+
const T = d ?? window.fetch, E = s ?? oe;
|
|
116
|
+
async function A() {
|
|
117
|
+
var x;
|
|
118
|
+
h = new AbortController();
|
|
119
|
+
try {
|
|
120
|
+
const N = await T(e, Object.assign(Object.assign({}, l), { headers: f, signal: h.signal }));
|
|
121
|
+
await E(N), await J(N.body, Q(Z((I) => {
|
|
122
|
+
I ? f[H] = I : delete f[H];
|
|
123
|
+
}, (I) => {
|
|
124
|
+
b = I;
|
|
125
|
+
}, m))), u == null || u(), w(), c();
|
|
126
|
+
} catch (N) {
|
|
127
|
+
if (!h.signal.aborted)
|
|
128
|
+
try {
|
|
129
|
+
const I = (x = a == null ? void 0 : a(N)) !== null && x !== void 0 ? x : b;
|
|
130
|
+
window.clearTimeout(y), y = window.setTimeout(A, I);
|
|
131
|
+
} catch (I) {
|
|
132
|
+
w(), r(I);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
A();
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function oe(e) {
|
|
140
|
+
const t = e.headers.get("content-type");
|
|
141
|
+
if (!(t != null && t.startsWith(O)))
|
|
142
|
+
throw new Error(`Expected content-type to be ${O}, Actual: ${t}`);
|
|
143
|
+
}
|
|
144
|
+
function ae(e) {
|
|
145
|
+
const [t, o] = k(null);
|
|
146
|
+
return P(() => {
|
|
147
|
+
if (!t)
|
|
22
148
|
return;
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
e == null
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
149
|
+
const i = new AbortController();
|
|
150
|
+
return re(t, {
|
|
151
|
+
headers: e == null ? void 0 : e.headers,
|
|
152
|
+
signal: i.signal,
|
|
153
|
+
async onopen(s) {
|
|
154
|
+
if (!s.ok && s.status >= 400 && s.status < 500 && s.status !== 429)
|
|
155
|
+
throw new Error(`Client error ${s.status}`);
|
|
156
|
+
},
|
|
157
|
+
onmessage(s) {
|
|
158
|
+
s.data && (e == null || e.onMessage({
|
|
159
|
+
url: t,
|
|
160
|
+
data: ie(s.data)
|
|
161
|
+
}));
|
|
162
|
+
},
|
|
163
|
+
onerror(s) {
|
|
164
|
+
throw console.error("EventSource error:", s), e == null || e.onError(t), o(null), s;
|
|
165
|
+
},
|
|
166
|
+
onclose() {
|
|
167
|
+
}
|
|
168
|
+
}), () => {
|
|
169
|
+
i.abort();
|
|
33
170
|
};
|
|
34
|
-
}, [
|
|
35
|
-
setSourceUrl:
|
|
36
|
-
sourceUrl:
|
|
171
|
+
}, [t, e == null ? void 0 : e.headers]), {
|
|
172
|
+
setSourceUrl: o,
|
|
173
|
+
sourceUrl: t
|
|
37
174
|
};
|
|
38
175
|
}
|
|
39
|
-
function
|
|
40
|
-
const
|
|
41
|
-
for (let
|
|
42
|
-
|
|
43
|
-
return new TextDecoder("utf-8").decode(
|
|
176
|
+
function ie(e) {
|
|
177
|
+
const t = atob(e), o = new Uint8Array(t.length);
|
|
178
|
+
for (let i = 0; i < t.length; i++)
|
|
179
|
+
o[i] = t.charCodeAt(i);
|
|
180
|
+
return new TextDecoder("utf-8").decode(o);
|
|
44
181
|
}
|
|
45
|
-
const
|
|
182
|
+
const se = (e) => {
|
|
46
183
|
try {
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
} catch (
|
|
50
|
-
return console.error("Error parsing message:",
|
|
184
|
+
const t = JSON.parse(e);
|
|
185
|
+
return ce(t);
|
|
186
|
+
} catch (t) {
|
|
187
|
+
return console.error("Error parsing message:", t), null;
|
|
51
188
|
}
|
|
52
|
-
},
|
|
189
|
+
}, ce = (e) => {
|
|
53
190
|
if (!(typeof e == "object" && e !== null && "type" in e && "streamId" in e && "timestamp" in e))
|
|
54
191
|
return null;
|
|
55
192
|
switch (e.type) {
|
|
56
193
|
case "NewChatCompletionStreamChunk":
|
|
57
|
-
return
|
|
194
|
+
return le(e);
|
|
58
195
|
case "ChatCompletionStreamCompleted":
|
|
59
|
-
return
|
|
196
|
+
return de(e);
|
|
60
197
|
case "StreamTimeout":
|
|
61
|
-
return
|
|
198
|
+
return ue(e);
|
|
62
199
|
case "StreamNotFound":
|
|
63
|
-
return
|
|
200
|
+
return me(e);
|
|
64
201
|
case "FileUploadCompleted":
|
|
65
|
-
return
|
|
202
|
+
return ge(e);
|
|
66
203
|
case "FileTextContentReady":
|
|
67
|
-
return
|
|
204
|
+
return fe(e);
|
|
68
205
|
case "AgentTaskProgressItemUpdated":
|
|
69
|
-
return
|
|
206
|
+
return ye(e);
|
|
70
207
|
}
|
|
71
208
|
return null;
|
|
72
|
-
},
|
|
209
|
+
}, le = (e) => ({
|
|
73
210
|
type: "NewChatCompletionStreamChunk",
|
|
74
211
|
streamId: e.streamId,
|
|
75
212
|
chatCompletionId: e.chatCompletionId,
|
|
76
213
|
timestamp: e.timestamp,
|
|
77
214
|
content: e.content
|
|
78
|
-
}),
|
|
215
|
+
}), de = (e) => ({
|
|
79
216
|
type: "ChatCompletionStreamCompleted",
|
|
80
217
|
streamId: e.streamId,
|
|
81
218
|
chatCompletionId: e.chatCompletionId,
|
|
82
219
|
timestamp: e.timestamp
|
|
83
|
-
}),
|
|
220
|
+
}), ue = (e) => ({
|
|
84
221
|
type: "StreamTimeout",
|
|
85
222
|
streamId: e.streamId,
|
|
86
223
|
timestamp: e.timestamp
|
|
87
|
-
}),
|
|
224
|
+
}), me = (e) => ({
|
|
88
225
|
type: "StreamNotFound",
|
|
89
226
|
streamId: e.streamId,
|
|
90
227
|
timestamp: e.timestamp
|
|
91
|
-
}),
|
|
228
|
+
}), ge = (e) => ({
|
|
92
229
|
type: "FileUploadCompleted",
|
|
93
230
|
streamId: e.streamId,
|
|
94
231
|
uploadId: e.fileId,
|
|
95
232
|
fileId: e.fileId,
|
|
96
233
|
timestamp: e.timestamp
|
|
97
|
-
}),
|
|
234
|
+
}), fe = (e) => ({
|
|
98
235
|
type: "FileTextContentReady",
|
|
99
236
|
streamId: e.streamId,
|
|
100
237
|
fileId: e.fileId,
|
|
101
238
|
textContent: e.textContent,
|
|
102
239
|
timestamp: e.timestamp
|
|
103
|
-
}),
|
|
240
|
+
}), ye = (e) => ({
|
|
104
241
|
type: "AgentTaskProgressItemUpdated",
|
|
105
242
|
streamId: e.streamId,
|
|
106
243
|
agentTaskId: e.agentTaskId,
|
|
@@ -110,168 +247,177 @@ const Ue = (e) => {
|
|
|
110
247
|
completedAt: e.completedAt || void 0,
|
|
111
248
|
response: e.response,
|
|
112
249
|
progressItemType: e.progressItemType
|
|
113
|
-
}),
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
250
|
+
}), he = (e) => {
|
|
251
|
+
const t = U(), [o, i] = k(null), [s, m] = k(null), [u, a] = k(null), n = B(() => {
|
|
252
|
+
if (s)
|
|
253
|
+
return {
|
|
254
|
+
"X-Fency-Publishable-Key": t.fency.publishableKey,
|
|
255
|
+
"X-Fency-Stream-Token": s
|
|
256
|
+
};
|
|
257
|
+
}, [s, t.fency.publishableKey]), d = ae({
|
|
258
|
+
headers: n,
|
|
259
|
+
onError: (c) => {
|
|
260
|
+
var r;
|
|
261
|
+
console.error("Stream error:", c), (r = e == null ? void 0 : e.onStreamError) == null || r.call(e, {
|
|
262
|
+
streamId: c,
|
|
119
263
|
error: {
|
|
120
264
|
code: "UnknownError",
|
|
121
265
|
message: "Unknown error in useStream"
|
|
122
266
|
}
|
|
123
267
|
});
|
|
124
268
|
},
|
|
125
|
-
onMessage: (
|
|
126
|
-
var
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
269
|
+
onMessage: (c) => {
|
|
270
|
+
var f, h, C, b, y, w, T, E, A, x;
|
|
271
|
+
const r = se(c.data);
|
|
272
|
+
if (!r)
|
|
129
273
|
return !1;
|
|
130
|
-
switch (
|
|
274
|
+
switch (r.type) {
|
|
131
275
|
case "NewChatCompletionStreamChunk":
|
|
132
|
-
return (
|
|
276
|
+
return (f = e == null ? void 0 : e.onNewChatCompletionStreamChunk) == null || f.call(e, r), !0;
|
|
133
277
|
case "ChatCompletionStreamCompleted":
|
|
134
|
-
return (h = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || h.call(e,
|
|
278
|
+
return (h = e == null ? void 0 : e.onChatCompletionStreamCompleted) == null || h.call(e, r), !0;
|
|
135
279
|
case "StreamTimeout":
|
|
136
|
-
return (
|
|
280
|
+
return (C = e == null ? void 0 : e.onStreamTimeout) == null || C.call(e, r), !0;
|
|
137
281
|
case "StreamNotFound":
|
|
138
|
-
return (
|
|
282
|
+
return (b = e == null ? void 0 : e.onStreamNotFound) == null || b.call(e, r), !0;
|
|
139
283
|
case "FileUploadCompleted":
|
|
140
|
-
return (
|
|
284
|
+
return (y = e == null ? void 0 : e.onFileUploadCompleted) == null || y.call(e, r), !0;
|
|
141
285
|
case "FileTextContentReady":
|
|
142
|
-
return (
|
|
286
|
+
return (w = e == null ? void 0 : e.onFileTextContentReady) == null || w.call(e, r), !0;
|
|
143
287
|
case "WebsiteHtmlContentReady":
|
|
144
|
-
return (
|
|
288
|
+
return (T = e == null ? void 0 : e.onWebsiteHtmlContentReady) == null || T.call(e, r), !0;
|
|
145
289
|
case "WebsiteTextContentReady":
|
|
146
|
-
return (
|
|
290
|
+
return (E = e == null ? void 0 : e.onWebsiteTextContentReady) == null || E.call(e, r), !0;
|
|
147
291
|
case "FileSearchIndexReady":
|
|
148
|
-
return (
|
|
292
|
+
return (A = e == null ? void 0 : e.onFileSearchIndexReady) == null || A.call(e, r), !0;
|
|
149
293
|
case "AgentTaskProgressItemUpdated":
|
|
150
|
-
return (
|
|
294
|
+
return (x = e == null ? void 0 : e.onAgentTaskProgressItemUpdated) == null || x.call(e, r), !0;
|
|
151
295
|
}
|
|
152
296
|
}
|
|
153
297
|
});
|
|
154
|
-
return {
|
|
298
|
+
return P(() => {
|
|
299
|
+
u && s && o && (d.setSourceUrl(u), a(null));
|
|
300
|
+
}, [u, s, o]), {
|
|
155
301
|
createStream: async () => {
|
|
156
302
|
try {
|
|
157
|
-
const
|
|
158
|
-
c(
|
|
159
|
-
const
|
|
160
|
-
return
|
|
303
|
+
const c = await t.getOrCreateStream(e.fetchTokens, 3e4);
|
|
304
|
+
i(c), m(c.token);
|
|
305
|
+
const r = `${t.fency.baseUrl}/sse/streams/${c.id}`;
|
|
306
|
+
return a(r), {
|
|
161
307
|
type: "success",
|
|
162
|
-
stream:
|
|
308
|
+
stream: c
|
|
163
309
|
};
|
|
164
|
-
} catch (
|
|
310
|
+
} catch (c) {
|
|
165
311
|
return {
|
|
166
312
|
type: "error",
|
|
167
313
|
error: {
|
|
168
314
|
code: "UnknownError",
|
|
169
|
-
message:
|
|
315
|
+
message: c instanceof Error ? c.message : "Failed to create stream"
|
|
170
316
|
}
|
|
171
317
|
};
|
|
172
318
|
}
|
|
173
319
|
},
|
|
174
|
-
stream:
|
|
320
|
+
stream: o
|
|
175
321
|
};
|
|
176
|
-
},
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
onAgentTaskProgressItemUpdated: (
|
|
322
|
+
}, Ee = (e) => {
|
|
323
|
+
const t = U(), [o, i] = k([]), { createStream: s } = he({
|
|
324
|
+
fetchTokens: e.fetchCreateStreamTokens,
|
|
325
|
+
onAgentTaskProgressItemUpdated: (a) => {
|
|
180
326
|
var n;
|
|
181
|
-
(n = e.onAgentTaskProgressItemUpdated) == null || n.call(e,
|
|
182
|
-
const
|
|
183
|
-
(
|
|
327
|
+
(n = e.onAgentTaskProgressItemUpdated) == null || n.call(e, a), i((d) => {
|
|
328
|
+
const l = d.find(
|
|
329
|
+
(r) => r.streamId === a.streamId
|
|
184
330
|
);
|
|
185
|
-
return
|
|
186
|
-
(
|
|
187
|
-
).includes(
|
|
188
|
-
...
|
|
331
|
+
return l ? l.progressItems.map(
|
|
332
|
+
(r) => r.progressItemId
|
|
333
|
+
).includes(a.progressItemId) ? [
|
|
334
|
+
...d.filter((r) => r.streamId !== a.streamId),
|
|
189
335
|
{
|
|
190
|
-
...
|
|
191
|
-
progressItems:
|
|
192
|
-
(
|
|
336
|
+
...l,
|
|
337
|
+
progressItems: l.progressItems.map(
|
|
338
|
+
(r) => r.progressItemId === a.progressItemId ? a : r
|
|
193
339
|
)
|
|
194
340
|
}
|
|
195
341
|
] : [
|
|
196
|
-
...
|
|
197
|
-
(
|
|
342
|
+
...d.filter(
|
|
343
|
+
(r) => r.streamId !== a.streamId
|
|
198
344
|
),
|
|
199
345
|
{
|
|
200
|
-
...
|
|
346
|
+
...l,
|
|
201
347
|
progressItems: [
|
|
202
|
-
...
|
|
203
|
-
|
|
348
|
+
...l.progressItems,
|
|
349
|
+
a
|
|
204
350
|
]
|
|
205
351
|
}
|
|
206
|
-
] :
|
|
352
|
+
] : d;
|
|
207
353
|
});
|
|
208
354
|
},
|
|
209
|
-
onStreamError: (
|
|
355
|
+
onStreamError: (a) => {
|
|
210
356
|
var n;
|
|
211
|
-
(n = e == null ? void 0 : e.onStreamError) == null || n.call(e,
|
|
212
|
-
const
|
|
213
|
-
return
|
|
214
|
-
...
|
|
357
|
+
(n = e == null ? void 0 : e.onStreamError) == null || n.call(e, a), i((d) => {
|
|
358
|
+
const l = d.find((c) => c.streamId === a.streamId);
|
|
359
|
+
return l ? [
|
|
360
|
+
...d.filter((c) => c.streamId !== a.streamId),
|
|
215
361
|
{
|
|
216
|
-
...
|
|
362
|
+
...l,
|
|
217
363
|
loading: !1,
|
|
218
|
-
error:
|
|
364
|
+
error: a.error
|
|
219
365
|
}
|
|
220
|
-
] :
|
|
366
|
+
] : d;
|
|
221
367
|
});
|
|
222
368
|
},
|
|
223
|
-
onStreamNotFound: (
|
|
369
|
+
onStreamNotFound: (a) => {
|
|
224
370
|
var n;
|
|
225
|
-
(n = e == null ? void 0 : e.onStreamNotFound) == null || n.call(e,
|
|
371
|
+
(n = e == null ? void 0 : e.onStreamNotFound) == null || n.call(e, a);
|
|
226
372
|
},
|
|
227
|
-
onStreamTimeout: (
|
|
373
|
+
onStreamTimeout: (a) => {
|
|
228
374
|
var n;
|
|
229
|
-
(n = e == null ? void 0 : e.onStreamTimeout) == null || n.call(e,
|
|
375
|
+
(n = e == null ? void 0 : e.onStreamTimeout) == null || n.call(e, a);
|
|
230
376
|
}
|
|
231
|
-
}),
|
|
232
|
-
async (
|
|
233
|
-
|
|
234
|
-
const n = await i();
|
|
377
|
+
}), m = D(
|
|
378
|
+
async (a) => {
|
|
379
|
+
const n = await s();
|
|
235
380
|
if (n.type === "success") {
|
|
236
|
-
|
|
237
|
-
...
|
|
381
|
+
i([
|
|
382
|
+
...o,
|
|
238
383
|
{
|
|
239
384
|
streamId: n.stream.id,
|
|
240
385
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
241
386
|
data: null,
|
|
242
387
|
error: null,
|
|
243
|
-
prompt:
|
|
388
|
+
prompt: a,
|
|
244
389
|
progressItems: [],
|
|
245
390
|
loading: !0,
|
|
246
391
|
doneStreaming: !1
|
|
247
392
|
}
|
|
248
393
|
]);
|
|
249
|
-
const
|
|
250
|
-
pk:
|
|
251
|
-
baseUrl:
|
|
252
|
-
|
|
394
|
+
const { clientToken: d } = await e.fetchClientToken(), l = await K({
|
|
395
|
+
pk: t.fency.publishableKey,
|
|
396
|
+
baseUrl: t.fency.baseUrl,
|
|
397
|
+
clientToken: d,
|
|
398
|
+
streamToken: n.stream.token,
|
|
253
399
|
request: {
|
|
254
400
|
streamId: n.stream.id,
|
|
255
|
-
queryText:
|
|
256
|
-
jsonSchema:
|
|
257
|
-
todos:
|
|
401
|
+
queryText: a.queryText,
|
|
402
|
+
jsonSchema: a.jsonSchema,
|
|
403
|
+
todos: a.todos
|
|
258
404
|
}
|
|
259
405
|
});
|
|
260
|
-
if (
|
|
261
|
-
return
|
|
262
|
-
...
|
|
263
|
-
(
|
|
406
|
+
if (l.type === "success" && l.agentTask)
|
|
407
|
+
return i((c) => [
|
|
408
|
+
...c.filter(
|
|
409
|
+
(r) => r.streamId !== n.stream.id
|
|
264
410
|
),
|
|
265
411
|
{
|
|
266
412
|
streamId: n.stream.id,
|
|
267
413
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
268
414
|
data: {
|
|
269
|
-
id:
|
|
270
|
-
createdAt:
|
|
415
|
+
id: l.agentTask.id,
|
|
416
|
+
createdAt: l.agentTask.createdAt,
|
|
271
417
|
streamId: n.stream.id
|
|
272
418
|
},
|
|
273
419
|
error: null,
|
|
274
|
-
prompt:
|
|
420
|
+
prompt: a,
|
|
275
421
|
progressItems: [],
|
|
276
422
|
doneStreaming: !1,
|
|
277
423
|
loading: !0
|
|
@@ -279,18 +425,18 @@ const Ue = (e) => {
|
|
|
279
425
|
]), {
|
|
280
426
|
type: "success",
|
|
281
427
|
streamId: n.stream.id,
|
|
282
|
-
agentTaskId:
|
|
428
|
+
agentTaskId: l.agentTask.id
|
|
283
429
|
};
|
|
284
|
-
if (
|
|
285
|
-
return
|
|
286
|
-
...
|
|
287
|
-
(
|
|
430
|
+
if (l.type === "error")
|
|
431
|
+
return i((c) => [
|
|
432
|
+
...c.filter(
|
|
433
|
+
(r) => r.streamId !== n.stream.id
|
|
288
434
|
),
|
|
289
435
|
{
|
|
290
436
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
291
437
|
streamId: n.stream.id,
|
|
292
|
-
prompt:
|
|
293
|
-
error:
|
|
438
|
+
prompt: a,
|
|
439
|
+
error: l.error,
|
|
294
440
|
progressItems: [],
|
|
295
441
|
loading: !1,
|
|
296
442
|
doneStreaming: !1,
|
|
@@ -298,22 +444,22 @@ const Ue = (e) => {
|
|
|
298
444
|
}
|
|
299
445
|
]), {
|
|
300
446
|
type: "error",
|
|
301
|
-
error:
|
|
447
|
+
error: l.error
|
|
302
448
|
};
|
|
303
449
|
{
|
|
304
|
-
const
|
|
450
|
+
const c = {
|
|
305
451
|
message: "No response received",
|
|
306
452
|
code: "UnknownError"
|
|
307
453
|
};
|
|
308
|
-
return
|
|
309
|
-
...
|
|
310
|
-
(
|
|
454
|
+
return i((r) => [
|
|
455
|
+
...r.filter(
|
|
456
|
+
(f) => f.streamId !== n.stream.id
|
|
311
457
|
),
|
|
312
458
|
{
|
|
313
459
|
triggeredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
314
460
|
streamId: n.stream.id,
|
|
315
|
-
error:
|
|
316
|
-
prompt:
|
|
461
|
+
error: c,
|
|
462
|
+
prompt: a,
|
|
317
463
|
progressItems: [],
|
|
318
464
|
loading: !1,
|
|
319
465
|
doneStreaming: !1,
|
|
@@ -321,68 +467,36 @@ const Ue = (e) => {
|
|
|
321
467
|
}
|
|
322
468
|
]), {
|
|
323
469
|
type: "error",
|
|
324
|
-
error:
|
|
470
|
+
error: c
|
|
325
471
|
};
|
|
326
472
|
}
|
|
327
473
|
} else
|
|
328
474
|
return console.error(n.error), n;
|
|
329
475
|
},
|
|
330
|
-
[
|
|
331
|
-
), u =
|
|
476
|
+
[t, o, s]
|
|
477
|
+
), u = B(() => o.sort((a, n) => new Date(n.triggeredAt).getTime() - new Date(a.triggeredAt).getTime())[0], [o]);
|
|
332
478
|
return {
|
|
333
|
-
agentTasks:
|
|
334
|
-
createAgentTask:
|
|
479
|
+
agentTasks: o,
|
|
480
|
+
createAgentTask: m,
|
|
335
481
|
latest: u
|
|
336
482
|
};
|
|
337
483
|
};
|
|
338
|
-
function
|
|
339
|
-
const
|
|
340
|
-
return {
|
|
341
|
-
search: async (s) => {
|
|
342
|
-
try {
|
|
343
|
-
const { clientSecret: c } = await s.fetchClientSecret(), i = await Ae({
|
|
344
|
-
pk: e.fency.publishableKey,
|
|
345
|
-
clientSecret: c,
|
|
346
|
-
request: {
|
|
347
|
-
memoryTypeId: s.memoryTypeId,
|
|
348
|
-
title: s.title
|
|
349
|
-
},
|
|
350
|
-
baseUrl: e.fency.baseUrl
|
|
351
|
-
});
|
|
352
|
-
return i.type === "success" ? {
|
|
353
|
-
type: "success",
|
|
354
|
-
items: i.items
|
|
355
|
-
} : {
|
|
356
|
-
type: "error",
|
|
357
|
-
error: i.error
|
|
358
|
-
};
|
|
359
|
-
} catch (c) {
|
|
360
|
-
return {
|
|
361
|
-
type: "error",
|
|
362
|
-
error: {
|
|
363
|
-
code: "UNKNOWN_ERROR",
|
|
364
|
-
message: c instanceof Error ? c.message : "An unknown error occurred"
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function Ve(e, a) {
|
|
372
|
-
const [s, c] = x(
|
|
484
|
+
function Ne(e, t) {
|
|
485
|
+
const [o, i] = k(
|
|
373
486
|
null
|
|
374
|
-
), [
|
|
487
|
+
), [s, m] = k(
|
|
375
488
|
null
|
|
376
|
-
), u =
|
|
377
|
-
const
|
|
489
|
+
), u = U(), a = async (c) => {
|
|
490
|
+
const r = await c.fetchTokens(), { fetchTokens: f, nextPageToken: h, previousPageToken: C, ...b } = c, y = await e({
|
|
378
491
|
pk: u.fency.publishableKey,
|
|
379
|
-
|
|
492
|
+
clientToken: r.clientToken,
|
|
493
|
+
streamToken: r.streamToken,
|
|
380
494
|
request: {
|
|
381
|
-
...
|
|
382
|
-
limit: (
|
|
495
|
+
...b,
|
|
496
|
+
limit: (t == null ? void 0 : t.pageSize) ?? 50,
|
|
383
497
|
pagination: {
|
|
384
|
-
nextPageToken:
|
|
385
|
-
previousPageToken:
|
|
498
|
+
nextPageToken: h,
|
|
499
|
+
previousPageToken: C
|
|
386
500
|
}
|
|
387
501
|
},
|
|
388
502
|
baseUrl: u.fency.baseUrl
|
|
@@ -404,16 +518,16 @@ function Ve(e, a) {
|
|
|
404
518
|
};
|
|
405
519
|
};
|
|
406
520
|
return {
|
|
407
|
-
fetchFirstPage: async (
|
|
408
|
-
const
|
|
409
|
-
...
|
|
521
|
+
fetchFirstPage: async (c) => {
|
|
522
|
+
const r = await a({
|
|
523
|
+
...c,
|
|
410
524
|
nextPageToken: void 0,
|
|
411
525
|
previousPageToken: void 0
|
|
412
526
|
});
|
|
413
|
-
return
|
|
527
|
+
return r.type === "success" && (m(r.page), i(c)), r;
|
|
414
528
|
},
|
|
415
|
-
fetchNextPage: async (
|
|
416
|
-
if (
|
|
529
|
+
fetchNextPage: async (c) => {
|
|
530
|
+
if (s == null)
|
|
417
531
|
return {
|
|
418
532
|
type: "error",
|
|
419
533
|
error: {
|
|
@@ -421,7 +535,7 @@ function Ve(e, a) {
|
|
|
421
535
|
message: "No current page"
|
|
422
536
|
}
|
|
423
537
|
};
|
|
424
|
-
if (
|
|
538
|
+
if (s.pagination.nextPageToken == null)
|
|
425
539
|
return {
|
|
426
540
|
type: "error",
|
|
427
541
|
error: {
|
|
@@ -429,15 +543,15 @@ function Ve(e, a) {
|
|
|
429
543
|
message: "No next page"
|
|
430
544
|
}
|
|
431
545
|
};
|
|
432
|
-
const
|
|
433
|
-
...
|
|
434
|
-
nextPageToken:
|
|
546
|
+
const r = await a({
|
|
547
|
+
...c,
|
|
548
|
+
nextPageToken: s.pagination.nextPageToken,
|
|
435
549
|
previousPageToken: void 0
|
|
436
550
|
});
|
|
437
|
-
return
|
|
551
|
+
return r.type === "success" && (m(r.page), i(c)), r;
|
|
438
552
|
},
|
|
439
|
-
fetchPreviousPage: async (
|
|
440
|
-
if (
|
|
553
|
+
fetchPreviousPage: async (c) => {
|
|
554
|
+
if (s == null)
|
|
441
555
|
return {
|
|
442
556
|
type: "error",
|
|
443
557
|
error: {
|
|
@@ -445,7 +559,7 @@ function Ve(e, a) {
|
|
|
445
559
|
message: "No current page"
|
|
446
560
|
}
|
|
447
561
|
};
|
|
448
|
-
if (
|
|
562
|
+
if (s.pagination.previousPageToken == null)
|
|
449
563
|
return {
|
|
450
564
|
type: "error",
|
|
451
565
|
error: {
|
|
@@ -453,44 +567,24 @@ function Ve(e, a) {
|
|
|
453
567
|
message: "No previous page"
|
|
454
568
|
}
|
|
455
569
|
};
|
|
456
|
-
const
|
|
457
|
-
...
|
|
570
|
+
const r = await a({
|
|
571
|
+
...c,
|
|
458
572
|
nextPageToken: void 0,
|
|
459
|
-
previousPageToken:
|
|
573
|
+
previousPageToken: s.pagination.previousPageToken
|
|
460
574
|
});
|
|
461
|
-
return
|
|
575
|
+
return r.type === "success" && (m(r.page), i(c)), r;
|
|
462
576
|
},
|
|
463
|
-
refetchCurrentPage: async () =>
|
|
577
|
+
refetchCurrentPage: async () => o == null ? {
|
|
464
578
|
type: "error",
|
|
465
579
|
error: {
|
|
466
580
|
code: "NO_CURRENT_PAGE",
|
|
467
581
|
message: "No current page, please call fetchFirstPage first."
|
|
468
582
|
}
|
|
469
|
-
} :
|
|
470
|
-
currentPage:
|
|
583
|
+
} : a(o),
|
|
584
|
+
currentPage: s
|
|
471
585
|
};
|
|
472
586
|
}
|
|
473
|
-
|
|
474
|
-
const e = H(), a = async (t) => Pe({
|
|
475
|
-
pk: e.fency.publishableKey,
|
|
476
|
-
clientSecret: t.clientSecret,
|
|
477
|
-
baseUrl: e.fency.baseUrl
|
|
478
|
-
}), {
|
|
479
|
-
fetchFirstPage: s,
|
|
480
|
-
fetchNextPage: c,
|
|
481
|
-
fetchPreviousPage: i,
|
|
482
|
-
refetchCurrentPage: d,
|
|
483
|
-
currentPage: u
|
|
484
|
-
} = Ve(a);
|
|
485
|
-
return {
|
|
486
|
-
listFirstPage: s,
|
|
487
|
-
listNextPage: c,
|
|
488
|
-
listPreviousPage: i,
|
|
489
|
-
refetchCurrentPage: d,
|
|
490
|
-
currentPage: u
|
|
491
|
-
};
|
|
492
|
-
}
|
|
493
|
-
const xe = {
|
|
587
|
+
const $ = {
|
|
494
588
|
'code[class*="language-"]': {
|
|
495
589
|
color: "#f8f8f2",
|
|
496
590
|
background: "none",
|
|
@@ -641,81 +735,83 @@ const xe = {
|
|
|
641
735
|
italic: {
|
|
642
736
|
fontStyle: "italic"
|
|
643
737
|
}
|
|
644
|
-
},
|
|
738
|
+
}, Ce = ({
|
|
645
739
|
markdown: e,
|
|
646
|
-
|
|
647
|
-
|
|
740
|
+
streamToken: t,
|
|
741
|
+
fetchClientToken: o,
|
|
742
|
+
durationSeconds: i
|
|
648
743
|
}) => {
|
|
649
|
-
const { fency:
|
|
650
|
-
async (
|
|
744
|
+
const { fency: s } = U(), m = D(
|
|
745
|
+
async (u) => {
|
|
651
746
|
try {
|
|
652
|
-
const {
|
|
653
|
-
pk:
|
|
654
|
-
baseUrl:
|
|
655
|
-
|
|
747
|
+
const { clientToken: a } = await o(), n = await q({
|
|
748
|
+
pk: s.publishableKey,
|
|
749
|
+
baseUrl: s.baseUrl,
|
|
750
|
+
clientToken: a,
|
|
751
|
+
streamToken: t,
|
|
656
752
|
request: {
|
|
657
|
-
fileId:
|
|
753
|
+
fileId: u
|
|
658
754
|
}
|
|
659
755
|
});
|
|
660
|
-
|
|
661
|
-
} catch (
|
|
662
|
-
console.error("Failed to download file:",
|
|
756
|
+
n.type === "success" && window.open(n.downloadLink, "_blank");
|
|
757
|
+
} catch (a) {
|
|
758
|
+
console.error("Failed to download file:", a);
|
|
663
759
|
}
|
|
664
760
|
},
|
|
665
|
-
[
|
|
761
|
+
[s, t, o]
|
|
666
762
|
);
|
|
667
|
-
return /* @__PURE__ */
|
|
763
|
+
return /* @__PURE__ */ S(
|
|
668
764
|
"div",
|
|
669
765
|
{
|
|
670
766
|
style: {
|
|
671
767
|
padding: "16px"
|
|
672
768
|
},
|
|
673
769
|
children: [
|
|
674
|
-
/* @__PURE__ */
|
|
675
|
-
|
|
770
|
+
/* @__PURE__ */ g(
|
|
771
|
+
v.div,
|
|
676
772
|
{
|
|
677
773
|
className: "fency-markdown-body-raw",
|
|
678
774
|
initial: { opacity: 0, y: -10 },
|
|
679
775
|
animate: { opacity: 1, y: 0 },
|
|
680
776
|
transition: { duration: 0.3, delay: 0 },
|
|
681
|
-
children: /* @__PURE__ */
|
|
682
|
-
|
|
777
|
+
children: /* @__PURE__ */ g(
|
|
778
|
+
W,
|
|
683
779
|
{
|
|
684
|
-
remarkPlugins: [
|
|
780
|
+
remarkPlugins: [p],
|
|
685
781
|
components: {
|
|
686
|
-
code(
|
|
687
|
-
const { children:
|
|
688
|
-
return r ? /* @__PURE__ */
|
|
689
|
-
|
|
782
|
+
code(u) {
|
|
783
|
+
const { children: a, className: n, node: d, ref: l, ...c } = u, r = /language-(\w+)/.exec(n || "");
|
|
784
|
+
return r ? /* @__PURE__ */ g(
|
|
785
|
+
j,
|
|
690
786
|
{
|
|
691
|
-
...
|
|
787
|
+
...c,
|
|
692
788
|
PreTag: "div",
|
|
693
|
-
children: String(
|
|
789
|
+
children: String(a).replace(
|
|
694
790
|
/\n$/,
|
|
695
791
|
""
|
|
696
792
|
),
|
|
697
793
|
language: r[1],
|
|
698
|
-
style:
|
|
794
|
+
style: $
|
|
699
795
|
}
|
|
700
|
-
) : /* @__PURE__ */
|
|
796
|
+
) : /* @__PURE__ */ g("code", { ...c, className: n, children: String(a) });
|
|
701
797
|
},
|
|
702
|
-
a(
|
|
703
|
-
const { children:
|
|
704
|
-
return /* @__PURE__ */
|
|
798
|
+
a(u) {
|
|
799
|
+
const { children: a, href: n, ...d } = u;
|
|
800
|
+
return /* @__PURE__ */ g(
|
|
705
801
|
"a",
|
|
706
802
|
{
|
|
707
|
-
...
|
|
708
|
-
href:
|
|
709
|
-
onClick: (
|
|
710
|
-
if (!
|
|
711
|
-
const
|
|
712
|
-
if (
|
|
713
|
-
|
|
714
|
-
const r =
|
|
715
|
-
|
|
803
|
+
...d,
|
|
804
|
+
href: n,
|
|
805
|
+
onClick: (l) => {
|
|
806
|
+
if (!n) return;
|
|
807
|
+
const c = n.match(/\/files\/(fil_[a-zA-Z0-9]+)\/download/);
|
|
808
|
+
if (c) {
|
|
809
|
+
l.preventDefault();
|
|
810
|
+
const r = c[1];
|
|
811
|
+
m(r);
|
|
716
812
|
}
|
|
717
813
|
},
|
|
718
|
-
children:
|
|
814
|
+
children: a
|
|
719
815
|
}
|
|
720
816
|
);
|
|
721
817
|
}
|
|
@@ -725,7 +821,7 @@ const xe = {
|
|
|
725
821
|
)
|
|
726
822
|
}
|
|
727
823
|
),
|
|
728
|
-
|
|
824
|
+
i !== void 0 && /* @__PURE__ */ S(
|
|
729
825
|
"div",
|
|
730
826
|
{
|
|
731
827
|
style: {
|
|
@@ -736,7 +832,7 @@ const xe = {
|
|
|
736
832
|
},
|
|
737
833
|
children: [
|
|
738
834
|
"Thought for ",
|
|
739
|
-
|
|
835
|
+
i,
|
|
740
836
|
" seconds"
|
|
741
837
|
]
|
|
742
838
|
}
|
|
@@ -745,27 +841,27 @@ const xe = {
|
|
|
745
841
|
}
|
|
746
842
|
);
|
|
747
843
|
};
|
|
748
|
-
function
|
|
844
|
+
function M({
|
|
749
845
|
text: e,
|
|
750
|
-
duration:
|
|
751
|
-
delay:
|
|
752
|
-
repeat:
|
|
753
|
-
repeatDelay:
|
|
754
|
-
className:
|
|
846
|
+
duration: t = 2,
|
|
847
|
+
delay: o = 0,
|
|
848
|
+
repeat: i = !0,
|
|
849
|
+
repeatDelay: s = 0.5,
|
|
850
|
+
className: m,
|
|
755
851
|
startOnView: u = !1,
|
|
756
|
-
once:
|
|
852
|
+
once: a = !1,
|
|
757
853
|
inViewMargin: n,
|
|
758
|
-
spread:
|
|
759
|
-
color:
|
|
760
|
-
shimmerColor:
|
|
761
|
-
direction:
|
|
854
|
+
spread: d = 2,
|
|
855
|
+
color: l = "#999",
|
|
856
|
+
shimmerColor: c = "#000",
|
|
857
|
+
direction: r = "fromBottom"
|
|
762
858
|
}) {
|
|
763
|
-
const
|
|
764
|
-
return /* @__PURE__ */
|
|
765
|
-
|
|
859
|
+
const f = R(null), h = Y(f, { once: a, margin: n }), C = B(() => e.length * d, [e, d]), b = !u || h, y = r === "fromBottom" ? "100% center" : "-100% center", w = r === "fromBottom" ? "0% center" : "200% center";
|
|
860
|
+
return /* @__PURE__ */ g(
|
|
861
|
+
v.span,
|
|
766
862
|
{
|
|
767
|
-
ref:
|
|
768
|
-
className:
|
|
863
|
+
ref: f,
|
|
864
|
+
className: m,
|
|
769
865
|
style: {
|
|
770
866
|
position: "relative",
|
|
771
867
|
display: "inline-block",
|
|
@@ -775,9 +871,9 @@ function se({
|
|
|
775
871
|
color: "transparent",
|
|
776
872
|
WebkitTextFillColor: "transparent",
|
|
777
873
|
backgroundRepeat: "no-repeat, padding-box",
|
|
778
|
-
"--spread": `${
|
|
779
|
-
"--base-color":
|
|
780
|
-
"--shimmer-color":
|
|
874
|
+
"--spread": `${C}px`,
|
|
875
|
+
"--base-color": l,
|
|
876
|
+
"--shimmer-color": c,
|
|
781
877
|
"--shimmer-bg": "linear-gradient(90deg, transparent calc(50% - var(--spread)), var(--shimmer-color), transparent calc(50% + var(--spread)))",
|
|
782
878
|
backgroundImage: "var(--shimmer-bg), linear-gradient(var(--base-color), var(--base-color))"
|
|
783
879
|
},
|
|
@@ -785,41 +881,41 @@ function se({
|
|
|
785
881
|
backgroundPosition: y,
|
|
786
882
|
opacity: 0
|
|
787
883
|
},
|
|
788
|
-
animate:
|
|
789
|
-
backgroundPosition:
|
|
884
|
+
animate: b ? {
|
|
885
|
+
backgroundPosition: w,
|
|
790
886
|
opacity: 1
|
|
791
887
|
} : {},
|
|
792
888
|
transition: {
|
|
793
889
|
backgroundPosition: {
|
|
794
|
-
repeat:
|
|
795
|
-
duration:
|
|
796
|
-
delay:
|
|
797
|
-
repeatDelay:
|
|
890
|
+
repeat: i ? 1 / 0 : 0,
|
|
891
|
+
duration: t,
|
|
892
|
+
delay: o,
|
|
893
|
+
repeatDelay: s,
|
|
798
894
|
ease: "linear"
|
|
799
895
|
},
|
|
800
896
|
opacity: {
|
|
801
897
|
duration: 0.3,
|
|
802
|
-
delay:
|
|
898
|
+
delay: o
|
|
803
899
|
}
|
|
804
900
|
},
|
|
805
901
|
children: e
|
|
806
902
|
}
|
|
807
903
|
);
|
|
808
904
|
}
|
|
809
|
-
const
|
|
905
|
+
const be = ({
|
|
810
906
|
title: e,
|
|
811
|
-
completed:
|
|
812
|
-
isLatest:
|
|
813
|
-
durationSeconds:
|
|
814
|
-
}) => /* @__PURE__ */
|
|
907
|
+
completed: t,
|
|
908
|
+
isLatest: o = !1,
|
|
909
|
+
durationSeconds: i
|
|
910
|
+
}) => /* @__PURE__ */ S(
|
|
815
911
|
"div",
|
|
816
912
|
{
|
|
817
913
|
style: {
|
|
818
914
|
padding: "16px"
|
|
819
915
|
},
|
|
820
916
|
children: [
|
|
821
|
-
/* @__PURE__ */
|
|
822
|
-
|
|
917
|
+
/* @__PURE__ */ g(
|
|
918
|
+
v.div,
|
|
823
919
|
{
|
|
824
920
|
style: {
|
|
825
921
|
display: "flex",
|
|
@@ -830,8 +926,8 @@ const Je = ({
|
|
|
830
926
|
initial: { opacity: 0, y: -10 },
|
|
831
927
|
animate: { opacity: 1, y: 0 },
|
|
832
928
|
transition: { duration: 0.3, delay: 0 },
|
|
833
|
-
children:
|
|
834
|
-
|
|
929
|
+
children: o && !i ? /* @__PURE__ */ g(
|
|
930
|
+
M,
|
|
835
931
|
{
|
|
836
932
|
text: e,
|
|
837
933
|
duration: 2.5,
|
|
@@ -839,10 +935,10 @@ const Je = ({
|
|
|
839
935
|
color: "#999",
|
|
840
936
|
shimmerColor: "#000"
|
|
841
937
|
}
|
|
842
|
-
) : /* @__PURE__ */
|
|
938
|
+
) : /* @__PURE__ */ g("span", { style: { color: "#666" }, children: e })
|
|
843
939
|
}
|
|
844
940
|
),
|
|
845
|
-
|
|
941
|
+
i !== void 0 && /* @__PURE__ */ S(
|
|
846
942
|
"div",
|
|
847
943
|
{
|
|
848
944
|
style: {
|
|
@@ -853,44 +949,44 @@ const Je = ({
|
|
|
853
949
|
},
|
|
854
950
|
children: [
|
|
855
951
|
"Thought for ",
|
|
856
|
-
|
|
952
|
+
i,
|
|
857
953
|
" seconds"
|
|
858
954
|
]
|
|
859
955
|
}
|
|
860
956
|
),
|
|
861
|
-
/* @__PURE__ */
|
|
957
|
+
/* @__PURE__ */ g("style", { children: `
|
|
862
958
|
@keyframes spin {
|
|
863
959
|
to { transform: rotate(360deg); }
|
|
864
960
|
}
|
|
865
961
|
` })
|
|
866
962
|
]
|
|
867
963
|
}
|
|
868
|
-
),
|
|
964
|
+
), we = ({
|
|
869
965
|
title: e,
|
|
870
|
-
markdown:
|
|
871
|
-
completed:
|
|
872
|
-
isLatest:
|
|
873
|
-
durationSeconds:
|
|
966
|
+
markdown: t,
|
|
967
|
+
completed: o,
|
|
968
|
+
isLatest: i = !1,
|
|
969
|
+
durationSeconds: s
|
|
874
970
|
}) => {
|
|
875
|
-
const
|
|
876
|
-
return
|
|
877
|
-
|
|
878
|
-
}, [
|
|
971
|
+
const m = R(null);
|
|
972
|
+
return P(() => {
|
|
973
|
+
m.current && !o && (m.current.scrollTop = m.current.scrollHeight);
|
|
974
|
+
}, [t, o]), /* @__PURE__ */ S(
|
|
879
975
|
"div",
|
|
880
976
|
{
|
|
881
977
|
style: {
|
|
882
978
|
padding: "16px"
|
|
883
979
|
},
|
|
884
980
|
children: [
|
|
885
|
-
/* @__PURE__ */
|
|
886
|
-
|
|
981
|
+
/* @__PURE__ */ g(
|
|
982
|
+
v.h3,
|
|
887
983
|
{
|
|
888
984
|
style: { marginBottom: "10px", color: "#666" },
|
|
889
985
|
initial: { opacity: 0, y: -10 },
|
|
890
986
|
animate: { opacity: 1, y: 0 },
|
|
891
987
|
transition: { duration: 0.3, delay: 0 },
|
|
892
|
-
children:
|
|
893
|
-
|
|
988
|
+
children: i && !s ? /* @__PURE__ */ g(
|
|
989
|
+
M,
|
|
894
990
|
{
|
|
895
991
|
text: e,
|
|
896
992
|
duration: 2.5,
|
|
@@ -901,10 +997,10 @@ const Je = ({
|
|
|
901
997
|
) : e
|
|
902
998
|
}
|
|
903
999
|
),
|
|
904
|
-
/* @__PURE__ */
|
|
905
|
-
|
|
1000
|
+
/* @__PURE__ */ g(
|
|
1001
|
+
v.div,
|
|
906
1002
|
{
|
|
907
|
-
ref:
|
|
1003
|
+
ref: m,
|
|
908
1004
|
style: {
|
|
909
1005
|
maxHeight: "100px",
|
|
910
1006
|
overflowY: "auto",
|
|
@@ -917,42 +1013,42 @@ const Je = ({
|
|
|
917
1013
|
initial: { opacity: 0, y: -10 },
|
|
918
1014
|
animate: { opacity: 0.5, y: 0 },
|
|
919
1015
|
transition: { duration: 0.3, delay: 0.1 },
|
|
920
|
-
children: /* @__PURE__ */
|
|
921
|
-
|
|
1016
|
+
children: /* @__PURE__ */ g("div", { className: "fency-markdown-body-raw", children: /* @__PURE__ */ g(
|
|
1017
|
+
W,
|
|
922
1018
|
{
|
|
923
|
-
remarkPlugins: [
|
|
1019
|
+
remarkPlugins: [p],
|
|
924
1020
|
components: {
|
|
925
1021
|
code(u) {
|
|
926
1022
|
const {
|
|
927
|
-
children:
|
|
1023
|
+
children: a,
|
|
928
1024
|
className: n,
|
|
929
|
-
node:
|
|
930
|
-
ref:
|
|
931
|
-
...
|
|
932
|
-
} = u,
|
|
1025
|
+
node: d,
|
|
1026
|
+
ref: l,
|
|
1027
|
+
...c
|
|
1028
|
+
} = u, r = /language-(\w+)/.exec(
|
|
933
1029
|
n || ""
|
|
934
1030
|
);
|
|
935
|
-
return
|
|
936
|
-
|
|
1031
|
+
return r ? /* @__PURE__ */ g(
|
|
1032
|
+
j,
|
|
937
1033
|
{
|
|
938
|
-
...
|
|
1034
|
+
...c,
|
|
939
1035
|
PreTag: "div",
|
|
940
|
-
children: String(
|
|
1036
|
+
children: String(a).replace(
|
|
941
1037
|
/\n$/,
|
|
942
1038
|
""
|
|
943
1039
|
),
|
|
944
|
-
language:
|
|
945
|
-
style:
|
|
1040
|
+
language: r[1],
|
|
1041
|
+
style: $
|
|
946
1042
|
}
|
|
947
|
-
) : /* @__PURE__ */
|
|
1043
|
+
) : /* @__PURE__ */ g("code", { ...c, className: n, children: String(a) });
|
|
948
1044
|
}
|
|
949
1045
|
},
|
|
950
|
-
children:
|
|
1046
|
+
children: t
|
|
951
1047
|
}
|
|
952
1048
|
) })
|
|
953
1049
|
}
|
|
954
1050
|
),
|
|
955
|
-
|
|
1051
|
+
s !== void 0 && /* @__PURE__ */ S(
|
|
956
1052
|
"div",
|
|
957
1053
|
{
|
|
958
1054
|
style: {
|
|
@@ -963,7 +1059,7 @@ const Je = ({
|
|
|
963
1059
|
},
|
|
964
1060
|
children: [
|
|
965
1061
|
"Thought for ",
|
|
966
|
-
|
|
1062
|
+
s,
|
|
967
1063
|
" seconds"
|
|
968
1064
|
]
|
|
969
1065
|
}
|
|
@@ -971,108 +1067,110 @@ const Je = ({
|
|
|
971
1067
|
]
|
|
972
1068
|
}
|
|
973
1069
|
);
|
|
974
|
-
},
|
|
975
|
-
const
|
|
976
|
-
if (
|
|
977
|
-
return /* @__PURE__ */
|
|
978
|
-
|
|
1070
|
+
}, ke = ({ message: e, isLatest: t = !1, streamToken: o, fetchClientToken: i }) => {
|
|
1071
|
+
const s = e.state || "complete";
|
|
1072
|
+
if (s === F.EXECUTION)
|
|
1073
|
+
return /* @__PURE__ */ g(
|
|
1074
|
+
be,
|
|
979
1075
|
{
|
|
980
1076
|
title: e.title,
|
|
981
1077
|
completed: e.completed,
|
|
982
|
-
isLatest:
|
|
1078
|
+
isLatest: t,
|
|
983
1079
|
durationSeconds: e.durationSeconds
|
|
984
1080
|
}
|
|
985
1081
|
);
|
|
986
|
-
if (
|
|
987
|
-
return /* @__PURE__ */
|
|
988
|
-
|
|
1082
|
+
if (s === F.REASONING)
|
|
1083
|
+
return /* @__PURE__ */ g(
|
|
1084
|
+
we,
|
|
989
1085
|
{
|
|
990
1086
|
title: e.title,
|
|
991
1087
|
markdown: e.markdown,
|
|
992
1088
|
completed: e.completed,
|
|
993
|
-
isLatest:
|
|
1089
|
+
isLatest: t,
|
|
994
1090
|
durationSeconds: e.durationSeconds
|
|
995
1091
|
}
|
|
996
1092
|
);
|
|
997
|
-
if (
|
|
998
|
-
return /* @__PURE__ */
|
|
999
|
-
|
|
1093
|
+
if (s === F.FINAL_RESPONSE)
|
|
1094
|
+
return /* @__PURE__ */ g(
|
|
1095
|
+
Ce,
|
|
1000
1096
|
{
|
|
1001
1097
|
markdown: e.markdown,
|
|
1002
|
-
|
|
1098
|
+
streamToken: o,
|
|
1099
|
+
fetchClientToken: i,
|
|
1003
1100
|
durationSeconds: e.durationSeconds
|
|
1004
1101
|
}
|
|
1005
1102
|
);
|
|
1006
|
-
throw new Error(`Unknown state: ${
|
|
1007
|
-
},
|
|
1103
|
+
throw new Error(`Unknown state: ${s}`);
|
|
1104
|
+
}, Fe = ({
|
|
1008
1105
|
agentTask: e,
|
|
1009
|
-
mode:
|
|
1010
|
-
placeholderMessage:
|
|
1011
|
-
|
|
1106
|
+
mode: t = "verbose",
|
|
1107
|
+
placeholderMessage: o = "Processing your request",
|
|
1108
|
+
streamToken: i,
|
|
1109
|
+
fetchClientToken: s
|
|
1012
1110
|
}) => {
|
|
1013
|
-
const [
|
|
1014
|
-
if (
|
|
1015
|
-
const
|
|
1016
|
-
let
|
|
1017
|
-
const
|
|
1018
|
-
if (
|
|
1019
|
-
const
|
|
1020
|
-
|
|
1111
|
+
const [m, u] = k([]), a = R(null);
|
|
1112
|
+
if (P(() => {
|
|
1113
|
+
const n = e.progressItems.map((r, f) => {
|
|
1114
|
+
let h;
|
|
1115
|
+
const C = e.progressItems[f + 1];
|
|
1116
|
+
if (C != null && C.startedAt) {
|
|
1117
|
+
const y = new Date(r.startedAt).getTime(), w = new Date(C.startedAt).getTime();
|
|
1118
|
+
h = Math.round((w - y) / 1e3);
|
|
1021
1119
|
}
|
|
1022
|
-
const
|
|
1120
|
+
const b = C != null;
|
|
1023
1121
|
return {
|
|
1024
1122
|
id: r.progressItemId,
|
|
1025
1123
|
title: r.title,
|
|
1026
1124
|
markdown: r.response || "",
|
|
1027
1125
|
state: r.progressItemType,
|
|
1028
|
-
completed:
|
|
1126
|
+
completed: b,
|
|
1029
1127
|
startedAt: r.startedAt,
|
|
1030
1128
|
completedAt: r.completedAt,
|
|
1031
|
-
durationSeconds:
|
|
1129
|
+
durationSeconds: h
|
|
1032
1130
|
};
|
|
1033
1131
|
});
|
|
1034
|
-
let
|
|
1035
|
-
const
|
|
1036
|
-
if (
|
|
1037
|
-
const r = new Date(e.triggeredAt).getTime(),
|
|
1038
|
-
|
|
1132
|
+
let d;
|
|
1133
|
+
const l = e.progressItems[0];
|
|
1134
|
+
if (l != null && l.startedAt) {
|
|
1135
|
+
const r = new Date(e.triggeredAt).getTime(), f = new Date(l.startedAt).getTime();
|
|
1136
|
+
d = Math.round((f - r) / 1e3);
|
|
1039
1137
|
}
|
|
1040
|
-
const
|
|
1138
|
+
const c = {
|
|
1041
1139
|
id: "placeholder",
|
|
1042
|
-
title:
|
|
1140
|
+
title: o,
|
|
1043
1141
|
markdown: "",
|
|
1044
|
-
state:
|
|
1045
|
-
completed:
|
|
1046
|
-
durationSeconds:
|
|
1142
|
+
state: F.EXECUTION,
|
|
1143
|
+
completed: l != null,
|
|
1144
|
+
durationSeconds: d
|
|
1047
1145
|
};
|
|
1048
|
-
|
|
1049
|
-
}, [e,
|
|
1050
|
-
|
|
1051
|
-
}, [
|
|
1052
|
-
const
|
|
1053
|
-
if (!
|
|
1146
|
+
u([c, ...n]);
|
|
1147
|
+
}, [e, o]), P(() => {
|
|
1148
|
+
t === "verbose" && a.current && (a.current.scrollTop = a.current.scrollHeight);
|
|
1149
|
+
}, [m, t]), t === "simple") {
|
|
1150
|
+
const n = m[m.length - 1];
|
|
1151
|
+
if (!n)
|
|
1054
1152
|
return null;
|
|
1055
|
-
const
|
|
1056
|
-
return /* @__PURE__ */
|
|
1057
|
-
|
|
1153
|
+
const d = n.completed;
|
|
1154
|
+
return /* @__PURE__ */ g("div", { className: "simple-mode-container", children: /* @__PURE__ */ g(_, { mode: "wait", children: /* @__PURE__ */ g(
|
|
1155
|
+
v.div,
|
|
1058
1156
|
{
|
|
1059
1157
|
initial: { opacity: 0, y: 10 },
|
|
1060
1158
|
animate: { opacity: 1, y: 0 },
|
|
1061
1159
|
exit: { opacity: 0, y: -10 },
|
|
1062
1160
|
transition: { duration: 0.3 },
|
|
1063
|
-
children:
|
|
1161
|
+
children: d ? /* @__PURE__ */ g(
|
|
1064
1162
|
"div",
|
|
1065
1163
|
{
|
|
1066
1164
|
className: "simple-mode-title",
|
|
1067
1165
|
style: {
|
|
1068
1166
|
color: "#666"
|
|
1069
1167
|
},
|
|
1070
|
-
children:
|
|
1168
|
+
children: n.title
|
|
1071
1169
|
}
|
|
1072
|
-
) : /* @__PURE__ */
|
|
1073
|
-
|
|
1170
|
+
) : /* @__PURE__ */ g(
|
|
1171
|
+
M,
|
|
1074
1172
|
{
|
|
1075
|
-
text:
|
|
1173
|
+
text: n.title,
|
|
1076
1174
|
className: "simple-mode-title",
|
|
1077
1175
|
duration: 2.5,
|
|
1078
1176
|
repeat: !0,
|
|
@@ -1081,820 +1179,111 @@ const Je = ({
|
|
|
1081
1179
|
}
|
|
1082
1180
|
)
|
|
1083
1181
|
},
|
|
1084
|
-
|
|
1182
|
+
n.id
|
|
1085
1183
|
) }) });
|
|
1086
1184
|
}
|
|
1087
|
-
return /* @__PURE__ */
|
|
1185
|
+
return /* @__PURE__ */ g(
|
|
1088
1186
|
"div",
|
|
1089
1187
|
{
|
|
1090
|
-
ref:
|
|
1188
|
+
ref: a,
|
|
1091
1189
|
style: {
|
|
1092
1190
|
flex: 1,
|
|
1093
1191
|
overflowY: "auto",
|
|
1094
1192
|
minHeight: 0
|
|
1095
1193
|
// Important for flex scroll
|
|
1096
1194
|
},
|
|
1097
|
-
children: /* @__PURE__ */
|
|
1098
|
-
|
|
1195
|
+
children: /* @__PURE__ */ g(_, { children: m.length > 0 && m.map((n, d) => /* @__PURE__ */ g(
|
|
1196
|
+
v.div,
|
|
1099
1197
|
{
|
|
1100
1198
|
initial: { opacity: 0, y: -20 },
|
|
1101
1199
|
animate: { opacity: 1, y: 0 },
|
|
1102
1200
|
transition: {
|
|
1103
1201
|
duration: 0.4,
|
|
1104
|
-
delay:
|
|
1202
|
+
delay: d * 0.1,
|
|
1105
1203
|
// Stagger effect
|
|
1106
1204
|
ease: "easeOut"
|
|
1107
1205
|
},
|
|
1108
|
-
children: /* @__PURE__ */
|
|
1109
|
-
|
|
1206
|
+
children: /* @__PURE__ */ g(
|
|
1207
|
+
ke,
|
|
1110
1208
|
{
|
|
1111
|
-
message:
|
|
1112
|
-
isLatest:
|
|
1113
|
-
|
|
1209
|
+
message: n,
|
|
1210
|
+
isLatest: d === m.length - 1,
|
|
1211
|
+
streamToken: i,
|
|
1212
|
+
fetchClientToken: s
|
|
1114
1213
|
}
|
|
1115
1214
|
)
|
|
1116
1215
|
},
|
|
1117
|
-
|
|
1216
|
+
n.id
|
|
1118
1217
|
)) })
|
|
1119
1218
|
}
|
|
1120
1219
|
);
|
|
1121
|
-
}, tt = "_wrapper_nvp45_1", nt = "_editable_nvp45_12", rt = "_mention_nvp45_48", ot = "_ghostWrapper_nvp45_58", at = "_ghost_nvp45_58", V = {
|
|
1122
|
-
wrapper: tt,
|
|
1123
|
-
editable: nt,
|
|
1124
|
-
mention: rt,
|
|
1125
|
-
ghostWrapper: ot,
|
|
1126
|
-
ghost: at
|
|
1127
|
-
}, st = ({
|
|
1128
|
-
editableRef: e,
|
|
1129
|
-
onInput: a,
|
|
1130
|
-
onKeyDown: s,
|
|
1131
|
-
isComposingRef: c,
|
|
1132
|
-
handleInput: i,
|
|
1133
|
-
placeholder: d = "Type your question or task and press Enter…"
|
|
1134
|
-
}) => {
|
|
1135
|
-
const [u, t] = x(!0);
|
|
1136
|
-
return N(() => {
|
|
1137
|
-
const n = () => {
|
|
1138
|
-
if (e.current) {
|
|
1139
|
-
const m = e.current.textContent || "";
|
|
1140
|
-
t(m.trim().length === 0);
|
|
1141
|
-
}
|
|
1142
|
-
};
|
|
1143
|
-
n();
|
|
1144
|
-
const h = new MutationObserver(n);
|
|
1145
|
-
return e.current && h.observe(e.current, {
|
|
1146
|
-
childList: !0,
|
|
1147
|
-
characterData: !0,
|
|
1148
|
-
subtree: !0
|
|
1149
|
-
}), () => h.disconnect();
|
|
1150
|
-
}, [e]), /* @__PURE__ */ f(
|
|
1151
|
-
"div",
|
|
1152
|
-
{
|
|
1153
|
-
ref: e,
|
|
1154
|
-
contentEditable: !0,
|
|
1155
|
-
onInput: a,
|
|
1156
|
-
onKeyDown: s,
|
|
1157
|
-
onCompositionStart: () => {
|
|
1158
|
-
c.current = !0;
|
|
1159
|
-
},
|
|
1160
|
-
onCompositionEnd: () => {
|
|
1161
|
-
c.current = !1, i();
|
|
1162
|
-
},
|
|
1163
|
-
className: V.editable,
|
|
1164
|
-
"data-placeholder": d,
|
|
1165
|
-
"data-empty": u ? "true" : "false",
|
|
1166
|
-
suppressContentEditableWarning: !0
|
|
1167
|
-
}
|
|
1168
|
-
);
|
|
1169
|
-
}, ct = ({
|
|
1170
|
-
ghostRef: e,
|
|
1171
|
-
isOpen: a,
|
|
1172
|
-
value: s,
|
|
1173
|
-
atPosition: c,
|
|
1174
|
-
caretPos: i
|
|
1175
|
-
}) => /* @__PURE__ */ f("div", { className: V.ghostWrapper, children: /* @__PURE__ */ f("div", { ref: e, className: V.ghost, children: (() => {
|
|
1176
|
-
if (a) {
|
|
1177
|
-
const d = s.slice(0, c), u = s.slice(c);
|
|
1178
|
-
return /* @__PURE__ */ A(fe, { children: [
|
|
1179
|
-
d,
|
|
1180
|
-
/* @__PURE__ */ f("span", { "data-at-marker": !0, children: "@" }),
|
|
1181
|
-
u.slice(1),
|
|
1182
|
-
" "
|
|
1183
|
-
] });
|
|
1184
|
-
} else {
|
|
1185
|
-
const d = s.slice(0, i), u = s.slice(i);
|
|
1186
|
-
return /* @__PURE__ */ A(fe, { children: [
|
|
1187
|
-
d,
|
|
1188
|
-
/* @__PURE__ */ f("span", { "data-caret": !0, children: "|" }),
|
|
1189
|
-
u
|
|
1190
|
-
] });
|
|
1191
|
-
}
|
|
1192
|
-
})() }) });
|
|
1193
|
-
function it(e) {
|
|
1194
|
-
const a = I(() => {
|
|
1195
|
-
const i = window.getSelection();
|
|
1196
|
-
if (!i || i.rangeCount === 0 || !e.current) return 0;
|
|
1197
|
-
const d = i.getRangeAt(0), u = d.cloneRange();
|
|
1198
|
-
return u.selectNodeContents(e.current), u.setEnd(d.endContainer, d.endOffset), u.toString().length;
|
|
1199
|
-
}, [e]), s = I((i) => {
|
|
1200
|
-
var r;
|
|
1201
|
-
if (!e.current) return;
|
|
1202
|
-
const d = window.getSelection();
|
|
1203
|
-
if (!d) return;
|
|
1204
|
-
let u = 0;
|
|
1205
|
-
const t = [e.current];
|
|
1206
|
-
let n, h = null, m = 0;
|
|
1207
|
-
for (; n = t.pop(); )
|
|
1208
|
-
if (n.nodeType === Node.TEXT_NODE) {
|
|
1209
|
-
const o = n, l = u + (((r = o.textContent) == null ? void 0 : r.length) || 0);
|
|
1210
|
-
if (i <= l) {
|
|
1211
|
-
h = o, m = i - u;
|
|
1212
|
-
break;
|
|
1213
|
-
}
|
|
1214
|
-
u = l;
|
|
1215
|
-
} else
|
|
1216
|
-
for (let o = n.childNodes.length - 1; o >= 0; o--)
|
|
1217
|
-
t.push(n.childNodes[o]);
|
|
1218
|
-
if (h) {
|
|
1219
|
-
const o = document.createRange();
|
|
1220
|
-
o.setStart(h, m), o.collapse(!0), d.removeAllRanges(), d.addRange(o);
|
|
1221
|
-
}
|
|
1222
|
-
}, [e]), c = I(() => {
|
|
1223
|
-
if (!e.current) return "";
|
|
1224
|
-
const i = e.current.cloneNode(!0);
|
|
1225
|
-
return i.querySelectorAll("br").forEach((d) => {
|
|
1226
|
-
d.replaceWith(`
|
|
1227
|
-
`);
|
|
1228
|
-
}), i.textContent || "";
|
|
1229
|
-
}, [e]);
|
|
1230
|
-
return {
|
|
1231
|
-
getCaretPosition: a,
|
|
1232
|
-
setCaretPosition: s,
|
|
1233
|
-
getPlainText: c
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
1236
|
-
function lt({
|
|
1237
|
-
onArrowDown: e,
|
|
1238
|
-
onArrowUp: a,
|
|
1239
|
-
onEnter: s,
|
|
1240
|
-
onEscape: c
|
|
1241
|
-
}) {
|
|
1242
|
-
return {
|
|
1243
|
-
handleKeyDown: I(
|
|
1244
|
-
(d) => d.key === "ArrowUp" ? (d.preventDefault(), a(), !0) : d.key === "ArrowDown" ? (d.preventDefault(), e(), !0) : d.key === "Enter" && !d.shiftKey ? (d.preventDefault(), s(), !0) : d.key === "Escape" ? (d.preventDefault(), c(), !0) : !1,
|
|
1245
|
-
[e, a, s, c]
|
|
1246
|
-
)
|
|
1247
|
-
};
|
|
1248
|
-
}
|
|
1249
|
-
function ut({
|
|
1250
|
-
options: e,
|
|
1251
|
-
onMentionChange: a,
|
|
1252
|
-
onChangeMentionPlaceholders: s
|
|
1253
|
-
}) {
|
|
1254
|
-
const c = _([]), i = I(
|
|
1255
|
-
(t) => {
|
|
1256
|
-
const n = /* @__PURE__ */ new Set();
|
|
1257
|
-
if (e.length > 0) {
|
|
1258
|
-
const h = [...e].sort((r, o) => o.label.length - r.label.length), m = [];
|
|
1259
|
-
h.forEach((r) => {
|
|
1260
|
-
const o = r.label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = new RegExp(`@${o}(?=\\s|$)`, "g");
|
|
1261
|
-
let g;
|
|
1262
|
-
for (; (g = l.exec(t)) !== null; )
|
|
1263
|
-
m.some((p) => Math.abs(p - g.index) < r.label.length) || (n.add(r.id), m.push(g.index));
|
|
1264
|
-
});
|
|
1265
|
-
}
|
|
1266
|
-
return Array.from(n);
|
|
1267
|
-
},
|
|
1268
|
-
[e]
|
|
1269
|
-
), d = I(
|
|
1270
|
-
(t) => {
|
|
1271
|
-
let n = t;
|
|
1272
|
-
if (e.length > 0) {
|
|
1273
|
-
const h = [...e].sort((r, o) => o.label.length - r.label.length), m = [];
|
|
1274
|
-
h.forEach((r) => {
|
|
1275
|
-
const o = r.label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = new RegExp(`@${o}(?=\\s|$)`, "g");
|
|
1276
|
-
let g;
|
|
1277
|
-
for (; (g = l.exec(t)) !== null; )
|
|
1278
|
-
m.some(
|
|
1279
|
-
(C) => g.index >= C.start && g.index < C.end
|
|
1280
|
-
) || m.push({
|
|
1281
|
-
start: g.index,
|
|
1282
|
-
end: g.index + g[0].length,
|
|
1283
|
-
placeholder: `{{{{${r.id}}}}}`
|
|
1284
|
-
});
|
|
1285
|
-
}), m.sort((r, o) => o.start - r.start), m.forEach((r) => {
|
|
1286
|
-
n = n.slice(0, r.start) + r.placeholder + n.slice(r.end);
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
return n;
|
|
1290
|
-
},
|
|
1291
|
-
[e]
|
|
1292
|
-
), u = I(
|
|
1293
|
-
(t) => {
|
|
1294
|
-
const n = i(t), h = c.current;
|
|
1295
|
-
(n.length !== h.length || n.some((l, g) => l !== h[g])) && (c.current = n, a(n));
|
|
1296
|
-
const r = n.map((l) => e.find((g) => g.id === l)).filter((l) => l !== void 0), o = d(t);
|
|
1297
|
-
s(o, r);
|
|
1298
|
-
},
|
|
1299
|
-
[
|
|
1300
|
-
i,
|
|
1301
|
-
d,
|
|
1302
|
-
a,
|
|
1303
|
-
s,
|
|
1304
|
-
e
|
|
1305
|
-
]
|
|
1306
|
-
);
|
|
1307
|
-
return {
|
|
1308
|
-
extractMentionIds: i,
|
|
1309
|
-
buildPlaceholderText: d,
|
|
1310
|
-
processText: u
|
|
1311
|
-
};
|
|
1312
|
-
}
|
|
1313
|
-
function dt({
|
|
1314
|
-
editableRef: e,
|
|
1315
|
-
options: a,
|
|
1316
|
-
mentionClassName: s,
|
|
1317
|
-
getCaretPosition: c,
|
|
1318
|
-
setCaretPosition: i
|
|
1319
|
-
}) {
|
|
1320
|
-
const d = _(""), u = I((r) => r.replace(/</g, "<").replace(/>/g, ">").replace(/\n/g, "<br>"), []), t = I((r, o = !1) => {
|
|
1321
|
-
if (!e.current) return;
|
|
1322
|
-
const l = o ? c() : 0;
|
|
1323
|
-
let g = "";
|
|
1324
|
-
const p = [];
|
|
1325
|
-
if (a.length > 0) {
|
|
1326
|
-
[...a].sort((S, M) => M.label.length - S.label.length).forEach((S) => {
|
|
1327
|
-
const M = S.label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), W = new RegExp(`@${M}(?=\\s|$)`, "g");
|
|
1328
|
-
let E;
|
|
1329
|
-
for (; (E = W.exec(r)) !== null; )
|
|
1330
|
-
p.some(
|
|
1331
|
-
(U) => E.index >= U.start && E.index < U.end
|
|
1332
|
-
) || p.push({
|
|
1333
|
-
start: E.index,
|
|
1334
|
-
end: E.index + E[0].length,
|
|
1335
|
-
html: `<span class="${s}" data-mention="${S.label}">${E[0]}</span>`
|
|
1336
|
-
});
|
|
1337
|
-
}), p.sort((S, M) => S.start - M.start);
|
|
1338
|
-
let y = 0;
|
|
1339
|
-
p.forEach((S) => {
|
|
1340
|
-
g += u(r.slice(y, S.start)), g += S.html, y = S.end;
|
|
1341
|
-
}), g += u(r.slice(y));
|
|
1342
|
-
} else
|
|
1343
|
-
g = u(r);
|
|
1344
|
-
if (e.current.innerHTML = g || "<br>", !g || g === "<br>") {
|
|
1345
|
-
const C = window.getSelection();
|
|
1346
|
-
if (C && e.current) {
|
|
1347
|
-
e.current.innerHTML = "", e.current.innerHTML = "<br>";
|
|
1348
|
-
const y = document.createRange();
|
|
1349
|
-
y.setStart(e.current, 0), y.collapse(!0), C.removeAllRanges(), C.addRange(y);
|
|
1350
|
-
}
|
|
1351
|
-
}
|
|
1352
|
-
o && requestAnimationFrame(() => {
|
|
1353
|
-
i(l);
|
|
1354
|
-
});
|
|
1355
|
-
}, [e, a, s, c, i, u]), n = I((r) => {
|
|
1356
|
-
const o = [];
|
|
1357
|
-
if (a.length > 0) {
|
|
1358
|
-
const l = [...a].sort((p, C) => C.label.length - p.label.length), g = [];
|
|
1359
|
-
l.forEach((p) => {
|
|
1360
|
-
const C = p.label.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), y = new RegExp(`@${C}(?=\\s|$)`, "g");
|
|
1361
|
-
let S;
|
|
1362
|
-
for (; (S = y.exec(r)) !== null; )
|
|
1363
|
-
g.some((M) => Math.abs(M - S.index) < p.label.length) || (o.push(`${S.index}:${S[0]}`), g.push(S.index));
|
|
1364
|
-
});
|
|
1365
|
-
}
|
|
1366
|
-
return o.sort().join(",");
|
|
1367
|
-
}, [a]), h = I((r) => {
|
|
1368
|
-
const o = n(r), l = o !== d.current;
|
|
1369
|
-
return l && (d.current = o), l;
|
|
1370
|
-
}, [n]), m = I((r) => {
|
|
1371
|
-
d.current = n(r);
|
|
1372
|
-
}, [n]);
|
|
1373
|
-
return {
|
|
1374
|
-
updateContent: t,
|
|
1375
|
-
haveMentionsChanged: h,
|
|
1376
|
-
updateMentionSignature: m
|
|
1377
|
-
};
|
|
1378
|
-
}
|
|
1379
|
-
function mt({ setQuery: e, setIsOpen: a, setAtPosition: s }) {
|
|
1380
|
-
const c = I((d, u) => {
|
|
1381
|
-
const t = d.slice(0, u), n = t.lastIndexOf("@");
|
|
1382
|
-
if (n === -1) {
|
|
1383
|
-
a(!1), e("");
|
|
1384
|
-
return;
|
|
1385
|
-
}
|
|
1386
|
-
const h = t.slice(n + 1);
|
|
1387
|
-
if (/\s/.test(h)) {
|
|
1388
|
-
a(!1), e("");
|
|
1389
|
-
return;
|
|
1390
|
-
}
|
|
1391
|
-
e(h), s(n), a(!0);
|
|
1392
|
-
}, []), i = I(() => {
|
|
1393
|
-
a(!1), e("");
|
|
1394
|
-
}, []);
|
|
1395
|
-
return {
|
|
1396
|
-
updateMention: c,
|
|
1397
|
-
closePopup: i
|
|
1398
|
-
};
|
|
1399
|
-
}
|
|
1400
|
-
const gt = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20stroke='currentColor'%20stroke-width='2'%20stroke-linecap='round'%20stroke-linejoin='round'%20class='icon%20icon-tabler%20icons-tabler-outline%20icon-tabler-arrow-right'%3e%3cpath%20stroke='none'%20d='M0%200h24v24H0z'%20fill='none'/%3e%3cpath%20d='M5%2012l14%200'%20/%3e%3cpath%20d='M13%2018l6%20-6'%20/%3e%3cpath%20d='M13%206l6%206'%20/%3e%3c/svg%3e", ht = ({ name: e }) => /* @__PURE__ */ A(
|
|
1401
|
-
"div",
|
|
1402
|
-
{
|
|
1403
|
-
style: {
|
|
1404
|
-
display: "flex",
|
|
1405
|
-
alignItems: "center",
|
|
1406
|
-
justifyContent: "space-between",
|
|
1407
|
-
fontSize: "14px"
|
|
1408
|
-
},
|
|
1409
|
-
children: [
|
|
1410
|
-
/* @__PURE__ */ f("div", { style: { color: "black", opacity: 0.7 }, children: e }),
|
|
1411
|
-
/* @__PURE__ */ f(
|
|
1412
|
-
"img",
|
|
1413
|
-
{
|
|
1414
|
-
src: gt,
|
|
1415
|
-
alt: "arrow",
|
|
1416
|
-
style: {
|
|
1417
|
-
width: "16px",
|
|
1418
|
-
height: "16px",
|
|
1419
|
-
color: "black",
|
|
1420
|
-
opacity: 0.7
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
)
|
|
1424
|
-
]
|
|
1425
|
-
}
|
|
1426
|
-
), ft = ({ name: e }) => /* @__PURE__ */ f("div", { children: e }), yt = "_popup_1en4y_2", pt = "_option_1en4y_16", bt = "_optionActive_1en4y_27", Ct = "_emptyState_1en4y_35", St = "_typeToSearch_1en4y_42", wt = "_breadcrumb_1en4y_49", xt = "_breadcrumbLink_1en4y_57", vt = "_breadcrumbSeparator_1en4y_67", It = "_breadcrumbCurrent_1en4y_72", k = {
|
|
1427
|
-
popup: yt,
|
|
1428
|
-
option: pt,
|
|
1429
|
-
optionActive: bt,
|
|
1430
|
-
emptyState: Ct,
|
|
1431
|
-
typeToSearch: St,
|
|
1432
|
-
breadcrumb: wt,
|
|
1433
|
-
breadcrumbLink: xt,
|
|
1434
|
-
breadcrumbSeparator: vt,
|
|
1435
|
-
breadcrumbCurrent: It
|
|
1436
|
-
}, Tt = ({
|
|
1437
|
-
isOpen: e,
|
|
1438
|
-
options: a,
|
|
1439
|
-
highlightedIndex: s,
|
|
1440
|
-
onSelect: c,
|
|
1441
|
-
caretElement: i,
|
|
1442
|
-
query: d,
|
|
1443
|
-
isInCategory: u,
|
|
1444
|
-
categoryName: t,
|
|
1445
|
-
onResetQuery: n
|
|
1446
|
-
}) => {
|
|
1447
|
-
const h = _(null), m = _([]);
|
|
1448
|
-
if (pe(() => {
|
|
1449
|
-
if (!i || !h.current) return;
|
|
1450
|
-
i.getBoundingClientRect();
|
|
1451
|
-
const l = i.getBoundingClientRect(), g = h.current;
|
|
1452
|
-
g.style.position = "fixed", g.style.top = `${l.top}px`, g.style.left = `${l.left}px`, g.style.width = "1px", g.style.height = `${l.height}px`;
|
|
1453
|
-
}, [i, e, a.length]), N(() => {
|
|
1454
|
-
if (s >= 0 && s < m.current.length) {
|
|
1455
|
-
const l = m.current[s];
|
|
1456
|
-
l && l.scrollIntoView({
|
|
1457
|
-
block: "nearest",
|
|
1458
|
-
behavior: "instant"
|
|
1459
|
-
});
|
|
1460
|
-
}
|
|
1461
|
-
}, [s]), !e || !i) return null;
|
|
1462
|
-
const r = a.filter((l) => l.type === "option"), o = a.filter((l) => l.type === "category");
|
|
1463
|
-
return /* @__PURE__ */ A(Z.Root, { open: e, children: [
|
|
1464
|
-
/* @__PURE__ */ f(Z.Anchor, { asChild: !0, children: /* @__PURE__ */ f(
|
|
1465
|
-
"div",
|
|
1466
|
-
{
|
|
1467
|
-
ref: h,
|
|
1468
|
-
style: {
|
|
1469
|
-
position: "fixed",
|
|
1470
|
-
pointerEvents: "none",
|
|
1471
|
-
width: 0,
|
|
1472
|
-
height: 0
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
) }),
|
|
1476
|
-
/* @__PURE__ */ f(Z.Portal, { children: /* @__PURE__ */ A(
|
|
1477
|
-
Z.Content,
|
|
1478
|
-
{
|
|
1479
|
-
className: k.popup,
|
|
1480
|
-
sideOffset: 2,
|
|
1481
|
-
side: "bottom",
|
|
1482
|
-
align: "start",
|
|
1483
|
-
collisionPadding: 16,
|
|
1484
|
-
avoidCollisions: !0,
|
|
1485
|
-
hideWhenDetached: !1,
|
|
1486
|
-
onOpenAutoFocus: (l) => {
|
|
1487
|
-
l.preventDefault();
|
|
1488
|
-
},
|
|
1489
|
-
onInteractOutside: (l) => {
|
|
1490
|
-
l.preventDefault();
|
|
1491
|
-
},
|
|
1492
|
-
children: [
|
|
1493
|
-
!u && d !== "" && /* @__PURE__ */ A("div", { className: k.breadcrumb, children: [
|
|
1494
|
-
/* @__PURE__ */ f(
|
|
1495
|
-
"span",
|
|
1496
|
-
{
|
|
1497
|
-
className: k.breadcrumbLink,
|
|
1498
|
-
onMouseDown: (l) => {
|
|
1499
|
-
l.preventDefault(), n();
|
|
1500
|
-
},
|
|
1501
|
-
children: "All items"
|
|
1502
|
-
}
|
|
1503
|
-
),
|
|
1504
|
-
/* @__PURE__ */ f("span", { className: k.breadcrumbSeparator, children: " / " }),
|
|
1505
|
-
/* @__PURE__ */ f("span", { className: k.breadcrumbCurrent, children: "search" })
|
|
1506
|
-
] }),
|
|
1507
|
-
u && t && /* @__PURE__ */ A("div", { className: k.breadcrumb, children: [
|
|
1508
|
-
/* @__PURE__ */ f(
|
|
1509
|
-
"span",
|
|
1510
|
-
{
|
|
1511
|
-
className: k.breadcrumbLink,
|
|
1512
|
-
onMouseDown: (l) => {
|
|
1513
|
-
l.preventDefault(), n();
|
|
1514
|
-
},
|
|
1515
|
-
children: "All items"
|
|
1516
|
-
}
|
|
1517
|
-
),
|
|
1518
|
-
/* @__PURE__ */ f("span", { className: k.breadcrumbSeparator, children: " / " }),
|
|
1519
|
-
/* @__PURE__ */ f("span", { className: k.breadcrumbCurrent, children: t })
|
|
1520
|
-
] }),
|
|
1521
|
-
d === "" && r.length === 0 && o.length > 0 && /* @__PURE__ */ f("div", { className: k.typeToSearch, children: "Type to search" }),
|
|
1522
|
-
r.length > 0 && /* @__PURE__ */ f("div", { className: k.section, children: r.map((l) => {
|
|
1523
|
-
const g = a.indexOf(l);
|
|
1524
|
-
return /* @__PURE__ */ f(
|
|
1525
|
-
"div",
|
|
1526
|
-
{
|
|
1527
|
-
ref: (p) => {
|
|
1528
|
-
m.current[g] = p;
|
|
1529
|
-
},
|
|
1530
|
-
className: `${k.option} ${g === s ? k.optionActive : ""}`,
|
|
1531
|
-
onMouseDown: (p) => {
|
|
1532
|
-
p.preventDefault(), c(g);
|
|
1533
|
-
},
|
|
1534
|
-
onMouseEnter: () => {
|
|
1535
|
-
},
|
|
1536
|
-
children: /* @__PURE__ */ f(ft, { name: l.label })
|
|
1537
|
-
},
|
|
1538
|
-
l.id
|
|
1539
|
-
);
|
|
1540
|
-
}) }),
|
|
1541
|
-
o.length > 0 && /* @__PURE__ */ f("div", { className: k.section, children: o.map((l) => {
|
|
1542
|
-
const g = a.indexOf(l);
|
|
1543
|
-
return /* @__PURE__ */ f(
|
|
1544
|
-
"div",
|
|
1545
|
-
{
|
|
1546
|
-
ref: (p) => {
|
|
1547
|
-
m.current[g] = p;
|
|
1548
|
-
},
|
|
1549
|
-
className: `${k.option} ${g === s ? k.optionActive : ""}`,
|
|
1550
|
-
onMouseDown: (p) => {
|
|
1551
|
-
p.preventDefault(), c(g);
|
|
1552
|
-
},
|
|
1553
|
-
onMouseEnter: () => {
|
|
1554
|
-
},
|
|
1555
|
-
children: /* @__PURE__ */ f(ht, { name: l.label })
|
|
1556
|
-
},
|
|
1557
|
-
l.id
|
|
1558
|
-
);
|
|
1559
|
-
}) }),
|
|
1560
|
-
o.length === 0 && r.length === 0 && /* @__PURE__ */ f("div", { className: k.emptyState, children: u ? "No memories found" : "No memory types have been added" })
|
|
1561
|
-
]
|
|
1562
|
-
}
|
|
1563
|
-
) })
|
|
1564
|
-
] });
|
|
1565
|
-
}, kt = ({
|
|
1566
|
-
onChange: e,
|
|
1567
|
-
onMemoryTypeChange: a,
|
|
1568
|
-
onTitleQueryChange: s,
|
|
1569
|
-
onMentionChange: c,
|
|
1570
|
-
onChangeMentionPlaceholders: i,
|
|
1571
|
-
onSubmit: d,
|
|
1572
|
-
memoryTypes: u,
|
|
1573
|
-
memories: t
|
|
1574
|
-
}) => {
|
|
1575
|
-
var ge;
|
|
1576
|
-
const [n, h] = x(""), [m, r] = x(""), [o, l] = x(""), [g, p] = x(!1), [C, y] = x(0), [S, M] = x(0), [W, E] = x(null), [v, U] = x(0), [P, Q] = x(null), D = _(null), X = _(null), te = _(!1), [ce, At] = x([]), ne = _(/* @__PURE__ */ new Map()), re = G(() => {
|
|
1577
|
-
const b = /* @__PURE__ */ new Map();
|
|
1578
|
-
return ne.current.forEach((w, O) => {
|
|
1579
|
-
b.set(O, w);
|
|
1580
|
-
}), t.forEach((w) => {
|
|
1581
|
-
b.set(w.id, w);
|
|
1582
|
-
}), Array.from(b.values()).map((w) => ({
|
|
1583
|
-
id: w.id,
|
|
1584
|
-
label: w.title ?? ""
|
|
1585
|
-
}));
|
|
1586
|
-
}, [t]);
|
|
1587
|
-
N(() => {
|
|
1588
|
-
const b = setTimeout(() => {
|
|
1589
|
-
l(m);
|
|
1590
|
-
}, 300);
|
|
1591
|
-
return () => {
|
|
1592
|
-
clearTimeout(b);
|
|
1593
|
-
};
|
|
1594
|
-
}, [m]);
|
|
1595
|
-
const z = G(() => {
|
|
1596
|
-
const b = P !== null || m !== "", w = P === null && m === "";
|
|
1597
|
-
return [
|
|
1598
|
-
...b ? t.map((T) => ({
|
|
1599
|
-
type: "option",
|
|
1600
|
-
id: T.id,
|
|
1601
|
-
label: T.title ?? ""
|
|
1602
|
-
})) : ce.map((T) => ({
|
|
1603
|
-
type: "option",
|
|
1604
|
-
id: T.id,
|
|
1605
|
-
label: T.label
|
|
1606
|
-
})),
|
|
1607
|
-
...w ? u.map((T) => ({
|
|
1608
|
-
type: "category",
|
|
1609
|
-
id: T.id,
|
|
1610
|
-
label: T.name
|
|
1611
|
-
})) : []
|
|
1612
|
-
];
|
|
1613
|
-
}, [ce, u, P, t, m]), { processText: q, extractMentionIds: ve, buildPlaceholderText: Ie } = ut({
|
|
1614
|
-
options: re,
|
|
1615
|
-
onMentionChange: c,
|
|
1616
|
-
onChangeMentionPlaceholders: i
|
|
1617
|
-
}), { updateMention: ie, closePopup: le } = mt({
|
|
1618
|
-
setQuery: r,
|
|
1619
|
-
setIsOpen: p,
|
|
1620
|
-
setAtPosition: M
|
|
1621
|
-
});
|
|
1622
|
-
N(() => {
|
|
1623
|
-
a(P), P && s("");
|
|
1624
|
-
}, [P, a, s]), N(() => {
|
|
1625
|
-
(o !== "" || P !== null) && s(o);
|
|
1626
|
-
}, [o, P, s]);
|
|
1627
|
-
const { getCaretPosition: oe, setCaretPosition: ae, getPlainText: J } = it(D), { updateContent: R, haveMentionsChanged: ue, updateMentionSignature: K } = dt({
|
|
1628
|
-
editableRef: D,
|
|
1629
|
-
options: re,
|
|
1630
|
-
mentionClassName: V.mention,
|
|
1631
|
-
getCaretPosition: oe,
|
|
1632
|
-
setCaretPosition: ae
|
|
1633
|
-
});
|
|
1634
|
-
function de(b) {
|
|
1635
|
-
const w = z[b];
|
|
1636
|
-
if (!w) return;
|
|
1637
|
-
if (w.type === "category") {
|
|
1638
|
-
Q(w.id), r("");
|
|
1639
|
-
return;
|
|
1640
|
-
}
|
|
1641
|
-
Q(null);
|
|
1642
|
-
const O = t.find((Y) => Y.id === w.id);
|
|
1643
|
-
O && ne.current.set(O.id, O);
|
|
1644
|
-
const T = n, F = T.slice(0, C), B = T.slice(C), L = F.lastIndexOf("@");
|
|
1645
|
-
if (L === -1) return;
|
|
1646
|
-
const j = F.slice(0, L) + "@" + w.label + " " + B, he = F.slice(0, L).length + w.label.length + 2;
|
|
1647
|
-
h(j), e(j), q(j), le(), K(j), requestAnimationFrame(() => {
|
|
1648
|
-
R(j, !1), requestAnimationFrame(() => {
|
|
1649
|
-
var Y;
|
|
1650
|
-
(Y = D.current) == null || Y.focus(), ae(he), y(he);
|
|
1651
|
-
});
|
|
1652
|
-
});
|
|
1653
|
-
}
|
|
1654
|
-
const { handleKeyDown: Te } = lt({
|
|
1655
|
-
onArrowDown: () => {
|
|
1656
|
-
U(
|
|
1657
|
-
(b) => (b + 1) % z.length
|
|
1658
|
-
);
|
|
1659
|
-
},
|
|
1660
|
-
onArrowUp: () => {
|
|
1661
|
-
U(
|
|
1662
|
-
(b) => (b - 1 + z.length) % z.length
|
|
1663
|
-
);
|
|
1664
|
-
},
|
|
1665
|
-
onEnter: () => {
|
|
1666
|
-
de(v);
|
|
1667
|
-
},
|
|
1668
|
-
onEscape: () => {
|
|
1669
|
-
P ? Q(null) : le();
|
|
1670
|
-
}
|
|
1671
|
-
}), me = I(() => {
|
|
1672
|
-
if (te.current) return;
|
|
1673
|
-
const b = J(), w = oe();
|
|
1674
|
-
h(b), e(b), q(b), y(w), ie(b, w), (ue(b) || b.trim() === "") && R(b, !0);
|
|
1675
|
-
}, [
|
|
1676
|
-
J,
|
|
1677
|
-
oe,
|
|
1678
|
-
ie,
|
|
1679
|
-
e,
|
|
1680
|
-
q,
|
|
1681
|
-
ue,
|
|
1682
|
-
R,
|
|
1683
|
-
y
|
|
1684
|
-
]);
|
|
1685
|
-
return N(() => {
|
|
1686
|
-
D.current && !D.current.textContent && (K(n), R(n, !1));
|
|
1687
|
-
}, [n, R, K]), N(() => {
|
|
1688
|
-
if (!D.current) return;
|
|
1689
|
-
J() !== n && !te.current && (K(n), R(n, !0));
|
|
1690
|
-
}, [n, J, R, K]), pe(() => {
|
|
1691
|
-
if (!g || !X.current) {
|
|
1692
|
-
E(null);
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
const w = X.current.querySelector("span[data-at-marker]");
|
|
1696
|
-
w instanceof HTMLElement ? E(w) : E(null);
|
|
1697
|
-
}, [C, m, g, n, X, E]), /* @__PURE__ */ A("div", { className: V.wrapper, children: [
|
|
1698
|
-
/* @__PURE__ */ f(
|
|
1699
|
-
st,
|
|
1700
|
-
{
|
|
1701
|
-
editableRef: D,
|
|
1702
|
-
onInput: me,
|
|
1703
|
-
onKeyDown: (b) => {
|
|
1704
|
-
if (!(g && Te(b)) && b.key === "Enter" && !b.shiftKey && !g) {
|
|
1705
|
-
if (b.preventDefault(), d && n.trim()) {
|
|
1706
|
-
const w = Ie(n), T = ve(n).map((F) => re.find((B) => B.id === F)).filter((F) => F !== void 0);
|
|
1707
|
-
d(n, w, T), h(""), e(""), q(""), R("", !1), ne.current.clear();
|
|
1708
|
-
}
|
|
1709
|
-
return;
|
|
1710
|
-
}
|
|
1711
|
-
},
|
|
1712
|
-
isComposingRef: te,
|
|
1713
|
-
handleInput: me
|
|
1714
|
-
}
|
|
1715
|
-
),
|
|
1716
|
-
/* @__PURE__ */ f(
|
|
1717
|
-
ct,
|
|
1718
|
-
{
|
|
1719
|
-
ghostRef: X,
|
|
1720
|
-
isOpen: g,
|
|
1721
|
-
value: n,
|
|
1722
|
-
atPosition: S,
|
|
1723
|
-
caretPos: C
|
|
1724
|
-
}
|
|
1725
|
-
),
|
|
1726
|
-
/* @__PURE__ */ f(
|
|
1727
|
-
Tt,
|
|
1728
|
-
{
|
|
1729
|
-
isOpen: g,
|
|
1730
|
-
options: z,
|
|
1731
|
-
highlightedIndex: v,
|
|
1732
|
-
onSelect: de,
|
|
1733
|
-
caretElement: W,
|
|
1734
|
-
query: m,
|
|
1735
|
-
isInCategory: P !== null,
|
|
1736
|
-
categoryName: P && ((ge = u.find((b) => b.id === P)) == null ? void 0 : ge.name) || null,
|
|
1737
|
-
onResetQuery: () => {
|
|
1738
|
-
r(""), l(""), P && Q(null);
|
|
1739
|
-
const b = n, w = b.slice(0, C), O = b.slice(C), T = w.lastIndexOf("@");
|
|
1740
|
-
if (T !== -1) {
|
|
1741
|
-
const F = b.slice(0, T + 1) + O, B = T + 1;
|
|
1742
|
-
h(F), e(F), q(F), requestAnimationFrame(() => {
|
|
1743
|
-
R(F, !1), requestAnimationFrame(() => {
|
|
1744
|
-
var L;
|
|
1745
|
-
(L = D.current) == null || L.focus(), ae(B), y(B);
|
|
1746
|
-
});
|
|
1747
|
-
});
|
|
1748
|
-
}
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
)
|
|
1752
|
-
] });
|
|
1753
|
-
}, Ot = ({
|
|
1754
|
-
height: e = "100vh",
|
|
1755
|
-
fetchListMemoryTypesClientSecret: a,
|
|
1756
|
-
fetchSearchMemoriesClientSecret: s,
|
|
1757
|
-
fetchCreateAgentTaskClientSecret: c,
|
|
1758
|
-
fetchCreateStreamClientSecret: i,
|
|
1759
|
-
fetchGetDownloadLinkClientSecret: d
|
|
1760
|
-
}) => {
|
|
1761
|
-
const { createAgentTask: u, agentTasks: t } = je({
|
|
1762
|
-
fetchCreateStreamClientSecret: i,
|
|
1763
|
-
fetchCreateAgentTaskClientSecret: c
|
|
1764
|
-
}), [n, h] = x(""), [m, r] = x(null), [o, l] = x(null), { listFirstPage: g } = Qe(), { search: p } = Ge(), [C, y] = x(
|
|
1765
|
-
null
|
|
1766
|
-
), [S, M] = x(null), W = _(!1);
|
|
1767
|
-
N(() => {
|
|
1768
|
-
W.current || (W.current = !0, g({
|
|
1769
|
-
fetchClientSecret: a
|
|
1770
|
-
}).then((v) => {
|
|
1771
|
-
v.type === "success" && y(v.page.items);
|
|
1772
|
-
}));
|
|
1773
|
-
}, [g, a]), N(() => {
|
|
1774
|
-
m === null && n === "" || p({
|
|
1775
|
-
fetchClientSecret: s,
|
|
1776
|
-
memoryTypeId: m ?? void 0,
|
|
1777
|
-
title: n
|
|
1778
|
-
}).then((v) => {
|
|
1779
|
-
v.type === "success" && M(v.items);
|
|
1780
|
-
});
|
|
1781
|
-
}, [m, o, n]);
|
|
1782
|
-
const E = G(() => t.flatMap((v) => /* @__PURE__ */ f(et, { agentTask: v, fetchGetDownloadLinkClientSecret: d }, v.streamId)), [t]);
|
|
1783
|
-
return /* @__PURE__ */ A(
|
|
1784
|
-
"div",
|
|
1785
|
-
{
|
|
1786
|
-
style: {
|
|
1787
|
-
display: "flex",
|
|
1788
|
-
flexDirection: "column",
|
|
1789
|
-
height: e,
|
|
1790
|
-
maxWidth: "100vw",
|
|
1791
|
-
overflow: "hidden"
|
|
1792
|
-
},
|
|
1793
|
-
children: [
|
|
1794
|
-
E,
|
|
1795
|
-
/* @__PURE__ */ f(
|
|
1796
|
-
kt,
|
|
1797
|
-
{
|
|
1798
|
-
memoryTypes: C ?? [],
|
|
1799
|
-
memories: S ?? [],
|
|
1800
|
-
onMemoryTypeChange: (v) => {
|
|
1801
|
-
r(v);
|
|
1802
|
-
},
|
|
1803
|
-
onTitleQueryChange: (v) => {
|
|
1804
|
-
h(v);
|
|
1805
|
-
},
|
|
1806
|
-
onChange: (v) => {
|
|
1807
|
-
},
|
|
1808
|
-
onMentionChange: (v) => {
|
|
1809
|
-
l(v);
|
|
1810
|
-
},
|
|
1811
|
-
onChangeMentionPlaceholders: (v, U) => {
|
|
1812
|
-
},
|
|
1813
|
-
onSubmit: (v, U, P) => {
|
|
1814
|
-
u({
|
|
1815
|
-
queryText: `
|
|
1816
|
-
${U}
|
|
1817
|
-
|
|
1818
|
-
${JSON.stringify(P, null, 2)}
|
|
1819
|
-
`.trim()
|
|
1820
|
-
});
|
|
1821
|
-
}
|
|
1822
|
-
}
|
|
1823
|
-
)
|
|
1824
|
-
]
|
|
1825
|
-
}
|
|
1826
|
-
);
|
|
1827
1220
|
};
|
|
1828
|
-
function
|
|
1829
|
-
const [
|
|
1221
|
+
function Re({ fency: e, children: t }) {
|
|
1222
|
+
const [o, i] = k(
|
|
1830
1223
|
null
|
|
1831
|
-
), [
|
|
1832
|
-
|
|
1833
|
-
e.then((
|
|
1834
|
-
|
|
1835
|
-
}).catch((
|
|
1836
|
-
|
|
1224
|
+
), [s, m] = k(!0), [u, a] = k(null), [n, d] = k(null), l = R(null);
|
|
1225
|
+
P(() => {
|
|
1226
|
+
e.then((f) => {
|
|
1227
|
+
i(f), m(!1);
|
|
1228
|
+
}).catch((f) => {
|
|
1229
|
+
a(f), m(!1);
|
|
1837
1230
|
});
|
|
1838
1231
|
}, [e]);
|
|
1839
|
-
const
|
|
1840
|
-
async (
|
|
1841
|
-
if (
|
|
1842
|
-
return
|
|
1843
|
-
const
|
|
1844
|
-
if (n &&
|
|
1232
|
+
const c = D(
|
|
1233
|
+
async (f, h = 3e4) => {
|
|
1234
|
+
if (l.current)
|
|
1235
|
+
return l.current;
|
|
1236
|
+
const C = Date.now();
|
|
1237
|
+
if (n && C - n.createdAt < h)
|
|
1845
1238
|
return n.stream;
|
|
1846
|
-
const
|
|
1847
|
-
if (!
|
|
1239
|
+
const b = (async () => {
|
|
1240
|
+
if (!o)
|
|
1848
1241
|
throw new Error("Fency instance not initialized");
|
|
1849
|
-
const y = await
|
|
1850
|
-
pk:
|
|
1851
|
-
baseUrl:
|
|
1852
|
-
|
|
1242
|
+
const y = await f(), w = await G({
|
|
1243
|
+
pk: o.publishableKey,
|
|
1244
|
+
baseUrl: o.baseUrl,
|
|
1245
|
+
clientToken: (y == null ? void 0 : y.clientToken) ?? ""
|
|
1853
1246
|
});
|
|
1854
|
-
if (
|
|
1855
|
-
const
|
|
1856
|
-
stream:
|
|
1247
|
+
if (w.type === "success") {
|
|
1248
|
+
const T = {
|
|
1249
|
+
stream: w.stream,
|
|
1857
1250
|
createdAt: Date.now()
|
|
1858
1251
|
};
|
|
1859
|
-
return
|
|
1252
|
+
return d(T), l.current = null, w.stream;
|
|
1860
1253
|
} else
|
|
1861
|
-
throw
|
|
1254
|
+
throw l.current = null, new Error("Failed to create stream");
|
|
1862
1255
|
})();
|
|
1863
|
-
return
|
|
1256
|
+
return l.current = b, b;
|
|
1864
1257
|
},
|
|
1865
|
-
[
|
|
1258
|
+
[o, n]
|
|
1866
1259
|
);
|
|
1867
1260
|
if (u)
|
|
1868
|
-
return /* @__PURE__ */
|
|
1261
|
+
return /* @__PURE__ */ S("div", { children: [
|
|
1869
1262
|
"Fency error: ",
|
|
1870
1263
|
u.message
|
|
1871
1264
|
] });
|
|
1872
|
-
if (!
|
|
1265
|
+
if (!o)
|
|
1873
1266
|
return null;
|
|
1874
|
-
const
|
|
1875
|
-
fency:
|
|
1876
|
-
loading:
|
|
1267
|
+
const r = {
|
|
1268
|
+
fency: o,
|
|
1269
|
+
loading: s,
|
|
1877
1270
|
error: u,
|
|
1878
1271
|
activeStream: n,
|
|
1879
|
-
getOrCreateStream:
|
|
1272
|
+
getOrCreateStream: c
|
|
1880
1273
|
};
|
|
1881
|
-
return /* @__PURE__ */
|
|
1274
|
+
return /* @__PURE__ */ g(L.Provider, { value: r, children: t });
|
|
1882
1275
|
}
|
|
1883
1276
|
export {
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
Qe as useListMemoryTypes,
|
|
1897
|
-
Ve as usePaginatedQuery,
|
|
1898
|
-
Ge as useSearchMemories,
|
|
1899
|
-
Ke as useStream
|
|
1277
|
+
Fe as AgentTaskProgress,
|
|
1278
|
+
ke as ChatResponse,
|
|
1279
|
+
Ce as ChatResponseComplete,
|
|
1280
|
+
be as ChatResponseLoading,
|
|
1281
|
+
we as ChatResponseThinking,
|
|
1282
|
+
Re as FencyProvider,
|
|
1283
|
+
M as ShimmeringText,
|
|
1284
|
+
Ee as useAgentTasks,
|
|
1285
|
+
U as useFencyContext,
|
|
1286
|
+
ae as useFencyEventSource,
|
|
1287
|
+
Ne as usePaginatedQuery,
|
|
1288
|
+
he as useStream
|
|
1900
1289
|
};
|