@ztimson/utils 0.9.0 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/utils.mjs DELETED
@@ -1,607 +0,0 @@
1
- var M = Object.defineProperty;
2
- var U = (n, e, t) => e in n ? M(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var c = (n, e, t) => (U(n, typeof e != "symbol" ? e + "" : e, t), t);
4
- function Y(n, e = !1) {
5
- if (n == null)
6
- throw new Error("Cannot clean a NULL value");
7
- return Array.isArray(n) ? n = n.filter((t) => t != null) : Object.entries(n).forEach(([t, r]) => {
8
- (e && r === void 0 || !e && r == null) && delete n[t];
9
- }), n;
10
- }
11
- function _(n) {
12
- return JSON.parse(JSON.stringify(n));
13
- }
14
- function A(n, e, t) {
15
- if (!(n == null || !e))
16
- return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, s, o, i) => {
17
- if ((s[0] == '"' || s[0] == "'") && (s = s.slice(1, -1)), !(r != null && r.hasOwnProperty(s))) {
18
- if (t == null)
19
- return;
20
- r[s] = {};
21
- }
22
- return t !== void 0 && o == i.length - 1 ? r[s] = t : r[s];
23
- }, n);
24
- }
25
- function H(n, e, t = {}) {
26
- if (typeof n == "object" && !Array.isArray(n)) {
27
- for (const r of Object.keys(n)) {
28
- const s = e ? e + "." + r : r;
29
- typeof n[r] == "object" ? H(n[r], s, t) : t[s] = n[r];
30
- }
31
- return t;
32
- }
33
- }
34
- function I(n, e, t = !1) {
35
- if (n == null)
36
- return t;
37
- if (Array.isArray(e))
38
- return e.findIndex((s, o) => !I(n[o], e[o], t)) == -1;
39
- const r = typeof e;
40
- return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((s) => !I(n[s], e[s], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
41
- }
42
- function m(n, e) {
43
- const t = typeof n, r = typeof e;
44
- return t != "object" || n == null || r != "object" || e == null ? t == "function" && r == "function" ? n.toString() == e.toString() : n === e : Object.keys(n).length != Object.keys(e).length ? !1 : Object.keys(n).every((o) => m(n[o], e[o]));
45
- }
46
- function tt(n, e) {
47
- e.forEach((t) => {
48
- Object.getOwnPropertyNames(t.prototype).forEach((r) => {
49
- Object.defineProperty(
50
- n.prototype,
51
- r,
52
- Object.getOwnPropertyDescriptor(t.prototype, r) || /* @__PURE__ */ Object.create(null)
53
- );
54
- });
55
- });
56
- }
57
- function et(n, e) {
58
- let t = [];
59
- return JSON.parse(JSON.stringify(n, (r, s) => {
60
- if (typeof s == "object" && s !== null) {
61
- if (t.includes(s))
62
- return;
63
- t.push(s);
64
- }
65
- return s;
66
- }, e));
67
- }
68
- function nt(n, e) {
69
- return n.indexOf(e) === -1 && n.push(e), n;
70
- }
71
- function rt(n, e) {
72
- return q([
73
- ...n.filter((t) => !e.includes((r) => m(t, r))),
74
- ...e.filter((t) => !n.includes((r) => m(t, r)))
75
- ]);
76
- }
77
- function st(n) {
78
- return function(e, t) {
79
- const r = A(e, n), s = A(t, n);
80
- return typeof r != "string" || typeof s != "string" ? 1 : r.toLowerCase().localeCompare(s.toLowerCase());
81
- };
82
- }
83
- function W(n, e = []) {
84
- return n.forEach((t) => Array.isArray(t) ? W(t, e) : e.push(t)), e;
85
- }
86
- function ot(n, e = !1) {
87
- return function(t, r) {
88
- const s = A(t, n), o = A(r, n);
89
- return typeof s == "number" && typeof o == "number" ? (e ? -1 : 1) * (s - o) : s > o ? e ? -1 : 1 : s < o ? e ? 1 : -1 : 0;
90
- };
91
- }
92
- function it(n, e) {
93
- return (t) => m(t[n], e);
94
- }
95
- function q(n) {
96
- for (let e = n.length - 1; e >= 0; e--)
97
- n.slice(0, e).find((t) => m(t, n[e])) && n.splice(e, 1);
98
- return n;
99
- }
100
- function ct(n) {
101
- return Array.isArray(n) ? n : [n];
102
- }
103
- class w extends Array {
104
- get size() {
105
- return this.length;
106
- }
107
- constructor(e = []) {
108
- super(), e != null && e.forEach && e.forEach((t) => this.add(t));
109
- }
110
- add(e) {
111
- this.has(e) || this.push(e);
112
- }
113
- delete(e) {
114
- const t = this.indexOf(e);
115
- t != -1 && this.slice(t, 1);
116
- }
117
- difference(e) {
118
- return new w(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
119
- }
120
- has(e) {
121
- return this.indexOf(e) != -1;
122
- }
123
- intersection(e) {
124
- return new w(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
125
- }
126
- isDisjointFrom(e) {
127
- return this.intersection(e).size == 0;
128
- }
129
- isSubsetOf(e) {
130
- return this.findIndex((t) => !e.has(t)) == -1;
131
- }
132
- isSuperset(e) {
133
- return e.findIndex((t) => !this.has(t)) == -1;
134
- }
135
- symmetricDifference(e) {
136
- return new w([...this.difference(e), ...e.difference(this)]);
137
- }
138
- union(e) {
139
- return new w([...this, ...e]);
140
- }
141
- }
142
- function ut(n, e) {
143
- const t = document.createElement("a");
144
- t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
145
- }
146
- class $ {
147
- constructor() {
148
- c(this, "listeners", {});
149
- }
150
- static emit(e, ...t) {
151
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
152
- }
153
- static off(e, t) {
154
- const r = e.toString();
155
- this.listeners[r] = (this.listeners[r] || []).filter((s) => s === t);
156
- }
157
- static on(e, t) {
158
- var s;
159
- const r = e.toString();
160
- return this.listeners[r] || (this.listeners[r] = []), (s = this.listeners[r]) == null || s.push(t), () => this.off(e, t);
161
- }
162
- static once(e, t) {
163
- return new Promise((r) => {
164
- const s = this.on(e, (...o) => {
165
- r(o.length == 1 ? o[0] : o), t && t(...o), s();
166
- });
167
- });
168
- }
169
- emit(e, ...t) {
170
- (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e] || []).forEach((r) => r(...t));
171
- }
172
- off(e, t) {
173
- this.listeners[e] = (this.listeners[e] || []).filter((r) => r === t);
174
- }
175
- on(e, t) {
176
- var r;
177
- return this.listeners[e] || (this.listeners[e] = []), (r = this.listeners[e]) == null || r.push(t), () => this.off(e, t);
178
- }
179
- once(e, t) {
180
- return new Promise((r) => {
181
- const s = this.on(e, (...o) => {
182
- r(o.length == 1 ? o[0] : o), t && t(...o), s();
183
- });
184
- });
185
- }
186
- }
187
- c($, "listeners", {});
188
- const d = class d {
189
- constructor(e = {}) {
190
- c(this, "interceptors", {});
191
- c(this, "headers", {});
192
- this.opts = e, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => d.addInterceptor(t));
193
- }
194
- static addInterceptor(e) {
195
- const t = Object.keys(d.interceptors).length.toString();
196
- return d.interceptors[t] = e, () => {
197
- d.interceptors[t] = null;
198
- };
199
- }
200
- addInterceptor(e) {
201
- const t = Object.keys(this.interceptors).length.toString();
202
- return this.interceptors[t] = e, () => {
203
- this.interceptors[t] = null;
204
- };
205
- }
206
- async request(e = {}) {
207
- var s, o;
208
- if (!this.opts.url && !e.url)
209
- throw new Error("URL needs to be set");
210
- const t = ((s = e.url) != null && s.startsWith("http") ? e.url : (this.opts.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1"), r = Y({
211
- "Content-Type": e.body && !(e.body instanceof FormData) ? "application/json" : void 0,
212
- ...d.headers,
213
- ...this.headers,
214
- ...e.headers
215
- });
216
- return fetch(t, {
217
- headers: r,
218
- method: e.method || (e.body ? "POST" : "GET"),
219
- body: (o = r["Content-Type"]) != null && o.startsWith("application/json") && e.body ? JSON.stringify(e.body) : e.body
220
- }).then(async (i) => {
221
- var g, E;
222
- for (let O of [...Object.values(d.interceptors), ...Object.values(this.interceptors)])
223
- await new Promise((S) => O(i, () => S()));
224
- if (!i.ok)
225
- throw new Error(i.statusText);
226
- return !e.skipConverting && ((g = i.headers.get("Content-Type")) != null && g.startsWith("application/json")) ? await i.json() : !e.skipConverting && ((E = i.headers.get("Content-Type")) != null && E.startsWith("text/plain")) ? await i.text() : i;
227
- });
228
- }
229
- };
230
- c(d, "interceptors", {}), c(d, "headers", {});
231
- let T = d;
232
- T.addInterceptor((n, e) => {
233
- if (n.status == 200)
234
- return e();
235
- throw n.status == 400 ? new D(n.statusText) : n.status == 401 ? new k(n.statusText) : n.status == 403 ? new G(n.statusText) : n.status == 404 ? new j(n.statusText) : n.status == 500 ? new P(n.statusText) : new y(n.statusText, n.status);
236
- });
237
- class y extends Error {
238
- constructor(t, r) {
239
- super(t);
240
- c(this, "_code");
241
- r != null && (this._code = r);
242
- }
243
- get code() {
244
- return this._code || this.constructor.code;
245
- }
246
- set code(t) {
247
- this._code = t;
248
- }
249
- static from(t) {
250
- const r = Number(t.statusCode) ?? Number(t.code), s = new this(t.message || t.toString());
251
- return Object.assign(s, {
252
- stack: t.stack,
253
- ...t,
254
- code: r ?? void 0
255
- });
256
- }
257
- static instanceof(t) {
258
- return t.constructor.code != null;
259
- }
260
- toString() {
261
- return this.message || super.toString();
262
- }
263
- }
264
- c(y, "code", 500);
265
- class D extends y {
266
- constructor(e = "Bad Request") {
267
- super(e);
268
- }
269
- static instanceof(e) {
270
- return e.constructor.code == this.code;
271
- }
272
- }
273
- c(D, "code", 400);
274
- class k extends y {
275
- constructor(e = "Unauthorized") {
276
- super(e);
277
- }
278
- static instanceof(e) {
279
- return e.constructor.code == this.code;
280
- }
281
- }
282
- c(k, "code", 401);
283
- class G extends y {
284
- constructor(e = "Forbidden") {
285
- super(e);
286
- }
287
- static instanceof(e) {
288
- return e.constructor.code == this.code;
289
- }
290
- }
291
- c(G, "code", 403);
292
- class j extends y {
293
- constructor(e = "Not Found") {
294
- super(e);
295
- }
296
- static instanceof(e) {
297
- return e.constructor.code == this.code;
298
- }
299
- }
300
- c(j, "code", 404);
301
- class P extends y {
302
- constructor(e = "Internal Server Error") {
303
- super(e);
304
- }
305
- static instanceof(e) {
306
- return e.constructor.code == this.code;
307
- }
308
- }
309
- c(P, "code", 500);
310
- const x = {
311
- CLEAR: "\x1B[0m",
312
- BRIGHT: "\x1B[1m",
313
- DIM: "\x1B[2m",
314
- UNDERSCORE: "\x1B[4m",
315
- BLINK: "\x1B[5m",
316
- REVERSE: "\x1B[7m",
317
- HIDDEN: "\x1B[8m"
318
- }, B = {
319
- BLACK: "\x1B[30m",
320
- RED: "\x1B[31m",
321
- GREEN: "\x1B[32m",
322
- YELLOW: "\x1B[33m",
323
- BLUE: "\x1B[34m",
324
- MAGENTA: "\x1B[35m",
325
- CYAN: "\x1B[36m",
326
- LIGHT_GREY: "\x1B[37m",
327
- GREY: "\x1B[90m",
328
- LIGHT_RED: "\x1B[91m",
329
- LIGHT_GREEN: "\x1B[92m",
330
- LIGHT_YELLOW: "\x1B[93m",
331
- LIGHT_BLUE: "\x1B[94m",
332
- LIGHT_MAGENTA: "\x1B[95m",
333
- LIGHT_CYAN: "\x1B[96m",
334
- WHITE: "\x1B[97m"
335
- }, at = {
336
- BLACK: "\x1B[40m",
337
- RED: "\x1B[41m",
338
- GREEN: "\x1B[42m",
339
- YELLOW: "\x1B[43m",
340
- BLUE: "\x1B[44m",
341
- MAGENTA: "\x1B[45m",
342
- CYAN: "\x1B[46m",
343
- WHITE: "\x1B[47m",
344
- GREY: "\x1B[100m"
345
- };
346
- var F = /* @__PURE__ */ ((n) => (n[n.ERROR = 0] = "ERROR", n[n.WARN = 1] = "WARN", n[n.INFO = 2] = "INFO", n[n.LOG = 3] = "LOG", n[n.DEBUG = 4] = "DEBUG", n))(F || {});
347
- const f = class f extends $ {
348
- constructor(e) {
349
- super(), this.namespace = e;
350
- }
351
- pad(e, t, r, s = !1) {
352
- const o = e.toString(), i = t - o.length;
353
- if (i <= 0)
354
- return o;
355
- const g = Array(~~(i / r.length)).fill(r).join("");
356
- return s ? o + g : g + o;
357
- }
358
- format(...e) {
359
- const t = /* @__PURE__ */ new Date();
360
- return `${`${t.getFullYear()}-${t.getMonth() + 1}-${t.getDate()} ${this.pad(t.getHours().toString(), 2, "0")}:${this.pad(t.getMinutes().toString(), 2, "0")}:${this.pad(t.getSeconds().toString(), 2, "0")}.${this.pad(t.getMilliseconds().toString(), 3, "0", !0)}`}${this.namespace ? ` [${this.namespace}]` : ""} ${e.join(" ")}`;
361
- }
362
- debug(...e) {
363
- if (f.LOG_LEVEL < 4)
364
- return;
365
- const t = this.format(...e);
366
- f.emit(4, t), console.debug(B.LIGHT_GREY + t + x.CLEAR);
367
- }
368
- log(...e) {
369
- if (f.LOG_LEVEL < 3)
370
- return;
371
- const t = this.format(...e);
372
- f.emit(3, t), console.log(x.CLEAR + t);
373
- }
374
- info(...e) {
375
- if (f.LOG_LEVEL < 2)
376
- return;
377
- const t = this.format(...e);
378
- f.emit(2, t), console.info(B.BLUE + t + x.CLEAR);
379
- }
380
- warn(...e) {
381
- if (f.LOG_LEVEL < 1)
382
- return;
383
- const t = this.format(...e);
384
- f.emit(1, t), console.warn(B.YELLOW + t + x.CLEAR);
385
- }
386
- error(...e) {
387
- if (f.LOG_LEVEL < 0)
388
- return;
389
- const t = this.format(...e);
390
- f.emit(0, t), console.error(B.RED + t + x.CLEAR);
391
- }
392
- };
393
- c(f, "LOG_LEVEL", 4);
394
- let L = f;
395
- function ht(n, e) {
396
- return n.length - n.replaceAll(e, "").length;
397
- }
398
- function lt(n) {
399
- return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
400
- }
401
- const R = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", N = "0123456789", b = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", v = R + N + b;
402
- function ft(n) {
403
- const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
404
- if (!e)
405
- throw new Error(`Number cannot be parsed: ${n}`);
406
- return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
407
- }
408
- function dt(n, e, t) {
409
- return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
410
- }
411
- function gt(n, e, t, r = !0) {
412
- const s = n.toString(), o = e - s.length;
413
- if (o <= 0)
414
- return s;
415
- const i = Array(~~(o / t.length)).fill(t).join("");
416
- return r ? i + s : s + i;
417
- }
418
- function pt(n, e = v) {
419
- return Array(n).fill(null).map(() => {
420
- const t = ~~(Math.random() * e.length);
421
- return e[t];
422
- }).join("");
423
- }
424
- function yt(n, e = !1, t = !1, r = !1) {
425
- if (!e && !t && !r)
426
- throw new Error("Must enable at least one: letters, numbers, symbols");
427
- return Array(n).fill(null).map(() => {
428
- let s;
429
- do {
430
- const o = ~~(Math.random() * 3);
431
- e && o == 0 ? s = R[~~(Math.random() * R.length)] : t && o == 1 ? s = N[~~(Math.random() * N.length)] : r && o == 2 && (s = b[~~(Math.random() * b.length)]);
432
- } while (!s);
433
- return s;
434
- }).join("");
435
- }
436
- function Et(n, e) {
437
- if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
438
- throw new TypeError("Regular expression must be global.");
439
- let t = [], r;
440
- for (; (r = e.exec(n)) !== null; )
441
- t.push(r);
442
- return t;
443
- }
444
- function z(n) {
445
- var e = J(V(Z(K(n), 8 * n.length)));
446
- return e.toLowerCase();
447
- }
448
- function J(n) {
449
- for (var e, t = "0123456789ABCDEF", r = "", s = 0; s < n.length; s++)
450
- e = n.charCodeAt(s), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
451
- return r;
452
- }
453
- function K(n) {
454
- for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
455
- e[t] = 0;
456
- for (t = 0; t < 8 * n.length; t += 8)
457
- e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
458
- return e;
459
- }
460
- function V(n) {
461
- for (var e = "", t = 0; t < 32 * n.length; t += 8)
462
- e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
463
- return e;
464
- }
465
- function Z(n, e) {
466
- n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
467
- for (var t = 1732584193, r = -271733879, s = -1732584194, o = 271733878, i = 0; i < n.length; i += 16) {
468
- var g = t, E = r, O = s, S = o;
469
- r = l(r = l(r = l(r = l(r = h(r = h(r = h(r = h(r = a(r = a(r = a(r = a(r = u(r = u(r = u(r = u(r, s = u(s, o = u(o, t = u(t, r, s, o, n[i + 0], 7, -680876936), r, s, n[i + 1], 12, -389564586), t, r, n[i + 2], 17, 606105819), o, t, n[i + 3], 22, -1044525330), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 4], 7, -176418897), r, s, n[i + 5], 12, 1200080426), t, r, n[i + 6], 17, -1473231341), o, t, n[i + 7], 22, -45705983), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 8], 7, 1770035416), r, s, n[i + 9], 12, -1958414417), t, r, n[i + 10], 17, -42063), o, t, n[i + 11], 22, -1990404162), s = u(s, o = u(o, t = u(t, r, s, o, n[i + 12], 7, 1804603682), r, s, n[i + 13], 12, -40341101), t, r, n[i + 14], 17, -1502002290), o, t, n[i + 15], 22, 1236535329), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 1], 5, -165796510), r, s, n[i + 6], 9, -1069501632), t, r, n[i + 11], 14, 643717713), o, t, n[i + 0], 20, -373897302), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 5], 5, -701558691), r, s, n[i + 10], 9, 38016083), t, r, n[i + 15], 14, -660478335), o, t, n[i + 4], 20, -405537848), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 9], 5, 568446438), r, s, n[i + 14], 9, -1019803690), t, r, n[i + 3], 14, -187363961), o, t, n[i + 8], 20, 1163531501), s = a(s, o = a(o, t = a(t, r, s, o, n[i + 13], 5, -1444681467), r, s, n[i + 2], 9, -51403784), t, r, n[i + 7], 14, 1735328473), o, t, n[i + 12], 20, -1926607734), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 5], 4, -378558), r, s, n[i + 8], 11, -2022574463), t, r, n[i + 11], 16, 1839030562), o, t, n[i + 14], 23, -35309556), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 1], 4, -1530992060), r, s, n[i + 4], 11, 1272893353), t, r, n[i + 7], 16, -155497632), o, t, n[i + 10], 23, -1094730640), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 13], 4, 681279174), r, s, n[i + 0], 11, -358537222), t, r, n[i + 3], 16, -722521979), o, t, n[i + 6], 23, 76029189), s = h(s, o = h(o, t = h(t, r, s, o, n[i + 9], 4, -640364487), r, s, n[i + 12], 11, -421815835), t, r, n[i + 15], 16, 530742520), o, t, n[i + 2], 23, -995338651), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 0], 6, -198630844), r, s, n[i + 7], 10, 1126891415), t, r, n[i + 14], 15, -1416354905), o, t, n[i + 5], 21, -57434055), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 12], 6, 1700485571), r, s, n[i + 3], 10, -1894986606), t, r, n[i + 10], 15, -1051523), o, t, n[i + 1], 21, -2054922799), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 8], 6, 1873313359), r, s, n[i + 15], 10, -30611744), t, r, n[i + 6], 15, -1560198380), o, t, n[i + 13], 21, 1309151649), s = l(s, o = l(o, t = l(t, r, s, o, n[i + 4], 6, -145523070), r, s, n[i + 11], 10, -1120210379), t, r, n[i + 2], 15, 718787259), o, t, n[i + 9], 21, -343485551), t = p(t, g), r = p(r, E), s = p(s, O), o = p(o, S);
470
- }
471
- return Array(t, r, s, o);
472
- }
473
- function C(n, e, t, r, s, o) {
474
- return p(Q(p(p(e, n), p(r, o)), s), t);
475
- }
476
- function u(n, e, t, r, s, o, i) {
477
- return C(e & t | ~e & r, n, e, s, o, i);
478
- }
479
- function a(n, e, t, r, s, o, i) {
480
- return C(e & r | t & ~r, n, e, s, o, i);
481
- }
482
- function h(n, e, t, r, s, o, i) {
483
- return C(e ^ t ^ r, n, e, s, o, i);
484
- }
485
- function l(n, e, t, r, s, o, i) {
486
- return C(t ^ (e | ~r), n, e, s, o, i);
487
- }
488
- function p(n, e) {
489
- var t = (65535 & n) + (65535 & e);
490
- return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
491
- }
492
- function Q(n, e) {
493
- return n << e | n >>> 32 - e;
494
- }
495
- function xt(n) {
496
- return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
497
- }
498
- function wt(n) {
499
- return Object.entries(n).map(
500
- ([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
501
- ).join("&");
502
- }
503
- function mt(n, e = "mp") {
504
- return n ? `https://www.gravatar.com/avatar/${z(n)}?d=${e}` : "";
505
- }
506
- function Bt(n) {
507
- const e = new RegExp(
508
- "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
509
- "gm"
510
- ).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
511
- if (t.port != null && (t.port = Number(t.port)), r.length > 2 && (t.domain = r.splice(-2, 2).join("."), t.subdomain = r.join(".")), t.query) {
512
- const s = t.query.split("&"), o = {};
513
- s.forEach((i) => {
514
- const [g, E] = i.split("=");
515
- o[g] = E;
516
- }), t.query = o;
517
- }
518
- return t;
519
- }
520
- class At extends Promise {
521
- constructor(t) {
522
- super((r, s) => t(
523
- (o) => r(o),
524
- (o) => s(o),
525
- (o) => this.progress = o
526
- ));
527
- c(this, "listeners", []);
528
- c(this, "_progress", 0);
529
- }
530
- get progress() {
531
- return this._progress;
532
- }
533
- set progress(t) {
534
- t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
535
- }
536
- onProgress(t) {
537
- return this.listeners.push(t), this;
538
- }
539
- }
540
- function Ct(n) {
541
- return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
542
- }
543
- function Ot(n) {
544
- return new Promise((e) => setTimeout(e, n));
545
- }
546
- function St(n) {
547
- const e = n instanceof Date ? n : new Date(n);
548
- return new Intl.DateTimeFormat("en-us", {
549
- weekday: "long",
550
- month: "short",
551
- day: "numeric",
552
- hour: "numeric",
553
- minute: "numeric",
554
- hour12: !0
555
- }).format(e);
556
- }
557
- export {
558
- w as ASet,
559
- D as BadRequestError,
560
- at as CliBackground,
561
- x as CliEffects,
562
- B as CliForeground,
563
- y as CustomError,
564
- G as ForbiddenError,
565
- P as InternalServerError,
566
- F as LOG_LEVEL,
567
- L as Logger,
568
- j as NotFoundError,
569
- At as PromiseProgress,
570
- $ as TypedEmitter,
571
- k as UnauthorizedError,
572
- T as XHR,
573
- nt as addUnique,
574
- rt as arrayDiff,
575
- st as caseInsensitiveSort,
576
- Y as clean,
577
- ht as countChars,
578
- lt as createHex,
579
- _ as deepCopy,
580
- A as dotNotation,
581
- ut as download,
582
- it as findByProp,
583
- W as flattenArr,
584
- H as flattenObj,
585
- wt as formEncode,
586
- St as formatDate,
587
- ft as formatPhoneNumber,
588
- mt as gravatar,
589
- I as includes,
590
- dt as insertAt,
591
- m as isEqual,
592
- ct as makeArray,
593
- q as makeUnique,
594
- Et as matchAll,
595
- z as md5,
596
- tt as mixin,
597
- gt as pad,
598
- pt as randomString,
599
- yt as randomStringBuilder,
600
- et as sanitizedJSON,
601
- Ot as sleep,
602
- ot as sortByProp,
603
- Ct as timeUntil,
604
- Bt as urlParser,
605
- xt as validateEmail
606
- };
607
- //# sourceMappingURL=utils.mjs.map