@ztimson/utils 0.15.1 → 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 a = (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 ht(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 ft(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 dt(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 yt(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 gt(n, e) {
90
+ function Rt(n, e) {
91
91
  return n.indexOf(e) === -1 && n.push(e), n;
92
92
  }
93
- function mt(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 Et(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,71 +105,124 @@ function Et(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 wt(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 xt(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 At(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
+ /** Number of elements in set */
126
127
  get size() {
127
128
  return this.length;
128
129
  }
130
+ /**
131
+ * Array to create set from, duplicate values will be removed
132
+ * @param {T[]} elements Elements which will be added to set
133
+ */
129
134
  constructor(e = []) {
130
135
  super(), e != null && e.forEach && e.forEach((t) => this.add(t));
131
136
  }
137
+ /**
138
+ * Add single element to set if unique
139
+ * @param {T} el Element to add
140
+ */
132
141
  add(e) {
133
142
  this.has(e) || this.push(e);
134
143
  }
144
+ /**
145
+ * Delete element from set
146
+ * @param {T} el Element that will be deleted
147
+ */
135
148
  delete(e) {
136
149
  const t = this.indexOf(e);
137
150
  t != -1 && this.slice(t, 1);
138
151
  }
152
+ /**
153
+ * Create list of elements this set has which the comparison set does not
154
+ * @param {ASet<T>} set Set to compare against
155
+ * @return {ASet<T>} Different elements
156
+ */
139
157
  difference(e) {
140
- return new B(this.reduce((t, r) => (e.has(r) || t.push(r), t), []));
158
+ return new b(this.filter((t) => !e.has(t)));
141
159
  }
160
+ /**
161
+ * Check if set includes element
162
+ * @param {T} el Element to look for
163
+ * @return {boolean} True if element was found, false otherwise
164
+ */
142
165
  has(e) {
143
166
  return this.indexOf(e) != -1;
144
167
  }
168
+ /**
169
+ * Create list of elements this set has in common with the comparison set
170
+ * @param {ASet<T>} set Set to compare against
171
+ * @return {boolean} Set of common elements
172
+ */
145
173
  intersection(e) {
146
- return new B(this.reduce((t, r) => (e.has(r) && t.push(r), t), []));
174
+ return new b(this.filter((t) => e.has(t)));
147
175
  }
176
+ /**
177
+ * Check if this set has no elements in common with the comparison set
178
+ * @param {ASet<T>} set Set to compare against
179
+ * @return {boolean} True if nothing in common, false otherwise
180
+ */
148
181
  isDisjointFrom(e) {
149
182
  return this.intersection(e).size == 0;
150
183
  }
184
+ /**
185
+ * Check if all elements in this set are included in the comparison set
186
+ * @param {ASet<T>} set Set to compare against
187
+ * @return {boolean} True if all elements are included, false otherwise
188
+ */
151
189
  isSubsetOf(e) {
152
190
  return this.findIndex((t) => !e.has(t)) == -1;
153
191
  }
192
+ /**
193
+ * Check if all elements from comparison set are included in this set
194
+ * @param {ASet<T>} set Set to compare against
195
+ * @return {boolean} True if all elements are included, false otherwise
196
+ */
154
197
  isSuperset(e) {
155
198
  return e.findIndex((t) => !this.has(t)) == -1;
156
199
  }
200
+ /**
201
+ * Create list of elements that are only in one set but not both (XOR)
202
+ * @param {ASet<T>} set Set to compare against
203
+ * @return {ASet<T>} New set of unique elements
204
+ */
157
205
  symmetricDifference(e) {
158
- return new B([...this.difference(e), ...e.difference(this)]);
206
+ return new b([...this.difference(e), ...e.difference(this)]);
159
207
  }
208
+ /**
209
+ * Create joined list of elements included in this & the comparison set
210
+ * @param {ASet<T>} set Set join
211
+ * @return {ASet<T>} New set of both previous sets combined
212
+ */
160
213
  union(e) {
161
- return new B([...this, ...e]);
214
+ return new b([...this, ...e]);
162
215
  }
163
216
  }
164
- class E extends Promise {
217
+ class w extends Promise {
165
218
  constructor(t) {
166
219
  super((r, o) => t(
167
220
  (s) => r(s),
168
221
  (s) => o(s),
169
222
  (s) => this.progress = s
170
223
  ));
171
- a(this, "listeners", []);
172
- a(this, "_progress", 0);
224
+ i(this, "listeners", []);
225
+ i(this, "_progress", 0);
173
226
  }
174
227
  get progress() {
175
228
  return this._progress;
@@ -178,10 +231,10 @@ class E extends Promise {
178
231
  t != this._progress && (this._progress = t, this.listeners.forEach((r) => r(t)));
179
232
  }
180
233
  static from(t) {
181
- 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)));
182
235
  }
183
236
  from(t) {
184
- const r = E.from(t);
237
+ const r = w.from(t);
185
238
  return this.onProgress((o) => r.progress = o), r;
186
239
  }
187
240
  onProgress(t) {
@@ -202,11 +255,11 @@ function Z(n, e) {
202
255
  const t = document.createElement("a");
203
256
  t.href = n, t.download = e, document.body.appendChild(t), t.click(), document.body.removeChild(t);
204
257
  }
205
- function Bt(n, e) {
258
+ function Tt(n, e) {
206
259
  const t = URL.createObjectURL(n);
207
260
  Z(t, e), URL.revokeObjectURL(t);
208
261
  }
209
- function bt(n = {}) {
262
+ function It(n = {}) {
210
263
  return new Promise((e) => {
211
264
  const t = document.createElement("input");
212
265
  t.type = "file", t.accept = n.accept || "*", t.style.display = "none", t.multiple = !!n.multiple, t.onblur = t.onchange = async () => {
@@ -214,15 +267,15 @@ function bt(n = {}) {
214
267
  }, document.body.appendChild(t), t.click();
215
268
  });
216
269
  }
217
- function Rt(n) {
218
- return new E((e, t, r) => {
270
+ function $t(n) {
271
+ return new w((e, t, r) => {
219
272
  const o = new XMLHttpRequest(), s = new FormData();
220
- 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, p]) => o.setRequestHeader(i, p)), 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);
221
274
  });
222
275
  }
223
- class H {
276
+ class v {
224
277
  constructor() {
225
- a(this, "listeners", {});
278
+ i(this, "listeners", {});
226
279
  }
227
280
  static emit(e, ...t) {
228
281
  (this.listeners["*"] || []).forEach((r) => r(e, ...t)), (this.listeners[e.toString()] || []).forEach((r) => r(...t));
@@ -261,11 +314,11 @@ class H {
261
314
  });
262
315
  }
263
316
  }
264
- a(H, "listeners", {});
265
- class w extends Error {
317
+ i(v, "listeners", {});
318
+ class g extends Error {
266
319
  constructor(t, r) {
267
320
  super(t);
268
- a(this, "_code");
321
+ i(this, "_code");
269
322
  r != null && (this._code = r);
270
323
  }
271
324
  get code() {
@@ -289,8 +342,8 @@ class w extends Error {
289
342
  return this.message || super.toString();
290
343
  }
291
344
  }
292
- a(w, "code", 500);
293
- class X extends w {
345
+ i(g, "code", 500);
346
+ class X extends g {
294
347
  constructor(e = "Bad Request") {
295
348
  super(e);
296
349
  }
@@ -298,8 +351,8 @@ class X extends w {
298
351
  return e.constructor.code == this.code;
299
352
  }
300
353
  }
301
- a(X, "code", 400);
302
- class Q extends w {
354
+ i(X, "code", 400);
355
+ class Q extends g {
303
356
  constructor(e = "Unauthorized") {
304
357
  super(e);
305
358
  }
@@ -307,8 +360,17 @@ class Q extends w {
307
360
  return e.constructor.code == this.code;
308
361
  }
309
362
  }
310
- a(Q, "code", 401);
311
- 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 {
312
374
  constructor(e = "Forbidden") {
313
375
  super(e);
314
376
  }
@@ -316,8 +378,8 @@ class _ extends w {
316
378
  return e.constructor.code == this.code;
317
379
  }
318
380
  }
319
- a(_, "code", 403);
320
- class tt extends w {
381
+ i(tt, "code", 403);
382
+ class et extends g {
321
383
  constructor(e = "Not Found") {
322
384
  super(e);
323
385
  }
@@ -325,8 +387,26 @@ class tt extends w {
325
387
  return e.constructor.code == this.code;
326
388
  }
327
389
  }
328
- a(tt, "code", 404);
329
- 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 {
330
410
  constructor(e = "Internal Server Error") {
331
411
  super(e);
332
412
  }
@@ -334,18 +414,54 @@ class et extends w {
334
414
  return e.constructor.code == this.code;
335
415
  }
336
416
  }
337
- a(et, "code", 500);
338
- 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 {
339
455
  constructor(e = {}) {
340
- a(this, "interceptors", {});
341
- a(this, "headers", {});
342
- a(this, "url");
343
- 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));
344
460
  }
345
461
  static addInterceptor(e) {
346
- const t = Object.keys(g.interceptors).length.toString();
347
- return g.interceptors[t] = e, () => {
348
- g.interceptors[t] = null;
462
+ const t = Object.keys(m.interceptors).length.toString();
463
+ return m.interceptors[t] = e, () => {
464
+ m.interceptors[t] = null;
349
465
  };
350
466
  }
351
467
  addInterceptor(e) {
@@ -359,28 +475,28 @@ const g = class g {
359
475
  if (!this.url && !e.url)
360
476
  throw new Error("URL needs to be set");
361
477
  let t = ((o = e.url) != null && o.startsWith("http") ? e.url : (this.url || "") + (e.url || "")).replace(/([^:]\/)\/+/g, "$1");
362
- if (e.fragment && (t.includes("#") ? t.replace(/#.*(\?|\n)/g, (s, i) => `#${e.fragment}${i}`) : t += "#" + e.fragment), e.query) {
363
- const s = Array.isArray(e.query) ? e.query : Object.keys(e.query).map((i) => ({ key: i, value: e.query[i] }));
364
- 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("&");
365
481
  }
366
482
  const r = W({
367
483
  "Content-Type": e.body ? e.body instanceof FormData ? "multipart/form-data" : "application/json" : void 0,
368
- ...g.headers,
484
+ ...m.headers,
369
485
  ...this.headers,
370
486
  ...e.headers
371
487
  });
372
- return typeof e.body == "object" && e.body != null && r["Content-Type"] == "application/json" && (e.body = JSON.stringify(e.body)), new E((s, i, p) => {
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) => {
373
489
  fetch(t, {
374
490
  headers: r,
375
491
  method: e.method || (e.body ? "POST" : "GET"),
376
492
  body: e.body
377
- }).then(async (c) => {
493
+ }).then(async (a) => {
378
494
  var j, G;
379
- for (let u of [...Object.values(g.interceptors), ...Object.values(this.interceptors)])
380
- await new Promise((O) => u(c, () => O()));
381
- 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;
382
498
  let k = 0;
383
- const T = (j = c.body) == null ? void 0 : j.getReader(), Y = new ReadableStream({
499
+ const T = (j = a.body) == null ? void 0 : j.getReader(), H = new ReadableStream({
384
500
  start(u) {
385
501
  function O() {
386
502
  T == null || T.read().then((x) => {
@@ -392,17 +508,17 @@ const g = class g {
392
508
  O();
393
509
  }
394
510
  });
395
- if (c.data = new Response(Y), e.decode == null || e.decode) {
396
- const u = (G = c.headers.get("Content-Type")) == null ? void 0 : G.toLowerCase();
397
- u != null && u.includes("form") ? c.data = await c.data.formData() : u != null && u.includes("json") ? c.data = await c.data.json() : u != null && u.includes("text") ? c.data = await c.data.text() : u != null && u.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());
398
514
  }
399
- c.ok ? s(c) : i(c);
515
+ a.ok ? s(a) : c(a);
400
516
  });
401
517
  });
402
518
  }
403
519
  };
404
- a(g, "interceptors", {}), a(g, "headers", {});
405
- let M = g;
520
+ i(m, "interceptors", {}), i(m, "headers", {});
521
+ let M = m;
406
522
  const A = {
407
523
  CLEAR: "\x1B[0m",
408
524
  BRIGHT: "\x1B[1m",
@@ -428,7 +544,7 @@ const A = {
428
544
  LIGHT_MAGENTA: "\x1B[95m",
429
545
  LIGHT_CYAN: "\x1B[96m",
430
546
  WHITE: "\x1B[97m"
431
- }, Ot = {
547
+ }, Dt = {
432
548
  BLACK: "\x1B[40m",
433
549
  RED: "\x1B[41m",
434
550
  GREEN: "\x1B[42m",
@@ -439,16 +555,16 @@ const A = {
439
555
  WHITE: "\x1B[47m",
440
556
  GREY: "\x1B[100m"
441
557
  };
442
- 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 || {});
443
- const y = class y 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 {
444
560
  constructor(e) {
445
561
  super(), this.namespace = e;
446
562
  }
447
563
  pad(e, t, r, o = !1) {
448
- const s = e.toString(), i = t - s.length;
449
- if (i <= 0)
564
+ const s = e.toString(), c = t - s.length;
565
+ if (c <= 0)
450
566
  return s;
451
- const p = Array(~~(i / r.length)).fill(r).join("");
567
+ const p = Array(~~(c / r.length)).fill(r).join("");
452
568
  return o ? s + p : p + s;
453
569
  }
454
570
  format(...e) {
@@ -486,51 +602,51 @@ const y = class y extends H {
486
602
  y.emit(0, t), console.error(L.RED + t + A.CLEAR);
487
603
  }
488
604
  };
489
- a(y, "LOG_LEVEL", 4);
605
+ i(y, "LOG_LEVEL", 4);
490
606
  let P = y;
491
- function Lt(n) {
492
- const e = (p, c) => c < 1e-7 ? p : e(c, ~~(p % c)), t = n.toString().length - 2;
607
+ function kt(n) {
608
+ const e = (p, a) => a < 1e-7 ? p : e(a, ~~(p % a)), t = n.toString().length - 2;
493
609
  let r = Math.pow(10, t), o = n * r;
494
610
  const s = e(o, r);
495
611
  o = ~~(o / s), r = ~~(r / s);
496
- const i = ~~(o / r);
497
- return o -= i * r, `${i ? i + " " : ""}${~~o}/${~~r}`;
612
+ const c = ~~(o / r);
613
+ return o -= c * r, `${c ? c + " " : ""}${~~o}/${~~r}`;
498
614
  }
499
- function St(n) {
615
+ function jt(n) {
500
616
  let e = n.split(" ");
501
617
  const t = e.length == 2 ? Number(e[0]) : 0;
502
618
  return e = e.pop().split("/"), t + Number(e[0]) / Number(e[1]);
503
619
  }
504
- function Ct(n, e) {
620
+ function Gt(n, e) {
505
621
  return n.length - n.replaceAll(e, "").length;
506
622
  }
507
- function Nt(n) {
623
+ function Ut(n) {
508
624
  return Array(n).fill(null).map(() => Math.round(Math.random() * 15).toString(16)).join("");
509
625
  }
510
- const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $ = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", rt = I + $ + D;
511
- function Tt(n) {
626
+ const I = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", $ = "0123456789", D = "~`!@#$%^&*()_-+={[}]|\\:;\"'<,>.?/", lt = I + $ + D;
627
+ function qt(n) {
512
628
  const e = /(\+?1)?.*?(\d{3}).*?(\d{3}).*?(\d{4})/g.exec(n);
513
629
  if (!e)
514
630
  throw new Error(`Number cannot be parsed: ${n}`);
515
631
  return `${e[1] ?? ""} (${e[2]}) ${e[3]}-${e[4]}`.trim();
516
632
  }
517
- function It(n, e, t) {
633
+ function Mt(n, e, t) {
518
634
  return `${n.slice(0, t)}${e}${n.slice(t + 1)}`;
519
635
  }
520
- function $t(n, e, t, r = !0) {
636
+ function Pt(n, e, t, r = !0) {
521
637
  const o = n.toString(), s = e - o.length;
522
638
  if (s <= 0)
523
639
  return o;
524
- const i = Array(~~(s / t.length)).fill(t).join("");
525
- return r ? i + o : o + i;
640
+ const c = Array(~~(s / t.length)).fill(t).join("");
641
+ return r ? c + o : o + c;
526
642
  }
527
- function Dt(n, e = rt) {
643
+ function vt(n, e = lt) {
528
644
  return Array(n).fill(null).map(() => {
529
645
  const t = ~~(Math.random() * e.length);
530
646
  return e[t];
531
647
  }).join("");
532
648
  }
533
- function kt(n, e = !1, t = !1, r = !1) {
649
+ function Ht(n, e = !1, t = !1, r = !1) {
534
650
  if (!e && !t && !r)
535
651
  throw new Error("Must enable at least one: letters, numbers, symbols");
536
652
  return Array(n).fill(null).map(() => {
@@ -542,7 +658,7 @@ function kt(n, e = !1, t = !1, r = !1) {
542
658
  return o;
543
659
  }).join("");
544
660
  }
545
- function jt(n, e) {
661
+ function Yt(n, e) {
546
662
  if (typeof e == "string" && (e = new RegExp(e, "g")), !e.global)
547
663
  throw new TypeError("Regular expression must be global.");
548
664
  let t = [], r;
@@ -550,84 +666,78 @@ function jt(n, e) {
550
666
  t.push(r);
551
667
  return t;
552
668
  }
553
- function ot(n) {
554
- var e = st(ct(ut(it(n), 8 * n.length)));
669
+ function ht(n) {
670
+ var e = ft(pt(yt(dt(n), 8 * n.length)));
555
671
  return e.toLowerCase();
556
672
  }
557
- function st(n) {
673
+ function ft(n) {
558
674
  for (var e, t = "0123456789ABCDEF", r = "", o = 0; o < n.length; o++)
559
675
  e = n.charCodeAt(o), r += t.charAt(e >>> 4 & 15) + t.charAt(15 & e);
560
676
  return r;
561
677
  }
562
- function it(n) {
678
+ function dt(n) {
563
679
  for (var e = Array(n.length >> 2), t = 0; t < e.length; t++)
564
680
  e[t] = 0;
565
681
  for (t = 0; t < 8 * n.length; t += 8)
566
682
  e[t >> 5] |= (255 & n.charCodeAt(t / 8)) << t % 32;
567
683
  return e;
568
684
  }
569
- function ct(n) {
685
+ function pt(n) {
570
686
  for (var e = "", t = 0; t < 32 * n.length; t += 8)
571
687
  e += String.fromCharCode(n[t >> 5] >>> t % 32 & 255);
572
688
  return e;
573
689
  }
574
- function ut(n, e) {
690
+ function yt(n, e) {
575
691
  n[e >> 5] |= 128 << e % 32, n[14 + (e + 64 >>> 9 << 4)] = e;
576
- for (var t = 1732584193, r = -271733879, o = -1732584194, s = 271733878, i = 0; i < n.length; i += 16) {
577
- var p = t, c = r, R = o, N = s;
578
- 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, p), 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);
579
695
  }
580
696
  return Array(t, r, o, s);
581
697
  }
582
698
  function C(n, e, t, r, o, s) {
583
- return m(at(m(m(e, n), m(r, s)), o), t);
699
+ return E(gt(E(E(e, n), E(r, s)), o), t);
584
700
  }
585
- function l(n, e, t, r, o, s, i) {
586
- 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);
587
703
  }
588
- function h(n, e, t, r, o, s, i) {
589
- 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);
590
706
  }
591
- function f(n, e, t, r, o, s, i) {
592
- 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);
593
709
  }
594
- function d(n, e, t, r, o, s, i) {
595
- 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);
596
712
  }
597
- function m(n, e) {
713
+ function E(n, e) {
598
714
  var t = (65535 & n) + (65535 & e);
599
715
  return (n >> 16) + (e >> 16) + (t >> 16) << 16 | 65535 & t;
600
716
  }
601
- function at(n, e) {
717
+ function gt(n, e) {
602
718
  return n << e | n >>> 32 - e;
603
719
  }
604
- function Gt(n) {
720
+ function Ft(n) {
605
721
  return /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(n);
606
722
  }
607
- function Ut(n, e = "mp") {
608
- 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}` : "";
609
725
  }
610
- function qt(n) {
726
+ function Jt(n) {
611
727
  const e = new RegExp(
612
728
  "(?:(?<protocol>[\\w\\d]+)\\:\\/\\/)?(?:(?<user>.+)\\@)?(?<host>(?<domain>[^:\\/\\?#@\\n]+)(?:\\:(?<port>\\d*))?)(?<path>\\/.*?)?(?:\\?(?<query>.*?))?(?:#(?<fragment>.*?))?$",
613
729
  "gm"
614
730
  ).exec(n), t = (e == null ? void 0 : e.groups) ?? {}, r = t.domain.split(".");
615
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) {
616
732
  const o = t.query.split("&"), s = {};
617
- o.forEach((i) => {
618
- const [p, c] = i.split("=");
619
- s[p] = c;
733
+ o.forEach((c) => {
734
+ const [p, a] = c.split("=");
735
+ s[p] = a;
620
736
  }), t.query = s;
621
737
  }
622
738
  return t;
623
739
  }
624
- function Mt(n) {
625
- return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
626
- }
627
- function Pt(n) {
628
- return new Promise((e) => setTimeout(e, n));
629
- }
630
- function Ht(n) {
740
+ function zt(n) {
631
741
  const e = n instanceof Date ? n : new Date(n);
632
742
  return new Intl.DateTimeFormat("en-us", {
633
743
  weekday: "long",
@@ -638,62 +748,80 @@ function Ht(n) {
638
748
  hour12: !0
639
749
  }).format(e);
640
750
  }
751
+ function mt(n) {
752
+ return new Promise((e) => setTimeout(e, n));
753
+ }
754
+ async function Kt(n, e = 100) {
755
+ for (; n(); )
756
+ await mt(e);
757
+ }
758
+ function Vt(n) {
759
+ return (n instanceof Date ? n.getTime() : n) - (/* @__PURE__ */ new Date()).getTime();
760
+ }
641
761
  export {
642
- B as ASet,
762
+ b as ASet,
763
+ ct as BadGatewayError,
643
764
  X as BadRequestError,
644
- Ot as CliBackground,
765
+ Dt as CliBackground,
645
766
  A as CliEffects,
646
767
  L as CliForeground,
647
- w as CustomError,
648
- _ as ForbiddenError,
768
+ g as CustomError,
769
+ tt as ForbiddenError,
770
+ at as GatewayTimeoutError,
649
771
  M as Http,
650
- et as InternalServerError,
772
+ ot as InternalServerError,
651
773
  q as JSONAttemptParse,
652
- pt as JSONSanitized,
653
- nt as LOG_LEVEL,
774
+ bt as JSONSanitized,
775
+ ut as LOG_LEVEL,
654
776
  P as Logger,
655
- tt as NotFoundError,
656
- E as PromiseProgress,
657
- 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,
658
785
  Q as UnauthorizedError,
659
- gt as addUnique,
660
- mt as arrayDiff,
661
- Et as caseInsensitiveSort,
786
+ Rt as addUnique,
787
+ Ot as arrayDiff,
788
+ Lt as caseInsensitiveSort,
662
789
  W as clean,
663
- Ct as countChars,
664
- Nt as createHex,
665
- Lt as dec2Frac,
666
- ht as deepCopy,
790
+ Gt as countChars,
791
+ Ut as createHex,
792
+ kt as dec2Frac,
793
+ wt as deepCopy,
667
794
  J as deepMerge,
668
795
  S as dotNotation,
669
796
  Z as download,
670
- Bt as downloadBlob,
671
- bt as fileBrowser,
672
- xt as findByProp,
797
+ Tt as downloadBlob,
798
+ It as fileBrowser,
799
+ Ct as findByProp,
673
800
  K as flattenArr,
674
801
  z as flattenObj,
675
- ft as formData,
676
- Ht as formatDate,
677
- Tt as formatPhoneNumber,
678
- St as fracToDec,
679
- Ut as gravatar,
802
+ xt as formData,
803
+ zt as formatDate,
804
+ qt as formatPhoneNumber,
805
+ jt as fracToDec,
806
+ Wt as gravatar,
680
807
  U as includes,
681
- It as insertAt,
682
- b as isEqual,
683
- At as makeArray,
808
+ Mt as insertAt,
809
+ B as isEqual,
810
+ Nt as makeArray,
684
811
  V as makeUnique,
685
- jt as matchAll,
686
- ot as md5,
687
- dt as mixin,
688
- $t as pad,
689
- Dt as randomString,
690
- kt as randomStringBuilder,
691
- Pt as sleep,
692
- wt as sortByProp,
693
- Mt as timeUntil,
694
- Rt as uploadWithProgress,
695
- yt as urlEncode,
696
- qt as urlParser,
697
- Gt 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
698
826
  };
699
827
  //# sourceMappingURL=index.mjs.map