astexplorer.app
Version:
https://astexplorer.net with ES Modules support and Hot Reloading
1 lines • 8.94 MB
JavaScript
(window.webpackJsonp=window.webpackJsonp||[]).push([[101],{"./node_modules/typescript/lib/typescript.js":function(module,exports){eval('/*! *****************************************************************************\nCopyright (c) Microsoft Corporation. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the "License"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\n\n"use strict";\nvar __spreadArrays = (this && this.__spreadArrays) || function () {\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\n r[k] = a[j];\n return r;\n};\nvar __assign = (this && this.__assign) || function () {\n __assign = Object.assign || function(t) {\n for (var s, i = 1, n = arguments.length; i < n; i++) {\n s = arguments[i];\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\n t[p] = s[p];\n }\n return t;\n };\n return __assign.apply(this, arguments);\n};\nvar __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {\n if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }\n return cooked;\n};\nvar __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError("Generator is already executing.");\n while (_) try {\n if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [op[0] & 2, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n};\nvar __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === "function")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\n t[p[i]] = s[p[i]];\n }\n return t;\n};\nvar __extends = (this && this.__extends) || (function () {\n var extendStatics = function (d, b) {\n extendStatics = Object.setPrototypeOf ||\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\n return extendStatics(d, b);\n };\n return function (d, b) {\n extendStatics(d, b);\n function __() { this.constructor = d; }\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n };\n})();\n/* @internal */\nvar ts;\n(function (ts) {\n function createMapData() {\n var sentinel = {};\n sentinel.prev = sentinel;\n return { head: sentinel, tail: sentinel, size: 0 };\n }\n function createMapEntry(key, value) {\n return { key: key, value: value, next: undefined, prev: undefined };\n }\n function sameValueZero(x, y) {\n // Treats -0 === 0 and NaN === NaN\n return x === y || x !== x && y !== y;\n }\n function getPrev(entry) {\n var prev = entry.prev;\n // Entries without a \'prev\' have been removed from the map.\n // An entry whose \'prev\' points to itself is the head of the list and is invalid here.\n if (!prev || prev === entry)\n throw new Error("Illegal state");\n return prev;\n }\n function getNext(entry) {\n while (entry) {\n // Entries without a \'prev\' have been removed from the map. Their \'next\'\n // pointer should point to the previous entry prior to deletion and\n // that entry should be skipped to resume iteration.\n var skipNext = !entry.prev;\n entry = entry.next;\n if (skipNext) {\n continue;\n }\n return entry;\n }\n }\n function getEntry(data, key) {\n // We walk backwards from \'tail\' to prioritize recently added entries.\n // We skip \'head\' because it is an empty entry used to track iteration start.\n for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {\n if (sameValueZero(entry.key, key)) {\n return entry;\n }\n }\n }\n function addOrUpdateEntry(data, key, value) {\n var existing = getEntry(data, key);\n if (existing) {\n existing.value = value;\n return;\n }\n var entry = createMapEntry(key, value);\n entry.prev = data.tail;\n data.tail.next = entry;\n data.tail = entry;\n data.size++;\n return entry;\n }\n function deleteEntry(data, key) {\n // We walk backwards from \'tail\' to prioritize recently added entries.\n // We skip \'head\' because it is an empty entry used to track iteration start.\n for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) {\n // all entries in the map should have a \'prev\' pointer.\n if (entry.prev === undefined)\n throw new Error("Illegal state");\n if (sameValueZero(entry.key, key)) {\n if (entry.next) {\n entry.next.prev = entry.prev;\n }\n else {\n // an entry in the map without a \'next\' pointer must be the \'tail\'.\n if (data.tail !== entry)\n throw new Error("Illegal state");\n data.tail = entry.prev;\n }\n entry.prev.next = entry.next;\n entry.next = entry.prev;\n entry.prev = undefined;\n data.size--;\n return entry;\n }\n }\n }\n function clearEntries(data) {\n var node = data.tail;\n while (node !== data.head) {\n var prev = getPrev(node);\n node.next = data.head;\n node.prev = undefined;\n node = prev;\n }\n data.head.next = undefined;\n data.tail = data.head;\n data.size = 0;\n }\n function forEachEntry(data, action) {\n var entry = data.head;\n while (entry) {\n entry = getNext(entry);\n if (entry) {\n action(entry.value, entry.key);\n }\n }\n }\n function forEachIteration(iterator, action) {\n if (iterator) {\n for (var step = iterator.next(); !step.done; step = iterator.next()) {\n action(step.value);\n }\n }\n }\n function createIteratorData(data, selector) {\n return { current: data.head, selector: selector };\n }\n function iteratorNext(data) {\n // Navigate to the next entry.\n data.current = getNext(data.current);\n if (data.current) {\n return { value: data.selector(data.current.key, data.current.value), done: false };\n }\n else {\n return { value: undefined, done: true };\n }\n }\n /* @internal */\n var ShimCollections;\n (function (ShimCollections) {\n function createMapShim(getIterator) {\n var MapIterator = /** @class */ (function () {\n function MapIterator(data, selector) {\n this._data = createIteratorData(data, selector);\n }\n MapIterator.prototype.next = function () { return iteratorNext(this._data); };\n return MapIterator;\n }());\n return /** @class */ (function () {\n function Map(iterable) {\n var _this = this;\n this._mapData = createMapData();\n forEachIteration(getIterator(iterable), function (_a) {\n var key = _a[0], value = _a[1];\n return _this.set(key, value);\n });\n }\n Object.defineProperty(Map.prototype, "size", {\n get: function () { return this._mapData.size; },\n enumerable: false,\n configurable: true\n });\n Map.prototype.get = function (key) { var _a; return (_a = getEntry(this._mapData, key)) === null || _a === void 0 ? void 0 : _a.value; };\n Map.prototype.set = function (key, value) { return addOrUpdateEntry(this._mapData, key, value), this; };\n Map.prototype.has = function (key) { return !!getEntry(this._mapData, key); };\n Map.prototype.delete = function (key) { return !!deleteEntry(this._mapData, key); };\n Map.prototype.clear = function () { clearEntries(this._mapData); };\n Map.prototype.keys = function () { return new MapIterator(this._mapData, function (key, _value) { return key; }); };\n Map.prototype.values = function () { return new MapIterator(this._mapData, function (_key, value) { return value; }); };\n Map.prototype.entries = function () { return new MapIterator(this._mapData, function (key, value) { return [key, value]; }); };\n Map.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };\n return Map;\n }());\n }\n ShimCollections.createMapShim = createMapShim;\n function createSetShim(getIterator) {\n var SetIterator = /** @class */ (function () {\n function SetIterator(data, selector) {\n this._data = createIteratorData(data, selector);\n }\n SetIterator.prototype.next = function () { return iteratorNext(this._data); };\n return SetIterator;\n }());\n return /** @class */ (function () {\n function Set(iterable) {\n var _this = this;\n this._mapData = createMapData();\n forEachIteration(getIterator(iterable), function (value) { return _this.add(value); });\n }\n Object.defineProperty(Set.prototype, "size", {\n get: function () { return this._mapData.size; },\n enumerable: false,\n configurable: true\n });\n Set.prototype.add = function (value) { return addOrUpdateEntry(this._mapData, value, value), this; };\n Set.prototype.has = function (value) { return !!getEntry(this._mapData, value); };\n Set.prototype.delete = function (value) { return !!deleteEntry(this._mapData, value); };\n Set.prototype.clear = function () { clearEntries(this._mapData); };\n Set.prototype.keys = function () { return new SetIterator(this._mapData, function (key, _value) { return key; }); };\n Set.prototype.values = function () { return new SetIterator(this._mapData, function (_key, value) { return value; }); };\n Set.prototype.entries = function () { return new SetIterator(this._mapData, function (key, value) { return [key, value]; }); };\n Set.prototype.forEach = function (action) { forEachEntry(this._mapData, action); };\n return Set;\n }());\n }\n ShimCollections.createSetShim = createSetShim;\n })(ShimCollections = ts.ShimCollections || (ts.ShimCollections = {}));\n})(ts || (ts = {}));\nvar ts;\n(function (ts) {\n // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.\n // If changing the text in this section, be sure to test `configurePrerelease` too.\n ts.versionMajorMinor = "4.0";\n /** The version of the TypeScript compiler release */\n ts.version = "4.0.3";\n /* @internal */\n var Comparison;\n (function (Comparison) {\n Comparison[Comparison["LessThan"] = -1] = "LessThan";\n Comparison[Comparison["EqualTo"] = 0] = "EqualTo";\n Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan";\n })(Comparison = ts.Comparison || (ts.Comparison = {}));\n /* @internal */\n var NativeCollections;\n (function (NativeCollections) {\n /**\n * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).\n */\n function tryGetNativeMap() {\n // Internet Explorer\'s Map doesn\'t support iteration, so don\'t use it.\n // eslint-disable-next-line no-in-operator\n return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;\n }\n NativeCollections.tryGetNativeMap = tryGetNativeMap;\n /**\n * Returns the native Set implementation if it is available and compatible (i.e. supports iteration).\n */\n function tryGetNativeSet() {\n // Internet Explorer\'s Set doesn\'t support iteration, so don\'t use it.\n // eslint-disable-next-line no-in-operator\n return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;\n }\n NativeCollections.tryGetNativeSet = tryGetNativeSet;\n })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));\n})(ts || (ts = {}));\n/* @internal */\nvar ts;\n(function (ts) {\n function getCollectionImplementation(name, nativeFactory, shimFactory) {\n var _a;\n // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it.\n var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);\n if (constructor)\n return constructor;\n throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");\n }\n ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");\n ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");\n function getIterator(iterable) {\n if (iterable) {\n if (isArray(iterable))\n return arrayIterator(iterable);\n if (iterable instanceof ts.Map)\n return iterable.entries();\n if (iterable instanceof ts.Set)\n return iterable.values();\n throw new Error("Iteration not supported.");\n }\n }\n ts.getIterator = getIterator;\n ts.emptyArray = [];\n ts.emptyMap = new ts.Map();\n ts.emptySet = new ts.Set();\n function createMap() {\n return new ts.Map();\n }\n ts.createMap = createMap;\n /**\n * Create a new map from a template object is provided, the map will copy entries from it.\n * @deprecated Use `new Map(getEntries(template))` instead.\n */\n function createMapFromTemplate(template) {\n var map = new ts.Map();\n // Copies keys/values from template. Note that for..in will not throw if\n // template is undefined, and instead will just exit the loop.\n for (var key in template) {\n if (hasOwnProperty.call(template, key)) {\n map.set(key, template[key]);\n }\n }\n return map;\n }\n ts.createMapFromTemplate = createMapFromTemplate;\n function length(array) {\n return array ? array.length : 0;\n }\n ts.length = length;\n /**\n * Iterates through \'array\' by index and performs the callback on each element of array until the callback\n * returns a truthy value, then returns that value.\n * If no such value is found, the callback is applied to each element of array and undefined is returned.\n */\n function forEach(array, callback) {\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var result = callback(array[i], i);\n if (result) {\n return result;\n }\n }\n }\n return undefined;\n }\n ts.forEach = forEach;\n /**\n * Like `forEach`, but iterates in reverse order.\n */\n function forEachRight(array, callback) {\n if (array) {\n for (var i = array.length - 1; i >= 0; i--) {\n var result = callback(array[i], i);\n if (result) {\n return result;\n }\n }\n }\n return undefined;\n }\n ts.forEachRight = forEachRight;\n /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */\n function firstDefined(array, callback) {\n if (array === undefined) {\n return undefined;\n }\n for (var i = 0; i < array.length; i++) {\n var result = callback(array[i], i);\n if (result !== undefined) {\n return result;\n }\n }\n return undefined;\n }\n ts.firstDefined = firstDefined;\n function firstDefinedIterator(iter, callback) {\n while (true) {\n var iterResult = iter.next();\n if (iterResult.done) {\n return undefined;\n }\n var result = callback(iterResult.value);\n if (result !== undefined) {\n return result;\n }\n }\n }\n ts.firstDefinedIterator = firstDefinedIterator;\n function reduceLeftIterator(iterator, f, initial) {\n var result = initial;\n if (iterator) {\n for (var step = iterator.next(), pos = 0; !step.done; step = iterator.next(), pos++) {\n result = f(result, step.value, pos);\n }\n }\n return result;\n }\n ts.reduceLeftIterator = reduceLeftIterator;\n function zipWith(arrayA, arrayB, callback) {\n var result = [];\n ts.Debug.assertEqual(arrayA.length, arrayB.length);\n for (var i = 0; i < arrayA.length; i++) {\n result.push(callback(arrayA[i], arrayB[i], i));\n }\n return result;\n }\n ts.zipWith = zipWith;\n function zipToIterator(arrayA, arrayB) {\n ts.Debug.assertEqual(arrayA.length, arrayB.length);\n var i = 0;\n return {\n next: function () {\n if (i === arrayA.length) {\n return { value: undefined, done: true };\n }\n i++;\n return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };\n }\n };\n }\n ts.zipToIterator = zipToIterator;\n function zipToMap(keys, values) {\n ts.Debug.assert(keys.length === values.length);\n var map = new ts.Map();\n for (var i = 0; i < keys.length; ++i) {\n map.set(keys[i], values[i]);\n }\n return map;\n }\n ts.zipToMap = zipToMap;\n /**\n * Creates a new array with `element` interspersed in between each element of `input`\n * if there is more than 1 value in `input`. Otherwise, returns the existing array.\n */\n function intersperse(input, element) {\n if (input.length <= 1) {\n return input;\n }\n var result = [];\n for (var i = 0, n = input.length; i < n; i++) {\n if (i)\n result.push(element);\n result.push(input[i]);\n }\n return result;\n }\n ts.intersperse = intersperse;\n /**\n * Iterates through `array` by index and performs the callback on each element of array until the callback\n * returns a falsey value, then returns false.\n * If no such value is found, the callback is applied to each element of array and `true` is returned.\n */\n function every(array, callback) {\n if (array) {\n for (var i = 0; i < array.length; i++) {\n if (!callback(array[i], i)) {\n return false;\n }\n }\n }\n return true;\n }\n ts.every = every;\n function find(array, predicate) {\n for (var i = 0; i < array.length; i++) {\n var value = array[i];\n if (predicate(value, i)) {\n return value;\n }\n }\n return undefined;\n }\n ts.find = find;\n function findLast(array, predicate) {\n for (var i = array.length - 1; i >= 0; i--) {\n var value = array[i];\n if (predicate(value, i)) {\n return value;\n }\n }\n return undefined;\n }\n ts.findLast = findLast;\n /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */\n function findIndex(array, predicate, startIndex) {\n for (var i = startIndex || 0; i < array.length; i++) {\n if (predicate(array[i], i)) {\n return i;\n }\n }\n return -1;\n }\n ts.findIndex = findIndex;\n function findLastIndex(array, predicate, startIndex) {\n for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {\n if (predicate(array[i], i)) {\n return i;\n }\n }\n return -1;\n }\n ts.findLastIndex = findLastIndex;\n /**\n * Returns the first truthy result of `callback`, or else fails.\n * This is like `forEach`, but never returns undefined.\n */\n function findMap(array, callback) {\n for (var i = 0; i < array.length; i++) {\n var result = callback(array[i], i);\n if (result) {\n return result;\n }\n }\n return ts.Debug.fail();\n }\n ts.findMap = findMap;\n function contains(array, value, equalityComparer) {\n if (equalityComparer === void 0) { equalityComparer = equateValues; }\n if (array) {\n for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {\n var v = array_1[_i];\n if (equalityComparer(v, value)) {\n return true;\n }\n }\n }\n return false;\n }\n ts.contains = contains;\n function arraysEqual(a, b, equalityComparer) {\n if (equalityComparer === void 0) { equalityComparer = equateValues; }\n return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });\n }\n ts.arraysEqual = arraysEqual;\n function indexOfAnyCharCode(text, charCodes, start) {\n for (var i = start || 0; i < text.length; i++) {\n if (contains(charCodes, text.charCodeAt(i))) {\n return i;\n }\n }\n return -1;\n }\n ts.indexOfAnyCharCode = indexOfAnyCharCode;\n function countWhere(array, predicate) {\n var count = 0;\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var v = array[i];\n if (predicate(v, i)) {\n count++;\n }\n }\n }\n return count;\n }\n ts.countWhere = countWhere;\n function filter(array, f) {\n if (array) {\n var len = array.length;\n var i = 0;\n while (i < len && f(array[i]))\n i++;\n if (i < len) {\n var result = array.slice(0, i);\n i++;\n while (i < len) {\n var item = array[i];\n if (f(item)) {\n result.push(item);\n }\n i++;\n }\n return result;\n }\n }\n return array;\n }\n ts.filter = filter;\n function filterMutate(array, f) {\n var outIndex = 0;\n for (var i = 0; i < array.length; i++) {\n if (f(array[i], i, array)) {\n array[outIndex] = array[i];\n outIndex++;\n }\n }\n array.length = outIndex;\n }\n ts.filterMutate = filterMutate;\n function clear(array) {\n array.length = 0;\n }\n ts.clear = clear;\n function map(array, f) {\n var result;\n if (array) {\n result = [];\n for (var i = 0; i < array.length; i++) {\n result.push(f(array[i], i));\n }\n }\n return result;\n }\n ts.map = map;\n function mapIterator(iter, mapFn) {\n return {\n next: function () {\n var iterRes = iter.next();\n return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };\n }\n };\n }\n ts.mapIterator = mapIterator;\n function sameMap(array, f) {\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n var mapped = f(item, i);\n if (item !== mapped) {\n var result = array.slice(0, i);\n result.push(mapped);\n for (i++; i < array.length; i++) {\n result.push(f(array[i], i));\n }\n return result;\n }\n }\n }\n return array;\n }\n ts.sameMap = sameMap;\n /**\n * Flattens an array containing a mix of array or non-array elements.\n *\n * @param array The array to flatten.\n */\n function flatten(array) {\n var result = [];\n for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {\n var v = array_2[_i];\n if (v) {\n if (isArray(v)) {\n addRange(result, v);\n }\n else {\n result.push(v);\n }\n }\n }\n return result;\n }\n ts.flatten = flatten;\n /**\n * Maps an array. If the mapped value is an array, it is spread into the result.\n *\n * @param array The array to map.\n * @param mapfn The callback used to map the result into one or more values.\n */\n function flatMap(array, mapfn) {\n var result;\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var v = mapfn(array[i], i);\n if (v) {\n if (isArray(v)) {\n result = addRange(result, v);\n }\n else {\n result = append(result, v);\n }\n }\n }\n }\n return result || ts.emptyArray;\n }\n ts.flatMap = flatMap;\n function flatMapToMutable(array, mapfn) {\n var result = [];\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var v = mapfn(array[i], i);\n if (v) {\n if (isArray(v)) {\n addRange(result, v);\n }\n else {\n result.push(v);\n }\n }\n }\n }\n return result;\n }\n ts.flatMapToMutable = flatMapToMutable;\n function flatMapIterator(iter, mapfn) {\n var first = iter.next();\n if (first.done) {\n return ts.emptyIterator;\n }\n var currentIter = getIterator(first.value);\n return {\n next: function () {\n while (true) {\n var currentRes = currentIter.next();\n if (!currentRes.done) {\n return currentRes;\n }\n var iterRes = iter.next();\n if (iterRes.done) {\n return iterRes;\n }\n currentIter = getIterator(iterRes.value);\n }\n },\n };\n function getIterator(x) {\n var res = mapfn(x);\n return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;\n }\n }\n ts.flatMapIterator = flatMapIterator;\n function sameFlatMap(array, mapfn) {\n var result;\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var item = array[i];\n var mapped = mapfn(item, i);\n if (result || item !== mapped || isArray(mapped)) {\n if (!result) {\n result = array.slice(0, i);\n }\n if (isArray(mapped)) {\n addRange(result, mapped);\n }\n else {\n result.push(mapped);\n }\n }\n }\n }\n return result || array;\n }\n ts.sameFlatMap = sameFlatMap;\n function mapAllOrFail(array, mapFn) {\n var result = [];\n for (var i = 0; i < array.length; i++) {\n var mapped = mapFn(array[i], i);\n if (mapped === undefined) {\n return undefined;\n }\n result.push(mapped);\n }\n return result;\n }\n ts.mapAllOrFail = mapAllOrFail;\n function mapDefined(array, mapFn) {\n var result = [];\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var mapped = mapFn(array[i], i);\n if (mapped !== undefined) {\n result.push(mapped);\n }\n }\n }\n return result;\n }\n ts.mapDefined = mapDefined;\n function mapDefinedIterator(iter, mapFn) {\n return {\n next: function () {\n while (true) {\n var res = iter.next();\n if (res.done) {\n return res;\n }\n var value = mapFn(res.value);\n if (value !== undefined) {\n return { value: value, done: false };\n }\n }\n }\n };\n }\n ts.mapDefinedIterator = mapDefinedIterator;\n function mapDefinedEntries(map, f) {\n if (!map) {\n return undefined;\n }\n var result = new ts.Map();\n map.forEach(function (value, key) {\n var entry = f(key, value);\n if (entry !== undefined) {\n var newKey = entry[0], newValue = entry[1];\n if (newKey !== undefined && newValue !== undefined) {\n result.set(newKey, newValue);\n }\n }\n });\n return result;\n }\n ts.mapDefinedEntries = mapDefinedEntries;\n function mapDefinedValues(set, f) {\n if (set) {\n var result_1 = new ts.Set();\n set.forEach(function (value) {\n var newValue = f(value);\n if (newValue !== undefined) {\n result_1.add(newValue);\n }\n });\n return result_1;\n }\n }\n ts.mapDefinedValues = mapDefinedValues;\n function getOrUpdate(map, key, callback) {\n if (map.has(key)) {\n return map.get(key);\n }\n var value = callback();\n map.set(key, value);\n return value;\n }\n ts.getOrUpdate = getOrUpdate;\n function tryAddToSet(set, value) {\n if (!set.has(value)) {\n set.add(value);\n return true;\n }\n return false;\n }\n ts.tryAddToSet = tryAddToSet;\n ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };\n function singleIterator(value) {\n var done = false;\n return {\n next: function () {\n var wasDone = done;\n done = true;\n return wasDone ? { value: undefined, done: true } : { value: value, done: false };\n }\n };\n }\n ts.singleIterator = singleIterator;\n function spanMap(array, keyfn, mapfn) {\n var result;\n if (array) {\n result = [];\n var len = array.length;\n var previousKey = void 0;\n var key = void 0;\n var start = 0;\n var pos = 0;\n while (start < len) {\n while (pos < len) {\n var value = array[pos];\n key = keyfn(value, pos);\n if (pos === 0) {\n previousKey = key;\n }\n else if (key !== previousKey) {\n break;\n }\n pos++;\n }\n if (start < pos) {\n var v = mapfn(array.slice(start, pos), previousKey, start, pos);\n if (v) {\n result.push(v);\n }\n start = pos;\n }\n previousKey = key;\n pos++;\n }\n }\n return result;\n }\n ts.spanMap = spanMap;\n function mapEntries(map, f) {\n if (!map) {\n return undefined;\n }\n var result = new ts.Map();\n map.forEach(function (value, key) {\n var _a = f(key, value), newKey = _a[0], newValue = _a[1];\n result.set(newKey, newValue);\n });\n return result;\n }\n ts.mapEntries = mapEntries;\n function some(array, predicate) {\n if (array) {\n if (predicate) {\n for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {\n var v = array_3[_i];\n if (predicate(v)) {\n return true;\n }\n }\n }\n else {\n return array.length > 0;\n }\n }\n return false;\n }\n ts.some = some;\n /** Calls the callback with (start, afterEnd) index pairs for each range where \'pred\' is true. */\n function getRangesWhere(arr, pred, cb) {\n var start;\n for (var i = 0; i < arr.length; i++) {\n if (pred(arr[i])) {\n start = start === undefined ? i : start;\n }\n else {\n if (start !== undefined) {\n cb(start, i);\n start = undefined;\n }\n }\n }\n if (start !== undefined)\n cb(start, arr.length);\n }\n ts.getRangesWhere = getRangesWhere;\n function concatenate(array1, array2) {\n if (!some(array2))\n return array1;\n if (!some(array1))\n return array2;\n return __spreadArrays(array1, array2);\n }\n ts.concatenate = concatenate;\n function selectIndex(_, i) {\n return i;\n }\n function indicesOf(array) {\n return array.map(selectIndex);\n }\n ts.indicesOf = indicesOf;\n function deduplicateRelational(array, equalityComparer, comparer) {\n // Perform a stable sort of the array. This ensures the first entry in a list of\n // duplicates remains the first entry in the result.\n var indices = indicesOf(array);\n stableSortIndices(array, indices, comparer);\n var last = array[indices[0]];\n var deduplicated = [indices[0]];\n for (var i = 1; i < indices.length; i++) {\n var index = indices[i];\n var item = array[index];\n if (!equalityComparer(last, item)) {\n deduplicated.push(index);\n last = item;\n }\n }\n // restore original order\n deduplicated.sort();\n return deduplicated.map(function (i) { return array[i]; });\n }\n function deduplicateEquality(array, equalityComparer) {\n var result = [];\n for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {\n var item = array_4[_i];\n pushIfUnique(result, item, equalityComparer);\n }\n return result;\n }\n /**\n * Deduplicates an unsorted array.\n * @param equalityComparer An `EqualityComparer` used to determine if two values are duplicates.\n * @param comparer An optional `Comparer` used to sort entries before comparison, though the\n * result will remain in the original order in `array`.\n */\n function deduplicate(array, equalityComparer, comparer) {\n return array.length === 0 ? [] :\n array.length === 1 ? array.slice() :\n comparer ? deduplicateRelational(array, equalityComparer, comparer) :\n deduplicateEquality(array, equalityComparer);\n }\n ts.deduplicate = deduplicate;\n /**\n * Deduplicates an array that has already been sorted.\n */\n function deduplicateSorted(array, comparer) {\n if (array.length === 0)\n return ts.emptyArray;\n var last = array[0];\n var deduplicated = [last];\n for (var i = 1; i < array.length; i++) {\n var next = array[i];\n switch (comparer(next, last)) {\n // equality comparison\n case true:\n // relational comparison\n // falls through\n case 0 /* EqualTo */:\n continue;\n case -1 /* LessThan */:\n // If `array` is sorted, `next` should **never** be less than `last`.\n return ts.Debug.fail("Array is unsorted.");\n }\n deduplicated.push(last = next);\n }\n return deduplicated;\n }\n function insertSorted(array, insert, compare) {\n if (array.length === 0) {\n array.push(insert);\n return;\n }\n var insertIndex = binarySearch(array, insert, identity, compare);\n if (insertIndex < 0) {\n array.splice(~insertIndex, 0, insert);\n }\n }\n ts.insertSorted = insertSorted;\n function sortAndDeduplicate(array, comparer, equalityComparer) {\n return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);\n }\n ts.sortAndDeduplicate = sortAndDeduplicate;\n function arrayIsSorted(array, comparer) {\n if (array.length < 2)\n return true;\n var prevElement = array[0];\n for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) {\n var element = _a[_i];\n if (comparer(prevElement, element) === 1 /* GreaterThan */) {\n return false;\n }\n prevElement = element;\n }\n return true;\n }\n ts.arrayIsSorted = arrayIsSorted;\n function arrayIsEqualTo(array1, array2, equalityComparer) {\n if (equalityComparer === void 0) { equalityComparer = equateValues; }\n if (!array1 || !array2) {\n return array1 === array2;\n }\n if (array1.length !== array2.length) {\n return false;\n }\n for (var i = 0; i < array1.length; i++) {\n if (!equalityComparer(array1[i], array2[i], i)) {\n return false;\n }\n }\n return true;\n }\n ts.arrayIsEqualTo = arrayIsEqualTo;\n function compact(array) {\n var result;\n if (array) {\n for (var i = 0; i < array.length; i++) {\n var v = array[i];\n if (result || !v) {\n if (!result) {\n result = array.slice(0, i);\n }\n if (v) {\n result.push(v);\n }\n }\n }\n }\n return result || array;\n }\n ts.compact = compact;\n /**\n * Gets the relative complement of `arrayA` with respect to `arrayB`, returning the elements that\n * are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted\n * based on the provided comparer.\n */\n function relativeComplement(arrayA, arrayB, comparer) {\n if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)\n return arrayB;\n var result = [];\n loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {\n if (offsetB > 0) {\n // Ensure `arrayB` is properly sorted.\n ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* EqualTo */);\n }\n loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {\n if (offsetA > startA) {\n // Ensure `arrayA` is properly sorted. We only need to perform this check if\n // `offsetA` has changed since we entered the loop.\n ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* EqualTo */);\n }\n switch (comparer(arrayB[offsetB], arrayA[offsetA])) {\n case -1 /* LessThan */:\n // If B is less than A, B does not exist in arrayA. Add B to the result and\n // move to the next element in arrayB without changing the current position\n // in arrayA.\n result.push(arrayB[offsetB]);\n continue loopB;\n case 0 /* EqualTo */:\n // If B is equal to A, B exists in arrayA. Move to the next element in\n // arrayB without adding B to the result or changing the current position\n // in arrayA.\n continue loopB;\n case 1 /* GreaterThan */:\n // If B is greater than A, we need to keep looking for B in arrayA. Move to\n // the next element in arrayA and recheck.\n continue loopA;\n }\n }\n }\n return result;\n }\n ts.relativeComplement = relativeComplement;\n function sum(array, prop) {\n var result = 0;\n for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {\n var v = array_5[_i];\n result += v[prop];\n }\n return result;\n }\n ts.sum = sum;\n function append(to, value) {\n if (value === undefined)\n return to;\n if (to === undefined)\n return [value];\n to.push(value);\n return to;\n }\n ts.append = append;\n function combine(xs, ys) {\n if (xs === undefined)\n return ys;\n if (ys === undefined)\n return xs;\n if (isArray(xs))\n return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);\n if (isArray(ys))\n return append(ys, xs);\n return [xs, ys];\n }\n ts.combine = combine;\n /**\n * Gets the actual offset into an array for a relative offset. Negative offsets indicate a\n * position offset from the end of the array.\n */\n function toOffset(array, offset) {\n return offset < 0 ? array.length + offset : offset;\n }\n function addRange(to, from, start, end) {\n if (from === undefined || from.length === 0)\n return to;\n if (to === undefined)\n return from.slice(start, end);\n start = start === undefined ? 0 : toOffset(from, start);\n end = end === undefined ? from.length : toOffset(from, end);\n for (var i = start; i < end && i < from.length; i++) {\n if (from[i] !== undefined) {\n to.push(from[i]);\n }\n }\n return to;\n }\n ts.addRange = addRange;\n /**\n * @return Whether the value was added.\n */\n function pushIfUnique(array, toAdd, equalityComparer) {\n if (contains(array, toAdd, equalityComparer)) {\n return false;\n }\n else {\n array.push(toAdd);\n return true;\n }\n }\n ts.pushIfUnique = pushIfUnique;\n /**\n * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array.\n */\n function appendIfUnique(array, toAdd, equalityComparer) {\n if (array) {\n pushIfUnique(array, toAdd, equalityComparer);\n return array;\n }\n else {\n return [toAdd];\n }\n }\n ts.appendIfUnique = appendIfUnique;\n function stableSortIndices(array, indices, comparer) {\n // sort indices by value then position\n indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });\n }\n /**\n * Returns a new sorted array.\n */\n function sort(array, comparer) {\n return (array.length === 0 ? array : array.slice().sort(comparer));\n }\n ts.sort = sort;\n function arrayIterator(array) {\n var i = 0;\n return { next: function () {\n if (i === array.length) {\n return { value: undefined, done: true };\n }\n else {\n i++;\n return { value: array[i - 1], done: false };\n }\n } };\n }\n ts.arrayIterator = arrayIterator;\n function arrayReverseIterator(array) {\n var i = array.length;\n return {\n next: function () {\n if (i === 0) {\n return { value: undefined, done: true };\n }\n else {\n i--;\n return { value: array[i], done: false };\n }\n }\n };\n }\n ts.arrayReverseIterator = arrayReverseIterator;\n /**\n * Stable sort of an array. Elements equal to each other maintain their relative position in the array.\n */\n function stableSort(array, comparer) {\n var indices = indicesOf(array);\n stableSortIndices(array, indices, comparer);\n return indices.map(function (i) { return array[i]; });\n }\n ts.stableSort = stableSort;\n function rangeEquals(array1, array2, pos, end) {\n while (pos < end) {\n if (array1[pos] !== array2[pos]) {\n return false;\n }\n pos++;\n }\n return true;\n }\n ts.rangeEquals = rangeEquals;\n /**\n * Returns the element at a specific offset in an array if non-empty, `undefined` otherwise.\n * A negative offset indicates the element should be retrieved from the end of the array.\n */\n function elementAt(array, offset) {\n if (array) {\n offset = toOffset(array, offset);\n if (offset < array.length) {\n return array[offset];\n }\n }\n return undefined;\n }\n ts.elementAt = elementAt;\n /**\n * Returns the first element of an array if non-empty, `undefined` otherwise.\n */\n function firstOrUndefined(array) {\n return array.length === 0 ? undefined : array[0];\n }\n ts.firstOrUndefined = firstOrUndefined;\n fun