esexts 1.4.1 → 1.4.2

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/esexts.js CHANGED
@@ -1,90 +1,70 @@
1
- const u = (t, e) => Object.defineProperties(t, Object.fromEntries(Object.keys(e).map((n) => [n, { value: e[n], enumerable: !1, configurable: !0, writable: !0 }])));
2
- function d() {
1
+ function u(t, e) {
2
+ return Object.defineProperties(t, Object.fromEntries(Object.keys(e).map((n) => [n, { value: e[n], enumerable: !1, configurable: !0, writable: !0 }])));
3
+ }
4
+ function p() {
3
5
  return {
4
6
  new: function(...t) {
5
7
  return new this(...t);
6
8
  }
7
9
  };
8
10
  }
9
- function g(...t) {
11
+ function d(...t) {
10
12
  const e = {};
11
- for (const n of t) {
12
- const [r, i] = Array.isArray(n) ? n : [n, n];
13
- e[i] = function(...s) {
14
- return this[r](...s), this;
13
+ for (const [n, r] of t)
14
+ e[r] = function() {
15
+ return this[n];
15
16
  };
16
- }
17
17
  return e;
18
18
  }
19
- function O(...t) {
19
+ function b(...t) {
20
20
  const e = {};
21
- for (const n of t) {
22
- const [r, i] = Array.isArray(n) ? n : [n, n];
23
- e[i] = function(...s) {
24
- return this[r](...s), s[0];
21
+ for (const [n, r] of t)
22
+ e[r] = function(...i) {
23
+ return [...this[n](...i)];
25
24
  };
26
- }
27
25
  return e;
28
26
  }
29
- function y(...t) {
27
+ function g(...t) {
30
28
  const e = {};
31
- for (const n of t) {
32
- const [r, i] = Array.isArray(n) ? n : [n, n];
33
- e[i] = function(...s) {
34
- return this[r](...s), s;
29
+ for (const [n, r] of t)
30
+ e[r] = function(...i) {
31
+ return this[n](...i), this;
35
32
  };
36
- }
37
33
  return e;
38
34
  }
39
- function p(...t) {
35
+ function O(...t) {
40
36
  const e = {};
41
- for (const n of t) {
42
- const [r, i] = Array.isArray(n) ? n : [n, n];
43
- e[i] = function() {
44
- return this[r];
37
+ for (const [n, r] of t)
38
+ e[r] = function(...i) {
39
+ return this[n](...i), i[0];
45
40
  };
46
- }
47
41
  return e;
48
42
  }
49
- function b(...t) {
43
+ function y(...t) {
50
44
  const e = {};
51
- for (const n of t) {
52
- const [r, i] = Array.isArray(n) ? n : [n, n];
53
- e[i] = function(...s) {
54
- return [...this[r](...s)];
45
+ for (const [n, r] of t)
46
+ e[r] = function(...i) {
47
+ return this[n](...i), i;
55
48
  };
56
- }
57
49
  return e;
58
50
  }
59
- function S(t, ...e) {
60
- const n = {};
61
- for (const r of e) {
62
- const [i, s] = Array.isArray(r) ? r : [r, r];
63
- n[s] = t[i];
64
- }
65
- return n;
66
- }
67
51
  function x(t, ...e) {
68
52
  const n = {};
69
- for (const r of e) {
70
- const [i, s] = Array.isArray(r) ? r : [r, r];
71
- n[s] = function(...o) {
72
- return t[i](this, ...o);
53
+ for (const [r, i] of e)
54
+ n[i] = function(...s) {
55
+ return t[r](this, ...s);
73
56
  };
74
- }
75
57
  return n;
76
58
  }
77
- function j(t, ...e) {
59
+ function S(t, ...e) {
78
60
  const n = {};
79
- for (const r of e) {
80
- const [i, s] = Array.isArray(r) ? r : [r, r];
81
- n[s] = function(...o) {
82
- return t[i](this, ...o), this;
61
+ for (const [r, i] of e)
62
+ n[i] = function(...s) {
63
+ return t[r](this, ...s), this;
83
64
  };
84
- }
85
65
  return n;
86
66
  }
87
- function D(t = { array: !1 }) {
67
+ function M(t = { array: !1 }) {
88
68
  return function(e = {}, ...n) {
89
69
  const r = (i, s) => {
90
70
  const o = Object.prototype.toString.call(i), a = Object.prototype.toString.call(s);
@@ -93,8 +73,8 @@ function D(t = { array: !1 }) {
93
73
  if (o === "[object Array]")
94
74
  return t.array ? i.concat(...s) : s;
95
75
  if (o === "[object Object]") {
96
- for (const l in s)
97
- i[l] = r(i[l], s[l]);
76
+ for (const f in s)
77
+ i[f] = r(i[f], s[f]);
98
78
  return i;
99
79
  } else
100
80
  return s;
@@ -104,16 +84,16 @@ function D(t = { array: !1 }) {
104
84
  return e;
105
85
  };
106
86
  }
107
- const F = D({ array: !1 }), M = D({ array: !0 });
87
+ const D = M({ array: !1 }), F = M({ array: !0 });
108
88
  u(Object, {
109
89
  isObject: function(t) {
110
90
  return Object.prototype.toString.call(t) === "[object Object]";
111
91
  },
112
92
  merge0: function(...t) {
113
- return F(this, ...t);
93
+ return D(this, ...t);
114
94
  },
115
95
  concat0: function(...t) {
116
- return M(this, ...t);
96
+ return F(this, ...t);
117
97
  }
118
98
  });
119
99
  u(Object.prototype, {
@@ -125,10 +105,10 @@ u(Object.prototype, {
125
105
  },
126
106
  ...x(Object, ["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
127
107
  merge0: function(...t) {
128
- return F(this, ...t);
108
+ return D(this, ...t);
129
109
  },
130
110
  concat0: function(...t) {
131
- return M(this, ...t);
111
+ return F(this, ...t);
132
112
  },
133
113
  map0: function(t = (n, r, i) => [n, r], e = 0) {
134
114
  return Object.entries(this).map(([n, r]) => t(n, r, e++));
@@ -151,7 +131,7 @@ u(Object.prototype, {
151
131
  toArray0: function() {
152
132
  return Array.isArray(this) ? this : [this];
153
133
  },
154
- ...j(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
134
+ ...S(console, ["debug", "debug0"], ["log", "log0"], ["info", "info0"], ["warn", "warn0"], ["error", "error0"], ["dir", "dir0"]),
155
135
  // ====== Tree ======
156
136
  getParents0: function(t = !1, e = -1, n = "parent") {
157
137
  const r = t ? [this] : [];
@@ -163,8 +143,8 @@ u(Object.prototype, {
163
143
  getChildrens0: function(t = !1, e = -1, n = "children") {
164
144
  const r = [], i = (s, o, a) => {
165
145
  if (o && r.push(s), !(a == 0 || !s[n] || s[n].length == 0))
166
- for (const l of s[n])
167
- i(l, !0, a - 1);
146
+ for (const f of s[n])
147
+ i(f, !0, a - 1);
168
148
  };
169
149
  return i(this, t, e), r;
170
150
  },
@@ -197,7 +177,7 @@ u(Object.prototype, {
197
177
  }
198
178
  });
199
179
  u(Number.prototype, {
200
- ...x(Math, "ceil", "floor", "trunc", "abs", "max", "min"),
180
+ ...x(Math, ["ceil", "ceil"], ["floor", "floor"], ["trunc", "trunc"], ["abs", "abs"], ["max", "max"], ["min", "min"]),
201
181
  baseConvert: function(t = 64) {
202
182
  let e = "", n = this, r = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";
203
183
  for (; n > 0; )
@@ -220,7 +200,7 @@ u(BigInt.prototype, {
220
200
  }
221
201
  });
222
202
  u(String.prototype, {
223
- ...p(["length", "length0"]),
203
+ ...d(["length", "length0"]),
224
204
  substring0: function(t = 0, e = this.length) {
225
205
  return t = t >= 0 ? t : this.length + t, e = e >= 0 ? e : this.length + e, this.substring(t, e);
226
206
  },
@@ -288,49 +268,21 @@ u(String.prototype, {
288
268
  toDate: function() {
289
269
  return Date.new(this);
290
270
  },
291
- hex2bytes: function() {
292
- const t = [];
293
- for (let e = 0; e < this.length; e += 2)
294
- t.push(Number.parseInt(this.substring(e, e + 2), 16));
295
- return t;
296
- },
297
271
  string2bytes: function() {
298
- if (typeof TextEncoder < "u")
299
- return Array.from(new TextEncoder().encode(this));
300
- const t = [], e = encodeURIComponent(this);
301
- for (let n = 0; n < e.length; )
302
- t.push(e.charAt(n) == "%" ? Number.parseInt(e.substring(n + 1, n += 3), 16) : e.charCodeAt(n++));
303
- return t;
272
+ return new TextEncoder().encode(this);
304
273
  },
305
- base64decode: function(t) {
306
- const e = [], n = {}, r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
307
- for (let s = 0; s < r.length; s++)
308
- n[r.charAt(s)] = s;
309
- const i = this.charAt(this.length - 1) != "=" ? this.length : this.charAt(this.length - 2) != "=" ? this.length - 1 : this.length - 2;
310
- for (let s = 3; s < i; s += 4) {
311
- const o = (n[this.charAt(s - 3)] << 18) + (n[this.charAt(s - 2)] << 12) + (n[this.charAt(s - 1)] << 6) + n[this.charAt(s)];
312
- e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
313
- }
314
- if (i % 4 == 3) {
315
- const s = (n[this.charAt(i - 3)] << 18) + (n[this.charAt(i - 2)] << 12) + (n[this.charAt(i - 1)] << 6);
316
- e.push((s & 16711680) >> 16, (s & 65280) >> 8);
317
- } else if (i % 4 == 2) {
318
- const s = (n[this.charAt(i - 2)] << 18) + (n[this.charAt(i - 1)] << 12);
319
- e.push((s & 16711680) >> 16);
320
- }
321
- return e;
322
- }
323
- });
324
- typeof Iterator < "u" && u(Iterator.prototype, {
325
- toArray: function() {
326
- return Array.from(this);
274
+ hex2bytes: function() {
275
+ return Uint8Array.fromHex(this);
276
+ },
277
+ base64decode: function() {
278
+ return Uint8Array.fromBase64(this);
327
279
  }
328
280
  });
329
281
  u(Array, {
330
- ...d()
282
+ ...p()
331
283
  });
332
284
  u(Array.prototype, {
333
- ...p(["length", "length0"]),
285
+ ...d(["length", "length0"]),
334
286
  ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
335
287
  ...g(["push", "push0"], ["pop", "pop0"], ["shift", "shift0"], ["unshift", "unshift0"]),
336
288
  ...O(["push", "push1"], ["unshift", "unshift1"]),
@@ -375,34 +327,14 @@ u(Array.prototype, {
375
327
  n(r.find((s) => t(s) == t(i)) ?? r.push1(e(i)), i);
376
328
  return r;
377
329
  },
330
+ bytes2string: function() {
331
+ return new TextDecoder().decode(new Uint8Array(this));
332
+ },
378
333
  bytes2hex: function() {
379
- let t = "";
380
- for (let e = 0; e < this.length; e++)
381
- t += (this[e] < 16 ? "0" : "") + this[e].toString(16);
382
- return t;
334
+ return new Uint8Array(this).toHex();
383
335
  },
384
- bytes2string: function() {
385
- if (typeof TextDecoder < "u")
386
- return new TextDecoder().decode(new Uint8Array(this));
387
- let t = "";
388
- for (let e = 0; e < this.length; e++)
389
- t += "%" + (this[e] < 16 ? "0" : "") + this[e].toString(16);
390
- return decodeURIComponent(t);
391
- },
392
- base64encode: function(t = !1, e = !0) {
393
- let n = "", r = t === !0 ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
394
- for (let i = 2; i < this.length; i += 3) {
395
- const s = (this[i - 2] << 16) + (this[i - 1] << 8) + this[i];
396
- n += r.charAt((s & 16515072) >> 18) + r.charAt((s & 258048) >> 12) + r.charAt((s & 4032) >> 6) + r.charAt(s & 63);
397
- }
398
- if (this.length % 3 == 2) {
399
- const i = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
400
- n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + r.charAt((i & 4032) >> 6) + (e === !1 ? "" : "=");
401
- } else if (this.length % 3 == 1) {
402
- const i = this[this.length - 1] << 16;
403
- n += r.charAt((i & 16515072) >> 18) + r.charAt((i & 258048) >> 12) + (e === !1 ? "" : "==");
404
- }
405
- return n;
336
+ base64encode: function() {
337
+ return new Uint8Array(this).toBase64();
406
338
  },
407
339
  toUint8Array: function() {
408
340
  return new Uint8Array(this);
@@ -414,24 +346,24 @@ u(Array.prototype, {
414
346
  },
415
347
  // ====== Tree ======
416
348
  toTree: function(t = {}) {
417
- const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: a = null, hasRoot: l = !0 } = t, m = this.toObject((h) => [h[e], h]), f = this.toGroup((h) => [h[n], h]), c = this.length && l ? this.find((h) => h[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: f[0] };
349
+ const { id: e = "id", pid: n = "pid", level: r = "level", root: i = "root", parent: s = "parent", children: o = "children", empty: a = null, hasRoot: f = !0 } = t, m = this.toObject((h) => [h[e], h]), l = this.toGroup((h) => [h[n], h]), c = this.length && f ? this.find((h) => h[n] === 0) : { [e]: 0, [n]: -1, [i]: null, [s]: null, [o]: l[0] };
418
350
  u(c, { [i]: { value: c, enumerable: !1, configurable: !0, writable: !0 } });
419
351
  for (const h of this)
420
352
  u(h, {
421
353
  [i]: { value: c, enumerable: !1, configurable: !0, writable: !0 },
422
354
  [s]: { value: m[h[n]], enumerable: !1, configurable: !0, writable: !0 }
423
- }), h[o] = f[h[e]] || a;
355
+ }), h[o] = l[h[e]] || a;
424
356
  return c.treeEach0((h) => h[r] = h[s] ? h[s][r] + 1 : 0, -1, o), c;
425
357
  },
426
358
  tree2tree: function(t = {}, e = null, n = null) {
427
- var f;
428
- const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: a = "parent", children: l = "children", empty: m = null } = t;
429
- e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [a]: null, [l]: this }, n = n || e;
359
+ var l;
360
+ const { id: r = "id", pid: i = "pid", level: s = "level", root: o = "root", parent: a = "parent", children: f = "children", empty: m = null } = t;
361
+ e = e || { [r]: 0, [i]: -1, [s]: 0, [o]: null, [a]: null, [f]: this }, n = n || e;
430
362
  for (const c of this)
431
363
  u(c, {
432
364
  [o]: { value: e, enumerable: !1, configurable: !0, writable: !0 },
433
365
  [a]: { value: n, enumerable: !1, configurable: !0, writable: !0 }
434
- }), c[i] = n[r], c[s] = n[s] + 1, c[l] = c[l] && c[l].length ? c[l] : m, (f = c[l]) == null || f.tree2tree(t, e, c);
366
+ }), c[i] = n[r], c[s] = n[s] + 1, c[f] = c[f] && c[f].length ? c[f] : m, (l = c[f]) == null || l.tree2tree(t, e, c);
435
367
  return e;
436
368
  },
437
369
  treeFind0: function(t, e = !0, n = -1, r = "children") {
@@ -451,22 +383,11 @@ u(Array.prototype, {
451
383
  return this.map((s) => s.treeMap0(t, e, n, r, i));
452
384
  }
453
385
  });
454
- u(ArrayBuffer.prototype, {
455
- toUint8Array: function() {
456
- return new Uint8Array(this);
457
- }
458
- });
459
- u(Uint8Array.prototype, {
460
- ...S(Array.prototype, "bytes2hex", "bytes2string", "base64encode"),
461
- toArray: function() {
462
- return new Array(...this);
463
- }
464
- });
465
386
  u(Map, {
466
- ...d()
387
+ ...p()
467
388
  });
468
389
  u(Map.prototype, {
469
- ...p(["size", "length0"]),
390
+ ...d(["size", "length0"]),
470
391
  ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
471
392
  ...g(["set", "set0"], ["delete", "delete0"]),
472
393
  ...y(["set", "set3"]),
@@ -490,10 +411,10 @@ u(Map.prototype, {
490
411
  }
491
412
  });
492
413
  u(Set, {
493
- ...d()
414
+ ...p()
494
415
  });
495
416
  u(Set.prototype, {
496
- ...p(["size", "length0"]),
417
+ ...d(["size", "length0"]),
497
418
  ...b(["entries", "entries0"], ["keys", "keys0"], ["values", "values0"]),
498
419
  ...g(["add", "add0"], ["delete", "delete0"]),
499
420
  ...y(["add", "add3"]),
@@ -586,21 +507,13 @@ u(Date.prototype, {
586
507
  }
587
508
  });
588
509
  u(RegExp, {
589
- ...d()
510
+ ...p()
590
511
  });
591
512
  u(RegExp.prototype, {
592
513
  toJSON: function() {
593
514
  return this.toString();
594
515
  }
595
516
  });
596
- typeof Promise.withResolvers > "u" && u(Promise, {
597
- withResolvers: function() {
598
- let t = null, e = null;
599
- return { promise: new this((r, i) => {
600
- t = r, e = i;
601
- }), resolve: t, reject: e };
602
- }
603
- });
604
517
  u(Promise, {
605
518
  channel: function() {
606
519
  let t = null, e = null;
@@ -625,7 +538,70 @@ u(JSON, {
625
538
  }
626
539
  }
627
540
  });
628
- let v = 0, A = 0, w = 0;
541
+ typeof Iterator < "u" && u(Iterator.prototype, {
542
+ toArray: function() {
543
+ return Array.from(this);
544
+ }
545
+ });
546
+ u(ArrayBuffer.prototype, {
547
+ toUint8Array: function() {
548
+ return new Uint8Array(this);
549
+ }
550
+ });
551
+ typeof Uint8Array.fromBase64 > "u" && (u(Uint8Array, {
552
+ fromHex: function(t) {
553
+ const e = [];
554
+ for (let n = 0; n < t.length; n += 2)
555
+ e.push(Number.parseInt(t.substring(n, n + 2), 16));
556
+ return new Uint8Array(e);
557
+ },
558
+ fromBase64: function(t) {
559
+ const e = [], n = {}, r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
560
+ for (let s = 0; s < r.length; s++)
561
+ n[r.charAt(s)] = s;
562
+ const i = t.charAt(t.length - 1) != "=" ? t.length : t.charAt(t.length - 2) != "=" ? t.length - 1 : t.length - 2;
563
+ for (let s = 3; s < i; s += 4) {
564
+ const o = (n[t.charAt(s - 3)] << 18) + (n[t.charAt(s - 2)] << 12) + (n[t.charAt(s - 1)] << 6) + n[t.charAt(s)];
565
+ e.push((o & 16711680) >> 16, (o & 65280) >> 8, o & 255);
566
+ }
567
+ if (i % 4 == 3) {
568
+ const s = (n[t.charAt(i - 3)] << 18) + (n[t.charAt(i - 2)] << 12) + (n[t.charAt(i - 1)] << 6);
569
+ e.push((s & 16711680) >> 16, (s & 65280) >> 8);
570
+ } else if (i % 4 == 2) {
571
+ const s = (n[t.charAt(i - 2)] << 18) + (n[t.charAt(i - 1)] << 12);
572
+ e.push((s & 16711680) >> 16);
573
+ }
574
+ return new Uint8Array(e);
575
+ }
576
+ }), u(Uint8Array.prototype, {
577
+ toHex: function() {
578
+ let t = "";
579
+ for (let e = 0; e < this.length; e++)
580
+ t += (this[e] < 16 ? "0" : "") + this[e].toString(16);
581
+ return t;
582
+ },
583
+ toBase64: function() {
584
+ let t = "", e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
585
+ for (let n = 2; n < this.length; n += 3) {
586
+ const r = (this[n - 2] << 16) + (this[n - 1] << 8) + this[n];
587
+ t += e.charAt((r & 16515072) >> 18) + e.charAt((r & 258048) >> 12) + e.charAt((r & 4032) >> 6) + e.charAt(r & 63);
588
+ }
589
+ if (this.length % 3 == 2) {
590
+ const n = (this[this.length - 2] << 16) + (this[this.length - 1] << 8);
591
+ t += e.charAt((n & 16515072) >> 18) + e.charAt((n & 258048) >> 12) + e.charAt((n & 4032) >> 6) + "=";
592
+ } else if (this.length % 3 == 1) {
593
+ const n = this[this.length - 1] << 16;
594
+ t += e.charAt((n & 16515072) >> 18) + e.charAt((n & 258048) >> 12) + "==";
595
+ }
596
+ return t;
597
+ }
598
+ }));
599
+ u(Uint8Array.prototype, {
600
+ toArray: function() {
601
+ return new Array(...this);
602
+ }
603
+ });
604
+ let j = 0, w = 0, A = 0;
629
605
  u(Math, {
630
606
  randstr: function(t = 16, e = 0, n = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", r = "~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/") {
631
607
  if (t < e)
@@ -645,13 +621,13 @@ u(Math, {
645
621
  return Math.floor(Math.random() * (e - t) + t);
646
622
  },
647
623
  incrid: function() {
648
- return ++v;
624
+ return ++j;
649
625
  },
650
626
  incrstr: function() {
651
627
  return "" + Math.incrid();
652
628
  },
653
629
  uniqid: function(t = Date.now()) {
654
- return t === w ? t * 2048 + ++A % 2048 : (w = t) * 2048 + (A = 0) % 2048;
630
+ return t === A ? t * 2048 + ++w % 2048 : (A = t) * 2048 + (w = 0) % 2048;
655
631
  },
656
632
  uniqstr: function() {
657
633
  return "" + Math.uniqid();
@@ -1 +1 @@
1
- (function(u){typeof define=="function"&&define.amd?define(u):u()})((function(){"use strict";const u=(t,e)=>Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])));function g(){return{new:function(...t){return new this(...t)}}}function d(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]=function(...s){return this[r](...s),this}}return e}function O(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]=function(...s){return this[r](...s),s[0]}}return e}function m(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]=function(...s){return this[r](...s),s}}return e}function p(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]=function(){return this[r]}}return e}function y(...t){const e={};for(const n of t){const[r,i]=Array.isArray(n)?n:[n,n];e[i]=function(...s){return[...this[r](...s)]}}return e}function S(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,r];n[s]=t[i]}return n}function A(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,r];n[s]=function(...o){return t[i](this,...o)}}return n}function j(t,...e){const n={};for(const r of e){const[i,s]=Array.isArray(r)?r:[r,r];n[s]=function(...o){return t[i](this,...o),this}}return n}function w(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),a=Object.prototype.toString.call(s);if(o!==a)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const f in s)i[f]=r(i[f],s[f]);return i}else return s};for(const i of n)e=r(e,i);return e}}const x=w({array:!1}),D=w({array:!0});u(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return x(this,...t)},concat0:function(...t){return D(this,...t)}}),u(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...A(Object,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:function(...t){return x(this,...t)},concat0:function(...t){return D(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...j(console,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,a)=>{if(o&&r.push(s),!(a==0||!s[n]||s[n].length==0))for(const f of s[n])i(f,!0,a-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const s=i.treeFind0(t,!0,n-1,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const s=e?t(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return s;for(const a of this[r])o.push(a.treeMap0(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...A(Math,"ceil","floor","trunc","abs","max","min"),baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},round:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},toFixed0:function(...t){return+this.toFixed(...t)},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),u(String.prototype,{...p(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let o=0;o<n&&r!=-1;o++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},lastSubOf:function(t,e,n=0,r=1/0){for(let o=0;o<n&&r!=-1;o++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},hex2bytes:function(){const t=[];for(let e=0;e<this.length;e+=2)t.push(Number.parseInt(this.substring(e,e+2),16));return t},string2bytes:function(){if(typeof TextEncoder<"u")return Array.from(new TextEncoder().encode(this));const t=[],e=encodeURIComponent(this);for(let n=0;n<e.length;)t.push(e.charAt(n)=="%"?Number.parseInt(e.substring(n+1,n+=3),16):e.charCodeAt(n++));return t},base64decode:function(t){const e=[],n={},r=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<r.length;s++)n[r.charAt(s)]=s;const i=this.charAt(this.length-1)!="="?this.length:this.charAt(this.length-2)!="="?this.length-1:this.length-2;for(let s=3;s<i;s+=4){const o=(n[this.charAt(s-3)]<<18)+(n[this.charAt(s-2)]<<12)+(n[this.charAt(s-1)]<<6)+n[this.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(n[this.charAt(i-3)]<<18)+(n[this.charAt(i-2)]<<12)+(n[this.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(n[this.charAt(i-2)]<<18)+(n[this.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return e}}),typeof Iterator<"u"&&u(Iterator.prototype,{toArray:function(){return Array.from(this)}}),u(Array,{...g()}),u(Array.prototype,{...p(["length","length0"]),...y(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...O(["push","push1"],["unshift","unshift1"]),...m(["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...d(["forEach","each0"]),toObject:function(t=(e,n)=>[n,e]){return Object.fromEntries(this.map(t))},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toGroup:function(t=e=>[e.id,e]){const e={};for(const n of this){const[r,i]=t(n);r in e||(e[r]=[]),e[r].push(i)}return e},toMerge:function(t=r=>r.id,e=r=>({...r,children:[]}),n=(r,i)=>r.children.push(i)){const r=[];for(const i of this)n(r.find(s=>t(s)==t(i))??r.push1(e(i)),i);return r},bytes2hex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},bytes2string:function(){if(typeof TextDecoder<"u")return new TextDecoder().decode(new Uint8Array(this));let t="";for(let e=0;e<this.length;e++)t+="%"+(this[e]<16?"0":"")+this[e].toString(16);return decodeURIComponent(t)},base64encode:function(t=!1,e=!0){let n="",r=t===!0?"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let i=2;i<this.length;i+=3){const s=(this[i-2]<<16)+(this[i-1]<<8)+this[i];n+=r.charAt((s&16515072)>>18)+r.charAt((s&258048)>>12)+r.charAt((s&4032)>>6)+r.charAt(s&63)}if(this.length%3==2){const i=(this[this.length-2]<<16)+(this[this.length-1]<<8);n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+r.charAt((i&4032)>>6)+(e===!1?"":"=")}else if(this.length%3==1){const i=this[this.length-1]<<16;n+=r.charAt((i&16515072)>>18)+r.charAt((i&258048)>>12)+(e===!1?"":"==")}return n},toUint8Array:function(){return new Uint8Array(this)},assoc:function(t,e,n={}){const r=this.unique0(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(s=>s[e]=i[s[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:s="parent",children:o="children",empty:a=null,hasRoot:f=!0}=t,b=this.toObject(h=>[h[e],h]),l=this.toGroup(h=>[h[n],h]),c=this.length&&f?this.find(h=>h[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:l[0]};u(c,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)u(h,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0},[s]:{value:b[h[n]],enumerable:!1,configurable:!0,writable:!0}}),h[o]=l[h[e]]||a;return c.treeEach0(h=>h[r]=h[s]?h[s][r]+1:0,-1,o),c},tree2tree:function(t={},e=null,n=null){var l;const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:a="parent",children:f="children",empty:b=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[a]:null,[f]:this},n=n||e;for(const c of this)u(c,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[a]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),c[i]=n[r],c[s]=n[s]+1,c[f]=c[f]&&c[f].length?c[f]:b,(l=c[f])==null||l.tree2tree(t,e,c);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.treeFind0(t,e,n,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.treeMap0(t,e,n,r,i))}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),u(Uint8Array.prototype,{...S(Array.prototype,"bytes2hex","bytes2string","base64encode"),toArray:function(){return new Array(...this)}}),u(Map,{...g()}),u(Map.prototype,{...p(["size","length0"]),...y(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["set","set0"],["delete","delete0"]),...m(["set","set3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Set,{...g()}),u(Set.prototype,{...p(["size","length0"]),...y(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["add","add0"],["delete","delete0"]),...m(["add","add3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),u(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s=0}){const o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+s)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),u(RegExp,{...g()}),u(RegExp.prototype,{toJSON:function(){return this.toString()}}),typeof Promise.withResolvers>"u"&&u(Promise,{withResolvers:function(){let t=null,e=null;return{promise:new this((r,i)=>{t=r,e=i}),resolve:t,reject:e}}}),u(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),u(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}});let v=0,F=0,M=0;u(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let s=0;s<t;s++)i.push(n.charAt(Math.random()*n.length|0));for(let s=new Set,o=0,a=0;a<e;a++){do o=Math.random()*t|0;while(s.has(o));s.set(o,!0),i[o]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++v},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===M?t*2048+ ++F%2048:(M=t)*2048+(F=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:s}){return e=s.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:s}){return()=>e==null?void 0:e(s)},name:t};return{[n.name]:n,[r.name]:r}}})}));
1
+ (function(u){typeof define=="function"&&define.amd?define(u):u()})((function(){"use strict";function u(t,e){return Object.defineProperties(t,Object.fromEntries(Object.keys(e).map(n=>[n,{value:e[n],enumerable:!1,configurable:!0,writable:!0}])))}function g(){return{new:function(...t){return new this(...t)}}}function p(...t){const e={};for(const[n,r]of t)e[r]=function(){return this[n]};return e}function m(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return[...this[n](...i)]};return e}function d(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),this};return e}function O(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),i[0]};return e}function b(...t){const e={};for(const[n,r]of t)e[r]=function(...i){return this[n](...i),i};return e}function w(t,...e){const n={};for(const[r,i]of e)n[i]=function(...s){return t[r](this,...s)};return n}function S(t,...e){const n={};for(const[r,i]of e)n[i]=function(...s){return t[r](this,...s),this};return n}function A(t={array:!1}){return function(e={},...n){const r=(i,s)=>{const o=Object.prototype.toString.call(i),a=Object.prototype.toString.call(s);if(o!==a)return s;if(o==="[object Array]")return t.array?i.concat(...s):s;if(o==="[object Object]"){for(const f in s)i[f]=r(i[f],s[f]);return i}else return s};for(const i of n)e=r(e,i);return e}}const x=A({array:!1}),M=A({array:!0});u(Object,{isObject:function(t){return Object.prototype.toString.call(t)==="[object Object]"},merge0:function(...t){return x(this,...t)},concat0:function(...t){return M(this,...t)}}),u(Object.prototype,{clone0:function(){return JSON.parse(JSON.stringify(this))},length0:function(){return Object.keys(this).length},...w(Object,["entries","entries0"],["keys","keys0"],["values","values0"]),merge0:function(...t){return x(this,...t)},concat0:function(...t){return M(this,...t)},map0:function(t=(n,r,i)=>[n,r],e=0){return Object.entries(this).map(([n,r])=>t(n,r,e++))},pick0:function(...t){const e={};for(const n of t)e[n]=this[n];return e},omit0:function(...t){const e={},n=new Set(t);for(const r in this)n.has(r)||(e[r]=this[r]);return e},attr0:function(t,...e){return typeof this!="object"?this:typeof t=="function"?t(this,...e):this[t]},toArray0:function(){return Array.isArray(this)?this:[this]},...S(console,["debug","debug0"],["log","log0"],["info","info0"],["warn","warn0"],["error","error0"],["dir","dir0"]),getParents0:function(t=!1,e=-1,n="parent"){const r=t?[this]:[];let i=this[n];for(;i&&e--!=0;)r.push(i),i=i[n];return r},getChildrens0:function(t=!1,e=-1,n="children"){const r=[],i=(s,o,a)=>{if(o&&r.push(s),!(a==0||!s[n]||s[n].length==0))for(const f of s[n])i(f,!0,a-1)};return i(this,t,e),r},treeFind0:function(t,e=!0,n=-1,r="children"){if(e&&t(this))return this;if(n==0||!this[r]||this[r].length==0)return null;for(const i of this[r]){const s=i.treeFind0(t,!0,n-1,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){if(e&&t(this),!(n==0||!this[r]||this[r].length==0)){for(const i of this[r])i.treeEach0(t,!0,n-1,r);return this}},treeMap0:function(t,e=!0,n=-1,r="children",i=null){const s=e?t(this):this,o=[];if(n==0||!this[r]||this[r].length==0)return s;for(const a of this[r])o.push(a.treeMap0(t,!0,n-1,r,i));return s[r]=o,s}}),u(Number.prototype,{...w(Math,["ceil","ceil"],["floor","floor"],["trunc","trunc"],["abs","abs"],["max","max"],["min","min"]),baseConvert:function(t=64){let e="",n=this,r="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(;n>0;)e=r.at(n%t)+e,n=Math.floor(n/t);return e||"0"},round:function(t=0){return t==0?Math.round(this):Math.round(this*10**t)/10**t},toFixed0:function(...t){return+this.toFixed(...t)},toDate:function(){return Date.new(this)}}),u(BigInt.prototype,{toJSON:function(){return this<BigInt(Number.MIN_SAFE_INTEGER)||this>BigInt(Number.MAX_SAFE_INTEGER)?this.toString():Number(this)}}),u(String.prototype,{...p(["length","length0"]),substring0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=e>=0?e:this.length+e,this.substring(t,e)},substr0:function(t=0,e=this.length){return t=t>=0?t:this.length+t,e=t+e,this.substring(t,e)},split0:function(t=",",e=-1){const n=this?this.split(t):[];return e===-1?n:n.push0(n.splice(e-1).join(t))},splitNumber:function(t=","){return this.split0(t).map(e=>+e)},splitSegment:function(t=1){const e=[];for(let n=0;n<this.length;n+=t)e.push(this.substring(n,n+t));return e},sprintf:function(...t){let[e,...n]=this.split(/%[sd]/);for(let r=0;r<n.length;r++)e+=t[r]+n[r];return e},subOf:function(t,e,n=0,r=0){for(let o=0;o<n&&r!=-1;o++,r++)r=this.indexOf(t,r);let i=this.indexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},lastSubOf:function(t,e,n=0,r=1/0){for(let o=0;o<n&&r!=-1;o++,r--)r=this.lastIndexOf(t,r);let i=this.lastIndexOf(t,r),s=this.indexOf(e,i);return i==-1||s==-1?"":(i+=t.length,this.substring(i,s))},camel2under:function(){return this.substr(0,1)+this.substr(1).replace(/([A-Z])/g,(t,e)=>"_"+e.toLowerCase())},under2camel:function(){return this.replace(/_([a-z])/g,(t,e)=>e.toUpperCase())},camel2pascal:function(){return this.substr(0,1).toUpperCase()+this.substr(1)},pascal2camel:function(){return this.substr(0,1).toLowerCase()+this.substr(1)},under2kebab:function(){return this.replace(/_/g,"-")},kebab2under:function(){return this.replace(/-/g,"_")},baseConvert:function(t=64){let e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";for(let r=0;r<this.length;r++)e=e*t+n.indexOf(this.at(r));return e},toFixed0:function(...t){return+(+this).toFixed(...t)},toDate:function(){return Date.new(this)},string2bytes:function(){return new TextEncoder().encode(this)},hex2bytes:function(){return Uint8Array.fromHex(this)},base64decode:function(){return Uint8Array.fromBase64(this)}}),u(Array,{...g()}),u(Array.prototype,{...p(["length","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["push","push0"],["pop","pop0"],["shift","shift0"],["unshift","unshift0"]),...O(["push","push1"],["unshift","unshift1"]),...b(["push","push3"],["unshift","unshift3"]),first0:function(t=null){return this.length?this[0]:t},last0:function(t=null){return this.length?this[this.length-1]:t},find0:function(t,e=null){return this.find(t)??e},equals0:function(t){return this.length===t.length&&(this===t||this.length===0||this.every((e,n)=>e===t[n]))},unique0:function(t=e=>e){const e=new Set;return this.filter(n=>e.has(t(n))?!1:!!e.add(t(n)))},...d(["forEach","each0"]),toObject:function(t=(e,n)=>[n,e]){return Object.fromEntries(this.map(t))},toMap:function(t=(e,n)=>[n,e]){return new Map(this.map(t))},toSet:function(t=e=>e){return new Set(this.map(t))},toGroup:function(t=e=>[e.id,e]){const e={};for(const n of this){const[r,i]=t(n);r in e||(e[r]=[]),e[r].push(i)}return e},toMerge:function(t=r=>r.id,e=r=>({...r,children:[]}),n=(r,i)=>r.children.push(i)){const r=[];for(const i of this)n(r.find(s=>t(s)==t(i))??r.push1(e(i)),i);return r},bytes2string:function(){return new TextDecoder().decode(new Uint8Array(this))},bytes2hex:function(){return new Uint8Array(this).toHex()},base64encode:function(){return new Uint8Array(this).toBase64()},toUint8Array:function(){return new Uint8Array(this)},assoc:function(t,e,n={}){const r=this.unique0(s=>s[t]),i=r.length==0?{}:typeof n=="function"?n(r):n;return this.each0(s=>s[e]=i[s[t]]??null)},toTree:function(t={}){const{id:e="id",pid:n="pid",level:r="level",root:i="root",parent:s="parent",children:o="children",empty:a=null,hasRoot:f=!0}=t,y=this.toObject(h=>[h[e],h]),l=this.toGroup(h=>[h[n],h]),c=this.length&&f?this.find(h=>h[n]===0):{[e]:0,[n]:-1,[i]:null,[s]:null,[o]:l[0]};u(c,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0}});for(const h of this)u(h,{[i]:{value:c,enumerable:!1,configurable:!0,writable:!0},[s]:{value:y[h[n]],enumerable:!1,configurable:!0,writable:!0}}),h[o]=l[h[e]]||a;return c.treeEach0(h=>h[r]=h[s]?h[s][r]+1:0,-1,o),c},tree2tree:function(t={},e=null,n=null){var l;const{id:r="id",pid:i="pid",level:s="level",root:o="root",parent:a="parent",children:f="children",empty:y=null}=t;e=e||{[r]:0,[i]:-1,[s]:0,[o]:null,[a]:null,[f]:this},n=n||e;for(const c of this)u(c,{[o]:{value:e,enumerable:!1,configurable:!0,writable:!0},[a]:{value:n,enumerable:!1,configurable:!0,writable:!0}}),c[i]=n[r],c[s]=n[s]+1,c[f]=c[f]&&c[f].length?c[f]:y,(l=c[f])==null||l.tree2tree(t,e,c);return e},treeFind0:function(t,e=!0,n=-1,r="children"){for(const i of this){const s=i.treeFind0(t,e,n,r);if(s!==null)return s}return null},treeEach0:function(t,e=!0,n=-1,r="children"){for(const i of this)i.treeEach0(t,e,n,r);return this},treeMap0:function(t,e=!0,n=-1,r="children",i=null){return this.map(s=>s.treeMap0(t,e,n,r,i))}}),u(Map,{...g()}),u(Map.prototype,{...p(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["set","set0"],["delete","delete0"]),...b(["set","set3"]),get0:function(t,e=null){return this.has(t)?this.get(t):e},get1:function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,e(t,...n))[1]},getAsync1:async function(t,e,...n){return this.has(t)?this.get(t):this.set3(t,await e(t,...n))[1]},toObject:function(){return Object.fromEntries(this)},toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Set,{...g()}),u(Set.prototype,{...p(["size","length0"]),...m(["entries","entries0"],["keys","keys0"],["values","values0"]),...d(["add","add0"],["delete","delete0"]),...b(["add","add3"]),toArray:function(){return[...this]},toJSON:function(){return[...this]}}),u(Date,{new:function(...t){return t.length!=1?new Date(...t):Number.isNaN(+t[0])?new Date(t[0].includes("T")?t[0]:t[0].replace(/-/g,"/")):new Date(t[0]>25e8?t[0]:t[0]*1e3)},format:function(t="y-m-d h:i:s"){return new Date().format(t)},unix:function(){return this.now()/1e3|0},fromUnix:function(t=0){return new Date((t||0)*1e3)},expr:function(t={}){return new Date().expr(t)},toDayRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400-1]},toWeekRange:function(){let t=new Date;for(;t.getDay()!=1;)t=new Date(t.getTime()-86400);const e=t.getFullYear(),n=t.getMonth(),r=t.getDate(),i=new Date(e,n,r).getTime()/1e3|0;return[i,i+86400*7-1]},toMonthRange:function(){const t=new Date,e=t.getFullYear(),n=t.getMonth(),r=new Date(e,n,1).getTime()/1e3|0,i=new Date(e,n+1,0,23,59,59).getTime()/1e3|0;return[r,i]},toYearRange:function(){const e=new Date().getFullYear(),n=new Date(e,1,1).getTime()/1e3|0,r=new Date(e+1,1,0,23,59,59).getTime()/1e3|0;return[n,r]}}),u(Date.prototype,{format:function(t="y-m-d h:i:s"){if(this.getTime()===0)return"-";const e={y:this.getFullYear(),m:this.getMonth()+1,d:this.getDate(),h:this.getHours(),i:this.getMinutes(),s:this.getSeconds(),l:this.getMilliseconds(),e:this.getMonthDay()};return t.replace(/([ymdhisle])/ig,(n,r)=>r>="A"&&r<="Z"?e[r.toLowerCase()]:e[r].toString().padStart(r==="l"?3:2,"0"))},unix:function(){return this.getTime()/1e3|0},isLeapYear:function(){return this.getFullYear()%4===0&&this.getFullYear()%400!==0},getMonthDay:function(){return[31,0,31,30,31,30,31,31,30,31,30,31][this.getMonth()]||(this.isLeapYear()?29:28)},expr:function({y:t=0,m:e=0,d:n=0,h:r=0,i=0,s=0}){const o=new Date(this.getFullYear()+t,this.getMonth()+e+1,0);return new Date(this.getFullYear()+t,this.getMonth()+e,Math.min(o.getDate(),this.getDate())+n,this.getHours()+r,this.getMinutes()+i,this.getSeconds()+s)},begin:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),0,1,0,0,0].slice(t))},end:function(t=3){return new Date(...[this.getFullYear(),this.getMonth(),this.getDate(),this.getHours(),this.getMinutes(),this.getSeconds()].slice(0,t),...[this.getFullYear(),11,t<2?31:this.getMonthDay(),23,59,59].slice(t))},week:function(t,e=1){let n=new Date(this.getTime());for(;n.getDay()!==t;)n=new Date(n.getTime()+864e5*e);return n},toJSON:function(){return this.getTime()}}),u(RegExp,{...g()}),u(RegExp.prototype,{toJSON:function(){return this.toString()}}),u(Promise,{channel:function(){let t=null,e=null;return[new this((r,i)=>{t=r,e=i}),t,e]}}),u(Promise.prototype,{tryCatch:function(){return new Promise(t=>this.then(e=>t([e,null])).catch(e=>t([null,e])))}}),u(JSON,{parse0:function(t,e=null){try{if(typeof t!="string")throw new Error("not string");return JSON.parse(t)}catch{return e}}}),typeof Iterator<"u"&&u(Iterator.prototype,{toArray:function(){return Array.from(this)}}),u(ArrayBuffer.prototype,{toUint8Array:function(){return new Uint8Array(this)}}),typeof Uint8Array.fromBase64>"u"&&(u(Uint8Array,{fromHex:function(t){const e=[];for(let n=0;n<t.length;n+=2)e.push(Number.parseInt(t.substring(n,n+2),16));return new Uint8Array(e)},fromBase64:function(t){const e=[],n={},r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let s=0;s<r.length;s++)n[r.charAt(s)]=s;const i=t.charAt(t.length-1)!="="?t.length:t.charAt(t.length-2)!="="?t.length-1:t.length-2;for(let s=3;s<i;s+=4){const o=(n[t.charAt(s-3)]<<18)+(n[t.charAt(s-2)]<<12)+(n[t.charAt(s-1)]<<6)+n[t.charAt(s)];e.push((o&16711680)>>16,(o&65280)>>8,o&255)}if(i%4==3){const s=(n[t.charAt(i-3)]<<18)+(n[t.charAt(i-2)]<<12)+(n[t.charAt(i-1)]<<6);e.push((s&16711680)>>16,(s&65280)>>8)}else if(i%4==2){const s=(n[t.charAt(i-2)]<<18)+(n[t.charAt(i-1)]<<12);e.push((s&16711680)>>16)}return new Uint8Array(e)}}),u(Uint8Array.prototype,{toHex:function(){let t="";for(let e=0;e<this.length;e++)t+=(this[e]<16?"0":"")+this[e].toString(16);return t},toBase64:function(){let t="",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let n=2;n<this.length;n+=3){const r=(this[n-2]<<16)+(this[n-1]<<8)+this[n];t+=e.charAt((r&16515072)>>18)+e.charAt((r&258048)>>12)+e.charAt((r&4032)>>6)+e.charAt(r&63)}if(this.length%3==2){const n=(this[this.length-2]<<16)+(this[this.length-1]<<8);t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+e.charAt((n&4032)>>6)+"="}else if(this.length%3==1){const n=this[this.length-1]<<16;t+=e.charAt((n&16515072)>>18)+e.charAt((n&258048)>>12)+"=="}return t}})),u(Uint8Array.prototype,{toArray:function(){return new Array(...this)}});let j=0,D=0,F=0;u(Math,{randstr:function(t=16,e=0,n="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",r="~!@#$%^&*()_+`{}|[]\\:\";'<>,.?/"){if(t<e)throw new Error("randstr: len < slen");const i=[];for(let s=0;s<t;s++)i.push(n.charAt(Math.random()*n.length|0));for(let s=new Set,o=0,a=0;a<e;a++){do o=Math.random()*t|0;while(s.has(o));s.set(o,!0),i[o]=r.charAt(Math.random()*r.length|0)}return i.join("")},randint:function(t=0,e=Number.MAX_SAFE_INTEGER){return Math.floor(Math.random()*(e-t)+t)},incrid:function(){return++j},incrstr:function(){return""+Math.incrid()},uniqid:function(t=Date.now()){return t===F?t*2048+ ++D%2048:(F=t)*2048+(D=0)%2048},uniqstr:function(){return""+Math.uniqid()},sleep:function(t){return new Promise(e=>setTimeout(e,t))},useTemplate:function(t){let e=null;const n={setup(i,{slots:s}){return e=s.default,()=>{}},name:t+"Template"},r={setup(i,{attrs:s}){return()=>e==null?void 0:e(s)},name:t};return{[n.name]:n,[r.name]:r}}})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "esexts",
3
- "version": "1.4.1",
3
+ "version": "1.4.2",
4
4
  "description": "esexts",
5
5
  "author": "dotcoo <dotcoo@163.com> (http://blog.dotcoo.com)",
6
6
  "homepage": "https://github.com/dotcoo/esexts#readme",