@ztimson/utils 0.20.11 → 0.21.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/README.md +91 -91
- package/dist/array.d.ts +0 -7
- package/dist/aset.d.ts +6 -6
- package/dist/cache.d.ts +5 -17
- package/dist/emitter.d.ts +5 -5
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +517 -561
- package/dist/index.mjs.map +1 -1
- package/dist/logger.d.ts +5 -5
- package/dist/makeArray.ts +7 -0
- package/dist/misc.d.ts +0 -11
- package/dist/time.d.ts +2 -2
- package/package.json +1 -1
- package/dist/path-events.d.ts +0 -137
package/dist/index.mjs
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
var it = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var c = (
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
return Array.isArray(
|
|
7
|
-
(t &&
|
|
8
|
-
}),
|
|
9
|
-
}
|
|
10
|
-
function
|
|
11
|
-
return structuredClone(
|
|
12
|
-
}
|
|
13
|
-
function
|
|
2
|
+
var ct = (r, t, e) => t in r ? it(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var c = (r, t, e) => ct(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
function ut(r, t = !1) {
|
|
5
|
+
if (r == null) throw new Error("Cannot clean a NULL value");
|
|
6
|
+
return Array.isArray(r) ? r = r.filter((e) => e != null) : Object.entries(r).forEach(([e, n]) => {
|
|
7
|
+
(t && n === void 0 || !t && n == null) && delete r[e];
|
|
8
|
+
}), r;
|
|
9
|
+
}
|
|
10
|
+
function Rt(r) {
|
|
11
|
+
return structuredClone(r);
|
|
12
|
+
}
|
|
13
|
+
function at(r, ...t) {
|
|
14
14
|
return t.forEach((e) => {
|
|
15
|
-
for (const
|
|
16
|
-
e[
|
|
17
|
-
}),
|
|
18
|
-
}
|
|
19
|
-
function
|
|
20
|
-
if (!(
|
|
21
|
-
return t.split(/[.[\]]/g).filter((
|
|
22
|
-
if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(
|
|
15
|
+
for (const n in e)
|
|
16
|
+
e[n] && typeof e[n] == "object" && !Array.isArray(e[n]) ? (r[n] || (r[n] = {}), at(r[n], e[n])) : r[n] = e[n];
|
|
17
|
+
}), r;
|
|
18
|
+
}
|
|
19
|
+
function b(r, t, e) {
|
|
20
|
+
if (!(r == null || !t))
|
|
21
|
+
return t.split(/[.[\]]/g).filter((n) => n.length).reduce((n, s, o, i) => {
|
|
22
|
+
if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(n != null && n.hasOwnProperty(s))) {
|
|
23
23
|
if (e == null) return;
|
|
24
|
-
|
|
24
|
+
n[s] = {};
|
|
25
25
|
}
|
|
26
|
-
return e !== void 0 &&
|
|
27
|
-
},
|
|
26
|
+
return e !== void 0 && o == i.length - 1 ? n[s] = e : n[s];
|
|
27
|
+
}, r);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return Object.entries(
|
|
29
|
+
function jt(r) {
|
|
30
|
+
return Object.entries(r).map(
|
|
31
31
|
([t, e]) => encodeURIComponent(t) + "=" + encodeURIComponent(e)
|
|
32
32
|
).join("&");
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
if (typeof
|
|
36
|
-
for (const
|
|
37
|
-
const s = t ? t + "." +
|
|
38
|
-
typeof n
|
|
34
|
+
function H(r, t, e = {}) {
|
|
35
|
+
if (typeof r == "object" && !Array.isArray(r)) {
|
|
36
|
+
for (const n of Object.keys(r)) {
|
|
37
|
+
const s = t ? t + "." + n : n;
|
|
38
|
+
typeof r[n] == "object" ? H(r[n], s, e) : e[s] = r[n];
|
|
39
39
|
}
|
|
40
40
|
return e;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function $t(r) {
|
|
44
44
|
const t = new FormData();
|
|
45
|
-
return Object.entries(
|
|
45
|
+
return Object.entries(r).forEach(([e, n]) => t.append(e, n)), t;
|
|
46
46
|
}
|
|
47
|
-
function q(
|
|
48
|
-
if (
|
|
49
|
-
if (Array.isArray(t)) return t.findIndex((s,
|
|
50
|
-
const
|
|
51
|
-
return
|
|
47
|
+
function q(r, t, e = !1) {
|
|
48
|
+
if (r == null) return e;
|
|
49
|
+
if (Array.isArray(t)) return t.findIndex((s, o) => !q(r[o], t[o], e)) == -1;
|
|
50
|
+
const n = typeof t;
|
|
51
|
+
return n != typeof r ? !1 : n == "object" ? Object.keys(t).find((s) => !q(r[s], t[s], e)) == null : n == "function" ? r.toString() == t.toString() : r == t;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
54
|
-
const e = typeof
|
|
55
|
-
return e != "object" ||
|
|
53
|
+
function A(r, t) {
|
|
54
|
+
const e = typeof r, n = typeof t;
|
|
55
|
+
return e != "object" || r == null || n != "object" || t == null ? e == "function" && n == "function" ? r.toString() == t.toString() : r === t : Object.keys(r).length != Object.keys(t).length ? !1 : Object.keys(r).every((o) => A(r[o], t[o]));
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function Ct(r, t) {
|
|
58
58
|
t.forEach((e) => {
|
|
59
|
-
Object.getOwnPropertyNames(e.prototype).forEach((
|
|
59
|
+
Object.getOwnPropertyNames(e.prototype).forEach((n) => {
|
|
60
60
|
Object.defineProperty(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Object.getOwnPropertyDescriptor(e.prototype,
|
|
61
|
+
r.prototype,
|
|
62
|
+
n,
|
|
63
|
+
Object.getOwnPropertyDescriptor(e.prototype, n) || /* @__PURE__ */ Object.create(null)
|
|
64
64
|
);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function M(r) {
|
|
69
69
|
try {
|
|
70
|
-
return JSON.parse(
|
|
70
|
+
return JSON.parse(r);
|
|
71
71
|
} catch {
|
|
72
|
-
return
|
|
72
|
+
return r;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function Lt(r, t) {
|
|
76
76
|
let e = [];
|
|
77
|
-
return JSON.stringify(
|
|
77
|
+
return JSON.stringify(r, (n, s) => {
|
|
78
78
|
if (typeof s == "object" && s !== null) {
|
|
79
79
|
if (e.includes(s)) return;
|
|
80
80
|
e.push(s);
|
|
@@ -82,42 +82,42 @@ function at(n, t) {
|
|
|
82
82
|
return s;
|
|
83
83
|
}, t);
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
return
|
|
85
|
+
function Nt(r, t) {
|
|
86
|
+
return r.indexOf(t) === -1 && r.push(t), r;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
89
|
-
return
|
|
90
|
-
...
|
|
91
|
-
...t.filter((e) => !
|
|
88
|
+
function It(r, t) {
|
|
89
|
+
return ht([
|
|
90
|
+
...r.filter((e) => !t.includes((n) => A(e, n))),
|
|
91
|
+
...t.filter((e) => !r.includes((n) => A(e, n)))
|
|
92
92
|
]);
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function Mt(r) {
|
|
95
95
|
return function(t, e) {
|
|
96
|
-
const
|
|
97
|
-
return typeof
|
|
96
|
+
const n = b(t, r), s = b(e, r);
|
|
97
|
+
return typeof n != "string" || typeof s != "string" ? 1 : n.toLowerCase().localeCompare(s.toLowerCase());
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
|
-
function
|
|
101
|
-
return (e) =>
|
|
100
|
+
function Tt(r, t) {
|
|
101
|
+
return (e) => A(b(e, r), t);
|
|
102
102
|
}
|
|
103
|
-
function lt(
|
|
104
|
-
return
|
|
103
|
+
function lt(r, t = []) {
|
|
104
|
+
return r.forEach((e) => Array.isArray(e) ? lt(e, t) : t.push(e)), t;
|
|
105
105
|
}
|
|
106
|
-
function
|
|
107
|
-
return function(e,
|
|
108
|
-
const s =
|
|
109
|
-
return typeof s == "number" && typeof
|
|
106
|
+
function kt(r, t = !1) {
|
|
107
|
+
return function(e, n) {
|
|
108
|
+
const s = b(e, r), o = b(n, r);
|
|
109
|
+
return typeof s == "number" && typeof o == "number" ? (t ? -1 : 1) * (s - o) : s > o ? t ? -1 : 1 : s < o ? t ? 1 : -1 : 0;
|
|
110
110
|
};
|
|
111
111
|
}
|
|
112
|
-
function
|
|
113
|
-
for (let t =
|
|
114
|
-
|
|
115
|
-
return
|
|
112
|
+
function ht(r) {
|
|
113
|
+
for (let t = r.length - 1; t >= 0; t--)
|
|
114
|
+
r.slice(0, t).find((e) => A(e, r[t])) && r.splice(t, 1);
|
|
115
|
+
return r;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
return Array.isArray(
|
|
117
|
+
function ft(r) {
|
|
118
|
+
return Array.isArray(r) ? r : [r];
|
|
119
119
|
}
|
|
120
|
-
class
|
|
120
|
+
class B extends Array {
|
|
121
121
|
/** Number of elements in set */
|
|
122
122
|
get size() {
|
|
123
123
|
return this.length;
|
|
@@ -130,21 +130,19 @@ class S extends Array {
|
|
|
130
130
|
super(), t != null && t.forEach && t.forEach((e) => this.add(e));
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
|
-
* Add
|
|
134
|
-
* @param
|
|
133
|
+
* Add single element to set if unique
|
|
134
|
+
* @param {T} el Element to add
|
|
135
135
|
*/
|
|
136
|
-
add(
|
|
137
|
-
|
|
136
|
+
add(t) {
|
|
137
|
+
this.has(t) || this.push(t);
|
|
138
138
|
}
|
|
139
139
|
/**
|
|
140
|
-
* Delete
|
|
141
|
-
* @param
|
|
140
|
+
* Delete element from set
|
|
141
|
+
* @param {T} el Element that will be deleted
|
|
142
142
|
*/
|
|
143
|
-
delete(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
r != -1 && this.slice(r, 1);
|
|
147
|
-
});
|
|
143
|
+
delete(t) {
|
|
144
|
+
const e = this.indexOf(t);
|
|
145
|
+
e != -1 && this.slice(e, 1);
|
|
148
146
|
}
|
|
149
147
|
/**
|
|
150
148
|
* Create list of elements this set has which the comparison set does not
|
|
@@ -152,7 +150,7 @@ class S extends Array {
|
|
|
152
150
|
* @return {ASet<T>} Different elements
|
|
153
151
|
*/
|
|
154
152
|
difference(t) {
|
|
155
|
-
return new
|
|
153
|
+
return new B(this.filter((e) => !t.has(e)));
|
|
156
154
|
}
|
|
157
155
|
/**
|
|
158
156
|
* Check if set includes element
|
|
@@ -168,7 +166,7 @@ class S extends Array {
|
|
|
168
166
|
* @return {boolean} Set of common elements
|
|
169
167
|
*/
|
|
170
168
|
intersection(t) {
|
|
171
|
-
return new
|
|
169
|
+
return new B(this.filter((e) => t.has(e)));
|
|
172
170
|
}
|
|
173
171
|
/**
|
|
174
172
|
* Check if this set has no elements in common with the comparison set
|
|
@@ -200,7 +198,7 @@ class S extends Array {
|
|
|
200
198
|
* @return {ASet<T>} New set of unique elements
|
|
201
199
|
*/
|
|
202
200
|
symmetricDifference(t) {
|
|
203
|
-
return new
|
|
201
|
+
return new B([...this.difference(t), ...t.difference(this)]);
|
|
204
202
|
}
|
|
205
203
|
/**
|
|
206
204
|
* Create joined list of elements included in this & the comparison set
|
|
@@ -208,17 +206,17 @@ class S extends Array {
|
|
|
208
206
|
* @return {ASet<T>} New set of both previous sets combined
|
|
209
207
|
*/
|
|
210
208
|
union(t) {
|
|
211
|
-
return new
|
|
209
|
+
return new B([...this, ...t]);
|
|
212
210
|
}
|
|
213
211
|
}
|
|
214
|
-
class
|
|
212
|
+
class Dt {
|
|
215
213
|
/**
|
|
216
214
|
* Create new cache
|
|
217
215
|
*
|
|
218
216
|
* @param {keyof T} key Default property to use as primary key
|
|
219
|
-
* @param
|
|
217
|
+
* @param {number} ttl Default expiry in milliseconds
|
|
220
218
|
*/
|
|
221
|
-
constructor(t, e
|
|
219
|
+
constructor(t, e) {
|
|
222
220
|
c(this, "store", {});
|
|
223
221
|
/** Whether cache is complete */
|
|
224
222
|
c(this, "complete", !1);
|
|
@@ -228,17 +226,9 @@ class It {
|
|
|
228
226
|
* @return {T[]} Array of items
|
|
229
227
|
*/
|
|
230
228
|
c(this, "values", this.all());
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
try {
|
|
235
|
-
Object.assign(this.store, JSON.parse(r));
|
|
236
|
-
} catch {
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
return new Proxy(this, {
|
|
240
|
-
get: (r, s) => s in r ? r[s] : r.store[s],
|
|
241
|
-
set: (r, s, i) => (s in r ? r[s] = i : r.store[s] = i, !0)
|
|
229
|
+
return this.key = t, this.ttl = e, new Proxy(this, {
|
|
230
|
+
get: (n, s) => s in n ? n[s] : n.store[s],
|
|
231
|
+
set: (n, s, o) => (s in n ? n[s] = o : n.store[s] = o, !0)
|
|
242
232
|
});
|
|
243
233
|
}
|
|
244
234
|
getKey(t) {
|
|
@@ -261,8 +251,8 @@ class It {
|
|
|
261
251
|
* @return {this}
|
|
262
252
|
*/
|
|
263
253
|
add(t, e = this.ttl) {
|
|
264
|
-
const
|
|
265
|
-
return this.set(
|
|
254
|
+
const n = this.getKey(t);
|
|
255
|
+
return this.set(n, t, e), this;
|
|
266
256
|
}
|
|
267
257
|
/**
|
|
268
258
|
* Add several rows to the cache
|
|
@@ -272,13 +262,7 @@ class It {
|
|
|
272
262
|
* @return {this}
|
|
273
263
|
*/
|
|
274
264
|
addAll(t, e = !0) {
|
|
275
|
-
return t.forEach((
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Remove all keys from cache
|
|
279
|
-
*/
|
|
280
|
-
clear() {
|
|
281
|
-
this.store = {};
|
|
265
|
+
return t.forEach((n) => this.add(n)), this.complete = e, this;
|
|
282
266
|
}
|
|
283
267
|
/**
|
|
284
268
|
* Delete an item from the cache
|
|
@@ -286,7 +270,7 @@ class It {
|
|
|
286
270
|
* @param {K} key Item's primary key
|
|
287
271
|
*/
|
|
288
272
|
delete(t) {
|
|
289
|
-
delete this.store[t]
|
|
273
|
+
delete this.store[t];
|
|
290
274
|
}
|
|
291
275
|
/**
|
|
292
276
|
* Return cache as an array of key-value pairs
|
|
@@ -324,34 +308,34 @@ class It {
|
|
|
324
308
|
*
|
|
325
309
|
* @param {K} key Key item will be cached under
|
|
326
310
|
* @param {T} value Item to cache
|
|
327
|
-
* @param {number | undefined} ttl Override default expiry
|
|
311
|
+
* @param {number | undefined} ttl Override default expiry
|
|
328
312
|
* @return {this}
|
|
329
313
|
*/
|
|
330
|
-
set(t, e,
|
|
331
|
-
return this.store[t] = e,
|
|
314
|
+
set(t, e, n = this.ttl) {
|
|
315
|
+
return this.store[t] = e, n && setTimeout(() => {
|
|
332
316
|
this.complete = !1, this.delete(t);
|
|
333
|
-
},
|
|
317
|
+
}, n), this;
|
|
334
318
|
}
|
|
335
319
|
}
|
|
336
|
-
function
|
|
337
|
-
const e =
|
|
338
|
-
|
|
339
|
-
}),
|
|
320
|
+
function Pt(r, t = !0) {
|
|
321
|
+
const e = r.reduce((n, s) => (Object.keys(t ? H(s) : s).forEach((o) => {
|
|
322
|
+
n.includes(o) || n.push(o);
|
|
323
|
+
}), n), []);
|
|
340
324
|
return [
|
|
341
325
|
e.join(","),
|
|
342
|
-
...
|
|
343
|
-
const
|
|
344
|
-
return
|
|
326
|
+
...r.map((n) => e.map((s) => {
|
|
327
|
+
const o = b(n, s), i = typeof o;
|
|
328
|
+
return i == "string" && o.includes(",") ? `"${o}"` : i == "object" ? `"${JSON.stringify(o)}"` : o;
|
|
345
329
|
}).join(","))
|
|
346
330
|
].join(`
|
|
347
331
|
`);
|
|
348
332
|
}
|
|
349
|
-
class
|
|
333
|
+
class E extends Promise {
|
|
350
334
|
constructor(e) {
|
|
351
|
-
super((
|
|
352
|
-
(
|
|
353
|
-
(
|
|
354
|
-
(
|
|
335
|
+
super((n, s) => e(
|
|
336
|
+
(o) => n(o),
|
|
337
|
+
(o) => s(o),
|
|
338
|
+
(o) => this.progress = o
|
|
355
339
|
));
|
|
356
340
|
c(this, "listeners", []);
|
|
357
341
|
c(this, "_progress", 0);
|
|
@@ -360,20 +344,20 @@ class b extends Promise {
|
|
|
360
344
|
return this._progress;
|
|
361
345
|
}
|
|
362
346
|
set progress(e) {
|
|
363
|
-
e != this._progress && (this._progress = e, this.listeners.forEach((
|
|
347
|
+
e != this._progress && (this._progress = e, this.listeners.forEach((n) => n(e)));
|
|
364
348
|
}
|
|
365
349
|
static from(e) {
|
|
366
|
-
return e instanceof
|
|
350
|
+
return e instanceof E ? e : new E((n, s) => e.then((...o) => n(...o)).catch((...o) => s(...o)));
|
|
367
351
|
}
|
|
368
352
|
from(e) {
|
|
369
|
-
const
|
|
370
|
-
return this.onProgress((s) =>
|
|
353
|
+
const n = E.from(e);
|
|
354
|
+
return this.onProgress((s) => n.progress = s), n;
|
|
371
355
|
}
|
|
372
356
|
onProgress(e) {
|
|
373
357
|
return this.listeners.push(e), this;
|
|
374
358
|
}
|
|
375
|
-
then(e,
|
|
376
|
-
const s = super.then(e,
|
|
359
|
+
then(e, n) {
|
|
360
|
+
const s = super.then(e, n);
|
|
377
361
|
return this.from(s);
|
|
378
362
|
}
|
|
379
363
|
catch(e) {
|
|
@@ -383,81 +367,81 @@ class b extends Promise {
|
|
|
383
367
|
return this.from(super.finally(e));
|
|
384
368
|
}
|
|
385
369
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
388
|
-
const e = URL.createObjectURL(
|
|
389
|
-
|
|
370
|
+
function Gt(r, t) {
|
|
371
|
+
r instanceof Blob || (r = new Blob(ft(r)));
|
|
372
|
+
const e = URL.createObjectURL(r);
|
|
373
|
+
dt(e, t), URL.revokeObjectURL(e);
|
|
390
374
|
}
|
|
391
|
-
function
|
|
375
|
+
function dt(r, t) {
|
|
392
376
|
const e = document.createElement("a");
|
|
393
|
-
e.href =
|
|
377
|
+
e.href = r, e.download = t || r.split("/").pop(), document.body.appendChild(e), e.click(), document.body.removeChild(e);
|
|
394
378
|
}
|
|
395
|
-
function
|
|
379
|
+
function Ut(r = {}) {
|
|
396
380
|
return new Promise((t) => {
|
|
397
381
|
const e = document.createElement("input");
|
|
398
|
-
e.type = "file", e.accept =
|
|
382
|
+
e.type = "file", e.accept = r.accept || "*", e.style.display = "none", e.multiple = !!r.multiple, e.onblur = e.onchange = async () => {
|
|
399
383
|
t(Array.from(e.files)), e.remove();
|
|
400
384
|
}, document.body.appendChild(e), e.click();
|
|
401
385
|
});
|
|
402
386
|
}
|
|
403
|
-
function
|
|
387
|
+
function qt(r, t = /* @__PURE__ */ new Date()) {
|
|
404
388
|
(typeof t == "number" || typeof t == "string") && (t = new Date(t));
|
|
405
389
|
const e = `${t.getFullYear()}-${(t.getMonth() + 1).toString().padStart(2, "0")}-${t.getDate().toString().padStart(2, "0")}_${t.getHours().toString().padStart(2, "0")}-${t.getMinutes().toString().padStart(2, "0")}-${t.getSeconds().toString().padStart(2, "0")}`;
|
|
406
|
-
return
|
|
390
|
+
return r ? r.replace("{{TIMESTAMP}}", e) : e;
|
|
407
391
|
}
|
|
408
|
-
function
|
|
409
|
-
return new
|
|
410
|
-
const s = new XMLHttpRequest(),
|
|
411
|
-
|
|
392
|
+
function Ft(r) {
|
|
393
|
+
return new E((t, e, n) => {
|
|
394
|
+
const s = new XMLHttpRequest(), o = new FormData();
|
|
395
|
+
r.files.forEach((i) => o.append("file", i)), s.withCredentials = !!r.withCredentials, s.upload.addEventListener("progress", (i) => i.lengthComputable ? n(i.loaded / i.total) : null), s.addEventListener("loadend", () => t(M(s.responseText))), s.addEventListener("error", () => e(M(s.responseText))), s.addEventListener("timeout", () => e({ error: "Request timed out" })), s.open("POST", r.url), Object.entries(r.headers || {}).forEach(([i, a]) => s.setRequestHeader(i, a)), s.send(o);
|
|
412
396
|
});
|
|
413
397
|
}
|
|
414
|
-
class
|
|
398
|
+
class _ {
|
|
415
399
|
constructor() {
|
|
416
400
|
c(this, "listeners", {});
|
|
417
401
|
}
|
|
418
402
|
static emit(t, ...e) {
|
|
419
|
-
(this.listeners["*"] || []).forEach((
|
|
403
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t.toString()] || []).forEach((n) => n(...e));
|
|
420
404
|
}
|
|
421
405
|
static off(t, e) {
|
|
422
|
-
const
|
|
423
|
-
this.listeners[
|
|
406
|
+
const n = t.toString();
|
|
407
|
+
this.listeners[n] = (this.listeners[n] || []).filter((s) => s === e);
|
|
424
408
|
}
|
|
425
409
|
static on(t, e) {
|
|
426
410
|
var s;
|
|
427
|
-
const
|
|
428
|
-
return this.listeners[
|
|
411
|
+
const n = t.toString();
|
|
412
|
+
return this.listeners[n] || (this.listeners[n] = []), (s = this.listeners[n]) == null || s.push(e), () => this.off(t, e);
|
|
429
413
|
}
|
|
430
414
|
static once(t, e) {
|
|
431
|
-
return new Promise((
|
|
432
|
-
const s = this.on(t, (...
|
|
433
|
-
|
|
415
|
+
return new Promise((n) => {
|
|
416
|
+
const s = this.on(t, (...o) => {
|
|
417
|
+
n(o.length == 1 ? o[0] : o), e && e(...o), s();
|
|
434
418
|
});
|
|
435
419
|
});
|
|
436
420
|
}
|
|
437
421
|
emit(t, ...e) {
|
|
438
|
-
(this.listeners["*"] || []).forEach((
|
|
422
|
+
(this.listeners["*"] || []).forEach((n) => n(t, ...e)), (this.listeners[t] || []).forEach((n) => n(...e));
|
|
439
423
|
}
|
|
440
424
|
off(t, e) {
|
|
441
|
-
this.listeners[t] = (this.listeners[t] || []).filter((
|
|
425
|
+
this.listeners[t] = (this.listeners[t] || []).filter((n) => n === e);
|
|
442
426
|
}
|
|
443
427
|
on(t, e) {
|
|
444
|
-
var
|
|
445
|
-
return this.listeners[t] || (this.listeners[t] = []), (
|
|
428
|
+
var n;
|
|
429
|
+
return this.listeners[t] || (this.listeners[t] = []), (n = this.listeners[t]) == null || n.push(e), () => this.off(t, e);
|
|
446
430
|
}
|
|
447
431
|
once(t, e) {
|
|
448
|
-
return new Promise((
|
|
449
|
-
const s = this.on(t, (...
|
|
450
|
-
|
|
432
|
+
return new Promise((n) => {
|
|
433
|
+
const s = this.on(t, (...o) => {
|
|
434
|
+
n(o.length == 1 ? o[0] : o), e && e(...o), s();
|
|
451
435
|
});
|
|
452
436
|
});
|
|
453
437
|
}
|
|
454
438
|
}
|
|
455
|
-
c(
|
|
456
|
-
class
|
|
457
|
-
constructor(e,
|
|
439
|
+
c(_, "listeners", {});
|
|
440
|
+
class p extends Error {
|
|
441
|
+
constructor(e, n) {
|
|
458
442
|
super(e);
|
|
459
443
|
c(this, "_code");
|
|
460
|
-
|
|
444
|
+
n != null && (this._code = n);
|
|
461
445
|
}
|
|
462
446
|
get code() {
|
|
463
447
|
return this._code || this.constructor.code;
|
|
@@ -466,11 +450,11 @@ class g extends Error {
|
|
|
466
450
|
this._code = e;
|
|
467
451
|
}
|
|
468
452
|
static from(e) {
|
|
469
|
-
const
|
|
453
|
+
const n = Number(e.statusCode) ?? Number(e.code), s = new this(e.message || e.toString());
|
|
470
454
|
return Object.assign(s, {
|
|
471
455
|
stack: e.stack,
|
|
472
456
|
...e,
|
|
473
|
-
code:
|
|
457
|
+
code: n ?? void 0
|
|
474
458
|
});
|
|
475
459
|
}
|
|
476
460
|
static instanceof(e) {
|
|
@@ -480,8 +464,8 @@ class g extends Error {
|
|
|
480
464
|
return this.message || super.toString();
|
|
481
465
|
}
|
|
482
466
|
}
|
|
483
|
-
c(
|
|
484
|
-
class
|
|
467
|
+
c(p, "code", 500);
|
|
468
|
+
class W extends p {
|
|
485
469
|
constructor(t = "Bad Request") {
|
|
486
470
|
super(t);
|
|
487
471
|
}
|
|
@@ -489,8 +473,8 @@ class v extends g {
|
|
|
489
473
|
return t.constructor.code == this.code;
|
|
490
474
|
}
|
|
491
475
|
}
|
|
492
|
-
c(
|
|
493
|
-
class J extends
|
|
476
|
+
c(W, "code", 400);
|
|
477
|
+
class J extends p {
|
|
494
478
|
constructor(t = "Unauthorized") {
|
|
495
479
|
super(t);
|
|
496
480
|
}
|
|
@@ -499,7 +483,7 @@ class J extends g {
|
|
|
499
483
|
}
|
|
500
484
|
}
|
|
501
485
|
c(J, "code", 401);
|
|
502
|
-
class z extends
|
|
486
|
+
class z extends p {
|
|
503
487
|
constructor(t = "Payment Required") {
|
|
504
488
|
super(t);
|
|
505
489
|
}
|
|
@@ -508,7 +492,7 @@ class z extends g {
|
|
|
508
492
|
}
|
|
509
493
|
}
|
|
510
494
|
c(z, "code", 402);
|
|
511
|
-
class
|
|
495
|
+
class K extends p {
|
|
512
496
|
constructor(t = "Forbidden") {
|
|
513
497
|
super(t);
|
|
514
498
|
}
|
|
@@ -516,8 +500,8 @@ class Z extends g {
|
|
|
516
500
|
return t.constructor.code == this.code;
|
|
517
501
|
}
|
|
518
502
|
}
|
|
519
|
-
c(
|
|
520
|
-
class
|
|
503
|
+
c(K, "code", 403);
|
|
504
|
+
class Z extends p {
|
|
521
505
|
constructor(t = "Not Found") {
|
|
522
506
|
super(t);
|
|
523
507
|
}
|
|
@@ -525,8 +509,8 @@ class V extends g {
|
|
|
525
509
|
return t.constructor.code == this.code;
|
|
526
510
|
}
|
|
527
511
|
}
|
|
528
|
-
c(
|
|
529
|
-
class
|
|
512
|
+
c(Z, "code", 404);
|
|
513
|
+
class V extends p {
|
|
530
514
|
constructor(t = "Method Not Allowed") {
|
|
531
515
|
super(t);
|
|
532
516
|
}
|
|
@@ -534,8 +518,8 @@ class X extends g {
|
|
|
534
518
|
return t.constructor.code == this.code;
|
|
535
519
|
}
|
|
536
520
|
}
|
|
537
|
-
c(
|
|
538
|
-
class
|
|
521
|
+
c(V, "code", 405);
|
|
522
|
+
class X extends p {
|
|
539
523
|
constructor(t = "Not Acceptable") {
|
|
540
524
|
super(t);
|
|
541
525
|
}
|
|
@@ -543,8 +527,8 @@ class Q extends g {
|
|
|
543
527
|
return t.constructor.code == this.code;
|
|
544
528
|
}
|
|
545
529
|
}
|
|
546
|
-
c(
|
|
547
|
-
class
|
|
530
|
+
c(X, "code", 406);
|
|
531
|
+
class Q extends p {
|
|
548
532
|
constructor(t = "Internal Server Error") {
|
|
549
533
|
super(t);
|
|
550
534
|
}
|
|
@@ -552,8 +536,8 @@ class _ extends g {
|
|
|
552
536
|
return t.constructor.code == this.code;
|
|
553
537
|
}
|
|
554
538
|
}
|
|
555
|
-
c(
|
|
556
|
-
class tt extends
|
|
539
|
+
c(Q, "code", 500);
|
|
540
|
+
class tt extends p {
|
|
557
541
|
constructor(t = "Not Implemented") {
|
|
558
542
|
super(t);
|
|
559
543
|
}
|
|
@@ -562,7 +546,7 @@ class tt extends g {
|
|
|
562
546
|
}
|
|
563
547
|
}
|
|
564
548
|
c(tt, "code", 501);
|
|
565
|
-
class et extends
|
|
549
|
+
class et extends p {
|
|
566
550
|
constructor(t = "Bad Gateway") {
|
|
567
551
|
super(t);
|
|
568
552
|
}
|
|
@@ -571,7 +555,7 @@ class et extends g {
|
|
|
571
555
|
}
|
|
572
556
|
}
|
|
573
557
|
c(et, "code", 502);
|
|
574
|
-
class
|
|
558
|
+
class rt extends p {
|
|
575
559
|
constructor(t = "Service Unavailable") {
|
|
576
560
|
super(t);
|
|
577
561
|
}
|
|
@@ -579,8 +563,8 @@ class nt extends g {
|
|
|
579
563
|
return t.constructor.code == this.code;
|
|
580
564
|
}
|
|
581
565
|
}
|
|
582
|
-
c(
|
|
583
|
-
class
|
|
566
|
+
c(rt, "code", 503);
|
|
567
|
+
class nt extends p {
|
|
584
568
|
constructor(t = "Gateway Timeout") {
|
|
585
569
|
super(t);
|
|
586
570
|
}
|
|
@@ -588,49 +572,49 @@ class rt extends g {
|
|
|
588
572
|
return t.constructor.code == this.code;
|
|
589
573
|
}
|
|
590
574
|
}
|
|
591
|
-
c(
|
|
592
|
-
function
|
|
593
|
-
if (
|
|
594
|
-
switch (
|
|
575
|
+
c(nt, "code", 504);
|
|
576
|
+
function Yt(r, t) {
|
|
577
|
+
if (r >= 200 && r < 300) return null;
|
|
578
|
+
switch (r) {
|
|
595
579
|
case 400:
|
|
596
|
-
return new
|
|
580
|
+
return new W(t);
|
|
597
581
|
case 401:
|
|
598
582
|
return new J(t);
|
|
599
583
|
case 402:
|
|
600
584
|
return new z(t);
|
|
601
585
|
case 403:
|
|
602
|
-
return new
|
|
586
|
+
return new K(t);
|
|
603
587
|
case 404:
|
|
604
|
-
return new
|
|
588
|
+
return new Z(t);
|
|
605
589
|
case 405:
|
|
606
|
-
return new
|
|
590
|
+
return new V(t);
|
|
607
591
|
case 406:
|
|
608
|
-
return new
|
|
592
|
+
return new X(t);
|
|
609
593
|
case 500:
|
|
610
|
-
return new
|
|
594
|
+
return new Q(t);
|
|
611
595
|
case 501:
|
|
612
596
|
return new tt(t);
|
|
613
597
|
case 502:
|
|
614
598
|
return new et(t);
|
|
615
599
|
case 503:
|
|
616
|
-
return new nt(t);
|
|
617
|
-
case 504:
|
|
618
600
|
return new rt(t);
|
|
601
|
+
case 504:
|
|
602
|
+
return new nt(t);
|
|
619
603
|
default:
|
|
620
|
-
return new
|
|
604
|
+
return new p(t, r);
|
|
621
605
|
}
|
|
622
606
|
}
|
|
623
|
-
const
|
|
607
|
+
const w = class w {
|
|
624
608
|
constructor(t = {}) {
|
|
625
609
|
c(this, "interceptors", {});
|
|
626
610
|
c(this, "headers", {});
|
|
627
611
|
c(this, "url");
|
|
628
|
-
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) =>
|
|
612
|
+
this.url = t.url ?? null, this.headers = t.headers || {}, t.interceptors && t.interceptors.forEach((e) => w.addInterceptor(e));
|
|
629
613
|
}
|
|
630
614
|
static addInterceptor(t) {
|
|
631
|
-
const e = Object.keys(
|
|
632
|
-
return
|
|
633
|
-
|
|
615
|
+
const e = Object.keys(w.interceptors).length.toString();
|
|
616
|
+
return w.interceptors[e] = t, () => {
|
|
617
|
+
w.interceptors[e] = null;
|
|
634
618
|
};
|
|
635
619
|
}
|
|
636
620
|
addInterceptor(t) {
|
|
@@ -643,60 +627,56 @@ const E = class E {
|
|
|
643
627
|
var s;
|
|
644
628
|
if (!this.url && !t.url) throw new Error("URL needs to be set");
|
|
645
629
|
let e = ((s = t.url) != null && s.startsWith("http") ? t.url : (this.url || "") + (t.url || "")).replace(/([^:]\/)\/+/g, "$1");
|
|
646
|
-
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (
|
|
647
|
-
const
|
|
648
|
-
e += (e.includes("?") ? "&" : "?") +
|
|
630
|
+
if (t.fragment && (e.includes("#") ? e.replace(/#.*(\?|\n)/g, (o, i) => `#${t.fragment}${i}`) : e += "#" + t.fragment), t.query) {
|
|
631
|
+
const o = Array.isArray(t.query) ? t.query : Object.keys(t.query).map((i) => ({ key: i, value: t.query[i] }));
|
|
632
|
+
e += (e.includes("?") ? "&" : "?") + o.map((i) => `${i.key}=${i.value}`).join("&");
|
|
649
633
|
}
|
|
650
|
-
const
|
|
634
|
+
const n = ut({
|
|
651
635
|
"Content-Type": t.body ? t.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
|
|
652
|
-
...
|
|
636
|
+
...w.headers,
|
|
653
637
|
...this.headers,
|
|
654
638
|
...t.headers
|
|
655
639
|
});
|
|
656
|
-
return typeof t.body == "object" && t.body != null &&
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
}).catch((A) => l.error(A));
|
|
675
|
-
}
|
|
676
|
-
C();
|
|
640
|
+
return typeof t.body == "object" && t.body != null && n["Content-Type"] == "application/json" && (t.body = JSON.stringify(t.body)), new E((o, i, a) => {
|
|
641
|
+
fetch(e, {
|
|
642
|
+
headers: n,
|
|
643
|
+
method: t.method || (t.body ? "POST" : "GET"),
|
|
644
|
+
body: t.body
|
|
645
|
+
}).then(async (u) => {
|
|
646
|
+
var G, U;
|
|
647
|
+
for (let l of [...Object.values(w.interceptors), ...Object.values(this.interceptors)])
|
|
648
|
+
await new Promise((R) => l(u, () => R()));
|
|
649
|
+
const v = u.headers.get("Content-Length"), N = v ? parseInt(v, 10) : 0;
|
|
650
|
+
let P = 0;
|
|
651
|
+
const I = (G = u.body) == null ? void 0 : G.getReader(), ot = new ReadableStream({
|
|
652
|
+
start(l) {
|
|
653
|
+
function R() {
|
|
654
|
+
I == null || I.read().then((O) => {
|
|
655
|
+
if (O.done) return l.close();
|
|
656
|
+
P += O.value.byteLength, a(P / N), l.enqueue(O.value), R();
|
|
657
|
+
}).catch((O) => l.error(O));
|
|
677
658
|
}
|
|
678
|
-
|
|
679
|
-
if (u.data = new Response(st), t.decode == null || t.decode) {
|
|
680
|
-
const l = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
|
|
681
|
-
l != null && l.includes("form") ? u.data = await u.data.formData() : l != null && l.includes("json") ? u.data = await u.data.json() : l != null && l.includes("text") ? u.data = await u.data.text() : l != null && l.includes("application") && (u.data = await u.data.blob());
|
|
659
|
+
R();
|
|
682
660
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
661
|
+
});
|
|
662
|
+
if (u.data = new Response(ot), t.decode == null || t.decode) {
|
|
663
|
+
const l = (U = u.headers.get("Content-Type")) == null ? void 0 : U.toLowerCase();
|
|
664
|
+
l != null && l.includes("form") ? u.data = await u.data.formData() : l != null && l.includes("json") ? u.data = await u.data.json() : l != null && l.includes("text") ? u.data = await u.data.text() : l != null && l.includes("application") && (u.data = await u.data.blob());
|
|
665
|
+
}
|
|
666
|
+
u.ok ? o(u) : i(u);
|
|
667
|
+
});
|
|
688
668
|
});
|
|
689
669
|
}
|
|
690
670
|
};
|
|
691
|
-
c(
|
|
692
|
-
let F =
|
|
693
|
-
function
|
|
694
|
-
const t =
|
|
695
|
-
return
|
|
671
|
+
c(w, "interceptors", {}), c(w, "headers", {});
|
|
672
|
+
let F = w;
|
|
673
|
+
function Ht(r) {
|
|
674
|
+
const t = r.split(".")[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
675
|
+
return M(decodeURIComponent(atob(t).split("").map(function(e) {
|
|
696
676
|
return "%" + ("00" + e.charCodeAt(0).toString(16)).slice(-2);
|
|
697
677
|
}).join("")));
|
|
698
678
|
}
|
|
699
|
-
const
|
|
679
|
+
const x = {
|
|
700
680
|
CLEAR: "\x1B[0m",
|
|
701
681
|
BRIGHT: "\x1B[1m",
|
|
702
682
|
DIM: "\x1B[2m",
|
|
@@ -704,7 +684,7 @@ const R = {
|
|
|
704
684
|
BLINK: "\x1B[5m",
|
|
705
685
|
REVERSE: "\x1B[7m",
|
|
706
686
|
HIDDEN: "\x1B[8m"
|
|
707
|
-
},
|
|
687
|
+
}, j = {
|
|
708
688
|
BLACK: "\x1B[30m",
|
|
709
689
|
RED: "\x1B[31m",
|
|
710
690
|
GREEN: "\x1B[32m",
|
|
@@ -721,7 +701,7 @@ const R = {
|
|
|
721
701
|
LIGHT_MAGENTA: "\x1B[95m",
|
|
722
702
|
LIGHT_CYAN: "\x1B[96m",
|
|
723
703
|
WHITE: "\x1B[97m"
|
|
724
|
-
},
|
|
704
|
+
}, _t = {
|
|
725
705
|
BLACK: "\x1B[40m",
|
|
726
706
|
RED: "\x1B[41m",
|
|
727
707
|
GREEN: "\x1B[42m",
|
|
@@ -732,421 +712,397 @@ const R = {
|
|
|
732
712
|
WHITE: "\x1B[47m",
|
|
733
713
|
GREY: "\x1B[100m"
|
|
734
714
|
};
|
|
735
|
-
var
|
|
736
|
-
const
|
|
715
|
+
var yt = /* @__PURE__ */ ((r) => (r[r.ERROR = 0] = "ERROR", r[r.WARN = 1] = "WARN", r[r.INFO = 2] = "INFO", r[r.LOG = 3] = "LOG", r[r.DEBUG = 4] = "DEBUG", r))(yt || {});
|
|
716
|
+
const g = class g extends _ {
|
|
737
717
|
constructor(t) {
|
|
738
718
|
super(), this.namespace = t;
|
|
739
719
|
}
|
|
740
|
-
pad(t, e,
|
|
741
|
-
const
|
|
742
|
-
if (
|
|
743
|
-
const a = Array(~~(
|
|
744
|
-
return s ?
|
|
720
|
+
pad(t, e, n, s = !1) {
|
|
721
|
+
const o = t.toString(), i = e - o.length;
|
|
722
|
+
if (i <= 0) return o;
|
|
723
|
+
const a = Array(~~(i / n.length)).fill(n).join("");
|
|
724
|
+
return s ? o + a : a + o;
|
|
745
725
|
}
|
|
746
726
|
format(...t) {
|
|
747
727
|
const e = /* @__PURE__ */ new Date();
|
|
748
|
-
return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.
|
|
728
|
+
return `${`${e.getFullYear()}-${e.getMonth() + 1}-${e.getDate()} ${this.pad(e.getHours().toString(), 2, "0")}:${this.pad(e.getMinutes().toString(), 2, "0")}:${this.pad(e.getSeconds().toString(), 2, "0")}.${this.pad(e.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${t.join(" ")}`;
|
|
749
729
|
}
|
|
750
730
|
debug(...t) {
|
|
751
|
-
if (
|
|
731
|
+
if (g.LOG_LEVEL < 4) return;
|
|
752
732
|
const e = this.format(...t);
|
|
753
|
-
|
|
733
|
+
g.emit(4, e), console.debug(j.LIGHT_GREY + e + x.CLEAR);
|
|
754
734
|
}
|
|
755
735
|
log(...t) {
|
|
756
|
-
if (
|
|
736
|
+
if (g.LOG_LEVEL < 3) return;
|
|
757
737
|
const e = this.format(...t);
|
|
758
|
-
|
|
738
|
+
g.emit(3, e), console.log(x.CLEAR + e);
|
|
759
739
|
}
|
|
760
740
|
info(...t) {
|
|
761
|
-
if (
|
|
741
|
+
if (g.LOG_LEVEL < 2) return;
|
|
762
742
|
const e = this.format(...t);
|
|
763
|
-
|
|
743
|
+
g.emit(2, e), console.info(j.BLUE + e + x.CLEAR);
|
|
764
744
|
}
|
|
765
745
|
warn(...t) {
|
|
766
|
-
if (
|
|
746
|
+
if (g.LOG_LEVEL < 1) return;
|
|
767
747
|
const e = this.format(...t);
|
|
768
|
-
|
|
748
|
+
g.emit(1, e), console.warn(j.YELLOW + e + x.CLEAR);
|
|
769
749
|
}
|
|
770
750
|
error(...t) {
|
|
771
|
-
if (
|
|
751
|
+
if (g.LOG_LEVEL < 0) return;
|
|
772
752
|
const e = this.format(...t);
|
|
773
|
-
|
|
753
|
+
g.emit(0, e), console.error(j.RED + e + x.CLEAR);
|
|
774
754
|
}
|
|
775
755
|
};
|
|
776
|
-
c(
|
|
777
|
-
let Y =
|
|
778
|
-
function
|
|
779
|
-
const t = (a, u) => u < 1e-7 ? a : t(u, ~~(a % u)), e =
|
|
780
|
-
let
|
|
781
|
-
const
|
|
782
|
-
s = ~~(s /
|
|
783
|
-
const
|
|
784
|
-
return s -=
|
|
785
|
-
}
|
|
786
|
-
function
|
|
787
|
-
let t =
|
|
756
|
+
c(g, "LOG_LEVEL", 4);
|
|
757
|
+
let Y = g;
|
|
758
|
+
function Wt(r) {
|
|
759
|
+
const t = (a, u) => u < 1e-7 ? a : t(u, ~~(a % u)), e = r.toString().length - 2;
|
|
760
|
+
let n = Math.pow(10, e), s = r * n;
|
|
761
|
+
const o = t(s, n);
|
|
762
|
+
s = ~~(s / o), n = ~~(n / o);
|
|
763
|
+
const i = ~~(s / n);
|
|
764
|
+
return s -= i * n, `${i ? i + " " : ""}${~~s}/${~~n}`;
|
|
765
|
+
}
|
|
766
|
+
function Jt(r) {
|
|
767
|
+
let t = r.split(" ");
|
|
788
768
|
const e = t.length == 2 ? Number(t[0]) : 0;
|
|
789
769
|
return t = t.pop().split("/"), e + Number(t[0]) / Number(t[1]);
|
|
790
770
|
}
|
|
791
|
-
const
|
|
792
|
-
function
|
|
793
|
-
if (
|
|
794
|
-
const e = 1024,
|
|
795
|
-
return parseFloat((
|
|
771
|
+
const T = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", k = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", pt = T + k + D;
|
|
772
|
+
function zt(r, t = 2) {
|
|
773
|
+
if (r === 0) return "0 Bytes";
|
|
774
|
+
const e = 1024, n = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], s = Math.floor(Math.log(r) / Math.log(e));
|
|
775
|
+
return parseFloat((r / Math.pow(e, s)).toFixed(t)) + " " + n[s];
|
|
796
776
|
}
|
|
797
|
-
function
|
|
798
|
-
const t = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(
|
|
799
|
-
if (!t) throw new Error(`Number cannot be parsed: ${
|
|
777
|
+
function Kt(r) {
|
|
778
|
+
const t = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(r);
|
|
779
|
+
if (!t) throw new Error(`Number cannot be parsed: ${r}`);
|
|
800
780
|
return `${t[1] ?? ""} (${t[2]}) ${t[3]}-${t[4]}`.trim();
|
|
801
781
|
}
|
|
802
|
-
function
|
|
803
|
-
return `${
|
|
782
|
+
function Zt(r, t, e) {
|
|
783
|
+
return `${r.slice(0, e)}${t}${r.slice(e + 1)}`;
|
|
804
784
|
}
|
|
805
|
-
function
|
|
806
|
-
return
|
|
785
|
+
function Vt(r, t, e = " ", n = !0) {
|
|
786
|
+
return n ? r.toString().padStart(t, e) : r.toString().padEnd(t, e);
|
|
807
787
|
}
|
|
808
|
-
function
|
|
809
|
-
return Array(
|
|
788
|
+
function Xt(r) {
|
|
789
|
+
return Array(r).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
|
|
810
790
|
}
|
|
811
|
-
function
|
|
812
|
-
return Array(
|
|
791
|
+
function Qt(r, t = pt) {
|
|
792
|
+
return Array(r).fill(null).map(() => {
|
|
813
793
|
const e = ~~(Math.random() * t.length);
|
|
814
794
|
return t[e];
|
|
815
795
|
}).join("");
|
|
816
796
|
}
|
|
817
|
-
function
|
|
818
|
-
if (!t && !e && !
|
|
819
|
-
return Array(
|
|
797
|
+
function te(r, t = !1, e = !1, n = !1) {
|
|
798
|
+
if (!t && !e && !n) throw new Error("Must enable at least one: letters, numbers, symbols");
|
|
799
|
+
return Array(r).fill(null).map(() => {
|
|
820
800
|
let s;
|
|
821
801
|
do {
|
|
822
|
-
const
|
|
823
|
-
t &&
|
|
802
|
+
const o = ~~(Math.random() * 3);
|
|
803
|
+
t && o == 0 ? s = T[~~(Math.random() * T.length)] : e && o == 1 ? s = k[~~(Math.random() * k.length)] : n && o == 2 && (s = D[~~(Math.random() * D.length)]);
|
|
824
804
|
} while (!s);
|
|
825
805
|
return s;
|
|
826
806
|
}).join("");
|
|
827
807
|
}
|
|
828
|
-
function
|
|
808
|
+
function ee(r, t) {
|
|
829
809
|
if (typeof t == "string" && (t = new RegExp(t, "g")), !t.global)
|
|
830
810
|
throw new TypeError("Regular expression must be global.");
|
|
831
|
-
let e = [],
|
|
832
|
-
for (; (
|
|
833
|
-
e.push(
|
|
811
|
+
let e = [], n;
|
|
812
|
+
for (; (n = t.exec(r)) !== null; )
|
|
813
|
+
e.push(n);
|
|
834
814
|
return e;
|
|
835
815
|
}
|
|
836
|
-
function
|
|
816
|
+
function re(r) {
|
|
837
817
|
const t = new RegExp(
|
|
838
818
|
"(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
|
|
839
819
|
"gm"
|
|
840
|
-
).exec(
|
|
841
|
-
if (e.port != null && (e.port = Number(e.port)),
|
|
842
|
-
const s = e.query.split("&"),
|
|
843
|
-
s.forEach((
|
|
844
|
-
const [a, u] =
|
|
845
|
-
|
|
846
|
-
}), e.query =
|
|
820
|
+
).exec(r), e = (t == null ? void 0 : t.groups) ?? {}, n = e.domain.split(".");
|
|
821
|
+
if (e.port != null && (e.port = Number(e.port)), n.length > 2 && (e.domain = n.splice(-2, 2).join("."), e.subdomain = n.join(".")), e.query) {
|
|
822
|
+
const s = e.query.split("&"), o = {};
|
|
823
|
+
s.forEach((i) => {
|
|
824
|
+
const [a, u] = i.split("=");
|
|
825
|
+
o[a] = u;
|
|
826
|
+
}), e.query = o;
|
|
847
827
|
}
|
|
848
828
|
return e;
|
|
849
829
|
}
|
|
850
|
-
function
|
|
851
|
-
var t =
|
|
830
|
+
function gt(r) {
|
|
831
|
+
var t = wt(Et(bt(mt(r), 8 * r.length)));
|
|
852
832
|
return t.toLowerCase();
|
|
853
833
|
}
|
|
854
|
-
function
|
|
855
|
-
for (var t, e = "0123456789ABCDEF",
|
|
856
|
-
return
|
|
834
|
+
function wt(r) {
|
|
835
|
+
for (var t, e = "0123456789ABCDEF", n = "", s = 0; s < r.length; s++) t = r.charCodeAt(s), n += e.charAt(t >>> 4 & 15) + e.charAt(15 & t);
|
|
836
|
+
return n;
|
|
857
837
|
}
|
|
858
|
-
function
|
|
859
|
-
for (var t = Array(
|
|
860
|
-
for (e = 0; e < 8 *
|
|
838
|
+
function mt(r) {
|
|
839
|
+
for (var t = Array(r.length >> 2), e = 0; e < t.length; e++) t[e] = 0;
|
|
840
|
+
for (e = 0; e < 8 * r.length; e += 8) t[e >> 5] |= (255 & r.charCodeAt(e / 8)) << e % 32;
|
|
861
841
|
return t;
|
|
862
842
|
}
|
|
863
|
-
function Et(
|
|
864
|
-
for (var t = "", e = 0; e < 32 *
|
|
843
|
+
function Et(r) {
|
|
844
|
+
for (var t = "", e = 0; e < 32 * r.length; e += 8) t += String.fromCharCode(r[e >> 5] >>> e % 32 & 255);
|
|
865
845
|
return t;
|
|
866
846
|
}
|
|
867
|
-
function
|
|
868
|
-
|
|
869
|
-
for (var e = 1732584193,
|
|
870
|
-
var a = e, u =
|
|
871
|
-
|
|
847
|
+
function bt(r, t) {
|
|
848
|
+
r[t >> 5] |= 128 << t % 32, r[14 + (t + 64 >>> 9 << 4)] = t;
|
|
849
|
+
for (var e = 1732584193, n = -271733879, s = -1732584194, o = 271733878, i = 0; i < r.length; i += 16) {
|
|
850
|
+
var a = e, u = n, v = s, N = o;
|
|
851
|
+
n = y(n = y(n = y(n = y(n = d(n = d(n = d(n = d(n = f(n = f(n = f(n = f(n = h(n = h(n = h(n = h(n, s = h(s, o = h(o, e = h(e, n, s, o, r[i + 0], 7, -680876936), n, s, r[i + 1], 12, -389564586), e, n, r[i + 2], 17, 606105819), o, e, r[i + 3], 22, -1044525330), s = h(s, o = h(o, e = h(e, n, s, o, r[i + 4], 7, -176418897), n, s, r[i + 5], 12, 1200080426), e, n, r[i + 6], 17, -1473231341), o, e, r[i + 7], 22, -45705983), s = h(s, o = h(o, e = h(e, n, s, o, r[i + 8], 7, 1770035416), n, s, r[i + 9], 12, -1958414417), e, n, r[i + 10], 17, -42063), o, e, r[i + 11], 22, -1990404162), s = h(s, o = h(o, e = h(e, n, s, o, r[i + 12], 7, 1804603682), n, s, r[i + 13], 12, -40341101), e, n, r[i + 14], 17, -1502002290), o, e, r[i + 15], 22, 1236535329), s = f(s, o = f(o, e = f(e, n, s, o, r[i + 1], 5, -165796510), n, s, r[i + 6], 9, -1069501632), e, n, r[i + 11], 14, 643717713), o, e, r[i + 0], 20, -373897302), s = f(s, o = f(o, e = f(e, n, s, o, r[i + 5], 5, -701558691), n, s, r[i + 10], 9, 38016083), e, n, r[i + 15], 14, -660478335), o, e, r[i + 4], 20, -405537848), s = f(s, o = f(o, e = f(e, n, s, o, r[i + 9], 5, 568446438), n, s, r[i + 14], 9, -1019803690), e, n, r[i + 3], 14, -187363961), o, e, r[i + 8], 20, 1163531501), s = f(s, o = f(o, e = f(e, n, s, o, r[i + 13], 5, -1444681467), n, s, r[i + 2], 9, -51403784), e, n, r[i + 7], 14, 1735328473), o, e, r[i + 12], 20, -1926607734), s = d(s, o = d(o, e = d(e, n, s, o, r[i + 5], 4, -378558), n, s, r[i + 8], 11, -2022574463), e, n, r[i + 11], 16, 1839030562), o, e, r[i + 14], 23, -35309556), s = d(s, o = d(o, e = d(e, n, s, o, r[i + 1], 4, -1530992060), n, s, r[i + 4], 11, 1272893353), e, n, r[i + 7], 16, -155497632), o, e, r[i + 10], 23, -1094730640), s = d(s, o = d(o, e = d(e, n, s, o, r[i + 13], 4, 681279174), n, s, r[i + 0], 11, -358537222), e, n, r[i + 3], 16, -722521979), o, e, r[i + 6], 23, 76029189), s = d(s, o = d(o, e = d(e, n, s, o, r[i + 9], 4, -640364487), n, s, r[i + 12], 11, -421815835), e, n, r[i + 15], 16, 530742520), o, e, r[i + 2], 23, -995338651), s = y(s, o = y(o, e = y(e, n, s, o, r[i + 0], 6, -198630844), n, s, r[i + 7], 10, 1126891415), e, n, r[i + 14], 15, -1416354905), o, e, r[i + 5], 21, -57434055), s = y(s, o = y(o, e = y(e, n, s, o, r[i + 12], 6, 1700485571), n, s, r[i + 3], 10, -1894986606), e, n, r[i + 10], 15, -1051523), o, e, r[i + 1], 21, -2054922799), s = y(s, o = y(o, e = y(e, n, s, o, r[i + 8], 6, 1873313359), n, s, r[i + 15], 10, -30611744), e, n, r[i + 6], 15, -1560198380), o, e, r[i + 13], 21, 1309151649), s = y(s, o = y(o, e = y(e, n, s, o, r[i + 4], 6, -145523070), n, s, r[i + 11], 10, -1120210379), e, n, r[i + 2], 15, 718787259), o, e, r[i + 9], 21, -343485551), e = m(e, a), n = m(n, u), s = m(s, v), o = m(o, N);
|
|
872
852
|
}
|
|
873
|
-
return Array(e,
|
|
853
|
+
return Array(e, n, s, o);
|
|
874
854
|
}
|
|
875
|
-
function
|
|
876
|
-
return
|
|
855
|
+
function C(r, t, e, n, s, o) {
|
|
856
|
+
return m(St(m(m(t, r), m(n, o)), s), e);
|
|
877
857
|
}
|
|
878
|
-
function
|
|
879
|
-
return
|
|
858
|
+
function h(r, t, e, n, s, o, i) {
|
|
859
|
+
return C(t & e | ~t & n, r, t, s, o, i);
|
|
880
860
|
}
|
|
881
|
-
function
|
|
882
|
-
return
|
|
861
|
+
function f(r, t, e, n, s, o, i) {
|
|
862
|
+
return C(t & n | e & ~n, r, t, s, o, i);
|
|
883
863
|
}
|
|
884
|
-
function d(
|
|
885
|
-
return
|
|
864
|
+
function d(r, t, e, n, s, o, i) {
|
|
865
|
+
return C(t ^ e ^ n, r, t, s, o, i);
|
|
886
866
|
}
|
|
887
|
-
function
|
|
888
|
-
return
|
|
867
|
+
function y(r, t, e, n, s, o, i) {
|
|
868
|
+
return C(e ^ (t | ~n), r, t, s, o, i);
|
|
889
869
|
}
|
|
890
|
-
function
|
|
891
|
-
var e = (65535 &
|
|
892
|
-
return (
|
|
870
|
+
function m(r, t) {
|
|
871
|
+
var e = (65535 & r) + (65535 & t);
|
|
872
|
+
return (r >> 16) + (t >> 16) + (e >> 16) << 16 | 65535 & e;
|
|
893
873
|
}
|
|
894
|
-
function St(
|
|
895
|
-
return
|
|
874
|
+
function St(r, t) {
|
|
875
|
+
return r << t | r >>> 32 - t;
|
|
896
876
|
}
|
|
897
|
-
function
|
|
898
|
-
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(
|
|
877
|
+
function ne(r) {
|
|
878
|
+
return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(r);
|
|
899
879
|
}
|
|
900
|
-
function
|
|
901
|
-
return
|
|
880
|
+
function se(r, t = "mp") {
|
|
881
|
+
return r ? `https://www.gravatar.com/avatar/${gt(r)}?d=${t}` : "";
|
|
902
882
|
}
|
|
903
|
-
function
|
|
904
|
-
|
|
883
|
+
function oe(r) {
|
|
884
|
+
(typeof r == "number" || typeof r == "string") && (r = new Date(r));
|
|
885
|
+
let t = r.getHours(), e = "AM";
|
|
886
|
+
return t >= 12 ? (t > 12 && (t -= 12), e = "PM") : t == 0 && (t = 12), `${r.getFullYear()}-${(r.getMonth() + 1).toString().padStart(2, "0")}-${r.getDate().toString().padStart(2, "0")}, ${t}:${r.getMinutes().toString().padStart(2, "0")} ${e}`;
|
|
905
887
|
}
|
|
906
|
-
function
|
|
907
|
-
|
|
908
|
-
for (let r = 0; r < n.length || r < t.length; r++)
|
|
909
|
-
n[r] && e.push(n[r]), t[r] && e.push(t[r]);
|
|
910
|
-
return new y(e.join(""));
|
|
888
|
+
function Ot(r) {
|
|
889
|
+
return new Promise((t) => setTimeout(t, r));
|
|
911
890
|
}
|
|
912
|
-
function
|
|
913
|
-
|
|
914
|
-
for (let i = 0; i < n.length || i < t.length; i++)
|
|
915
|
-
n[i] && e.push(n[i]), t[i] && e.push(t[i]);
|
|
916
|
-
const [r, s] = e.join("").split(":");
|
|
917
|
-
return y.toString(r, s == null ? void 0 : s.split(""));
|
|
891
|
+
async function ie(r, t = 100) {
|
|
892
|
+
for (; await r(); ) await Ot(t);
|
|
918
893
|
}
|
|
919
|
-
|
|
894
|
+
function ce(r) {
|
|
895
|
+
return (r instanceof Date ? r.getTime() : r) - (/* @__PURE__ */ new Date()).getTime();
|
|
920
896
|
}
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
c(this, "path");
|
|
929
|
-
/** Last sagment of path */
|
|
930
|
-
c(this, "name");
|
|
931
|
-
/** List of methods */
|
|
932
|
-
c(this, "methods");
|
|
933
|
-
/** All/Wildcard specified */
|
|
934
|
-
c(this, "all");
|
|
935
|
-
/** None specified */
|
|
936
|
-
c(this, "none");
|
|
937
|
-
/** Create method specified */
|
|
938
|
-
c(this, "create");
|
|
939
|
-
/** Read method specified */
|
|
940
|
-
c(this, "read");
|
|
941
|
-
/** Update method specified */
|
|
942
|
-
c(this, "update");
|
|
943
|
-
/** Delete method specified */
|
|
944
|
-
c(this, "delete");
|
|
945
|
-
var o;
|
|
946
|
-
if (typeof t == "object") return Object.assign(this, t);
|
|
947
|
-
let [e, r, s] = t.split(":");
|
|
948
|
-
s || (s = r || "*"), (e == "*" || !e && s == "*") && (e = "", s = "*");
|
|
949
|
-
let i = e.split("/").filter((a) => !!a);
|
|
950
|
-
this.module = ((o = i.splice(0, 1)[0]) == null ? void 0 : o.toLowerCase()) || "", this.fullPath = e, this.path = i.join("/"), this.name = i.pop() || "", this.methods = s.split(""), this.all = s == null ? void 0 : s.includes("*"), this.none = s == null ? void 0 : s.includes("n"), this.create = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("c"))), this.read = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("r"))), this.update = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("u"))), this.delete = !(s != null && s.includes("n")) && ((s == null ? void 0 : s.includes("*")) || (s == null ? void 0 : s.includes("w")) || (s == null ? void 0 : s.includes("d")));
|
|
951
|
-
}
|
|
952
|
-
/**
|
|
953
|
-
* Combine multiple events into one parsed object. Longest path takes precedent, but all subsequent methods are
|
|
954
|
-
* combined until a "none" is reached
|
|
955
|
-
*
|
|
956
|
-
* @param {string | PathEvent} paths Events as strings or pre-parsed
|
|
957
|
-
* @return {PathEvent} Final combined permission
|
|
958
|
-
*/
|
|
959
|
-
static combine(t) {
|
|
960
|
-
let e = !1;
|
|
961
|
-
const r = t.map((s) => new y(s)).toSorted((s, i) => {
|
|
962
|
-
const o = s.fullPath.length, a = i.fullPath.length;
|
|
963
|
-
return o < a ? 1 : o > a ? -1 : 0;
|
|
964
|
-
}).reduce((s, i) => (i.none && (e = !0), s ? (e || (i.all && (s.all = !0), (i.all || i.create) && (s.create = !0), (i.all || i.read) && (s.read = !0), (i.all || i.update) && (s.update = !0), (i.all || i.delete) && (s.delete = !0), s.methods = [...s.methods, ...i.methods]), s) : i), null);
|
|
965
|
-
return r.all && (r.methods = ["*"]), r.none && (r.methods = ["n"]), r.methods = new S(r.methods), r.raw = xt`${r.fullPath}:${r.methods}`, r;
|
|
966
|
-
}
|
|
897
|
+
function ue() {
|
|
898
|
+
return Object.keys({});
|
|
899
|
+
}
|
|
900
|
+
var $ = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, xt = {}, S = {};
|
|
901
|
+
Object.defineProperty(S, "__esModule", { value: !0 });
|
|
902
|
+
S.persist = S.Persist = void 0;
|
|
903
|
+
class st {
|
|
967
904
|
/**
|
|
968
|
-
*
|
|
969
|
-
*
|
|
970
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
971
|
-
* @param has Target must have at least one of these path
|
|
972
|
-
* @return {boolean} Whether there is any overlap
|
|
905
|
+
* @param {string} key Primary key value will be stored under
|
|
906
|
+
* @param {PersistOptions<T>} options Configure using {@link PersistOptions}
|
|
973
907
|
*/
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
908
|
+
constructor(t, e = {}) {
|
|
909
|
+
c(this, "key");
|
|
910
|
+
c(this, "options");
|
|
911
|
+
/** Backend service to store data, must implement `Storage` interface */
|
|
912
|
+
c(this, "storage");
|
|
913
|
+
/** Listeners which should be notified on changes */
|
|
914
|
+
c(this, "watches", {});
|
|
915
|
+
/** Private value field */
|
|
916
|
+
c(this, "_value");
|
|
917
|
+
this.key = t, this.options = e, this.storage = e.storage || localStorage, this.load();
|
|
918
|
+
}
|
|
919
|
+
/** Current value or default if undefined */
|
|
920
|
+
get value() {
|
|
921
|
+
var t;
|
|
922
|
+
return this._value !== void 0 ? this._value : (t = this.options) == null ? void 0 : t.default;
|
|
923
|
+
}
|
|
924
|
+
/** Set value with proxy object wrapper to sync future changes */
|
|
925
|
+
set value(t) {
|
|
926
|
+
t == null || typeof t != "object" ? this._value = t : this._value = new Proxy(t, {
|
|
927
|
+
get: (e, n) => typeof e[n] == "function" ? (...o) => {
|
|
928
|
+
const i = e[n](...o);
|
|
929
|
+
return this.save(), i;
|
|
930
|
+
} : e[n],
|
|
931
|
+
set: (e, n, s) => (e[n] = s, this.save(), !0)
|
|
932
|
+
}), this.save();
|
|
933
|
+
}
|
|
934
|
+
/** Notify listeners of change */
|
|
935
|
+
notify(t) {
|
|
936
|
+
Object.values(this.watches).forEach((e) => e(t));
|
|
937
|
+
}
|
|
938
|
+
/** Delete value from storage */
|
|
939
|
+
clear() {
|
|
940
|
+
this.storage.removeItem(this.key);
|
|
983
941
|
}
|
|
984
|
-
/**
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
* @param {string | PathEvent | (string | PathEvent)[]} target Array of Events as strings or pre-parsed
|
|
988
|
-
* @param has Target must have all these paths
|
|
989
|
-
* @return {boolean} Whether there is any overlap
|
|
990
|
-
*/
|
|
991
|
-
static hasAll(t, ...e) {
|
|
992
|
-
return e.filter((r) => y.has(t, r)).length == e.length;
|
|
942
|
+
/** Save current value to storage */
|
|
943
|
+
save() {
|
|
944
|
+
this._value === void 0 ? this.clear() : this.storage.setItem(this.key, JSON.stringify(this._value)), this.notify(this.value);
|
|
993
945
|
}
|
|
994
|
-
/**
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
if (!y.has(t, ...e)) throw new H(`Requires one of: ${m(e).join(", ")}`);
|
|
946
|
+
/** Load value from storage */
|
|
947
|
+
load() {
|
|
948
|
+
if (this.storage[this.key] != null) {
|
|
949
|
+
let t = JSON.parse(this.storage.getItem(this.key));
|
|
950
|
+
t != null && typeof t == "object" && this.options.type && (t.__proto__ = this.options.type.prototype), this.value = t;
|
|
951
|
+
} else
|
|
952
|
+
this.value = this.options.default || void 0;
|
|
1002
953
|
}
|
|
1003
954
|
/**
|
|
1004
|
-
*
|
|
955
|
+
* Callback function which is run when there are changes
|
|
1005
956
|
*
|
|
1006
|
-
* @param {
|
|
1007
|
-
* @
|
|
957
|
+
* @param {(value: T) => any} fn Callback will run on each change; it's passed the next value & it's return is ignored
|
|
958
|
+
* @returns {() => void} Function which will unsubscribe the watch/callback when called
|
|
1008
959
|
*/
|
|
1009
|
-
|
|
1010
|
-
|
|
960
|
+
watch(t) {
|
|
961
|
+
const e = Object.keys(this.watches).length;
|
|
962
|
+
return this.watches[e] = t, () => {
|
|
963
|
+
delete this.watches[e];
|
|
964
|
+
};
|
|
1011
965
|
}
|
|
1012
966
|
/**
|
|
1013
|
-
*
|
|
967
|
+
* Return value as JSON string
|
|
1014
968
|
*
|
|
1015
|
-
* @
|
|
1016
|
-
* @param {Method} methods Event method
|
|
1017
|
-
* @return {string} String representation of Event
|
|
969
|
+
* @returns {string} Stringified object as JSON
|
|
1018
970
|
*/
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
return e != null && e.length && (r += `:${m(e).map((s) => s.toLowerCase()).join("")}`), r == null ? void 0 : r.trim().replaceAll(/\/{2,}/g, "/").replaceAll(/(^\/|\/$)/g, "");
|
|
971
|
+
toString() {
|
|
972
|
+
return JSON.stringify(this.value);
|
|
1022
973
|
}
|
|
1023
974
|
/**
|
|
1024
|
-
*
|
|
975
|
+
* Return current value
|
|
1025
976
|
*
|
|
1026
|
-
* @
|
|
977
|
+
* @returns {T} Current value
|
|
1027
978
|
*/
|
|
1028
|
-
|
|
1029
|
-
return
|
|
1030
|
-
}
|
|
979
|
+
valueOf() {
|
|
980
|
+
return this.value;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
S.Persist = st;
|
|
984
|
+
function Bt(r) {
|
|
985
|
+
return (t, e) => {
|
|
986
|
+
const n = (r == null ? void 0 : r.key) || `${t.constructor.name}.${e.toString()}`, s = new st(n, r);
|
|
987
|
+
Object.defineProperty(t, e, {
|
|
988
|
+
get: function() {
|
|
989
|
+
return s.value;
|
|
990
|
+
},
|
|
991
|
+
set: function(o) {
|
|
992
|
+
s.value = o;
|
|
993
|
+
}
|
|
994
|
+
});
|
|
995
|
+
};
|
|
1031
996
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
997
|
+
S.persist = Bt;
|
|
998
|
+
var L = {};
|
|
999
|
+
Object.defineProperty(L, "__esModule", { value: !0 });
|
|
1000
|
+
L.MemoryStorage = void 0;
|
|
1001
|
+
class At {
|
|
1002
|
+
get length() {
|
|
1003
|
+
return Object.keys(this).length;
|
|
1035
1004
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
this.listeners.filter((s) => y.has(s[0], t)).forEach(async (s) => s[1](r, ...e));
|
|
1005
|
+
clear() {
|
|
1006
|
+
Object.keys(this).forEach((t) => this.removeItem(t));
|
|
1039
1007
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1008
|
+
getItem(t) {
|
|
1009
|
+
return this[t];
|
|
1042
1010
|
}
|
|
1043
|
-
|
|
1044
|
-
return
|
|
1011
|
+
key(t) {
|
|
1012
|
+
return Object.keys(this)[t];
|
|
1045
1013
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
const s = this.on(t, (i, ...o) => {
|
|
1049
|
-
r(o.length < 2 ? o[0] : o), e && e(i, ...o), s();
|
|
1050
|
-
});
|
|
1051
|
-
});
|
|
1014
|
+
removeItem(t) {
|
|
1015
|
+
delete this[t];
|
|
1052
1016
|
}
|
|
1053
|
-
|
|
1054
|
-
t
|
|
1017
|
+
setItem(t, e) {
|
|
1018
|
+
this[t] = e;
|
|
1055
1019
|
}
|
|
1056
1020
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
return Object.keys({});
|
|
1073
|
-
}
|
|
1021
|
+
L.MemoryStorage = At;
|
|
1022
|
+
(function(r) {
|
|
1023
|
+
var t = $ && $.__createBinding || (Object.create ? function(n, s, o, i) {
|
|
1024
|
+
i === void 0 && (i = o);
|
|
1025
|
+
var a = Object.getOwnPropertyDescriptor(s, o);
|
|
1026
|
+
(!a || ("get" in a ? !s.__esModule : a.writable || a.configurable)) && (a = { enumerable: !0, get: function() {
|
|
1027
|
+
return s[o];
|
|
1028
|
+
} }), Object.defineProperty(n, i, a);
|
|
1029
|
+
} : function(n, s, o, i) {
|
|
1030
|
+
i === void 0 && (i = o), n[i] = s[o];
|
|
1031
|
+
}), e = $ && $.__exportStar || function(n, s) {
|
|
1032
|
+
for (var o in n) o !== "default" && !Object.prototype.hasOwnProperty.call(s, o) && t(s, n, o);
|
|
1033
|
+
};
|
|
1034
|
+
Object.defineProperty(r, "__esModule", { value: !0 }), e(S, r), e(L, r);
|
|
1035
|
+
})(xt);
|
|
1074
1036
|
export {
|
|
1075
|
-
|
|
1037
|
+
B as ASet,
|
|
1076
1038
|
et as BadGatewayError,
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1039
|
+
W as BadRequestError,
|
|
1040
|
+
Dt as Cache,
|
|
1041
|
+
_t as CliBackground,
|
|
1042
|
+
x as CliEffects,
|
|
1043
|
+
j as CliForeground,
|
|
1044
|
+
p as CustomError,
|
|
1045
|
+
K as ForbiddenError,
|
|
1046
|
+
nt as GatewayTimeoutError,
|
|
1085
1047
|
F as Http,
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1048
|
+
Q as InternalServerError,
|
|
1049
|
+
M as JSONAttemptParse,
|
|
1050
|
+
Lt as JSONSanitize,
|
|
1051
|
+
yt as LOG_LEVEL,
|
|
1090
1052
|
Y as Logger,
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1053
|
+
V as MethodNotAllowedError,
|
|
1054
|
+
X as NotAcceptableError,
|
|
1055
|
+
Z as NotFoundError,
|
|
1094
1056
|
tt as NotImplementedError,
|
|
1095
|
-
ne as PE,
|
|
1096
|
-
xt as PES,
|
|
1097
|
-
H as PathError,
|
|
1098
|
-
y as PathEvent,
|
|
1099
|
-
re as PathEventEmitter,
|
|
1100
1057
|
z as PaymentRequiredError,
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1058
|
+
E as PromiseProgress,
|
|
1059
|
+
rt as ServiceUnavailableError,
|
|
1060
|
+
_ as TypedEmitter,
|
|
1104
1061
|
J as UnauthorizedError,
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
jt as findByProp,
|
|
1062
|
+
Nt as addUnique,
|
|
1063
|
+
It as arrayDiff,
|
|
1064
|
+
Mt as caseInsensitiveSort,
|
|
1065
|
+
ut as clean,
|
|
1066
|
+
Pt as csv,
|
|
1067
|
+
Wt as dec2Frac,
|
|
1068
|
+
Rt as deepCopy,
|
|
1069
|
+
at as deepMerge,
|
|
1070
|
+
b as dotNotation,
|
|
1071
|
+
Gt as downloadFile,
|
|
1072
|
+
dt as downloadUrl,
|
|
1073
|
+
jt as encodeQuery,
|
|
1074
|
+
Yt as errorFromCode,
|
|
1075
|
+
Ut as fileBrowser,
|
|
1076
|
+
Tt as findByProp,
|
|
1121
1077
|
lt as flattenArr,
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1078
|
+
H as flattenObj,
|
|
1079
|
+
$t as formData,
|
|
1080
|
+
zt as formatBytes,
|
|
1081
|
+
oe as formatDate,
|
|
1082
|
+
Kt as formatPhoneNumber,
|
|
1083
|
+
Jt as fracToDec,
|
|
1084
|
+
se as gravatar,
|
|
1129
1085
|
q as includes,
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
ie as
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1086
|
+
Zt as insertAt,
|
|
1087
|
+
A as isEqual,
|
|
1088
|
+
Ht as jwtDecode,
|
|
1089
|
+
ft as makeArray,
|
|
1090
|
+
ht as makeUnique,
|
|
1091
|
+
ee as matchAll,
|
|
1092
|
+
gt as md5,
|
|
1093
|
+
Ct as mixin,
|
|
1094
|
+
Vt as pad,
|
|
1095
|
+
re as parseUrl,
|
|
1096
|
+
Xt as randomHex,
|
|
1097
|
+
Qt as randomString,
|
|
1098
|
+
te as randomStringBuilder,
|
|
1099
|
+
Ot as sleep,
|
|
1100
|
+
ie as sleepUntil,
|
|
1101
|
+
kt as sortByProp,
|
|
1102
|
+
ce as timeUntil,
|
|
1103
|
+
qt as timestampFilename,
|
|
1104
|
+
ue as tyoeKeys,
|
|
1105
|
+
Ft as uploadWithProgress,
|
|
1106
|
+
ne as validateEmail
|
|
1151
1107
|
};
|
|
1152
1108
|
//# sourceMappingURL=index.mjs.map
|