rxfy 0.1.2 → 0.2.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/index.js CHANGED
@@ -1,2 +1,4946 @@
1
- function e(){return"The lib will be there very soon!"}export{e as helloWorld};
2
- //# sourceMappingURL=index.js.map
1
+ // src/atom/atom.ts
2
+ import { Observable, BehaviorSubject } from "rxjs";
3
+ var Atom = class extends Observable {
4
+ constructor(value) {
5
+ const subject$ = new BehaviorSubject(value);
6
+ super((subscriber) => {
7
+ const sub = subject$.subscribe(subscriber);
8
+ return () => sub.unsubscribe();
9
+ });
10
+ this.get = () => this.subject$.getValue();
11
+ this.set = (val) => this.subject$.next(val);
12
+ this.modify = (fn) => this.set(fn(this.get()));
13
+ this.subject$ = subject$;
14
+ }
15
+ };
16
+ function createAtom(value) {
17
+ return new Atom(value);
18
+ }
19
+
20
+ // src/edge/edge.ts
21
+ import { catchError, EMPTY, lastValueFrom, map, of, switchMap, take, tap, throwError } from "rxjs";
22
+
23
+ // src/wrapped/wrapped.ts
24
+ var StatusEnum = /* @__PURE__ */ ((StatusEnum2) => {
25
+ StatusEnum2["IDLE"] = "IDLE";
26
+ StatusEnum2["PENDING"] = "PENDING";
27
+ StatusEnum2["FULFILLED"] = "FULFILLED";
28
+ StatusEnum2["REJECTED"] = "REJECTED";
29
+ return StatusEnum2;
30
+ })(StatusEnum || {});
31
+ function createIdle() {
32
+ return {
33
+ type: "IDLE" /* IDLE */
34
+ };
35
+ }
36
+ function createPending() {
37
+ return {
38
+ type: "PENDING" /* PENDING */
39
+ };
40
+ }
41
+ function createFulfilled(value) {
42
+ return {
43
+ type: "FULFILLED" /* FULFILLED */,
44
+ value
45
+ };
46
+ }
47
+ function createRejected(error) {
48
+ return {
49
+ type: "REJECTED" /* REJECTED */,
50
+ error
51
+ };
52
+ }
53
+
54
+ // src/edge/edge.ts
55
+ function toBranded(brand, value) {
56
+ return { value, brand };
57
+ }
58
+ function isBranded(brand, val) {
59
+ return val && typeof val === "object" && val.brand === brand;
60
+ }
61
+ function createEdge(state$, queue, loader) {
62
+ const load = () => {
63
+ state$.set(createPending());
64
+ return lastValueFrom(
65
+ loader().pipe(
66
+ map((x) => createFulfilled(x)),
67
+ catchError((x) => of(createRejected(x))),
68
+ tap((x) => state$.set(x)),
69
+ take(1)
70
+ )
71
+ );
72
+ };
73
+ queue.add(async () => {
74
+ const value = state$.get();
75
+ if (value.type === "IDLE" /* IDLE */) {
76
+ await load();
77
+ }
78
+ });
79
+ return {
80
+ subject$: state$,
81
+ toObservable: () => state$.pipe(
82
+ switchMap((x) => {
83
+ switch (x.type) {
84
+ case "FULFILLED" /* FULFILLED */:
85
+ return of(x.value);
86
+ case "REJECTED" /* REJECTED */:
87
+ return throwError(() => x.error);
88
+ default:
89
+ return EMPTY;
90
+ }
91
+ })
92
+ ),
93
+ next: () => load()
94
+ };
95
+ }
96
+
97
+ // ../../../node_modules/.pnpm/immutable@5.1.1/node_modules/immutable/dist/immutable.es.js
98
+ var DELETE = "delete";
99
+ var SHIFT = 5;
100
+ var SIZE = 1 << SHIFT;
101
+ var MASK = SIZE - 1;
102
+ var NOT_SET = {};
103
+ function MakeRef() {
104
+ return { value: false };
105
+ }
106
+ function SetRef(ref) {
107
+ if (ref) {
108
+ ref.value = true;
109
+ }
110
+ }
111
+ function OwnerID() {
112
+ }
113
+ function ensureSize(iter) {
114
+ if (iter.size === void 0) {
115
+ iter.size = iter.__iterate(returnTrue);
116
+ }
117
+ return iter.size;
118
+ }
119
+ function wrapIndex(iter, index) {
120
+ if (typeof index !== "number") {
121
+ var uint32Index = index >>> 0;
122
+ if ("" + uint32Index !== index || uint32Index === 4294967295) {
123
+ return NaN;
124
+ }
125
+ index = uint32Index;
126
+ }
127
+ return index < 0 ? ensureSize(iter) + index : index;
128
+ }
129
+ function returnTrue() {
130
+ return true;
131
+ }
132
+ function wholeSlice(begin, end, size) {
133
+ return (begin === 0 && !isNeg(begin) || size !== void 0 && begin <= -size) && (end === void 0 || size !== void 0 && end >= size);
134
+ }
135
+ function resolveBegin(begin, size) {
136
+ return resolveIndex(begin, size, 0);
137
+ }
138
+ function resolveEnd(end, size) {
139
+ return resolveIndex(end, size, size);
140
+ }
141
+ function resolveIndex(index, size, defaultIndex) {
142
+ return index === void 0 ? defaultIndex : isNeg(index) ? size === Infinity ? size : Math.max(0, size + index) | 0 : size === void 0 || size === index ? index : Math.min(size, index) | 0;
143
+ }
144
+ function isNeg(value) {
145
+ return value < 0 || value === 0 && 1 / value === -Infinity;
146
+ }
147
+ var IS_COLLECTION_SYMBOL = "@@__IMMUTABLE_ITERABLE__@@";
148
+ function isCollection(maybeCollection) {
149
+ return Boolean(maybeCollection && // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection`
150
+ maybeCollection[IS_COLLECTION_SYMBOL]);
151
+ }
152
+ var IS_KEYED_SYMBOL = "@@__IMMUTABLE_KEYED__@@";
153
+ function isKeyed(maybeKeyed) {
154
+ return Boolean(maybeKeyed && // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed`
155
+ maybeKeyed[IS_KEYED_SYMBOL]);
156
+ }
157
+ var IS_INDEXED_SYMBOL = "@@__IMMUTABLE_INDEXED__@@";
158
+ function isIndexed(maybeIndexed) {
159
+ return Boolean(maybeIndexed && // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed`
160
+ maybeIndexed[IS_INDEXED_SYMBOL]);
161
+ }
162
+ function isAssociative(maybeAssociative) {
163
+ return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
164
+ }
165
+ var Collection = function Collection2(value) {
166
+ return isCollection(value) ? value : Seq(value);
167
+ };
168
+ var KeyedCollection = /* @__PURE__ */ function(Collection3) {
169
+ function KeyedCollection2(value) {
170
+ return isKeyed(value) ? value : KeyedSeq(value);
171
+ }
172
+ if (Collection3) KeyedCollection2.__proto__ = Collection3;
173
+ KeyedCollection2.prototype = Object.create(Collection3 && Collection3.prototype);
174
+ KeyedCollection2.prototype.constructor = KeyedCollection2;
175
+ return KeyedCollection2;
176
+ }(Collection);
177
+ var IndexedCollection = /* @__PURE__ */ function(Collection3) {
178
+ function IndexedCollection2(value) {
179
+ return isIndexed(value) ? value : IndexedSeq(value);
180
+ }
181
+ if (Collection3) IndexedCollection2.__proto__ = Collection3;
182
+ IndexedCollection2.prototype = Object.create(Collection3 && Collection3.prototype);
183
+ IndexedCollection2.prototype.constructor = IndexedCollection2;
184
+ return IndexedCollection2;
185
+ }(Collection);
186
+ var SetCollection = /* @__PURE__ */ function(Collection3) {
187
+ function SetCollection2(value) {
188
+ return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
189
+ }
190
+ if (Collection3) SetCollection2.__proto__ = Collection3;
191
+ SetCollection2.prototype = Object.create(Collection3 && Collection3.prototype);
192
+ SetCollection2.prototype.constructor = SetCollection2;
193
+ return SetCollection2;
194
+ }(Collection);
195
+ Collection.Keyed = KeyedCollection;
196
+ Collection.Indexed = IndexedCollection;
197
+ Collection.Set = SetCollection;
198
+ var IS_SEQ_SYMBOL = "@@__IMMUTABLE_SEQ__@@";
199
+ function isSeq(maybeSeq) {
200
+ return Boolean(maybeSeq && // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq`
201
+ maybeSeq[IS_SEQ_SYMBOL]);
202
+ }
203
+ var IS_RECORD_SYMBOL = "@@__IMMUTABLE_RECORD__@@";
204
+ function isRecord(maybeRecord) {
205
+ return Boolean(maybeRecord && // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord`
206
+ maybeRecord[IS_RECORD_SYMBOL]);
207
+ }
208
+ function isImmutable(maybeImmutable) {
209
+ return isCollection(maybeImmutable) || isRecord(maybeImmutable);
210
+ }
211
+ var IS_ORDERED_SYMBOL = "@@__IMMUTABLE_ORDERED__@@";
212
+ function isOrdered(maybeOrdered) {
213
+ return Boolean(maybeOrdered && // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered`
214
+ maybeOrdered[IS_ORDERED_SYMBOL]);
215
+ }
216
+ var ITERATE_KEYS = 0;
217
+ var ITERATE_VALUES = 1;
218
+ var ITERATE_ENTRIES = 2;
219
+ var REAL_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
220
+ var FAUX_ITERATOR_SYMBOL = "@@iterator";
221
+ var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
222
+ var Iterator = function Iterator2(next) {
223
+ this.next = next;
224
+ };
225
+ Iterator.prototype.toString = function toString() {
226
+ return "[Iterator]";
227
+ };
228
+ Iterator.KEYS = ITERATE_KEYS;
229
+ Iterator.VALUES = ITERATE_VALUES;
230
+ Iterator.ENTRIES = ITERATE_ENTRIES;
231
+ Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
232
+ return this.toString();
233
+ };
234
+ Iterator.prototype[ITERATOR_SYMBOL] = function() {
235
+ return this;
236
+ };
237
+ function iteratorValue(type, k, v, iteratorResult) {
238
+ var value = type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v];
239
+ iteratorResult ? iteratorResult.value = value : iteratorResult = {
240
+ value,
241
+ done: false
242
+ };
243
+ return iteratorResult;
244
+ }
245
+ function iteratorDone() {
246
+ return { value: void 0, done: true };
247
+ }
248
+ function hasIterator(maybeIterable) {
249
+ if (Array.isArray(maybeIterable)) {
250
+ return true;
251
+ }
252
+ return !!getIteratorFn(maybeIterable);
253
+ }
254
+ function isIterator(maybeIterator) {
255
+ return maybeIterator && typeof maybeIterator.next === "function";
256
+ }
257
+ function getIterator(iterable) {
258
+ var iteratorFn = getIteratorFn(iterable);
259
+ return iteratorFn && iteratorFn.call(iterable);
260
+ }
261
+ function getIteratorFn(iterable) {
262
+ var iteratorFn = iterable && (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL] || iterable[FAUX_ITERATOR_SYMBOL]);
263
+ if (typeof iteratorFn === "function") {
264
+ return iteratorFn;
265
+ }
266
+ }
267
+ function isEntriesIterable(maybeIterable) {
268
+ var iteratorFn = getIteratorFn(maybeIterable);
269
+ return iteratorFn && iteratorFn === maybeIterable.entries;
270
+ }
271
+ function isKeysIterable(maybeIterable) {
272
+ var iteratorFn = getIteratorFn(maybeIterable);
273
+ return iteratorFn && iteratorFn === maybeIterable.keys;
274
+ }
275
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
276
+ function isArrayLike(value) {
277
+ if (Array.isArray(value) || typeof value === "string") {
278
+ return true;
279
+ }
280
+ return value && typeof value === "object" && // @ts-expect-error check that `'length' in value &&`
281
+ Number.isInteger(value.length) && // @ts-expect-error check that `'length' in value &&`
282
+ value.length >= 0 && // @ts-expect-error check that `'length' in value &&`
283
+ (value.length === 0 ? (
284
+ // Only {length: 0} is considered Array-like.
285
+ Object.keys(value).length === 1
286
+ ) : (
287
+ // An object is only Array-like if it has a property where the last value
288
+ // in the array-like may be found (which could be undefined).
289
+ // @ts-expect-error check that `'length' in value &&`
290
+ value.hasOwnProperty(value.length - 1)
291
+ ));
292
+ }
293
+ var Seq = /* @__PURE__ */ function(Collection3) {
294
+ function Seq2(value) {
295
+ return value === void 0 || value === null ? emptySequence() : isImmutable(value) ? value.toSeq() : seqFromValue(value);
296
+ }
297
+ if (Collection3) Seq2.__proto__ = Collection3;
298
+ Seq2.prototype = Object.create(Collection3 && Collection3.prototype);
299
+ Seq2.prototype.constructor = Seq2;
300
+ Seq2.prototype.toSeq = function toSeq3() {
301
+ return this;
302
+ };
303
+ Seq2.prototype.toString = function toString5() {
304
+ return this.__toString("Seq {", "}");
305
+ };
306
+ Seq2.prototype.cacheResult = function cacheResult() {
307
+ if (!this._cache && this.__iterateUncached) {
308
+ this._cache = this.entrySeq().toArray();
309
+ this.size = this._cache.length;
310
+ }
311
+ return this;
312
+ };
313
+ Seq2.prototype.__iterate = function __iterate2(fn, reverse3) {
314
+ var cache = this._cache;
315
+ if (cache) {
316
+ var size = cache.length;
317
+ var i = 0;
318
+ while (i !== size) {
319
+ var entry = cache[reverse3 ? size - ++i : i++];
320
+ if (fn(entry[1], entry[0], this) === false) {
321
+ break;
322
+ }
323
+ }
324
+ return i;
325
+ }
326
+ return this.__iterateUncached(fn, reverse3);
327
+ };
328
+ Seq2.prototype.__iterator = function __iterator2(type, reverse3) {
329
+ var cache = this._cache;
330
+ if (cache) {
331
+ var size = cache.length;
332
+ var i = 0;
333
+ return new Iterator(function() {
334
+ if (i === size) {
335
+ return iteratorDone();
336
+ }
337
+ var entry = cache[reverse3 ? size - ++i : i++];
338
+ return iteratorValue(type, entry[0], entry[1]);
339
+ });
340
+ }
341
+ return this.__iteratorUncached(type, reverse3);
342
+ };
343
+ return Seq2;
344
+ }(Collection);
345
+ var KeyedSeq = /* @__PURE__ */ function(Seq2) {
346
+ function KeyedSeq2(value) {
347
+ return value === void 0 || value === null ? emptySequence().toKeyedSeq() : isCollection(value) ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq() : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value);
348
+ }
349
+ if (Seq2) KeyedSeq2.__proto__ = Seq2;
350
+ KeyedSeq2.prototype = Object.create(Seq2 && Seq2.prototype);
351
+ KeyedSeq2.prototype.constructor = KeyedSeq2;
352
+ KeyedSeq2.prototype.toKeyedSeq = function toKeyedSeq3() {
353
+ return this;
354
+ };
355
+ return KeyedSeq2;
356
+ }(Seq);
357
+ var IndexedSeq = /* @__PURE__ */ function(Seq2) {
358
+ function IndexedSeq2(value) {
359
+ return value === void 0 || value === null ? emptySequence() : isCollection(value) ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq() : isRecord(value) ? value.toSeq().entrySeq() : indexedSeqFromValue(value);
360
+ }
361
+ if (Seq2) IndexedSeq2.__proto__ = Seq2;
362
+ IndexedSeq2.prototype = Object.create(Seq2 && Seq2.prototype);
363
+ IndexedSeq2.prototype.constructor = IndexedSeq2;
364
+ IndexedSeq2.of = function of3() {
365
+ return IndexedSeq2(arguments);
366
+ };
367
+ IndexedSeq2.prototype.toIndexedSeq = function toIndexedSeq2() {
368
+ return this;
369
+ };
370
+ IndexedSeq2.prototype.toString = function toString5() {
371
+ return this.__toString("Seq [", "]");
372
+ };
373
+ return IndexedSeq2;
374
+ }(Seq);
375
+ var SetSeq = /* @__PURE__ */ function(Seq2) {
376
+ function SetSeq2(value) {
377
+ return (isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)).toSetSeq();
378
+ }
379
+ if (Seq2) SetSeq2.__proto__ = Seq2;
380
+ SetSeq2.prototype = Object.create(Seq2 && Seq2.prototype);
381
+ SetSeq2.prototype.constructor = SetSeq2;
382
+ SetSeq2.of = function of3() {
383
+ return SetSeq2(arguments);
384
+ };
385
+ SetSeq2.prototype.toSetSeq = function toSetSeq2() {
386
+ return this;
387
+ };
388
+ return SetSeq2;
389
+ }(Seq);
390
+ Seq.isSeq = isSeq;
391
+ Seq.Keyed = KeyedSeq;
392
+ Seq.Set = SetSeq;
393
+ Seq.Indexed = IndexedSeq;
394
+ Seq.prototype[IS_SEQ_SYMBOL] = true;
395
+ var ArraySeq = /* @__PURE__ */ function(IndexedSeq2) {
396
+ function ArraySeq2(array) {
397
+ this._array = array;
398
+ this.size = array.length;
399
+ }
400
+ if (IndexedSeq2) ArraySeq2.__proto__ = IndexedSeq2;
401
+ ArraySeq2.prototype = Object.create(IndexedSeq2 && IndexedSeq2.prototype);
402
+ ArraySeq2.prototype.constructor = ArraySeq2;
403
+ ArraySeq2.prototype.get = function get11(index, notSetValue) {
404
+ return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
405
+ };
406
+ ArraySeq2.prototype.__iterate = function __iterate2(fn, reverse3) {
407
+ var array = this._array;
408
+ var size = array.length;
409
+ var i = 0;
410
+ while (i !== size) {
411
+ var ii = reverse3 ? size - ++i : i++;
412
+ if (fn(array[ii], ii, this) === false) {
413
+ break;
414
+ }
415
+ }
416
+ return i;
417
+ };
418
+ ArraySeq2.prototype.__iterator = function __iterator2(type, reverse3) {
419
+ var array = this._array;
420
+ var size = array.length;
421
+ var i = 0;
422
+ return new Iterator(function() {
423
+ if (i === size) {
424
+ return iteratorDone();
425
+ }
426
+ var ii = reverse3 ? size - ++i : i++;
427
+ return iteratorValue(type, ii, array[ii]);
428
+ });
429
+ };
430
+ return ArraySeq2;
431
+ }(IndexedSeq);
432
+ var ObjectSeq = /* @__PURE__ */ function(KeyedSeq2) {
433
+ function ObjectSeq2(object) {
434
+ var keys2 = Object.keys(object).concat(
435
+ Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []
436
+ );
437
+ this._object = object;
438
+ this._keys = keys2;
439
+ this.size = keys2.length;
440
+ }
441
+ if (KeyedSeq2) ObjectSeq2.__proto__ = KeyedSeq2;
442
+ ObjectSeq2.prototype = Object.create(KeyedSeq2 && KeyedSeq2.prototype);
443
+ ObjectSeq2.prototype.constructor = ObjectSeq2;
444
+ ObjectSeq2.prototype.get = function get11(key, notSetValue) {
445
+ if (notSetValue !== void 0 && !this.has(key)) {
446
+ return notSetValue;
447
+ }
448
+ return this._object[key];
449
+ };
450
+ ObjectSeq2.prototype.has = function has5(key) {
451
+ return hasOwnProperty.call(this._object, key);
452
+ };
453
+ ObjectSeq2.prototype.__iterate = function __iterate2(fn, reverse3) {
454
+ var object = this._object;
455
+ var keys2 = this._keys;
456
+ var size = keys2.length;
457
+ var i = 0;
458
+ while (i !== size) {
459
+ var key = keys2[reverse3 ? size - ++i : i++];
460
+ if (fn(object[key], key, this) === false) {
461
+ break;
462
+ }
463
+ }
464
+ return i;
465
+ };
466
+ ObjectSeq2.prototype.__iterator = function __iterator2(type, reverse3) {
467
+ var object = this._object;
468
+ var keys2 = this._keys;
469
+ var size = keys2.length;
470
+ var i = 0;
471
+ return new Iterator(function() {
472
+ if (i === size) {
473
+ return iteratorDone();
474
+ }
475
+ var key = keys2[reverse3 ? size - ++i : i++];
476
+ return iteratorValue(type, key, object[key]);
477
+ });
478
+ };
479
+ return ObjectSeq2;
480
+ }(KeyedSeq);
481
+ ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
482
+ var CollectionSeq = /* @__PURE__ */ function(IndexedSeq2) {
483
+ function CollectionSeq2(collection) {
484
+ this._collection = collection;
485
+ this.size = collection.length || collection.size;
486
+ }
487
+ if (IndexedSeq2) CollectionSeq2.__proto__ = IndexedSeq2;
488
+ CollectionSeq2.prototype = Object.create(IndexedSeq2 && IndexedSeq2.prototype);
489
+ CollectionSeq2.prototype.constructor = CollectionSeq2;
490
+ CollectionSeq2.prototype.__iterateUncached = function __iterateUncached(fn, reverse3) {
491
+ if (reverse3) {
492
+ return this.cacheResult().__iterate(fn, reverse3);
493
+ }
494
+ var collection = this._collection;
495
+ var iterator = getIterator(collection);
496
+ var iterations = 0;
497
+ if (isIterator(iterator)) {
498
+ var step;
499
+ while (!(step = iterator.next()).done) {
500
+ if (fn(step.value, iterations++, this) === false) {
501
+ break;
502
+ }
503
+ }
504
+ }
505
+ return iterations;
506
+ };
507
+ CollectionSeq2.prototype.__iteratorUncached = function __iteratorUncached(type, reverse3) {
508
+ if (reverse3) {
509
+ return this.cacheResult().__iterator(type, reverse3);
510
+ }
511
+ var collection = this._collection;
512
+ var iterator = getIterator(collection);
513
+ if (!isIterator(iterator)) {
514
+ return new Iterator(iteratorDone);
515
+ }
516
+ var iterations = 0;
517
+ return new Iterator(function() {
518
+ var step = iterator.next();
519
+ return step.done ? step : iteratorValue(type, iterations++, step.value);
520
+ });
521
+ };
522
+ return CollectionSeq2;
523
+ }(IndexedSeq);
524
+ var EMPTY_SEQ;
525
+ function emptySequence() {
526
+ return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
527
+ }
528
+ function keyedSeqFromValue(value) {
529
+ var seq = maybeIndexedSeqFromValue(value);
530
+ if (seq) {
531
+ return seq.fromEntrySeq();
532
+ }
533
+ if (typeof value === "object") {
534
+ return new ObjectSeq(value);
535
+ }
536
+ throw new TypeError(
537
+ "Expected Array or collection object of [k, v] entries, or keyed object: " + value
538
+ );
539
+ }
540
+ function indexedSeqFromValue(value) {
541
+ var seq = maybeIndexedSeqFromValue(value);
542
+ if (seq) {
543
+ return seq;
544
+ }
545
+ throw new TypeError(
546
+ "Expected Array or collection object of values: " + value
547
+ );
548
+ }
549
+ function seqFromValue(value) {
550
+ var seq = maybeIndexedSeqFromValue(value);
551
+ if (seq) {
552
+ return isEntriesIterable(value) ? seq.fromEntrySeq() : isKeysIterable(value) ? seq.toSetSeq() : seq;
553
+ }
554
+ if (typeof value === "object") {
555
+ return new ObjectSeq(value);
556
+ }
557
+ throw new TypeError(
558
+ "Expected Array or collection object of values, or keyed object: " + value
559
+ );
560
+ }
561
+ function maybeIndexedSeqFromValue(value) {
562
+ return isArrayLike(value) ? new ArraySeq(value) : hasIterator(value) ? new CollectionSeq(value) : void 0;
563
+ }
564
+ var IS_MAP_SYMBOL = "@@__IMMUTABLE_MAP__@@";
565
+ function isMap(maybeMap) {
566
+ return Boolean(maybeMap && // @ts-expect-error: maybeMap is typed as `{}`, need to change in 6.0 to `maybeMap && typeof maybeMap === 'object' && IS_MAP_SYMBOL in maybeMap`
567
+ maybeMap[IS_MAP_SYMBOL]);
568
+ }
569
+ function isOrderedMap(maybeOrderedMap) {
570
+ return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
571
+ }
572
+ function isValueObject(maybeValue) {
573
+ return Boolean(maybeValue && // @ts-expect-error: maybeValue is typed as `{}`
574
+ typeof maybeValue.equals === "function" && // @ts-expect-error: maybeValue is typed as `{}`
575
+ typeof maybeValue.hashCode === "function");
576
+ }
577
+ function is(valueA, valueB) {
578
+ if (valueA === valueB || valueA !== valueA && valueB !== valueB) {
579
+ return true;
580
+ }
581
+ if (!valueA || !valueB) {
582
+ return false;
583
+ }
584
+ if (typeof valueA.valueOf === "function" && typeof valueB.valueOf === "function") {
585
+ valueA = valueA.valueOf();
586
+ valueB = valueB.valueOf();
587
+ if (valueA === valueB || valueA !== valueA && valueB !== valueB) {
588
+ return true;
589
+ }
590
+ if (!valueA || !valueB) {
591
+ return false;
592
+ }
593
+ }
594
+ return !!(isValueObject(valueA) && isValueObject(valueB) && valueA.equals(valueB));
595
+ }
596
+ var imul = typeof Math.imul === "function" && Math.imul(4294967295, 2) === -2 ? Math.imul : function imul2(a, b) {
597
+ a |= 0;
598
+ b |= 0;
599
+ var c = a & 65535;
600
+ var d = b & 65535;
601
+ return c * d + ((a >>> 16) * d + c * (b >>> 16) << 16 >>> 0) | 0;
602
+ };
603
+ function smi(i32) {
604
+ return i32 >>> 1 & 1073741824 | i32 & 3221225471;
605
+ }
606
+ var defaultValueOf = Object.prototype.valueOf;
607
+ function hash(o) {
608
+ if (o == null) {
609
+ return hashNullish(o);
610
+ }
611
+ if (typeof o.hashCode === "function") {
612
+ return smi(o.hashCode(o));
613
+ }
614
+ var v = valueOf(o);
615
+ if (v == null) {
616
+ return hashNullish(v);
617
+ }
618
+ switch (typeof v) {
619
+ case "boolean":
620
+ return v ? 1108378657 : 1108378656;
621
+ case "number":
622
+ return hashNumber(v);
623
+ case "string":
624
+ return v.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(v) : hashString(v);
625
+ case "object":
626
+ case "function":
627
+ return hashJSObj(v);
628
+ case "symbol":
629
+ return hashSymbol(v);
630
+ default:
631
+ if (typeof v.toString === "function") {
632
+ return hashString(v.toString());
633
+ }
634
+ throw new Error("Value type " + typeof v + " cannot be hashed.");
635
+ }
636
+ }
637
+ function hashNullish(nullish) {
638
+ return nullish === null ? 1108378658 : (
639
+ /* undefined */
640
+ 1108378659
641
+ );
642
+ }
643
+ function hashNumber(n) {
644
+ if (n !== n || n === Infinity) {
645
+ return 0;
646
+ }
647
+ var hash2 = n | 0;
648
+ if (hash2 !== n) {
649
+ hash2 ^= n * 4294967295;
650
+ }
651
+ while (n > 4294967295) {
652
+ n /= 4294967295;
653
+ hash2 ^= n;
654
+ }
655
+ return smi(hash2);
656
+ }
657
+ function cachedHashString(string) {
658
+ var hashed = stringHashCache[string];
659
+ if (hashed === void 0) {
660
+ hashed = hashString(string);
661
+ if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
662
+ STRING_HASH_CACHE_SIZE = 0;
663
+ stringHashCache = {};
664
+ }
665
+ STRING_HASH_CACHE_SIZE++;
666
+ stringHashCache[string] = hashed;
667
+ }
668
+ return hashed;
669
+ }
670
+ function hashString(string) {
671
+ var hashed = 0;
672
+ for (var ii = 0; ii < string.length; ii++) {
673
+ hashed = 31 * hashed + string.charCodeAt(ii) | 0;
674
+ }
675
+ return smi(hashed);
676
+ }
677
+ function hashSymbol(sym) {
678
+ var hashed = symbolMap[sym];
679
+ if (hashed !== void 0) {
680
+ return hashed;
681
+ }
682
+ hashed = nextHash();
683
+ symbolMap[sym] = hashed;
684
+ return hashed;
685
+ }
686
+ function hashJSObj(obj) {
687
+ var hashed;
688
+ if (usingWeakMap) {
689
+ hashed = weakMap.get(obj);
690
+ if (hashed !== void 0) {
691
+ return hashed;
692
+ }
693
+ }
694
+ hashed = obj[UID_HASH_KEY];
695
+ if (hashed !== void 0) {
696
+ return hashed;
697
+ }
698
+ if (!canDefineProperty) {
699
+ hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
700
+ if (hashed !== void 0) {
701
+ return hashed;
702
+ }
703
+ hashed = getIENodeHash(obj);
704
+ if (hashed !== void 0) {
705
+ return hashed;
706
+ }
707
+ }
708
+ hashed = nextHash();
709
+ if (usingWeakMap) {
710
+ weakMap.set(obj, hashed);
711
+ } else if (isExtensible !== void 0 && isExtensible(obj) === false) {
712
+ throw new Error("Non-extensible objects are not allowed as keys.");
713
+ } else if (canDefineProperty) {
714
+ Object.defineProperty(obj, UID_HASH_KEY, {
715
+ enumerable: false,
716
+ configurable: false,
717
+ writable: false,
718
+ value: hashed
719
+ });
720
+ } else if (obj.propertyIsEnumerable !== void 0 && obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
721
+ obj.propertyIsEnumerable = function() {
722
+ return this.constructor.prototype.propertyIsEnumerable.apply(
723
+ this,
724
+ arguments
725
+ );
726
+ };
727
+ obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
728
+ } else if (obj.nodeType !== void 0) {
729
+ obj[UID_HASH_KEY] = hashed;
730
+ } else {
731
+ throw new Error("Unable to set a non-enumerable property on object.");
732
+ }
733
+ return hashed;
734
+ }
735
+ var isExtensible = Object.isExtensible;
736
+ var canDefineProperty = function() {
737
+ try {
738
+ Object.defineProperty({}, "@", {});
739
+ return true;
740
+ } catch (e) {
741
+ return false;
742
+ }
743
+ }();
744
+ function getIENodeHash(node) {
745
+ if (node && node.nodeType > 0) {
746
+ switch (node.nodeType) {
747
+ case 1:
748
+ return node.uniqueID;
749
+ case 9:
750
+ return node.documentElement && node.documentElement.uniqueID;
751
+ }
752
+ }
753
+ }
754
+ function valueOf(obj) {
755
+ return obj.valueOf !== defaultValueOf && typeof obj.valueOf === "function" ? obj.valueOf(obj) : obj;
756
+ }
757
+ function nextHash() {
758
+ var nextHash2 = ++_objHashUID;
759
+ if (_objHashUID & 1073741824) {
760
+ _objHashUID = 0;
761
+ }
762
+ return nextHash2;
763
+ }
764
+ var usingWeakMap = typeof WeakMap === "function";
765
+ var weakMap;
766
+ if (usingWeakMap) {
767
+ weakMap = /* @__PURE__ */ new WeakMap();
768
+ }
769
+ var symbolMap = /* @__PURE__ */ Object.create(null);
770
+ var _objHashUID = 0;
771
+ var UID_HASH_KEY = "__immutablehash__";
772
+ if (typeof Symbol === "function") {
773
+ UID_HASH_KEY = Symbol(UID_HASH_KEY);
774
+ }
775
+ var STRING_HASH_CACHE_MIN_STRLEN = 16;
776
+ var STRING_HASH_CACHE_MAX_SIZE = 255;
777
+ var STRING_HASH_CACHE_SIZE = 0;
778
+ var stringHashCache = {};
779
+ var ToKeyedSequence = /* @__PURE__ */ function(KeyedSeq2) {
780
+ function ToKeyedSequence2(indexed, useKeys) {
781
+ this._iter = indexed;
782
+ this._useKeys = useKeys;
783
+ this.size = indexed.size;
784
+ }
785
+ if (KeyedSeq2) ToKeyedSequence2.__proto__ = KeyedSeq2;
786
+ ToKeyedSequence2.prototype = Object.create(KeyedSeq2 && KeyedSeq2.prototype);
787
+ ToKeyedSequence2.prototype.constructor = ToKeyedSequence2;
788
+ ToKeyedSequence2.prototype.get = function get11(key, notSetValue) {
789
+ return this._iter.get(key, notSetValue);
790
+ };
791
+ ToKeyedSequence2.prototype.has = function has5(key) {
792
+ return this._iter.has(key);
793
+ };
794
+ ToKeyedSequence2.prototype.valueSeq = function valueSeq2() {
795
+ return this._iter.valueSeq();
796
+ };
797
+ ToKeyedSequence2.prototype.reverse = function reverse3() {
798
+ var this$1$1 = this;
799
+ var reversedSequence = reverseFactory(this, true);
800
+ if (!this._useKeys) {
801
+ reversedSequence.valueSeq = function() {
802
+ return this$1$1._iter.toSeq().reverse();
803
+ };
804
+ }
805
+ return reversedSequence;
806
+ };
807
+ ToKeyedSequence2.prototype.map = function map5(mapper, context) {
808
+ var this$1$1 = this;
809
+ var mappedSequence = mapFactory(this, mapper, context);
810
+ if (!this._useKeys) {
811
+ mappedSequence.valueSeq = function() {
812
+ return this$1$1._iter.toSeq().map(mapper, context);
813
+ };
814
+ }
815
+ return mappedSequence;
816
+ };
817
+ ToKeyedSequence2.prototype.__iterate = function __iterate2(fn, reverse3) {
818
+ var this$1$1 = this;
819
+ return this._iter.__iterate(function(v, k) {
820
+ return fn(v, k, this$1$1);
821
+ }, reverse3);
822
+ };
823
+ ToKeyedSequence2.prototype.__iterator = function __iterator2(type, reverse3) {
824
+ return this._iter.__iterator(type, reverse3);
825
+ };
826
+ return ToKeyedSequence2;
827
+ }(KeyedSeq);
828
+ ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
829
+ var ToIndexedSequence = /* @__PURE__ */ function(IndexedSeq2) {
830
+ function ToIndexedSequence2(iter) {
831
+ this._iter = iter;
832
+ this.size = iter.size;
833
+ }
834
+ if (IndexedSeq2) ToIndexedSequence2.__proto__ = IndexedSeq2;
835
+ ToIndexedSequence2.prototype = Object.create(IndexedSeq2 && IndexedSeq2.prototype);
836
+ ToIndexedSequence2.prototype.constructor = ToIndexedSequence2;
837
+ ToIndexedSequence2.prototype.includes = function includes3(value) {
838
+ return this._iter.includes(value);
839
+ };
840
+ ToIndexedSequence2.prototype.__iterate = function __iterate2(fn, reverse3) {
841
+ var this$1$1 = this;
842
+ var i = 0;
843
+ reverse3 && ensureSize(this);
844
+ return this._iter.__iterate(
845
+ function(v) {
846
+ return fn(v, reverse3 ? this$1$1.size - ++i : i++, this$1$1);
847
+ },
848
+ reverse3
849
+ );
850
+ };
851
+ ToIndexedSequence2.prototype.__iterator = function __iterator2(type, reverse3) {
852
+ var this$1$1 = this;
853
+ var iterator = this._iter.__iterator(ITERATE_VALUES, reverse3);
854
+ var i = 0;
855
+ reverse3 && ensureSize(this);
856
+ return new Iterator(function() {
857
+ var step = iterator.next();
858
+ return step.done ? step : iteratorValue(
859
+ type,
860
+ reverse3 ? this$1$1.size - ++i : i++,
861
+ step.value,
862
+ step
863
+ );
864
+ });
865
+ };
866
+ return ToIndexedSequence2;
867
+ }(IndexedSeq);
868
+ var ToSetSequence = /* @__PURE__ */ function(SetSeq2) {
869
+ function ToSetSequence2(iter) {
870
+ this._iter = iter;
871
+ this.size = iter.size;
872
+ }
873
+ if (SetSeq2) ToSetSequence2.__proto__ = SetSeq2;
874
+ ToSetSequence2.prototype = Object.create(SetSeq2 && SetSeq2.prototype);
875
+ ToSetSequence2.prototype.constructor = ToSetSequence2;
876
+ ToSetSequence2.prototype.has = function has5(key) {
877
+ return this._iter.includes(key);
878
+ };
879
+ ToSetSequence2.prototype.__iterate = function __iterate2(fn, reverse3) {
880
+ var this$1$1 = this;
881
+ return this._iter.__iterate(function(v) {
882
+ return fn(v, v, this$1$1);
883
+ }, reverse3);
884
+ };
885
+ ToSetSequence2.prototype.__iterator = function __iterator2(type, reverse3) {
886
+ var iterator = this._iter.__iterator(ITERATE_VALUES, reverse3);
887
+ return new Iterator(function() {
888
+ var step = iterator.next();
889
+ return step.done ? step : iteratorValue(type, step.value, step.value, step);
890
+ });
891
+ };
892
+ return ToSetSequence2;
893
+ }(SetSeq);
894
+ var FromEntriesSequence = /* @__PURE__ */ function(KeyedSeq2) {
895
+ function FromEntriesSequence2(entries3) {
896
+ this._iter = entries3;
897
+ this.size = entries3.size;
898
+ }
899
+ if (KeyedSeq2) FromEntriesSequence2.__proto__ = KeyedSeq2;
900
+ FromEntriesSequence2.prototype = Object.create(KeyedSeq2 && KeyedSeq2.prototype);
901
+ FromEntriesSequence2.prototype.constructor = FromEntriesSequence2;
902
+ FromEntriesSequence2.prototype.entrySeq = function entrySeq2() {
903
+ return this._iter.toSeq();
904
+ };
905
+ FromEntriesSequence2.prototype.__iterate = function __iterate2(fn, reverse3) {
906
+ var this$1$1 = this;
907
+ return this._iter.__iterate(function(entry) {
908
+ if (entry) {
909
+ validateEntry(entry);
910
+ var indexedCollection = isCollection(entry);
911
+ return fn(
912
+ indexedCollection ? entry.get(1) : entry[1],
913
+ indexedCollection ? entry.get(0) : entry[0],
914
+ this$1$1
915
+ );
916
+ }
917
+ }, reverse3);
918
+ };
919
+ FromEntriesSequence2.prototype.__iterator = function __iterator2(type, reverse3) {
920
+ var iterator = this._iter.__iterator(ITERATE_VALUES, reverse3);
921
+ return new Iterator(function() {
922
+ while (true) {
923
+ var step = iterator.next();
924
+ if (step.done) {
925
+ return step;
926
+ }
927
+ var entry = step.value;
928
+ if (entry) {
929
+ validateEntry(entry);
930
+ var indexedCollection = isCollection(entry);
931
+ return iteratorValue(
932
+ type,
933
+ indexedCollection ? entry.get(0) : entry[0],
934
+ indexedCollection ? entry.get(1) : entry[1],
935
+ step
936
+ );
937
+ }
938
+ }
939
+ });
940
+ };
941
+ return FromEntriesSequence2;
942
+ }(KeyedSeq);
943
+ ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
944
+ function flipFactory(collection) {
945
+ var flipSequence = makeSequence(collection);
946
+ flipSequence._iter = collection;
947
+ flipSequence.size = collection.size;
948
+ flipSequence.flip = function() {
949
+ return collection;
950
+ };
951
+ flipSequence.reverse = function() {
952
+ var reversedSequence = collection.reverse.apply(this);
953
+ reversedSequence.flip = function() {
954
+ return collection.reverse();
955
+ };
956
+ return reversedSequence;
957
+ };
958
+ flipSequence.has = function(key) {
959
+ return collection.includes(key);
960
+ };
961
+ flipSequence.includes = function(key) {
962
+ return collection.has(key);
963
+ };
964
+ flipSequence.cacheResult = cacheResultThrough;
965
+ flipSequence.__iterateUncached = function(fn, reverse3) {
966
+ var this$1$1 = this;
967
+ return collection.__iterate(function(v, k) {
968
+ return fn(k, v, this$1$1) !== false;
969
+ }, reverse3);
970
+ };
971
+ flipSequence.__iteratorUncached = function(type, reverse3) {
972
+ if (type === ITERATE_ENTRIES) {
973
+ var iterator = collection.__iterator(type, reverse3);
974
+ return new Iterator(function() {
975
+ var step = iterator.next();
976
+ if (!step.done) {
977
+ var k = step.value[0];
978
+ step.value[0] = step.value[1];
979
+ step.value[1] = k;
980
+ }
981
+ return step;
982
+ });
983
+ }
984
+ return collection.__iterator(
985
+ type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
986
+ reverse3
987
+ );
988
+ };
989
+ return flipSequence;
990
+ }
991
+ function mapFactory(collection, mapper, context) {
992
+ var mappedSequence = makeSequence(collection);
993
+ mappedSequence.size = collection.size;
994
+ mappedSequence.has = function(key) {
995
+ return collection.has(key);
996
+ };
997
+ mappedSequence.get = function(key, notSetValue) {
998
+ var v = collection.get(key, NOT_SET);
999
+ return v === NOT_SET ? notSetValue : mapper.call(context, v, key, collection);
1000
+ };
1001
+ mappedSequence.__iterateUncached = function(fn, reverse3) {
1002
+ var this$1$1 = this;
1003
+ return collection.__iterate(
1004
+ function(v, k, c) {
1005
+ return fn(mapper.call(context, v, k, c), k, this$1$1) !== false;
1006
+ },
1007
+ reverse3
1008
+ );
1009
+ };
1010
+ mappedSequence.__iteratorUncached = function(type, reverse3) {
1011
+ var iterator = collection.__iterator(ITERATE_ENTRIES, reverse3);
1012
+ return new Iterator(function() {
1013
+ var step = iterator.next();
1014
+ if (step.done) {
1015
+ return step;
1016
+ }
1017
+ var entry = step.value;
1018
+ var key = entry[0];
1019
+ return iteratorValue(
1020
+ type,
1021
+ key,
1022
+ mapper.call(context, entry[1], key, collection),
1023
+ step
1024
+ );
1025
+ });
1026
+ };
1027
+ return mappedSequence;
1028
+ }
1029
+ function reverseFactory(collection, useKeys) {
1030
+ var this$1$1 = this;
1031
+ var reversedSequence = makeSequence(collection);
1032
+ reversedSequence._iter = collection;
1033
+ reversedSequence.size = collection.size;
1034
+ reversedSequence.reverse = function() {
1035
+ return collection;
1036
+ };
1037
+ if (collection.flip) {
1038
+ reversedSequence.flip = function() {
1039
+ var flipSequence = flipFactory(collection);
1040
+ flipSequence.reverse = function() {
1041
+ return collection.flip();
1042
+ };
1043
+ return flipSequence;
1044
+ };
1045
+ }
1046
+ reversedSequence.get = function(key, notSetValue) {
1047
+ return collection.get(useKeys ? key : -1 - key, notSetValue);
1048
+ };
1049
+ reversedSequence.has = function(key) {
1050
+ return collection.has(useKeys ? key : -1 - key);
1051
+ };
1052
+ reversedSequence.includes = function(value) {
1053
+ return collection.includes(value);
1054
+ };
1055
+ reversedSequence.cacheResult = cacheResultThrough;
1056
+ reversedSequence.__iterate = function(fn, reverse3) {
1057
+ var this$1$12 = this;
1058
+ var i = 0;
1059
+ reverse3 && ensureSize(collection);
1060
+ return collection.__iterate(
1061
+ function(v, k) {
1062
+ return fn(v, useKeys ? k : reverse3 ? this$1$12.size - ++i : i++, this$1$12);
1063
+ },
1064
+ !reverse3
1065
+ );
1066
+ };
1067
+ reversedSequence.__iterator = function(type, reverse3) {
1068
+ var i = 0;
1069
+ reverse3 && ensureSize(collection);
1070
+ var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse3);
1071
+ return new Iterator(function() {
1072
+ var step = iterator.next();
1073
+ if (step.done) {
1074
+ return step;
1075
+ }
1076
+ var entry = step.value;
1077
+ return iteratorValue(
1078
+ type,
1079
+ useKeys ? entry[0] : reverse3 ? this$1$1.size - ++i : i++,
1080
+ entry[1],
1081
+ step
1082
+ );
1083
+ });
1084
+ };
1085
+ return reversedSequence;
1086
+ }
1087
+ function filterFactory(collection, predicate, context, useKeys) {
1088
+ var filterSequence = makeSequence(collection);
1089
+ if (useKeys) {
1090
+ filterSequence.has = function(key) {
1091
+ var v = collection.get(key, NOT_SET);
1092
+ return v !== NOT_SET && !!predicate.call(context, v, key, collection);
1093
+ };
1094
+ filterSequence.get = function(key, notSetValue) {
1095
+ var v = collection.get(key, NOT_SET);
1096
+ return v !== NOT_SET && predicate.call(context, v, key, collection) ? v : notSetValue;
1097
+ };
1098
+ }
1099
+ filterSequence.__iterateUncached = function(fn, reverse3) {
1100
+ var this$1$1 = this;
1101
+ var iterations = 0;
1102
+ collection.__iterate(function(v, k, c) {
1103
+ if (predicate.call(context, v, k, c)) {
1104
+ iterations++;
1105
+ return fn(v, useKeys ? k : iterations - 1, this$1$1);
1106
+ }
1107
+ }, reverse3);
1108
+ return iterations;
1109
+ };
1110
+ filterSequence.__iteratorUncached = function(type, reverse3) {
1111
+ var iterator = collection.__iterator(ITERATE_ENTRIES, reverse3);
1112
+ var iterations = 0;
1113
+ return new Iterator(function() {
1114
+ while (true) {
1115
+ var step = iterator.next();
1116
+ if (step.done) {
1117
+ return step;
1118
+ }
1119
+ var entry = step.value;
1120
+ var key = entry[0];
1121
+ var value = entry[1];
1122
+ if (predicate.call(context, value, key, collection)) {
1123
+ return iteratorValue(type, useKeys ? key : iterations++, value, step);
1124
+ }
1125
+ }
1126
+ });
1127
+ };
1128
+ return filterSequence;
1129
+ }
1130
+ function countByFactory(collection, grouper, context) {
1131
+ var groups = Map().asMutable();
1132
+ collection.__iterate(function(v, k) {
1133
+ groups.update(grouper.call(context, v, k, collection), 0, function(a) {
1134
+ return a + 1;
1135
+ });
1136
+ });
1137
+ return groups.asImmutable();
1138
+ }
1139
+ function groupByFactory(collection, grouper, context) {
1140
+ var isKeyedIter = isKeyed(collection);
1141
+ var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
1142
+ collection.__iterate(function(v, k) {
1143
+ groups.update(
1144
+ grouper.call(context, v, k, collection),
1145
+ function(a) {
1146
+ return a = a || [], a.push(isKeyedIter ? [k, v] : v), a;
1147
+ }
1148
+ );
1149
+ });
1150
+ var coerce = collectionClass(collection);
1151
+ return groups.map(function(arr) {
1152
+ return reify(collection, coerce(arr));
1153
+ }).asImmutable();
1154
+ }
1155
+ function partitionFactory(collection, predicate, context) {
1156
+ var isKeyedIter = isKeyed(collection);
1157
+ var groups = [[], []];
1158
+ collection.__iterate(function(v, k) {
1159
+ groups[predicate.call(context, v, k, collection) ? 1 : 0].push(
1160
+ isKeyedIter ? [k, v] : v
1161
+ );
1162
+ });
1163
+ var coerce = collectionClass(collection);
1164
+ return groups.map(function(arr) {
1165
+ return reify(collection, coerce(arr));
1166
+ });
1167
+ }
1168
+ function sliceFactory(collection, begin, end, useKeys) {
1169
+ var originalSize = collection.size;
1170
+ if (wholeSlice(begin, end, originalSize)) {
1171
+ return collection;
1172
+ }
1173
+ if (typeof originalSize === "undefined" && (begin < 0 || end < 0)) {
1174
+ return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
1175
+ }
1176
+ var resolvedBegin = resolveBegin(begin, originalSize);
1177
+ var resolvedEnd = resolveEnd(end, originalSize);
1178
+ var resolvedSize = resolvedEnd - resolvedBegin;
1179
+ var sliceSize;
1180
+ if (resolvedSize === resolvedSize) {
1181
+ sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
1182
+ }
1183
+ var sliceSeq = makeSequence(collection);
1184
+ sliceSeq.size = sliceSize === 0 ? sliceSize : collection.size && sliceSize || void 0;
1185
+ if (!useKeys && isSeq(collection) && sliceSize >= 0) {
1186
+ sliceSeq.get = function(index, notSetValue) {
1187
+ index = wrapIndex(this, index);
1188
+ return index >= 0 && index < sliceSize ? collection.get(index + resolvedBegin, notSetValue) : notSetValue;
1189
+ };
1190
+ }
1191
+ sliceSeq.__iterateUncached = function(fn, reverse3) {
1192
+ var this$1$1 = this;
1193
+ if (sliceSize === 0) {
1194
+ return 0;
1195
+ }
1196
+ if (reverse3) {
1197
+ return this.cacheResult().__iterate(fn, reverse3);
1198
+ }
1199
+ var skipped = 0;
1200
+ var isSkipping = true;
1201
+ var iterations = 0;
1202
+ collection.__iterate(function(v, k) {
1203
+ if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
1204
+ iterations++;
1205
+ return fn(v, useKeys ? k : iterations - 1, this$1$1) !== false && iterations !== sliceSize;
1206
+ }
1207
+ });
1208
+ return iterations;
1209
+ };
1210
+ sliceSeq.__iteratorUncached = function(type, reverse3) {
1211
+ if (sliceSize !== 0 && reverse3) {
1212
+ return this.cacheResult().__iterator(type, reverse3);
1213
+ }
1214
+ if (sliceSize === 0) {
1215
+ return new Iterator(iteratorDone);
1216
+ }
1217
+ var iterator = collection.__iterator(type, reverse3);
1218
+ var skipped = 0;
1219
+ var iterations = 0;
1220
+ return new Iterator(function() {
1221
+ while (skipped++ < resolvedBegin) {
1222
+ iterator.next();
1223
+ }
1224
+ if (++iterations > sliceSize) {
1225
+ return iteratorDone();
1226
+ }
1227
+ var step = iterator.next();
1228
+ if (useKeys || type === ITERATE_VALUES || step.done) {
1229
+ return step;
1230
+ }
1231
+ if (type === ITERATE_KEYS) {
1232
+ return iteratorValue(type, iterations - 1, void 0, step);
1233
+ }
1234
+ return iteratorValue(type, iterations - 1, step.value[1], step);
1235
+ });
1236
+ };
1237
+ return sliceSeq;
1238
+ }
1239
+ function takeWhileFactory(collection, predicate, context) {
1240
+ var takeSequence = makeSequence(collection);
1241
+ takeSequence.__iterateUncached = function(fn, reverse3) {
1242
+ var this$1$1 = this;
1243
+ if (reverse3) {
1244
+ return this.cacheResult().__iterate(fn, reverse3);
1245
+ }
1246
+ var iterations = 0;
1247
+ collection.__iterate(
1248
+ function(v, k, c) {
1249
+ return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1);
1250
+ }
1251
+ );
1252
+ return iterations;
1253
+ };
1254
+ takeSequence.__iteratorUncached = function(type, reverse3) {
1255
+ var this$1$1 = this;
1256
+ if (reverse3) {
1257
+ return this.cacheResult().__iterator(type, reverse3);
1258
+ }
1259
+ var iterator = collection.__iterator(ITERATE_ENTRIES, reverse3);
1260
+ var iterating = true;
1261
+ return new Iterator(function() {
1262
+ if (!iterating) {
1263
+ return iteratorDone();
1264
+ }
1265
+ var step = iterator.next();
1266
+ if (step.done) {
1267
+ return step;
1268
+ }
1269
+ var entry = step.value;
1270
+ var k = entry[0];
1271
+ var v = entry[1];
1272
+ if (!predicate.call(context, v, k, this$1$1)) {
1273
+ iterating = false;
1274
+ return iteratorDone();
1275
+ }
1276
+ return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
1277
+ });
1278
+ };
1279
+ return takeSequence;
1280
+ }
1281
+ function skipWhileFactory(collection, predicate, context, useKeys) {
1282
+ var skipSequence = makeSequence(collection);
1283
+ skipSequence.__iterateUncached = function(fn, reverse3) {
1284
+ var this$1$1 = this;
1285
+ if (reverse3) {
1286
+ return this.cacheResult().__iterate(fn, reverse3);
1287
+ }
1288
+ var isSkipping = true;
1289
+ var iterations = 0;
1290
+ collection.__iterate(function(v, k, c) {
1291
+ if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
1292
+ iterations++;
1293
+ return fn(v, useKeys ? k : iterations - 1, this$1$1);
1294
+ }
1295
+ });
1296
+ return iterations;
1297
+ };
1298
+ skipSequence.__iteratorUncached = function(type, reverse3) {
1299
+ var this$1$1 = this;
1300
+ if (reverse3) {
1301
+ return this.cacheResult().__iterator(type, reverse3);
1302
+ }
1303
+ var iterator = collection.__iterator(ITERATE_ENTRIES, reverse3);
1304
+ var skipping = true;
1305
+ var iterations = 0;
1306
+ return new Iterator(function() {
1307
+ var step;
1308
+ var k;
1309
+ var v;
1310
+ do {
1311
+ step = iterator.next();
1312
+ if (step.done) {
1313
+ if (useKeys || type === ITERATE_VALUES) {
1314
+ return step;
1315
+ }
1316
+ if (type === ITERATE_KEYS) {
1317
+ return iteratorValue(type, iterations++, void 0, step);
1318
+ }
1319
+ return iteratorValue(type, iterations++, step.value[1], step);
1320
+ }
1321
+ var entry = step.value;
1322
+ k = entry[0];
1323
+ v = entry[1];
1324
+ skipping && (skipping = predicate.call(context, v, k, this$1$1));
1325
+ } while (skipping);
1326
+ return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
1327
+ });
1328
+ };
1329
+ return skipSequence;
1330
+ }
1331
+ var ConcatSeq = /* @__PURE__ */ function(Seq2) {
1332
+ function ConcatSeq2(iterables) {
1333
+ this._wrappedIterables = iterables.flatMap(function(iterable) {
1334
+ if (iterable._wrappedIterables) {
1335
+ return iterable._wrappedIterables;
1336
+ }
1337
+ return [iterable];
1338
+ });
1339
+ this.size = this._wrappedIterables.reduce(function(sum, iterable) {
1340
+ if (sum !== void 0) {
1341
+ var size = iterable.size;
1342
+ if (size !== void 0) {
1343
+ return sum + size;
1344
+ }
1345
+ }
1346
+ }, 0);
1347
+ this[IS_KEYED_SYMBOL] = this._wrappedIterables[0][IS_KEYED_SYMBOL];
1348
+ this[IS_INDEXED_SYMBOL] = this._wrappedIterables[0][IS_INDEXED_SYMBOL];
1349
+ this[IS_ORDERED_SYMBOL] = this._wrappedIterables[0][IS_ORDERED_SYMBOL];
1350
+ }
1351
+ if (Seq2) ConcatSeq2.__proto__ = Seq2;
1352
+ ConcatSeq2.prototype = Object.create(Seq2 && Seq2.prototype);
1353
+ ConcatSeq2.prototype.constructor = ConcatSeq2;
1354
+ ConcatSeq2.prototype.__iterateUncached = function __iterateUncached(fn, reverse3) {
1355
+ if (this._wrappedIterables.length === 0) {
1356
+ return;
1357
+ }
1358
+ if (reverse3) {
1359
+ return this.cacheResult().__iterate(fn, reverse3);
1360
+ }
1361
+ var iterableIndex = 0;
1362
+ var useKeys = isKeyed(this);
1363
+ var iteratorType = useKeys ? ITERATE_ENTRIES : ITERATE_VALUES;
1364
+ var currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1365
+ iteratorType,
1366
+ reverse3
1367
+ );
1368
+ var keepGoing = true;
1369
+ var index = 0;
1370
+ while (keepGoing) {
1371
+ var next = currentIterator.next();
1372
+ while (next.done) {
1373
+ iterableIndex++;
1374
+ if (iterableIndex === this._wrappedIterables.length) {
1375
+ return index;
1376
+ }
1377
+ currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1378
+ iteratorType,
1379
+ reverse3
1380
+ );
1381
+ next = currentIterator.next();
1382
+ }
1383
+ var fnResult = useKeys ? fn(next.value[1], next.value[0], this) : fn(next.value, index, this);
1384
+ keepGoing = fnResult !== false;
1385
+ index++;
1386
+ }
1387
+ return index;
1388
+ };
1389
+ ConcatSeq2.prototype.__iteratorUncached = function __iteratorUncached(type, reverse3) {
1390
+ var this$1$1 = this;
1391
+ if (this._wrappedIterables.length === 0) {
1392
+ return new Iterator(iteratorDone);
1393
+ }
1394
+ if (reverse3) {
1395
+ return this.cacheResult().__iterator(type, reverse3);
1396
+ }
1397
+ var iterableIndex = 0;
1398
+ var currentIterator = this._wrappedIterables[iterableIndex].__iterator(
1399
+ type,
1400
+ reverse3
1401
+ );
1402
+ return new Iterator(function() {
1403
+ var next = currentIterator.next();
1404
+ while (next.done) {
1405
+ iterableIndex++;
1406
+ if (iterableIndex === this$1$1._wrappedIterables.length) {
1407
+ return next;
1408
+ }
1409
+ currentIterator = this$1$1._wrappedIterables[iterableIndex].__iterator(
1410
+ type,
1411
+ reverse3
1412
+ );
1413
+ next = currentIterator.next();
1414
+ }
1415
+ return next;
1416
+ });
1417
+ };
1418
+ return ConcatSeq2;
1419
+ }(Seq);
1420
+ function concatFactory(collection, values2) {
1421
+ var isKeyedCollection = isKeyed(collection);
1422
+ var iters = [collection].concat(values2).map(function(v) {
1423
+ if (!isCollection(v)) {
1424
+ v = isKeyedCollection ? keyedSeqFromValue(v) : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
1425
+ } else if (isKeyedCollection) {
1426
+ v = KeyedCollection(v);
1427
+ }
1428
+ return v;
1429
+ }).filter(function(v) {
1430
+ return v.size !== 0;
1431
+ });
1432
+ if (iters.length === 0) {
1433
+ return collection;
1434
+ }
1435
+ if (iters.length === 1) {
1436
+ var singleton = iters[0];
1437
+ if (singleton === collection || isKeyedCollection && isKeyed(singleton) || isIndexed(collection) && isIndexed(singleton)) {
1438
+ return singleton;
1439
+ }
1440
+ }
1441
+ return new ConcatSeq(iters);
1442
+ }
1443
+ function flattenFactory(collection, depth, useKeys) {
1444
+ var flatSequence = makeSequence(collection);
1445
+ flatSequence.__iterateUncached = function(fn, reverse3) {
1446
+ if (reverse3) {
1447
+ return this.cacheResult().__iterate(fn, reverse3);
1448
+ }
1449
+ var iterations = 0;
1450
+ var stopped = false;
1451
+ function flatDeep(iter, currentDepth) {
1452
+ iter.__iterate(function(v, k) {
1453
+ if ((!depth || currentDepth < depth) && isCollection(v)) {
1454
+ flatDeep(v, currentDepth + 1);
1455
+ } else {
1456
+ iterations++;
1457
+ if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
1458
+ stopped = true;
1459
+ }
1460
+ }
1461
+ return !stopped;
1462
+ }, reverse3);
1463
+ }
1464
+ flatDeep(collection, 0);
1465
+ return iterations;
1466
+ };
1467
+ flatSequence.__iteratorUncached = function(type, reverse3) {
1468
+ if (reverse3) {
1469
+ return this.cacheResult().__iterator(type, reverse3);
1470
+ }
1471
+ var iterator = collection.__iterator(type, reverse3);
1472
+ var stack = [];
1473
+ var iterations = 0;
1474
+ return new Iterator(function() {
1475
+ while (iterator) {
1476
+ var step = iterator.next();
1477
+ if (step.done !== false) {
1478
+ iterator = stack.pop();
1479
+ continue;
1480
+ }
1481
+ var v = step.value;
1482
+ if (type === ITERATE_ENTRIES) {
1483
+ v = v[1];
1484
+ }
1485
+ if ((!depth || stack.length < depth) && isCollection(v)) {
1486
+ stack.push(iterator);
1487
+ iterator = v.__iterator(type, reverse3);
1488
+ } else {
1489
+ return useKeys ? step : iteratorValue(type, iterations++, v, step);
1490
+ }
1491
+ }
1492
+ return iteratorDone();
1493
+ });
1494
+ };
1495
+ return flatSequence;
1496
+ }
1497
+ function flatMapFactory(collection, mapper, context) {
1498
+ var coerce = collectionClass(collection);
1499
+ return collection.toSeq().map(function(v, k) {
1500
+ return coerce(mapper.call(context, v, k, collection));
1501
+ }).flatten(true);
1502
+ }
1503
+ function interposeFactory(collection, separator) {
1504
+ var interposedSequence = makeSequence(collection);
1505
+ interposedSequence.size = collection.size && collection.size * 2 - 1;
1506
+ interposedSequence.__iterateUncached = function(fn, reverse3) {
1507
+ var this$1$1 = this;
1508
+ var iterations = 0;
1509
+ collection.__iterate(
1510
+ function(v) {
1511
+ return (!iterations || fn(separator, iterations++, this$1$1) !== false) && fn(v, iterations++, this$1$1) !== false;
1512
+ },
1513
+ reverse3
1514
+ );
1515
+ return iterations;
1516
+ };
1517
+ interposedSequence.__iteratorUncached = function(type, reverse3) {
1518
+ var iterator = collection.__iterator(ITERATE_VALUES, reverse3);
1519
+ var iterations = 0;
1520
+ var step;
1521
+ return new Iterator(function() {
1522
+ if (!step || iterations % 2) {
1523
+ step = iterator.next();
1524
+ if (step.done) {
1525
+ return step;
1526
+ }
1527
+ }
1528
+ return iterations % 2 ? iteratorValue(type, iterations++, separator) : iteratorValue(type, iterations++, step.value, step);
1529
+ });
1530
+ };
1531
+ return interposedSequence;
1532
+ }
1533
+ function sortFactory(collection, comparator, mapper) {
1534
+ if (!comparator) {
1535
+ comparator = defaultComparator;
1536
+ }
1537
+ var isKeyedCollection = isKeyed(collection);
1538
+ var index = 0;
1539
+ var entries3 = collection.toSeq().map(function(v, k) {
1540
+ return [k, v, index++, mapper ? mapper(v, k, collection) : v];
1541
+ }).valueSeq().toArray();
1542
+ entries3.sort(function(a, b) {
1543
+ return comparator(a[3], b[3]) || a[2] - b[2];
1544
+ }).forEach(
1545
+ isKeyedCollection ? function(v, i) {
1546
+ entries3[i].length = 2;
1547
+ } : function(v, i) {
1548
+ entries3[i] = v[1];
1549
+ }
1550
+ );
1551
+ return isKeyedCollection ? KeyedSeq(entries3) : isIndexed(collection) ? IndexedSeq(entries3) : SetSeq(entries3);
1552
+ }
1553
+ function maxFactory(collection, comparator, mapper) {
1554
+ if (!comparator) {
1555
+ comparator = defaultComparator;
1556
+ }
1557
+ if (mapper) {
1558
+ var entry = collection.toSeq().map(function(v, k) {
1559
+ return [v, mapper(v, k, collection)];
1560
+ }).reduce(function(a, b) {
1561
+ return maxCompare(comparator, a[1], b[1]) ? b : a;
1562
+ });
1563
+ return entry && entry[0];
1564
+ }
1565
+ return collection.reduce(function(a, b) {
1566
+ return maxCompare(comparator, a, b) ? b : a;
1567
+ });
1568
+ }
1569
+ function maxCompare(comparator, a, b) {
1570
+ var comp = comparator(b, a);
1571
+ return comp === 0 && b !== a && (b === void 0 || b === null || b !== b) || comp > 0;
1572
+ }
1573
+ function zipWithFactory(keyIter, zipper, iters, zipAll2) {
1574
+ var zipSequence = makeSequence(keyIter);
1575
+ var sizes = new ArraySeq(iters).map(function(i) {
1576
+ return i.size;
1577
+ });
1578
+ zipSequence.size = zipAll2 ? sizes.max() : sizes.min();
1579
+ zipSequence.__iterate = function(fn, reverse3) {
1580
+ var iterator = this.__iterator(ITERATE_VALUES, reverse3);
1581
+ var step;
1582
+ var iterations = 0;
1583
+ while (!(step = iterator.next()).done) {
1584
+ if (fn(step.value, iterations++, this) === false) {
1585
+ break;
1586
+ }
1587
+ }
1588
+ return iterations;
1589
+ };
1590
+ zipSequence.__iteratorUncached = function(type, reverse3) {
1591
+ var iterators = iters.map(
1592
+ function(i) {
1593
+ return i = Collection(i), getIterator(reverse3 ? i.reverse() : i);
1594
+ }
1595
+ );
1596
+ var iterations = 0;
1597
+ var isDone = false;
1598
+ return new Iterator(function() {
1599
+ var steps;
1600
+ if (!isDone) {
1601
+ steps = iterators.map(function(i) {
1602
+ return i.next();
1603
+ });
1604
+ isDone = zipAll2 ? steps.every(function(s) {
1605
+ return s.done;
1606
+ }) : steps.some(function(s) {
1607
+ return s.done;
1608
+ });
1609
+ }
1610
+ if (isDone) {
1611
+ return iteratorDone();
1612
+ }
1613
+ return iteratorValue(
1614
+ type,
1615
+ iterations++,
1616
+ zipper.apply(
1617
+ null,
1618
+ steps.map(function(s) {
1619
+ return s.value;
1620
+ })
1621
+ )
1622
+ );
1623
+ });
1624
+ };
1625
+ return zipSequence;
1626
+ }
1627
+ function reify(iter, seq) {
1628
+ return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
1629
+ }
1630
+ function validateEntry(entry) {
1631
+ if (entry !== Object(entry)) {
1632
+ throw new TypeError("Expected [K, V] tuple: " + entry);
1633
+ }
1634
+ }
1635
+ function collectionClass(collection) {
1636
+ return isKeyed(collection) ? KeyedCollection : isIndexed(collection) ? IndexedCollection : SetCollection;
1637
+ }
1638
+ function makeSequence(collection) {
1639
+ return Object.create(
1640
+ (isKeyed(collection) ? KeyedSeq : isIndexed(collection) ? IndexedSeq : SetSeq).prototype
1641
+ );
1642
+ }
1643
+ function cacheResultThrough() {
1644
+ if (this._iter.cacheResult) {
1645
+ this._iter.cacheResult();
1646
+ this.size = this._iter.size;
1647
+ return this;
1648
+ }
1649
+ return Seq.prototype.cacheResult.call(this);
1650
+ }
1651
+ function defaultComparator(a, b) {
1652
+ if (a === void 0 && b === void 0) {
1653
+ return 0;
1654
+ }
1655
+ if (a === void 0) {
1656
+ return 1;
1657
+ }
1658
+ if (b === void 0) {
1659
+ return -1;
1660
+ }
1661
+ return a > b ? 1 : a < b ? -1 : 0;
1662
+ }
1663
+ function arrCopy(arr, offset) {
1664
+ offset = offset || 0;
1665
+ var len = Math.max(0, arr.length - offset);
1666
+ var newArr = new Array(len);
1667
+ for (var ii = 0; ii < len; ii++) {
1668
+ newArr[ii] = arr[ii + offset];
1669
+ }
1670
+ return newArr;
1671
+ }
1672
+ function invariant(condition, error) {
1673
+ if (!condition) {
1674
+ throw new Error(error);
1675
+ }
1676
+ }
1677
+ function assertNotInfinite(size) {
1678
+ invariant(size !== Infinity, "Cannot perform this action with an infinite size.");
1679
+ }
1680
+ function coerceKeyPath(keyPath) {
1681
+ if (isArrayLike(keyPath) && typeof keyPath !== "string") {
1682
+ return keyPath;
1683
+ }
1684
+ if (isOrdered(keyPath)) {
1685
+ return keyPath.toArray();
1686
+ }
1687
+ throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: " + keyPath);
1688
+ }
1689
+ var toString2 = Object.prototype.toString;
1690
+ function isPlainObject(value) {
1691
+ if (!value || typeof value !== "object" || toString2.call(value) !== "[object Object]") {
1692
+ return false;
1693
+ }
1694
+ var proto = Object.getPrototypeOf(value);
1695
+ if (proto === null) {
1696
+ return true;
1697
+ }
1698
+ var parentProto = proto;
1699
+ var nextProto = Object.getPrototypeOf(proto);
1700
+ while (nextProto !== null) {
1701
+ parentProto = nextProto;
1702
+ nextProto = Object.getPrototypeOf(parentProto);
1703
+ }
1704
+ return parentProto === proto;
1705
+ }
1706
+ function isDataStructure(value) {
1707
+ return typeof value === "object" && (isImmutable(value) || Array.isArray(value) || isPlainObject(value));
1708
+ }
1709
+ function quoteString(value) {
1710
+ try {
1711
+ return typeof value === "string" ? JSON.stringify(value) : String(value);
1712
+ } catch (_ignoreError) {
1713
+ return JSON.stringify(value);
1714
+ }
1715
+ }
1716
+ function has(collection, key) {
1717
+ return isImmutable(collection) ? (
1718
+ // @ts-expect-error key might be a number or symbol, which is not handled be Record key type
1719
+ collection.has(key)
1720
+ ) : (
1721
+ // @ts-expect-error key might be anything else than PropertyKey, and will return false in that case but runtime is OK
1722
+ isDataStructure(collection) && hasOwnProperty.call(collection, key)
1723
+ );
1724
+ }
1725
+ function get(collection, key, notSetValue) {
1726
+ return isImmutable(collection) ? collection.get(key, notSetValue) : !has(collection, key) ? notSetValue : (
1727
+ // @ts-expect-error weird "get" here,
1728
+ typeof collection.get === "function" ? (
1729
+ // @ts-expect-error weird "get" here,
1730
+ collection.get(key)
1731
+ ) : (
1732
+ // @ts-expect-error key is unknown here,
1733
+ collection[key]
1734
+ )
1735
+ );
1736
+ }
1737
+ function shallowCopy(from) {
1738
+ if (Array.isArray(from)) {
1739
+ return arrCopy(from);
1740
+ }
1741
+ var to = {};
1742
+ for (var key in from) {
1743
+ if (hasOwnProperty.call(from, key)) {
1744
+ to[key] = from[key];
1745
+ }
1746
+ }
1747
+ return to;
1748
+ }
1749
+ function remove(collection, key) {
1750
+ if (!isDataStructure(collection)) {
1751
+ throw new TypeError("Cannot update non-data-structure value: " + collection);
1752
+ }
1753
+ if (isImmutable(collection)) {
1754
+ if (!collection.remove) {
1755
+ throw new TypeError("Cannot update immutable value without .remove() method: " + collection);
1756
+ }
1757
+ return collection.remove(key);
1758
+ }
1759
+ if (!hasOwnProperty.call(collection, key)) {
1760
+ return collection;
1761
+ }
1762
+ var collectionCopy = shallowCopy(collection);
1763
+ if (Array.isArray(collectionCopy)) {
1764
+ collectionCopy.splice(key, 1);
1765
+ } else {
1766
+ delete collectionCopy[key];
1767
+ }
1768
+ return collectionCopy;
1769
+ }
1770
+ function set(collection, key, value) {
1771
+ if (!isDataStructure(collection)) {
1772
+ throw new TypeError("Cannot update non-data-structure value: " + collection);
1773
+ }
1774
+ if (isImmutable(collection)) {
1775
+ if (!collection.set) {
1776
+ throw new TypeError("Cannot update immutable value without .set() method: " + collection);
1777
+ }
1778
+ return collection.set(key, value);
1779
+ }
1780
+ if (hasOwnProperty.call(collection, key) && value === collection[key]) {
1781
+ return collection;
1782
+ }
1783
+ var collectionCopy = shallowCopy(collection);
1784
+ collectionCopy[key] = value;
1785
+ return collectionCopy;
1786
+ }
1787
+ function updateIn$1(collection, keyPath, notSetValue, updater) {
1788
+ if (!updater) {
1789
+ updater = notSetValue;
1790
+ notSetValue = void 0;
1791
+ }
1792
+ var updatedValue = updateInDeeply(
1793
+ isImmutable(collection),
1794
+ // @ts-expect-error type issues with Record and mixed types
1795
+ collection,
1796
+ coerceKeyPath(keyPath),
1797
+ 0,
1798
+ notSetValue,
1799
+ updater
1800
+ );
1801
+ return updatedValue === NOT_SET ? notSetValue : updatedValue;
1802
+ }
1803
+ function updateInDeeply(inImmutable, existing, keyPath, i, notSetValue, updater) {
1804
+ var wasNotSet = existing === NOT_SET;
1805
+ if (i === keyPath.length) {
1806
+ var existingValue = wasNotSet ? notSetValue : existing;
1807
+ var newValue = updater(existingValue);
1808
+ return newValue === existingValue ? existing : newValue;
1809
+ }
1810
+ if (!wasNotSet && !isDataStructure(existing)) {
1811
+ throw new TypeError("Cannot update within non-data-structure value in path [" + Array.from(keyPath).slice(0, i).map(quoteString) + "]: " + existing);
1812
+ }
1813
+ var key = keyPath[i];
1814
+ if (typeof key === "undefined") {
1815
+ throw new TypeError("Index can not be undefined in updateIn(). This should not happen");
1816
+ }
1817
+ var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
1818
+ var nextUpdated = updateInDeeply(
1819
+ nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
1820
+ // @ts-expect-error mixed type
1821
+ nextExisting,
1822
+ keyPath,
1823
+ i + 1,
1824
+ notSetValue,
1825
+ updater
1826
+ );
1827
+ return nextUpdated === nextExisting ? existing : nextUpdated === NOT_SET ? remove(existing, key) : set(wasNotSet ? inImmutable ? emptyMap() : {} : existing, key, nextUpdated);
1828
+ }
1829
+ function setIn$1(collection, keyPath, value) {
1830
+ return updateIn$1(collection, keyPath, NOT_SET, function() {
1831
+ return value;
1832
+ });
1833
+ }
1834
+ function setIn(keyPath, v) {
1835
+ return setIn$1(this, keyPath, v);
1836
+ }
1837
+ function removeIn(collection, keyPath) {
1838
+ return updateIn$1(collection, keyPath, function() {
1839
+ return NOT_SET;
1840
+ });
1841
+ }
1842
+ function deleteIn(keyPath) {
1843
+ return removeIn(this, keyPath);
1844
+ }
1845
+ function update$1(collection, key, notSetValue, updater) {
1846
+ return updateIn$1(
1847
+ // @ts-expect-error Index signature for type string is missing in type V[]
1848
+ collection,
1849
+ [key],
1850
+ notSetValue,
1851
+ updater
1852
+ );
1853
+ }
1854
+ function update(key, notSetValue, updater) {
1855
+ return arguments.length === 1 ? key(this) : update$1(this, key, notSetValue, updater);
1856
+ }
1857
+ function updateIn(keyPath, notSetValue, updater) {
1858
+ return updateIn$1(this, keyPath, notSetValue, updater);
1859
+ }
1860
+ function merge$1() {
1861
+ var iters = [], len = arguments.length;
1862
+ while (len--) iters[len] = arguments[len];
1863
+ return mergeIntoKeyedWith(this, iters);
1864
+ }
1865
+ function mergeWith$1(merger) {
1866
+ var iters = [], len = arguments.length - 1;
1867
+ while (len-- > 0) iters[len] = arguments[len + 1];
1868
+ if (typeof merger !== "function") {
1869
+ throw new TypeError("Invalid merger function: " + merger);
1870
+ }
1871
+ return mergeIntoKeyedWith(this, iters, merger);
1872
+ }
1873
+ function mergeIntoKeyedWith(collection, collections, merger) {
1874
+ var iters = [];
1875
+ for (var ii = 0; ii < collections.length; ii++) {
1876
+ var collection$1 = KeyedCollection(collections[ii]);
1877
+ if (collection$1.size !== 0) {
1878
+ iters.push(collection$1);
1879
+ }
1880
+ }
1881
+ if (iters.length === 0) {
1882
+ return collection;
1883
+ }
1884
+ if (collection.toSeq().size === 0 && !collection.__ownerID && iters.length === 1) {
1885
+ return collection.constructor(iters[0]);
1886
+ }
1887
+ return collection.withMutations(function(collection2) {
1888
+ var mergeIntoCollection = merger ? function(value, key) {
1889
+ update$1(
1890
+ collection2,
1891
+ key,
1892
+ NOT_SET,
1893
+ function(oldVal) {
1894
+ return oldVal === NOT_SET ? value : merger(oldVal, value, key);
1895
+ }
1896
+ );
1897
+ } : function(value, key) {
1898
+ collection2.set(key, value);
1899
+ };
1900
+ for (var ii2 = 0; ii2 < iters.length; ii2++) {
1901
+ iters[ii2].forEach(mergeIntoCollection);
1902
+ }
1903
+ });
1904
+ }
1905
+ function mergeDeepWithSources(collection, sources, merger) {
1906
+ return mergeWithSources(collection, sources, deepMergerWith(merger));
1907
+ }
1908
+ function mergeWithSources(collection, sources, merger) {
1909
+ if (!isDataStructure(collection)) {
1910
+ throw new TypeError(
1911
+ "Cannot merge into non-data-structure value: " + collection
1912
+ );
1913
+ }
1914
+ if (isImmutable(collection)) {
1915
+ return typeof merger === "function" && collection.mergeWith ? collection.mergeWith.apply(collection, [merger].concat(sources)) : collection.merge ? collection.merge.apply(collection, sources) : collection.concat.apply(collection, sources);
1916
+ }
1917
+ var isArray = Array.isArray(collection);
1918
+ var merged = collection;
1919
+ var Collection3 = isArray ? IndexedCollection : KeyedCollection;
1920
+ var mergeItem = isArray ? function(value) {
1921
+ if (merged === collection) {
1922
+ merged = shallowCopy(merged);
1923
+ }
1924
+ merged.push(value);
1925
+ } : function(value, key) {
1926
+ var hasVal = hasOwnProperty.call(merged, key);
1927
+ var nextVal = hasVal && merger ? merger(merged[key], value, key) : value;
1928
+ if (!hasVal || nextVal !== merged[key]) {
1929
+ if (merged === collection) {
1930
+ merged = shallowCopy(merged);
1931
+ }
1932
+ merged[key] = nextVal;
1933
+ }
1934
+ };
1935
+ for (var i = 0; i < sources.length; i++) {
1936
+ Collection3(sources[i]).forEach(mergeItem);
1937
+ }
1938
+ return merged;
1939
+ }
1940
+ function deepMergerWith(merger) {
1941
+ function deepMerger(oldValue, newValue, key) {
1942
+ return isDataStructure(oldValue) && isDataStructure(newValue) && areMergeable(oldValue, newValue) ? mergeWithSources(oldValue, [newValue], deepMerger) : merger ? merger(oldValue, newValue, key) : newValue;
1943
+ }
1944
+ return deepMerger;
1945
+ }
1946
+ function areMergeable(oldDataStructure, newDataStructure) {
1947
+ var oldSeq = Seq(oldDataStructure);
1948
+ var newSeq = Seq(newDataStructure);
1949
+ return isIndexed(oldSeq) === isIndexed(newSeq) && isKeyed(oldSeq) === isKeyed(newSeq);
1950
+ }
1951
+ function mergeDeep() {
1952
+ var iters = [], len = arguments.length;
1953
+ while (len--) iters[len] = arguments[len];
1954
+ return mergeDeepWithSources(this, iters);
1955
+ }
1956
+ function mergeDeepWith(merger) {
1957
+ var iters = [], len = arguments.length - 1;
1958
+ while (len-- > 0) iters[len] = arguments[len + 1];
1959
+ return mergeDeepWithSources(this, iters, merger);
1960
+ }
1961
+ function mergeIn(keyPath) {
1962
+ var iters = [], len = arguments.length - 1;
1963
+ while (len-- > 0) iters[len] = arguments[len + 1];
1964
+ return updateIn$1(this, keyPath, emptyMap(), function(m) {
1965
+ return mergeWithSources(m, iters);
1966
+ });
1967
+ }
1968
+ function mergeDeepIn(keyPath) {
1969
+ var iters = [], len = arguments.length - 1;
1970
+ while (len-- > 0) iters[len] = arguments[len + 1];
1971
+ return updateIn$1(
1972
+ this,
1973
+ keyPath,
1974
+ emptyMap(),
1975
+ function(m) {
1976
+ return mergeDeepWithSources(m, iters);
1977
+ }
1978
+ );
1979
+ }
1980
+ function withMutations(fn) {
1981
+ var mutable = this.asMutable();
1982
+ fn(mutable);
1983
+ return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
1984
+ }
1985
+ function asMutable() {
1986
+ return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
1987
+ }
1988
+ function asImmutable() {
1989
+ return this.__ensureOwner();
1990
+ }
1991
+ function wasAltered() {
1992
+ return this.__altered;
1993
+ }
1994
+ var Map = /* @__PURE__ */ function(KeyedCollection2) {
1995
+ function Map2(value) {
1996
+ return value === void 0 || value === null ? emptyMap() : isMap(value) && !isOrdered(value) ? value : emptyMap().withMutations(function(map5) {
1997
+ var iter = KeyedCollection2(value);
1998
+ assertNotInfinite(iter.size);
1999
+ iter.forEach(function(v, k) {
2000
+ return map5.set(k, v);
2001
+ });
2002
+ });
2003
+ }
2004
+ if (KeyedCollection2) Map2.__proto__ = KeyedCollection2;
2005
+ Map2.prototype = Object.create(KeyedCollection2 && KeyedCollection2.prototype);
2006
+ Map2.prototype.constructor = Map2;
2007
+ Map2.prototype.toString = function toString5() {
2008
+ return this.__toString("Map {", "}");
2009
+ };
2010
+ Map2.prototype.get = function get11(k, notSetValue) {
2011
+ return this._root ? this._root.get(0, void 0, k, notSetValue) : notSetValue;
2012
+ };
2013
+ Map2.prototype.set = function set3(k, v) {
2014
+ return updateMap(this, k, v);
2015
+ };
2016
+ Map2.prototype.remove = function remove3(k) {
2017
+ return updateMap(this, k, NOT_SET);
2018
+ };
2019
+ Map2.prototype.deleteAll = function deleteAll(keys2) {
2020
+ var collection = Collection(keys2);
2021
+ if (collection.size === 0) {
2022
+ return this;
2023
+ }
2024
+ return this.withMutations(function(map5) {
2025
+ collection.forEach(function(key) {
2026
+ return map5.remove(key);
2027
+ });
2028
+ });
2029
+ };
2030
+ Map2.prototype.clear = function clear2() {
2031
+ if (this.size === 0) {
2032
+ return this;
2033
+ }
2034
+ if (this.__ownerID) {
2035
+ this.size = 0;
2036
+ this._root = null;
2037
+ this.__hash = void 0;
2038
+ this.__altered = true;
2039
+ return this;
2040
+ }
2041
+ return emptyMap();
2042
+ };
2043
+ Map2.prototype.sort = function sort2(comparator) {
2044
+ return OrderedMap(sortFactory(this, comparator));
2045
+ };
2046
+ Map2.prototype.sortBy = function sortBy2(mapper, comparator) {
2047
+ return OrderedMap(sortFactory(this, comparator, mapper));
2048
+ };
2049
+ Map2.prototype.map = function map5(mapper, context) {
2050
+ var this$1$1 = this;
2051
+ return this.withMutations(function(map6) {
2052
+ map6.forEach(function(value, key) {
2053
+ map6.set(key, mapper.call(context, value, key, this$1$1));
2054
+ });
2055
+ });
2056
+ };
2057
+ Map2.prototype.__iterator = function __iterator2(type, reverse3) {
2058
+ return new MapIterator(this, type, reverse3);
2059
+ };
2060
+ Map2.prototype.__iterate = function __iterate2(fn, reverse3) {
2061
+ var this$1$1 = this;
2062
+ var iterations = 0;
2063
+ this._root && this._root.iterate(function(entry) {
2064
+ iterations++;
2065
+ return fn(entry[1], entry[0], this$1$1);
2066
+ }, reverse3);
2067
+ return iterations;
2068
+ };
2069
+ Map2.prototype.__ensureOwner = function __ensureOwner2(ownerID) {
2070
+ if (ownerID === this.__ownerID) {
2071
+ return this;
2072
+ }
2073
+ if (!ownerID) {
2074
+ if (this.size === 0) {
2075
+ return emptyMap();
2076
+ }
2077
+ this.__ownerID = ownerID;
2078
+ this.__altered = false;
2079
+ return this;
2080
+ }
2081
+ return makeMap(this.size, this._root, ownerID, this.__hash);
2082
+ };
2083
+ return Map2;
2084
+ }(KeyedCollection);
2085
+ Map.isMap = isMap;
2086
+ var MapPrototype = Map.prototype;
2087
+ MapPrototype[IS_MAP_SYMBOL] = true;
2088
+ MapPrototype[DELETE] = MapPrototype.remove;
2089
+ MapPrototype.removeAll = MapPrototype.deleteAll;
2090
+ MapPrototype.setIn = setIn;
2091
+ MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
2092
+ MapPrototype.update = update;
2093
+ MapPrototype.updateIn = updateIn;
2094
+ MapPrototype.merge = MapPrototype.concat = merge$1;
2095
+ MapPrototype.mergeWith = mergeWith$1;
2096
+ MapPrototype.mergeDeep = mergeDeep;
2097
+ MapPrototype.mergeDeepWith = mergeDeepWith;
2098
+ MapPrototype.mergeIn = mergeIn;
2099
+ MapPrototype.mergeDeepIn = mergeDeepIn;
2100
+ MapPrototype.withMutations = withMutations;
2101
+ MapPrototype.wasAltered = wasAltered;
2102
+ MapPrototype.asImmutable = asImmutable;
2103
+ MapPrototype["@@transducer/init"] = MapPrototype.asMutable = asMutable;
2104
+ MapPrototype["@@transducer/step"] = function(result, arr) {
2105
+ return result.set(arr[0], arr[1]);
2106
+ };
2107
+ MapPrototype["@@transducer/result"] = function(obj) {
2108
+ return obj.asImmutable();
2109
+ };
2110
+ var ArrayMapNode = function ArrayMapNode2(ownerID, entries3) {
2111
+ this.ownerID = ownerID;
2112
+ this.entries = entries3;
2113
+ };
2114
+ ArrayMapNode.prototype.get = function get2(shift, keyHash, key, notSetValue) {
2115
+ var entries3 = this.entries;
2116
+ for (var ii = 0, len = entries3.length; ii < len; ii++) {
2117
+ if (is(key, entries3[ii][0])) {
2118
+ return entries3[ii][1];
2119
+ }
2120
+ }
2121
+ return notSetValue;
2122
+ };
2123
+ ArrayMapNode.prototype.update = function update2(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2124
+ var removed = value === NOT_SET;
2125
+ var entries3 = this.entries;
2126
+ var idx = 0;
2127
+ var len = entries3.length;
2128
+ for (; idx < len; idx++) {
2129
+ if (is(key, entries3[idx][0])) {
2130
+ break;
2131
+ }
2132
+ }
2133
+ var exists = idx < len;
2134
+ if (exists ? entries3[idx][1] === value : removed) {
2135
+ return this;
2136
+ }
2137
+ SetRef(didAlter);
2138
+ (removed || !exists) && SetRef(didChangeSize);
2139
+ if (removed && entries3.length === 1) {
2140
+ return;
2141
+ }
2142
+ if (!exists && !removed && entries3.length >= MAX_ARRAY_MAP_SIZE) {
2143
+ return createNodes(ownerID, entries3, key, value);
2144
+ }
2145
+ var isEditable = ownerID && ownerID === this.ownerID;
2146
+ var newEntries = isEditable ? entries3 : arrCopy(entries3);
2147
+ if (exists) {
2148
+ if (removed) {
2149
+ idx === len - 1 ? newEntries.pop() : newEntries[idx] = newEntries.pop();
2150
+ } else {
2151
+ newEntries[idx] = [key, value];
2152
+ }
2153
+ } else {
2154
+ newEntries.push([key, value]);
2155
+ }
2156
+ if (isEditable) {
2157
+ this.entries = newEntries;
2158
+ return this;
2159
+ }
2160
+ return new ArrayMapNode(ownerID, newEntries);
2161
+ };
2162
+ var BitmapIndexedNode = function BitmapIndexedNode2(ownerID, bitmap, nodes) {
2163
+ this.ownerID = ownerID;
2164
+ this.bitmap = bitmap;
2165
+ this.nodes = nodes;
2166
+ };
2167
+ BitmapIndexedNode.prototype.get = function get3(shift, keyHash, key, notSetValue) {
2168
+ if (keyHash === void 0) {
2169
+ keyHash = hash(key);
2170
+ }
2171
+ var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
2172
+ var bitmap = this.bitmap;
2173
+ return (bitmap & bit) === 0 ? notSetValue : this.nodes[popCount(bitmap & bit - 1)].get(
2174
+ shift + SHIFT,
2175
+ keyHash,
2176
+ key,
2177
+ notSetValue
2178
+ );
2179
+ };
2180
+ BitmapIndexedNode.prototype.update = function update3(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2181
+ if (keyHash === void 0) {
2182
+ keyHash = hash(key);
2183
+ }
2184
+ var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
2185
+ var bit = 1 << keyHashFrag;
2186
+ var bitmap = this.bitmap;
2187
+ var exists = (bitmap & bit) !== 0;
2188
+ if (!exists && value === NOT_SET) {
2189
+ return this;
2190
+ }
2191
+ var idx = popCount(bitmap & bit - 1);
2192
+ var nodes = this.nodes;
2193
+ var node = exists ? nodes[idx] : void 0;
2194
+ var newNode = updateNode(
2195
+ node,
2196
+ ownerID,
2197
+ shift + SHIFT,
2198
+ keyHash,
2199
+ key,
2200
+ value,
2201
+ didChangeSize,
2202
+ didAlter
2203
+ );
2204
+ if (newNode === node) {
2205
+ return this;
2206
+ }
2207
+ if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
2208
+ return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
2209
+ }
2210
+ if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
2211
+ return nodes[idx ^ 1];
2212
+ }
2213
+ if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
2214
+ return newNode;
2215
+ }
2216
+ var isEditable = ownerID && ownerID === this.ownerID;
2217
+ var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
2218
+ var newNodes = exists ? newNode ? setAt(nodes, idx, newNode, isEditable) : spliceOut(nodes, idx, isEditable) : spliceIn(nodes, idx, newNode, isEditable);
2219
+ if (isEditable) {
2220
+ this.bitmap = newBitmap;
2221
+ this.nodes = newNodes;
2222
+ return this;
2223
+ }
2224
+ return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
2225
+ };
2226
+ var HashArrayMapNode = function HashArrayMapNode2(ownerID, count2, nodes) {
2227
+ this.ownerID = ownerID;
2228
+ this.count = count2;
2229
+ this.nodes = nodes;
2230
+ };
2231
+ HashArrayMapNode.prototype.get = function get4(shift, keyHash, key, notSetValue) {
2232
+ if (keyHash === void 0) {
2233
+ keyHash = hash(key);
2234
+ }
2235
+ var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
2236
+ var node = this.nodes[idx];
2237
+ return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
2238
+ };
2239
+ HashArrayMapNode.prototype.update = function update4(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2240
+ if (keyHash === void 0) {
2241
+ keyHash = hash(key);
2242
+ }
2243
+ var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
2244
+ var removed = value === NOT_SET;
2245
+ var nodes = this.nodes;
2246
+ var node = nodes[idx];
2247
+ if (removed && !node) {
2248
+ return this;
2249
+ }
2250
+ var newNode = updateNode(
2251
+ node,
2252
+ ownerID,
2253
+ shift + SHIFT,
2254
+ keyHash,
2255
+ key,
2256
+ value,
2257
+ didChangeSize,
2258
+ didAlter
2259
+ );
2260
+ if (newNode === node) {
2261
+ return this;
2262
+ }
2263
+ var newCount = this.count;
2264
+ if (!node) {
2265
+ newCount++;
2266
+ } else if (!newNode) {
2267
+ newCount--;
2268
+ if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
2269
+ return packNodes(ownerID, nodes, newCount, idx);
2270
+ }
2271
+ }
2272
+ var isEditable = ownerID && ownerID === this.ownerID;
2273
+ var newNodes = setAt(nodes, idx, newNode, isEditable);
2274
+ if (isEditable) {
2275
+ this.count = newCount;
2276
+ this.nodes = newNodes;
2277
+ return this;
2278
+ }
2279
+ return new HashArrayMapNode(ownerID, newCount, newNodes);
2280
+ };
2281
+ var HashCollisionNode = function HashCollisionNode2(ownerID, keyHash, entries3) {
2282
+ this.ownerID = ownerID;
2283
+ this.keyHash = keyHash;
2284
+ this.entries = entries3;
2285
+ };
2286
+ HashCollisionNode.prototype.get = function get5(shift, keyHash, key, notSetValue) {
2287
+ var entries3 = this.entries;
2288
+ for (var ii = 0, len = entries3.length; ii < len; ii++) {
2289
+ if (is(key, entries3[ii][0])) {
2290
+ return entries3[ii][1];
2291
+ }
2292
+ }
2293
+ return notSetValue;
2294
+ };
2295
+ HashCollisionNode.prototype.update = function update5(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2296
+ if (keyHash === void 0) {
2297
+ keyHash = hash(key);
2298
+ }
2299
+ var removed = value === NOT_SET;
2300
+ if (keyHash !== this.keyHash) {
2301
+ if (removed) {
2302
+ return this;
2303
+ }
2304
+ SetRef(didAlter);
2305
+ SetRef(didChangeSize);
2306
+ return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
2307
+ }
2308
+ var entries3 = this.entries;
2309
+ var idx = 0;
2310
+ var len = entries3.length;
2311
+ for (; idx < len; idx++) {
2312
+ if (is(key, entries3[idx][0])) {
2313
+ break;
2314
+ }
2315
+ }
2316
+ var exists = idx < len;
2317
+ if (exists ? entries3[idx][1] === value : removed) {
2318
+ return this;
2319
+ }
2320
+ SetRef(didAlter);
2321
+ (removed || !exists) && SetRef(didChangeSize);
2322
+ if (removed && len === 2) {
2323
+ return new ValueNode(ownerID, this.keyHash, entries3[idx ^ 1]);
2324
+ }
2325
+ var isEditable = ownerID && ownerID === this.ownerID;
2326
+ var newEntries = isEditable ? entries3 : arrCopy(entries3);
2327
+ if (exists) {
2328
+ if (removed) {
2329
+ idx === len - 1 ? newEntries.pop() : newEntries[idx] = newEntries.pop();
2330
+ } else {
2331
+ newEntries[idx] = [key, value];
2332
+ }
2333
+ } else {
2334
+ newEntries.push([key, value]);
2335
+ }
2336
+ if (isEditable) {
2337
+ this.entries = newEntries;
2338
+ return this;
2339
+ }
2340
+ return new HashCollisionNode(ownerID, this.keyHash, newEntries);
2341
+ };
2342
+ var ValueNode = function ValueNode2(ownerID, keyHash, entry) {
2343
+ this.ownerID = ownerID;
2344
+ this.keyHash = keyHash;
2345
+ this.entry = entry;
2346
+ };
2347
+ ValueNode.prototype.get = function get6(shift, keyHash, key, notSetValue) {
2348
+ return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
2349
+ };
2350
+ ValueNode.prototype.update = function update6(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2351
+ var removed = value === NOT_SET;
2352
+ var keyMatch = is(key, this.entry[0]);
2353
+ if (keyMatch ? value === this.entry[1] : removed) {
2354
+ return this;
2355
+ }
2356
+ SetRef(didAlter);
2357
+ if (removed) {
2358
+ SetRef(didChangeSize);
2359
+ return;
2360
+ }
2361
+ if (keyMatch) {
2362
+ if (ownerID && ownerID === this.ownerID) {
2363
+ this.entry[1] = value;
2364
+ return this;
2365
+ }
2366
+ return new ValueNode(ownerID, this.keyHash, [key, value]);
2367
+ }
2368
+ SetRef(didChangeSize);
2369
+ return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
2370
+ };
2371
+ ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(fn, reverse3) {
2372
+ var entries3 = this.entries;
2373
+ for (var ii = 0, maxIndex = entries3.length - 1; ii <= maxIndex; ii++) {
2374
+ if (fn(entries3[reverse3 ? maxIndex - ii : ii]) === false) {
2375
+ return false;
2376
+ }
2377
+ }
2378
+ };
2379
+ BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(fn, reverse3) {
2380
+ var nodes = this.nodes;
2381
+ for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
2382
+ var node = nodes[reverse3 ? maxIndex - ii : ii];
2383
+ if (node && node.iterate(fn, reverse3) === false) {
2384
+ return false;
2385
+ }
2386
+ }
2387
+ };
2388
+ ValueNode.prototype.iterate = function(fn, reverse3) {
2389
+ return fn(this.entry);
2390
+ };
2391
+ var MapIterator = /* @__PURE__ */ function(Iterator3) {
2392
+ function MapIterator2(map5, type, reverse3) {
2393
+ this._type = type;
2394
+ this._reverse = reverse3;
2395
+ this._stack = map5._root && mapIteratorFrame(map5._root);
2396
+ }
2397
+ if (Iterator3) MapIterator2.__proto__ = Iterator3;
2398
+ MapIterator2.prototype = Object.create(Iterator3 && Iterator3.prototype);
2399
+ MapIterator2.prototype.constructor = MapIterator2;
2400
+ MapIterator2.prototype.next = function next() {
2401
+ var type = this._type;
2402
+ var stack = this._stack;
2403
+ while (stack) {
2404
+ var node = stack.node;
2405
+ var index = stack.index++;
2406
+ var maxIndex = void 0;
2407
+ if (node.entry) {
2408
+ if (index === 0) {
2409
+ return mapIteratorValue(type, node.entry);
2410
+ }
2411
+ } else if (node.entries) {
2412
+ maxIndex = node.entries.length - 1;
2413
+ if (index <= maxIndex) {
2414
+ return mapIteratorValue(
2415
+ type,
2416
+ node.entries[this._reverse ? maxIndex - index : index]
2417
+ );
2418
+ }
2419
+ } else {
2420
+ maxIndex = node.nodes.length - 1;
2421
+ if (index <= maxIndex) {
2422
+ var subNode = node.nodes[this._reverse ? maxIndex - index : index];
2423
+ if (subNode) {
2424
+ if (subNode.entry) {
2425
+ return mapIteratorValue(type, subNode.entry);
2426
+ }
2427
+ stack = this._stack = mapIteratorFrame(subNode, stack);
2428
+ }
2429
+ continue;
2430
+ }
2431
+ }
2432
+ stack = this._stack = this._stack.__prev;
2433
+ }
2434
+ return iteratorDone();
2435
+ };
2436
+ return MapIterator2;
2437
+ }(Iterator);
2438
+ function mapIteratorValue(type, entry) {
2439
+ return iteratorValue(type, entry[0], entry[1]);
2440
+ }
2441
+ function mapIteratorFrame(node, prev) {
2442
+ return {
2443
+ node,
2444
+ index: 0,
2445
+ __prev: prev
2446
+ };
2447
+ }
2448
+ function makeMap(size, root, ownerID, hash2) {
2449
+ var map5 = Object.create(MapPrototype);
2450
+ map5.size = size;
2451
+ map5._root = root;
2452
+ map5.__ownerID = ownerID;
2453
+ map5.__hash = hash2;
2454
+ map5.__altered = false;
2455
+ return map5;
2456
+ }
2457
+ var EMPTY_MAP;
2458
+ function emptyMap() {
2459
+ return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
2460
+ }
2461
+ function updateMap(map5, k, v) {
2462
+ var newRoot;
2463
+ var newSize;
2464
+ if (!map5._root) {
2465
+ if (v === NOT_SET) {
2466
+ return map5;
2467
+ }
2468
+ newSize = 1;
2469
+ newRoot = new ArrayMapNode(map5.__ownerID, [[k, v]]);
2470
+ } else {
2471
+ var didChangeSize = MakeRef();
2472
+ var didAlter = MakeRef();
2473
+ newRoot = updateNode(
2474
+ map5._root,
2475
+ map5.__ownerID,
2476
+ 0,
2477
+ void 0,
2478
+ k,
2479
+ v,
2480
+ didChangeSize,
2481
+ didAlter
2482
+ );
2483
+ if (!didAlter.value) {
2484
+ return map5;
2485
+ }
2486
+ newSize = map5.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
2487
+ }
2488
+ if (map5.__ownerID) {
2489
+ map5.size = newSize;
2490
+ map5._root = newRoot;
2491
+ map5.__hash = void 0;
2492
+ map5.__altered = true;
2493
+ return map5;
2494
+ }
2495
+ return newRoot ? makeMap(newSize, newRoot) : emptyMap();
2496
+ }
2497
+ function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
2498
+ if (!node) {
2499
+ if (value === NOT_SET) {
2500
+ return node;
2501
+ }
2502
+ SetRef(didAlter);
2503
+ SetRef(didChangeSize);
2504
+ return new ValueNode(ownerID, keyHash, [key, value]);
2505
+ }
2506
+ return node.update(
2507
+ ownerID,
2508
+ shift,
2509
+ keyHash,
2510
+ key,
2511
+ value,
2512
+ didChangeSize,
2513
+ didAlter
2514
+ );
2515
+ }
2516
+ function isLeafNode(node) {
2517
+ return node.constructor === ValueNode || node.constructor === HashCollisionNode;
2518
+ }
2519
+ function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
2520
+ if (node.keyHash === keyHash) {
2521
+ return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
2522
+ }
2523
+ var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
2524
+ var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
2525
+ var newNode;
2526
+ var nodes = idx1 === idx2 ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] : (newNode = new ValueNode(ownerID, keyHash, entry), idx1 < idx2 ? [node, newNode] : [newNode, node]);
2527
+ return new BitmapIndexedNode(ownerID, 1 << idx1 | 1 << idx2, nodes);
2528
+ }
2529
+ function createNodes(ownerID, entries3, key, value) {
2530
+ if (!ownerID) {
2531
+ ownerID = new OwnerID();
2532
+ }
2533
+ var node = new ValueNode(ownerID, hash(key), [key, value]);
2534
+ for (var ii = 0; ii < entries3.length; ii++) {
2535
+ var entry = entries3[ii];
2536
+ node = node.update(ownerID, 0, void 0, entry[0], entry[1]);
2537
+ }
2538
+ return node;
2539
+ }
2540
+ function packNodes(ownerID, nodes, count2, excluding) {
2541
+ var bitmap = 0;
2542
+ var packedII = 0;
2543
+ var packedNodes = new Array(count2);
2544
+ for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
2545
+ var node = nodes[ii];
2546
+ if (node !== void 0 && ii !== excluding) {
2547
+ bitmap |= bit;
2548
+ packedNodes[packedII++] = node;
2549
+ }
2550
+ }
2551
+ return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
2552
+ }
2553
+ function expandNodes(ownerID, nodes, bitmap, including, node) {
2554
+ var count2 = 0;
2555
+ var expandedNodes = new Array(SIZE);
2556
+ for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
2557
+ expandedNodes[ii] = bitmap & 1 ? nodes[count2++] : void 0;
2558
+ }
2559
+ expandedNodes[including] = node;
2560
+ return new HashArrayMapNode(ownerID, count2 + 1, expandedNodes);
2561
+ }
2562
+ function popCount(x) {
2563
+ x -= x >> 1 & 1431655765;
2564
+ x = (x & 858993459) + (x >> 2 & 858993459);
2565
+ x = x + (x >> 4) & 252645135;
2566
+ x += x >> 8;
2567
+ x += x >> 16;
2568
+ return x & 127;
2569
+ }
2570
+ function setAt(array, idx, val, canEdit) {
2571
+ var newArray = canEdit ? array : arrCopy(array);
2572
+ newArray[idx] = val;
2573
+ return newArray;
2574
+ }
2575
+ function spliceIn(array, idx, val, canEdit) {
2576
+ var newLen = array.length + 1;
2577
+ if (canEdit && idx + 1 === newLen) {
2578
+ array[idx] = val;
2579
+ return array;
2580
+ }
2581
+ var newArray = new Array(newLen);
2582
+ var after = 0;
2583
+ for (var ii = 0; ii < newLen; ii++) {
2584
+ if (ii === idx) {
2585
+ newArray[ii] = val;
2586
+ after = -1;
2587
+ } else {
2588
+ newArray[ii] = array[ii + after];
2589
+ }
2590
+ }
2591
+ return newArray;
2592
+ }
2593
+ function spliceOut(array, idx, canEdit) {
2594
+ var newLen = array.length - 1;
2595
+ if (canEdit && idx === newLen) {
2596
+ array.pop();
2597
+ return array;
2598
+ }
2599
+ var newArray = new Array(newLen);
2600
+ var after = 0;
2601
+ for (var ii = 0; ii < newLen; ii++) {
2602
+ if (ii === idx) {
2603
+ after = 1;
2604
+ }
2605
+ newArray[ii] = array[ii + after];
2606
+ }
2607
+ return newArray;
2608
+ }
2609
+ var MAX_ARRAY_MAP_SIZE = SIZE / 4;
2610
+ var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
2611
+ var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
2612
+ var IS_LIST_SYMBOL = "@@__IMMUTABLE_LIST__@@";
2613
+ function isList(maybeList) {
2614
+ return Boolean(maybeList && // @ts-expect-error: maybeList is typed as `{}`, need to change in 6.0 to `maybeList && typeof maybeList === 'object' && IS_LIST_SYMBOL in maybeList`
2615
+ maybeList[IS_LIST_SYMBOL]);
2616
+ }
2617
+ var List = /* @__PURE__ */ function(IndexedCollection2) {
2618
+ function List2(value) {
2619
+ var empty = emptyList();
2620
+ if (value === void 0 || value === null) {
2621
+ return empty;
2622
+ }
2623
+ if (isList(value)) {
2624
+ return value;
2625
+ }
2626
+ var iter = IndexedCollection2(value);
2627
+ var size = iter.size;
2628
+ if (size === 0) {
2629
+ return empty;
2630
+ }
2631
+ assertNotInfinite(size);
2632
+ if (size > 0 && size < SIZE) {
2633
+ return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
2634
+ }
2635
+ return empty.withMutations(function(list) {
2636
+ list.setSize(size);
2637
+ iter.forEach(function(v, i) {
2638
+ return list.set(i, v);
2639
+ });
2640
+ });
2641
+ }
2642
+ if (IndexedCollection2) List2.__proto__ = IndexedCollection2;
2643
+ List2.prototype = Object.create(IndexedCollection2 && IndexedCollection2.prototype);
2644
+ List2.prototype.constructor = List2;
2645
+ List2.of = function of3() {
2646
+ return this(arguments);
2647
+ };
2648
+ List2.prototype.toString = function toString5() {
2649
+ return this.__toString("List [", "]");
2650
+ };
2651
+ List2.prototype.get = function get11(index, notSetValue) {
2652
+ index = wrapIndex(this, index);
2653
+ if (index >= 0 && index < this.size) {
2654
+ index += this._origin;
2655
+ var node = listNodeFor(this, index);
2656
+ return node && node.array[index & MASK];
2657
+ }
2658
+ return notSetValue;
2659
+ };
2660
+ List2.prototype.set = function set3(index, value) {
2661
+ return updateList(this, index, value);
2662
+ };
2663
+ List2.prototype.remove = function remove3(index) {
2664
+ return !this.has(index) ? this : index === 0 ? this.shift() : index === this.size - 1 ? this.pop() : this.splice(index, 1);
2665
+ };
2666
+ List2.prototype.insert = function insert(index, value) {
2667
+ return this.splice(index, 0, value);
2668
+ };
2669
+ List2.prototype.clear = function clear2() {
2670
+ if (this.size === 0) {
2671
+ return this;
2672
+ }
2673
+ if (this.__ownerID) {
2674
+ this.size = this._origin = this._capacity = 0;
2675
+ this._level = SHIFT;
2676
+ this._root = this._tail = this.__hash = void 0;
2677
+ this.__altered = true;
2678
+ return this;
2679
+ }
2680
+ return emptyList();
2681
+ };
2682
+ List2.prototype.push = function push() {
2683
+ var values2 = arguments;
2684
+ var oldSize = this.size;
2685
+ return this.withMutations(function(list) {
2686
+ setListBounds(list, 0, oldSize + values2.length);
2687
+ for (var ii = 0; ii < values2.length; ii++) {
2688
+ list.set(oldSize + ii, values2[ii]);
2689
+ }
2690
+ });
2691
+ };
2692
+ List2.prototype.pop = function pop() {
2693
+ return setListBounds(this, 0, -1);
2694
+ };
2695
+ List2.prototype.unshift = function unshift() {
2696
+ var values2 = arguments;
2697
+ return this.withMutations(function(list) {
2698
+ setListBounds(list, -values2.length);
2699
+ for (var ii = 0; ii < values2.length; ii++) {
2700
+ list.set(ii, values2[ii]);
2701
+ }
2702
+ });
2703
+ };
2704
+ List2.prototype.shift = function shift() {
2705
+ return setListBounds(this, 1);
2706
+ };
2707
+ List2.prototype.shuffle = function shuffle(random) {
2708
+ if (random === void 0) random = Math.random;
2709
+ return this.withMutations(function(mutable) {
2710
+ var current = mutable.size;
2711
+ var destination;
2712
+ var tmp;
2713
+ while (current) {
2714
+ destination = Math.floor(random() * current--);
2715
+ tmp = mutable.get(destination);
2716
+ mutable.set(destination, mutable.get(current));
2717
+ mutable.set(current, tmp);
2718
+ }
2719
+ });
2720
+ };
2721
+ List2.prototype.concat = function concat2() {
2722
+ var arguments$1 = arguments;
2723
+ var seqs = [];
2724
+ for (var i = 0; i < arguments.length; i++) {
2725
+ var argument = arguments$1[i];
2726
+ var seq = IndexedCollection2(
2727
+ typeof argument !== "string" && hasIterator(argument) ? argument : [argument]
2728
+ );
2729
+ if (seq.size !== 0) {
2730
+ seqs.push(seq);
2731
+ }
2732
+ }
2733
+ if (seqs.length === 0) {
2734
+ return this;
2735
+ }
2736
+ if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
2737
+ return this.constructor(seqs[0]);
2738
+ }
2739
+ return this.withMutations(function(list) {
2740
+ seqs.forEach(function(seq2) {
2741
+ return seq2.forEach(function(value) {
2742
+ return list.push(value);
2743
+ });
2744
+ });
2745
+ });
2746
+ };
2747
+ List2.prototype.setSize = function setSize(size) {
2748
+ return setListBounds(this, 0, size);
2749
+ };
2750
+ List2.prototype.map = function map5(mapper, context) {
2751
+ var this$1$1 = this;
2752
+ return this.withMutations(function(list) {
2753
+ for (var i = 0; i < this$1$1.size; i++) {
2754
+ list.set(i, mapper.call(context, list.get(i), i, this$1$1));
2755
+ }
2756
+ });
2757
+ };
2758
+ List2.prototype.slice = function slice3(begin, end) {
2759
+ var size = this.size;
2760
+ if (wholeSlice(begin, end, size)) {
2761
+ return this;
2762
+ }
2763
+ return setListBounds(
2764
+ this,
2765
+ resolveBegin(begin, size),
2766
+ resolveEnd(end, size)
2767
+ );
2768
+ };
2769
+ List2.prototype.__iterator = function __iterator2(type, reverse3) {
2770
+ var index = reverse3 ? this.size : 0;
2771
+ var values2 = iterateList(this, reverse3);
2772
+ return new Iterator(function() {
2773
+ var value = values2();
2774
+ return value === DONE ? iteratorDone() : iteratorValue(type, reverse3 ? --index : index++, value);
2775
+ });
2776
+ };
2777
+ List2.prototype.__iterate = function __iterate2(fn, reverse3) {
2778
+ var index = reverse3 ? this.size : 0;
2779
+ var values2 = iterateList(this, reverse3);
2780
+ var value;
2781
+ while ((value = values2()) !== DONE) {
2782
+ if (fn(value, reverse3 ? --index : index++, this) === false) {
2783
+ break;
2784
+ }
2785
+ }
2786
+ return index;
2787
+ };
2788
+ List2.prototype.__ensureOwner = function __ensureOwner2(ownerID) {
2789
+ if (ownerID === this.__ownerID) {
2790
+ return this;
2791
+ }
2792
+ if (!ownerID) {
2793
+ if (this.size === 0) {
2794
+ return emptyList();
2795
+ }
2796
+ this.__ownerID = ownerID;
2797
+ this.__altered = false;
2798
+ return this;
2799
+ }
2800
+ return makeList(
2801
+ this._origin,
2802
+ this._capacity,
2803
+ this._level,
2804
+ this._root,
2805
+ this._tail,
2806
+ ownerID,
2807
+ this.__hash
2808
+ );
2809
+ };
2810
+ return List2;
2811
+ }(IndexedCollection);
2812
+ List.isList = isList;
2813
+ var ListPrototype = List.prototype;
2814
+ ListPrototype[IS_LIST_SYMBOL] = true;
2815
+ ListPrototype[DELETE] = ListPrototype.remove;
2816
+ ListPrototype.merge = ListPrototype.concat;
2817
+ ListPrototype.setIn = setIn;
2818
+ ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
2819
+ ListPrototype.update = update;
2820
+ ListPrototype.updateIn = updateIn;
2821
+ ListPrototype.mergeIn = mergeIn;
2822
+ ListPrototype.mergeDeepIn = mergeDeepIn;
2823
+ ListPrototype.withMutations = withMutations;
2824
+ ListPrototype.wasAltered = wasAltered;
2825
+ ListPrototype.asImmutable = asImmutable;
2826
+ ListPrototype["@@transducer/init"] = ListPrototype.asMutable = asMutable;
2827
+ ListPrototype["@@transducer/step"] = function(result, arr) {
2828
+ return result.push(arr);
2829
+ };
2830
+ ListPrototype["@@transducer/result"] = function(obj) {
2831
+ return obj.asImmutable();
2832
+ };
2833
+ var VNode = function VNode2(array, ownerID) {
2834
+ this.array = array;
2835
+ this.ownerID = ownerID;
2836
+ };
2837
+ VNode.prototype.removeBefore = function removeBefore(ownerID, level, index) {
2838
+ if ((index & (1 << level + SHIFT) - 1) === 0 || this.array.length === 0) {
2839
+ return this;
2840
+ }
2841
+ var originIndex = index >>> level & MASK;
2842
+ if (originIndex >= this.array.length) {
2843
+ return new VNode([], ownerID);
2844
+ }
2845
+ var removingFirst = originIndex === 0;
2846
+ var newChild;
2847
+ if (level > 0) {
2848
+ var oldChild = this.array[originIndex];
2849
+ newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
2850
+ if (newChild === oldChild && removingFirst) {
2851
+ return this;
2852
+ }
2853
+ }
2854
+ if (removingFirst && !newChild) {
2855
+ return this;
2856
+ }
2857
+ var editable = editableVNode(this, ownerID);
2858
+ if (!removingFirst) {
2859
+ for (var ii = 0; ii < originIndex; ii++) {
2860
+ editable.array[ii] = void 0;
2861
+ }
2862
+ }
2863
+ if (newChild) {
2864
+ editable.array[originIndex] = newChild;
2865
+ }
2866
+ return editable;
2867
+ };
2868
+ VNode.prototype.removeAfter = function removeAfter(ownerID, level, index) {
2869
+ if (index === (level ? 1 << level + SHIFT : SIZE) || this.array.length === 0) {
2870
+ return this;
2871
+ }
2872
+ var sizeIndex = index - 1 >>> level & MASK;
2873
+ if (sizeIndex >= this.array.length) {
2874
+ return this;
2875
+ }
2876
+ var newChild;
2877
+ if (level > 0) {
2878
+ var oldChild = this.array[sizeIndex];
2879
+ newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
2880
+ if (newChild === oldChild && sizeIndex === this.array.length - 1) {
2881
+ return this;
2882
+ }
2883
+ }
2884
+ var editable = editableVNode(this, ownerID);
2885
+ editable.array.splice(sizeIndex + 1);
2886
+ if (newChild) {
2887
+ editable.array[sizeIndex] = newChild;
2888
+ }
2889
+ return editable;
2890
+ };
2891
+ var DONE = {};
2892
+ function iterateList(list, reverse3) {
2893
+ var left = list._origin;
2894
+ var right = list._capacity;
2895
+ var tailPos = getTailOffset(right);
2896
+ var tail = list._tail;
2897
+ return iterateNodeOrLeaf(list._root, list._level, 0);
2898
+ function iterateNodeOrLeaf(node, level, offset) {
2899
+ return level === 0 ? iterateLeaf(node, offset) : iterateNode(node, level, offset);
2900
+ }
2901
+ function iterateLeaf(node, offset) {
2902
+ var array = offset === tailPos ? tail && tail.array : node && node.array;
2903
+ var from = offset > left ? 0 : left - offset;
2904
+ var to = right - offset;
2905
+ if (to > SIZE) {
2906
+ to = SIZE;
2907
+ }
2908
+ return function() {
2909
+ if (from === to) {
2910
+ return DONE;
2911
+ }
2912
+ var idx = reverse3 ? --to : from++;
2913
+ return array && array[idx];
2914
+ };
2915
+ }
2916
+ function iterateNode(node, level, offset) {
2917
+ var values2;
2918
+ var array = node && node.array;
2919
+ var from = offset > left ? 0 : left - offset >> level;
2920
+ var to = (right - offset >> level) + 1;
2921
+ if (to > SIZE) {
2922
+ to = SIZE;
2923
+ }
2924
+ return function() {
2925
+ while (true) {
2926
+ if (values2) {
2927
+ var value = values2();
2928
+ if (value !== DONE) {
2929
+ return value;
2930
+ }
2931
+ values2 = null;
2932
+ }
2933
+ if (from === to) {
2934
+ return DONE;
2935
+ }
2936
+ var idx = reverse3 ? --to : from++;
2937
+ values2 = iterateNodeOrLeaf(
2938
+ array && array[idx],
2939
+ level - SHIFT,
2940
+ offset + (idx << level)
2941
+ );
2942
+ }
2943
+ };
2944
+ }
2945
+ }
2946
+ function makeList(origin, capacity, level, root, tail, ownerID, hash2) {
2947
+ var list = Object.create(ListPrototype);
2948
+ list.size = capacity - origin;
2949
+ list._origin = origin;
2950
+ list._capacity = capacity;
2951
+ list._level = level;
2952
+ list._root = root;
2953
+ list._tail = tail;
2954
+ list.__ownerID = ownerID;
2955
+ list.__hash = hash2;
2956
+ list.__altered = false;
2957
+ return list;
2958
+ }
2959
+ function emptyList() {
2960
+ return makeList(0, 0, SHIFT);
2961
+ }
2962
+ function updateList(list, index, value) {
2963
+ index = wrapIndex(list, index);
2964
+ if (index !== index) {
2965
+ return list;
2966
+ }
2967
+ if (index >= list.size || index < 0) {
2968
+ return list.withMutations(function(list2) {
2969
+ index < 0 ? setListBounds(list2, index).set(0, value) : setListBounds(list2, 0, index + 1).set(index, value);
2970
+ });
2971
+ }
2972
+ index += list._origin;
2973
+ var newTail = list._tail;
2974
+ var newRoot = list._root;
2975
+ var didAlter = MakeRef();
2976
+ if (index >= getTailOffset(list._capacity)) {
2977
+ newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
2978
+ } else {
2979
+ newRoot = updateVNode(
2980
+ newRoot,
2981
+ list.__ownerID,
2982
+ list._level,
2983
+ index,
2984
+ value,
2985
+ didAlter
2986
+ );
2987
+ }
2988
+ if (!didAlter.value) {
2989
+ return list;
2990
+ }
2991
+ if (list.__ownerID) {
2992
+ list._root = newRoot;
2993
+ list._tail = newTail;
2994
+ list.__hash = void 0;
2995
+ list.__altered = true;
2996
+ return list;
2997
+ }
2998
+ return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
2999
+ }
3000
+ function updateVNode(node, ownerID, level, index, value, didAlter) {
3001
+ var idx = index >>> level & MASK;
3002
+ var nodeHas = node && idx < node.array.length;
3003
+ if (!nodeHas && value === void 0) {
3004
+ return node;
3005
+ }
3006
+ var newNode;
3007
+ if (level > 0) {
3008
+ var lowerNode = node && node.array[idx];
3009
+ var newLowerNode = updateVNode(
3010
+ lowerNode,
3011
+ ownerID,
3012
+ level - SHIFT,
3013
+ index,
3014
+ value,
3015
+ didAlter
3016
+ );
3017
+ if (newLowerNode === lowerNode) {
3018
+ return node;
3019
+ }
3020
+ newNode = editableVNode(node, ownerID);
3021
+ newNode.array[idx] = newLowerNode;
3022
+ return newNode;
3023
+ }
3024
+ if (nodeHas && node.array[idx] === value) {
3025
+ return node;
3026
+ }
3027
+ if (didAlter) {
3028
+ SetRef(didAlter);
3029
+ }
3030
+ newNode = editableVNode(node, ownerID);
3031
+ if (value === void 0 && idx === newNode.array.length - 1) {
3032
+ newNode.array.pop();
3033
+ } else {
3034
+ newNode.array[idx] = value;
3035
+ }
3036
+ return newNode;
3037
+ }
3038
+ function editableVNode(node, ownerID) {
3039
+ if (ownerID && node && ownerID === node.ownerID) {
3040
+ return node;
3041
+ }
3042
+ return new VNode(node ? node.array.slice() : [], ownerID);
3043
+ }
3044
+ function listNodeFor(list, rawIndex) {
3045
+ if (rawIndex >= getTailOffset(list._capacity)) {
3046
+ return list._tail;
3047
+ }
3048
+ if (rawIndex < 1 << list._level + SHIFT) {
3049
+ var node = list._root;
3050
+ var level = list._level;
3051
+ while (node && level > 0) {
3052
+ node = node.array[rawIndex >>> level & MASK];
3053
+ level -= SHIFT;
3054
+ }
3055
+ return node;
3056
+ }
3057
+ }
3058
+ function setListBounds(list, begin, end) {
3059
+ if (begin !== void 0) {
3060
+ begin |= 0;
3061
+ }
3062
+ if (end !== void 0) {
3063
+ end |= 0;
3064
+ }
3065
+ var owner = list.__ownerID || new OwnerID();
3066
+ var oldOrigin = list._origin;
3067
+ var oldCapacity = list._capacity;
3068
+ var newOrigin = oldOrigin + begin;
3069
+ var newCapacity = end === void 0 ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
3070
+ if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
3071
+ return list;
3072
+ }
3073
+ if (newOrigin >= newCapacity) {
3074
+ return list.clear();
3075
+ }
3076
+ var newLevel = list._level;
3077
+ var newRoot = list._root;
3078
+ var offsetShift = 0;
3079
+ while (newOrigin + offsetShift < 0) {
3080
+ newRoot = new VNode(
3081
+ newRoot && newRoot.array.length ? [void 0, newRoot] : [],
3082
+ owner
3083
+ );
3084
+ newLevel += SHIFT;
3085
+ offsetShift += 1 << newLevel;
3086
+ }
3087
+ if (offsetShift) {
3088
+ newOrigin += offsetShift;
3089
+ oldOrigin += offsetShift;
3090
+ newCapacity += offsetShift;
3091
+ oldCapacity += offsetShift;
3092
+ }
3093
+ var oldTailOffset = getTailOffset(oldCapacity);
3094
+ var newTailOffset = getTailOffset(newCapacity);
3095
+ while (newTailOffset >= 1 << newLevel + SHIFT) {
3096
+ newRoot = new VNode(
3097
+ newRoot && newRoot.array.length ? [newRoot] : [],
3098
+ owner
3099
+ );
3100
+ newLevel += SHIFT;
3101
+ }
3102
+ var oldTail = list._tail;
3103
+ var newTail = newTailOffset < oldTailOffset ? listNodeFor(list, newCapacity - 1) : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
3104
+ if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
3105
+ newRoot = editableVNode(newRoot, owner);
3106
+ var node = newRoot;
3107
+ for (var level = newLevel; level > SHIFT; level -= SHIFT) {
3108
+ var idx = oldTailOffset >>> level & MASK;
3109
+ node = node.array[idx] = editableVNode(node.array[idx], owner);
3110
+ }
3111
+ node.array[oldTailOffset >>> SHIFT & MASK] = oldTail;
3112
+ }
3113
+ if (newCapacity < oldCapacity) {
3114
+ newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
3115
+ }
3116
+ if (newOrigin >= newTailOffset) {
3117
+ newOrigin -= newTailOffset;
3118
+ newCapacity -= newTailOffset;
3119
+ newLevel = SHIFT;
3120
+ newRoot = null;
3121
+ newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
3122
+ } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
3123
+ offsetShift = 0;
3124
+ while (newRoot) {
3125
+ var beginIndex = newOrigin >>> newLevel & MASK;
3126
+ if (beginIndex !== newTailOffset >>> newLevel & MASK) {
3127
+ break;
3128
+ }
3129
+ if (beginIndex) {
3130
+ offsetShift += (1 << newLevel) * beginIndex;
3131
+ }
3132
+ newLevel -= SHIFT;
3133
+ newRoot = newRoot.array[beginIndex];
3134
+ }
3135
+ if (newRoot && newOrigin > oldOrigin) {
3136
+ newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
3137
+ }
3138
+ if (newRoot && newTailOffset < oldTailOffset) {
3139
+ newRoot = newRoot.removeAfter(
3140
+ owner,
3141
+ newLevel,
3142
+ newTailOffset - offsetShift
3143
+ );
3144
+ }
3145
+ if (offsetShift) {
3146
+ newOrigin -= offsetShift;
3147
+ newCapacity -= offsetShift;
3148
+ }
3149
+ }
3150
+ if (list.__ownerID) {
3151
+ list.size = newCapacity - newOrigin;
3152
+ list._origin = newOrigin;
3153
+ list._capacity = newCapacity;
3154
+ list._level = newLevel;
3155
+ list._root = newRoot;
3156
+ list._tail = newTail;
3157
+ list.__hash = void 0;
3158
+ list.__altered = true;
3159
+ return list;
3160
+ }
3161
+ return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
3162
+ }
3163
+ function getTailOffset(size) {
3164
+ return size < SIZE ? 0 : size - 1 >>> SHIFT << SHIFT;
3165
+ }
3166
+ var OrderedMap = /* @__PURE__ */ function(Map2) {
3167
+ function OrderedMap2(value) {
3168
+ return value === void 0 || value === null ? emptyOrderedMap() : isOrderedMap(value) ? value : emptyOrderedMap().withMutations(function(map5) {
3169
+ var iter = KeyedCollection(value);
3170
+ assertNotInfinite(iter.size);
3171
+ iter.forEach(function(v, k) {
3172
+ return map5.set(k, v);
3173
+ });
3174
+ });
3175
+ }
3176
+ if (Map2) OrderedMap2.__proto__ = Map2;
3177
+ OrderedMap2.prototype = Object.create(Map2 && Map2.prototype);
3178
+ OrderedMap2.prototype.constructor = OrderedMap2;
3179
+ OrderedMap2.of = function of3() {
3180
+ return this(arguments);
3181
+ };
3182
+ OrderedMap2.prototype.toString = function toString5() {
3183
+ return this.__toString("OrderedMap {", "}");
3184
+ };
3185
+ OrderedMap2.prototype.get = function get11(k, notSetValue) {
3186
+ var index = this._map.get(k);
3187
+ return index !== void 0 ? this._list.get(index)[1] : notSetValue;
3188
+ };
3189
+ OrderedMap2.prototype.clear = function clear2() {
3190
+ if (this.size === 0) {
3191
+ return this;
3192
+ }
3193
+ if (this.__ownerID) {
3194
+ this.size = 0;
3195
+ this._map.clear();
3196
+ this._list.clear();
3197
+ this.__altered = true;
3198
+ return this;
3199
+ }
3200
+ return emptyOrderedMap();
3201
+ };
3202
+ OrderedMap2.prototype.set = function set3(k, v) {
3203
+ return updateOrderedMap(this, k, v);
3204
+ };
3205
+ OrderedMap2.prototype.remove = function remove3(k) {
3206
+ return updateOrderedMap(this, k, NOT_SET);
3207
+ };
3208
+ OrderedMap2.prototype.__iterate = function __iterate2(fn, reverse3) {
3209
+ var this$1$1 = this;
3210
+ return this._list.__iterate(
3211
+ function(entry) {
3212
+ return entry && fn(entry[1], entry[0], this$1$1);
3213
+ },
3214
+ reverse3
3215
+ );
3216
+ };
3217
+ OrderedMap2.prototype.__iterator = function __iterator2(type, reverse3) {
3218
+ return this._list.fromEntrySeq().__iterator(type, reverse3);
3219
+ };
3220
+ OrderedMap2.prototype.__ensureOwner = function __ensureOwner2(ownerID) {
3221
+ if (ownerID === this.__ownerID) {
3222
+ return this;
3223
+ }
3224
+ var newMap = this._map.__ensureOwner(ownerID);
3225
+ var newList = this._list.__ensureOwner(ownerID);
3226
+ if (!ownerID) {
3227
+ if (this.size === 0) {
3228
+ return emptyOrderedMap();
3229
+ }
3230
+ this.__ownerID = ownerID;
3231
+ this.__altered = false;
3232
+ this._map = newMap;
3233
+ this._list = newList;
3234
+ return this;
3235
+ }
3236
+ return makeOrderedMap(newMap, newList, ownerID, this.__hash);
3237
+ };
3238
+ return OrderedMap2;
3239
+ }(Map);
3240
+ OrderedMap.isOrderedMap = isOrderedMap;
3241
+ OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
3242
+ OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
3243
+ function makeOrderedMap(map5, list, ownerID, hash2) {
3244
+ var omap = Object.create(OrderedMap.prototype);
3245
+ omap.size = map5 ? map5.size : 0;
3246
+ omap._map = map5;
3247
+ omap._list = list;
3248
+ omap.__ownerID = ownerID;
3249
+ omap.__hash = hash2;
3250
+ omap.__altered = false;
3251
+ return omap;
3252
+ }
3253
+ var EMPTY_ORDERED_MAP;
3254
+ function emptyOrderedMap() {
3255
+ return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
3256
+ }
3257
+ function updateOrderedMap(omap, k, v) {
3258
+ var map5 = omap._map;
3259
+ var list = omap._list;
3260
+ var i = map5.get(k);
3261
+ var has5 = i !== void 0;
3262
+ var newMap;
3263
+ var newList;
3264
+ if (v === NOT_SET) {
3265
+ if (!has5) {
3266
+ return omap;
3267
+ }
3268
+ if (list.size >= SIZE && list.size >= map5.size * 2) {
3269
+ newList = list.filter(function(entry, idx) {
3270
+ return entry !== void 0 && i !== idx;
3271
+ });
3272
+ newMap = newList.toKeyedSeq().map(function(entry) {
3273
+ return entry[0];
3274
+ }).flip().toMap();
3275
+ if (omap.__ownerID) {
3276
+ newMap.__ownerID = newList.__ownerID = omap.__ownerID;
3277
+ }
3278
+ } else {
3279
+ newMap = map5.remove(k);
3280
+ newList = i === list.size - 1 ? list.pop() : list.set(i, void 0);
3281
+ }
3282
+ } else if (has5) {
3283
+ if (v === list.get(i)[1]) {
3284
+ return omap;
3285
+ }
3286
+ newMap = map5;
3287
+ newList = list.set(i, [k, v]);
3288
+ } else {
3289
+ newMap = map5.set(k, list.size);
3290
+ newList = list.set(list.size, [k, v]);
3291
+ }
3292
+ if (omap.__ownerID) {
3293
+ omap.size = newMap.size;
3294
+ omap._map = newMap;
3295
+ omap._list = newList;
3296
+ omap.__hash = void 0;
3297
+ omap.__altered = true;
3298
+ return omap;
3299
+ }
3300
+ return makeOrderedMap(newMap, newList);
3301
+ }
3302
+ var IS_STACK_SYMBOL = "@@__IMMUTABLE_STACK__@@";
3303
+ function isStack(maybeStack) {
3304
+ return Boolean(maybeStack && // @ts-expect-error: maybeStack is typed as `{}`, need to change in 6.0 to `maybeStack && typeof maybeStack === 'object' && MAYBE_STACK_SYMBOL in maybeStack`
3305
+ maybeStack[IS_STACK_SYMBOL]);
3306
+ }
3307
+ var Stack = /* @__PURE__ */ function(IndexedCollection2) {
3308
+ function Stack2(value) {
3309
+ return value === void 0 || value === null ? emptyStack() : isStack(value) ? value : emptyStack().pushAll(value);
3310
+ }
3311
+ if (IndexedCollection2) Stack2.__proto__ = IndexedCollection2;
3312
+ Stack2.prototype = Object.create(IndexedCollection2 && IndexedCollection2.prototype);
3313
+ Stack2.prototype.constructor = Stack2;
3314
+ Stack2.of = function of3() {
3315
+ return this(arguments);
3316
+ };
3317
+ Stack2.prototype.toString = function toString5() {
3318
+ return this.__toString("Stack [", "]");
3319
+ };
3320
+ Stack2.prototype.get = function get11(index, notSetValue) {
3321
+ var head = this._head;
3322
+ index = wrapIndex(this, index);
3323
+ while (head && index--) {
3324
+ head = head.next;
3325
+ }
3326
+ return head ? head.value : notSetValue;
3327
+ };
3328
+ Stack2.prototype.peek = function peek() {
3329
+ return this._head && this._head.value;
3330
+ };
3331
+ Stack2.prototype.push = function push() {
3332
+ var arguments$1 = arguments;
3333
+ if (arguments.length === 0) {
3334
+ return this;
3335
+ }
3336
+ var newSize = this.size + arguments.length;
3337
+ var head = this._head;
3338
+ for (var ii = arguments.length - 1; ii >= 0; ii--) {
3339
+ head = {
3340
+ value: arguments$1[ii],
3341
+ next: head
3342
+ };
3343
+ }
3344
+ if (this.__ownerID) {
3345
+ this.size = newSize;
3346
+ this._head = head;
3347
+ this.__hash = void 0;
3348
+ this.__altered = true;
3349
+ return this;
3350
+ }
3351
+ return makeStack(newSize, head);
3352
+ };
3353
+ Stack2.prototype.pushAll = function pushAll(iter) {
3354
+ iter = IndexedCollection2(iter);
3355
+ if (iter.size === 0) {
3356
+ return this;
3357
+ }
3358
+ if (this.size === 0 && isStack(iter)) {
3359
+ return iter;
3360
+ }
3361
+ assertNotInfinite(iter.size);
3362
+ var newSize = this.size;
3363
+ var head = this._head;
3364
+ iter.__iterate(
3365
+ function(value) {
3366
+ newSize++;
3367
+ head = {
3368
+ value,
3369
+ next: head
3370
+ };
3371
+ },
3372
+ /* reverse */
3373
+ true
3374
+ );
3375
+ if (this.__ownerID) {
3376
+ this.size = newSize;
3377
+ this._head = head;
3378
+ this.__hash = void 0;
3379
+ this.__altered = true;
3380
+ return this;
3381
+ }
3382
+ return makeStack(newSize, head);
3383
+ };
3384
+ Stack2.prototype.pop = function pop() {
3385
+ return this.slice(1);
3386
+ };
3387
+ Stack2.prototype.clear = function clear2() {
3388
+ if (this.size === 0) {
3389
+ return this;
3390
+ }
3391
+ if (this.__ownerID) {
3392
+ this.size = 0;
3393
+ this._head = void 0;
3394
+ this.__hash = void 0;
3395
+ this.__altered = true;
3396
+ return this;
3397
+ }
3398
+ return emptyStack();
3399
+ };
3400
+ Stack2.prototype.slice = function slice3(begin, end) {
3401
+ if (wholeSlice(begin, end, this.size)) {
3402
+ return this;
3403
+ }
3404
+ var resolvedBegin = resolveBegin(begin, this.size);
3405
+ var resolvedEnd = resolveEnd(end, this.size);
3406
+ if (resolvedEnd !== this.size) {
3407
+ return IndexedCollection2.prototype.slice.call(this, begin, end);
3408
+ }
3409
+ var newSize = this.size - resolvedBegin;
3410
+ var head = this._head;
3411
+ while (resolvedBegin--) {
3412
+ head = head.next;
3413
+ }
3414
+ if (this.__ownerID) {
3415
+ this.size = newSize;
3416
+ this._head = head;
3417
+ this.__hash = void 0;
3418
+ this.__altered = true;
3419
+ return this;
3420
+ }
3421
+ return makeStack(newSize, head);
3422
+ };
3423
+ Stack2.prototype.__ensureOwner = function __ensureOwner2(ownerID) {
3424
+ if (ownerID === this.__ownerID) {
3425
+ return this;
3426
+ }
3427
+ if (!ownerID) {
3428
+ if (this.size === 0) {
3429
+ return emptyStack();
3430
+ }
3431
+ this.__ownerID = ownerID;
3432
+ this.__altered = false;
3433
+ return this;
3434
+ }
3435
+ return makeStack(this.size, this._head, ownerID, this.__hash);
3436
+ };
3437
+ Stack2.prototype.__iterate = function __iterate2(fn, reverse3) {
3438
+ var this$1$1 = this;
3439
+ if (reverse3) {
3440
+ return new ArraySeq(this.toArray()).__iterate(
3441
+ function(v, k) {
3442
+ return fn(v, k, this$1$1);
3443
+ },
3444
+ reverse3
3445
+ );
3446
+ }
3447
+ var iterations = 0;
3448
+ var node = this._head;
3449
+ while (node) {
3450
+ if (fn(node.value, iterations++, this) === false) {
3451
+ break;
3452
+ }
3453
+ node = node.next;
3454
+ }
3455
+ return iterations;
3456
+ };
3457
+ Stack2.prototype.__iterator = function __iterator2(type, reverse3) {
3458
+ if (reverse3) {
3459
+ return new ArraySeq(this.toArray()).__iterator(type, reverse3);
3460
+ }
3461
+ var iterations = 0;
3462
+ var node = this._head;
3463
+ return new Iterator(function() {
3464
+ if (node) {
3465
+ var value = node.value;
3466
+ node = node.next;
3467
+ return iteratorValue(type, iterations++, value);
3468
+ }
3469
+ return iteratorDone();
3470
+ });
3471
+ };
3472
+ return Stack2;
3473
+ }(IndexedCollection);
3474
+ Stack.isStack = isStack;
3475
+ var StackPrototype = Stack.prototype;
3476
+ StackPrototype[IS_STACK_SYMBOL] = true;
3477
+ StackPrototype.shift = StackPrototype.pop;
3478
+ StackPrototype.unshift = StackPrototype.push;
3479
+ StackPrototype.unshiftAll = StackPrototype.pushAll;
3480
+ StackPrototype.withMutations = withMutations;
3481
+ StackPrototype.wasAltered = wasAltered;
3482
+ StackPrototype.asImmutable = asImmutable;
3483
+ StackPrototype["@@transducer/init"] = StackPrototype.asMutable = asMutable;
3484
+ StackPrototype["@@transducer/step"] = function(result, arr) {
3485
+ return result.unshift(arr);
3486
+ };
3487
+ StackPrototype["@@transducer/result"] = function(obj) {
3488
+ return obj.asImmutable();
3489
+ };
3490
+ function makeStack(size, head, ownerID, hash2) {
3491
+ var map5 = Object.create(StackPrototype);
3492
+ map5.size = size;
3493
+ map5._head = head;
3494
+ map5.__ownerID = ownerID;
3495
+ map5.__hash = hash2;
3496
+ map5.__altered = false;
3497
+ return map5;
3498
+ }
3499
+ var EMPTY_STACK;
3500
+ function emptyStack() {
3501
+ return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
3502
+ }
3503
+ var IS_SET_SYMBOL = "@@__IMMUTABLE_SET__@@";
3504
+ function isSet(maybeSet) {
3505
+ return Boolean(maybeSet && // @ts-expect-error: maybeSet is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSet === 'object' && MAYBE_SET_SYMBOL in maybeSet`
3506
+ maybeSet[IS_SET_SYMBOL]);
3507
+ }
3508
+ function isOrderedSet(maybeOrderedSet) {
3509
+ return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
3510
+ }
3511
+ function deepEqual(a, b) {
3512
+ if (a === b) {
3513
+ return true;
3514
+ }
3515
+ if (!isCollection(b) || // @ts-expect-error size should exists on Collection
3516
+ a.size !== void 0 && b.size !== void 0 && a.size !== b.size || // @ts-expect-error __hash exists on Collection
3517
+ a.__hash !== void 0 && // @ts-expect-error __hash exists on Collection
3518
+ b.__hash !== void 0 && // @ts-expect-error __hash exists on Collection
3519
+ a.__hash !== b.__hash || isKeyed(a) !== isKeyed(b) || isIndexed(a) !== isIndexed(b) || // @ts-expect-error Range extends Collection, which implements [Symbol.iterator], so it is valid
3520
+ isOrdered(a) !== isOrdered(b)) {
3521
+ return false;
3522
+ }
3523
+ if (a.size === 0 && b.size === 0) {
3524
+ return true;
3525
+ }
3526
+ var notAssociative = !isAssociative(a);
3527
+ if (isOrdered(a)) {
3528
+ var entries3 = a.entries();
3529
+ return b.every(function(v, k) {
3530
+ var entry = entries3.next().value;
3531
+ return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
3532
+ }) && entries3.next().done;
3533
+ }
3534
+ var flipped = false;
3535
+ if (a.size === void 0) {
3536
+ if (b.size === void 0) {
3537
+ if (typeof a.cacheResult === "function") {
3538
+ a.cacheResult();
3539
+ }
3540
+ } else {
3541
+ flipped = true;
3542
+ var _ = a;
3543
+ a = b;
3544
+ b = _;
3545
+ }
3546
+ }
3547
+ var allEqual = true;
3548
+ var bSize = (
3549
+ // @ts-expect-error b is Range | Repeat | Collection<unknown, unknown> as it may have been flipped, and __iterate is valid
3550
+ b.__iterate(function(v, k) {
3551
+ if (notAssociative ? (
3552
+ // @ts-expect-error has exists on Collection
3553
+ !a.has(v)
3554
+ ) : flipped ? (
3555
+ // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
3556
+ !is(v, a.get(k, NOT_SET))
3557
+ ) : (
3558
+ // @ts-expect-error type of `get` does not "catch" the version with `notSetValue`
3559
+ !is(a.get(k, NOT_SET), v)
3560
+ )) {
3561
+ allEqual = false;
3562
+ return false;
3563
+ }
3564
+ })
3565
+ );
3566
+ return allEqual && // @ts-expect-error size should exists on Collection
3567
+ a.size === bSize;
3568
+ }
3569
+ function mixin(ctor, methods) {
3570
+ var keyCopier = function(key) {
3571
+ ctor.prototype[key] = methods[key];
3572
+ };
3573
+ Object.keys(methods).forEach(keyCopier);
3574
+ Object.getOwnPropertySymbols && Object.getOwnPropertySymbols(methods).forEach(keyCopier);
3575
+ return ctor;
3576
+ }
3577
+ function toJS(value) {
3578
+ if (!value || typeof value !== "object") {
3579
+ return value;
3580
+ }
3581
+ if (!isCollection(value)) {
3582
+ if (!isDataStructure(value)) {
3583
+ return value;
3584
+ }
3585
+ value = Seq(value);
3586
+ }
3587
+ if (isKeyed(value)) {
3588
+ var result$1 = {};
3589
+ value.__iterate(function(v, k) {
3590
+ result$1[k] = toJS(v);
3591
+ });
3592
+ return result$1;
3593
+ }
3594
+ var result = [];
3595
+ value.__iterate(function(v) {
3596
+ result.push(toJS(v));
3597
+ });
3598
+ return result;
3599
+ }
3600
+ var Set = /* @__PURE__ */ function(SetCollection2) {
3601
+ function Set2(value) {
3602
+ return value === void 0 || value === null ? emptySet() : isSet(value) && !isOrdered(value) ? value : emptySet().withMutations(function(set3) {
3603
+ var iter = SetCollection2(value);
3604
+ assertNotInfinite(iter.size);
3605
+ iter.forEach(function(v) {
3606
+ return set3.add(v);
3607
+ });
3608
+ });
3609
+ }
3610
+ if (SetCollection2) Set2.__proto__ = SetCollection2;
3611
+ Set2.prototype = Object.create(SetCollection2 && SetCollection2.prototype);
3612
+ Set2.prototype.constructor = Set2;
3613
+ Set2.of = function of3() {
3614
+ return this(arguments);
3615
+ };
3616
+ Set2.fromKeys = function fromKeys(value) {
3617
+ return this(KeyedCollection(value).keySeq());
3618
+ };
3619
+ Set2.intersect = function intersect(sets) {
3620
+ sets = Collection(sets).toArray();
3621
+ return sets.length ? SetPrototype.intersect.apply(Set2(sets.pop()), sets) : emptySet();
3622
+ };
3623
+ Set2.union = function union(sets) {
3624
+ sets = Collection(sets).toArray();
3625
+ return sets.length ? SetPrototype.union.apply(Set2(sets.pop()), sets) : emptySet();
3626
+ };
3627
+ Set2.prototype.toString = function toString5() {
3628
+ return this.__toString("Set {", "}");
3629
+ };
3630
+ Set2.prototype.has = function has5(value) {
3631
+ return this._map.has(value);
3632
+ };
3633
+ Set2.prototype.add = function add(value) {
3634
+ return updateSet(this, this._map.set(value, value));
3635
+ };
3636
+ Set2.prototype.remove = function remove3(value) {
3637
+ return updateSet(this, this._map.remove(value));
3638
+ };
3639
+ Set2.prototype.clear = function clear2() {
3640
+ return updateSet(this, this._map.clear());
3641
+ };
3642
+ Set2.prototype.map = function map5(mapper, context) {
3643
+ var this$1$1 = this;
3644
+ var didChanges = false;
3645
+ var newMap = updateSet(
3646
+ this,
3647
+ this._map.mapEntries(function(ref) {
3648
+ var v = ref[1];
3649
+ var mapped = mapper.call(context, v, v, this$1$1);
3650
+ if (mapped !== v) {
3651
+ didChanges = true;
3652
+ }
3653
+ return [mapped, mapped];
3654
+ }, context)
3655
+ );
3656
+ return didChanges ? newMap : this;
3657
+ };
3658
+ Set2.prototype.union = function union() {
3659
+ var iters = [], len = arguments.length;
3660
+ while (len--) iters[len] = arguments[len];
3661
+ iters = iters.filter(function(x) {
3662
+ return x.size !== 0;
3663
+ });
3664
+ if (iters.length === 0) {
3665
+ return this;
3666
+ }
3667
+ if (this.size === 0 && !this.__ownerID && iters.length === 1) {
3668
+ return this.constructor(iters[0]);
3669
+ }
3670
+ return this.withMutations(function(set3) {
3671
+ for (var ii = 0; ii < iters.length; ii++) {
3672
+ if (typeof iters[ii] === "string") {
3673
+ set3.add(iters[ii]);
3674
+ } else {
3675
+ SetCollection2(iters[ii]).forEach(function(value) {
3676
+ return set3.add(value);
3677
+ });
3678
+ }
3679
+ }
3680
+ });
3681
+ };
3682
+ Set2.prototype.intersect = function intersect() {
3683
+ var iters = [], len = arguments.length;
3684
+ while (len--) iters[len] = arguments[len];
3685
+ if (iters.length === 0) {
3686
+ return this;
3687
+ }
3688
+ iters = iters.map(function(iter) {
3689
+ return SetCollection2(iter);
3690
+ });
3691
+ var toRemove = [];
3692
+ this.forEach(function(value) {
3693
+ if (!iters.every(function(iter) {
3694
+ return iter.includes(value);
3695
+ })) {
3696
+ toRemove.push(value);
3697
+ }
3698
+ });
3699
+ return this.withMutations(function(set3) {
3700
+ toRemove.forEach(function(value) {
3701
+ set3.remove(value);
3702
+ });
3703
+ });
3704
+ };
3705
+ Set2.prototype.subtract = function subtract() {
3706
+ var iters = [], len = arguments.length;
3707
+ while (len--) iters[len] = arguments[len];
3708
+ if (iters.length === 0) {
3709
+ return this;
3710
+ }
3711
+ iters = iters.map(function(iter) {
3712
+ return SetCollection2(iter);
3713
+ });
3714
+ var toRemove = [];
3715
+ this.forEach(function(value) {
3716
+ if (iters.some(function(iter) {
3717
+ return iter.includes(value);
3718
+ })) {
3719
+ toRemove.push(value);
3720
+ }
3721
+ });
3722
+ return this.withMutations(function(set3) {
3723
+ toRemove.forEach(function(value) {
3724
+ set3.remove(value);
3725
+ });
3726
+ });
3727
+ };
3728
+ Set2.prototype.sort = function sort2(comparator) {
3729
+ return OrderedSet(sortFactory(this, comparator));
3730
+ };
3731
+ Set2.prototype.sortBy = function sortBy2(mapper, comparator) {
3732
+ return OrderedSet(sortFactory(this, comparator, mapper));
3733
+ };
3734
+ Set2.prototype.wasAltered = function wasAltered3() {
3735
+ return this._map.wasAltered();
3736
+ };
3737
+ Set2.prototype.__iterate = function __iterate2(fn, reverse3) {
3738
+ var this$1$1 = this;
3739
+ return this._map.__iterate(function(k) {
3740
+ return fn(k, k, this$1$1);
3741
+ }, reverse3);
3742
+ };
3743
+ Set2.prototype.__iterator = function __iterator2(type, reverse3) {
3744
+ return this._map.__iterator(type, reverse3);
3745
+ };
3746
+ Set2.prototype.__ensureOwner = function __ensureOwner2(ownerID) {
3747
+ if (ownerID === this.__ownerID) {
3748
+ return this;
3749
+ }
3750
+ var newMap = this._map.__ensureOwner(ownerID);
3751
+ if (!ownerID) {
3752
+ if (this.size === 0) {
3753
+ return this.__empty();
3754
+ }
3755
+ this.__ownerID = ownerID;
3756
+ this._map = newMap;
3757
+ return this;
3758
+ }
3759
+ return this.__make(newMap, ownerID);
3760
+ };
3761
+ return Set2;
3762
+ }(SetCollection);
3763
+ Set.isSet = isSet;
3764
+ var SetPrototype = Set.prototype;
3765
+ SetPrototype[IS_SET_SYMBOL] = true;
3766
+ SetPrototype[DELETE] = SetPrototype.remove;
3767
+ SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
3768
+ SetPrototype.withMutations = withMutations;
3769
+ SetPrototype.asImmutable = asImmutable;
3770
+ SetPrototype["@@transducer/init"] = SetPrototype.asMutable = asMutable;
3771
+ SetPrototype["@@transducer/step"] = function(result, arr) {
3772
+ return result.add(arr);
3773
+ };
3774
+ SetPrototype["@@transducer/result"] = function(obj) {
3775
+ return obj.asImmutable();
3776
+ };
3777
+ SetPrototype.__empty = emptySet;
3778
+ SetPrototype.__make = makeSet;
3779
+ function updateSet(set3, newMap) {
3780
+ if (set3.__ownerID) {
3781
+ set3.size = newMap.size;
3782
+ set3._map = newMap;
3783
+ return set3;
3784
+ }
3785
+ return newMap === set3._map ? set3 : newMap.size === 0 ? set3.__empty() : set3.__make(newMap);
3786
+ }
3787
+ function makeSet(map5, ownerID) {
3788
+ var set3 = Object.create(SetPrototype);
3789
+ set3.size = map5 ? map5.size : 0;
3790
+ set3._map = map5;
3791
+ set3.__ownerID = ownerID;
3792
+ return set3;
3793
+ }
3794
+ var EMPTY_SET;
3795
+ function emptySet() {
3796
+ return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
3797
+ }
3798
+ var Range = /* @__PURE__ */ function(IndexedSeq2) {
3799
+ function Range2(start, end, step) {
3800
+ if (step === void 0) step = 1;
3801
+ if (!(this instanceof Range2)) {
3802
+ return new Range2(start, end, step);
3803
+ }
3804
+ invariant(step !== 0, "Cannot step a Range by 0");
3805
+ invariant(
3806
+ start !== void 0,
3807
+ "You must define a start value when using Range"
3808
+ );
3809
+ invariant(
3810
+ end !== void 0,
3811
+ "You must define an end value when using Range"
3812
+ );
3813
+ step = Math.abs(step);
3814
+ if (end < start) {
3815
+ step = -step;
3816
+ }
3817
+ this._start = start;
3818
+ this._end = end;
3819
+ this._step = step;
3820
+ this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
3821
+ if (this.size === 0) {
3822
+ if (EMPTY_RANGE) {
3823
+ return EMPTY_RANGE;
3824
+ }
3825
+ EMPTY_RANGE = this;
3826
+ }
3827
+ }
3828
+ if (IndexedSeq2) Range2.__proto__ = IndexedSeq2;
3829
+ Range2.prototype = Object.create(IndexedSeq2 && IndexedSeq2.prototype);
3830
+ Range2.prototype.constructor = Range2;
3831
+ Range2.prototype.toString = function toString5() {
3832
+ return this.size === 0 ? "Range []" : "Range [ " + this._start + "..." + this._end + (this._step !== 1 ? " by " + this._step : "") + " ]";
3833
+ };
3834
+ Range2.prototype.get = function get11(index, notSetValue) {
3835
+ return this.has(index) ? this._start + wrapIndex(this, index) * this._step : notSetValue;
3836
+ };
3837
+ Range2.prototype.includes = function includes3(searchValue) {
3838
+ var possibleIndex = (searchValue - this._start) / this._step;
3839
+ return possibleIndex >= 0 && possibleIndex < this.size && possibleIndex === Math.floor(possibleIndex);
3840
+ };
3841
+ Range2.prototype.slice = function slice3(begin, end) {
3842
+ if (wholeSlice(begin, end, this.size)) {
3843
+ return this;
3844
+ }
3845
+ begin = resolveBegin(begin, this.size);
3846
+ end = resolveEnd(end, this.size);
3847
+ if (end <= begin) {
3848
+ return new Range2(0, 0);
3849
+ }
3850
+ return new Range2(
3851
+ this.get(begin, this._end),
3852
+ this.get(end, this._end),
3853
+ this._step
3854
+ );
3855
+ };
3856
+ Range2.prototype.indexOf = function indexOf2(searchValue) {
3857
+ var offsetValue = searchValue - this._start;
3858
+ if (offsetValue % this._step === 0) {
3859
+ var index = offsetValue / this._step;
3860
+ if (index >= 0 && index < this.size) {
3861
+ return index;
3862
+ }
3863
+ }
3864
+ return -1;
3865
+ };
3866
+ Range2.prototype.lastIndexOf = function lastIndexOf2(searchValue) {
3867
+ return this.indexOf(searchValue);
3868
+ };
3869
+ Range2.prototype.__iterate = function __iterate2(fn, reverse3) {
3870
+ var size = this.size;
3871
+ var step = this._step;
3872
+ var value = reverse3 ? this._start + (size - 1) * step : this._start;
3873
+ var i = 0;
3874
+ while (i !== size) {
3875
+ if (fn(value, reverse3 ? size - ++i : i++, this) === false) {
3876
+ break;
3877
+ }
3878
+ value += reverse3 ? -step : step;
3879
+ }
3880
+ return i;
3881
+ };
3882
+ Range2.prototype.__iterator = function __iterator2(type, reverse3) {
3883
+ var size = this.size;
3884
+ var step = this._step;
3885
+ var value = reverse3 ? this._start + (size - 1) * step : this._start;
3886
+ var i = 0;
3887
+ return new Iterator(function() {
3888
+ if (i === size) {
3889
+ return iteratorDone();
3890
+ }
3891
+ var v = value;
3892
+ value += reverse3 ? -step : step;
3893
+ return iteratorValue(type, reverse3 ? size - ++i : i++, v);
3894
+ });
3895
+ };
3896
+ Range2.prototype.equals = function equals3(other) {
3897
+ return other instanceof Range2 ? this._start === other._start && this._end === other._end && this._step === other._step : deepEqual(this, other);
3898
+ };
3899
+ return Range2;
3900
+ }(IndexedSeq);
3901
+ var EMPTY_RANGE;
3902
+ function getIn$1(collection, searchKeyPath, notSetValue) {
3903
+ var keyPath = coerceKeyPath(searchKeyPath);
3904
+ var i = 0;
3905
+ while (i !== keyPath.length) {
3906
+ collection = get(collection, keyPath[i++], NOT_SET);
3907
+ if (collection === NOT_SET) {
3908
+ return notSetValue;
3909
+ }
3910
+ }
3911
+ return collection;
3912
+ }
3913
+ function getIn(searchKeyPath, notSetValue) {
3914
+ return getIn$1(this, searchKeyPath, notSetValue);
3915
+ }
3916
+ function hasIn$1(collection, keyPath) {
3917
+ return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
3918
+ }
3919
+ function hasIn(searchKeyPath) {
3920
+ return hasIn$1(this, searchKeyPath);
3921
+ }
3922
+ function toObject() {
3923
+ assertNotInfinite(this.size);
3924
+ var object = {};
3925
+ this.__iterate(function(v, k) {
3926
+ object[k] = v;
3927
+ });
3928
+ return object;
3929
+ }
3930
+ Collection.Iterator = Iterator;
3931
+ mixin(Collection, {
3932
+ // ### Conversion to other types
3933
+ toArray: function toArray() {
3934
+ assertNotInfinite(this.size);
3935
+ var array = new Array(this.size || 0);
3936
+ var useTuples = isKeyed(this);
3937
+ var i = 0;
3938
+ this.__iterate(function(v, k) {
3939
+ array[i++] = useTuples ? [k, v] : v;
3940
+ });
3941
+ return array;
3942
+ },
3943
+ toIndexedSeq: function toIndexedSeq() {
3944
+ return new ToIndexedSequence(this);
3945
+ },
3946
+ toJS: function toJS$1() {
3947
+ return toJS(this);
3948
+ },
3949
+ toKeyedSeq: function toKeyedSeq() {
3950
+ return new ToKeyedSequence(this, true);
3951
+ },
3952
+ toMap: function toMap() {
3953
+ return Map(this.toKeyedSeq());
3954
+ },
3955
+ toObject,
3956
+ toOrderedMap: function toOrderedMap() {
3957
+ return OrderedMap(this.toKeyedSeq());
3958
+ },
3959
+ toOrderedSet: function toOrderedSet() {
3960
+ return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
3961
+ },
3962
+ toSet: function toSet() {
3963
+ return Set(isKeyed(this) ? this.valueSeq() : this);
3964
+ },
3965
+ toSetSeq: function toSetSeq() {
3966
+ return new ToSetSequence(this);
3967
+ },
3968
+ toSeq: function toSeq() {
3969
+ return isIndexed(this) ? this.toIndexedSeq() : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq();
3970
+ },
3971
+ toStack: function toStack() {
3972
+ return Stack(isKeyed(this) ? this.valueSeq() : this);
3973
+ },
3974
+ toList: function toList() {
3975
+ return List(isKeyed(this) ? this.valueSeq() : this);
3976
+ },
3977
+ // ### Common JavaScript methods and properties
3978
+ toString: function toString3() {
3979
+ return "[Collection]";
3980
+ },
3981
+ __toString: function __toString(head, tail) {
3982
+ if (this.size === 0) {
3983
+ return head + tail;
3984
+ }
3985
+ return head + " " + this.toSeq().map(this.__toStringMapper).join(", ") + " " + tail;
3986
+ },
3987
+ // ### ES6 Collection methods (ES6 Array and Map)
3988
+ concat: function concat() {
3989
+ var values2 = [], len = arguments.length;
3990
+ while (len--) values2[len] = arguments[len];
3991
+ return reify(this, concatFactory(this, values2));
3992
+ },
3993
+ includes: function includes(searchValue) {
3994
+ return this.some(function(value) {
3995
+ return is(value, searchValue);
3996
+ });
3997
+ },
3998
+ entries: function entries() {
3999
+ return this.__iterator(ITERATE_ENTRIES);
4000
+ },
4001
+ every: function every(predicate, context) {
4002
+ assertNotInfinite(this.size);
4003
+ var returnValue = true;
4004
+ this.__iterate(function(v, k, c) {
4005
+ if (!predicate.call(context, v, k, c)) {
4006
+ returnValue = false;
4007
+ return false;
4008
+ }
4009
+ });
4010
+ return returnValue;
4011
+ },
4012
+ filter: function filter(predicate, context) {
4013
+ return reify(this, filterFactory(this, predicate, context, true));
4014
+ },
4015
+ partition: function partition(predicate, context) {
4016
+ return partitionFactory(this, predicate, context);
4017
+ },
4018
+ find: function find(predicate, context, notSetValue) {
4019
+ var entry = this.findEntry(predicate, context);
4020
+ return entry ? entry[1] : notSetValue;
4021
+ },
4022
+ forEach: function forEach(sideEffect, context) {
4023
+ assertNotInfinite(this.size);
4024
+ return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
4025
+ },
4026
+ join: function join(separator) {
4027
+ assertNotInfinite(this.size);
4028
+ separator = separator !== void 0 ? "" + separator : ",";
4029
+ var joined = "";
4030
+ var isFirst = true;
4031
+ this.__iterate(function(v) {
4032
+ isFirst ? isFirst = false : joined += separator;
4033
+ joined += v !== null && v !== void 0 ? v.toString() : "";
4034
+ });
4035
+ return joined;
4036
+ },
4037
+ keys: function keys() {
4038
+ return this.__iterator(ITERATE_KEYS);
4039
+ },
4040
+ map: function map2(mapper, context) {
4041
+ return reify(this, mapFactory(this, mapper, context));
4042
+ },
4043
+ reduce: function reduce$1(reducer, initialReduction, context) {
4044
+ return reduce(
4045
+ this,
4046
+ reducer,
4047
+ initialReduction,
4048
+ context,
4049
+ arguments.length < 2,
4050
+ false
4051
+ );
4052
+ },
4053
+ reduceRight: function reduceRight(reducer, initialReduction, context) {
4054
+ return reduce(
4055
+ this,
4056
+ reducer,
4057
+ initialReduction,
4058
+ context,
4059
+ arguments.length < 2,
4060
+ true
4061
+ );
4062
+ },
4063
+ reverse: function reverse() {
4064
+ return reify(this, reverseFactory(this, true));
4065
+ },
4066
+ slice: function slice(begin, end) {
4067
+ return reify(this, sliceFactory(this, begin, end, true));
4068
+ },
4069
+ some: function some(predicate, context) {
4070
+ assertNotInfinite(this.size);
4071
+ var returnValue = false;
4072
+ this.__iterate(function(v, k, c) {
4073
+ if (predicate.call(context, v, k, c)) {
4074
+ returnValue = true;
4075
+ return false;
4076
+ }
4077
+ });
4078
+ return returnValue;
4079
+ },
4080
+ sort: function sort(comparator) {
4081
+ return reify(this, sortFactory(this, comparator));
4082
+ },
4083
+ values: function values() {
4084
+ return this.__iterator(ITERATE_VALUES);
4085
+ },
4086
+ // ### More sequential methods
4087
+ butLast: function butLast() {
4088
+ return this.slice(0, -1);
4089
+ },
4090
+ isEmpty: function isEmpty() {
4091
+ return this.size !== void 0 ? this.size === 0 : !this.some(function() {
4092
+ return true;
4093
+ });
4094
+ },
4095
+ count: function count(predicate, context) {
4096
+ return ensureSize(
4097
+ predicate ? this.toSeq().filter(predicate, context) : this
4098
+ );
4099
+ },
4100
+ countBy: function countBy(grouper, context) {
4101
+ return countByFactory(this, grouper, context);
4102
+ },
4103
+ equals: function equals(other) {
4104
+ return deepEqual(this, other);
4105
+ },
4106
+ entrySeq: function entrySeq() {
4107
+ var collection = this;
4108
+ if (collection._cache) {
4109
+ return new ArraySeq(collection._cache);
4110
+ }
4111
+ var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq();
4112
+ entriesSequence.fromEntrySeq = function() {
4113
+ return collection.toSeq();
4114
+ };
4115
+ return entriesSequence;
4116
+ },
4117
+ filterNot: function filterNot(predicate, context) {
4118
+ return this.filter(not(predicate), context);
4119
+ },
4120
+ findEntry: function findEntry(predicate, context, notSetValue) {
4121
+ var found = notSetValue;
4122
+ this.__iterate(function(v, k, c) {
4123
+ if (predicate.call(context, v, k, c)) {
4124
+ found = [k, v];
4125
+ return false;
4126
+ }
4127
+ });
4128
+ return found;
4129
+ },
4130
+ findKey: function findKey(predicate, context) {
4131
+ var entry = this.findEntry(predicate, context);
4132
+ return entry && entry[0];
4133
+ },
4134
+ findLast: function findLast(predicate, context, notSetValue) {
4135
+ return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
4136
+ },
4137
+ findLastEntry: function findLastEntry(predicate, context, notSetValue) {
4138
+ return this.toKeyedSeq().reverse().findEntry(predicate, context, notSetValue);
4139
+ },
4140
+ findLastKey: function findLastKey(predicate, context) {
4141
+ return this.toKeyedSeq().reverse().findKey(predicate, context);
4142
+ },
4143
+ first: function first(notSetValue) {
4144
+ return this.find(returnTrue, null, notSetValue);
4145
+ },
4146
+ flatMap: function flatMap(mapper, context) {
4147
+ return reify(this, flatMapFactory(this, mapper, context));
4148
+ },
4149
+ flatten: function flatten(depth) {
4150
+ return reify(this, flattenFactory(this, depth, true));
4151
+ },
4152
+ fromEntrySeq: function fromEntrySeq() {
4153
+ return new FromEntriesSequence(this);
4154
+ },
4155
+ get: function get7(searchKey, notSetValue) {
4156
+ return this.find(function(_, key) {
4157
+ return is(key, searchKey);
4158
+ }, void 0, notSetValue);
4159
+ },
4160
+ getIn,
4161
+ groupBy: function groupBy(grouper, context) {
4162
+ return groupByFactory(this, grouper, context);
4163
+ },
4164
+ has: function has2(searchKey) {
4165
+ return this.get(searchKey, NOT_SET) !== NOT_SET;
4166
+ },
4167
+ hasIn,
4168
+ isSubset: function isSubset(iter) {
4169
+ iter = typeof iter.includes === "function" ? iter : Collection(iter);
4170
+ return this.every(function(value) {
4171
+ return iter.includes(value);
4172
+ });
4173
+ },
4174
+ isSuperset: function isSuperset(iter) {
4175
+ iter = typeof iter.isSubset === "function" ? iter : Collection(iter);
4176
+ return iter.isSubset(this);
4177
+ },
4178
+ keyOf: function keyOf(searchValue) {
4179
+ return this.findKey(function(value) {
4180
+ return is(value, searchValue);
4181
+ });
4182
+ },
4183
+ keySeq: function keySeq() {
4184
+ return this.toSeq().map(keyMapper).toIndexedSeq();
4185
+ },
4186
+ last: function last(notSetValue) {
4187
+ return this.toSeq().reverse().first(notSetValue);
4188
+ },
4189
+ lastKeyOf: function lastKeyOf(searchValue) {
4190
+ return this.toKeyedSeq().reverse().keyOf(searchValue);
4191
+ },
4192
+ max: function max(comparator) {
4193
+ return maxFactory(this, comparator);
4194
+ },
4195
+ maxBy: function maxBy(mapper, comparator) {
4196
+ return maxFactory(this, comparator, mapper);
4197
+ },
4198
+ min: function min(comparator) {
4199
+ return maxFactory(
4200
+ this,
4201
+ comparator ? neg(comparator) : defaultNegComparator
4202
+ );
4203
+ },
4204
+ minBy: function minBy(mapper, comparator) {
4205
+ return maxFactory(
4206
+ this,
4207
+ comparator ? neg(comparator) : defaultNegComparator,
4208
+ mapper
4209
+ );
4210
+ },
4211
+ rest: function rest() {
4212
+ return this.slice(1);
4213
+ },
4214
+ skip: function skip(amount) {
4215
+ return amount === 0 ? this : this.slice(Math.max(0, amount));
4216
+ },
4217
+ skipLast: function skipLast(amount) {
4218
+ return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
4219
+ },
4220
+ skipWhile: function skipWhile(predicate, context) {
4221
+ return reify(this, skipWhileFactory(this, predicate, context, true));
4222
+ },
4223
+ skipUntil: function skipUntil(predicate, context) {
4224
+ return this.skipWhile(not(predicate), context);
4225
+ },
4226
+ sortBy: function sortBy(mapper, comparator) {
4227
+ return reify(this, sortFactory(this, comparator, mapper));
4228
+ },
4229
+ take: function take2(amount) {
4230
+ return this.slice(0, Math.max(0, amount));
4231
+ },
4232
+ takeLast: function takeLast(amount) {
4233
+ return this.slice(-Math.max(0, amount));
4234
+ },
4235
+ takeWhile: function takeWhile(predicate, context) {
4236
+ return reify(this, takeWhileFactory(this, predicate, context));
4237
+ },
4238
+ takeUntil: function takeUntil(predicate, context) {
4239
+ return this.takeWhile(not(predicate), context);
4240
+ },
4241
+ update: function update7(fn) {
4242
+ return fn(this);
4243
+ },
4244
+ valueSeq: function valueSeq() {
4245
+ return this.toIndexedSeq();
4246
+ },
4247
+ // ### Hashable Object
4248
+ hashCode: function hashCode() {
4249
+ return this.__hash || (this.__hash = hashCollection(this));
4250
+ }
4251
+ // ### Internal
4252
+ // abstract __iterate(fn, reverse)
4253
+ // abstract __iterator(type, reverse)
4254
+ });
4255
+ var CollectionPrototype = Collection.prototype;
4256
+ CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
4257
+ CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
4258
+ CollectionPrototype.toJSON = CollectionPrototype.toArray;
4259
+ CollectionPrototype.__toStringMapper = quoteString;
4260
+ CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
4261
+ return this.toString();
4262
+ };
4263
+ CollectionPrototype.chain = CollectionPrototype.flatMap;
4264
+ CollectionPrototype.contains = CollectionPrototype.includes;
4265
+ mixin(KeyedCollection, {
4266
+ // ### More sequential methods
4267
+ flip: function flip() {
4268
+ return reify(this, flipFactory(this));
4269
+ },
4270
+ mapEntries: function mapEntries(mapper, context) {
4271
+ var this$1$1 = this;
4272
+ var iterations = 0;
4273
+ return reify(
4274
+ this,
4275
+ this.toSeq().map(function(v, k) {
4276
+ return mapper.call(context, [k, v], iterations++, this$1$1);
4277
+ }).fromEntrySeq()
4278
+ );
4279
+ },
4280
+ mapKeys: function mapKeys(mapper, context) {
4281
+ var this$1$1 = this;
4282
+ return reify(
4283
+ this,
4284
+ this.toSeq().flip().map(function(k, v) {
4285
+ return mapper.call(context, k, v, this$1$1);
4286
+ }).flip()
4287
+ );
4288
+ }
4289
+ });
4290
+ var KeyedCollectionPrototype = KeyedCollection.prototype;
4291
+ KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
4292
+ KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
4293
+ KeyedCollectionPrototype.toJSON = toObject;
4294
+ KeyedCollectionPrototype.__toStringMapper = function(v, k) {
4295
+ return quoteString(k) + ": " + quoteString(v);
4296
+ };
4297
+ mixin(IndexedCollection, {
4298
+ // ### Conversion to other types
4299
+ toKeyedSeq: function toKeyedSeq2() {
4300
+ return new ToKeyedSequence(this, false);
4301
+ },
4302
+ // ### ES6 Collection methods (ES6 Array and Map)
4303
+ filter: function filter2(predicate, context) {
4304
+ return reify(this, filterFactory(this, predicate, context, false));
4305
+ },
4306
+ findIndex: function findIndex(predicate, context) {
4307
+ var entry = this.findEntry(predicate, context);
4308
+ return entry ? entry[0] : -1;
4309
+ },
4310
+ indexOf: function indexOf(searchValue) {
4311
+ var key = this.keyOf(searchValue);
4312
+ return key === void 0 ? -1 : key;
4313
+ },
4314
+ lastIndexOf: function lastIndexOf(searchValue) {
4315
+ var key = this.lastKeyOf(searchValue);
4316
+ return key === void 0 ? -1 : key;
4317
+ },
4318
+ reverse: function reverse2() {
4319
+ return reify(this, reverseFactory(this, false));
4320
+ },
4321
+ slice: function slice2(begin, end) {
4322
+ return reify(this, sliceFactory(this, begin, end, false));
4323
+ },
4324
+ splice: function splice(index, removeNum) {
4325
+ var numArgs = arguments.length;
4326
+ removeNum = Math.max(removeNum || 0, 0);
4327
+ if (numArgs === 0 || numArgs === 2 && !removeNum) {
4328
+ return this;
4329
+ }
4330
+ index = resolveBegin(index, index < 0 ? this.count() : this.size);
4331
+ var spliced = this.slice(0, index);
4332
+ return reify(
4333
+ this,
4334
+ numArgs === 1 ? spliced : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
4335
+ );
4336
+ },
4337
+ // ### More collection methods
4338
+ findLastIndex: function findLastIndex(predicate, context) {
4339
+ var entry = this.findLastEntry(predicate, context);
4340
+ return entry ? entry[0] : -1;
4341
+ },
4342
+ first: function first2(notSetValue) {
4343
+ return this.get(0, notSetValue);
4344
+ },
4345
+ flatten: function flatten2(depth) {
4346
+ return reify(this, flattenFactory(this, depth, false));
4347
+ },
4348
+ get: function get8(index, notSetValue) {
4349
+ index = wrapIndex(this, index);
4350
+ return index < 0 || this.size === Infinity || this.size !== void 0 && index > this.size ? notSetValue : this.find(function(_, key) {
4351
+ return key === index;
4352
+ }, void 0, notSetValue);
4353
+ },
4354
+ has: function has3(index) {
4355
+ index = wrapIndex(this, index);
4356
+ return index >= 0 && (this.size !== void 0 ? this.size === Infinity || index < this.size : this.indexOf(index) !== -1);
4357
+ },
4358
+ interpose: function interpose(separator) {
4359
+ return reify(this, interposeFactory(this, separator));
4360
+ },
4361
+ interleave: function interleave() {
4362
+ var collections = [this].concat(arrCopy(arguments));
4363
+ var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
4364
+ var interleaved = zipped.flatten(true);
4365
+ if (zipped.size) {
4366
+ interleaved.size = zipped.size * collections.length;
4367
+ }
4368
+ return reify(this, interleaved);
4369
+ },
4370
+ keySeq: function keySeq2() {
4371
+ return Range(0, this.size);
4372
+ },
4373
+ last: function last2(notSetValue) {
4374
+ return this.get(-1, notSetValue);
4375
+ },
4376
+ skipWhile: function skipWhile2(predicate, context) {
4377
+ return reify(this, skipWhileFactory(this, predicate, context, false));
4378
+ },
4379
+ zip: function zip() {
4380
+ var collections = [this].concat(arrCopy(arguments));
4381
+ return reify(this, zipWithFactory(this, defaultZipper, collections));
4382
+ },
4383
+ zipAll: function zipAll() {
4384
+ var collections = [this].concat(arrCopy(arguments));
4385
+ return reify(this, zipWithFactory(this, defaultZipper, collections, true));
4386
+ },
4387
+ zipWith: function zipWith(zipper) {
4388
+ var collections = arrCopy(arguments);
4389
+ collections[0] = this;
4390
+ return reify(this, zipWithFactory(this, zipper, collections));
4391
+ }
4392
+ });
4393
+ var IndexedCollectionPrototype = IndexedCollection.prototype;
4394
+ IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
4395
+ IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
4396
+ mixin(SetCollection, {
4397
+ // ### ES6 Collection methods (ES6 Array and Map)
4398
+ get: function get9(value, notSetValue) {
4399
+ return this.has(value) ? value : notSetValue;
4400
+ },
4401
+ includes: function includes2(value) {
4402
+ return this.has(value);
4403
+ },
4404
+ // ### More sequential methods
4405
+ keySeq: function keySeq3() {
4406
+ return this.valueSeq();
4407
+ }
4408
+ });
4409
+ var SetCollectionPrototype = SetCollection.prototype;
4410
+ SetCollectionPrototype.has = CollectionPrototype.includes;
4411
+ SetCollectionPrototype.contains = SetCollectionPrototype.includes;
4412
+ SetCollectionPrototype.keys = SetCollectionPrototype.values;
4413
+ mixin(KeyedSeq, KeyedCollectionPrototype);
4414
+ mixin(IndexedSeq, IndexedCollectionPrototype);
4415
+ mixin(SetSeq, SetCollectionPrototype);
4416
+ function reduce(collection, reducer, reduction, context, useFirst, reverse3) {
4417
+ assertNotInfinite(collection.size);
4418
+ collection.__iterate(function(v, k, c) {
4419
+ if (useFirst) {
4420
+ useFirst = false;
4421
+ reduction = v;
4422
+ } else {
4423
+ reduction = reducer.call(context, reduction, v, k, c);
4424
+ }
4425
+ }, reverse3);
4426
+ return reduction;
4427
+ }
4428
+ function keyMapper(v, k) {
4429
+ return k;
4430
+ }
4431
+ function entryMapper(v, k) {
4432
+ return [k, v];
4433
+ }
4434
+ function not(predicate) {
4435
+ return function() {
4436
+ return !predicate.apply(this, arguments);
4437
+ };
4438
+ }
4439
+ function neg(predicate) {
4440
+ return function() {
4441
+ return -predicate.apply(this, arguments);
4442
+ };
4443
+ }
4444
+ function defaultZipper() {
4445
+ return arrCopy(arguments);
4446
+ }
4447
+ function defaultNegComparator(a, b) {
4448
+ return a < b ? 1 : a > b ? -1 : 0;
4449
+ }
4450
+ function hashCollection(collection) {
4451
+ if (collection.size === Infinity) {
4452
+ return 0;
4453
+ }
4454
+ var ordered = isOrdered(collection);
4455
+ var keyed = isKeyed(collection);
4456
+ var h = ordered ? 1 : 0;
4457
+ collection.__iterate(
4458
+ keyed ? ordered ? function(v, k) {
4459
+ h = 31 * h + hashMerge(hash(v), hash(k)) | 0;
4460
+ } : function(v, k) {
4461
+ h = h + hashMerge(hash(v), hash(k)) | 0;
4462
+ } : ordered ? function(v) {
4463
+ h = 31 * h + hash(v) | 0;
4464
+ } : function(v) {
4465
+ h = h + hash(v) | 0;
4466
+ }
4467
+ );
4468
+ return murmurHashOfSize(collection.size, h);
4469
+ }
4470
+ function murmurHashOfSize(size, h) {
4471
+ h = imul(h, 3432918353);
4472
+ h = imul(h << 15 | h >>> -15, 461845907);
4473
+ h = imul(h << 13 | h >>> -13, 5);
4474
+ h = (h + 3864292196 | 0) ^ size;
4475
+ h = imul(h ^ h >>> 16, 2246822507);
4476
+ h = imul(h ^ h >>> 13, 3266489909);
4477
+ h = smi(h ^ h >>> 16);
4478
+ return h;
4479
+ }
4480
+ function hashMerge(a, b) {
4481
+ return a ^ b + 2654435769 + (a << 6) + (a >> 2) | 0;
4482
+ }
4483
+ var OrderedSet = /* @__PURE__ */ function(Set2) {
4484
+ function OrderedSet2(value) {
4485
+ return value === void 0 || value === null ? emptyOrderedSet() : isOrderedSet(value) ? value : emptyOrderedSet().withMutations(function(set3) {
4486
+ var iter = SetCollection(value);
4487
+ assertNotInfinite(iter.size);
4488
+ iter.forEach(function(v) {
4489
+ return set3.add(v);
4490
+ });
4491
+ });
4492
+ }
4493
+ if (Set2) OrderedSet2.__proto__ = Set2;
4494
+ OrderedSet2.prototype = Object.create(Set2 && Set2.prototype);
4495
+ OrderedSet2.prototype.constructor = OrderedSet2;
4496
+ OrderedSet2.of = function of3() {
4497
+ return this(arguments);
4498
+ };
4499
+ OrderedSet2.fromKeys = function fromKeys(value) {
4500
+ return this(KeyedCollection(value).keySeq());
4501
+ };
4502
+ OrderedSet2.prototype.toString = function toString5() {
4503
+ return this.__toString("OrderedSet {", "}");
4504
+ };
4505
+ return OrderedSet2;
4506
+ }(Set);
4507
+ OrderedSet.isOrderedSet = isOrderedSet;
4508
+ var OrderedSetPrototype = OrderedSet.prototype;
4509
+ OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
4510
+ OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
4511
+ OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
4512
+ OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll;
4513
+ OrderedSetPrototype.__empty = emptyOrderedSet;
4514
+ OrderedSetPrototype.__make = makeOrderedSet;
4515
+ function makeOrderedSet(map5, ownerID) {
4516
+ var set3 = Object.create(OrderedSetPrototype);
4517
+ set3.size = map5 ? map5.size : 0;
4518
+ set3._map = map5;
4519
+ set3.__ownerID = ownerID;
4520
+ return set3;
4521
+ }
4522
+ var EMPTY_ORDERED_SET;
4523
+ function emptyOrderedSet() {
4524
+ return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
4525
+ }
4526
+ function throwOnInvalidDefaultValues(defaultValues) {
4527
+ if (isRecord(defaultValues)) {
4528
+ throw new Error(
4529
+ "Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead."
4530
+ );
4531
+ }
4532
+ if (isImmutable(defaultValues)) {
4533
+ throw new Error(
4534
+ "Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead."
4535
+ );
4536
+ }
4537
+ if (defaultValues === null || typeof defaultValues !== "object") {
4538
+ throw new Error(
4539
+ "Can not call `Record` with a non-object as default values. Use a plain javascript object instead."
4540
+ );
4541
+ }
4542
+ }
4543
+ var Record = function Record2(defaultValues, name) {
4544
+ var hasInitialized;
4545
+ throwOnInvalidDefaultValues(defaultValues);
4546
+ var RecordType = function Record3(values2) {
4547
+ var this$1$1 = this;
4548
+ if (values2 instanceof RecordType) {
4549
+ return values2;
4550
+ }
4551
+ if (!(this instanceof RecordType)) {
4552
+ return new RecordType(values2);
4553
+ }
4554
+ if (!hasInitialized) {
4555
+ hasInitialized = true;
4556
+ var keys2 = Object.keys(defaultValues);
4557
+ var indices = RecordTypePrototype._indices = {};
4558
+ RecordTypePrototype._name = name;
4559
+ RecordTypePrototype._keys = keys2;
4560
+ RecordTypePrototype._defaultValues = defaultValues;
4561
+ for (var i = 0; i < keys2.length; i++) {
4562
+ var propName = keys2[i];
4563
+ indices[propName] = i;
4564
+ if (RecordTypePrototype[propName]) {
4565
+ typeof console === "object" && console.warn && console.warn(
4566
+ "Cannot define " + recordName(this) + ' with property "' + propName + '" since that property name is part of the Record API.'
4567
+ );
4568
+ } else {
4569
+ setProp(RecordTypePrototype, propName);
4570
+ }
4571
+ }
4572
+ }
4573
+ this.__ownerID = void 0;
4574
+ this._values = List().withMutations(function(l) {
4575
+ l.setSize(this$1$1._keys.length);
4576
+ KeyedCollection(values2).forEach(function(v, k) {
4577
+ l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? void 0 : v);
4578
+ });
4579
+ });
4580
+ return this;
4581
+ };
4582
+ var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
4583
+ RecordTypePrototype.constructor = RecordType;
4584
+ if (name) {
4585
+ RecordType.displayName = name;
4586
+ }
4587
+ return RecordType;
4588
+ };
4589
+ Record.prototype.toString = function toString4() {
4590
+ var str = recordName(this) + " { ";
4591
+ var keys2 = this._keys;
4592
+ var k;
4593
+ for (var i = 0, l = keys2.length; i !== l; i++) {
4594
+ k = keys2[i];
4595
+ str += (i ? ", " : "") + k + ": " + quoteString(this.get(k));
4596
+ }
4597
+ return str + " }";
4598
+ };
4599
+ Record.prototype.equals = function equals2(other) {
4600
+ return this === other || isRecord(other) && recordSeq(this).equals(recordSeq(other));
4601
+ };
4602
+ Record.prototype.hashCode = function hashCode2() {
4603
+ return recordSeq(this).hashCode();
4604
+ };
4605
+ Record.prototype.has = function has4(k) {
4606
+ return this._indices.hasOwnProperty(k);
4607
+ };
4608
+ Record.prototype.get = function get10(k, notSetValue) {
4609
+ if (!this.has(k)) {
4610
+ return notSetValue;
4611
+ }
4612
+ var index = this._indices[k];
4613
+ var value = this._values.get(index);
4614
+ return value === void 0 ? this._defaultValues[k] : value;
4615
+ };
4616
+ Record.prototype.set = function set2(k, v) {
4617
+ if (this.has(k)) {
4618
+ var newValues = this._values.set(
4619
+ this._indices[k],
4620
+ v === this._defaultValues[k] ? void 0 : v
4621
+ );
4622
+ if (newValues !== this._values && !this.__ownerID) {
4623
+ return makeRecord(this, newValues);
4624
+ }
4625
+ }
4626
+ return this;
4627
+ };
4628
+ Record.prototype.remove = function remove2(k) {
4629
+ return this.set(k);
4630
+ };
4631
+ Record.prototype.clear = function clear() {
4632
+ var newValues = this._values.clear().setSize(this._keys.length);
4633
+ return this.__ownerID ? this : makeRecord(this, newValues);
4634
+ };
4635
+ Record.prototype.wasAltered = function wasAltered2() {
4636
+ return this._values.wasAltered();
4637
+ };
4638
+ Record.prototype.toSeq = function toSeq2() {
4639
+ return recordSeq(this);
4640
+ };
4641
+ Record.prototype.toJS = function toJS$12() {
4642
+ return toJS(this);
4643
+ };
4644
+ Record.prototype.entries = function entries2() {
4645
+ return this.__iterator(ITERATE_ENTRIES);
4646
+ };
4647
+ Record.prototype.__iterator = function __iterator(type, reverse3) {
4648
+ return recordSeq(this).__iterator(type, reverse3);
4649
+ };
4650
+ Record.prototype.__iterate = function __iterate(fn, reverse3) {
4651
+ return recordSeq(this).__iterate(fn, reverse3);
4652
+ };
4653
+ Record.prototype.__ensureOwner = function __ensureOwner(ownerID) {
4654
+ if (ownerID === this.__ownerID) {
4655
+ return this;
4656
+ }
4657
+ var newValues = this._values.__ensureOwner(ownerID);
4658
+ if (!ownerID) {
4659
+ this.__ownerID = ownerID;
4660
+ this._values = newValues;
4661
+ return this;
4662
+ }
4663
+ return makeRecord(this, newValues, ownerID);
4664
+ };
4665
+ Record.isRecord = isRecord;
4666
+ Record.getDescriptiveName = recordName;
4667
+ var RecordPrototype = Record.prototype;
4668
+ RecordPrototype[IS_RECORD_SYMBOL] = true;
4669
+ RecordPrototype[DELETE] = RecordPrototype.remove;
4670
+ RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
4671
+ RecordPrototype.getIn = getIn;
4672
+ RecordPrototype.hasIn = CollectionPrototype.hasIn;
4673
+ RecordPrototype.merge = merge$1;
4674
+ RecordPrototype.mergeWith = mergeWith$1;
4675
+ RecordPrototype.mergeIn = mergeIn;
4676
+ RecordPrototype.mergeDeep = mergeDeep;
4677
+ RecordPrototype.mergeDeepWith = mergeDeepWith;
4678
+ RecordPrototype.mergeDeepIn = mergeDeepIn;
4679
+ RecordPrototype.setIn = setIn;
4680
+ RecordPrototype.update = update;
4681
+ RecordPrototype.updateIn = updateIn;
4682
+ RecordPrototype.withMutations = withMutations;
4683
+ RecordPrototype.asMutable = asMutable;
4684
+ RecordPrototype.asImmutable = asImmutable;
4685
+ RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
4686
+ RecordPrototype.toJSON = RecordPrototype.toObject = CollectionPrototype.toObject;
4687
+ RecordPrototype.inspect = RecordPrototype.toSource = function() {
4688
+ return this.toString();
4689
+ };
4690
+ function makeRecord(likeRecord, values2, ownerID) {
4691
+ var record = Object.create(Object.getPrototypeOf(likeRecord));
4692
+ record._values = values2;
4693
+ record.__ownerID = ownerID;
4694
+ return record;
4695
+ }
4696
+ function recordName(record) {
4697
+ return record.constructor.displayName || record.constructor.name || "Record";
4698
+ }
4699
+ function recordSeq(record) {
4700
+ return keyedSeqFromValue(record._keys.map(function(k) {
4701
+ return [k, record.get(k)];
4702
+ }));
4703
+ }
4704
+ function setProp(prototype, name) {
4705
+ try {
4706
+ Object.defineProperty(prototype, name, {
4707
+ get: function() {
4708
+ return this.get(name);
4709
+ },
4710
+ set: function(value) {
4711
+ invariant(this.__ownerID, "Cannot set on an immutable record.");
4712
+ this.set(name, value);
4713
+ }
4714
+ });
4715
+ } catch (error) {
4716
+ }
4717
+ }
4718
+
4719
+ // src/store/store.ts
4720
+ import { EMPTY as EMPTY2, map as map4, of as of2, scan, shareReplay, Subject, switchMap as switchMap2 } from "rxjs";
4721
+
4722
+ // src/batcher/index.ts
4723
+ import { Observable as Observable3 } from "rxjs";
4724
+ function batcher(waitTime) {
4725
+ return (source$) => new Observable3((observer) => {
4726
+ let buffer = [];
4727
+ const loaded = [];
4728
+ let timerId = null;
4729
+ const emitBuffer = () => {
4730
+ if (buffer.length > 0) {
4731
+ observer.next({
4732
+ next: [...buffer],
4733
+ loaded: [...loaded]
4734
+ });
4735
+ loaded.push(...buffer);
4736
+ buffer = [];
4737
+ }
4738
+ clearTimeout(timerId);
4739
+ timerId = null;
4740
+ };
4741
+ const sub = source$.subscribe({
4742
+ next: (value) => {
4743
+ buffer.push(value);
4744
+ if (!timerId) {
4745
+ timerId = setTimeout(() => {
4746
+ emitBuffer();
4747
+ }, waitTime);
4748
+ }
4749
+ },
4750
+ error: (err) => observer.error(err),
4751
+ complete: () => {
4752
+ emitBuffer();
4753
+ observer.complete();
4754
+ }
4755
+ });
4756
+ return () => {
4757
+ clearTimeout(timerId);
4758
+ sub.unsubscribe();
4759
+ };
4760
+ });
4761
+ }
4762
+
4763
+ // src/lens/lens.ts
4764
+ import { Observable as Observable4, BehaviorSubject as BehaviorSubject2, Subscription } from "rxjs";
4765
+ import { distinctUntilChanged, map as map3, tap as tap2 } from "rxjs/operators";
4766
+ import { isEqual } from "lodash";
4767
+ var Lens = class extends Observable4 {
4768
+ constructor(source$, lens) {
4769
+ const initialValue = lens.get(source$.get());
4770
+ const subject$ = new BehaviorSubject2(initialValue);
4771
+ super((subscriber) => {
4772
+ const localSub = subject$.subscribe(subscriber);
4773
+ if (this.subCount++ === 0) {
4774
+ this.sub = new Subscription();
4775
+ this.sub.add(
4776
+ source$.pipe(
4777
+ map3((x) => lens.get(x)),
4778
+ distinctUntilChanged(isEqual),
4779
+ tap2((x) => {
4780
+ const prev = subject$.getValue();
4781
+ if (!isEqual(prev, x)) {
4782
+ subject$.next(x);
4783
+ }
4784
+ })
4785
+ ).subscribe()
4786
+ );
4787
+ this.sub.add(
4788
+ subject$.pipe(
4789
+ distinctUntilChanged(isEqual),
4790
+ tap2((next) => {
4791
+ const value = source$.get();
4792
+ const updated = lens.set(next, value);
4793
+ if (!isEqual(updated, value)) {
4794
+ source$.set(updated);
4795
+ }
4796
+ })
4797
+ ).subscribe()
4798
+ );
4799
+ return () => {
4800
+ localSub.unsubscribe();
4801
+ if (--this.subCount === 0) {
4802
+ this.sub?.unsubscribe();
4803
+ this.sub = void 0;
4804
+ }
4805
+ };
4806
+ }
4807
+ });
4808
+ this.subCount = 0;
4809
+ this.set = (value) => this.subject$.next(value);
4810
+ this.get = () => this.subject$.getValue();
4811
+ this.modify = (fn) => this.set(fn(this.get()));
4812
+ this.subject$ = subject$;
4813
+ }
4814
+ };
4815
+ function createLens(source$, lens) {
4816
+ return new Lens(source$, lens);
4817
+ }
4818
+ function keyLens(key) {
4819
+ return {
4820
+ get: (source) => source[key],
4821
+ set: (current, source) => ({
4822
+ ...source,
4823
+ [key]: current
4824
+ })
4825
+ };
4826
+ }
4827
+
4828
+ // src/store/store.ts
4829
+ function createState(val) {
4830
+ return toBranded("store", val);
4831
+ }
4832
+ function createStore(queue, state$) {
4833
+ return {
4834
+ state$,
4835
+ collect: () => queue.start().onIdle(),
4836
+ node: (name) => {
4837
+ const lens = createLens(state$, {
4838
+ get: (x) => x.value[name] ?? toBranded("store", {}),
4839
+ set: (x, xs) => ({
4840
+ ...xs,
4841
+ value: { ...xs.value, [name]: x }
4842
+ })
4843
+ });
4844
+ return createStore(queue, lens);
4845
+ },
4846
+ factoryBatch: (name, batch) => {
4847
+ const lens = createLens(state$, {
4848
+ get: (x) => x.value[name] ?? toBranded("map", {}),
4849
+ set: (x, xs) => ({
4850
+ ...xs,
4851
+ value: { ...xs.value, [name]: x }
4852
+ })
4853
+ });
4854
+ return createFactory(batch, queue, lens);
4855
+ }
4856
+ };
4857
+ }
4858
+ function createFactory(batch, queue, state$) {
4859
+ const cache = Map().asMutable();
4860
+ const keys$ = new Subject();
4861
+ const map$ = keys$.pipe(
4862
+ batcher(250),
4863
+ switchMap2(({ next, loaded }) => batch(subtractArrays(next, loaded))),
4864
+ scan((acc, val) => ({ ...acc, ...val }), {}),
4865
+ shareReplay(1)
4866
+ );
4867
+ map$.subscribe();
4868
+ return {
4869
+ get: (key) => {
4870
+ if (!cache.has(key)) {
4871
+ keys$.next(key);
4872
+ const lens = createLens(
4873
+ createLens(state$, {
4874
+ get: (x) => {
4875
+ const value = x.value[key];
4876
+ return value ?? toBranded("edge", createIdle());
4877
+ },
4878
+ set: (x, xs) => ({
4879
+ ...xs,
4880
+ value: { ...xs.value, [key]: x }
4881
+ })
4882
+ }),
4883
+ keyLens("value")
4884
+ );
4885
+ const edge = createEdge(
4886
+ lens,
4887
+ queue,
4888
+ () => map$.pipe(
4889
+ map4((x) => x[key]),
4890
+ switchMap2((x) => x ? of2(x) : EMPTY2)
4891
+ )
4892
+ );
4893
+ cache.set(key, edge);
4894
+ }
4895
+ return cache.get(key);
4896
+ }
4897
+ };
4898
+ }
4899
+ function subtractArrays(arrayA, arrayB) {
4900
+ return arrayA.filter((item) => !arrayB.includes(item));
4901
+ }
4902
+ export {
4903
+ Atom,
4904
+ Lens,
4905
+ StatusEnum,
4906
+ createAtom,
4907
+ createEdge,
4908
+ createFulfilled,
4909
+ createIdle,
4910
+ createLens,
4911
+ createPending,
4912
+ createRejected,
4913
+ createState,
4914
+ createStore,
4915
+ isBranded,
4916
+ keyLens,
4917
+ toBranded
4918
+ };
4919
+ /*! Bundled license information:
4920
+
4921
+ immutable/dist/immutable.es.js:
4922
+ (**
4923
+ * @license
4924
+ * MIT License
4925
+ *
4926
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
4927
+ *
4928
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4929
+ * of this software and associated documentation files (the "Software"), to deal
4930
+ * in the Software without restriction, including without limitation the rights
4931
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
4932
+ * copies of the Software, and to permit persons to whom the Software is
4933
+ * furnished to do so, subject to the following conditions:
4934
+ *
4935
+ * The above copyright notice and this permission notice shall be included in all
4936
+ * copies or substantial portions of the Software.
4937
+ *
4938
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
4939
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
4940
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
4941
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
4942
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
4943
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4944
+ * SOFTWARE.
4945
+ *)
4946
+ */