@ztimson/utils 0.15.2 → 0.15.3

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.mjs CHANGED
@@ -1,6 +1,6 @@
1
- var v = Object.defineProperty;
2
- var F = (n, e, t) => e in n ? v(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
- var u = (n, e, t) => (F(n, typeof e != "symbol" ? e + "" : e, t), t);
1
+ var Y = Object.defineProperty;
2
+ var F = (n, e, t) => e in n ? Y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var i = (n, e, t) => (F(n, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  function W(n, e = !1) {
5
5
  if (n == null)
6
6
  throw new Error("Cannot clean a NULL value");
@@ -8,7 +8,7 @@ function W(n, e = !1) {
8
8
  (e && r === void 0 || !e && r == null) && delete n[t];
9
9
  }), n;
10
10
  }
11
- function ft(n) {
11
+ function wt(n) {
12
12
  return JSON.parse(JSON.stringify(n));
13
13
  }
14
14
  function J(n, ...e) {
@@ -19,13 +19,13 @@ function J(n, ...e) {
19
19
  }
20
20
  function S(n, e, t) {
21
21
  if (!(n == null || !e))
22
- return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, i) => {
22
+ return e.split(/[.[\]]/g).filter((r) => r.length).reduce((r, o, s, c) => {
23
23
  if ((o[0] == '"' || o[0] == "'") && (o = o.slice(1, -1)), !(r != null && r.hasOwnProperty(o))) {
24
24
  if (t == null)
25
25
  return;
26
26
  r[o] = {};
27
27
  }
28
- return t !== void 0 && s == i.length - 1 ? r[o] = t : r[o];
28
+ return t !== void 0 && s == c.length - 1 ? r[o] = t : r[o];
29
29
  }, n);
30
30
  }
31
31
  function z(n, e, t = {}) {
@@ -37,7 +37,7 @@ function z(n, e, t = {}) {
37
37
  return t;
38
38
  }
39
39
  }
40
- function dt(n) {
40
+ function xt(n) {
41
41
  const e = new FormData();
42
42
  return Object.entries(n).forEach(([t, r]) => e.append(t, r)), e;
43
43
  }
@@ -49,11 +49,11 @@ function U(n, e, t = !1) {
49
49
  const r = typeof e;
50
50
  return r != typeof n ? !1 : r == "object" ? Object.keys(e).find((o) => !U(n[o], e[o], t)) == null : r == "function" ? n.toString() == e.toString() : n == e;
51
51
  }
52
- function b(n, e) {
52
+ function B(n, e) {
53
53
  const t = typeof n, r = typeof e;
54
- 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((s) => b(n[s], e[s]));
54
+ 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((s) => B(n[s], e[s]));
55
55
  }
56
- function yt(n, e) {
56
+ function At(n, e) {
57
57
  e.forEach((t) => {
58
58
  Object.getOwnPropertyNames(t.prototype).forEach((r) => {
59
59
  Object.defineProperty(
@@ -71,7 +71,7 @@ function q(n) {
71
71
  return n;
72
72
  }
73
73
  }
74
- function pt(n, e) {
74
+ function bt(n, e) {
75
75
  let t = [];
76
76
  return JSON.parse(JSON.stringify(n, (r, o) => {
77
77
  if (typeof o == "object" && o !== null) {
@@ -82,21 +82,21 @@ function pt(n, e) {
82
82
  return o;
83
83
  }, e));
84
84
  }
85
- function gt(n) {
85
+ function Bt(n) {
86
86
  return Object.entries(n).map(
87
87
  ([e, t]) => encodeURIComponent(e) + "=" + encodeURIComponent(t)
88
88
  ).join("&");
89
89
  }
90
- function mt(n, e) {
90
+ function Rt(n, e) {
91
91
  return n.indexOf(e) === -1 && n.push(e), n;
92
92
  }
93
- function Et(n, e) {
93
+ function Ot(n, e) {
94
94
  return V([
95
- ...n.filter((t) => !e.includes((r) => b(t, r))),
96
- ...e.filter((t) => !n.includes((r) => b(t, r)))
95
+ ...n.filter((t) => !e.includes((r) => B(t, r))),
96
+ ...e.filter((t) => !n.includes((r) => B(t, r)))
97
97
  ]);
98
98
  }
99
- function wt(n) {
99
+ function Lt(n) {
100
100
  return function(e, t) {
101
101
  const r = S(e, n), o = S(t, n);
102
102
  return typeof r != "string" || typeof o != "string" ? 1 : r.toLowerCase().localeCompare(o.toLowerCase());
@@ -105,24 +105,24 @@ function wt(n) {
105
105
  function K(n, e = []) {
106
106
  return n.forEach((t) => Array.isArray(t) ? K(t, e) : e.push(t)), e;
107
107
  }
108
- function xt(n, e = !1) {
108
+ function St(n, e = !1) {
109
109
  return function(t, r) {
110
110
  const o = S(t, n), s = S(r, n);
111
111
  return typeof o == "number" && typeof s == "number" ? (e ? -1 : 1) * (o - s) : o > s ? e ? -1 : 1 : o < s ? e ? 1 : -1 : 0;
112
112
  };
113
113
  }
114
- function At(n, e) {
115
- return (t) => b(t[n], e);
114
+ function Ct(n, e) {
115
+ return (t) => B(t[n], e);
116
116
  }
117
117
  function V(n) {
118
118
  for (let e = n.length - 1; e >= 0; e--)
119
- n.slice(0, e).find((t) => b(t, n[e])) && n.splice(e, 1);
119
+ n.slice(0, e).find((t) => B(t, n[e])) && n.splice(e, 1);
120
120
  return n;
121
121
  }
122
- function Bt(n) {
122
+ function Nt(n) {
123
123
  return Array.isArray(n) ? n : [n];
124
124
  }
125
- class B extends Array {
125
+ class b extends Array {
126
126
  /** Number of elements in set */
127
127
  get size() {
128
128
  return this.length;
@@ -155,7 +155,7 @@ class B extends Array {
155
155
  * @return {ASet<T>} Different elements
156
156
  */
157
157
  difference(e) {
158
- return new B(this.filter((t) => !e.has(t)));
158
+ return new b(this.filter((t) => !e.has(t)));
159
159
  }
160
160
  /**
161
161
  * Check if set includes element
@@ -171,7 +171,7 @@ class B extends Array {
171
171
  * @return {boolean} Set of common elements
172
172
  */
173
173
  intersection(e) {
174
- return new B(this.filter((t) => e.has(t)));
174
+ return new b(this.filter((t) => e.has(t)));
175
175
  }
176
176
  /**
177
177
  * Check if this set has no elements in common with the comparison set
@@ -203,7 +203,7 @@ class B extends Array {
203
203
  * @return {ASet<T>} New set of unique elements
204
204
  */
205
205
  symmetricDifference(e) {
206
- return new B([...this.difference(e), ...e.difference(this)]);
206
+ return new b([...this.difference(e), ...e.difference(this)]);
207
207
  }
208
208
  /**
209
209
  * Create joined list of elements included in this & the comparison set
@@ -211,18 +211,18 @@ class B extends Array {
211
211
  * @return {ASet<T>} New set of both previous sets combined
212
212
  */
213
213
  union(e) {
214
- return new B([...this, ...e]);
214
+ return new b([...this, ...e]);
215
215
  }
216
216
  }
217
- class E extends Promise {
217
+ class w extends Promise {
218
218
  constructor(t) {
219
219
  super((r, o) => t(
220
220
  (s) => r(s),
221
221
  (s) => o(s),
222
222
  (s) => this.progress = s
223
223
  ));
224
- u(this, "listeners", []);
225
- u(this, "_progress", 0);
224
+ i(this, "listeners", []);
225
+ i(this, "_progress", 0);
226
226
  }
227
227
  get progress() {
228
228
  return this._progress;
@@ -231,10 +231,10 @@ class E extends Promise {
231
231
  t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
232
232
  }
233
233
  static from(t) {
234
- return t instanceof E ? t : new E((r, o) => t.then((...s) => r(...s)).catch((...s) => o(...s)));
234
+ return t instanceof w ? t : new w((r, o) => t.then((...s) => r(...s)).catch((...s) => o(...s)));
235
235
  }
236
236
  from(t) {
237
- const r = E.from(t);
237
+ const r = w.from(t);
238
238
  return this.onProgress((o) => r.progress = o), r;
239
239
  }
240
240
  onProgress(t) {
@@ -255,11 +255,11 @@ function Z(n, e) {
255
255
  const t = document.createElement("a");
256
256
  t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
257
257
  }
258
- function bt(n, e) {
258
+ function Tt(n, e) {
259
259
  const t = URL.createObjectURL(n);
260
260
  Z(t, e), URL.revokeObjectURL(t);
261
261
  }
262
- function Rt(n = {}) {
262
+ function It(n = {}) {
263
263
  return new Promise((e) => {
264
264
  const t = document.createElement("input");
265
265
  t.type = "file", t.accept = n.accept || "*", t.style.display = "none", t.multiple = !!n.multiple, t.onblur = t.onchange = async () => {
@@ -267,15 +267,15 @@ function Rt(n = {}) {
267
267
  }, document.body.appendChild(t), t.click();
268
268
  });
269
269
  }
270
- function Ot(n) {
271
- return new E((e, t, r) => {
270
+ function $t(n) {
271
+ return new w((e, t, r) => {
272
272
  const o = new XMLHttpRequest(), s = new FormData();
273
- n.files.forEach((i) => s.append("file", i)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (i) => i.lengthComputable ? r(i.loaded / i.total) : null), o.addEventListener("loadend", () => e(q(o.responseText))), o.addEventListener("error", () => t(q(o.responseText))), o.addEventListener("timeout", () => t({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([i, y]) => o.setRequestHeader(i, y)), o.send(s);
273
+ n.files.forEach((c) => s.append("file", c)), o.withCredentials = !!n.withCredentials, o.upload.addEventListener("progress", (c) => c.lengthComputable ? r(c.loaded / c.total) : null), o.addEventListener("loadend", () => e(q(o.responseText))), o.addEventListener("error", () => t(q(o.responseText))), o.addEventListener("timeout", () => t({ error: "Request timed out" })), o.open("POST", n.url), Object.entries(n.headers || {}).forEach(([c, p]) => o.setRequestHeader(c, p)), o.send(s);
274
274
  });
275
275
  }
276
- class H {
276
+ class v {
277
277
  constructor() {
278
- u(this, "listeners", {});
278
+ i(this, "listeners", {});
279
279
  }
280
280
  static emit(e, ...t) {
281
281
  (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
@@ -314,11 +314,11 @@ class H {
314
314
  });
315
315
  }
316
316
  }
317
- u(H, "listeners", {});
318
- class w extends Error {
317
+ i(v, "listeners", {});
318
+ class g extends Error {
319
319
  constructor(t, r) {
320
320
  super(t);
321
- u(this, "_code");
321
+ i(this, "_code");
322
322
  r != null && (this._code = r);
323
323
  }
324
324
  get code() {
@@ -342,8 +342,8 @@ class w extends Error {
342
342
  return this.message || super.toString();
343
343
  }
344
344
  }
345
- u(w, "code", 500);
346
- class X extends w {
345
+ i(g, "code", 500);
346
+ class X extends g {
347
347
  constructor(e = "Bad Request") {
348
348
  super(e);
349
349
  }
@@ -351,8 +351,8 @@ class X extends w {
351
351
  return e.constructor.code == this.code;
352
352
  }
353
353
  }
354
- u(X, "code", 400);
355
- class Q extends w {
354
+ i(X, "code", 400);
355
+ class Q extends g {
356
356
  constructor(e = "Unauthorized") {
357
357
  super(e);
358
358
  }
@@ -360,8 +360,17 @@ class Q extends w {
360
360
  return e.constructor.code == this.code;
361
361
  }
362
362
  }
363
- u(Q, "code", 401);
364
- class _ extends w {
363
+ i(Q, "code", 401);
364
+ class _ extends g {
365
+ constructor(e = "Payment Required") {
366
+ super(e);
367
+ }
368
+ static instanceof(e) {
369
+ return e.constructor.code == this.code;
370
+ }
371
+ }
372
+ i(_, "code", 402);
373
+ class tt extends g {
365
374
  constructor(e = "Forbidden") {
366
375
  super(e);
367
376
  }
@@ -369,8 +378,8 @@ class _ extends w {
369
378
  return e.constructor.code == this.code;
370
379
  }
371
380
  }
372
- u(_, "code", 403);
373
- class tt extends w {
381
+ i(tt, "code", 403);
382
+ class et extends g {
374
383
  constructor(e = "Not Found") {
375
384
  super(e);
376
385
  }
@@ -378,8 +387,26 @@ class tt extends w {
378
387
  return e.constructor.code == this.code;
379
388
  }
380
389
  }
381
- u(tt, "code", 404);
382
- class et extends w {
390
+ i(et, "code", 404);
391
+ class nt extends g {
392
+ constructor(e = "Method Not Allowed") {
393
+ super(e);
394
+ }
395
+ static instanceof(e) {
396
+ return e.constructor.code == this.code;
397
+ }
398
+ }
399
+ i(nt, "code", 405);
400
+ class rt extends g {
401
+ constructor(e = "Not Acceptable") {
402
+ super(e);
403
+ }
404
+ static instanceof(e) {
405
+ return e.constructor.code == this.code;
406
+ }
407
+ }
408
+ i(rt, "code", 406);
409
+ class ot extends g {
383
410
  constructor(e = "Internal Server Error") {
384
411
  super(e);
385
412
  }
@@ -387,18 +414,54 @@ class et extends w {
387
414
  return e.constructor.code == this.code;
388
415
  }
389
416
  }
390
- u(et, "code", 500);
391
- const g = class g {
417
+ i(ot, "code", 500);
418
+ class st extends g {
419
+ constructor(e = "Not Implemented") {
420
+ super(e);
421
+ }
422
+ static instanceof(e) {
423
+ return e.constructor.code == this.code;
424
+ }
425
+ }
426
+ i(st, "code", 501);
427
+ class ct extends g {
428
+ constructor(e = "Bad Gateway") {
429
+ super(e);
430
+ }
431
+ static instanceof(e) {
432
+ return e.constructor.code == this.code;
433
+ }
434
+ }
435
+ i(ct, "code", 502);
436
+ class it extends g {
437
+ constructor(e = "Service Unavailable") {
438
+ super(e);
439
+ }
440
+ static instanceof(e) {
441
+ return e.constructor.code == this.code;
442
+ }
443
+ }
444
+ i(it, "code", 503);
445
+ class at extends g {
446
+ constructor(e = "Gateway Timeout") {
447
+ super(e);
448
+ }
449
+ static instanceof(e) {
450
+ return e.constructor.code == this.code;
451
+ }
452
+ }
453
+ i(at, "code", 504);
454
+ const m = class m {
392
455
  constructor(e = {}) {
393
- u(this, "interceptors", {});
394
- u(this, "headers", {});
395
- u(this, "url");
396
- this.url = e.url ?? null, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => g.addInterceptor(t));
456
+ i(this, "interceptors", {});
457
+ i(this, "headers", {});
458
+ i(this, "url");
459
+ this.url = e.url ?? null, this.headers = e.headers || {}, e.interceptors && e.interceptors.forEach((t) => m.addInterceptor(t));
397
460
  }
398
461
  static addInterceptor(e) {
399
- const t = Object.keys(g.interceptors).length.toString();
400
- return g.interceptors[t] = e, () => {
401
- g.interceptors[t] = null;
462
+ const t = Object.keys(m.interceptors).length.toString();
463
+ return m.interceptors[t] = e, () => {
464
+ m.interceptors[t] = null;
402
465
  };
403
466
  }
404
467
  addInterceptor(e) {
@@ -412,50 +475,50 @@ const g = class g {
412
475
  if (!this.url && !e.url)
413
476
  throw new Error("URL needs to be set");
414
477
  let t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
415
- if (e.fragment && (t.includes("#") ? t.replace(/#.*(\?|\n)/g, (s, i) => `#${e.fragment}${i}`) : t += "#" + e.fragment), e.query) {
416
- const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((i) => ({ key: i, value: e.query[i] }));
417
- t += (t.includes("?") ? "&" : "?") + s.map((i) => `${i.key}=${i.value}`).join("&");
478
+ if (e.fragment && (t.includes("#") ? t.replace(/#.*(\?|\n)/g, (s, c) => `#${e.fragment}${c}`) : t += "#" + e.fragment), e.query) {
479
+ const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((c) => ({ key: c, value: e.query[c] }));
480
+ t += (t.includes("?") ? "&" : "?") + s.map((c) => `${c.key}=${c.value}`).join("&");
418
481
  }
419
482
  const r = W({
420
483
  "Content-Type": e.body ? e.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
421
- ...g.headers,
484
+ ...m.headers,
422
485
  ...this.headers,
423
486
  ...e.headers
424
487
  });
425
- return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, y) => {
488
+ return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new w((s, c, p) => {
426
489
  fetch(t, {
427
490
  headers: r,
428
491
  method: e.method || (e.body ? "POST" : "GET"),
429
492
  body: e.body
430
- }).then(async (c) => {
493
+ }).then(async (a) => {
431
494
  var j, G;
432
- for (let a of [...Object.values(g.interceptors), ...Object.values(this.interceptors)])
433
- await new Promise((O) => a(c, () => O()));
434
- const R = c.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
495
+ for (let u of [...Object.values(m.interceptors), ...Object.values(this.interceptors)])
496
+ await new Promise((O) => u(a, () => O()));
497
+ const R = a.headers.get("Content-Length"), N = R ? parseInt(R, 10) : 0;
435
498
  let k = 0;
436
- const T = (j = c.body) == null ? void 0 : j.getReader(), Y = new ReadableStream({
437
- start(a) {
499
+ const T = (j = a.body) == null ? void 0 : j.getReader(), H = new ReadableStream({
500
+ start(u) {
438
501
  function O() {
439
502
  T == null || T.read().then((x) => {
440
503
  if (x.done)
441
- return a.close();
442
- k += x.value.byteLength, y(k / N), a.enqueue(x.value), O();
443
- }).catch((x) => a.error(x));
504
+ return u.close();
505
+ k += x.value.byteLength, p(k / N), u.enqueue(x.value), O();
506
+ }).catch((x) => u.error(x));
444
507
  }
445
508
  O();
446
509
  }
447
510
  });
448
- if (c.data = new Response(Y), e.decode == null || e.decode) {
449
- const a = (G = c.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
450
- a != null && a.includes("form") ? c.data = await c.data.formData() : a != null && a.includes("json") ? c.data = await c.data.json() : a != null && a.includes("text") ? c.data = await c.data.text() : a != null && a.includes("application") && (c.data = await c.data.blob());
511
+ if (a.data = new Response(H), e.decode == null || e.decode) {
512
+ const u = (G = a.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
513
+ u != null && u.includes("form") ? a.data = await a.data.formData() : u != null && u.includes("json") ? a.data = await a.data.json() : u != null && u.includes("text") ? a.data = await a.data.text() : u != null && u.includes("application") && (a.data = await a.data.blob());
451
514
  }
452
- c.ok ? s(c) : i(c);
515
+ a.ok ? s(a) : c(a);
453
516
  });
454
517
  });
455
518
  }
456
519
  };
457
- u(g, "interceptors", {}), u(g, "headers", {});
458
- let M = g;
520
+ i(m, "interceptors", {}), i(m, "headers", {});
521
+ let M = m;
459
522
  const A = {
460
523
  CLEAR: "\x1B[0m",
461
524
  BRIGHT: "\x1B[1m",
@@ -481,7 +544,7 @@ const A = {
481
544
  LIGHT_MAGENTA: "\x1B[95m",
482
545
  LIGHT_CYAN: "\x1B[96m",
483
546
  WHITE: "\x1B[97m"
484
- }, Lt = {
547
+ }, Dt = {
485
548
  BLACK: "\x1B[40m",
486
549
  RED: "\x1B[41m",
487
550
  GREEN: "\x1B[42m",
@@ -492,98 +555,98 @@ const A = {
492
555
  WHITE: "\x1B[47m",
493
556
  GREY: "\x1B[100m"
494
557
  };
495
- var nt = /* @__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))(nt || {});
496
- const p = class p extends H {
558
+ var ut = /* @__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))(ut || {});
559
+ const y = class y extends v {
497
560
  constructor(e) {
498
561
  super(), this.namespace = e;
499
562
  }
500
563
  pad(e, t, r, o = !1) {
501
- const s = e.toString(), i = t - s.length;
502
- if (i <= 0)
564
+ const s = e.toString(), c = t - s.length;
565
+ if (c <= 0)
503
566
  return s;
504
- const y = Array(~~(i / r.length)).fill(r).join("");
505
- return o ? s + y : y + s;
567
+ const p = Array(~~(c / r.length)).fill(r).join("");
568
+ return o ? s + p : p + s;
506
569
  }
507
570
  format(...e) {
508
571
  const t = /* @__PURE__ */ new Date();
509
572
  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(" ")}`;
510
573
  }
511
574
  debug(...e) {
512
- if (p.LOG_LEVEL < 4)
575
+ if (y.LOG_LEVEL < 4)
513
576
  return;
514
577
  const t = this.format(...e);
515
- p.emit(4, t), console.debug(L.LIGHT_GREY + t + A.CLEAR);
578
+ y.emit(4, t), console.debug(L.LIGHT_GREY + t + A.CLEAR);
516
579
  }
517
580
  log(...e) {
518
- if (p.LOG_LEVEL < 3)
581
+ if (y.LOG_LEVEL < 3)
519
582
  return;
520
583
  const t = this.format(...e);
521
- p.emit(3, t), console.log(A.CLEAR + t);
584
+ y.emit(3, t), console.log(A.CLEAR + t);
522
585
  }
523
586
  info(...e) {
524
- if (p.LOG_LEVEL < 2)
587
+ if (y.LOG_LEVEL < 2)
525
588
  return;
526
589
  const t = this.format(...e);
527
- p.emit(2, t), console.info(L.BLUE + t + A.CLEAR);
590
+ y.emit(2, t), console.info(L.BLUE + t + A.CLEAR);
528
591
  }
529
592
  warn(...e) {
530
- if (p.LOG_LEVEL < 1)
593
+ if (y.LOG_LEVEL < 1)
531
594
  return;
532
595
  const t = this.format(...e);
533
- p.emit(1, t), console.warn(L.YELLOW + t + A.CLEAR);
596
+ y.emit(1, t), console.warn(L.YELLOW + t + A.CLEAR);
534
597
  }
535
598
  error(...e) {
536
- if (p.LOG_LEVEL < 0)
599
+ if (y.LOG_LEVEL < 0)
537
600
  return;
538
601
  const t = this.format(...e);
539
- p.emit(0, t), console.error(L.RED + t + A.CLEAR);
602
+ y.emit(0, t), console.error(L.RED + t + A.CLEAR);
540
603
  }
541
604
  };
542
- u(p, "LOG_LEVEL", 4);
543
- let P = p;
544
- function St(n) {
545
- const e = (y, c) => c < 1e-7 ? y : e(c, ~~(y % c)), t = n.toString().length - 2;
605
+ i(y, "LOG_LEVEL", 4);
606
+ let P = y;
607
+ function kt(n) {
608
+ const e = (p, a) => a < 1e-7 ? p : e(a, ~~(p % a)), t = n.toString().length - 2;
546
609
  let r = Math.pow(10, t), o = n * r;
547
610
  const s = e(o, r);
548
611
  o = ~~(o / s), r = ~~(r / s);
549
- const i = ~~(o / r);
550
- return o -= i * r, `${i ? i + " " : ""}${~~o}/${~~r}`;
612
+ const c = ~~(o / r);
613
+ return o -= c * r, `${c ? c + " " : ""}${~~o}/${~~r}`;
551
614
  }
552
- function Ct(n) {
615
+ function jt(n) {
553
616
  let e = n.split(" ");
554
617
  const t = e.length == 2 ? Number(e[0]) : 0;
555
618
  return e = e.pop().split("/"), t + Number(e[0]) / Number(e[1]);
556
619
  }
557
- function Nt(n, e) {
620
+ function Gt(n, e) {
558
621
  return n.length - n.replaceAll(e, "").length;
559
622
  }
560
- function Tt(n) {
623
+ function Ut(n) {
561
624
  return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
562
625
  }
563
- const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $ = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", rt = I + $ + D;
564
- function It(n) {
626
+ const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $ = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", lt = I + $ + D;
627
+ function qt(n) {
565
628
  const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
566
629
  if (!e)
567
630
  throw new Error(`Number cannot be parsed: ${n}`);
568
631
  return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
569
632
  }
570
- function $t(n, e, t) {
633
+ function Mt(n, e, t) {
571
634
  return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
572
635
  }
573
- function Dt(n, e, t, r = !0) {
636
+ function Pt(n, e, t, r = !0) {
574
637
  const o = n.toString(), s = e - o.length;
575
638
  if (s <= 0)
576
639
  return o;
577
- const i = Array(~~(s / t.length)).fill(t).join("");
578
- return r ? i + o : o + i;
640
+ const c = Array(~~(s / t.length)).fill(t).join("");
641
+ return r ? c + o : o + c;
579
642
  }
580
- function kt(n, e = rt) {
643
+ function vt(n, e = lt) {
581
644
  return Array(n).fill(null).map(() => {
582
645
  const t = ~~(Math.random() * e.length);
583
646
  return e[t];
584
647
  }).join("");
585
648
  }
586
- function jt(n, e = !1, t = !1, r = !1) {
649
+ function Ht(n, e = !1, t = !1, r = !1) {
587
650
  if (!e && !t && !r)
588
651
  throw new Error("Must enable at least one: letters, numbers, symbols");
589
652
  return Array(n).fill(null).map(() => {
@@ -595,7 +658,7 @@ function jt(n, e = !1, t = !1, r = !1) {
595
658
  return o;
596
659
  }).join("");
597
660
  }
598
- function Gt(n, e) {
661
+ function Yt(n, e) {
599
662
  if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
600
663
  throw new TypeError("Regular expression must be global.");
601
664
  let t = [], r;
@@ -603,78 +666,78 @@ function Gt(n, e) {
603
666
  t.push(r);
604
667
  return t;
605
668
  }
606
- function ot(n) {
607
- var e = st(ct(at(it(n), 8 * n.length)));
669
+ function ht(n) {
670
+ var e = ft(pt(yt(dt(n), 8 * n.length)));
608
671
  return e.toLowerCase();
609
672
  }
610
- function st(n) {
673
+ function ft(n) {
611
674
  for (var e, t = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
612
675
  e = n.charCodeAt(o), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
613
676
  return r;
614
677
  }
615
- function it(n) {
678
+ function dt(n) {
616
679
  for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
617
680
  e[t] = 0;
618
681
  for (t = 0; t < 8 * n.length; t += 8)
619
682
  e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
620
683
  return e;
621
684
  }
622
- function ct(n) {
685
+ function pt(n) {
623
686
  for (var e = "", t = 0; t < 32 * n.length; t += 8)
624
687
  e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
625
688
  return e;
626
689
  }
627
- function at(n, e) {
690
+ function yt(n, e) {
628
691
  n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
629
- for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i < n.length; i += 16) {
630
- var y = t, c = r, R = o, N = s;
631
- r = d(r = d(r = d(r = d(r = f(r = f(r = f(r = f(r = h(r = h(r = h(r = h(r = l(r = l(r = l(r = l(r, o = l(o, s = l(s, t = l(t, r, o, s, n[i + 0], 7, -680876936), r, o, n[i + 1], 12, -389564586), t, r, n[i + 2], 17, 606105819), s, t, n[i + 3], 22, -1044525330), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 4], 7, -176418897), r, o, n[i + 5], 12, 1200080426), t, r, n[i + 6], 17, -1473231341), s, t, n[i + 7], 22, -45705983), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 8], 7, 1770035416), r, o, n[i + 9], 12, -1958414417), t, r, n[i + 10], 17, -42063), s, t, n[i + 11], 22, -1990404162), o = l(o, s = l(s, t = l(t, r, o, s, n[i + 12], 7, 1804603682), r, o, n[i + 13], 12, -40341101), t, r, n[i + 14], 17, -1502002290), s, t, n[i + 15], 22, 1236535329), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 1], 5, -165796510), r, o, n[i + 6], 9, -1069501632), t, r, n[i + 11], 14, 643717713), s, t, n[i + 0], 20, -373897302), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 5], 5, -701558691), r, o, n[i + 10], 9, 38016083), t, r, n[i + 15], 14, -660478335), s, t, n[i + 4], 20, -405537848), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 9], 5, 568446438), r, o, n[i + 14], 9, -1019803690), t, r, n[i + 3], 14, -187363961), s, t, n[i + 8], 20, 1163531501), o = h(o, s = h(s, t = h(t, r, o, s, n[i + 13], 5, -1444681467), r, o, n[i + 2], 9, -51403784), t, r, n[i + 7], 14, 1735328473), s, t, n[i + 12], 20, -1926607734), o = f(o, s = f(s, t = f(t, r, o, s, n[i + 5], 4, -378558), r, o, n[i + 8], 11, -2022574463), t, r, n[i + 11], 16, 1839030562), s, t, n[i + 14], 23, -35309556), o = f(o, s = f(s, t = f(t, r, o, s, n[i + 1], 4, -1530992060), r, o, n[i + 4], 11, 1272893353), t, r, n[i + 7], 16, -155497632), s, t, n[i + 10], 23, -1094730640), o = f(o, s = f(s, t = f(t, r, o, s, n[i + 13], 4, 681279174), r, o, n[i + 0], 11, -358537222), t, r, n[i + 3], 16, -722521979), s, t, n[i + 6], 23, 76029189), o = f(o, s = f(s, t = f(t, r, o, s, n[i + 9], 4, -640364487), r, o, n[i + 12], 11, -421815835), t, r, n[i + 15], 16, 530742520), s, t, n[i + 2], 23, -995338651), o = d(o, s = d(s, t = d(t, r, o, s, n[i + 0], 6, -198630844), r, o, n[i + 7], 10, 1126891415), t, r, n[i + 14], 15, -1416354905), s, t, n[i + 5], 21, -57434055), o = d(o, s = d(s, t = d(t, r, o, s, n[i + 12], 6, 1700485571), r, o, n[i + 3], 10, -1894986606), t, r, n[i + 10], 15, -1051523), s, t, n[i + 1], 21, -2054922799), o = d(o, s = d(s, t = d(t, r, o, s, n[i + 8], 6, 1873313359), r, o, n[i + 15], 10, -30611744), t, r, n[i + 6], 15, -1560198380), s, t, n[i + 13], 21, 1309151649), o = d(o, s = d(s, t = d(t, r, o, s, n[i + 4], 6, -145523070), r, o, n[i + 11], 10, -1120210379), t, r, n[i + 2], 15, 718787259), s, t, n[i + 9], 21, -343485551), t = m(t, y), r = m(r, c), o = m(o, R), s = m(s, N);
692
+ for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, c = 0; c < n.length; c += 16) {
693
+ var p = t, a = r, R = o, N = s;
694
+ r = d(r = d(r = d(r = d(r = f(r = f(r = f(r = f(r = h(r = h(r = h(r = h(r = l(r = l(r = l(r = l(r, o = l(o, s = l(s, t = l(t, r, o, s, n[c + 0], 7, -680876936), r, o, n[c + 1], 12, -389564586), t, r, n[c + 2], 17, 606105819), s, t, n[c + 3], 22, -1044525330), o = l(o, s = l(s, t = l(t, r, o, s, n[c + 4], 7, -176418897), r, o, n[c + 5], 12, 1200080426), t, r, n[c + 6], 17, -1473231341), s, t, n[c + 7], 22, -45705983), o = l(o, s = l(s, t = l(t, r, o, s, n[c + 8], 7, 1770035416), r, o, n[c + 9], 12, -1958414417), t, r, n[c + 10], 17, -42063), s, t, n[c + 11], 22, -1990404162), o = l(o, s = l(s, t = l(t, r, o, s, n[c + 12], 7, 1804603682), r, o, n[c + 13], 12, -40341101), t, r, n[c + 14], 17, -1502002290), s, t, n[c + 15], 22, 1236535329), o = h(o, s = h(s, t = h(t, r, o, s, n[c + 1], 5, -165796510), r, o, n[c + 6], 9, -1069501632), t, r, n[c + 11], 14, 643717713), s, t, n[c + 0], 20, -373897302), o = h(o, s = h(s, t = h(t, r, o, s, n[c + 5], 5, -701558691), r, o, n[c + 10], 9, 38016083), t, r, n[c + 15], 14, -660478335), s, t, n[c + 4], 20, -405537848), o = h(o, s = h(s, t = h(t, r, o, s, n[c + 9], 5, 568446438), r, o, n[c + 14], 9, -1019803690), t, r, n[c + 3], 14, -187363961), s, t, n[c + 8], 20, 1163531501), o = h(o, s = h(s, t = h(t, r, o, s, n[c + 13], 5, -1444681467), r, o, n[c + 2], 9, -51403784), t, r, n[c + 7], 14, 1735328473), s, t, n[c + 12], 20, -1926607734), o = f(o, s = f(s, t = f(t, r, o, s, n[c + 5], 4, -378558), r, o, n[c + 8], 11, -2022574463), t, r, n[c + 11], 16, 1839030562), s, t, n[c + 14], 23, -35309556), o = f(o, s = f(s, t = f(t, r, o, s, n[c + 1], 4, -1530992060), r, o, n[c + 4], 11, 1272893353), t, r, n[c + 7], 16, -155497632), s, t, n[c + 10], 23, -1094730640), o = f(o, s = f(s, t = f(t, r, o, s, n[c + 13], 4, 681279174), r, o, n[c + 0], 11, -358537222), t, r, n[c + 3], 16, -722521979), s, t, n[c + 6], 23, 76029189), o = f(o, s = f(s, t = f(t, r, o, s, n[c + 9], 4, -640364487), r, o, n[c + 12], 11, -421815835), t, r, n[c + 15], 16, 530742520), s, t, n[c + 2], 23, -995338651), o = d(o, s = d(s, t = d(t, r, o, s, n[c + 0], 6, -198630844), r, o, n[c + 7], 10, 1126891415), t, r, n[c + 14], 15, -1416354905), s, t, n[c + 5], 21, -57434055), o = d(o, s = d(s, t = d(t, r, o, s, n[c + 12], 6, 1700485571), r, o, n[c + 3], 10, -1894986606), t, r, n[c + 10], 15, -1051523), s, t, n[c + 1], 21, -2054922799), o = d(o, s = d(s, t = d(t, r, o, s, n[c + 8], 6, 1873313359), r, o, n[c + 15], 10, -30611744), t, r, n[c + 6], 15, -1560198380), s, t, n[c + 13], 21, 1309151649), o = d(o, s = d(s, t = d(t, r, o, s, n[c + 4], 6, -145523070), r, o, n[c + 11], 10, -1120210379), t, r, n[c + 2], 15, 718787259), s, t, n[c + 9], 21, -343485551), t = E(t, p), r = E(r, a), o = E(o, R), s = E(s, N);
632
695
  }
633
696
  return Array(t, r, o, s);
634
697
  }
635
698
  function C(n, e, t, r, o, s) {
636
- return m(ut(m(m(e, n), m(r, s)), o), t);
699
+ return E(gt(E(E(e, n), E(r, s)), o), t);
637
700
  }
638
- function l(n, e, t, r, o, s, i) {
639
- return C(e & t | ~e & r, n, e, o, s, i);
701
+ function l(n, e, t, r, o, s, c) {
702
+ return C(e & t | ~e & r, n, e, o, s, c);
640
703
  }
641
- function h(n, e, t, r, o, s, i) {
642
- return C(e & r | t & ~r, n, e, o, s, i);
704
+ function h(n, e, t, r, o, s, c) {
705
+ return C(e & r | t & ~r, n, e, o, s, c);
643
706
  }
644
- function f(n, e, t, r, o, s, i) {
645
- return C(e ^ t ^ r, n, e, o, s, i);
707
+ function f(n, e, t, r, o, s, c) {
708
+ return C(e ^ t ^ r, n, e, o, s, c);
646
709
  }
647
- function d(n, e, t, r, o, s, i) {
648
- return C(t ^ (e | ~r), n, e, o, s, i);
710
+ function d(n, e, t, r, o, s, c) {
711
+ return C(t ^ (e | ~r), n, e, o, s, c);
649
712
  }
650
- function m(n, e) {
713
+ function E(n, e) {
651
714
  var t = (65535 & n) + (65535 & e);
652
715
  return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
653
716
  }
654
- function ut(n, e) {
717
+ function gt(n, e) {
655
718
  return n << e | n >>> 32 - e;
656
719
  }
657
- function Ut(n) {
720
+ function Ft(n) {
658
721
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
659
722
  }
660
- function qt(n, e = "mp") {
661
- return n ? `https://www.gravatar.com/avatar/${ot(n)}?d=${e}` : "";
723
+ function Wt(n, e = "mp") {
724
+ return n ? `https://www.gravatar.com/avatar/${ht(n)}?d=${e}` : "";
662
725
  }
663
- function Mt(n) {
726
+ function Jt(n) {
664
727
  const e = new RegExp(
665
728
  "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
666
729
  "gm"
667
730
  ).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
668
731
  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) {
669
732
  const o = t.query.split("&"), s = {};
670
- o.forEach((i) => {
671
- const [y, c] = i.split("=");
672
- s[y] = c;
733
+ o.forEach((c) => {
734
+ const [p, a] = c.split("=");
735
+ s[p] = a;
673
736
  }), t.query = s;
674
737
  }
675
738
  return t;
676
739
  }
677
- function Pt(n) {
740
+ function zt(n) {
678
741
  const e = n instanceof Date ? n : new Date(n);
679
742
  return new Intl.DateTimeFormat("en-us", {
680
743
  weekday: "long",
@@ -685,73 +748,80 @@ function Pt(n) {
685
748
  hour12: !0
686
749
  }).format(e);
687
750
  }
688
- function lt(n) {
751
+ function mt(n) {
689
752
  return new Promise((e) => setTimeout(e, n));
690
753
  }
691
- async function Ht(n, e = 100) {
754
+ async function Kt(n, e = 100) {
692
755
  for (; n(); )
693
- await lt(e);
756
+ await mt(e);
694
757
  }
695
- function Yt(n) {
758
+ function Vt(n) {
696
759
  return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
697
760
  }
698
761
  export {
699
- B as ASet,
762
+ b as ASet,
763
+ ct as BadGatewayError,
700
764
  X as BadRequestError,
701
- Lt as CliBackground,
765
+ Dt as CliBackground,
702
766
  A as CliEffects,
703
767
  L as CliForeground,
704
- w as CustomError,
705
- _ as ForbiddenError,
768
+ g as CustomError,
769
+ tt as ForbiddenError,
770
+ at as GatewayTimeoutError,
706
771
  M as Http,
707
- et as InternalServerError,
772
+ ot as InternalServerError,
708
773
  q as JSONAttemptParse,
709
- pt as JSONSanitized,
710
- nt as LOG_LEVEL,
774
+ bt as JSONSanitized,
775
+ ut as LOG_LEVEL,
711
776
  P as Logger,
712
- tt as NotFoundError,
713
- E as PromiseProgress,
714
- H as TypedEmitter,
777
+ nt as MethodNotAllowedError,
778
+ rt as NotAcceptableError,
779
+ et as NotFoundError,
780
+ st as NotImplementedError,
781
+ _ as PaymentRequiredError,
782
+ w as PromiseProgress,
783
+ it as ServiceUnavailableError,
784
+ v as TypedEmitter,
715
785
  Q as UnauthorizedError,
716
- mt as addUnique,
717
- Et as arrayDiff,
718
- wt as caseInsensitiveSort,
786
+ Rt as addUnique,
787
+ Ot as arrayDiff,
788
+ Lt as caseInsensitiveSort,
719
789
  W as clean,
720
- Nt as countChars,
721
- Tt as createHex,
722
- St as dec2Frac,
723
- ft as deepCopy,
790
+ Gt as countChars,
791
+ Ut as createHex,
792
+ kt as dec2Frac,
793
+ wt as deepCopy,
724
794
  J as deepMerge,
725
795
  S as dotNotation,
726
796
  Z as download,
727
- bt as downloadBlob,
728
- Rt as fileBrowser,
729
- At as findByProp,
797
+ Tt as downloadBlob,
798
+ It as fileBrowser,
799
+ Ct as findByProp,
730
800
  K as flattenArr,
731
801
  z as flattenObj,
732
- dt as formData,
733
- Pt as formatDate,
734
- It as formatPhoneNumber,
735
- Ct as fracToDec,
736
- qt as gravatar,
802
+ xt as formData,
803
+ zt as formatDate,
804
+ qt as formatPhoneNumber,
805
+ jt as fracToDec,
806
+ Wt as gravatar,
737
807
  U as includes,
738
- $t as insertAt,
739
- b as isEqual,
740
- Bt as makeArray,
808
+ Mt as insertAt,
809
+ B as isEqual,
810
+ Nt as makeArray,
741
811
  V as makeUnique,
742
- Gt as matchAll,
743
- ot as md5,
744
- yt as mixin,
745
- Dt as pad,
746
- kt as randomString,
747
- jt as randomStringBuilder,
748
- lt as sleep,
749
- Ht as sleepUntil,
750
- xt as sortByProp,
751
- Yt as timeUntil,
752
- Ot as uploadWithProgress,
753
- gt as urlEncode,
754
- Mt as urlParser,
755
- Ut as validateEmail
812
+ Yt as matchAll,
813
+ ht as md5,
814
+ At as mixin,
815
+ Pt as pad,
816
+ vt as randomString,
817
+ Ht as randomStringBuilder,
818
+ mt as sleep,
819
+ Kt as sleepUntil,
820
+ St as sortByProp,
821
+ Vt as timeUntil,
822
+ $t as uploadWithProgress,
823
+ Bt as urlEncode,
824
+ Jt as urlParser,
825
+ Ft as validateEmail
756
826
  };
757
827
  //# sourceMappingURL=index.mjs.map