@epam/ai-dial-chat-hooks 1.1.0-dev.254 → 1.1.0-dev.255
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/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import { AttachmentContentType as e, useAttachmentCanvas as t } from "@epam/ai-dial-attachment-canvas";
|
|
2
|
-
import { AttachmentErrorReason as n, MIMEType as r, MessageRole as i,
|
|
3
|
-
import { isReferenceOnlyAttachment as
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { isMimeTypeAllowed as
|
|
6
|
-
import { strFromU8 as
|
|
7
|
-
import { SendCompletionDtoModeEnum as
|
|
8
|
-
import { ShareLinkAccess as
|
|
2
|
+
import { AttachmentErrorReason as n, MIMEType as r, MessageRole as i, ResponseFormat as a, base64ToBlob as o, messageAttachmentToDisplayAttachment as s, triggerAnchorDownload as c, triggerBlobDownload as l } from "@epam/ai-dial-chat-shared";
|
|
3
|
+
import { isReferenceOnlyAttachment as u, normalizeRawAnnotations as d, parsePdfPageReference as f, resolveMessageAnnotations as p } from "@epam/ai-dial-quotations";
|
|
4
|
+
import { useCallback as m, useEffect as h, useLayoutEffect as g, useMemo as _, useRef as v, useState as y } from "react";
|
|
5
|
+
import { isMimeTypeAllowed as b, mimeTypesToExtensionLabels as x } from "@epam/ai-dial-attachment-input";
|
|
6
|
+
import { strFromU8 as S, strToU8 as C, unzipSync as w, zipSync as T } from "fflate";
|
|
7
|
+
import { SendCompletionDtoModeEnum as E, ShareLinkResponseDtoAccessEnum as D } from "@epam/ai-dial-chat-api-client";
|
|
8
|
+
import { ShareLinkAccess as O } from "@epam/ai-dial-share";
|
|
9
9
|
//#region src/attachment/useAttachmentAction/useAttachmentAction.ts
|
|
10
|
-
var
|
|
11
|
-
let { url: n, name: i, contentType:
|
|
12
|
-
if (n != null &&
|
|
10
|
+
var k = (e) => e.startsWith("files/"), A = (e) => e.url != null && k(e.url) || e.data != null, j = (e, t) => {
|
|
11
|
+
let { url: n, name: i, contentType: a, data: s } = e;
|
|
12
|
+
if (n != null && k(n)) {
|
|
13
13
|
let e = t(n);
|
|
14
|
-
return e == null ? !1 : (
|
|
14
|
+
return e == null ? !1 : (c(e, i), !0);
|
|
15
15
|
}
|
|
16
|
-
return
|
|
17
|
-
},
|
|
16
|
+
return s == null ? !1 : (l(o(s, a || r.Plain), i), !0);
|
|
17
|
+
}, M = (e, t) => {
|
|
18
18
|
let { url: n } = e;
|
|
19
19
|
if (n == null) return;
|
|
20
20
|
let r = n.split("#")[0];
|
|
21
|
-
if (
|
|
21
|
+
if (k(r)) {
|
|
22
22
|
let n = t(r);
|
|
23
23
|
if (n == null) return;
|
|
24
|
-
|
|
24
|
+
c(n, e.title ?? r.split("/").pop() ?? "");
|
|
25
25
|
} else window.open(n, "_blank", "noopener,noreferrer");
|
|
26
|
-
},
|
|
27
|
-
let r =
|
|
26
|
+
}, N = (t, n) => {
|
|
27
|
+
let r = f(t.url);
|
|
28
28
|
if (r == null) return null;
|
|
29
|
-
let i =
|
|
29
|
+
let i = k(r.baseUrl) ? n(r.baseUrl) : r.baseUrl;
|
|
30
30
|
if (i == null) return null;
|
|
31
31
|
if (r.page == null) return {
|
|
32
32
|
type: e.Pdf,
|
|
@@ -52,12 +52,12 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
52
52
|
}],
|
|
53
53
|
selectedHighlightId: a
|
|
54
54
|
};
|
|
55
|
-
},
|
|
55
|
+
}, P = ({ resolveDownloadUrl: e }) => {
|
|
56
56
|
let { openCanvas: n } = t();
|
|
57
|
-
return { handleAttachmentClick:
|
|
57
|
+
return { handleAttachmentClick: m((t) => {
|
|
58
58
|
let { url: r, referenceUrl: i, data: a, name: o } = t;
|
|
59
59
|
if (r != null || a != null) {
|
|
60
|
-
|
|
60
|
+
j(t, e);
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
63
|
if (i == null) return;
|
|
@@ -65,34 +65,34 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
65
65
|
type: t.contentType,
|
|
66
66
|
url: i,
|
|
67
67
|
title: o
|
|
68
|
-
}, c =
|
|
68
|
+
}, c = N(s, e);
|
|
69
69
|
if (c) {
|
|
70
70
|
n(c, o);
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
M(s, e);
|
|
74
74
|
}, [n, e]) };
|
|
75
|
-
},
|
|
76
|
-
if (e != null) return e.map((e) => e === "*" ?
|
|
77
|
-
},
|
|
78
|
-
let t =
|
|
79
|
-
if (!(t == null || t.length === 0) && !t.some((e) => e ===
|
|
80
|
-
},
|
|
75
|
+
}, F = 100, I = "*/*", ee = (e) => e.startsWith(".") || e.includes("/"), te = (e) => {
|
|
76
|
+
if (e != null) return e.map((e) => e === "*" ? I : e).filter(ee);
|
|
77
|
+
}, ne = (e) => {
|
|
78
|
+
let t = te(e);
|
|
79
|
+
if (!(t == null || t.length === 0) && !t.some((e) => e === I)) return t.join(",");
|
|
80
|
+
}, re = /* @__PURE__ */ function(e) {
|
|
81
81
|
return e.NoTypesAllowed = "noTypesAllowed", e.UnsupportedType = "unsupportedType", e;
|
|
82
|
-
}({}),
|
|
83
|
-
let i = e.length > 0, a =
|
|
84
|
-
return
|
|
82
|
+
}({}), ie = ({ allowedMimeTypes: e, onValidationError: t, debounceMs: r = F }) => {
|
|
83
|
+
let i = e.length > 0, a = _(() => ne(e), [e]), o = v(null);
|
|
84
|
+
return h(() => () => {
|
|
85
85
|
o.current != null && clearTimeout(o.current);
|
|
86
86
|
}, []), {
|
|
87
87
|
inputAttachmentTypes: e,
|
|
88
88
|
isAttachmentsAllowed: i,
|
|
89
|
-
validateAttachment:
|
|
90
|
-
if (!
|
|
89
|
+
validateAttachment: m((i) => {
|
|
90
|
+
if (!b(i.contentType, e)) return o.current != null && clearTimeout(o.current), o.current = setTimeout(() => {
|
|
91
91
|
let n = e.length === 0;
|
|
92
92
|
t?.({
|
|
93
93
|
reason: n ? "noTypesAllowed" : "unsupportedType",
|
|
94
94
|
allowedMimeTypes: e,
|
|
95
|
-
...n ? {} : { formats:
|
|
95
|
+
...n ? {} : { formats: x(e) }
|
|
96
96
|
}), o.current = null;
|
|
97
97
|
}, r), n.UnsupportedType;
|
|
98
98
|
}, [
|
|
@@ -102,7 +102,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
102
102
|
]),
|
|
103
103
|
fileAccept: a
|
|
104
104
|
};
|
|
105
|
-
},
|
|
105
|
+
}, ae = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}-${String(e.getDate()).padStart(2, "0")}`, L = (e) => `${e.getFullYear()}-${String(e.getMonth() + 1).padStart(2, "0")}`, oe = /* @__PURE__ */ function(e) {
|
|
106
106
|
return e.WithAttachments = "withAttachments", e.WithoutAttachments = "withoutAttachments", e;
|
|
107
107
|
}({}), R = /* @__PURE__ */ function(e) {
|
|
108
108
|
return e.SingleConversation = "chat_conversation", e.SingleConversationWithAttachments = "chat_with_attachments", e.AllConversationsHistory = "chat_conversations_history", e;
|
|
@@ -118,19 +118,19 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
118
118
|
version: 5,
|
|
119
119
|
history: e,
|
|
120
120
|
folders: t
|
|
121
|
-
}),
|
|
121
|
+
}), se = (e) => new Blob([JSON.stringify(e, null, 2)], { type: "application/json" }), ce = {
|
|
122
122
|
[R.SingleConversation]: "json",
|
|
123
123
|
[R.SingleConversationWithAttachments]: "dial",
|
|
124
124
|
[R.AllConversationsHistory]: "json"
|
|
125
|
-
}, G = (e, t, n = /* @__PURE__ */ new Date()) => `${
|
|
125
|
+
}, G = (e, t, n = /* @__PURE__ */ new Date()) => `${ae(n)}_${t}_${e}.${ce[e]}`, le = (e) => e.startsWith("files/"), ue = (e) => {
|
|
126
126
|
let t = /* @__PURE__ */ new Set();
|
|
127
127
|
for (let n of e.messages) for (let e of n.custom_content?.attachments ?? []) {
|
|
128
128
|
let n = e.url ?? e.reference_url;
|
|
129
|
-
n != null &&
|
|
129
|
+
n != null && le(n) && t.add(n);
|
|
130
130
|
}
|
|
131
131
|
return Array.from(t, (e) => ({ fileId: e }));
|
|
132
|
-
},
|
|
133
|
-
if (!
|
|
132
|
+
}, de = (e) => e.startsWith("files/"), fe = (e) => {
|
|
133
|
+
if (!de(e)) return;
|
|
134
134
|
let t = e.slice(6), n = t.indexOf("/");
|
|
135
135
|
if (n < 0) return;
|
|
136
136
|
let r = t.slice(0, n), i = t.slice(n + 1), a;
|
|
@@ -147,27 +147,27 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
147
147
|
constructor(e) {
|
|
148
148
|
super(e), this.name = "UnsupportedImportFormatError";
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, pe = (e) => typeof e == "object" && !!e, me = 5, he = (e) => {
|
|
151
151
|
let t;
|
|
152
152
|
try {
|
|
153
153
|
t = JSON.parse(e);
|
|
154
154
|
} catch {
|
|
155
155
|
throw new K("Import file is not valid JSON");
|
|
156
156
|
}
|
|
157
|
-
if (!
|
|
157
|
+
if (!pe(t) || t.version !== me || !Array.isArray(t.history)) throw new K("Import file is not a supported export format");
|
|
158
158
|
let n = Array.isArray(t.folders) ? t.folders : [];
|
|
159
159
|
return {
|
|
160
|
-
version:
|
|
160
|
+
version: me,
|
|
161
161
|
history: t.history,
|
|
162
162
|
folders: n
|
|
163
163
|
};
|
|
164
|
-
},
|
|
164
|
+
}, ge = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, _e = (e) => {
|
|
165
165
|
let t = e.lastIndexOf("__");
|
|
166
166
|
if (t < 0) return e;
|
|
167
167
|
let n = e.slice(t + 2);
|
|
168
|
-
return
|
|
169
|
-
},
|
|
170
|
-
let n = q(e.id), r = n.split("/"), i = q(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = `${
|
|
168
|
+
return ge.test(n) ? e.slice(0, t) : e;
|
|
169
|
+
}, ve = "conversations/", q = (e) => e.startsWith(ve) ? e.slice(14) : e, ye = (e, t) => {
|
|
170
|
+
let n = q(e.id), r = n.split("/"), i = q(e.folderId), a = r[0], o = i.startsWith(`${a}/`) ? i.slice(a.length + 1).split("/").filter(Boolean) : [], s = r.slice(1).slice(o.length), c = s.slice(0, -1), l = `${_e(s.at(-1) ?? r.at(-1) ?? n)}__${crypto.randomUUID()}`, u = [
|
|
171
171
|
...o,
|
|
172
172
|
...c,
|
|
173
173
|
l
|
|
@@ -180,10 +180,10 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
180
180
|
},
|
|
181
181
|
subPath: u
|
|
182
182
|
};
|
|
183
|
-
},
|
|
183
|
+
}, be = (e) => {
|
|
184
184
|
let t = q(e.folderId).split("/").filter(Boolean).slice(1);
|
|
185
185
|
return t.length ? t.join(" / ") : void 0;
|
|
186
|
-
},
|
|
186
|
+
}, xe = (e) => e.map((e) => `"${e}"`).join(", "), Se = (e, t) => ({
|
|
187
187
|
...e,
|
|
188
188
|
messages: e.messages.map((e) => {
|
|
189
189
|
let n = e.custom_content?.attachments;
|
|
@@ -205,12 +205,12 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
205
205
|
}
|
|
206
206
|
} : e;
|
|
207
207
|
})
|
|
208
|
-
}),
|
|
208
|
+
}), Ce = (e) => e.split("/").pop() || e, we = (e, t, n) => {
|
|
209
209
|
let r = [], i = [];
|
|
210
|
-
for (let a of
|
|
211
|
-
let e =
|
|
210
|
+
for (let a of ue(e)) {
|
|
211
|
+
let e = fe(a.fileId);
|
|
212
212
|
if (!e) {
|
|
213
|
-
i.push(
|
|
213
|
+
i.push(Ce(a.fileId));
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
216
216
|
let o = e.path.split("/").pop() ?? e.path, s = t.get(e.path);
|
|
@@ -229,14 +229,14 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
229
229
|
plan: r,
|
|
230
230
|
skippedNames: i
|
|
231
231
|
};
|
|
232
|
-
},
|
|
233
|
-
let a =
|
|
234
|
-
return { handleUploadAttachment:
|
|
232
|
+
}, Te = 700, Ee = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", De = (e, t = /* @__PURE__ */ new Date()) => `uploads/${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}/${encodeURIComponent(Ee(e))}`, Oe = ({ filesApi: e, bucket: t, onNetworkError: r, debounceMs: i = Te }) => {
|
|
233
|
+
let a = v([]), o = v(null);
|
|
234
|
+
return { handleUploadAttachment: m(async (s) => {
|
|
235
235
|
if (!t) throw Error("User bucket is not available");
|
|
236
236
|
try {
|
|
237
237
|
return (await e.uploadFile({
|
|
238
238
|
bucket: t,
|
|
239
|
-
path:
|
|
239
|
+
path: De(s.name),
|
|
240
240
|
file: s.file
|
|
241
241
|
})).url;
|
|
242
242
|
} catch (e) {
|
|
@@ -256,7 +256,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
256
256
|
e,
|
|
257
257
|
r
|
|
258
258
|
]) };
|
|
259
|
-
},
|
|
259
|
+
}, ke = async (e, t, n) => {
|
|
260
260
|
let r = [], i = 0, a = async () => {
|
|
261
261
|
let t = i;
|
|
262
262
|
if (i += 1, !(t >= e.length)) {
|
|
@@ -270,34 +270,34 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
return await Promise.all(Array.from({ length: Math.min(t, e.length) }, a)), r;
|
|
273
|
-
},
|
|
274
|
-
let [e, t] =
|
|
273
|
+
}, Ae = () => {
|
|
274
|
+
let [e, t] = y([]), n = v(/* @__PURE__ */ new Map()), r = v(/* @__PURE__ */ new Map()), i = m((e, n) => {
|
|
275
275
|
t((t) => t.map((t) => t.id === e ? {
|
|
276
276
|
...t,
|
|
277
277
|
...n
|
|
278
278
|
} : t));
|
|
279
|
-
}, []), a =
|
|
279
|
+
}, []), a = m((e) => {
|
|
280
280
|
let n = crypto.randomUUID();
|
|
281
281
|
return t((t) => [...t, {
|
|
282
282
|
id: n,
|
|
283
283
|
subject: e,
|
|
284
284
|
status: z.InProgress
|
|
285
285
|
}]), n;
|
|
286
|
-
}, []), o =
|
|
286
|
+
}, []), o = m((e) => {
|
|
287
287
|
n.current.get(e)?.abort(), n.current.delete(e), r.current.delete(e), t((t) => t.filter((t) => t.id !== e));
|
|
288
|
-
}, []), s =
|
|
288
|
+
}, []), s = m((e) => {
|
|
289
289
|
r.current.get(e)?.();
|
|
290
|
-
}, []), c =
|
|
290
|
+
}, []), c = m(() => {
|
|
291
291
|
for (let e of n.current.values()) e.abort();
|
|
292
292
|
n.current.clear(), r.current.clear(), t([]);
|
|
293
|
-
}, []), l =
|
|
293
|
+
}, []), l = m((e, t) => {
|
|
294
294
|
let a = () => {
|
|
295
295
|
let r = new AbortController();
|
|
296
296
|
return n.current.set(e, r), t(r.signal);
|
|
297
297
|
};
|
|
298
298
|
return r.current.set(e, () => (i(e, { status: z.InProgress }), a())), a();
|
|
299
299
|
}, [i]);
|
|
300
|
-
return
|
|
300
|
+
return h(() => {
|
|
301
301
|
let e = n.current;
|
|
302
302
|
return () => {
|
|
303
303
|
for (let t of e.values()) t.abort();
|
|
@@ -311,27 +311,27 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
311
311
|
dismissAll: c,
|
|
312
312
|
startJob: l
|
|
313
313
|
};
|
|
314
|
-
},
|
|
315
|
-
let n = [], r = { "conversation.json":
|
|
314
|
+
}, je = C("", !0).constructor, Me = (e) => e instanceof je ? e : new je(e), Ne = (e) => e.length > 0 && e.split("/").every((e) => e !== "" && e !== "." && e !== ".."), Pe = (e, t) => {
|
|
315
|
+
let n = [], r = { "conversation.json": Me(C(JSON.stringify(e, null, 2))) };
|
|
316
316
|
for (let e of t) {
|
|
317
|
-
if (!
|
|
317
|
+
if (!Ne(e.path)) {
|
|
318
318
|
n.push(e.path);
|
|
319
319
|
continue;
|
|
320
320
|
}
|
|
321
|
-
r[`res/${e.path}`] =
|
|
321
|
+
r[`res/${e.path}`] = Me(e.data);
|
|
322
322
|
}
|
|
323
|
-
let i =
|
|
323
|
+
let i = T(r);
|
|
324
324
|
return {
|
|
325
325
|
blob: new Blob([new Uint8Array(i)], { type: "application/zip" }),
|
|
326
326
|
skippedPaths: n
|
|
327
327
|
};
|
|
328
|
-
},
|
|
329
|
-
let
|
|
328
|
+
}, Fe = 5, Ie = (e) => !e.sharedWithMe && !e.publishedWithMe, Le = ({ conversationsApi: e, filesApi: t, normalizeConversationPath: n, classifyTransferError: r = () => ({}), resolveErrorTraceId: i = async () => void 0, onSuccess: a, onWarning: o, onError: s }) => {
|
|
329
|
+
let c = Ae(), u = m(async (e, n) => {
|
|
330
330
|
let i = !1, a = !1;
|
|
331
331
|
return {
|
|
332
|
-
entries: await
|
|
332
|
+
entries: await ke(e, Fe, async (e) => {
|
|
333
333
|
if (n.aborted || a) return;
|
|
334
|
-
let o =
|
|
334
|
+
let o = fe(e.fileId);
|
|
335
335
|
if (!o) {
|
|
336
336
|
i = !0;
|
|
337
337
|
return;
|
|
@@ -358,7 +358,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
358
358
|
anySkipped: !n.aborted && !a && i,
|
|
359
359
|
isUnauthorized: !n.aborted && a
|
|
360
360
|
};
|
|
361
|
-
}, [r, t]), d =
|
|
361
|
+
}, [r, t]), d = m(async (t, d, f, p, m) => {
|
|
362
362
|
let h;
|
|
363
363
|
try {
|
|
364
364
|
h = await e.getConversation({ path: n(d) }, { signal: m });
|
|
@@ -377,34 +377,34 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
377
377
|
traceId: n
|
|
378
378
|
});
|
|
379
379
|
}
|
|
380
|
-
|
|
380
|
+
c.updateJob(t, { status: z.Failed }), console.error("Failed to fetch conversation for export", e);
|
|
381
381
|
return;
|
|
382
382
|
}
|
|
383
383
|
if (!m.aborted) try {
|
|
384
|
-
if (p ===
|
|
385
|
-
|
|
384
|
+
if (p === oe.WithoutAttachments) {
|
|
385
|
+
l(se(W([h], [])), G(R.SingleConversation, U)), a?.({
|
|
386
386
|
jobId: t,
|
|
387
387
|
titles: [f]
|
|
388
|
-
}),
|
|
388
|
+
}), c.updateJob(t, { status: z.Success });
|
|
389
389
|
return;
|
|
390
390
|
}
|
|
391
|
-
let { entries: e, anySkipped: n, isUnauthorized: r } = await u(
|
|
391
|
+
let { entries: e, anySkipped: n, isUnauthorized: r } = await u(ue(h), m);
|
|
392
392
|
if (m.aborted) return;
|
|
393
393
|
if (r) {
|
|
394
394
|
s?.({
|
|
395
395
|
jobId: t,
|
|
396
396
|
code: V.Unauthorized
|
|
397
|
-
}),
|
|
397
|
+
}), c.updateJob(t, { status: z.Failed });
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
|
-
let { blob: i, skippedPaths: d } =
|
|
400
|
+
let { blob: i, skippedPaths: d } = Pe(W([h], []), e);
|
|
401
401
|
(n || d.length > 0) && o?.({
|
|
402
402
|
jobId: t,
|
|
403
403
|
code: H.AttachmentSkipped
|
|
404
|
-
}),
|
|
404
|
+
}), l(i, G(R.SingleConversationWithAttachments, U)), a?.({
|
|
405
405
|
jobId: t,
|
|
406
406
|
titles: [f]
|
|
407
|
-
}),
|
|
407
|
+
}), c.updateJob(t, { status: z.Success });
|
|
408
408
|
} catch (e) {
|
|
409
409
|
if (m.aborted) return;
|
|
410
410
|
let n = await i(e);
|
|
@@ -413,7 +413,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
413
413
|
code: V.Unknown,
|
|
414
414
|
titles: [f],
|
|
415
415
|
traceId: n
|
|
416
|
-
}),
|
|
416
|
+
}), c.updateJob(t, { status: z.Failed }), console.error("Failed to build conversation export archive", e);
|
|
417
417
|
}
|
|
418
418
|
}, [
|
|
419
419
|
r,
|
|
@@ -423,15 +423,15 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
423
423
|
s,
|
|
424
424
|
a,
|
|
425
425
|
o,
|
|
426
|
-
|
|
426
|
+
c,
|
|
427
427
|
i
|
|
428
|
-
]), f =
|
|
429
|
-
let r =
|
|
428
|
+
]), f = m((e, t, n) => {
|
|
429
|
+
let r = c.addJob({
|
|
430
430
|
kind: B.Single,
|
|
431
431
|
title: t
|
|
432
432
|
});
|
|
433
|
-
return
|
|
434
|
-
}, [
|
|
433
|
+
return c.startJob(r, (i) => d(r, e, t, n, i));
|
|
434
|
+
}, [c, d]), p = m(async (t, o) => {
|
|
435
435
|
let u = [], d;
|
|
436
436
|
do {
|
|
437
437
|
if (o.aborted) return;
|
|
@@ -452,10 +452,10 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
452
452
|
traceId: n
|
|
453
453
|
});
|
|
454
454
|
}
|
|
455
|
-
|
|
455
|
+
c.updateJob(t, { status: z.Failed }), console.error("Failed to list conversations for export", e);
|
|
456
456
|
return;
|
|
457
457
|
}
|
|
458
|
-
u.push(...n.items.filter(
|
|
458
|
+
u.push(...n.items.filter(Ie).map((e) => ({
|
|
459
459
|
id: e.id,
|
|
460
460
|
title: e.title
|
|
461
461
|
}))), d = n.nextToken;
|
|
@@ -473,7 +473,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
473
473
|
s?.({
|
|
474
474
|
jobId: t,
|
|
475
475
|
code: V.Unauthorized
|
|
476
|
-
}),
|
|
476
|
+
}), c.updateJob(t, { status: z.Failed });
|
|
477
477
|
return;
|
|
478
478
|
}
|
|
479
479
|
if (n.isNotFound) {
|
|
@@ -486,24 +486,24 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
486
486
|
}), console.error("Skipped a conversation during export-all: not found", e);
|
|
487
487
|
continue;
|
|
488
488
|
}
|
|
489
|
-
let
|
|
489
|
+
let l = await i(e);
|
|
490
490
|
s?.({
|
|
491
491
|
jobId: t,
|
|
492
492
|
code: V.Unknown,
|
|
493
|
-
traceId:
|
|
494
|
-
}),
|
|
493
|
+
traceId: l
|
|
494
|
+
}), c.updateJob(t, { status: z.Failed }), console.error("Aborted export-all: failed to fetch conversation", e);
|
|
495
495
|
return;
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
if (!o.aborted) try {
|
|
499
|
-
|
|
499
|
+
l(se(W(f, [])), G(R.AllConversationsHistory, U)), a?.({ jobId: t }), c.updateJob(t, { status: z.Success });
|
|
500
500
|
} catch (e) {
|
|
501
501
|
let n = await i(e);
|
|
502
502
|
s?.({
|
|
503
503
|
jobId: t,
|
|
504
504
|
code: V.Unknown,
|
|
505
505
|
traceId: n
|
|
506
|
-
}),
|
|
506
|
+
}), c.updateJob(t, { status: z.Failed }), console.error("Failed to build export-all archive", e);
|
|
507
507
|
}
|
|
508
508
|
}, [
|
|
509
509
|
r,
|
|
@@ -511,21 +511,21 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
511
511
|
n,
|
|
512
512
|
s,
|
|
513
513
|
a,
|
|
514
|
-
|
|
514
|
+
c,
|
|
515
515
|
i
|
|
516
|
-
]), h =
|
|
517
|
-
let e =
|
|
518
|
-
return
|
|
519
|
-
}, [
|
|
516
|
+
]), h = m(() => {
|
|
517
|
+
let e = c.addJob({ kind: B.All });
|
|
518
|
+
return c.startJob(e, (t) => p(e, t));
|
|
519
|
+
}, [c, p]);
|
|
520
520
|
return {
|
|
521
|
-
jobs:
|
|
521
|
+
jobs: c.jobs,
|
|
522
522
|
exportSingle: f,
|
|
523
523
|
exportAll: h,
|
|
524
|
-
dismissJob:
|
|
525
|
-
retryJob:
|
|
526
|
-
dismissAll:
|
|
524
|
+
dismissJob: c.dismissJob,
|
|
525
|
+
retryJob: c.retryJob,
|
|
526
|
+
dismissAll: c.dismissAll
|
|
527
527
|
};
|
|
528
|
-
},
|
|
528
|
+
}, Re = (e) => {
|
|
529
529
|
if (!e.url) throw Error(`Attachment "${e.name}" has not been uploaded`);
|
|
530
530
|
return {
|
|
531
531
|
type: e.contentType,
|
|
@@ -533,7 +533,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
533
533
|
url: e.url
|
|
534
534
|
};
|
|
535
535
|
}, J = (e) => {
|
|
536
|
-
if (e.length) return e.map(
|
|
536
|
+
if (e.length) return e.map(Re);
|
|
537
537
|
}, Y = (e, t, n) => {
|
|
538
538
|
let r = new Date(Date.now()).toISOString();
|
|
539
539
|
return {
|
|
@@ -550,16 +550,16 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
550
550
|
...n ? { deploymentId: n } : {}
|
|
551
551
|
}
|
|
552
552
|
};
|
|
553
|
-
}, X = (e) => e != null && Object.keys(e).length > 0,
|
|
553
|
+
}, X = (e) => e != null && Object.keys(e).length > 0, ze = (e, t, n, r) => {
|
|
554
554
|
if (t !== e.content || r.length > 0) return !0;
|
|
555
555
|
let i = e.custom_content?.attachments?.length ?? 0;
|
|
556
556
|
return n.length !== i;
|
|
557
|
-
},
|
|
557
|
+
}, Be = (e) => e["dial:widgetOptions"].populateText || e.title, Ve = (e, t) => {
|
|
558
558
|
let { populateText: n } = e["dial:widgetOptions"];
|
|
559
|
-
return n == null && t ? t :
|
|
560
|
-
},
|
|
559
|
+
return n == null && t ? t : Be(e);
|
|
560
|
+
}, He = (e, t) => {
|
|
561
561
|
let { populateText: n, submit: r } = e["dial:widgetOptions"];
|
|
562
|
-
return r && n == null ? "" : t ??
|
|
562
|
+
return r && n == null ? "" : t ?? Be(e);
|
|
563
563
|
}, Z = (e) => {
|
|
564
564
|
try {
|
|
565
565
|
return decodeURIComponent(e);
|
|
@@ -569,12 +569,12 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
569
569
|
}, Q = (e) => {
|
|
570
570
|
let t = e.indexOf("/");
|
|
571
571
|
return Z(t === -1 ? e : e.substring(t + 1));
|
|
572
|
-
},
|
|
573
|
-
let [g, _] =
|
|
572
|
+
}, Ue = ({ conversation: e, conversationId: t, bucket: n, isStreaming: r, startStream: a, state: { setConversation: o, conversationRef: s }, filesApi: c, conversationsApi: l, rateApi: u, resolveModelId: d, onConversationDeleted: f, showNetworkError: p, toolConfigurationValue: h }) => {
|
|
573
|
+
let [g, _] = y(null), [v, b] = y(/* @__PURE__ */ new Set()), [x, S] = y(null), { handleUploadAttachment: C } = Oe({
|
|
574
574
|
filesApi: c,
|
|
575
575
|
bucket: n,
|
|
576
|
-
onNetworkError:
|
|
577
|
-
}), w =
|
|
576
|
+
onNetworkError: p
|
|
577
|
+
}), w = m(async (n, r) => {
|
|
578
578
|
if (!t || !e) return;
|
|
579
579
|
let i = J(r), c = X(h), l = i?.length || c ? {
|
|
580
580
|
...i?.length ? { attachments: i } : {},
|
|
@@ -591,7 +591,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
591
591
|
]
|
|
592
592
|
};
|
|
593
593
|
return s.current = t, t;
|
|
594
|
-
}), a(t, n, e.messages.length + 1, u, l, crypto.randomUUID(),
|
|
594
|
+
}), a(t, n, e.messages.length + 1, u, l, crypto.randomUUID(), E.Append);
|
|
595
595
|
}, [
|
|
596
596
|
e,
|
|
597
597
|
t,
|
|
@@ -600,7 +600,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
600
600
|
o,
|
|
601
601
|
a,
|
|
602
602
|
h
|
|
603
|
-
]),
|
|
603
|
+
]), T = m((n) => {
|
|
604
604
|
if (r || !t || !e || n === -1 || e.messages[n]?.role !== i.Assistant) return;
|
|
605
605
|
let c = e.messages[n - 1];
|
|
606
606
|
if (!c || c.role !== i.User) return;
|
|
@@ -620,7 +620,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
620
620
|
messages: [...e.messages.slice(0, n), t]
|
|
621
621
|
};
|
|
622
622
|
return s.current = r, r;
|
|
623
|
-
}), b((e) => new Set([...e].filter((e) => e < n))), a(t, c.content, n, l, c.custom_content, crypto.randomUUID(),
|
|
623
|
+
}), b((e) => new Set([...e].filter((e) => e < n))), a(t, c.content, n, l, c.custom_content, crypto.randomUUID(), E.Regenerate);
|
|
624
624
|
}, [
|
|
625
625
|
e,
|
|
626
626
|
t,
|
|
@@ -629,9 +629,9 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
629
629
|
d,
|
|
630
630
|
o,
|
|
631
631
|
a
|
|
632
|
-
]), D =
|
|
632
|
+
]), D = m((e) => {
|
|
633
633
|
r || _(e);
|
|
634
|
-
}, [r]), O =
|
|
634
|
+
}, [r]), O = m(() => {
|
|
635
635
|
if (!t || g == null) return;
|
|
636
636
|
_(null);
|
|
637
637
|
let e = Q(t);
|
|
@@ -657,7 +657,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
657
657
|
f,
|
|
658
658
|
g,
|
|
659
659
|
o
|
|
660
|
-
]), k =
|
|
660
|
+
]), k = m(async (n, r, i) => {
|
|
661
661
|
if (!t || !e) return !1;
|
|
662
662
|
let a = e.messages[n];
|
|
663
663
|
if (!a) return !1;
|
|
@@ -707,9 +707,9 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
707
707
|
l,
|
|
708
708
|
u,
|
|
709
709
|
o
|
|
710
|
-
]), A =
|
|
710
|
+
]), A = m((n, r, i) => {
|
|
711
711
|
if (!t || !e) return;
|
|
712
|
-
let c = i ?? n.title, l =
|
|
712
|
+
let c = i ?? n.title, l = He(n, i), u = r ? { [r]: n.const } : void 0, f = X(h), p = u || f ? {
|
|
713
713
|
...u ? { form_value: u } : {},
|
|
714
714
|
...f ? { configuration_value: h } : {}
|
|
715
715
|
} : void 0, m = d(), { userMessage: g, assistantMessage: _ } = Y(c, p, m);
|
|
@@ -724,7 +724,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
724
724
|
]
|
|
725
725
|
};
|
|
726
726
|
return s.current = t, t;
|
|
727
|
-
}), a(t, l, e.messages.length + 1, m, p, crypto.randomUUID(),
|
|
727
|
+
}), a(t, l, e.messages.length + 1, m, p, crypto.randomUUID(), E.Append);
|
|
728
728
|
}, [
|
|
729
729
|
e,
|
|
730
730
|
t,
|
|
@@ -737,11 +737,11 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
737
737
|
return {
|
|
738
738
|
handleSend: w,
|
|
739
739
|
handleUploadAttachment: C,
|
|
740
|
-
handleRegenerateMessage:
|
|
740
|
+
handleRegenerateMessage: T,
|
|
741
741
|
handleDeleteMessage: D,
|
|
742
742
|
handleConfirmDelete: O,
|
|
743
743
|
handleRateMessage: k,
|
|
744
|
-
handleButtonSelect:
|
|
744
|
+
handleButtonSelect: m((n, i, a) => {
|
|
745
745
|
!t || !e || r || (n["dial:widgetOptions"].confirmationMessage ? S({
|
|
746
746
|
starter: n,
|
|
747
747
|
propertyKey: i,
|
|
@@ -753,26 +753,26 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
753
753
|
r,
|
|
754
754
|
A
|
|
755
755
|
]),
|
|
756
|
-
handleConfirmStarter:
|
|
756
|
+
handleConfirmStarter: m(() => {
|
|
757
757
|
if (!x) return;
|
|
758
758
|
let { starter: e, propertyKey: t, description: n } = x;
|
|
759
759
|
S(null), A(e, t, n);
|
|
760
760
|
}, [x, A]),
|
|
761
|
-
handleStartEdit:
|
|
761
|
+
handleStartEdit: m((e) => {
|
|
762
762
|
b((t) => new Set([...t, e]));
|
|
763
763
|
}, []),
|
|
764
|
-
handleCancelEdit:
|
|
764
|
+
handleCancelEdit: m((e) => {
|
|
765
765
|
b((t) => {
|
|
766
766
|
let n = new Set(t);
|
|
767
767
|
return n.delete(e), n;
|
|
768
768
|
});
|
|
769
769
|
}, []),
|
|
770
|
-
handleEditMessage:
|
|
770
|
+
handleEditMessage: m(async (n, c, l, u) => {
|
|
771
771
|
if (r || !t || !e) return;
|
|
772
772
|
let f = n;
|
|
773
773
|
if (f === -1 || e.messages[f].role !== i.User) return;
|
|
774
774
|
let p = e.messages[f];
|
|
775
|
-
if (!
|
|
775
|
+
if (!ze(p, c, l, u)) {
|
|
776
776
|
b((e) => {
|
|
777
777
|
let t = new Set(e);
|
|
778
778
|
return t.delete(f), t;
|
|
@@ -797,13 +797,13 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
797
797
|
...e.messages.slice(0, f),
|
|
798
798
|
x,
|
|
799
799
|
C
|
|
800
|
-
],
|
|
800
|
+
], T = {
|
|
801
801
|
...e,
|
|
802
802
|
messages: w
|
|
803
803
|
};
|
|
804
|
-
o(() => (s.current =
|
|
804
|
+
o(() => (s.current = T, T));
|
|
805
805
|
let D = d();
|
|
806
|
-
a(t, c, w.length - 1, D, y, crypto.randomUUID(),
|
|
806
|
+
a(t, c, w.length - 1, D, y, crypto.randomUUID(), E.Edit), b(/* @__PURE__ */ new Set());
|
|
807
807
|
}, [
|
|
808
808
|
e,
|
|
809
809
|
t,
|
|
@@ -813,24 +813,24 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
813
813
|
o,
|
|
814
814
|
a
|
|
815
815
|
]),
|
|
816
|
-
editingMessageIndexes:
|
|
816
|
+
editingMessageIndexes: v,
|
|
817
817
|
pendingDeleteIndex: g,
|
|
818
818
|
setPendingDeleteIndex: _,
|
|
819
819
|
pendingStarterContext: x,
|
|
820
820
|
setPendingStarterContext: S
|
|
821
821
|
};
|
|
822
|
-
},
|
|
822
|
+
}, We = (e) => {
|
|
823
823
|
let t = e.lastIndexOf("."), n = t > 0;
|
|
824
824
|
return {
|
|
825
825
|
base: n ? e.slice(0, t) : e,
|
|
826
826
|
extension: n ? e.slice(t) : ""
|
|
827
827
|
};
|
|
828
|
-
},
|
|
828
|
+
}, Ge = (e) => (e.split(/[\\/]/).filter(Boolean).pop() ?? "file").replace(/\.\.+/g, ".").replace(/^\.+/, "") || "file", Ke = (e, t, n) => n === 0 ? `${e}${t}` : `${e} (${n})${t}`, qe = (e) => {
|
|
829
829
|
let t = e?.date ?? /* @__PURE__ */ new Date(), n = new Set(e?.existingNames);
|
|
830
830
|
return {
|
|
831
831
|
allocate: (e) => {
|
|
832
|
-
let { base: r, extension: i } =
|
|
833
|
-
for (; n.has(o);) a += 1, o =
|
|
832
|
+
let { base: r, extension: i } = We(Ge(e)), a = 0, o = Ke(r, i, a);
|
|
833
|
+
for (; n.has(o);) a += 1, o = Ke(r, i, a);
|
|
834
834
|
return n.add(o), {
|
|
835
835
|
path: `uploads/${L(t)}/${encodeURIComponent(o)}`,
|
|
836
836
|
fileName: o,
|
|
@@ -841,34 +841,34 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
841
841
|
n.add(e);
|
|
842
842
|
}
|
|
843
843
|
};
|
|
844
|
-
},
|
|
844
|
+
}, Je = "conversation.json", Ye = /^conversations\/.*\.json$/, Xe = "res/", Ze = (e) => e.find((e) => e === Je) ?? e.find((e) => Ye.test(e)) ?? e.find((e) => !e.includes("/") && e.toLowerCase().endsWith(".json")), Qe = (e) => new Promise((t, n) => {
|
|
845
845
|
let r = new FileReader();
|
|
846
846
|
r.onload = () => t(new Uint8Array(r.result)), r.onerror = () => n(r.error), r.readAsArrayBuffer(e);
|
|
847
|
-
}),
|
|
848
|
-
let t = await
|
|
847
|
+
}), $e = async (e) => {
|
|
848
|
+
let t = await Qe(e), n;
|
|
849
849
|
try {
|
|
850
|
-
n =
|
|
850
|
+
n = w(t);
|
|
851
851
|
} catch {
|
|
852
852
|
throw new K("Import file is not a valid archive");
|
|
853
853
|
}
|
|
854
|
-
let r = Object.keys(n), i =
|
|
854
|
+
let r = Object.keys(n), i = Ze(r);
|
|
855
855
|
if (!i) throw new K("Archive does not contain a readable conversation-JSON entry");
|
|
856
|
-
let a =
|
|
856
|
+
let a = he(S(n[i])), o = /* @__PURE__ */ new Map();
|
|
857
857
|
for (let e of r) {
|
|
858
|
-
if (e.endsWith("/") || !e.startsWith(
|
|
858
|
+
if (e.endsWith("/") || !e.startsWith(Xe)) continue;
|
|
859
859
|
let t = e.slice(4);
|
|
860
|
-
!t || !
|
|
860
|
+
!t || !Ne(t) || o.set(t, n[e]);
|
|
861
861
|
}
|
|
862
862
|
return {
|
|
863
863
|
envelope: a,
|
|
864
864
|
attachments: o
|
|
865
865
|
};
|
|
866
|
-
},
|
|
866
|
+
}, et = 5, tt = 5, nt = (e) => /\.(dial|zip)$/i.test(e.name), rt = (e) => new Promise((t, n) => {
|
|
867
867
|
let r = new FileReader();
|
|
868
868
|
r.onload = () => t(r.result), r.onerror = () => n(r.error), r.readAsText(e);
|
|
869
|
-
}),
|
|
870
|
-
if (
|
|
871
|
-
let { envelope: t, attachments: n } = await
|
|
869
|
+
}), it = async (e) => {
|
|
870
|
+
if (nt(e)) {
|
|
871
|
+
let { envelope: t, attachments: n } = await $e(e);
|
|
872
872
|
return {
|
|
873
873
|
history: t.history,
|
|
874
874
|
attachments: n,
|
|
@@ -876,15 +876,15 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
876
876
|
};
|
|
877
877
|
}
|
|
878
878
|
return {
|
|
879
|
-
history:
|
|
879
|
+
history: he(await rt(e)).history,
|
|
880
880
|
attachments: /* @__PURE__ */ new Map(),
|
|
881
881
|
isArchive: !1
|
|
882
882
|
};
|
|
883
|
-
},
|
|
884
|
-
let { plan: s, skippedNames: c } =
|
|
883
|
+
}, at = async (e, t, n, r, i, a, o) => {
|
|
884
|
+
let { plan: s, skippedNames: c } = we(e, t, r), l = !1, u = await ke(s, et, async (e) => {
|
|
885
885
|
if (o.aborted || l) return;
|
|
886
886
|
let t = e.allocated;
|
|
887
|
-
for (let s = 0; s <=
|
|
887
|
+
for (let s = 0; s <= tt; s += 1) try {
|
|
888
888
|
let r = new File([new Uint8Array(e.bytes)], t.fileName), a = await i.uploadFile({
|
|
889
889
|
bucket: n,
|
|
890
890
|
path: t.path,
|
|
@@ -903,7 +903,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
903
903
|
l = !0;
|
|
904
904
|
return;
|
|
905
905
|
}
|
|
906
|
-
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || s ===
|
|
906
|
+
if (!(typeof n == "object" && n && "response" in n && n.response?.status === 409) || s === tt) return {
|
|
907
907
|
kind: "skipped",
|
|
908
908
|
name: e.originalFileName
|
|
909
909
|
};
|
|
@@ -923,8 +923,8 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
923
923
|
skippedNames: o.aborted || l ? [] : f,
|
|
924
924
|
isUnauthorized: !o.aborted && l
|
|
925
925
|
};
|
|
926
|
-
},
|
|
927
|
-
let l =
|
|
926
|
+
}, ot = ({ conversationsApi: e, filesApi: t, bucket: n, onImported: r, classifyTransferError: i = () => ({}), resolveErrorTraceId: a = async () => void 0, onSuccess: o, onWarning: s, onError: c }) => {
|
|
927
|
+
let l = Ae(), u = m(async (u, d, f) => {
|
|
928
928
|
if (!n) {
|
|
929
929
|
c?.({
|
|
930
930
|
jobId: u,
|
|
@@ -951,7 +951,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
951
951
|
}
|
|
952
952
|
console.error("Failed to list the upload folder for attachment name disambiguation", e);
|
|
953
953
|
}
|
|
954
|
-
b =
|
|
954
|
+
b = qe({
|
|
955
955
|
date: v,
|
|
956
956
|
existingNames: r
|
|
957
957
|
});
|
|
@@ -962,7 +962,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
962
962
|
try {
|
|
963
963
|
let i = /* @__PURE__ */ new Map();
|
|
964
964
|
if (d.isArchive && b) {
|
|
965
|
-
let e = await
|
|
965
|
+
let e = await at(r, d.attachments, n, b, t, y, f);
|
|
966
966
|
if (f.aborted) return;
|
|
967
967
|
if (e.isUnauthorized) {
|
|
968
968
|
g = !0;
|
|
@@ -970,7 +970,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
970
970
|
}
|
|
971
971
|
e.skippedNames.length > 0 && h.push(...e.skippedNames), i = e.targetMap;
|
|
972
972
|
}
|
|
973
|
-
let { conversation: a, subPath: o } =
|
|
973
|
+
let { conversation: a, subPath: o } = ye(Se(r, i), n);
|
|
974
974
|
if (await e.saveConversation({
|
|
975
975
|
path: o,
|
|
976
976
|
saveConversationBodyDto: { conversation: {
|
|
@@ -1027,10 +1027,10 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1027
1027
|
s,
|
|
1028
1028
|
l,
|
|
1029
1029
|
a
|
|
1030
|
-
]), d =
|
|
1030
|
+
]), d = m(async (e) => {
|
|
1031
1031
|
let t;
|
|
1032
1032
|
try {
|
|
1033
|
-
t = await
|
|
1033
|
+
t = await it(e);
|
|
1034
1034
|
} catch (e) {
|
|
1035
1035
|
c?.({
|
|
1036
1036
|
jobId: crypto.randomUUID(),
|
|
@@ -1041,7 +1041,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1041
1041
|
let n = t.history.length > 1, r = t.history[0], i = n ? { kind: B.All } : {
|
|
1042
1042
|
kind: B.Single,
|
|
1043
1043
|
title: r?.name ?? e.name,
|
|
1044
|
-
sourceBreadcrumb: r ?
|
|
1044
|
+
sourceBreadcrumb: r ? be(r) : void 0
|
|
1045
1045
|
}, a = l.addJob(i);
|
|
1046
1046
|
return l.startJob(a, (e) => u(a, t, e));
|
|
1047
1047
|
}, [
|
|
@@ -1056,78 +1056,78 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1056
1056
|
retryJob: l.retryJob,
|
|
1057
1057
|
dismissAll: l.dismissAll
|
|
1058
1058
|
};
|
|
1059
|
-
},
|
|
1060
|
-
let [r, i] =
|
|
1059
|
+
}, st = 80, ct = 1, lt = ({ messages: e, isAssistantTyping: t, conversationId: n }) => {
|
|
1060
|
+
let [r, i] = y(!1), a = v(null), o = v(null), s = v(null), c = v(!1), l = v(!1), u = v(null), d = v(/* @__PURE__ */ new Map()), f = m((e, t) => {
|
|
1061
1061
|
t ? d.current.set(e, t) : d.current.delete(e);
|
|
1062
|
-
}, []),
|
|
1063
|
-
|
|
1064
|
-
}, []), b =
|
|
1062
|
+
}, []), p = v(null), _ = m((e) => {
|
|
1063
|
+
p.current = e;
|
|
1064
|
+
}, []), b = m((e, t) => {
|
|
1065
1065
|
let n = a.current;
|
|
1066
1066
|
n && n.scrollTo({
|
|
1067
1067
|
top: e,
|
|
1068
1068
|
behavior: t ? "instant" : "smooth"
|
|
1069
1069
|
});
|
|
1070
|
-
}, []), x =
|
|
1070
|
+
}, []), x = m(() => {
|
|
1071
1071
|
s.current && (s.current.style.height = "0px"), c.current = !1, l.current = !1, u.current = null;
|
|
1072
|
-
}, []), S =
|
|
1072
|
+
}, []), S = m(() => {
|
|
1073
1073
|
let e = a.current, t = o.current;
|
|
1074
1074
|
if (!e || !t) return null;
|
|
1075
1075
|
let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
1076
1076
|
return e.scrollTop + (r.bottom - n.top) - e.clientHeight;
|
|
1077
|
-
}, []), C =
|
|
1077
|
+
}, []), C = m((e = !1) => {
|
|
1078
1078
|
let t = S();
|
|
1079
1079
|
t != null && b(Math.max(t, 0), e);
|
|
1080
|
-
}, [b, S]), w =
|
|
1080
|
+
}, [b, S]), w = m(() => {
|
|
1081
1081
|
let e = a.current, t = o.current;
|
|
1082
1082
|
if (!e || !t) return null;
|
|
1083
1083
|
let n = e.getBoundingClientRect();
|
|
1084
1084
|
return t.getBoundingClientRect().bottom - n.top - e.clientHeight;
|
|
1085
|
-
}, []), T =
|
|
1085
|
+
}, []), T = m(() => {
|
|
1086
1086
|
if (!l.current) return;
|
|
1087
1087
|
let e = w();
|
|
1088
1088
|
e == null || e < -1 || x();
|
|
1089
|
-
}, [x, w]), E =
|
|
1089
|
+
}, [x, w]), E = m((e) => {
|
|
1090
1090
|
let t = a.current, n = d.current.get(e);
|
|
1091
1091
|
if (!t || !n) return null;
|
|
1092
1092
|
let r = t.getBoundingClientRect(), i = n.getBoundingClientRect(), o = t.scrollTop + (i.top - r.top);
|
|
1093
1093
|
return Math.max(o, 0);
|
|
1094
|
-
}, []), D =
|
|
1094
|
+
}, []), D = m((e, t = !1) => {
|
|
1095
1095
|
let n = E(e);
|
|
1096
1096
|
n != null && b(n, t);
|
|
1097
|
-
}, [E, b]), O =
|
|
1097
|
+
}, [E, b]), O = m(() => {
|
|
1098
1098
|
let e = S();
|
|
1099
1099
|
return e == null ? null : Math.max(e, 0);
|
|
1100
|
-
}, [S]), k =
|
|
1100
|
+
}, [S]), k = m(() => {
|
|
1101
1101
|
if (!c.current) return null;
|
|
1102
1102
|
let e = u.current, t = O();
|
|
1103
1103
|
return e == null || t == null ? null : Math.max(e, t);
|
|
1104
|
-
}, [O]), A =
|
|
1104
|
+
}, [O]), A = m(() => {
|
|
1105
1105
|
let e = a.current, t = k();
|
|
1106
|
-
!e || t == null || e.scrollTop > t +
|
|
1107
|
-
}, [k]), j =
|
|
1106
|
+
!e || t == null || e.scrollTop > t + ct && (e.scrollTop = t);
|
|
1107
|
+
}, [k]), j = m((e) => {
|
|
1108
1108
|
let t = s.current, n = O();
|
|
1109
1109
|
if (!t || n == null) return;
|
|
1110
1110
|
let r = Math.max(e - n, 0);
|
|
1111
1111
|
t.style.height = `${r}px`, c.current = r > 0, l.current = !1, u.current = r > 0 ? e : null;
|
|
1112
|
-
}, [O]), M =
|
|
1112
|
+
}, [O]), M = m((e) => {
|
|
1113
1113
|
let t = E(e);
|
|
1114
1114
|
t != null && (j(t), D(e, !1));
|
|
1115
1115
|
}, [
|
|
1116
1116
|
j,
|
|
1117
1117
|
E,
|
|
1118
1118
|
D
|
|
1119
|
-
]), N =
|
|
1119
|
+
]), N = m(() => {
|
|
1120
1120
|
let e = w();
|
|
1121
|
-
e != null && i(e >=
|
|
1122
|
-
}, [w]), P =
|
|
1123
|
-
|
|
1121
|
+
e != null && i(e >= st);
|
|
1122
|
+
}, [w]), P = v(e.length), F = v(null);
|
|
1123
|
+
g(() => {
|
|
1124
1124
|
let r = e.length !== P.current, i = n !== F.current, a = () => {
|
|
1125
1125
|
P.current = e.length, F.current = n;
|
|
1126
1126
|
};
|
|
1127
1127
|
i && x();
|
|
1128
|
-
let o =
|
|
1128
|
+
let o = p.current;
|
|
1129
1129
|
if (o != null && d.current.has(o)) {
|
|
1130
|
-
|
|
1130
|
+
p.current = null, M(o), a();
|
|
1131
1131
|
return;
|
|
1132
1132
|
}
|
|
1133
1133
|
t || ((r || i) && C(!1), a());
|
|
@@ -1138,20 +1138,20 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1138
1138
|
C,
|
|
1139
1139
|
M,
|
|
1140
1140
|
x
|
|
1141
|
-
]),
|
|
1141
|
+
]), g(() => {
|
|
1142
1142
|
!t && c.current && (l.current = !0, T());
|
|
1143
1143
|
}, [t, T]);
|
|
1144
|
-
let I =
|
|
1144
|
+
let I = m(() => {
|
|
1145
1145
|
A(), T(), N();
|
|
1146
1146
|
}, [
|
|
1147
1147
|
A,
|
|
1148
1148
|
T,
|
|
1149
1149
|
N
|
|
1150
1150
|
]);
|
|
1151
|
-
return
|
|
1151
|
+
return h(() => {
|
|
1152
1152
|
let e = a.current;
|
|
1153
1153
|
if (e) return e.addEventListener("scroll", I, { passive: !0 }), () => e.removeEventListener("scroll", I);
|
|
1154
|
-
}, [I]),
|
|
1154
|
+
}, [I]), h(() => {
|
|
1155
1155
|
let e = o.current;
|
|
1156
1156
|
if (!e) return;
|
|
1157
1157
|
let t = new ResizeObserver(() => {
|
|
@@ -1168,15 +1168,15 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1168
1168
|
spacerRef: s,
|
|
1169
1169
|
setMessageRef: f,
|
|
1170
1170
|
isScrollButtonVisible: r,
|
|
1171
|
-
scrollToBottom:
|
|
1171
|
+
scrollToBottom: m(() => {
|
|
1172
1172
|
C(!1);
|
|
1173
1173
|
}, [C]),
|
|
1174
|
-
armAnchor:
|
|
1174
|
+
armAnchor: _
|
|
1175
1175
|
};
|
|
1176
1176
|
}, $ = (e) => {
|
|
1177
1177
|
let t = e.messages[e.messages.length - 1];
|
|
1178
1178
|
return !!t && t.role === i.Assistant && !t.content && t.streamErrorMessage == null && !t.wasStoppedByUser;
|
|
1179
|
-
},
|
|
1179
|
+
}, ut = (e, t) => {
|
|
1180
1180
|
let n = [...e];
|
|
1181
1181
|
for (let e of t) {
|
|
1182
1182
|
let t = n.findIndex((t) => t.index === e.index);
|
|
@@ -1195,7 +1195,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1195
1195
|
} else n.push(e);
|
|
1196
1196
|
}
|
|
1197
1197
|
return n;
|
|
1198
|
-
},
|
|
1198
|
+
}, dt = (e, t) => {
|
|
1199
1199
|
let n = [...e];
|
|
1200
1200
|
for (let e of t) {
|
|
1201
1201
|
let t = e.index == null ? -1 : n.findIndex((t) => t.index === e.index);
|
|
@@ -1207,7 +1207,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1207
1207
|
} : n.push(e);
|
|
1208
1208
|
}
|
|
1209
1209
|
return n;
|
|
1210
|
-
},
|
|
1210
|
+
}, ft = (e, t) => {
|
|
1211
1211
|
let n = [...e];
|
|
1212
1212
|
for (let e of t) {
|
|
1213
1213
|
let t = n.findIndex((t) => t.index === e.index);
|
|
@@ -1216,18 +1216,18 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1216
1216
|
...e,
|
|
1217
1217
|
name: (n[t].name ?? "") + (e.name ?? ""),
|
|
1218
1218
|
content: (n[t].content ?? "") + (e.content ?? "") || void 0,
|
|
1219
|
-
attachments: e.attachments?.length ?
|
|
1219
|
+
attachments: e.attachments?.length ? dt(n[t].attachments ?? [], e.attachments) : n[t].attachments
|
|
1220
1220
|
} : n.push({
|
|
1221
1221
|
...e,
|
|
1222
1222
|
name: e.name ?? ""
|
|
1223
1223
|
});
|
|
1224
1224
|
}
|
|
1225
1225
|
return n;
|
|
1226
|
-
},
|
|
1227
|
-
let r = n.choices[0]?.delta, i = r?.content ?? "", a = r?.custom_content?.form_schema, o = r?.custom_content?.attachments, s = r?.custom_content?.stages, c = r?.custom_content?.annotations, l = r?.custom_fields?.annotations,
|
|
1226
|
+
}, pt = (e, t, n) => {
|
|
1227
|
+
let r = n.choices[0]?.delta, i = r?.content ?? "", a = r?.custom_content?.form_schema, o = r?.custom_content?.attachments, s = r?.custom_content?.stages, c = r?.custom_content?.annotations, l = r?.custom_fields?.annotations, u = r?.custom_content?.state, f = !!i || !!a || !!o?.length || !!s?.length || !!c?.length || !!l?.length || !!u, p = r?.responseId ?? (f ? n.id : void 0);
|
|
1228
1228
|
return !f && !p ? null : e.map((e, n) => {
|
|
1229
1229
|
if (n !== t) return e;
|
|
1230
|
-
let r = [...e.custom_content?.attachments ?? [], ...o ?? []], f = l?.length ?
|
|
1230
|
+
let r = [...e.custom_content?.attachments ?? [], ...o ?? []], f = l?.length ? d(l, r) : [], m = [...c ?? [], ...f], h = a || o?.length || s?.length || m.length || u;
|
|
1231
1231
|
return {
|
|
1232
1232
|
...e,
|
|
1233
1233
|
content: i ? e.content + i : e.content,
|
|
@@ -1236,41 +1236,41 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1236
1236
|
...e.custom_content,
|
|
1237
1237
|
...a && { form_schema: a },
|
|
1238
1238
|
...o?.length && { attachments: r },
|
|
1239
|
-
...s?.length && { stages:
|
|
1240
|
-
...m.length && { annotations:
|
|
1241
|
-
...
|
|
1239
|
+
...s?.length && { stages: ft(e.custom_content?.stages ?? [], s) },
|
|
1240
|
+
...m.length && { annotations: ut(e.custom_content?.annotations ?? [], m) },
|
|
1241
|
+
...u && { state: u }
|
|
1242
1242
|
} }
|
|
1243
1243
|
};
|
|
1244
1244
|
});
|
|
1245
|
-
},
|
|
1246
|
-
let [l, u] =
|
|
1247
|
-
|
|
1245
|
+
}, mt = 300 * 1e3, ht = ({ conversationId: e, state: { setConversation: t, conversationRef: n }, transport: r, generation: { startGeneration: i, completeGeneration: a }, channel: o, overlay: s, onStopError: c }) => {
|
|
1246
|
+
let [l, u] = y(() => /* @__PURE__ */ new Set()), [d, f] = y(null), p = v(null), g = v(null), _ = v(/* @__PURE__ */ new Set()), b = v(/* @__PURE__ */ new Set()), x = v(e);
|
|
1247
|
+
h(() => {
|
|
1248
1248
|
x.current = e;
|
|
1249
1249
|
}, [e]);
|
|
1250
|
-
let S =
|
|
1250
|
+
let S = m((e) => Q(x.current ?? "") === e, []), C = m((e) => {
|
|
1251
1251
|
u((t) => {
|
|
1252
1252
|
if (t.has(e)) return t;
|
|
1253
1253
|
let n = new Set(t);
|
|
1254
1254
|
return n.add(e), n;
|
|
1255
1255
|
});
|
|
1256
|
-
}, []), w =
|
|
1256
|
+
}, []), w = m((e) => {
|
|
1257
1257
|
u((t) => {
|
|
1258
1258
|
if (!t.has(e)) return t;
|
|
1259
1259
|
let n = new Set(t);
|
|
1260
1260
|
return n.delete(e), n;
|
|
1261
1261
|
});
|
|
1262
|
-
}, []),
|
|
1263
|
-
let _ =
|
|
1264
|
-
|
|
1262
|
+
}, []), T = m((e, c, l, u, d, m, h = E.Append) => {
|
|
1263
|
+
let _ = m ?? crypto.randomUUID(), v = Q(e);
|
|
1264
|
+
p.current = _, g.current = v, f(v);
|
|
1265
1265
|
let y;
|
|
1266
|
-
|
|
1266
|
+
h === E.Regenerate ? y = l : h === E.Edit && (y = l - 1);
|
|
1267
1267
|
let x = i(v, _);
|
|
1268
1268
|
C(v), s?.notifyGenerationStart?.(), o?.ensureConnected(), r.streamCompletion(v, c, u, {
|
|
1269
1269
|
signal: x.signal,
|
|
1270
1270
|
onChunk: (e) => {
|
|
1271
|
-
|
|
1271
|
+
p.current === _ && S(v) && t((t) => {
|
|
1272
1272
|
if (!t) return t;
|
|
1273
|
-
let r =
|
|
1273
|
+
let r = pt(t.messages, l, e);
|
|
1274
1274
|
if (!r) return t;
|
|
1275
1275
|
let i = {
|
|
1276
1276
|
...t,
|
|
@@ -1280,14 +1280,14 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1280
1280
|
});
|
|
1281
1281
|
},
|
|
1282
1282
|
onComplete: async () => {
|
|
1283
|
-
if (w(v),
|
|
1283
|
+
if (w(v), p.current === _ && (p.current = null, g.current = null, f(null)), a(v, _), b.current.has(_) ? b.current.delete(_) : s?.notifyGenerationEnd?.(), S(v)) try {
|
|
1284
1284
|
let i = await r.getConversation(Z(e));
|
|
1285
1285
|
if (!S(v)) return;
|
|
1286
1286
|
t(i), n.current = i;
|
|
1287
1287
|
} catch {}
|
|
1288
1288
|
},
|
|
1289
1289
|
onError: (e) => {
|
|
1290
|
-
w(v),
|
|
1290
|
+
w(v), p.current === _ && (p.current = null, g.current = null, f(null)), S(v) && t((t) => {
|
|
1291
1291
|
if (!t) return t;
|
|
1292
1292
|
let r = {
|
|
1293
1293
|
...t,
|
|
@@ -1299,7 +1299,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1299
1299
|
return n.current = r, r;
|
|
1300
1300
|
});
|
|
1301
1301
|
}
|
|
1302
|
-
}, d, _,
|
|
1302
|
+
}, d, _, h, y, o?.channelId ?? void 0);
|
|
1303
1303
|
}, [
|
|
1304
1304
|
i,
|
|
1305
1305
|
a,
|
|
@@ -1310,8 +1310,8 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1310
1310
|
o?.ensureConnected,
|
|
1311
1311
|
s,
|
|
1312
1312
|
r
|
|
1313
|
-
]), D =
|
|
1314
|
-
let t =
|
|
1313
|
+
]), D = m(() => {
|
|
1314
|
+
let t = p.current;
|
|
1315
1315
|
if (!t || !e) return;
|
|
1316
1316
|
let n = Q(e);
|
|
1317
1317
|
g.current === n && (b.current.add(t), s?.notifyStopGenerating?.(), r.stopCompletion({
|
|
@@ -1326,13 +1326,13 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1326
1326
|
c,
|
|
1327
1327
|
s,
|
|
1328
1328
|
r
|
|
1329
|
-
]), O =
|
|
1329
|
+
]), O = m((e, i) => {
|
|
1330
1330
|
if (!$(i)) return;
|
|
1331
1331
|
let a = Q(e);
|
|
1332
|
-
if (
|
|
1333
|
-
|
|
1332
|
+
if (_.current.has(a)) return;
|
|
1333
|
+
_.current.add(a), C(a);
|
|
1334
1334
|
let o = new AbortController(), s = (e) => {
|
|
1335
|
-
|
|
1335
|
+
_.current.delete(a), w(a), e && S(a) && (t(e), n.current = e);
|
|
1336
1336
|
}, c = async () => {
|
|
1337
1337
|
try {
|
|
1338
1338
|
s(await r.getConversation(Z(e)));
|
|
@@ -1350,7 +1350,7 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1350
1350
|
}
|
|
1351
1351
|
let n = t.getReader(), i = new TextDecoder(), l = "", u = window.setTimeout(() => {
|
|
1352
1352
|
o.abort();
|
|
1353
|
-
},
|
|
1353
|
+
}, mt);
|
|
1354
1354
|
try {
|
|
1355
1355
|
for (;;) {
|
|
1356
1356
|
let { done: t, value: a } = await n.read();
|
|
@@ -1388,39 +1388,39 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1388
1388
|
r
|
|
1389
1389
|
]), k = e != null && l.has(Q(e)), A = e == null ? null : Q(e);
|
|
1390
1390
|
return {
|
|
1391
|
-
startStream:
|
|
1391
|
+
startStream: T,
|
|
1392
1392
|
handleStop: D,
|
|
1393
1393
|
resumeIfAwaitingGeneration: O,
|
|
1394
1394
|
isStreaming: k,
|
|
1395
1395
|
canStopStreaming: A != null && d === A
|
|
1396
1396
|
};
|
|
1397
|
-
},
|
|
1398
|
-
let n = [], r = [], a = [],
|
|
1397
|
+
}, gt = {}, _t = (e, t = gt) => _(() => {
|
|
1398
|
+
let n = [], r = [], a = [], o = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
|
|
1399
1399
|
for (let d of e) {
|
|
1400
1400
|
let e = d.custom_content?.attachments;
|
|
1401
1401
|
if (d.role === i.User) for (let r of e ?? []) {
|
|
1402
|
-
let e =
|
|
1402
|
+
let e = s(r, t);
|
|
1403
1403
|
c.has(e.id) || (c.add(e.id), n.push(e));
|
|
1404
1404
|
}
|
|
1405
1405
|
else if (d.role === i.Assistant) {
|
|
1406
|
-
let n = e?.filter((e) => !
|
|
1406
|
+
let n = e?.filter((e) => !u(e));
|
|
1407
1407
|
for (let e of n ?? []) {
|
|
1408
|
-
let n =
|
|
1409
|
-
|
|
1408
|
+
let n = s(e, t);
|
|
1409
|
+
l.has(n.id) || (l.add(n.id), r.push(n));
|
|
1410
1410
|
}
|
|
1411
1411
|
for (let t of e ?? []) {
|
|
1412
|
-
if (!
|
|
1412
|
+
if (!u(t)) continue;
|
|
1413
1413
|
let e = t.reference_url;
|
|
1414
|
-
|
|
1414
|
+
o.has(e) || (o.add(e), a.push({
|
|
1415
1415
|
url: e,
|
|
1416
1416
|
title: t.title ?? e,
|
|
1417
1417
|
contentType: t.reference_type ?? t.type ?? "",
|
|
1418
1418
|
quote: t.data
|
|
1419
1419
|
}));
|
|
1420
1420
|
}
|
|
1421
|
-
for (let e of
|
|
1421
|
+
for (let e of p(d)) {
|
|
1422
1422
|
let t = e?.body?.source?.attachment, n = t?.url;
|
|
1423
|
-
!n ||
|
|
1423
|
+
!n || o.has(n) || (o.add(n), a.push({
|
|
1424
1424
|
url: n,
|
|
1425
1425
|
title: t?.title ?? n.split("/").pop() ?? n,
|
|
1426
1426
|
contentType: t?.type ?? "",
|
|
@@ -1434,15 +1434,83 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1434
1434
|
generated: r,
|
|
1435
1435
|
sources: a
|
|
1436
1436
|
};
|
|
1437
|
-
}, [e, t]),
|
|
1438
|
-
|
|
1439
|
-
|
|
1437
|
+
}, [e, t]), vt = {
|
|
1438
|
+
settings: "Settings",
|
|
1439
|
+
savedNotification: "Chat settings have been saved",
|
|
1440
|
+
responseFormatLabel: "Response format",
|
|
1441
|
+
responseFormatHint: "Applies to new and existing messages",
|
|
1442
|
+
responseFormatMarkdown: "Markdown",
|
|
1443
|
+
responseFormatPlainText: "Plain text",
|
|
1444
|
+
systemPromptLabel: "System prompt",
|
|
1445
|
+
systemPromptTooltip: "Enter a prompt",
|
|
1446
|
+
temperatureLabel: "Temperature",
|
|
1447
|
+
temperaturePrecise: "Precise",
|
|
1448
|
+
temperatureNeutral: "Neutral",
|
|
1449
|
+
temperatureCreative: "Creative",
|
|
1450
|
+
temperatureHint: "Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.",
|
|
1451
|
+
saveLabel: "Apply changes",
|
|
1452
|
+
saveDisabledTooltip: "Please select a response format"
|
|
1453
|
+
}, yt = (e) => (e ?? "").toLowerCase().replace(/[^a-z]/g, "") === "plaintext" ? a.PlainText : a.Markdown, bt = (e) => {
|
|
1454
|
+
let t = _(() => ({
|
|
1455
|
+
...vt,
|
|
1456
|
+
...e.labels
|
|
1457
|
+
}), [e.labels]), { onSaved: n } = e, r = e.mode === "local" ? e.values.responseFormat : yt(e.conversation.responseFormat), i = e.mode === "local" ? e.values.systemPrompt : e.conversation.prompt ?? "", a = e.mode === "local" ? e.values.temperature : e.conversation.temperature ?? .5, o = m((t) => {
|
|
1458
|
+
e.mode === "local" ? e.onValuesChange({
|
|
1459
|
+
responseFormat: t.responseFormat ?? e.values.responseFormat,
|
|
1460
|
+
systemPrompt: t.systemPrompt ?? e.values.systemPrompt,
|
|
1461
|
+
temperature: t.temperature ?? e.values.temperature
|
|
1462
|
+
}) : e.onConversationChange({
|
|
1463
|
+
...e.conversation,
|
|
1464
|
+
...t.responseFormat != null && { responseFormat: t.responseFormat },
|
|
1465
|
+
...t.systemPrompt != null && { prompt: t.systemPrompt },
|
|
1466
|
+
...t.temperature != null && { temperature: t.temperature }
|
|
1467
|
+
}), n?.();
|
|
1468
|
+
}, [n, e]), s = e.deploymentFeatures?.systemPrompt ?? !1, c = !e.isQuickApp && (e.deploymentFeatures?.temperature ?? !1);
|
|
1469
|
+
return _(() => ({
|
|
1470
|
+
features: {
|
|
1471
|
+
systemPrompt: s,
|
|
1472
|
+
temperature: c,
|
|
1473
|
+
responseFormat: !0
|
|
1474
|
+
},
|
|
1475
|
+
responseFormat: r,
|
|
1476
|
+
systemPrompt: i,
|
|
1477
|
+
temperature: a,
|
|
1478
|
+
onSave: o,
|
|
1479
|
+
menuItemLabel: t.settings,
|
|
1480
|
+
title: t.settings,
|
|
1481
|
+
responseFormatLabel: t.responseFormatLabel,
|
|
1482
|
+
responseFormatHint: t.responseFormatHint,
|
|
1483
|
+
responseFormatMarkdownLabel: t.responseFormatMarkdown,
|
|
1484
|
+
responseFormatPlainTextLabel: t.responseFormatPlainText,
|
|
1485
|
+
systemPromptLabel: t.systemPromptLabel,
|
|
1486
|
+
systemPromptTooltip: t.systemPromptTooltip,
|
|
1487
|
+
temperatureLabel: t.temperatureLabel,
|
|
1488
|
+
temperatureLabels: [
|
|
1489
|
+
t.temperaturePrecise,
|
|
1490
|
+
t.temperatureNeutral,
|
|
1491
|
+
t.temperatureCreative
|
|
1492
|
+
],
|
|
1493
|
+
temperatureHint: t.temperatureHint,
|
|
1494
|
+
saveLabel: t.saveLabel,
|
|
1495
|
+
saveDisabledTooltip: t.saveDisabledTooltip
|
|
1496
|
+
}), [
|
|
1497
|
+
o,
|
|
1498
|
+
s,
|
|
1499
|
+
c,
|
|
1500
|
+
t,
|
|
1501
|
+
r,
|
|
1502
|
+
i,
|
|
1503
|
+
a
|
|
1504
|
+
]);
|
|
1505
|
+
}, xt = (e = !0, t = !0) => {
|
|
1506
|
+
let [n, r] = y(!1), [i, a] = y([]), o = v(0), s = v(e), c = v(t);
|
|
1507
|
+
g(() => {
|
|
1440
1508
|
s.current = e, c.current = t, t || (o.current = 0, r(!1));
|
|
1441
1509
|
}, [e, t]);
|
|
1442
|
-
let l =
|
|
1510
|
+
let l = m(() => {
|
|
1443
1511
|
a([]);
|
|
1444
1512
|
}, []);
|
|
1445
|
-
return
|
|
1513
|
+
return h(() => {
|
|
1446
1514
|
let e = (e) => !!e.dataTransfer?.types.includes("Files"), t = (t) => {
|
|
1447
1515
|
!c.current || !e(t) || (o.current += 1, r(!0));
|
|
1448
1516
|
}, n = (t) => {
|
|
@@ -1463,21 +1531,21 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1463
1531
|
pendingFiles: i,
|
|
1464
1532
|
onFilesConsumed: l
|
|
1465
1533
|
};
|
|
1466
|
-
},
|
|
1467
|
-
let [e, t] =
|
|
1468
|
-
return
|
|
1534
|
+
}, St = () => typeof window < "u" ? window.innerWidth : 1024, Ct = () => {
|
|
1535
|
+
let [e, t] = y(St);
|
|
1536
|
+
return h(() => {
|
|
1469
1537
|
if (typeof window > "u") return;
|
|
1470
1538
|
let e = () => t(window.innerWidth);
|
|
1471
1539
|
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1472
1540
|
}, []), e;
|
|
1473
|
-
},
|
|
1474
|
-
let t =
|
|
1541
|
+
}, wt = (e) => {
|
|
1542
|
+
let t = Ct();
|
|
1475
1543
|
return Math.max(0, t - e);
|
|
1476
|
-
},
|
|
1544
|
+
}, Tt = (e) => e.map((e) => e === D.Edit ? O.Edit : O.View), Et = (e, t) => {
|
|
1477
1545
|
let n = new URL(e, t);
|
|
1478
1546
|
return `${t}${n.pathname}${n.search}${n.hash}`;
|
|
1479
|
-
},
|
|
1480
|
-
let [i, a] =
|
|
1547
|
+
}, Dt = (e, t, n, r = window.location.origin) => {
|
|
1548
|
+
let [i, a] = y(), [o, s] = y(!0), [c, l] = y(null), u = v(0), d = m(async (i = [O.View]) => {
|
|
1481
1549
|
let o = ++u.current;
|
|
1482
1550
|
s(!0), l(null);
|
|
1483
1551
|
try {
|
|
@@ -1487,9 +1555,9 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1487
1555
|
access: i
|
|
1488
1556
|
} });
|
|
1489
1557
|
u.current === o && a({
|
|
1490
|
-
url:
|
|
1558
|
+
url: Et(s.url, r),
|
|
1491
1559
|
expiresInDays: s.expiresInDays,
|
|
1492
|
-
access:
|
|
1560
|
+
access: Tt(s.access)
|
|
1493
1561
|
});
|
|
1494
1562
|
} catch (e) {
|
|
1495
1563
|
u.current === o && l(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to create share link"));
|
|
@@ -1502,22 +1570,22 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1502
1570
|
n,
|
|
1503
1571
|
e
|
|
1504
1572
|
]);
|
|
1505
|
-
return
|
|
1573
|
+
return h(() => {
|
|
1506
1574
|
a(void 0), d();
|
|
1507
1575
|
}, [t, d]), {
|
|
1508
1576
|
data: i,
|
|
1509
1577
|
isLoading: o,
|
|
1510
1578
|
error: c,
|
|
1511
|
-
setAccess:
|
|
1579
|
+
setAccess: m((e) => {
|
|
1512
1580
|
d(e);
|
|
1513
1581
|
}, [d])
|
|
1514
1582
|
};
|
|
1515
|
-
},
|
|
1583
|
+
}, Ot = /* @__PURE__ */ function(e) {
|
|
1516
1584
|
return e.Idle = "idle", e.Loading = "loading", e.Resolved = "resolved", e.Unknown = "unknown", e;
|
|
1517
|
-
}({}),
|
|
1518
|
-
let [t, n] =
|
|
1585
|
+
}({}), kt = { status: "idle" }, At = (e) => {
|
|
1586
|
+
let [t, n] = y({}), r = v(/* @__PURE__ */ new Set());
|
|
1519
1587
|
return {
|
|
1520
|
-
requestRecipientsCount:
|
|
1588
|
+
requestRecipientsCount: m((t) => {
|
|
1521
1589
|
r.current.has(t) || (r.current.add(t), n((e) => ({
|
|
1522
1590
|
...e,
|
|
1523
1591
|
[t]: { status: "loading" }
|
|
@@ -1539,11 +1607,11 @@ var O = (e) => e.startsWith("files/"), k = (e) => e.url != null && O(e.url) || e
|
|
|
1539
1607
|
}
|
|
1540
1608
|
})());
|
|
1541
1609
|
}, [e]),
|
|
1542
|
-
getRecipientsCount:
|
|
1543
|
-
invalidateRecipientsCount:
|
|
1610
|
+
getRecipientsCount: m((e) => t[e] ?? kt, [t]),
|
|
1611
|
+
invalidateRecipientsCount: m((e) => {
|
|
1544
1612
|
r.current.delete(e), n(({ [e]: t, ...n }) => n);
|
|
1545
1613
|
}, [])
|
|
1546
1614
|
};
|
|
1547
1615
|
};
|
|
1548
1616
|
//#endregion
|
|
1549
|
-
export {
|
|
1617
|
+
export { re as AttachmentValidationErrorReason, oe as ConversationExportMode, V as ConversationTransferErrorCode, z as ConversationTransferJobStatus, B as ConversationTransferSubjectKind, H as ConversationTransferWarningCode, U as EXPORT_APP_NAME, R as ExportFileNameKind, Ot as RecipientsCountStatus, Re as attachmentToDto, J as attachmentsToDtos, Y as createMessagePair, j as downloadAttachment, L as formatDateYM, ae as formatDateYMD, xe as formatQuotedNameList, Q as getConversationPath, Ve as getStarterConversationText, He as getStarterSubmitText, X as hasActiveToolConfig, $ as isAwaitingGenerationResume, k as isDialFileId, A as isDownloadableAttachment, ze as isMessageChanged, P as useAttachmentAction, Oe as useAttachmentUpload, ie as useAttachmentValidation, bt as useChatSettingsFormConfig, Le as useConversationExport, Ue as useConversationHandlers, ot as useConversationImport, lt as useConversationScroll, _t as useConversationSources, ht as useConversationStream, xt as usePageFileDrag, wt as usePanelMaxWidth, Dt as useShareLink, At as useShareRecipientsCount, Ct as useViewportWidth };
|