@epam/ai-dial-chat-hooks 1.3.0-dev.105 → 1.3.0-dev.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.
Files changed (28) hide show
  1. package/file-manager.js +21 -21
  2. package/files/create-files-api.d.ts +1 -1
  3. package/files/create-files-api.d.ts.map +1 -1
  4. package/files/create-files-api.js +1 -1
  5. package/files/create-upload-file-with-progress.d.ts +4 -1
  6. package/files/create-upload-file-with-progress.d.ts.map +1 -1
  7. package/files/create-upload-file-with-progress.js +43 -28
  8. package/files/dial-file-manager-mapping.util.d.ts +6 -2
  9. package/files/dial-file-manager-mapping.util.d.ts.map +1 -1
  10. package/files/dial-file-manager-mapping.util.js +85 -72
  11. package/files/dial-file-manager.types.d.ts +12 -4
  12. package/files/dial-file-manager.types.d.ts.map +1 -1
  13. package/files/dial-files-api.d.ts +2 -2
  14. package/files/dial-files-api.d.ts.map +1 -1
  15. package/files/download-progress.d.ts +33 -0
  16. package/files/download-progress.d.ts.map +1 -0
  17. package/files/download-progress.js +28 -0
  18. package/files/useDialFileManager/useDialFileManager.d.ts.map +1 -1
  19. package/files/useDialFileManager/useDialFileManager.js +5 -2
  20. package/files/useDialFileManagerSections/useDialFileManagerSections.d.ts.map +1 -1
  21. package/files/useDialFileManagerSections/useDialFileManagerSections.js +85 -78
  22. package/files/useDialFileMutations/useDialFileMutations.d.ts +9 -0
  23. package/files/useDialFileMutations/useDialFileMutations.d.ts.map +1 -1
  24. package/files/useDialFileMutations/useDialFileMutations.js +230 -159
  25. package/files/useDialFileUploadBatch/useDialFileUploadBatch.d.ts.map +1 -1
  26. package/files/useDialFileUploadBatch/useDialFileUploadBatch.js +108 -100
  27. package/index.js +46 -46
  28. package/package.json +18 -18
@@ -4,21 +4,22 @@ import { RESERVED_MARKER_NAME as i } from "../dial-file-manager.model.js";
4
4
  import { formatOperationFolderName as a, getVirtualPathName as o, hasForbiddenNameSymbols as s, parseNewFolderVirtualPath as c, resolveOwnerCoords as l } from "../dial-file-manager-path.util.js";
5
5
  import { resolveDialFileApiPath as u, virtualPathToApiPath as d } from "../resolve-dial-file-api-path.js";
6
6
  import { prepareCopyItems as f, prepareMoveRenameItems as p } from "../dial-file-manager-copy-move.util.js";
7
- import { findFirstSuccessfulCopyMoveItem as m } from "../dial-file-manager-mapping.util.js";
8
- import { DownloadDestinationType as h } from "../download-destination.js";
9
- import { getParentFolderPath as g } from "@epam/ai-dial-chat-shared";
10
- import { useCallback as _, useRef as v, useState as y } from "react";
11
- import { ArchiveItemDtoNodeTypeEnum as b, CopyItemDtoNodeTypeEnum as x, DeleteItemDtoNodeTypeEnum as S, MoveItemDtoNodeTypeEnum as ee, RenameItemDtoNodeTypeEnum as C } from "@epam/ai-dial-chat-api-client";
12
- import { NOT_ALLOWED_SYMBOLS as te, NotificationVariant as w } from "@epam/ai-dial-ui-kit";
13
- import { DialFileManagerTabs as T, DialFileNodeType as E } from "@epam/ai-dial-react-file-manager";
7
+ import { findFirstSuccessfulCopyMoveItem as m, resolveTransferFailureReason as h } from "../dial-file-manager-mapping.util.js";
8
+ import { DownloadDestinationType as g } from "../download-destination.js";
9
+ import { createDownloadResponseError as _, estimateArchiveSize as v, getContentLength as y, getDownloadPercent as b, withDownloadProgress as ee } from "../download-progress.js";
10
+ import { FileDownloadStatus as x, getParentFolderPath as S, isDownloadInProgress as te } from "@epam/ai-dial-chat-shared";
11
+ import { useCallback as C, useEffect as ne, useRef as w, useState as T } from "react";
12
+ import { ArchiveItemDtoNodeTypeEnum as re, CopyItemDtoNodeTypeEnum as ie, DeleteItemDtoNodeTypeEnum as E, MoveItemDtoNodeTypeEnum as ae, RenameItemDtoNodeTypeEnum as oe } from "@epam/ai-dial-chat-api-client";
13
+ import { NOT_ALLOWED_SYMBOLS as se, NotificationVariant as D } from "@epam/ai-dial-ui-kit";
14
+ import { DialFileManagerTabs as ce, DialFileNodeType as O } from "@epam/ai-dial-react-file-manager";
14
15
  //#region src/files/useDialFileMutations/useDialFileMutations.ts
