immutable 4.0.0-rc.6 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,26 @@
1
1
  /**
2
- * Copyright (c) 2014-present, Facebook, Inc.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
2
+ * MIT License
3
+ *
4
+ * Copyright (c) 2014-present, Lee Byron and other contributors.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
6
23
  */
7
-
8
- // Used for setting prototype methods that IE8 chokes on.
9
24
  var DELETE = 'delete';
10
25
 
11
26
  // Constants describing the size of trie nodes.
@@ -18,16 +33,14 @@ var MASK = SIZE - 1;
18
33
  var NOT_SET = {};
19
34
 
20
35
  // Boolean references, Rough equivalent of `bool &`.
21
- var CHANGE_LENGTH = { value: false };
22
- var DID_ALTER = { value: false };
23
-
24
- function MakeRef(ref) {
25
- ref.value = false;
26
- return ref;
36
+ function MakeRef() {
37
+ return { value: false };
27
38
  }
28
39
 
29
40
  function SetRef(ref) {
30
- ref && (ref.value = true);
41
+ if (ref) {
42
+ ref.value = true;
43
+ }
31
44
  }
32
45
 
33
46
  // A function which returns a value representing an "owner" for transient writes
@@ -35,17 +48,6 @@ function SetRef(ref) {
35
48
  // the return of any subsequent call of this function.
36
49
  function OwnerID() {}
37
50
 
38
- // http://jsperf.com/copy-array-inline
39
- function arrCopy(arr, offset) {
40
- offset = offset || 0;
41
- var len = Math.max(0, arr.length - offset);
42
- var newArr = new Array(len);
43
- for (var ii = 0; ii < len; ii++) {
44
- newArr[ii] = arr[ii + offset];
45
- }
46
- return newArr;
47
- }
48
-
49
51
  function ensureSize(iter) {
50
52
  if (iter.size === undefined) {
51
53
  iter.size = iter.__iterate(returnTrue);
@@ -97,10 +99,12 @@ function resolveIndex(index, size, defaultIndex) {
97
99
  return index === undefined
98
100
  ? defaultIndex
99
101
  : isNeg(index)
100
- ? size === Infinity ? size : Math.max(0, size + index) | 0
101
- : size === undefined || size === index
102
- ? index
103
- : Math.min(size, index) | 0;
102
+ ? size === Infinity
103
+ ? size
104
+ : Math.max(0, size + index) | 0
105
+ : size === undefined || size === index
106
+ ? index
107
+ : Math.min(size, index) | 0;
104
108
  }
105
109
 
106
110
  function isNeg(value) {
@@ -108,56 +112,33 @@ function isNeg(value) {
108
112
  return value < 0 || (value === 0 && 1 / value === -Infinity);
109
113
  }
110
114
 
111
- function isImmutable(maybeImmutable) {
112
- return (
113
- (isCollection(maybeImmutable) || isRecord(maybeImmutable)) &&
114
- !maybeImmutable.__ownerID
115
- );
116
- }
115
+ var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
117
116
 
118
117
  function isCollection(maybeCollection) {
119
- return !!(maybeCollection && maybeCollection[IS_ITERABLE_SENTINEL]);
118
+ return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
120
119
  }
121
120
 
121
+ var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
122
+
122
123
  function isKeyed(maybeKeyed) {
123
- return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
124
+ return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
124
125
  }
125
126
 
127
+ var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
128
+
126
129
  function isIndexed(maybeIndexed) {
127
- return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
130
+ return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
128
131
  }
129
132
 
130
133
  function isAssociative(maybeAssociative) {
131
134
  return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
132
135
  }
133
136
 
134
- function isOrdered(maybeOrdered) {
135
- return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
136
- }
137
-
138
- function isRecord(maybeRecord) {
139
- return !!(maybeRecord && maybeRecord[IS_RECORD_SENTINEL]);
140
- }
141
-
142
- function isValueObject(maybeValue) {
143
- return !!(
144
- maybeValue &&
145
- typeof maybeValue.equals === 'function' &&
146
- typeof maybeValue.hashCode === 'function'
147
- );
148
- }
149
-
150
- var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
151
- var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
152
- var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
153
- var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
154
- var IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@';
155
-
156
137
  var Collection = function Collection(value) {
157
138
  return isCollection(value) ? value : Seq(value);
158
139
  };
159
140
 
160
- var KeyedCollection = (function (Collection) {
141
+ var KeyedCollection = /*@__PURE__*/(function (Collection) {
161
142
  function KeyedCollection(value) {
162
143
  return isKeyed(value) ? value : KeyedSeq(value);
163
144
  }
@@ -169,7 +150,7 @@ var KeyedCollection = (function (Collection) {
169
150
  return KeyedCollection;
170
151
  }(Collection));
171
152
 
172
- var IndexedCollection = (function (Collection) {
153
+ var IndexedCollection = /*@__PURE__*/(function (Collection) {
173
154
  function IndexedCollection(value) {
174
155
  return isIndexed(value) ? value : IndexedSeq(value);
175
156
  }
@@ -181,7 +162,7 @@ var IndexedCollection = (function (Collection) {
181
162
  return IndexedCollection;
182
163
  }(Collection));
183
164
 
184
- var SetCollection = (function (Collection) {
165
+ var SetCollection = /*@__PURE__*/(function (Collection) {
185
166
  function SetCollection(value) {
186
167
  return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
187
168
  }
@@ -197,6 +178,28 @@ Collection.Keyed = KeyedCollection;
197
178
  Collection.Indexed = IndexedCollection;
198
179
  Collection.Set = SetCollection;
199
180
 
181
+ var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
182
+
183
+ function isSeq(maybeSeq) {
184
+ return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
185
+ }
186
+
187
+ var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
188
+
189
+ function isRecord(maybeRecord) {
190
+ return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
191
+ }
192
+
193
+ function isImmutable(maybeImmutable) {
194
+ return isCollection(maybeImmutable) || isRecord(maybeImmutable);
195
+ }
196
+
197
+ var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
198
+
199
+ function isOrdered(maybeOrdered) {
200
+ return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
201
+ }
202
+
200
203
  var ITERATE_KEYS = 0;
201
204
  var ITERATE_VALUES = 1;
202
205
  var ITERATE_ENTRIES = 2;
@@ -218,10 +221,10 @@ Iterator.KEYS = ITERATE_KEYS;
218
221
  Iterator.VALUES = ITERATE_VALUES;
219
222
  Iterator.ENTRIES = ITERATE_ENTRIES;
220
223
 
221
- Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
224
+ Iterator.prototype.inspect = Iterator.prototype.toSource = function () {
222
225
  return this.toString();
223
226
  };
224
- Iterator.prototype[ITERATOR_SYMBOL] = function() {
227
+ Iterator.prototype[ITERATOR_SYMBOL] = function () {
225
228
  return this;
226
229
  };
227
230
 
@@ -231,7 +234,7 @@ function iteratorValue(type, k, v, iteratorResult) {
231
234
  ? (iteratorResult.value = value)
232
235
  : (iteratorResult = {
233
236
  value: value,
234
- done: false
237
+ done: false,
235
238
  });
236
239
  return iteratorResult;
237
240
  }
@@ -241,6 +244,11 @@ function iteratorDone() {
241
244
  }
242
245
 
243
246
  function hasIterator(maybeIterable) {
247
+ if (Array.isArray(maybeIterable)) {
248
+ // IE11 trick as it does not support `Symbol.iterator`
249
+ return true;
250
+ }
251
+
244
252
  return !!getIteratorFn(maybeIterable);
245
253
  }
246
254
 
@@ -263,21 +271,48 @@ function getIteratorFn(iterable) {
263
271
  }
264
272
  }
265
273
 
274
+ function isEntriesIterable(maybeIterable) {
275
+ var iteratorFn = getIteratorFn(maybeIterable);
276
+ return iteratorFn && iteratorFn === maybeIterable.entries;
277
+ }
278
+
279
+ function isKeysIterable(maybeIterable) {
280
+ var iteratorFn = getIteratorFn(maybeIterable);
281
+ return iteratorFn && iteratorFn === maybeIterable.keys;
282
+ }
283
+
284
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
285
+
266
286
  function isArrayLike(value) {
267
- return value && typeof value.length === 'number';
287
+ if (Array.isArray(value) || typeof value === 'string') {
288
+ return true;
289
+ }
290
+
291
+ return (
292
+ value &&
293
+ typeof value === 'object' &&
294
+ Number.isInteger(value.length) &&
295
+ value.length >= 0 &&
296
+ (value.length === 0
297
+ ? // Only {length: 0} is considered Array-like.
298
+ Object.keys(value).length === 1
299
+ : // An object is only Array-like if it has a property where the last value
300
+ // in the array-like may be found (which could be undefined).
301
+ value.hasOwnProperty(value.length - 1))
302
+ );
268
303
  }
269
304
 
270
- var Seq = (function (Collection$$1) {
305
+ var Seq = /*@__PURE__*/(function (Collection) {
271
306
  function Seq(value) {
272
307
  return value === null || value === undefined
273
308
  ? emptySequence()
274
- : isCollection(value) || isRecord(value)
275
- ? value.toSeq()
276
- : seqFromValue(value);
309
+ : isImmutable(value)
310
+ ? value.toSeq()
311
+ : seqFromValue(value);
277
312
  }
278
313
 
279
- if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
280
- Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
314
+ if ( Collection ) Seq.__proto__ = Collection;
315
+ Seq.prototype = Object.create( Collection && Collection.prototype );
281
316
  Seq.prototype.constructor = Seq;
282
317
 
283
318
  Seq.prototype.toSeq = function toSeq () {
@@ -299,15 +334,13 @@ var Seq = (function (Collection$$1) {
299
334
  // abstract __iterateUncached(fn, reverse)
300
335
 
301
336
  Seq.prototype.__iterate = function __iterate (fn, reverse) {
302
- var this$1 = this;
303
-
304
337
  var cache = this._cache;
305
338
  if (cache) {
306
339
  var size = cache.length;
307
340
  var i = 0;
308
341
  while (i !== size) {
309
342
  var entry = cache[reverse ? size - ++i : i++];
310
- if (fn(entry[1], entry[0], this$1) === false) {
343
+ if (fn(entry[1], entry[0], this) === false) {
311
344
  break;
312
345
  }
313
346
  }
@@ -337,13 +370,17 @@ var Seq = (function (Collection$$1) {
337
370
  return Seq;
338
371
  }(Collection));
339
372
 
340
- var KeyedSeq = (function (Seq) {
373
+ var KeyedSeq = /*@__PURE__*/(function (Seq) {
341
374
  function KeyedSeq(value) {
342
375
  return value === null || value === undefined
343
376
  ? emptySequence().toKeyedSeq()
344
377
  : isCollection(value)
345
- ? isKeyed(value) ? value.toSeq() : value.fromEntrySeq()
346
- : isRecord(value) ? value.toSeq() : keyedSeqFromValue(value);
378
+ ? isKeyed(value)
379
+ ? value.toSeq()
380
+ : value.fromEntrySeq()
381
+ : isRecord(value)
382
+ ? value.toSeq()
383
+ : keyedSeqFromValue(value);
347
384
  }
348
385
 
349
386
  if ( Seq ) KeyedSeq.__proto__ = Seq;
@@ -357,15 +394,17 @@ var KeyedSeq = (function (Seq) {
357
394
  return KeyedSeq;
358
395
  }(Seq));
359
396
 
360
- var IndexedSeq = (function (Seq) {
397
+ var IndexedSeq = /*@__PURE__*/(function (Seq) {
361
398
  function IndexedSeq(value) {
362
399
  return value === null || value === undefined
363
400
  ? emptySequence()
364
401
  : isCollection(value)
365
- ? isKeyed(value) ? value.entrySeq() : value.toIndexedSeq()
366
- : isRecord(value)
367
- ? value.toSeq().entrySeq()
368
- : indexedSeqFromValue(value);
402
+ ? isKeyed(value)
403
+ ? value.entrySeq()
404
+ : value.toIndexedSeq()
405
+ : isRecord(value)
406
+ ? value.toSeq().entrySeq()
407
+ : indexedSeqFromValue(value);
369
408
  }
370
409
 
371
410
  if ( Seq ) IndexedSeq.__proto__ = Seq;
@@ -387,11 +426,10 @@ var IndexedSeq = (function (Seq) {
387
426
  return IndexedSeq;
388
427
  }(Seq));
389
428
 
390
- var SetSeq = (function (Seq) {
429
+ var SetSeq = /*@__PURE__*/(function (Seq) {
391
430
  function SetSeq(value) {
392
- return (isCollection(value) && !isAssociative(value)
393
- ? value
394
- : IndexedSeq(value)
431
+ return (
432
+ isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)
395
433
  ).toSetSeq();
396
434
  }
397
435
 
@@ -415,13 +453,11 @@ Seq.Keyed = KeyedSeq;
415
453
  Seq.Set = SetSeq;
416
454
  Seq.Indexed = IndexedSeq;
417
455
 
418
- var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
419
-
420
- Seq.prototype[IS_SEQ_SENTINEL] = true;
456
+ Seq.prototype[IS_SEQ_SYMBOL] = true;
421
457
 
422
458
  // #pragma Root Sequences
423
459
 
424
- var ArraySeq = (function (IndexedSeq) {
460
+ var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
425
461
  function ArraySeq(array) {
426
462
  this._array = array;
427
463
  this.size = array.length;
@@ -436,14 +472,12 @@ var ArraySeq = (function (IndexedSeq) {
436
472
  };
437
473
 
438
474
  ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
439
- var this$1 = this;
440
-
441
475
  var array = this._array;
442
476
  var size = array.length;
443
477
  var i = 0;
444
478
  while (i !== size) {
445
479
  var ii = reverse ? size - ++i : i++;
446
- if (fn(array[ii], ii, this$1) === false) {
480
+ if (fn(array[ii], ii, this) === false) {
447
481
  break;
448
482
  }
449
483
  }
@@ -466,7 +500,7 @@ var ArraySeq = (function (IndexedSeq) {
466
500
  return ArraySeq;
467
501
  }(IndexedSeq));
468
502
 
469
- var ObjectSeq = (function (KeyedSeq) {
503
+ var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
470
504
  function ObjectSeq(object) {
471
505
  var keys = Object.keys(object);
472
506
  this._object = object;
@@ -486,19 +520,17 @@ var ObjectSeq = (function (KeyedSeq) {
486
520
  };
487
521
 
488
522
  ObjectSeq.prototype.has = function has (key) {
489
- return this._object.hasOwnProperty(key);
523
+ return hasOwnProperty.call(this._object, key);
490
524
  };
491
525
 
492
526
  ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
493
- var this$1 = this;
494
-
495
527
  var object = this._object;
496
528
  var keys = this._keys;
497
529
  var size = keys.length;
498
530
  var i = 0;
499
531
  while (i !== size) {
500
532
  var key = keys[reverse ? size - ++i : i++];
501
- if (fn(object[key], key, this$1) === false) {
533
+ if (fn(object[key], key, this) === false) {
502
534
  break;
503
535
  }
504
536
  }
@@ -521,9 +553,9 @@ var ObjectSeq = (function (KeyedSeq) {
521
553
 
522
554
  return ObjectSeq;
523
555
  }(KeyedSeq));
524
- ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
556
+ ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
525
557
 
526
- var CollectionSeq = (function (IndexedSeq) {
558
+ var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
527
559
  function CollectionSeq(collection) {
528
560
  this._collection = collection;
529
561
  this.size = collection.length || collection.size;
@@ -534,8 +566,6 @@ var CollectionSeq = (function (IndexedSeq) {
534
566
  CollectionSeq.prototype.constructor = CollectionSeq;
535
567
 
536
568
  CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
537
- var this$1 = this;
538
-
539
569
  if (reverse) {
540
570
  return this.cacheResult().__iterate(fn, reverse);
541
571
  }
@@ -545,7 +575,7 @@ var CollectionSeq = (function (IndexedSeq) {
545
575
  if (isIterator(iterator)) {
546
576
  var step;
547
577
  while (!(step = iterator.next()).done) {
548
- if (fn(step.value, iterations++, this$1) === false) {
578
+ if (fn(step.value, iterations++, this) === false) {
549
579
  break;
550
580
  }
551
581
  }
@@ -572,69 +602,8 @@ var CollectionSeq = (function (IndexedSeq) {
572
602
  return CollectionSeq;
573
603
  }(IndexedSeq));
574
604
 
575
- var IteratorSeq = (function (IndexedSeq) {
576
- function IteratorSeq(iterator) {
577
- this._iterator = iterator;
578
- this._iteratorCache = [];
579
- }
580
-
581
- if ( IndexedSeq ) IteratorSeq.__proto__ = IndexedSeq;
582
- IteratorSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
583
- IteratorSeq.prototype.constructor = IteratorSeq;
584
-
585
- IteratorSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
586
- var this$1 = this;
587
-
588
- if (reverse) {
589
- return this.cacheResult().__iterate(fn, reverse);
590
- }
591
- var iterator = this._iterator;
592
- var cache = this._iteratorCache;
593
- var iterations = 0;
594
- while (iterations < cache.length) {
595
- if (fn(cache[iterations], iterations++, this$1) === false) {
596
- return iterations;
597
- }
598
- }
599
- var step;
600
- while (!(step = iterator.next()).done) {
601
- var val = step.value;
602
- cache[iterations] = val;
603
- if (fn(val, iterations++, this$1) === false) {
604
- break;
605
- }
606
- }
607
- return iterations;
608
- };
609
-
610
- IteratorSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
611
- if (reverse) {
612
- return this.cacheResult().__iterator(type, reverse);
613
- }
614
- var iterator = this._iterator;
615
- var cache = this._iteratorCache;
616
- var iterations = 0;
617
- return new Iterator(function () {
618
- if (iterations >= cache.length) {
619
- var step = iterator.next();
620
- if (step.done) {
621
- return step;
622
- }
623
- cache[iterations] = step.value;
624
- }
625
- return iteratorValue(type, iterations, cache[iterations++]);
626
- });
627
- };
628
-
629
- return IteratorSeq;
630
- }(IndexedSeq));
631
-
632
605
  // # pragma Helper functions
633
606
 
634
- function isSeq(maybeSeq) {
635
- return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
636
- }
637
-
638
607
  var EMPTY_SEQ;
639
608
 
640
609
  function emptySequence() {
@@ -642,11 +611,7 @@ function emptySequence() {
642
611
  }
643
612
 
644
613
  function keyedSeqFromValue(value) {
645
- var seq = Array.isArray(value)
646
- ? new ArraySeq(value)
647
- : isIterator(value)
648
- ? new IteratorSeq(value)
649
- : hasIterator(value) ? new CollectionSeq(value) : undefined;
614
+ var seq = maybeIndexedSeqFromValue(value);
650
615
  if (seq) {
651
616
  return seq.fromEntrySeq();
652
617
  }
@@ -672,7 +637,11 @@ function indexedSeqFromValue(value) {
672
637
  function seqFromValue(value) {
673
638
  var seq = maybeIndexedSeqFromValue(value);
674
639
  if (seq) {
675
- return seq;
640
+ return isEntriesIterable(value)
641
+ ? seq.fromEntrySeq()
642
+ : isKeysIterable(value)
643
+ ? seq.toSetSeq()
644
+ : seq;
676
645
  }
677
646
  if (typeof value === 'object') {
678
647
  return new ObjectSeq(value);
@@ -685,9 +654,27 @@ function seqFromValue(value) {
685
654
  function maybeIndexedSeqFromValue(value) {
686
655
  return isArrayLike(value)
687
656
  ? new ArraySeq(value)
688
- : isIterator(value)
689
- ? new IteratorSeq(value)
690
- : hasIterator(value) ? new CollectionSeq(value) : undefined;
657
+ : hasIterator(value)
658
+ ? new CollectionSeq(value)
659
+ : undefined;
660
+ }
661
+
662
+ var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
663
+
664
+ function isMap(maybeMap) {
665
+ return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
666
+ }
667
+
668
+ function isOrderedMap(maybeOrderedMap) {
669
+ return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
670
+ }
671
+
672
+ function isValueObject(maybeValue) {
673
+ return Boolean(
674
+ maybeValue &&
675
+ typeof maybeValue.equals === 'function' &&
676
+ typeof maybeValue.hashCode === 'function'
677
+ );
691
678
  }
692
679
 
693
680
  /**
@@ -791,50 +778,67 @@ function smi(i32) {
791
778
  return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
792
779
  }
793
780
 
781
+ var defaultValueOf = Object.prototype.valueOf;
782
+
794
783
  function hash(o) {
795
- if (o === false || o === null || o === undefined) {
796
- return 0;
797
- }
798
- if (typeof o.valueOf === 'function') {
799
- o = o.valueOf();
800
- if (o === false || o === null || o === undefined) {
801
- return 0;
802
- }
803
- }
804
- if (o === true) {
805
- return 1;
806
- }
807
- var type = typeof o;
808
- if (type === 'number') {
809
- if (o !== o || o === Infinity) {
810
- return 0;
811
- }
812
- var h = o | 0;
813
- if (h !== o) {
814
- h ^= o * 0xffffffff;
815
- }
816
- while (o > 0xffffffff) {
817
- o /= 0xffffffff;
818
- h ^= o;
819
- }
820
- return smi(h);
821
- }
822
- if (type === 'string') {
823
- return o.length > STRING_HASH_CACHE_MIN_STRLEN
824
- ? cachedHashString(o)
825
- : hashString(o);
784
+ if (o == null) {
785
+ return hashNullish(o);
826
786
  }
787
+
827
788
  if (typeof o.hashCode === 'function') {
828
789
  // Drop any high bits from accidentally long hash codes.
829
- return smi(o.hashCode());
790
+ return smi(o.hashCode(o));
791
+ }
792
+
793
+ var v = valueOf(o);
794
+
795
+ if (v == null) {
796
+ return hashNullish(v);
797
+ }
798
+
799
+ switch (typeof v) {
800
+ case 'boolean':
801
+ // The hash values for built-in constants are a 1 value for each 5-byte
802
+ // shift region expect for the first, which encodes the value. This
803
+ // reduces the odds of a hash collision for these common values.
804
+ return v ? 0x42108421 : 0x42108420;
805
+ case 'number':
806
+ return hashNumber(v);
807
+ case 'string':
808
+ return v.length > STRING_HASH_CACHE_MIN_STRLEN
809
+ ? cachedHashString(v)
810
+ : hashString(v);
811
+ case 'object':
812
+ case 'function':
813
+ return hashJSObj(v);
814
+ case 'symbol':
815
+ return hashSymbol(v);
816
+ default:
817
+ if (typeof v.toString === 'function') {
818
+ return hashString(v.toString());
819
+ }
820
+ throw new Error('Value type ' + typeof v + ' cannot be hashed.');
821
+ }
822
+ }
823
+
824
+ function hashNullish(nullish) {
825
+ return nullish === null ? 0x42108422 : /* undefined */ 0x42108423;
826
+ }
827
+
828
+ // Compress arbitrarily large numbers into smi hashes.
829
+ function hashNumber(n) {
830
+ if (n !== n || n === Infinity) {
831
+ return 0;
830
832
  }
831
- if (type === 'object') {
832
- return hashJSObj(o);
833
+ var hash = n | 0;
834
+ if (hash !== n) {
835
+ hash ^= n * 0xffffffff;
833
836
  }
834
- if (typeof o.toString === 'function') {
835
- return hashString(o.toString());
837
+ while (n > 0xffffffff) {
838
+ n /= 0xffffffff;
839
+ hash ^= n;
836
840
  }
837
- throw new Error('Value type ' + type + ' cannot be hashed.');
841
+ return smi(hash);
838
842
  }
839
843
 
840
844
  function cachedHashString(string) {
@@ -866,6 +870,19 @@ function hashString(string) {
866
870
  return smi(hashed);
867
871
  }
868
872
 
873
+ function hashSymbol(sym) {
874
+ var hashed = symbolMap[sym];
875
+ if (hashed !== undefined) {
876
+ return hashed;
877
+ }
878
+
879
+ hashed = nextHash();
880
+
881
+ symbolMap[sym] = hashed;
882
+
883
+ return hashed;
884
+ }
885
+
869
886
  function hashJSObj(obj) {
870
887
  var hashed;
871
888
  if (usingWeakMap) {
@@ -892,10 +909,7 @@ function hashJSObj(obj) {
892
909
  }
893
910
  }
894
911
 
895
- hashed = ++objHashUID;
896
- if (objHashUID & 0x40000000) {
897
- objHashUID = 0;
898
- }
912
+ hashed = nextHash();
899
913
 
900
914
  if (usingWeakMap) {
901
915
  weakMap.set(obj, hashed);
@@ -906,7 +920,7 @@ function hashJSObj(obj) {
906
920
  enumerable: false,
907
921
  configurable: false,
908
922
  writable: false,
909
- value: hashed
923
+ value: hashed,
910
924
  });
911
925
  } else if (
912
926
  obj.propertyIsEnumerable !== undefined &&
@@ -916,7 +930,7 @@ function hashJSObj(obj) {
916
930
  // we'll hijack one of the less-used non-enumerable properties to
917
931
  // save our hash on it. Since this is a function it will not show up in
918
932
  // `JSON.stringify` which is what we want.
919
- obj.propertyIsEnumerable = function() {
933
+ obj.propertyIsEnumerable = function () {
920
934
  return this.constructor.prototype.propertyIsEnumerable.apply(
921
935
  this,
922
936
  arguments
@@ -940,7 +954,7 @@ function hashJSObj(obj) {
940
954
  var isExtensible = Object.isExtensible;
941
955
 
942
956
  // True if Object.defineProperty works as expected. IE8 fails this test.
943
- var canDefineProperty = (function() {
957
+ var canDefineProperty = (function () {
944
958
  try {
945
959
  Object.defineProperty({}, '@', {});
946
960
  return true;
@@ -962,6 +976,20 @@ function getIENodeHash(node) {
962
976
  }
963
977
  }
964
978
 
979
+ function valueOf(obj) {
980
+ return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function'
981
+ ? obj.valueOf(obj)
982
+ : obj;
983
+ }
984
+
985
+ function nextHash() {
986
+ var nextHash = ++_objHashUID;
987
+ if (_objHashUID & 0x40000000) {
988
+ _objHashUID = 0;
989
+ }
990
+ return nextHash;
991
+ }
992
+
965
993
  // If possible, use a WeakMap.
966
994
  var usingWeakMap = typeof WeakMap === 'function';
967
995
  var weakMap;
@@ -969,7 +997,9 @@ if (usingWeakMap) {
969
997
  weakMap = new WeakMap();
970
998
  }
971
999
 
972
- var objHashUID = 0;
1000
+ var symbolMap = Object.create(null);
1001
+
1002
+ var _objHashUID = 0;
973
1003
 
974
1004
  var UID_HASH_KEY = '__immutablehash__';
975
1005
  if (typeof Symbol === 'function') {
@@ -981,15 +1011,15 @@ var STRING_HASH_CACHE_MAX_SIZE = 255;
981
1011
  var STRING_HASH_CACHE_SIZE = 0;
982
1012
  var stringHashCache = {};
983
1013
 
984
- var ToKeyedSequence = (function (KeyedSeq$$1) {
1014
+ var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) {
985
1015
  function ToKeyedSequence(indexed, useKeys) {
986
1016
  this._iter = indexed;
987
1017
  this._useKeys = useKeys;
988
1018
  this.size = indexed.size;
989
1019
  }
990
1020
 
991
- if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
992
- ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
1021
+ if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq;
1022
+ ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
993
1023
  ToKeyedSequence.prototype.constructor = ToKeyedSequence;
994
1024
 
995
1025
  ToKeyedSequence.prototype.get = function get (key, notSetValue) {
@@ -1005,29 +1035,29 @@ var ToKeyedSequence = (function (KeyedSeq$$1) {
1005
1035
  };
1006
1036
 
1007
1037
  ToKeyedSequence.prototype.reverse = function reverse () {
1008
- var this$1 = this;
1038
+ var this$1$1 = this;
1009
1039
 
1010
1040
  var reversedSequence = reverseFactory(this, true);
1011
1041
  if (!this._useKeys) {
1012
- reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
1042
+ reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); };
1013
1043
  }
1014
1044
  return reversedSequence;
1015
1045
  };
1016
1046
 
1017
1047
  ToKeyedSequence.prototype.map = function map (mapper, context) {
1018
- var this$1 = this;
1048
+ var this$1$1 = this;
1019
1049
 
1020
1050
  var mappedSequence = mapFactory(this, mapper, context);
1021
1051
  if (!this._useKeys) {
1022
- mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
1052
+ mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); };
1023
1053
  }
1024
1054
  return mappedSequence;
1025
1055
  };
1026
1056
 
1027
1057
  ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
1028
- var this$1 = this;
1058
+ var this$1$1 = this;
1029
1059
 
1030
- return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
1060
+ return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse);
1031
1061
  };
1032
1062
 
1033
1063
  ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
@@ -1036,16 +1066,16 @@ var ToKeyedSequence = (function (KeyedSeq$$1) {
1036
1066
 
1037
1067
  return ToKeyedSequence;
1038
1068
  }(KeyedSeq));
1039
- ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
1069
+ ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
1040
1070
 
1041
- var ToIndexedSequence = (function (IndexedSeq$$1) {
1071
+ var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {
1042
1072
  function ToIndexedSequence(iter) {
1043
1073
  this._iter = iter;
1044
1074
  this.size = iter.size;
1045
1075
  }
1046
1076
 
1047
- if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
1048
- ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
1077
+ if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq;
1078
+ ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
1049
1079
  ToIndexedSequence.prototype.constructor = ToIndexedSequence;
1050
1080
 
1051
1081
  ToIndexedSequence.prototype.includes = function includes (value) {
@@ -1053,18 +1083,18 @@ var ToIndexedSequence = (function (IndexedSeq$$1) {
1053
1083
  };
1054
1084
 
1055
1085
  ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
1056
- var this$1 = this;
1086
+ var this$1$1 = this;
1057
1087
 
1058
1088
  var i = 0;
1059
1089
  reverse && ensureSize(this);
1060
1090
  return this._iter.__iterate(
1061
- function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
1091
+ function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },
1062
1092
  reverse
1063
1093
  );
1064
1094
  };
1065
1095
 
1066
1096
  ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
1067
- var this$1 = this;
1097
+ var this$1$1 = this;
1068
1098
 
1069
1099
  var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
1070
1100
  var i = 0;
@@ -1075,7 +1105,7 @@ var ToIndexedSequence = (function (IndexedSeq$$1) {
1075
1105
  ? step
1076
1106
  : iteratorValue(
1077
1107
  type,
1078
- reverse ? this$1.size - ++i : i++,
1108
+ reverse ? this$1$1.size - ++i : i++,
1079
1109
  step.value,
1080
1110
  step
1081
1111
  );
@@ -1085,14 +1115,14 @@ var ToIndexedSequence = (function (IndexedSeq$$1) {
1085
1115
  return ToIndexedSequence;
1086
1116
  }(IndexedSeq));
1087
1117
 
1088
- var ToSetSequence = (function (SetSeq$$1) {
1118
+ var ToSetSequence = /*@__PURE__*/(function (SetSeq) {
1089
1119
  function ToSetSequence(iter) {
1090
1120
  this._iter = iter;
1091
1121
  this.size = iter.size;
1092
1122
  }
1093
1123
 
1094
- if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
1095
- ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
1124
+ if ( SetSeq ) ToSetSequence.__proto__ = SetSeq;
1125
+ ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype );
1096
1126
  ToSetSequence.prototype.constructor = ToSetSequence;
1097
1127
 
1098
1128
  ToSetSequence.prototype.has = function has (key) {
@@ -1100,9 +1130,9 @@ var ToSetSequence = (function (SetSeq$$1) {
1100
1130
  };
1101
1131
 
1102
1132
  ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
1103
- var this$1 = this;
1133
+ var this$1$1 = this;
1104
1134
 
1105
- return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
1135
+ return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse);
1106
1136
  };
1107
1137
 
1108
1138
  ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
@@ -1118,14 +1148,14 @@ var ToSetSequence = (function (SetSeq$$1) {
1118
1148
  return ToSetSequence;
1119
1149
  }(SetSeq));
1120
1150
 
1121
- var FromEntriesSequence = (function (KeyedSeq$$1) {
1151
+ var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) {
1122
1152
  function FromEntriesSequence(entries) {
1123
1153
  this._iter = entries;
1124
1154
  this.size = entries.size;
1125
1155
  }
1126
1156
 
1127
- if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
1128
- FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
1157
+ if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq;
1158
+ FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
1129
1159
  FromEntriesSequence.prototype.constructor = FromEntriesSequence;
1130
1160
 
1131
1161
  FromEntriesSequence.prototype.entrySeq = function entrySeq () {
@@ -1133,7 +1163,7 @@ var FromEntriesSequence = (function (KeyedSeq$$1) {
1133
1163
  };
1134
1164
 
1135
1165
  FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
1136
- var this$1 = this;
1166
+ var this$1$1 = this;
1137
1167
 
1138
1168
  return this._iter.__iterate(function (entry) {
1139
1169
  // Check if entry exists first so array access doesn't throw for holes
@@ -1144,7 +1174,7 @@ var FromEntriesSequence = (function (KeyedSeq$$1) {
1144
1174
  return fn(
1145
1175
  indexedCollection ? entry.get(1) : entry[1],
1146
1176
  indexedCollection ? entry.get(0) : entry[0],
1147
- this$1
1177
+ this$1$1
1148
1178
  );
1149
1179
  }
1150
1180
  }, reverse);
@@ -1178,14 +1208,18 @@ var FromEntriesSequence = (function (KeyedSeq$$1) {
1178
1208
  return FromEntriesSequence;
1179
1209
  }(KeyedSeq));
1180
1210
 
1181
- ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
1211
+ ToIndexedSequence.prototype.cacheResult =
1212
+ ToKeyedSequence.prototype.cacheResult =
1213
+ ToSetSequence.prototype.cacheResult =
1214
+ FromEntriesSequence.prototype.cacheResult =
1215
+ cacheResultThrough;
1182
1216
 
1183
1217
  function flipFactory(collection) {
1184
1218
  var flipSequence = makeSequence(collection);
1185
1219
  flipSequence._iter = collection;
1186
1220
  flipSequence.size = collection.size;
1187
1221
  flipSequence.flip = function () { return collection; };
1188
- flipSequence.reverse = function() {
1222
+ flipSequence.reverse = function () {
1189
1223
  var reversedSequence = collection.reverse.apply(this); // super.reverse()
1190
1224
  reversedSequence.flip = function () { return collection.reverse(); };
1191
1225
  return reversedSequence;
@@ -1193,12 +1227,12 @@ function flipFactory(collection) {
1193
1227
  flipSequence.has = function (key) { return collection.includes(key); };
1194
1228
  flipSequence.includes = function (key) { return collection.has(key); };
1195
1229
  flipSequence.cacheResult = cacheResultThrough;
1196
- flipSequence.__iterateUncached = function(fn, reverse) {
1197
- var this$1 = this;
1230
+ flipSequence.__iterateUncached = function (fn, reverse) {
1231
+ var this$1$1 = this;
1198
1232
 
1199
- return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
1233
+ return collection.__iterate(function (v, k) { return fn(k, v, this$1$1) !== false; }, reverse);
1200
1234
  };
1201
- flipSequence.__iteratorUncached = function(type, reverse) {
1235
+ flipSequence.__iteratorUncached = function (type, reverse) {
1202
1236
  if (type === ITERATE_ENTRIES) {
1203
1237
  var iterator = collection.__iterator(type, reverse);
1204
1238
  return new Iterator(function () {
@@ -1229,15 +1263,15 @@ function mapFactory(collection, mapper, context) {
1229
1263
  ? notSetValue
1230
1264
  : mapper.call(context, v, key, collection);
1231
1265
  };
1232
- mappedSequence.__iterateUncached = function(fn, reverse) {
1233
- var this$1 = this;
1266
+ mappedSequence.__iterateUncached = function (fn, reverse) {
1267
+ var this$1$1 = this;
1234
1268
 
1235
1269
  return collection.__iterate(
1236
- function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
1270
+ function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1$1) !== false; },
1237
1271
  reverse
1238
1272
  );
1239
1273
  };
1240
- mappedSequence.__iteratorUncached = function(type, reverse) {
1274
+ mappedSequence.__iteratorUncached = function (type, reverse) {
1241
1275
  var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
1242
1276
  return new Iterator(function () {
1243
1277
  var step = iterator.next();
@@ -1258,14 +1292,14 @@ function mapFactory(collection, mapper, context) {
1258
1292
  }
1259
1293
 
1260
1294
  function reverseFactory(collection, useKeys) {
1261
- var this$1 = this;
1295
+ var this$1$1 = this;
1262
1296
 
1263
1297
  var reversedSequence = makeSequence(collection);
1264
1298
  reversedSequence._iter = collection;
1265
1299
  reversedSequence.size = collection.size;
1266
1300
  reversedSequence.reverse = function () { return collection; };
1267
1301
  if (collection.flip) {
1268
- reversedSequence.flip = function() {
1302
+ reversedSequence.flip = function () {
1269
1303
  var flipSequence = flipFactory(collection);
1270
1304
  flipSequence.reverse = function () { return collection.flip(); };
1271
1305
  return flipSequence;
@@ -1275,13 +1309,13 @@ function reverseFactory(collection, useKeys) {
1275
1309
  reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
1276
1310
  reversedSequence.includes = function (value) { return collection.includes(value); };
1277
1311
  reversedSequence.cacheResult = cacheResultThrough;
1278
- reversedSequence.__iterate = function(fn, reverse) {
1279
- var this$1 = this;
1312
+ reversedSequence.__iterate = function (fn, reverse) {
1313
+ var this$1$1 = this;
1280
1314
 
1281
1315
  var i = 0;
1282
1316
  reverse && ensureSize(collection);
1283
1317
  return collection.__iterate(
1284
- function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
1318
+ function (v, k) { return fn(v, useKeys ? k : reverse ? this$1$1.size - ++i : i++, this$1$1); },
1285
1319
  !reverse
1286
1320
  );
1287
1321
  };
@@ -1297,7 +1331,7 @@ function reverseFactory(collection, useKeys) {
1297
1331
  var entry = step.value;
1298
1332
  return iteratorValue(
1299
1333
  type,
1300
- useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
1334
+ useKeys ? entry[0] : reverse ? this$1$1.size - ++i : i++,
1301
1335
  entry[1],
1302
1336
  step
1303
1337
  );
@@ -1320,19 +1354,19 @@ function filterFactory(collection, predicate, context, useKeys) {
1320
1354
  : notSetValue;
1321
1355
  };
1322
1356
  }
1323
- filterSequence.__iterateUncached = function(fn, reverse) {
1324
- var this$1 = this;
1357
+ filterSequence.__iterateUncached = function (fn, reverse) {
1358
+ var this$1$1 = this;
1325
1359
 
1326
1360
  var iterations = 0;
1327
1361
  collection.__iterate(function (v, k, c) {
1328
1362
  if (predicate.call(context, v, k, c)) {
1329
1363
  iterations++;
1330
- return fn(v, useKeys ? k : iterations - 1, this$1);
1364
+ return fn(v, useKeys ? k : iterations - 1, this$1$1);
1331
1365
  }
1332
1366
  }, reverse);
1333
1367
  return iterations;
1334
1368
  };
1335
- filterSequence.__iteratorUncached = function(type, reverse) {
1369
+ filterSequence.__iteratorUncached = function (type, reverse) {
1336
1370
  var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
1337
1371
  var iterations = 0;
1338
1372
  return new Iterator(function () {
@@ -1371,7 +1405,7 @@ function groupByFactory(collection, grouper, context) {
1371
1405
  );
1372
1406
  });
1373
1407
  var coerce = collectionClass(collection);
1374
- return groups.map(function (arr) { return reify(collection, coerce(arr)); });
1408
+ return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
1375
1409
  }
1376
1410
 
1377
1411
  function sliceFactory(collection, begin, end, useKeys) {
@@ -1409,7 +1443,7 @@ function sliceFactory(collection, begin, end, useKeys) {
1409
1443
  sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
1410
1444
 
1411
1445
  if (!useKeys && isSeq(collection) && sliceSize >= 0) {
1412
- sliceSeq.get = function(index, notSetValue) {
1446
+ sliceSeq.get = function (index, notSetValue) {
1413
1447
  index = wrapIndex(this, index);
1414
1448
  return index >= 0 && index < sliceSize
1415
1449
  ? collection.get(index + resolvedBegin, notSetValue)
@@ -1417,8 +1451,8 @@ function sliceFactory(collection, begin, end, useKeys) {
1417
1451
  };
1418
1452
  }
1419
1453
 
1420
- sliceSeq.__iterateUncached = function(fn, reverse) {
1421
- var this$1 = this;
1454
+ sliceSeq.__iterateUncached = function (fn, reverse) {
1455
+ var this$1$1 = this;
1422
1456
 
1423
1457
  if (sliceSize === 0) {
1424
1458
  return 0;
@@ -1433,7 +1467,7 @@ function sliceFactory(collection, begin, end, useKeys) {
1433
1467
  if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
1434
1468
  iterations++;
1435
1469
  return (
1436
- fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
1470
+ fn(v, useKeys ? k : iterations - 1, this$1$1) !== false &&
1437
1471
  iterations !== sliceSize
1438
1472
  );
1439
1473
  }
@@ -1441,7 +1475,7 @@ function sliceFactory(collection, begin, end, useKeys) {
1441
1475
  return iterations;
1442
1476
  };
1443
1477
 
1444
- sliceSeq.__iteratorUncached = function(type, reverse) {
1478
+ sliceSeq.__iteratorUncached = function (type, reverse) {
1445
1479
  if (sliceSize !== 0 && reverse) {
1446
1480
  return this.cacheResult().__iterator(type, reverse);
1447
1481
  }
@@ -1475,20 +1509,20 @@ function sliceFactory(collection, begin, end, useKeys) {
1475
1509
 
1476
1510
  function takeWhileFactory(collection, predicate, context) {
1477
1511
  var takeSequence = makeSequence(collection);
1478
- takeSequence.__iterateUncached = function(fn, reverse) {
1479
- var this$1 = this;
1512
+ takeSequence.__iterateUncached = function (fn, reverse) {
1513
+ var this$1$1 = this;
1480
1514
 
1481
1515
  if (reverse) {
1482
1516
  return this.cacheResult().__iterate(fn, reverse);
1483
1517
  }
1484
1518
  var iterations = 0;
1485
1519
  collection.__iterate(
1486
- function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
1520
+ function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1$1); }
1487
1521
  );
1488
1522
  return iterations;
1489
1523
  };
1490
- takeSequence.__iteratorUncached = function(type, reverse) {
1491
- var this$1 = this;
1524
+ takeSequence.__iteratorUncached = function (type, reverse) {
1525
+ var this$1$1 = this;
1492
1526
 
1493
1527
  if (reverse) {
1494
1528
  return this.cacheResult().__iterator(type, reverse);
@@ -1506,7 +1540,7 @@ function takeWhileFactory(collection, predicate, context) {
1506
1540
  var entry = step.value;
1507
1541
  var k = entry[0];
1508
1542
  var v = entry[1];
1509
- if (!predicate.call(context, v, k, this$1)) {
1543
+ if (!predicate.call(context, v, k, this$1$1)) {
1510
1544
  iterating = false;
1511
1545
  return iteratorDone();
1512
1546
  }
@@ -1518,8 +1552,8 @@ function takeWhileFactory(collection, predicate, context) {
1518
1552
 
1519
1553
  function skipWhileFactory(collection, predicate, context, useKeys) {
1520
1554
  var skipSequence = makeSequence(collection);
1521
- skipSequence.__iterateUncached = function(fn, reverse) {
1522
- var this$1 = this;
1555
+ skipSequence.__iterateUncached = function (fn, reverse) {
1556
+ var this$1$1 = this;
1523
1557
 
1524
1558
  if (reverse) {
1525
1559
  return this.cacheResult().__iterate(fn, reverse);
@@ -1529,13 +1563,13 @@ function skipWhileFactory(collection, predicate, context, useKeys) {
1529
1563
  collection.__iterate(function (v, k, c) {
1530
1564
  if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
1531
1565
  iterations++;
1532
- return fn(v, useKeys ? k : iterations - 1, this$1);
1566
+ return fn(v, useKeys ? k : iterations - 1, this$1$1);
1533
1567
  }
1534
1568
  });
1535
1569
  return iterations;
1536
1570
  };
1537
- skipSequence.__iteratorUncached = function(type, reverse) {
1538
- var this$1 = this;
1571
+ skipSequence.__iteratorUncached = function (type, reverse) {
1572
+ var this$1$1 = this;
1539
1573
 
1540
1574
  if (reverse) {
1541
1575
  return this.cacheResult().__iterator(type, reverse);
@@ -1561,7 +1595,7 @@ function skipWhileFactory(collection, predicate, context, useKeys) {
1561
1595
  var entry = step.value;
1562
1596
  k = entry[0];
1563
1597
  v = entry[1];
1564
- skipping && (skipping = predicate.call(context, v, k, this$1));
1598
+ skipping && (skipping = predicate.call(context, v, k, this$1$1));
1565
1599
  } while (skipping);
1566
1600
  return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
1567
1601
  });
@@ -1620,7 +1654,7 @@ function concatFactory(collection, values) {
1620
1654
 
1621
1655
  function flattenFactory(collection, depth, useKeys) {
1622
1656
  var flatSequence = makeSequence(collection);
1623
- flatSequence.__iterateUncached = function(fn, reverse) {
1657
+ flatSequence.__iterateUncached = function (fn, reverse) {
1624
1658
  if (reverse) {
1625
1659
  return this.cacheResult().__iterate(fn, reverse);
1626
1660
  }
@@ -1642,7 +1676,7 @@ function flattenFactory(collection, depth, useKeys) {
1642
1676
  flatDeep(collection, 0);
1643
1677
  return iterations;
1644
1678
  };
1645
- flatSequence.__iteratorUncached = function(type, reverse) {
1679
+ flatSequence.__iteratorUncached = function (type, reverse) {
1646
1680
  if (reverse) {
1647
1681
  return this.cacheResult().__iterator(type, reverse);
1648
1682
  }
@@ -1684,18 +1718,18 @@ function flatMapFactory(collection, mapper, context) {
1684
1718
  function interposeFactory(collection, separator) {
1685
1719
  var interposedSequence = makeSequence(collection);
1686
1720
  interposedSequence.size = collection.size && collection.size * 2 - 1;
1687
- interposedSequence.__iterateUncached = function(fn, reverse) {
1688
- var this$1 = this;
1721
+ interposedSequence.__iterateUncached = function (fn, reverse) {
1722
+ var this$1$1 = this;
1689
1723
 
1690
1724
  var iterations = 0;
1691
1725
  collection.__iterate(
1692
- function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
1693
- fn(v, iterations++, this$1) !== false; },
1726
+ function (v) { return (!iterations || fn(separator, iterations++, this$1$1) !== false) &&
1727
+ fn(v, iterations++, this$1$1) !== false; },
1694
1728
  reverse
1695
1729
  );
1696
1730
  return iterations;
1697
1731
  };
1698
- interposedSequence.__iteratorUncached = function(type, reverse) {
1732
+ interposedSequence.__iteratorUncached = function (type, reverse) {
1699
1733
  var iterator = collection.__iterator(ITERATE_VALUES, reverse);
1700
1734
  var iterations = 0;
1701
1735
  var step;
@@ -1725,18 +1759,22 @@ function sortFactory(collection, comparator, mapper) {
1725
1759
  .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
1726
1760
  .valueSeq()
1727
1761
  .toArray();
1728
- entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
1729
- isKeyedCollection
1730
- ? function (v, i) {
1731
- entries[i].length = 2;
1732
- }
1733
- : function (v, i) {
1734
- entries[i] = v[1];
1735
- }
1736
- );
1762
+ entries
1763
+ .sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; })
1764
+ .forEach(
1765
+ isKeyedCollection
1766
+ ? function (v, i) {
1767
+ entries[i].length = 2;
1768
+ }
1769
+ : function (v, i) {
1770
+ entries[i] = v[1];
1771
+ }
1772
+ );
1737
1773
  return isKeyedCollection
1738
1774
  ? KeyedSeq(entries)
1739
- : isIndexed(collection) ? IndexedSeq(entries) : SetSeq(entries);
1775
+ : isIndexed(collection)
1776
+ ? IndexedSeq(entries)
1777
+ : SetSeq(entries);
1740
1778
  }
1741
1779
 
1742
1780
  function maxFactory(collection, comparator, mapper) {
@@ -1769,9 +1807,7 @@ function zipWithFactory(keyIter, zipper, iters, zipAll) {
1769
1807
  zipSequence.size = zipAll ? sizes.max() : sizes.min();
1770
1808
  // Note: this a generic base implementation of __iterate in terms of
1771
1809
  // __iterator which may be more generically useful in the future.
1772
- zipSequence.__iterate = function(fn, reverse) {
1773
- var this$1 = this;
1774
-
1810
+ zipSequence.__iterate = function (fn, reverse) {
1775
1811
  /* generic:
1776
1812
  var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
1777
1813
  var step;
@@ -1789,13 +1825,13 @@ function zipWithFactory(keyIter, zipper, iters, zipAll) {
1789
1825
  var step;
1790
1826
  var iterations = 0;
1791
1827
  while (!(step = iterator.next()).done) {
1792
- if (fn(step.value, iterations++, this$1) === false) {
1828
+ if (fn(step.value, iterations++, this) === false) {
1793
1829
  break;
1794
1830
  }
1795
1831
  }
1796
1832
  return iterations;
1797
1833
  };
1798
- zipSequence.__iteratorUncached = function(type, reverse) {
1834
+ zipSequence.__iteratorUncached = function (type, reverse) {
1799
1835
  var iterators = iters.map(
1800
1836
  function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
1801
1837
  );
@@ -1813,7 +1849,10 @@ function zipWithFactory(keyIter, zipper, iters, zipAll) {
1813
1849
  return iteratorValue(
1814
1850
  type,
1815
1851
  iterations++,
1816
- zipper.apply(null, steps.map(function (s) { return s.value; }))
1852
+ zipper.apply(
1853
+ null,
1854
+ steps.map(function (s) { return s.value; })
1855
+ )
1817
1856
  );
1818
1857
  });
1819
1858
  };
@@ -1835,14 +1874,18 @@ function validateEntry(entry) {
1835
1874
  function collectionClass(collection) {
1836
1875
  return isKeyed(collection)
1837
1876
  ? KeyedCollection
1838
- : isIndexed(collection) ? IndexedCollection : SetCollection;
1877
+ : isIndexed(collection)
1878
+ ? IndexedCollection
1879
+ : SetCollection;
1839
1880
  }
1840
1881
 
1841
1882
  function makeSequence(collection) {
1842
1883
  return Object.create(
1843
1884
  (isKeyed(collection)
1844
1885
  ? KeyedSeq
1845
- : isIndexed(collection) ? IndexedSeq : SetSeq
1886
+ : isIndexed(collection)
1887
+ ? IndexedSeq
1888
+ : SetSeq
1846
1889
  ).prototype
1847
1890
  );
1848
1891
  }
@@ -1872,6 +1915,27 @@ function defaultComparator(a, b) {
1872
1915
  return a > b ? 1 : a < b ? -1 : 0;
1873
1916
  }
1874
1917
 
1918
+ function arrCopy(arr, offset) {
1919
+ offset = offset || 0;
1920
+ var len = Math.max(0, arr.length - offset);
1921
+ var newArr = new Array(len);
1922
+ for (var ii = 0; ii < len; ii++) {
1923
+ newArr[ii] = arr[ii + offset];
1924
+ }
1925
+ return newArr;
1926
+ }
1927
+
1928
+ function invariant(condition, error) {
1929
+ if (!condition) { throw new Error(error); }
1930
+ }
1931
+
1932
+ function assertNotInfinite(size) {
1933
+ invariant(
1934
+ size !== Infinity,
1935
+ 'Cannot perform this action with an infinite size.'
1936
+ );
1937
+ }
1938
+
1875
1939
  function coerceKeyPath(keyPath) {
1876
1940
  if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
1877
1941
  return keyPath;
@@ -1884,20 +1948,44 @@ function coerceKeyPath(keyPath) {
1884
1948
  );
1885
1949
  }
1886
1950
 
1887
- function invariant(condition, error) {
1888
- if (!condition) { throw new Error(error); }
1889
- }
1951
+ var toString = Object.prototype.toString;
1890
1952
 
1891
- function assertNotInfinite(size) {
1892
- invariant(
1893
- size !== Infinity,
1894
- 'Cannot perform this action with an infinite size.'
1895
- );
1953
+ function isPlainObject(value) {
1954
+ // The base prototype's toString deals with Argument objects and native namespaces like Math
1955
+ if (
1956
+ !value ||
1957
+ typeof value !== 'object' ||
1958
+ toString.call(value) !== '[object Object]'
1959
+ ) {
1960
+ return false;
1961
+ }
1962
+
1963
+ var proto = Object.getPrototypeOf(value);
1964
+ if (proto === null) {
1965
+ return true;
1966
+ }
1967
+
1968
+ // Iteratively going up the prototype chain is needed for cross-realm environments (differing contexts, iframes, etc)
1969
+ var parentProto = proto;
1970
+ var nextProto = Object.getPrototypeOf(proto);
1971
+ while (nextProto !== null) {
1972
+ parentProto = nextProto;
1973
+ nextProto = Object.getPrototypeOf(parentProto);
1974
+ }
1975
+ return parentProto === proto;
1896
1976
  }
1897
1977
 
1898
1978
  /**
1899
- * Converts a value to a string, adding quotes if a string was provided.
1979
+ * Returns true if the value is a potentially-persistent data structure, either
1980
+ * provided by Immutable.js or a plain Array or Object.
1900
1981
  */
1982
+ function isDataStructure(value) {
1983
+ return (
1984
+ typeof value === 'object' &&
1985
+ (isImmutable(value) || Array.isArray(value) || isPlainObject(value))
1986
+ );
1987
+ }
1988
+
1901
1989
  function quoteString(value) {
1902
1990
  try {
1903
1991
  return typeof value === 'string' ? JSON.stringify(value) : String(value);
@@ -1906,21 +1994,387 @@ function quoteString(value) {
1906
1994
  }
1907
1995
  }
1908
1996
 
1909
- var Map = (function (KeyedCollection$$1) {
1997
+ function has(collection, key) {
1998
+ return isImmutable(collection)
1999
+ ? collection.has(key)
2000
+ : isDataStructure(collection) && hasOwnProperty.call(collection, key);
2001
+ }
2002
+
2003
+ function get(collection, key, notSetValue) {
2004
+ return isImmutable(collection)
2005
+ ? collection.get(key, notSetValue)
2006
+ : !has(collection, key)
2007
+ ? notSetValue
2008
+ : typeof collection.get === 'function'
2009
+ ? collection.get(key)
2010
+ : collection[key];
2011
+ }
2012
+
2013
+ function shallowCopy(from) {
2014
+ if (Array.isArray(from)) {
2015
+ return arrCopy(from);
2016
+ }
2017
+ var to = {};
2018
+ for (var key in from) {
2019
+ if (hasOwnProperty.call(from, key)) {
2020
+ to[key] = from[key];
2021
+ }
2022
+ }
2023
+ return to;
2024
+ }
2025
+
2026
+ function remove(collection, key) {
2027
+ if (!isDataStructure(collection)) {
2028
+ throw new TypeError(
2029
+ 'Cannot update non-data-structure value: ' + collection
2030
+ );
2031
+ }
2032
+ if (isImmutable(collection)) {
2033
+ if (!collection.remove) {
2034
+ throw new TypeError(
2035
+ 'Cannot update immutable value without .remove() method: ' + collection
2036
+ );
2037
+ }
2038
+ return collection.remove(key);
2039
+ }
2040
+ if (!hasOwnProperty.call(collection, key)) {
2041
+ return collection;
2042
+ }
2043
+ var collectionCopy = shallowCopy(collection);
2044
+ if (Array.isArray(collectionCopy)) {
2045
+ collectionCopy.splice(key, 1);
2046
+ } else {
2047
+ delete collectionCopy[key];
2048
+ }
2049
+ return collectionCopy;
2050
+ }
2051
+
2052
+ function set(collection, key, value) {
2053
+ if (!isDataStructure(collection)) {
2054
+ throw new TypeError(
2055
+ 'Cannot update non-data-structure value: ' + collection
2056
+ );
2057
+ }
2058
+ if (isImmutable(collection)) {
2059
+ if (!collection.set) {
2060
+ throw new TypeError(
2061
+ 'Cannot update immutable value without .set() method: ' + collection
2062
+ );
2063
+ }
2064
+ return collection.set(key, value);
2065
+ }
2066
+ if (hasOwnProperty.call(collection, key) && value === collection[key]) {
2067
+ return collection;
2068
+ }
2069
+ var collectionCopy = shallowCopy(collection);
2070
+ collectionCopy[key] = value;
2071
+ return collectionCopy;
2072
+ }
2073
+
2074
+ function updateIn$1(collection, keyPath, notSetValue, updater) {
2075
+ if (!updater) {
2076
+ updater = notSetValue;
2077
+ notSetValue = undefined;
2078
+ }
2079
+ var updatedValue = updateInDeeply(
2080
+ isImmutable(collection),
2081
+ collection,
2082
+ coerceKeyPath(keyPath),
2083
+ 0,
2084
+ notSetValue,
2085
+ updater
2086
+ );
2087
+ return updatedValue === NOT_SET ? notSetValue : updatedValue;
2088
+ }
2089
+
2090
+ function updateInDeeply(
2091
+ inImmutable,
2092
+ existing,
2093
+ keyPath,
2094
+ i,
2095
+ notSetValue,
2096
+ updater
2097
+ ) {
2098
+ var wasNotSet = existing === NOT_SET;
2099
+ if (i === keyPath.length) {
2100
+ var existingValue = wasNotSet ? notSetValue : existing;
2101
+ var newValue = updater(existingValue);
2102
+ return newValue === existingValue ? existing : newValue;
2103
+ }
2104
+ if (!wasNotSet && !isDataStructure(existing)) {
2105
+ throw new TypeError(
2106
+ 'Cannot update within non-data-structure value in path [' +
2107
+ keyPath.slice(0, i).map(quoteString) +
2108
+ ']: ' +
2109
+ existing
2110
+ );
2111
+ }
2112
+ var key = keyPath[i];
2113
+ var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
2114
+ var nextUpdated = updateInDeeply(
2115
+ nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
2116
+ nextExisting,
2117
+ keyPath,
2118
+ i + 1,
2119
+ notSetValue,
2120
+ updater
2121
+ );
2122
+ return nextUpdated === nextExisting
2123
+ ? existing
2124
+ : nextUpdated === NOT_SET
2125
+ ? remove(existing, key)
2126
+ : set(
2127
+ wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
2128
+ key,
2129
+ nextUpdated
2130
+ );
2131
+ }
2132
+
2133
+ function setIn$1(collection, keyPath, value) {
2134
+ return updateIn$1(collection, keyPath, NOT_SET, function () { return value; });
2135
+ }
2136
+
2137
+ function setIn(keyPath, v) {
2138
+ return setIn$1(this, keyPath, v);
2139
+ }
2140
+
2141
+ function removeIn(collection, keyPath) {
2142
+ return updateIn$1(collection, keyPath, function () { return NOT_SET; });
2143
+ }
2144
+
2145
+ function deleteIn(keyPath) {
2146
+ return removeIn(this, keyPath);
2147
+ }
2148
+
2149
+ function update$1(collection, key, notSetValue, updater) {
2150
+ return updateIn$1(collection, [key], notSetValue, updater);
2151
+ }
2152
+
2153
+ function update(key, notSetValue, updater) {
2154
+ return arguments.length === 1
2155
+ ? key(this)
2156
+ : update$1(this, key, notSetValue, updater);
2157
+ }
2158
+
2159
+ function updateIn(keyPath, notSetValue, updater) {
2160
+ return updateIn$1(this, keyPath, notSetValue, updater);
2161
+ }
2162
+
2163
+ function merge$1() {
2164
+ var iters = [], len = arguments.length;
2165
+ while ( len-- ) iters[ len ] = arguments[ len ];
2166
+
2167
+ return mergeIntoKeyedWith(this, iters);
2168
+ }
2169
+
2170
+ function mergeWith$1(merger) {
2171
+ var iters = [], len = arguments.length - 1;
2172
+ while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2173
+
2174
+ if (typeof merger !== 'function') {
2175
+ throw new TypeError('Invalid merger function: ' + merger);
2176
+ }
2177
+ return mergeIntoKeyedWith(this, iters, merger);
2178
+ }
2179
+
2180
+ function mergeIntoKeyedWith(collection, collections, merger) {
2181
+ var iters = [];
2182
+ for (var ii = 0; ii < collections.length; ii++) {
2183
+ var collection$1 = KeyedCollection(collections[ii]);
2184
+ if (collection$1.size !== 0) {
2185
+ iters.push(collection$1);
2186
+ }
2187
+ }
2188
+ if (iters.length === 0) {
2189
+ return collection;
2190
+ }
2191
+ if (
2192
+ collection.toSeq().size === 0 &&
2193
+ !collection.__ownerID &&
2194
+ iters.length === 1
2195
+ ) {
2196
+ return collection.constructor(iters[0]);
2197
+ }
2198
+ return collection.withMutations(function (collection) {
2199
+ var mergeIntoCollection = merger
2200
+ ? function (value, key) {
2201
+ update$1(collection, key, NOT_SET, function (oldVal) { return oldVal === NOT_SET ? value : merger(oldVal, value, key); }
2202
+ );
2203
+ }
2204
+ : function (value, key) {
2205
+ collection.set(key, value);
2206
+ };
2207
+ for (var ii = 0; ii < iters.length; ii++) {
2208
+ iters[ii].forEach(mergeIntoCollection);
2209
+ }
2210
+ });
2211
+ }
2212
+
2213
+ function merge(collection) {
2214
+ var sources = [], len = arguments.length - 1;
2215
+ while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
2216
+
2217
+ return mergeWithSources(collection, sources);
2218
+ }
2219
+
2220
+ function mergeWith(merger, collection) {
2221
+ var sources = [], len = arguments.length - 2;
2222
+ while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
2223
+
2224
+ return mergeWithSources(collection, sources, merger);
2225
+ }
2226
+
2227
+ function mergeDeep$1(collection) {
2228
+ var sources = [], len = arguments.length - 1;
2229
+ while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
2230
+
2231
+ return mergeDeepWithSources(collection, sources);
2232
+ }
2233
+
2234
+ function mergeDeepWith$1(merger, collection) {
2235
+ var sources = [], len = arguments.length - 2;
2236
+ while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
2237
+
2238
+ return mergeDeepWithSources(collection, sources, merger);
2239
+ }
2240
+
2241
+ function mergeDeepWithSources(collection, sources, merger) {
2242
+ return mergeWithSources(collection, sources, deepMergerWith(merger));
2243
+ }
2244
+
2245
+ function mergeWithSources(collection, sources, merger) {
2246
+ if (!isDataStructure(collection)) {
2247
+ throw new TypeError(
2248
+ 'Cannot merge into non-data-structure value: ' + collection
2249
+ );
2250
+ }
2251
+ if (isImmutable(collection)) {
2252
+ return typeof merger === 'function' && collection.mergeWith
2253
+ ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
2254
+ : collection.merge
2255
+ ? collection.merge.apply(collection, sources)
2256
+ : collection.concat.apply(collection, sources);
2257
+ }
2258
+ var isArray = Array.isArray(collection);
2259
+ var merged = collection;
2260
+ var Collection = isArray ? IndexedCollection : KeyedCollection;
2261
+ var mergeItem = isArray
2262
+ ? function (value) {
2263
+ // Copy on write
2264
+ if (merged === collection) {
2265
+ merged = shallowCopy(merged);
2266
+ }
2267
+ merged.push(value);
2268
+ }
2269
+ : function (value, key) {
2270
+ var hasVal = hasOwnProperty.call(merged, key);
2271
+ var nextVal =
2272
+ hasVal && merger ? merger(merged[key], value, key) : value;
2273
+ if (!hasVal || nextVal !== merged[key]) {
2274
+ // Copy on write
2275
+ if (merged === collection) {
2276
+ merged = shallowCopy(merged);
2277
+ }
2278
+ merged[key] = nextVal;
2279
+ }
2280
+ };
2281
+ for (var i = 0; i < sources.length; i++) {
2282
+ Collection(sources[i]).forEach(mergeItem);
2283
+ }
2284
+ return merged;
2285
+ }
2286
+
2287
+ function deepMergerWith(merger) {
2288
+ function deepMerger(oldValue, newValue, key) {
2289
+ return isDataStructure(oldValue) &&
2290
+ isDataStructure(newValue) &&
2291
+ areMergeable(oldValue, newValue)
2292
+ ? mergeWithSources(oldValue, [newValue], deepMerger)
2293
+ : merger
2294
+ ? merger(oldValue, newValue, key)
2295
+ : newValue;
2296
+ }
2297
+ return deepMerger;
2298
+ }
2299
+
2300
+ /**
2301
+ * It's unclear what the desired behavior is for merging two collections that
2302
+ * fall into separate categories between keyed, indexed, or set-like, so we only
2303
+ * consider them mergeable if they fall into the same category.
2304
+ */
2305
+ function areMergeable(oldDataStructure, newDataStructure) {
2306
+ var oldSeq = Seq(oldDataStructure);
2307
+ var newSeq = Seq(newDataStructure);
2308
+ // This logic assumes that a sequence can only fall into one of the three
2309
+ // categories mentioned above (since there's no `isSetLike()` method).
2310
+ return (
2311
+ isIndexed(oldSeq) === isIndexed(newSeq) &&
2312
+ isKeyed(oldSeq) === isKeyed(newSeq)
2313
+ );
2314
+ }
2315
+
2316
+ function mergeDeep() {
2317
+ var iters = [], len = arguments.length;
2318
+ while ( len-- ) iters[ len ] = arguments[ len ];
2319
+
2320
+ return mergeDeepWithSources(this, iters);
2321
+ }
2322
+
2323
+ function mergeDeepWith(merger) {
2324
+ var iters = [], len = arguments.length - 1;
2325
+ while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2326
+
2327
+ return mergeDeepWithSources(this, iters, merger);
2328
+ }
2329
+
2330
+ function mergeIn(keyPath) {
2331
+ var iters = [], len = arguments.length - 1;
2332
+ while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2333
+
2334
+ return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
2335
+ }
2336
+
2337
+ function mergeDeepIn(keyPath) {
2338
+ var iters = [], len = arguments.length - 1;
2339
+ while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2340
+
2341
+ return updateIn$1(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
2342
+ );
2343
+ }
2344
+
2345
+ function withMutations(fn) {
2346
+ var mutable = this.asMutable();
2347
+ fn(mutable);
2348
+ return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
2349
+ }
2350
+
2351
+ function asMutable() {
2352
+ return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
2353
+ }
2354
+
2355
+ function asImmutable() {
2356
+ return this.__ensureOwner();
2357
+ }
2358
+
2359
+ function wasAltered() {
2360
+ return this.__altered;
2361
+ }
2362
+
2363
+ var Map = /*@__PURE__*/(function (KeyedCollection) {
1910
2364
  function Map(value) {
1911
2365
  return value === null || value === undefined
1912
2366
  ? emptyMap()
1913
2367
  : isMap(value) && !isOrdered(value)
1914
- ? value
1915
- : emptyMap().withMutations(function (map) {
1916
- var iter = KeyedCollection$$1(value);
1917
- assertNotInfinite(iter.size);
1918
- iter.forEach(function (v, k) { return map.set(k, v); });
1919
- });
2368
+ ? value
2369
+ : emptyMap().withMutations(function (map) {
2370
+ var iter = KeyedCollection(value);
2371
+ assertNotInfinite(iter.size);
2372
+ iter.forEach(function (v, k) { return map.set(k, v); });
2373
+ });
1920
2374
  }
1921
2375
 
1922
- if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
1923
- Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
2376
+ if ( KeyedCollection ) Map.__proto__ = KeyedCollection;
2377
+ Map.prototype = Object.create( KeyedCollection && KeyedCollection.prototype );
1924
2378
  Map.prototype.constructor = Map;
1925
2379
 
1926
2380
  Map.of = function of () {
@@ -1955,22 +2409,10 @@ var Map = (function (KeyedCollection$$1) {
1955
2409
  return updateMap(this, k, v);
1956
2410
  };
1957
2411
 
1958
- Map.prototype.setIn = function setIn (keyPath, v) {
1959
- return this.updateIn(keyPath, NOT_SET, function () { return v; });
1960
- };
1961
-
1962
2412
  Map.prototype.remove = function remove (k) {
1963
2413
  return updateMap(this, k, NOT_SET);
1964
2414
  };
1965
2415
 
1966
- Map.prototype.deleteIn = function deleteIn (keyPath) {
1967
- keyPath = [].concat( coerceKeyPath(keyPath) );
1968
- if (keyPath.length) {
1969
- var lastKey = keyPath.pop();
1970
- return this.updateIn(keyPath, function (c) { return c && c.remove(lastKey); });
1971
- }
1972
- };
1973
-
1974
2416
  Map.prototype.deleteAll = function deleteAll (keys) {
1975
2417
  var collection = Collection(keys);
1976
2418
 
@@ -1983,27 +2425,6 @@ var Map = (function (KeyedCollection$$1) {
1983
2425
  });
1984
2426
  };
1985
2427
 
1986
- Map.prototype.update = function update (k, notSetValue, updater) {
1987
- return arguments.length === 1
1988
- ? k(this)
1989
- : this.updateIn([k], notSetValue, updater);
1990
- };
1991
-
1992
- Map.prototype.updateIn = function updateIn (keyPath, notSetValue, updater) {
1993
- if (!updater) {
1994
- updater = notSetValue;
1995
- notSetValue = undefined;
1996
- }
1997
- var updatedValue = updateInDeepMap(
1998
- this,
1999
- coerceKeyPath(keyPath),
2000
- 0,
2001
- notSetValue,
2002
- updater
2003
- );
2004
- return updatedValue === NOT_SET ? notSetValue : updatedValue;
2005
- };
2006
-
2007
2428
  Map.prototype.clear = function clear () {
2008
2429
  if (this.size === 0) {
2009
2430
  return this;
@@ -2020,54 +2441,6 @@ var Map = (function (KeyedCollection$$1) {
2020
2441
 
2021
2442
  // @pragma Composition
2022
2443
 
2023
- Map.prototype.merge = function merge (/*...iters*/) {
2024
- return mergeIntoMapWith(this, undefined, arguments);
2025
- };
2026
-
2027
- Map.prototype.mergeWith = function mergeWith (merger) {
2028
- var iters = [], len = arguments.length - 1;
2029
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2030
-
2031
- return mergeIntoMapWith(this, merger, iters);
2032
- };
2033
-
2034
- Map.prototype.mergeIn = function mergeIn (keyPath) {
2035
- var iters = [], len = arguments.length - 1;
2036
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2037
-
2038
- return this.updateIn(
2039
- keyPath,
2040
- emptyMap(),
2041
- function (m) { return typeof m.merge === 'function'
2042
- ? m.merge.apply(m, iters)
2043
- : iters[iters.length - 1]; }
2044
- );
2045
- };
2046
-
2047
- Map.prototype.mergeDeep = function mergeDeep (/*...iters*/) {
2048
- return mergeIntoMapWith(this, deepMergerWith(alwaysNewVal), arguments);
2049
- };
2050
-
2051
- Map.prototype.mergeDeepWith = function mergeDeepWith (merger) {
2052
- var iters = [], len = arguments.length - 1;
2053
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2054
-
2055
- return mergeIntoMapWith(this, deepMergerWith(merger), iters);
2056
- };
2057
-
2058
- Map.prototype.mergeDeepIn = function mergeDeepIn (keyPath) {
2059
- var iters = [], len = arguments.length - 1;
2060
- while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
2061
-
2062
- return this.updateIn(
2063
- keyPath,
2064
- emptyMap(),
2065
- function (m) { return typeof m.mergeDeep === 'function'
2066
- ? m.mergeDeep.apply(m, iters)
2067
- : iters[iters.length - 1]; }
2068
- );
2069
- };
2070
-
2071
2444
  Map.prototype.sort = function sort (comparator) {
2072
2445
  // Late binding
2073
2446
  return OrderedMap(sortFactory(this, comparator));
@@ -2078,38 +2451,30 @@ var Map = (function (KeyedCollection$$1) {
2078
2451
  return OrderedMap(sortFactory(this, comparator, mapper));
2079
2452
  };
2080
2453
 
2081
- // @pragma Mutability
2082
-
2083
- Map.prototype.withMutations = function withMutations (fn) {
2084
- var mutable = this.asMutable();
2085
- fn(mutable);
2086
- return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
2087
- };
2454
+ Map.prototype.map = function map (mapper, context) {
2455
+ var this$1$1 = this;
2088
2456
 
2089
- Map.prototype.asMutable = function asMutable () {
2090
- return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
2091
- };
2092
-
2093
- Map.prototype.asImmutable = function asImmutable () {
2094
- return this.__ensureOwner();
2457
+ return this.withMutations(function (map) {
2458
+ map.forEach(function (value, key) {
2459
+ map.set(key, mapper.call(context, value, key, this$1$1));
2460
+ });
2461
+ });
2095
2462
  };
2096
2463
 
2097
- Map.prototype.wasAltered = function wasAltered () {
2098
- return this.__altered;
2099
- };
2464
+ // @pragma Mutability
2100
2465
 
2101
2466
  Map.prototype.__iterator = function __iterator (type, reverse) {
2102
2467
  return new MapIterator(this, type, reverse);
2103
2468
  };
2104
2469
 
2105
2470
  Map.prototype.__iterate = function __iterate (fn, reverse) {
2106
- var this$1 = this;
2471
+ var this$1$1 = this;
2107
2472
 
2108
2473
  var iterations = 0;
2109
2474
  this._root &&
2110
2475
  this._root.iterate(function (entry) {
2111
2476
  iterations++;
2112
- return fn(entry[1], entry[0], this$1);
2477
+ return fn(entry[1], entry[0], this$1$1);
2113
2478
  }, reverse);
2114
2479
  return iterations;
2115
2480
  };
@@ -2132,24 +2497,30 @@ var Map = (function (KeyedCollection$$1) {
2132
2497
  return Map;
2133
2498
  }(KeyedCollection));
2134
2499
 
2135
- function isMap(maybeMap) {
2136
- return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
2137
- }
2138
-
2139
2500
  Map.isMap = isMap;
2140
2501
 
2141
- var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
2142
-
2143
2502
  var MapPrototype = Map.prototype;
2144
- MapPrototype[IS_MAP_SENTINEL] = true;
2503
+ MapPrototype[IS_MAP_SYMBOL] = true;
2145
2504
  MapPrototype[DELETE] = MapPrototype.remove;
2146
- MapPrototype.removeIn = MapPrototype.deleteIn;
2147
2505
  MapPrototype.removeAll = MapPrototype.deleteAll;
2148
- MapPrototype['@@transducer/init'] = MapPrototype.asMutable;
2149
- MapPrototype['@@transducer/step'] = function(result, arr) {
2506
+ MapPrototype.setIn = setIn;
2507
+ MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
2508
+ MapPrototype.update = update;
2509
+ MapPrototype.updateIn = updateIn;
2510
+ MapPrototype.merge = MapPrototype.concat = merge$1;
2511
+ MapPrototype.mergeWith = mergeWith$1;
2512
+ MapPrototype.mergeDeep = mergeDeep;
2513
+ MapPrototype.mergeDeepWith = mergeDeepWith;
2514
+ MapPrototype.mergeIn = mergeIn;
2515
+ MapPrototype.mergeDeepIn = mergeDeepIn;
2516
+ MapPrototype.withMutations = withMutations;
2517
+ MapPrototype.wasAltered = wasAltered;
2518
+ MapPrototype.asImmutable = asImmutable;
2519
+ MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
2520
+ MapPrototype['@@transducer/step'] = function (result, arr) {
2150
2521
  return result.set(arr[0], arr[1]);
2151
2522
  };
2152
- MapPrototype['@@transducer/result'] = function(obj) {
2523
+ MapPrototype['@@transducer/result'] = function (obj) {
2153
2524
  return obj.asImmutable();
2154
2525
  };
2155
2526
 
@@ -2295,7 +2666,7 @@ BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, k
2295
2666
  var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
2296
2667
  var newNodes = exists
2297
2668
  ? newNode
2298
- ? setIn(nodes, idx, newNode, isEditable)
2669
+ ? setAt(nodes, idx, newNode, isEditable)
2299
2670
  : spliceOut(nodes, idx, isEditable)
2300
2671
  : spliceIn(nodes, idx, newNode, isEditable);
2301
2672
 
@@ -2363,7 +2734,7 @@ HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, ke
2363
2734
  }
2364
2735
 
2365
2736
  var isEditable = ownerID && ownerID === this.ownerID;
2366
- var newNodes = setIn(nodes, idx, newNode, isEditable);
2737
+ var newNodes = setAt(nodes, idx, newNode, isEditable);
2367
2738
 
2368
2739
  if (isEditable) {
2369
2740
  this.count = newCount;
@@ -2488,50 +2859,44 @@ ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, valu
2488
2859
 
2489
2860
  // #pragma Iterators
2490
2861
 
2491
- ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
2492
- fn,
2493
- reverse
2494
- ) {
2495
- var entries = this.entries;
2496
- for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
2497
- if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
2498
- return false;
2862
+ ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate =
2863
+ function (fn, reverse) {
2864
+ var entries = this.entries;
2865
+ for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
2866
+ if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
2867
+ return false;
2868
+ }
2499
2869
  }
2500
- }
2501
- };
2870
+ };
2502
2871
 
2503
- BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
2504
- fn,
2505
- reverse
2506
- ) {
2507
- var nodes = this.nodes;
2508
- for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
2509
- var node = nodes[reverse ? maxIndex - ii : ii];
2510
- if (node && node.iterate(fn, reverse) === false) {
2511
- return false;
2872
+ BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate =
2873
+ function (fn, reverse) {
2874
+ var nodes = this.nodes;
2875
+ for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
2876
+ var node = nodes[reverse ? maxIndex - ii : ii];
2877
+ if (node && node.iterate(fn, reverse) === false) {
2878
+ return false;
2879
+ }
2512
2880
  }
2513
- }
2514
- };
2881
+ };
2515
2882
 
2516
2883
  // eslint-disable-next-line no-unused-vars
2517
- ValueNode.prototype.iterate = function(fn, reverse) {
2884
+ ValueNode.prototype.iterate = function (fn, reverse) {
2518
2885
  return fn(this.entry);
2519
2886
  };
2520
2887
 
2521
- var MapIterator = (function (Iterator$$1) {
2888
+ var MapIterator = /*@__PURE__*/(function (Iterator) {
2522
2889
  function MapIterator(map, type, reverse) {
2523
2890
  this._type = type;
2524
2891
  this._reverse = reverse;
2525
2892
  this._stack = map._root && mapIteratorFrame(map._root);
2526
2893
  }
2527
2894
 
2528
- if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
2529
- MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
2895
+ if ( Iterator ) MapIterator.__proto__ = Iterator;
2896
+ MapIterator.prototype = Object.create( Iterator && Iterator.prototype );
2530
2897
  MapIterator.prototype.constructor = MapIterator;
2531
2898
 
2532
2899
  MapIterator.prototype.next = function next () {
2533
- var this$1 = this;
2534
-
2535
2900
  var type = this._type;
2536
2901
  var stack = this._stack;
2537
2902
  while (stack) {
@@ -2547,23 +2912,23 @@ var MapIterator = (function (Iterator$$1) {
2547
2912
  if (index <= maxIndex) {
2548
2913
  return mapIteratorValue(
2549
2914
  type,
2550
- node.entries[this$1._reverse ? maxIndex - index : index]
2915
+ node.entries[this._reverse ? maxIndex - index : index]
2551
2916
  );
2552
2917
  }
2553
2918
  } else {
2554
2919
  maxIndex = node.nodes.length - 1;
2555
2920
  if (index <= maxIndex) {
2556
- var subNode = node.nodes[this$1._reverse ? maxIndex - index : index];
2921
+ var subNode = node.nodes[this._reverse ? maxIndex - index : index];
2557
2922
  if (subNode) {
2558
2923
  if (subNode.entry) {
2559
2924
  return mapIteratorValue(type, subNode.entry);
2560
2925
  }
2561
- stack = this$1._stack = mapIteratorFrame(subNode, stack);
2926
+ stack = this._stack = mapIteratorFrame(subNode, stack);
2562
2927
  }
2563
2928
  continue;
2564
2929
  }
2565
2930
  }
2566
- stack = this$1._stack = this$1._stack.__prev;
2931
+ stack = this._stack = this._stack.__prev;
2567
2932
  }
2568
2933
  return iteratorDone();
2569
2934
  };
@@ -2579,16 +2944,16 @@ function mapIteratorFrame(node, prev) {
2579
2944
  return {
2580
2945
  node: node,
2581
2946
  index: 0,
2582
- __prev: prev
2947
+ __prev: prev,
2583
2948
  };
2584
2949
  }
2585
2950
 
2586
- function makeMap(size, root, ownerID, hash$$1) {
2951
+ function makeMap(size, root, ownerID, hash) {
2587
2952
  var map = Object.create(MapPrototype);
2588
2953
  map.size = size;
2589
2954
  map._root = root;
2590
2955
  map.__ownerID = ownerID;
2591
- map.__hash = hash$$1;
2956
+ map.__hash = hash;
2592
2957
  map.__altered = false;
2593
2958
  return map;
2594
2959
  }
@@ -2608,8 +2973,8 @@ function updateMap(map, k, v) {
2608
2973
  newSize = 1;
2609
2974
  newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
2610
2975
  } else {
2611
- var didChangeSize = MakeRef(CHANGE_LENGTH);
2612
- var didAlter = MakeRef(DID_ALTER);
2976
+ var didChangeSize = MakeRef();
2977
+ var didAlter = MakeRef();
2613
2978
  newRoot = updateNode(
2614
2979
  map._root,
2615
2980
  map.__ownerID,
@@ -2724,90 +3089,6 @@ function expandNodes(ownerID, nodes, bitmap, including, node) {
2724
3089
  return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
2725
3090
  }
2726
3091
 
2727
- function mergeIntoMapWith(map, merger, collections) {
2728
- var iters = [];
2729
- for (var ii = 0; ii < collections.length; ii++) {
2730
- iters.push(KeyedCollection(collections[ii]));
2731
- }
2732
- return mergeIntoCollectionWith(map, merger, iters);
2733
- }
2734
-
2735
- function alwaysNewVal(oldVal, newVal) {
2736
- return newVal;
2737
- }
2738
-
2739
- function deepMergerWith(merger) {
2740
- return function(oldVal, newVal, key) {
2741
- if (oldVal && newVal && typeof newVal === 'object') {
2742
- if (oldVal.mergeDeepWith) {
2743
- return oldVal.mergeDeepWith(merger, newVal);
2744
- }
2745
- if (oldVal.merge) {
2746
- return oldVal.merge(newVal);
2747
- }
2748
- }
2749
- var nextValue = merger(oldVal, newVal, key);
2750
- return is(oldVal, nextValue) ? oldVal : nextValue;
2751
- };
2752
- }
2753
-
2754
- function mergeIntoCollectionWith(collection, merger, iters) {
2755
- iters = iters.filter(function (x) { return x.size !== 0; });
2756
- if (iters.length === 0) {
2757
- return collection;
2758
- }
2759
- if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
2760
- return collection.constructor(iters[0]);
2761
- }
2762
- return collection.withMutations(function (collection) {
2763
- var mergeIntoCollection = merger
2764
- ? function (value, key) {
2765
- collection.update(
2766
- key,
2767
- NOT_SET,
2768
- function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
2769
- );
2770
- }
2771
- : function (value, key) {
2772
- collection.set(key, value);
2773
- };
2774
- for (var ii = 0; ii < iters.length; ii++) {
2775
- iters[ii].forEach(mergeIntoCollection);
2776
- }
2777
- });
2778
- }
2779
-
2780
- function updateInDeepMap(existing, keyPath, i, notSetValue, updater) {
2781
- var isNotSet = existing === NOT_SET;
2782
- if (i === keyPath.length) {
2783
- var existingValue = isNotSet ? notSetValue : existing;
2784
- var newValue = updater(existingValue);
2785
- return newValue === existingValue ? existing : newValue;
2786
- }
2787
- if (!(isNotSet || (existing && existing.set))) {
2788
- throw new TypeError(
2789
- 'Invalid keyPath: Value at [' +
2790
- keyPath.slice(0, i).map(quoteString) +
2791
- '] does not have a .set() method and cannot be updated: ' +
2792
- existing
2793
- );
2794
- }
2795
- var key = keyPath[i];
2796
- var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
2797
- var nextUpdated = updateInDeepMap(
2798
- nextExisting,
2799
- keyPath,
2800
- i + 1,
2801
- notSetValue,
2802
- updater
2803
- );
2804
- return nextUpdated === nextExisting
2805
- ? existing
2806
- : nextUpdated === NOT_SET
2807
- ? existing.remove(key)
2808
- : (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
2809
- }
2810
-
2811
3092
  function popCount(x) {
2812
3093
  x -= (x >> 1) & 0x55555555;
2813
3094
  x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
@@ -2817,7 +3098,7 @@ function popCount(x) {
2817
3098
  return x & 0x7f;
2818
3099
  }
2819
3100
 
2820
- function setIn(array, idx, val, canEdit) {
3101
+ function setAt(array, idx, val, canEdit) {
2821
3102
  var newArray = canEdit ? array : arrCopy(array);
2822
3103
  newArray[idx] = val;
2823
3104
  return newArray;
@@ -2863,7 +3144,13 @@ var MAX_ARRAY_MAP_SIZE = SIZE / 4;
2863
3144
  var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
2864
3145
  var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
2865
3146
 
2866
- var List = (function (IndexedCollection$$1) {
3147
+ var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
3148
+
3149
+ function isList(maybeList) {
3150
+ return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
3151
+ }
3152
+
3153
+ var List = /*@__PURE__*/(function (IndexedCollection) {
2867
3154
  function List(value) {
2868
3155
  var empty = emptyList();
2869
3156
  if (value === null || value === undefined) {
@@ -2872,7 +3159,7 @@ var List = (function (IndexedCollection$$1) {
2872
3159
  if (isList(value)) {
2873
3160
  return value;
2874
3161
  }
2875
- var iter = IndexedCollection$$1(value);
3162
+ var iter = IndexedCollection(value);
2876
3163
  var size = iter.size;
2877
3164
  if (size === 0) {
2878
3165
  return empty;
@@ -2887,8 +3174,8 @@ var List = (function (IndexedCollection$$1) {
2887
3174
  });
2888
3175
  }
2889
3176
 
2890
- if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
2891
- List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
3177
+ if ( IndexedCollection ) List.__proto__ = IndexedCollection;
3178
+ List.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
2892
3179
  List.prototype.constructor = List;
2893
3180
 
2894
3181
  List.of = function of (/*...values*/) {
@@ -2921,8 +3208,10 @@ var List = (function (IndexedCollection$$1) {
2921
3208
  return !this.has(index)
2922
3209
  ? this
2923
3210
  : index === 0
2924
- ? this.shift()
2925
- : index === this.size - 1 ? this.pop() : this.splice(index, 1);
3211
+ ? this.shift()
3212
+ : index === this.size - 1
3213
+ ? this.pop()
3214
+ : this.splice(index, 1);
2926
3215
  };
2927
3216
 
2928
3217
  List.prototype.insert = function insert (index, value) {
@@ -2936,8 +3225,7 @@ var List = (function (IndexedCollection$$1) {
2936
3225
  if (this.__ownerID) {
2937
3226
  this.size = this._origin = this._capacity = 0;
2938
3227
  this._level = SHIFT;
2939
- this._root = this._tail = null;
2940
- this.__hash = undefined;
3228
+ this._root = this._tail = this.__hash = undefined;
2941
3229
  this.__altered = true;
2942
3230
  return this;
2943
3231
  }
@@ -2975,14 +3263,46 @@ var List = (function (IndexedCollection$$1) {
2975
3263
 
2976
3264
  // @pragma Composition
2977
3265
 
2978
- List.prototype.merge = function merge (/*...collections*/) {
2979
- return this.concat.apply(this, arguments);
3266
+ List.prototype.concat = function concat (/*...collections*/) {
3267
+ var arguments$1 = arguments;
3268
+
3269
+ var seqs = [];
3270
+ for (var i = 0; i < arguments.length; i++) {
3271
+ var argument = arguments$1[i];
3272
+ var seq = IndexedCollection(
3273
+ typeof argument !== 'string' && hasIterator(argument)
3274
+ ? argument
3275
+ : [argument]
3276
+ );
3277
+ if (seq.size !== 0) {
3278
+ seqs.push(seq);
3279
+ }
3280
+ }
3281
+ if (seqs.length === 0) {
3282
+ return this;
3283
+ }
3284
+ if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
3285
+ return this.constructor(seqs[0]);
3286
+ }
3287
+ return this.withMutations(function (list) {
3288
+ seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
3289
+ });
2980
3290
  };
2981
3291
 
2982
3292
  List.prototype.setSize = function setSize (size) {
2983
3293
  return setListBounds(this, 0, size);
2984
3294
  };
2985
3295
 
3296
+ List.prototype.map = function map (mapper, context) {
3297
+ var this$1$1 = this;
3298
+
3299
+ return this.withMutations(function (list) {
3300
+ for (var i = 0; i < this$1$1.size; i++) {
3301
+ list.set(i, mapper.call(context, list.get(i), i, this$1$1));
3302
+ }
3303
+ });
3304
+ };
3305
+
2986
3306
  // @pragma Iteration
2987
3307
 
2988
3308
  List.prototype.slice = function slice (begin, end) {
@@ -3009,13 +3329,11 @@ var List = (function (IndexedCollection$$1) {
3009
3329
  };
3010
3330
 
3011
3331
  List.prototype.__iterate = function __iterate (fn, reverse) {
3012
- var this$1 = this;
3013
-
3014
3332
  var index = reverse ? this.size : 0;
3015
3333
  var values = iterateList(this, reverse);
3016
3334
  var value;
3017
3335
  while ((value = values()) !== DONE) {
3018
- if (fn(value, reverse ? --index : index++, this$1) === false) {
3336
+ if (fn(value, reverse ? --index : index++, this) === false) {
3019
3337
  break;
3020
3338
  }
3021
3339
  }
@@ -3048,32 +3366,28 @@ var List = (function (IndexedCollection$$1) {
3048
3366
  return List;
3049
3367
  }(IndexedCollection));
3050
3368
 
3051
- function isList(maybeList) {
3052
- return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
3053
- }
3054
-
3055
3369
  List.isList = isList;
3056
3370
 
3057
- var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
3058
-
3059
3371
  var ListPrototype = List.prototype;
3060
- ListPrototype[IS_LIST_SENTINEL] = true;
3372
+ ListPrototype[IS_LIST_SYMBOL] = true;
3061
3373
  ListPrototype[DELETE] = ListPrototype.remove;
3062
- ListPrototype.setIn = MapPrototype.setIn;
3063
- ListPrototype.deleteIn = ListPrototype.removeIn = MapPrototype.removeIn;
3064
- ListPrototype.update = MapPrototype.update;
3065
- ListPrototype.updateIn = MapPrototype.updateIn;
3066
- ListPrototype.mergeIn = MapPrototype.mergeIn;
3067
- ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
3068
- ListPrototype.withMutations = MapPrototype.withMutations;
3069
- ListPrototype.asMutable = MapPrototype.asMutable;
3070
- ListPrototype.asImmutable = MapPrototype.asImmutable;
3071
- ListPrototype.wasAltered = MapPrototype.wasAltered;
3072
- ListPrototype['@@transducer/init'] = ListPrototype.asMutable;
3073
- ListPrototype['@@transducer/step'] = function(result, arr) {
3374
+ ListPrototype.merge = ListPrototype.concat;
3375
+ ListPrototype.setIn = setIn;
3376
+ ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
3377
+ ListPrototype.update = update;
3378
+ ListPrototype.updateIn = updateIn;
3379
+ ListPrototype.mergeIn = mergeIn;
3380
+ ListPrototype.mergeDeepIn = mergeDeepIn;
3381
+ ListPrototype.withMutations = withMutations;
3382
+ ListPrototype.wasAltered = wasAltered;
3383
+ ListPrototype.asImmutable = asImmutable;
3384
+ ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
3385
+ ListPrototype['@@transducer/step'] = function (result, arr) {
3074
3386
  return result.push(arr);
3075
3387
  };
3076
- ListPrototype['@@transducer/result'] = MapPrototype['@@transducer/result'];
3388
+ ListPrototype['@@transducer/result'] = function (obj) {
3389
+ return obj.asImmutable();
3390
+ };
3077
3391
 
3078
3392
  var VNode = function VNode(array, ownerID) {
3079
3393
  this.array = array;
@@ -3083,7 +3397,7 @@ var VNode = function VNode(array, ownerID) {
3083
3397
  // TODO: seems like these methods are very similar
3084
3398
 
3085
3399
  VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
3086
- if (index === level ? 1 << level : 0 || this.array.length === 0) {
3400
+ if (index === level ? 1 << level : this.array.length === 0) {
3087
3401
  return this;
3088
3402
  }
3089
3403
  var originIndex = (index >>> level) & MASK;
@@ -3243,7 +3557,7 @@ function updateList(list, index, value) {
3243
3557
 
3244
3558
  var newTail = list._tail;
3245
3559
  var newRoot = list._root;
3246
- var didAlter = MakeRef(DID_ALTER);
3560
+ var didAlter = MakeRef();
3247
3561
  if (index >= getTailOffset(list._capacity)) {
3248
3562
  newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
3249
3563
  } else {
@@ -3302,7 +3616,9 @@ function updateVNode(node, ownerID, level, index, value, didAlter) {
3302
3616
  return node;
3303
3617
  }
3304
3618
 
3305
- SetRef(didAlter);
3619
+ if (didAlter) {
3620
+ SetRef(didAlter);
3621
+ }
3306
3622
 
3307
3623
  newNode = editableVNode(node, ownerID);
3308
3624
  if (value === undefined && idx === newNode.array.length - 1) {
@@ -3351,7 +3667,9 @@ function setListBounds(list, begin, end) {
3351
3667
  var newCapacity =
3352
3668
  end === undefined
3353
3669
  ? oldCapacity
3354
- : end < 0 ? oldCapacity + end : oldOrigin + end;
3670
+ : end < 0
3671
+ ? oldCapacity + end
3672
+ : oldOrigin + end;
3355
3673
  if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
3356
3674
  return list;
3357
3675
  }
@@ -3398,7 +3716,9 @@ function setListBounds(list, begin, end) {
3398
3716
  var newTail =
3399
3717
  newTailOffset < oldTailOffset
3400
3718
  ? listNodeFor(list, newCapacity - 1)
3401
- : newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
3719
+ : newTailOffset > oldTailOffset
3720
+ ? new VNode([], owner)
3721
+ : oldTail;
3402
3722
 
3403
3723
  // Merge Tail into tree.
3404
3724
  if (
@@ -3481,21 +3801,21 @@ function getTailOffset(size) {
3481
3801
  return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
3482
3802
  }
3483
3803
 
3484
- var OrderedMap = (function (Map$$1) {
3804
+ var OrderedMap = /*@__PURE__*/(function (Map) {
3485
3805
  function OrderedMap(value) {
3486
3806
  return value === null || value === undefined
3487
3807
  ? emptyOrderedMap()
3488
3808
  : isOrderedMap(value)
3489
- ? value
3490
- : emptyOrderedMap().withMutations(function (map) {
3491
- var iter = KeyedCollection(value);
3492
- assertNotInfinite(iter.size);
3493
- iter.forEach(function (v, k) { return map.set(k, v); });
3494
- });
3809
+ ? value
3810
+ : emptyOrderedMap().withMutations(function (map) {
3811
+ var iter = KeyedCollection(value);
3812
+ assertNotInfinite(iter.size);
3813
+ iter.forEach(function (v, k) { return map.set(k, v); });
3814
+ });
3495
3815
  }
3496
3816
 
3497
- if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
3498
- OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
3817
+ if ( Map ) OrderedMap.__proto__ = Map;
3818
+ OrderedMap.prototype = Object.create( Map && Map.prototype );
3499
3819
  OrderedMap.prototype.constructor = OrderedMap;
3500
3820
 
3501
3821
  OrderedMap.of = function of (/*...values*/) {
@@ -3523,6 +3843,7 @@ var OrderedMap = (function (Map$$1) {
3523
3843
  this.size = 0;
3524
3844
  this._map.clear();
3525
3845
  this._list.clear();
3846
+ this.__altered = true;
3526
3847
  return this;
3527
3848
  }
3528
3849
  return emptyOrderedMap();
@@ -3536,15 +3857,11 @@ var OrderedMap = (function (Map$$1) {
3536
3857
  return updateOrderedMap(this, k, NOT_SET);
3537
3858
  };
3538
3859
 
3539
- OrderedMap.prototype.wasAltered = function wasAltered () {
3540
- return this._map.wasAltered() || this._list.wasAltered();
3541
- };
3542
-
3543
3860
  OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
3544
- var this$1 = this;
3861
+ var this$1$1 = this;
3545
3862
 
3546
3863
  return this._list.__iterate(
3547
- function (entry) { return entry && fn(entry[1], entry[0], this$1); },
3864
+ function (entry) { return entry && fn(entry[1], entry[0], this$1$1); },
3548
3865
  reverse
3549
3866
  );
3550
3867
  };
@@ -3564,6 +3881,7 @@ var OrderedMap = (function (Map$$1) {
3564
3881
  return emptyOrderedMap();
3565
3882
  }
3566
3883
  this.__ownerID = ownerID;
3884
+ this.__altered = false;
3567
3885
  this._map = newMap;
3568
3886
  this._list = newList;
3569
3887
  return this;
@@ -3574,13 +3892,9 @@ var OrderedMap = (function (Map$$1) {
3574
3892
  return OrderedMap;
3575
3893
  }(Map));
3576
3894
 
3577
- function isOrderedMap(maybeOrderedMap) {
3578
- return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
3579
- }
3580
-
3581
3895
  OrderedMap.isOrderedMap = isOrderedMap;
3582
3896
 
3583
- OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
3897
+ OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
3584
3898
  OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
3585
3899
 
3586
3900
  function makeOrderedMap(map, list, ownerID, hash) {
@@ -3590,6 +3904,7 @@ function makeOrderedMap(map, list, ownerID, hash) {
3590
3904
  omap._list = list;
3591
3905
  omap.__ownerID = ownerID;
3592
3906
  omap.__hash = hash;
3907
+ omap.__altered = false;
3593
3908
  return omap;
3594
3909
  }
3595
3910
 
@@ -3642,20 +3957,29 @@ function updateOrderedMap(omap, k, v) {
3642
3957
  omap._map = newMap;
3643
3958
  omap._list = newList;
3644
3959
  omap.__hash = undefined;
3960
+ omap.__altered = true;
3645
3961
  return omap;
3646
3962
  }
3647
3963
  return makeOrderedMap(newMap, newList);
3648
3964
  }
3649
3965
 
3650
- var Stack = (function (IndexedCollection$$1) {
3966
+ var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
3967
+
3968
+ function isStack(maybeStack) {
3969
+ return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
3970
+ }
3971
+
3972
+ var Stack = /*@__PURE__*/(function (IndexedCollection) {
3651
3973
  function Stack(value) {
3652
3974
  return value === null || value === undefined
3653
3975
  ? emptyStack()
3654
- : isStack(value) ? value : emptyStack().pushAll(value);
3976
+ : isStack(value)
3977
+ ? value
3978
+ : emptyStack().pushAll(value);
3655
3979
  }
3656
3980
 
3657
- if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
3658
- Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
3981
+ if ( IndexedCollection ) Stack.__proto__ = IndexedCollection;
3982
+ Stack.prototype = Object.create( IndexedCollection && IndexedCollection.prototype );
3659
3983
  Stack.prototype.constructor = Stack;
3660
3984
 
3661
3985
  Stack.of = function of (/*...values*/) {
@@ -3694,7 +4018,7 @@ var Stack = (function (IndexedCollection$$1) {
3694
4018
  for (var ii = arguments.length - 1; ii >= 0; ii--) {
3695
4019
  head = {
3696
4020
  value: arguments$1[ii],
3697
- next: head
4021
+ next: head,
3698
4022
  };
3699
4023
  }
3700
4024
  if (this.__ownerID) {
@@ -3708,7 +4032,7 @@ var Stack = (function (IndexedCollection$$1) {
3708
4032
  };
3709
4033
 
3710
4034
  Stack.prototype.pushAll = function pushAll (iter) {
3711
- iter = IndexedCollection$$1(iter);
4035
+ iter = IndexedCollection(iter);
3712
4036
  if (iter.size === 0) {
3713
4037
  return this;
3714
4038
  }
@@ -3722,7 +4046,7 @@ var Stack = (function (IndexedCollection$$1) {
3722
4046
  newSize++;
3723
4047
  head = {
3724
4048
  value: value,
3725
- next: head
4049
+ next: head,
3726
4050
  };
3727
4051
  }, /* reverse */ true);
3728
4052
  if (this.__ownerID) {
@@ -3761,7 +4085,7 @@ var Stack = (function (IndexedCollection$$1) {
3761
4085
  var resolvedEnd = resolveEnd(end, this.size);
3762
4086
  if (resolvedEnd !== this.size) {
3763
4087
  // super.slice(begin, end);
3764
- return IndexedCollection$$1.prototype.slice.call(this, begin, end);
4088
+ return IndexedCollection.prototype.slice.call(this, begin, end);
3765
4089
  }
3766
4090
  var newSize = this.size - resolvedBegin;
3767
4091
  var head = this._head;
@@ -3798,18 +4122,18 @@ var Stack = (function (IndexedCollection$$1) {
3798
4122
  // @pragma Iteration
3799
4123
 
3800
4124
  Stack.prototype.__iterate = function __iterate (fn, reverse) {
3801
- var this$1 = this;
4125
+ var this$1$1 = this;
3802
4126
 
3803
4127
  if (reverse) {
3804
4128
  return new ArraySeq(this.toArray()).__iterate(
3805
- function (v, k) { return fn(v, k, this$1); },
4129
+ function (v, k) { return fn(v, k, this$1$1); },
3806
4130
  reverse
3807
4131
  );
3808
4132
  }
3809
4133
  var iterations = 0;
3810
4134
  var node = this._head;
3811
4135
  while (node) {
3812
- if (fn(node.value, iterations++, this$1) === false) {
4136
+ if (fn(node.value, iterations++, this) === false) {
3813
4137
  break;
3814
4138
  }
3815
4139
  node = node.next;
@@ -3836,28 +4160,23 @@ var Stack = (function (IndexedCollection$$1) {
3836
4160
  return Stack;
3837
4161
  }(IndexedCollection));
3838
4162
 
3839
- function isStack(maybeStack) {
3840
- return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
3841
- }
3842
-
3843
4163
  Stack.isStack = isStack;
3844
4164
 
3845
- var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
3846
-
3847
4165
  var StackPrototype = Stack.prototype;
3848
- StackPrototype[IS_STACK_SENTINEL] = true;
3849
- StackPrototype.withMutations = MapPrototype.withMutations;
3850
- StackPrototype.asMutable = MapPrototype.asMutable;
3851
- StackPrototype.asImmutable = MapPrototype.asImmutable;
3852
- StackPrototype.wasAltered = MapPrototype.wasAltered;
4166
+ StackPrototype[IS_STACK_SYMBOL] = true;
3853
4167
  StackPrototype.shift = StackPrototype.pop;
3854
4168
  StackPrototype.unshift = StackPrototype.push;
3855
4169
  StackPrototype.unshiftAll = StackPrototype.pushAll;
3856
- StackPrototype['@@transducer/init'] = StackPrototype.asMutable;
3857
- StackPrototype['@@transducer/step'] = function(result, arr) {
4170
+ StackPrototype.withMutations = withMutations;
4171
+ StackPrototype.wasAltered = wasAltered;
4172
+ StackPrototype.asImmutable = asImmutable;
4173
+ StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
4174
+ StackPrototype['@@transducer/step'] = function (result, arr) {
3858
4175
  return result.unshift(arr);
3859
4176
  };
3860
- StackPrototype['@@transducer/result'] = MapPrototype['@@transducer/result'];
4177
+ StackPrototype['@@transducer/result'] = function (obj) {
4178
+ return obj.asImmutable();
4179
+ };
3861
4180
 
3862
4181
  function makeStack(size, head, ownerID, hash) {
3863
4182
  var map = Object.create(StackPrototype);
@@ -3874,6 +4193,16 @@ function emptyStack() {
3874
4193
  return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
3875
4194
  }
3876
4195
 
4196
+ var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
4197
+
4198
+ function isSet(maybeSet) {
4199
+ return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
4200
+ }
4201
+
4202
+ function isOrderedSet(maybeOrderedSet) {
4203
+ return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
4204
+ }
4205
+
3877
4206
  function deepEqual(a, b) {
3878
4207
  if (a === b) {
3879
4208
  return true;
@@ -3928,7 +4257,9 @@ function deepEqual(a, b) {
3928
4257
  if (
3929
4258
  notAssociative
3930
4259
  ? !a.has(v)
3931
- : flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)
4260
+ : flipped
4261
+ ? !is(v, a.get(k, NOT_SET))
4262
+ : !is(a.get(k, NOT_SET), v)
3932
4263
  ) {
3933
4264
  allEqual = false;
3934
4265
  return false;
@@ -3938,9 +4269,6 @@ function deepEqual(a, b) {
3938
4269
  return allEqual && a.size === bSize;
3939
4270
  }
3940
4271
 
3941
- /**
3942
- * Contributes additional methods to a constructor
3943
- */
3944
4272
  function mixin(ctor, methods) {
3945
4273
  var keyCopier = function (key) {
3946
4274
  ctor.prototype[key] = methods[key];
@@ -3951,21 +4279,45 @@ function mixin(ctor, methods) {
3951
4279
  return ctor;
3952
4280
  }
3953
4281
 
3954
- var Set = (function (SetCollection$$1) {
4282
+ function toJS(value) {
4283
+ if (!value || typeof value !== 'object') {
4284
+ return value;
4285
+ }
4286
+ if (!isCollection(value)) {
4287
+ if (!isDataStructure(value)) {
4288
+ return value;
4289
+ }
4290
+ value = Seq(value);
4291
+ }
4292
+ if (isKeyed(value)) {
4293
+ var result$1 = {};
4294
+ value.__iterate(function (v, k) {
4295
+ result$1[k] = toJS(v);
4296
+ });
4297
+ return result$1;
4298
+ }
4299
+ var result = [];
4300
+ value.__iterate(function (v) {
4301
+ result.push(toJS(v));
4302
+ });
4303
+ return result;
4304
+ }
4305
+
4306
+ var Set = /*@__PURE__*/(function (SetCollection) {
3955
4307
  function Set(value) {
3956
4308
  return value === null || value === undefined
3957
4309
  ? emptySet()
3958
4310
  : isSet(value) && !isOrdered(value)
3959
- ? value
3960
- : emptySet().withMutations(function (set) {
3961
- var iter = SetCollection$$1(value);
3962
- assertNotInfinite(iter.size);
3963
- iter.forEach(function (v) { return set.add(v); });
3964
- });
4311
+ ? value
4312
+ : emptySet().withMutations(function (set) {
4313
+ var iter = SetCollection(value);
4314
+ assertNotInfinite(iter.size);
4315
+ iter.forEach(function (v) { return set.add(v); });
4316
+ });
3965
4317
  }
3966
4318
 
3967
- if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
3968
- Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
4319
+ if ( SetCollection ) Set.__proto__ = SetCollection;
4320
+ Set.prototype = Object.create( SetCollection && SetCollection.prototype );
3969
4321
  Set.prototype.constructor = Set;
3970
4322
 
3971
4323
  Set.of = function of (/*...values*/) {
@@ -4016,6 +4368,30 @@ var Set = (function (SetCollection$$1) {
4016
4368
 
4017
4369
  // @pragma Composition
4018
4370
 
4371
+ Set.prototype.map = function map (mapper, context) {
4372
+ var this$1$1 = this;
4373
+
4374
+ // keep track if the set is altered by the map function
4375
+ var didChanges = false;
4376
+
4377
+ var newMap = updateSet(
4378
+ this,
4379
+ this._map.mapEntries(function (ref) {
4380
+ var v = ref[1];
4381
+
4382
+ var mapped = mapper.call(context, v, v, this$1$1);
4383
+
4384
+ if (mapped !== v) {
4385
+ didChanges = true;
4386
+ }
4387
+
4388
+ return [mapped, mapped];
4389
+ }, context)
4390
+ );
4391
+
4392
+ return didChanges ? newMap : this;
4393
+ };
4394
+
4019
4395
  Set.prototype.union = function union () {
4020
4396
  var iters = [], len = arguments.length;
4021
4397
  while ( len-- ) iters[ len ] = arguments[ len ];
@@ -4029,7 +4405,7 @@ var Set = (function (SetCollection$$1) {
4029
4405
  }
4030
4406
  return this.withMutations(function (set) {
4031
4407
  for (var ii = 0; ii < iters.length; ii++) {
4032
- SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
4408
+ SetCollection(iters[ii]).forEach(function (value) { return set.add(value); });
4033
4409
  }
4034
4410
  });
4035
4411
  };
@@ -4041,7 +4417,7 @@ var Set = (function (SetCollection$$1) {
4041
4417
  if (iters.length === 0) {
4042
4418
  return this;
4043
4419
  }
4044
- iters = iters.map(function (iter) { return SetCollection$$1(iter); });
4420
+ iters = iters.map(function (iter) { return SetCollection(iter); });
4045
4421
  var toRemove = [];
4046
4422
  this.forEach(function (value) {
4047
4423
  if (!iters.every(function (iter) { return iter.includes(value); })) {
@@ -4062,7 +4438,7 @@ var Set = (function (SetCollection$$1) {
4062
4438
  if (iters.length === 0) {
4063
4439
  return this;
4064
4440
  }
4065
- iters = iters.map(function (iter) { return SetCollection$$1(iter); });
4441
+ iters = iters.map(function (iter) { return SetCollection(iter); });
4066
4442
  var toRemove = [];
4067
4443
  this.forEach(function (value) {
4068
4444
  if (iters.some(function (iter) { return iter.includes(value); })) {
@@ -4091,9 +4467,9 @@ var Set = (function (SetCollection$$1) {
4091
4467
  };
4092
4468
 
4093
4469
  Set.prototype.__iterate = function __iterate (fn, reverse) {
4094
- var this$1 = this;
4470
+ var this$1$1 = this;
4095
4471
 
4096
- return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
4472
+ return this._map.__iterate(function (k) { return fn(k, k, this$1$1); }, reverse);
4097
4473
  };
4098
4474
 
4099
4475
  Set.prototype.__iterator = function __iterator (type, reverse) {
@@ -4119,26 +4495,21 @@ var Set = (function (SetCollection$$1) {
4119
4495
  return Set;
4120
4496
  }(SetCollection));
4121
4497
 
4122
- function isSet(maybeSet) {
4123
- return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
4124
- }
4125
-
4126
4498
  Set.isSet = isSet;
4127
4499
 
4128
- var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
4129
-
4130
4500
  var SetPrototype = Set.prototype;
4131
- SetPrototype[IS_SET_SENTINEL] = true;
4501
+ SetPrototype[IS_SET_SYMBOL] = true;
4132
4502
  SetPrototype[DELETE] = SetPrototype.remove;
4133
- SetPrototype.merge = SetPrototype.union;
4134
- SetPrototype.withMutations = MapPrototype.withMutations;
4135
- SetPrototype.asMutable = MapPrototype.asMutable;
4136
- SetPrototype.asImmutable = MapPrototype.asImmutable;
4137
- SetPrototype['@@transducer/init'] = SetPrototype.asMutable;
4138
- SetPrototype['@@transducer/step'] = function(result, arr) {
4503
+ SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
4504
+ SetPrototype.withMutations = withMutations;
4505
+ SetPrototype.asImmutable = asImmutable;
4506
+ SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
4507
+ SetPrototype['@@transducer/step'] = function (result, arr) {
4139
4508
  return result.add(arr);
4140
4509
  };
4141
- SetPrototype['@@transducer/result'] = MapPrototype['@@transducer/result'];
4510
+ SetPrototype['@@transducer/result'] = function (obj) {
4511
+ return obj.asImmutable();
4512
+ };
4142
4513
 
4143
4514
  SetPrototype.__empty = emptySet;
4144
4515
  SetPrototype.__make = makeSet;
@@ -4151,7 +4522,9 @@ function updateSet(set, newMap) {
4151
4522
  }
4152
4523
  return newMap === set._map
4153
4524
  ? set
4154
- : newMap.size === 0 ? set.__empty() : set.__make(newMap);
4525
+ : newMap.size === 0
4526
+ ? set.__empty()
4527
+ : set.__make(newMap);
4155
4528
  }
4156
4529
 
4157
4530
  function makeSet(map, ownerID) {
@@ -4172,7 +4545,7 @@ function emptySet() {
4172
4545
  * (exclusive), by step, where start defaults to 0, step to 1, and end to
4173
4546
  * infinity. When start is equal to end, returns empty list.
4174
4547
  */
4175
- var Range = (function (IndexedSeq$$1) {
4548
+ var Range = /*@__PURE__*/(function (IndexedSeq) {
4176
4549
  function Range(start, end, step) {
4177
4550
  if (!(this instanceof Range)) {
4178
4551
  return new Range(start, end, step);
@@ -4198,8 +4571,8 @@ var Range = (function (IndexedSeq$$1) {
4198
4571
  }
4199
4572
  }
4200
4573
 
4201
- if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
4202
- Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
4574
+ if ( IndexedSeq ) Range.__proto__ = IndexedSeq;
4575
+ Range.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
4203
4576
  Range.prototype.constructor = Range;
4204
4577
 
4205
4578
  Range.prototype.toString = function toString () {
@@ -4263,14 +4636,12 @@ var Range = (function (IndexedSeq$$1) {
4263
4636
  };
4264
4637
 
4265
4638
  Range.prototype.__iterate = function __iterate (fn, reverse) {
4266
- var this$1 = this;
4267
-
4268
4639
  var size = this.size;
4269
4640
  var step = this._step;
4270
4641
  var value = reverse ? this._start + (size - 1) * step : this._start;
4271
4642
  var i = 0;
4272
4643
  while (i !== size) {
4273
- if (fn(value, reverse ? size - ++i : i++, this$1) === false) {
4644
+ if (fn(value, reverse ? size - ++i : i++, this) === false) {
4274
4645
  break;
4275
4646
  }
4276
4647
  value += reverse ? -step : step;
@@ -4306,6 +4677,39 @@ var Range = (function (IndexedSeq$$1) {
4306
4677
 
4307
4678
  var EMPTY_RANGE;
4308
4679
 
4680
+ function getIn$1(collection, searchKeyPath, notSetValue) {
4681
+ var keyPath = coerceKeyPath(searchKeyPath);
4682
+ var i = 0;
4683
+ while (i !== keyPath.length) {
4684
+ collection = get(collection, keyPath[i++], NOT_SET);
4685
+ if (collection === NOT_SET) {
4686
+ return notSetValue;
4687
+ }
4688
+ }
4689
+ return collection;
4690
+ }
4691
+
4692
+ function getIn(searchKeyPath, notSetValue) {
4693
+ return getIn$1(this, searchKeyPath, notSetValue);
4694
+ }
4695
+
4696
+ function hasIn$1(collection, keyPath) {
4697
+ return getIn$1(collection, keyPath, NOT_SET) !== NOT_SET;
4698
+ }
4699
+
4700
+ function hasIn(searchKeyPath) {
4701
+ return hasIn$1(this, searchKeyPath);
4702
+ }
4703
+
4704
+ function toObject() {
4705
+ assertNotInfinite(this.size);
4706
+ var object = {};
4707
+ this.__iterate(function (v, k) {
4708
+ object[k] = v;
4709
+ });
4710
+ return object;
4711
+ }
4712
+
4309
4713
  // Note: all of these methods are deprecated.
4310
4714
  Collection.isIterable = isCollection;
4311
4715
  Collection.isKeyed = isKeyed;
@@ -4335,9 +4739,7 @@ mixin(Collection, {
4335
4739
  },
4336
4740
 
4337
4741
  toJS: function toJS$1() {
4338
- return this.toSeq()
4339
- .map(toJS)
4340
- .toJSON();
4742
+ return toJS(this);
4341
4743
  },
4342
4744
 
4343
4745
  toKeyedSeq: function toKeyedSeq() {
@@ -4349,14 +4751,7 @@ mixin(Collection, {
4349
4751
  return Map(this.toKeyedSeq());
4350
4752
  },
4351
4753
 
4352
- toObject: function toObject() {
4353
- assertNotInfinite(this.size);
4354
- var object = {};
4355
- this.__iterate(function (v, k) {
4356
- object[k] = v;
4357
- });
4358
- return object;
4359
- },
4754
+ toObject: toObject,
4360
4755
 
4361
4756
  toOrderedMap: function toOrderedMap() {
4362
4757
  // Use Late Binding here to solve the circular dependency.
@@ -4380,7 +4775,9 @@ mixin(Collection, {
4380
4775
  toSeq: function toSeq() {
4381
4776
  return isIndexed(this)
4382
4777
  ? this.toIndexedSeq()
4383
- : isKeyed(this) ? this.toKeyedSeq() : this.toSetSeq();
4778
+ : isKeyed(this)
4779
+ ? this.toKeyedSeq()
4780
+ : this.toSetSeq();
4384
4781
  },
4385
4782
 
4386
4783
  toStack: function toStack() {
@@ -4406,9 +4803,7 @@ mixin(Collection, {
4406
4803
  return (
4407
4804
  head +
4408
4805
  ' ' +
4409
- this.toSeq()
4410
- .map(this.__toStringMapper)
4411
- .join(', ') +
4806
+ this.toSeq().map(this.__toStringMapper).join(', ') +
4412
4807
  ' ' +
4413
4808
  tail
4414
4809
  );
@@ -4549,18 +4944,8 @@ mixin(Collection, {
4549
4944
  // We cache as an entries array, so we can just return the cache!
4550
4945
  return new ArraySeq(collection._cache);
4551
4946
  }
4552
- var entriesSequence = collection
4553
- .toSeq()
4554
- .map(entryMapper)
4555
- .toIndexedSeq();
4947
+ var entriesSequence = collection.toSeq().map(entryMapper).toIndexedSeq();
4556
4948
  entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
4557
-
4558
- // Entries are plain Array, which do not define toJS, so it must
4559
- // manually converts keys and values before conversion.
4560
- entriesSequence.toJS = function() {
4561
- return this.map(function (entry) { return [toJS(entry[0]), toJS(entry[1])]; }).toJSON();
4562
- };
4563
-
4564
4949
  return entriesSequence;
4565
4950
  },
4566
4951
 
@@ -4585,9 +4970,7 @@ mixin(Collection, {
4585
4970
  },
4586
4971
 
4587
4972
  findLast: function findLast(predicate, context, notSetValue) {
4588
- return this.toKeyedSeq()
4589
- .reverse()
4590
- .find(predicate, context, notSetValue);
4973
+ return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
4591
4974
  },
4592
4975
 
4593
4976
  findLastEntry: function findLastEntry(predicate, context, notSetValue) {
@@ -4597,13 +4980,11 @@ mixin(Collection, {
4597
4980
  },
4598
4981
 
4599
4982
  findLastKey: function findLastKey(predicate, context) {
4600
- return this.toKeyedSeq()
4601
- .reverse()
4602
- .findKey(predicate, context);
4983
+ return this.toKeyedSeq().reverse().findKey(predicate, context);
4603
4984
  },
4604
4985
 
4605
- first: function first() {
4606
- return this.find(returnTrue);
4986
+ first: function first(notSetValue) {
4987
+ return this.find(returnTrue, null, notSetValue);
4607
4988
  },
4608
4989
 
4609
4990
  flatMap: function flatMap(mapper, context) {
@@ -4622,9 +5003,7 @@ mixin(Collection, {
4622
5003
  return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
4623
5004
  },
4624
5005
 
4625
- getIn: function getIn$1(searchKeyPath, notSetValue) {
4626
- return getIn(this, notSetValue, searchKeyPath, true /* report bad path */);
4627
- },
5006
+ getIn: getIn,
4628
5007
 
4629
5008
  groupBy: function groupBy(grouper, context) {
4630
5009
  return groupByFactory(this, grouper, context);
@@ -4634,12 +5013,7 @@ mixin(Collection, {
4634
5013
  return this.get(searchKey, NOT_SET) !== NOT_SET;
4635
5014
  },
4636
5015
 
4637
- hasIn: function hasIn(searchKeyPath) {
4638
- return (
4639
- getIn(this, NOT_SET, searchKeyPath, false /* report bad path */) !==
4640
- NOT_SET
4641
- );
4642
- },
5016
+ hasIn: hasIn,
4643
5017
 
4644
5018
  isSubset: function isSubset(iter) {
4645
5019
  iter = typeof iter.includes === 'function' ? iter : Collection(iter);
@@ -4656,21 +5030,15 @@ mixin(Collection, {
4656
5030
  },
4657
5031
 
4658
5032
  keySeq: function keySeq() {
4659
- return this.toSeq()
4660
- .map(keyMapper)
4661
- .toIndexedSeq();
5033
+ return this.toSeq().map(keyMapper).toIndexedSeq();
4662
5034
  },
4663
5035
 
4664
- last: function last() {
4665
- return this.toSeq()
4666
- .reverse()
4667
- .first();
5036
+ last: function last(notSetValue) {
5037
+ return this.toSeq().reverse().first(notSetValue);
4668
5038
  },
4669
5039
 
4670
5040
  lastKeyOf: function lastKeyOf(searchValue) {
4671
- return this.toKeyedSeq()
4672
- .reverse()
4673
- .keyOf(searchValue);
5041
+ return this.toKeyedSeq().reverse().keyOf(searchValue);
4674
5042
  },
4675
5043
 
4676
5044
  max: function max(comparator) {
@@ -4748,7 +5116,7 @@ mixin(Collection, {
4748
5116
 
4749
5117
  hashCode: function hashCode() {
4750
5118
  return this.__hash || (this.__hash = hashCollection(this));
4751
- }
5119
+ },
4752
5120
 
4753
5121
  // ### Internal
4754
5122
 
@@ -4758,11 +5126,11 @@ mixin(Collection, {
4758
5126
  });
4759
5127
 
4760
5128
  var CollectionPrototype = Collection.prototype;
4761
- CollectionPrototype[IS_ITERABLE_SENTINEL] = true;
5129
+ CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
4762
5130
  CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
4763
5131
  CollectionPrototype.toJSON = CollectionPrototype.toArray;
4764
5132
  CollectionPrototype.__toStringMapper = quoteString;
4765
- CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
5133
+ CollectionPrototype.inspect = CollectionPrototype.toSource = function () {
4766
5134
  return this.toString();
4767
5135
  };
4768
5136
  CollectionPrototype.chain = CollectionPrototype.flatMap;
@@ -4776,34 +5144,34 @@ mixin(KeyedCollection, {
4776
5144
  },
4777
5145
 
4778
5146
  mapEntries: function mapEntries(mapper, context) {
4779
- var this$1 = this;
5147
+ var this$1$1 = this;
4780
5148
 
4781
5149
  var iterations = 0;
4782
5150
  return reify(
4783
5151
  this,
4784
5152
  this.toSeq()
4785
- .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
5153
+ .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1$1); })
4786
5154
  .fromEntrySeq()
4787
5155
  );
4788
5156
  },
4789
5157
 
4790
5158
  mapKeys: function mapKeys(mapper, context) {
4791
- var this$1 = this;
5159
+ var this$1$1 = this;
4792
5160
 
4793
5161
  return reify(
4794
5162
  this,
4795
5163
  this.toSeq()
4796
5164
  .flip()
4797
- .map(function (k, v) { return mapper.call(context, k, v, this$1); })
5165
+ .map(function (k, v) { return mapper.call(context, k, v, this$1$1); })
4798
5166
  .flip()
4799
5167
  );
4800
- }
5168
+ },
4801
5169
  });
4802
5170
 
4803
5171
  var KeyedCollectionPrototype = KeyedCollection.prototype;
4804
- KeyedCollectionPrototype[IS_KEYED_SENTINEL] = true;
5172
+ KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
4805
5173
  KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
4806
- KeyedCollectionPrototype.toJSON = CollectionPrototype.toObject;
5174
+ KeyedCollectionPrototype.toJSON = toObject;
4807
5175
  KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
4808
5176
 
4809
5177
  mixin(IndexedCollection, {
@@ -4868,8 +5236,8 @@ mixin(IndexedCollection, {
4868
5236
  return entry ? entry[0] : -1;
4869
5237
  },
4870
5238
 
4871
- first: function first() {
4872
- return this.get(0);
5239
+ first: function first(notSetValue) {
5240
+ return this.get(0, notSetValue);
4873
5241
  },
4874
5242
 
4875
5243
  flatten: function flatten(depth) {
@@ -4879,7 +5247,8 @@ mixin(IndexedCollection, {
4879
5247
  get: function get(index, notSetValue) {
4880
5248
  index = wrapIndex(this, index);
4881
5249
  return index < 0 ||
4882
- (this.size === Infinity || (this.size !== undefined && index > this.size))
5250
+ this.size === Infinity ||
5251
+ (this.size !== undefined && index > this.size)
4883
5252
  ? notSetValue
4884
5253
  : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
4885
5254
  },
@@ -4912,8 +5281,8 @@ mixin(IndexedCollection, {
4912
5281
  return Range(0, this.size);
4913
5282
  },
4914
5283
 
4915
- last: function last() {
4916
- return this.get(-1);
5284
+ last: function last(notSetValue) {
5285
+ return this.get(-1, notSetValue);
4917
5286
  },
4918
5287
 
4919
5288
  skipWhile: function skipWhile(predicate, context) {
@@ -4934,12 +5303,12 @@ mixin(IndexedCollection, {
4934
5303
  var collections = arrCopy(arguments);
4935
5304
  collections[0] = this;
4936
5305
  return reify(this, zipWithFactory(this, zipper, collections));
4937
- }
5306
+ },
4938
5307
  });
4939
5308
 
4940
5309
  var IndexedCollectionPrototype = IndexedCollection.prototype;
4941
- IndexedCollectionPrototype[IS_INDEXED_SENTINEL] = true;
4942
- IndexedCollectionPrototype[IS_ORDERED_SENTINEL] = true;
5310
+ IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
5311
+ IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
4943
5312
 
4944
5313
  mixin(SetCollection, {
4945
5314
  // ### ES6 Collection methods (ES6 Array and Map)
@@ -4956,17 +5325,19 @@ mixin(SetCollection, {
4956
5325
 
4957
5326
  keySeq: function keySeq() {
4958
5327
  return this.valueSeq();
4959
- }
5328
+ },
4960
5329
  });
4961
5330
 
4962
- SetCollection.prototype.has = CollectionPrototype.includes;
4963
- SetCollection.prototype.contains = SetCollection.prototype.includes;
5331
+ var SetCollectionPrototype = SetCollection.prototype;
5332
+ SetCollectionPrototype.has = CollectionPrototype.includes;
5333
+ SetCollectionPrototype.contains = SetCollectionPrototype.includes;
5334
+ SetCollectionPrototype.keys = SetCollectionPrototype.values;
4964
5335
 
4965
5336
  // Mixin subclasses
4966
5337
 
4967
- mixin(KeyedSeq, KeyedCollection.prototype);
4968
- mixin(IndexedSeq, IndexedCollection.prototype);
4969
- mixin(SetSeq, SetCollection.prototype);
5338
+ mixin(KeyedSeq, KeyedCollectionPrototype);
5339
+ mixin(IndexedSeq, IndexedCollectionPrototype);
5340
+ mixin(SetSeq, SetCollectionPrototype);
4970
5341
 
4971
5342
  // #pragma Helper functions
4972
5343
 
@@ -4991,18 +5362,14 @@ function entryMapper(v, k) {
4991
5362
  return [k, v];
4992
5363
  }
4993
5364
 
4994
- function toJS(value) {
4995
- return value && typeof value.toJS === 'function' ? value.toJS() : value;
4996
- }
4997
-
4998
5365
  function not(predicate) {
4999
- return function() {
5366
+ return function () {
5000
5367
  return !predicate.apply(this, arguments);
5001
5368
  };
5002
5369
  }
5003
5370
 
5004
5371
  function neg(predicate) {
5005
- return function() {
5372
+ return function () {
5006
5373
  return -predicate.apply(this, arguments);
5007
5374
  };
5008
5375
  }
@@ -5032,12 +5399,12 @@ function hashCollection(collection) {
5032
5399
  h = (h + hashMerge(hash(v), hash(k))) | 0;
5033
5400
  }
5034
5401
  : ordered
5035
- ? function (v) {
5036
- h = (31 * h + hash(v)) | 0;
5037
- }
5038
- : function (v) {
5039
- h = (h + hash(v)) | 0;
5040
- }
5402
+ ? function (v) {
5403
+ h = (31 * h + hash(v)) | 0;
5404
+ }
5405
+ : function (v) {
5406
+ h = (h + hash(v)) | 0;
5407
+ }
5041
5408
  );
5042
5409
  return murmurHashOfSize(size, h);
5043
5410
  }
@@ -5057,55 +5424,21 @@ function hashMerge(a, b) {
5057
5424
  return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
5058
5425
  }
5059
5426
 
5060
- function warn(message) {
5061
- /* eslint-disable no-console */
5062
- if (typeof console === 'object' && console.warn) {
5063
- console.warn(message);
5064
- } else {
5065
- throw new Error(message);
5066
- }
5067
- /* eslint-enable no-console */
5068
- }
5069
-
5070
- function getIn(value, notSetValue, searchKeyPath, reportBadKeyPath) {
5071
- var keyPath = coerceKeyPath(searchKeyPath);
5072
- var i = 0;
5073
- while (i !== keyPath.length) {
5074
- if (!value || !value.get) {
5075
- if (reportBadKeyPath) {
5076
- warn(
5077
- 'Invalid keyPath: Value at [' +
5078
- keyPath.slice(0, i).map(quoteString) +
5079
- '] does not have a .get() method: ' +
5080
- value +
5081
- '\nThis warning will throw in a future version'
5082
- );
5083
- }
5084
- return notSetValue;
5085
- }
5086
- value = value.get(keyPath[i++], NOT_SET);
5087
- if (value === NOT_SET) {
5088
- return notSetValue;
5089
- }
5090
- }
5091
- return value;
5092
- }
5093
-
5094
- var OrderedSet = (function (Set$$1) {
5427
+ var OrderedSet = /*@__PURE__*/(function (Set) {
5095
5428
  function OrderedSet(value) {
5096
5429
  return value === null || value === undefined
5097
5430
  ? emptyOrderedSet()
5098
5431
  : isOrderedSet(value)
5099
- ? value
5100
- : emptyOrderedSet().withMutations(function (set) {
5101
- var iter = SetCollection(value);
5102
- assertNotInfinite(iter.size);
5103
- iter.forEach(function (v) { return set.add(v); });
5104
- });
5432
+ ? value
5433
+ : emptyOrderedSet().withMutations(function (set) {
5434
+ var iter = SetCollection(value);
5435
+ assertNotInfinite(iter.size);
5436
+ iter.forEach(function (v) { return set.add(v); });
5437
+ });
5105
5438
  }
5106
5439
 
5107
- if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
5108
- OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
5440
+ if ( Set ) OrderedSet.__proto__ = Set;
5441
+ OrderedSet.prototype = Object.create( Set && Set.prototype );
5109
5442
  OrderedSet.prototype.constructor = OrderedSet;
5110
5443
 
5111
5444
  OrderedSet.of = function of (/*...values*/) {
@@ -5123,16 +5456,13 @@ var OrderedSet = (function (Set$$1) {
5123
5456
  return OrderedSet;
5124
5457
  }(Set));
5125
5458
 
5126
- function isOrderedSet(maybeOrderedSet) {
5127
- return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
5128
- }
5129
-
5130
5459
  OrderedSet.isOrderedSet = isOrderedSet;
5131
5460
 
5132
5461
  var OrderedSetPrototype = OrderedSet.prototype;
5133
- OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
5462
+ OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
5134
5463
  OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
5135
5464
  OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
5465
+ OrderedSetPrototype.zipAll = IndexedCollectionPrototype.zipAll;
5136
5466
 
5137
5467
  OrderedSetPrototype.__empty = emptyOrderedSet;
5138
5468
  OrderedSetPrototype.__make = makeOrderedSet;
@@ -5152,11 +5482,33 @@ function emptyOrderedSet() {
5152
5482
  );
5153
5483
  }
5154
5484
 
5485
+ function throwOnInvalidDefaultValues(defaultValues) {
5486
+ if (isRecord(defaultValues)) {
5487
+ throw new Error(
5488
+ 'Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.'
5489
+ );
5490
+ }
5491
+
5492
+ if (isImmutable(defaultValues)) {
5493
+ throw new Error(
5494
+ 'Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.'
5495
+ );
5496
+ }
5497
+
5498
+ if (defaultValues === null || typeof defaultValues !== 'object') {
5499
+ throw new Error(
5500
+ 'Can not call `Record` with a non-object as default values. Use a plain javascript object instead.'
5501
+ );
5502
+ }
5503
+ }
5504
+
5155
5505
  var Record = function Record(defaultValues, name) {
5156
5506
  var hasInitialized;
5157
5507
 
5508
+ throwOnInvalidDefaultValues(defaultValues);
5509
+
5158
5510
  var RecordType = function Record(values) {
5159
- var this$1 = this;
5511
+ var this$1$1 = this;
5160
5512
 
5161
5513
  if (values instanceof RecordType) {
5162
5514
  return values;
@@ -5168,6 +5520,9 @@ var Record = function Record(defaultValues, name) {
5168
5520
  hasInitialized = true;
5169
5521
  var keys = Object.keys(defaultValues);
5170
5522
  var indices = (RecordTypePrototype._indices = {});
5523
+ // Deprecated: left to attempt not to break any external code which
5524
+ // relies on a ._name property existing on record instances.
5525
+ // Use Record.getDescriptiveName() instead
5171
5526
  RecordTypePrototype._name = name;
5172
5527
  RecordTypePrototype._keys = keys;
5173
5528
  RecordTypePrototype._defaultValues = defaultValues;
@@ -5180,7 +5535,7 @@ var Record = function Record(defaultValues, name) {
5180
5535
  console.warn &&
5181
5536
  console.warn(
5182
5537
  'Cannot define ' +
5183
- recordName(this$1) +
5538
+ recordName(this) +
5184
5539
  ' with property "' +
5185
5540
  propName +
5186
5541
  '" since that property name is part of the Record API.'
@@ -5193,40 +5548,39 @@ var Record = function Record(defaultValues, name) {
5193
5548
  }
5194
5549
  this.__ownerID = undefined;
5195
5550
  this._values = List().withMutations(function (l) {
5196
- l.setSize(this$1._keys.length);
5551
+ l.setSize(this$1$1._keys.length);
5197
5552
  KeyedCollection(values).forEach(function (v, k) {
5198
- l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
5553
+ l.set(this$1$1._indices[k], v === this$1$1._defaultValues[k] ? undefined : v);
5199
5554
  });
5200
5555
  });
5556
+ return this;
5201
5557
  };
5202
5558
 
5203
- var RecordTypePrototype = (RecordType.prototype = Object.create(
5204
- RecordPrototype
5205
- ));
5559
+ var RecordTypePrototype = (RecordType.prototype =
5560
+ Object.create(RecordPrototype));
5206
5561
  RecordTypePrototype.constructor = RecordType;
5207
5562
 
5563
+ if (name) {
5564
+ RecordType.displayName = name;
5565
+ }
5566
+
5208
5567
  return RecordType;
5209
5568
  };
5210
5569
 
5211
5570
  Record.prototype.toString = function toString () {
5212
- var this$1 = this;
5213
-
5214
5571
  var str = recordName(this) + ' { ';
5215
5572
  var keys = this._keys;
5216
5573
  var k;
5217
5574
  for (var i = 0, l = keys.length; i !== l; i++) {
5218
5575
  k = keys[i];
5219
- str += (i ? ', ' : '') + k + ': ' + quoteString(this$1.get(k));
5576
+ str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
5220
5577
  }
5221
5578
  return str + ' }';
5222
5579
  };
5223
5580
 
5224
5581
  Record.prototype.equals = function equals (other) {
5225
5582
  return (
5226
- this === other ||
5227
- (other &&
5228
- this._keys === other._keys &&
5229
- recordSeq(this).equals(recordSeq(other)))
5583
+ this === other || (other && recordSeq(this).equals(recordSeq(other)))
5230
5584
  );
5231
5585
  };
5232
5586
 
@@ -5270,6 +5624,7 @@ Record.prototype.remove = function remove (k) {
5270
5624
 
5271
5625
  Record.prototype.clear = function clear () {
5272
5626
  var newValues = this._values.clear().setSize(this._keys.length);
5627
+
5273
5628
  return this.__ownerID ? this : makeRecord(this, newValues);
5274
5629
  };
5275
5630
 
@@ -5281,8 +5636,12 @@ Record.prototype.toSeq = function toSeq () {
5281
5636
  return recordSeq(this);
5282
5637
  };
5283
5638
 
5284
- Record.prototype.toJS = function toJS () {
5285
- return recordSeq(this).toJS();
5639
+ Record.prototype.toJS = function toJS$1 () {
5640
+ return toJS(this);
5641
+ };
5642
+
5643
+ Record.prototype.entries = function entries () {
5644
+ return this.__iterator(ITERATE_ENTRIES);
5286
5645
  };
5287
5646
 
5288
5647
  Record.prototype.__iterator = function __iterator (type, reverse) {
@@ -5309,28 +5668,29 @@ Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
5309
5668
  Record.isRecord = isRecord;
5310
5669
  Record.getDescriptiveName = recordName;
5311
5670
  var RecordPrototype = Record.prototype;
5312
- RecordPrototype[IS_RECORD_SENTINEL] = true;
5671
+ RecordPrototype[IS_RECORD_SYMBOL] = true;
5313
5672
  RecordPrototype[DELETE] = RecordPrototype.remove;
5314
- RecordPrototype.deleteIn = RecordPrototype.removeIn = MapPrototype.removeIn;
5315
- RecordPrototype.getIn = CollectionPrototype.getIn;
5673
+ RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
5674
+ RecordPrototype.getIn = getIn;
5316
5675
  RecordPrototype.hasIn = CollectionPrototype.hasIn;
5317
- RecordPrototype.merge = MapPrototype.merge;
5318
- RecordPrototype.mergeWith = MapPrototype.mergeWith;
5319
- RecordPrototype.mergeIn = MapPrototype.mergeIn;
5320
- RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
5321
- RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
5322
- RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
5323
- RecordPrototype.setIn = MapPrototype.setIn;
5324
- RecordPrototype.update = MapPrototype.update;
5325
- RecordPrototype.updateIn = MapPrototype.updateIn;
5326
- RecordPrototype.withMutations = MapPrototype.withMutations;
5327
- RecordPrototype.asMutable = MapPrototype.asMutable;
5328
- RecordPrototype.asImmutable = MapPrototype.asImmutable;
5329
- RecordPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
5676
+ RecordPrototype.merge = merge$1;
5677
+ RecordPrototype.mergeWith = mergeWith$1;
5678
+ RecordPrototype.mergeIn = mergeIn;
5679
+ RecordPrototype.mergeDeep = mergeDeep;
5680
+ RecordPrototype.mergeDeepWith = mergeDeepWith;
5681
+ RecordPrototype.mergeDeepIn = mergeDeepIn;
5682
+ RecordPrototype.setIn = setIn;
5683
+ RecordPrototype.update = update;
5684
+ RecordPrototype.updateIn = updateIn;
5685
+ RecordPrototype.withMutations = withMutations;
5686
+ RecordPrototype.asMutable = asMutable;
5687
+ RecordPrototype.asImmutable = asImmutable;
5688
+ RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
5330
5689
  RecordPrototype.toJSON = RecordPrototype.toObject =
5331
5690
  CollectionPrototype.toObject;
5332
- RecordPrototype.inspect = RecordPrototype.toSource =
5333
- CollectionPrototype.toSource;
5691
+ RecordPrototype.inspect = RecordPrototype.toSource = function () {
5692
+ return this.toString();
5693
+ };
5334
5694
 
5335
5695
  function makeRecord(likeRecord, values, ownerID) {
5336
5696
  var record = Object.create(Object.getPrototypeOf(likeRecord));
@@ -5340,7 +5700,7 @@ function makeRecord(likeRecord, values, ownerID) {
5340
5700
  }
5341
5701
 
5342
5702
  function recordName(record) {
5343
- return record._name || record.constructor.name || 'Record';
5703
+ return record.constructor.displayName || record.constructor.name || 'Record';
5344
5704
  }
5345
5705
 
5346
5706
  function recordSeq(record) {
@@ -5350,13 +5710,13 @@ function recordSeq(record) {
5350
5710
  function setProp(prototype, name) {
5351
5711
  try {
5352
5712
  Object.defineProperty(prototype, name, {
5353
- get: function() {
5713
+ get: function () {
5354
5714
  return this.get(name);
5355
5715
  },
5356
- set: function(value) {
5716
+ set: function (value) {
5357
5717
  invariant(this.__ownerID, 'Cannot set on an immutable record.');
5358
5718
  this.set(name, value);
5359
- }
5719
+ },
5360
5720
  });
5361
5721
  } catch (error) {
5362
5722
  // Object.defineProperty failed. Probably IE8.
@@ -5367,7 +5727,7 @@ function setProp(prototype, name) {
5367
5727
  * Returns a lazy Seq of `value` repeated `times` times. When `times` is
5368
5728
  * undefined, returns an infinite sequence of `value`.
5369
5729
  */
5370
- var Repeat = (function (IndexedSeq$$1) {
5730
+ var Repeat = /*@__PURE__*/(function (IndexedSeq) {
5371
5731
  function Repeat(value, times) {
5372
5732
  if (!(this instanceof Repeat)) {
5373
5733
  return new Repeat(value, times);
@@ -5382,8 +5742,8 @@ var Repeat = (function (IndexedSeq$$1) {
5382
5742
  }
5383
5743
  }
5384
5744
 
5385
- if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
5386
- Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
5745
+ if ( IndexedSeq ) Repeat.__proto__ = IndexedSeq;
5746
+ Repeat.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
5387
5747
  Repeat.prototype.constructor = Repeat;
5388
5748
 
5389
5749
  Repeat.prototype.toString = function toString () {
@@ -5430,12 +5790,10 @@ var Repeat = (function (IndexedSeq$$1) {
5430
5790
  };
5431
5791
 
5432
5792
  Repeat.prototype.__iterate = function __iterate (fn, reverse) {
5433
- var this$1 = this;
5434
-
5435
5793
  var size = this.size;
5436
5794
  var i = 0;
5437
5795
  while (i !== size) {
5438
- if (fn(this$1._value, reverse ? size - ++i : i++, this$1) === false) {
5796
+ if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
5439
5797
  break;
5440
5798
  }
5441
5799
  }
@@ -5443,14 +5801,13 @@ var Repeat = (function (IndexedSeq$$1) {
5443
5801
  };
5444
5802
 
5445
5803
  Repeat.prototype.__iterator = function __iterator (type, reverse) {
5446
- var this$1 = this;
5804
+ var this$1$1 = this;
5447
5805
 
5448
5806
  var size = this.size;
5449
5807
  var i = 0;
5450
- return new Iterator(
5451
- function () { return i === size
5452
- ? iteratorDone()
5453
- : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
5808
+ return new Iterator(function () { return i === size
5809
+ ? iteratorDone()
5810
+ : iteratorValue(type, reverse ? size - ++i : i++, this$1$1._value); }
5454
5811
  );
5455
5812
  };
5456
5813
 
@@ -5477,10 +5834,11 @@ function fromJS(value, converter) {
5477
5834
  }
5478
5835
 
5479
5836
  function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
5480
- var toSeq = Array.isArray(value)
5481
- ? IndexedSeq
5482
- : isPlainObj(value) ? KeyedSeq : null;
5483
- if (toSeq) {
5837
+ if (
5838
+ typeof value !== 'string' &&
5839
+ !isImmutable(value) &&
5840
+ (isArrayLike(value) || hasIterator(value) || isPlainObject(value))
5841
+ ) {
5484
5842
  if (~stack.indexOf(value)) {
5485
5843
  throw new TypeError('Cannot convert circular structure to Immutable');
5486
5844
  }
@@ -5489,7 +5847,7 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
5489
5847
  var converted = converter.call(
5490
5848
  parentValue,
5491
5849
  key,
5492
- toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
5850
+ Seq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
5493
5851
  ),
5494
5852
  keyPath && keyPath.slice()
5495
5853
  );
@@ -5501,16 +5859,11 @@ function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
5501
5859
  }
5502
5860
 
5503
5861
  function defaultConverter(k, v) {
5504
- return isKeyed(v) ? v.toMap() : v.toList();
5505
- }
5506
-
5507
- function isPlainObj(value) {
5508
- return (
5509
- value && (value.constructor === Object || value.constructor === undefined)
5510
- );
5862
+ // Effectively the opposite of "Collection.toSeq()"
5863
+ return isIndexed(v) ? v.toList() : isKeyed(v) ? v.toMap() : v.toSet();
5511
5864
  }
5512
5865
 
5513
- var version = "4.0.0-rc.6";
5866
+ var version = "4.0.0";
5514
5867
 
5515
5868
  var Immutable = {
5516
5869
  version: version,
@@ -5541,11 +5894,35 @@ var Immutable = {
5541
5894
  isIndexed: isIndexed,
5542
5895
  isAssociative: isAssociative,
5543
5896
  isOrdered: isOrdered,
5544
- isValueObject: isValueObject
5897
+ isValueObject: isValueObject,
5898
+ isPlainObject: isPlainObject,
5899
+ isSeq: isSeq,
5900
+ isList: isList,
5901
+ isMap: isMap,
5902
+ isOrderedMap: isOrderedMap,
5903
+ isStack: isStack,
5904
+ isSet: isSet,
5905
+ isOrderedSet: isOrderedSet,
5906
+ isRecord: isRecord,
5907
+
5908
+ get: get,
5909
+ getIn: getIn$1,
5910
+ has: has,
5911
+ hasIn: hasIn$1,
5912
+ merge: merge,
5913
+ mergeDeep: mergeDeep$1,
5914
+ mergeWith: mergeWith,
5915
+ mergeDeepWith: mergeDeepWith$1,
5916
+ remove: remove,
5917
+ removeIn: removeIn,
5918
+ set: set,
5919
+ setIn: setIn$1,
5920
+ update: update$1,
5921
+ updateIn: updateIn$1,
5545
5922
  };
5546
5923
 
5547
5924
  // Note: Iterable is deprecated
5548
5925
  var Iterable = Collection;
5549
5926
 
5550
- export { version, Collection, Iterable, Seq, Map, OrderedMap, List, Stack, Set, OrderedSet, Record, Range, Repeat, is, fromJS, hash, isImmutable, isCollection, isKeyed, isIndexed, isAssociative, isOrdered, isValueObject };
5551
5927
  export default Immutable;
5928
+ export { Collection, Iterable, List, Map, OrderedMap, OrderedSet, Range, Record, Repeat, Seq, Set, Stack, fromJS, get, getIn$1 as getIn, has, hasIn$1 as hasIn, hash, is, isAssociative, isCollection, isImmutable, isIndexed, isKeyed, isList, isMap, isOrdered, isOrderedMap, isOrderedSet, isPlainObject, isRecord, isSeq, isSet, isStack, isValueObject, merge, mergeDeep$1 as mergeDeep, mergeDeepWith$1 as mergeDeepWith, mergeWith, remove, removeIn, set, setIn$1 as setIn, update$1 as update, updateIn$1 as updateIn, version };