@scaleflex/dam-core 0.3.2 → 0.4.1

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 (35) hide show
  1. package/dist/api/files.service.d.ts +12 -1
  2. package/dist/api/files.service.d.ts.map +1 -1
  3. package/dist/api/folders.service.d.ts +1 -1
  4. package/dist/api/folders.service.d.ts.map +1 -1
  5. package/dist/api/index.d.ts +1 -1
  6. package/dist/api/index.d.ts.map +1 -1
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.js +389 -372
  10. package/dist/index.js.map +1 -1
  11. package/dist/store/browse-store.d.ts +4 -2
  12. package/dist/store/browse-store.d.ts.map +1 -1
  13. package/dist/types/api.types.d.ts +7 -1
  14. package/dist/types/api.types.d.ts.map +1 -1
  15. package/dist/types/asset.types.d.ts +2 -0
  16. package/dist/types/asset.types.d.ts.map +1 -1
  17. package/package.json +1 -1
  18. package/dist/api/archive.test.d.ts +0 -2
  19. package/dist/api/archive.test.d.ts.map +0 -1
  20. package/dist/api/files.service.test.d.ts +0 -2
  21. package/dist/api/files.service.test.d.ts.map +0 -1
  22. package/dist/api/variations.service.test.d.ts +0 -2
  23. package/dist/api/variations.service.test.d.ts.map +0 -1
  24. package/dist/auth/auth.service.test.d.ts +0 -2
  25. package/dist/auth/auth.service.test.d.ts.map +0 -1
  26. package/dist/helpers/cdn.test.d.ts +0 -2
  27. package/dist/helpers/cdn.test.d.ts.map +0 -1
  28. package/dist/helpers/format.test.d.ts +0 -2
  29. package/dist/helpers/format.test.d.ts.map +0 -1
  30. package/dist/helpers/thumbnail.test.d.ts +0 -2
  31. package/dist/helpers/thumbnail.test.d.ts.map +0 -1
  32. package/dist/helpers/variations.test.d.ts +0 -2
  33. package/dist/helpers/variations.test.d.ts.map +0 -1
  34. package/dist/store/browse-store.test.d.ts +0 -2
  35. package/dist/store/browse-store.test.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- const N = "https://api.filerobot.com";