15
- var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, currentFolder: M, sharedRootMetaRef: N, listingPermissionsCache: P, invalidateFolders: F, bumpRetry: I, mergeCreatedFolder: L, setFolderPath: R, onNotification: z, onOperationSuccess: B, downloadDestination: V, forbiddenSymbolsRegExp: H }) => {
16
- let [ne, U] = y(!1), [re, W] = y(!1), [ie, G] = y(!1), [K, q] = y(!1), [J, Y] = y(!1), [X, ae] = y(!1), Z = v(null), Q = v(null), $ = _((e, t) => {
16
+ var k = 0, le = () => (k += 1, `download-${Date.now()}-${k}`), A = ({ filesApi: k, bucket: A, rootLabel: j, activeTab: M, folderPath: N, currentFolder: P, sharedRootMetaRef: F, listingPermissionsCache: ue, invalidateFolders: I, bumpRetry: L, mergeCreatedFolder: de, setFolderPath: R, onNotification: z, onOperationSuccess: B, downloadDestination: V, forbiddenSymbolsRegExp: H }) => {
17
+ let [fe, pe] = T(!1), [me, U] = T(null), W = w(/* @__PURE__ */ new Map()), G = w(/* @__PURE__ */ new Map()), K = w(null), [he, ge] = T(!1), [q, _e] = T(!1), [J, ve] = T(!1), [Y, ye] = T(!1), X = w(null), Z = w(null), Q = C((e, t) => {
17
18
  let r = null;
18
19
  if (!e || e.trim() === "") r = { reason: n.Empty };
19
20
  else if (s(e, H)) r = {
20
21
  reason: n.ForbiddenSymbols,
21
- symbols: te
22
+ symbols: se
22
23
  };
23
24
  else if (e === i) r = { reason: n.ReservedName };
24
25
  else if (e.length > 255) r = {
@@ -32,132 +33,198 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
32
33
  existingName: o.name
33
34
  });
34
35
  }
35
- return Q.current = r, r;
36
- }, [H]), oe = _(async (e, n, i) => {
37
- let { parentVirtualPath: a, name: o } = c(n, k), s = d(a, k), u = M && j === s ? M : {
36
+ return Z.current = r, r;
37
+ }, [H]), be = C(async (e, n, i) => {
38
+ let { parentVirtualPath: a, name: o } = c(n, j), s = d(a, j), u = P && N === s ? P : {
38
39
  id: s,
39
40
  path: s,
40
41
  name: a.split("/").filter(Boolean).pop() ?? "",
41
42
  folderId: s,
42
- nodeType: E.FOLDER,
43
+ nodeType: O.FOLDER,
43
44
  items: []
44
- }, f = Q.current;
45
- if (Q.current = null, $(o, u) || f) return;
46
- U(!0);
47
- let { bucket: p, path: m } = A === T.Shared ? l(s, N.current, O) : {
48
- bucket: O,
45
+ }, f = Z.current;
46
+ if (Z.current = null, Q(o, u) || f) return;
47
+ pe(!0);
48
+ let { bucket: p, path: m } = M === ce.Shared ? l(s, F.current, A) : {
49
+ bucket: A,
49
50
  path: s
50
51
  };
51
52
  try {
52
- L(s, await D.createFolder({
53
+ de(s, await k.createFolder({
53
54
  bucket: p,
54
55
  parentPath: m,
55
56
  name: o
56
- }), P.get(s)), I(), B?.({
57
+ }), ue.get(s)), L(), B?.({
57
58
  kind: r.FolderCreated,
58
59
  name: o
59
60
  });
60
61
  } catch {
61
62
  z?.({
62
- variant: w.Error,
63
+ variant: D.Error,
63
64
  reason: t.FolderCreateFailed
64
65
  });
65
66
  } finally {
66
- U(!1);
67
+ pe(!1);
67
68
  }
68
69
  }, [
69
- A,
70
- O,
71
70
  M,
72
- D,
73
- j,
74
- $,
75
- k,
71
+ A,
76
72
  P,
73
+ k,
74
+ N,
75
+ Q,
76
+ j,
77
+ ue,
78
+ de,
77
79
  L,
78
- I,
79
80
  B,
80
- N,
81
+ F,
81
82
  z
82
- ]), se = _((e) => {
83
+ ]), $ = C((e, t) => {
84
+ G.current.delete(e), U((n) => n && {
85
+ ...n,
86
+ files: n.files.map((n) => n.id === e ? {
87
+ ...n,
88
+ ...t
89
+ } : n)
90
+ });
91
+ }, []), xe = C((e, t) => {
92
+ G.current.set(e, t), K.current ??= requestAnimationFrame(() => {
93
+ K.current = null;
94
+ let e = new Map(G.current);
95
+ G.current.clear(), U((t) => t && {
96
+ ...t,
97
+ files: t.files.map((t) => e.has(t.id) && t.status === x.Downloading ? {
98
+ ...t,
99
+ percent: e.get(t.id)
100
+ } : t)
101
+ });
102
+ });
103
+ }, []);
104
+ ne(() => () => {
105
+ K.current != null && cancelAnimationFrame(K.current);
106
+ }, []);
107
+ let Se = C((e) => {
83
108
  (async () => {
84
- W(!0);
109
+ let n = e.length === 1 && e[0].nodeType === O.ITEM, i = "files.zip";
110
+ n ? i = e[0].name : e.length === 1 && (i = `${e[0].name}.zip`);
111
+ let a = e.length === 1 ? t.DownloadFileFailed : t.DownloadFilesFailed, o;
85
112
  try {
86
- let t = e.length === 1 ? e[0].nodeType === E.ITEM ? e[0].name : `${e[0].name}.zip` : "files.zip", n = await V.resolveDestination(t, e.length === 1 && e[0].nodeType === E.ITEM ? e[0].contentType ?? "application/octet-stream" : "application/zip");
87
- if (n.type === h.Cancelled) return;
88
- if (e.length === 1 && e[0].nodeType === E.ITEM) {
89
- let t = e[0];
90
- if (!t.bucket) throw Error("File is missing bucket");
91
- let i = u(t, t.bucket, k), a = await D.downloadFile(t.bucket, i);
92
- if (!a.ok) throw Error(`Download failed with status ${a.status}`);
93
- let o = await V.triggerDownload(a, t.name, n);
94
- B?.({
95
- kind: r.FileDownloaded,
96
- name: o,
97
- count: 1
98
- });
113
+ o = await V.resolveDestination(i, n ? e[0].contentType ?? "application/octet-stream" : "application/zip");
114
+ } catch {
115
+ z?.({
116
+ variant: D.Error,
117
+ reason: a
118
+ });
119
+ return;
120
+ }
121
+ if (o.type === g.Cancelled) return;
122
+ let s = le(), c = new AbortController();
123
+ W.current.set(s, c), U((e) => ({
124
+ isOpen: !0,
125
+ files: [...e?.files ?? [], {
126
+ id: s,
127
+ name: i,
128
+ status: x.Downloading
129
+ }]
130
+ }));
131
+ try {
132
+ let t, a, l = !1;
133
+ if (n) {
134
+ let n = e[0];
135
+ if (!n.bucket) throw Error("File is missing bucket");
136
+ let r = u(n, n.bucket, j);
137
+ if (t = await k.downloadFile(n.bucket, r, c.signal), !t.ok) throw _(t);
138
+ a = y(t);
99
139
  } else {
100
- let i = e.map((e) => ({
101
- bucket: e.bucket ?? O,
102
- path: u(e, e.bucket ?? O, k),
140
+ let n = e.map((e) => ({
141
+ bucket: e.bucket ?? A,
142
+ path: u(e, e.bucket ?? A, j),
103
143
  name: e.name,
104
- nodeType: e.nodeType === E.FOLDER ? b.Folder : b.Item
105
- })), a = await D.downloadArchive(i);
106
- if (!a.ok) throw Error(`Download failed with status ${a.status}`);
107
- let o = await V.triggerDownload(a, t, n);
108
- e.length === 1 ? B?.({
109
- kind: r.FileDownloaded,
110
- name: o
111
- }) : B?.({
112
- kind: r.FilesDownloaded,
113
- count: e.length
114
- });
144
+ nodeType: e.nodeType === O.FOLDER ? re.Folder : re.Item
145
+ }));
146
+ if (t = await k.downloadArchive(n, c.signal), !t.ok) throw _(t);
147
+ a = v(e.map((e) => ({
148
+ isFolder: e.nodeType === O.FOLDER,
149
+ contentLength: e.contentLength
150
+ }))), l = !0;
115
151
  }
116
- } catch {
117
- z?.({
118
- variant: w.Error,
119
- reason: e.length === 1 ? t.DownloadFileFailed : t.DownloadFilesFailed
152
+ let d = ee(t, (e) => xe(s, b(e, a, l))), f = await V.triggerDownload(d, i, o);
153
+ $(s, {
154
+ status: x.Completed,
155
+ percent: 100
156
+ }), n ? B?.({
157
+ kind: r.FileDownloaded,
158
+ name: f,
159
+ count: 1
160
+ }) : e.length === 1 ? B?.({
161
+ kind: r.FileDownloaded,
162
+ name: f
163
+ }) : B?.({
164
+ kind: r.FilesDownloaded,
165
+ count: e.length
166
+ });
167
+ } catch (e) {
168
+ if (c.signal.aborted) {
169
+ $(s, { status: x.Cancelled });
170
+ return;
171
+ }
172
+ let t = await h(e);
173
+ $(s, {
174
+ status: x.Failed,
175
+ failureReason: t
176
+ }), z?.({
177
+ variant: D.Error,
178
+ reason: a
120
179
  });
121
180
  } finally {
122
- W(!1);
181
+ W.current.delete(s);
123
182
  }
124
183
  })();
125
184
  }, [
126
- O,
127
- k,
185
+ A,
186
+ j,
128
187
  B,
129
188
  z,
130
- D,
131
- V
132
- ]), ce = _((e, n) => {
189
+ k,
190
+ V,
191
+ $,
192
+ xe
193
+ ]), Ce = C((e) => {
194
+ W.current.get(e)?.abort();
195
+ }, []), we = C(() => {
196
+ for (let e of W.current.values()) e.abort();
197
+ }, []), Te = C(() => {
198
+ G.current.clear(), U(null);
199
+ }, []), Ee = te(me), De = C((e, n) => {
133
200
  e.length !== 0 && (async () => {
134
- G(!0);
201
+ ge(!0);
135
202
  let r = [], i = e.map((e) => {
136
- let t = e.nodeType === E.FOLDER, n = d(e.sourceUrl, k), i = t ? n : n.replace(/\/$/, "");
203
+ let t = e.nodeType === O.FOLDER, n = d(e.sourceUrl, j), i = t ? n : n.replace(/\/$/, "");
137
204
  t && i !== "" && r.push(i.endsWith("/") ? i : `${i}/`);
138
- let a = o(e.sourceUrl, i), { bucket: s, path: c } = A === T.Shared ? l(i, N.current, O) : {
139
- bucket: O,
205
+ let a = o(e.sourceUrl, i), { bucket: s, path: c } = M === ce.Shared ? l(i, F.current, A) : {
206
+ bucket: A,
140
207
  path: i
141
208
  };
142
209
  return {
143
210
  bucket: s,
144
211
  path: c,
145
212
  name: a,
146
- nodeType: t ? S.Folder : S.Item
213
+ nodeType: t ? E.Folder : E.Item
147
214
  };
148
215
  });
149
216
  try {
150
- let { results: e } = await D.deleteFiles(i), r = e.filter((e) => !e.success), a = r.length, o = e.length - a, s = e.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
217
+ let { results: e } = await k.deleteFiles(i), r = e.filter((e) => !e.success), a = r.length, o = e.length - a, s = e.find((e) => e.success), c = i.find((e) => e.path === s?.path) ?? i[0];
151
218
  if (o > 0 && z?.({
152
- variant: w.Success,
219
+ variant: D.Success,
153
220
  reason: t.FilesDeleted,
154
221
  count: o,
155
222
  name: c?.name,
156
- folder: n || k
223
+ folder: n || j
157
224
  }), a > 0) {
158
225
  let e = r.slice(0, 3).map((e) => i.find((t) => t.path === e.path)?.name ?? e.path), n = a - e.length;
159
226
  z?.({
160
- variant: w.Error,
227
+ variant: D.Error,
161
228
  reason: t.FilesDeletePartiallyFailed,
162
229
  names: e,
163
230
  restCount: n
@@ -165,118 +232,122 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
165
232
  }
166
233
  } catch {
167
234
  z?.({
168
- variant: w.Error,
235
+ variant: D.Error,
169
236
  reason: t.DeleteFailed
170
237
  });
171
238
  }
172
- F([...new Set(i.map((e) => {
173
- if (e.nodeType === S.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
239
+ I([...new Set(i.map((e) => {
240
+ if (e.nodeType === E.Folder) return e.path.endsWith("/") ? e.path : `${e.path}/`;
174
241
  let t = e.path.lastIndexOf("/");
175
242
  return t > 0 ? e.path.slice(0, t + 1) : "";
176
243
  }))]);
177
- let a = r.filter((e) => j.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
178
- a != null && R(g(a)), I(), G(!1);
244
+ let a = r.filter((e) => N.startsWith(e)).reduce((e, t) => e == null || t.length < e.length ? t : e, void 0);
245
+ a != null && R(S(a)), L(), ge(!1);
179
246
  })();
180
247
  }, [
248
+ M,
181
249
  A,
182
- O,
183
- k,
184
250
  j,
185
- z,
186
- D,
187
251
  N,
252
+ z,
253
+ k,
188
254
  F,
189
255
  I,
256
+ L,
190
257
  R
191
- ]), le = _((t, r) => {
258
+ ]), Oe = C((t, r) => {
192
259
  if (!t || t.trim() === "") return { reason: n.Empty };
193
- let a = r.nodeType === E.ITEM ? e(r.name).extension : "";
260
+ let a = r.nodeType === O.ITEM ? e(r.name).extension : "";
194
261
  if (t === i || a !== "" && t === `${i}${a}`) return { reason: n.ReservedName };
195
262
  if (s(t, H)) return {
196
263
  reason: n.ForbiddenSymbols,
197
- symbols: te
264
+ symbols: se
198
265
  };
199
266
  if (t.length > 255) return {
200
267
  reason: n.TooLong,
201
268
  maxLength: 255
202
269
  };
203
- let o = M?.items ?? [], c = t.toLowerCase(), l = o.find((e) => e.path !== r.path && e.name.toLowerCase() === c);
270
+ let o = P?.items ?? [], c = t.toLowerCase(), l = o.find((e) => e.path !== r.path && e.name.toLowerCase() === c);
204
271
  return l ? {
205
272
  reason: n.DuplicateName,
206
273
  existingName: l.name
207
274
  } : null;
208
- }, [H, M]), ue = _((e, n) => {
209
- if (e.length === 0 || J || X) return;
275
+ }, [H, P]), ke = C((e, n) => {
276
+ if (e.length === 0 || J || Y) return;
210
277
  let i = new AbortController();
211
- Z.current = i, (async () => {
212
- Y(!0);
213
- let o = f(e, O, k), s = o.map(({ dto: e }) => e);
278
+ X.current = i, (async () => {
279
+ ve(!0);
280
+ let o = f(e, A, j), s = o.map(({ dto: e }) => e);
214
281
  try {
215
- let { results: e } = await D.copyFiles(s, i.signal), c = e.filter((e) => !e.success).length, l = e.length - c;
282
+ let { results: e } = await k.copyFiles(s, i.signal), c = e.filter((e) => !e.success).length, l = e.length - c;
216
283
  if (l > 0) {
217
- let t = m(o, e), i = s.every((e) => g(e.sourcePath) === g(e.destinationPath)), c;
284
+ let t = m(o, e), i = s.every((e) => S(e.sourcePath) === S(e.destinationPath)), c;
218
285
  c = i ? l === 1 ? r.FileDuplicated : r.FilesDuplicated : l === 1 ? r.FileCopied : r.FilesCopied, B?.({
219
286
  kind: c,
220
287
  name: t?.destinationName,
221
288
  count: l,
222
- isFolder: t?.dto.nodeType === x.Folder,
223
- destinationFolderName: a(n, k)
289
+ isFolder: t?.dto.nodeType === ie.Folder,
290
+ destinationFolderName: a(n, j)
224
291
  });
225
292
  }
226
293
  c > 0 && c < e.length ? z?.({
227
- variant: w.Error,
294
+ variant: D.Error,
228
295
  reason: t.CopyPartiallyFailed,
229
296
  count: c
230
297
  }) : c === e.length && z?.({
231
- variant: w.Error,
298
+ variant: D.Error,
232
299
  reason: t.CopyFailed
233
300
  });
234
301
  } catch {
235
302
  i.signal.aborted || z?.({
236
- variant: w.Error,
303
+ variant: D.Error,
237
304
  reason: t.CopyFailed
238
305
  });
239
306
  } finally {
240
- F([...new Set(s.flatMap((e) => [g(e.sourcePath), g(e.destinationPath)]))]), I(), Y(!1), Z.current = null;
307
+ I([...new Set(s.flatMap((e) => [S(e.sourcePath), S(e.destinationPath)]))]), L(), ve(!1), X.current = null;
241
308
  }
242
309
  })();
243
310
  }, [
244
- O,
245
- k,
311
+ A,
312
+ j,
246
313
  z,
247
314
  B,
248
- D,
315
+ k,
249
316
  J,
250
- X,
251
- F,
252
- I
253
- ]), de = _(() => {
254
- Z.current?.abort();
317
+ Y,
318
+ I,
319
+ L
320
+ ]), Ae = C(() => {
321
+ X.current?.abort();
255
322
  }, []);
256
323
  return {
257
- isCreatingFolder: ne,
258
- isDownloading: re,
259
- isDeleting: ie,
260
- isRenaming: K,
324
+ isCreatingFolder: fe,
325
+ isDownloading: Ee,
326
+ isDeleting: he,
327
+ isRenaming: q,
261
328
  isCopying: J,
262
- isMoving: X,
263
- onCreateFolder: oe,
264
- onCreateFolderValidate: $,
265
- onDownloadFiles: se,
266
- onDeleteFiles: ce,
267
- onRenameValidate: le,
268
- onMoveToFiles: _((e, n, i) => {
269
- if (e.length === 0 || J || X || K) return;
270
- let { renameDtos: s, preparedMoveItems: c } = p(e, O, k), l = c.map(({ dto: e }) => e), u = new AbortController();
271
- l.length > 0 && (Z.current = u), (async () => {
272
- s.length > 0 && q(!0), l.length > 0 && ae(!0);
329
+ isMoving: Y,
330
+ onCreateFolder: be,
331
+ onCreateFolderValidate: Q,
332
+ onDownloadFiles: Se,
333
+ downloadBatchState: me,
334
+ cancelDownloadFile: Ce,
335
+ cancelAllDownloads: we,
336
+ clearDownloadBatch: Te,
337
+ onDeleteFiles: De,
338
+ onRenameValidate: Oe,
339
+ onMoveToFiles: C((e, n, i) => {
340
+ if (e.length === 0 || J || Y || q) return;
341
+ let { renameDtos: s, preparedMoveItems: c } = p(e, A, j), l = c.map(({ dto: e }) => e), u = new AbortController();
342
+ l.length > 0 && (X.current = u), (async () => {
343
+ s.length > 0 && _e(!0), l.length > 0 && ye(!0);
273
344
  let [e, n] = await Promise.all([(async () => {
274
345
  if (s.length === 0) return {
275
346
  results: [],
276
347
  threw: !1
277
348
  };
278
349
  try {
279
- let { results: e } = await D.renameFiles(s);
350
+ let { results: e } = await k.renameFiles(s);
280
351
  return {
281
352
  results: e,
282
353
  threw: !1
@@ -294,7 +365,7 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
294
365
  aborted: !1
295
366
  };
296
367
  try {
297
- let { results: e } = await D.moveFiles(l, u.signal);
368
+ let { results: e } = await k.moveFiles(l, u.signal);
298
369
  return {
299
370
  results: e,
300
371
  threw: !1,
@@ -307,15 +378,15 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
307
378
  aborted: u.signal.aborted
308
379
  };
309
380
  }
310
- })()]), d = e.threw ? s.length : e.results.filter((e) => !e.success).length, f = n.threw && n.aborted, p = f ? 0 : l.length, h = f ? 0 : n.threw ? l.length : n.results.filter((e) => !e.success).length, _ = n.threw ? 0 : n.results.filter((e) => e.success).length, v = s.length + p, y = d + h, b = h > 0;
311
- if (_ > 0) {
381
+ })()]), d = e.threw ? s.length : e.results.filter((e) => !e.success).length, f = n.threw && n.aborted, p = f ? 0 : l.length, h = f ? 0 : n.threw ? l.length : n.results.filter((e) => !e.success).length, g = n.threw ? 0 : n.results.filter((e) => e.success).length, _ = s.length + p, v = d + h, y = h > 0;
382
+ if (g > 0) {
312
383
  let e = m(c, n.results);
313
384
  B?.({
314
- kind: _ === 1 ? r.FileMoved : r.FilesMoved,
385
+ kind: g === 1 ? r.FileMoved : r.FilesMoved,
315
386
  name: e?.destinationName,
316
- count: _,
317
- isFolder: e?.dto.nodeType === ee.Folder,
318
- destinationFolderName: a(i, k)
387
+ count: g,
388
+ isFolder: e?.dto.nodeType === ae.Folder,
389
+ destinationFolderName: a(i, j)
319
390
  });
320
391
  }
321
392
  if (s.length === 1 && d === 0) {
@@ -323,44 +394,44 @@ var D = ({ filesApi: D, bucket: O, rootLabel: k, activeTab: A, folderPath: j, cu
323
394
  B?.({
324
395
  kind: r.FileRenamed,
325
396
  name: o(e.destinationPath, e.destinationPath),
326
- isFolder: e.nodeType === C.Folder
397
+ isFolder: e.nodeType === oe.Folder
327
398
  });
328
399
  }
329
- y > 0 && (y === v ? z?.({
330
- variant: w.Error,
331
- reason: b ? t.MoveFailed : t.RenameFailed
400
+ v > 0 && (v === _ ? z?.({
401
+ variant: D.Error,
402
+ reason: y ? t.MoveFailed : t.RenameFailed
332
403
  }) : z?.({
333
- variant: w.Error,
334
- reason: b ? t.MovePartiallyFailed : t.RenamePartiallyFailed,
335
- count: y
404
+ variant: D.Error,
405
+ reason: y ? t.MovePartiallyFailed : t.RenamePartiallyFailed,
406
+ count: v
336
407
  }));
337
- let x = s.find((t) => t.nodeType === C.Folder && e.results.some((e) => e.success && e.sourcePath === t.sourcePath));
338
- if (x != null) {
339
- let e = x.sourcePath.endsWith("/") ? x.sourcePath : `${x.sourcePath}/`;
340
- if (j === e || j.startsWith(e)) {
341
- let t = x.destinationPath.endsWith("/") ? x.destinationPath : `${x.destinationPath}/`;
342
- R(j.replace(e, t));
408
+ let b = s.find((t) => t.nodeType === oe.Folder && e.results.some((e) => e.success && e.sourcePath === t.sourcePath));
409
+ if (b != null) {
410
+ let e = b.sourcePath.endsWith("/") ? b.sourcePath : `${b.sourcePath}/`;
411
+ if (N === e || N.startsWith(e)) {
412
+ let t = b.destinationPath.endsWith("/") ? b.destinationPath : `${b.destinationPath}/`;
413
+ R(N.replace(e, t));
343
414
  }
344
415
  }
345
- F([...new Set([...s, ...l].flatMap((e) => [g(e.sourcePath), g(e.destinationPath)]))]), I(), q(!1), ae(!1), l.length > 0 && (Z.current = null);
416
+ I([...new Set([...s, ...l].flatMap((e) => [S(e.sourcePath), S(e.destinationPath)]))]), L(), _e(!1), ye(!1), l.length > 0 && (X.current = null);
346
417
  })();
347
418
  }, [
348
- O,
349
- k,
419
+ A,
350
420
  j,
421
+ N,
351
422
  B,
352
423
  z,
353
- D,
424
+ k,
354
425
  J,
355
- X,
356
- K,
357
- F,
426
+ Y,
427
+ q,
358
428
  I,
429
+ L,
359
430
  R
360
431
  ]),
361
- onCopyFiles: ue,
362
- cancelCopyMove: de
432
+ onCopyFiles: ke,
433
+ cancelCopyMove: Ae
363
434
  };
364
435
  };
365
436
  //#endregion
366
- export { D as useDialFileMutations };
437
+ export { A as useDialFileMutations };
@@ -1 +1 @@
1
- {"version":3,"file":"useDialFileUploadBatch.d.ts","sourceRoot":"","sources":["../../../src/files/useDialFileUploadBatch/useDialFileUploadBatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EACV,oBAAoB,EAEpB,0BAA0B,EAC3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAKvE,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyDtD,oDAAoD;AACpD,MAAM,WAAW,6BAA6B;IAC5C,kEAAkE;IAClE,QAAQ,EAAE,YAAY,CAAC;IACvB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,SAAS,EAAE,mBAAmB,CAAC;IAC/B,gHAAgH;IAChH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACvC,0FAA0F;IAC1F,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAChE,+EAA+E;IAC/E,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAChD,4DAA4D;IAC5D,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAClE;AAED,mDAAmD;AACnD,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,CACb,KAAK,EAAE,kBAAkB,EAAE,EAC3B,iBAAiB,EAAE,MAAM,KACtB,IAAI,CAAC;IACV,eAAe,EAAE,CACf,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,MAAM,KACtB,IAAI,CAAC;IACV,gBAAgB,EAAE,CAChB,KAAK,EAAE,kBAAkB,EAAE,EAC3B,aAAa,EAAE,QAAQ,EAAE,EACzB,iBAAiB,EAAE,MAAM,KACtB,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACzC,gBAAgB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,qHAUpC,6BAA6B,KAAG,4BAwRlC,CAAC"}
1
+ {"version":3,"file":"useDialFileUploadBatch.d.ts","sourceRoot":"","sources":["../../../src/files/useDialFileUploadBatch/useDialFileUploadBatch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,oBAAoB,EAIzB,KAAK,0BAA0B,EAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EACV,QAAQ,EACR,kBAAkB,EACnB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAQvE,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAG1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAyDtD,oDAAoD;AACpD,MAAM,WAAW,6BAA6B;IAC5C,kEAAkE;IAClE,QAAQ,EAAE,YAAY,CAAC;IACvB,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,sEAAsE;IACtE,SAAS,EAAE,mBAAmB,CAAC;IAC/B,gHAAgH;IAChH,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAAC;IACvC,0FAA0F;IAC1F,iBAAiB,EAAE,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IAChE,+EAA+E;IAC/E,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAChD,4DAA4D;IAC5D,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,8FAA8F;IAC9F,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,uBAAuB,KAAK,IAAI,CAAC;CAClE;AAED,mDAAmD;AACnD,MAAM,WAAW,4BAA4B;IAC3C,aAAa,EAAE,CACb,KAAK,EAAE,kBAAkB,EAAE,EAC3B,iBAAiB,EAAE,MAAM,KACtB,IAAI,CAAC;IACV,eAAe,EAAE,CACf,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,iBAAiB,EAAE,MAAM,KACtB,IAAI,CAAC;IACV,gBAAgB,EAAE,CAChB,KAAK,EAAE,kBAAkB,EAAE,EAC3B,aAAa,EAAE,QAAQ,EAAE,EACzB,iBAAiB,EAAE,MAAM,KACtB,OAAO,CAAC,0BAA0B,CAAC,CAAC;IACzC,gBAAgB,EAAE,oBAAoB,GAAG,IAAI,CAAC;IAC9C,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAAI,qHAUpC,6BAA6B,KAAG,4BAiSlC,CAAC"}