@tolki/obj 0.0.0-stage → 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/obj.js ADDED
@@ -0,0 +1,1406 @@
1
+ import { SortDirection as cn } from "@tolki/enum";
2
+ import { getNestedValue as q, getObjectValue as I, setObjectValue as d, dotFlatten as Sn, undotExpandObject as En, forgetKeys as xn, hasMixed as un, resolvePluckPath as tn, explodePluckPath as en, isEnumerable as z, isArrayAccess as $n, readPluckKey as An } from "@tolki/path";
3
+ import { randomInt as dn, finish as rn } from "@tolki/str";
4
+ import { createSortSpecComparator as Cn, isObject as O, isPhpAccessible as F, isNull as y, phpTypeName as D, InvalidArgumentException as $, isBoolean as Y, isUndefined as a, keyedEntries as p, phpArrayKey as m, defineKey as h, isFunction as b, isPlainObject as S, isArray as v, isNumber as M, arrayableValues as N, toPhpKeyString as H, isMap as k, isIterable as Mn, arrayableItems as E, isPrototypeObject as U, renumberPhpIntegerKeys as L, looseEqual as W, isPhpFalsy as w, isPhpArrayKey as fn, isWeakMap as Nn, readMapKey as on, isInteger as Ln, phpStringCast as Pn, isSymbol as X, phpComputedKey as Rn, resolveTakeCount as ln, operatorMatch as B, isString as P, isPhpNumeric as Z, arrayValueMessage as Dn, resolveSliceRange as Un, ItemNotFoundException as Q, MultipleItemsFoundException as Fn, phpSortComparator as hn, isFalsy as pn, compareValues as x, reindexIntegerKeys as G, resolveSpliceRange as Wn, cssListItemToString as gn, resolvePadLength as _n, strictEqual as V, phpValueMatcher as yn, phpValueMatch as _, isTruthyObject as Tn, isIllegalOffset as Qn, arrayKeyExistsError as zn, nextIntegerKey as Bn } from "@tolki/utils";
5
+ const mn = Cn(
6
+ (n, t) => q(n, t)
7
+ );
8
+ function l(n) {
9
+ return O(n) && F(n);
10
+ }
11
+ function nn(n) {
12
+ return p(n).map(([t, e]) => [
13
+ m(t),
14
+ e
15
+ ]);
16
+ }
17
+ function an(n) {
18
+ const t = z(n) ? n.all() : n;
19
+ return z(n) && v(t) ? [...t.entries()] : l(t) ? nn(t) : null;
20
+ }
21
+ function R(n, t) {
22
+ if (k(n)) {
23
+ n.clear();
24
+ for (const [r, o] of t)
25
+ n.set(m(r), o);
26
+ return;
27
+ }
28
+ const e = n;
29
+ for (const r of Object.keys(e))
30
+ delete e[r];
31
+ for (const [r, o] of t)
32
+ h(e, r, o);
33
+ }
34
+ function C(n) {
35
+ return k(n) ? bn(n) : n;
36
+ }
37
+ function sn(n, t) {
38
+ let e = Bn(n);
39
+ if (k(n)) {
40
+ const o = new Map(n);
41
+ for (const s of t)
42
+ o.set(e++, s);
43
+ return o;
44
+ }
45
+ const r = { ...n };
46
+ for (const o of t)
47
+ h(r, String(e++), o);
48
+ return r;
49
+ }
50
+ function ut(n) {
51
+ return O(n) && F(n);
52
+ }
53
+ function ft(n, t, e) {
54
+ const r = { ...C(n) };
55
+ return y(I(r, t)) ? d(r, t, e) : r;
56
+ }
57
+ function lt(n, t, e = null) {
58
+ const r = I(n, t, e);
59
+ if (!O(r)) {
60
+ const o = D(r);
61
+ throw new $(
62
+ `Object value for key [${t}] must be an object, ${o} found.`
63
+ );
64
+ }
65
+ return r;
66
+ }
67
+ function ht(n, t, e = null) {
68
+ const r = I(n, t, e);
69
+ if (!Y(r))
70
+ throw new $(
71
+ `Object value for key [${t}] must be a boolean, ${D(r)} found.`
72
+ );
73
+ return r;
74
+ }
75
+ function pt(n, t, e) {
76
+ if (e = a(e) ? !0 : e, t <= 0)
77
+ return {};
78
+ if (!l(n))
79
+ return {};
80
+ const r = p(n), o = {};
81
+ let s = 0;
82
+ for (let i = 0; i < r.length; i += t) {
83
+ const c = r.slice(i, i + t);
84
+ if (e)
85
+ o[s] = Object.fromEntries(c);
86
+ else {
87
+ let u = 0;
88
+ o[s] = Object.fromEntries(
89
+ c.map(([, f]) => {
90
+ const g = [u, f];
91
+ return u += 1, g;
92
+ })
93
+ );
94
+ }
95
+ s++;
96
+ }
97
+ return o;
98
+ }
99
+ function Jn(n, t) {
100
+ const e = {};
101
+ if (!l(n))
102
+ return e;
103
+ let r = {}, o = 0, s = 0;
104
+ for (const [i, c] of p(n)) {
105
+ const u = m(i);
106
+ o > 0 && w(t(c, u, r)) && (e[s] = r, s += 1, r = {}, o = 0), h(r, i, c), o += 1;
107
+ }
108
+ return o > 0 && (e[s] = r), e;
109
+ }
110
+ function gt(n, t) {
111
+ const e = b(t) ? t : (o) => y(t) || a(t) ? o : q(o, t);
112
+ let r;
113
+ return Jn(
114
+ n,
115
+ (o, s, i) => {
116
+ if (r === void 0) {
117
+ const [u, f] = Object.entries(i).at(-1);
118
+ r = {
119
+ key: m(u),
120
+ value: f
121
+ };
122
+ }
123
+ const c = r;
124
+ return r = { key: s, value: o }, W(
125
+ e(o, s),
126
+ e(c.value, c.key)
127
+ );
128
+ }
129
+ );
130
+ }
131
+ function yt(n) {
132
+ const t = {};
133
+ if (y(n) || a(n))
134
+ return t;
135
+ let e = 0;
136
+ for (const [, r] of p(n)) {
137
+ const o = !S(r) && O(r) && b(r.all) ? r.all() : r;
138
+ if (!(!S(o) && !v(o)))
139
+ for (const [s, i] of Object.entries(o))
140
+ M(m(s)) ? (h(
141
+ t,
142
+ e,
143
+ i
144
+ ), e++) : h(t, s, i);
145
+ }
146
+ return t;
147
+ }
148
+ function mt(n, t) {
149
+ const e = N(n).map(
150
+ (i) => H(i)
151
+ ), r = N(t), o = e.length;
152
+ if (o !== r.length)
153
+ throw new Error(
154
+ "array_combine(): Argument #1 ($keys) and argument #2 ($values) must have the same number of elements"
155
+ );
156
+ const s = {};
157
+ for (let i = 0; i < o; i++) {
158
+ const c = e[i];
159
+ h(
160
+ s,
161
+ c,
162
+ r[i]
163
+ );
164
+ }
165
+ return s;
166
+ }
167
+ function at(...n) {
168
+ let t = [{}];
169
+ for (const e of n)
170
+ for (const [r, o] of p(e)) {
171
+ const s = qn(o);
172
+ if (s.length === 0)
173
+ return [];
174
+ const i = [];
175
+ for (const c of t)
176
+ for (const u of s) {
177
+ const f = { ...c };
178
+ h(
179
+ f,
180
+ r,
181
+ u
182
+ ), i.push(f);
183
+ }
184
+ t = i;
185
+ }
186
+ return t;
187
+ }
188
+ function qn(n) {
189
+ return v(n) ? n : k(n) ? [...n.values()] : Mn(n) ? [...n] : O(n) ? Object.values(n) : [];
190
+ }
191
+ function vt(n) {
192
+ if (!l(n))
193
+ return [[], []];
194
+ const t = p(n);
195
+ return [
196
+ t.map(([e]) => m(e)),
197
+ t.map(([, e]) => e)
198
+ ];
199
+ }
200
+ function bt(n, t = "", e = 1 / 0) {
201
+ return l(n) ? Sn(n, t, e) : {};
202
+ }
203
+ function jt(n) {
204
+ return y(n) || a(n) ? {} : En(n);
205
+ }
206
+ function Ot(...n) {
207
+ const [t, ...e] = n, r = {}, o = [
208
+ v(t) || O(t) ? t : {},
209
+ ...e.map(E)
210
+ ];
211
+ for (const s of o)
212
+ for (const [i, c] of Object.entries(s))
213
+ Object.hasOwn(r, i) || h(r, i, c);
214
+ return r;
215
+ }
216
+ function Yn(...n) {
217
+ const [t, ...e] = n;
218
+ if (!l(t)) {
219
+ const r = {};
220
+ return e.forEach((o, s) => {
221
+ r[s] = o;
222
+ }), r;
223
+ }
224
+ return U(t) || R(
225
+ t,
226
+ L([
227
+ ...e.map((r) => ["0", r]),
228
+ ...p(t)
229
+ ])
230
+ ), t;
231
+ }
232
+ function wt(n, t) {
233
+ return vn(n, t);
234
+ }
235
+ function kt(n, t, e = !1) {
236
+ if (y(n) || a(n))
237
+ return {};
238
+ const r = n, o = v(t) ? t : [t], s = {};
239
+ for (const [i, c] of Object.entries(r))
240
+ o.some(
241
+ (f) => e ? c === f : W(c, f)
242
+ ) || h(s, i, c);
243
+ return s;
244
+ }
245
+ function It(n, t) {
246
+ return l(n) ? Object.hasOwn(n, H(t)) : !1;
247
+ }
248
+ function Kt(n, t, e) {
249
+ const r = () => a(e) ? null : b(e) ? e() : e, o = an(n);
250
+ if (y(o))
251
+ return r();
252
+ if (!t)
253
+ return o.length === 0 ? r() : o[0]?.[1];
254
+ for (const [s, i] of o)
255
+ if (!w(t(i, s)))
256
+ return i;
257
+ return r();
258
+ }
259
+ function St(n, t, e) {
260
+ const r = () => a(e) ? null : b(e) ? e() : e, o = an(n);
261
+ if (y(o))
262
+ return r();
263
+ if (!b(t))
264
+ return o.length === 0 ? r() : o[o.length - 1]?.[1];
265
+ let s = !1, i;
266
+ for (let c = o.length - 1; c >= 0; c--) {
267
+ const [u, f] = o[c];
268
+ if (!w(t(f, u))) {
269
+ i = f, s = !0;
270
+ break;
271
+ }
272
+ }
273
+ return s ? i : r();
274
+ }
275
+ function Et(n, t) {
276
+ if (!l(n) || t === 0)
277
+ return {};
278
+ const e = p(n), r = e.length;
279
+ if (r === 0)
280
+ return {};
281
+ let o;
282
+ if (t > 0)
283
+ t >= r ? o = e : o = e.slice(0, t);
284
+ else {
285
+ const i = Math.abs(t);
286
+ i >= r ? o = e : o = e.slice(r - i);
287
+ }
288
+ const s = {};
289
+ for (const [i, c] of o)
290
+ h(s, i, c);
291
+ return s;
292
+ }
293
+ function xt(n, t = 1 / 0) {
294
+ if (!l(n))
295
+ return [];
296
+ const e = [], r = (o, s) => {
297
+ const i = v(o) ? o : p(o).map(([, c]) => c);
298
+ for (const c of i) {
299
+ const u = !S(c) && O(c) && b(c.all) ? c.all() : c;
300
+ if (!v(u) && !S(u))
301
+ e.push(u);
302
+ else if (s === 1) {
303
+ const f = v(u) ? u : Object.values(u);
304
+ for (const g of f)
305
+ e.push(g);
306
+ } else
307
+ r(u, s - 1);
308
+ }
309
+ };
310
+ return r(n, t), e;
311
+ }
312
+ function $t(n, t = 1 / 0) {
313
+ if (!l(n))
314
+ return {};
315
+ const e = {}, r = (s, i, c) => {
316
+ const u = i.length, f = u === 0 ? O(s) : S(s) || k(s), g = v(s);
317
+ if (!f && !g || u >= c) {
318
+ u > 0 && h(e, i.join("."), s);
319
+ return;
320
+ }
321
+ if (g) {
322
+ for (let j = 0; j < s.length; j++)
323
+ r(
324
+ s[j],
325
+ [...i, String(j)],
326
+ c
327
+ );
328
+ return;
329
+ }
330
+ for (const [j, K] of p(s))
331
+ r(K, [...i, String(j)], c);
332
+ }, o = Number.isFinite(t) ? t + 1 : 1 / 0;
333
+ return r(n, [], o), e;
334
+ }
335
+ function At(n) {
336
+ if (!l(n))
337
+ return {};
338
+ const t = {};
339
+ for (const [e, r] of p(n))
340
+ fn(r) && h(t, String(r), m(e));
341
+ return t;
342
+ }
343
+ function dt(n, t, e = null) {
344
+ const r = I(n, t, e);
345
+ if (!M(r))
346
+ throw new $(
347
+ `Object value for key [${t}] must be a float, ${D(r)} found.`
348
+ );
349
+ return r;
350
+ }
351
+ function vn(n, t) {
352
+ return l(n) ? xn(
353
+ C(n),
354
+ t
355
+ ) : {};
356
+ }
357
+ function bn(n) {
358
+ if (k(n)) {
359
+ const t = {};
360
+ for (const [e, r] of p(n))
361
+ h(t, e, r);
362
+ return t;
363
+ }
364
+ if (Nn(n))
365
+ throw new Error(
366
+ "WeakMap values cannot be enumerated in JavaScript; cannot convert to object."
367
+ );
368
+ if (v(n)) {
369
+ const t = {};
370
+ for (let e = 0; e < n.length; e++)
371
+ t[e] = n[e];
372
+ return t;
373
+ }
374
+ if (O(n))
375
+ return { ...n };
376
+ throw new $(
377
+ "Items cannot be represented by a scalar value."
378
+ );
379
+ }
380
+ function Ct(n, t, e = null) {
381
+ if (y(t) || a(t))
382
+ return O(n) ? n : b(e) ? e() : e;
383
+ if (!O(n))
384
+ return b(e) ? e() : e;
385
+ const r = String(t), o = k(n) ? on(n, r) : Object.hasOwn(n, r) ? {
386
+ found: !0,
387
+ value: n[r]
388
+ } : { found: !1 };
389
+ if (o.found)
390
+ return a(o.value) ? b(e) ? e() : e : o.value;
391
+ if (M(t) || !t.includes("."))
392
+ return b(e) ? e() : e;
393
+ const s = String(t).split(".");
394
+ let i = n;
395
+ for (const c of s) {
396
+ if (k(i)) {
397
+ i = on(i, c).value;
398
+ continue;
399
+ }
400
+ if (!O(i) && !v(i))
401
+ return b(e) ? e() : e;
402
+ const u = v(i) ? m(c) : c;
403
+ if (v(i) && !M(u) || !Object.hasOwn(i, u))
404
+ return b(e) ? e() : e;
405
+ i = i[u];
406
+ }
407
+ return a(i) ? b(e) ? e() : e : i;
408
+ }
409
+ function jn(n, t) {
410
+ if (y(t) || a(t))
411
+ return !1;
412
+ const e = v(t) ? t : [t];
413
+ if (!l(n) || e.length === 0)
414
+ return !1;
415
+ for (const r of e)
416
+ if (!un(n, y(r) || a(r) ? "" : r))
417
+ return !1;
418
+ return !0;
419
+ }
420
+ function Mt(n, t) {
421
+ const e = v(t) ? t : [t];
422
+ if (!l(n) || e.length === 0)
423
+ return !1;
424
+ for (const r of e)
425
+ if (!jn(n, r))
426
+ return !1;
427
+ return !0;
428
+ }
429
+ function Nt(n, t) {
430
+ if (y(t))
431
+ return !1;
432
+ const e = v(t) ? t : [t];
433
+ if (e.length === 0 || !l(n))
434
+ return !1;
435
+ for (const r of e)
436
+ if (jn(n, r))
437
+ return !0;
438
+ return !1;
439
+ }
440
+ function Lt(n, t) {
441
+ if (!l(n))
442
+ return !1;
443
+ for (const [e, r] of nn(n))
444
+ if (w(t(r, e)))
445
+ return !1;
446
+ return !0;
447
+ }
448
+ function Pt(n, t) {
449
+ if (!l(n))
450
+ return !1;
451
+ for (const [e, r] of nn(n))
452
+ if (!w(t(r, e)))
453
+ return !0;
454
+ return !1;
455
+ }
456
+ function Rt(n, t, e = null) {
457
+ const r = I(n, t, e);
458
+ if (!Ln(r))
459
+ throw new $(
460
+ `Object value for key [${t}] must be an integer, ${D(r)} found.`
461
+ );
462
+ return r;
463
+ }
464
+ function Dt(n, t, e = "") {
465
+ if (!l(n))
466
+ return "";
467
+ const r = p(n).map(([, c]) => Pn(c));
468
+ if (e === "")
469
+ return r.join(t);
470
+ const o = r.length;
471
+ if (o === 0)
472
+ return "";
473
+ if (o === 1)
474
+ return r[0];
475
+ const s = r.slice(0, -1).join(t), i = r[o - 1];
476
+ return s + e + i;
477
+ }
478
+ function Ut(n, t) {
479
+ if (!l(n))
480
+ return {};
481
+ const e = {};
482
+ for (const [r, o] of p(n)) {
483
+ const s = b(t) ? t(o, m(r)) : I(o, t);
484
+ h(
485
+ e,
486
+ X(s) ? s : m(s),
487
+ o
488
+ );
489
+ }
490
+ return e;
491
+ }
492
+ function Ft(n, t) {
493
+ if (!l(n))
494
+ return {};
495
+ const e = {};
496
+ for (const [r, o] of p(n))
497
+ h(e, t + r, o);
498
+ return e;
499
+ }
500
+ function Wt(n, t) {
501
+ if (!l(n))
502
+ return {};
503
+ const e = {}, r = y(t) ? [] : v(t) ? t : [t], o = new Set(r.filter(fn).map(String));
504
+ for (const [s, i] of p(n))
505
+ o.has(s) && h(e, s, i);
506
+ for (const s of r)
507
+ X(s) && Object.hasOwn(n, s) && h(
508
+ e,
509
+ s,
510
+ n[s]
511
+ );
512
+ return e;
513
+ }
514
+ function _t(n, t, e = !1) {
515
+ if (y(n) || a(n))
516
+ return {};
517
+ const r = n, o = v(t) ? t : [t], s = {};
518
+ for (const [i, c] of Object.entries(r))
519
+ o.some(
520
+ (f) => e ? c === f : W(c, f)
521
+ ) && h(s, i, c);
522
+ return s;
523
+ }
524
+ function Tt(n, t) {
525
+ if (!l(n))
526
+ return {};
527
+ const e = n, r = y(t) || a(t) ? [] : v(t) ? t : [t], o = {};
528
+ for (const [s, i] of Object.entries(e))
529
+ h(
530
+ o,
531
+ s,
532
+ rt(i, r)
533
+ );
534
+ return o;
535
+ }
536
+ function Qt(n, t, e = null) {
537
+ const r = a(t) ? null : t;
538
+ if (!l(n))
539
+ return y(e) || a(e) ? [] : {};
540
+ const o = y(e) || a(e) ? [] : {};
541
+ for (const [, s] of p(n)) {
542
+ let i;
543
+ if (b(r) ? i = r(s) : i = tn(
544
+ s,
545
+ en(
546
+ r
547
+ )
548
+ ), y(e) || a(e)) {
549
+ o.push(i);
550
+ continue;
551
+ }
552
+ const c = b(e) ? e(s) : tn(
553
+ s,
554
+ en(e)
555
+ );
556
+ h(
557
+ o,
558
+ Rn(c, { stringables: !0 }),
559
+ i
560
+ );
561
+ }
562
+ return o;
563
+ }
564
+ function zt(n, t = 1) {
565
+ if (y(n) || !l(n) || U(n))
566
+ return t === 1 ? null : [];
567
+ const e = n, r = p(n);
568
+ if (r.length === 0)
569
+ return t === 1 ? null : [];
570
+ if (t === 1) {
571
+ const [i, c] = r[r.length - 1];
572
+ return k(n) ? R(n, r.slice(0, -1)) : delete e[i], c;
573
+ }
574
+ if (t < 1)
575
+ return [];
576
+ const o = [], s = ln(t, r.length);
577
+ for (let i = 0; i < s; i++) {
578
+ const [c, u] = r[r.length - 1 - i];
579
+ k(n) || delete e[c], o.push(u);
580
+ }
581
+ return k(n) && R(n, r.slice(0, r.length - s)), o;
582
+ }
583
+ function Bt(n, t) {
584
+ if (!l(n))
585
+ return {};
586
+ const e = {};
587
+ for (const [r, o] of p(n))
588
+ h(
589
+ e,
590
+ r,
591
+ t(o, m(r))
592
+ );
593
+ return e;
594
+ }
595
+ function Jt(n, t) {
596
+ if (!l(n))
597
+ return {};
598
+ const e = {};
599
+ for (const [r, o] of p(n)) {
600
+ const s = t(o, m(r));
601
+ for (const [i, c] of Object.entries(s))
602
+ h(
603
+ e,
604
+ i,
605
+ c
606
+ );
607
+ }
608
+ return e;
609
+ }
610
+ function qt(n, t) {
611
+ if (!l(n))
612
+ return {};
613
+ const e = {};
614
+ for (const [r, o] of p(n)) {
615
+ const s = !S(o) && O(o) && b(o.all) ? o.all() : o, i = v(s) ? s : tt(nt(s));
616
+ h(
617
+ e,
618
+ r,
619
+ t(...i, m(r))
620
+ );
621
+ }
622
+ return e;
623
+ }
624
+ function Yt(n, t, ...e) {
625
+ if (e.length === 0)
626
+ return k(n) ? Hn(n, t) : Yn({ ...l(n) ? n : {} }, t);
627
+ const [r] = e, o = {};
628
+ if (h(o, X(r) ? r : m(r), t), l(n))
629
+ for (const [s, i] of p(n))
630
+ Object.hasOwn(o, s) || h(o, s, i);
631
+ return o;
632
+ }
633
+ function Hn(n, t) {
634
+ const e = {};
635
+ let r = 0;
636
+ h(e, r++, t);
637
+ for (const [o, s] of p(n))
638
+ h(
639
+ e,
640
+ M(m(o)) ? r++ : o,
641
+ s
642
+ );
643
+ return e;
644
+ }
645
+ function Ht(n, t, e = null) {
646
+ const r = () => b(e) ? e() : e;
647
+ if (!l(n))
648
+ return { value: r(), data: {} };
649
+ if (y(t)) {
650
+ const c = { ...C(n) };
651
+ return { value: r(), data: c };
652
+ }
653
+ const o = C(n), s = I(o, t);
654
+ if (y(s))
655
+ return { value: r(), data: { ...o } };
656
+ const i = vn(o, t);
657
+ return { value: s, data: i };
658
+ }
659
+ function Xt(n) {
660
+ if (y(n) || a(n))
661
+ return "";
662
+ const t = (o) => encodeURIComponent(o).replace(
663
+ /[!'()*]/g,
664
+ (s) => `%${s.charCodeAt(0).toString(16).toUpperCase()}`
665
+ ), e = (o) => Y(o) ? o ? "1" : "0" : String(o), r = (o, s = "") => {
666
+ const i = [];
667
+ if (v(o))
668
+ for (let c = 0; c < o.length; c++) {
669
+ const u = s ? `${s}[${c}]` : String(c), f = o[c];
670
+ if (!y(f) && !a(f))
671
+ if (v(f) || O(f))
672
+ i.push(...r(f, u));
673
+ else {
674
+ const g = t(u);
675
+ i.push(
676
+ `${g}=${t(e(f))}`
677
+ );
678
+ }
679
+ }
680
+ else if (O(o) && !y(o))
681
+ for (const [c, u] of p(o)) {
682
+ const f = s ? `${s}[${c}]` : c;
683
+ if (!y(u) && !a(u))
684
+ if (v(u) || O(u))
685
+ i.push(...r(u, f));
686
+ else {
687
+ const g = t(f);
688
+ i.push(
689
+ `${g}=${t(e(u))}`
690
+ );
691
+ }
692
+ }
693
+ else {
694
+ const u = t(s || "0");
695
+ i.push(
696
+ `${u}=${t(e(o))}`
697
+ );
698
+ }
699
+ return i;
700
+ };
701
+ return r(n).join("&");
702
+ }
703
+ function Zt(n, t, e = !1) {
704
+ if (!l(n))
705
+ return y(t) || a(t) ? null : {};
706
+ const r = p(n), o = r.length, s = y(t) || a(t) ? 1 : t;
707
+ if (B(s, ">", o))
708
+ throw new $(
709
+ `You requested ${H(s)} items, but there are only ${o} items available.`
710
+ );
711
+ if (o === 0 || B(s, "<=", 0))
712
+ return {};
713
+ const i = Xn(s), c = [], u = Array.from({ length: o }, (g, j) => j);
714
+ for (let g = 0; g < i; g++) {
715
+ const j = dn(0, u.length - 1);
716
+ c.push(u[j]), u.splice(j, 1);
717
+ }
718
+ if (c.sort((g, j) => g - j), y(t) || a(t)) {
719
+ const [, g] = r[c[0]];
720
+ return g;
721
+ }
722
+ const f = {};
723
+ for (let g = 0; g < c.length; g++) {
724
+ const j = c[g], [K, A] = r[j];
725
+ e ? h(f, K, A) : f[g] = A;
726
+ }
727
+ return f;
728
+ }
729
+ function Xn(n) {
730
+ if (P(n) ? !Z(n) : Number.isNaN(n))
731
+ throw new TypeError(
732
+ `Random\\Randomizer::pickArrayKeys(): Argument #2 ($num) must be of type int, ${P(n) ? "string" : "float"} given`
733
+ );
734
+ const t = Math.trunc(Number(n));
735
+ if (t < 1)
736
+ throw new Error(
737
+ "Random\\Randomizer::pickArrayKeys(): Argument #2 ($num) must be between 1 and the number of elements in argument #1 ($array)"
738
+ );
739
+ return t;
740
+ }
741
+ function Gt(n, t = 1) {
742
+ if (t < 0)
743
+ throw new $(
744
+ "Number of shifted items may not be less than zero."
745
+ );
746
+ if (t === 0)
747
+ return [];
748
+ if (!l(n) || U(n))
749
+ return t === 1 ? null : [];
750
+ const e = p(n);
751
+ if (e.length === 0)
752
+ return t === 1 ? null : [];
753
+ const r = ln(t, e.length), o = e.slice(0, r).map(([, s]) => s);
754
+ return R(n, L(e.slice(r))), t === 1 ? o[0] : o;
755
+ }
756
+ function Vt(n, t, e) {
757
+ return y(t) || a(t) ? e : l(n) ? d(
758
+ C(n),
759
+ t,
760
+ e
761
+ ) : {};
762
+ }
763
+ function ne(n, t, ...e) {
764
+ if (!l(n)) {
765
+ if (y(t) || a(t))
766
+ throw new Error(
767
+ "Cannot push to root of non-object data when key is null or undefined"
768
+ );
769
+ return d({}, t, e);
770
+ }
771
+ const r = C(n);
772
+ if (y(t) || a(t))
773
+ return sn(r, e);
774
+ const o = I(r, t);
775
+ if (v(o)) {
776
+ const s = [...o, ...e];
777
+ return d(r, t, s);
778
+ }
779
+ if (k(o) || S(o) && !U(o))
780
+ return d(
781
+ r,
782
+ t,
783
+ sn(o, e)
784
+ );
785
+ if (!un(r, t))
786
+ return d(r, t, [...e]);
787
+ throw new $(Dn(o, t));
788
+ }
789
+ function te(n) {
790
+ if (!l(n))
791
+ return {};
792
+ const t = Object.values(n);
793
+ for (let r = t.length - 1; r > 0; r--) {
794
+ const o = Math.floor(Math.random() * (r + 1));
795
+ [t[r], t[o]] = [t[o], t[r]];
796
+ }
797
+ const e = {};
798
+ return t.forEach((r, o) => {
799
+ e[o] = r;
800
+ }), e;
801
+ }
802
+ function ee(n, t) {
803
+ const e = T(t);
804
+ return Zn(
805
+ n,
806
+ (r, o) => w(e(r, o))
807
+ );
808
+ }
809
+ function Zn(n, t) {
810
+ if (!l(n))
811
+ return {};
812
+ const e = p(n), r = T(t), o = e.findIndex(
813
+ ([s, i]) => w(r(i, m(s)))
814
+ );
815
+ return Kn(
816
+ e.slice(o === -1 ? e.length : o)
817
+ );
818
+ }
819
+ function re(n, t, e = null) {
820
+ if (!l(n))
821
+ return {};
822
+ const r = p(n), { start: o, end: s } = Un(r.length, t, e), i = r.slice(o, s), c = {};
823
+ for (const [u, f] of i)
824
+ h(c, u, f);
825
+ return c;
826
+ }
827
+ function oe(n, t) {
828
+ if (!l(n))
829
+ throw new Q();
830
+ const e = p(n);
831
+ if (e.length === 0)
832
+ throw new Q();
833
+ let r;
834
+ if (t) {
835
+ r = [];
836
+ for (const [s, i] of e)
837
+ w(t(i, m(s))) || r.push([s, i]);
838
+ } else
839
+ r = e;
840
+ const o = r.length;
841
+ if (o === 0)
842
+ throw new Q();
843
+ if (o > 1)
844
+ throw new Fn(o);
845
+ return r[0][1];
846
+ }
847
+ function se(n, t = null) {
848
+ if (!l(n))
849
+ return {};
850
+ let e = p(n);
851
+ if (v(t)) {
852
+ const o = t.map(
853
+ (s) => mn(s, !1)
854
+ );
855
+ e.sort(
856
+ hn(([, s], [, i]) => {
857
+ for (const c of o) {
858
+ const u = c(s, i);
859
+ if (u !== 0)
860
+ return u;
861
+ }
862
+ return 0;
863
+ })
864
+ );
865
+ } else pn(t) ? e.sort(([, o], [, s]) => x(o, s)) : P(t) ? e.sort(
866
+ ([, o], [, s]) => x(
867
+ I(o, t),
868
+ I(s, t)
869
+ )
870
+ ) : b(t) && (e = e.map(([o, s]) => ({
871
+ key: o,
872
+ value: s,
873
+ sortKey: t(s, m(o))
874
+ })).sort((o, s) => x(o.sortKey, s.sortKey)).map(({ key: o, value: s }) => [o, s]));
875
+ const r = {};
876
+ for (const [o, s] of G(e))
877
+ h(r, o, s);
878
+ return r;
879
+ }
880
+ function ie(n, t) {
881
+ if (!l(n))
882
+ return {};
883
+ let e = p(n);
884
+ if (v(t)) {
885
+ const o = t.map(
886
+ (s) => mn(s, !0)
887
+ );
888
+ e.sort(
889
+ hn(([, s], [, i]) => {
890
+ for (const c of o) {
891
+ const u = c(s, i);
892
+ if (u !== 0)
893
+ return u;
894
+ }
895
+ return 0;
896
+ })
897
+ );
898
+ } else pn(t) ? e.sort(([, o], [, s]) => x(s, o)) : P(t) ? e.sort(
899
+ ([, o], [, s]) => x(
900
+ I(s, t),
901
+ I(o, t)
902
+ )
903
+ ) : b(t) && (e = e.map(([o, s]) => ({
904
+ key: o,
905
+ value: s,
906
+ sortKey: t(s, m(o))
907
+ })).sort((o, s) => x(s.sortKey, o.sortKey)).map(({ key: o, value: s }) => [o, s]));
908
+ const r = {};
909
+ for (const [o, s] of G(e))
910
+ h(r, o, s);
911
+ return r;
912
+ }
913
+ function On(n, t = !1) {
914
+ const e = t === !0 || t === cn.Descending;
915
+ if (!l(n))
916
+ return {};
917
+ const r = (u) => e ? -u : u, o = (u) => v(u) ? u.map(o).sort((f, g) => r(x(f, g))) : S(u) ? On(u, e) : u, s = p(n).map(
918
+ ([u, f]) => [u, o(f)]
919
+ ), i = s.every(([u], f) => u === String(f)), c = {};
920
+ if (i)
921
+ return s.sort(([, u], [, f]) => r(x(u, f))), s.forEach(([, u], f) => {
922
+ h(c, String(f), u);
923
+ }), c;
924
+ s.sort(
925
+ ([u], [f]) => r(x(m(u), m(f)))
926
+ );
927
+ for (const [u, f] of s)
928
+ h(c, u, f);
929
+ return c;
930
+ }
931
+ function ce(n) {
932
+ return On(n, cn.Descending);
933
+ }
934
+ function ue(n, t, e, ...r) {
935
+ if (!l(n) || U(n))
936
+ return {};
937
+ const o = p(n), { start: s, count: i } = Wn(
938
+ o.length,
939
+ t,
940
+ e
941
+ ), c = o.slice(0, s), u = o.slice(s, s + i), f = o.slice(s + i), g = [];
942
+ for (const K of r) {
943
+ if (l(K) || v(K)) {
944
+ for (const [, A] of p(K))
945
+ g.push(["0", A]);
946
+ continue;
947
+ }
948
+ g.push(["0", K]);
949
+ }
950
+ R(
951
+ n,
952
+ L([
953
+ ...c,
954
+ ...g,
955
+ ...f
956
+ ])
957
+ );
958
+ const j = {};
959
+ for (const [K, A] of L(u))
960
+ h(j, K, A);
961
+ return j;
962
+ }
963
+ function Gn(n, t) {
964
+ if (!l(n))
965
+ return {};
966
+ const e = p(n), r = T(t), o = e.findIndex(
967
+ ([s, i]) => !w(r(i, m(s)))
968
+ );
969
+ return Kn(
970
+ e.slice(0, o === -1 ? e.length : o)
971
+ );
972
+ }
973
+ function fe(n, t) {
974
+ const e = T(t);
975
+ return Gn(
976
+ n,
977
+ (r, o) => w(e(r, o))
978
+ );
979
+ }
980
+ function le(n, t, e = null) {
981
+ const r = I(n, t, e);
982
+ if (!P(r))
983
+ throw new $(
984
+ `Object value for key [${t}] must be a string, ${D(r)} found.`
985
+ );
986
+ return r;
987
+ }
988
+ function he(n) {
989
+ if (!l(n))
990
+ return "";
991
+ const t = [];
992
+ for (const [e, r] of p(n))
993
+ Z(e) ? t.push(gn(r)) : w(r) || t.push(e);
994
+ return t.join(" ");
995
+ }
996
+ function pe(n) {
997
+ if (!l(n))
998
+ return "";
999
+ const t = [];
1000
+ for (const [e, r] of p(n))
1001
+ Z(e) ? t.push(rn(gn(r), ";")) : w(r) || t.push(rn(e, ";"));
1002
+ return t.join(" ");
1003
+ }
1004
+ function wn(n, t) {
1005
+ if (!l(n))
1006
+ return {};
1007
+ const e = {};
1008
+ for (const [r, o] of p(n))
1009
+ w(t(o, m(r))) || h(e, r, o);
1010
+ return e;
1011
+ }
1012
+ function ge(n, t) {
1013
+ return wn(
1014
+ n,
1015
+ (e, r) => w(t(e, r))
1016
+ );
1017
+ }
1018
+ function ye(n, t) {
1019
+ const e = {
1020
+ ...n
1021
+ }, r = E(t);
1022
+ for (const [o, s] of Object.entries(r))
1023
+ h(e, o, s);
1024
+ return e;
1025
+ }
1026
+ function me(n, t) {
1027
+ return kn(
1028
+ n,
1029
+ E(t)
1030
+ );
1031
+ }
1032
+ function kn(n, t) {
1033
+ const r = { ...n };
1034
+ for (const [o, s] of Object.entries(t)) {
1035
+ if (o === "__proto__")
1036
+ continue;
1037
+ const i = r[o];
1038
+ if ((v(s) || S(s)) && (v(i) || S(i))) {
1039
+ const c = kn(i, s), u = (v(i) || v(s)) && Object.keys(c).every(
1040
+ (f, g) => f === String(g)
1041
+ );
1042
+ h(r, o, u ? Object.values(c) : c);
1043
+ } else
1044
+ h(r, o, s);
1045
+ }
1046
+ return r;
1047
+ }
1048
+ function ae(n) {
1049
+ if (!l(n))
1050
+ return {};
1051
+ const t = p(n);
1052
+ t.reverse();
1053
+ const e = {};
1054
+ for (const [r, o] of G(t))
1055
+ h(e, r, o);
1056
+ return e;
1057
+ }
1058
+ function ve(n, t, e) {
1059
+ const r = _n(t);
1060
+ if (!l(n))
1061
+ return {};
1062
+ const o = p(n), s = o.length;
1063
+ if (Math.abs(r) <= s)
1064
+ return k(n) ? bn(n) : { ...n };
1065
+ const i = Math.abs(r) - s, c = [];
1066
+ for (let g = 0; g < i; g++)
1067
+ c.push(["0", e]);
1068
+ const u = r > 0 ? [...o, ...c] : [...c, ...o], f = {};
1069
+ for (const [g, j] of L(u))
1070
+ h(f, g, j);
1071
+ return f;
1072
+ }
1073
+ function be(n, t) {
1074
+ if (!l(n))
1075
+ return [{}, {}];
1076
+ const e = {}, r = {};
1077
+ for (const [o, s] of p(n))
1078
+ w(t(s, m(o))) ? h(r, o, s) : h(e, o, s);
1079
+ return [e, r];
1080
+ }
1081
+ function je(n) {
1082
+ return wn(
1083
+ n,
1084
+ (t) => !y(t)
1085
+ );
1086
+ }
1087
+ function J(n, t, ...e) {
1088
+ const [r, o] = e;
1089
+ if (e.length > 1 || e.length === 1 && !Y(r) && !a(r)) {
1090
+ const c = e.length > 1 ? String(r) : "=";
1091
+ return J(
1092
+ n,
1093
+ Vn(
1094
+ t,
1095
+ c,
1096
+ e.length > 1 ? o : r
1097
+ )
1098
+ );
1099
+ }
1100
+ const s = r === !0;
1101
+ if (!l(n))
1102
+ return !1;
1103
+ const i = p(n);
1104
+ if (b(t)) {
1105
+ for (const [c, u] of i)
1106
+ if (!w(t(u, m(c))))
1107
+ return !0;
1108
+ return !1;
1109
+ }
1110
+ if (s)
1111
+ return i.some(([, c]) => V(c, t));
1112
+ for (const [, c] of i)
1113
+ if (W(c, t))
1114
+ return !0;
1115
+ return !1;
1116
+ }
1117
+ function In(n, t) {
1118
+ return y(t) || a(t) ? n : q(n, t) ?? null;
1119
+ }
1120
+ function Vn(n, t, e) {
1121
+ return b(n) ? n : (r) => B(In(r, n), t, e);
1122
+ }
1123
+ function Oe(n, t, e) {
1124
+ return a(e) ? J(n, t, !0) : J(
1125
+ n,
1126
+ (r) => V(In(r, t), e)
1127
+ );
1128
+ }
1129
+ function we(n, t) {
1130
+ if (!l(n))
1131
+ return {};
1132
+ const e = {};
1133
+ for (const [r, o] of p(n)) {
1134
+ const s = b(t) ? t(o, m(r)) : o;
1135
+ w(s) || h(e, r, o);
1136
+ }
1137
+ return e;
1138
+ }
1139
+ function nt(n) {
1140
+ return y(n) ? {} : O(n) && F(n) ? n : { 0: n };
1141
+ }
1142
+ function ke(n) {
1143
+ return l(n) ? (k(n) ? p(n).map(([e]) => e) : Object.keys(n)).map(m) : [];
1144
+ }
1145
+ function tt(n) {
1146
+ return l(n) ? p(n).map(([, t]) => t) : [];
1147
+ }
1148
+ function Ie(n, t) {
1149
+ if (!l(n))
1150
+ return {};
1151
+ const e = n, r = N(t), o = yn(r), s = {};
1152
+ for (const [i, c] of Object.entries(e))
1153
+ o(c) || h(s, i, c);
1154
+ return s;
1155
+ }
1156
+ function Ke(n, t) {
1157
+ if (!l(n))
1158
+ return {};
1159
+ const e = n, r = E(t), o = {};
1160
+ for (const [s, i] of Object.entries(e))
1161
+ (!Object.hasOwn(r, s) || !_(r[s], i)) && h(o, s, i);
1162
+ return o;
1163
+ }
1164
+ function Se(n, t) {
1165
+ if (!l(n))
1166
+ return {};
1167
+ const e = n, r = E(t), o = {};
1168
+ for (const [s, i] of Object.entries(e))
1169
+ Object.hasOwn(r, s) || h(o, s, i);
1170
+ return o;
1171
+ }
1172
+ function Ee(n, t, e) {
1173
+ const r = {};
1174
+ if (!l(n))
1175
+ return r;
1176
+ const o = N(t);
1177
+ for (const [s, i] of Object.entries(
1178
+ n
1179
+ ))
1180
+ o.some((c) => e(i, c)) || h(r, s, i);
1181
+ return r;
1182
+ }
1183
+ function xe(n, t, e) {
1184
+ if (!l(n))
1185
+ return {};
1186
+ const r = n, o = E(t), s = {}, i = Object.keys(o);
1187
+ for (const [c, u] of Object.entries(r)) {
1188
+ const f = i.find(
1189
+ (g) => e(
1190
+ m(String(c)),
1191
+ m(String(g))
1192
+ )
1193
+ );
1194
+ (f === void 0 || !_(o[f], u)) && h(s, c, u);
1195
+ }
1196
+ return s;
1197
+ }
1198
+ function $e(n, t, e) {
1199
+ if (!l(n))
1200
+ return {};
1201
+ const r = n, o = E(t), s = {}, i = Object.keys(o);
1202
+ for (const [c, u] of Object.entries(r))
1203
+ i.find(
1204
+ (g) => e(
1205
+ m(String(c)),
1206
+ m(String(g))
1207
+ )
1208
+ ) === void 0 && h(s, c, u);
1209
+ return s;
1210
+ }
1211
+ function et(n, t, e = null) {
1212
+ const r = {};
1213
+ if (!l(n))
1214
+ return r;
1215
+ const o = N(t), s = Object.entries(n);
1216
+ if (b(e)) {
1217
+ for (const [c, u] of s)
1218
+ o.some(
1219
+ (f) => e(u, f)
1220
+ ) && h(r, c, u);
1221
+ return r;
1222
+ }
1223
+ const i = yn(o);
1224
+ for (const [c, u] of s)
1225
+ i(u) && h(r, c, u);
1226
+ return r;
1227
+ }
1228
+ function Ae(n, t, e) {
1229
+ return et(
1230
+ n,
1231
+ t,
1232
+ e
1233
+ );
1234
+ }
1235
+ function de(n, t) {
1236
+ const e = {};
1237
+ if (!l(n))
1238
+ return e;
1239
+ const r = E(t);
1240
+ for (const [o, s] of Object.entries(
1241
+ n
1242
+ ))
1243
+ Object.hasOwn(r, o) && _(
1244
+ s,
1245
+ r[o]
1246
+ ) && h(e, o, s);
1247
+ return e;
1248
+ }
1249
+ function Ce(n, t, e) {
1250
+ const r = {};
1251
+ if (!l(n))
1252
+ return r;
1253
+ const o = E(t);
1254
+ for (const [s, i] of Object.entries(
1255
+ n
1256
+ ))
1257
+ for (const [c, u] of Object.entries(o))
1258
+ if (e(m(s), m(c)) && _(i, u)) {
1259
+ h(
1260
+ r,
1261
+ s,
1262
+ i
1263
+ );
1264
+ break;
1265
+ }
1266
+ return r;
1267
+ }
1268
+ function Me(n, t) {
1269
+ const e = {};
1270
+ if (!l(n))
1271
+ return e;
1272
+ const r = E(t);
1273
+ for (const [o, s] of Object.entries(
1274
+ n
1275
+ ))
1276
+ Object.hasOwn(r, o) && h(e, o, s);
1277
+ return e;
1278
+ }
1279
+ function rt(n, t) {
1280
+ const e = {};
1281
+ if (!Tn(n))
1282
+ return e;
1283
+ const r = new Map(z(n) ? [] : p(n)), o = F(n);
1284
+ for (const s of t) {
1285
+ if (Qn(s)) {
1286
+ if (o)
1287
+ throw zn();
1288
+ continue;
1289
+ }
1290
+ const i = y(s) || a(s) ? "" : String(s);
1291
+ if ($n(n)) {
1292
+ const [u, f] = An(n, i);
1293
+ if (u) {
1294
+ h(e, i, f);
1295
+ continue;
1296
+ }
1297
+ }
1298
+ const c = r.get(i);
1299
+ r.has(i) && (o || !(y(c) || a(c))) && h(e, i, c);
1300
+ }
1301
+ return e;
1302
+ }
1303
+ function T(n) {
1304
+ return b(n) ? n : (t) => V(t, n);
1305
+ }
1306
+ function Kn(n) {
1307
+ const t = {};
1308
+ for (const [e, r] of n)
1309
+ h(t, e, r);
1310
+ return t;
1311
+ }
1312
+ export {
1313
+ l as accessible,
1314
+ ft as add,
1315
+ ht as boolean,
1316
+ pt as chunk,
1317
+ gt as chunkBy,
1318
+ Jn as chunkWhile,
1319
+ yt as collapse,
1320
+ mt as combine,
1321
+ J as contains,
1322
+ Oe as containsStrict,
1323
+ at as crossJoin,
1324
+ Ie as diff,
1325
+ Ke as diffAssoc,
1326
+ xe as diffAssocUsing,
1327
+ Se as diffKeys,
1328
+ $e as diffKeysUsing,
1329
+ Ee as diffUsing,
1330
+ vt as divide,
1331
+ bt as dot,
1332
+ Lt as every,
1333
+ wt as except,
1334
+ kt as exceptValues,
1335
+ It as exists,
1336
+ we as filter,
1337
+ Kt as first,
1338
+ xt as flatten,
1339
+ $t as flattenDot,
1340
+ At as flip,
1341
+ dt as float,
1342
+ vn as forget,
1343
+ bn as from,
1344
+ Ct as get,
1345
+ jn as has,
1346
+ Mt as hasAll,
1347
+ Nt as hasAny,
1348
+ Rt as integer,
1349
+ et as intersect,
1350
+ de as intersectAssoc,
1351
+ Ce as intersectAssocUsing,
1352
+ Me as intersectByKeys,
1353
+ Ae as intersectUsing,
1354
+ Dt as join,
1355
+ Ut as keyBy,
1356
+ ke as keys,
1357
+ St as last,
1358
+ Bt as map,
1359
+ qt as mapSpread,
1360
+ Jt as mapWithKeys,
1361
+ lt as objectItem,
1362
+ ut as objectifiable,
1363
+ Wt as only,
1364
+ _t as onlyValues,
1365
+ ve as pad,
1366
+ be as partition,
1367
+ Qt as pluck,
1368
+ zt as pop,
1369
+ Yt as prepend,
1370
+ Ft as prependKeysWith,
1371
+ Ht as pull,
1372
+ ne as push,
1373
+ Xt as query,
1374
+ Zt as random,
1375
+ ge as reject,
1376
+ ye as replace,
1377
+ me as replaceRecursive,
1378
+ ae as reverse,
1379
+ Tt as select,
1380
+ Vt as set,
1381
+ Gt as shift,
1382
+ te as shuffle,
1383
+ ee as skipUntil,
1384
+ Zn as skipWhile,
1385
+ re as slice,
1386
+ oe as sole,
1387
+ Pt as some,
1388
+ se as sort,
1389
+ ie as sortDesc,
1390
+ On as sortRecursive,
1391
+ ce as sortRecursiveDesc,
1392
+ ue as splice,
1393
+ le as string,
1394
+ Et as take,
1395
+ Gn as takeUntil,
1396
+ fe as takeWhile,
1397
+ he as toCssClasses,
1398
+ pe as toCssStyles,
1399
+ jt as undot,
1400
+ Ot as union,
1401
+ Yn as unshift,
1402
+ tt as values,
1403
+ wn as where,
1404
+ je as whereNotNull,
1405
+ nt as wrap
1406
+ };