@synopackageland/sdk 0.48.0 → 0.49.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.
package/dist/index.js CHANGED
@@ -83,12 +83,12 @@ function ke(e) {
83
83
  function i() {
84
84
  var s = o();
85
85
  return s ? Promise.resolve(s) : a || (a = new Promise(function(r) {
86
- var c = new AbortController(), d = !1;
87
- function g(l) {
88
- d || (d = !0, clearTimeout(u), r(l));
86
+ var l = new AbortController(), c = !1;
87
+ function p(d) {
88
+ c || (c = !0, clearTimeout(u), r(d));
89
89
  }
90
90
  var u = setTimeout(function() {
91
- c.abort(), g(void 0);
91
+ l.abort(), p(void 0);
92
92
  }, 15e3);
93
93
  try {
94
94
  e.fetch("webman/login.cgi?enable_syno_token=yes", {
@@ -97,24 +97,24 @@ function ke(e) {
97
97
  mode: "same-origin",
98
98
  redirect: "error",
99
99
  cache: "no-store",
100
- signal: c.signal
101
- }).then(function(l) {
102
- return l.ok ? l.json() : void 0;
103
- }).then(function(l) {
104
- if (!d) {
105
- var p = n(e.read());
106
- if (p) {
107
- g(p);
100
+ signal: l.signal
101
+ }).then(function(d) {
102
+ return d.ok ? d.json() : void 0;
103
+ }).then(function(d) {
104
+ if (!c) {
105
+ var h = n(e.read());
106
+ if (h) {
107
+ p(h);
108
108
  return;
109
109
  }
110
- var f = l && l.success === !0 ? n(l.SynoToken) : void 0;
111
- f && (e.write && e.write(f), t = f), g(f);
110
+ var m = d && d.success === !0 ? n(d.SynoToken) : void 0;
111
+ m && (e.write && e.write(m), t = m), p(m);
112
112
  }
113
113
  }).catch(function() {
114
- g(void 0);
114
+ p(void 0);
115
115
  });
116
116
  } catch {
117
- g(void 0);
117
+ p(void 0);
118
118
  }
119
119
  }), a);
120
120
  }
@@ -152,7 +152,7 @@ async function De(e) {
152
152
  function U(e) {
153
153
  throw { code: { 106: "session_required", 107: "session_required", 119: "session_required", 105: "denied", 403: "denied", 407: "denied", 408: "denied", 414: "conflict", 1805: "conflict", 400: "invalid-request" }[String(e)] ?? "unavailable" };
154
154
  }
155
- function w(e) {
155
+ function D(e) {
156
156
  if (typeof e != "string" || e.length < 2 || e.length > 4096 || !e.startsWith("/") || /[\u0000-\u001f\u007f\\,"]/.test(e) || e.split("/").slice(1).some((t) => !t || t === "." || t === "..")) throw { code: "invalid-request" };
157
157
  }
158
158
  function Y(e) {
@@ -170,129 +170,129 @@ function le(e = {}) {
170
170
  if (!s) throw { code: "dsm_session_required" };
171
171
  return s;
172
172
  }
173
- async function n(i, s, r, c, d, g = !1, u) {
174
- if (d.aborted) throw { code: "canceled" };
175
- const l = new AbortController();
176
- let p = !1, f = !1;
177
- const h = () => l.abort();
178
- d.addEventListener("abort", h, { once: !0 }), d.aborted && l.abort();
179
- const m = setTimeout(() => {
180
- f = !0, l.abort();
173
+ async function n(i, s, r, l, c, p = !1, u) {
174
+ if (c.aborted) throw { code: "canceled" };
175
+ const d = new AbortController();
176
+ let h = !1, m = !1;
177
+ const g = () => d.abort();
178
+ c.addEventListener("abort", g, { once: !0 }), c.aborted && d.abort();
179
+ const f = setTimeout(() => {
180
+ m = !0, d.abort();
181
181
  }, e.timeout ?? (u ? 1200 * 1e3 : L()));
182
- let $ = () => {
182
+ let b = () => {
183
183
  };
184
184
  try {
185
- const _ = async () => {
186
- if (l.signal.aborted) throw { code: "canceled" };
185
+ const $ = async () => {
186
+ if (d.signal.aborted) throw { code: "canceled" };
187
187
  if (e.webApi && !u) {
188
- p = !0;
188
+ h = !0;
189
189
  try {
190
- return await e.webApi(i, s, r, c);
190
+ return await e.webApi(i, s, r, l);
191
191
  } catch (q) {
192
192
  const T = /^dsm_(\d+)$/.exec(String(q?.code));
193
193
  throw T && U(T[1]), q;
194
194
  }
195
195
  }
196
- const N = await a(l.signal);
197
- if (l.signal.aborted) throw { code: "canceled" };
198
- const D = u ? new FormData() : new URLSearchParams();
199
- for (const [q, T] of Object.entries({ api: i, method: s, version: String(r), ...c, SynoToken: N })) D.append(q, T);
200
- u && D.append("file", u), p = !0;
201
- const K = await fetch(ce, { method: "POST", body: D, credentials: "same-origin", mode: "same-origin", redirect: "error", cache: "no-store", signal: l.signal, headers: { "X-SYNO-TOKEN": N } });
196
+ const N = await a(d.signal);
197
+ if (d.signal.aborted) throw { code: "canceled" };
198
+ const C = u ? new FormData() : new URLSearchParams();
199
+ for (const [q, T] of Object.entries({ api: i, method: s, version: String(r), ...l, SynoToken: N })) C.append(q, T);
200
+ u && C.append("file", u), h = !0;
201
+ const K = await fetch(ce, { method: "POST", body: C, credentials: "same-origin", mode: "same-origin", redirect: "error", cache: "no-store", signal: d.signal, headers: { "X-SYNO-TOKEN": N } });
202
202
  if (!K.ok) throw Error();
203
203
  const M = await De(K);
204
204
  if (M?.success === !1 && U(M.error?.code), M?.success !== !0) throw Error();
205
205
  return M.data;
206
- }, S = new Promise((N, D) => {
207
- $ = () => D({ code: f ? "timeout" : "canceled" }), l.signal.addEventListener("abort", $, { once: !0 }), l.signal.aborted && $();
208
- }), P = await Promise.race([_(), S]);
209
- if (P?.error || Array.isArray(P?.errors) && P.errors.length) throw { code: "denied" };
210
- return P;
211
- } catch (_) {
212
- const S = _?.code;
213
- throw typeof S == "number" && [106, 107, 119, 105, 403, 407, 408, 414, 1805, 400].includes(S) && U(S), typeof S == "string" && ["canceled", "timeout"].includes(S) ? { code: g && p ? "commit-uncertain" : S } : typeof S == "string" && ["session_required", "dsm_session_required", "denied", "not_found", "conflict", "invalid-request", "unavailable", "commit-uncertain"].includes(S) ? { code: S } : { code: g && p ? "commit-uncertain" : f ? "timeout" : d.aborted ? "canceled" : "unavailable" };
206
+ }, v = new Promise((N, C) => {
207
+ b = () => C({ code: m ? "timeout" : "canceled" }), d.signal.addEventListener("abort", b, { once: !0 }), d.signal.aborted && b();
208
+ }), w = await Promise.race([$(), v]);
209
+ if (w?.error || Array.isArray(w?.errors) && w.errors.length) throw { code: "denied" };
210
+ return w;
211
+ } catch ($) {
212
+ const v = $?.code;
213
+ throw typeof v == "number" && [106, 107, 119, 105, 403, 407, 408, 414, 1805, 400].includes(v) && U(v), typeof v == "string" && ["canceled", "timeout"].includes(v) ? { code: p && h ? "commit-uncertain" : v } : typeof v == "string" && ["session_required", "dsm_session_required", "denied", "not_found", "conflict", "invalid-request", "unavailable", "commit-uncertain"].includes(v) ? { code: v } : { code: p && h ? "commit-uncertain" : m ? "timeout" : c.aborted ? "canceled" : "unavailable" };
214
214
  } finally {
215
- clearTimeout(m), d.removeEventListener("abort", h), l.signal.removeEventListener("abort", $);
215
+ clearTimeout(f), c.removeEventListener("abort", g), d.signal.removeEventListener("abort", b);
216
216
  }
217
217
  }
218
- async function o(i, s, r, c) {
219
- i !== void 0 && w(i);
220
- const d = r.limit ?? 100, g = r.sortBy ?? "name", u = r.sortDirection ?? "ASC";
221
- if (!Number.isSafeInteger(s) || s < 0 || s > 1e6 || !Number.isSafeInteger(d) || d < 1 || d > 100 || !["name", "size", "type", "mtime"].includes(g) || !["ASC", "DESC"].includes(u)) throw { code: "invalid-request" };
222
- const l = await n("SYNO.FileStation.List", i === void 0 ? "list_share" : "list", 2, { offset: String(s), limit: String(d), sort_by: g, sort_direction: u, additional: '["size"]', ...i === void 0 ? {} : { folder_path: i } }, c), p = i === void 0 ? l?.shares ?? l?.files : l?.files;
223
- if (!Array.isArray(p) || p.length > d || !Number.isSafeInteger(l.total) || l.total < 0 || l.offset !== s || s + p.length > l.total || !p.length && s < l.total) throw { code: "unavailable" };
224
- return p.forEach(Z), l;
218
+ async function o(i, s, r, l) {
219
+ i !== void 0 && D(i);
220
+ const c = r.limit ?? 100, p = r.sortBy ?? "name", u = r.sortDirection ?? "ASC";
221
+ if (!Number.isSafeInteger(s) || s < 0 || s > 1e6 || !Number.isSafeInteger(c) || c < 1 || c > 100 || !["name", "size", "type", "mtime"].includes(p) || !["ASC", "DESC"].includes(u)) throw { code: "invalid-request" };
222
+ const d = await n("SYNO.FileStation.List", i === void 0 ? "list_share" : "list", 2, { offset: String(s), limit: String(c), sort_by: p, sort_direction: u, additional: '["size"]', ...i === void 0 ? {} : { folder_path: i } }, l), h = i === void 0 ? d?.shares ?? d?.files : d?.files;
223
+ if (!Array.isArray(h) || h.length > c || !Number.isSafeInteger(d.total) || d.total < 0 || d.offset !== s || s + h.length > d.total || !h.length && s < d.total) throw { code: "unavailable" };
224
+ return h.forEach(Z), d;
225
225
  }
226
226
  return {
227
227
  token: a,
228
228
  shares: (i, s) => o(void 0, i, {}, s),
229
229
  list: (i, s, r) => o(i, s.offset ?? 0, s, r),
230
230
  async info(i, s) {
231
- w(i);
231
+ D(i);
232
232
  const r = await n("SYNO.FileStation.List", "getinfo", 2, { path: JSON.stringify([i]), additional: '["size"]' }, s);
233
233
  if (!Array.isArray(r?.files) || r.files.length !== 1 || r.files[0]?.path !== i) throw { code: "not_found" };
234
234
  return Z(r.files[0]);
235
235
  },
236
236
  async createFolder(i, s, r) {
237
- return w(i), Y(s), await n("SYNO.FileStation.CreateFolder", "create", 2, { folder_path: JSON.stringify([i]), name: JSON.stringify([s]), force_parent: "false" }, r, !0), { created: !0 };
237
+ return D(i), Y(s), await n("SYNO.FileStation.CreateFolder", "create", 2, { folder_path: JSON.stringify([i]), name: JSON.stringify([s]), force_parent: "false" }, r, !0), { created: !0 };
238
238
  },
239
239
  // Display/preview only. A successful browser result never authorizes a
240
240
  // backend write or grant; the executor independently checks its subject.
241
241
  async checkPermission(i, s) {
242
- w(i);
243
- const r = Array.from(crypto.getRandomValues(new Uint8Array(16)), (d) => d.toString(16).padStart(2, "0")).join("");
242
+ D(i);
243
+ const r = Array.from(crypto.getRandomValues(new Uint8Array(16)), (c) => c.toString(16).padStart(2, "0")).join("");
244
244
  if ((await n("SYNO.FileStation.CheckPermission", "write", 3, { path: i, filename: `.synopkgland-permission-probe-${r}`, overwrite: "false", size: "0" }, s))?.blSkip !== !1) throw { code: "denied" };
245
245
  },
246
246
  async upload(i, s, r) {
247
- if (w(i), Y(s.name), !Number.isSafeInteger(s.size) || s.size < 0 || s.size > we) throw { code: "upload_size_required" };
247
+ if (D(i), Y(s.name), !Number.isSafeInteger(s.size) || s.size < 0 || s.size > we) throw { code: "upload_size_required" };
248
248
  await n("SYNO.FileStation.Upload", "upload", 2, { path: i, create_parents: "false", overwrite: "false", size: String(s.size) }, r, !0, s);
249
249
  }
250
250
  };
251
251
  }
252
252
  const Pe = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/, k = (e) => typeof e == "string" && Pe.test(e), O = (e) => e && k(e.delegation_id) && k(e.job_id), I = (e) => typeof e == "string" && e.startsWith("/") && e !== "/" && !e.includes("\0") && !e.slice(1).split("/").some((t) => !t || t === "." || t === "..");
253
- function v() {
253
+ function S() {
254
254
  throw { code: "EXECUTOR_PROTOCOL" };
255
255
  }
256
256
  function Q(e) {
257
257
  return e && Number.isSafeInteger(e.generation) && e.generation >= 0 && I(e.root) && (e.scope === "home" ? e.root === "/home" : e.scope.startsWith("shared:") && e.root === "/" + e.scope.slice(7));
258
258
  }
259
259
  function Me(e, t) {
260
- return (!e || e.job_id !== t.job_id || !["queued", "copying", "committed", "canceled", "interrupted", "uncertain"].includes(e.state)) && v(), e.state === "committed" ? (!e.receipt || !I(e.receipt.path) || !Number.isSafeInteger(e.receipt.size) || e.receipt.size < 0 || e.receipt.size > 16 * 1024 ** 3) && v() : e.receipt !== void 0 && v(), e.reason !== void 0 && (typeof e.reason != "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(e.reason)) && v(), { job_id: e.job_id, state: e.state, ...e.receipt ? { receipt: { ...e.receipt } } : {}, ...e.code ? { code: e.code } : {}, ...e.reason ? { reason: e.reason } : {} };
260
+ return (!e || e.job_id !== t.job_id || !["queued", "copying", "committed", "canceled", "interrupted", "uncertain"].includes(e.state)) && S(), e.state === "committed" ? (!e.receipt || !I(e.receipt.path) || !Number.isSafeInteger(e.receipt.size) || e.receipt.size < 0 || e.receipt.size > 16 * 1024 ** 3) && S() : e.receipt !== void 0 && S(), e.reason !== void 0 && (typeof e.reason != "string" || !/^[A-Za-z][A-Za-z0-9_-]{0,127}$/.test(e.reason)) && S(), { job_id: e.job_id, state: e.state, ...e.receipt ? { receipt: { ...e.receipt } } : {}, ...e.code ? { code: e.code } : {}, ...e.reason ? { reason: e.reason } : {} };
261
261
  }
262
262
  function b6(e, t = async () => {
263
263
  const a = await e.call("delegate.operations.list");
264
- return Array.isArray(a?.operations) || v(), a.operations;
264
+ return Array.isArray(a?.operations) || S(), a.operations;
265
265
  }) {
266
- const a = async (n, o) => (O(o) || v(), Me(await e.call(n, { delegation_id: o.delegation_id, job_id: o.job_id }), o));
266
+ const a = async (n, o) => (O(o) || S(), Me(await e.call(n, { delegation_id: o.delegation_id, job_id: o.job_id }), o));
267
267
  return {
268
268
  async destination(n) {
269
- k(n) || v();
269
+ k(n) || S();
270
270
  const o = await e.call("delegate.destination", { key: n });
271
- if ((!o || o.key !== n || !["active", "missing", "revoked", "reselection-required", "needs-scope-confirmation", "disabled"].includes(o.status) || o.selection !== null && !Q(o.selection)) && v(), o.status === "active") {
271
+ if ((!o || o.key !== n || !["active", "missing", "revoked", "reselection-required", "needs-scope-confirmation", "disabled"].includes(o.status) || o.selection !== null && !Q(o.selection)) && S(), o.status === "active") {
272
272
  const i = o.destination, s = o.selection;
273
- (!i || !s || !k(i.id) || i.key !== n || i.lifetime !== "until-revoked" || !i.username || !I(i.path) || !(i.path === s.root || i.path.startsWith(s.root + "/"))) && v();
274
- } else o.destination !== null && v();
273
+ (!i || !s || !k(i.id) || i.key !== n || i.lifetime !== "until-revoked" || !i.username || !I(i.path) || !(i.path === s.root || i.path.startsWith(s.root + "/"))) && S();
274
+ } else o.destination !== null && S();
275
275
  return o;
276
276
  },
277
277
  async exportExample(n) {
278
- (!k(n.key) || !k(n.job_id)) && v();
278
+ (!k(n.key) || !k(n.job_id)) && S();
279
279
  const o = await e.call("delegate.example.export", { key: n.key, job_id: n.job_id });
280
- return (!O(o) || o.job_id !== n.job_id) && v(), o;
280
+ return (!O(o) || o.job_id !== n.job_id) && S(), o;
281
281
  },
282
282
  selectDestination: (n) => e.call("delegate.select_destination", { key: n.key, path: n.path }),
283
283
  async status() {
284
284
  const n = await e.call("delegate.status");
285
285
  if (!["ready", "disabled", "needs-scope-confirmation"].includes(n?.state)) throw { code: "EXECUTOR_UNAVAILABLE" };
286
- return typeof n?.disabled != "boolean" && v(), n.selection && !Q(n.selection) && v(), { disabled: n.disabled, ...n.scope_mode ? { scopeMode: n.scope_mode, selection: n.selection ?? null, preselection: n.preselection, mismatch: n.mismatch } : {} };
286
+ return typeof n?.disabled != "boolean" && S(), n.selection && !Q(n.selection) && S(), { disabled: n.disabled, ...n.scope_mode ? { scopeMode: n.scope_mode, selection: n.selection ?? null, preselection: n.preselection, mismatch: n.mismatch } : {} };
287
287
  },
288
288
  async list() {
289
289
  const n = await e.call("delegate.list");
290
- return Array.isArray(n?.delegations) || v(), n.delegations.filter((o) => o.lifetime === "until-revoked" && !o.revoked).map((o) => ((!k(o.delegation_id) || typeof o.destination != "string" || !o.destination || !I(o.path) || typeof o.subject?.username != "string" || !o.subject.username) && v(), { id: o.delegation_id, key: o.destination, path: o.path, username: o.subject.username, lifetime: "until-revoked" }));
290
+ return Array.isArray(n?.delegations) || S(), n.delegations.filter((o) => o.lifetime === "until-revoked" && !o.revoked).map((o) => ((!k(o.delegation_id) || typeof o.destination != "string" || !o.destination || !I(o.path) || typeof o.subject?.username != "string" || !o.subject.username) && S(), { id: o.delegation_id, key: o.destination, path: o.path, username: o.subject.username, lifetime: "until-revoked" }));
291
291
  },
292
292
  async operations() {
293
293
  const n = await t();
294
294
  return Promise.all(n.map(async (o) => {
295
- (typeof o?.name != "string" || !o.name || !O(o)) && v();
295
+ (typeof o?.name != "string" || !o.name || !O(o)) && S();
296
296
  const i = { delegation_id: o.delegation_id, job_id: o.job_id };
297
297
  try {
298
298
  return { ...i, name: o.name, ...await a("delegate.operations.get", i) };
@@ -303,14 +303,14 @@ function b6(e, t = async () => {
303
303
  }));
304
304
  },
305
305
  async revoke(n) {
306
- return (await e.call("delegate.revoke", { delegation_id: n.delegation_id }))?.revoked !== !0 && v(), { revoked: !0 };
306
+ return (await e.call("delegate.revoke", { delegation_id: n.delegation_id }))?.revoked !== !0 && S(), { revoked: !0 };
307
307
  },
308
308
  cancel: (n) => a("delegate.operations.cancel", n),
309
309
  async disable() {
310
- return (await e.call("delegate.disable"))?.disabled !== !0 && v(), { disabled: !0 };
310
+ return (await e.call("delegate.disable"))?.disabled !== !0 && S(), { disabled: !0 };
311
311
  },
312
312
  async enable() {
313
- return (await e.call("delegate.enable"))?.disabled !== !1 && v(), { disabled: !1 };
313
+ return (await e.call("delegate.enable"))?.disabled !== !1 && S(), { disabled: !1 };
314
314
  }
315
315
  };
316
316
  }
@@ -807,11 +807,11 @@ function z(e) {
807
807
  }
808
808
  function A(e, t) {
809
809
  const a = pe(e);
810
- return Object.fromEntries(B.map((n) => [n, C(a.en, a[n])]));
810
+ return Object.fromEntries(B.map((n) => [n, P(a.en, a[n])]));
811
811
  }
812
812
  function S6(e, t) {
813
- const a = pe(t), n = C(e.en, a.en);
814
- return Object.fromEntries(B.map((o) => [o, C(C(n, e[o]), a[o])]));
813
+ const a = pe(t), n = P(e.en, a.en);
814
+ return Object.fromEntries(B.map((o) => [o, P(P(n, e[o]), a[o])]));
815
815
  }
816
816
  function Ne(e, t, a = "en") {
817
817
  return (typeof e == "string" ? e : e[Ue(t.count, a)] ?? e.other).replace(/\{(\w+)\}/g, (o, i) => i in t ? String(t[i]) : o);
@@ -823,10 +823,10 @@ function pe(e) {
823
823
  return Object.fromEntries(Object.entries(e).map(([t, a]) => [t.slice(t.lastIndexOf("/") + 1, -5), a]));
824
824
  }
825
825
  const X = (e) => typeof e == "object" && e !== null && !Array.isArray(e), Oe = (e) => typeof e.other == "string";
826
- function C(e, t) {
826
+ function P(e, t) {
827
827
  if (!X(e) || !X(t) || Oe(t)) return t ?? e;
828
828
  const a = { ...e };
829
- for (const [n, o] of Object.entries(t)) a[n] = C(e[n], o);
829
+ for (const [n, o] of Object.entries(t)) a[n] = P(e[n], o);
830
830
  return a;
831
831
  }
832
832
  function _6(e) {
@@ -857,28 +857,28 @@ function Ve(e = {}) {
857
857
  let o = !1;
858
858
  return {
859
859
  async download(i) {
860
- if (w(i), o) throw { code: "canceled" };
860
+ if (D(i), o) throw { code: "canceled" };
861
861
  const s = await t.token();
862
862
  if (o) throw { code: "canceled" };
863
863
  const r = document.createElement("iframe");
864
864
  r.hidden = !0, r.setAttribute("sandbox", "allow-forms allow-same-origin allow-downloads"), a.add(r), document.body.append(r);
865
- const c = r.contentDocument;
866
- if (!c)
865
+ const l = r.contentDocument;
866
+ if (!l)
867
867
  throw r.remove(), a.delete(r), { code: "unavailable" };
868
- const d = c.createElement("meta");
869
- d.httpEquiv = "Content-Security-Policy", d.content = "default-src 'none'; form-action 'self'; base-uri 'none'", c.head.append(d);
870
- const g = c.createElement("form");
871
- g.method = "POST", g.action = ce;
872
- for (const [u, l] of Object.entries({ api: "SYNO.FileStation.Download", method: "download", version: "2", path: JSON.stringify([i]), mode: "download", SynoToken: s })) {
873
- const p = c.createElement("input");
874
- p.type = "hidden", p.name = u, p.value = l, g.append(p);
868
+ const c = l.createElement("meta");
869
+ c.httpEquiv = "Content-Security-Policy", c.content = "default-src 'none'; form-action 'self'; base-uri 'none'", l.head.append(c);
870
+ const p = l.createElement("form");
871
+ p.method = "POST", p.action = ce;
872
+ for (const [u, d] of Object.entries({ api: "SYNO.FileStation.Download", method: "download", version: "2", path: JSON.stringify([i]), mode: "download", SynoToken: s })) {
873
+ const h = l.createElement("input");
874
+ h.type = "hidden", h.name = u, h.value = d, p.append(h);
875
875
  }
876
- c.body.append(g);
876
+ l.body.append(p);
877
877
  try {
878
- g.submit();
878
+ p.submit();
879
879
  } finally {
880
- for (const u of Array.from(g.querySelectorAll("input"))) u.value = "";
881
- g.remove();
880
+ for (const u of Array.from(p.querySelectorAll("input"))) u.value = "";
881
+ p.remove();
882
882
  }
883
883
  },
884
884
  dispose() {
@@ -890,89 +890,95 @@ function Ve(e = {}) {
890
890
  },
891
891
  async upload(i, s, r) {
892
892
  if (o) throw { code: "canceled" };
893
- const c = new AbortController(), d = () => c.abort();
894
- n.add(c), r.addEventListener("abort", d, { once: !0 }), r.aborted && c.abort();
893
+ const l = new AbortController(), c = () => l.abort();
894
+ n.add(l), r.addEventListener("abort", c, { once: !0 }), r.aborted && l.abort();
895
895
  try {
896
- await t.upload(i, s, c.signal);
896
+ await t.upload(i, s, l.signal);
897
897
  } finally {
898
- n.delete(c), r.removeEventListener("abort", d);
898
+ n.delete(l), r.removeEventListener("abort", c);
899
899
  }
900
900
  }
901
901
  };
902
902
  }
903
- function b(e = "unavailable") {
903
+ function _(e = "unavailable") {
904
904
  throw { code: e };
905
905
  }
906
906
  function j(e) {
907
- return (!e || typeof e != "object" || Array.isArray(e)) && b(), e;
907
+ return (!e || typeof e != "object" || Array.isArray(e)) && _(), e;
908
908
  }
909
909
  const he = (e) => typeof e == "number" && Number.isSafeInteger(e) && e >= 0;
910
910
  function ge(e) {
911
911
  const t = j(e), a = j(t.additional ?? {});
912
- return (typeof t.name != "string" || typeof t.path != "string" || typeof t.isdir != "boolean" || a.size !== void 0 && !he(a.size)) && b(), { name: t.name, path: t.path, isDir: t.isdir, ...a.size === void 0 ? {} : { bytes: a.size } };
912
+ return (typeof t.name != "string" || typeof t.path != "string" || typeof t.isdir != "boolean" || a.size !== void 0 && !he(a.size)) && _(), { name: t.name, path: t.path, isDir: t.isdir, ...a.size === void 0 ? {} : { bytes: a.size } };
913
913
  }
914
914
  const We = /* @__PURE__ */ new Set(["#recycle", "#snapshot", "@eaDir", "@tmp", "@sharebin"]);
915
915
  function ee(e, t, a) {
916
916
  const n = j(e), o = n.shares ?? n.files;
917
- (!Array.isArray(o) || o.length > a || !he(n.total) || n.offset !== t || t + o.length > n.total) && b();
917
+ (!Array.isArray(o) || o.length > a || !he(n.total) || n.offset !== t || t + o.length > n.total) && _();
918
918
  const i = o.map(ge), s = t + i.length;
919
- return s < n.total && !i.length && b(), { entries: i.filter((r) => !We.has(r.name)), total: n.total, offset: t, ...s < n.total ? { nextOffset: s } : {} };
919
+ return s < n.total && !i.length && _(), { entries: i.filter((r) => !We.has(r.name)), total: n.total, offset: t, ...s < n.total ? { nextOffset: s } : {} };
920
920
  }
921
921
  function Je(e) {
922
922
  let t = !1;
923
923
  const a = new AbortController(), n = Ve(e.files), o = le({ webApi: e.webApi, token: e.files?.token, timeout: L(e.requestTimeout) });
924
- async function i(s, r, c, d = !1) {
925
- (t || c.aborted) && b("canceled");
926
- let g = () => {
924
+ let i;
925
+ function s() {
926
+ return i ??= e.call("nas.session.status", {}, { signal: a.signal }).finally(() => {
927
+ i = void 0;
928
+ }), i;
929
+ }
930
+ async function r(l, c, p, u = !1) {
931
+ (t || p.aborted) && _("canceled");
932
+ let d = () => {
927
933
  };
928
- const u = new Promise((h, m) => {
929
- const $ = () => m({ code: d ? "commit-uncertain" : "canceled" }), _ = setTimeout(() => m({ code: d ? "commit-uncertain" : "timeout" }), L(e.requestTimeout));
930
- c.addEventListener("abort", $, { once: !0 }), a.signal.addEventListener("abort", $, { once: !0 }), g = () => {
931
- clearTimeout(_), c.removeEventListener("abort", $), a.signal.removeEventListener("abort", $);
934
+ const h = new Promise((b, $) => {
935
+ const v = () => $({ code: u ? "commit-uncertain" : "canceled" }), w = setTimeout(() => $({ code: u ? "commit-uncertain" : "timeout" }), L(e.requestTimeout));
936
+ p.addEventListener("abort", v, { once: !0 }), a.signal.addEventListener("abort", v, { once: !0 }), d = () => {
937
+ clearTimeout(w), p.removeEventListener("abort", v), a.signal.removeEventListener("abort", v);
932
938
  };
933
- }), l = new AbortController(), p = () => l.abort();
934
- c.addEventListener("abort", p, { once: !0 }), a.signal.addEventListener("abort", p, { once: !0 });
939
+ }), m = new AbortController(), g = () => m.abort();
940
+ p.addEventListener("abort", g, { once: !0 }), a.signal.addEventListener("abort", g, { once: !0 });
935
941
  async function f() {
936
- switch (await e.call("nas.session.status", {}, { signal: l.signal }), l.signal.aborted && b("canceled"), s) {
942
+ switch (await s(), m.signal.aborted && _("canceled"), l) {
937
943
  case "nas.files.shares":
938
- return o.shares(r.offset, l.signal);
944
+ return o.shares(c.offset, m.signal);
939
945
  case "nas.files.list":
940
- return o.list(r.path, r, l.signal);
946
+ return o.list(c.path, c, m.signal);
941
947
  case "nas.files.info":
942
- return o.info(r.path, l.signal);
948
+ return o.info(c.path, m.signal);
943
949
  case "nas.files.create_folder":
944
- return o.createFolder(r.parent, r.name, l.signal);
950
+ return o.createFolder(c.parent, c.name, m.signal);
945
951
  }
946
- b("unsupported");
952
+ _("unsupported");
947
953
  }
948
954
  try {
949
- return await Promise.race([f(), u]);
950
- } catch (h) {
951
- const m = h?.code;
952
- H(h) && b(H(h)), [407, 408, "407", "408", "denied"].includes(m) && b("denied"), (m === "cross_origin" || m === "origin_required") && b("origin-refused"), (m === "request_timeout" || m === "request_canceled") && b(d ? "commit-uncertain" : m === "request_timeout" ? "timeout" : "canceled"), b(typeof m == "string" && ["session_required", "dsm_session_required", "auth_unavailable", "denied", "not_found", "conflict", "invalid-request", "unavailable", "unknown_method", "unsupported", "commit-uncertain", "canceled", "timeout"].includes(m) ? m : d ? "commit-uncertain" : "unavailable");
955
+ return await Promise.race([f(), h]);
956
+ } catch (b) {
957
+ const $ = b?.code;
958
+ H(b) && _(H(b)), [407, 408, "407", "408", "denied"].includes($) && _("denied"), ($ === "cross_origin" || $ === "origin_required") && _("origin-refused"), ($ === "request_timeout" || $ === "request_canceled") && _(u ? "commit-uncertain" : $ === "request_timeout" ? "timeout" : "canceled"), _(typeof $ == "string" && ["session_required", "dsm_session_required", "auth_unavailable", "denied", "not_found", "conflict", "invalid-request", "unavailable", "unknown_method", "unsupported", "commit-uncertain", "canceled", "timeout"].includes($) ? $ : u ? "commit-uncertain" : "unavailable");
953
959
  } finally {
954
- g(), l.abort(), c.removeEventListener("abort", p), a.signal.removeEventListener("abort", p);
960
+ d(), m.abort(), p.removeEventListener("abort", g), a.signal.removeEventListener("abort", g);
955
961
  }
956
962
  }
957
963
  return {
958
- async upload(s, r, c) {
959
- (t || c.aborted) && b("canceled"), await e.call("nas.session.status", {}, { signal: c }), (t || c.aborted) && b("canceled"), await n.upload(s, r, c);
964
+ async upload(l, c, p) {
965
+ (t || p.aborted) && _("canceled"), await e.call("nas.session.status", {}, { signal: p }), (t || p.aborted) && _("canceled"), await n.upload(l, c, p);
960
966
  },
961
- async download(s) {
962
- t && b("canceled"), await e.call("nas.session.status"), t && b("canceled"), await n.download(s);
967
+ async download(l) {
968
+ t && _("canceled"), await e.call("nas.session.status"), t && _("canceled"), await n.download(l);
963
969
  },
964
- async shares(s, r) {
965
- return ee(await i("nas.files.shares", { offset: s }, r), s, 100);
970
+ async shares(l, c) {
971
+ return ee(await r("nas.files.shares", { offset: l }, c), l, 100);
966
972
  },
967
- async list(s, r, c) {
968
- const d = r.offset ?? 0, g = r.limit ?? 100;
969
- return ee(await i("nas.files.list", { path: s, ...r, offset: d, limit: g }, c), d, g);
973
+ async list(l, c, p) {
974
+ const u = c.offset ?? 0, d = c.limit ?? 100;
975
+ return ee(await r("nas.files.list", { path: l, ...c, offset: u, limit: d }, p), u, d);
970
976
  },
971
- async info(s, r) {
972
- return ge(await i("nas.files.info", { path: s }, r));
977
+ async info(l, c) {
978
+ return ge(await r("nas.files.info", { path: l }, c));
973
979
  },
974
- async createFolder(s, r, c) {
975
- j(await i("nas.files.create_folder", { parent: s, name: r }, c, !0)).created !== !0 && b("commit-uncertain");
980
+ async createFolder(l, c, p) {
981
+ j(await r("nas.files.create_folder", { parent: l, name: c }, p, !0)).created !== !0 && _("commit-uncertain");
976
982
  },
977
983
  dispose() {
978
984
  t = !0, a.abort(), n?.dispose();
@@ -2277,7 +2283,7 @@ function T6(e) {
2277
2283
  return ve[z(e)];
2278
2284
  }
2279
2285
  function E6(e, t, a, n) {
2280
- const o = x(e, a ?? Object.entries(ve).find(([, c]) => c === t)?.[0], n);
2286
+ const o = x(e, a ?? Object.entries(ve).find(([, l]) => l === t)?.[0], n);
2281
2287
  if (o) return o.message;
2282
2288
  const i = V(e, a);
2283
2289
  if (i) return i;
@@ -3434,10 +3440,10 @@ function s4(e = "en") {
3434
3440
  return Se[z(e)];
3435
3441
  }
3436
3442
  function x6(e, t = s4(), a = "save", n, o) {
3437
- const i = x(e, n ?? Object.entries(Se).find(([, d]) => d === t)?.[0], o);
3443
+ const i = x(e, n ?? Object.entries(Se).find(([, c]) => c === t)?.[0], o);
3438
3444
  if (i) return i.message;
3439
- const s = a === "select", r = e?.code, c = V(e, n);
3440
- return c || (r === "disabled" ? t.disabled : ["EXECUTOR_UNAVAILABLE", "needs-admin-approval", "needs-scope-confirmation"].includes(r ?? "") ? t.needs : ["session_required", "dsm_session_required", "AUTH_DENIED"].includes(r ?? "") ? t.session : ["DENIED", "DELEGATION_DENIED", "IDENTITY_CHANGED", "SCOPE_DENIED", "INELIGIBLE", "DESTINATION_CHANGED", "denied", "grant-revoked", "identity-changed", "permission-changed"].includes(r ?? "") ? t.denied : r === "PERMISSION_DENIED" ? s ? t.permissionSelect : t.permission : r === "not-found" ? t.missing : r === "APP_DENIED" ? s ? t.appPrivilegeSelect : t.appPrivilege : ["CONFLICT", "conflict", "file-exists", "destination-exists"].includes(r ?? "") ? t.conflict : ["NO_SPACE", "ENOSPC", "no-space"].includes(r ?? "") ? t.space : ["uncertain", "commit-uncertain"].includes(r ?? "") ? t.uncertainHelp : t.error);
3445
+ const s = a === "select", r = e?.code, l = V(e, n);
3446
+ return l || (r === "disabled" ? t.disabled : ["EXECUTOR_UNAVAILABLE", "needs-admin-approval", "needs-scope-confirmation"].includes(r ?? "") ? t.needs : ["session_required", "dsm_session_required", "AUTH_DENIED"].includes(r ?? "") ? t.session : ["DENIED", "DELEGATION_DENIED", "IDENTITY_CHANGED", "SCOPE_DENIED", "INELIGIBLE", "DESTINATION_CHANGED", "denied", "grant-revoked", "identity-changed", "permission-changed"].includes(r ?? "") ? t.denied : r === "PERMISSION_DENIED" ? s ? t.permissionSelect : t.permission : r === "not-found" ? t.missing : r === "APP_DENIED" ? s ? t.appPrivilegeSelect : t.appPrivilege : ["CONFLICT", "conflict", "file-exists", "destination-exists"].includes(r ?? "") ? t.conflict : ["NO_SPACE", "ENOSPC", "no-space"].includes(r ?? "") ? t.space : ["uncertain", "commit-uncertain"].includes(r ?? "") ? t.uncertainHelp : t.error);
3441
3447
  }
3442
3448
  const r4 = {
3443
3449
  "portal.title": "Anwendungsportal",
@@ -3776,12 +3782,12 @@ const ne = /^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/, WO = [
3776
3782
  "synologymeet"
3777
3783
  ], oe = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/, JO = ["registered", "unregistered", "cleanup-required"], KO = { dsm_4100: "portal_alias_invalid", dsm_4102: "portal_alias_reserved", dsm_4103: "portal_alias_in_use", dsm_105: "admin_required" }, ae = (e) => e?.code;
3778
3784
  function U6(e) {
3779
- function t(h, m, $) {
3780
- const _ = { state: h, canManage: $ === !0, controlPanel: $ !== void 0, defaultAlias: e.defaultAlias };
3781
- return h === "active" && m && (_.alias = m, _.url = `${e.location.protocol}//${e.location.host}/${encodeURIComponent(m)}/`), _;
3785
+ function t(g, f, b) {
3786
+ const $ = { state: g, canManage: b === !0, controlPanel: b !== void 0, defaultAlias: e.defaultAlias };
3787
+ return g === "active" && f && ($.alias = f, $.url = `${e.location.protocol}//${e.location.host}/${encodeURIComponent(f)}/`), $;
3782
3788
  }
3783
- function a(h) {
3784
- return h?.state === "active" && typeof h.alias == "string" && oe.test(h.alias) ? t("active", h.alias) : t(h?.state === "inactive" ? "inactive" : "unavailable");
3789
+ function a(g) {
3790
+ return g?.state === "active" && typeof g.alias == "string" && oe.test(g.alias) ? t("active", g.alias) : t(g?.state === "inactive" ? "inactive" : "unavailable");
3785
3791
  }
3786
3792
  async function n() {
3787
3793
  try {
@@ -3793,76 +3799,76 @@ function U6(e) {
3793
3799
  async function o() {
3794
3800
  try {
3795
3801
  if (!(((await e.send("SYNO.API.Info", "query", 1, { query: "SYNO.Core.AppPortal" }))?.["SYNO.Core.AppPortal"]?.maxVersion ?? 0) >= 2)) return t("unavailable", void 0, !1);
3796
- const m = await e.send("SYNO.Core.AppPortal", "get", 2, { id: e.appId, additional: ["default_setting"] });
3797
- if (m?.id !== e.appId) return t("unavailable", void 0, !1);
3798
- const $ = typeof m.alias == "string" && oe.test(m.alias) ? m.alias : "", _ = t($ ? "active" : "inactive", $, !0), S = m.additional?.default_setting?.alias;
3799
- return typeof S == "string" && ne.test(S) && (_.defaultAlias = S), _;
3802
+ const f = await e.send("SYNO.Core.AppPortal", "get", 2, { id: e.appId, additional: ["default_setting"] });
3803
+ if (f?.id !== e.appId) return t("unavailable", void 0, !1);
3804
+ const b = typeof f.alias == "string" && oe.test(f.alias) ? f.alias : "", $ = t(b ? "active" : "inactive", b, !0), v = f.additional?.default_setting?.alias;
3805
+ return typeof v == "string" && ne.test(v) && ($.defaultAlias = v), $;
3800
3806
  } catch {
3801
3807
  return t("unavailable", void 0, !1);
3802
3808
  }
3803
3809
  }
3804
3810
  async function i() {
3805
- let h;
3811
+ let g;
3806
3812
  try {
3807
- h = await e.call("portal.status", {});
3813
+ g = await e.call("portal.status", {});
3808
3814
  } catch {
3809
3815
  return e.isAdmin() ? t("unavailable", void 0, !1) : t("unavailable");
3810
3816
  }
3811
- if (!e.isAdmin()) return a(h);
3812
- const m = JO.find((_) => _ === h?.entry);
3813
- if (!m) return t("unavailable", void 0, !1);
3814
- if (m === "registered") return { ...await o(), entry: m };
3815
- const $ = a(h);
3816
- return { ...t(m === "unregistered" ? "inactive" : $.state, $.alias, !0), entry: m };
3817
+ if (!e.isAdmin()) return a(g);
3818
+ const f = JO.find(($) => $ === g?.entry);
3819
+ if (!f) return t("unavailable", void 0, !1);
3820
+ if (f === "registered") return { ...await o(), entry: f };
3821
+ const b = a(g);
3822
+ return { ...t(f === "unregistered" ? "inactive" : b.state, b.alias, !0), entry: f };
3817
3823
  }
3818
- let s = Promise.resolve(), r, c, d = 0;
3819
- async function g() {
3820
- const h = ++d;
3824
+ let s = Promise.resolve(), r, l, c = 0;
3825
+ async function p() {
3826
+ const g = ++c;
3821
3827
  await s;
3822
- const m = e.entry ? await i() : e.isAdmin() ? await o() : await n();
3823
- return h === d && (r = m), m;
3828
+ const f = e.entry ? await i() : e.isAdmin() ? await o() : await n();
3829
+ return g === c && (r = f), f;
3824
3830
  }
3825
3831
  function u() {
3826
- return c ??= g().finally(() => {
3827
- c = void 0;
3832
+ return l ??= p().finally(() => {
3833
+ l = void 0;
3828
3834
  });
3829
3835
  }
3830
- async function l(h) {
3836
+ async function d(g) {
3831
3837
  if (!e.isAdmin()) throw { code: "admin_required" };
3832
- const m = e.call(h, {});
3833
- s = m.catch(() => {
3834
- }), c = void 0;
3838
+ const f = e.call(g, {});
3839
+ s = f.catch(() => {
3840
+ }), l = void 0;
3835
3841
  try {
3836
- await m;
3837
- } catch ($) {
3838
- throw { code: ae($) === "ADMIN_REQUIRED" ? "admin_required" : "PORTAL_FAILED" };
3842
+ await f;
3843
+ } catch (b) {
3844
+ throw { code: ae(b) === "ADMIN_REQUIRED" ? "admin_required" : "PORTAL_FAILED" };
3839
3845
  }
3840
- return g();
3846
+ return p();
3841
3847
  }
3842
- async function p(h) {
3848
+ async function h(g) {
3843
3849
  if (!e.isAdmin()) throw { code: "admin_required" };
3844
3850
  try {
3845
- await e.send("SYNO.Core.AppPortal", "set", 2, { id: e.appId, alias: h });
3846
- } catch (m) {
3847
- throw { code: KO[ae(m) ?? ""] ?? "portal_unavailable" };
3851
+ await e.send("SYNO.Core.AppPortal", "set", 2, { id: e.appId, alias: g });
3852
+ } catch (f) {
3853
+ throw { code: KO[ae(f) ?? ""] ?? "portal_unavailable" };
3848
3854
  }
3849
- return g();
3855
+ return p();
3850
3856
  }
3851
- const f = {
3857
+ const m = {
3852
3858
  messages: $4(e.locale),
3853
3859
  status: u,
3854
3860
  lastStatus: () => r,
3855
- async apply(h) {
3856
- if (typeof h != "string" || !ne.test(h)) throw { code: "portal_alias_invalid" };
3857
- if (WO.includes(h)) throw { code: "portal_alias_reserved" };
3858
- return p(h);
3861
+ async apply(g) {
3862
+ if (typeof g != "string" || !ne.test(g)) throw { code: "portal_alias_invalid" };
3863
+ if (WO.includes(g)) throw { code: "portal_alias_reserved" };
3864
+ return h(g);
3859
3865
  },
3860
- disable: () => p(null),
3866
+ disable: () => h(null),
3861
3867
  openControlPanel() {
3862
3868
  e.launch("SYNO.SDS.AdminCenter.Application", { fn: "SYNO.SDS.AdminCenter.Login.Main", tab: "applications" });
3863
3869
  }
3864
3870
  };
3865
- return e.entry && (f.register = () => l("portal.register"), f.unregister = () => l("portal.unregister")), u(), f;
3871
+ return e.entry && (m.register = () => d("portal.register"), m.unregister = () => d("portal.unregister")), u(), m;
3866
3872
  }
3867
3873
  const GO = {
3868
3874
  "sharedfolder.title": "Freigegebene Ordner",
@@ -4155,25 +4161,25 @@ function _e(e) {
4155
4161
  canGrant: () => e.isAdmin() && e.send !== void 0,
4156
4162
  async grant(o) {
4157
4163
  if (!e.isAdmin() || !e.send) throw { code: "admin_required" };
4158
- const i = await a(), s = i.folders.find((d) => d.key === o);
4164
+ const i = await a(), s = i.folders.find((c) => c.key === o);
4159
4165
  if (!s || s.state === "missing" || s.state === "ambiguous") throw { code: "shared_folder_unavailable" };
4160
4166
  if (s.state === "ready") return i;
4161
4167
  if (s.required === "none") throw { code: "shared_folder_unavailable" };
4162
4168
  const r = s.required === "write";
4163
4169
  try {
4164
- const d = J(await e.send("SYNO.Core.Share.Permission", "list", 1, { name: s.name, user_group_type: "system", offset: 0, limit: 1e3, with_inherit: !1, is_unite_permission: !1 }));
4165
- if ((Array.isArray(d?.items) ? d.items : []).some((u) => u?.name === i.account && u.is_custom === !0)) throw { code: "shared_folder_custom_acl" };
4166
- } catch (d) {
4167
- if (se(d) === "shared_folder_custom_acl") throw d;
4170
+ const c = J(await e.send("SYNO.Core.Share.Permission", "list", 1, { name: s.name, user_group_type: "system", offset: 0, limit: 1e3, with_inherit: !1, is_unite_permission: !1 }));
4171
+ if ((Array.isArray(c?.items) ? c.items : []).some((u) => u?.name === i.account && u.is_custom === !0)) throw { code: "shared_folder_custom_acl" };
4172
+ } catch (c) {
4173
+ if (se(c) === "shared_folder_custom_acl") throw c;
4168
4174
  }
4169
4175
  try {
4170
4176
  await e.send("SYNO.Core.Share.Permission", "set", 1, { name: s.name, user_group_type: "system", permissions: [{ name: i.account, is_readonly: !r, is_writable: r, is_deny: !1, is_custom: !1 }] });
4171
- } catch (d) {
4172
- throw { code: se(d) === "dsm_105" ? "admin_required" : "shared_folder_grant_failed" };
4177
+ } catch (c) {
4178
+ throw { code: se(c) === "dsm_105" ? "admin_required" : "shared_folder_grant_failed" };
4173
4179
  }
4174
- const c = await a();
4175
- if (c.folders.find((d) => d.key === o)?.state !== "ready") throw { code: "shared_folder_grant_unverified" };
4176
- return c;
4180
+ const l = await a();
4181
+ if (l.folders.find((c) => c.key === o)?.state !== "ready") throw { code: "shared_folder_grant_unverified" };
4182
+ return l;
4177
4183
  },
4178
4184
  openControlPanel() {
4179
4185
  e.launch?.("SYNO.SDS.AdminCenter.Application", { fn: "SYNO.SDS.AdminCenter.Share.Main" });
@@ -4204,40 +4210,40 @@ function l6(e, t = "en") {
4204
4210
  function F6(e) {
4205
4211
  const t = e.locale ?? "en", a = _e({ call: e.call, locale: t, isAdmin: () => !1 }), n = /* @__PURE__ */ new Set();
4206
4212
  let o = [], i, s, r = 0;
4207
- function c(u) {
4208
- const l = /* @__PURE__ */ new Map();
4209
- for (const p of u) l.set(JSON.stringify([p.account, p.share, p.required]), p);
4210
- o = [...l.values()];
4211
- for (const p of n) p(o);
4213
+ function l(u) {
4214
+ const d = /* @__PURE__ */ new Map();
4215
+ for (const h of u) d.set(JSON.stringify([h.account, h.share, h.required]), h);
4216
+ o = [...d.values()];
4217
+ for (const h of n) h(o);
4212
4218
  }
4213
- function d(u) {
4219
+ function c(u) {
4214
4220
  if (s) return s;
4215
- const l = r;
4216
- return s = a.status().then((p) => {
4217
- const f = p.folders.filter((h) => h.state === "pending" && h.required !== "none").map((h) => ({ account: p.account, share: h.name, required: h.required }));
4218
- u && l === r ? c(f) : f.length && c([...f, ...o]);
4221
+ const d = r;
4222
+ return s = a.status().then((h) => {
4223
+ const m = h.folders.filter((g) => g.state === "pending" && g.required !== "none").map((g) => ({ account: h.account, share: g.name, required: g.required }));
4224
+ u && d === r ? l(m) : m.length && l([...m, ...o]);
4219
4225
  }).finally(() => {
4220
4226
  s = void 0;
4221
4227
  }), s;
4222
4228
  }
4223
- const g = {
4229
+ const p = {
4224
4230
  messages: W(t),
4225
4231
  message: (u) => l6(u, t),
4226
4232
  check() {
4227
- return i ??= d(!1);
4233
+ return i ??= c(!1);
4228
4234
  },
4229
4235
  retry() {
4230
- return d(!0);
4236
+ return c(!0);
4231
4237
  },
4232
4238
  handle(u) {
4233
- const l = c6(u);
4234
- return l ? (r++, c([...o, l]), !0) : !1;
4239
+ const d = c6(u);
4240
+ return d ? (r++, l([...o, d]), !0) : !1;
4235
4241
  },
4236
- async call(u, l, p) {
4242
+ async call(u, d, h) {
4237
4243
  try {
4238
- return await e.call(u, l, p);
4239
- } catch (f) {
4240
- throw g.handle(f), f;
4244
+ return await e.call(u, d, h);
4245
+ } catch (m) {
4246
+ throw p.handle(m), m;
4241
4247
  }
4242
4248
  },
4243
4249
  subscribe(u) {
@@ -4247,7 +4253,7 @@ function F6(e) {
4247
4253
  },
4248
4254
  openControlPanel: () => e.openControlPanel?.()
4249
4255
  };
4250
- return g;
4256
+ return p;
4251
4257
  }
4252
4258
  const d6 = {
4253
4259
  /** The DSM session in auth is missing, invalid or expired. */
@@ -4442,8 +4448,8 @@ function W6(e, t, a) {
4442
4448
  const r = await e.call("app.status", {}, { signal: n.signal });
4443
4449
  !r || typeof r.user != "string" || !r.user || typeof r.admin != "boolean" ? s = { code: "auth_unavailable" } : t === "admin-only" && !r.admin && (s = { code: "admin_required" });
4444
4450
  } catch (r) {
4445
- const c = r?.code;
4446
- s = { code: c === "session_required" || c === "admin_required" || c === "app_privilege_denied" ? c : "auth_unavailable" };
4451
+ const l = r?.code;
4452
+ s = { code: l === "session_required" || l === "admin_required" || l === "app_privilege_denied" ? l : "auth_unavailable" };
4447
4453
  }
4448
4454
  n.signal.aborted || a(s);
4449
4455
  }
@@ -4481,25 +4487,25 @@ function J6(e) {
4481
4487
  async function a(n, o) {
4482
4488
  const i = new AbortController(), s = { code: "request_canceled", message: "request canceled" };
4483
4489
  let r;
4484
- const c = () => {
4490
+ const l = () => {
4485
4491
  r = s, i.abort();
4486
- }, d = setTimeout(() => {
4492
+ }, c = setTimeout(() => {
4487
4493
  r = { code: "request_timeout", message: "request timeout" }, i.abort();
4488
- }, L(e.requestTimeout)), g = o?.signal;
4489
- if (g?.aborted)
4490
- throw clearTimeout(d), s;
4491
- g?.addEventListener("abort", c);
4494
+ }, L(e.requestTimeout)), p = o?.signal;
4495
+ if (p?.aborted)
4496
+ throw clearTimeout(c), s;
4497
+ p?.addEventListener("abort", l);
4492
4498
  try {
4493
- if (e.ready && !e.token?.() && await Promise.race([e.ready(), new Promise((h) => i.signal.addEventListener("abort", () => h(), { once: !0 }))]), r) throw r;
4494
- const u = e.token?.(), p = await (await t(e.endpoint, { method: "POST", mode: "same-origin", credentials: "same-origin", redirect: "error", cache: "no-store", headers: { "Content-Type": "application/json", ...u ? { "X-SYNO-TOKEN": u } : {} }, body: JSON.stringify(n), signal: i.signal })).json();
4495
- if (!p || typeof p != "object" || !("success" in p)) throw { code: "bad_response", message: "unexpected response" };
4496
- const f = p;
4497
- if (!f.success) throw f.error ?? { code: "bad_response", message: "unexpected response" };
4498
- return f.data;
4499
+ if (e.ready && !e.token?.() && await Promise.race([e.ready(), new Promise((g) => i.signal.addEventListener("abort", () => g(), { once: !0 }))]), r) throw r;
4500
+ const u = e.token?.(), h = await (await t(e.endpoint, { method: "POST", mode: "same-origin", credentials: "same-origin", redirect: "error", cache: "no-store", headers: { "Content-Type": "application/json", ...u ? { "X-SYNO-TOKEN": u } : {} }, body: JSON.stringify(n), signal: i.signal })).json();
4501
+ if (!h || typeof h != "object" || !("success" in h)) throw { code: "bad_response", message: "unexpected response" };
4502
+ const m = h;
4503
+ if (!m.success) throw m.error ?? { code: "bad_response", message: "unexpected response" };
4504
+ return m.data;
4499
4505
  } catch (u) {
4500
4506
  throw r ?? u;
4501
4507
  } finally {
4502
- clearTimeout(d), g?.removeEventListener("abort", c);
4508
+ clearTimeout(c), p?.removeEventListener("abort", l);
4503
4509
  }
4504
4510
  }
4505
4511
  return { call: (n, o, i) => a({ method: n, params: o ?? {} }, i), batch: h6(a) };
@@ -4521,8 +4527,8 @@ async function K6(e) {
4521
4527
  signal: a.signal,
4522
4528
  headers: { "Content-Type": "application/x-www-form-urlencoded", "X-SYNO-TOKEN": s },
4523
4529
  body: new URLSearchParams({ api: "SYNO.Core.Service.PortInfo", version: "1", method: "load", SynoToken: s })
4524
- }), c = r.ok ? await r.json() : void 0;
4525
- return c?.success === !0 ? c.data : void 0;
4530
+ }), l = r.ok ? await r.json() : void 0;
4531
+ return l?.success === !0 ? l.data : void 0;
4526
4532
  }, o = await Promise.race([n(), new Promise((s) => {
4527
4533
  t = setTimeout(() => {
4528
4534
  a.abort(), s(void 0);
@@ -4532,21 +4538,21 @@ async function K6(e) {
4532
4538
  const i = (s) => typeof s == "string" ? s.trim() : "";
4533
4539
  return o.port_info.flatMap((s) => {
4534
4540
  if (!s || typeof s != "object") return [];
4535
- const r = s, c = i(r.port_id), d = i(r.protocol);
4536
- if (!c || !Array.isArray(r.dst_port)) return [];
4537
- const g = r.dst_port.flatMap((u) => {
4538
- const l = /^(\d{1,5})(?:[-:](\d{1,5}))?$/.exec(i(u));
4539
- if (!l) return [];
4540
- const p = Number(l[1]), f = Number(l[2] ?? l[1]);
4541
- return p >= 1 && f <= 65535 && f >= p ? [{ first: p, last: f }] : [];
4541
+ const r = s, l = i(r.port_id), c = i(r.protocol);
4542
+ if (!l || !Array.isArray(r.dst_port)) return [];
4543
+ const p = r.dst_port.flatMap((u) => {
4544
+ const d = /^(\d{1,5})(?:[-:](\d{1,5}))?$/.exec(i(u));
4545
+ if (!d) return [];
4546
+ const h = Number(d[1]), m = Number(d[2] ?? d[1]);
4547
+ return h >= 1 && m <= 65535 && m >= h ? [{ first: h, last: m }] : [];
4542
4548
  });
4543
4549
  return [{
4544
- id: c,
4550
+ id: l,
4545
4551
  name: i(r.name),
4546
4552
  desc: i(r.desc),
4547
- protocol: d,
4553
+ protocol: c,
4548
4554
  ports: r.dst_port.map(i).filter((u) => /^\d{1,5}$/.test(u)).map(Number).filter((u) => u >= 1 && u <= 65535),
4549
- ranges: g
4555
+ ranges: p
4550
4556
  }];
4551
4557
  });
4552
4558
  } catch {