@nextcloud/files 3.0.1-beta.0 → 3.1.0

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.cjs ADDED
@@ -0,0 +1,2194 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const _ = require("@nextcloud/auth"), W = require("@nextcloud/logger"), ge = require("@nextcloud/l10n"), b = require("path"), we = require("@nextcloud/paths"), me = require("@nextcloud/router"), Z = require("webdav");
4
+ /**
5
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
6
+ *
7
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
8
+ *
9
+ * @license AGPL-3.0-or-later
10
+ *
11
+ * This program is free software: you can redistribute it and/or modify
12
+ * it under the terms of the GNU Affero General Public License as
13
+ * published by the Free Software Foundation, either version 3 of the
14
+ * License, or (at your option) any later version.
15
+ *
16
+ * This program is distributed in the hope that it will be useful,
17
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
+ * GNU Affero General Public License for more details.
20
+ *
21
+ * You should have received a copy of the GNU Affero General Public License
22
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
23
+ *
24
+ */
25
+ const Ne = (e) => e === null ? W.getLoggerBuilder().setApp("files").build() : W.getLoggerBuilder().setApp("files").setUid(e.uid).build(), N = Ne(_.getCurrentUser());
26
+ /**
27
+ * @copyright Copyright (c) 2021 John Molakvoæ <skjnldsv@protonmail.com>
28
+ *
29
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
30
+ *
31
+ * @license AGPL-3.0-or-later
32
+ *
33
+ * This program is free software: you can redistribute it and/or modify
34
+ * it under the terms of the GNU Affero General Public License as
35
+ * published by the Free Software Foundation, either version 3 of the
36
+ * License, or (at your option) any later version.
37
+ *
38
+ * This program is distributed in the hope that it will be useful,
39
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
40
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41
+ * GNU Affero General Public License for more details.
42
+ *
43
+ * You should have received a copy of the GNU Affero General Public License
44
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
45
+ *
46
+ */
47
+ class Ee {
48
+ _entries = [];
49
+ registerEntry(t) {
50
+ this.validateEntry(t), this._entries.push(t);
51
+ }
52
+ unregisterEntry(t) {
53
+ const r = typeof t == "string" ? this.getEntryIndex(t) : this.getEntryIndex(t.id);
54
+ if (r === -1) {
55
+ N.warn("Entry not found, nothing removed", { entry: t, entries: this.getEntries() });
56
+ return;
57
+ }
58
+ this._entries.splice(r, 1);
59
+ }
60
+ /**
61
+ * Get the list of registered entries
62
+ *
63
+ * @param {Folder} context the creation context. Usually the current folder
64
+ */
65
+ getEntries(t) {
66
+ return t ? this._entries.filter((r) => typeof r.enabled == "function" ? r.enabled(t) : !0) : this._entries;
67
+ }
68
+ getEntryIndex(t) {
69
+ return this._entries.findIndex((r) => r.id === t);
70
+ }
71
+ validateEntry(t) {
72
+ if (!t.id || !t.displayName || !(t.iconSvgInline || t.iconClass) || !t.handler)
73
+ throw new Error("Invalid entry");
74
+ if (typeof t.id != "string" || typeof t.displayName != "string")
75
+ throw new Error("Invalid id or displayName property");
76
+ if (t.iconClass && typeof t.iconClass != "string" || t.iconSvgInline && typeof t.iconSvgInline != "string")
77
+ throw new Error("Invalid icon provided");
78
+ if (t.enabled !== void 0 && typeof t.enabled != "function")
79
+ throw new Error("Invalid enabled property");
80
+ if (typeof t.handler != "function")
81
+ throw new Error("Invalid handler property");
82
+ if ("order" in t && typeof t.order != "number")
83
+ throw new Error("Invalid order property");
84
+ if (this.getEntryIndex(t.id) !== -1)
85
+ throw new Error("Duplicate entry");
86
+ }
87
+ }
88
+ const S = function() {
89
+ return typeof window._nc_newfilemenu > "u" && (window._nc_newfilemenu = new Ee(), N.debug("NewFileMenu initialized")), window._nc_newfilemenu;
90
+ };
91
+ /**
92
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
93
+ *
94
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
95
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
96
+ *
97
+ * @license AGPL-3.0-or-later
98
+ *
99
+ * This program is free software: you can redistribute it and/or modify
100
+ * it under the terms of the GNU Affero General Public License as
101
+ * published by the Free Software Foundation, either version 3 of the
102
+ * License, or (at your option) any later version.
103
+ *
104
+ * This program is distributed in the hope that it will be useful,
105
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
106
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
107
+ * GNU Affero General Public License for more details.
108
+ *
109
+ * You should have received a copy of the GNU Affero General Public License
110
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
111
+ *
112
+ */
113
+ const x = ["B", "KB", "MB", "GB", "TB", "PB"], $ = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
114
+ function ye(e, t = !1, r = !1, s = !1) {
115
+ r = r && !s, typeof e == "string" && (e = Number(e));
116
+ let n = e > 0 ? Math.floor(Math.log(e) / Math.log(s ? 1e3 : 1024)) : 0;
117
+ n = Math.min((r ? $.length : x.length) - 1, n);
118
+ const i = r ? $[n] : x[n];
119
+ let a = (e / Math.pow(s ? 1e3 : 1024, n)).toFixed(1);
120
+ return t === !0 && n === 0 ? (a !== "0.0" ? "< 1 " : "0 ") + (r ? $[1] : x[1]) : (n < 2 ? a = parseFloat(a).toFixed(0) : a = parseFloat(a).toLocaleString(ge.getCanonicalLocale()), a + " " + i);
121
+ }
122
+ function be(e, t = !1) {
123
+ try {
124
+ e = `${e}`.toLocaleLowerCase().replaceAll(/\s+/g, "").replaceAll(",", ".");
125
+ } catch {
126
+ return null;
127
+ }
128
+ const r = e.match(/^([0-9]*(\.[0-9]*)?)([kmgtp]?)(i?)b?$/);
129
+ if (r === null || r[1] === "." || r[1] === "")
130
+ return null;
131
+ const s = {
132
+ "": 0,
133
+ k: 1,
134
+ m: 2,
135
+ g: 3,
136
+ t: 4,
137
+ p: 5,
138
+ e: 6
139
+ }, n = `${r[1]}`, i = r[4] === "i" || t ? 1024 : 1e3;
140
+ return Math.round(Number.parseFloat(n) * i ** s[r[3]]);
141
+ }
142
+ /**
143
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
144
+ *
145
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
146
+ *
147
+ * @license AGPL-3.0-or-later
148
+ *
149
+ * This program is free software: you can redistribute it and/or modify
150
+ * it under the terms of the GNU Affero General Public License as
151
+ * published by the Free Software Foundation, either version 3 of the
152
+ * License, or (at your option) any later version.
153
+ *
154
+ * This program is distributed in the hope that it will be useful,
155
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
156
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
157
+ * GNU Affero General Public License for more details.
158
+ *
159
+ * You should have received a copy of the GNU Affero General Public License
160
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
161
+ *
162
+ */
163
+ var L = /* @__PURE__ */ ((e) => (e.DEFAULT = "default", e.HIDDEN = "hidden", e))(L || {});
164
+ class ve {
165
+ _action;
166
+ constructor(t) {
167
+ this.validateAction(t), this._action = t;
168
+ }
169
+ get id() {
170
+ return this._action.id;
171
+ }
172
+ get displayName() {
173
+ return this._action.displayName;
174
+ }
175
+ get title() {
176
+ return this._action.title;
177
+ }
178
+ get iconSvgInline() {
179
+ return this._action.iconSvgInline;
180
+ }
181
+ get enabled() {
182
+ return this._action.enabled;
183
+ }
184
+ get exec() {
185
+ return this._action.exec;
186
+ }
187
+ get execBatch() {
188
+ return this._action.execBatch;
189
+ }
190
+ get order() {
191
+ return this._action.order;
192
+ }
193
+ get parent() {
194
+ return this._action.parent;
195
+ }
196
+ get default() {
197
+ return this._action.default;
198
+ }
199
+ get inline() {
200
+ return this._action.inline;
201
+ }
202
+ get renderInline() {
203
+ return this._action.renderInline;
204
+ }
205
+ validateAction(t) {
206
+ if (!t.id || typeof t.id != "string")
207
+ throw new Error("Invalid id");
208
+ if (!t.displayName || typeof t.displayName != "function")
209
+ throw new Error("Invalid displayName function");
210
+ if ("title" in t && typeof t.title != "function")
211
+ throw new Error("Invalid title function");
212
+ if (!t.iconSvgInline || typeof t.iconSvgInline != "function")
213
+ throw new Error("Invalid iconSvgInline function");
214
+ if (!t.exec || typeof t.exec != "function")
215
+ throw new Error("Invalid exec function");
216
+ if ("enabled" in t && typeof t.enabled != "function")
217
+ throw new Error("Invalid enabled function");
218
+ if ("execBatch" in t && typeof t.execBatch != "function")
219
+ throw new Error("Invalid execBatch function");
220
+ if ("order" in t && typeof t.order != "number")
221
+ throw new Error("Invalid order");
222
+ if ("parent" in t && typeof t.parent != "string")
223
+ throw new Error("Invalid parent");
224
+ if (t.default && !Object.values(L).includes(t.default))
225
+ throw new Error("Invalid default");
226
+ if ("inline" in t && typeof t.inline != "function")
227
+ throw new Error("Invalid inline function");
228
+ if ("renderInline" in t && typeof t.renderInline != "function")
229
+ throw new Error("Invalid renderInline function");
230
+ }
231
+ }
232
+ const _e = function(e) {
233
+ if (typeof window._nc_fileactions > "u" && (window._nc_fileactions = [], N.debug("FileActions initialized")), window._nc_fileactions.find((t) => t.id === e.id)) {
234
+ N.error(`FileAction ${e.id} already registered`, { action: e });
235
+ return;
236
+ }
237
+ window._nc_fileactions.push(e);
238
+ }, Te = function() {
239
+ return typeof window._nc_fileactions > "u" && (window._nc_fileactions = [], N.debug("FileActions initialized")), window._nc_fileactions;
240
+ };
241
+ /**
242
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
243
+ *
244
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
245
+ *
246
+ * @license AGPL-3.0-or-later
247
+ *
248
+ * This program is free software: you can redistribute it and/or modify
249
+ * it under the terms of the GNU Affero General Public License as
250
+ * published by the Free Software Foundation, either version 3 of the
251
+ * License, or (at your option) any later version.
252
+ *
253
+ * This program is distributed in the hope that it will be useful,
254
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
255
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
256
+ * GNU Affero General Public License for more details.
257
+ *
258
+ * You should have received a copy of the GNU Affero General Public License
259
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
260
+ *
261
+ */
262
+ class Ie {
263
+ _header;
264
+ constructor(t) {
265
+ this.validateHeader(t), this._header = t;
266
+ }
267
+ get id() {
268
+ return this._header.id;
269
+ }
270
+ get order() {
271
+ return this._header.order;
272
+ }
273
+ get enabled() {
274
+ return this._header.enabled;
275
+ }
276
+ get render() {
277
+ return this._header.render;
278
+ }
279
+ get updated() {
280
+ return this._header.updated;
281
+ }
282
+ validateHeader(t) {
283
+ if (!t.id || !t.render || !t.updated)
284
+ throw new Error("Invalid header: id, render and updated are required");
285
+ if (typeof t.id != "string")
286
+ throw new Error("Invalid id property");
287
+ if (t.enabled !== void 0 && typeof t.enabled != "function")
288
+ throw new Error("Invalid enabled property");
289
+ if (t.render && typeof t.render != "function")
290
+ throw new Error("Invalid render property");
291
+ if (t.updated && typeof t.updated != "function")
292
+ throw new Error("Invalid updated property");
293
+ }
294
+ }
295
+ const Ae = function(e) {
296
+ if (typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], N.debug("FileListHeaders initialized")), window._nc_filelistheader.find((t) => t.id === e.id)) {
297
+ N.error(`Header ${e.id} already registered`, { header: e });
298
+ return;
299
+ }
300
+ window._nc_filelistheader.push(e);
301
+ }, Pe = function() {
302
+ return typeof window._nc_filelistheader > "u" && (window._nc_filelistheader = [], N.debug("FileListHeaders initialized")), window._nc_filelistheader;
303
+ };
304
+ /**
305
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
306
+ *
307
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
308
+ *
309
+ * @license AGPL-3.0-or-later
310
+ *
311
+ * This program is free software: you can redistribute it and/or modify
312
+ * it under the terms of the GNU Affero General Public License as
313
+ * published by the Free Software Foundation, either version 3 of the
314
+ * License, or (at your option) any later version.
315
+ *
316
+ * This program is distributed in the hope that it will be useful,
317
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
318
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
319
+ * GNU Affero General Public License for more details.
320
+ *
321
+ * You should have received a copy of the GNU Affero General Public License
322
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
323
+ *
324
+ */
325
+ var m = /* @__PURE__ */ ((e) => (e[e.NONE = 0] = "NONE", e[e.CREATE = 4] = "CREATE", e[e.READ = 1] = "READ", e[e.UPDATE = 2] = "UPDATE", e[e.DELETE = 8] = "DELETE", e[e.SHARE = 16] = "SHARE", e[e.ALL = 31] = "ALL", e))(m || {});
326
+ /**
327
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
328
+ *
329
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
330
+ * @author Ferdinand Thiessen <opensource@fthiessen.de>
331
+ *
332
+ * @license AGPL-3.0-or-later
333
+ *
334
+ * This program is free software: you can redistribute it and/or modify
335
+ * it under the terms of the GNU Affero General Public License as
336
+ * published by the Free Software Foundation, either version 3 of the
337
+ * License, or (at your option) any later version.
338
+ *
339
+ * This program is distributed in the hope that it will be useful,
340
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
341
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
342
+ * GNU Affero General Public License for more details.
343
+ *
344
+ * You should have received a copy of the GNU Affero General Public License
345
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
346
+ *
347
+ */
348
+ const M = [
349
+ "d:getcontentlength",
350
+ "d:getcontenttype",
351
+ "d:getetag",
352
+ "d:getlastmodified",
353
+ "d:quota-available-bytes",
354
+ "d:resourcetype",
355
+ "nc:has-preview",
356
+ "nc:is-encrypted",
357
+ "nc:mount-type",
358
+ "nc:share-attributes",
359
+ "oc:comments-unread",
360
+ "oc:favorite",
361
+ "oc:fileid",
362
+ "oc:owner-display-name",
363
+ "oc:owner-id",
364
+ "oc:permissions",
365
+ "oc:share-types",
366
+ "oc:size",
367
+ "ocs:share-permissions"
368
+ ], B = {
369
+ d: "DAV:",
370
+ nc: "http://nextcloud.org/ns",
371
+ oc: "http://owncloud.org/ns",
372
+ ocs: "http://open-collaboration-services.org/ns"
373
+ }, Ce = function(e, t = { nc: "http://nextcloud.org/ns" }) {
374
+ typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...M], window._nc_dav_namespaces = { ...B });
375
+ const r = { ...window._nc_dav_namespaces, ...t };
376
+ if (window._nc_dav_properties.find((n) => n === e))
377
+ return N.error(`${e} already registered`, { prop: e }), !1;
378
+ if (e.startsWith("<") || e.split(":").length !== 2)
379
+ return N.error(`${e} is not valid. See example: 'oc:fileid'`, { prop: e }), !1;
380
+ const s = e.split(":")[0];
381
+ return r[s] ? (window._nc_dav_properties.push(e), window._nc_dav_namespaces = r, !0) : (N.error(`${e} namespace unknown`, { prop: e, namespaces: r }), !1);
382
+ }, P = function() {
383
+ return typeof window._nc_dav_properties > "u" && (window._nc_dav_properties = [...M]), window._nc_dav_properties.map((e) => `<${e} />`).join(" ");
384
+ }, C = function() {
385
+ return typeof window._nc_dav_namespaces > "u" && (window._nc_dav_namespaces = { ...B }), Object.keys(window._nc_dav_namespaces).map((e) => `xmlns:${e}="${window._nc_dav_namespaces?.[e]}"`).join(" ");
386
+ }, Oe = function() {
387
+ return `<?xml version="1.0"?>
388
+ <d:propfind ${C()}>
389
+ <d:prop>
390
+ ${P()}
391
+ </d:prop>
392
+ </d:propfind>`;
393
+ }, re = function() {
394
+ return `<?xml version="1.0"?>
395
+ <oc:filter-files ${C()}>
396
+ <d:prop>
397
+ ${P()}
398
+ </d:prop>
399
+ <oc:filter-rules>
400
+ <oc:favorite>1</oc:favorite>
401
+ </oc:filter-rules>
402
+ </oc:filter-files>`;
403
+ }, Fe = function(e) {
404
+ return `<?xml version="1.0" encoding="UTF-8"?>
405
+ <d:searchrequest ${C()}
406
+ xmlns:ns="https://github.com/icewind1991/SearchDAV/ns">
407
+ <d:basicsearch>
408
+ <d:select>
409
+ <d:prop>
410
+ ${P()}
411
+ </d:prop>
412
+ </d:select>
413
+ <d:from>
414
+ <d:scope>
415
+ <d:href>/files/${_.getCurrentUser()?.uid}/</d:href>
416
+ <d:depth>infinity</d:depth>
417
+ </d:scope>
418
+ </d:from>
419
+ <d:where>
420
+ <d:and>
421
+ <d:or>
422
+ <d:not>
423
+ <d:eq>
424
+ <d:prop>
425
+ <d:getcontenttype/>
426
+ </d:prop>
427
+ <d:literal>httpd/unix-directory</d:literal>
428
+ </d:eq>
429
+ </d:not>
430
+ <d:eq>
431
+ <d:prop>
432
+ <oc:size/>
433
+ </d:prop>
434
+ <d:literal>0</d:literal>
435
+ </d:eq>
436
+ </d:or>
437
+ <d:gt>
438
+ <d:prop>
439
+ <d:getlastmodified/>
440
+ </d:prop>
441
+ <d:literal>${e}</d:literal>
442
+ </d:gt>
443
+ </d:and>
444
+ </d:where>
445
+ <d:orderby>
446
+ <d:order>
447
+ <d:prop>
448
+ <d:getlastmodified/>
449
+ </d:prop>
450
+ <d:descending/>
451
+ </d:order>
452
+ </d:orderby>
453
+ <d:limit>
454
+ <d:nresults>100</d:nresults>
455
+ <ns:firstresult>0</ns:firstresult>
456
+ </d:limit>
457
+ </d:basicsearch>
458
+ </d:searchrequest>`;
459
+ };
460
+ /**
461
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
462
+ *
463
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
464
+ * @author Ferdinand Thiessen <opensource@fthiessen.de>
465
+ *
466
+ * @license AGPL-3.0-or-later
467
+ *
468
+ * This program is free software: you can redistribute it and/or modify
469
+ * it under the terms of the GNU Affero General Public License as
470
+ * published by the Free Software Foundation, either version 3 of the
471
+ * License, or (at your option) any later version.
472
+ *
473
+ * This program is distributed in the hope that it will be useful,
474
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
475
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
476
+ * GNU Affero General Public License for more details.
477
+ *
478
+ * You should have received a copy of the GNU Affero General Public License
479
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
480
+ *
481
+ */
482
+ const ne = function(e = "") {
483
+ let t = m.NONE;
484
+ return e && ((e.includes("C") || e.includes("K")) && (t |= m.CREATE), e.includes("G") && (t |= m.READ), (e.includes("W") || e.includes("N") || e.includes("V")) && (t |= m.UPDATE), e.includes("D") && (t |= m.DELETE), e.includes("R") && (t |= m.SHARE)), t;
485
+ };
486
+ /**
487
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
488
+ *
489
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
490
+ *
491
+ * @license AGPL-3.0-or-later
492
+ *
493
+ * This program is free software: you can redistribute it and/or modify
494
+ * it under the terms of the GNU Affero General Public License as
495
+ * published by the Free Software Foundation, either version 3 of the
496
+ * License, or (at your option) any later version.
497
+ *
498
+ * This program is distributed in the hope that it will be useful,
499
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
500
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
501
+ * GNU Affero General Public License for more details.
502
+ *
503
+ * You should have received a copy of the GNU Affero General Public License
504
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
505
+ *
506
+ */
507
+ var O = /* @__PURE__ */ ((e) => (e.Folder = "folder", e.File = "file", e))(O || {});
508
+ /**
509
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
510
+ *
511
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
512
+ *
513
+ * @license AGPL-3.0-or-later
514
+ *
515
+ * This program is free software: you can redistribute it and/or modify
516
+ * it under the terms of the GNU Affero General Public License as
517
+ * published by the Free Software Foundation, either version 3 of the
518
+ * License, or (at your option) any later version.
519
+ *
520
+ * This program is distributed in the hope that it will be useful,
521
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
522
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
523
+ * GNU Affero General Public License for more details.
524
+ *
525
+ * You should have received a copy of the GNU Affero General Public License
526
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
527
+ *
528
+ */
529
+ const ie = function(e, t) {
530
+ return e.match(t) !== null;
531
+ }, j = (e, t) => {
532
+ if (e.id && typeof e.id != "number")
533
+ throw new Error("Invalid id type of value");
534
+ if (!e.source)
535
+ throw new Error("Missing mandatory source");
536
+ try {
537
+ new URL(e.source);
538
+ } catch {
539
+ throw new Error("Invalid source format, source must be a valid URL");
540
+ }
541
+ if (!e.source.startsWith("http"))
542
+ throw new Error("Invalid source format, only http(s) is supported");
543
+ if (e.mtime && !(e.mtime instanceof Date))
544
+ throw new Error("Invalid mtime type");
545
+ if (e.crtime && !(e.crtime instanceof Date))
546
+ throw new Error("Invalid crtime type");
547
+ if (!e.mime || typeof e.mime != "string" || !e.mime.match(/^[-\w.]+\/[-+\w.]+$/gi))
548
+ throw new Error("Missing or invalid mandatory mime");
549
+ if ("size" in e && typeof e.size != "number" && e.size !== void 0)
550
+ throw new Error("Invalid size type");
551
+ if ("permissions" in e && e.permissions !== void 0 && !(typeof e.permissions == "number" && e.permissions >= m.NONE && e.permissions <= m.ALL))
552
+ throw new Error("Invalid permissions");
553
+ if (e.owner && e.owner !== null && typeof e.owner != "string")
554
+ throw new Error("Invalid owner type");
555
+ if (e.attributes && typeof e.attributes != "object")
556
+ throw new Error("Invalid attributes type");
557
+ if (e.root && typeof e.root != "string")
558
+ throw new Error("Invalid root type");
559
+ if (e.root && !e.root.startsWith("/"))
560
+ throw new Error("Root must start with a leading slash");
561
+ if (e.root && !e.source.includes(e.root))
562
+ throw new Error("Root must be part of the source");
563
+ if (e.root && ie(e.source, t)) {
564
+ const r = e.source.match(t)[0];
565
+ if (!e.source.includes(b.join(r, e.root)))
566
+ throw new Error("The root must be relative to the service. e.g /files/emma");
567
+ }
568
+ if (e.status && !Object.values(k).includes(e.status))
569
+ throw new Error("Status must be a valid NodeStatus");
570
+ };
571
+ /**
572
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
573
+ *
574
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
575
+ *
576
+ * @license AGPL-3.0-or-later
577
+ *
578
+ * This program is free software: you can redistribute it and/or modify
579
+ * it under the terms of the GNU Affero General Public License as
580
+ * published by the Free Software Foundation, either version 3 of the
581
+ * License, or (at your option) any later version.
582
+ *
583
+ * This program is distributed in the hope that it will be useful,
584
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
585
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
586
+ * GNU Affero General Public License for more details.
587
+ *
588
+ * You should have received a copy of the GNU Affero General Public License
589
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
590
+ *
591
+ */
592
+ var k = /* @__PURE__ */ ((e) => (e.NEW = "new", e.FAILED = "failed", e.LOADING = "loading", e.LOCKED = "locked", e))(k || {});
593
+ class q {
594
+ _data;
595
+ _attributes;
596
+ _knownDavService = /(remote|public)\.php\/(web)?dav/i;
597
+ constructor(t, r) {
598
+ j(t, r || this._knownDavService), this._data = t;
599
+ const s = {
600
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
601
+ set: (n, i, a) => (this.updateMtime(), Reflect.set(n, i, a)),
602
+ deleteProperty: (n, i) => (this.updateMtime(), Reflect.deleteProperty(n, i))
603
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
604
+ };
605
+ this._attributes = new Proxy(t.attributes || {}, s), delete this._data.attributes, r && (this._knownDavService = r);
606
+ }
607
+ /**
608
+ * Get the source url to this object
609
+ */
610
+ get source() {
611
+ return this._data.source.replace(/\/$/i, "");
612
+ }
613
+ /**
614
+ * Get the encoded source url to this object for requests purposes
615
+ */
616
+ get encodedSource() {
617
+ const { origin: t } = new URL(this.source);
618
+ return t + we.encodePath(this.source.slice(t.length));
619
+ }
620
+ /**
621
+ * Get this object name
622
+ */
623
+ get basename() {
624
+ return b.basename(this.source);
625
+ }
626
+ /**
627
+ * Get this object's extension
628
+ */
629
+ get extension() {
630
+ return b.extname(this.source);
631
+ }
632
+ /**
633
+ * Get the directory path leading to this object
634
+ * Will use the relative path to root if available
635
+ */
636
+ get dirname() {
637
+ if (this.root) {
638
+ let r = this.source;
639
+ this.isDavRessource && (r = r.split(this._knownDavService).pop());
640
+ const s = r.indexOf(this.root), n = this.root.replace(/\/$/, "");
641
+ return b.dirname(r.slice(s + n.length) || "/");
642
+ }
643
+ const t = new URL(this.source);
644
+ return b.dirname(t.pathname);
645
+ }
646
+ /**
647
+ * Get the file mime
648
+ */
649
+ get mime() {
650
+ return this._data.mime;
651
+ }
652
+ /**
653
+ * Get the file modification time
654
+ */
655
+ get mtime() {
656
+ return this._data.mtime;
657
+ }
658
+ /**
659
+ * Get the file creation time
660
+ */
661
+ get crtime() {
662
+ return this._data.crtime;
663
+ }
664
+ /**
665
+ * Get the file size
666
+ */
667
+ get size() {
668
+ return this._data.size;
669
+ }
670
+ /**
671
+ * Get the file attribute
672
+ */
673
+ get attributes() {
674
+ return this._attributes;
675
+ }
676
+ /**
677
+ * Get the file permissions
678
+ */
679
+ get permissions() {
680
+ return this.owner === null && !this.isDavRessource ? m.READ : this._data.permissions !== void 0 ? this._data.permissions : m.NONE;
681
+ }
682
+ /**
683
+ * Get the file owner
684
+ */
685
+ get owner() {
686
+ return this.isDavRessource ? this._data.owner : null;
687
+ }
688
+ /**
689
+ * Is this a dav-related ressource ?
690
+ */
691
+ get isDavRessource() {
692
+ return ie(this.source, this._knownDavService);
693
+ }
694
+ /**
695
+ * Get the dav root of this object
696
+ */
697
+ get root() {
698
+ return this._data.root ? this._data.root.replace(/^(.+)\/$/, "$1") : this.isDavRessource && b.dirname(this.source).split(this._knownDavService).pop() || null;
699
+ }
700
+ /**
701
+ * Get the absolute path of this object relative to the root
702
+ */
703
+ get path() {
704
+ if (this.root) {
705
+ let t = this.source;
706
+ this.isDavRessource && (t = t.split(this._knownDavService).pop());
707
+ const r = t.indexOf(this.root), s = this.root.replace(/\/$/, "");
708
+ return t.slice(r + s.length) || "/";
709
+ }
710
+ return (this.dirname + "/" + this.basename).replace(/\/\//g, "/");
711
+ }
712
+ /**
713
+ * Get the node id if defined.
714
+ * Will look for the fileid in attributes if undefined.
715
+ */
716
+ get fileid() {
717
+ return this._data?.id || this.attributes?.fileid;
718
+ }
719
+ /**
720
+ * Get the node status.
721
+ */
722
+ get status() {
723
+ return this._data?.status;
724
+ }
725
+ /**
726
+ * Set the node status.
727
+ */
728
+ set status(t) {
729
+ this._data.status = t;
730
+ }
731
+ /**
732
+ * Move the node to a new destination
733
+ *
734
+ * @param {string} destination the new source.
735
+ * e.g. https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg
736
+ */
737
+ move(t) {
738
+ j({ ...this._data, source: t }, this._knownDavService), this._data.source = t, this.updateMtime();
739
+ }
740
+ /**
741
+ * Rename the node
742
+ * This aliases the move method for easier usage
743
+ *
744
+ * @param basename The new name of the node
745
+ */
746
+ rename(t) {
747
+ if (t.includes("/"))
748
+ throw new Error("Invalid basename");
749
+ this.move(b.dirname(this.source) + "/" + t);
750
+ }
751
+ /**
752
+ * Update the mtime if exists.
753
+ */
754
+ updateMtime() {
755
+ this._data.mtime && (this._data.mtime = /* @__PURE__ */ new Date());
756
+ }
757
+ }
758
+ /**
759
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
760
+ *
761
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
762
+ *
763
+ * @license AGPL-3.0-or-later
764
+ *
765
+ * This program is free software: you can redistribute it and/or modify
766
+ * it under the terms of the GNU Affero General Public License as
767
+ * published by the Free Software Foundation, either version 3 of the
768
+ * License, or (at your option) any later version.
769
+ *
770
+ * This program is distributed in the hope that it will be useful,
771
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
772
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
773
+ * GNU Affero General Public License for more details.
774
+ *
775
+ * You should have received a copy of the GNU Affero General Public License
776
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
777
+ *
778
+ */
779
+ class se extends q {
780
+ get type() {
781
+ return O.File;
782
+ }
783
+ }
784
+ /**
785
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
786
+ *
787
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
788
+ *
789
+ * @license AGPL-3.0-or-later
790
+ *
791
+ * This program is free software: you can redistribute it and/or modify
792
+ * it under the terms of the GNU Affero General Public License as
793
+ * published by the Free Software Foundation, either version 3 of the
794
+ * License, or (at your option) any later version.
795
+ *
796
+ * This program is distributed in the hope that it will be useful,
797
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
798
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
799
+ * GNU Affero General Public License for more details.
800
+ *
801
+ * You should have received a copy of the GNU Affero General Public License
802
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
803
+ *
804
+ */
805
+ class oe extends q {
806
+ constructor(t) {
807
+ super({
808
+ ...t,
809
+ mime: "httpd/unix-directory"
810
+ });
811
+ }
812
+ get type() {
813
+ return O.Folder;
814
+ }
815
+ get extension() {
816
+ return null;
817
+ }
818
+ get mime() {
819
+ return "httpd/unix-directory";
820
+ }
821
+ }
822
+ /**
823
+ * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
824
+ *
825
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
826
+ * @author Ferdinand Thiessen <opensource@fthiessen.de>
827
+ *
828
+ * @license AGPL-3.0-or-later
829
+ *
830
+ * This program is free software: you can redistribute it and/or modify
831
+ * it under the terms of the GNU Affero General Public License as
832
+ * published by the Free Software Foundation, either version 3 of the
833
+ * License, or (at your option) any later version.
834
+ *
835
+ * This program is distributed in the hope that it will be useful,
836
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
837
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
838
+ * GNU Affero General Public License for more details.
839
+ *
840
+ * You should have received a copy of the GNU Affero General Public License
841
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
842
+ *
843
+ */
844
+ const U = `/files/${_.getCurrentUser()?.uid}`, X = me.generateRemoteUrl("dav"), xe = function(e = X, t = {}) {
845
+ const r = Z.createClient(e, { headers: t });
846
+ function s(i) {
847
+ r.setHeaders({
848
+ ...t,
849
+ // Add this so the server knows it is an request from the browser
850
+ "X-Requested-With": "XMLHttpRequest",
851
+ // Inject user auth
852
+ requesttoken: i ?? ""
853
+ });
854
+ }
855
+ return _.onRequestTokenUpdate(s), s(_.getRequestToken()), Z.getPatcher().patch("fetch", (i, a) => {
856
+ const u = a.headers;
857
+ return u?.method && (a.method = u.method, delete u.method), fetch(i, a);
858
+ }), r;
859
+ }, $e = async (e, t = "/", r = U) => (await e.getDirectoryContents(`${r}${t}`, {
860
+ details: !0,
861
+ data: re(),
862
+ headers: {
863
+ // see davGetClient for patched webdav client
864
+ method: "REPORT"
865
+ },
866
+ includeSelf: !0
867
+ })).data.filter((n) => n.filename !== t).map((n) => ue(n, r)), ue = function(e, t = U, r = X) {
868
+ const s = e.props, n = ne(s?.permissions), i = s?.["owner-id"] || _.getCurrentUser()?.uid, a = {
869
+ id: s?.fileid || 0,
870
+ source: `${r}${e.filename}`,
871
+ mtime: new Date(Date.parse(e.lastmod)),
872
+ mime: e.mime,
873
+ size: s?.size || Number.parseInt(s.getcontentlength || "0"),
874
+ permissions: n,
875
+ owner: i,
876
+ root: t,
877
+ attributes: {
878
+ ...e,
879
+ ...s,
880
+ hasPreview: s?.["has-preview"]
881
+ }
882
+ };
883
+ return delete a.attributes?.props, e.type === "file" ? new se(a) : new oe(a);
884
+ };
885
+ /**
886
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
887
+ *
888
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
889
+ *
890
+ * @license AGPL-3.0-or-later
891
+ *
892
+ * This program is free software: you can redistribute it and/or modify
893
+ * it under the terms of the GNU Affero General Public License as
894
+ * published by the Free Software Foundation, either version 3 of the
895
+ * License, or (at your option) any later version.
896
+ *
897
+ * This program is distributed in the hope that it will be useful,
898
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
899
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
900
+ * GNU Affero General Public License for more details.
901
+ *
902
+ * You should have received a copy of the GNU Affero General Public License
903
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
904
+ *
905
+ */
906
+ class ae {
907
+ _views = [];
908
+ _currentView = null;
909
+ register(t) {
910
+ if (this._views.find((r) => r.id === t.id))
911
+ throw new Error(`View id ${t.id} is already registered`);
912
+ this._views.push(t);
913
+ }
914
+ remove(t) {
915
+ const r = this._views.findIndex((s) => s.id === t);
916
+ r !== -1 && this._views.splice(r, 1);
917
+ }
918
+ get views() {
919
+ return this._views;
920
+ }
921
+ setActive(t) {
922
+ this._currentView = t;
923
+ }
924
+ get active() {
925
+ return this._currentView;
926
+ }
927
+ }
928
+ const Ve = function() {
929
+ return typeof window._nc_navigation > "u" && (window._nc_navigation = new ae(), N.debug("Navigation service initialized")), window._nc_navigation;
930
+ };
931
+ /**
932
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
933
+ *
934
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
935
+ *
936
+ * @license AGPL-3.0-or-later
937
+ *
938
+ * This program is free software: you can redistribute it and/or modify
939
+ * it under the terms of the GNU Affero General Public License as
940
+ * published by the Free Software Foundation, either version 3 of the
941
+ * License, or (at your option) any later version.
942
+ *
943
+ * This program is distributed in the hope that it will be useful,
944
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
945
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
946
+ * GNU Affero General Public License for more details.
947
+ *
948
+ * You should have received a copy of the GNU Affero General Public License
949
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
950
+ *
951
+ */
952
+ class de {
953
+ _column;
954
+ constructor(t) {
955
+ Re(t), this._column = t;
956
+ }
957
+ get id() {
958
+ return this._column.id;
959
+ }
960
+ get title() {
961
+ return this._column.title;
962
+ }
963
+ get render() {
964
+ return this._column.render;
965
+ }
966
+ get sort() {
967
+ return this._column.sort;
968
+ }
969
+ get summary() {
970
+ return this._column.summary;
971
+ }
972
+ }
973
+ const Re = function(e) {
974
+ if (!e.id || typeof e.id != "string")
975
+ throw new Error("A column id is required");
976
+ if (!e.title || typeof e.title != "string")
977
+ throw new Error("A column title is required");
978
+ if (!e.render || typeof e.render != "function")
979
+ throw new Error("A render function is required");
980
+ if (e.sort && typeof e.sort != "function")
981
+ throw new Error("Column sortFunction must be a function");
982
+ if (e.summary && typeof e.summary != "function")
983
+ throw new Error("Column summary must be a function");
984
+ return !0;
985
+ };
986
+ var G = {}, F = {};
987
+ (function(e) {
988
+ const t = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", r = t + "\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040", s = "[" + t + "][" + r + "]*", n = new RegExp("^" + s + "$"), i = function(u, o) {
989
+ const d = [];
990
+ let l = o.exec(u);
991
+ for (; l; ) {
992
+ const f = [];
993
+ f.startIndex = o.lastIndex - l[0].length;
994
+ const c = l.length;
995
+ for (let g = 0; g < c; g++)
996
+ f.push(l[g]);
997
+ d.push(f), l = o.exec(u);
998
+ }
999
+ return d;
1000
+ }, a = function(u) {
1001
+ const o = n.exec(u);
1002
+ return !(o === null || typeof o > "u");
1003
+ };
1004
+ e.isExist = function(u) {
1005
+ return typeof u < "u";
1006
+ }, e.isEmptyObject = function(u) {
1007
+ return Object.keys(u).length === 0;
1008
+ }, e.merge = function(u, o, d) {
1009
+ if (o) {
1010
+ const l = Object.keys(o), f = l.length;
1011
+ for (let c = 0; c < f; c++)
1012
+ d === "strict" ? u[l[c]] = [o[l[c]]] : u[l[c]] = o[l[c]];
1013
+ }
1014
+ }, e.getValue = function(u) {
1015
+ return e.isExist(u) ? u : "";
1016
+ }, e.isName = a, e.getAllMatches = i, e.nameRegexp = s;
1017
+ })(F);
1018
+ const H = F, Se = {
1019
+ allowBooleanAttributes: !1,
1020
+ //A tag can have attributes without any value
1021
+ unpairedTags: []
1022
+ };
1023
+ G.validate = function(e, t) {
1024
+ t = Object.assign({}, Se, t);
1025
+ const r = [];
1026
+ let s = !1, n = !1;
1027
+ e[0] === "\uFEFF" && (e = e.substr(1));
1028
+ for (let i = 0; i < e.length; i++)
1029
+ if (e[i] === "<" && e[i + 1] === "?") {
1030
+ if (i += 2, i = J(e, i), i.err)
1031
+ return i;
1032
+ } else if (e[i] === "<") {
1033
+ let a = i;
1034
+ if (i++, e[i] === "!") {
1035
+ i = Q(e, i);
1036
+ continue;
1037
+ } else {
1038
+ let u = !1;
1039
+ e[i] === "/" && (u = !0, i++);
1040
+ let o = "";
1041
+ for (; i < e.length && e[i] !== ">" && e[i] !== " " && e[i] !== " " && e[i] !== `
1042
+ ` && e[i] !== "\r"; i++)
1043
+ o += e[i];
1044
+ if (o = o.trim(), o[o.length - 1] === "/" && (o = o.substring(0, o.length - 1), i--), !Ge(o)) {
1045
+ let f;
1046
+ return o.trim().length === 0 ? f = "Invalid space after '<'." : f = "Tag '" + o + "' is an invalid name.", p("InvalidTag", f, w(e, i));
1047
+ }
1048
+ const d = Be(e, i);
1049
+ if (d === !1)
1050
+ return p("InvalidAttr", "Attributes for '" + o + "' have open quote.", w(e, i));
1051
+ let l = d.value;
1052
+ if (i = d.index, l[l.length - 1] === "/") {
1053
+ const f = i - l.length;
1054
+ l = l.substring(0, l.length - 1);
1055
+ const c = D(l, t);
1056
+ if (c === !0)
1057
+ s = !0;
1058
+ else
1059
+ return p(c.err.code, c.err.msg, w(e, f + c.err.line));
1060
+ } else if (u)
1061
+ if (d.tagClosed) {
1062
+ if (l.trim().length > 0)
1063
+ return p("InvalidTag", "Closing tag '" + o + "' can't have attributes or invalid starting.", w(e, a));
1064
+ {
1065
+ const f = r.pop();
1066
+ if (o !== f.tagName) {
1067
+ let c = w(e, f.tagStartPos);
1068
+ return p(
1069
+ "InvalidTag",
1070
+ "Expected closing tag '" + f.tagName + "' (opened in line " + c.line + ", col " + c.col + ") instead of closing tag '" + o + "'.",
1071
+ w(e, a)
1072
+ );
1073
+ }
1074
+ r.length == 0 && (n = !0);
1075
+ }
1076
+ } else
1077
+ return p("InvalidTag", "Closing tag '" + o + "' doesn't have proper closing.", w(e, i));
1078
+ else {
1079
+ const f = D(l, t);
1080
+ if (f !== !0)
1081
+ return p(f.err.code, f.err.msg, w(e, i - l.length + f.err.line));
1082
+ if (n === !0)
1083
+ return p("InvalidXml", "Multiple possible root nodes found.", w(e, i));
1084
+ t.unpairedTags.indexOf(o) !== -1 || r.push({ tagName: o, tagStartPos: a }), s = !0;
1085
+ }
1086
+ for (i++; i < e.length; i++)
1087
+ if (e[i] === "<")
1088
+ if (e[i + 1] === "!") {
1089
+ i++, i = Q(e, i);
1090
+ continue;
1091
+ } else if (e[i + 1] === "?") {
1092
+ if (i = J(e, ++i), i.err)
1093
+ return i;
1094
+ } else
1095
+ break;
1096
+ else if (e[i] === "&") {
1097
+ const f = Ue(e, i);
1098
+ if (f == -1)
1099
+ return p("InvalidChar", "char '&' is not expected.", w(e, i));
1100
+ i = f;
1101
+ } else if (n === !0 && !Y(e[i]))
1102
+ return p("InvalidXml", "Extra text at the end", w(e, i));
1103
+ e[i] === "<" && i--;
1104
+ }
1105
+ } else {
1106
+ if (Y(e[i]))
1107
+ continue;
1108
+ return p("InvalidChar", "char '" + e[i] + "' is not expected.", w(e, i));
1109
+ }
1110
+ if (s) {
1111
+ if (r.length == 1)
1112
+ return p("InvalidTag", "Unclosed tag '" + r[0].tagName + "'.", w(e, r[0].tagStartPos));
1113
+ if (r.length > 0)
1114
+ return p("InvalidXml", "Invalid '" + JSON.stringify(r.map((i) => i.tagName), null, 4).replace(/\r?\n/g, "") + "' found.", { line: 1, col: 1 });
1115
+ } else
1116
+ return p("InvalidXml", "Start tag expected.", 1);
1117
+ return !0;
1118
+ };
1119
+ function Y(e) {
1120
+ return e === " " || e === " " || e === `
1121
+ ` || e === "\r";
1122
+ }
1123
+ function J(e, t) {
1124
+ const r = t;
1125
+ for (; t < e.length; t++)
1126
+ if (e[t] == "?" || e[t] == " ") {
1127
+ const s = e.substr(r, t - r);
1128
+ if (t > 5 && s === "xml")
1129
+ return p("InvalidXml", "XML declaration allowed only at the start of the document.", w(e, t));
1130
+ if (e[t] == "?" && e[t + 1] == ">") {
1131
+ t++;
1132
+ break;
1133
+ } else
1134
+ continue;
1135
+ }
1136
+ return t;
1137
+ }
1138
+ function Q(e, t) {
1139
+ if (e.length > t + 5 && e[t + 1] === "-" && e[t + 2] === "-") {
1140
+ for (t += 3; t < e.length; t++)
1141
+ if (e[t] === "-" && e[t + 1] === "-" && e[t + 2] === ">") {
1142
+ t += 2;
1143
+ break;
1144
+ }
1145
+ } else if (e.length > t + 8 && e[t + 1] === "D" && e[t + 2] === "O" && e[t + 3] === "C" && e[t + 4] === "T" && e[t + 5] === "Y" && e[t + 6] === "P" && e[t + 7] === "E") {
1146
+ let r = 1;
1147
+ for (t += 8; t < e.length; t++)
1148
+ if (e[t] === "<")
1149
+ r++;
1150
+ else if (e[t] === ">" && (r--, r === 0))
1151
+ break;
1152
+ } else if (e.length > t + 9 && e[t + 1] === "[" && e[t + 2] === "C" && e[t + 3] === "D" && e[t + 4] === "A" && e[t + 5] === "T" && e[t + 6] === "A" && e[t + 7] === "[") {
1153
+ for (t += 8; t < e.length; t++)
1154
+ if (e[t] === "]" && e[t + 1] === "]" && e[t + 2] === ">") {
1155
+ t += 2;
1156
+ break;
1157
+ }
1158
+ }
1159
+ return t;
1160
+ }
1161
+ const Le = '"', Me = "'";
1162
+ function Be(e, t) {
1163
+ let r = "", s = "", n = !1;
1164
+ for (; t < e.length; t++) {
1165
+ if (e[t] === Le || e[t] === Me)
1166
+ s === "" ? s = e[t] : s !== e[t] || (s = "");
1167
+ else if (e[t] === ">" && s === "") {
1168
+ n = !0;
1169
+ break;
1170
+ }
1171
+ r += e[t];
1172
+ }
1173
+ return s !== "" ? !1 : {
1174
+ value: r,
1175
+ index: t,
1176
+ tagClosed: n
1177
+ };
1178
+ }
1179
+ const ke = new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`, "g");
1180
+ function D(e, t) {
1181
+ const r = H.getAllMatches(e, ke), s = {};
1182
+ for (let n = 0; n < r.length; n++) {
1183
+ if (r[n][1].length === 0)
1184
+ return p("InvalidAttr", "Attribute '" + r[n][2] + "' has no space in starting.", I(r[n]));
1185
+ if (r[n][3] !== void 0 && r[n][4] === void 0)
1186
+ return p("InvalidAttr", "Attribute '" + r[n][2] + "' is without value.", I(r[n]));
1187
+ if (r[n][3] === void 0 && !t.allowBooleanAttributes)
1188
+ return p("InvalidAttr", "boolean attribute '" + r[n][2] + "' is not allowed.", I(r[n]));
1189
+ const i = r[n][2];
1190
+ if (!Xe(i))
1191
+ return p("InvalidAttr", "Attribute '" + i + "' is an invalid name.", I(r[n]));
1192
+ if (!s.hasOwnProperty(i))
1193
+ s[i] = 1;
1194
+ else
1195
+ return p("InvalidAttr", "Attribute '" + i + "' is repeated.", I(r[n]));
1196
+ }
1197
+ return !0;
1198
+ }
1199
+ function qe(e, t) {
1200
+ let r = /\d/;
1201
+ for (e[t] === "x" && (t++, r = /[\da-fA-F]/); t < e.length; t++) {
1202
+ if (e[t] === ";")
1203
+ return t;
1204
+ if (!e[t].match(r))
1205
+ break;
1206
+ }
1207
+ return -1;
1208
+ }
1209
+ function Ue(e, t) {
1210
+ if (t++, e[t] === ";")
1211
+ return -1;
1212
+ if (e[t] === "#")
1213
+ return t++, qe(e, t);
1214
+ let r = 0;
1215
+ for (; t < e.length; t++, r++)
1216
+ if (!(e[t].match(/\w/) && r < 20)) {
1217
+ if (e[t] === ";")
1218
+ break;
1219
+ return -1;
1220
+ }
1221
+ return t;
1222
+ }
1223
+ function p(e, t, r) {
1224
+ return {
1225
+ err: {
1226
+ code: e,
1227
+ msg: t,
1228
+ line: r.line || r,
1229
+ col: r.col
1230
+ }
1231
+ };
1232
+ }
1233
+ function Xe(e) {
1234
+ return H.isName(e);
1235
+ }
1236
+ function Ge(e) {
1237
+ return H.isName(e);
1238
+ }
1239
+ function w(e, t) {
1240
+ const r = e.substring(0, t).split(/\r?\n/);
1241
+ return {
1242
+ line: r.length,
1243
+ // column number is last line's length + 1, because column numbering starts at 1:
1244
+ col: r[r.length - 1].length + 1
1245
+ };
1246
+ }
1247
+ function I(e) {
1248
+ return e.startIndex + e[1].length;
1249
+ }
1250
+ var z = {};
1251
+ const le = {
1252
+ preserveOrder: !1,
1253
+ attributeNamePrefix: "@_",
1254
+ attributesGroupName: !1,
1255
+ textNodeName: "#text",
1256
+ ignoreAttributes: !0,
1257
+ removeNSPrefix: !1,
1258
+ // remove NS from tag name or attribute name if true
1259
+ allowBooleanAttributes: !1,
1260
+ //a tag can have attributes without any value
1261
+ //ignoreRootElement : false,
1262
+ parseTagValue: !0,
1263
+ parseAttributeValue: !1,
1264
+ trimValues: !0,
1265
+ //Trim string values of tag and attributes
1266
+ cdataPropName: !1,
1267
+ numberParseOptions: {
1268
+ hex: !0,
1269
+ leadingZeros: !0,
1270
+ eNotation: !0
1271
+ },
1272
+ tagValueProcessor: function(e, t) {
1273
+ return t;
1274
+ },
1275
+ attributeValueProcessor: function(e, t) {
1276
+ return t;
1277
+ },
1278
+ stopNodes: [],
1279
+ //nested tags will not be parsed even for errors
1280
+ alwaysCreateTextNode: !1,
1281
+ isArray: () => !1,
1282
+ commentPropName: !1,
1283
+ unpairedTags: [],
1284
+ processEntities: !0,
1285
+ htmlEntities: !1,
1286
+ ignoreDeclaration: !1,
1287
+ ignorePiTags: !1,
1288
+ transformTagName: !1,
1289
+ transformAttributeName: !1,
1290
+ updateTag: function(e, t, r) {
1291
+ return e;
1292
+ }
1293
+ // skipEmptyListItem: false
1294
+ }, He = function(e) {
1295
+ return Object.assign({}, le, e);
1296
+ };
1297
+ z.buildOptions = He;
1298
+ z.defaultOptions = le;
1299
+ class ze {
1300
+ constructor(t) {
1301
+ this.tagname = t, this.child = [], this[":@"] = {};
1302
+ }
1303
+ add(t, r) {
1304
+ t === "__proto__" && (t = "#__proto__"), this.child.push({ [t]: r });
1305
+ }
1306
+ addChild(t) {
1307
+ t.tagname === "__proto__" && (t.tagname = "#__proto__"), t[":@"] && Object.keys(t[":@"]).length > 0 ? this.child.push({ [t.tagname]: t.child, ":@": t[":@"] }) : this.child.push({ [t.tagname]: t.child });
1308
+ }
1309
+ }
1310
+ var Ke = ze;
1311
+ const We = F;
1312
+ function Ze(e, t) {
1313
+ const r = {};
1314
+ if (e[t + 3] === "O" && e[t + 4] === "C" && e[t + 5] === "T" && e[t + 6] === "Y" && e[t + 7] === "P" && e[t + 8] === "E") {
1315
+ t = t + 9;
1316
+ let s = 1, n = !1, i = !1, a = "";
1317
+ for (; t < e.length; t++)
1318
+ if (e[t] === "<" && !i) {
1319
+ if (n && Je(e, t))
1320
+ t += 7, [entityName, val, t] = je(e, t + 1), val.indexOf("&") === -1 && (r[tt(entityName)] = {
1321
+ regx: RegExp(`&${entityName};`, "g"),
1322
+ val
1323
+ });
1324
+ else if (n && Qe(e, t))
1325
+ t += 8;
1326
+ else if (n && De(e, t))
1327
+ t += 8;
1328
+ else if (n && et(e, t))
1329
+ t += 9;
1330
+ else if (Ye)
1331
+ i = !0;
1332
+ else
1333
+ throw new Error("Invalid DOCTYPE");
1334
+ s++, a = "";
1335
+ } else if (e[t] === ">") {
1336
+ if (i ? e[t - 1] === "-" && e[t - 2] === "-" && (i = !1, s--) : s--, s === 0)
1337
+ break;
1338
+ } else
1339
+ e[t] === "[" ? n = !0 : a += e[t];
1340
+ if (s !== 0)
1341
+ throw new Error("Unclosed DOCTYPE");
1342
+ } else
1343
+ throw new Error("Invalid Tag instead of DOCTYPE");
1344
+ return { entities: r, i: t };
1345
+ }
1346
+ function je(e, t) {
1347
+ let r = "";
1348
+ for (; t < e.length && e[t] !== "'" && e[t] !== '"'; t++)
1349
+ r += e[t];
1350
+ if (r = r.trim(), r.indexOf(" ") !== -1)
1351
+ throw new Error("External entites are not supported");
1352
+ const s = e[t++];
1353
+ let n = "";
1354
+ for (; t < e.length && e[t] !== s; t++)
1355
+ n += e[t];
1356
+ return [r, n, t];
1357
+ }
1358
+ function Ye(e, t) {
1359
+ return e[t + 1] === "!" && e[t + 2] === "-" && e[t + 3] === "-";
1360
+ }
1361
+ function Je(e, t) {
1362
+ return e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "N" && e[t + 4] === "T" && e[t + 5] === "I" && e[t + 6] === "T" && e[t + 7] === "Y";
1363
+ }
1364
+ function Qe(e, t) {
1365
+ return e[t + 1] === "!" && e[t + 2] === "E" && e[t + 3] === "L" && e[t + 4] === "E" && e[t + 5] === "M" && e[t + 6] === "E" && e[t + 7] === "N" && e[t + 8] === "T";
1366
+ }
1367
+ function De(e, t) {
1368
+ return e[t + 1] === "!" && e[t + 2] === "A" && e[t + 3] === "T" && e[t + 4] === "T" && e[t + 5] === "L" && e[t + 6] === "I" && e[t + 7] === "S" && e[t + 8] === "T";
1369
+ }
1370
+ function et(e, t) {
1371
+ return e[t + 1] === "!" && e[t + 2] === "N" && e[t + 3] === "O" && e[t + 4] === "T" && e[t + 5] === "A" && e[t + 6] === "T" && e[t + 7] === "I" && e[t + 8] === "O" && e[t + 9] === "N";
1372
+ }
1373
+ function tt(e) {
1374
+ if (We.isName(e))
1375
+ return e;
1376
+ throw new Error(`Invalid entity name ${e}`);
1377
+ }
1378
+ var rt = Ze;
1379
+ const nt = /^[-+]?0x[a-fA-F0-9]+$/, it = /^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;
1380
+ !Number.parseInt && window.parseInt && (Number.parseInt = window.parseInt);
1381
+ !Number.parseFloat && window.parseFloat && (Number.parseFloat = window.parseFloat);
1382
+ const st = {
1383
+ hex: !0,
1384
+ leadingZeros: !0,
1385
+ decimalPoint: ".",
1386
+ eNotation: !0
1387
+ //skipLike: /regex/
1388
+ };
1389
+ function ot(e, t = {}) {
1390
+ if (t = Object.assign({}, st, t), !e || typeof e != "string")
1391
+ return e;
1392
+ let r = e.trim();
1393
+ if (t.skipLike !== void 0 && t.skipLike.test(r))
1394
+ return e;
1395
+ if (t.hex && nt.test(r))
1396
+ return Number.parseInt(r, 16);
1397
+ {
1398
+ const s = it.exec(r);
1399
+ if (s) {
1400
+ const n = s[1], i = s[2];
1401
+ let a = ut(s[3]);
1402
+ const u = s[4] || s[6];
1403
+ if (!t.leadingZeros && i.length > 0 && n && r[2] !== ".")
1404
+ return e;
1405
+ if (!t.leadingZeros && i.length > 0 && !n && r[1] !== ".")
1406
+ return e;
1407
+ {
1408
+ const o = Number(r), d = "" + o;
1409
+ return d.search(/[eE]/) !== -1 || u ? t.eNotation ? o : e : r.indexOf(".") !== -1 ? d === "0" && a === "" || d === a || n && d === "-" + a ? o : e : i ? a === d || n + a === d ? o : e : r === d || r === n + d ? o : e;
1410
+ }
1411
+ } else
1412
+ return e;
1413
+ }
1414
+ }
1415
+ function ut(e) {
1416
+ return e && e.indexOf(".") !== -1 && (e = e.replace(/0+$/, ""), e === "." ? e = "0" : e[0] === "." ? e = "0" + e : e[e.length - 1] === "." && (e = e.substr(0, e.length - 1))), e;
1417
+ }
1418
+ var at = ot;
1419
+ const K = F, A = Ke, dt = rt, lt = at;
1420
+ "<((!\\[CDATA\\[([\\s\\S]*?)(]]>))|((NAME:)?(NAME))([^>]*)>|((\\/)(NAME)\\s*>))([^<]*)".replace(/NAME/g, K.nameRegexp);
1421
+ let ft = class {
1422
+ constructor(t) {
1423
+ this.options = t, this.currentNode = null, this.tagsNodeStack = [], this.docTypeEntities = {}, this.lastEntities = {
1424
+ apos: { regex: /&(apos|#39|#x27);/g, val: "'" },
1425
+ gt: { regex: /&(gt|#62|#x3E);/g, val: ">" },
1426
+ lt: { regex: /&(lt|#60|#x3C);/g, val: "<" },
1427
+ quot: { regex: /&(quot|#34|#x22);/g, val: '"' }
1428
+ }, this.ampEntity = { regex: /&(amp|#38|#x26);/g, val: "&" }, this.htmlEntities = {
1429
+ space: { regex: /&(nbsp|#160);/g, val: " " },
1430
+ // "lt" : { regex: /&(lt|#60);/g, val: "<" },
1431
+ // "gt" : { regex: /&(gt|#62);/g, val: ">" },
1432
+ // "amp" : { regex: /&(amp|#38);/g, val: "&" },
1433
+ // "quot" : { regex: /&(quot|#34);/g, val: "\"" },
1434
+ // "apos" : { regex: /&(apos|#39);/g, val: "'" },
1435
+ cent: { regex: /&(cent|#162);/g, val: "¢" },
1436
+ pound: { regex: /&(pound|#163);/g, val: "£" },
1437
+ yen: { regex: /&(yen|#165);/g, val: "¥" },
1438
+ euro: { regex: /&(euro|#8364);/g, val: "€" },
1439
+ copyright: { regex: /&(copy|#169);/g, val: "©" },
1440
+ reg: { regex: /&(reg|#174);/g, val: "®" },
1441
+ inr: { regex: /&(inr|#8377);/g, val: "₹" }
1442
+ }, this.addExternalEntities = ct, this.parseXml = mt, this.parseTextData = ht, this.resolveNameSpace = pt, this.buildAttributesMap = wt, this.isItStopNode = bt, this.replaceEntitiesValue = Et, this.readStopNodeData = _t, this.saveTextToParentTag = yt, this.addChild = Nt;
1443
+ }
1444
+ };
1445
+ function ct(e) {
1446
+ const t = Object.keys(e);
1447
+ for (let r = 0; r < t.length; r++) {
1448
+ const s = t[r];
1449
+ this.lastEntities[s] = {
1450
+ regex: new RegExp("&" + s + ";", "g"),
1451
+ val: e[s]
1452
+ };
1453
+ }
1454
+ }
1455
+ function ht(e, t, r, s, n, i, a) {
1456
+ if (e !== void 0 && (this.options.trimValues && !s && (e = e.trim()), e.length > 0)) {
1457
+ a || (e = this.replaceEntitiesValue(e));
1458
+ const u = this.options.tagValueProcessor(t, e, r, n, i);
1459
+ return u == null ? e : typeof u != typeof e || u !== e ? u : this.options.trimValues ? R(e, this.options.parseTagValue, this.options.numberParseOptions) : e.trim() === e ? R(e, this.options.parseTagValue, this.options.numberParseOptions) : e;
1460
+ }
1461
+ }
1462
+ function pt(e) {
1463
+ if (this.options.removeNSPrefix) {
1464
+ const t = e.split(":"), r = e.charAt(0) === "/" ? "/" : "";
1465
+ if (t[0] === "xmlns")
1466
+ return "";
1467
+ t.length === 2 && (e = r + t[1]);
1468
+ }
1469
+ return e;
1470
+ }
1471
+ const gt = new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`, "gm");
1472
+ function wt(e, t, r) {
1473
+ if (!this.options.ignoreAttributes && typeof e == "string") {
1474
+ const s = K.getAllMatches(e, gt), n = s.length, i = {};
1475
+ for (let a = 0; a < n; a++) {
1476
+ const u = this.resolveNameSpace(s[a][1]);
1477
+ let o = s[a][4], d = this.options.attributeNamePrefix + u;
1478
+ if (u.length)
1479
+ if (this.options.transformAttributeName && (d = this.options.transformAttributeName(d)), d === "__proto__" && (d = "#__proto__"), o !== void 0) {
1480
+ this.options.trimValues && (o = o.trim()), o = this.replaceEntitiesValue(o);
1481
+ const l = this.options.attributeValueProcessor(u, o, t);
1482
+ l == null ? i[d] = o : typeof l != typeof o || l !== o ? i[d] = l : i[d] = R(
1483
+ o,
1484
+ this.options.parseAttributeValue,
1485
+ this.options.numberParseOptions
1486
+ );
1487
+ } else
1488
+ this.options.allowBooleanAttributes && (i[d] = !0);
1489
+ }
1490
+ if (!Object.keys(i).length)
1491
+ return;
1492
+ if (this.options.attributesGroupName) {
1493
+ const a = {};
1494
+ return a[this.options.attributesGroupName] = i, a;
1495
+ }
1496
+ return i;
1497
+ }
1498
+ }
1499
+ const mt = function(e) {
1500
+ e = e.replace(/\r\n?/g, `
1501
+ `);
1502
+ const t = new A("!xml");
1503
+ let r = t, s = "", n = "";
1504
+ for (let i = 0; i < e.length; i++)
1505
+ if (e[i] === "<")
1506
+ if (e[i + 1] === "/") {
1507
+ const u = v(e, ">", i, "Closing Tag is not closed.");
1508
+ let o = e.substring(i + 2, u).trim();
1509
+ if (this.options.removeNSPrefix) {
1510
+ const f = o.indexOf(":");
1511
+ f !== -1 && (o = o.substr(f + 1));
1512
+ }
1513
+ this.options.transformTagName && (o = this.options.transformTagName(o)), r && (s = this.saveTextToParentTag(s, r, n));
1514
+ const d = n.substring(n.lastIndexOf(".") + 1);
1515
+ if (o && this.options.unpairedTags.indexOf(o) !== -1)
1516
+ throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);
1517
+ let l = 0;
1518
+ d && this.options.unpairedTags.indexOf(d) !== -1 ? (l = n.lastIndexOf(".", n.lastIndexOf(".") - 1), this.tagsNodeStack.pop()) : l = n.lastIndexOf("."), n = n.substring(0, l), r = this.tagsNodeStack.pop(), s = "", i = u;
1519
+ } else if (e[i + 1] === "?") {
1520
+ let u = V(e, i, !1, "?>");
1521
+ if (!u)
1522
+ throw new Error("Pi Tag is not closed.");
1523
+ if (s = this.saveTextToParentTag(s, r, n), !(this.options.ignoreDeclaration && u.tagName === "?xml" || this.options.ignorePiTags)) {
1524
+ const o = new A(u.tagName);
1525
+ o.add(this.options.textNodeName, ""), u.tagName !== u.tagExp && u.attrExpPresent && (o[":@"] = this.buildAttributesMap(u.tagExp, n, u.tagName)), this.addChild(r, o, n);
1526
+ }
1527
+ i = u.closeIndex + 1;
1528
+ } else if (e.substr(i + 1, 3) === "!--") {
1529
+ const u = v(e, "-->", i + 4, "Comment is not closed.");
1530
+ if (this.options.commentPropName) {
1531
+ const o = e.substring(i + 4, u - 2);
1532
+ s = this.saveTextToParentTag(s, r, n), r.add(this.options.commentPropName, [{ [this.options.textNodeName]: o }]);
1533
+ }
1534
+ i = u;
1535
+ } else if (e.substr(i + 1, 2) === "!D") {
1536
+ const u = dt(e, i);
1537
+ this.docTypeEntities = u.entities, i = u.i;
1538
+ } else if (e.substr(i + 1, 2) === "![") {
1539
+ const u = v(e, "]]>", i, "CDATA is not closed.") - 2, o = e.substring(i + 9, u);
1540
+ if (s = this.saveTextToParentTag(s, r, n), this.options.cdataPropName)
1541
+ r.add(this.options.cdataPropName, [{ [this.options.textNodeName]: o }]);
1542
+ else {
1543
+ let d = this.parseTextData(o, r.tagname, n, !0, !1, !0);
1544
+ d == null && (d = ""), r.add(this.options.textNodeName, d);
1545
+ }
1546
+ i = u + 2;
1547
+ } else {
1548
+ let u = V(e, i, this.options.removeNSPrefix), o = u.tagName;
1549
+ const d = u.rawTagName;
1550
+ let l = u.tagExp, f = u.attrExpPresent, c = u.closeIndex;
1551
+ this.options.transformTagName && (o = this.options.transformTagName(o)), r && s && r.tagname !== "!xml" && (s = this.saveTextToParentTag(s, r, n, !1));
1552
+ const g = r;
1553
+ if (g && this.options.unpairedTags.indexOf(g.tagname) !== -1 && (r = this.tagsNodeStack.pop(), n = n.substring(0, n.lastIndexOf("."))), o !== t.tagname && (n += n ? "." + o : o), this.isItStopNode(this.options.stopNodes, n, o)) {
1554
+ let h = "";
1555
+ if (l.length > 0 && l.lastIndexOf("/") === l.length - 1)
1556
+ i = u.closeIndex;
1557
+ else if (this.options.unpairedTags.indexOf(o) !== -1)
1558
+ i = u.closeIndex;
1559
+ else {
1560
+ const E = this.readStopNodeData(e, d, c + 1);
1561
+ if (!E)
1562
+ throw new Error(`Unexpected end of ${d}`);
1563
+ i = E.i, h = E.tagContent;
1564
+ }
1565
+ const T = new A(o);
1566
+ o !== l && f && (T[":@"] = this.buildAttributesMap(l, n, o)), h && (h = this.parseTextData(h, o, n, !0, f, !0, !0)), n = n.substr(0, n.lastIndexOf(".")), T.add(this.options.textNodeName, h), this.addChild(r, T, n);
1567
+ } else {
1568
+ if (l.length > 0 && l.lastIndexOf("/") === l.length - 1) {
1569
+ o[o.length - 1] === "/" ? (o = o.substr(0, o.length - 1), n = n.substr(0, n.length - 1), l = o) : l = l.substr(0, l.length - 1), this.options.transformTagName && (o = this.options.transformTagName(o));
1570
+ const h = new A(o);
1571
+ o !== l && f && (h[":@"] = this.buildAttributesMap(l, n, o)), this.addChild(r, h, n), n = n.substr(0, n.lastIndexOf("."));
1572
+ } else {
1573
+ const h = new A(o);
1574
+ this.tagsNodeStack.push(r), o !== l && f && (h[":@"] = this.buildAttributesMap(l, n, o)), this.addChild(r, h, n), r = h;
1575
+ }
1576
+ s = "", i = c;
1577
+ }
1578
+ }
1579
+ else
1580
+ s += e[i];
1581
+ return t.child;
1582
+ };
1583
+ function Nt(e, t, r) {
1584
+ const s = this.options.updateTag(t.tagname, r, t[":@"]);
1585
+ s === !1 || (typeof s == "string" && (t.tagname = s), e.addChild(t));
1586
+ }
1587
+ const Et = function(e) {
1588
+ if (this.options.processEntities) {
1589
+ for (let t in this.docTypeEntities) {
1590
+ const r = this.docTypeEntities[t];
1591
+ e = e.replace(r.regx, r.val);
1592
+ }
1593
+ for (let t in this.lastEntities) {
1594
+ const r = this.lastEntities[t];
1595
+ e = e.replace(r.regex, r.val);
1596
+ }
1597
+ if (this.options.htmlEntities)
1598
+ for (let t in this.htmlEntities) {
1599
+ const r = this.htmlEntities[t];
1600
+ e = e.replace(r.regex, r.val);
1601
+ }
1602
+ e = e.replace(this.ampEntity.regex, this.ampEntity.val);
1603
+ }
1604
+ return e;
1605
+ };
1606
+ function yt(e, t, r, s) {
1607
+ return e && (s === void 0 && (s = Object.keys(t.child).length === 0), e = this.parseTextData(
1608
+ e,
1609
+ t.tagname,
1610
+ r,
1611
+ !1,
1612
+ t[":@"] ? Object.keys(t[":@"]).length !== 0 : !1,
1613
+ s
1614
+ ), e !== void 0 && e !== "" && t.add(this.options.textNodeName, e), e = ""), e;
1615
+ }
1616
+ function bt(e, t, r) {
1617
+ const s = "*." + r;
1618
+ for (const n in e) {
1619
+ const i = e[n];
1620
+ if (s === i || t === i)
1621
+ return !0;
1622
+ }
1623
+ return !1;
1624
+ }
1625
+ function vt(e, t, r = ">") {
1626
+ let s, n = "";
1627
+ for (let i = t; i < e.length; i++) {
1628
+ let a = e[i];
1629
+ if (s)
1630
+ a === s && (s = "");
1631
+ else if (a === '"' || a === "'")
1632
+ s = a;
1633
+ else if (a === r[0])
1634
+ if (r[1]) {
1635
+ if (e[i + 1] === r[1])
1636
+ return {
1637
+ data: n,
1638
+ index: i
1639
+ };
1640
+ } else
1641
+ return {
1642
+ data: n,
1643
+ index: i
1644
+ };
1645
+ else
1646
+ a === " " && (a = " ");
1647
+ n += a;
1648
+ }
1649
+ }
1650
+ function v(e, t, r, s) {
1651
+ const n = e.indexOf(t, r);
1652
+ if (n === -1)
1653
+ throw new Error(s);
1654
+ return n + t.length - 1;
1655
+ }
1656
+ function V(e, t, r, s = ">") {
1657
+ const n = vt(e, t + 1, s);
1658
+ if (!n)
1659
+ return;
1660
+ let i = n.data;
1661
+ const a = n.index, u = i.search(/\s/);
1662
+ let o = i, d = !0;
1663
+ u !== -1 && (o = i.substr(0, u).replace(/\s\s*$/, ""), i = i.substr(u + 1));
1664
+ const l = o;
1665
+ if (r) {
1666
+ const f = o.indexOf(":");
1667
+ f !== -1 && (o = o.substr(f + 1), d = o !== n.data.substr(f + 1));
1668
+ }
1669
+ return {
1670
+ tagName: o,
1671
+ tagExp: i,
1672
+ closeIndex: a,
1673
+ attrExpPresent: d,
1674
+ rawTagName: l
1675
+ };
1676
+ }
1677
+ function _t(e, t, r) {
1678
+ const s = r;
1679
+ let n = 1;
1680
+ for (; r < e.length; r++)
1681
+ if (e[r] === "<")
1682
+ if (e[r + 1] === "/") {
1683
+ const i = v(e, ">", r, `${t} is not closed`);
1684
+ if (e.substring(r + 2, i).trim() === t && (n--, n === 0))
1685
+ return {
1686
+ tagContent: e.substring(s, r),
1687
+ i
1688
+ };
1689
+ r = i;
1690
+ } else if (e[r + 1] === "?")
1691
+ r = v(e, "?>", r + 1, "StopNode is not closed.");
1692
+ else if (e.substr(r + 1, 3) === "!--")
1693
+ r = v(e, "-->", r + 3, "StopNode is not closed.");
1694
+ else if (e.substr(r + 1, 2) === "![")
1695
+ r = v(e, "]]>", r, "StopNode is not closed.") - 2;
1696
+ else {
1697
+ const i = V(e, r, ">");
1698
+ i && ((i && i.tagName) === t && i.tagExp[i.tagExp.length - 1] !== "/" && n++, r = i.closeIndex);
1699
+ }
1700
+ }
1701
+ function R(e, t, r) {
1702
+ if (t && typeof e == "string") {
1703
+ const s = e.trim();
1704
+ return s === "true" ? !0 : s === "false" ? !1 : lt(e, r);
1705
+ } else
1706
+ return K.isExist(e) ? e : "";
1707
+ }
1708
+ var Tt = ft, fe = {};
1709
+ function It(e, t) {
1710
+ return ce(e, t);
1711
+ }
1712
+ function ce(e, t, r) {
1713
+ let s;
1714
+ const n = {};
1715
+ for (let i = 0; i < e.length; i++) {
1716
+ const a = e[i], u = At(a);
1717
+ let o = "";
1718
+ if (r === void 0 ? o = u : o = r + "." + u, u === t.textNodeName)
1719
+ s === void 0 ? s = a[u] : s += "" + a[u];
1720
+ else {
1721
+ if (u === void 0)
1722
+ continue;
1723
+ if (a[u]) {
1724
+ let d = ce(a[u], t, o);
1725
+ const l = Ct(d, t);
1726
+ a[":@"] ? Pt(d, a[":@"], o, t) : Object.keys(d).length === 1 && d[t.textNodeName] !== void 0 && !t.alwaysCreateTextNode ? d = d[t.textNodeName] : Object.keys(d).length === 0 && (t.alwaysCreateTextNode ? d[t.textNodeName] = "" : d = ""), n[u] !== void 0 && n.hasOwnProperty(u) ? (Array.isArray(n[u]) || (n[u] = [n[u]]), n[u].push(d)) : t.isArray(u, o, l) ? n[u] = [d] : n[u] = d;
1727
+ }
1728
+ }
1729
+ }
1730
+ return typeof s == "string" ? s.length > 0 && (n[t.textNodeName] = s) : s !== void 0 && (n[t.textNodeName] = s), n;
1731
+ }
1732
+ function At(e) {
1733
+ const t = Object.keys(e);
1734
+ for (let r = 0; r < t.length; r++) {
1735
+ const s = t[r];
1736
+ if (s !== ":@")
1737
+ return s;
1738
+ }
1739
+ }
1740
+ function Pt(e, t, r, s) {
1741
+ if (t) {
1742
+ const n = Object.keys(t), i = n.length;
1743
+ for (let a = 0; a < i; a++) {
1744
+ const u = n[a];
1745
+ s.isArray(u, r + "." + u, !0, !0) ? e[u] = [t[u]] : e[u] = t[u];
1746
+ }
1747
+ }
1748
+ }
1749
+ function Ct(e, t) {
1750
+ const { textNodeName: r } = t, s = Object.keys(e).length;
1751
+ return !!(s === 0 || s === 1 && (e[r] || typeof e[r] == "boolean" || e[r] === 0));
1752
+ }
1753
+ fe.prettify = It;
1754
+ const { buildOptions: Ot } = z, Ft = Tt, { prettify: xt } = fe, $t = G;
1755
+ let Vt = class {
1756
+ constructor(t) {
1757
+ this.externalEntities = {}, this.options = Ot(t);
1758
+ }
1759
+ /**
1760
+ * Parse XML dats to JS object
1761
+ * @param {string|Buffer} xmlData
1762
+ * @param {boolean|Object} validationOption
1763
+ */
1764
+ parse(t, r) {
1765
+ if (typeof t != "string")
1766
+ if (t.toString)
1767
+ t = t.toString();
1768
+ else
1769
+ throw new Error("XML data is accepted in String or Bytes[] form.");
1770
+ if (r) {
1771
+ r === !0 && (r = {});
1772
+ const i = $t.validate(t, r);
1773
+ if (i !== !0)
1774
+ throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`);
1775
+ }
1776
+ const s = new Ft(this.options);
1777
+ s.addExternalEntities(this.externalEntities);
1778
+ const n = s.parseXml(t);
1779
+ return this.options.preserveOrder || n === void 0 ? n : xt(n, this.options);
1780
+ }
1781
+ /**
1782
+ * Add Entity which is not by default supported by this library
1783
+ * @param {string} key
1784
+ * @param {string} value
1785
+ */
1786
+ addEntity(t, r) {
1787
+ if (r.indexOf("&") !== -1)
1788
+ throw new Error("Entity value can't have '&'");
1789
+ if (t.indexOf("&") !== -1 || t.indexOf(";") !== -1)
1790
+ throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");
1791
+ if (r === "&")
1792
+ throw new Error("An entity with value '&' is not permitted");
1793
+ this.externalEntities[t] = r;
1794
+ }
1795
+ };
1796
+ var Rt = Vt;
1797
+ const St = `
1798
+ `;
1799
+ function Lt(e, t) {
1800
+ let r = "";
1801
+ return t.format && t.indentBy.length > 0 && (r = St), he(e, t, "", r);
1802
+ }
1803
+ function he(e, t, r, s) {
1804
+ let n = "", i = !1;
1805
+ for (let a = 0; a < e.length; a++) {
1806
+ const u = e[a], o = Mt(u);
1807
+ if (o === void 0)
1808
+ continue;
1809
+ let d = "";
1810
+ if (r.length === 0 ? d = o : d = `${r}.${o}`, o === t.textNodeName) {
1811
+ let h = u[o];
1812
+ Bt(d, t) || (h = t.tagValueProcessor(o, h), h = pe(h, t)), i && (n += s), n += h, i = !1;
1813
+ continue;
1814
+ } else if (o === t.cdataPropName) {
1815
+ i && (n += s), n += `<![CDATA[${u[o][0][t.textNodeName]}]]>`, i = !1;
1816
+ continue;
1817
+ } else if (o === t.commentPropName) {
1818
+ n += s + `<!--${u[o][0][t.textNodeName]}-->`, i = !0;
1819
+ continue;
1820
+ } else if (o[0] === "?") {
1821
+ const h = ee(u[":@"], t), T = o === "?xml" ? "" : s;
1822
+ let E = u[o][0][t.textNodeName];
1823
+ E = E.length !== 0 ? " " + E : "", n += T + `<${o}${E}${h}?>`, i = !0;
1824
+ continue;
1825
+ }
1826
+ let l = s;
1827
+ l !== "" && (l += t.indentBy);
1828
+ const f = ee(u[":@"], t), c = s + `<${o}${f}`, g = he(u[o], t, d, l);
1829
+ t.unpairedTags.indexOf(o) !== -1 ? t.suppressUnpairedNode ? n += c + ">" : n += c + "/>" : (!g || g.length === 0) && t.suppressEmptyNode ? n += c + "/>" : g && g.endsWith(">") ? n += c + `>${g}${s}</${o}>` : (n += c + ">", g && s !== "" && (g.includes("/>") || g.includes("</")) ? n += s + t.indentBy + g + s : n += g, n += `</${o}>`), i = !0;
1830
+ }
1831
+ return n;
1832
+ }
1833
+ function Mt(e) {
1834
+ const t = Object.keys(e);
1835
+ for (let r = 0; r < t.length; r++) {
1836
+ const s = t[r];
1837
+ if (e.hasOwnProperty(s) && s !== ":@")
1838
+ return s;
1839
+ }
1840
+ }
1841
+ function ee(e, t) {
1842
+ let r = "";
1843
+ if (e && !t.ignoreAttributes)
1844
+ for (let s in e) {
1845
+ if (!e.hasOwnProperty(s))
1846
+ continue;
1847
+ let n = t.attributeValueProcessor(s, e[s]);
1848
+ n = pe(n, t), n === !0 && t.suppressBooleanAttributes ? r += ` ${s.substr(t.attributeNamePrefix.length)}` : r += ` ${s.substr(t.attributeNamePrefix.length)}="${n}"`;
1849
+ }
1850
+ return r;
1851
+ }
1852
+ function Bt(e, t) {
1853
+ e = e.substr(0, e.length - t.textNodeName.length - 1);
1854
+ let r = e.substr(e.lastIndexOf(".") + 1);
1855
+ for (let s in t.stopNodes)
1856
+ if (t.stopNodes[s] === e || t.stopNodes[s] === "*." + r)
1857
+ return !0;
1858
+ return !1;
1859
+ }
1860
+ function pe(e, t) {
1861
+ if (e && e.length > 0 && t.processEntities)
1862
+ for (let r = 0; r < t.entities.length; r++) {
1863
+ const s = t.entities[r];
1864
+ e = e.replace(s.regex, s.val);
1865
+ }
1866
+ return e;
1867
+ }
1868
+ var kt = Lt;
1869
+ const qt = kt, Ut = {
1870
+ attributeNamePrefix: "@_",
1871
+ attributesGroupName: !1,
1872
+ textNodeName: "#text",
1873
+ ignoreAttributes: !0,
1874
+ cdataPropName: !1,
1875
+ format: !1,
1876
+ indentBy: " ",
1877
+ suppressEmptyNode: !1,
1878
+ suppressUnpairedNode: !0,
1879
+ suppressBooleanAttributes: !0,
1880
+ tagValueProcessor: function(e, t) {
1881
+ return t;
1882
+ },
1883
+ attributeValueProcessor: function(e, t) {
1884
+ return t;
1885
+ },
1886
+ preserveOrder: !1,
1887
+ commentPropName: !1,
1888
+ unpairedTags: [],
1889
+ entities: [
1890
+ { regex: new RegExp("&", "g"), val: "&amp;" },
1891
+ //it must be on top
1892
+ { regex: new RegExp(">", "g"), val: "&gt;" },
1893
+ { regex: new RegExp("<", "g"), val: "&lt;" },
1894
+ { regex: new RegExp("'", "g"), val: "&apos;" },
1895
+ { regex: new RegExp('"', "g"), val: "&quot;" }
1896
+ ],
1897
+ processEntities: !0,
1898
+ stopNodes: [],
1899
+ // transformTagName: false,
1900
+ // transformAttributeName: false,
1901
+ oneListGroup: !1
1902
+ };
1903
+ function y(e) {
1904
+ this.options = Object.assign({}, Ut, e), this.options.ignoreAttributes || this.options.attributesGroupName ? this.isAttribute = function() {
1905
+ return !1;
1906
+ } : (this.attrPrefixLen = this.options.attributeNamePrefix.length, this.isAttribute = Ht), this.processTextOrObjNode = Xt, this.options.format ? (this.indentate = Gt, this.tagEndChar = `>
1907
+ `, this.newLine = `
1908
+ `) : (this.indentate = function() {
1909
+ return "";
1910
+ }, this.tagEndChar = ">", this.newLine = "");
1911
+ }
1912
+ y.prototype.build = function(e) {
1913
+ return this.options.preserveOrder ? qt(e, this.options) : (Array.isArray(e) && this.options.arrayNodeName && this.options.arrayNodeName.length > 1 && (e = {
1914
+ [this.options.arrayNodeName]: e
1915
+ }), this.j2x(e, 0).val);
1916
+ };
1917
+ y.prototype.j2x = function(e, t) {
1918
+ let r = "", s = "";
1919
+ for (let n in e)
1920
+ if (Object.prototype.hasOwnProperty.call(e, n))
1921
+ if (typeof e[n] > "u")
1922
+ this.isAttribute(n) && (s += "");
1923
+ else if (e[n] === null)
1924
+ this.isAttribute(n) ? s += "" : n[0] === "?" ? s += this.indentate(t) + "<" + n + "?" + this.tagEndChar : s += this.indentate(t) + "<" + n + "/" + this.tagEndChar;
1925
+ else if (e[n] instanceof Date)
1926
+ s += this.buildTextValNode(e[n], n, "", t);
1927
+ else if (typeof e[n] != "object") {
1928
+ const i = this.isAttribute(n);
1929
+ if (i)
1930
+ r += this.buildAttrPairStr(i, "" + e[n]);
1931
+ else if (n === this.options.textNodeName) {
1932
+ let a = this.options.tagValueProcessor(n, "" + e[n]);
1933
+ s += this.replaceEntitiesValue(a);
1934
+ } else
1935
+ s += this.buildTextValNode(e[n], n, "", t);
1936
+ } else if (Array.isArray(e[n])) {
1937
+ const i = e[n].length;
1938
+ let a = "";
1939
+ for (let u = 0; u < i; u++) {
1940
+ const o = e[n][u];
1941
+ typeof o > "u" || (o === null ? n[0] === "?" ? s += this.indentate(t) + "<" + n + "?" + this.tagEndChar : s += this.indentate(t) + "<" + n + "/" + this.tagEndChar : typeof o == "object" ? this.options.oneListGroup ? a += this.j2x(o, t + 1).val : a += this.processTextOrObjNode(o, n, t) : a += this.buildTextValNode(o, n, "", t));
1942
+ }
1943
+ this.options.oneListGroup && (a = this.buildObjectNode(a, n, "", t)), s += a;
1944
+ } else if (this.options.attributesGroupName && n === this.options.attributesGroupName) {
1945
+ const i = Object.keys(e[n]), a = i.length;
1946
+ for (let u = 0; u < a; u++)
1947
+ r += this.buildAttrPairStr(i[u], "" + e[n][i[u]]);
1948
+ } else
1949
+ s += this.processTextOrObjNode(e[n], n, t);
1950
+ return { attrStr: r, val: s };
1951
+ };
1952
+ y.prototype.buildAttrPairStr = function(e, t) {
1953
+ return t = this.options.attributeValueProcessor(e, "" + t), t = this.replaceEntitiesValue(t), this.options.suppressBooleanAttributes && t === "true" ? " " + e : " " + e + '="' + t + '"';
1954
+ };
1955
+ function Xt(e, t, r) {
1956
+ const s = this.j2x(e, r + 1);
1957
+ return e[this.options.textNodeName] !== void 0 && Object.keys(e).length === 1 ? this.buildTextValNode(e[this.options.textNodeName], t, s.attrStr, r) : this.buildObjectNode(s.val, t, s.attrStr, r);
1958
+ }
1959
+ y.prototype.buildObjectNode = function(e, t, r, s) {
1960
+ if (e === "")
1961
+ return t[0] === "?" ? this.indentate(s) + "<" + t + r + "?" + this.tagEndChar : this.indentate(s) + "<" + t + r + this.closeTag(t) + this.tagEndChar;
1962
+ {
1963
+ let n = "</" + t + this.tagEndChar, i = "";
1964
+ return t[0] === "?" && (i = "?", n = ""), (r || r === "") && e.indexOf("<") === -1 ? this.indentate(s) + "<" + t + r + i + ">" + e + n : this.options.commentPropName !== !1 && t === this.options.commentPropName && i.length === 0 ? this.indentate(s) + `<!--${e}-->` + this.newLine : this.indentate(s) + "<" + t + r + i + this.tagEndChar + e + this.indentate(s) + n;
1965
+ }
1966
+ };
1967
+ y.prototype.closeTag = function(e) {
1968
+ let t = "";
1969
+ return this.options.unpairedTags.indexOf(e) !== -1 ? this.options.suppressUnpairedNode || (t = "/") : this.options.suppressEmptyNode ? t = "/" : t = `></${e}`, t;
1970
+ };
1971
+ y.prototype.buildTextValNode = function(e, t, r, s) {
1972
+ if (this.options.cdataPropName !== !1 && t === this.options.cdataPropName)
1973
+ return this.indentate(s) + `<![CDATA[${e}]]>` + this.newLine;
1974
+ if (this.options.commentPropName !== !1 && t === this.options.commentPropName)
1975
+ return this.indentate(s) + `<!--${e}-->` + this.newLine;
1976
+ if (t[0] === "?")
1977
+ return this.indentate(s) + "<" + t + r + "?" + this.tagEndChar;
1978
+ {
1979
+ let n = this.options.tagValueProcessor(t, e);
1980
+ return n = this.replaceEntitiesValue(n), n === "" ? this.indentate(s) + "<" + t + r + this.closeTag(t) + this.tagEndChar : this.indentate(s) + "<" + t + r + ">" + n + "</" + t + this.tagEndChar;
1981
+ }
1982
+ };
1983
+ y.prototype.replaceEntitiesValue = function(e) {
1984
+ if (e && e.length > 0 && this.options.processEntities)
1985
+ for (let t = 0; t < this.options.entities.length; t++) {
1986
+ const r = this.options.entities[t];
1987
+ e = e.replace(r.regex, r.val);
1988
+ }
1989
+ return e;
1990
+ };
1991
+ function Gt(e) {
1992
+ return this.options.indentBy.repeat(e);
1993
+ }
1994
+ function Ht(e) {
1995
+ return e.startsWith(this.options.attributeNamePrefix) && e !== this.options.textNodeName ? e.substr(this.attrPrefixLen) : !1;
1996
+ }
1997
+ var zt = y;
1998
+ const Kt = G, Wt = Rt, Zt = zt;
1999
+ var te = {
2000
+ XMLParser: Wt,
2001
+ XMLValidator: Kt,
2002
+ XMLBuilder: Zt
2003
+ };
2004
+ function jt(e) {
2005
+ if (typeof e != "string")
2006
+ throw new TypeError(`Expected a \`string\`, got \`${typeof e}\``);
2007
+ if (e = e.trim(), e.length === 0 || te.XMLValidator.validate(e) !== !0)
2008
+ return !1;
2009
+ let t;
2010
+ const r = new te.XMLParser();
2011
+ try {
2012
+ t = r.parse(e);
2013
+ } catch {
2014
+ return !1;
2015
+ }
2016
+ return !(!t || !("svg" in t));
2017
+ }
2018
+ /**
2019
+ * @copyright Copyright (c) 2022 John Molakvoæ <skjnldsv@protonmail.com>
2020
+ *
2021
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
2022
+ *
2023
+ * @license AGPL-3.0-or-later
2024
+ *
2025
+ * This program is free software: you can redistribute it and/or modify
2026
+ * it under the terms of the GNU Affero General Public License as
2027
+ * published by the Free Software Foundation, either version 3 of the
2028
+ * License, or (at your option) any later version.
2029
+ *
2030
+ * This program is distributed in the hope that it will be useful,
2031
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2032
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2033
+ * GNU Affero General Public License for more details.
2034
+ *
2035
+ * You should have received a copy of the GNU Affero General Public License
2036
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2037
+ *
2038
+ */
2039
+ class Yt {
2040
+ _view;
2041
+ constructor(t) {
2042
+ Jt(t), this._view = t;
2043
+ }
2044
+ get id() {
2045
+ return this._view.id;
2046
+ }
2047
+ get name() {
2048
+ return this._view.name;
2049
+ }
2050
+ get caption() {
2051
+ return this._view.caption;
2052
+ }
2053
+ get emptyTitle() {
2054
+ return this._view.emptyTitle;
2055
+ }
2056
+ get emptyCaption() {
2057
+ return this._view.emptyCaption;
2058
+ }
2059
+ get getContents() {
2060
+ return this._view.getContents;
2061
+ }
2062
+ get icon() {
2063
+ return this._view.icon;
2064
+ }
2065
+ set icon(t) {
2066
+ this._view.icon = t;
2067
+ }
2068
+ get order() {
2069
+ return this._view.order;
2070
+ }
2071
+ set order(t) {
2072
+ this._view.order = t;
2073
+ }
2074
+ get params() {
2075
+ return this._view.params;
2076
+ }
2077
+ set params(t) {
2078
+ this._view.params = t;
2079
+ }
2080
+ get columns() {
2081
+ return this._view.columns;
2082
+ }
2083
+ get emptyView() {
2084
+ return this._view.emptyView;
2085
+ }
2086
+ get parent() {
2087
+ return this._view.parent;
2088
+ }
2089
+ get sticky() {
2090
+ return this._view.sticky;
2091
+ }
2092
+ get expanded() {
2093
+ return this._view.expanded;
2094
+ }
2095
+ set expanded(t) {
2096
+ this._view.expanded = t;
2097
+ }
2098
+ get defaultSortKey() {
2099
+ return this._view.defaultSortKey;
2100
+ }
2101
+ }
2102
+ const Jt = function(e) {
2103
+ if (!e.id || typeof e.id != "string")
2104
+ throw new Error("View id is required and must be a string");
2105
+ if (!e.name || typeof e.name != "string")
2106
+ throw new Error("View name is required and must be a string");
2107
+ if (e.columns && e.columns.length > 0 && (!e.caption || typeof e.caption != "string"))
2108
+ throw new Error("View caption is required for top-level views and must be a string");
2109
+ if (!e.getContents || typeof e.getContents != "function")
2110
+ throw new Error("View getContents is required and must be a function");
2111
+ if (!e.icon || typeof e.icon != "string" || !jt(e.icon))
2112
+ throw new Error("View icon is required and must be a valid svg string");
2113
+ if (!("order" in e) || typeof e.order != "number")
2114
+ throw new Error("View order is required and must be a number");
2115
+ if (e.columns && e.columns.forEach((t) => {
2116
+ if (!(t instanceof de))
2117
+ throw new Error("View columns must be an array of Column. Invalid column found");
2118
+ }), e.emptyView && typeof e.emptyView != "function")
2119
+ throw new Error("View emptyView must be a function");
2120
+ if (e.parent && typeof e.parent != "string")
2121
+ throw new Error("View parent must be a string");
2122
+ if ("sticky" in e && typeof e.sticky != "boolean")
2123
+ throw new Error("View sticky must be a boolean");
2124
+ if ("expanded" in e && typeof e.expanded != "boolean")
2125
+ throw new Error("View expanded must be a boolean");
2126
+ if (e.defaultSortKey && typeof e.defaultSortKey != "string")
2127
+ throw new Error("View defaultSortKey must be a string");
2128
+ return !0;
2129
+ };
2130
+ /**
2131
+ * @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
2132
+ *
2133
+ * @author Christoph Wurst <christoph@winzerhof-wurst.at>
2134
+ * @author John Molakvoæ <skjnldsv@protonmail.com>
2135
+ *
2136
+ * @license AGPL-3.0-or-later
2137
+ *
2138
+ * This program is free software: you can redistribute it and/or modify
2139
+ * it under the terms of the GNU Affero General Public License as
2140
+ * published by the Free Software Foundation, either version 3 of the
2141
+ * License, or (at your option) any later version.
2142
+ *
2143
+ * This program is distributed in the hope that it will be useful,
2144
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2145
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2146
+ * GNU Affero General Public License for more details.
2147
+ *
2148
+ * You should have received a copy of the GNU Affero General Public License
2149
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2150
+ *
2151
+ */
2152
+ const Qt = function(e) {
2153
+ return S().registerEntry(e);
2154
+ }, Dt = function(e) {
2155
+ return S().unregisterEntry(e);
2156
+ }, er = function(e) {
2157
+ return S().getEntries(e).sort((r, s) => r.order !== void 0 && s.order !== void 0 && r.order !== s.order ? r.order - s.order : r.displayName.localeCompare(s.displayName, void 0, { numeric: !0, sensitivity: "base" }));
2158
+ };
2159
+ exports.Column = de;
2160
+ exports.DefaultType = L;
2161
+ exports.File = se;
2162
+ exports.FileAction = ve;
2163
+ exports.FileType = O;
2164
+ exports.Folder = oe;
2165
+ exports.Header = Ie;
2166
+ exports.Navigation = ae;
2167
+ exports.Node = q;
2168
+ exports.NodeStatus = k;
2169
+ exports.Permission = m;
2170
+ exports.View = Yt;
2171
+ exports.addNewFileMenuEntry = Qt;
2172
+ exports.davGetClient = xe;
2173
+ exports.davGetDefaultPropfind = Oe;
2174
+ exports.davGetFavoritesReport = re;
2175
+ exports.davGetRecentSearch = Fe;
2176
+ exports.davParsePermissions = ne;
2177
+ exports.davRemoteURL = X;
2178
+ exports.davResultToNode = ue;
2179
+ exports.davRootPath = U;
2180
+ exports.defaultDavNamespaces = B;
2181
+ exports.defaultDavProperties = M;
2182
+ exports.formatFileSize = ye;
2183
+ exports.getDavNameSpaces = C;
2184
+ exports.getDavProperties = P;
2185
+ exports.getFavoriteNodes = $e;
2186
+ exports.getFileActions = Te;
2187
+ exports.getFileListHeaders = Pe;
2188
+ exports.getNavigation = Ve;
2189
+ exports.getNewFileMenuEntries = er;
2190
+ exports.parseFileSize = be;
2191
+ exports.registerDavProperty = Ce;
2192
+ exports.registerFileAction = _e;
2193
+ exports.registerFileListHeaders = Ae;
2194
+ exports.removeNewFileMenuEntry = Dt;