Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03k
1/**2 * @license3 * MIT License4 * 5 * Copyright (c) 2014-present, Lee Byron and other contributors.6 * 7 * Permission is hereby granted, free of charge, to any person obtaining a copy8 * of this software and associated documentation files (the "Software"), to deal9 * in the Software without restriction, including without limitation the rights10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell11 * copies of the Software, and to permit persons to whom the Software is12 * furnished to do so, subject to the following conditions:13 * 14 * The above copyright notice and this permission notice shall be included in all15 * copies or substantial portions of the Software.16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23 * SOFTWARE.24 */25(function (global, factory) {26 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :27 typeof define === 'function' && define.amd ? define(['exports'], factory) :28 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Immutable = {}));29})(this, (function (exports) { 'use strict';30 31 var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';32 /**33 * True if `maybeIndexed` is a Collection.Indexed, or any of its subclasses.34 *35 * ```js36 * import { isIndexed, Map, List, Stack, Set } from 'immutable';37 *38 * isIndexed([]); // false39 * isIndexed({}); // false40 * isIndexed(Map()); // false41 * isIndexed(List()); // true42 * isIndexed(Stack()); // true43 * isIndexed(Set()); // false44 * ```45 */46 function isIndexed(maybeIndexed) {47 return Boolean(maybeIndexed &&48 // @ts-expect-error: maybeIndexed is typed as `{}`, need to change in 6.0 to `maybeIndexed && typeof maybeIndexed === 'object' && IS_INDEXED_SYMBOL in maybeIndexed`49 maybeIndexed[IS_INDEXED_SYMBOL]);50 }51 52 var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';53 /**54 * True if `maybeKeyed` is a Collection.Keyed, or any of its subclasses.55 *56 * ```js57 * import { isKeyed, Map, List, Stack } from 'immutable';58 *59 * isKeyed([]); // false60 * isKeyed({}); // false61 * isKeyed(Map()); // true62 * isKeyed(List()); // false63 * isKeyed(Stack()); // false64 * ```65 */66 function isKeyed(maybeKeyed) {67 return Boolean(maybeKeyed &&68 // @ts-expect-error: maybeKeyed is typed as `{}`, need to change in 6.0 to `maybeKeyed && typeof maybeKeyed === 'object' && IS_KEYED_SYMBOL in maybeKeyed`69 maybeKeyed[IS_KEYED_SYMBOL]);70 }71 72 /**73 * True if `maybeAssociative` is either a Keyed or Indexed Collection.74 *75 * ```js76 * import { isAssociative, Map, List, Stack, Set } from 'immutable';77 *78 * isAssociative([]); // false79 * isAssociative({}); // false80 * isAssociative(Map()); // true81 * isAssociative(List()); // true82 * isAssociative(Stack()); // true83 * isAssociative(Set()); // false84 * ```85 */86 function isAssociative(maybeAssociative) {87 return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);88 }89 90 // Note: value is unchanged to not break immutable-devtools.91 var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';92 /**93 * True if `maybeCollection` is a Collection, or any of its subclasses.94 *95 * ```js96 * import { isCollection, Map, List, Stack } from 'immutable';97 *98 * isCollection([]); // false99 * isCollection({}); // false100 * isCollection(Map()); // true101 * isCollection(List()); // true102 * isCollection(Stack()); // true103 * ```104 */105 function isCollection(maybeCollection) {106 return Boolean(maybeCollection &&107 // @ts-expect-error: maybeCollection is typed as `{}`, need to change in 6.0 to `maybeCollection && typeof maybeCollection === 'object' && IS_COLLECTION_SYMBOL in maybeCollection`108 maybeCollection[IS_COLLECTION_SYMBOL]);109 }110 111 var Collection = function Collection(value) {112 // eslint-disable-next-line no-constructor-return113 return isCollection(value) ? value : Seq(value);114 };115 116 var KeyedCollection = /*@__PURE__*/(function (Collection) {117 function KeyedCollection(value) {118 // eslint-disable-next-line no-constructor-return119 return isKeyed(value) ? value : KeyedSeq(value);120 }121 122 if ( Collection ) KeyedCollection.__proto__ = Collection;123 KeyedCollection.prototype = Object.create( Collection && Collection.prototype );124 KeyedCollection.prototype.constructor = KeyedCollection;125 126 return KeyedCollection;127 }(Collection));128 129 var IndexedCollection = /*@__PURE__*/(function (Collection) {130 function IndexedCollection(value) {131 // eslint-disable-next-line no-constructor-return132 return isIndexed(value) ? value : IndexedSeq(value);133 }134 135 if ( Collection ) IndexedCollection.__proto__ = Collection;136 IndexedCollection.prototype = Object.create( Collection && Collection.prototype );137 IndexedCollection.prototype.constructor = IndexedCollection;138 139 return IndexedCollection;140 }(Collection));141 142 var SetCollection = /*@__PURE__*/(function (Collection) {143 function SetCollection(value) {144 // eslint-disable-next-line no-constructor-return145 return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);146 }147 148 if ( Collection ) SetCollection.__proto__ = Collection;149 SetCollection.prototype = Object.create( Collection && Collection.prototype );150 SetCollection.prototype.constructor = SetCollection;151 152 return SetCollection;153 }(Collection));154 155 Collection.Keyed = KeyedCollection;156 Collection.Indexed = IndexedCollection;157 Collection.Set = SetCollection;158 159 var ITERATE_KEYS = 0;160 var ITERATE_VALUES = 1;161 var ITERATE_ENTRIES = 2;162 // TODO Symbol is widely available in modern JavaScript environments, clean this163 var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;164 var FAUX_ITERATOR_SYMBOL = '@@iterator';165 var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;166 // @ts-expect-error: properties are not supported in buble167 var Iterator = function Iterator(next) {168 // @ts-expect-error: properties are not supported in buble169 this.next = next;170 };171 Iterator.prototype.toString = function toString () {172 return '[Iterator]';173 };174 // @ts-expect-error: static properties are not supported in buble175 Iterator.KEYS = ITERATE_KEYS;176 // @ts-expect-error: static properties are not supported in buble177 Iterator.VALUES = ITERATE_VALUES;178 // @ts-expect-error: static properties are not supported in buble179 Iterator.ENTRIES = ITERATE_ENTRIES;180 // @ts-expect-error: properties are not supported in buble181 Iterator.prototype.inspect = Iterator.prototype.toSource = function () {182 return this.toString();183 };184 // @ts-expect-error don't know how to type this185 Iterator.prototype[ITERATOR_SYMBOL] = function () {186 return this;187 };188 function iteratorValue(type, k, v, iteratorResult) {189 var value = type === ITERATE_KEYS ? k : type === ITERATE_VALUES ? v : [k, v];190 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here191 iteratorResult192 ? (iteratorResult.value = value)193 : (iteratorResult = {194 // @ts-expect-error ensure value is not undefined195 value: value,196 done: false,197 });198 return iteratorResult;199 }200 function iteratorDone() {201 return { value: undefined, done: true };202 }203 function hasIterator(maybeIterable) {204 if (Array.isArray(maybeIterable)) {205 // IE11 trick as it does not support `Symbol.iterator`206 return true;207 }208 return !!getIteratorFn(maybeIterable);209 }210 function isIterator(maybeIterator) {211 return !!(maybeIterator &&212 // @ts-expect-error: maybeIterator is typed as `{}`213 typeof maybeIterator.next === 'function');214 }215 function getIterator(iterable) {216 var iteratorFn = getIteratorFn(iterable);217 return iteratorFn && iteratorFn.call(iterable);218 }219 function getIteratorFn(iterable) {220 var iteratorFn = iterable &&221 // @ts-expect-error: maybeIterator is typed as `{}`222 ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||223 // @ts-expect-error: maybeIterator is typed as `{}`224 iterable[FAUX_ITERATOR_SYMBOL]);225 if (typeof iteratorFn === 'function') {226 return iteratorFn;227 }228 }229 function isEntriesIterable(maybeIterable) {230 var iteratorFn = getIteratorFn(maybeIterable);231 // @ts-expect-error: maybeIterator is typed as `{}`232 return iteratorFn && iteratorFn === maybeIterable.entries;233 }234 function isKeysIterable(maybeIterable) {235 var iteratorFn = getIteratorFn(maybeIterable);236 // @ts-expect-error: maybeIterator is typed as `{}`237 return iteratorFn && iteratorFn === maybeIterable.keys;238 }239 240 // Used for setting prototype methods that IE8 chokes on.241 var DELETE = 'delete';242 // Constants describing the size of trie nodes.243 var SHIFT = 5; // Resulted in best performance after ______?244 var SIZE = 1 << SHIFT;245 var MASK = SIZE - 1;246 // A consistent shared value representing "not set" which equals nothing other247 // than itself, and nothing that could be provided externally.248 var NOT_SET = {};249 // Boolean references, Rough equivalent of `bool &`.250 function MakeRef() {251 return { value: false };252 }253 function SetRef(ref) {254 if (ref) {255 ref.value = true;256 }257 }258 // A function which returns a value representing an "owner" for transient writes259 // to tries. The return value will only ever equal itself, and will not equal260 // the return of any subsequent call of this function.261 function OwnerID() { }262 function ensureSize(iter) {263 // @ts-expect-error size should exists on Collection264 if (iter.size === undefined) {265 // @ts-expect-error size should exists on Collection, __iterate does exist on Collection266 iter.size = iter.__iterate(returnTrue);267 }268 // @ts-expect-error size should exists on Collection269 return iter.size;270 }271 function wrapIndex(iter, index) {272 // This implements "is array index" which the ECMAString spec defines as:273 //274 // A String property name P is an array index if and only if275 // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal276 // to 2^32−1.277 //278 // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects279 if (typeof index !== 'number') {280 var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32281 if ('' + uint32Index !== index || uint32Index === 4294967295) {282 return NaN;283 }284 index = uint32Index;285 }286 return index < 0 ? ensureSize(iter) + index : index;287 }288 function returnTrue() {289 return true;290 }291 function wholeSlice(begin, end, size) {292 return (((begin === 0 && !isNeg(begin)) ||293 (size !== undefined && begin <= -size)) &&294 (end === undefined || (size !== undefined && end >= size)));295 }296 function resolveBegin(begin, size) {297 return resolveIndex(begin, size, 0);298 }299 function resolveEnd(end, size) {300 return resolveIndex(end, size, size);301 }302 function resolveIndex(index, size, defaultIndex) {303 // Sanitize indices using this shorthand for ToInt32(argument)304 // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32305 return index === undefined306 ? defaultIndex307 : isNeg(index)308 ? size === Infinity309 ? size310 : Math.max(0, size + index) | 0311 : size === undefined || size === index312 ? index313 : Math.min(size, index) | 0;314 }315 function isNeg(value) {316 // Account for -0 which is negative, but not less than 0.317 return value < 0 || (value === 0 && 1 / value === -Infinity);318 }319 320 var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';321 /**322 * True if `maybeRecord` is a Record.323 */324 function isRecord(maybeRecord) {325 return Boolean(maybeRecord &&326 // @ts-expect-error: maybeRecord is typed as `{}`, need to change in 6.0 to `maybeRecord && typeof maybeRecord === 'object' && IS_RECORD_SYMBOL in maybeRecord`327 maybeRecord[IS_RECORD_SYMBOL]);328 }329 330 /**331 * True if `maybeImmutable` is an Immutable Collection or Record.332 *333 * Note: Still returns true even if the collections is within a `withMutations()`.334 *335 * ```js336 * import { isImmutable, Map, List, Stack } from 'immutable';337 * isImmutable([]); // false338 * isImmutable({}); // false339 * isImmutable(Map()); // true340 * isImmutable(List()); // true341 * isImmutable(Stack()); // true342 * isImmutable(Map().asMutable()); // true343 * ```344 */345 function isImmutable(maybeImmutable) {346 return isCollection(maybeImmutable) || isRecord(maybeImmutable);347 }348 349 var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';350 function isOrdered(maybeOrdered) {351 return Boolean(maybeOrdered &&352 // @ts-expect-error: maybeOrdered is typed as `{}`, need to change in 6.0 to `maybeOrdered && typeof maybeOrdered === 'object' && IS_ORDERED_SYMBOL in maybeOrdered`353 maybeOrdered[IS_ORDERED_SYMBOL]);354 }355 356 var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';357 /**358 * True if `maybeSeq` is a Seq.359 */360 function isSeq(maybeSeq) {361 return Boolean(maybeSeq &&362 // @ts-expect-error: maybeSeq is typed as `{}`, need to change in 6.0 to `maybeSeq && typeof maybeSeq === 'object' && MAYBE_SEQ_SYMBOL in maybeSeq`363 maybeSeq[IS_SEQ_SYMBOL]);364 }365 366 var hasOwnProperty = Object.prototype.hasOwnProperty;367 368 function isArrayLike(value) {369 if (Array.isArray(value) || typeof value === 'string') {370 return true;371 }372 // @ts-expect-error "Type 'unknown' is not assignable to type 'boolean'" : convert to Boolean373 return (value &&374 typeof value === 'object' &&375 // @ts-expect-error check that `'length' in value &&`376 Number.isInteger(value.length) &&377 // @ts-expect-error check that `'length' in value &&`378 value.length >= 0 &&379 // @ts-expect-error check that `'length' in value &&`380 (value.length === 0381 ? // Only {length: 0} is considered Array-like.382 Object.keys(value).length === 1383 : // An object is only Array-like if it has a property where the last value384 // in the array-like may be found (which could be undefined).385 // @ts-expect-error check that `'length' in value &&`386 value.hasOwnProperty(value.length - 1)));387 }388 389 var Seq = /*@__PURE__*/(function (Collection) {390 function Seq(value) {391 // eslint-disable-next-line no-constructor-return392 return value === undefined || value === null393 ? emptySequence()394 : isImmutable(value)395 ? value.toSeq()396 : seqFromValue(value);397 }398 399 if ( Collection ) Seq.__proto__ = Collection;400 Seq.prototype = Object.create( Collection && Collection.prototype );401 Seq.prototype.constructor = Seq;402 403 Seq.prototype.toSeq = function toSeq () {404 return this;405 };406 407 Seq.prototype.toString = function toString () {408 return this.__toString('Seq {', '}');409 };410 411 Seq.prototype.cacheResult = function cacheResult () {412 if (!this._cache && this.__iterateUncached) {413 this._cache = this.entrySeq().toArray();414 this.size = this._cache.length;415 }416 return this;417 };418 419 // abstract __iterateUncached(fn, reverse)420 421 Seq.prototype.__iterate = function __iterate (fn, reverse) {422 var cache = this._cache;423 if (cache) {424 var size = cache.length;425 var i = 0;426 while (i !== size) {427 var entry = cache[reverse ? size - ++i : i++];428 if (fn(entry[1], entry[0], this) === false) {429 break;430 }431 }432 return i;433 }434 return this.__iterateUncached(fn, reverse);435 };436 437 // abstract __iteratorUncached(type, reverse)438 439 Seq.prototype.__iterator = function __iterator (type, reverse) {440 var cache = this._cache;441 if (cache) {442 var size = cache.length;443 var i = 0;444 return new Iterator(function () {445 if (i === size) {446 return iteratorDone();447 }448 var entry = cache[reverse ? size - ++i : i++];449 return iteratorValue(type, entry[0], entry[1]);450 });451 }452 return this.__iteratorUncached(type, reverse);453 };454 455 return Seq;456 }(Collection));457 458 var KeyedSeq = /*@__PURE__*/(function (Seq) {459 function KeyedSeq(value) {460 // eslint-disable-next-line no-constructor-return461 return value === undefined || value === null462 ? emptySequence().toKeyedSeq()463 : isCollection(value)464 ? isKeyed(value)465 ? value.toSeq()466 : value.fromEntrySeq()467 : isRecord(value)468 ? value.toSeq()469 : keyedSeqFromValue(value);470 }471 472 if ( Seq ) KeyedSeq.__proto__ = Seq;473 KeyedSeq.prototype = Object.create( Seq && Seq.prototype );474 KeyedSeq.prototype.constructor = KeyedSeq;475 476 KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {477 return this;478 };479 480 return KeyedSeq;481 }(Seq));482 483 var IndexedSeq = /*@__PURE__*/(function (Seq) {484 function IndexedSeq(value) {485 // eslint-disable-next-line no-constructor-return486 return value === undefined || value === null487 ? emptySequence()488 : isCollection(value)489 ? isKeyed(value)490 ? value.entrySeq()491 : value.toIndexedSeq()492 : isRecord(value)493 ? value.toSeq().entrySeq()494 : indexedSeqFromValue(value);495 }496 497 if ( Seq ) IndexedSeq.__proto__ = Seq;498 IndexedSeq.prototype = Object.create( Seq && Seq.prototype );499 IndexedSeq.prototype.constructor = IndexedSeq;500 501 IndexedSeq.of = function of (/*...values*/) {502 return IndexedSeq(arguments);503 };504 505 IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {506 return this;507 };508 509 IndexedSeq.prototype.toString = function toString () {510 return this.__toString('Seq [', ']');511 };512 513 return IndexedSeq;514 }(Seq));515 516 var SetSeq = /*@__PURE__*/(function (Seq) {517 function SetSeq(value) {518 // eslint-disable-next-line no-constructor-return519 return (520 isCollection(value) && !isAssociative(value) ? value : IndexedSeq(value)521 ).toSetSeq();522 }523 524 if ( Seq ) SetSeq.__proto__ = Seq;525 SetSeq.prototype = Object.create( Seq && Seq.prototype );526 SetSeq.prototype.constructor = SetSeq;527 528 SetSeq.of = function of (/*...values*/) {529 return SetSeq(arguments);530 };531 532 SetSeq.prototype.toSetSeq = function toSetSeq () {533 return this;534 };535 536 return SetSeq;537 }(Seq));538 539 Seq.isSeq = isSeq;540 Seq.Keyed = KeyedSeq;541 Seq.Set = SetSeq;542 Seq.Indexed = IndexedSeq;543 544 Seq.prototype[IS_SEQ_SYMBOL] = true;545 546 // #pragma Root Sequences547 548 var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {549 function ArraySeq(array) {550 this._array = array;551 this.size = array.length;552 }553 554 if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;555 ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );556 ArraySeq.prototype.constructor = ArraySeq;557 558 ArraySeq.prototype.get = function get (index, notSetValue) {559 return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;560 };561 562 ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {563 var array = this._array;564 var size = array.length;565 var i = 0;566 while (i !== size) {567 var ii = reverse ? size - ++i : i++;568 if (fn(array[ii], ii, this) === false) {569 break;570 }571 }572 return i;573 };574 575 ArraySeq.prototype.__iterator = function __iterator (type, reverse) {576 var array = this._array;577 var size = array.length;578 var i = 0;579 return new Iterator(function () {580 if (i === size) {581 return iteratorDone();582 }583 var ii = reverse ? size - ++i : i++;584 return iteratorValue(type, ii, array[ii]);585 });586 };587 588 return ArraySeq;589 }(IndexedSeq));590 591 var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {592 function ObjectSeq(object) {593 var keys = Object.keys(object).concat(594 Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : []595 );596 this._object = object;597 this._keys = keys;598 this.size = keys.length;599 }600 601 if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;602 ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );603 ObjectSeq.prototype.constructor = ObjectSeq;604 605 ObjectSeq.prototype.get = function get (key, notSetValue) {606 if (notSetValue !== undefined && !this.has(key)) {607 return notSetValue;608 }609 return this._object[key];610 };611 612 ObjectSeq.prototype.has = function has (key) {613 return hasOwnProperty.call(this._object, key);614 };615 616 ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {617 var object = this._object;618 var keys = this._keys;619 var size = keys.length;620 var i = 0;621 while (i !== size) {622 var key = keys[reverse ? size - ++i : i++];623 if (fn(object[key], key, this) === false) {624 break;625 }626 }627 return i;628 };629 630 ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {631 var object = this._object;632 var keys = this._keys;633 var size = keys.length;634 var i = 0;635 return new Iterator(function () {636 if (i === size) {637 return iteratorDone();638 }639 var key = keys[reverse ? size - ++i : i++];640 return iteratorValue(type, key, object[key]);641 });642 };643 644 return ObjectSeq;645 }(KeyedSeq));646 ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;647 648 var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {649 function CollectionSeq(collection) {650 this._collection = collection;651 this.size = collection.length || collection.size;652 }653 654 if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;655 CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );656 CollectionSeq.prototype.constructor = CollectionSeq;657 658 CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {659 if (reverse) {660 return this.cacheResult().__iterate(fn, reverse);661 }662 var collection = this._collection;663 var iterator = getIterator(collection);664 var iterations = 0;665 if (isIterator(iterator)) {666 var step;667 while (!(step = iterator.next()).done) {668 if (fn(step.value, iterations++, this) === false) {669 break;670 }671 }672 }673 return iterations;674 };675 676 CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {677 if (reverse) {678 return this.cacheResult().__iterator(type, reverse);679 }680 var collection = this._collection;681 var iterator = getIterator(collection);682 if (!isIterator(iterator)) {683 return new Iterator(iteratorDone);684 }685 var iterations = 0;686 return new Iterator(function () {687 var step = iterator.next();688 return step.done ? step : iteratorValue(type, iterations++, step.value);689 });690 };691 692 return CollectionSeq;693 }(IndexedSeq));694 695 // # pragma Helper functions696 697 var EMPTY_SEQ;698 699 function emptySequence() {700 return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));701 }702 703 function keyedSeqFromValue(value) {704 var seq = maybeIndexedSeqFromValue(value);705 if (seq) {706 return seq.fromEntrySeq();707 }708 if (typeof value === 'object') {709 return new ObjectSeq(value);710 }711 throw new TypeError(712 'Expected Array or collection object of [k, v] entries, or keyed object: ' +713 value714 );715 }716 717 function indexedSeqFromValue(value) {718 var seq = maybeIndexedSeqFromValue(value);719 if (seq) {720 return seq;721 }722 throw new TypeError(723 'Expected Array or collection object of values: ' + value724 );725 }726 727 function seqFromValue(value) {728 var seq = maybeIndexedSeqFromValue(value);729 if (seq) {730 return isEntriesIterable(value)731 ? seq.fromEntrySeq()732 : isKeysIterable(value)733 ? seq.toSetSeq()734 : seq;735 }736 if (typeof value === 'object') {737 return new ObjectSeq(value);738 }739 throw new TypeError(740 'Expected Array or collection object of values, or keyed object: ' + value741 );742 }743 744 function maybeIndexedSeqFromValue(value) {745 return isArrayLike(value)746 ? new ArraySeq(value)747 : hasIterator(value)748 ? new CollectionSeq(value)749 : undefined;750 }751 752 function asImmutable() {753 return this.__ensureOwner();754 }755 756 function asMutable() {757 return this.__ownerID ? this : this.__ensureOwner(new OwnerID());758 }759 760 // TODO remove in v6 as Math.imul is widely available now: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul761 var imul = typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2762 ? Math.imul763 : function imul(a, b) {764 a |= 0; // int765 b |= 0; // int766 var c = a & 0xffff;767 var d = b & 0xffff;768 // Shift by 0 fixes the sign on the high part.769 return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int770 };771 // v8 has an optimization for storing 31-bit signed numbers.772 // Values which have either 00 or 11 as the high order bits qualify.773 // This function drops the highest order bit in a signed number, maintaining774 // the sign bit.775 function smi(i32) {776 return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);777 }778 779 var defaultValueOf = Object.prototype.valueOf;780 function hash(o) {781 // eslint-disable-next-line eqeqeq782 if (o == null) {783 return hashNullish(o);784 }785 // @ts-expect-error don't care about object beeing typed as `{}` here786 if (typeof o.hashCode === 'function') {787 // Drop any high bits from accidentally long hash codes.788 // @ts-expect-error don't care about object beeing typed as `{}` here789 return smi(o.hashCode(o));790 }791 var v = valueOf(o);792 // eslint-disable-next-line eqeqeq793 if (v == null) {794 return hashNullish(v);795 }796 switch (typeof v) {797 case 'boolean':798 // The hash values for built-in constants are a 1 value for each 5-byte799 // shift region expect for the first, which encodes the value. This800 // reduces the odds of a hash collision for these common values.801 return v ? 0x42108421 : 0x42108420;802 case 'number':803 return hashNumber(v);804 case 'string':805 return v.length > STRING_HASH_CACHE_MIN_STRLEN806 ? cachedHashString(v)807 : hashString(v);808 case 'object':809 case 'function':810 return hashJSObj(v);811 case 'symbol':812 return hashSymbol(v);813 default:814 if (typeof v.toString === 'function') {815 return hashString(v.toString());816 }817 throw new Error('Value type ' + typeof v + ' cannot be hashed.');818 }819 }820 function hashNullish(nullish) {821 return nullish === null ? 0x42108422 : /* undefined */ 0x42108423;822 }823 // Compress arbitrarily large numbers into smi hashes.824 function hashNumber(n) {825 if (n !== n || n === Infinity) {826 return 0;827 }828 var hash = n | 0;829 if (hash !== n) {830 hash ^= n * 0xffffffff;831 }832 while (n > 0xffffffff) {833 n /= 0xffffffff;834 hash ^= n;835 }836 return smi(hash);837 }838 function cachedHashString(string) {839 var hashed = stringHashCache[string];840 if (hashed === undefined) {841 hashed = hashString(string);842 if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {843 STRING_HASH_CACHE_SIZE = 0;844 stringHashCache = {};845 }846 STRING_HASH_CACHE_SIZE++;847 stringHashCache[string] = hashed;848 }849 return hashed;850 }851 // http://jsperf.com/hashing-strings852 function hashString(string) {853 // This is the hash from JVM854 // The hash code for a string is computed as855 // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],856 // where s[i] is the ith character of the string and n is the length of857 // the string. We "mod" the result to make it between 0 (inclusive) and 2^31858 // (exclusive) by dropping high bits.859 var hashed = 0;860 for (var ii = 0; ii < string.length; ii++) {861 hashed = (31 * hashed + string.charCodeAt(ii)) | 0;862 }863 return smi(hashed);864 }865 // Per-process seed for the secondary collision hash. Never exposed nor866 // serialized, so the public `hash()` stays deterministic. An odd base in867 // [3, 2^20) keeps `base * h` exact as a double (no `Math.imul`).868 var COLLISION_HASH_BASE = ((Math.random() * 0x100000) | 1) % 0x100000 || 0x9e37;869 // Secondary hash to index entries within a `HashCollisionNode`, where every key870 // shares the same primary `hash()`. Using a different, seeded base scatters871 // crafted collision families (e.g. "Aa"/"BB", which only collide under base 31)872 // that an attacker cannot precompute without the seed. It only narrows873 // candidates — `is()` still decides equality — so non-string keys can safely874 // fall back to the (here constant) primary hash and a linear scan.875 function hashCollisionKey(key) {876 if (typeof key !== 'string') {877 return hash(key);878 }879 var hashed = 0;880 for (var ii = 0; ii < key.length; ii++) {881 hashed = (COLLISION_HASH_BASE * hashed + key.charCodeAt(ii)) | 0;882 }883 return hashed;884 }885 function hashSymbol(sym) {886 var hashed = symbolMap[sym];887 if (hashed !== undefined) {888 return hashed;889 }890 hashed = nextHash();891 symbolMap[sym] = hashed;892 return hashed;893 }894 // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type895 function hashJSObj(obj) {896 var hashed;897 if (usingWeakMap) {898 // @ts-expect-error weakMap is defined899 hashed = weakMap.get(obj);900 if (hashed !== undefined) {901 return hashed;902 }903 }904 // @ts-expect-error used for old code, will be removed905 hashed = obj[UID_HASH_KEY];906 if (hashed !== undefined) {907 return hashed;908 }909 if (!canDefineProperty) {910 // @ts-expect-error used for old code, will be removed911 hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];912 if (hashed !== undefined) {913 return hashed;914 }915 hashed = getIENodeHash(obj);916 if (hashed !== undefined) {917 return hashed;918 }919 }920 hashed = nextHash();921 if (usingWeakMap) {922 // @ts-expect-error weakMap is defined923 weakMap.set(obj, hashed);924 }925 else if (isExtensible !== undefined && isExtensible(obj) === false) {926 throw new Error('Non-extensible objects are not allowed as keys.');927 }928 else if (canDefineProperty) {929 Object.defineProperty(obj, UID_HASH_KEY, {930 enumerable: false,931 configurable: false,932 writable: false,933 value: hashed,934 });935 }936 else if (obj.propertyIsEnumerable !== undefined &&937 obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {938 // Since we can't define a non-enumerable property on the object939 // we'll hijack one of the less-used non-enumerable properties to940 // save our hash on it. Since this is a function it will not show up in941 // `JSON.stringify` which is what we want.942 obj.propertyIsEnumerable = function () {943 return this.constructor.prototype.propertyIsEnumerable.apply(this, 944 // eslint-disable-next-line prefer-rest-params945 arguments);946 };947 // @ts-expect-error used for old code, will be removed948 obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;949 // @ts-expect-error used for old code, will be removed950 }951 else if (obj.nodeType !== undefined) {952 // At this point we couldn't get the IE `uniqueID` to use as a hash953 // and we couldn't use a non-enumerable property to exploit the954 // dontEnum bug so we simply add the `UID_HASH_KEY` on the node955 // itself.956 // @ts-expect-error used for old code, will be removed957 obj[UID_HASH_KEY] = hashed;958 }959 else {960 throw new Error('Unable to set a non-enumerable property on object.');961 }962 return hashed;963 }964 // Get references to ES5 object methods.965 var isExtensible = Object.isExtensible;966 // True if Object.defineProperty works as expected. IE8 fails this test.967 // TODO remove this as widely available https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty968 var canDefineProperty = (function () {969 try {970 Object.defineProperty({}, '@', {});971 return true;972 // eslint-disable-next-line @typescript-eslint/no-unused-vars973 }974 catch (e) {975 return false;976 }977 })();978 // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it979 // and avoid memory leaks from the IE cloneNode bug.980 // TODO remove this method as only used if `canDefineProperty` is false981 function getIENodeHash(node) {982 // @ts-expect-error don't care983 if (node && node.nodeType > 0) {984 // @ts-expect-error don't care985 switch (node.nodeType) {986 case 1: // Element987 // @ts-expect-error don't care988 return node.uniqueID;989 case 9: // Document990 // @ts-expect-error don't care991 return node.documentElement && node.documentElement.uniqueID;992 }993 }994 }995 function valueOf(obj) {996 return obj.valueOf !== defaultValueOf && typeof obj.valueOf === 'function'997 ? // @ts-expect-error weird the "obj" parameter as `valueOf` should not have a parameter998 obj.valueOf(obj)999 : obj;1000 }1001 function nextHash() {1002 var nextHash = ++_objHashUID;1003 if (_objHashUID & 0x40000000) {1004 _objHashUID = 0;1005 }1006 return nextHash;1007 }1008 // If possible, use a WeakMap.1009 // TODO using WeakMap should be true everywhere now that WeakMap is widely supported: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap1010 var usingWeakMap = typeof WeakMap === 'function';1011 var weakMap;1012 if (usingWeakMap) {1013 weakMap = new WeakMap();1014 }1015 var symbolMap = Object.create(null);1016 var _objHashUID = 0;1017 // TODO remove string as Symbol is now widely supported: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol1018 var UID_HASH_KEY = '__immutablehash__';1019 if (typeof Symbol === 'function') {1020 UID_HASH_KEY = Symbol(UID_HASH_KEY);1021 }1022 var STRING_HASH_CACHE_MIN_STRLEN = 16;1023 var STRING_HASH_CACHE_MAX_SIZE = 255;1024 var STRING_HASH_CACHE_SIZE = 0;1025 var stringHashCache = {};1026 1027 var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq) {1028 function ToKeyedSequence(indexed, useKeys) {1029 this._iter = indexed;1030 this._useKeys = useKeys;1031 this.size = indexed.size;1032 }1033 1034 if ( KeyedSeq ) ToKeyedSequence.__proto__ = KeyedSeq;1035 ToKeyedSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );1036 ToKeyedSequence.prototype.constructor = ToKeyedSequence;1037 1038 ToKeyedSequence.prototype.get = function get (key, notSetValue) {1039 return this._iter.get(key, notSetValue);1040 };1041 1042 ToKeyedSequence.prototype.has = function has (key) {1043 return this._iter.has(key);1044 };1045 1046 ToKeyedSequence.prototype.valueSeq = function valueSeq () {1047 return this._iter.valueSeq();1048 };1049 1050 ToKeyedSequence.prototype.reverse = function reverse () {1051 var this$1$1 = this;1052 1053 var reversedSequence = reverseFactory(this, true);1054 if (!this._useKeys) {1055 reversedSequence.valueSeq = function () { return this$1$1._iter.toSeq().reverse(); };1056 }1057 return reversedSequence;1058 };1059 1060 ToKeyedSequence.prototype.map = function map (mapper, context) {1061 var this$1$1 = this;1062 1063 var mappedSequence = mapFactory(this, mapper, context);1064 if (!this._useKeys) {1065 mappedSequence.valueSeq = function () { return this$1$1._iter.toSeq().map(mapper, context); };1066 }1067 return mappedSequence;1068 };1069 1070 ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {1071 var this$1$1 = this;1072 1073 return this._iter.__iterate(function (v, k) { return fn(v, k, this$1$1); }, reverse);1074 };1075 1076 ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {1077 return this._iter.__iterator(type, reverse);1078 };1079 1080 return ToKeyedSequence;1081 }(KeyedSeq));1082 ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;1083 1084 var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq) {1085 function ToIndexedSequence(iter) {1086 this._iter = iter;1087 this.size = iter.size;1088 }1089 1090 if ( IndexedSeq ) ToIndexedSequence.__proto__ = IndexedSeq;1091 ToIndexedSequence.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );1092 ToIndexedSequence.prototype.constructor = ToIndexedSequence;1093 1094 ToIndexedSequence.prototype.includes = function includes (value) {1095 return this._iter.includes(value);1096 };1097 1098 ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {1099 var this$1$1 = this;1100 1101 var i = 0;1102 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here1103 reverse && ensureSize(this);1104 return this._iter.__iterate(1105 function (v) { return fn(v, reverse ? this$1$1.size - ++i : i++, this$1$1); },1106 reverse1107 );1108 };1109 1110 ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {1111 var this$1$1 = this;1112 1113 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1114 var i = 0;1115 // eslint-disable-next-line @typescript-eslint/no-unused-expressions -- TODO enable eslint here1116 reverse && ensureSize(this);1117 return new Iterator(function () {1118 var step = iterator.next();1119 return step.done1120 ? step1121 : iteratorValue(1122 type,1123 reverse ? this$1$1.size - ++i : i++,1124 step.value,1125 step1126 );1127 });1128 };1129 1130 return ToIndexedSequence;1131 }(IndexedSeq));1132 1133 var ToSetSequence = /*@__PURE__*/(function (SetSeq) {1134 function ToSetSequence(iter) {1135 this._iter = iter;1136 this.size = iter.size;1137 }1138 1139 if ( SetSeq ) ToSetSequence.__proto__ = SetSeq;1140 ToSetSequence.prototype = Object.create( SetSeq && SetSeq.prototype );1141 ToSetSequence.prototype.constructor = ToSetSequence;1142 1143 ToSetSequence.prototype.has = function has (key) {1144 return this._iter.includes(key);1145 };1146 1147 ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {1148 var this$1$1 = this;1149 1150 return this._iter.__iterate(function (v) { return fn(v, v, this$1$1); }, reverse);1151 };1152 1153 ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {1154 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1155 return new Iterator(function () {1156 var step = iterator.next();1157 return step.done1158 ? step1159 : iteratorValue(type, step.value, step.value, step);1160 });1161 };1162 1163 return ToSetSequence;1164 }(SetSeq));1165 1166 var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq) {1167 function FromEntriesSequence(entries) {1168 this._iter = entries;1169 this.size = entries.size;1170 }1171 1172 if ( KeyedSeq ) FromEntriesSequence.__proto__ = KeyedSeq;1173 FromEntriesSequence.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );1174 FromEntriesSequence.prototype.constructor = FromEntriesSequence;1175 1176 FromEntriesSequence.prototype.entrySeq = function entrySeq () {1177 return this._iter.toSeq();1178 };1179 1180 FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {1181 var this$1$1 = this;1182 1183 return this._iter.__iterate(function (entry) {1184 // Check if entry exists first so array access doesn't throw for holes1185 // in the parent iteration.1186 if (entry) {1187 validateEntry(entry);1188 var indexedCollection = isCollection(entry);1189 return fn(1190 indexedCollection ? entry.get(1) : entry[1],1191 indexedCollection ? entry.get(0) : entry[0],1192 this$1$11193 );1194 }1195 }, reverse);1196 };1197 1198 FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {1199 var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);1200 return new Iterator(function () {