2
- function B(s) {
3
- return s === 404 || s === 408 || s === 429 || s >= 500;
1
+ const B = "https://api.filerobot.com";
2
+ function G(t) {
3
+ return t === 404 || t === 408 || t === 429 || t >= 500;
4
4
  }
5
- const G = (s) => new Promise((e) => setTimeout(e, s));
6
- function M(s, e) {
7
- return `${(e || N).replace(/\/+$/, "")}/${s}`;
5
+ const W = (t) => new Promise((e) => setTimeout(e, t));
6
+ function M(t, e) {
7
+ return `${(e || B).replace(/\/+$/, "")}/${t}`;
8
8
  }
9
- async function W(s, e, t, i = {}) {
10
- const r = `${M(s, t)}/key/${encodeURIComponent(e)}`, o = i.retries ?? 2, l = i.retryDelayMs ?? 400;
9
+ async function X(t, e, s, i = {}) {
10
+ const r = `${M(t, s)}/key/${encodeURIComponent(e)}`, o = i.retries ?? 2, l = i.retryDelayMs ?? 400;
11
11
  let a = new Error("SASS key exchange failed");
12
12
  for (let c = 0; c <= o; c++) {
13
- c > 0 && await G(l * c);
13
+ c > 0 && await W(l * c);
14
14
  const f = new AbortController(), h = setTimeout(() => f.abort(), 3e4);
15
15
  try {
16
16
  const d = await fetch(r, { signal: f.signal, cache: "no-store" });
17
17
  if (clearTimeout(h), !d.ok) {
18
- if (a = new Error(`SASS key exchange failed (HTTP ${d.status})`), B(d.status) && c < o) continue;
18
+ if (a = new Error(`SASS key exchange failed (HTTP ${d.status})`), G(d.status) && c < o) continue;
19
19
  throw a;
20
20
  }
21
21
  const u = await d.json();
@@ -34,71 +34,71 @@ async function W(s, e, t, i = {}) {
34
34
  }
35
35
  throw a;
36
36
  }
37
- function T(s, e) {
38
- const t = {};
39
- switch (s.mode) {
37
+ function T(t, e) {
38
+ const s = {};
39
+ switch (t.mode) {
40
40
  case "security-template":
41
41
  if (!e)
42
42
  throw new Error(
43
43
  "[dam-core] Cannot build auth headers for security-template mode: SASS key exchange has not been performed. Call resolveAuth() first, or use sass-key mode."
44
44
  );
45
- t["X-Filerobot-Key"] = e;
45
+ s["X-Filerobot-Key"] = e;
46
46
  break;
47
47
  case "sass-key":
48
- t["X-Filerobot-Key"] = s.sassKey;
48
+ s["X-Filerobot-Key"] = t.sassKey;
49
49
  break;
50
50
  }
51
- return s.airboxPuid && (t["X-Filerobot-Airbox-Puid"] = s.airboxPuid), t;
51
+ return t.airboxPuid && (s["X-Filerobot-Airbox-Puid"] = t.airboxPuid), s;
52
52
  }
53
- function X(s) {
54
- return s.mode === "securityTemplate" || s.mode === "sassKey";
53
+ function V(t) {
54
+ return t.mode === "securityTemplate" || t.mode === "sassKey";
55
55
  }
56
- function V(s) {
57
- return X(s) ? s.mode === "securityTemplate" ? {
56
+ function H(t) {
57
+ return V(t) ? t.mode === "securityTemplate" ? {
58
58
  mode: "security-template",
59
- container: s.projectToken,
60
- securityTemplateId: s.securityTemplateKey,
61
- airboxPuid: s.airboxPuid
59
+ container: t.projectToken,
60
+ securityTemplateId: t.securityTemplateKey,
61
+ airboxPuid: t.airboxPuid
62
62
  } : {
63
63
  mode: "sass-key",
64
- container: s.projectToken,
65
- sassKey: s.sassKey,
66
- airboxPuid: s.airboxPuid
67
- } : s;
64
+ container: t.projectToken,
65
+ sassKey: t.sassKey,
66
+ airboxPuid: t.airboxPuid
67
+ } : t;
68
68
  }
69
- async function I(s, e) {
70
- const t = V(s), i = M(t.container, e);
71
- if (t.mode === "security-template") {
72
- const r = await W(t.container, t.securityTemplateId, e);
73
- return { apiBase: i, headers: T(t, r), sassKey: r };
69
+ async function I(t, e) {
70
+ const s = H(t), i = M(s.container, e);
71
+ if (s.mode === "security-template") {
72
+ const r = await X(s.container, s.securityTemplateId, e);
73
+ return { apiBase: i, headers: T(s, r), sassKey: r };
74
74
  }
75
- return { apiBase: i, headers: T(t) };
75
+ return { apiBase: i, headers: T(s) };
76
76
  }
77
- const H = 3e4;
78
- class O {
79
- constructor(e, t, i) {
80
- this.baseUrl = `${e.apiBase}/v5`, this.headers = e.headers, this.auth = t, this.apiDomain = i;
77
+ const J = 3e4;
78
+ class R {
79
+ constructor(e, s, i) {
80
+ this.baseUrl = `${e.apiBase}/v5`, this.headers = e.headers, this.auth = s, this.apiDomain = i;
81
81
  }
82
82
  /** Resolve an AuthConfig (performing key exchange if needed) and build a client. */
83
- static async create(e, t) {
84
- const i = await I(e, t);
85
- return new O(i, e, t);
83
+ static async create(e, s) {
84
+ const i = await I(e, s);
85
+ return new R(i, e, s);
86
86
  }
87
- get(e, t) {
87
+ get(e, s) {
88
88
  const i = new URL(`${this.baseUrl}${e}`);
89
- if (t)
90
- for (const [r, o] of Object.entries(t))
89
+ if (s)
90
+ for (const [r, o] of Object.entries(s))
91
91
  o != null && i.searchParams.set(r, Array.isArray(o) ? o.join(",") : String(o));
92
92
  return this.send(i, { method: "GET" });
93
93
  }
94
- post(e, t) {
95
- return this.sendJson("POST", e, t);
94
+ post(e, s) {
95
+ return this.sendJson("POST", e, s);
96
96
  }
97
- put(e, t) {
98
- return this.sendJson("PUT", e, t);
97
+ put(e, s) {
98
+ return this.sendJson("PUT", e, s);
99
99
  }
100
- delete(e, t) {
101
- return this.sendJson("DELETE", e, t);
100
+ delete(e, s) {
101
+ return this.sendJson("DELETE", e, s);
102
102
  }
103
103
  /**
104
104
  * Absolute REST URL (incl. the `/v5` base) for a path — for building direct
@@ -111,25 +111,25 @@ class O {
111
111
  get authKey() {
112
112
  return this.headers["X-Filerobot-Key"];
113
113
  }
114
- sendJson(e, t, i) {
115
- return this.send(new URL(`${this.baseUrl}${t}`), {
114
+ sendJson(e, s, i) {
115
+ return this.send(new URL(`${this.baseUrl}${s}`), {
116
116
  method: e,
117
117
  headers: { "Content-Type": "application/json" },
118
118
  body: i === void 0 ? void 0 : JSON.stringify(i)
119
119
  });
120
120
  }
121
- async send(e, t, i = !1) {
121
+ async send(e, s, i = !1) {
122
122
  var l;
123
- const r = new AbortController(), o = setTimeout(() => r.abort(), H);
123
+ const r = new AbortController(), o = setTimeout(() => r.abort(), J);
124
124
  try {
125
125
  const a = await fetch(e.toString(), {
126
- ...t,
127
- headers: { ...this.headers, ...t.headers },
126
+ ...s,
127
+ headers: { ...this.headers, ...s.headers },
128
128
  signal: r.signal
129
129
  });
130
130
  if (clearTimeout(o), a.status === 401 && !i && ((l = this.auth) == null ? void 0 : l.mode) === "security-template") {
131
131
  const h = await I(this.auth, this.apiDomain);
132
- return this.headers = h.headers, this.send(e, t, !0);
132
+ return this.headers = h.headers, this.send(e, s, !0);
133
133
  }
134
134
  if (!a.ok) {
135
135
  let h = `API error: ${a.status} ${a.statusText}`;
@@ -152,50 +152,51 @@ class O {
152
152
  }
153
153
  }
154
154
  }
155
- function J(s) {
156
- const e = s.path ?? s.name, t = e.replace(/\/[^/]*$/, "") || "/";
155
+ function O(t) {
156
+ const e = t.path ?? t.name, s = e.replace(/\/[^/]*$/, "") || "/";
157
157
  return {
158
- uuid: s.uuid,
159
- name: s.name.split("/").pop() || s.name,
158
+ uuid: t.uuid,
159
+ name: t.name.split("/").pop() || t.name,
160
160
  path: e,
161
- parentPath: t,
162
- createdAt: s.created_at,
163
- modifiedAt: s.modified_at
161
+ parentPath: s,
162
+ createdAt: t.created_at,
163
+ modifiedAt: t.modified_at
164
164
  };
165
165
  }
166
- async function b(s, e = {}) {
167
- const t = e.sortBy ?? "name", i = e.sortDirection ?? "asc";
168
- return ((await s.get("/folders", {
166
+ async function b(t, e = {}) {
167
+ const s = e.sortBy ?? "name", i = e.sortDirection ?? "asc";
168
+ return ((await t.get("/folders", {
169
169
  folder: e.folderPath ?? "/",
170
170
  recursive: e.recursive ?? 0,
171
171
  limit: e.limit ?? 1e3,
172
172
  offset: e.offset ?? 0,
173
173
  q: e.q,
174
- sort: `${t}:${i}`
175
- })).folders ?? []).map(J);
174
+ sort: `${s}:${i}`
175
+ })).folders ?? []).map(O);
176
176
  }
177
- async function K(s, e, t) {
178
- const i = t.replace(/\/+$/, ""), r = i ? `${i}/${e}` : `/${e}`, o = await s.post("/folders", { name: r });
179
- if (o.status !== "success") throw new Error(o.msg || "Failed to create folder");
177
+ async function K(t, e, s) {
178
+ const i = s.replace(/\/+$/, ""), r = i ? `${i}/${e}` : `/${e}`, o = await t.post("/folders", { name: r });
179
+ if (o.status !== "success" || !o.folder) throw new Error(o.msg || "Failed to create folder");
180
+ return O(o.folder);
180
181
  }
181
- async function Y(s, e, t) {
182
- const i = await s.put(`/folder/${encodeURIComponent(e)}/name`, {
183
- name: t
182
+ async function Y(t, e, s) {
183
+ const i = await t.put(`/folder/${encodeURIComponent(e)}/name`, {
184
+ name: s
184
185
  });
185
186
  if ((i == null ? void 0 : i.status) === "error") throw new Error(i.msg || "Failed to rename folder");
186
187
  }
187
- async function Z(s, e) {
188
- const t = await s.delete("/folders", { folders_uuids: e });
189
- if ((t == null ? void 0 : t.status) === "error") throw new Error(t.msg || "Failed to delete folders");
188
+ async function Z(t, e) {
189
+ const s = await t.delete("/folders", { folders_uuids: e });
190
+ if ((s == null ? void 0 : s.status) === "error") throw new Error(s.msg || "Failed to delete folders");
190
191
  }
191
- async function Q(s, e, t) {
192
- const i = await s.post("/folders", {
192
+ async function Q(t, e, s) {
193
+ const i = await t.post("/folders", {
193
194
  folders_uuids: e,
194
- new_folder_name: t
195
+ new_folder_name: s
195
196
  });
196
197
  if ((i == null ? void 0 : i.status) === "error") throw new Error(i.msg || "Failed to move folders");
197
198
  }
198
- const R = {
199
+ const L = {
199
200
  small: [null, 1048576],
200
201
  // < 1 MB
201
202
  medium: [1048576, 10485760],
@@ -210,67 +211,72 @@ const R = {
210
211
  month: 30,
211
212
  year: 365
212
213
  };
213
- function y(s, e) {
214
- const t = new Date(e);
215
- return t.setUTCHours(0, 0, 0, 0), t.setUTCDate(t.getUTCDate() - ee[s]), t;
214
+ function y(t, e) {
215
+ const s = new Date(e);
216
+ return s.setUTCHours(0, 0, 0, 0), s.setUTCDate(s.getUTCDate() - ee[t]), s;
216
217
  }
217
- const L = ["cdn_permalink"], F = {}, m = (s, e) => e.split(" ").forEach((t) => F[t] = s);
218
+ const z = ["cdn_permalink"], F = {}, m = (t, e) => e.split(" ").forEach((s) => F[s] = t);
218
219
  m("image", "jpg jpeg png gif webp svg avif bmp tif tiff heic ico");
219
220
  m("video", "mp4 webm mov m4v avi mkv ogv");
220
221
  m("audio", "mp3 wav ogg oga m4a aac flac");
221
222
  m("document", "pdf doc docx xls xlsx ppt pptx txt csv rtf md");
222
223
  m("model", "glb gltf obj fbx stl usdz ply 3ds dae");
223
- function te(s) {
224
- const e = (s.name.split(".").pop() || "").toLowerCase();
224
+ function te(t) {
225
+ const e = (t.name.split(".").pop() || "").toLowerCase();
225
226
  if (F[e] === "model") return "model";
226
- const t = (s.file_type || s.type || "").toLowerCase();
227
- return t.startsWith("image") ? "image" : t.startsWith("video") ? "video" : t.startsWith("audio") ? "audio" : t.includes("pdf") || t.includes("document") || t.includes("text") ? "document" : F[e] ?? "other";
227
+ const s = (t.file_type || t.type || "").toLowerCase();
228
+ return s.startsWith("image") ? "image" : s.startsWith("video") ? "video" : s.startsWith("audio") ? "audio" : s.includes("pdf") || s.includes("document") || s.includes("text") ? "document" : F[e] ?? "other";
228
229
  }
229
- function z(s) {
230
- var e, t, i, r, o;
230
+ function q(t) {
231
+ var e, s, i, r, o, l, a;
231
232
  return {
232
- uuid: s.uuid,
233
- name: s.name,
234
- folder: s.folder ?? "/",
235
- type: te(s),
236
- fileType: s.file_type ?? s.type,
237
- cdnUrl: s.cdn_permalink ?? s.cdn_url,
238
- thumbnailUrl: ((e = s.info) == null ? void 0 : e.video_thumbnail) ?? ((t = s.info) == null ? void 0 : t.image_thumbnail) ?? ((i = s.info) == null ? void 0 : i.thumbnail) ?? ((r = s.info) == null ? void 0 : r.preview),
233
+ uuid: t.uuid,
234
+ name: t.name,
235
+ folder: t.folder ?? "/",
236
+ type: te(t),
237
+ fileType: t.file_type ?? t.type,
238
+ cdnUrl: t.cdn_permalink ?? t.cdn_url,
239
+ thumbnailUrl: ((e = t.info) == null ? void 0 : e.video_thumbnail) ?? ((s = t.info) == null ? void 0 : s.image_thumbnail) ?? ((i = t.info) == null ? void 0 : i.thumbnail) ?? ((r = t.info) == null ? void 0 : r.preview),
239
240
  // Live API returns `size: { bytes, pretty }`; tolerate a plain number too.
240
- size: typeof s.size == "object" ? (o = s.size) == null ? void 0 : o.bytes : s.size,
241
- width: s.width,
242
- height: s.height,
243
- createdAt: s.created_at,
244
- modifiedAt: s.modified_at
241
+ size: typeof t.size == "object" ? (o = t.size) == null ? void 0 : o.bytes : t.size,
242
+ duration: ((l = t.info) == null ? void 0 : l.video_duration) ?? ((a = t.info) == null ? void 0 : a.duration),
243
+ width: t.width,
244
+ height: t.height,
245
+ createdAt: t.created_at,
246
+ modifiedAt: t.modified_at
245
247
  };
246
248
  }
247
- function se(s) {
249
+ function se(t) {
248
250
  var l;
249
- const e = s.fields ?? L, t = s.sortBy ?? "created_at", i = s.sortDirection ?? "desc", r = [];
250
- if (s.search && r.push(s.search), s.q && r.push(s.q), (l = s.types) != null && l.length && r.push(`type:${s.types.map((a) => `"${a}"`).join(",")}`), s.sizeBucket) {
251
- const [a, c] = R[s.sizeBucket];
251
+ const e = t.fields ?? z, s = t.sortBy ?? "created_at", i = t.sortDirection ?? "desc", r = [];
252
+ if (t.search && r.push(t.search), t.q && r.push(t.q), (l = t.types) != null && l.length && r.push(`type:${t.types.map((a) => `"${a}"`).join(",")}`), t.sizeBucket) {
253
+ const [a, c] = L[t.sizeBucket];
252
254
  r.push(`size:"${a ?? ""}..${c ?? ""}"`);
253
255
  }
256
+ if (t.durationRange) {
257
+ const { min: a, max: c } = t.durationRange;
258
+ (a != null || c != null) && r.push(`video_duration:"${a ?? ""}..${c ?? ""}"`);
259
+ }
254
260
  const o = Date.now();
255
- return s.createdWithin && r.push(`created>"${y(s.createdWithin, o).toISOString()}"`), s.updatedWithin && r.push(`updated>"${y(s.updatedWithin, o).toISOString()}"`), {
256
- offset: s.offset ?? 0,
257
- limit: s.limit ?? 100,
261
+ return t.createdWithin && r.push(`created>"${y(t.createdWithin, o).toISOString()}"`), t.updatedWithin && r.push(`updated>"${y(t.updatedWithin, o).toISOString()}"`), {
262
+ offset: t.offset ?? 0,
263
+ limit: t.limit ?? 100,
258
264
  format: "json,regvar:api,select:internal",
259
265
  preview: 2301,
260
266
  // Filerobot preview-size preset for thumbnails
261
- recursive: s.recursive ?? 1,
267
+ recursive: t.recursive ?? 1,
262
268
  fields: e.length ? e : void 0,
263
- sort: `${t}:${i}`,
264
- folder: s.folder,
269
+ sort: `${s}:${i}`,
270
+ folder: t.folder,
265
271
  q: r.length ? r.join(" ") : void 0
266
272
  };
267
273
  }
268
- async function w(s, e = {}) {
269
- const t = se(e), i = await s.get("/files", t), r = (i.files ?? []).map(z), o = typeof i.total == "number" ? i.total : i.count ?? r.length;
274
+ async function w(t, e = {}) {
275
+ const s = se(e), i = await t.get("/files", s), r = (i.files ?? []).map(q), o = typeof i.total == "number" ? i.total : i.count ?? r.length;
270
276
  return { assets: r, total: o };
271
277
  }
272
- async function $e(s, e = {}) {
273
- return (await w(s, e)).assets;
278
+ async function $e(t, e = {}) {
279
+ return (await w(t, e)).assets;
274
280
  }
275
281
  const ie = {
276
282
  image: "image",
@@ -283,17 +289,21 @@ const ie = {
283
289
  font: "other",
284
290
  other: "other"
285
291
  };
286
- function re(s, e, t) {
292
+ function re(t, e, s) {
287
293
  var i;
288
- if ((i = e.types) != null && i.length && !e.types.includes(ie[s.type])) return !1;
294
+ if ((i = e.types) != null && i.length && !e.types.includes(ie[t.type])) return !1;
289
295
  if (e.sizeBucket) {
290
- const [r, o] = R[e.sizeBucket];
291
- if (s.size == null || r != null && s.size < r || o != null && s.size >= o) return !1;
296
+ const [r, o] = L[e.sizeBucket];
297
+ if (t.size == null || r != null && t.size < r || o != null && t.size >= o) return !1;
298
+ }
299
+ if (e.durationRange) {
300
+ const { min: r, max: o } = e.durationRange;
301
+ if (t.duration == null || r != null && t.duration < r || o != null && t.duration > o) return !1;
292
302
  }
293
- return !(e.createdWithin && !((s.createdAt ? Date.parse(s.createdAt) : NaN) >= y(e.createdWithin, t).getTime()) || e.updatedWithin && !((s.modifiedAt ? Date.parse(s.modifiedAt) : NaN) >= y(e.updatedWithin, t).getTime()));
303
+ return !(e.createdWithin && !((t.createdAt ? Date.parse(t.createdAt) : NaN) >= y(e.createdWithin, s).getTime()) || e.updatedWithin && !((t.modifiedAt ? Date.parse(t.modifiedAt) : NaN) >= y(e.updatedWithin, s).getTime()));
294
304
  }
295
- function ne(s, e, t) {
296
- const i = t === "asc" ? 1 : -1, r = (o) => {
305
+ function ne(t, e, s) {
306
+ const i = s === "asc" ? 1 : -1, r = (o) => {
297
307
  var l;
298
308
  switch (e) {
299
309
  case "name":
@@ -308,173 +318,173 @@ function ne(s, e, t) {
308
318
  return o.createdAt ? Date.parse(o.createdAt) : 0;
309
319
  }
310
320
  };
311
- return [...s].sort((o, l) => {
321
+ return [...t].sort((o, l) => {
312
322
  const a = r(o), c = r(l);
313
323
  return a < c ? -i : a > c ? i : 0;
314
324
  });
315
325
  }
316
- async function oe(s, e, t = {}) {
317
- const i = t.fields ?? L, r = new Array(e.length);
326
+ async function oe(t, e, s = {}) {
327
+ const i = s.fields ?? z, r = new Array(e.length);
318
328
  let o = 0;
319
329
  const l = async () => {
320
330
  for (; o < e.length; ) {
321
331
  const c = o++;
322
332
  try {
323
- const f = await s.get(`/file/${encodeURIComponent(e[c])}`, {
333
+ const f = await t.get(`/file/${encodeURIComponent(e[c])}`, {
324
334
  format: "json,regvar:api,select:internal",
325
335
  preview: 2301,
326
336
  fields: i.length ? i : void 0
327
337
  });
328
- f != null && f.file && (r[c] = z(f.file));
338
+ f != null && f.file && (r[c] = q(f.file));
329
339
  } catch {
330
340
  }
331
341
  }
332
- }, a = Math.min(t.concurrency ?? 8, e.length);
342
+ }, a = Math.min(s.concurrency ?? 8, e.length);
333
343
  return await Promise.all(Array.from({ length: a }, l)), r.filter((c) => c !== void 0);
334
344
  }
335
- async function ae(s, e, t) {
336
- const i = await s.put(`/file/${encodeURIComponent(e)}/name`, {
337
- name: t
345
+ async function ae(t, e, s) {
346
+ const i = await t.put(`/file/${encodeURIComponent(e)}/name`, {
347
+ name: s
338
348
  });
339
349
  if ((i == null ? void 0 : i.status) === "error") throw new Error(i.msg || "Failed to rename file");
340
350
  }
341
- async function ce(s, e) {
342
- const t = await s.delete("/files", { files_uuids: e });
343
- if ((t == null ? void 0 : t.status) === "error") throw new Error(t.msg || "Failed to delete files");
351
+ async function ce(t, e) {
352
+ const s = await t.delete("/files", { files_uuids: e });
353
+ if ((s == null ? void 0 : s.status) === "error") throw new Error(s.msg || "Failed to delete files");
344
354
  }
345
- async function le(s, e, t) {
346
- const i = await s.post("/files", {
355
+ async function le(t, e, s) {
356
+ const i = await t.post("/files", {
347
357
  files_uuids: e,
348
- new_folder_name: t
358
+ new_folder_name: s
349
359
  });
350
360
  if ((i == null ? void 0 : i.status) === "error") throw new Error(i.msg || "Failed to move files");
351
361
  }
352
- async function de(s) {
353
- return (await s.get("/labels")).labels ?? [];
362
+ async function de(t) {
363
+ return (await t.get("/labels")).labels ?? [];
354
364
  }
355
- function he(s) {
356
- if (s.sid)
357
- return `labels:${s.sid.replace(/^#/, "")}`;
365
+ function he(t) {
366
+ if (t.sid)
367
+ return `labels:${t.sid.replace(/^#/, "")}`;
358
368
  }
359
- function $(s, e) {
369
+ function $(t, e) {
360
370
  try {
361
- const t = new URL(s);
362
- return t.searchParams.set("p", e), t.toString();
371
+ const s = new URL(t);
372
+ return s.searchParams.set("p", e), s.toString();
363
373
  } catch {
364
- return s;
374
+ return t;
365
375
  }
366
376
  }
367
- function x(s) {
368
- var e, t, i, r, o;
377
+ function x(t) {
378
+ var e, s, i, r, o;
369
379
  return {
370
- uuid: s.uuid,
371
- name: s.name,
372
- url: s.url,
373
- previewUrl: s.preview ?? s.url,
374
- width: (e = s.info) == null ? void 0 : e.img_w,
375
- height: (t = s.info) == null ? void 0 : t.img_h,
376
- size: (i = s.info) == null ? void 0 : i.size,
377
- format: (r = s.info) == null ? void 0 : r.img_type,
380
+ uuid: t.uuid,
381
+ name: t.name,
382
+ url: t.url,
383
+ previewUrl: t.preview ?? t.url,
384
+ width: (e = t.info) == null ? void 0 : e.img_w,
385
+ height: (s = t.info) == null ? void 0 : s.img_h,
386
+ size: (i = t.info) == null ? void 0 : i.size,
387
+ format: (r = t.info) == null ? void 0 : r.img_type,
378
388
  isOriginal: !1,
379
389
  isPreset: !1,
380
- bgRemoved: ((o = s.info) == null ? void 0 : o.remove_background) === !0
390
+ bgRemoved: ((o = t.info) == null ? void 0 : o.remove_background) === !0
381
391
  };
382
392
  }
383
- function fe(s) {
393
+ function fe(t) {
384
394
  return {
385
- uuid: s.uuid,
386
- name: s.name,
387
- url: s.cdnUrl ?? "",
388
- previewUrl: s.thumbnailUrl ?? s.cdnUrl,
389
- width: s.width,
390
- height: s.height,
391
- size: s.size,
392
- format: s.fileType,
395
+ uuid: t.uuid,
396
+ name: t.name,
397
+ url: t.cdnUrl ?? "",
398
+ previewUrl: t.thumbnailUrl ?? t.cdnUrl,
399
+ width: t.width,
400
+ height: t.height,
401
+ size: t.size,
402
+ format: t.fileType,
393
403
  isOriginal: !0,
394
404
  isPreset: !1,
395
405
  bgRemoved: !1
396
406
  };
397
407
  }
398
- function ue(s, e) {
399
- const t = s.cdnUrl ?? "";
408
+ function ue(t, e) {
409
+ const s = t.cdnUrl ?? "";
400
410
  return {
401
411
  uuid: `preset-${e.name}`,
402
412
  name: e.name,
403
- url: $(t, e.name),
404
- previewUrl: $(s.thumbnailUrl ?? t, e.name),
413
+ url: $(s, e.name),
414
+ previewUrl: $(t.thumbnailUrl ?? s, e.name),
405
415
  isOriginal: !1,
406
416
  isPreset: !0,
407
417
  bgRemoved: !1
408
418
  };
409
419
  }
410
420
  function ve({
411
- asset: s,
421
+ asset: t,
412
422
  variants: e = [],
413
- presets: t = []
423
+ presets: s = []
414
424
  }) {
415
- const i = new Set(t.map((a) => a.name)), r = e.filter((a) => {
425
+ const i = new Set(s.map((a) => a.name)), r = e.filter((a) => {
416
426
  var c;
417
427
  return !i.has(a.name) && ((c = a.info) == null ? void 0 : c.remove_background) !== !0;
418
428
  }).map(x), o = e.filter((a) => {
419
429
  var c;
420
430
  return ((c = a.info) == null ? void 0 : c.remove_background) === !0 && !i.has(a.name);
421
- }).map(x), l = t.map((a) => ue(s, a));
422
- return [fe(s), ...r, ...o, ...l];
431
+ }).map(x), l = s.map((a) => ue(t, a));
432
+ return [fe(t), ...r, ...o, ...l];
423
433
  }
424
- async function ge(s, e) {
425
- const t = await s.get(
434
+ async function ge(t, e) {
435
+ const s = await t.get(
426
436
  `/file/${encodeURIComponent(e)}/variants`
427
437
  );
428
- return (t == null ? void 0 : t.variants) ?? [];
438
+ return (s == null ? void 0 : s.variants) ?? [];
429
439
  }
430
- function me(s) {
431
- return Array.isArray(s) ? s.map(
440
+ function me(t) {
441
+ return Array.isArray(t) ? t.map(
432
442
  (e) => typeof e == "string" ? { name: e } : e && typeof e.name == "string" ? { name: e.name, desc: e.desc } : null
433
443
  ).filter((e) => e !== null) : [];
434
444
  }
435
- async function pe(s) {
445
+ async function pe(t) {
436
446
  var i, r, o;
437
- const e = await s.get("/settings"), t = (e == null ? void 0 : e.presets) ?? ((i = e == null ? void 0 : e.cloudimg) == null ? void 0 : i.presets) ?? ((o = (r = e == null ? void 0 : e.settings) == null ? void 0 : r.cloudimg) == null ? void 0 : o.presets) ?? void 0;
438
- return me(t);
447
+ const e = await t.get("/settings"), s = (e == null ? void 0 : e.presets) ?? ((i = e == null ? void 0 : e.cloudimg) == null ? void 0 : i.presets) ?? ((o = (r = e == null ? void 0 : e.settings) == null ? void 0 : r.cloudimg) == null ? void 0 : o.presets) ?? void 0;
448
+ return me(s);
439
449
  }
440
- async function xe(s, e) {
441
- const [t, i] = await Promise.all([
442
- ge(s, e.uuid),
443
- pe(s)
450
+ async function xe(t, e) {
451
+ const [s, i] = await Promise.all([
452
+ ge(t, e.uuid),
453
+ pe(t)
444
454
  ]);
445
- return ve({ asset: e, variants: t, presets: i });
455
+ return ve({ asset: e, variants: s, presets: i });
446
456
  }
447
- async function we(s, e) {
448
- const t = await s.post("/file-archive", {
457
+ async function we(t, e) {
458
+ const s = await t.post("/file-archive", {
449
459
  files_uuids: e.filesUuids ?? [],
450
460
  folders_uuids: e.foldersUuids ?? [],
451
461
  urls: e.urls ?? []
452
462
  });
453
- if (!(t != null && t.task_id)) throw new Error("Archive task was not created");
454
- return t.task_id;
463
+ if (!(s != null && s.task_id)) throw new Error("Archive task was not created");
464
+ return s.task_id;
455
465
  }
456
- function ye(s, e) {
457
- return s.get(`/file-archive/${encodeURIComponent(e)}`, {
466
+ function ye(t, e) {
467
+ return t.get(`/file-archive/${encodeURIComponent(e)}`, {
458
468
  status_only: 1
459
469
  });
460
470
  }
461
471
  const Se = /* @__PURE__ */ new Set(["PENDING", "RUNNING", "PROCESSING", ""]);
462
- function be(s) {
463
- const e = ((s == null ? void 0 : s.task_status) ?? "").toUpperCase(), t = typeof (s == null ? void 0 : s.task_percent) == "number" ? s.task_percent : 0;
472
+ function be(t) {
473
+ const e = ((t == null ? void 0 : t.task_status) ?? "").toUpperCase(), s = typeof (t == null ? void 0 : t.task_percent) == "number" ? t.task_percent : 0;
464
474
  if (e === "DONE") return { done: !0, progress: 100 };
465
- if (Se.has(e)) return { done: !1, progress: t };
466
- throw new Error(`Archive job failed: ${(s == null ? void 0 : s.task_status) ?? "unknown status"}`);
475
+ if (Se.has(e)) return { done: !1, progress: s };
476
+ throw new Error(`Archive job failed: ${(t == null ? void 0 : t.task_status) ?? "unknown status"}`);
467
477
  }
468
- async function _e(s, e, t = {}) {
478
+ async function _e(t, e, s = {}) {
469
479
  var h, d;
470
- const i = t.intervalMs ?? 1500, r = t.timeoutMs ?? 12e4, o = t.maxRetries ?? 5, l = t.sleep ?? ((u) => new Promise((g) => setTimeout(g, u))), a = t.now ?? Date.now, c = a() + r;
480
+ const i = s.intervalMs ?? 1500, r = s.timeoutMs ?? 12e4, o = s.maxRetries ?? 5, l = s.sleep ?? ((u) => new Promise((g) => setTimeout(g, u))), a = s.now ?? Date.now, c = a() + r;
471
481
  let f = 0;
472
482
  for (; ; ) {
473
- if ((h = t.signal) != null && h.aborted) throw new Error("Archive polling aborted");
483
+ if ((h = s.signal) != null && h.aborted) throw new Error("Archive polling aborted");
474
484
  if (a() > c) throw new Error("Archive polling timed out");
475
485
  let u;
476
486
  try {
477
- u = await ye(s, e);
487
+ u = await ye(t, e);
478
488
  } catch (S) {
479
489
  if (f++ < o) {
480
490
  await l(i);
@@ -483,77 +493,83 @@ async function _e(s, e, t = {}) {
483
493
  throw S;
484
494
  }
485
495
  const { done: g, progress: p } = be(u);
486
- if ((d = t.onProgress) == null || d.call(t, p), g) return;
496
+ if ((d = s.onProgress) == null || d.call(s, p), g) return;
487
497
  await l(i);
488
498
  }
489
499
  }
490
- function Ae(s, e) {
491
- const t = s.absoluteUrl(`/file-archive/${encodeURIComponent(e)}`), i = s.authKey;
492
- if (!i) return t;
493
- const r = t.includes("?") ? "&" : "?";
494
- return `${t}${r}secret_key=${encodeURIComponent(i)}`;
500
+ function Ae(t, e) {
501
+ const s = t.absoluteUrl(`/file-archive/${encodeURIComponent(e)}`), i = t.authKey;
502
+ if (!i) return s;
503
+ const r = s.includes("?") ? "&" : "?";
504
+ return `${s}${r}secret_key=${encodeURIComponent(i)}`;
495
505
  }
496
- async function Ce(s, e, t = {}) {
497
- const i = await we(s, e);
498
- return await _e(s, i, t), Ae(s, i);
506
+ async function Ce(t, e, s = {}) {
507
+ const i = await we(t, e);
508
+ return await _e(t, i, s), Ae(t, i);
499
509
  }
500
- const Fe = ["cdn_permalink"], q = {
510
+ const Fe = ["cdn_permalink"], j = {
501
511
  created_at: "created_at",
502
512
  modified_at: "modified_at",
503
513
  name: "name",
504
514
  size: "size",
505
515
  type: "type"
506
516
  };
507
- function Ee(s) {
508
- let e = s.fields ?? Fe;
509
- s.permalinksEnabled || (e = e.filter((l) => l !== "cdn_permalink"));
510
- const t = {
511
- offset: s.offset ?? 0,
512
- limit: s.limit ?? 100,
517
+ function Ee(t) {
518
+ let e = t.fields ?? Fe;
519
+ t.permalinksEnabled || (e = e.filter((l) => l !== "cdn_permalink"));
520
+ const s = {
521
+ offset: t.offset ?? 0,
522
+ limit: t.limit ?? 100,
513
523
  format: "json,regvar:api,select:internal",
514
524
  preview: 2301,
515
- recursive: s.recursive ?? 1
525
+ recursive: t.recursive ?? 1
516
526
  };
517
- e.length > 0 && (t.fields = e);
518
- const i = s.sort_by ?? "created_at", r = s.sort_direction ?? "desc";
519
- t.sort = `${q[i] || i}:${r}`, s.folder && (t.folder = s.folder);
527
+ e.length > 0 && (s.fields = e);
528
+ const i = t.sort_by ?? "created_at", r = t.sort_direction ?? "desc";
529
+ s.sort = `${j[i] || i}:${r}`, t.folder && (s.folder = t.folder);
520
530
  const o = [];
521
- return s.search && !s.with_ai && o.push(s.search), s.q && o.push(s.q), o.length > 0 && (t.q = o.join(" ")), s.with_ai && (t.with_ai = !0, s.ai_query && (t.ai_query = s.ai_query), s.ai_lang && (t.ai_lang = s.ai_lang)), s.collection_uuid && (t.collection_uuid = s.collection_uuid), s.f64 && (t.f64 = s.f64), t;
531
+ return t.search && !t.with_ai && o.push(t.search), t.q && o.push(t.q), o.length > 0 && (s.q = o.join(" ")), t.with_ai && (s.with_ai = !0, t.ai_query && (s.ai_query = t.ai_query), t.ai_lang && (s.ai_lang = t.ai_lang)), t.collection_uuid && (s.collection_uuid = t.collection_uuid), t.f64 && (s.f64 = t.f64), s;
522
532
  }
523
- function Ue(s, e) {
524
- return s.get("/files", Ee(e));
533
+ function Ue(t, e) {
534
+ return t.get("/files", Ee(e));
525
535
  }
526
- function De(s, e) {
527
- const t = { recursive: e.recursive ?? 1 };
528
- e.folder && (t.folder = e.folder);
536
+ function De(t, e) {
537
+ const s = { recursive: e.recursive ?? 1 };
538
+ e.folder && (s.folder = e.folder);
529
539
  const i = [];
530
- return e.search && !e.with_ai && i.push(e.search), e.q && i.push(e.q), i.length > 0 && (t.q = i.join(" ")), e.with_ai && (t.with_ai = !0, e.ai_query && (t.ai_query = e.ai_query), e.ai_lang && (t.ai_lang = e.ai_lang)), e.collection_uuid && (t.collection_uuid = e.collection_uuid), e.f64 && (t.f64 = e.f64), s.get("/files/stats", t);
540
+ return e.search && !e.with_ai && i.push(e.search), e.q && i.push(e.q), i.length > 0 && (s.q = i.join(" ")), e.with_ai && (s.with_ai = !0, e.ai_query && (s.ai_query = e.ai_query), e.ai_lang && (s.ai_lang = e.ai_lang)), e.collection_uuid && (s.collection_uuid = e.collection_uuid), e.f64 && (s.f64 = e.f64), t.get("/files/stats", s);
531
541
  }
532
- function ke(s, e = {}) {
533
- const t = {
542
+ function ke(t, e = {}) {
543
+ const s = {
534
544
  recursive: e.recursive ?? 0,
535
545
  folder: e.folderPath ?? "/",
536
546
  limit: e.limit ?? 1e3,
537
547
  offset: e.offset ?? 0
538
548
  };
539
- e.q && (t.q = e.q);
549
+ e.q && (s.q = e.q);
540
550
  const i = e.sort_by ?? "created_at", r = e.sort_direction ?? "asc";
541
- return t.sort = `${q[i] || i}:${r}`, s.get("/folders", t);
551
+ return s.sort = `${j[i] || i}:${r}`, t.get("/folders", s);
542
552
  }
543
- async function Me(s, e) {
544
- return e.length === 0 ? {} : (await s.post("/folders/previews", {
553
+ async function Me(t, e) {
554
+ return e.length === 0 ? {} : (await t.post("/folders/previews", {
545
555
  folders: e
546
556
  })).folders || {};
547
557
  }
548
- const C = 100, U = 1e3, D = { types: [], size: null, created: null, updated: null };
558
+ const C = 100, U = 1e3, D = {
559
+ types: [],
560
+ size: null,
561
+ duration: null,
562
+ created: null,
563
+ updated: null
564
+ };
549
565
  class E {
550
- constructor(e, t = {}) {
551
- this.client = e, this.listeners = /* @__PURE__ */ new Set(), this.loadSeq = 0, this.treeSeq = 0, this.fetchedCount = 0, this.selectionAnchor = null, this.favAdapter = t.favourites, this.onScopeChange = t.onScopeChange, this.state = {
552
- scope: { type: "folder", value: t.rootFolder ?? "/" },
553
- viewMode: t.viewMode ?? "grid",
554
- gridSize: t.gridSize ?? "m",
555
- sortBy: t.sortBy ?? "created_at",
556
- sortDirection: t.sortDirection ?? "desc",
566
+ constructor(e, s = {}) {
567
+ this.client = e, this.listeners = /* @__PURE__ */ new Set(), this.loadSeq = 0, this.treeSeq = 0, this.fetchedCount = 0, this.selectionAnchor = null, this.favAdapter = s.favourites, this.onScopeChange = s.onScopeChange, this.state = {
568
+ scope: { type: "folder", value: s.rootFolder ?? "/" },
569
+ viewMode: s.viewMode ?? "grid",
570
+ gridSize: s.gridSize ?? "m",
571
+ sortBy: s.sortBy ?? "created_at",
572
+ sortDirection: s.sortDirection ?? "desc",
557
573
  searchQuery: "",
558
574
  filters: { ...D },
559
575
  folders: [],
@@ -580,15 +596,15 @@ class E {
580
596
  async loadFolderChildren(e) {
581
597
  if (!this.state.treeChildren[e])
582
598
  try {
583
- const t = await b(this.client, { folderPath: e });
584
- this.set({ treeChildren: { ...this.state.treeChildren, [e]: t } });
599
+ const s = await b(this.client, { folderPath: e });
600
+ this.set({ treeChildren: { ...this.state.treeChildren, [e]: s } });
585
601
  } catch {
586
602
  }
587
603
  }
588
604
  /** Expand/collapse a folder node, lazy-loading its children on first expand. */
589
605
  async toggleFolder(e) {
590
- const t = new Set(this.state.expandedFolders);
591
- t.has(e) ? (t.delete(e), this.set({ expandedFolders: t })) : (await this.loadFolderChildren(e), t.add(e), this.set({ expandedFolders: t }));
606
+ const s = new Set(this.state.expandedFolders);
607
+ s.has(e) ? (s.delete(e), this.set({ expandedFolders: s })) : (await this.loadFolderChildren(e), s.add(e), this.set({ expandedFolders: s }));
592
608
  }
593
609
  async loadLabels() {
594
610
  try {
@@ -605,13 +621,13 @@ class E {
605
621
  }
606
622
  /** Toggle an asset's favourite status (per-user, via the adapter). */
607
623
  async toggleFavourite(e) {
608
- const t = this.state.favourites.has(e), i = new Set(this.state.favourites);
609
- t ? i.delete(e) : i.add(e), this.set({ favourites: i });
624
+ const s = this.state.favourites.has(e), i = new Set(this.state.favourites);
625
+ s ? i.delete(e) : i.add(e), this.set({ favourites: i });
610
626
  try {
611
- this.favAdapter && (t ? await this.favAdapter.remove(e) : await this.favAdapter.add(e));
627
+ this.favAdapter && (s ? await this.favAdapter.remove(e) : await this.favAdapter.add(e));
612
628
  } catch {
613
629
  const r = new Set(this.state.favourites);
614
- t ? r.add(e) : r.delete(e), this.set({ favourites: r });
630
+ s ? r.add(e) : r.delete(e), this.set({ favourites: r });
615
631
  return;
616
632
  }
617
633
  this.state.scope.type === "favourites" && this.load();
@@ -624,12 +640,12 @@ class E {
624
640
  }
625
641
  set(e) {
626
642
  this.state = { ...this.state, ...e };
627
- for (const t of this.listeners) t(this.state);
643
+ for (const s of this.listeners) s(this.state);
628
644
  }
629
645
  // ── navigation / scope ─────────────────────────────────────────────────────
630
646
  setScope(e) {
631
- var t;
632
- this.selectionAnchor = null, this.set({ scope: e, selection: /* @__PURE__ */ new Set() }), (t = this.onScopeChange) == null || t.call(this, e), this.load();
647
+ var s;
648
+ this.selectionAnchor = null, this.set({ scope: e, selection: /* @__PURE__ */ new Set() }), (s = this.onScopeChange) == null || s.call(this, e), this.load();
633
649
  }
634
650
  openFolder(e) {
635
651
  this.setScope({ type: "folder", value: e });
@@ -647,8 +663,8 @@ class E {
647
663
  setGridSize(e) {
648
664
  this.set({ gridSize: e });
649
665
  }
650
- setSort(e, t) {
651
- this.set({ sortBy: e, sortDirection: t }), this.load();
666
+ setSort(e, s) {
667
+ this.set({ sortBy: e, sortDirection: s }), this.load();
652
668
  }
653
669
  setSearch(e) {
654
670
  this.set({ searchQuery: e }), this.load();
@@ -659,23 +675,23 @@ class E {
659
675
  }
660
676
  /** Toggle one file-type in the type facet. Reloads from page 1. */
661
677
  toggleType(e) {
662
- const t = this.state.filters.types;
678
+ const s = this.state.filters.types;
663
679
  this.setFilters({
664
- types: t.includes(e) ? t.filter((i) => i !== e) : [...t, e]
680
+ types: s.includes(e) ? s.filter((i) => i !== e) : [...s, e]
665
681
  });
666
682
  }
667
683
  /** Number of active facets across all groups (for the toolbar badge). */
668
684
  get activeFilterCount() {
669
- const { types: e, size: t, created: i, updated: r } = this.state.filters;
670
- return e.length + (t ? 1 : 0) + (i ? 1 : 0) + (r ? 1 : 0);
685
+ const { types: e, size: s, duration: i, created: r, updated: o } = this.state.filters;
686
+ return e.length + (s ? 1 : 0) + (i ? 1 : 0) + (r ? 1 : 0) + (o ? 1 : 0);
671
687
  }
672
688
  /** Clear every facet in one update, then reload. No-op if nothing is active. */
673
689
  clearFilters() {
674
690
  this.activeFilterCount && (this.set({ filters: { ...D } }), this.load());
675
691
  }
676
692
  // ── selection ──────────────────────────────────────────────────────────────
677
- toggleSelect(e, t = !1) {
678
- const i = new Set(t ? this.state.selection : []), r = !i.has(e);
693
+ toggleSelect(e, s = !1) {
694
+ const i = new Set(s ? this.state.selection : []), r = !i.has(e);
679
695
  r ? i.add(e) : i.delete(e), r && (this.selectionAnchor = e), this.set({ selection: i });
680
696
  }
681
697
  /**
@@ -686,23 +702,23 @@ class E {
686
702
  * anchor yet, behaves like a plain multi-select toggle.
687
703
  */
688
704
  selectRange(e) {
689
- const t = this.state.assets, i = t.findIndex((c) => c.uuid === e);
705
+ const s = this.state.assets, i = s.findIndex((c) => c.uuid === e);
690
706
  if (i < 0) return;
691
- const r = this.selectionAnchor != null ? t.findIndex((c) => c.uuid === this.selectionAnchor) : -1;
707
+ const r = this.selectionAnchor != null ? s.findIndex((c) => c.uuid === this.selectionAnchor) : -1;
692
708
  if (r < 0) {
693
709
  this.toggleSelect(e, !0);
694
710
  return;
695
711
  }
696
712
  const [o, l] = r <= i ? [r, i] : [i, r], a = new Set(this.state.selection);
697
- for (let c = o; c <= l; c++) a.add(t[c].uuid);
713
+ for (let c = o; c <= l; c++) a.add(s[c].uuid);
698
714
  this.set({ selection: a });
699
715
  }
700
716
  /** Replace the whole selection in one update (e.g. "select all", marquee drag). */
701
717
  setSelection(e) {
702
- const t = new Set(e);
718
+ const s = new Set(e);
703
719
  let i = null;
704
- for (const r of t) i = r;
705
- this.selectionAnchor = i, this.set({ selection: t });
720
+ for (const r of s) i = r;
721
+ this.selectionAnchor = i, this.set({ selection: s });
706
722
  }
707
723
  clearSelection() {
708
724
  this.selectionAnchor = null, this.set({ selection: /* @__PURE__ */ new Set() });
@@ -721,9 +737,9 @@ class E {
721
737
  * `treeSeq` guard discards a superseded refresh.
722
738
  */
723
739
  async refreshTree() {
724
- const e = ++this.treeSeq, t = /* @__PURE__ */ new Set(["/", this.currentFolderPath, ...this.state.expandedFolders]), i = {};
740
+ const e = ++this.treeSeq, s = /* @__PURE__ */ new Set(["/", this.currentFolderPath, ...this.state.expandedFolders]), i = {};
725
741
  await Promise.all(
726
- [...t].map(async (r) => {
742
+ [...s].map(async (r) => {
727
743
  try {
728
744
  i[r] = await b(this.client, { folderPath: r });
729
745
  } catch {
@@ -740,8 +756,8 @@ class E {
740
756
  }
741
757
  /** Find a cached folder's path by uuid (across the tree cache + current list). */
742
758
  folderPath(e) {
743
- for (const t of [this.state.folders, ...Object.values(this.state.treeChildren)]) {
744
- const i = t.find((r) => r.uuid === e);
759
+ for (const s of [this.state.folders, ...Object.values(this.state.treeChildren)]) {
760
+ const i = s.find((r) => r.uuid === e);
745
761
  if (i) return i.path;
746
762
  }
747
763
  }
@@ -751,49 +767,50 @@ class E {
751
767
  * scope to its new path (or the parent on delete). Returns true if it redirected
752
768
  * (which itself triggers a reload), so the caller can skip its own load().
753
769
  */
754
- redirectScope(e, t) {
770
+ redirectScope(e, s) {
755
771
  const { scope: i } = this.state;
756
772
  if (i.type !== "folder" || !i.value) return !1;
757
773
  const r = i.value;
758
- return r !== e && !r.startsWith(e + "/") ? !1 : (t === null ? this.openFolder(E.parentOf(e)) : this.openFolder(r === e ? t : t + r.slice(e.length)), !0);
774
+ return r !== e && !r.startsWith(e + "/") ? !1 : (s === null ? this.openFolder(E.parentOf(e)) : this.openFolder(r === e ? s : s + r.slice(e.length)), !0);
759
775
  }
760
776
  async createFolder(e) {
761
777
  await K(this.client, e, this.currentFolderPath), await this.refreshTree(), await this.load();
762
778
  }
763
- async renameFolderById(e, t) {
779
+ async renameFolderById(e, s) {
764
780
  const i = this.folderPath(e);
765
- await Y(this.client, e, t), await this.refreshTree();
766
- const r = i ? `${E.parentOf(i).replace(/\/$/, "")}/${t}` : null;
781
+ await Y(this.client, e, s), await this.refreshTree();
782
+ const r = i ? `${E.parentOf(i).replace(/\/$/, "")}/${s}` : null;
767
783
  i && r && this.redirectScope(i, r) || await this.load();
768
784
  }
769
785
  async deleteFolderById(e) {
770
- const t = this.folderPath(e);
771
- await Z(this.client, [e]), await this.refreshTree(), t && this.redirectScope(t, null) || await this.load();
786
+ const s = this.folderPath(e);
787
+ await Z(this.client, [e]), await this.refreshTree(), s && this.redirectScope(s, null) || await this.load();
772
788
  }
773
- async moveFolderById(e, t) {
789
+ async moveFolderById(e, s) {
774
790
  const i = this.folderPath(e);
775
- await Q(this.client, [e], t), await this.refreshTree();
776
- const r = (i == null ? void 0 : i.split("/").pop()) ?? "", o = i ? `${t.replace(/\/$/, "")}/${r}` : null;
791
+ await Q(this.client, [e], s), await this.refreshTree();
792
+ const r = (i == null ? void 0 : i.split("/").pop()) ?? "", o = i ? `${s.replace(/\/$/, "")}/${r}` : null;
777
793
  i && o && this.redirectScope(i, o) || await this.load();
778
794
  }
779
- async renameAsset(e, t) {
780
- await ae(this.client, e, t), await this.load();
795
+ async renameAsset(e, s) {
796
+ await ae(this.client, e, s), await this.load();
781
797
  }
782
798
  async deleteAssets(e) {
783
799
  await ce(this.client, e), this.clearSelection(), await this.load();
784
800
  }
785
- async moveAssets(e, t) {
786
- await le(this.client, e, t), this.clearSelection(), await this.load();
801
+ async moveAssets(e, s) {
802
+ await le(this.client, e, s), this.clearSelection(), await this.load();
787
803
  }
788
804
  // ── data loading ───────────────────────────────────────────────────────────
789
805
  /** Translate the active filter facets into the api query shape (undefined = off). */
790
806
  facetParams() {
791
- const { types: e, size: t, created: i, updated: r } = this.state.filters;
807
+ const { types: e, size: s, duration: i, created: r, updated: o } = this.state.filters;
792
808
  return {
793
809
  types: e.length ? e : void 0,
794
- sizeBucket: t ?? void 0,
795
- createdWithin: i ?? void 0,
796
- updatedWithin: r ?? void 0
810
+ sizeBucket: s ?? void 0,
811
+ durationRange: i ?? void 0,
812
+ createdWithin: r ?? void 0,
813
+ updatedWithin: o ?? void 0
797
814
  };
798
815
  }
799
816
  /**
@@ -808,8 +825,8 @@ class E {
808
825
  * the caller advances its offset cursor correctly even when dedupe drops items.
809
826
  */
810
827
  async fetchAssetsPage(e) {
811
- const { scope: t, sortBy: i, sortDirection: r } = this.state, o = this.state.searchQuery || void 0, l = this.facetParams();
812
- if (t.type === "favourites") {
828
+ const { scope: s, sortBy: i, sortDirection: r } = this.state, o = this.state.searchQuery || void 0, l = this.facetParams();
829
+ if (s.type === "favourites") {
813
830
  const h = [...this.state.favourites], d = await oe(this.client, h.slice(0, U)), u = Date.now(), g = d.filter((S) => re(S, l, u)), p = ne(g, i, r);
814
831
  return {
815
832
  assets: p,
@@ -821,11 +838,11 @@ class E {
821
838
  }
822
839
  const a = { sortBy: i, sortDirection: r, search: o, ...l, offset: e, limit: C };
823
840
  let c;
824
- if (t.type === "folder") {
841
+ if (s.type === "folder") {
825
842
  const h = this.state.searchQuery.trim() ? 1 : 0;
826
- c = await w(this.client, { ...a, folder: t.value ?? "/", recursive: h });
827
- } else if (t.type === "label") {
828
- const h = this.state.labels.find((u) => u.uuid === t.value), d = h ? he(h) : void 0;
843
+ c = await w(this.client, { ...a, folder: s.value ?? "/", recursive: h });
844
+ } else if (s.type === "label") {
845
+ const h = this.state.labels.find((u) => u.uuid === s.value), d = h ? he(h) : void 0;
829
846
  c = await w(this.client, { ...a, recursive: 1, q: d });
830
847
  } else
831
848
  c = await w(this.client, { ...a, recursive: 1 });
@@ -843,7 +860,7 @@ class E {
843
860
  const e = ++this.loadSeq;
844
861
  this.set({ loading: !0, loadingMore: !1, error: null });
845
862
  try {
846
- const t = b(this.client, { folderPath: this.currentFolderPath }), i = this.fetchAssetsPage(0), [r, o] = await Promise.all([t, i]);
863
+ const s = b(this.client, { folderPath: this.currentFolderPath }), i = this.fetchAssetsPage(0), [r, o] = await Promise.all([s, i]);
847
864
  if (e !== this.loadSeq) return;
848
865
  this.fetchedCount = o.fetched, this.set({
849
866
  folders: r,
@@ -855,9 +872,9 @@ class E {
855
872
  // keep the tree cache warm for the folder we just listed
856
873
  treeChildren: { ...this.state.treeChildren, [this.currentFolderPath]: r }
857
874
  });
858
- } catch (t) {
875
+ } catch (s) {
859
876
  if (e !== this.loadSeq) return;
860
- this.set({ error: t instanceof Error ? t.message : String(t), loading: !1 });
877
+ this.set({ error: s instanceof Error ? s.message : String(s), loading: !1 });
861
878
  }
862
879
  }
863
880
  /**
@@ -874,25 +891,25 @@ class E {
874
891
  const e = this.loadSeq;
875
892
  this.set({ loadingMore: !0 });
876
893
  try {
877
- const t = await this.fetchAssetsPage(this.fetchedCount);
894
+ const s = await this.fetchAssetsPage(this.fetchedCount);
878
895
  if (e !== this.loadSeq) return;
879
- this.fetchedCount += t.fetched;
880
- const i = new Set(this.state.assets.map((o) => o.uuid)), r = t.assets.filter((o) => !i.has(o.uuid));
896
+ this.fetchedCount += s.fetched;
897
+ const i = new Set(this.state.assets.map((o) => o.uuid)), r = s.assets.filter((o) => !i.has(o.uuid));
881
898
  this.set({
882
899
  assets: [...this.state.assets, ...r],
883
- total: t.total,
884
- hasMore: t.hasMore,
900
+ total: s.total,
901
+ hasMore: s.hasMore,
885
902
  loadingMore: !1,
886
903
  error: null
887
904
  // a recovered page clears any prior load-more failure
888
905
  });
889
- } catch (t) {
906
+ } catch (s) {
890
907
  if (e !== this.loadSeq) return;
891
- this.set({ error: t instanceof Error ? t.message : String(t), loadingMore: !1 });
908
+ this.set({ error: s instanceof Error ? s.message : String(s), loadingMore: !1 });
892
909
  }
893
910
  }
894
911
  }
895
- class Oe {
912
+ class Re {
896
913
  constructor(e = "sfx-light-dam:favourites") {
897
914
  this.key = e;
898
915
  }
@@ -917,73 +934,73 @@ class Oe {
917
934
  return this.read().has(e);
918
935
  }
919
936
  add(e) {
920
- const t = this.read();
921
- t.add(e), this.write(t);
937
+ const s = this.read();
938
+ s.add(e), this.write(s);
922
939
  }
923
940
  remove(e) {
924
- const t = this.read();
925
- t.delete(e), this.write(t);
941
+ const s = this.read();
942
+ s.delete(e), this.write(s);
926
943
  }
927
944
  }
928
- function Re(s, e) {
929
- const t = new URL(s);
930
- return e.width && t.searchParams.set("w", String(e.width)), e.height && t.searchParams.set("h", String(e.height)), e.quality !== void 0 && t.searchParams.set("q", String(e.quality)), t.toString();
945
+ function Oe(t, e) {
946
+ const s = new URL(t);
947
+ return e.width && s.searchParams.set("w", String(e.width)), e.height && s.searchParams.set("h", String(e.height)), e.quality !== void 0 && s.searchParams.set("q", String(e.quality)), s.toString();
931
948
  }
932
949
  const Le = { excellent: 90, good: 75, fair: 60 }, ze = { fullhd: 1920, large: 1200, medium: 600, small: 300 }, Pe = {
933
950
  webp: "awebp,webp",
934
951
  gif: "agif,gif"
935
952
  };
936
- function j(s, e) {
937
- s.searchParams.delete("download"), e.width && s.searchParams.set("w", String(e.width)), e.height && s.searchParams.set("h", String(e.height)), e.quality != null && s.searchParams.set("q", String(e.quality)), e.format && s.searchParams.set("force_format", Pe[e.format] ?? e.format), e.strictSizes !== void 0 && (e.width || e.height) && s.searchParams.set("func", e.strictSizes ? "bound" : "cover");
953
+ function N(t, e) {
954
+ t.searchParams.delete("download"), e.width && t.searchParams.set("w", String(e.width)), e.height && t.searchParams.set("h", String(e.height)), e.quality != null && t.searchParams.set("q", String(e.quality)), e.format && t.searchParams.set("force_format", Pe[e.format] ?? e.format), e.strictSizes !== void 0 && (e.width || e.height) && t.searchParams.set("func", e.strictSizes ? "bound" : "cover");
938
955
  }
939
- function Te(s, e) {
940
- if (!e) return s;
941
- const t = e === "jpeg" ? "jpg" : e;
942
- return `${s.replace(/\.[^./\\]+$/, "") || s}.${t}`;
956
+ function Te(t, e) {
957
+ if (!e) return t;
958
+ const s = e === "jpeg" ? "jpg" : e;
959
+ return `${t.replace(/\.[^./\\]+$/, "") || t}.${s}`;
943
960
  }
944
- function qe(s, e, t = {}) {
945
- const i = new URL(s);
946
- return j(i, t), i.searchParams.set("force_download", Te(e, t.format)), i.toString();
961
+ function qe(t, e, s = {}) {
962
+ const i = new URL(t);
963
+ return N(i, s), i.searchParams.set("force_download", Te(e, s.format)), i.toString();
947
964
  }
948
- function je(s, e = {}) {
949
- const t = new URL(s);
950
- return j(t, e), t.toString();
965
+ function je(t, e = {}) {
966
+ const s = new URL(t);
967
+ return N(s, e), s.toString();
951
968
  }
952
969
  const k = /^(https:\/\/)([a-z0-9_-]+)\.filerobot\.com\/(?:v\d+\/)?/i;
953
- function _(s) {
954
- if (!s) return "";
970
+ function _(t) {
971
+ if (!t) return "";
955
972
  const e = (i) => i.replace(/(\.filerobot\.com\/[a-z0-9_-]+)\/v\d+\//i, "$1/");
956
- if (s.includes("assets.filerobot.com")) return e(s);
957
- const t = s.match(k);
958
- return t ? e(s.replace(k, `$1assets.filerobot.com/${t[2]}/`)) : s;
973
+ if (t.includes("assets.filerobot.com")) return e(t);
974
+ const s = t.match(k);
975
+ return s ? e(t.replace(k, `$1assets.filerobot.com/${s[2]}/`)) : t;
959
976
  }
960
- function A(s, e) {
977
+ function A(t, e) {
961
978
  try {
962
- const t = new URL(s);
963
- for (const [i, r] of Object.entries(e)) t.searchParams.set(i, r);
964
- return t.toString();
979
+ const s = new URL(t);
980
+ for (const [i, r] of Object.entries(e)) s.searchParams.set(i, r);
981
+ return s.toString();
965
982
  } catch {
966
- return s;
983
+ return t;
967
984
  }
968
985
  }
969
- function Ne(s, e = 240) {
970
- const t = String(e);
971
- if (s.type === "video")
972
- return s.thumbnailUrl ? A(_(s.thumbnailUrl), { w: t, force_format: "webp,jpeg" }) : "";
973
- if (s.type === "document" && /\.pdf$/i.test(s.name)) {
974
- const i = _(s.cdnUrl ?? "");
986
+ function Ne(t, e = 240) {
987
+ const s = String(e);
988
+ if (t.type === "video")
989
+ return t.thumbnailUrl ? A(_(t.thumbnailUrl), { w: s, force_format: "webp,jpeg" }) : "";
990
+ if (t.type === "document" && /\.pdf$/i.test(t.name)) {
991
+ const i = _(t.cdnUrl ?? "");
975
992
  if (!i) return "";
976
993
  const r = i.replace(/([?&])func=proxy&?/, "$1").replace(/[?&]$/, "");
977
994
  return A(r, {
978
- w: t,
995
+ w: s,
979
996
  force_format: "webp,jpeg",
980
997
  doc_page: "1",
981
998
  bypass_process_proxy: "1"
982
999
  });
983
1000
  }
984
- if (s.type === "image" || s.thumbnailUrl) {
985
- const i = s.thumbnailUrl ?? s.cdnUrl;
986
- return i ? A(_(i), { w: t, func: "bound" }) : "";
1001
+ if (t.type === "image" || t.thumbnailUrl) {
1002
+ const i = t.thumbnailUrl ?? t.cdnUrl;
1003
+ return i ? A(_(i), { w: s, func: "bound" }) : "";
987
1004
  }
988
1005
  return "";
989
1006
  }
@@ -1099,47 +1116,47 @@ const n = "https://scaleflex.cloudimg.io/v7/assets/file-types/v3/", Ie = '<svg x
1099
1116
  function Be() {
1100
1117
  return P._default;
1101
1118
  }
1102
- function Ge(s) {
1103
- const e = (s.split(".").pop() || "").toLowerCase();
1119
+ function Ge(t) {
1120
+ const e = (t.split(".").pop() || "").toLowerCase();
1104
1121
  return P[e] || P._default;
1105
1122
  }
1106
- function We(s) {
1107
- if (s == null || !Number.isFinite(s) || s < 0) return "—";
1123
+ function We(t) {
1124
+ if (t == null || !Number.isFinite(t) || t < 0) return "—";
1108
1125
  const e = ["B", "KB", "MB", "GB", "TB"];
1109
- let t = s, i = 0;
1110
- for (; t >= 1024 && i < e.length - 1; )
1111
- t /= 1024, i++;
1126
+ let s = t, i = 0;
1127
+ for (; s >= 1024 && i < e.length - 1; )
1128
+ s /= 1024, i++;
1112
1129
  const r = (a, c) => {
1113
1130
  const f = c > 0 && Math.round(a * 10) / 10 < 10 ? 1 : 0, h = a.toFixed(f);
1114
1131
  return { str: h, rounded: Number(h) };
1115
- }, o = r(t, i);
1132
+ }, o = r(s, i);
1116
1133
  let l = o.str;
1117
- return o.rounded >= 1024 && i < e.length - 1 && (t /= 1024, i++, l = r(t, i).str), `${l} ${e[i]}`;
1134
+ return o.rounded >= 1024 && i < e.length - 1 && (s /= 1024, i++, l = r(s, i).str), `${l} ${e[i]}`;
1118
1135
  }
1119
- function Xe(s) {
1120
- if (!s) return "—";
1121
- const e = new Date(s);
1122
- return Number.isNaN(e.getTime()) ? s : e.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
1136
+ function Xe(t) {
1137
+ if (!t) return "—";
1138
+ const e = new Date(t);
1139
+ return Number.isNaN(e.getTime()) ? t : e.toLocaleDateString(void 0, { year: "numeric", month: "short", day: "numeric" });
1123
1140
  }
1124
- function Ve(s, e) {
1125
- return s && e ? `${s} × ${e}` : "—";
1141
+ function Ve(t, e) {
1142
+ return t && e ? `${t} × ${e}` : "—";
1126
1143
  }
1127
- function He(s, e) {
1128
- let t;
1144
+ function He(t, e) {
1145
+ let s;
1129
1146
  const i = ((...r) => {
1130
- clearTimeout(t), t = setTimeout(() => s(...r), e);
1147
+ clearTimeout(s), s = setTimeout(() => t(...r), e);
1131
1148
  });
1132
- return i.cancel = () => clearTimeout(t), i;
1149
+ return i.cancel = () => clearTimeout(s), i;
1133
1150
  }
1134
1151
  export {
1135
1152
  E as BrowseStore,
1136
- O as DamClient,
1137
- Oe as LocalFavouritesAdapter,
1153
+ R as DamClient,
1154
+ Re as LocalFavouritesAdapter,
1138
1155
  U as MAX_FAVOURITES,
1139
1156
  C as PAGE_SIZE,
1140
1157
  Le as QUALITY_LEVELS,
1141
1158
  ze as RESIZE_PRESETS,
1142
- Re as addCdnParams,
1159
+ Oe as addCdnParams,
1143
1160
  Ae as archiveDownloadUrl,
1144
1161
  be as archiveStatusOutcome,
1145
1162
  ve as assembleVariations,
@@ -1153,7 +1170,7 @@ export {
1153
1170
  He as debounce,
1154
1171
  ce as deleteFiles,
1155
1172
  Z as deleteFolders,
1156
- W as exchangeSassKey,
1173
+ X as exchangeSassKey,
1157
1174
  Xe as formatDate,
1158
1175
  Ve as formatDimensions,
1159
1176
  We as formatFileSize,
@@ -1178,7 +1195,7 @@ export {
1178
1195
  xe as loadVariations,
1179
1196
  le as moveFiles,
1180
1197
  Q as moveFolders,
1181
- V as normalizeAuth,
1198
+ H as normalizeAuth,
1182
1199
  me as normalizePresets,
1183
1200
  x as normalizeVariation,
1184
1201
  _e as pollArchive,