@emailmaker/filemanager 1.1.85-dev.7 → 1.1.88

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/core.esm.js CHANGED
@@ -168,76 +168,74 @@ function b(e) {
168
168
  };
169
169
  }
170
170
  //#endregion
171
- //#region packages/file-manager/src/utils/generateId.ts
172
- function x() {
173
- if (typeof globalThis?.crypto?.randomUUID == "function") return globalThis.crypto.randomUUID();
174
- try {
175
- let e = globalThis.crypto || globalThis.msCrypto;
176
- if (e && typeof e.getRandomValues == "function") {
177
- let t = /* @__PURE__ */ new Uint8Array(16);
178
- e.getRandomValues(t);
179
- let n = "";
180
- for (let e = 0; e < t.length; e++) n += t[e].toString(16).padStart(2, "0");
181
- return `id_${n}`;
182
- }
183
- } catch {}
184
- return `id_fallback_${Date.now().toString(36)}_${Math.floor(Math.random() * (2 ** 53 - 1)).toString(36).slice(0, 8)}`;
185
- }
186
- //#endregion
187
171
  //#region packages/file-manager/src/utils/urlNormalization.ts
188
- var S = /^(utm_[a-z0-9_]+|fbclid|gclid|igshid|mc_cid|mc_eid)$/i;
189
- function C(e) {
172
+ var x = /^(utm_[a-z0-9_]+|fbclid|gclid|igshid|mc_cid|mc_eid)$/i;
173
+ function S(e) {
190
174
  try {
191
175
  return decodeURIComponent(e.replace(/\+/g, " "));
192
176
  } catch {
193
177
  return e;
194
178
  }
195
179
  }
196
- function w(e) {
180
+ function C(e) {
197
181
  let t = new URL(e.trim());
198
182
  t.hash = "", t.hostname = t.hostname.toLowerCase(), (t.protocol === "https:" && t.port === "443" || t.protocol === "http:" && t.port === "80") && (t.port = "");
199
183
  let n = (t.search.startsWith("?") ? t.search.slice(1) : t.search).split("&").filter(Boolean).map((e) => {
200
184
  let t = e.indexOf("="), n = t === -1 ? e : e.slice(0, t), r = t === -1 ? "" : e.slice(t + 1);
201
185
  return {
202
186
  pair: e,
203
- key: C(n),
204
- value: C(r)
187
+ key: S(n),
188
+ value: S(r)
205
189
  };
206
- }).filter(({ key: e }) => !S.test(e)).sort((e, t) => {
190
+ }).filter(({ key: e }) => !x.test(e)).sort((e, t) => {
207
191
  let n = e.key.localeCompare(t.key);
208
192
  return n === 0 ? e.value.localeCompare(t.value) : n;
209
193
  });
210
194
  return t.search = n.length ? `?${n.map(({ pair: e }) => e).join("&")}` : "", t.toString();
211
195
  }
212
- function T(e) {
196
+ function w(e) {
213
197
  try {
214
- return w(e);
198
+ return C(e);
215
199
  } catch {
216
200
  return e.trim();
217
201
  }
218
202
  }
219
203
  //#endregion
220
204
  //#region packages/file-manager/src/adapters/TreeCache.ts
221
- var E = "", D = 18e5;
222
- function O(e) {
223
- return e == null || e === "" ? E : e;
205
+ var T = "", E = 1800 * 1e3;
206
+ function D(e) {
207
+ return e == null || e === "" ? T : e;
224
208
  }
225
- function k(e) {
209
+ function O(e) {
226
210
  if (e == null) return Infinity;
227
211
  let t = Number(e);
228
212
  return Number.isFinite(t) && t >= 0 ? t : Infinity;
229
213
  }
230
- function A(e) {
214
+ function k(e) {
231
215
  return !e || typeof e.search != "string" ? !1 : e.search.trim().length > 0;
232
216
  }
233
- function j(e) {
217
+ function A(e) {
234
218
  if (!e) return null;
235
219
  let t = e.folderId;
236
220
  return t == null ? null : String(t);
237
221
  }
238
- function M(e) {
222
+ function j(e) {
239
223
  return !!e && !!e.isFolder;
240
224
  }
225
+ function M() {
226
+ if (typeof globalThis?.crypto?.randomUUID == "function") return globalThis.crypto.randomUUID();
227
+ try {
228
+ let e = globalThis.crypto || globalThis.msCrypto;
229
+ if (e && typeof e.getRandomValues == "function") {
230
+ let t = /* @__PURE__ */ new Uint8Array(16);
231
+ e.getRandomValues(t);
232
+ let n = "";
233
+ for (let e = 0; e < t.length; e++) n += t[e].toString(16).padStart(2, "0");
234
+ return `id_${n}`;
235
+ }
236
+ } catch {}
237
+ return `id_fallback_${Date.now().toString(36)}_${Math.floor(Math.random() * (2 ** 53 - 1)).toString(36).slice(0, 8)}`;
238
+ }
241
239
  function N(e) {
242
240
  if (!e || typeof e != "object") return !1;
243
241
  let t = e;
@@ -290,32 +288,32 @@ var I = class e {
290
288
  }
291
289
  getFileSystemItem(e) {
292
290
  let t = this.getEntity(e);
293
- return t && !M(t) ? t : void 0;
291
+ return t && !j(t) ? t : void 0;
294
292
  }
295
293
  getFolder(e) {
296
294
  let t = this.getEntity(e);
297
- return t && M(t) ? t : void 0;
295
+ return t && j(t) ? t : void 0;
298
296
  }
299
297
  getChildrenIds(e, t = {}) {
300
- let n = O(e), r = this.childrenByParent.get(n);
298
+ let n = D(e), r = this.childrenByParent.get(n);
301
299
  return r ? t.onlyFileSystemItems ? Array.from(r.files) : t.onlyFolders ? Array.from(r.folders) : [...Array.from(r.folders), ...Array.from(r.files)] : [];
302
300
  }
303
301
  searchByUrl(e) {
304
- let t = T(e);
302
+ let t = w(e);
305
303
  for (let n of this.entities.values()) {
306
304
  let r = n.value.url;
307
- if (r && (r === e || T(r) === t)) return n.value;
305
+ if (r && (r === e || w(r) === t)) return n.value;
308
306
  }
309
307
  return null;
310
308
  }
311
309
  upsertEntity(e) {
312
- let t = this.entities.get(e.id) ?? null, n = t ? t.value : null, r = n ? j(n) : null, i = j(e), a = n ? M(n) : !1, o = M(e), s;
313
- if (n && M(n) && o) {
310
+ let t = this.entities.get(e.id) ?? null, n = t ? t.value : null, r = n ? A(n) : null, i = A(e), a = n ? j(n) : !1, o = j(e), s;
311
+ if (n && j(n) && o) {
314
312
  let t = n.childrenCount, r = e.childrenCount;
315
313
  t !== void 0 && r === void 0 && (s = t);
316
314
  }
317
315
  if (n && (r !== i || a !== o)) {
318
- let t = O(r), n = this.childrenByParent.get(t);
316
+ let t = D(r), n = this.childrenByParent.get(t);
319
317
  n && (a ? n.folders.delete(e.id) : n.files.delete(e.id), n.files.size === 0 && n.folders.size === 0 && this.childrenByParent.delete(t));
320
318
  }
321
319
  let c = e;
@@ -326,7 +324,7 @@ var I = class e {
326
324
  value: { ...c },
327
325
  updatedAt: this.now()
328
326
  }), this.checkCacheSize();
329
- let l = O(i), u = this.childrenByParent.get(l);
327
+ let l = D(i), u = this.childrenByParent.get(l);
330
328
  u || (u = {
331
329
  files: /* @__PURE__ */ new Set(),
332
330
  folders: /* @__PURE__ */ new Set()
@@ -335,7 +333,7 @@ var I = class e {
335
333
  updateServerChildrenCount(e, t) {
336
334
  if (e == null || t == null || Number.isNaN(t)) return;
337
335
  let n = this.entities.get(e);
338
- if (!n || !M(n.value)) return;
336
+ if (!n || !j(n.value)) return;
339
337
  let r = {
340
338
  ...n.value,
341
339
  childrenCount: t
@@ -351,32 +349,32 @@ var I = class e {
351
349
  entity: null,
352
350
  parentId: null
353
351
  };
354
- let n = t.value, r = j(n), i = O(r), a = this.childrenByParent.get(i);
355
- return a && (M(n) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i)), this.entities.delete(e), {
352
+ let n = t.value, r = A(n), i = D(r), a = this.childrenByParent.get(i);
353
+ return a && (j(n) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i)), this.entities.delete(e), {
356
354
  entity: { ...n },
357
355
  parentId: r
358
356
  };
359
357
  }
360
358
  deleteFolderRecursive(e) {
361
359
  let t = this.entities.get(e);
362
- if (!t || !M(t.value)) return {
360
+ if (!t || !j(t.value)) return {
363
361
  deletedFolderRecords: [],
364
362
  deletedFileSystemItemRecords: []
365
363
  };
366
364
  let n = [{
367
365
  id: e,
368
- parentId: j(t.value)
366
+ parentId: A(t.value)
369
367
  }], r = [], i = [];
370
368
  for (; n.length;) {
371
369
  let e = n.shift();
372
370
  r.push(e);
373
- let t = this.childrenByParent.get(O(e.id));
371
+ let t = this.childrenByParent.get(D(e.id));
374
372
  if (t) {
375
373
  for (let e of Array.from(t.folders)) {
376
374
  let t = this.entities.get(e);
377
375
  t && n.push({
378
376
  id: e,
379
- parentId: j(t.value)
377
+ parentId: A(t.value)
380
378
  });
381
379
  }
382
380
  for (let e of Array.from(t.files)) i.push(e);
@@ -386,16 +384,16 @@ var I = class e {
386
384
  for (let e of i) {
387
385
  let t = this.entities.get(e);
388
386
  if (!t) continue;
389
- let n = t.value, r = O(j(n)), i = this.childrenByParent.get(r);
387
+ let n = t.value, r = D(A(n)), i = this.childrenByParent.get(r);
390
388
  i && (i.files.delete(e), i.files.size === 0 && i.folders.size === 0 && this.childrenByParent.delete(r)), this.entities.delete(e), a.push({ ...n });
391
389
  }
392
390
  let o = [];
393
391
  for (let e = r.length - 1; e >= 0; e--) {
394
392
  let { id: t, parentId: n } = r[e], i = this.entities.get(t);
395
393
  if (!i) continue;
396
- let a = i.value, s = O(a.id);
394
+ let a = i.value, s = D(a.id);
397
395
  this.childrenByParent.delete(s);
398
- let c = O(n), l = this.childrenByParent.get(c);
396
+ let c = D(n), l = this.childrenByParent.get(c);
399
397
  l && (l.folders.delete(t), l.files.size === 0 && l.folders.size === 0 && this.childrenByParent.delete(c)), this.entities.delete(t), o.push({ ...a });
400
398
  }
401
399
  return {
@@ -406,13 +404,13 @@ var I = class e {
406
404
  moveEntityById(e, t) {
407
405
  let n = this.entities.get(e) ?? null;
408
406
  if (!n) return null;
409
- let r = n.value, i = O(j(r)), a = this.childrenByParent.get(i);
410
- a && (M(r) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i));
407
+ let r = n.value, i = D(A(r)), a = this.childrenByParent.get(i);
408
+ a && (j(r) ? a.folders.delete(e) : a.files.delete(e), a.files.size === 0 && a.folders.size === 0 && this.childrenByParent.delete(i));
411
409
  let o = {
412
410
  ...r,
413
411
  folderId: t
414
412
  };
415
- if (M(r) && M(o)) {
413
+ if (j(r) && j(o)) {
416
414
  let e = r.childrenCount;
417
415
  e !== void 0 && (o.childrenCount = e);
418
416
  }
@@ -420,15 +418,15 @@ var I = class e {
420
418
  value: o,
421
419
  updatedAt: this.now()
422
420
  });
423
- let s = O(t), c = this.childrenByParent.get(s);
421
+ let s = D(t), c = this.childrenByParent.get(s);
424
422
  return c || (c = {
425
423
  files: /* @__PURE__ */ new Set(),
426
424
  folders: /* @__PURE__ */ new Set()
427
- }, this.childrenByParent.set(s, c)), M(o) ? c.folders.add(e) : c.files.add(e), { ...o };
425
+ }, this.childrenByParent.set(s, c)), j(o) ? c.folders.add(e) : c.files.add(e), { ...o };
428
426
  }
429
427
  copyFileSystemItem(e, t, n) {
430
428
  let r = this.entities.get(e) ?? null;
431
- if (!r || M(r.value)) return null;
429
+ if (!r || j(r.value)) return null;
432
430
  let i = {
433
431
  ...r.value,
434
432
  id: t,
@@ -438,7 +436,7 @@ var I = class e {
438
436
  }
439
437
  copyFolderShallow(e, t, n) {
440
438
  let r = this.entities.get(e) ?? null;
441
- if (!r || !M(r.value)) return null;
439
+ if (!r || !j(r.value)) return null;
442
440
  let i = {
443
441
  ...r.value,
444
442
  id: t,
@@ -462,7 +460,7 @@ var I = class e {
462
460
  let n = t?.parentId, r = t?.recursive ?? !1, i = t?.itemType ?? "all", a = t?.caseSensitive ?? !1, o = t?.limit ?? Infinity, s = a ? e.trim() : e.trim().toLowerCase(), c = [], l = null;
463
461
  if (n !== void 0) {
464
462
  l = /* @__PURE__ */ new Set();
465
- let e = O(n);
463
+ let e = D(n);
466
464
  if (l.add(e), r) {
467
465
  let t = [e], n = /* @__PURE__ */ new Set();
468
466
  for (; t.length > 0;) {
@@ -478,10 +476,10 @@ var I = class e {
478
476
  if (c.length >= o) break;
479
477
  let t = e.value;
480
478
  if (l !== null) {
481
- let e = O(j(t));
479
+ let e = D(A(t));
482
480
  if (!l.has(e)) continue;
483
481
  }
484
- if (i === "file" && M(t) || i === "folder" && !M(t)) continue;
482
+ if (i === "file" && j(t) || i === "folder" && !j(t)) continue;
485
483
  let n = t.name ?? "";
486
484
  (a ? n : n.toLowerCase()).includes(s) && c.push({ ...t });
487
485
  }
@@ -509,7 +507,7 @@ var I = class e {
509
507
  return n;
510
508
  }
511
509
  }, L = class e {
512
- constructor(e = {}, t = D, n, r, i = new o(), a = N) {
510
+ constructor(e = {}, t = E, n, r, i = new o(), a = N) {
513
511
  this.views = /* @__PURE__ */ new Map(), this.maxViewsPerParent = 50;
514
512
  let s = g(e);
515
513
  this.strategy = {
@@ -533,7 +531,7 @@ var I = class e {
533
531
  return Date.now();
534
532
  }
535
533
  parentKey(e) {
536
- return O(e ?? null);
534
+ return D(e ?? null);
537
535
  }
538
536
  isExpired(e) {
539
537
  return e == null || this.ttl !== Infinity && this.now() - e > this.ttl;
@@ -542,13 +540,13 @@ var I = class e {
542
540
  return !e || e.some((e) => !t.getEntity(e) || t.isEntityStale(e, this.entityTtl));
543
541
  }
544
542
  isEntityTypeCompatible(e, t) {
545
- return !!(!t || t === "all" || t === "file" && !M(e) || t === "folder" && M(e));
543
+ return !!(!t || t === "all" || t === "file" && !j(e) || t === "folder" && j(e));
546
544
  }
547
545
  markViewStaleForReload(e) {
548
546
  e.view.meta = {
549
547
  ...e.view.meta ?? {},
550
548
  stale: !0
551
- }, e.view.updatedAt = this.now(), e.view.loadId = x(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
549
+ }, e.view.updatedAt = this.now(), e.view.loadId = M(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
552
550
  }
553
551
  cleanupOldViews(e) {
554
552
  if (e.size <= this.maxViewsPerParent) return;
@@ -582,11 +580,11 @@ var I = class e {
582
580
  };
583
581
  }
584
582
  if (l.view.promise) return l.view.promise;
585
- let d = x();
583
+ let d = M();
586
584
  l.view.loadId = d;
587
585
  let f = (async () => {
588
586
  try {
589
- let a = await n(e, t), o = A(t), s = o ? {
587
+ let a = await n(e, t), o = k(t), s = o ? {
590
588
  ...a,
591
589
  total: void 0
592
590
  } : a, u = this.views.get(i)?.get(F(t));
@@ -598,7 +596,7 @@ var I = class e {
598
596
  l.view.value = s.items.map((e) => e.id);
599
597
  let { items: f, ...p } = s, m = { ...p };
600
598
  l.view.meta = m, l.view.meta && (l.view.meta.stale = !1), this.failedRequests.delete(c), l.view.updatedAt = this.now(), !o && typeof m.total == "number" && (this.serverChildrenCountHandler ? this.serverChildrenCountHandler(e ?? null, m.total, r) : r.updateServerChildrenCount(e, m.total));
601
- let h = this.strategy.preloadPagesAfter ?? 0, g = this.strategy.preloadPagesBefore ?? 0, _ = k(t?.pageSize);
599
+ let h = this.strategy.preloadPagesAfter ?? 0, g = this.strategy.preloadPagesBefore ?? 0, _ = O(t?.pageSize);
602
600
  if ((h > 0 || g > 0) && Number.isFinite(_)) {
603
601
  let i = e, a = { ...t }, o = typeof m.totalPages == "number" ? m.totalPages : 1, s = t?.page ?? 1, c = _, l = n, u = d;
604
602
  setTimeout(() => {
@@ -709,7 +707,7 @@ var I = class e {
709
707
  syncTotalsInSameViews(e, t) {
710
708
  let n = t.view.meta;
711
709
  if (!n || typeof n.total != "number") return;
712
- let r = Number(n.total), i = k(t.params?.pageSize), a = Number.isFinite(i) && i > 0 ? Math.max(1, Math.ceil(r / i)) : void 0;
710
+ let r = Number(n.total), i = O(t.params?.pageSize), a = Number.isFinite(i) && i > 0 ? Math.max(1, Math.ceil(r / i)) : void 0;
713
711
  for (let [, n] of e) this.isParamsSame(n.params ?? {}, t.params ?? {}) && (n.view.meta || (n.view.meta = {}), n.view.meta.total = r, a !== void 0 && (n.view.meta.totalPages = a));
714
712
  }
715
713
  cascadeShiftPages(e, t, n, r, i, a, o) {
@@ -763,28 +761,26 @@ var I = class e {
763
761
  ...o,
764
762
  page: n + 1
765
763
  }, c = F(s), l = e.get(c), u = !1;
766
- if (!l?.view.value || this.isExpired(l.view.updatedAt)) {
767
- if (n >= i) {
768
- l = {
769
- params: s,
770
- view: {
771
- promise: null,
772
- value: void 0,
773
- meta: void 0,
774
- updatedAt: 0,
775
- loadId: null
776
- }
777
- }, e.set(c, l), this.cleanupOldViews(e);
778
- let r = t.view.meta;
779
- r && (l.view.meta = {
780
- ...r,
781
- page: n + 1
782
- }), u = !0;
783
- } else return t.view.meta = {
784
- ...t.view.meta ?? {},
785
- stale: !0
786
- }, !1;
787
- }
764
+ if (!l?.view.value || this.isExpired(l.view.updatedAt)) if (n >= i) {
765
+ l = {
766
+ params: s,
767
+ view: {
768
+ promise: null,
769
+ value: void 0,
770
+ meta: void 0,
771
+ updatedAt: 0,
772
+ loadId: null
773
+ }
774
+ }, e.set(c, l), this.cleanupOldViews(e);
775
+ let r = t.view.meta;
776
+ r && (l.view.meta = {
777
+ ...r,
778
+ page: n + 1
779
+ }), u = !0;
780
+ } else return t.view.meta = {
781
+ ...t.view.meta ?? {},
782
+ stale: !0
783
+ }, !1;
788
784
  let d = t.view.value.slice(r).filter((e) => a.getEntity(e));
789
785
  if (d.length === 0) return u && e.delete(c), !1;
790
786
  t.view.value = t.view.value.slice(0, r), t.view.updatedAt = Date.now(), l.view.value = [...d, ...l.view.value ?? []], l.view.updatedAt = Date.now();
@@ -828,7 +824,7 @@ var I = class e {
828
824
  ], e.view.updatedAt = this.now(), !0);
829
825
  }
830
826
  updateChildrenCountForOperation(e, t, n, r) {
831
- let i = j(t);
827
+ let i = A(t);
832
828
  switch (e) {
833
829
  case "delete":
834
830
  this.adjustChildrenCount(r, i, -1), this.childrenCountInvalidator?.(i);
@@ -837,7 +833,9 @@ var I = class e {
837
833
  case "copy":
838
834
  this.adjustChildrenCount(r, i, 1), this.childrenCountInvalidator?.(i);
839
835
  break;
840
- case "move": this.adjustChildrenCount(r, n ?? null, -1), this.adjustChildrenCount(r, i, 1), this.childrenCountInvalidator?.(n ?? null), this.childrenCountInvalidator?.(i);
836
+ case "move":
837
+ this.adjustChildrenCount(r, n ?? null, -1), this.adjustChildrenCount(r, i, 1), this.childrenCountInvalidator?.(n ?? null), this.childrenCountInvalidator?.(i);
838
+ break;
841
839
  }
842
840
  }
843
841
  adjustChildrenCount(e, t, n) {
@@ -853,14 +851,14 @@ var I = class e {
853
851
  this.updateChildrenCountForOperation(n, t, i, r);
854
852
  let o = this.parentKey(e), s = this.views.get(o);
855
853
  if (s) for (let [, e] of s) {
856
- let a = e.params ?? {}, o = a?.page ?? 1, c = k(a?.pageSize), l = Number.isFinite(c), u = !!(a?.sortBy || a?.sortOrder), d = !!a?.search, f = a?.itemType || "all";
854
+ let a = e.params ?? {}, o = a?.page ?? 1, c = O(a?.pageSize), l = Number.isFinite(c), u = !!(a?.sortBy || a?.sortOrder), d = !!a?.search, f = a?.itemType || "all";
857
855
  if (this.isEntityTypeCompatible(t, f)) {
858
856
  if (d && this.strategy.filterMatch && !this.strategy.filterMatch(t, e.params)) {
859
857
  e.view.value?.includes(t.id) && (e.view.value = e.view.value.filter((e) => e !== t.id), e.view.meta && typeof e.view.meta.total == "number" && (e.view.meta.total = Math.max(0, e.view.meta.total - 1)), this.markViewStaleForReload(e));
860
858
  continue;
861
859
  }
862
860
  if (!e.view.value) {
863
- e.view.meta && (e.view.meta.stale = !0), e.view.loadId = x(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
861
+ e.view.meta && (e.view.meta.stale = !0), e.view.loadId = M(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
864
862
  continue;
865
863
  }
866
864
  if (e.view.value.includes(t.id), this.shouldInvalidateCompletely(e, n, t, u, l, o)) {
@@ -878,7 +876,9 @@ var I = class e {
878
876
  case "update":
879
877
  this.handleUpdate(s, e, o, c, l, u, d, t, r);
880
878
  break;
881
- case "move": this.handleMove(s, e, o, c, l, u, t, i, r);
879
+ case "move":
880
+ this.handleMove(s, e, o, c, l, u, t, i, r);
881
+ break;
882
882
  }
883
883
  }
884
884
  }
@@ -908,28 +908,27 @@ var I = class e {
908
908
  t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
909
909
  }
910
910
  }
911
- t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
911
+ t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
912
912
  }
913
913
  handleInsert(e, t, n, r, i, a, o, s) {
914
914
  if (!t.view.value.includes(o.id)) {
915
- if (a && this.strategy.allowSortedInsert && this.strategy.comparator && s) {
916
- if (this.tryInsertSorted(t, o, s)) {
917
- if (t.view.meta && typeof t.view.meta.total == "number") {
918
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
919
- let e = r;
920
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
921
- }
922
- this.syncTotalsInSameViews(e, t);
915
+ if (a && this.strategy.allowSortedInsert && this.strategy.comparator && s) if (this.tryInsertSorted(t, o, s)) {
916
+ if (t.view.meta && typeof t.view.meta.total == "number") {
917
+ if (t.view.meta.total += 1, i && Number.isFinite(r)) {
918
+ let e = r;
919
+ e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
923
920
  }
924
- if (t.view.updatedAt = Date.now(), i && (t.view.value?.length ?? 0) > r && s) {
925
- let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
926
- if (this.cascadeShiftToNextPage(e, t, n, r, a, s, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
927
- let n = t.view.meta.totalPages + 1;
928
- t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
929
- }
921
+ this.syncTotalsInSameViews(e, t);
922
+ }
923
+ if (t.view.updatedAt = Date.now(), i && (t.view.value?.length ?? 0) > r && s) {
924
+ let i = t.view.meta, a = i && typeof i.totalPages == "number" ? i.totalPages : 1;
925
+ if (this.cascadeShiftToNextPage(e, t, n, r, a, s, t.params ?? {}) && t.view.meta && typeof t.view.meta.totalPages == "number") {
926
+ let n = t.view.meta.totalPages + 1;
927
+ t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
930
928
  }
931
- } else this.markViewStaleForReload(t);
932
- } else if (!i || t.view.value.length < r) {
929
+ }
930
+ } else this.markViewStaleForReload(t);
931
+ else if (!i || t.view.value.length < r) {
933
932
  if (t.view.value.push(o.id), t.view.meta && typeof t.view.meta.total == "number") {
934
933
  if (t.view.meta.total += 1, i && Number.isFinite(r)) {
935
934
  let e = r;
@@ -939,7 +938,7 @@ var I = class e {
939
938
  }
940
939
  t.view.updatedAt = Date.now();
941
940
  } else this.markViewStaleForReload(t);
942
- t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
941
+ t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
943
942
  }
944
943
  }
945
944
  handleUpdate(e, t, n, r, i, a, o, s, c) {
@@ -956,30 +955,29 @@ var I = class e {
956
955
  t.view.meta.totalPages = n, this.updateTotalPagesForAllViews(e, n);
957
956
  }
958
957
  }
959
- t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
958
+ t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
960
959
  return;
961
960
  }
962
961
  if (l && (a || o)) {
963
- t.view.value = t.view.value.filter((e) => e !== s.id), this.tryReinsertEntity(t, s, c, i, r) ? (t.view.updatedAt = Date.now(), t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0)) : this.markViewStaleForReload(t);
962
+ t.view.value = t.view.value.filter((e) => e !== s.id), this.tryReinsertEntity(t, s, c, i, r) ? (t.view.updatedAt = Date.now(), t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0)) : this.markViewStaleForReload(t);
964
963
  return;
965
964
  }
966
965
  if (l) {
967
- t.view.updatedAt = Date.now(), t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
966
+ t.view.updatedAt = Date.now(), t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
968
967
  return;
969
968
  }
970
969
  if (u && !o) {
971
- if (a && this.strategy.allowSortedInsert && this.strategy.comparator && c) {
972
- if (this.tryInsertSorted(t, s, c)) {
973
- if (t.view.meta && typeof t.view.meta.total == "number") {
974
- if (t.view.meta.total += 1, i && Number.isFinite(r)) {
975
- let e = r;
976
- e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
977
- }
978
- this.syncTotalsInSameViews(e, t);
970
+ if (a && this.strategy.allowSortedInsert && this.strategy.comparator && c) if (this.tryInsertSorted(t, s, c)) {
971
+ if (t.view.meta && typeof t.view.meta.total == "number") {
972
+ if (t.view.meta.total += 1, i && Number.isFinite(r)) {
973
+ let e = r;
974
+ e > 0 && (t.view.meta.totalPages = Math.max(1, Math.ceil(t.view.meta.total / e)));
979
975
  }
980
- t.view.updatedAt = Date.now();
981
- } else this.markViewStaleForReload(t);
982
- } else if (!i || t.view.value.length < r) {
976
+ this.syncTotalsInSameViews(e, t);
977
+ }
978
+ t.view.updatedAt = Date.now();
979
+ } else this.markViewStaleForReload(t);
980
+ else if (!i || t.view.value.length < r) {
983
981
  if (t.view.value.push(s.id), t.view.meta && typeof t.view.meta.total == "number") {
984
982
  if (t.view.meta.total += 1, i && Number.isFinite(r)) {
985
983
  let e = r;
@@ -989,7 +987,7 @@ var I = class e {
989
987
  }
990
988
  t.view.updatedAt = Date.now();
991
989
  } else this.markViewStaleForReload(t);
992
- t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
990
+ t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
993
991
  }
994
992
  }
995
993
  handleMove(e, t, n, r, i, a, o, s, c) {
@@ -1007,13 +1005,13 @@ var I = class e {
1007
1005
  }
1008
1006
  this.syncTotalsInSameViews(e, t);
1009
1007
  }
1010
- t.view.loadId = x(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
1008
+ t.view.loadId = M(), t.view.abortController && (t.view.abortController.abort(), t.view.abortController = void 0);
1011
1009
  }
1012
1010
  forceInvalidateChildrenViews(e) {
1013
1011
  let t = this.parentKey(e ?? null);
1014
1012
  this.failedRequests.clearChildrenViewErrorsForParent(t);
1015
1013
  let n = this.views.get(t);
1016
- if (n) for (let [, e] of n) e.view.value = void 0, e.view.meta = void 0, e.view.promise = null, e.view.updatedAt = 0, e.view.loadId = x(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
1014
+ if (n) for (let [, e] of n) e.view.value = void 0, e.view.meta = void 0, e.view.promise = null, e.view.updatedAt = 0, e.view.loadId = M(), e.view.abortController && (e.view.abortController.abort(), e.view.abortController = void 0);
1017
1015
  }
1018
1016
  getKnownTotal(e) {
1019
1017
  let t = this.parentKey(e ?? null), n = this.views.get(t);
@@ -1057,10 +1055,10 @@ var I = class e {
1057
1055
  }
1058
1056
  }, R = class e {
1059
1057
  invalidateChildrenCountCache(e) {
1060
- let t = O(e ?? "");
1058
+ let t = D(e ?? "");
1061
1059
  this.childrenCountPromises.delete(t), this.failedRequests.delete(o.childrenCountKey(t));
1062
1060
  }
1063
- constructor(e = {}, t = D, n, r) {
1061
+ constructor(e = {}, t = E, n, r) {
1064
1062
  this.childrenCountPromises = /* @__PURE__ */ new Map(), this.isFolderNotFoundError = r?.isFolderNotFoundError ?? N, this.failedRequests = new o(), this.ttl = r?.ttl ?? t, this.errorTtl = r?.errorTtl ?? n ?? this.ttl, this.entities = new I(), this.views = new L(e, this.ttl, this.errorTtl, void 0, this.failedRequests, this.isFolderNotFoundError), this.views.setServerChildrenCountHandler((e, t, n) => {
1065
1063
  this.handleServerReportedChildrenCount(e, t, n ?? this.entities);
1066
1064
  }), this.views.setChildrenCountInvalidator((e) => {
@@ -1080,7 +1078,7 @@ var I = class e {
1080
1078
  return this.views.getOrCreateChildren(e, t, n, this.entities);
1081
1079
  }
1082
1080
  upsertEntity(e) {
1083
- let t = this.entities.getEntity(e.id), n = t ? j(t) : null, r = j(e), i = t ? M(t) : !1, a = M(e);
1081
+ let t = this.entities.getEntity(e.id), n = t ? A(t) : null, r = A(e), i = t ? j(t) : !1, a = j(e);
1084
1082
  if (this.entities.upsertEntity(e), t) {
1085
1083
  if (n !== r || i !== a) {
1086
1084
  this.views.smartInvalidateChildrenViews(n, t, "delete", this.entities), this.views.smartInvalidateChildrenViews(r, e, "insert", this.entities);
@@ -1092,24 +1090,24 @@ var I = class e {
1092
1090
  isAncestor(e, t) {
1093
1091
  let n = t, r = /* @__PURE__ */ new Set();
1094
1092
  for (; n && !r.has(n);) {
1095
- if (r.add(n), O(n) === O(e)) return !0;
1093
+ if (r.add(n), D(n) === D(e)) return !0;
1096
1094
  let t = this.entities.getEntity(n);
1097
1095
  if (!t) break;
1098
- n = j(t), n === null && (n = E);
1096
+ n = A(t), n === null && (n = T);
1099
1097
  }
1100
1098
  return !1;
1101
1099
  }
1102
1100
  moveEntity(e, t) {
1103
1101
  let n = this.entities.getEntity(e);
1104
- if (!n || M(n) && t !== null && this.isAncestor(e, t)) return null;
1105
- let r = j(n), i = this.entities.moveEntityById(e, t);
1102
+ if (!n || j(n) && t !== null && this.isAncestor(e, t)) return null;
1103
+ let r = A(n), i = this.entities.moveEntityById(e, t);
1106
1104
  return i ? (this.views.smartInvalidateChildrenViews(r, n, "delete", this.entities), this.views.smartInvalidateChildrenViews(t, i, "insert", this.entities), i) : null;
1107
1105
  }
1108
1106
  copyEntity(e, t, n, r) {
1109
1107
  let i = this.entities.getEntity(e);
1110
1108
  if (!i) return null;
1111
1109
  let a = null;
1112
- if (M(i)) {
1110
+ if (j(i)) {
1113
1111
  let n = [e], i = [];
1114
1112
  for (; n.length;) {
1115
1113
  let e = n.shift();
@@ -1118,9 +1116,9 @@ var I = class e {
1118
1116
  for (let e of t) n.push(e);
1119
1117
  }
1120
1118
  let o = /* @__PURE__ */ new Map();
1121
- for (let e of i) o.set(e, x());
1119
+ for (let e of i) o.set(e, M());
1122
1120
  for (let n of i) {
1123
- let i = this.entities.getFolder(n), a = o.get(n), s = j(i), c = s === null ? t : o.get(s) ?? null, l = {
1121
+ let i = this.entities.getFolder(n), a = o.get(n), s = A(i), c = s === null ? t : o.get(s) ?? null, l = {
1124
1122
  ...i,
1125
1123
  ...n === e ? r : void 0,
1126
1124
  id: a,
@@ -1133,7 +1131,7 @@ var I = class e {
1133
1131
  for (let e of n) {
1134
1132
  let n = this.entities.getFileSystemItem(e);
1135
1133
  if (!n) continue;
1136
- let r = x(), i = {
1134
+ let r = M(), i = {
1137
1135
  ...n,
1138
1136
  id: r,
1139
1137
  folderId: t
@@ -1143,7 +1141,7 @@ var I = class e {
1143
1141
  }
1144
1142
  a = this.entities.getEntity(o.get(e)) ?? null;
1145
1143
  } else {
1146
- let i = n ?? x();
1144
+ let i = n ?? M();
1147
1145
  if (a = this.entities.copyFileSystemItem(e, i, t ?? null), a && r) {
1148
1146
  let e = {
1149
1147
  ...a,
@@ -1162,14 +1160,13 @@ var I = class e {
1162
1160
  deleteEntity(e) {
1163
1161
  let t = this.entities.getEntity(e);
1164
1162
  if (!t) return null;
1165
- if (M(t)) {
1163
+ if (j(t)) {
1166
1164
  let { deletedFolderRecords: n, deletedFileSystemItemRecords: r } = this.entities.deleteFolderRecursive(e);
1167
1165
  for (let e of r) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
1168
1166
  for (let e of n) this.views.smartInvalidateChildrenViews(e.folderId, e, "delete", this.entities);
1169
1167
  for (let e of n) this.views.forceInvalidateChildrenViews(e.id);
1170
1168
  return t;
1171
- }
1172
- {
1169
+ } else {
1173
1170
  let { entity: t, parentId: n } = this.entities.deleteEntityById(e);
1174
1171
  return t && this.views.smartInvalidateChildrenViews(n, t, "delete", this.entities), t;
1175
1172
  }
@@ -1191,7 +1188,7 @@ var I = class e {
1191
1188
  return;
1192
1189
  }
1193
1190
  let n = /* @__PURE__ */ new Set();
1194
- if (M(t)) {
1191
+ if (j(t)) {
1195
1192
  let t = [e];
1196
1193
  for (; t.length;) {
1197
1194
  let e = t.pop();
@@ -1215,7 +1212,7 @@ var I = class e {
1215
1212
  return this.entities.searchByName(e, t);
1216
1213
  }
1217
1214
  async getChildrenCount(e = "", t) {
1218
- let n = O(e), r = o.childrenCountKey(n), i = this.failedRequests.getFreshError(r, this.errorTtl);
1215
+ let n = D(e), r = o.childrenCountKey(n), i = this.failedRequests.getFreshError(r, this.errorTtl);
1219
1216
  if (i != null) return Promise.reject(i);
1220
1217
  let a = this.childrenCountPromises.get(n);
1221
1218
  if (a) return a;
@@ -1285,8 +1282,8 @@ var I = class e {
1285
1282
  let i = n.getFolder(r)?.childrenCount;
1286
1283
  i !== void 0 && i !== t && (console.warn(`Conflict: folder "${r}" has childrenCount=${i} but server says total=${t}`), this.views.forceInvalidateChildrenViews(r)), n.updateServerChildrenCount(r, t);
1287
1284
  }
1288
- }, ee = "", z = "Trash", B = "Edited", V = 1e4, H = 1e4, U = 25, W = 10;
1289
- function G(e, t) {
1285
+ }, ee = "", te = "Trash", ne = "Edited", z = 1e4, B = 1e4, V = 25, H = 10;
1286
+ function U(e, t) {
1290
1287
  let n = e ?? {}, r = Array.isArray(n.detailed) ? n.detailed.map((e) => ({
1291
1288
  requestId: e.requestId ?? e.id,
1292
1289
  success: !!e.success,
@@ -1299,30 +1296,30 @@ function G(e, t) {
1299
1296
  detailed: r
1300
1297
  };
1301
1298
  }
1302
- function K(e) {
1299
+ function W(e) {
1303
1300
  return e == null ? "" : String(e);
1304
1301
  }
1305
- function q(e) {
1302
+ function G(e) {
1306
1303
  return {
1307
1304
  ...e,
1308
- name: K(e.name)
1305
+ name: W(e.name)
1309
1306
  };
1310
1307
  }
1311
- function J(e) {
1312
- return (e ?? []).map(q);
1308
+ function K(e) {
1309
+ return (e ?? []).map(G);
1313
1310
  }
1314
- function Y(e) {
1311
+ function q(e) {
1315
1312
  return !e || typeof e != "object" || !("name" in e) ? e : {
1316
1313
  ...e,
1317
- name: K(e.name)
1314
+ name: W(e.name)
1318
1315
  };
1319
1316
  }
1320
- function X(e) {
1317
+ function J(e) {
1321
1318
  return e ? e.replaceAll("\\", "/").split("/").filter(Boolean) : [];
1322
1319
  }
1323
- var Z = class {
1320
+ for (var re = class {
1324
1321
  _getTrashPath() {
1325
- return this._pathOptions.trashPath || z;
1322
+ return this._pathOptions.trashPath || te;
1326
1323
  }
1327
1324
  _getPathLookupCandidates(e) {
1328
1325
  return y(e, this._getTrashPath(), _);
@@ -1335,7 +1332,7 @@ var Z = class {
1335
1332
  name: t.name || t.id,
1336
1333
  parentId: t.folderId
1337
1334
  };
1338
- return this._cache.upsertEntity(q({
1335
+ return this._cache.upsertEntity(G({
1339
1336
  id: r.id,
1340
1337
  name: r.name,
1341
1338
  folderId: r.parentId ?? null,
@@ -1349,8 +1346,8 @@ var Z = class {
1349
1346
  }
1350
1347
  }
1351
1348
  async _findOrCreateFolderByPath(t) {
1352
- let n = X(t);
1353
- if (n.length > W) throw new e("Path depth exceeds maximum limit of %s".replace("%s", String(W)), "ValidationError");
1349
+ let n = J(t);
1350
+ if (n.length > H) throw new e("Path depth exceeds maximum limit of %s".replace("%s", String(H)), "ValidationError");
1354
1351
  let r = await this._resolveFolderByPath(t);
1355
1352
  if (r) return r;
1356
1353
  let i;
@@ -1382,7 +1379,7 @@ var Z = class {
1382
1379
  return t;
1383
1380
  }
1384
1381
  async getTempFolder() {
1385
- let t = this._pathOptions.tempPath ?? B;
1382
+ let t = this._pathOptions.tempPath ?? ne;
1386
1383
  if (t) try {
1387
1384
  return await this._findOrCreateFolderByPath(t);
1388
1385
  } catch (t) {
@@ -1393,7 +1390,7 @@ var Z = class {
1393
1390
  }
1394
1391
  constructor(e, t = {}, n, r = {}) {
1395
1392
  this._dataProvider = e, this._options = t, this._pathOptions = n, this._blobFetchForceReloadOnceIds = /* @__PURE__ */ new Set(), this._mutationRegistry = new s(), this._mapItem = async ({ childrenCount: e, ...t }) => {
1396
- let n = q(t);
1393
+ let n = G(t);
1397
1394
  if (n.isFolder) return {
1398
1395
  ...n,
1399
1396
  childCount: e,
@@ -1532,7 +1529,7 @@ var Z = class {
1532
1529
  if (!this._dataProvider.pathMode) return null;
1533
1530
  let r = await this._getFileByPathStyleId(t);
1534
1531
  if (r && !r.isFolder) {
1535
- let e = q(r);
1532
+ let e = G(r);
1536
1533
  return this._cache.upsertEntity(e), await this._mapItem(e);
1537
1534
  }
1538
1535
  return null;
@@ -1547,14 +1544,14 @@ var Z = class {
1547
1544
  }
1548
1545
  async getFiles({ folderId: e, search: t, sortBy: n, sortOrder: r, page: i, limit: a, itemType: o = "all", noFolder: s = !1 }) {
1549
1546
  s && (e = (await this.getTempFolder())?.id);
1550
- let c = this.normalizeId(e ?? this._rootId), l = this._options.enablePagination === !1, u = l ? 1 : i, d = l ? V : a, f = this._options.clientSideFilter, p = this._options.clientSideSorting, m = this._options.clientSidePaging, h = m ? Math.max(1, i ?? 1) : void 0, g = m ? typeof a == "number" && Number.isFinite(a) && a > 0 ? a : U : void 0, _ = this._emptyFilesResult(m ? h : u, m ? g : d);
1547
+ let c = this.normalizeId(e ?? this._rootId), l = this._options.enablePagination === !1, u = l ? 1 : i, d = l ? z : a, f = this._options.clientSideFilter, p = this._options.clientSideSorting, m = this._options.clientSidePaging, h = m ? Math.max(1, i ?? 1) : void 0, g = m ? typeof a == "number" && Number.isFinite(a) && a > 0 ? a : V : void 0, _ = this._emptyFilesResult(m ? h : u, m ? g : d);
1551
1548
  if (this._isDeletingId(c)) return _;
1552
1549
  let v = this._options.unifiedCatalogFetch !== !1 && l && (o === "folder" || o === "file"), y = v ? "all" : o, b = {
1553
1550
  folderId: c,
1554
1551
  itemType: y
1555
1552
  };
1556
- f || (b.search = t), p || (b.sortBy = n ?? (y === "folder" ? void 0 : "date"), b.sortOrder = r ?? (y === "folder" ? void 0 : "desc")), m || (b.page = u, b.limit = v ? H : d);
1557
- let x = v ? H : m ? void 0 : d, S = {
1553
+ f || (b.search = t), p || (b.sortBy = n ?? (y === "folder" ? void 0 : "date"), b.sortOrder = r ?? (y === "folder" ? void 0 : "desc")), m || (b.page = u, b.limit = v ? B : d);
1554
+ let x = v ? B : m ? void 0 : d, S = {
1558
1555
  folderId: c,
1559
1556
  itemType: y,
1560
1557
  search: f ? void 0 : t,
@@ -1565,11 +1562,11 @@ var Z = class {
1565
1562
  }, C;
1566
1563
  try {
1567
1564
  C = await this._cache.getOrCreateChildren(c, S, async (e, t) => {
1568
- let n = t.pageSize, r = n != null && Number.isFinite(Number(n)) ? Number(n) : V, i = await this._dataProvider.getItems({
1565
+ let n = t.pageSize, r = n != null && Number.isFinite(Number(n)) ? Number(n) : z, i = await this._dataProvider.getItems({
1569
1566
  ...t,
1570
1567
  folderId: e,
1571
1568
  limit: r
1572
- }), a = J(i.items);
1569
+ }), a = K(i.items);
1573
1570
  return m ? {
1574
1571
  items: a,
1575
1572
  total: typeof i.pagination?.total == "number" ? i.pagination.total : a.length
@@ -1594,12 +1591,10 @@ var Z = class {
1594
1591
  let T;
1595
1592
  T = m || f || v ? w.length : C.total ?? w.length;
1596
1593
  let E = w;
1597
- if (m) {
1598
- if (typeof this._options.clientSidePaging == "function") E = this._options.clientSidePaging(w, h, g);
1599
- else {
1600
- let e = (h - 1) * g, t = e + g;
1601
- E = w.slice(e, t);
1602
- }
1594
+ if (m) if (typeof this._options.clientSidePaging == "function") E = this._options.clientSidePaging(w, h, g);
1595
+ else {
1596
+ let e = (h - 1) * g, t = e + g;
1597
+ E = w.slice(e, t);
1603
1598
  }
1604
1599
  if (typeof this._dataProvider.getUrl == "function" || typeof this._dataProvider.getThumbnailUrl == "function") {
1605
1600
  let e = E.map(async (e) => {
@@ -1665,7 +1660,7 @@ var Z = class {
1665
1660
  if (typeof this._dataProvider.findFileByUrl == "function") try {
1666
1661
  let t = await this._dataProvider.findFileByUrl(e);
1667
1662
  if (t) {
1668
- let e = q(t);
1663
+ let e = G(t);
1669
1664
  return this._cache.upsertEntity(e), e;
1670
1665
  }
1671
1666
  } catch (e) {
@@ -1683,7 +1678,7 @@ var Z = class {
1683
1678
  folderId: t,
1684
1679
  itemType: "all",
1685
1680
  page: 1,
1686
- limit: U
1681
+ limit: V
1687
1682
  });
1688
1683
  return e.pagination.total ?? e.files.length;
1689
1684
  }
@@ -1711,7 +1706,7 @@ var Z = class {
1711
1706
  let r = await this._dataProvider.uploadFile({
1712
1707
  ...t,
1713
1708
  folderId: n
1714
- }), i = q({
1709
+ }), i = G({
1715
1710
  name: t.name,
1716
1711
  size: t.size,
1717
1712
  ...r,
@@ -1749,10 +1744,10 @@ var Z = class {
1749
1744
  folderId: a,
1750
1745
  items: e
1751
1746
  });
1752
- o = G(t, (e) => {
1747
+ o = U(t, (e) => {
1753
1748
  if (e) return {
1754
1749
  id: e.id,
1755
- name: K(e.name),
1750
+ name: W(e.name),
1756
1751
  folderId: e.folderId,
1757
1752
  url: e.url,
1758
1753
  thumbnailUrl: e.thumbnailUrl,
@@ -1764,7 +1759,7 @@ var Z = class {
1764
1759
  for (let e = 0; e < o.detailed.length; e++) {
1765
1760
  let t = o.detailed[e];
1766
1761
  if (t && t.success) {
1767
- let r = t.data, i = r?.id ?? t.requestId, o = n?.[e]?.data, s = q({
1762
+ let r = t.data, i = r?.id ?? t.requestId, o = n?.[e]?.data, s = G({
1768
1763
  ...o,
1769
1764
  ...r,
1770
1765
  id: i,
@@ -1838,7 +1833,7 @@ var Z = class {
1838
1833
  detailed: []
1839
1834
  }, i = n.permanent ? null : await this.getTrashFolder();
1840
1835
  if (typeof this._dataProvider.deleteItems == "function") {
1841
- if (r = G(await this._dataProvider.deleteItems(t.map((e) => this._cache.getEntity(e)), n), (e) => e), r.success) {
1836
+ if (r = U(await this._dataProvider.deleteItems(t.map((e) => this._cache.getEntity(e)), n), (e) => e), r.success) {
1842
1837
  let e = r.detailed || t.map((e) => ({
1843
1838
  requestId: e,
1844
1839
  success: !0,
@@ -1896,7 +1891,7 @@ var Z = class {
1896
1891
  async createFolder({ name: t, parentId: n, is_force_create: r }) {
1897
1892
  let i = this.normalizeId(n ?? this._rootId);
1898
1893
  if (this._validateName(t, !0), this._validateDuplicates && this._checkNameExistsInCache(i, t, !0)) throw new e("Folder '%s' already exists in parent folder".replace("%s", t), "FolderAlreadyExists");
1899
- let a = await this._dataProvider.createFolder(t, i, r), o = q({
1894
+ let a = await this._dataProvider.createFolder(t, i, r), o = G({
1900
1895
  id: a.id,
1901
1896
  folderId: i,
1902
1897
  name: a.name,
@@ -1935,8 +1930,8 @@ var Z = class {
1935
1930
  let t = this.normalizeId(i.folderId);
1936
1931
  if (this._checkNameExistsInCache(t, n, !0, r)) throw new e("Folder '%s' already exists in parent folder".replace("%s", n), "FolderAlreadyExists");
1937
1932
  }
1938
- let a = Y(await this._dataProvider.renameItem(i, n));
1939
- return this._cache.upsertEntity(q({
1933
+ let a = q(await this._dataProvider.renameItem(i, n));
1934
+ return this._cache.upsertEntity(G({
1940
1935
  ...this._cache.getEntity(a.id),
1941
1936
  ...a
1942
1937
  })), this._cache.getEntity(a.id);
@@ -1950,8 +1945,8 @@ var Z = class {
1950
1945
  let t = this.normalizeId(r.folderId);
1951
1946
  if (this._checkNameExistsInCache(t, n, !1, i)) throw new e("File '%s' already exists in parent folder".replace("%s", n), "FileAlreadyExists");
1952
1947
  }
1953
- let a = Y(await this._dataProvider.renameItem(r, n));
1954
- return a && this._cache.upsertEntity(q({
1948
+ let a = q(await this._dataProvider.renameItem(r, n));
1949
+ return a && this._cache.upsertEntity(G({
1955
1950
  ...this._cache.getEntity(i),
1956
1951
  ...a
1957
1952
  })), this._cache.getEntity(i);
@@ -1962,12 +1957,12 @@ var Z = class {
1962
1957
  this._validateTargetFolderType(n);
1963
1958
  let a = this._cache.getEntity(t);
1964
1959
  if (!a) {
1965
- let e = Y(await this._dataProvider.moveItem({
1960
+ let e = q(await this._dataProvider.moveItem({
1966
1961
  id: t,
1967
1962
  folderId: i,
1968
1963
  isFolder: r
1969
1964
  }, i));
1970
- if (e.id === t) this._cache.upsertEntity(q({
1965
+ if (e.id === t) this._cache.upsertEntity(G({
1971
1966
  ...e,
1972
1967
  folderId: i
1973
1968
  }));
@@ -1975,7 +1970,7 @@ var Z = class {
1975
1970
  try {
1976
1971
  this._cache.deleteEntity(t);
1977
1972
  } catch {}
1978
- this._cache.upsertEntity(q({
1973
+ this._cache.upsertEntity(G({
1979
1974
  ...e,
1980
1975
  folderId: i
1981
1976
  }));
@@ -1990,17 +1985,16 @@ var Z = class {
1990
1985
  let t = a.isFolder ? "FolderAlreadyExists" : "FileAlreadyExists";
1991
1986
  throw new e(`${a.isFolder ? "Folder" : "File"} '${a.name}' already exists in target folder`, t);
1992
1987
  }
1993
- let o = Y(await this._dataProvider.moveItem(a, i));
1988
+ let o = q(await this._dataProvider.moveItem(a, i));
1994
1989
  if (o.id === t) {
1995
1990
  let e = this._cache.moveEntity(t, i);
1996
- return this._cache.upsertEntity(q({
1991
+ return this._cache.upsertEntity(G({
1997
1992
  ...e,
1998
1993
  ...o
1999
1994
  })), !0;
2000
- }
2001
- {
1995
+ } else {
2002
1996
  let e = this._cache.deleteEntity(t);
2003
- return this._cache.upsertEntity(q({
1997
+ return this._cache.upsertEntity(G({
2004
1998
  ...e,
2005
1999
  ...o,
2006
2000
  folderId: i
@@ -2025,7 +2019,7 @@ var Z = class {
2025
2019
  detailed: Array(i.length),
2026
2020
  success: !0
2027
2021
  };
2028
- if (typeof this._dataProvider.moveItems == "function") a = G(await this._dataProvider.moveItems(i, r), (e) => e);
2022
+ if (typeof this._dataProvider.moveItems == "function") a = U(await this._dataProvider.moveItems(i, r), (e) => e);
2029
2023
  else if (typeof this._dataProvider.moveItem == "function") a.detailed = await Promise.all(n.map(async (e, t) => {
2030
2024
  let n = i[t] || {
2031
2025
  id: e,
@@ -2036,7 +2030,7 @@ var Z = class {
2036
2030
  try {
2037
2031
  return {
2038
2032
  requestId: e,
2039
- data: Y(await this._dataProvider.moveItem(n, r)),
2033
+ data: q(await this._dataProvider.moveItem(n, r)),
2040
2034
  success: !0
2041
2035
  };
2042
2036
  } catch (t) {
@@ -2054,24 +2048,21 @@ var Z = class {
2054
2048
  success: !0,
2055
2049
  data: void 0
2056
2050
  }));
2057
- for (let t of e) if (t.success) {
2058
- if (!t.data || t.data.id === t.requestId) this._cache.moveEntity(t.requestId, r), t.data && this._cache.upsertEntity(q({
2059
- ...this._cache.getEntity(t.requestId),
2051
+ for (let t of e) if (t.success) if (!t.data || t.data.id === t.requestId) this._cache.moveEntity(t.requestId, r), t.data && this._cache.upsertEntity(G({
2052
+ ...this._cache.getEntity(t.requestId),
2053
+ ...t.data,
2054
+ folderId: r
2055
+ }));
2056
+ else {
2057
+ let e = this._cache.deleteEntity(t.requestId);
2058
+ this._cache.upsertEntity(G({
2059
+ ...e,
2060
2060
  ...t.data,
2061
2061
  folderId: r
2062
2062
  }));
2063
- else {
2064
- let e = this._cache.deleteEntity(t.requestId);
2065
- this._cache.upsertEntity(q({
2066
- ...e,
2067
- ...t.data,
2068
- folderId: r
2069
- }));
2070
- }
2071
2063
  }
2072
2064
  return a;
2073
- }
2074
- return {
2065
+ } else return {
2075
2066
  success: !1,
2076
2067
  error: a.error || new e("Move items failed", "MoveNotAllowed")
2077
2068
  };
@@ -2082,11 +2073,11 @@ var Z = class {
2082
2073
  this._validateTargetFolderType(n);
2083
2074
  let i = this._cache.getEntity(t);
2084
2075
  if (!i) {
2085
- let e = Y(await this._dataProvider.copyItem({
2076
+ let e = q(await this._dataProvider.copyItem({
2086
2077
  id: t,
2087
2078
  folderId: r
2088
2079
  }, r));
2089
- return this._cache.copyEntity(t, r, e.id), this._cache.upsertEntity(q({
2080
+ return this._cache.copyEntity(t, r, e.id), this._cache.upsertEntity(G({
2090
2081
  ...e,
2091
2082
  folderId: r
2092
2083
  })), !0;
@@ -2098,11 +2089,11 @@ var Z = class {
2098
2089
  throw new e(`${i.isFolder ? "Folder" : "File"} '${i.name}' already exists in target folder`, t);
2099
2090
  }
2100
2091
  }
2101
- let a = Y(await this._dataProvider.copyItem(i, r));
2092
+ let a = q(await this._dataProvider.copyItem(i, r));
2102
2093
  return this._cache.copyEntity(t, r, a.id, {
2103
2094
  ...a,
2104
2095
  folderId: r
2105
- }) || this._cache.upsertEntity(q({
2096
+ }) || this._cache.upsertEntity(G({
2106
2097
  ...a,
2107
2098
  folderId: r
2108
2099
  })), !0;
@@ -2131,7 +2122,7 @@ var Z = class {
2131
2122
  detailed: Array(o.length),
2132
2123
  success: !0
2133
2124
  };
2134
- if (typeof this._dataProvider.copyItems == "function") s = G(await this._dataProvider.copyItems(o, r), (e) => e);
2125
+ if (typeof this._dataProvider.copyItems == "function") s = U(await this._dataProvider.copyItems(o, r), (e) => e);
2135
2126
  else if (typeof this._dataProvider.copyItem == "function") s.detailed = await Promise.all(a.map(async (e, t) => {
2136
2127
  let n = o[t] || {
2137
2128
  id: e,
@@ -2141,7 +2132,7 @@ var Z = class {
2141
2132
  try {
2142
2133
  return {
2143
2134
  requestId: e,
2144
- data: Y(await this._dataProvider.copyItem(n, r)),
2135
+ data: q(await this._dataProvider.copyItem(n, r)),
2145
2136
  success: !0
2146
2137
  };
2147
2138
  } catch (t) {
@@ -2155,18 +2146,16 @@ var Z = class {
2155
2146
  else throw new e("Copy items is not supported", "CopyNotAllowed");
2156
2147
  if (s.success && s.detailed) for (let e = 0, t = s.detailed.length; e < t; e++) {
2157
2148
  let t = s.detailed[e];
2158
- if (t.success) {
2159
- if (t.data?.id) {
2160
- let e = t.data.folderId || r;
2161
- !this._cache.copyEntity(t.requestId, e, t.data.id, {
2162
- ...t.data,
2163
- folderId: e
2164
- }) && t.data && this._cache.upsertEntity(q({
2165
- ...t.data,
2166
- folderId: e
2167
- }));
2168
- } else console.error("batchResult in copy method must have ids");
2169
- }
2149
+ if (t.success) if (t.data?.id) {
2150
+ let e = t.data.folderId || r;
2151
+ !this._cache.copyEntity(t.requestId, e, t.data.id, {
2152
+ ...t.data,
2153
+ folderId: e
2154
+ }) && t.data && this._cache.upsertEntity(G({
2155
+ ...t.data,
2156
+ folderId: e
2157
+ }));
2158
+ } else console.error("batchResult in copy method must have ids");
2170
2159
  }
2171
2160
  else if (!s.detailed) throw new e("batchResult in copy method must have detailed results", "ValidationError");
2172
2161
  return s;
@@ -2181,7 +2170,7 @@ var Z = class {
2181
2170
  }
2182
2171
  let t = this.normalizeId(e.folderId ?? this._rootId);
2183
2172
  try {
2184
- let n = q({
2173
+ let n = G({
2185
2174
  ...await this._dataProvider.uploadFileByUrl(e.url, t, { eventSource: e.eventSource }),
2186
2175
  folderId: t
2187
2176
  });
@@ -2198,15 +2187,42 @@ var Z = class {
2198
2187
  let t = this.normalizeId(i.folderId);
2199
2188
  if (this._checkNameExistsInCache(t, n.name, !1, r)) throw new e("File '%s' already exists in parent folder".replace("%s", n.name), "FileAlreadyExists");
2200
2189
  }
2201
- let a = Y(await this._dataProvider.updateFile(i, { ...n }));
2202
- return this._cache.upsertEntity(q({
2190
+ let a = q(await this._dataProvider.updateFile(i, { ...n }));
2191
+ return this._cache.upsertEntity(G({
2203
2192
  ...this._cache.getEntity(r),
2204
2193
  ...a,
2205
2194
  ...n
2206
2195
  })), this._cache.getEntity(r);
2207
2196
  }
2208
- }, Q = "", te = "Trash", ne = class {
2209
- constructor(e, t = Q, n = _, r = te, i = !0) {
2197
+ }, Y = [], X = 0; X < 256; ++X) Y.push((X + 256).toString(16).slice(1));
2198
+ function ie(e, t = 0) {
2199
+ return (Y[e[t + 0]] + Y[e[t + 1]] + Y[e[t + 2]] + Y[e[t + 3]] + "-" + Y[e[t + 4]] + Y[e[t + 5]] + "-" + Y[e[t + 6]] + Y[e[t + 7]] + "-" + Y[e[t + 8]] + Y[e[t + 9]] + "-" + Y[e[t + 10]] + Y[e[t + 11]] + Y[e[t + 12]] + Y[e[t + 13]] + Y[e[t + 14]] + Y[e[t + 15]]).toLowerCase();
2200
+ }
2201
+ //#endregion
2202
+ //#region packages/file-manager/node_modules/uuid/dist/esm-browser/rng.js
2203
+ var Z, ae = /* @__PURE__ */ new Uint8Array(16);
2204
+ function oe() {
2205
+ if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z)) throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
2206
+ return Z(ae);
2207
+ }
2208
+ var Q = { randomUUID: typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto) };
2209
+ //#endregion
2210
+ //#region packages/file-manager/node_modules/uuid/dist/esm-browser/v4.js
2211
+ function se(e, t, n) {
2212
+ if (Q.randomUUID && !t && !e) return Q.randomUUID();
2213
+ e ||= {};
2214
+ var r = e.random || (e.rng || oe)();
2215
+ if (r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, t) {
2216
+ n ||= 0;
2217
+ for (var i = 0; i < 16; ++i) t[n + i] = r[i];
2218
+ return t;
2219
+ }
2220
+ return ie(r);
2221
+ }
2222
+ //#endregion
2223
+ //#region packages/file-manager/src/adapters/PathAwareStorageAdapter.ts
2224
+ var ce = "", le = "Trash", ue = class {
2225
+ constructor(e, t = ce, n = _, r = le, i = !0) {
2210
2226
  this._inner = e, this.rootPath = t, this.trashId = n, this.trashPath = r, this.ensureFolderTrailingSlash = i, this._pathToId = /* @__PURE__ */ new Map(), this._idToPath = /* @__PURE__ */ new Map(), this.validateDuplicates = this._inner.validateDuplicates ?? !1, typeof e.getUrl == "function" && (this.getUrl = (t) => e.getUrl({
2211
2227
  ...t,
2212
2228
  id: this.pathForId(t.id, !1),
@@ -2267,7 +2283,7 @@ var Z = class {
2267
2283
  let t = v(e);
2268
2284
  if (t === v(this.trashPath)) return this.trashId;
2269
2285
  if (this._pathToId.has(t)) return this._pathToId.get(t);
2270
- let n = x();
2286
+ let n = se();
2271
2287
  return this._pathToId.set(t, n), this._idToPath.set(n, t), n;
2272
2288
  }
2273
2289
  pathForId(t, n, r) {
@@ -2666,15 +2682,15 @@ var Z = class {
2666
2682
  };
2667
2683
  //#endregion
2668
2684
  //#region packages/file-manager/src/utils/directResourceFetchError.ts
2669
- function re(e) {
2685
+ function de(e) {
2670
2686
  return typeof e != "object" || !e ? !1 : "name" in e && e.name === "DirectResourceFetchError" ? !("final" in e) || e.final !== !1 : "final" in e && e.final === !0;
2671
2687
  }
2672
2688
  //#endregion
2673
2689
  //#region packages/file-manager/src/utils/remoteFileFetchPipeline.ts
2674
2690
  function $(t) {
2675
- if (re(t) || t instanceof e) throw t;
2691
+ if (de(t) || t instanceof e) throw t;
2676
2692
  }
2677
- async function ie(e, t, n, r, i) {
2693
+ async function fe(e, t, n, r, i) {
2678
2694
  let { fetchWithProxy: a, handleFileProxy: o, handleProxyUrl: s } = t, c = {
2679
2695
  mode: "cors",
2680
2696
  ...i?.fetchInit
@@ -2706,6 +2722,6 @@ async function ie(e, t, n, r, i) {
2706
2722
  throw l instanceof Error ? l : /* @__PURE__ */ Error("Failed to download file from the URL");
2707
2723
  }
2708
2724
  //#endregion
2709
- export { D as DEFAULT_FILE_MANAGER_CACHE_TTL_MS, Z as DataSourceProxyBase, o as FailedRequestCache, e as FileManagerApiError, s as MutationRegistry, ne as PathAwareStorageAdapter, _ as TRASH_FOLDER_ID, R as TreeCache, L as ViewCacheManager, i as buildAssetsPath, l as compareFileSystemItems, b as createSystemFolderByPathResolver, m as defaultChildrenViewFilterMatch, p as defaultFileSystemItemComparator, h as defaultHasSortValue, N as defaultIsFolderNotFoundError, ie as fetchRemoteImageBlobByUrl, r as getAssetsBase, y as getTrashFolderLookupCandidates, d as hasComparableSortValue, n as joinUrls, t as mapHttpStatusToErrorCode, f as matchesChildrenViewFilter, v as normalizeSystemFolderPath, c as resolveSortParams, g as resolveViewStrategyOptions };
2725
+ export { E as DEFAULT_FILE_MANAGER_CACHE_TTL_MS, re as DataSourceProxyBase, o as FailedRequestCache, e as FileManagerApiError, s as MutationRegistry, ue as PathAwareStorageAdapter, _ as TRASH_FOLDER_ID, R as TreeCache, L as ViewCacheManager, i as buildAssetsPath, l as compareFileSystemItems, b as createSystemFolderByPathResolver, m as defaultChildrenViewFilterMatch, p as defaultFileSystemItemComparator, h as defaultHasSortValue, N as defaultIsFolderNotFoundError, fe as fetchRemoteImageBlobByUrl, r as getAssetsBase, y as getTrashFolderLookupCandidates, d as hasComparableSortValue, n as joinUrls, t as mapHttpStatusToErrorCode, f as matchesChildrenViewFilter, v as normalizeSystemFolderPath, c as resolveSortParams, g as resolveViewStrategyOptions };
2710
2726
 
2711
2727
  //# sourceMappingURL=core.esm.js.map