{"version":3,"file":"tko.min.js","sources":["../../tko.utils/dist/tko.utils.js","../../tko.observable/dist/tko.observable.js","../../tko.utils.parser/dist/tko.utils.parser.js","../../tko.computed/dist/tko.computed.js","../../tko.lifecycle/dist/tko.lifecycle.js","../../tko.bind/dist/tko.bind.js","../../tko.binding.template/dist/tko.binding.template.js","../../tko.builder/dist/tko.builder.js","../../tko.provider/dist/tko.provider.js","../../tko.provider.bindingstring/dist/tko.provider.bindingString.js","../../tko.provider.virtual/dist/tko.provider.virtual.js","../../tko.provider.databind/dist/tko.provider.databind.js","../../tko.utils.component/dist/tko.utils.component.js","../../tko.provider.component/dist/tko.provider.component.js","../../tko.provider.attr/dist/tko.provider.attr.js","../../tko.provider.multi/dist/tko.provider.multi.js","../../tko.provider.mustache/dist/tko.provider.mustache.js","../../tko.provider.native/dist/tko.provider.native.js","../../tko.binding.core/dist/tko.binding.core.js","../../tko.binding.if/dist/tko.binding.if.js","../../tko.binding.foreach/dist/tko.binding.foreach.js","../../tko.utils.jsx/dist/tko.utils.jsx.js","../../tko.binding.component/dist/tko.binding.component.js","../../tko.filter.punches/dist/tko.filter.punches.js"],"sourcesContent":["/*!\n * TKO Utilities 🥊 tko.utils@4.0.0-alpha5c\n * (c) The Knockout.js Team - https://tko.io/\n * License: MIT (http://www.opensource.org/licenses/mit-license.php)\n */\n\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n\r\nfunction __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nfunction __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\n\n//\r\nvar isArray = Array.isArray;\r\nfunction arrayForEach(array, action, thisArg) {\r\n if (arguments.length > 2) {\r\n action = action.bind(thisArg);\r\n }\r\n for (var i = 0, j = array.length; i < j; ++i) {\r\n action(array[i], i, array);\r\n }\r\n}\r\nfunction arrayIndexOf(array, item) {\r\n return (isArray(array) ? array : __spread(array)).indexOf(item);\r\n}\r\nfunction arrayFirst(array, predicate, predicateOwner) {\r\n return (isArray(array) ? array : __spread(array))\r\n .find(predicate, predicateOwner);\r\n}\r\nfunction arrayMap(array, mapping, thisArg) {\r\n if (array === void 0) { array = []; }\r\n if (arguments.length > 2) {\r\n mapping = mapping.bind(thisArg);\r\n }\r\n return array === null ? [] : Array.from(array, mapping);\r\n}\r\nfunction arrayRemoveItem(array, itemToRemove) {\r\n var index = arrayIndexOf(array, itemToRemove);\r\n if (index > 0) {\r\n array.splice(index, 1);\r\n }\r\n else if (index === 0) {\r\n array.shift();\r\n }\r\n}\r\nfunction arrayGetDistinctValues(array) {\r\n if (array === void 0) { array = []; }\r\n var seen = new Set();\r\n if (array === null) {\r\n return [];\r\n }\r\n return (isArray(array) ? array : __spread(array))\r\n .filter(function (item) { return seen.has(item) ? false : seen.add(item); });\r\n}\r\nfunction arrayFilter(array, predicate, thisArg) {\r\n if (arguments.length > 2) {\r\n predicate = predicate.bind(thisArg);\r\n }\r\n return array === null ? [] : (isArray(array) ? array : __spread(array)).filter(predicate);\r\n}\r\nfunction arrayPushAll(array, valuesToPush) {\r\n if (isArray(valuesToPush)) {\r\n array.push.apply(array, valuesToPush);\r\n }\r\n else {\r\n for (var i = 0, j = valuesToPush.length; i < j; i++) {\r\n array.push(valuesToPush[i]);\r\n }\r\n }\r\n return array;\r\n}\r\nfunction addOrRemoveItem(array, value, included) {\r\n var existingEntryIndex = arrayIndexOf(typeof array.peek === 'function' ? array.peek() : array, value);\r\n if (existingEntryIndex < 0) {\r\n if (included) {\r\n array.push(value);\r\n }\r\n }\r\n else {\r\n if (!included) {\r\n array.splice(existingEntryIndex, 1);\r\n }\r\n }\r\n}\r\nfunction makeArray(arrayLikeObject) {\r\n return Array.from(arrayLikeObject);\r\n}\r\nfunction range(min, max) {\r\n min = typeof min === 'function' ? min() : min;\r\n max = typeof max === 'function' ? max() : max;\r\n var result = [];\r\n for (var i = min; i <= max; i++) {\r\n result.push(i);\r\n }\r\n return result;\r\n}\r\n// Go through the items that have been added and deleted and try to find matches between them.\r\nfunction findMovesInArrayComparison(left, right, limitFailedCompares) {\r\n if (left.length && right.length) {\r\n var failedCompares, l, r, leftItem, rightItem;\r\n for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {\r\n for (r = 0; rightItem = right[r]; ++r) {\r\n if (leftItem['value'] === rightItem['value']) {\r\n leftItem['moved'] = rightItem['index'];\r\n rightItem['moved'] = leftItem['index'];\r\n right.splice(r, 1); // This item is marked as moved; so remove it from right list\r\n failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures\r\n break;\r\n }\r\n }\r\n failedCompares += r;\r\n }\r\n }\r\n}\r\nvar statusNotInOld = 'added', statusNotInNew = 'deleted';\r\n// Simple calculation based on Levenshtein distance.\r\nfunction compareArrays(oldArray, newArray, options) {\r\n // For backward compatibility, if the third arg is actually a bool, interpret\r\n // it as the old parameter 'dontLimitMoves'. Newer code should use { dontLimitMoves: true }.\r\n options = (typeof options === 'boolean') ? { 'dontLimitMoves': options } : (options || {});\r\n oldArray = oldArray || [];\r\n newArray = newArray || [];\r\n if (oldArray.length < newArray.length) {\r\n return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options);\r\n }\r\n else {\r\n return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options);\r\n }\r\n}\r\nfunction compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options) {\r\n var myMin = Math.min, myMax = Math.max, editDistanceMatrix = [], smlIndex, smlIndexMax = smlArray.length, bigIndex, bigIndexMax = bigArray.length, compareRange = (bigIndexMax - smlIndexMax) || 1, maxDistance = smlIndexMax + bigIndexMax + 1, thisRow, lastRow, bigIndexMaxForRow, bigIndexMinForRow;\r\n for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {\r\n lastRow = thisRow;\r\n editDistanceMatrix.push(thisRow = []);\r\n bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);\r\n bigIndexMinForRow = myMax(0, smlIndex - 1);\r\n for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {\r\n if (!bigIndex) {\r\n thisRow[bigIndex] = smlIndex + 1;\r\n }\r\n else if (!smlIndex) // Top row - transform empty array into new array via additions\r\n {\r\n thisRow[bigIndex] = bigIndex + 1;\r\n }\r\n else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1]) {\r\n thisRow[bigIndex] = lastRow[bigIndex - 1];\r\n } // copy value (no edit)\r\n else {\r\n var northDistance = lastRow[bigIndex] || maxDistance; // not in big (deletion)\r\n var westDistance = thisRow[bigIndex - 1] || maxDistance; // not in small (addition)\r\n thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;\r\n }\r\n }\r\n }\r\n var editScript = [], meMinusOne, notInSml = [], notInBig = [];\r\n for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex;) {\r\n meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;\r\n if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex - 1]) {\r\n notInSml.push(editScript[editScript.length] = {\r\n 'status': statusNotInSml,\r\n 'value': bigArray[--bigIndex],\r\n 'index': bigIndex\r\n });\r\n }\r\n else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {\r\n notInBig.push(editScript[editScript.length] = {\r\n 'status': statusNotInBig,\r\n 'value': smlArray[--smlIndex],\r\n 'index': smlIndex\r\n });\r\n }\r\n else {\r\n --bigIndex;\r\n --smlIndex;\r\n if (!options['sparse']) {\r\n editScript.push({\r\n 'status': 'retained',\r\n 'value': bigArray[bigIndex]\r\n });\r\n }\r\n }\r\n }\r\n // Set a limit on the number of consecutive non-matching comparisons; having it a multiple of\r\n // smlIndexMax keeps the time complexity of this algorithm linear.\r\n findMovesInArrayComparison(notInBig, notInSml, !options['dontLimitMoves'] && smlIndexMax * 10);\r\n return editScript.reverse();\r\n}\n\n//\r\n// This becomes ko.options\r\n// --\r\n//\r\n// This is the root 'options', which must be extended by others.\r\nvar _global;\r\ntry {\r\n _global = window;\r\n}\r\ncatch (e) {\r\n _global = global;\r\n}\r\nvar options = {\r\n deferUpdates: false,\r\n useOnlyNativeEvents: false,\r\n protoProperty: '__ko_proto__',\r\n // Modify the default attribute from `data-bind`.\r\n defaultBindingAttribute: 'data-bind',\r\n // Enable/disable ',\r\n iElems[0]) { }\r\n if (!version) {\r\n var userAgent = window.navigator.userAgent;\r\n // Detect IE 10/11\r\n return ua.match(/MSIE ([^ ]+)/) || ua.match(/rv:([^ )]+)/);\r\n }\r\n return version > 4 ? version : undefined;\r\n}());\r\nvar isIe6 = ieVersion === 6;\r\nvar isIe7 = ieVersion === 7;\n\n//\r\n// Object functions\r\n//\r\nfunction hasOwnProperty(obj, propName) {\r\n return Object.prototype.hasOwnProperty.call(obj, propName);\r\n}\r\nfunction extend(target, source) {\r\n if (source) {\r\n for (var prop in source) {\r\n if (hasOwnProperty(source, prop)) {\r\n target[prop] = source[prop];\r\n }\r\n }\r\n }\r\n return target;\r\n}\r\nfunction objectForEach(obj, action) {\r\n for (var prop in obj) {\r\n if (hasOwnProperty(obj, prop)) {\r\n action(prop, obj[prop]);\r\n }\r\n }\r\n}\r\nfunction objectMap(source, mapping, thisArg) {\r\n if (!source) {\r\n return source;\r\n }\r\n if (arguments.length > 2) {\r\n mapping = mapping.bind(thisArg);\r\n }\r\n var target = {};\r\n for (var prop in source) {\r\n if (hasOwnProperty(source, prop)) {\r\n target[prop] = mapping(source[prop], prop, source);\r\n }\r\n }\r\n return target;\r\n}\r\nfunction getObjectOwnProperty(obj, propName) {\r\n return hasOwnProperty(obj, propName) ? obj[propName] : undefined;\r\n}\r\nfunction clonePlainObjectDeep(obj, seen) {\r\n if (!seen) {\r\n seen = [];\r\n }\r\n if (!obj || typeof obj !== 'object' ||\r\n obj.constructor !== Object ||\r\n seen.indexOf(obj) !== -1) {\r\n return obj;\r\n }\r\n // Anything that makes it below is a plain object that has not yet\r\n // been seen/cloned.\r\n seen.push(obj);\r\n var result = {};\r\n for (var prop in obj) {\r\n if (hasOwnProperty(obj, prop)) {\r\n result[prop] = clonePlainObjectDeep(obj[prop], seen);\r\n }\r\n }\r\n return result;\r\n}\n\nfunction testOverwrite() {\r\n try {\r\n Object.defineProperty(function x() { }, 'length', {});\r\n return true;\r\n }\r\n catch (e) {\r\n return false;\r\n }\r\n}\r\nvar functionSupportsLengthOverwrite = testOverwrite();\r\nfunction overwriteLengthPropertyIfSupported(fn, descriptor) {\r\n if (functionSupportsLengthOverwrite) {\r\n Object.defineProperty(fn, 'length', descriptor);\r\n }\r\n}\n\n//\r\n// String (and JSON)\r\n//\r\nfunction stringTrim(string) {\r\n return string === null || string === undefined ? ''\r\n : string.trim\r\n ? string.trim()\r\n : string.toString().replace(/^[\\s\\xa0]+|[\\s\\xa0]+$/g, '');\r\n}\r\nfunction stringStartsWith(string, startsWith) {\r\n string = string || '';\r\n if (startsWith.length > string.length) {\r\n return false;\r\n }\r\n return string.substring(0, startsWith.length) === startsWith;\r\n}\r\nfunction parseJson(jsonString) {\r\n if (typeof jsonString === 'string') {\r\n jsonString = stringTrim(jsonString);\r\n if (jsonString) {\r\n if (JSON && JSON.parse) // Use native parsing where available\r\n {\r\n return JSON.parse(jsonString);\r\n }\r\n return (new Function('return ' + jsonString))(); // Fallback on less safe parsing for older browsers\r\n }\r\n }\r\n return null;\r\n}\n\n//\r\n// ES6 Symbols\r\n//\r\nvar useSymbols = typeof Symbol === 'function';\r\nfunction createSymbolOrString(identifier) {\r\n return useSymbols ? Symbol(identifier) : identifier;\r\n}\n\n//\r\n// For details on the pattern for changing node classes\r\n// see: https://github.com/knockout/knockout/issues/1597\r\nvar cssClassNameRegex = /\\S+/g;\r\nfunction toggleDomNodeCssClass(node, classNames, shouldHaveClass) {\r\n var addOrRemoveFn;\r\n if (!classNames) {\r\n return;\r\n }\r\n if (typeof node.classList === 'object') {\r\n addOrRemoveFn = node.classList[shouldHaveClass ? 'add' : 'remove'];\r\n arrayForEach(classNames.match(cssClassNameRegex), function (className) {\r\n addOrRemoveFn.call(node.classList, className);\r\n });\r\n }\r\n else if (typeof node.className['baseVal'] === 'string') {\r\n // SVG tag .classNames is an SVGAnimatedString instance\r\n toggleObjectClassPropertyString(node.className, 'baseVal', classNames, shouldHaveClass);\r\n }\r\n else {\r\n // node.className ought to be a string.\r\n toggleObjectClassPropertyString(node, 'className', classNames, shouldHaveClass);\r\n }\r\n}\r\nfunction toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {\r\n // obj/prop is either a node/'className' or a SVGAnimatedString/'baseVal'.\r\n var currentClassNames = obj[prop].match(cssClassNameRegex) || [];\r\n arrayForEach(classNames.match(cssClassNameRegex), function (className) {\r\n addOrRemoveItem(currentClassNames, className, shouldHaveClass);\r\n });\r\n obj[prop] = currentClassNames.join(' ');\r\n}\n\n//\r\nvar jQueryInstance = options.global && options.global.jQuery;\r\nfunction jQuerySetInstance(jquery) {\r\n options.jQuery = jQueryInstance = jquery;\r\n}\n\n//\r\nfunction domNodeIsContainedBy(node, containedByNode) {\r\n if (node === containedByNode) {\r\n return true;\r\n }\r\n if (node.nodeType === 11) {\r\n return false;\r\n } // Fixes issue #1162 - can't use node.contains for document fragments on IE8\r\n if (containedByNode.contains) {\r\n return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);\r\n }\r\n if (containedByNode.compareDocumentPosition) {\r\n return (containedByNode.compareDocumentPosition(node) & 16) == 16;\r\n }\r\n while (node && node != containedByNode) {\r\n node = node.parentNode;\r\n }\r\n return !!node;\r\n}\r\nfunction domNodeIsAttachedToDocument(node) {\r\n return domNodeIsContainedBy(node, node.ownerDocument.documentElement);\r\n}\r\nfunction anyDomNodeIsAttachedToDocument(nodes) {\r\n return !!arrayFirst(nodes, domNodeIsAttachedToDocument);\r\n}\r\nfunction tagNameLower(element) {\r\n // For HTML elements, tagName will always be upper case; for XHTML elements, it'll be lower case.\r\n // Possible future optimization: If we know it's an element from an XHTML document (not HTML),\r\n // we don't need to do the .toLowerCase() as it will always be lower case anyway.\r\n return element && element.tagName && element.tagName.toLowerCase();\r\n}\r\nfunction isDomElement(obj) {\r\n if (window.HTMLElement) {\r\n return obj instanceof HTMLElement;\r\n }\r\n else {\r\n return obj && obj.tagName && obj.nodeType === 1;\r\n }\r\n}\r\nfunction isDocumentFragment(obj) {\r\n if (window.DocumentFragment) {\r\n return obj instanceof DocumentFragment;\r\n }\r\n else {\r\n return obj && obj.nodeType === 11;\r\n }\r\n}\n\n//\r\nvar datastoreTime = new Date().getTime();\r\nvar dataStoreKeyExpandoPropertyName = \"__ko__\" + datastoreTime;\r\nvar dataStoreSymbol = Symbol('Knockout data');\r\nvar dataStore;\r\nvar uniqueId = 0;\r\n/*\r\n * We considered using WeakMap, but it has a problem in IE 11 and Edge that\r\n * prevents using it cross-window, so instead we just store the data directly\r\n * on the node. See https://github.com/knockout/knockout/issues/2141\r\n */\r\nvar modern = {\r\n getDataForNode: function (node, createIfNotFound) {\r\n var dataForNode = node[dataStoreSymbol];\r\n if (!dataForNode && createIfNotFound) {\r\n dataForNode = node[dataStoreSymbol] = {};\r\n }\r\n return dataForNode;\r\n },\r\n clear: function (node) {\r\n if (node[dataStoreSymbol]) {\r\n delete node[dataStoreSymbol];\r\n return true;\r\n }\r\n return false;\r\n }\r\n};\r\n/**\r\n * Old IE versions have memory issues if you store objects on the node, so we\r\n * use a separate data storage and link to it from the node using a string key.\r\n */\r\nvar IE = {\r\n getDataforNode: function (node, createIfNotFound) {\r\n var dataStoreKey = node[dataStoreKeyExpandoPropertyName];\r\n var hasExistingDataStore = dataStoreKey && (dataStoreKey !== 'null') && dataStore[dataStoreKey];\r\n if (!hasExistingDataStore) {\r\n if (!createIfNotFound) {\r\n return undefined;\r\n }\r\n dataStoreKey = node[dataStoreKeyExpandoPropertyName] = 'ko' + uniqueId++;\r\n dataStore[dataStoreKey] = {};\r\n }\r\n return dataStore[dataStoreKey];\r\n },\r\n clear: function (node) {\r\n var dataStoreKey = node[dataStoreKeyExpandoPropertyName];\r\n if (dataStoreKey) {\r\n delete dataStore[dataStoreKey];\r\n node[dataStoreKeyExpandoPropertyName] = null;\r\n return true; // Exposing 'did clean' flag purely so specs can infer whether things have been cleaned up as intended\r\n }\r\n return false;\r\n }\r\n};\r\nvar _a = ieVersion ? IE : modern, getDataForNode = _a.getDataForNode, clear = _a.clear;\r\n/**\r\n * Create a unique key-string identifier.\r\n */\r\nfunction nextKey() {\r\n return (uniqueId++) + dataStoreKeyExpandoPropertyName;\r\n}\r\nfunction get(node, key) {\r\n var dataForNode = getDataForNode(node, false);\r\n return dataForNode && dataForNode[key];\r\n}\r\nfunction set(node, key, value) {\r\n // Make sure we don't actually create a new domData key if we are actually deleting a value\r\n var dataForNode = getDataForNode(node, value !== undefined /* createIfNotFound */);\r\n dataForNode && (dataForNode[key] = value);\r\n}\r\nfunction getOrSet(node, key, value) {\r\n var dataForNode = getDataForNode(node, true);\r\n return dataForNode[key] || (dataForNode[key] = value);\r\n}\n\nvar data = /*#__PURE__*/Object.freeze({\n nextKey: nextKey,\n get: get,\n set: set,\n getOrSet: getOrSet,\n clear: clear\n});\n\n//\r\nvar domDataKey = nextKey();\r\n// Node types:\r\n// 1: Element\r\n// 8: Comment\r\n// 9: Document\r\nvar cleanableNodeTypes = { 1: true, 8: true, 9: true };\r\nvar cleanableNodeTypesWithDescendants = { 1: true, 9: true };\r\nfunction getDisposeCallbacksCollection(node, createIfNotFound) {\r\n var allDisposeCallbacks = get(node, domDataKey);\r\n if ((allDisposeCallbacks === undefined) && createIfNotFound) {\r\n allDisposeCallbacks = [];\r\n set(node, domDataKey, allDisposeCallbacks);\r\n }\r\n return allDisposeCallbacks;\r\n}\r\nfunction destroyCallbacksCollection(node) {\r\n set(node, domDataKey, undefined);\r\n}\r\nfunction cleanSingleNode(node) {\r\n // Run all the dispose callbacks\r\n var callbacks = getDisposeCallbacksCollection(node, false);\r\n if (callbacks) {\r\n callbacks = callbacks.slice(0); // Clone, as the array may be modified during iteration (typically, callbacks will remove themselves)\r\n for (var i = 0; i < callbacks.length; i++) {\r\n callbacks[i](node);\r\n }\r\n }\r\n // Erase the DOM data\r\n clear(node);\r\n // Perform cleanup needed by external libraries (currently only jQuery, but can be extended)\r\n for (var i = 0, j = otherNodeCleanerFunctions.length; i < j; ++i) {\r\n otherNodeCleanerFunctions[i](node);\r\n }\r\n if (options.cleanExternalData) {\r\n options.cleanExternalData(node);\r\n }\r\n // Clear any immediate-child comment nodes, as these wouldn't have been found by\r\n // node.getElementsByTagName('*') in cleanNode() (comment nodes aren't elements)\r\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\r\n cleanNodesInList(node.childNodes, true /* onlyComments */);\r\n }\r\n}\r\nfunction cleanNodesInList(nodeList, onlyComments) {\r\n var cleanedNodes = [];\r\n var lastCleanedNode;\r\n for (var i = 0; i < nodeList.length; i++) {\r\n if (!onlyComments || nodeList[i].nodeType === 8) {\r\n cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);\r\n if (nodeList[i] !== lastCleanedNode) {\r\n while (i-- && arrayIndexOf(cleanedNodes, nodeList[i]) === -1) { }\r\n }\r\n }\r\n }\r\n}\r\n// Exports\r\nfunction addDisposeCallback(node, callback) {\r\n if (typeof callback !== 'function') {\r\n throw new Error('Callback must be a function');\r\n }\r\n getDisposeCallbacksCollection(node, true).push(callback);\r\n}\r\nfunction removeDisposeCallback(node, callback) {\r\n var callbacksCollection = getDisposeCallbacksCollection(node, false);\r\n if (callbacksCollection) {\r\n arrayRemoveItem(callbacksCollection, callback);\r\n if (callbacksCollection.length === 0) {\r\n destroyCallbacksCollection(node);\r\n }\r\n }\r\n}\r\nfunction cleanNode(node) {\r\n // First clean this node, where applicable\r\n if (cleanableNodeTypes[node.nodeType]) {\r\n cleanSingleNode(node);\r\n // ... then its descendants, where applicable\r\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\r\n cleanNodesInList(node.getElementsByTagName(\"*\"));\r\n }\r\n }\r\n return node;\r\n}\r\nfunction removeNode(node) {\r\n cleanNode(node);\r\n if (node.parentNode) {\r\n node.parentNode.removeChild(node);\r\n }\r\n}\r\n// Expose supplemental node cleaning functions.\r\nvar otherNodeCleanerFunctions = [];\r\nfunction addCleaner(fn) {\r\n otherNodeCleanerFunctions.push(fn);\r\n}\r\nfunction removeCleaner(fn) {\r\n var fnIndex = otherNodeCleanerFunctions.indexOf(fn);\r\n if (fnIndex >= 0) {\r\n otherNodeCleanerFunctions.splice(fnIndex, 1);\r\n }\r\n}\r\n// Special support for jQuery here because it's so commonly used.\r\n// Many jQuery plugins (including jquery.tmpl) store data using jQuery's equivalent of domData\r\n// so notify it to tear down any resources associated with the node & descendants here.\r\nfunction cleanjQueryData(node) {\r\n var jQueryCleanNodeFn = jQueryInstance ? jQueryInstance.cleanData : null;\r\n if (jQueryCleanNodeFn) {\r\n jQueryCleanNodeFn([node]);\r\n }\r\n}\r\notherNodeCleanerFunctions.push(cleanjQueryData);\n\n//\r\n// Represent the known event types in a compact way, then at runtime transform it into a hash with event name as key (for fast lookup)\r\nvar knownEvents = {}, knownEventTypesByEventName = {};\r\nvar keyEventTypeName = (options.global.navigator && /Firefox\\/2/i.test(options.global.navigator.userAgent)) ? 'KeyboardEvent' : 'UIEvents';\r\nknownEvents[keyEventTypeName] = ['keyup', 'keydown', 'keypress'];\r\nknownEvents['MouseEvents'] = [\r\n 'click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover',\r\n 'mouseout', 'mouseenter', 'mouseleave'\r\n];\r\nobjectForEach(knownEvents, function (eventType, knownEventsForType) {\r\n if (knownEventsForType.length) {\r\n for (var i = 0, j = knownEventsForType.length; i < j; i++) {\r\n knownEventTypesByEventName[knownEventsForType[i]] = eventType;\r\n }\r\n }\r\n});\r\nfunction isClickOnCheckableElement(element, eventType) {\r\n if ((tagNameLower(element) !== 'input') || !element.type)\r\n return false;\r\n if (eventType.toLowerCase() != 'click')\r\n return false;\r\n var inputType = element.type;\r\n return (inputType == 'checkbox') || (inputType == 'radio');\r\n}\r\n// Workaround for an IE9 issue - https://github.com/SteveSanderson/knockout/issues/406\r\nvar eventsThatMustBeRegisteredUsingAttachEvent = { 'propertychange': true };\r\nvar jQueryEventAttachName;\r\nfunction registerEventHandler(element, eventType, handler, eventOptions) {\r\n if (eventOptions === void 0) { eventOptions = false; }\r\n var wrappedHandler = catchFunctionErrors(handler);\r\n var mustUseAttachEvent = ieVersion && eventsThatMustBeRegisteredUsingAttachEvent[eventType];\r\n var mustUseNative = Boolean(eventOptions);\r\n if (!options.useOnlyNativeEvents && !mustUseAttachEvent && !mustUseNative && jQueryInstance) {\r\n if (!jQueryEventAttachName) {\r\n jQueryEventAttachName = (typeof jQueryInstance(element).on === 'function') ? 'on' : 'bind';\r\n }\r\n jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);\r\n }\r\n else if (!mustUseAttachEvent && typeof element.addEventListener === 'function') {\r\n element.addEventListener(eventType, wrappedHandler, eventOptions);\r\n }\r\n else if (typeof element.attachEvent !== 'undefined') {\r\n var attachEventHandler_1 = function (event) { wrappedHandler.call(element, event); };\r\n var attachEventName_1 = 'on' + eventType;\r\n element.attachEvent(attachEventName_1, attachEventHandler_1);\r\n // IE does not dispose attachEvent handlers automatically (unlike with addEventListener)\r\n // so to avoid leaks, we have to remove them manually. See bug #856\r\n addDisposeCallback(element, function () {\r\n element.detachEvent(attachEventName_1, attachEventHandler_1);\r\n });\r\n }\r\n else {\r\n throw new Error(\"Browser doesn't support addEventListener or attachEvent\");\r\n }\r\n}\r\nfunction triggerEvent(element, eventType) {\r\n if (!(element && element.nodeType)) {\r\n throw new Error('element must be a DOM node when calling triggerEvent');\r\n }\r\n // For click events on checkboxes and radio buttons, jQuery toggles the element checked state *after* the\r\n // event handler runs instead of *before*. (This was fixed in 1.9 for checkboxes but not for radio buttons.)\r\n // IE doesn't change the checked state when you trigger the click event using \"fireEvent\".\r\n // In both cases, we'll use the click method instead.\r\n var useClickWorkaround = isClickOnCheckableElement(element, eventType);\r\n if (!options.useOnlyNativeEvents && jQueryInstance && !useClickWorkaround) {\r\n jQueryInstance(element).trigger(eventType);\r\n }\r\n else if (typeof document.createEvent === 'function') {\r\n if (typeof element.dispatchEvent === 'function') {\r\n var eventCategory = knownEventTypesByEventName[eventType] || 'HTMLEvents';\r\n var event = document.createEvent(eventCategory);\r\n event.initEvent(eventType, true, true, options.global, 0, 0, 0, 0, 0, false, false, false, false, 0, element);\r\n element.dispatchEvent(event);\r\n }\r\n else {\r\n throw new Error(\"The supplied element doesn't support dispatchEvent\");\r\n }\r\n }\r\n else if (useClickWorkaround && element.click) {\r\n element.click();\r\n }\r\n else if (typeof element.fireEvent !== 'undefined') {\r\n element.fireEvent('on' + eventType);\r\n }\r\n else {\r\n throw new Error(\"Browser doesn't support triggering events\");\r\n }\r\n}\n\n//\r\nfunction moveCleanedNodesToContainerElement(nodes) {\r\n // Ensure it's a real array, as we're about to reparent the nodes and\r\n // we don't want the underlying collection to change while we're doing that.\r\n var nodesArray = makeArray(nodes);\r\n var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document;\r\n var container = templateDocument.createElement('div');\r\n for (var i = 0, j = nodesArray.length; i < j; i++) {\r\n container.appendChild(cleanNode(nodesArray[i]));\r\n }\r\n return container;\r\n}\r\nfunction cloneNodes(nodesArray, shouldCleanNodes) {\r\n for (var i = 0, j = nodesArray.length, newNodesArray = []; i < j; i++) {\r\n var clonedNode = nodesArray[i].cloneNode(true);\r\n newNodesArray.push(shouldCleanNodes ? cleanNode(clonedNode) : clonedNode);\r\n }\r\n return newNodesArray;\r\n}\r\nfunction setDomNodeChildren(domNode, childNodes) {\r\n emptyDomNode(domNode);\r\n if (childNodes) {\r\n for (var i = 0, j = childNodes.length; i < j; i++) {\r\n domNode.appendChild(childNodes[i]);\r\n }\r\n }\r\n}\r\nfunction replaceDomNodes(nodeToReplaceOrNodeArray, newNodesArray) {\r\n var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;\r\n if (nodesToReplaceArray.length > 0) {\r\n var insertionPoint = nodesToReplaceArray[0];\r\n var parent = insertionPoint.parentNode;\r\n for (var i = 0, j = newNodesArray.length; i < j; i++) {\r\n parent.insertBefore(newNodesArray[i], insertionPoint);\r\n }\r\n for (i = 0, j = nodesToReplaceArray.length; i < j; i++) {\r\n removeNode(nodesToReplaceArray[i]);\r\n }\r\n }\r\n}\r\nfunction setElementName(element, name) {\r\n element.name = name;\r\n // Workaround IE 6/7 issue\r\n // - https://github.com/SteveSanderson/knockout/issues/197\r\n // - http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/\r\n if (ieVersion <= 7) {\r\n try {\r\n element.mergeAttributes(document.createElement(\"\"), false);\r\n }\r\n catch (e) { } // For IE9 with doc mode \"IE9 Standards\" and browser mode \"IE9 Compatibility View\"\r\n }\r\n}\r\nfunction emptyDomNode(domNode) {\r\n while (domNode.firstChild) {\r\n removeNode(domNode.firstChild);\r\n }\r\n}\n\n//\r\nfunction fixUpContinuousNodeArray(continuousNodeArray, parentNode) {\r\n // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile\r\n // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that\r\n // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been\r\n // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding.\r\n // So, this function translates the old \"map\" output array into its best guess of the set of current DOM nodes.\r\n //\r\n // Rules:\r\n // [A] Any leading nodes that have been removed should be ignored\r\n // These most likely correspond to memoization nodes that were already removed during binding\r\n // See https://github.com/knockout/knockout/pull/440\r\n // [B] Any trailing nodes that have been remove should be ignored\r\n // This prevents the code here from adding unrelated nodes to the array while processing rule [C]\r\n // See https://github.com/knockout/knockout/pull/1903\r\n // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed,\r\n // and include any nodes that have been inserted among the previous collection\r\n if (continuousNodeArray.length) {\r\n // The parent node can be a virtual element; so get the real parent node\r\n parentNode = (parentNode.nodeType === 8 && parentNode.parentNode) || parentNode;\r\n // Rule [A]\r\n while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode) {\r\n continuousNodeArray.splice(0, 1);\r\n }\r\n // Rule [B]\r\n while (continuousNodeArray.length > 1 && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode) {\r\n continuousNodeArray.length--;\r\n }\r\n // Rule [C]\r\n if (continuousNodeArray.length > 1) {\r\n var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];\r\n // Replace with the actual new continuous node set\r\n continuousNodeArray.length = 0;\r\n while (current !== last) {\r\n continuousNodeArray.push(current);\r\n current = current.nextSibling;\r\n }\r\n continuousNodeArray.push(last);\r\n }\r\n }\r\n return continuousNodeArray;\r\n}\r\nfunction setOptionNodeSelectionState(optionNode, isSelected) {\r\n // IE6 sometimes throws \"unknown error\" if you try to write to .selected directly, whereas Firefox struggles with setAttribute. Pick one based on browser.\r\n if (ieVersion < 7) {\r\n optionNode.setAttribute('selected', isSelected);\r\n }\r\n else {\r\n optionNode.selected = isSelected;\r\n }\r\n}\r\nfunction forceRefresh(node) {\r\n // Workaround for an IE9 rendering bug - https://github.com/SteveSanderson/knockout/issues/209\r\n if (ieVersion >= 9) {\r\n // For text nodes and comment nodes (most likely virtual elements), we will have to refresh the container\r\n var elem = node.nodeType == 1 ? node : node.parentNode;\r\n if (elem.style) {\r\n elem.style.zoom = elem.style.zoom;\r\n }\r\n }\r\n}\r\nfunction ensureSelectElementIsRenderedCorrectly(selectElement) {\r\n // Workaround for IE9 rendering bug - it doesn't reliably display all the text in dynamically-added select boxes unless you force it to re-render by updating the width.\r\n // (See https://github.com/SteveSanderson/knockout/issues/312, http://stackoverflow.com/questions/5908494/select-only-shows-first-char-of-selected-option)\r\n // Also fixes IE7 and IE8 bug that causes selects to be zero width if enclosed by 'if' or 'with'. (See issue #839)\r\n if (ieVersion) {\r\n var originalWidth = selectElement.style.width;\r\n selectElement.style.width = 0;\r\n selectElement.style.width = originalWidth;\r\n }\r\n}\n\n/* eslint no-cond-assign: 0 */\r\nvar commentNodesHaveTextProperty = options.document && options.document.createComment('test').text === '';\r\nvar startCommentRegex = commentNodesHaveTextProperty ? /^$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/;\r\nvar endCommentRegex = commentNodesHaveTextProperty ? /^$/ : /^\\s*\\/ko\\s*$/;\r\nvar htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };\r\nfunction isStartComment(node) {\r\n return (node.nodeType == 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\r\n}\r\nfunction isEndComment(node) {\r\n return (node.nodeType == 8) && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\r\n}\r\nfunction isUnmatchedEndComment(node) {\r\n return isEndComment(node) && !get(node, matchedEndCommentDataKey);\r\n}\r\nvar matchedEndCommentDataKey = '__ko_matchedEndComment__';\r\nfunction getVirtualChildren(startComment, allowUnbalanced) {\r\n var currentNode = startComment;\r\n var depth = 1;\r\n var children = [];\r\n while (currentNode = currentNode.nextSibling) {\r\n if (isEndComment(currentNode)) {\r\n set(currentNode, matchedEndCommentDataKey, true);\r\n depth--;\r\n if (depth === 0) {\r\n return children;\r\n }\r\n }\r\n children.push(currentNode);\r\n if (isStartComment(currentNode)) {\r\n depth++;\r\n }\r\n }\r\n if (!allowUnbalanced) {\r\n throw new Error('Cannot find closing comment tag to match: ' + startComment.nodeValue);\r\n }\r\n return null;\r\n}\r\nfunction getMatchingEndComment(startComment, allowUnbalanced) {\r\n var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);\r\n if (allVirtualChildren) {\r\n if (allVirtualChildren.length > 0) {\r\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;\r\n }\r\n return startComment.nextSibling;\r\n }\r\n else {\r\n return null;\r\n } // Must have no matching end comment, and allowUnbalanced is true\r\n}\r\nfunction getUnbalancedChildTags(node) {\r\n // e.g., from