| Current Path : /var/www/clients/client3/web2/web/pub/static/frontend/Magento/luma/en_US/js/bundle/ |
| Current File : /var/www/clients/client3/web2/web/pub/static/frontend/Magento/luma/en_US/js/bundle/bundle1.js |
require.config({"config": {
"jsbuild":{"knockoutjs/knockout.js":"/*!\n * Knockout JavaScript library v3.5.1\n * (c) The Knockout.js team - http://knockoutjs.com/\n * License: MIT (http://www.opensource.org/licenses/mit-license.php)\n */\n\n(function(){\n var DEBUG=true;\n (function(undefined){\n // (0, eval)('this') is a robust way of getting a reference to the global object\n // For details, see http://stackoverflow.com/questions/14119988/return-this-0-evalthis/14120023#14120023\n var window = this || (0, eval)('this'),\n document = window['document'],\n navigator = window['navigator'],\n jQueryInstance = window[\"jQuery\"],\n JSON = window[\"JSON\"];\n\n if (!jQueryInstance && typeof jQuery !== \"undefined\") {\n jQueryInstance = jQuery;\n }\n (function(factory) {\n // Support three module loading scenarios\n if (typeof define === 'function' && define['amd']) {\n // [1] AMD anonymous module\n define(['exports', 'require'], factory);\n } else if (typeof exports === 'object' && typeof module === 'object') {\n // [2] CommonJS/Node.js\n factory(module['exports'] || exports); // module.exports is for Node.js\n } else {\n // [3] No module loader (plain <script> tag) - put directly in global namespace\n factory(window['ko'] = {});\n }\n }(function(koExports, amdRequire){\n// Internally, all KO objects are attached to koExports (even the non-exported ones whose names will be minified by the closure compiler).\n// In the future, the following \"ko\" variable may be made distinct from \"koExports\" so that private objects are not externally reachable.\n var ko = typeof koExports !== 'undefined' ? koExports : {};\n// Google Closure Compiler helpers (used only to make the minified file smaller)\n ko.exportSymbol = function(koPath, object) {\n var tokens = koPath.split(\".\");\n\n // In the future, \"ko\" may become distinct from \"koExports\" (so that non-exported objects are not reachable)\n // At that point, \"target\" would be set to: (typeof koExports !== \"undefined\" ? koExports : ko)\n var target = ko;\n\n for (var i = 0; i < tokens.length - 1; i++)\n target = target[tokens[i]];\n target[tokens[tokens.length - 1]] = object;\n };\n ko.exportProperty = function(owner, publicName, object) {\n owner[publicName] = object;\n };\n ko.version = \"3.5.1\";\n\n ko.exportSymbol('version', ko.version);\n// For any options that may affect various areas of Knockout and aren't directly associated with data binding.\n ko.options = {\n 'deferUpdates': false,\n 'useOnlyNativeEvents': false,\n 'foreachHidesDestroyed': false\n };\n\n//ko.exportSymbol('options', ko.options); // 'options' isn't minified\n ko.utils = (function () {\n var hasOwnProperty = Object.prototype.hasOwnProperty;\n\n function objectForEach(obj, action) {\n for (var prop in obj) {\n if (hasOwnProperty.call(obj, prop)) {\n action(prop, obj[prop]);\n }\n }\n }\n\n function extend(target, source) {\n if (source) {\n for(var prop in source) {\n if(hasOwnProperty.call(source, prop)) {\n target[prop] = source[prop];\n }\n }\n }\n return target;\n }\n\n function setPrototypeOf(obj, proto) {\n obj.__proto__ = proto;\n return obj;\n }\n\n var canSetPrototype = ({ __proto__: [] } instanceof Array);\n var canUseSymbols = !DEBUG && typeof Symbol === 'function';\n\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)\n var knownEvents = {}, knownEventTypesByEventName = {};\n var keyEventTypeName = (navigator && /Firefox\\/2/i.test(navigator.userAgent)) ? 'KeyboardEvent' : 'UIEvents';\n knownEvents[keyEventTypeName] = ['keyup', 'keydown', 'keypress'];\n knownEvents['MouseEvents'] = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove', 'mouseover', 'mouseout', 'mouseenter', 'mouseleave'];\n objectForEach(knownEvents, function(eventType, knownEventsForType) {\n if (knownEventsForType.length) {\n for (var i = 0, j = knownEventsForType.length; i < j; i++)\n knownEventTypesByEventName[knownEventsForType[i]] = eventType;\n }\n });\n var eventsThatMustBeRegisteredUsingAttachEvent = { 'propertychange': true }; // Workaround for an IE9 issue - https://github.com/SteveSanderson/knockout/issues/406\n\n // Detect IE versions for bug workarounds (uses IE conditionals, not UA string, for robustness)\n // Note that, since IE 10 does not support conditional comments, the following logic only detects IE < 10.\n // Currently this is by design, since IE 10+ behaves correctly when treated as a standard browser.\n // If there is a future need to detect specific versions of IE10+, we will amend this.\n var ieVersion = document && (function() {\n var version = 3, div = document.createElement('div'), iElems = div.getElementsByTagName('i');\n\n // Keep constructing conditional HTML blocks until we hit one that resolves to an empty fragment\n while (\n div.innerHTML = '<!--[if gt IE ' + (++version) + ']><i></i><![endif]-->',\n iElems[0]\n ) {}\n return version > 4 ? version : undefined;\n }());\n var isIe6 = ieVersion === 6,\n isIe7 = ieVersion === 7;\n\n function isClickOnCheckableElement(element, eventType) {\n if ((ko.utils.tagNameLower(element) !== \"input\") || !element.type) return false;\n if (eventType.toLowerCase() != \"click\") return false;\n var inputType = element.type;\n return (inputType == \"checkbox\") || (inputType == \"radio\");\n }\n\n // For details on the pattern for changing node classes\n // see: https://github.com/knockout/knockout/issues/1597\n var cssClassNameRegex = /\\S+/g;\n\n var jQueryEventAttachName;\n\n function toggleDomNodeCssClass(node, classNames, shouldHaveClass) {\n var addOrRemoveFn;\n if (classNames) {\n if (typeof node.classList === 'object') {\n addOrRemoveFn = node.classList[shouldHaveClass ? 'add' : 'remove'];\n ko.utils.arrayForEach(classNames.match(cssClassNameRegex), function(className) {\n addOrRemoveFn.call(node.classList, className);\n });\n } else if (typeof node.className['baseVal'] === 'string') {\n // SVG tag .classNames is an SVGAnimatedString instance\n toggleObjectClassPropertyString(node.className, 'baseVal', classNames, shouldHaveClass);\n } else {\n // node.className ought to be a string.\n toggleObjectClassPropertyString(node, 'className', classNames, shouldHaveClass);\n }\n }\n }\n\n function toggleObjectClassPropertyString(obj, prop, classNames, shouldHaveClass) {\n // obj/prop is either a node/'className' or a SVGAnimatedString/'baseVal'.\n var currentClassNames = obj[prop].match(cssClassNameRegex) || [];\n ko.utils.arrayForEach(classNames.match(cssClassNameRegex), function(className) {\n ko.utils.addOrRemoveItem(currentClassNames, className, shouldHaveClass);\n });\n obj[prop] = currentClassNames.join(\" \");\n }\n\n return {\n fieldsIncludedWithJsonPost: ['authenticity_token', /^__RequestVerificationToken(_.*)?$/],\n\n arrayForEach: function (array, action, actionOwner) {\n for (var i = 0, j = array.length; i < j; i++) {\n action.call(actionOwner, array[i], i, array);\n }\n },\n\n arrayIndexOf: typeof Array.prototype.indexOf == \"function\"\n ? function (array, item) {\n return Array.prototype.indexOf.call(array, item);\n }\n : function (array, item) {\n for (var i = 0, j = array.length; i < j; i++) {\n if (array[i] === item)\n return i;\n }\n return -1;\n },\n\n arrayFirst: function (array, predicate, predicateOwner) {\n for (var i = 0, j = array.length; i < j; i++) {\n if (predicate.call(predicateOwner, array[i], i, array))\n return array[i];\n }\n return undefined;\n },\n\n arrayRemoveItem: function (array, itemToRemove) {\n var index = ko.utils.arrayIndexOf(array, itemToRemove);\n if (index > 0) {\n array.splice(index, 1);\n }\n else if (index === 0) {\n array.shift();\n }\n },\n\n arrayGetDistinctValues: function (array) {\n var result = [];\n if (array) {\n ko.utils.arrayForEach(array, function(item) {\n if (ko.utils.arrayIndexOf(result, item) < 0)\n result.push(item);\n });\n }\n return result;\n },\n\n arrayMap: function (array, mapping, mappingOwner) {\n var result = [];\n if (array) {\n for (var i = 0, j = array.length; i < j; i++)\n result.push(mapping.call(mappingOwner, array[i], i));\n }\n return result;\n },\n\n arrayFilter: function (array, predicate, predicateOwner) {\n var result = [];\n if (array) {\n for (var i = 0, j = array.length; i < j; i++)\n if (predicate.call(predicateOwner, array[i], i))\n result.push(array[i]);\n }\n return result;\n },\n\n arrayPushAll: function (array, valuesToPush) {\n if (valuesToPush instanceof Array)\n array.push.apply(array, valuesToPush);\n else\n for (var i = 0, j = valuesToPush.length; i < j; i++)\n array.push(valuesToPush[i]);\n return array;\n },\n\n addOrRemoveItem: function(array, value, included) {\n var existingEntryIndex = ko.utils.arrayIndexOf(ko.utils.peekObservable(array), value);\n if (existingEntryIndex < 0) {\n if (included)\n array.push(value);\n } else {\n if (!included)\n array.splice(existingEntryIndex, 1);\n }\n },\n\n canSetPrototype: canSetPrototype,\n\n extend: extend,\n\n setPrototypeOf: setPrototypeOf,\n\n setPrototypeOfOrExtend: canSetPrototype ? setPrototypeOf : extend,\n\n objectForEach: objectForEach,\n\n objectMap: function(source, mapping, mappingOwner) {\n if (!source)\n return source;\n var target = {};\n for (var prop in source) {\n if (hasOwnProperty.call(source, prop)) {\n target[prop] = mapping.call(mappingOwner, source[prop], prop, source);\n }\n }\n return target;\n },\n\n emptyDomNode: function (domNode) {\n while (domNode.firstChild) {\n ko.removeNode(domNode.firstChild);\n }\n },\n\n moveCleanedNodesToContainerElement: function(nodes) {\n // Ensure it's a real array, as we're about to reparent the nodes and\n // we don't want the underlying collection to change while we're doing that.\n var nodesArray = ko.utils.makeArray(nodes);\n var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document;\n\n var container = templateDocument.createElement('div');\n for (var i = 0, j = nodesArray.length; i < j; i++) {\n container.appendChild(ko.cleanNode(nodesArray[i]));\n }\n return container;\n },\n\n cloneNodes: function (nodesArray, shouldCleanNodes) {\n for (var i = 0, j = nodesArray.length, newNodesArray = []; i < j; i++) {\n var clonedNode = nodesArray[i].cloneNode(true);\n newNodesArray.push(shouldCleanNodes ? ko.cleanNode(clonedNode) : clonedNode);\n }\n return newNodesArray;\n },\n\n setDomNodeChildren: function (domNode, childNodes) {\n ko.utils.emptyDomNode(domNode);\n if (childNodes) {\n for (var i = 0, j = childNodes.length; i < j; i++)\n domNode.appendChild(childNodes[i]);\n }\n },\n\n replaceDomNodes: function (nodeToReplaceOrNodeArray, newNodesArray) {\n var nodesToReplaceArray = nodeToReplaceOrNodeArray.nodeType ? [nodeToReplaceOrNodeArray] : nodeToReplaceOrNodeArray;\n if (nodesToReplaceArray.length > 0) {\n var insertionPoint = nodesToReplaceArray[0];\n var parent = insertionPoint.parentNode;\n for (var i = 0, j = newNodesArray.length; i < j; i++)\n parent.insertBefore(newNodesArray[i], insertionPoint);\n for (var i = 0, j = nodesToReplaceArray.length; i < j; i++) {\n ko.removeNode(nodesToReplaceArray[i]);\n }\n }\n },\n\n fixUpContinuousNodeArray: function(continuousNodeArray, parentNode) {\n // Before acting on a set of nodes that were previously outputted by a template function, we have to reconcile\n // them against what is in the DOM right now. It may be that some of the nodes have already been removed, or that\n // new nodes might have been inserted in the middle, for example by a binding. Also, there may previously have been\n // leading comment nodes (created by rewritten string-based templates) that have since been removed during binding.\n // So, this function translates the old \"map\" output array into its best guess of the set of current DOM nodes.\n //\n // Rules:\n // [A] Any leading nodes that have been removed should be ignored\n // These most likely correspond to memoization nodes that were already removed during binding\n // See https://github.com/knockout/knockout/pull/440\n // [B] Any trailing nodes that have been remove should be ignored\n // This prevents the code here from adding unrelated nodes to the array while processing rule [C]\n // See https://github.com/knockout/knockout/pull/1903\n // [C] We want to output a continuous series of nodes. So, ignore any nodes that have already been removed,\n // and include any nodes that have been inserted among the previous collection\n\n if (continuousNodeArray.length) {\n // The parent node can be a virtual element; so get the real parent node\n parentNode = (parentNode.nodeType === 8 && parentNode.parentNode) || parentNode;\n\n // Rule [A]\n while (continuousNodeArray.length && continuousNodeArray[0].parentNode !== parentNode)\n continuousNodeArray.splice(0, 1);\n\n // Rule [B]\n while (continuousNodeArray.length > 1 && continuousNodeArray[continuousNodeArray.length - 1].parentNode !== parentNode)\n continuousNodeArray.length--;\n\n // Rule [C]\n if (continuousNodeArray.length > 1) {\n var current = continuousNodeArray[0], last = continuousNodeArray[continuousNodeArray.length - 1];\n // Replace with the actual new continuous node set\n continuousNodeArray.length = 0;\n while (current !== last) {\n continuousNodeArray.push(current);\n current = current.nextSibling;\n }\n continuousNodeArray.push(last);\n }\n }\n return continuousNodeArray;\n },\n\n setOptionNodeSelectionState: function (optionNode, isSelected) {\n // IE6 sometimes throws \"unknown error\" if you try to write to .selected directly, whereas Firefox struggles with setAttribute. Pick one based on browser.\n if (ieVersion < 7)\n optionNode.setAttribute(\"selected\", isSelected);\n else\n optionNode.selected = isSelected;\n },\n\n stringTrim: function (string) {\n return string === null || string === undefined ? '' :\n string.trim ?\n string.trim() :\n string.toString().replace(/^[\\s\\xa0]+|[\\s\\xa0]+$/g, '');\n },\n\n stringStartsWith: function (string, startsWith) {\n string = string || \"\";\n if (startsWith.length > string.length)\n return false;\n return string.substring(0, startsWith.length) === startsWith;\n },\n\n domNodeIsContainedBy: function (node, containedByNode) {\n if (node === containedByNode)\n return true;\n if (node.nodeType === 11)\n return false; // Fixes issue #1162 - can't use node.contains for document fragments on IE8\n if (containedByNode.contains)\n return containedByNode.contains(node.nodeType !== 1 ? node.parentNode : node);\n if (containedByNode.compareDocumentPosition)\n return (containedByNode.compareDocumentPosition(node) & 16) == 16;\n while (node && node != containedByNode) {\n node = node.parentNode;\n }\n return !!node;\n },\n\n domNodeIsAttachedToDocument: function (node) {\n return ko.utils.domNodeIsContainedBy(node, node.ownerDocument.documentElement);\n },\n\n anyDomNodeIsAttachedToDocument: function(nodes) {\n return !!ko.utils.arrayFirst(nodes, ko.utils.domNodeIsAttachedToDocument);\n },\n\n tagNameLower: function(element) {\n // For HTML elements, tagName will always be upper case; for XHTML elements, it'll be lower case.\n // Possible future optimization: If we know it's an element from an XHTML document (not HTML),\n // we don't need to do the .toLowerCase() as it will always be lower case anyway.\n return element && element.tagName && element.tagName.toLowerCase();\n },\n\n catchFunctionErrors: function (delegate) {\n return ko['onError'] ? function () {\n try {\n return delegate.apply(this, arguments);\n } catch (e) {\n ko['onError'] && ko['onError'](e);\n throw e;\n }\n } : delegate;\n },\n\n setTimeout: function (handler, timeout) {\n return setTimeout(ko.utils.catchFunctionErrors(handler), timeout);\n },\n\n deferError: function (error) {\n setTimeout(function () {\n ko['onError'] && ko['onError'](error);\n throw error;\n }, 0);\n },\n\n registerEventHandler: function (element, eventType, handler) {\n var wrappedHandler = ko.utils.catchFunctionErrors(handler);\n\n var mustUseAttachEvent = eventsThatMustBeRegisteredUsingAttachEvent[eventType];\n if (!ko.options['useOnlyNativeEvents'] && !mustUseAttachEvent && jQueryInstance) {\n if (!jQueryEventAttachName) {\n jQueryEventAttachName = (typeof jQueryInstance(element)['on'] == 'function') ? 'on' : 'bind';\n }\n jQueryInstance(element)[jQueryEventAttachName](eventType, wrappedHandler);\n } else if (!mustUseAttachEvent && typeof element.addEventListener == \"function\")\n element.addEventListener(eventType, wrappedHandler, false);\n else if (typeof element.attachEvent != \"undefined\") {\n var attachEventHandler = function (event) { wrappedHandler.call(element, event); },\n attachEventName = \"on\" + eventType;\n element.attachEvent(attachEventName, attachEventHandler);\n\n // IE does not dispose attachEvent handlers automatically (unlike with addEventListener)\n // so to avoid leaks, we have to remove them manually. See bug #856\n ko.utils.domNodeDisposal.addDisposeCallback(element, function() {\n element.detachEvent(attachEventName, attachEventHandler);\n });\n } else\n throw new Error(\"Browser doesn't support addEventListener or attachEvent\");\n },\n\n triggerEvent: function (element, eventType) {\n if (!(element && element.nodeType))\n throw new Error(\"element must be a DOM node when calling triggerEvent\");\n\n // For click events on checkboxes and radio buttons, jQuery toggles the element checked state *after* the\n // event handler runs instead of *before*. (This was fixed in 1.9 for checkboxes but not for radio buttons.)\n // IE doesn't change the checked state when you trigger the click event using \"fireEvent\".\n // In both cases, we'll use the click method instead.\n var useClickWorkaround = isClickOnCheckableElement(element, eventType);\n\n if (!ko.options['useOnlyNativeEvents'] && jQueryInstance && !useClickWorkaround) {\n jQueryInstance(element)['trigger'](eventType);\n } else if (typeof document.createEvent == \"function\") {\n if (typeof element.dispatchEvent == \"function\") {\n var eventCategory = knownEventTypesByEventName[eventType] || \"HTMLEvents\";\n var event = document.createEvent(eventCategory);\n event.initEvent(eventType, true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, element);\n element.dispatchEvent(event);\n }\n else\n throw new Error(\"The supplied element doesn't support dispatchEvent\");\n } else if (useClickWorkaround && element.click) {\n element.click();\n } else if (typeof element.fireEvent != \"undefined\") {\n element.fireEvent(\"on\" + eventType);\n } else {\n throw new Error(\"Browser doesn't support triggering events\");\n }\n },\n\n unwrapObservable: function (value) {\n return ko.isObservable(value) ? value() : value;\n },\n\n peekObservable: function (value) {\n return ko.isObservable(value) ? value.peek() : value;\n },\n\n toggleDomNodeCssClass: toggleDomNodeCssClass,\n\n setTextContent: function(element, textContent) {\n var value = ko.utils.unwrapObservable(textContent);\n if ((value === null) || (value === undefined))\n value = \"\";\n\n // We need there to be exactly one child: a text node.\n // If there are no children, more than one, or if it's not a text node,\n // we'll clear everything and create a single text node.\n var innerTextNode = ko.virtualElements.firstChild(element);\n if (!innerTextNode || innerTextNode.nodeType != 3 || ko.virtualElements.nextSibling(innerTextNode)) {\n ko.virtualElements.setDomNodeChildren(element, [element.ownerDocument.createTextNode(value)]);\n } else {\n innerTextNode.data = value;\n }\n\n ko.utils.forceRefresh(element);\n },\n\n setElementName: function(element, name) {\n element.name = name;\n\n // Workaround IE 6/7 issue\n // - https://github.com/SteveSanderson/knockout/issues/197\n // - http://www.matts411.com/post/setting_the_name_attribute_in_ie_dom/\n if (ieVersion <= 7) {\n try {\n var escapedName = element.name.replace(/[&<>'\"]/g, function(r){ return \"&#\" + r.charCodeAt(0) + \";\"; });\n element.mergeAttributes(document.createElement(\"<input name='\" + escapedName + \"'/>\"), false);\n }\n catch(e) {} // For IE9 with doc mode \"IE9 Standards\" and browser mode \"IE9 Compatibility View\"\n }\n },\n\n forceRefresh: function(node) {\n // Workaround for an IE9 rendering bug - https://github.com/SteveSanderson/knockout/issues/209\n if (ieVersion >= 9) {\n // For text nodes and comment nodes (most likely virtual elements), we will have to refresh the container\n var elem = node.nodeType == 1 ? node : node.parentNode;\n if (elem.style)\n elem.style.zoom = elem.style.zoom;\n }\n },\n\n ensureSelectElementIsRenderedCorrectly: function(selectElement) {\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.\n // (See https://github.com/SteveSanderson/knockout/issues/312, http://stackoverflow.com/questions/5908494/select-only-shows-first-char-of-selected-option)\n // Also fixes IE7 and IE8 bug that causes selects to be zero width if enclosed by 'if' or 'with'. (See issue #839)\n if (ieVersion) {\n var originalWidth = selectElement.style.width;\n selectElement.style.width = 0;\n selectElement.style.width = originalWidth;\n }\n },\n\n range: function (min, max) {\n min = ko.utils.unwrapObservable(min);\n max = ko.utils.unwrapObservable(max);\n var result = [];\n for (var i = min; i <= max; i++)\n result.push(i);\n return result;\n },\n\n makeArray: function(arrayLikeObject) {\n var result = [];\n for (var i = 0, j = arrayLikeObject.length; i < j; i++) {\n result.push(arrayLikeObject[i]);\n };\n return result;\n },\n\n createSymbolOrString: function(identifier) {\n return canUseSymbols ? Symbol(identifier) : identifier;\n },\n\n isIe6 : isIe6,\n isIe7 : isIe7,\n ieVersion : ieVersion,\n\n getFormFields: function(form, fieldName) {\n var fields = ko.utils.makeArray(form.getElementsByTagName(\"input\")).concat(ko.utils.makeArray(form.getElementsByTagName(\"textarea\")));\n var isMatchingField = (typeof fieldName == 'string')\n ? function(field) { return field.name === fieldName }\n : function(field) { return fieldName.test(field.name) }; // Treat fieldName as regex or object containing predicate\n var matches = [];\n for (var i = fields.length - 1; i >= 0; i--) {\n if (isMatchingField(fields[i]))\n matches.push(fields[i]);\n };\n return matches;\n },\n\n parseJson: function (jsonString) {\n if (typeof jsonString == \"string\") {\n jsonString = ko.utils.stringTrim(jsonString);\n if (jsonString) {\n if (JSON && JSON.parse) // Use native parsing where available\n return JSON.parse(jsonString);\n return (new Function(\"return \" + jsonString))(); // Fallback on less safe parsing for older browsers\n }\n }\n return null;\n },\n\n stringifyJson: function (data, replacer, space) { // replacer and space are optional\n if (!JSON || !JSON.stringify)\n throw new Error(\"Cannot find JSON.stringify(). Some browsers (e.g., IE < 8) don't support it natively, but you can overcome this by adding a script reference to json2.js, downloadable from http://www.json.org/json2.js\");\n return JSON.stringify(ko.utils.unwrapObservable(data), replacer, space);\n },\n\n postJson: function (urlOrForm, data, options) {\n options = options || {};\n var params = options['params'] || {};\n var includeFields = options['includeFields'] || this.fieldsIncludedWithJsonPost;\n var url = urlOrForm;\n\n // If we were given a form, use its 'action' URL and pick out any requested field values\n if((typeof urlOrForm == 'object') && (ko.utils.tagNameLower(urlOrForm) === \"form\")) {\n var originalForm = urlOrForm;\n url = originalForm.action;\n for (var i = includeFields.length - 1; i >= 0; i--) {\n var fields = ko.utils.getFormFields(originalForm, includeFields[i]);\n for (var j = fields.length - 1; j >= 0; j--)\n params[fields[j].name] = fields[j].value;\n }\n }\n\n data = ko.utils.unwrapObservable(data);\n var form = document.createElement(\"form\");\n form.style.display = \"none\";\n form.action = url;\n form.method = \"post\";\n for (var key in data) {\n // Since 'data' this is a model object, we include all properties including those inherited from its prototype\n var input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = key;\n input.value = ko.utils.stringifyJson(ko.utils.unwrapObservable(data[key]));\n form.appendChild(input);\n }\n objectForEach(params, function(key, value) {\n var input = document.createElement(\"input\");\n input.type = \"hidden\";\n input.name = key;\n input.value = value;\n form.appendChild(input);\n });\n document.body.appendChild(form);\n options['submitter'] ? options['submitter'](form) : form.submit();\n setTimeout(function () { form.parentNode.removeChild(form); }, 0);\n }\n }\n }());\n\n ko.exportSymbol('utils', ko.utils);\n ko.exportSymbol('utils.arrayForEach', ko.utils.arrayForEach);\n ko.exportSymbol('utils.arrayFirst', ko.utils.arrayFirst);\n ko.exportSymbol('utils.arrayFilter', ko.utils.arrayFilter);\n ko.exportSymbol('utils.arrayGetDistinctValues', ko.utils.arrayGetDistinctValues);\n ko.exportSymbol('utils.arrayIndexOf', ko.utils.arrayIndexOf);\n ko.exportSymbol('utils.arrayMap', ko.utils.arrayMap);\n ko.exportSymbol('utils.arrayPushAll', ko.utils.arrayPushAll);\n ko.exportSymbol('utils.arrayRemoveItem', ko.utils.arrayRemoveItem);\n ko.exportSymbol('utils.cloneNodes', ko.utils.cloneNodes);\n ko.exportSymbol('utils.createSymbolOrString', ko.utils.createSymbolOrString);\n ko.exportSymbol('utils.extend', ko.utils.extend);\n ko.exportSymbol('utils.fieldsIncludedWithJsonPost', ko.utils.fieldsIncludedWithJsonPost);\n ko.exportSymbol('utils.getFormFields', ko.utils.getFormFields);\n ko.exportSymbol('utils.objectMap', ko.utils.objectMap);\n ko.exportSymbol('utils.peekObservable', ko.utils.peekObservable);\n ko.exportSymbol('utils.postJson', ko.utils.postJson);\n ko.exportSymbol('utils.parseJson', ko.utils.parseJson);\n ko.exportSymbol('utils.registerEventHandler', ko.utils.registerEventHandler);\n ko.exportSymbol('utils.stringifyJson', ko.utils.stringifyJson);\n ko.exportSymbol('utils.range', ko.utils.range);\n ko.exportSymbol('utils.toggleDomNodeCssClass', ko.utils.toggleDomNodeCssClass);\n ko.exportSymbol('utils.triggerEvent', ko.utils.triggerEvent);\n ko.exportSymbol('utils.unwrapObservable', ko.utils.unwrapObservable);\n ko.exportSymbol('utils.objectForEach', ko.utils.objectForEach);\n ko.exportSymbol('utils.addOrRemoveItem', ko.utils.addOrRemoveItem);\n ko.exportSymbol('utils.setTextContent', ko.utils.setTextContent);\n ko.exportSymbol('unwrap', ko.utils.unwrapObservable); // Convenient shorthand, because this is used so commonly\n\n if (!Function.prototype['bind']) {\n // Function.prototype.bind is a standard part of ECMAScript 5th Edition (December 2009, http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf)\n // In case the browser doesn't implement it natively, provide a JavaScript implementation. This implementation is based on the one in prototype.js\n Function.prototype['bind'] = function (object) {\n var originalFunction = this;\n if (arguments.length === 1) {\n return function () {\n return originalFunction.apply(object, arguments);\n };\n } else {\n var partialArgs = Array.prototype.slice.call(arguments, 1);\n return function () {\n var args = partialArgs.slice(0);\n args.push.apply(args, arguments);\n return originalFunction.apply(object, args);\n };\n }\n };\n }\n\n ko.utils.domData = new (function () {\n var uniqueId = 0;\n var dataStoreKeyExpandoPropertyName = \"__ko__\" + (new Date).getTime();\n var dataStore = {};\n\n var getDataForNode, clear;\n if (!ko.utils.ieVersion) {\n // We considered using WeakMap, but it has a problem in IE 11 and Edge that prevents using\n // it cross-window, so instead we just store the data directly on the node.\n // See https://github.com/knockout/knockout/issues/2141\n getDataForNode = function (node, createIfNotFound) {\n var dataForNode = node[dataStoreKeyExpandoPropertyName];\n if (!dataForNode && createIfNotFound) {\n dataForNode = node[dataStoreKeyExpandoPropertyName] = {};\n }\n return dataForNode;\n };\n clear = function (node) {\n if (node[dataStoreKeyExpandoPropertyName]) {\n delete node[dataStoreKeyExpandoPropertyName];\n return true; // Exposing \"did clean\" flag purely so specs can infer whether things have been cleaned up as intended\n }\n return false;\n };\n } else {\n // Old IE versions have memory issues if you store objects on the node, so we use a\n // separate data storage and link to it from the node using a string key.\n getDataForNode = function (node, createIfNotFound) {\n var dataStoreKey = node[dataStoreKeyExpandoPropertyName];\n var hasExistingDataStore = dataStoreKey && (dataStoreKey !== \"null\") && dataStore[dataStoreKey];\n if (!hasExistingDataStore) {\n if (!createIfNotFound)\n return undefined;\n dataStoreKey = node[dataStoreKeyExpandoPropertyName] = \"ko\" + uniqueId++;\n dataStore[dataStoreKey] = {};\n }\n return dataStore[dataStoreKey];\n };\n clear = function (node) {\n var dataStoreKey = node[dataStoreKeyExpandoPropertyName];\n if (dataStoreKey) {\n delete dataStore[dataStoreKey];\n node[dataStoreKeyExpandoPropertyName] = null;\n return true; // Exposing \"did clean\" flag purely so specs can infer whether things have been cleaned up as intended\n }\n return false;\n };\n }\n\n return {\n get: function (node, key) {\n var dataForNode = getDataForNode(node, false);\n return dataForNode && dataForNode[key];\n },\n set: function (node, key, value) {\n // Make sure we don't actually create a new domData key if we are actually deleting a value\n var dataForNode = getDataForNode(node, value !== undefined /* createIfNotFound */);\n dataForNode && (dataForNode[key] = value);\n },\n getOrSet: function (node, key, value) {\n var dataForNode = getDataForNode(node, true /* createIfNotFound */);\n return dataForNode[key] || (dataForNode[key] = value);\n },\n clear: clear,\n\n nextKey: function () {\n return (uniqueId++) + dataStoreKeyExpandoPropertyName;\n }\n };\n })();\n\n ko.exportSymbol('utils.domData', ko.utils.domData);\n ko.exportSymbol('utils.domData.clear', ko.utils.domData.clear); // Exporting only so specs can clear up after themselves fully\n\n ko.utils.domNodeDisposal = new (function () {\n var domDataKey = ko.utils.domData.nextKey();\n var cleanableNodeTypes = { 1: true, 8: true, 9: true }; // Element, Comment, Document\n var cleanableNodeTypesWithDescendants = { 1: true, 9: true }; // Element, Document\n\n function getDisposeCallbacksCollection(node, createIfNotFound) {\n var allDisposeCallbacks = ko.utils.domData.get(node, domDataKey);\n if ((allDisposeCallbacks === undefined) && createIfNotFound) {\n allDisposeCallbacks = [];\n ko.utils.domData.set(node, domDataKey, allDisposeCallbacks);\n }\n return allDisposeCallbacks;\n }\n function destroyCallbacksCollection(node) {\n ko.utils.domData.set(node, domDataKey, undefined);\n }\n\n function cleanSingleNode(node) {\n // Run all the dispose callbacks\n var callbacks = getDisposeCallbacksCollection(node, false);\n if (callbacks) {\n callbacks = callbacks.slice(0); // Clone, as the array may be modified during iteration (typically, callbacks will remove themselves)\n for (var i = 0; i < callbacks.length; i++)\n callbacks[i](node);\n }\n\n // Erase the DOM data\n ko.utils.domData.clear(node);\n\n // Perform cleanup needed by external libraries (currently only jQuery, but can be extended)\n ko.utils.domNodeDisposal[\"cleanExternalData\"](node);\n\n // Clear any immediate-child comment nodes, as these wouldn't have been found by\n // node.getElementsByTagName(\"*\") in cleanNode() (comment nodes aren't elements)\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.childNodes, true/*onlyComments*/);\n }\n }\n\n function cleanNodesInList(nodeList, onlyComments) {\n var cleanedNodes = [], lastCleanedNode;\n for (var i = 0; i < nodeList.length; i++) {\n if (!onlyComments || nodeList[i].nodeType === 8) {\n cleanSingleNode(cleanedNodes[cleanedNodes.length] = lastCleanedNode = nodeList[i]);\n if (nodeList[i] !== lastCleanedNode) {\n while (i-- && ko.utils.arrayIndexOf(cleanedNodes, nodeList[i]) == -1) {}\n }\n }\n }\n }\n\n return {\n addDisposeCallback : function(node, callback) {\n if (typeof callback != \"function\")\n throw new Error(\"Callback must be a function\");\n getDisposeCallbacksCollection(node, true).push(callback);\n },\n\n removeDisposeCallback : function(node, callback) {\n var callbacksCollection = getDisposeCallbacksCollection(node, false);\n if (callbacksCollection) {\n ko.utils.arrayRemoveItem(callbacksCollection, callback);\n if (callbacksCollection.length == 0)\n destroyCallbacksCollection(node);\n }\n },\n\n cleanNode : function(node) {\n ko.dependencyDetection.ignore(function () {\n // First clean this node, where applicable\n if (cleanableNodeTypes[node.nodeType]) {\n cleanSingleNode(node);\n\n // ... then its descendants, where applicable\n if (cleanableNodeTypesWithDescendants[node.nodeType]) {\n cleanNodesInList(node.getElementsByTagName(\"*\"));\n }\n }\n });\n\n return node;\n },\n\n removeNode : function(node) {\n ko.cleanNode(node);\n if (node.parentNode)\n node.parentNode.removeChild(node);\n },\n\n \"cleanExternalData\" : function (node) {\n // Special support for jQuery here because it's so commonly used.\n // Many jQuery plugins (including jquery.tmpl) store data using jQuery's equivalent of domData\n // so notify it to tear down any resources associated with the node & descendants here.\n if (jQueryInstance && (typeof jQueryInstance['cleanData'] == \"function\"))\n jQueryInstance['cleanData']([node]);\n }\n };\n })();\n ko.cleanNode = ko.utils.domNodeDisposal.cleanNode; // Shorthand name for convenience\n ko.removeNode = ko.utils.domNodeDisposal.removeNode; // Shorthand name for convenience\n ko.exportSymbol('cleanNode', ko.cleanNode);\n ko.exportSymbol('removeNode', ko.removeNode);\n ko.exportSymbol('utils.domNodeDisposal', ko.utils.domNodeDisposal);\n ko.exportSymbol('utils.domNodeDisposal.addDisposeCallback', ko.utils.domNodeDisposal.addDisposeCallback);\n ko.exportSymbol('utils.domNodeDisposal.removeDisposeCallback', ko.utils.domNodeDisposal.removeDisposeCallback);\n (function () {\n var none = [0, \"\", \"\"],\n table = [1, \"<table>\", \"</table>\"],\n tbody = [2, \"<table><tbody>\", \"</tbody></table>\"],\n tr = [3, \"<table><tbody><tr>\", \"</tr></tbody></table>\"],\n select = [1, \"<select multiple='multiple'>\", \"</select>\"],\n lookup = {\n 'thead': table,\n 'tbody': table,\n 'tfoot': table,\n 'tr': tbody,\n 'td': tr,\n 'th': tr,\n 'option': select,\n 'optgroup': select\n },\n\n // This is needed for old IE if you're *not* using either jQuery or innerShiv. Doesn't affect other cases.\n mayRequireCreateElementHack = ko.utils.ieVersion <= 8;\n\n function getWrap(tags) {\n var m = tags.match(/^(?:<!--.*?-->\\s*?)*?<([a-z]+)[\\s>]/);\n return (m && lookup[m[1]]) || none;\n }\n\n function simpleHtmlParse(html, documentContext) {\n documentContext || (documentContext = document);\n var windowContext = documentContext['parentWindow'] || documentContext['defaultView'] || window;\n\n // Based on jQuery's \"clean\" function, but only accounting for table-related elements.\n // If you have referenced jQuery, this won't be used anyway - KO will use jQuery's \"clean\" function directly\n\n // Note that there's still an issue in IE < 9 whereby it will discard comment nodes that are the first child of\n // a descendant node. For example: \"<div><!-- mycomment -->abc</div>\" will get parsed as \"<div>abc</div>\"\n // This won't affect anyone who has referenced jQuery, and there's always the workaround of inserting a dummy node\n // (possibly a text node) in front of the comment. So, KO does not attempt to workaround this IE issue automatically at present.\n\n // Trim whitespace, otherwise indexOf won't work as expected\n var tags = ko.utils.stringTrim(html).toLowerCase(), div = documentContext.createElement(\"div\"),\n wrap = getWrap(tags),\n depth = wrap[0];\n\n // Go to html and back, then peel off extra wrappers\n // Note that we always prefix with some dummy text, because otherwise, IE<9 will strip out leading comment nodes in descendants. Total madness.\n var markup = \"ignored<div>\" + wrap[1] + html + wrap[2] + \"</div>\";\n if (typeof windowContext['innerShiv'] == \"function\") {\n // Note that innerShiv is deprecated in favour of html5shiv. We should consider adding\n // support for html5shiv (except if no explicit support is needed, e.g., if html5shiv\n // somehow shims the native APIs so it just works anyway)\n div.appendChild(windowContext['innerShiv'](markup));\n } else {\n if (mayRequireCreateElementHack) {\n // The document.createElement('my-element') trick to enable custom elements in IE6-8\n // only works if we assign innerHTML on an element associated with that document.\n documentContext.body.appendChild(div);\n }\n\n div.innerHTML = markup;\n\n if (mayRequireCreateElementHack) {\n div.parentNode.removeChild(div);\n }\n }\n\n // Move to the right depth\n while (depth--)\n div = div.lastChild;\n\n return ko.utils.makeArray(div.lastChild.childNodes);\n }\n\n function jQueryHtmlParse(html, documentContext) {\n // jQuery's \"parseHTML\" function was introduced in jQuery 1.8.0 and is a documented public API.\n if (jQueryInstance['parseHTML']) {\n return jQueryInstance['parseHTML'](html, documentContext) || []; // Ensure we always return an array and never null\n } else {\n // For jQuery < 1.8.0, we fall back on the undocumented internal \"clean\" function.\n var elems = jQueryInstance['clean']([html], documentContext);\n\n // As of jQuery 1.7.1, jQuery parses the HTML by appending it to some dummy parent nodes held in an in-memory document fragment.\n // Unfortunately, it never clears the dummy parent nodes from the document fragment, so it leaks memory over time.\n // Fix this by finding the top-most dummy parent element, and detaching it from its owner fragment.\n if (elems && elems[0]) {\n // Find the top-most parent element that's a direct child of a document fragment\n var elem = elems[0];\n while (elem.parentNode && elem.parentNode.nodeType !== 11 /* i.e., DocumentFragment */)\n elem = elem.parentNode;\n // ... then detach it\n if (elem.parentNode)\n elem.parentNode.removeChild(elem);\n }\n\n return elems;\n }\n }\n\n ko.utils.parseHtmlFragment = function(html, documentContext) {\n return jQueryInstance ?\n jQueryHtmlParse(html, documentContext) : // As below, benefit from jQuery's optimisations where possible\n simpleHtmlParse(html, documentContext); // ... otherwise, this simple logic will do in most common cases.\n };\n\n ko.utils.parseHtmlForTemplateNodes = function(html, documentContext) {\n var nodes = ko.utils.parseHtmlFragment(html, documentContext);\n return (nodes.length && nodes[0].parentElement) || ko.utils.moveCleanedNodesToContainerElement(nodes);\n };\n\n ko.utils.setHtml = function(node, html) {\n ko.utils.emptyDomNode(node);\n\n // There's no legitimate reason to display a stringified observable without unwrapping it, so we'll unwrap it\n html = ko.utils.unwrapObservable(html);\n\n if ((html !== null) && (html !== undefined)) {\n if (typeof html != 'string')\n html = html.toString();\n\n // jQuery contains a lot of sophisticated code to parse arbitrary HTML fragments,\n // for example <tr> elements which are not normally allowed to exist on their own.\n // If you've referenced jQuery we'll use that rather than duplicating its code.\n if (jQueryInstance) {\n jQueryInstance(node)['html'](html);\n } else {\n // ... otherwise, use KO's own parsing logic.\n var parsedNodes = ko.utils.parseHtmlFragment(html, node.ownerDocument);\n for (var i = 0; i < parsedNodes.length; i++)\n node.appendChild(parsedNodes[i]);\n }\n }\n };\n })();\n\n ko.exportSymbol('utils.parseHtmlFragment', ko.utils.parseHtmlFragment);\n ko.exportSymbol('utils.setHtml', ko.utils.setHtml);\n\n ko.memoization = (function () {\n var memos = {};\n\n function randomMax8HexChars() {\n return (((1 + Math.random()) * 0x100000000) | 0).toString(16).substring(1);\n }\n function generateRandomId() {\n return randomMax8HexChars() + randomMax8HexChars();\n }\n function findMemoNodes(rootNode, appendToArray) {\n if (!rootNode)\n return;\n if (rootNode.nodeType == 8) {\n var memoId = ko.memoization.parseMemoText(rootNode.nodeValue);\n if (memoId != null)\n appendToArray.push({ domNode: rootNode, memoId: memoId });\n } else if (rootNode.nodeType == 1) {\n for (var i = 0, childNodes = rootNode.childNodes, j = childNodes.length; i < j; i++)\n findMemoNodes(childNodes[i], appendToArray);\n }\n }\n\n return {\n memoize: function (callback) {\n if (typeof callback != \"function\")\n throw new Error(\"You can only pass a function to ko.memoization.memoize()\");\n var memoId = generateRandomId();\n memos[memoId] = callback;\n return \"<!--[ko_memo:\" + memoId + \"]-->\";\n },\n\n unmemoize: function (memoId, callbackParams) {\n var callback = memos[memoId];\n if (callback === undefined)\n throw new Error(\"Couldn't find any memo with ID \" + memoId + \". Perhaps it's already been unmemoized.\");\n try {\n callback.apply(null, callbackParams || []);\n return true;\n }\n finally { delete memos[memoId]; }\n },\n\n unmemoizeDomNodeAndDescendants: function (domNode, extraCallbackParamsArray) {\n var memos = [];\n findMemoNodes(domNode, memos);\n for (var i = 0, j = memos.length; i < j; i++) {\n var node = memos[i].domNode;\n var combinedParams = [node];\n if (extraCallbackParamsArray)\n ko.utils.arrayPushAll(combinedParams, extraCallbackParamsArray);\n ko.memoization.unmemoize(memos[i].memoId, combinedParams);\n node.nodeValue = \"\"; // Neuter this node so we don't try to unmemoize it again\n if (node.parentNode)\n node.parentNode.removeChild(node); // If possible, erase it totally (not always possible - someone else might just hold a reference to it then call unmemoizeDomNodeAndDescendants again)\n }\n },\n\n parseMemoText: function (memoText) {\n var match = memoText.match(/^\\[ko_memo\\:(.*?)\\]$/);\n return match ? match[1] : null;\n }\n };\n })();\n\n ko.exportSymbol('memoization', ko.memoization);\n ko.exportSymbol('memoization.memoize', ko.memoization.memoize);\n ko.exportSymbol('memoization.unmemoize', ko.memoization.unmemoize);\n ko.exportSymbol('memoization.parseMemoText', ko.memoization.parseMemoText);\n ko.exportSymbol('memoization.unmemoizeDomNodeAndDescendants', ko.memoization.unmemoizeDomNodeAndDescendants);\n ko.tasks = (function () {\n var scheduler,\n taskQueue = [],\n taskQueueLength = 0,\n nextHandle = 1,\n nextIndexToProcess = 0;\n\n if (window['MutationObserver']) {\n // Chrome 27+, Firefox 14+, IE 11+, Opera 15+, Safari 6.1+\n // From https://github.com/petkaantonov/bluebird * Copyright (c) 2014 Petka Antonov * License: MIT\n scheduler = (function (callback) {\n var div = document.createElement(\"div\");\n new MutationObserver(callback).observe(div, {attributes: true});\n return function () { div.classList.toggle(\"foo\"); };\n })(scheduledProcess);\n } else if (document && \"onreadystatechange\" in document.createElement(\"script\")) {\n // IE 6-10\n // From https://github.com/YuzuJS/setImmediate * Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic Denicola * License: MIT\n scheduler = function (callback) {\n var script = document.createElement(\"script\");\n script.onreadystatechange = function () {\n script.onreadystatechange = null;\n document.documentElement.removeChild(script);\n script = null;\n callback();\n };\n document.documentElement.appendChild(script);\n };\n } else {\n scheduler = function (callback) {\n setTimeout(callback, 0);\n };\n }\n\n function processTasks() {\n if (taskQueueLength) {\n // Each mark represents the end of a logical group of tasks and the number of these groups is\n // limited to prevent unchecked recursion.\n var mark = taskQueueLength, countMarks = 0;\n\n // nextIndexToProcess keeps track of where we are in the queue; processTasks can be called recursively without issue\n for (var task; nextIndexToProcess < taskQueueLength; ) {\n if (task = taskQueue[nextIndexToProcess++]) {\n if (nextIndexToProcess > mark) {\n if (++countMarks >= 5000) {\n nextIndexToProcess = taskQueueLength; // skip all tasks remaining in the queue since any of them could be causing the recursion\n ko.utils.deferError(Error(\"'Too much recursion' after processing \" + countMarks + \" task groups.\"));\n break;\n }\n mark = taskQueueLength;\n }\n try {\n task();\n } catch (ex) {\n ko.utils.deferError(ex);\n }\n }\n }\n }\n }\n\n function scheduledProcess() {\n processTasks();\n\n // Reset the queue\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0;\n }\n\n function scheduleTaskProcessing() {\n ko.tasks['scheduler'](scheduledProcess);\n }\n\n var tasks = {\n 'scheduler': scheduler, // Allow overriding the scheduler\n\n schedule: function (func) {\n if (!taskQueueLength) {\n scheduleTaskProcessing();\n }\n\n taskQueue[taskQueueLength++] = func;\n return nextHandle++;\n },\n\n cancel: function (handle) {\n var index = handle - (nextHandle - taskQueueLength);\n if (index >= nextIndexToProcess && index < taskQueueLength) {\n taskQueue[index] = null;\n }\n },\n\n // For testing only: reset the queue and return the previous queue length\n 'resetForTesting': function () {\n var length = taskQueueLength - nextIndexToProcess;\n nextIndexToProcess = taskQueueLength = taskQueue.length = 0;\n return length;\n },\n\n runEarly: processTasks\n };\n\n return tasks;\n })();\n\n ko.exportSymbol('tasks', ko.tasks);\n ko.exportSymbol('tasks.schedule', ko.tasks.schedule);\n//ko.exportSymbol('tasks.cancel', ko.tasks.cancel); \"cancel\" isn't minified\n ko.exportSymbol('tasks.runEarly', ko.tasks.runEarly);\n ko.extenders = {\n 'throttle': function(target, timeout) {\n // Throttling means two things:\n\n // (1) For dependent observables, we throttle *evaluations* so that, no matter how fast its dependencies\n // notify updates, the target doesn't re-evaluate (and hence doesn't notify) faster than a certain rate\n target['throttleEvaluation'] = timeout;\n\n // (2) For writable targets (observables, or writable dependent observables), we throttle *writes*\n // so the target cannot change value synchronously or faster than a certain rate\n var writeTimeoutInstance = null;\n return ko.dependentObservable({\n 'read': target,\n 'write': function(value) {\n clearTimeout(writeTimeoutInstance);\n writeTimeoutInstance = ko.utils.setTimeout(function() {\n target(value);\n }, timeout);\n }\n });\n },\n\n 'rateLimit': function(target, options) {\n var timeout, method, limitFunction;\n\n if (typeof options == 'number') {\n timeout = options;\n } else {\n timeout = options['timeout'];\n method = options['method'];\n }\n\n // rateLimit supersedes deferred updates\n target._deferUpdates = false;\n\n limitFunction = typeof method == 'function' ? method : method == 'notifyWhenChangesStop' ? debounce : throttle;\n target.limit(function(callback) {\n return limitFunction(callback, timeout, options);\n });\n },\n\n 'deferred': function(target, options) {\n if (options !== true) {\n throw new Error('The \\'deferred\\' extender only accepts the value \\'true\\', because it is not supported to turn deferral off once enabled.')\n }\n\n if (!target._deferUpdates) {\n target._deferUpdates = true;\n target.limit(function (callback) {\n var handle,\n ignoreUpdates = false;\n return function () {\n if (!ignoreUpdates) {\n ko.tasks.cancel(handle);\n handle = ko.tasks.schedule(callback);\n\n try {\n ignoreUpdates = true;\n target['notifySubscribers'](undefined, 'dirty');\n } finally {\n ignoreUpdates = false;\n }\n }\n };\n });\n }\n },\n\n 'notify': function(target, notifyWhen) {\n target[\"equalityComparer\"] = notifyWhen == \"always\" ?\n null : // null equalityComparer means to always notify\n valuesArePrimitiveAndEqual;\n }\n };\n\n var primitiveTypes = { 'undefined':1, 'boolean':1, 'number':1, 'string':1 };\n function valuesArePrimitiveAndEqual(a, b) {\n var oldValueIsPrimitive = (a === null) || (typeof(a) in primitiveTypes);\n return oldValueIsPrimitive ? (a === b) : false;\n }\n\n function throttle(callback, timeout) {\n var timeoutInstance;\n return function () {\n if (!timeoutInstance) {\n timeoutInstance = ko.utils.setTimeout(function () {\n timeoutInstance = undefined;\n callback();\n }, timeout);\n }\n };\n }\n\n function debounce(callback, timeout) {\n var timeoutInstance;\n return function () {\n clearTimeout(timeoutInstance);\n timeoutInstance = ko.utils.setTimeout(callback, timeout);\n };\n }\n\n function applyExtenders(requestedExtenders) {\n var target = this;\n if (requestedExtenders) {\n ko.utils.objectForEach(requestedExtenders, function(key, value) {\n var extenderHandler = ko.extenders[key];\n if (typeof extenderHandler == 'function') {\n target = extenderHandler(target, value) || target;\n }\n });\n }\n return target;\n }\n\n ko.exportSymbol('extenders', ko.extenders);\n\n ko.subscription = function (target, callback, disposeCallback) {\n this._target = target;\n this._callback = callback;\n this._disposeCallback = disposeCallback;\n this._isDisposed = false;\n this._node = null;\n this._domNodeDisposalCallback = null;\n ko.exportProperty(this, 'dispose', this.dispose);\n ko.exportProperty(this, 'disposeWhenNodeIsRemoved', this.disposeWhenNodeIsRemoved);\n };\n ko.subscription.prototype.dispose = function () {\n var self = this;\n if (!self._isDisposed) {\n if (self._domNodeDisposalCallback) {\n ko.utils.domNodeDisposal.removeDisposeCallback(self._node, self._domNodeDisposalCallback);\n }\n self._isDisposed = true;\n self._disposeCallback();\n\n self._target = self._callback = self._disposeCallback = self._node = self._domNodeDisposalCallback = null;\n }\n };\n ko.subscription.prototype.disposeWhenNodeIsRemoved = function (node) {\n this._node = node;\n ko.utils.domNodeDisposal.addDisposeCallback(node, this._domNodeDisposalCallback = this.dispose.bind(this));\n };\n\n ko.subscribable = function () {\n ko.utils.setPrototypeOfOrExtend(this, ko_subscribable_fn);\n ko_subscribable_fn.init(this);\n }\n\n var defaultEvent = \"change\";\n\n// Moved out of \"limit\" to avoid the extra closure\n function limitNotifySubscribers(value, event) {\n if (!event || event === defaultEvent) {\n this._limitChange(value);\n } else if (event === 'beforeChange') {\n this._limitBeforeChange(value);\n } else {\n this._origNotifySubscribers(value, event);\n }\n }\n\n var ko_subscribable_fn = {\n init: function(instance) {\n instance._subscriptions = { \"change\": [] };\n instance._versionNumber = 1;\n },\n\n subscribe: function (callback, callbackTarget, event) {\n var self = this;\n\n event = event || defaultEvent;\n var boundCallback = callbackTarget ? callback.bind(callbackTarget) : callback;\n\n var subscription = new ko.subscription(self, boundCallback, function () {\n ko.utils.arrayRemoveItem(self._subscriptions[event], subscription);\n if (self.afterSubscriptionRemove)\n self.afterSubscriptionRemove(event);\n });\n\n if (self.beforeSubscriptionAdd)\n self.beforeSubscriptionAdd(event);\n\n if (!self._subscriptions[event])\n self._subscriptions[event] = [];\n self._subscriptions[event].push(subscription);\n\n return subscription;\n },\n\n \"notifySubscribers\": function (valueToNotify, event) {\n event = event || defaultEvent;\n if (event === defaultEvent) {\n this.updateVersion();\n }\n if (this.hasSubscriptionsForEvent(event)) {\n var subs = event === defaultEvent && this._changeSubscriptions || this._subscriptions[event].slice(0);\n try {\n ko.dependencyDetection.begin(); // Begin suppressing dependency detection (by setting the top frame to undefined)\n for (var i = 0, subscription; subscription = subs[i]; ++i) {\n // In case a subscription was disposed during the arrayForEach cycle, check\n // for isDisposed on each subscription before invoking its callback\n if (!subscription._isDisposed)\n subscription._callback(valueToNotify);\n }\n } finally {\n ko.dependencyDetection.end(); // End suppressing dependency detection\n }\n }\n },\n\n getVersion: function () {\n return this._versionNumber;\n },\n\n hasChanged: function (versionToCheck) {\n return this.getVersion() !== versionToCheck;\n },\n\n updateVersion: function () {\n ++this._versionNumber;\n },\n\n limit: function(limitFunction) {\n var self = this, selfIsObservable = ko.isObservable(self),\n ignoreBeforeChange, notifyNextChange, previousValue, pendingValue, didUpdate,\n beforeChange = 'beforeChange';\n\n if (!self._origNotifySubscribers) {\n self._origNotifySubscribers = self[\"notifySubscribers\"];\n self[\"notifySubscribers\"] = limitNotifySubscribers;\n }\n\n var finish = limitFunction(function() {\n self._notificationIsPending = false;\n\n // If an observable provided a reference to itself, access it to get the latest value.\n // This allows computed observables to delay calculating their value until needed.\n if (selfIsObservable && pendingValue === self) {\n pendingValue = self._evalIfChanged ? self._evalIfChanged() : self();\n }\n var shouldNotify = notifyNextChange || (didUpdate && self.isDifferent(previousValue, pendingValue));\n\n didUpdate = notifyNextChange = ignoreBeforeChange = false;\n\n if (shouldNotify) {\n self._origNotifySubscribers(previousValue = pendingValue);\n }\n });\n\n self._limitChange = function(value, isDirty) {\n if (!isDirty || !self._notificationIsPending) {\n didUpdate = !isDirty;\n }\n self._changeSubscriptions = self._subscriptions[defaultEvent].slice(0);\n self._notificationIsPending = ignoreBeforeChange = true;\n pendingValue = value;\n finish();\n };\n self._limitBeforeChange = function(value) {\n if (!ignoreBeforeChange) {\n previousValue = value;\n self._origNotifySubscribers(value, beforeChange);\n }\n };\n self._recordUpdate = function() {\n didUpdate = true;\n };\n self._notifyNextChangeIfValueIsDifferent = function() {\n if (self.isDifferent(previousValue, self.peek(true /*evaluate*/))) {\n notifyNextChange = true;\n }\n };\n },\n\n hasSubscriptionsForEvent: function(event) {\n return this._subscriptions[event] && this._subscriptions[event].length;\n },\n\n getSubscriptionsCount: function (event) {\n if (event) {\n return this._subscriptions[event] && this._subscriptions[event].length || 0;\n } else {\n var total = 0;\n ko.utils.objectForEach(this._subscriptions, function(eventName, subscriptions) {\n if (eventName !== 'dirty')\n total += subscriptions.length;\n });\n return total;\n }\n },\n\n isDifferent: function(oldValue, newValue) {\n return !this['equalityComparer'] || !this['equalityComparer'](oldValue, newValue);\n },\n\n toString: function() {\n return '[object Object]'\n },\n\n extend: applyExtenders\n };\n\n ko.exportProperty(ko_subscribable_fn, 'init', ko_subscribable_fn.init);\n ko.exportProperty(ko_subscribable_fn, 'subscribe', ko_subscribable_fn.subscribe);\n ko.exportProperty(ko_subscribable_fn, 'extend', ko_subscribable_fn.extend);\n ko.exportProperty(ko_subscribable_fn, 'getSubscriptionsCount', ko_subscribable_fn.getSubscriptionsCount);\n\n// For browsers that support proto assignment, we overwrite the prototype of each\n// observable instance. Since observables are functions, we need Function.prototype\n// to still be in the prototype chain.\n if (ko.utils.canSetPrototype) {\n ko.utils.setPrototypeOf(ko_subscribable_fn, Function.prototype);\n }\n\n ko.subscribable['fn'] = ko_subscribable_fn;\n\n\n ko.isSubscribable = function (instance) {\n return instance != null && typeof instance.subscribe == \"function\" && typeof instance[\"notifySubscribers\"] == \"function\";\n };\n\n ko.exportSymbol('subscribable', ko.subscribable);\n ko.exportSymbol('isSubscribable', ko.isSubscribable);\n\n ko.computedContext = ko.dependencyDetection = (function () {\n var outerFrames = [],\n currentFrame,\n lastId = 0;\n\n // Return a unique ID that can be assigned to an observable for dependency tracking.\n // Theoretically, you could eventually overflow the number storage size, resulting\n // in duplicate IDs. But in JavaScript, the largest exact integral value is 2^53\n // or 9,007,199,254,740,992. If you created 1,000,000 IDs per second, it would\n // take over 285 years to reach that number.\n // Reference http://blog.vjeux.com/2010/javascript/javascript-max_int-number-limits.html\n function getId() {\n return ++lastId;\n }\n\n function begin(options) {\n outerFrames.push(currentFrame);\n currentFrame = options;\n }\n\n function end() {\n currentFrame = outerFrames.pop();\n }\n\n return {\n begin: begin,\n\n end: end,\n\n registerDependency: function (subscribable) {\n if (currentFrame) {\n if (!ko.isSubscribable(subscribable))\n throw new Error(\"Only subscribable things can act as dependencies\");\n currentFrame.callback.call(currentFrame.callbackTarget, subscribable, subscribable._id || (subscribable._id = getId()));\n }\n },\n\n ignore: function (callback, callbackTarget, callbackArgs) {\n try {\n begin();\n return callback.apply(callbackTarget, callbackArgs || []);\n } finally {\n end();\n }\n },\n\n getDependenciesCount: function () {\n if (currentFrame)\n return currentFrame.computed.getDependenciesCount();\n },\n\n getDependencies: function () {\n if (currentFrame)\n return currentFrame.computed.getDependencies();\n },\n\n isInitial: function() {\n if (currentFrame)\n return currentFrame.isInitial;\n },\n\n computed: function() {\n if (currentFrame)\n return currentFrame.computed;\n }\n };\n })();\n\n ko.exportSymbol('computedContext', ko.computedContext);\n ko.exportSymbol('computedContext.getDependenciesCount', ko.computedContext.getDependenciesCount);\n ko.exportSymbol('computedContext.getDependencies', ko.computedContext.getDependencies);\n ko.exportSymbol('computedContext.isInitial', ko.computedContext.isInitial);\n ko.exportSymbol('computedContext.registerDependency', ko.computedContext.registerDependency);\n\n ko.exportSymbol('ignoreDependencies', ko.ignoreDependencies = ko.dependencyDetection.ignore);\n var observableLatestValue = ko.utils.createSymbolOrString('_latestValue');\n\n ko.observable = function (initialValue) {\n function observable() {\n if (arguments.length > 0) {\n // Write\n\n // Ignore writes if the value hasn't changed\n if (observable.isDifferent(observable[observableLatestValue], arguments[0])) {\n observable.valueWillMutate();\n observable[observableLatestValue] = arguments[0];\n observable.valueHasMutated();\n }\n return this; // Permits chained assignments\n }\n else {\n // Read\n ko.dependencyDetection.registerDependency(observable); // The caller only needs to be notified of changes if they did a \"read\" operation\n return observable[observableLatestValue];\n }\n }\n\n observable[observableLatestValue] = initialValue;\n\n // Inherit from 'subscribable'\n if (!ko.utils.canSetPrototype) {\n // 'subscribable' won't be on the prototype chain unless we put it there directly\n ko.utils.extend(observable, ko.subscribable['fn']);\n }\n ko.subscribable['fn'].init(observable);\n\n // Inherit from 'observable'\n ko.utils.setPrototypeOfOrExtend(observable, observableFn);\n\n if (ko.options['deferUpdates']) {\n ko.extenders['deferred'](observable, true);\n }\n\n return observable;\n }\n\n// Define prototype for observables\n var observableFn = {\n 'equalityComparer': valuesArePrimitiveAndEqual,\n peek: function() { return this[observableLatestValue]; },\n valueHasMutated: function () {\n this['notifySubscribers'](this[observableLatestValue], 'spectate');\n this['notifySubscribers'](this[observableLatestValue]);\n },\n valueWillMutate: function () { this['notifySubscribers'](this[observableLatestValue], 'beforeChange'); }\n };\n\n// Note that for browsers that don't support proto assignment, the\n// inheritance chain is created manually in the ko.observable constructor\n if (ko.utils.canSetPrototype) {\n ko.utils.setPrototypeOf(observableFn, ko.subscribable['fn']);\n }\n\n var protoProperty = ko.observable.protoProperty = '__ko_proto__';\n observableFn[protoProperty] = ko.observable;\n\n ko.isObservable = function (instance) {\n var proto = typeof instance == 'function' && instance[protoProperty];\n if (proto && proto !== observableFn[protoProperty] && proto !== ko.computed['fn'][protoProperty]) {\n throw Error(\"Invalid object that looks like an observable; possibly from another Knockout instance\");\n }\n return !!proto;\n };\n\n ko.isWriteableObservable = function (instance) {\n return (typeof instance == 'function' && (\n (instance[protoProperty] === observableFn[protoProperty]) || // Observable\n (instance[protoProperty] === ko.computed['fn'][protoProperty] && instance.hasWriteFunction))); // Writable computed observable\n };\n\n ko.exportSymbol('observable', ko.observable);\n ko.exportSymbol('isObservable', ko.isObservable);\n ko.exportSymbol('isWriteableObservable', ko.isWriteableObservable);\n ko.exportSymbol('isWritableObservable', ko.isWriteableObservable);\n ko.exportSymbol('observable.fn', observableFn);\n ko.exportProperty(observableFn, 'peek', observableFn.peek);\n ko.exportProperty(observableFn, 'valueHasMutated', observableFn.valueHasMutated);\n ko.exportProperty(observableFn, 'valueWillMutate', observableFn.valueWillMutate);\n ko.observableArray = function (initialValues) {\n initialValues = initialValues || [];\n\n if (typeof initialValues != 'object' || !('length' in initialValues))\n throw new Error(\"The argument passed when initializing an observable array must be an array, or null, or undefined.\");\n\n var result = ko.observable(initialValues);\n ko.utils.setPrototypeOfOrExtend(result, ko.observableArray['fn']);\n return result.extend({'trackArrayChanges':true});\n };\n\n ko.observableArray['fn'] = {\n 'remove': function (valueOrPredicate) {\n var underlyingArray = this.peek();\n var removedValues = [];\n var predicate = typeof valueOrPredicate == \"function\" && !ko.isObservable(valueOrPredicate) ? valueOrPredicate : function (value) { return value === valueOrPredicate; };\n for (var i = 0; i < underlyingArray.length; i++) {\n var value = underlyingArray[i];\n if (predicate(value)) {\n if (removedValues.length === 0) {\n this.valueWillMutate();\n }\n if (underlyingArray[i] !== value) {\n throw Error(\"Array modified during remove; cannot remove item\");\n }\n removedValues.push(value);\n underlyingArray.splice(i, 1);\n i--;\n }\n }\n if (removedValues.length) {\n this.valueHasMutated();\n }\n return removedValues;\n },\n\n 'removeAll': function (arrayOfValues) {\n // If you passed zero args, we remove everything\n if (arrayOfValues === undefined) {\n var underlyingArray = this.peek();\n var allValues = underlyingArray.slice(0);\n this.valueWillMutate();\n underlyingArray.splice(0, underlyingArray.length);\n this.valueHasMutated();\n return allValues;\n }\n // If you passed an arg, we interpret it as an array of entries to remove\n if (!arrayOfValues)\n return [];\n return this['remove'](function (value) {\n return ko.utils.arrayIndexOf(arrayOfValues, value) >= 0;\n });\n },\n\n 'destroy': function (valueOrPredicate) {\n var underlyingArray = this.peek();\n var predicate = typeof valueOrPredicate == \"function\" && !ko.isObservable(valueOrPredicate) ? valueOrPredicate : function (value) { return value === valueOrPredicate; };\n this.valueWillMutate();\n for (var i = underlyingArray.length - 1; i >= 0; i--) {\n var value = underlyingArray[i];\n if (predicate(value))\n value[\"_destroy\"] = true;\n }\n this.valueHasMutated();\n },\n\n 'destroyAll': function (arrayOfValues) {\n // If you passed zero args, we destroy everything\n if (arrayOfValues === undefined)\n return this['destroy'](function() { return true });\n\n // If you passed an arg, we interpret it as an array of entries to destroy\n if (!arrayOfValues)\n return [];\n return this['destroy'](function (value) {\n return ko.utils.arrayIndexOf(arrayOfValues, value) >= 0;\n });\n },\n\n 'indexOf': function (item) {\n var underlyingArray = this();\n return ko.utils.arrayIndexOf(underlyingArray, item);\n },\n\n 'replace': function(oldItem, newItem) {\n var index = this['indexOf'](oldItem);\n if (index >= 0) {\n this.valueWillMutate();\n this.peek()[index] = newItem;\n this.valueHasMutated();\n }\n },\n\n 'sorted': function (compareFunction) {\n var arrayCopy = this().slice(0);\n return compareFunction ? arrayCopy.sort(compareFunction) : arrayCopy.sort();\n },\n\n 'reversed': function () {\n return this().slice(0).reverse();\n }\n };\n\n// Note that for browsers that don't support proto assignment, the\n// inheritance chain is created manually in the ko.observableArray constructor\n if (ko.utils.canSetPrototype) {\n ko.utils.setPrototypeOf(ko.observableArray['fn'], ko.observable['fn']);\n }\n\n// Populate ko.observableArray.fn with read/write functions from native arrays\n// Important: Do not add any additional functions here that may reasonably be used to *read* data from the array\n// because we'll eval them without causing subscriptions, so ko.computed output could end up getting stale\n ko.utils.arrayForEach([\"pop\", \"push\", \"reverse\", \"shift\", \"sort\", \"splice\", \"unshift\"], function (methodName) {\n ko.observableArray['fn'][methodName] = function () {\n // Use \"peek\" to avoid creating a subscription in any computed that we're executing in the context of\n // (for consistency with mutating regular observables)\n var underlyingArray = this.peek();\n this.valueWillMutate();\n this.cacheDiffForKnownOperation(underlyingArray, methodName, arguments);\n var methodCallResult = underlyingArray[methodName].apply(underlyingArray, arguments);\n this.valueHasMutated();\n // The native sort and reverse methods return a reference to the array, but it makes more sense to return the observable array instead.\n return methodCallResult === underlyingArray ? this : methodCallResult;\n };\n });\n\n// Populate ko.observableArray.fn with read-only functions from native arrays\n ko.utils.arrayForEach([\"slice\"], function (methodName) {\n ko.observableArray['fn'][methodName] = function () {\n var underlyingArray = this();\n return underlyingArray[methodName].apply(underlyingArray, arguments);\n };\n });\n\n ko.isObservableArray = function (instance) {\n return ko.isObservable(instance)\n && typeof instance[\"remove\"] == \"function\"\n && typeof instance[\"push\"] == \"function\";\n };\n\n ko.exportSymbol('observableArray', ko.observableArray);\n ko.exportSymbol('isObservableArray', ko.isObservableArray);\n var arrayChangeEventName = 'arrayChange';\n ko.extenders['trackArrayChanges'] = function(target, options) {\n // Use the provided options--each call to trackArrayChanges overwrites the previously set options\n target.compareArrayOptions = {};\n if (options && typeof options == \"object\") {\n ko.utils.extend(target.compareArrayOptions, options);\n }\n target.compareArrayOptions['sparse'] = true;\n\n // Only modify the target observable once\n if (target.cacheDiffForKnownOperation) {\n return;\n }\n var trackingChanges = false,\n cachedDiff = null,\n changeSubscription,\n spectateSubscription,\n pendingChanges = 0,\n previousContents,\n underlyingBeforeSubscriptionAddFunction = target.beforeSubscriptionAdd,\n underlyingAfterSubscriptionRemoveFunction = target.afterSubscriptionRemove;\n\n // Watch \"subscribe\" calls, and for array change events, ensure change tracking is enabled\n target.beforeSubscriptionAdd = function (event) {\n if (underlyingBeforeSubscriptionAddFunction) {\n underlyingBeforeSubscriptionAddFunction.call(target, event);\n }\n if (event === arrayChangeEventName) {\n trackChanges();\n }\n };\n // Watch \"dispose\" calls, and for array change events, ensure change tracking is disabled when all are disposed\n target.afterSubscriptionRemove = function (event) {\n if (underlyingAfterSubscriptionRemoveFunction) {\n underlyingAfterSubscriptionRemoveFunction.call(target, event);\n }\n if (event === arrayChangeEventName && !target.hasSubscriptionsForEvent(arrayChangeEventName)) {\n if (changeSubscription) {\n changeSubscription.dispose();\n }\n if (spectateSubscription) {\n spectateSubscription.dispose();\n }\n spectateSubscription = changeSubscription = null;\n trackingChanges = false;\n previousContents = undefined;\n }\n };\n\n function trackChanges() {\n if (trackingChanges) {\n // Whenever there's a new subscription and there are pending notifications, make sure all previous\n // subscriptions are notified of the change so that all subscriptions are in sync.\n notifyChanges();\n return;\n }\n\n trackingChanges = true;\n\n // Track how many times the array actually changed value\n spectateSubscription = target.subscribe(function () {\n ++pendingChanges;\n }, null, \"spectate\");\n\n // Each time the array changes value, capture a clone so that on the next\n // change it's possible to produce a diff\n previousContents = [].concat(target.peek() || []);\n cachedDiff = null;\n changeSubscription = target.subscribe(notifyChanges);\n\n function notifyChanges() {\n if (pendingChanges) {\n // Make a copy of the current contents and ensure it's an array\n var currentContents = [].concat(target.peek() || []), changes;\n\n // Compute the diff and issue notifications, but only if someone is listening\n if (target.hasSubscriptionsForEvent(arrayChangeEventName)) {\n changes = getChanges(previousContents, currentContents);\n }\n\n // Eliminate references to the old, removed items, so they can be GCed\n previousContents = currentContents;\n cachedDiff = null;\n pendingChanges = 0;\n\n if (changes && changes.length) {\n target['notifySubscribers'](changes, arrayChangeEventName);\n }\n }\n }\n }\n\n function getChanges(previousContents, currentContents) {\n // We try to re-use cached diffs.\n // The scenarios where pendingChanges > 1 are when using rate limiting or deferred updates,\n // which without this check would not be compatible with arrayChange notifications. Normally,\n // notifications are issued immediately so we wouldn't be queueing up more than one.\n if (!cachedDiff || pendingChanges > 1) {\n cachedDiff = ko.utils.compareArrays(previousContents, currentContents, target.compareArrayOptions);\n }\n\n return cachedDiff;\n }\n\n target.cacheDiffForKnownOperation = function(rawArray, operationName, args) {\n // Only run if we're currently tracking changes for this observable array\n // and there aren't any pending deferred notifications.\n if (!trackingChanges || pendingChanges) {\n return;\n }\n var diff = [],\n arrayLength = rawArray.length,\n argsLength = args.length,\n offset = 0;\n\n function pushDiff(status, value, index) {\n return diff[diff.length] = { 'status': status, 'value': value, 'index': index };\n }\n switch (operationName) {\n case 'push':\n offset = arrayLength;\n case 'unshift':\n for (var index = 0; index < argsLength; index++) {\n pushDiff('added', args[index], offset + index);\n }\n break;\n\n case 'pop':\n offset = arrayLength - 1;\n case 'shift':\n if (arrayLength) {\n pushDiff('deleted', rawArray[offset], offset);\n }\n break;\n\n case 'splice':\n // Negative start index means 'from end of array'. After that we clamp to [0...arrayLength].\n // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice\n var startIndex = Math.min(Math.max(0, args[0] < 0 ? arrayLength + args[0] : args[0]), arrayLength),\n endDeleteIndex = argsLength === 1 ? arrayLength : Math.min(startIndex + (args[1] || 0), arrayLength),\n endAddIndex = startIndex + argsLength - 2,\n endIndex = Math.max(endDeleteIndex, endAddIndex),\n additions = [], deletions = [];\n for (var index = startIndex, argsIndex = 2; index < endIndex; ++index, ++argsIndex) {\n if (index < endDeleteIndex)\n deletions.push(pushDiff('deleted', rawArray[index], index));\n if (index < endAddIndex)\n additions.push(pushDiff('added', args[argsIndex], index));\n }\n ko.utils.findMovesInArrayComparison(deletions, additions);\n break;\n\n default:\n return;\n }\n cachedDiff = diff;\n };\n };\n var computedState = ko.utils.createSymbolOrString('_state');\n\n ko.computed = ko.dependentObservable = function (evaluatorFunctionOrOptions, evaluatorFunctionTarget, options) {\n if (typeof evaluatorFunctionOrOptions === \"object\") {\n // Single-parameter syntax - everything is on this \"options\" param\n options = evaluatorFunctionOrOptions;\n } else {\n // Multi-parameter syntax - construct the options according to the params passed\n options = options || {};\n if (evaluatorFunctionOrOptions) {\n options[\"read\"] = evaluatorFunctionOrOptions;\n }\n }\n if (typeof options[\"read\"] != \"function\")\n throw Error(\"Pass a function that returns the value of the ko.computed\");\n\n var writeFunction = options[\"write\"];\n var state = {\n latestValue: undefined,\n isStale: true,\n isDirty: true,\n isBeingEvaluated: false,\n suppressDisposalUntilDisposeWhenReturnsFalse: false,\n isDisposed: false,\n pure: false,\n isSleeping: false,\n readFunction: options[\"read\"],\n evaluatorFunctionTarget: evaluatorFunctionTarget || options[\"owner\"],\n disposeWhenNodeIsRemoved: options[\"disposeWhenNodeIsRemoved\"] || options.disposeWhenNodeIsRemoved || null,\n disposeWhen: options[\"disposeWhen\"] || options.disposeWhen,\n domNodeDisposalCallback: null,\n dependencyTracking: {},\n dependenciesCount: 0,\n evaluationTimeoutInstance: null\n };\n\n function computedObservable() {\n if (arguments.length > 0) {\n if (typeof writeFunction === \"function\") {\n // Writing a value\n writeFunction.apply(state.evaluatorFunctionTarget, arguments);\n } else {\n throw new Error(\"Cannot write a value to a ko.computed unless you specify a 'write' option. If you wish to read the current value, don't pass any parameters.\");\n }\n return this; // Permits chained assignments\n } else {\n // Reading the value\n if (!state.isDisposed) {\n ko.dependencyDetection.registerDependency(computedObservable);\n }\n if (state.isDirty || (state.isSleeping && computedObservable.haveDependenciesChanged())) {\n computedObservable.evaluateImmediate();\n }\n return state.latestValue;\n }\n }\n\n computedObservable[computedState] = state;\n computedObservable.hasWriteFunction = typeof writeFunction === \"function\";\n\n // Inherit from 'subscribable'\n if (!ko.utils.canSetPrototype) {\n // 'subscribable' won't be on the prototype chain unless we put it there directly\n ko.utils.extend(computedObservable, ko.subscribable['fn']);\n }\n ko.subscribable['fn'].init(computedObservable);\n\n // Inherit from 'computed'\n ko.utils.setPrototypeOfOrExtend(computedObservable, computedFn);\n\n if (options['pure']) {\n state.pure = true;\n state.isSleeping = true; // Starts off sleeping; will awake on the first subscription\n ko.utils.extend(computedObservable, pureComputedOverrides);\n } else if (options['deferEvaluation']) {\n ko.utils.extend(computedObservable, deferEvaluationOverrides);\n }\n\n if (ko.options['deferUpdates']) {\n ko.extenders['deferred'](computedObservable, true);\n }\n\n if (DEBUG) {\n // #1731 - Aid debugging by exposing the computed's options\n computedObservable[\"_options\"] = options;\n }\n\n if (state.disposeWhenNodeIsRemoved) {\n // Since this computed is associated with a DOM node, and we don't want to dispose the computed\n // until the DOM node is *removed* from the document (as opposed to never having been in the document),\n // we'll prevent disposal until \"disposeWhen\" first returns false.\n state.suppressDisposalUntilDisposeWhenReturnsFalse = true;\n\n // disposeWhenNodeIsRemoved: true can be used to opt into the \"only dispose after first false result\"\n // behaviour even if there's no specific node to watch. In that case, clear the option so we don't try\n // to watch for a non-node's disposal. This technique is intended for KO's internal use only and shouldn't\n // be documented or used by application code, as it's likely to change in a future version of KO.\n if (!state.disposeWhenNodeIsRemoved.nodeType) {\n state.disposeWhenNodeIsRemoved = null;\n }\n }\n\n // Evaluate, unless sleeping or deferEvaluation is true\n if (!state.isSleeping && !options['deferEvaluation']) {\n computedObservable.evaluateImmediate();\n }\n\n // Attach a DOM node disposal callback so that the computed will be proactively disposed as soon as the node is\n // removed using ko.removeNode. But skip if isActive is false (there will never be any dependencies to dispose).\n if (state.disposeWhenNodeIsRemoved && computedObservable.isActive()) {\n ko.utils.domNodeDisposal.addDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback = function () {\n computedObservable.dispose();\n });\n }\n\n return computedObservable;\n };\n\n// Utility function that disposes a given dependencyTracking entry\n function computedDisposeDependencyCallback(id, entryToDispose) {\n if (entryToDispose !== null && entryToDispose.dispose) {\n entryToDispose.dispose();\n }\n }\n\n// This function gets called each time a dependency is detected while evaluating a computed.\n// It's factored out as a shared function to avoid creating unnecessary function instances during evaluation.\n function computedBeginDependencyDetectionCallback(subscribable, id) {\n var computedObservable = this.computedObservable,\n state = computedObservable[computedState];\n if (!state.isDisposed) {\n if (this.disposalCount && this.disposalCandidates[id]) {\n // Don't want to dispose this subscription, as it's still being used\n computedObservable.addDependencyTracking(id, subscribable, this.disposalCandidates[id]);\n this.disposalCandidates[id] = null; // No need to actually delete the property - disposalCandidates is a transient object anyway\n --this.disposalCount;\n } else if (!state.dependencyTracking[id]) {\n // Brand new subscription - add it\n computedObservable.addDependencyTracking(id, subscribable, state.isSleeping ? { _target: subscribable } : computedObservable.subscribeToDependency(subscribable));\n }\n // If the observable we've accessed has a pending notification, ensure we get notified of the actual final value (bypass equality checks)\n if (subscribable._notificationIsPending) {\n subscribable._notifyNextChangeIfValueIsDifferent();\n }\n }\n }\n\n var computedFn = {\n \"equalityComparer\": valuesArePrimitiveAndEqual,\n getDependenciesCount: function () {\n return this[computedState].dependenciesCount;\n },\n getDependencies: function () {\n var dependencyTracking = this[computedState].dependencyTracking, dependentObservables = [];\n\n ko.utils.objectForEach(dependencyTracking, function (id, dependency) {\n dependentObservables[dependency._order] = dependency._target;\n });\n\n return dependentObservables;\n },\n hasAncestorDependency: function (obs) {\n if (!this[computedState].dependenciesCount) {\n return false;\n }\n var dependencies = this.getDependencies();\n if (ko.utils.arrayIndexOf(dependencies, obs) !== -1) {\n return true;\n }\n return !!ko.utils.arrayFirst(dependencies, function (dep) {\n return dep.hasAncestorDependency && dep.hasAncestorDependency(obs);\n });\n },\n addDependencyTracking: function (id, target, trackingObj) {\n if (this[computedState].pure && target === this) {\n throw Error(\"A 'pure' computed must not be called recursively\");\n }\n\n this[computedState].dependencyTracking[id] = trackingObj;\n trackingObj._order = this[computedState].dependenciesCount++;\n trackingObj._version = target.getVersion();\n },\n haveDependenciesChanged: function () {\n var id, dependency, dependencyTracking = this[computedState].dependencyTracking;\n for (id in dependencyTracking) {\n if (Object.prototype.hasOwnProperty.call(dependencyTracking, id)) {\n dependency = dependencyTracking[id];\n if ((this._evalDelayed && dependency._target._notificationIsPending) || dependency._target.hasChanged(dependency._version)) {\n return true;\n }\n }\n }\n },\n markDirty: function () {\n // Process \"dirty\" events if we can handle delayed notifications\n if (this._evalDelayed && !this[computedState].isBeingEvaluated) {\n this._evalDelayed(false /*isChange*/);\n }\n },\n isActive: function () {\n var state = this[computedState];\n return state.isDirty || state.dependenciesCount > 0;\n },\n respondToChange: function () {\n // Ignore \"change\" events if we've already scheduled a delayed notification\n if (!this._notificationIsPending) {\n this.evaluatePossiblyAsync();\n } else if (this[computedState].isDirty) {\n this[computedState].isStale = true;\n }\n },\n subscribeToDependency: function (target) {\n if (target._deferUpdates) {\n var dirtySub = target.subscribe(this.markDirty, this, 'dirty'),\n changeSub = target.subscribe(this.respondToChange, this);\n return {\n _target: target,\n dispose: function () {\n dirtySub.dispose();\n changeSub.dispose();\n }\n };\n } else {\n return target.subscribe(this.evaluatePossiblyAsync, this);\n }\n },\n evaluatePossiblyAsync: function () {\n var computedObservable = this,\n throttleEvaluationTimeout = computedObservable['throttleEvaluation'];\n if (throttleEvaluationTimeout && throttleEvaluationTimeout >= 0) {\n clearTimeout(this[computedState].evaluationTimeoutInstance);\n this[computedState].evaluationTimeoutInstance = ko.utils.setTimeout(function () {\n computedObservable.evaluateImmediate(true /*notifyChange*/);\n }, throttleEvaluationTimeout);\n } else if (computedObservable._evalDelayed) {\n computedObservable._evalDelayed(true /*isChange*/);\n } else {\n computedObservable.evaluateImmediate(true /*notifyChange*/);\n }\n },\n evaluateImmediate: function (notifyChange) {\n var computedObservable = this,\n state = computedObservable[computedState],\n disposeWhen = state.disposeWhen,\n changed = false;\n\n if (state.isBeingEvaluated) {\n // If the evaluation of a ko.computed causes side effects, it's possible that it will trigger its own re-evaluation.\n // This is not desirable (it's hard for a developer to realise a chain of dependencies might cause this, and they almost\n // certainly didn't intend infinite re-evaluations). So, for predictability, we simply prevent ko.computeds from causing\n // their own re-evaluation. Further discussion at https://github.com/SteveSanderson/knockout/pull/387\n return;\n }\n\n // Do not evaluate (and possibly capture new dependencies) if disposed\n if (state.isDisposed) {\n return;\n }\n\n if (state.disposeWhenNodeIsRemoved && !ko.utils.domNodeIsAttachedToDocument(state.disposeWhenNodeIsRemoved) || disposeWhen && disposeWhen()) {\n // See comment above about suppressDisposalUntilDisposeWhenReturnsFalse\n if (!state.suppressDisposalUntilDisposeWhenReturnsFalse) {\n computedObservable.dispose();\n return;\n }\n } else {\n // It just did return false, so we can stop suppressing now\n state.suppressDisposalUntilDisposeWhenReturnsFalse = false;\n }\n\n state.isBeingEvaluated = true;\n try {\n changed = this.evaluateImmediate_CallReadWithDependencyDetection(notifyChange);\n } finally {\n state.isBeingEvaluated = false;\n }\n\n return changed;\n },\n evaluateImmediate_CallReadWithDependencyDetection: function (notifyChange) {\n // This function is really just part of the evaluateImmediate logic. You would never call it from anywhere else.\n // Factoring it out into a separate function means it can be independent of the try/catch block in evaluateImmediate,\n // which contributes to saving about 40% off the CPU overhead of computed evaluation (on V8 at least).\n\n var computedObservable = this,\n state = computedObservable[computedState],\n changed = false;\n\n // Initially, we assume that none of the subscriptions are still being used (i.e., all are candidates for disposal).\n // Then, during evaluation, we cross off any that are in fact still being used.\n var isInitial = state.pure ? undefined : !state.dependenciesCount, // If we're evaluating when there are no previous dependencies, it must be the first time\n dependencyDetectionContext = {\n computedObservable: computedObservable,\n disposalCandidates: state.dependencyTracking,\n disposalCount: state.dependenciesCount\n };\n\n ko.dependencyDetection.begin({\n callbackTarget: dependencyDetectionContext,\n callback: computedBeginDependencyDetectionCallback,\n computed: computedObservable,\n isInitial: isInitial\n });\n\n state.dependencyTracking = {};\n state.dependenciesCount = 0;\n\n var newValue = this.evaluateImmediate_CallReadThenEndDependencyDetection(state, dependencyDetectionContext);\n\n if (!state.dependenciesCount) {\n computedObservable.dispose();\n changed = true; // When evaluation causes a disposal, make sure all dependent computeds get notified so they'll see the new state\n } else {\n changed = computedObservable.isDifferent(state.latestValue, newValue);\n }\n\n if (changed) {\n if (!state.isSleeping) {\n computedObservable[\"notifySubscribers\"](state.latestValue, \"beforeChange\");\n } else {\n computedObservable.updateVersion();\n }\n\n state.latestValue = newValue;\n if (DEBUG) computedObservable._latestValue = newValue;\n\n computedObservable[\"notifySubscribers\"](state.latestValue, \"spectate\");\n\n if (!state.isSleeping && notifyChange) {\n computedObservable[\"notifySubscribers\"](state.latestValue);\n }\n if (computedObservable._recordUpdate) {\n computedObservable._recordUpdate();\n }\n }\n\n if (isInitial) {\n computedObservable[\"notifySubscribers\"](state.latestValue, \"awake\");\n }\n\n return changed;\n },\n evaluateImmediate_CallReadThenEndDependencyDetection: function (state, dependencyDetectionContext) {\n // This function is really part of the evaluateImmediate_CallReadWithDependencyDetection logic.\n // You'd never call it from anywhere else. Factoring it out means that evaluateImmediate_CallReadWithDependencyDetection\n // can be independent of try/finally blocks, which contributes to saving about 40% off the CPU\n // overhead of computed evaluation (on V8 at least).\n\n try {\n var readFunction = state.readFunction;\n return state.evaluatorFunctionTarget ? readFunction.call(state.evaluatorFunctionTarget) : readFunction();\n } finally {\n ko.dependencyDetection.end();\n\n // For each subscription no longer being used, remove it from the active subscriptions list and dispose it\n if (dependencyDetectionContext.disposalCount && !state.isSleeping) {\n ko.utils.objectForEach(dependencyDetectionContext.disposalCandidates, computedDisposeDependencyCallback);\n }\n\n state.isStale = state.isDirty = false;\n }\n },\n peek: function (evaluate) {\n // By default, peek won't re-evaluate, except while the computed is sleeping or to get the initial value when \"deferEvaluation\" is set.\n // Pass in true to evaluate if needed.\n var state = this[computedState];\n if ((state.isDirty && (evaluate || !state.dependenciesCount)) || (state.isSleeping && this.haveDependenciesChanged())) {\n this.evaluateImmediate();\n }\n return state.latestValue;\n },\n limit: function (limitFunction) {\n // Override the limit function with one that delays evaluation as well\n ko.subscribable['fn'].limit.call(this, limitFunction);\n this._evalIfChanged = function () {\n if (!this[computedState].isSleeping) {\n if (this[computedState].isStale) {\n this.evaluateImmediate();\n } else {\n this[computedState].isDirty = false;\n }\n }\n return this[computedState].latestValue;\n };\n this._evalDelayed = function (isChange) {\n this._limitBeforeChange(this[computedState].latestValue);\n\n // Mark as dirty\n this[computedState].isDirty = true;\n if (isChange) {\n this[computedState].isStale = true;\n }\n\n // Pass the observable to the \"limit\" code, which will evaluate it when\n // it's time to do the notification.\n this._limitChange(this, !isChange /* isDirty */);\n };\n },\n dispose: function () {\n var state = this[computedState];\n if (!state.isSleeping && state.dependencyTracking) {\n ko.utils.objectForEach(state.dependencyTracking, function (id, dependency) {\n if (dependency.dispose)\n dependency.dispose();\n });\n }\n if (state.disposeWhenNodeIsRemoved && state.domNodeDisposalCallback) {\n ko.utils.domNodeDisposal.removeDisposeCallback(state.disposeWhenNodeIsRemoved, state.domNodeDisposalCallback);\n }\n state.dependencyTracking = undefined;\n state.dependenciesCount = 0;\n state.isDisposed = true;\n state.isStale = false;\n state.isDirty = false;\n state.isSleeping = false;\n state.disposeWhenNodeIsRemoved = undefined;\n state.disposeWhen = undefined;\n state.readFunction = undefined;\n if (!this.hasWriteFunction) {\n state.evaluatorFunctionTarget = undefined;\n }\n }\n };\n\n var pureComputedOverrides = {\n beforeSubscriptionAdd: function (event) {\n // If asleep, wake up the computed by subscribing to any dependencies.\n var computedObservable = this,\n state = computedObservable[computedState];\n if (!state.isDisposed && state.isSleeping && event == 'change') {\n state.isSleeping = false;\n if (state.isStale || computedObservable.haveDependenciesChanged()) {\n state.dependencyTracking = null;\n state.dependenciesCount = 0;\n if (computedObservable.evaluateImmediate()) {\n computedObservable.updateVersion();\n }\n } else {\n // First put the dependencies in order\n var dependenciesOrder = [];\n ko.utils.objectForEach(state.dependencyTracking, function (id, dependency) {\n dependenciesOrder[dependency._order] = id;\n });\n // Next, subscribe to each one\n ko.utils.arrayForEach(dependenciesOrder, function (id, order) {\n var dependency = state.dependencyTracking[id],\n subscription = computedObservable.subscribeToDependency(dependency._target);\n subscription._order = order;\n subscription._version = dependency._version;\n state.dependencyTracking[id] = subscription;\n });\n // Waking dependencies may have triggered effects\n if (computedObservable.haveDependenciesChanged()) {\n if (computedObservable.evaluateImmediate()) {\n computedObservable.updateVersion();\n }\n }\n }\n\n if (!state.isDisposed) { // test since evaluating could trigger disposal\n computedObservable[\"notifySubscribers\"](state.latestValue, \"awake\");\n }\n }\n },\n afterSubscriptionRemove: function (event) {\n var state = this[computedState];\n if (!state.isDisposed && event == 'change' && !this.hasSubscriptionsForEvent('change')) {\n ko.utils.objectForEach(state.dependencyTracking, function (id, dependency) {\n if (dependency.dispose) {\n state.dependencyTracking[id] = {\n _target: dependency._target,\n _order: dependency._order,\n _version: dependency._version\n };\n dependency.dispose();\n }\n });\n state.isSleeping = true;\n this[\"notifySubscribers\"](undefined, \"asleep\");\n }\n },\n getVersion: function () {\n // Because a pure computed is not automatically updated while it is sleeping, we can't\n // simply return the version number. Instead, we check if any of the dependencies have\n // changed and conditionally re-evaluate the computed observable.\n var state = this[computedState];\n if (state.isSleeping && (state.isStale || this.haveDependenciesChanged())) {\n this.evaluateImmediate();\n }\n return ko.subscribable['fn'].getVersion.call(this);\n }\n };\n\n var deferEvaluationOverrides = {\n beforeSubscriptionAdd: function (event) {\n // This will force a computed with deferEvaluation to evaluate when the first subscription is registered.\n if (event == 'change' || event == 'beforeChange') {\n this.peek();\n }\n }\n };\n\n// Note that for browsers that don't support proto assignment, the\n// inheritance chain is created manually in the ko.computed constructor\n if (ko.utils.canSetPrototype) {\n ko.utils.setPrototypeOf(computedFn, ko.subscribable['fn']);\n }\n\n// Set the proto values for ko.computed\n var protoProp = ko.observable.protoProperty; // == \"__ko_proto__\"\n computedFn[protoProp] = ko.computed;\n\n ko.isComputed = function (instance) {\n return (typeof instance == 'function' && instance[protoProp] === computedFn[protoProp]);\n };\n\n ko.isPureComputed = function (instance) {\n return ko.isComputed(instance) && instance[computedState] && instance[computedState].pure;\n };\n\n ko.exportSymbol('computed', ko.computed);\n ko.exportSymbol('dependentObservable', ko.computed); // export ko.dependentObservable for backwards compatibility (1.x)\n ko.exportSymbol('isComputed', ko.isComputed);\n ko.exportSymbol('isPureComputed', ko.isPureComputed);\n ko.exportSymbol('computed.fn', computedFn);\n ko.exportProperty(computedFn, 'peek', computedFn.peek);\n ko.exportProperty(computedFn, 'dispose', computedFn.dispose);\n ko.exportProperty(computedFn, 'isActive', computedFn.isActive);\n ko.exportProperty(computedFn, 'getDependenciesCount', computedFn.getDependenciesCount);\n ko.exportProperty(computedFn, 'getDependencies', computedFn.getDependencies);\n\n ko.pureComputed = function (evaluatorFunctionOrOptions, evaluatorFunctionTarget) {\n if (typeof evaluatorFunctionOrOptions === 'function') {\n return ko.computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget, {'pure':true});\n } else {\n evaluatorFunctionOrOptions = ko.utils.extend({}, evaluatorFunctionOrOptions); // make a copy of the parameter object\n evaluatorFunctionOrOptions['pure'] = true;\n return ko.computed(evaluatorFunctionOrOptions, evaluatorFunctionTarget);\n }\n }\n ko.exportSymbol('pureComputed', ko.pureComputed);\n\n (function() {\n var maxNestedObservableDepth = 10; // Escape the (unlikely) pathological case where an observable's current value is itself (or similar reference cycle)\n\n ko.toJS = function(rootObject) {\n if (arguments.length == 0)\n throw new Error(\"When calling ko.toJS, pass the object you want to convert.\");\n\n // We just unwrap everything at every level in the object graph\n return mapJsObjectGraph(rootObject, function(valueToMap) {\n // Loop because an observable's value might in turn be another observable wrapper\n for (var i = 0; ko.isObservable(valueToMap) && (i < maxNestedObservableDepth); i++)\n valueToMap = valueToMap();\n return valueToMap;\n });\n };\n\n ko.toJSON = function(rootObject, replacer, space) { // replacer and space are optional\n var plainJavaScriptObject = ko.toJS(rootObject);\n return ko.utils.stringifyJson(plainJavaScriptObject, replacer, space);\n };\n\n function mapJsObjectGraph(rootObject, mapInputCallback, visitedObjects) {\n visitedObjects = visitedObjects || new objectLookup();\n\n rootObject = mapInputCallback(rootObject);\n var canHaveProperties = (typeof rootObject == \"object\") && (rootObject !== null) && (rootObject !== undefined) && (!(rootObject instanceof RegExp)) && (!(rootObject instanceof Date)) && (!(rootObject instanceof String)) && (!(rootObject instanceof Number)) && (!(rootObject instanceof Boolean));\n if (!canHaveProperties)\n return rootObject;\n\n var outputProperties = rootObject instanceof Array ? [] : {};\n visitedObjects.save(rootObject, outputProperties);\n\n visitPropertiesOrArrayEntries(rootObject, function(indexer) {\n var propertyValue = mapInputCallback(rootObject[indexer]);\n\n switch (typeof propertyValue) {\n case \"boolean\":\n case \"number\":\n case \"string\":\n case \"function\":\n outputProperties[indexer] = propertyValue;\n break;\n case \"object\":\n case \"undefined\":\n var previouslyMappedValue = visitedObjects.get(propertyValue);\n outputProperties[indexer] = (previouslyMappedValue !== undefined)\n ? previouslyMappedValue\n : mapJsObjectGraph(propertyValue, mapInputCallback, visitedObjects);\n break;\n }\n });\n\n return outputProperties;\n }\n\n function visitPropertiesOrArrayEntries(rootObject, visitorCallback) {\n if (rootObject instanceof Array) {\n for (var i = 0; i < rootObject.length; i++)\n visitorCallback(i);\n\n // For arrays, also respect toJSON property for custom mappings (fixes #278)\n if (typeof rootObject['toJSON'] == 'function')\n visitorCallback('toJSON');\n } else {\n for (var propertyName in rootObject) {\n visitorCallback(propertyName);\n }\n }\n };\n\n function objectLookup() {\n this.keys = [];\n this.values = [];\n };\n\n objectLookup.prototype = {\n constructor: objectLookup,\n save: function(key, value) {\n var existingIndex = ko.utils.arrayIndexOf(this.keys, key);\n if (existingIndex >= 0)\n this.values[existingIndex] = value;\n else {\n this.keys.push(key);\n this.values.push(value);\n }\n },\n get: function(key) {\n var existingIndex = ko.utils.arrayIndexOf(this.keys, key);\n return (existingIndex >= 0) ? this.values[existingIndex] : undefined;\n }\n };\n })();\n\n ko.exportSymbol('toJS', ko.toJS);\n ko.exportSymbol('toJSON', ko.toJSON);\n ko.when = function(predicate, callback, context) {\n function kowhen (resolve) {\n var observable = ko.pureComputed(predicate, context).extend({notify:'always'});\n var subscription = observable.subscribe(function(value) {\n if (value) {\n subscription.dispose();\n resolve(value);\n }\n });\n // In case the initial value is true, process it right away\n observable['notifySubscribers'](observable.peek());\n\n return subscription;\n }\n if (typeof Promise === \"function\" && !callback) {\n return new Promise(kowhen);\n } else {\n return kowhen(callback.bind(context));\n }\n };\n\n ko.exportSymbol('when', ko.when);\n (function () {\n var hasDomDataExpandoProperty = '__ko__hasDomDataOptionValue__';\n\n // Normally, SELECT elements and their OPTIONs can only take value of type 'string' (because the values\n // are stored on DOM attributes). ko.selectExtensions provides a way for SELECTs/OPTIONs to have values\n // that are arbitrary objects. This is very convenient when implementing things like cascading dropdowns.\n ko.selectExtensions = {\n readValue : function(element) {\n switch (ko.utils.tagNameLower(element)) {\n case 'option':\n if (element[hasDomDataExpandoProperty] === true)\n return ko.utils.domData.get(element, ko.bindingHandlers.options.optionValueDomDataKey);\n return ko.utils.ieVersion <= 7\n ? (element.getAttributeNode('value') && element.getAttributeNode('value').specified ? element.value : element.text)\n : element.value;\n case 'select':\n return element.selectedIndex >= 0 ? ko.selectExtensions.readValue(element.options[element.selectedIndex]) : undefined;\n default:\n return element.value;\n }\n },\n\n writeValue: function(element, value, allowUnset) {\n switch (ko.utils.tagNameLower(element)) {\n case 'option':\n if (typeof value === \"string\") {\n ko.utils.domData.set(element, ko.bindingHandlers.options.optionValueDomDataKey, undefined);\n if (hasDomDataExpandoProperty in element) { // IE <= 8 throws errors if you delete non-existent properties from a DOM node\n delete element[hasDomDataExpandoProperty];\n }\n element.value = value;\n }\n else {\n // Store arbitrary object using DomData\n ko.utils.domData.set(element, ko.bindingHandlers.options.optionValueDomDataKey, value);\n element[hasDomDataExpandoProperty] = true;\n\n // Special treatment of numbers is just for backward compatibility. KO 1.2.1 wrote numerical values to element.value.\n element.value = typeof value === \"number\" ? value : \"\";\n }\n break;\n case 'select':\n if (value === \"\" || value === null) // A blank string or null value will select the caption\n value = undefined;\n var selection = -1;\n for (var i = 0, n = element.options.length, optionValue; i < n; ++i) {\n optionValue = ko.selectExtensions.readValue(element.options[i]);\n // Include special check to handle selecting a caption with a blank string value\n if (optionValue == value || (optionValue === \"\" && value === undefined)) {\n selection = i;\n break;\n }\n }\n if (allowUnset || selection >= 0 || (value === undefined && element.size > 1)) {\n element.selectedIndex = selection;\n if (ko.utils.ieVersion === 6) {\n // Workaround for IE6 bug: It won't reliably apply values to SELECT nodes during the same execution thread\n // right after you've changed the set of OPTION nodes on it. So for that node type, we'll schedule a second thread\n // to apply the value as well.\n ko.utils.setTimeout(function () {\n element.selectedIndex = selection;\n }, 0);\n }\n }\n break;\n default:\n if ((value === null) || (value === undefined))\n value = \"\";\n element.value = value;\n break;\n }\n }\n };\n })();\n\n ko.exportSymbol('selectExtensions', ko.selectExtensions);\n ko.exportSymbol('selectExtensions.readValue', ko.selectExtensions.readValue);\n ko.exportSymbol('selectExtensions.writeValue', ko.selectExtensions.writeValue);\n ko.expressionRewriting = (function () {\n var javaScriptReservedWords = [\"true\", \"false\", \"null\", \"undefined\"];\n\n // Matches something that can be assigned to--either an isolated identifier or something ending with a property accessor\n // This is designed to be simple and avoid false negatives, but could produce false positives (e.g., a+b.c).\n // This also will not properly handle nested brackets (e.g., obj1[obj2['prop']]; see #911).\n var javaScriptAssignmentTarget = /^(?:[$_a-z][$\\w]*|(.+)(\\.\\s*[$_a-z][$\\w]*|\\[.+\\]))$/i;\n\n function getWriteableValue(expression) {\n if (ko.utils.arrayIndexOf(javaScriptReservedWords, expression) >= 0)\n return false;\n var match = expression.match(javaScriptAssignmentTarget);\n return match === null ? false : match[1] ? ('Object(' + match[1] + ')' + match[2]) : expression;\n }\n\n // The following regular expressions will be used to split an object-literal string into tokens\n\n var specials = ',\"\\'`{}()/:[\\\\]', // These characters have special meaning to the parser and must not appear in the middle of a token, except as part of a string.\n // Create the actual regular expression by or-ing the following regex strings. The order is important.\n bindingToken = RegExp([\n // These match strings, either with double quotes, single quotes, or backticks\n '\"(?:\\\\\\\\.|[^\"])*\"',\n \"'(?:\\\\\\\\.|[^'])*'\",\n \"`(?:\\\\\\\\.|[^`])*`\",\n // Match C style comments\n \"/\\\\*(?:[^*]|\\\\*+[^*/])*\\\\*+/\",\n // Match C++ style comments\n \"//.*\\n\",\n // Match a regular expression (text enclosed by slashes), but will also match sets of divisions\n // as a regular expression (this is handled by the parsing loop below).\n '/(?:\\\\\\\\.|[^/])+/\\w*',\n // Match text (at least two characters) that does not contain any of the above special characters,\n // although some of the special characters are allowed to start it (all but the colon and comma).\n // The text can contain spaces, but leading or trailing spaces are skipped.\n '[^\\\\s:,/][^' + specials + ']*[^\\\\s' + specials + ']',\n // Match any non-space character not matched already. This will match colons and commas, since they're\n // not matched by \"everyThingElse\", but will also match any other single character that wasn't already\n // matched (for example: in \"a: 1, b: 2\", each of the non-space characters will be matched by oneNotSpace).\n '[^\\\\s]'\n ].join('|'), 'g'),\n\n // Match end of previous token to determine whether a slash is a division or regex.\n divisionLookBehind = /[\\])\"'A-Za-z0-9_$]+$/,\n keywordRegexLookBehind = {'in':1,'return':1,'typeof':1};\n\n function parseObjectLiteral(objectLiteralString) {\n // Trim leading and trailing spaces from the string\n var str = ko.utils.stringTrim(objectLiteralString);\n\n // Trim braces '{' surrounding the whole object literal\n if (str.charCodeAt(0) === 123) str = str.slice(1, -1);\n\n // Add a newline to correctly match a C++ style comment at the end of the string and\n // add a comma so that we don't need a separate code block to deal with the last item\n str += \"\\n,\";\n\n // Split into tokens\n var result = [], toks = str.match(bindingToken), key, values = [], depth = 0;\n\n if (toks.length > 1) {\n for (var i = 0, tok; tok = toks[i]; ++i) {\n var c = tok.charCodeAt(0);\n // A comma signals the end of a key/value pair if depth is zero\n if (c === 44) { // \",\"\n if (depth <= 0) {\n result.push((key && values.length) ? {key: key, value: values.join('')} : {'unknown': key || values.join('')});\n key = depth = 0;\n values = [];\n continue;\n }\n // Simply skip the colon that separates the name and value\n } else if (c === 58) { // \":\"\n if (!depth && !key && values.length === 1) {\n key = values.pop();\n continue;\n }\n // Comments: skip them\n } else if (c === 47 && tok.length > 1 && (tok.charCodeAt(1) === 47 || tok.charCodeAt(1) === 42)) { // \"//\" or \"/*\"\n continue;\n // A set of slashes is initially matched as a regular expression, but could be division\n } else if (c === 47 && i && tok.length > 1) { // \"/\"\n // Look at the end of the previous token to determine if the slash is actually division\n var match = toks[i-1].match(divisionLookBehind);\n if (match && !keywordRegexLookBehind[match[0]]) {\n // The slash is actually a division punctuator; re-parse the remainder of the string (not including the slash)\n str = str.substr(str.indexOf(tok) + 1);\n toks = str.match(bindingToken);\n i = -1;\n // Continue with just the slash\n tok = '/';\n }\n // Increment depth for parentheses, braces, and brackets so that interior commas are ignored\n } else if (c === 40 || c === 123 || c === 91) { // '(', '{', '['\n ++depth;\n } else if (c === 41 || c === 125 || c === 93) { // ')', '}', ']'\n --depth;\n // The key will be the first token; if it's a string, trim the quotes\n } else if (!key && !values.length && (c === 34 || c === 39)) { // '\"', \"'\"\n tok = tok.slice(1, -1);\n }\n values.push(tok);\n }\n if (depth > 0) {\n throw Error(\"Unbalanced parentheses, braces, or brackets\");\n }\n }\n return result;\n }\n\n // Two-way bindings include a write function that allow the handler to update the value even if it's not an observable.\n var twoWayBindings = {};\n\n function preProcessBindings(bindingsStringOrKeyValueArray, bindingOptions) {\n bindingOptions = bindingOptions || {};\n\n function processKeyValue(key, val) {\n var writableVal;\n function callPreprocessHook(obj) {\n return (obj && obj['preprocess']) ? (val = obj['preprocess'](val, key, processKeyValue)) : true;\n }\n if (!bindingParams) {\n if (!callPreprocessHook(ko['getBindingHandler'](key)))\n return;\n\n if (twoWayBindings[key] && (writableVal = getWriteableValue(val))) {\n // For two-way bindings, provide a write method in case the value\n // isn't a writable observable.\n var writeKey = typeof twoWayBindings[key] == 'string' ? twoWayBindings[key] : key;\n propertyAccessorResultStrings.push(\"'\" + writeKey + \"':function(_z){\" + writableVal + \"=_z}\");\n }\n }\n // Values are wrapped in a function so that each value can be accessed independently\n if (makeValueAccessors) {\n val = 'function(){return ' + val + ' }';\n }\n resultStrings.push(\"'\" + key + \"':\" + val);\n }\n\n var resultStrings = [],\n propertyAccessorResultStrings = [],\n makeValueAccessors = bindingOptions['valueAccessors'],\n bindingParams = bindingOptions['bindingParams'],\n keyValueArray = typeof bindingsStringOrKeyValueArray === \"string\" ?\n parseObjectLiteral(bindingsStringOrKeyValueArray) : bindingsStringOrKeyValueArray;\n\n ko.utils.arrayForEach(keyValueArray, function(keyValue) {\n processKeyValue(keyValue.key || keyValue['unknown'], keyValue.value);\n });\n\n if (propertyAccessorResultStrings.length)\n processKeyValue('_ko_property_writers', \"{\" + propertyAccessorResultStrings.join(\",\") + \" }\");\n\n return resultStrings.join(\",\");\n }\n\n return {\n bindingRewriteValidators: [],\n\n twoWayBindings: twoWayBindings,\n\n parseObjectLiteral: parseObjectLiteral,\n\n preProcessBindings: preProcessBindings,\n\n keyValueArrayContainsKey: function(keyValueArray, key) {\n for (var i = 0; i < keyValueArray.length; i++)\n if (keyValueArray[i]['key'] == key)\n return true;\n return false;\n },\n\n // Internal, private KO utility for updating model properties from within bindings\n // property: If the property being updated is (or might be) an observable, pass it here\n // If it turns out to be a writable observable, it will be written to directly\n // allBindings: An object with a get method to retrieve bindings in the current execution context.\n // This will be searched for a '_ko_property_writers' property in case you're writing to a non-observable\n // key: The key identifying the property to be written. Example: for { hasFocus: myValue }, write to 'myValue' by specifying the key 'hasFocus'\n // value: The value to be written\n // checkIfDifferent: If true, and if the property being written is a writable observable, the value will only be written if\n // it is !== existing value on that writable observable\n writeValueToProperty: function(property, allBindings, key, value, checkIfDifferent) {\n if (!property || !ko.isObservable(property)) {\n var propWriters = allBindings.get('_ko_property_writers');\n if (propWriters && propWriters[key])\n propWriters[key](value);\n } else if (ko.isWriteableObservable(property) && (!checkIfDifferent || property.peek() !== value)) {\n property(value);\n }\n }\n };\n })();\n\n ko.exportSymbol('expressionRewriting', ko.expressionRewriting);\n ko.exportSymbol('expressionRewriting.bindingRewriteValidators', ko.expressionRewriting.bindingRewriteValidators);\n ko.exportSymbol('expressionRewriting.parseObjectLiteral', ko.expressionRewriting.parseObjectLiteral);\n ko.exportSymbol('expressionRewriting.preProcessBindings', ko.expressionRewriting.preProcessBindings);\n\n// Making bindings explicitly declare themselves as \"two way\" isn't ideal in the long term (it would be better if\n// all bindings could use an official 'property writer' API without needing to declare that they might). However,\n// since this is not, and has never been, a public API (_ko_property_writers was never documented), it's acceptable\n// as an internal implementation detail in the short term.\n// For those developers who rely on _ko_property_writers in their custom bindings, we expose _twoWayBindings as an\n// undocumented feature that makes it relatively easy to upgrade to KO 3.0. However, this is still not an official\n// public API, and we reserve the right to remove it at any time if we create a real public property writers API.\n ko.exportSymbol('expressionRewriting._twoWayBindings', ko.expressionRewriting.twoWayBindings);\n\n// For backward compatibility, define the following aliases. (Previously, these function names were misleading because\n// they referred to JSON specifically, even though they actually work with arbitrary JavaScript object literal expressions.)\n ko.exportSymbol('jsonExpressionRewriting', ko.expressionRewriting);\n ko.exportSymbol('jsonExpressionRewriting.insertPropertyAccessorsIntoJson', ko.expressionRewriting.preProcessBindings);\n (function() {\n // \"Virtual elements\" is an abstraction on top of the usual DOM API which understands the notion that comment nodes\n // may be used to represent hierarchy (in addition to the DOM's natural hierarchy).\n // If you call the DOM-manipulating functions on ko.virtualElements, you will be able to read and write the state\n // of that virtual hierarchy\n //\n // The point of all this is to support containerless templates (e.g., <!-- ko foreach:someCollection -->blah<!-- /ko -->)\n // without having to scatter special cases all over the binding and templating code.\n\n // IE 9 cannot reliably read the \"nodeValue\" property of a comment node (see https://github.com/SteveSanderson/knockout/issues/186)\n // but it does give them a nonstandard alternative property called \"text\" that it can read reliably. Other browsers don't have that property.\n // So, use node.text where available, and node.nodeValue elsewhere\n var commentNodesHaveTextProperty = document && document.createComment(\"test\").text === \"<!--test-->\";\n\n var startCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*ko(?:\\s+([\\s\\S]+))?\\s*-->$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/;\n var endCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*\\/ko\\s*-->$/ : /^\\s*\\/ko\\s*$/;\n var htmlTagsWithOptionallyClosingChildren = { 'ul': true, 'ol': true };\n\n function isStartComment(node) {\n return (node.nodeType == 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\n }\n\n function isEndComment(node) {\n return (node.nodeType == 8) && endCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\n }\n\n function isUnmatchedEndComment(node) {\n return isEndComment(node) && !(ko.utils.domData.get(node, matchedEndCommentDataKey));\n }\n\n var matchedEndCommentDataKey = \"__ko_matchedEndComment__\"\n\n function getVirtualChildren(startComment, allowUnbalanced) {\n var currentNode = startComment;\n var depth = 1;\n var children = [];\n while (currentNode = currentNode.nextSibling) {\n if (isEndComment(currentNode)) {\n ko.utils.domData.set(currentNode, matchedEndCommentDataKey, true);\n depth--;\n if (depth === 0)\n return children;\n }\n\n children.push(currentNode);\n\n if (isStartComment(currentNode))\n depth++;\n }\n if (!allowUnbalanced)\n throw new Error(\"Cannot find closing comment tag to match: \" + startComment.nodeValue);\n return null;\n }\n\n function getMatchingEndComment(startComment, allowUnbalanced) {\n var allVirtualChildren = getVirtualChildren(startComment, allowUnbalanced);\n if (allVirtualChildren) {\n if (allVirtualChildren.length > 0)\n return allVirtualChildren[allVirtualChildren.length - 1].nextSibling;\n return startComment.nextSibling;\n } else\n return null; // Must have no matching end comment, and allowUnbalanced is true\n }\n\n function getUnbalancedChildTags(node) {\n // e.g., from <div>OK</div><!-- ko blah --><span>Another</span>, returns: <!-- ko blah --><span>Another</span>\n // from <div>OK</div><!-- /ko --><!-- /ko -->, returns: <!-- /ko --><!-- /ko -->\n var childNode = node.firstChild, captureRemaining = null;\n if (childNode) {\n do {\n if (captureRemaining) // We already hit an unbalanced node and are now just scooping up all subsequent nodes\n captureRemaining.push(childNode);\n else if (isStartComment(childNode)) {\n var matchingEndComment = getMatchingEndComment(childNode, /* allowUnbalanced: */ true);\n if (matchingEndComment) // It's a balanced tag, so skip immediately to the end of this virtual set\n childNode = matchingEndComment;\n else\n captureRemaining = [childNode]; // It's unbalanced, so start capturing from this point\n } else if (isEndComment(childNode)) {\n captureRemaining = [childNode]; // It's unbalanced (if it wasn't, we'd have skipped over it already), so start capturing\n }\n } while (childNode = childNode.nextSibling);\n }\n return captureRemaining;\n }\n\n ko.virtualElements = {\n allowedBindings: {},\n\n childNodes: function(node) {\n return isStartComment(node) ? getVirtualChildren(node) : node.childNodes;\n },\n\n emptyNode: function(node) {\n if (!isStartComment(node))\n ko.utils.emptyDomNode(node);\n else {\n var virtualChildren = ko.virtualElements.childNodes(node);\n for (var i = 0, j = virtualChildren.length; i < j; i++)\n ko.removeNode(virtualChildren[i]);\n }\n },\n\n setDomNodeChildren: function(node, childNodes) {\n if (!isStartComment(node))\n ko.utils.setDomNodeChildren(node, childNodes);\n else {\n ko.virtualElements.emptyNode(node);\n var endCommentNode = node.nextSibling; // Must be the next sibling, as we just emptied the children\n for (var i = 0, j = childNodes.length; i < j; i++)\n endCommentNode.parentNode.insertBefore(childNodes[i], endCommentNode);\n }\n },\n\n prepend: function(containerNode, nodeToPrepend) {\n var insertBeforeNode;\n\n if (isStartComment(containerNode)) {\n // Start comments must always have a parent and at least one following sibling (the end comment)\n insertBeforeNode = containerNode.nextSibling;\n containerNode = containerNode.parentNode;\n } else {\n insertBeforeNode = containerNode.firstChild;\n }\n\n if (!insertBeforeNode) {\n containerNode.appendChild(nodeToPrepend);\n } else if (nodeToPrepend !== insertBeforeNode) { // IE will sometimes crash if you try to insert a node before itself\n containerNode.insertBefore(nodeToPrepend, insertBeforeNode);\n }\n },\n\n insertAfter: function(containerNode, nodeToInsert, insertAfterNode) {\n if (!insertAfterNode) {\n ko.virtualElements.prepend(containerNode, nodeToInsert);\n } else {\n // Children of start comments must always have a parent and at least one following sibling (the end comment)\n var insertBeforeNode = insertAfterNode.nextSibling;\n\n if (isStartComment(containerNode)) {\n containerNode = containerNode.parentNode;\n }\n\n if (!insertBeforeNode) {\n containerNode.appendChild(nodeToInsert);\n } else if (nodeToInsert !== insertBeforeNode) { // IE will sometimes crash if you try to insert a node before itself\n containerNode.insertBefore(nodeToInsert, insertBeforeNode);\n }\n }\n },\n\n firstChild: function(node) {\n if (!isStartComment(node)) {\n if (node.firstChild && isEndComment(node.firstChild)) {\n throw new Error(\"Found invalid end comment, as the first child of \" + node);\n }\n return node.firstChild;\n } else if (!node.nextSibling || isEndComment(node.nextSibling)) {\n return null;\n } else {\n return node.nextSibling;\n }\n },\n\n nextSibling: function(node) {\n if (isStartComment(node)) {\n node = getMatchingEndComment(node);\n }\n\n if (node.nextSibling && isEndComment(node.nextSibling)) {\n if (isUnmatchedEndComment(node.nextSibling)) {\n throw Error(\"Found end comment without a matching opening comment, as child of \" + node);\n } else {\n return null;\n }\n } else {\n return node.nextSibling;\n }\n },\n\n hasBindingValue: isStartComment,\n\n virtualNodeBindingValue: function(node) {\n var regexMatch = (commentNodesHaveTextProperty ? node.text : node.nodeValue).match(startCommentRegex);\n return regexMatch ? regexMatch[1] : null;\n },\n\n normaliseVirtualElementDomStructure: function(elementVerified) {\n // Workaround for https://github.com/SteveSanderson/knockout/issues/155\n // (IE <= 8 or IE 9 quirks mode parses your HTML weirdly, treating closing </li> tags as if they don't exist, thereby moving comment nodes\n // that are direct descendants of <ul> into the preceding <li>)\n if (!htmlTagsWithOptionallyClosingChildren[ko.utils.tagNameLower(elementVerified)])\n return;\n\n // Scan immediate children to see if they contain unbalanced comment tags. If they do, those comment tags\n // must be intended to appear *after* that child, so move them there.\n var childNode = elementVerified.firstChild;\n if (childNode) {\n do {\n if (childNode.nodeType === 1) {\n var unbalancedTags = getUnbalancedChildTags(childNode);\n if (unbalancedTags) {\n // Fix up the DOM by moving the unbalanced tags to where they most likely were intended to be placed - *after* the child\n var nodeToInsertBefore = childNode.nextSibling;\n for (var i = 0; i < unbalancedTags.length; i++) {\n if (nodeToInsertBefore)\n elementVerified.insertBefore(unbalancedTags[i], nodeToInsertBefore);\n else\n elementVerified.appendChild(unbalancedTags[i]);\n }\n }\n }\n } while (childNode = childNode.nextSibling);\n }\n }\n };\n })();\n ko.exportSymbol('virtualElements', ko.virtualElements);\n ko.exportSymbol('virtualElements.allowedBindings', ko.virtualElements.allowedBindings);\n ko.exportSymbol('virtualElements.emptyNode', ko.virtualElements.emptyNode);\n//ko.exportSymbol('virtualElements.firstChild', ko.virtualElements.firstChild); // firstChild is not minified\n ko.exportSymbol('virtualElements.insertAfter', ko.virtualElements.insertAfter);\n//ko.exportSymbol('virtualElements.nextSibling', ko.virtualElements.nextSibling); // nextSibling is not minified\n ko.exportSymbol('virtualElements.prepend', ko.virtualElements.prepend);\n ko.exportSymbol('virtualElements.setDomNodeChildren', ko.virtualElements.setDomNodeChildren);\n (function() {\n var defaultBindingAttributeName = \"data-bind\";\n\n ko.bindingProvider = function() {\n this.bindingCache = {};\n };\n\n ko.utils.extend(ko.bindingProvider.prototype, {\n 'nodeHasBindings': function(node) {\n switch (node.nodeType) {\n case 1: // Element\n return node.getAttribute(defaultBindingAttributeName) != null\n || ko.components['getComponentNameForNode'](node);\n case 8: // Comment node\n return ko.virtualElements.hasBindingValue(node);\n default: return false;\n }\n },\n\n 'getBindings': function(node, bindingContext) {\n var bindingsString = this['getBindingsString'](node, bindingContext),\n parsedBindings = bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node) : null;\n return ko.components.addBindingsForCustomElement(parsedBindings, node, bindingContext, /* valueAccessors */ false);\n },\n\n 'getBindingAccessors': function(node, bindingContext) {\n var bindingsString = this['getBindingsString'](node, bindingContext),\n parsedBindings = bindingsString ? this['parseBindingsString'](bindingsString, bindingContext, node, { 'valueAccessors': true }) : null;\n return ko.components.addBindingsForCustomElement(parsedBindings, node, bindingContext, /* valueAccessors */ true);\n },\n\n // The following function is only used internally by this default provider.\n // It's not part of the interface definition for a general binding provider.\n 'getBindingsString': function(node, bindingContext) {\n switch (node.nodeType) {\n case 1: return node.getAttribute(defaultBindingAttributeName); // Element\n case 8: return ko.virtualElements.virtualNodeBindingValue(node); // Comment node\n default: return null;\n }\n },\n\n // The following function is only used internally by this default provider.\n // It's not part of the interface definition for a general binding provider.\n 'parseBindingsString': function(bindingsString, bindingContext, node, options) {\n try {\n var bindingFunction = createBindingsStringEvaluatorViaCache(bindingsString, this.bindingCache, options);\n return bindingFunction(bindingContext, node);\n } catch (ex) {\n ex.message = \"Unable to parse bindings.\\nBindings value: \" + bindingsString + \"\\nMessage: \" + ex.message;\n throw ex;\n }\n }\n });\n\n ko.bindingProvider['instance'] = new ko.bindingProvider();\n\n function createBindingsStringEvaluatorViaCache(bindingsString, cache, options) {\n var cacheKey = bindingsString + (options && options['valueAccessors'] || '');\n return cache[cacheKey]\n || (cache[cacheKey] = createBindingsStringEvaluator(bindingsString, options));\n }\n\n function createBindingsStringEvaluator(bindingsString, options) {\n // Build the source for a function that evaluates \"expression\"\n // For each scope variable, add an extra level of \"with\" nesting\n // Example result: with(sc1) { with(sc0) { return (expression) } }\n var rewrittenBindings = ko.expressionRewriting.preProcessBindings(bindingsString, options),\n functionBody = \"with($context){with($data||{}){return{\" + rewrittenBindings + \"}}}\";\n return new Function(\"$context\", \"$element\", functionBody);\n }\n })();\n\n ko.exportSymbol('bindingProvider', ko.bindingProvider);\n (function () {\n // Hide or don't minify context properties, see https://github.com/knockout/knockout/issues/2294\n var contextSubscribable = ko.utils.createSymbolOrString('_subscribable');\n var contextAncestorBindingInfo = ko.utils.createSymbolOrString('_ancestorBindingInfo');\n var contextDataDependency = ko.utils.createSymbolOrString('_dataDependency');\n\n ko.bindingHandlers = {};\n\n // The following element types will not be recursed into during binding.\n var bindingDoesNotRecurseIntoElementTypes = {\n // Don't want bindings that operate on text nodes to mutate <script> and <textarea> contents,\n // because it's unexpected and a potential XSS issue.\n // Also bindings should not operate on <template> elements since this breaks in Internet Explorer\n // and because such elements' contents are always intended to be bound in a different context\n // from where they appear in the document.\n 'script': true,\n 'textarea': true,\n 'template': true\n };\n\n // Use an overridable method for retrieving binding handlers so that plugins may support dynamically created handlers\n ko['getBindingHandler'] = function(bindingKey) {\n return ko.bindingHandlers[bindingKey];\n };\n\n var inheritParentVm = {};\n\n // The ko.bindingContext constructor is only called directly to create the root context. For child\n // contexts, use bindingContext.createChildContext or bindingContext.extend.\n ko.bindingContext = function(dataItemOrAccessor, parentContext, dataItemAlias, extendCallback, options) {\n\n // The binding context object includes static properties for the current, parent, and root view models.\n // If a view model is actually stored in an observable, the corresponding binding context object, and\n // any child contexts, must be updated when the view model is changed.\n function updateContext() {\n // Most of the time, the context will directly get a view model object, but if a function is given,\n // we call the function to retrieve the view model. If the function accesses any observables or returns\n // an observable, the dependency is tracked, and those observables can later cause the binding\n // context to be updated.\n var dataItemOrObservable = isFunc ? realDataItemOrAccessor() : realDataItemOrAccessor,\n dataItem = ko.utils.unwrapObservable(dataItemOrObservable);\n\n if (parentContext) {\n // Copy $root and any custom properties from the parent context\n ko.utils.extend(self, parentContext);\n\n // Copy Symbol properties\n if (contextAncestorBindingInfo in parentContext) {\n self[contextAncestorBindingInfo] = parentContext[contextAncestorBindingInfo];\n }\n } else {\n self['$parents'] = [];\n self['$root'] = dataItem;\n\n // Export 'ko' in the binding context so it will be available in bindings and templates\n // even if 'ko' isn't exported as a global, such as when using an AMD loader.\n // See https://github.com/SteveSanderson/knockout/issues/490\n self['ko'] = ko;\n }\n\n self[contextSubscribable] = subscribable;\n\n if (shouldInheritData) {\n dataItem = self['$data'];\n } else {\n self['$rawData'] = dataItemOrObservable;\n self['$data'] = dataItem;\n }\n\n if (dataItemAlias)\n self[dataItemAlias] = dataItem;\n\n // The extendCallback function is provided when creating a child context or extending a context.\n // It handles the specific actions needed to finish setting up the binding context. Actions in this\n // function could also add dependencies to this binding context.\n if (extendCallback)\n extendCallback(self, parentContext, dataItem);\n\n // When a \"parent\" context is given and we don't already have a dependency on its context, register a dependency on it.\n // Thus whenever the parent context is updated, this context will also be updated.\n if (parentContext && parentContext[contextSubscribable] && !ko.computedContext.computed().hasAncestorDependency(parentContext[contextSubscribable])) {\n parentContext[contextSubscribable]();\n }\n\n if (dataDependency) {\n self[contextDataDependency] = dataDependency;\n }\n\n return self['$data'];\n }\n\n var self = this,\n shouldInheritData = dataItemOrAccessor === inheritParentVm,\n realDataItemOrAccessor = shouldInheritData ? undefined : dataItemOrAccessor,\n isFunc = typeof(realDataItemOrAccessor) == \"function\" && !ko.isObservable(realDataItemOrAccessor),\n nodes,\n subscribable,\n dataDependency = options && options['dataDependency'];\n\n if (options && options['exportDependencies']) {\n // The \"exportDependencies\" option means that the calling code will track any dependencies and re-create\n // the binding context when they change.\n updateContext();\n } else {\n subscribable = ko.pureComputed(updateContext);\n subscribable.peek();\n\n // At this point, the binding context has been initialized, and the \"subscribable\" computed observable is\n // subscribed to any observables that were accessed in the process. If there is nothing to track, the\n // computed will be inactive, and we can safely throw it away. If it's active, the computed is stored in\n // the context object.\n if (subscribable.isActive()) {\n // Always notify because even if the model ($data) hasn't changed, other context properties might have changed\n subscribable['equalityComparer'] = null;\n } else {\n self[contextSubscribable] = undefined;\n }\n }\n }\n\n // Extend the binding context hierarchy with a new view model object. If the parent context is watching\n // any observables, the new child context will automatically get a dependency on the parent context.\n // But this does not mean that the $data value of the child context will also get updated. If the child\n // view model also depends on the parent view model, you must provide a function that returns the correct\n // view model on each update.\n ko.bindingContext.prototype['createChildContext'] = function (dataItemOrAccessor, dataItemAlias, extendCallback, options) {\n if (!options && dataItemAlias && typeof dataItemAlias == \"object\") {\n options = dataItemAlias;\n dataItemAlias = options['as'];\n extendCallback = options['extend'];\n }\n\n if (dataItemAlias && options && options['noChildContext']) {\n var isFunc = typeof(dataItemOrAccessor) == \"function\" && !ko.isObservable(dataItemOrAccessor);\n return new ko.bindingContext(inheritParentVm, this, null, function (self) {\n if (extendCallback)\n extendCallback(self);\n self[dataItemAlias] = isFunc ? dataItemOrAccessor() : dataItemOrAccessor;\n }, options);\n }\n\n return new ko.bindingContext(dataItemOrAccessor, this, dataItemAlias, function (self, parentContext) {\n // Extend the context hierarchy by setting the appropriate pointers\n self['$parentContext'] = parentContext;\n self['$parent'] = parentContext['$data'];\n self['$parents'] = (parentContext['$parents'] || []).slice(0);\n self['$parents'].unshift(self['$parent']);\n if (extendCallback)\n extendCallback(self);\n }, options);\n };\n\n // Extend the binding context with new custom properties. This doesn't change the context hierarchy.\n // Similarly to \"child\" contexts, provide a function here to make sure that the correct values are set\n // when an observable view model is updated.\n ko.bindingContext.prototype['extend'] = function(properties, options) {\n return new ko.bindingContext(inheritParentVm, this, null, function(self, parentContext) {\n ko.utils.extend(self, typeof(properties) == \"function\" ? properties(self) : properties);\n }, options);\n };\n\n var boundElementDomDataKey = ko.utils.domData.nextKey();\n\n function asyncContextDispose(node) {\n var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey),\n asyncContext = bindingInfo && bindingInfo.asyncContext;\n if (asyncContext) {\n bindingInfo.asyncContext = null;\n asyncContext.notifyAncestor();\n }\n }\n function AsyncCompleteContext(node, bindingInfo, ancestorBindingInfo) {\n this.node = node;\n this.bindingInfo = bindingInfo;\n this.asyncDescendants = [];\n this.childrenComplete = false;\n\n if (!bindingInfo.asyncContext) {\n ko.utils.domNodeDisposal.addDisposeCallback(node, asyncContextDispose);\n }\n\n if (ancestorBindingInfo && ancestorBindingInfo.asyncContext) {\n ancestorBindingInfo.asyncContext.asyncDescendants.push(node);\n this.ancestorBindingInfo = ancestorBindingInfo;\n }\n }\n AsyncCompleteContext.prototype.notifyAncestor = function () {\n if (this.ancestorBindingInfo && this.ancestorBindingInfo.asyncContext) {\n this.ancestorBindingInfo.asyncContext.descendantComplete(this.node);\n }\n };\n AsyncCompleteContext.prototype.descendantComplete = function (node) {\n ko.utils.arrayRemoveItem(this.asyncDescendants, node);\n if (!this.asyncDescendants.length && this.childrenComplete) {\n this.completeChildren();\n }\n };\n AsyncCompleteContext.prototype.completeChildren = function () {\n this.childrenComplete = true;\n if (this.bindingInfo.asyncContext && !this.asyncDescendants.length) {\n this.bindingInfo.asyncContext = null;\n ko.utils.domNodeDisposal.removeDisposeCallback(this.node, asyncContextDispose);\n ko.bindingEvent.notify(this.node, ko.bindingEvent.descendantsComplete);\n this.notifyAncestor();\n }\n };\n\n ko.bindingEvent = {\n childrenComplete: \"childrenComplete\",\n descendantsComplete : \"descendantsComplete\",\n\n subscribe: function (node, event, callback, context, options) {\n var bindingInfo = ko.utils.domData.getOrSet(node, boundElementDomDataKey, {});\n if (!bindingInfo.eventSubscribable) {\n bindingInfo.eventSubscribable = new ko.subscribable;\n }\n if (options && options['notifyImmediately'] && bindingInfo.notifiedEvents[event]) {\n ko.dependencyDetection.ignore(callback, context, [node]);\n }\n return bindingInfo.eventSubscribable.subscribe(callback, context, event);\n },\n\n notify: function (node, event) {\n var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey);\n if (bindingInfo) {\n bindingInfo.notifiedEvents[event] = true;\n if (bindingInfo.eventSubscribable) {\n bindingInfo.eventSubscribable['notifySubscribers'](node, event);\n }\n if (event == ko.bindingEvent.childrenComplete) {\n if (bindingInfo.asyncContext) {\n bindingInfo.asyncContext.completeChildren();\n } else if (bindingInfo.asyncContext === undefined && bindingInfo.eventSubscribable && bindingInfo.eventSubscribable.hasSubscriptionsForEvent(ko.bindingEvent.descendantsComplete)) {\n // It's currently an error to register a descendantsComplete handler for a node that was never registered as completing asynchronously.\n // That's because without the asyncContext, we don't have a way to know that all descendants have completed.\n throw new Error(\"descendantsComplete event not supported for bindings on this node\");\n }\n }\n }\n },\n\n startPossiblyAsyncContentBinding: function (node, bindingContext) {\n var bindingInfo = ko.utils.domData.getOrSet(node, boundElementDomDataKey, {});\n\n if (!bindingInfo.asyncContext) {\n bindingInfo.asyncContext = new AsyncCompleteContext(node, bindingInfo, bindingContext[contextAncestorBindingInfo]);\n }\n\n // If the provided context was already extended with this node's binding info, just return the extended context\n if (bindingContext[contextAncestorBindingInfo] == bindingInfo) {\n return bindingContext;\n }\n\n return bindingContext['extend'](function (ctx) {\n ctx[contextAncestorBindingInfo] = bindingInfo;\n });\n }\n };\n\n // Returns the valueAccessor function for a binding value\n function makeValueAccessor(value) {\n return function() {\n return value;\n };\n }\n\n // Returns the value of a valueAccessor function\n function evaluateValueAccessor(valueAccessor) {\n return valueAccessor();\n }\n\n // Given a function that returns bindings, create and return a new object that contains\n // binding value-accessors functions. Each accessor function calls the original function\n // so that it always gets the latest value and all dependencies are captured. This is used\n // by ko.applyBindingsToNode and getBindingsAndMakeAccessors.\n function makeAccessorsFromFunction(callback) {\n return ko.utils.objectMap(ko.dependencyDetection.ignore(callback), function(value, key) {\n return function() {\n return callback()[key];\n };\n });\n }\n\n // Given a bindings function or object, create and return a new object that contains\n // binding value-accessors functions. This is used by ko.applyBindingsToNode.\n function makeBindingAccessors(bindings, context, node) {\n if (typeof bindings === 'function') {\n return makeAccessorsFromFunction(bindings.bind(null, context, node));\n } else {\n return ko.utils.objectMap(bindings, makeValueAccessor);\n }\n }\n\n // This function is used if the binding provider doesn't include a getBindingAccessors function.\n // It must be called with 'this' set to the provider instance.\n function getBindingsAndMakeAccessors(node, context) {\n return makeAccessorsFromFunction(this['getBindings'].bind(this, node, context));\n }\n\n function validateThatBindingIsAllowedForVirtualElements(bindingName) {\n var validator = ko.virtualElements.allowedBindings[bindingName];\n if (!validator)\n throw new Error(\"The binding '\" + bindingName + \"' cannot be used with virtual elements\")\n }\n\n function applyBindingsToDescendantsInternal(bindingContext, elementOrVirtualElement) {\n var nextInQueue = ko.virtualElements.firstChild(elementOrVirtualElement);\n\n if (nextInQueue) {\n var currentChild,\n provider = ko.bindingProvider['instance'],\n preprocessNode = provider['preprocessNode'];\n\n // Preprocessing allows a binding provider to mutate a node before bindings are applied to it. For example it's\n // possible to insert new siblings after it, and/or replace the node with a different one. This can be used to\n // implement custom binding syntaxes, such as {{ value }} for string interpolation, or custom element types that\n // trigger insertion of <template> contents at that point in the document.\n if (preprocessNode) {\n while (currentChild = nextInQueue) {\n nextInQueue = ko.virtualElements.nextSibling(currentChild);\n preprocessNode.call(provider, currentChild);\n }\n // Reset nextInQueue for the next loop\n nextInQueue = ko.virtualElements.firstChild(elementOrVirtualElement);\n }\n\n while (currentChild = nextInQueue) {\n // Keep a record of the next child *before* applying bindings, in case the binding removes the current child from its position\n nextInQueue = ko.virtualElements.nextSibling(currentChild);\n applyBindingsToNodeAndDescendantsInternal(bindingContext, currentChild);\n }\n }\n ko.bindingEvent.notify(elementOrVirtualElement, ko.bindingEvent.childrenComplete);\n }\n\n function applyBindingsToNodeAndDescendantsInternal(bindingContext, nodeVerified) {\n var bindingContextForDescendants = bindingContext;\n\n var isElement = (nodeVerified.nodeType === 1);\n if (isElement) // Workaround IE <= 8 HTML parsing weirdness\n ko.virtualElements.normaliseVirtualElementDomStructure(nodeVerified);\n\n // Perf optimisation: Apply bindings only if...\n // (1) We need to store the binding info for the node (all element nodes)\n // (2) It might have bindings (e.g., it has a data-bind attribute, or it's a marker for a containerless template)\n var shouldApplyBindings = isElement || ko.bindingProvider['instance']['nodeHasBindings'](nodeVerified);\n if (shouldApplyBindings)\n bindingContextForDescendants = applyBindingsToNodeInternal(nodeVerified, null, bindingContext)['bindingContextForDescendants'];\n\n if (bindingContextForDescendants && !bindingDoesNotRecurseIntoElementTypes[ko.utils.tagNameLower(nodeVerified)]) {\n applyBindingsToDescendantsInternal(bindingContextForDescendants, nodeVerified);\n }\n }\n\n function topologicalSortBindings(bindings) {\n // Depth-first sort\n var result = [], // The list of key/handler pairs that we will return\n bindingsConsidered = {}, // A temporary record of which bindings are already in 'result'\n cyclicDependencyStack = []; // Keeps track of a depth-search so that, if there's a cycle, we know which bindings caused it\n ko.utils.objectForEach(bindings, function pushBinding(bindingKey) {\n if (!bindingsConsidered[bindingKey]) {\n var binding = ko['getBindingHandler'](bindingKey);\n if (binding) {\n // First add dependencies (if any) of the current binding\n if (binding['after']) {\n cyclicDependencyStack.push(bindingKey);\n ko.utils.arrayForEach(binding['after'], function(bindingDependencyKey) {\n if (bindings[bindingDependencyKey]) {\n if (ko.utils.arrayIndexOf(cyclicDependencyStack, bindingDependencyKey) !== -1) {\n throw Error(\"Cannot combine the following bindings, because they have a cyclic dependency: \" + cyclicDependencyStack.join(\", \"));\n } else {\n pushBinding(bindingDependencyKey);\n }\n }\n });\n cyclicDependencyStack.length--;\n }\n // Next add the current binding\n result.push({ key: bindingKey, handler: binding });\n }\n bindingsConsidered[bindingKey] = true;\n }\n });\n\n return result;\n }\n\n function applyBindingsToNodeInternal(node, sourceBindings, bindingContext) {\n var bindingInfo = ko.utils.domData.getOrSet(node, boundElementDomDataKey, {});\n\n // Prevent multiple applyBindings calls for the same node, except when a binding value is specified\n var alreadyBound = bindingInfo.alreadyBound;\n if (!sourceBindings) {\n if (alreadyBound) {\n throw Error(\"You cannot apply bindings multiple times to the same element.\");\n }\n bindingInfo.alreadyBound = true;\n }\n if (!alreadyBound) {\n bindingInfo.context = bindingContext;\n }\n if (!bindingInfo.notifiedEvents) {\n bindingInfo.notifiedEvents = {};\n }\n\n // Use bindings if given, otherwise fall back on asking the bindings provider to give us some bindings\n var bindings;\n if (sourceBindings && typeof sourceBindings !== 'function') {\n bindings = sourceBindings;\n } else {\n var provider = ko.bindingProvider['instance'],\n getBindings = provider['getBindingAccessors'] || getBindingsAndMakeAccessors;\n\n // Get the binding from the provider within a computed observable so that we can update the bindings whenever\n // the binding context is updated or if the binding provider accesses observables.\n var bindingsUpdater = ko.dependentObservable(\n function() {\n bindings = sourceBindings ? sourceBindings(bindingContext, node) : getBindings.call(provider, node, bindingContext);\n // Register a dependency on the binding context to support observable view models.\n if (bindings) {\n if (bindingContext[contextSubscribable]) {\n bindingContext[contextSubscribable]();\n }\n if (bindingContext[contextDataDependency]) {\n bindingContext[contextDataDependency]();\n }\n }\n return bindings;\n },\n null, { disposeWhenNodeIsRemoved: node }\n );\n\n if (!bindings || !bindingsUpdater.isActive())\n bindingsUpdater = null;\n }\n\n var contextToExtend = bindingContext;\n var bindingHandlerThatControlsDescendantBindings;\n if (bindings) {\n // Return the value accessor for a given binding. When bindings are static (won't be updated because of a binding\n // context update), just return the value accessor from the binding. Otherwise, return a function that always gets\n // the latest binding value and registers a dependency on the binding updater.\n var getValueAccessor = bindingsUpdater\n ? function(bindingKey) {\n return function() {\n return evaluateValueAccessor(bindingsUpdater()[bindingKey]);\n };\n } : function(bindingKey) {\n return bindings[bindingKey];\n };\n\n // Use of allBindings as a function is maintained for backwards compatibility, but its use is deprecated\n function allBindings() {\n return ko.utils.objectMap(bindingsUpdater ? bindingsUpdater() : bindings, evaluateValueAccessor);\n }\n // The following is the 3.x allBindings API\n allBindings['get'] = function(key) {\n return bindings[key] && evaluateValueAccessor(getValueAccessor(key));\n };\n allBindings['has'] = function(key) {\n return key in bindings;\n };\n\n if (ko.bindingEvent.childrenComplete in bindings) {\n ko.bindingEvent.subscribe(node, ko.bindingEvent.childrenComplete, function () {\n var callback = evaluateValueAccessor(bindings[ko.bindingEvent.childrenComplete]);\n if (callback) {\n var nodes = ko.virtualElements.childNodes(node);\n if (nodes.length) {\n callback(nodes, ko.dataFor(nodes[0]));\n }\n }\n });\n }\n\n if (ko.bindingEvent.descendantsComplete in bindings) {\n contextToExtend = ko.bindingEvent.startPossiblyAsyncContentBinding(node, bindingContext);\n ko.bindingEvent.subscribe(node, ko.bindingEvent.descendantsComplete, function () {\n var callback = evaluateValueAccessor(bindings[ko.bindingEvent.descendantsComplete]);\n if (callback && ko.virtualElements.firstChild(node)) {\n callback(node);\n }\n });\n }\n\n // First put the bindings into the right order\n var orderedBindings = topologicalSortBindings(bindings);\n\n // Go through the sorted bindings, calling init and update for each\n ko.utils.arrayForEach(orderedBindings, function(bindingKeyAndHandler) {\n // Note that topologicalSortBindings has already filtered out any nonexistent binding handlers,\n // so bindingKeyAndHandler.handler will always be nonnull.\n var handlerInitFn = bindingKeyAndHandler.handler[\"init\"],\n handlerUpdateFn = bindingKeyAndHandler.handler[\"update\"],\n bindingKey = bindingKeyAndHandler.key;\n\n if (node.nodeType === 8) {\n validateThatBindingIsAllowedForVirtualElements(bindingKey);\n }\n\n try {\n // Run init, ignoring any dependencies\n if (typeof handlerInitFn == \"function\") {\n ko.dependencyDetection.ignore(function() {\n var initResult = handlerInitFn(node, getValueAccessor(bindingKey), allBindings, contextToExtend['$data'], contextToExtend);\n\n // If this binding handler claims to control descendant bindings, make a note of this\n if (initResult && initResult['controlsDescendantBindings']) {\n if (bindingHandlerThatControlsDescendantBindings !== undefined)\n throw new Error(\"Multiple bindings (\" + bindingHandlerThatControlsDescendantBindings + \" and \" + bindingKey + \") are trying to control descendant bindings of the same element. You cannot use these bindings together on the same element.\");\n bindingHandlerThatControlsDescendantBindings = bindingKey;\n }\n });\n }\n\n // Run update in its own computed wrapper\n if (typeof handlerUpdateFn == \"function\") {\n ko.dependentObservable(\n function() {\n handlerUpdateFn(node, getValueAccessor(bindingKey), allBindings, contextToExtend['$data'], contextToExtend);\n },\n null,\n { disposeWhenNodeIsRemoved: node }\n );\n }\n } catch (ex) {\n ex.message = \"Unable to process binding \\\"\" + bindingKey + \": \" + bindings[bindingKey] + \"\\\"\\nMessage: \" + ex.message;\n throw ex;\n }\n });\n }\n\n var shouldBindDescendants = bindingHandlerThatControlsDescendantBindings === undefined;\n return {\n 'shouldBindDescendants': shouldBindDescendants,\n 'bindingContextForDescendants': shouldBindDescendants && contextToExtend\n };\n };\n\n ko.storedBindingContextForNode = function (node) {\n var bindingInfo = ko.utils.domData.get(node, boundElementDomDataKey);\n return bindingInfo && bindingInfo.context;\n }\n\n function getBindingContext(viewModelOrBindingContext, extendContextCallback) {\n return viewModelOrBindingContext && (viewModelOrBindingContext instanceof ko.bindingContext)\n ? viewModelOrBindingContext\n : new ko.bindingContext(viewModelOrBindingContext, undefined, undefined, extendContextCallback);\n }\n\n ko.applyBindingAccessorsToNode = function (node, bindings, viewModelOrBindingContext) {\n if (node.nodeType === 1) // If it's an element, workaround IE <= 8 HTML parsing weirdness\n ko.virtualElements.normaliseVirtualElementDomStructure(node);\n return applyBindingsToNodeInternal(node, bindings, getBindingContext(viewModelOrBindingContext));\n };\n\n ko.applyBindingsToNode = function (node, bindings, viewModelOrBindingContext) {\n var context = getBindingContext(viewModelOrBindingContext);\n return ko.applyBindingAccessorsToNode(node, makeBindingAccessors(bindings, context, node), context);\n };\n\n ko.applyBindingsToDescendants = function(viewModelOrBindingContext, rootNode) {\n if (rootNode.nodeType === 1 || rootNode.nodeType === 8)\n applyBindingsToDescendantsInternal(getBindingContext(viewModelOrBindingContext), rootNode);\n };\n\n ko.applyBindings = function (viewModelOrBindingContext, rootNode, extendContextCallback) {\n // If jQuery is loaded after Knockout, we won't initially have access to it. So save it here.\n if (!jQueryInstance && window['jQuery']) {\n jQueryInstance = window['jQuery'];\n }\n\n if (arguments.length < 2) {\n rootNode = document.body;\n if (!rootNode) {\n throw Error(\"ko.applyBindings: could not find document.body; has the document been loaded?\");\n }\n } else if (!rootNode || (rootNode.nodeType !== 1 && rootNode.nodeType !== 8)) {\n throw Error(\"ko.applyBindings: first parameter should be your view model; second parameter should be a DOM node\");\n }\n\n applyBindingsToNodeAndDescendantsInternal(getBindingContext(viewModelOrBindingContext, extendContextCallback), rootNode);\n };\n\n // Retrieving binding context from arbitrary nodes\n ko.contextFor = function(node) {\n // We can only do something meaningful for elements and comment nodes (in particular, not text nodes, as IE can't store domdata for them)\n if (node && (node.nodeType === 1 || node.nodeType === 8)) {\n return ko.storedBindingContextForNode(node);\n }\n return undefined;\n };\n ko.dataFor = function(node) {\n var context = ko.contextFor(node);\n return context ? context['$data'] : undefined;\n };\n\n ko.exportSymbol('bindingHandlers', ko.bindingHandlers);\n ko.exportSymbol('bindingEvent', ko.bindingEvent);\n ko.exportSymbol('bindingEvent.subscribe', ko.bindingEvent.subscribe);\n ko.exportSymbol('bindingEvent.startPossiblyAsyncContentBinding', ko.bindingEvent.startPossiblyAsyncContentBinding);\n ko.exportSymbol('applyBindings', ko.applyBindings);\n ko.exportSymbol('applyBindingsToDescendants', ko.applyBindingsToDescendants);\n ko.exportSymbol('applyBindingAccessorsToNode', ko.applyBindingAccessorsToNode);\n ko.exportSymbol('applyBindingsToNode', ko.applyBindingsToNode);\n ko.exportSymbol('contextFor', ko.contextFor);\n ko.exportSymbol('dataFor', ko.dataFor);\n })();\n (function(undefined) {\n var loadingSubscribablesCache = {}, // Tracks component loads that are currently in flight\n loadedDefinitionsCache = {}; // Tracks component loads that have already completed\n\n ko.components = {\n get: function(componentName, callback) {\n var cachedDefinition = getObjectOwnProperty(loadedDefinitionsCache, componentName);\n if (cachedDefinition) {\n // It's already loaded and cached. Reuse the same definition object.\n // Note that for API consistency, even cache hits complete asynchronously by default.\n // You can bypass this by putting synchronous:true on your component config.\n if (cachedDefinition.isSynchronousComponent) {\n ko.dependencyDetection.ignore(function() { // See comment in loaderRegistryBehaviors.js for reasoning\n callback(cachedDefinition.definition);\n });\n } else {\n ko.tasks.schedule(function() { callback(cachedDefinition.definition); });\n }\n } else {\n // Join the loading process that is already underway, or start a new one.\n loadComponentAndNotify(componentName, callback);\n }\n },\n\n clearCachedDefinition: function(componentName) {\n delete loadedDefinitionsCache[componentName];\n },\n\n _getFirstResultFromLoaders: getFirstResultFromLoaders\n };\n\n function getObjectOwnProperty(obj, propName) {\n return Object.prototype.hasOwnProperty.call(obj, propName) ? obj[propName] : undefined;\n }\n\n function loadComponentAndNotify(componentName, callback) {\n var subscribable = getObjectOwnProperty(loadingSubscribablesCache, componentName),\n completedAsync;\n if (!subscribable) {\n // It's not started loading yet. Start loading, and when it's done, move it to loadedDefinitionsCache.\n subscribable = loadingSubscribablesCache[componentName] = new ko.subscribable();\n subscribable.subscribe(callback);\n\n beginLoadingComponent(componentName, function(definition, config) {\n var isSynchronousComponent = !!(config && config['synchronous']);\n loadedDefinitionsCache[componentName] = { definition: definition, isSynchronousComponent: isSynchronousComponent };\n delete loadingSubscribablesCache[componentName];\n\n // For API consistency, all loads complete asynchronously. However we want to avoid\n // adding an extra task schedule if it's unnecessary (i.e., the completion is already\n // async).\n //\n // You can bypass the 'always asynchronous' feature by putting the synchronous:true\n // flag on your component configuration when you register it.\n if (completedAsync || isSynchronousComponent) {\n // Note that notifySubscribers ignores any dependencies read within the callback.\n // See comment in loaderRegistryBehaviors.js for reasoning\n subscribable['notifySubscribers'](definition);\n } else {\n ko.tasks.schedule(function() {\n subscribable['notifySubscribers'](definition);\n });\n }\n });\n completedAsync = true;\n } else {\n subscribable.subscribe(callback);\n }\n }\n\n function beginLoadingComponent(componentName, callback) {\n getFirstResultFromLoaders('getConfig', [componentName], function(config) {\n if (config) {\n // We have a config, so now load its definition\n getFirstResultFromLoaders('loadComponent', [componentName, config], function(definition) {\n callback(definition, config);\n });\n } else {\n // The component has no config - it's unknown to all the loaders.\n // Note that this is not an error (e.g., a module loading error) - that would abort the\n // process and this callback would not run. For this callback to run, all loaders must\n // have confirmed they don't know about this component.\n callback(null, null);\n }\n });\n }\n\n function getFirstResultFromLoaders(methodName, argsExceptCallback, callback, candidateLoaders) {\n // On the first call in the stack, start with the full set of loaders\n if (!candidateLoaders) {\n candidateLoaders = ko.components['loaders'].slice(0); // Use a copy, because we'll be mutating this array\n }\n\n // Try the next candidate\n var currentCandidateLoader = candidateLoaders.shift();\n if (currentCandidateLoader) {\n var methodInstance = currentCandidateLoader[methodName];\n if (methodInstance) {\n var wasAborted = false,\n synchronousReturnValue = methodInstance.apply(currentCandidateLoader, argsExceptCallback.concat(function(result) {\n if (wasAborted) {\n callback(null);\n } else if (result !== null) {\n // This candidate returned a value. Use it.\n callback(result);\n } else {\n // Try the next candidate\n getFirstResultFromLoaders(methodName, argsExceptCallback, callback, candidateLoaders);\n }\n }));\n\n // Currently, loaders may not return anything synchronously. This leaves open the possibility\n // that we'll extend the API to support synchronous return values in the future. It won't be\n // a breaking change, because currently no loader is allowed to return anything except undefined.\n if (synchronousReturnValue !== undefined) {\n wasAborted = true;\n\n // Method to suppress exceptions will remain undocumented. This is only to keep\n // KO's specs running tidily, since we can observe the loading got aborted without\n // having exceptions cluttering up the console too.\n if (!currentCandidateLoader['suppressLoaderExceptions']) {\n throw new Error('Component loaders must supply values by invoking the callback, not by returning values synchronously.');\n }\n }\n } else {\n // This candidate doesn't have the relevant handler. Synchronously move on to the next one.\n getFirstResultFromLoaders(methodName, argsExceptCallback, callback, candidateLoaders);\n }\n } else {\n // No candidates returned a value\n callback(null);\n }\n }\n\n // Reference the loaders via string name so it's possible for developers\n // to replace the whole array by assigning to ko.components.loaders\n ko.components['loaders'] = [];\n\n ko.exportSymbol('components', ko.components);\n ko.exportSymbol('components.get', ko.components.get);\n ko.exportSymbol('components.clearCachedDefinition', ko.components.clearCachedDefinition);\n })();\n (function(undefined) {\n\n // The default loader is responsible for two things:\n // 1. Maintaining the default in-memory registry of component configuration objects\n // (i.e., the thing you're writing to when you call ko.components.register(someName, ...))\n // 2. Answering requests for components by fetching configuration objects\n // from that default in-memory registry and resolving them into standard\n // component definition objects (of the form { createViewModel: ..., template: ... })\n // Custom loaders may override either of these facilities, i.e.,\n // 1. To supply configuration objects from some other source (e.g., conventions)\n // 2. Or, to resolve configuration objects by loading viewmodels/templates via arbitrary logic.\n\n var defaultConfigRegistry = {};\n\n ko.components.register = function(componentName, config) {\n if (!config) {\n throw new Error('Invalid configuration for ' + componentName);\n }\n\n if (ko.components.isRegistered(componentName)) {\n throw new Error('Component ' + componentName + ' is already registered');\n }\n\n defaultConfigRegistry[componentName] = config;\n };\n\n ko.components.isRegistered = function(componentName) {\n return Object.prototype.hasOwnProperty.call(defaultConfigRegistry, componentName);\n };\n\n ko.components.unregister = function(componentName) {\n delete defaultConfigRegistry[componentName];\n ko.components.clearCachedDefinition(componentName);\n };\n\n ko.components.defaultLoader = {\n 'getConfig': function(componentName, callback) {\n var result = ko.components.isRegistered(componentName)\n ? defaultConfigRegistry[componentName]\n : null;\n callback(result);\n },\n\n 'loadComponent': function(componentName, config, callback) {\n var errorCallback = makeErrorCallback(componentName);\n possiblyGetConfigFromAmd(errorCallback, config, function(loadedConfig) {\n resolveConfig(componentName, errorCallback, loadedConfig, callback);\n });\n },\n\n 'loadTemplate': function(componentName, templateConfig, callback) {\n resolveTemplate(makeErrorCallback(componentName), templateConfig, callback);\n },\n\n 'loadViewModel': function(componentName, viewModelConfig, callback) {\n resolveViewModel(makeErrorCallback(componentName), viewModelConfig, callback);\n }\n };\n\n var createViewModelKey = 'createViewModel';\n\n // Takes a config object of the form { template: ..., viewModel: ... }, and asynchronously convert it\n // into the standard component definition format:\n // { template: <ArrayOfDomNodes>, createViewModel: function(params, componentInfo) { ... } }.\n // Since both template and viewModel may need to be resolved asynchronously, both tasks are performed\n // in parallel, and the results joined when both are ready. We don't depend on any promises infrastructure,\n // so this is implemented manually below.\n function resolveConfig(componentName, errorCallback, config, callback) {\n var result = {},\n makeCallBackWhenZero = 2,\n tryIssueCallback = function() {\n if (--makeCallBackWhenZero === 0) {\n callback(result);\n }\n },\n templateConfig = config['template'],\n viewModelConfig = config['viewModel'];\n\n if (templateConfig) {\n possiblyGetConfigFromAmd(errorCallback, templateConfig, function(loadedConfig) {\n ko.components._getFirstResultFromLoaders('loadTemplate', [componentName, loadedConfig], function(resolvedTemplate) {\n result['template'] = resolvedTemplate;\n tryIssueCallback();\n });\n });\n } else {\n tryIssueCallback();\n }\n\n if (viewModelConfig) {\n possiblyGetConfigFromAmd(errorCallback, viewModelConfig, function(loadedConfig) {\n ko.components._getFirstResultFromLoaders('loadViewModel', [componentName, loadedConfig], function(resolvedViewModel) {\n result[createViewModelKey] = resolvedViewModel;\n tryIssueCallback();\n });\n });\n } else {\n tryIssueCallback();\n }\n }\n\n function resolveTemplate(errorCallback, templateConfig, callback) {\n if (typeof templateConfig === 'string') {\n // Markup - parse it\n callback(ko.utils.parseHtmlFragment(templateConfig));\n } else if (templateConfig instanceof Array) {\n // Assume already an array of DOM nodes - pass through unchanged\n callback(templateConfig);\n } else if (isDocumentFragment(templateConfig)) {\n // Document fragment - use its child nodes\n callback(ko.utils.makeArray(templateConfig.childNodes));\n } else if (templateConfig['element']) {\n var element = templateConfig['element'];\n if (isDomElement(element)) {\n // Element instance - copy its child nodes\n callback(cloneNodesFromTemplateSourceElement(element));\n } else if (typeof element === 'string') {\n // Element ID - find it, then copy its child nodes\n var elemInstance = document.getElementById(element);\n if (elemInstance) {\n callback(cloneNodesFromTemplateSourceElement(elemInstance));\n } else {\n errorCallback('Cannot find element with ID ' + element);\n }\n } else {\n errorCallback('Unknown element type: ' + element);\n }\n } else {\n errorCallback('Unknown template value: ' + templateConfig);\n }\n }\n\n function resolveViewModel(errorCallback, viewModelConfig, callback) {\n if (typeof viewModelConfig === 'function') {\n // Constructor - convert to standard factory function format\n // By design, this does *not* supply componentInfo to the constructor, as the intent is that\n // componentInfo contains non-viewmodel data (e.g., the component's element) that should only\n // be used in factory functions, not viewmodel constructors.\n callback(function (params /*, componentInfo */) {\n return new viewModelConfig(params);\n });\n } else if (typeof viewModelConfig[createViewModelKey] === 'function') {\n // Already a factory function - use it as-is\n callback(viewModelConfig[createViewModelKey]);\n } else if ('instance' in viewModelConfig) {\n // Fixed object instance - promote to createViewModel format for API consistency\n var fixedInstance = viewModelConfig['instance'];\n callback(function (params, componentInfo) {\n return fixedInstance;\n });\n } else if ('viewModel' in viewModelConfig) {\n // Resolved AMD module whose value is of the form { viewModel: ... }\n resolveViewModel(errorCallback, viewModelConfig['viewModel'], callback);\n } else {\n errorCallback('Unknown viewModel value: ' + viewModelConfig);\n }\n }\n\n function cloneNodesFromTemplateSourceElement(elemInstance) {\n switch (ko.utils.tagNameLower(elemInstance)) {\n case 'script':\n return ko.utils.parseHtmlFragment(elemInstance.text);\n case 'textarea':\n return ko.utils.parseHtmlFragment(elemInstance.value);\n case 'template':\n // For browsers with proper <template> element support (i.e., where the .content property\n // gives a document fragment), use that document fragment.\n if (isDocumentFragment(elemInstance.content)) {\n return ko.utils.cloneNodes(elemInstance.content.childNodes);\n }\n }\n\n // Regular elements such as <div>, and <template> elements on old browsers that don't really\n // understand <template> and just treat it as a regular container\n return ko.utils.cloneNodes(elemInstance.childNodes);\n }\n\n function isDomElement(obj) {\n if (window['HTMLElement']) {\n return obj instanceof HTMLElement;\n } else {\n return obj && obj.tagName && obj.nodeType === 1;\n }\n }\n\n function isDocumentFragment(obj) {\n if (window['DocumentFragment']) {\n return obj instanceof DocumentFragment;\n } else {\n return obj && obj.nodeType === 11;\n }\n }\n\n function possiblyGetConfigFromAmd(errorCallback, config, callback) {\n if (typeof config['require'] === 'string') {\n // The config is the value of an AMD module\n if (amdRequire || window['require']) {\n (amdRequire || window['require'])([config['require']], function (module) {\n if (module && typeof module === 'object' && module.__esModule && module.default) {\n module = module.default;\n }\n callback(module);\n });\n } else {\n errorCallback('Uses require, but no AMD loader is present');\n }\n } else {\n callback(config);\n }\n }\n\n function makeErrorCallback(componentName) {\n return function (message) {\n throw new Error('Component \\'' + componentName + '\\': ' + message);\n };\n }\n\n ko.exportSymbol('components.register', ko.components.register);\n ko.exportSymbol('components.isRegistered', ko.components.isRegistered);\n ko.exportSymbol('components.unregister', ko.components.unregister);\n\n // Expose the default loader so that developers can directly ask it for configuration\n // or to resolve configuration\n ko.exportSymbol('components.defaultLoader', ko.components.defaultLoader);\n\n // By default, the default loader is the only registered component loader\n ko.components['loaders'].push(ko.components.defaultLoader);\n\n // Privately expose the underlying config registry for use in old-IE shim\n ko.components._allRegisteredComponents = defaultConfigRegistry;\n })();\n (function (undefined) {\n // Overridable API for determining which component name applies to a given node. By overriding this,\n // you can for example map specific tagNames to components that are not preregistered.\n ko.components['getComponentNameForNode'] = function(node) {\n var tagNameLower = ko.utils.tagNameLower(node);\n if (ko.components.isRegistered(tagNameLower)) {\n // Try to determine that this node can be considered a *custom* element; see https://github.com/knockout/knockout/issues/1603\n if (tagNameLower.indexOf('-') != -1 || ('' + node) == \"[object HTMLUnknownElement]\" || (ko.utils.ieVersion <= 8 && node.tagName === tagNameLower)) {\n return tagNameLower;\n }\n }\n };\n\n ko.components.addBindingsForCustomElement = function(allBindings, node, bindingContext, valueAccessors) {\n // Determine if it's really a custom element matching a component\n if (node.nodeType === 1) {\n var componentName = ko.components['getComponentNameForNode'](node);\n if (componentName) {\n // It does represent a component, so add a component binding for it\n allBindings = allBindings || {};\n\n if (allBindings['component']) {\n // Avoid silently overwriting some other 'component' binding that may already be on the element\n throw new Error('Cannot use the \"component\" binding on a custom element matching a component');\n }\n\n var componentBindingValue = { 'name': componentName, 'params': getComponentParamsFromCustomElement(node, bindingContext) };\n\n allBindings['component'] = valueAccessors\n ? function() { return componentBindingValue; }\n : componentBindingValue;\n }\n }\n\n return allBindings;\n }\n\n var nativeBindingProviderInstance = new ko.bindingProvider();\n\n function getComponentParamsFromCustomElement(elem, bindingContext) {\n var paramsAttribute = elem.getAttribute('params');\n\n if (paramsAttribute) {\n var params = nativeBindingProviderInstance['parseBindingsString'](paramsAttribute, bindingContext, elem, { 'valueAccessors': true, 'bindingParams': true }),\n rawParamComputedValues = ko.utils.objectMap(params, function(paramValue, paramName) {\n return ko.computed(paramValue, null, { disposeWhenNodeIsRemoved: elem });\n }),\n result = ko.utils.objectMap(rawParamComputedValues, function(paramValueComputed, paramName) {\n var paramValue = paramValueComputed.peek();\n // Does the evaluation of the parameter value unwrap any observables?\n if (!paramValueComputed.isActive()) {\n // No it doesn't, so there's no need for any computed wrapper. Just pass through the supplied value directly.\n // Example: \"someVal: firstName, age: 123\" (whether or not firstName is an observable/computed)\n return paramValue;\n } else {\n // Yes it does. Supply a computed property that unwraps both the outer (binding expression)\n // level of observability, and any inner (resulting model value) level of observability.\n // This means the component doesn't have to worry about multiple unwrapping. If the value is a\n // writable observable, the computed will also be writable and pass the value on to the observable.\n return ko.computed({\n 'read': function() {\n return ko.utils.unwrapObservable(paramValueComputed());\n },\n 'write': ko.isWriteableObservable(paramValue) && function(value) {\n paramValueComputed()(value);\n },\n disposeWhenNodeIsRemoved: elem\n });\n }\n });\n\n // Give access to the raw computeds, as long as that wouldn't overwrite any custom param also called '$raw'\n // This is in case the developer wants to react to outer (binding) observability separately from inner\n // (model value) observability, or in case the model value observable has subobservables.\n if (!Object.prototype.hasOwnProperty.call(result, '$raw')) {\n result['$raw'] = rawParamComputedValues;\n }\n\n return result;\n } else {\n // For consistency, absence of a \"params\" attribute is treated the same as the presence of\n // any empty one. Otherwise component viewmodels need special code to check whether or not\n // 'params' or 'params.$raw' is null/undefined before reading subproperties, which is annoying.\n return { '$raw': {} };\n }\n }\n\n // --------------------------------------------------------------------------------\n // Compatibility code for older (pre-HTML5) IE browsers\n\n if (ko.utils.ieVersion < 9) {\n // Whenever you preregister a component, enable it as a custom element in the current document\n ko.components['register'] = (function(originalFunction) {\n return function(componentName) {\n document.createElement(componentName); // Allows IE<9 to parse markup containing the custom element\n return originalFunction.apply(this, arguments);\n }\n })(ko.components['register']);\n\n // Whenever you create a document fragment, enable all preregistered component names as custom elements\n // This is needed to make innerShiv/jQuery HTML parsing correctly handle the custom elements\n document.createDocumentFragment = (function(originalFunction) {\n return function() {\n var newDocFrag = originalFunction(),\n allComponents = ko.components._allRegisteredComponents;\n for (var componentName in allComponents) {\n if (Object.prototype.hasOwnProperty.call(allComponents, componentName)) {\n newDocFrag.createElement(componentName);\n }\n }\n return newDocFrag;\n };\n })(document.createDocumentFragment);\n }\n })();(function(undefined) {\n var componentLoadingOperationUniqueId = 0;\n\n ko.bindingHandlers['component'] = {\n 'init': function(element, valueAccessor, ignored1, ignored2, bindingContext) {\n var currentViewModel,\n currentLoadingOperationId,\n afterRenderSub,\n disposeAssociatedComponentViewModel = function () {\n var currentViewModelDispose = currentViewModel && currentViewModel['dispose'];\n if (typeof currentViewModelDispose === 'function') {\n currentViewModelDispose.call(currentViewModel);\n }\n if (afterRenderSub) {\n afterRenderSub.dispose();\n }\n afterRenderSub = null;\n currentViewModel = null;\n // Any in-flight loading operation is no longer relevant, so make sure we ignore its completion\n currentLoadingOperationId = null;\n },\n originalChildNodes = ko.utils.makeArray(ko.virtualElements.childNodes(element));\n\n ko.virtualElements.emptyNode(element);\n ko.utils.domNodeDisposal.addDisposeCallback(element, disposeAssociatedComponentViewModel);\n\n ko.computed(function () {\n var value = ko.utils.unwrapObservable(valueAccessor()),\n componentName, componentParams;\n\n if (typeof value === 'string') {\n componentName = value;\n } else {\n componentName = ko.utils.unwrapObservable(value['name']);\n componentParams = ko.utils.unwrapObservable(value['params']);\n }\n\n if (!componentName) {\n throw new Error('No component name specified');\n }\n\n var asyncContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);\n\n var loadingOperationId = currentLoadingOperationId = ++componentLoadingOperationUniqueId;\n ko.components.get(componentName, function(componentDefinition) {\n // If this is not the current load operation for this element, ignore it.\n if (currentLoadingOperationId !== loadingOperationId) {\n return;\n }\n\n // Clean up previous state\n disposeAssociatedComponentViewModel();\n\n // Instantiate and bind new component. Implicitly this cleans any old DOM nodes.\n if (!componentDefinition) {\n throw new Error('Unknown component \\'' + componentName + '\\'');\n }\n cloneTemplateIntoElement(componentName, componentDefinition, element);\n\n var componentInfo = {\n 'element': element,\n 'templateNodes': originalChildNodes\n };\n\n var componentViewModel = createViewModel(componentDefinition, componentParams, componentInfo),\n childBindingContext = asyncContext['createChildContext'](componentViewModel, {\n 'extend': function(ctx) {\n ctx['$component'] = componentViewModel;\n ctx['$componentTemplateNodes'] = originalChildNodes;\n }\n });\n\n if (componentViewModel && componentViewModel['koDescendantsComplete']) {\n afterRenderSub = ko.bindingEvent.subscribe(element, ko.bindingEvent.descendantsComplete, componentViewModel['koDescendantsComplete'], componentViewModel);\n }\n\n currentViewModel = componentViewModel;\n ko.applyBindingsToDescendants(childBindingContext, element);\n });\n }, null, { disposeWhenNodeIsRemoved: element });\n\n return { 'controlsDescendantBindings': true };\n }\n };\n\n ko.virtualElements.allowedBindings['component'] = true;\n\n function cloneTemplateIntoElement(componentName, componentDefinition, element) {\n var template = componentDefinition['template'];\n if (!template) {\n throw new Error('Component \\'' + componentName + '\\' has no template');\n }\n\n var clonedNodesArray = ko.utils.cloneNodes(template);\n ko.virtualElements.setDomNodeChildren(element, clonedNodesArray);\n }\n\n function createViewModel(componentDefinition, componentParams, componentInfo) {\n var componentViewModelFactory = componentDefinition['createViewModel'];\n return componentViewModelFactory\n ? componentViewModelFactory.call(componentDefinition, componentParams, componentInfo)\n : componentParams; // Template-only component\n }\n\n })();\n var attrHtmlToJavaScriptMap = { 'class': 'className', 'for': 'htmlFor' };\n ko.bindingHandlers['attr'] = {\n 'update': function(element, valueAccessor, allBindings) {\n var value = ko.utils.unwrapObservable(valueAccessor()) || {};\n ko.utils.objectForEach(value, function(attrName, attrValue) {\n attrValue = ko.utils.unwrapObservable(attrValue);\n\n // Find the namespace of this attribute, if any.\n var prefixLen = attrName.indexOf(':');\n var namespace = \"lookupNamespaceURI\" in element && prefixLen > 0 && element.lookupNamespaceURI(attrName.substr(0, prefixLen));\n\n // To cover cases like \"attr: { checked:someProp }\", we want to remove the attribute entirely\n // when someProp is a \"no value\"-like value (strictly null, false, or undefined)\n // (because the absence of the \"checked\" attr is how to mark an element as not checked, etc.)\n var toRemove = (attrValue === false) || (attrValue === null) || (attrValue === undefined);\n if (toRemove) {\n namespace ? element.removeAttributeNS(namespace, attrName) : element.removeAttribute(attrName);\n } else {\n attrValue = attrValue.toString();\n }\n\n // In IE <= 7 and IE8 Quirks Mode, you have to use the JavaScript property name instead of the\n // HTML attribute name for certain attributes. IE8 Standards Mode supports the correct behavior,\n // but instead of figuring out the mode, we'll just set the attribute through the JavaScript\n // property for IE <= 8.\n if (ko.utils.ieVersion <= 8 && attrName in attrHtmlToJavaScriptMap) {\n attrName = attrHtmlToJavaScriptMap[attrName];\n if (toRemove)\n element.removeAttribute(attrName);\n else\n element[attrName] = attrValue;\n } else if (!toRemove) {\n namespace ? element.setAttributeNS(namespace, attrName, attrValue) : element.setAttribute(attrName, attrValue);\n }\n\n // Treat \"name\" specially - although you can think of it as an attribute, it also needs\n // special handling on older versions of IE (https://github.com/SteveSanderson/knockout/pull/333)\n // Deliberately being case-sensitive here because XHTML would regard \"Name\" as a different thing\n // entirely, and there's no strong reason to allow for such casing in HTML.\n if (attrName === \"name\") {\n ko.utils.setElementName(element, toRemove ? \"\" : attrValue);\n }\n });\n }\n };\n (function() {\n\n ko.bindingHandlers['checked'] = {\n 'after': ['value', 'attr'],\n 'init': function (element, valueAccessor, allBindings) {\n var checkedValue = ko.pureComputed(function() {\n // Treat \"value\" like \"checkedValue\" when it is included with \"checked\" binding\n if (allBindings['has']('checkedValue')) {\n return ko.utils.unwrapObservable(allBindings.get('checkedValue'));\n } else if (useElementValue) {\n if (allBindings['has']('value')) {\n return ko.utils.unwrapObservable(allBindings.get('value'));\n } else {\n return element.value;\n }\n }\n });\n\n function updateModel() {\n // This updates the model value from the view value.\n // It runs in response to DOM events (click) and changes in checkedValue.\n var isChecked = element.checked,\n elemValue = checkedValue();\n\n // When we're first setting up this computed, don't change any model state.\n if (ko.computedContext.isInitial()) {\n return;\n }\n\n // We can ignore unchecked radio buttons, because some other radio\n // button will be checked, and that one can take care of updating state.\n // Also ignore value changes to an already unchecked checkbox.\n if (!isChecked && (isRadio || ko.computedContext.getDependenciesCount())) {\n return;\n }\n\n var modelValue = ko.dependencyDetection.ignore(valueAccessor);\n if (valueIsArray) {\n var writableValue = rawValueIsNonArrayObservable ? modelValue.peek() : modelValue,\n saveOldValue = oldElemValue;\n oldElemValue = elemValue;\n\n if (saveOldValue !== elemValue) {\n // When we're responding to the checkedValue changing, and the element is\n // currently checked, replace the old elem value with the new elem value\n // in the model array.\n if (isChecked) {\n ko.utils.addOrRemoveItem(writableValue, elemValue, true);\n ko.utils.addOrRemoveItem(writableValue, saveOldValue, false);\n }\n } else {\n // When we're responding to the user having checked/unchecked a checkbox,\n // add/remove the element value to the model array.\n ko.utils.addOrRemoveItem(writableValue, elemValue, isChecked);\n }\n\n if (rawValueIsNonArrayObservable && ko.isWriteableObservable(modelValue)) {\n modelValue(writableValue);\n }\n } else {\n if (isCheckbox) {\n if (elemValue === undefined) {\n elemValue = isChecked;\n } else if (!isChecked) {\n elemValue = undefined;\n }\n }\n ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'checked', elemValue, true);\n }\n };\n\n function updateView() {\n // This updates the view value from the model value.\n // It runs in response to changes in the bound (checked) value.\n var modelValue = ko.utils.unwrapObservable(valueAccessor()),\n elemValue = checkedValue();\n\n if (valueIsArray) {\n // When a checkbox is bound to an array, being checked represents its value being present in that array\n element.checked = ko.utils.arrayIndexOf(modelValue, elemValue) >= 0;\n oldElemValue = elemValue;\n } else if (isCheckbox && elemValue === undefined) {\n // When a checkbox is bound to any other value (not an array) and \"checkedValue\" is not defined,\n // being checked represents the value being trueish\n element.checked = !!modelValue;\n } else {\n // Otherwise, being checked means that the checkbox or radio button's value corresponds to the model value\n element.checked = (checkedValue() === modelValue);\n }\n };\n\n var isCheckbox = element.type == \"checkbox\",\n isRadio = element.type == \"radio\";\n\n // Only bind to check boxes and radio buttons\n if (!isCheckbox && !isRadio) {\n return;\n }\n\n var rawValue = valueAccessor(),\n valueIsArray = isCheckbox && (ko.utils.unwrapObservable(rawValue) instanceof Array),\n rawValueIsNonArrayObservable = !(valueIsArray && rawValue.push && rawValue.splice),\n useElementValue = isRadio || valueIsArray,\n oldElemValue = valueIsArray ? checkedValue() : undefined;\n\n // IE 6 won't allow radio buttons to be selected unless they have a name\n if (isRadio && !element.name)\n ko.bindingHandlers['uniqueName']['init'](element, function() { return true });\n\n // Set up two computeds to update the binding:\n\n // The first responds to changes in the checkedValue value and to element clicks\n ko.computed(updateModel, null, { disposeWhenNodeIsRemoved: element });\n ko.utils.registerEventHandler(element, \"click\", updateModel);\n\n // The second responds to changes in the model value (the one associated with the checked binding)\n ko.computed(updateView, null, { disposeWhenNodeIsRemoved: element });\n\n rawValue = undefined;\n }\n };\n ko.expressionRewriting.twoWayBindings['checked'] = true;\n\n ko.bindingHandlers['checkedValue'] = {\n 'update': function (element, valueAccessor) {\n element.value = ko.utils.unwrapObservable(valueAccessor());\n }\n };\n\n })();var classesWrittenByBindingKey = '__ko__cssValue';\n ko.bindingHandlers['class'] = {\n 'update': function (element, valueAccessor) {\n var value = ko.utils.stringTrim(ko.utils.unwrapObservable(valueAccessor()));\n ko.utils.toggleDomNodeCssClass(element, element[classesWrittenByBindingKey], false);\n element[classesWrittenByBindingKey] = value;\n ko.utils.toggleDomNodeCssClass(element, value, true);\n }\n };\n\n ko.bindingHandlers['css'] = {\n 'update': function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n if (value !== null && typeof value == \"object\") {\n ko.utils.objectForEach(value, function(className, shouldHaveClass) {\n shouldHaveClass = ko.utils.unwrapObservable(shouldHaveClass);\n ko.utils.toggleDomNodeCssClass(element, className, shouldHaveClass);\n });\n } else {\n ko.bindingHandlers['class']['update'](element, valueAccessor);\n }\n }\n };\n ko.bindingHandlers['enable'] = {\n 'update': function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n if (value && element.disabled)\n element.removeAttribute(\"disabled\");\n else if ((!value) && (!element.disabled))\n element.disabled = true;\n }\n };\n\n ko.bindingHandlers['disable'] = {\n 'update': function (element, valueAccessor) {\n ko.bindingHandlers['enable']['update'](element, function() { return !ko.utils.unwrapObservable(valueAccessor()) });\n }\n };\n// For certain common events (currently just 'click'), allow a simplified data-binding syntax\n// e.g. click:handler instead of the usual full-length event:{click:handler}\n function makeEventHandlerShortcut(eventName) {\n ko.bindingHandlers[eventName] = {\n 'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n var newValueAccessor = function () {\n var result = {};\n result[eventName] = valueAccessor();\n return result;\n };\n return ko.bindingHandlers['event']['init'].call(this, element, newValueAccessor, allBindings, viewModel, bindingContext);\n }\n }\n }\n\n ko.bindingHandlers['event'] = {\n 'init' : function (element, valueAccessor, allBindings, viewModel, bindingContext) {\n var eventsToHandle = valueAccessor() || {};\n ko.utils.objectForEach(eventsToHandle, function(eventName) {\n if (typeof eventName == \"string\") {\n ko.utils.registerEventHandler(element, eventName, function (event) {\n var handlerReturnValue;\n var handlerFunction = valueAccessor()[eventName];\n if (!handlerFunction)\n return;\n\n try {\n // Take all the event args, and prefix with the viewmodel\n var argsForHandler = ko.utils.makeArray(arguments);\n viewModel = bindingContext['$data'];\n argsForHandler.unshift(viewModel);\n handlerReturnValue = handlerFunction.apply(viewModel, argsForHandler);\n } finally {\n if (handlerReturnValue !== true) { // Normally we want to prevent default action. Developer can override this be explicitly returning true.\n if (event.preventDefault)\n event.preventDefault();\n else\n event.returnValue = false;\n }\n }\n\n var bubble = allBindings.get(eventName + 'Bubble') !== false;\n if (!bubble) {\n event.cancelBubble = true;\n if (event.stopPropagation)\n event.stopPropagation();\n }\n });\n }\n });\n }\n };\n// \"foreach: someExpression\" is equivalent to \"template: { foreach: someExpression }\"\n// \"foreach: { data: someExpression, afterAdd: myfn }\" is equivalent to \"template: { foreach: someExpression, afterAdd: myfn }\"\n ko.bindingHandlers['foreach'] = {\n makeTemplateValueAccessor: function(valueAccessor) {\n return function() {\n var modelValue = valueAccessor(),\n unwrappedValue = ko.utils.peekObservable(modelValue); // Unwrap without setting a dependency here\n\n // If unwrappedValue is the array, pass in the wrapped value on its own\n // The value will be unwrapped and tracked within the template binding\n // (See https://github.com/SteveSanderson/knockout/issues/523)\n if ((!unwrappedValue) || typeof unwrappedValue.length == \"number\")\n return { 'foreach': modelValue, 'templateEngine': ko.nativeTemplateEngine.instance };\n\n // If unwrappedValue.data is the array, preserve all relevant options and unwrap again value so we get updates\n ko.utils.unwrapObservable(modelValue);\n return {\n 'foreach': unwrappedValue['data'],\n 'as': unwrappedValue['as'],\n 'noChildContext': unwrappedValue['noChildContext'],\n 'includeDestroyed': unwrappedValue['includeDestroyed'],\n 'afterAdd': unwrappedValue['afterAdd'],\n 'beforeRemove': unwrappedValue['beforeRemove'],\n 'afterRender': unwrappedValue['afterRender'],\n 'beforeMove': unwrappedValue['beforeMove'],\n 'afterMove': unwrappedValue['afterMove'],\n 'templateEngine': ko.nativeTemplateEngine.instance\n };\n };\n },\n 'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n return ko.bindingHandlers['template']['init'](element, ko.bindingHandlers['foreach'].makeTemplateValueAccessor(valueAccessor));\n },\n 'update': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n return ko.bindingHandlers['template']['update'](element, ko.bindingHandlers['foreach'].makeTemplateValueAccessor(valueAccessor), allBindings, viewModel, bindingContext);\n }\n };\n ko.expressionRewriting.bindingRewriteValidators['foreach'] = false; // Can't rewrite control flow bindings\n ko.virtualElements.allowedBindings['foreach'] = true;\n var hasfocusUpdatingProperty = '__ko_hasfocusUpdating';\n var hasfocusLastValue = '__ko_hasfocusLastValue';\n ko.bindingHandlers['hasfocus'] = {\n 'init': function(element, valueAccessor, allBindings) {\n var handleElementFocusChange = function(isFocused) {\n // Where possible, ignore which event was raised and determine focus state using activeElement,\n // as this avoids phantom focus/blur events raised when changing tabs in modern browsers.\n // However, not all KO-targeted browsers (Firefox 2) support activeElement. For those browsers,\n // prevent a loss of focus when changing tabs/windows by setting a flag that prevents hasfocus\n // from calling 'blur()' on the element when it loses focus.\n // Discussion at https://github.com/SteveSanderson/knockout/pull/352\n element[hasfocusUpdatingProperty] = true;\n var ownerDoc = element.ownerDocument;\n if (\"activeElement\" in ownerDoc) {\n var active;\n try {\n active = ownerDoc.activeElement;\n } catch(e) {\n // IE9 throws if you access activeElement during page load (see issue #703)\n active = ownerDoc.body;\n }\n isFocused = (active === element);\n }\n var modelValue = valueAccessor();\n ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'hasfocus', isFocused, true);\n\n //cache the latest value, so we can avoid unnecessarily calling focus/blur in the update function\n element[hasfocusLastValue] = isFocused;\n element[hasfocusUpdatingProperty] = false;\n };\n var handleElementFocusIn = handleElementFocusChange.bind(null, true);\n var handleElementFocusOut = handleElementFocusChange.bind(null, false);\n\n ko.utils.registerEventHandler(element, \"focus\", handleElementFocusIn);\n ko.utils.registerEventHandler(element, \"focusin\", handleElementFocusIn); // For IE\n ko.utils.registerEventHandler(element, \"blur\", handleElementFocusOut);\n ko.utils.registerEventHandler(element, \"focusout\", handleElementFocusOut); // For IE\n\n // Assume element is not focused (prevents \"blur\" being called initially)\n element[hasfocusLastValue] = false;\n },\n 'update': function(element, valueAccessor) {\n var value = !!ko.utils.unwrapObservable(valueAccessor());\n\n if (!element[hasfocusUpdatingProperty] && element[hasfocusLastValue] !== value) {\n value ? element.focus() : element.blur();\n\n // In IE, the blur method doesn't always cause the element to lose focus (for example, if the window is not in focus).\n // Setting focus to the body element does seem to be reliable in IE, but should only be used if we know that the current\n // element was focused already.\n if (!value && element[hasfocusLastValue]) {\n element.ownerDocument.body.focus();\n }\n\n // For IE, which doesn't reliably fire \"focus\" or \"blur\" events synchronously\n ko.dependencyDetection.ignore(ko.utils.triggerEvent, null, [element, value ? \"focusin\" : \"focusout\"]);\n }\n }\n };\n ko.expressionRewriting.twoWayBindings['hasfocus'] = true;\n\n ko.bindingHandlers['hasFocus'] = ko.bindingHandlers['hasfocus']; // Make \"hasFocus\" an alias\n ko.expressionRewriting.twoWayBindings['hasFocus'] = 'hasfocus';\n ko.bindingHandlers['html'] = {\n 'init': function() {\n // Prevent binding on the dynamically-injected HTML (as developers are unlikely to expect that, and it has security implications)\n return { 'controlsDescendantBindings': true };\n },\n 'update': function (element, valueAccessor) {\n // setHtml will unwrap the value if needed\n ko.utils.setHtml(element, valueAccessor());\n }\n };\n (function () {\n\n// Makes a binding like with or if\n function makeWithIfBinding(bindingKey, isWith, isNot) {\n ko.bindingHandlers[bindingKey] = {\n 'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n var didDisplayOnLastUpdate, savedNodes, contextOptions = {}, completeOnRender, needAsyncContext, renderOnEveryChange;\n\n if (isWith) {\n var as = allBindings.get('as'), noChildContext = allBindings.get('noChildContext');\n renderOnEveryChange = !(as && noChildContext);\n contextOptions = { 'as': as, 'noChildContext': noChildContext, 'exportDependencies': renderOnEveryChange };\n }\n\n completeOnRender = allBindings.get(\"completeOn\") == \"render\";\n needAsyncContext = completeOnRender || allBindings['has'](ko.bindingEvent.descendantsComplete);\n\n ko.computed(function() {\n var value = ko.utils.unwrapObservable(valueAccessor()),\n shouldDisplay = !isNot !== !value, // equivalent to isNot ? !value : !!value,\n isInitial = !savedNodes,\n childContext;\n\n if (!renderOnEveryChange && shouldDisplay === didDisplayOnLastUpdate) {\n return;\n }\n\n if (needAsyncContext) {\n bindingContext = ko.bindingEvent.startPossiblyAsyncContentBinding(element, bindingContext);\n }\n\n if (shouldDisplay) {\n if (!isWith || renderOnEveryChange) {\n contextOptions['dataDependency'] = ko.computedContext.computed();\n }\n\n if (isWith) {\n childContext = bindingContext['createChildContext'](typeof value == \"function\" ? value : valueAccessor, contextOptions);\n } else if (ko.computedContext.getDependenciesCount()) {\n childContext = bindingContext['extend'](null, contextOptions);\n } else {\n childContext = bindingContext;\n }\n }\n\n // Save a copy of the inner nodes on the initial update, but only if we have dependencies.\n if (isInitial && ko.computedContext.getDependenciesCount()) {\n savedNodes = ko.utils.cloneNodes(ko.virtualElements.childNodes(element), true /* shouldCleanNodes */);\n }\n\n if (shouldDisplay) {\n if (!isInitial) {\n ko.virtualElements.setDomNodeChildren(element, ko.utils.cloneNodes(savedNodes));\n }\n\n ko.applyBindingsToDescendants(childContext, element);\n } else {\n ko.virtualElements.emptyNode(element);\n\n if (!completeOnRender) {\n ko.bindingEvent.notify(element, ko.bindingEvent.childrenComplete);\n }\n }\n\n didDisplayOnLastUpdate = shouldDisplay;\n\n }, null, { disposeWhenNodeIsRemoved: element });\n\n return { 'controlsDescendantBindings': true };\n }\n };\n ko.expressionRewriting.bindingRewriteValidators[bindingKey] = false; // Can't rewrite control flow bindings\n ko.virtualElements.allowedBindings[bindingKey] = true;\n }\n\n// Construct the actual binding handlers\n makeWithIfBinding('if');\n makeWithIfBinding('ifnot', false /* isWith */, true /* isNot */);\n makeWithIfBinding('with', true /* isWith */);\n\n })();ko.bindingHandlers['let'] = {\n 'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n // Make a modified binding context, with extra properties, and apply it to descendant elements\n var innerContext = bindingContext['extend'](valueAccessor);\n ko.applyBindingsToDescendants(innerContext, element);\n\n return { 'controlsDescendantBindings': true };\n }\n };\n ko.virtualElements.allowedBindings['let'] = true;\n var captionPlaceholder = {};\n ko.bindingHandlers['options'] = {\n 'init': function(element) {\n if (ko.utils.tagNameLower(element) !== \"select\")\n throw new Error(\"options binding applies only to SELECT elements\");\n\n // Remove all existing <option>s.\n while (element.length > 0) {\n element.remove(0);\n }\n\n // Ensures that the binding processor doesn't try to bind the options\n return { 'controlsDescendantBindings': true };\n },\n 'update': function (element, valueAccessor, allBindings) {\n function selectedOptions() {\n return ko.utils.arrayFilter(element.options, function (node) { return node.selected; });\n }\n\n var selectWasPreviouslyEmpty = element.length == 0,\n multiple = element.multiple,\n previousScrollTop = (!selectWasPreviouslyEmpty && multiple) ? element.scrollTop : null,\n unwrappedArray = ko.utils.unwrapObservable(valueAccessor()),\n valueAllowUnset = allBindings.get('valueAllowUnset') && allBindings['has']('value'),\n includeDestroyed = allBindings.get('optionsIncludeDestroyed'),\n arrayToDomNodeChildrenOptions = {},\n captionValue,\n filteredArray,\n previousSelectedValues = [];\n\n if (!valueAllowUnset) {\n if (multiple) {\n previousSelectedValues = ko.utils.arrayMap(selectedOptions(), ko.selectExtensions.readValue);\n } else if (element.selectedIndex >= 0) {\n previousSelectedValues.push(ko.selectExtensions.readValue(element.options[element.selectedIndex]));\n }\n }\n\n if (unwrappedArray) {\n if (typeof unwrappedArray.length == \"undefined\") // Coerce single value into array\n unwrappedArray = [unwrappedArray];\n\n // Filter out any entries marked as destroyed\n filteredArray = ko.utils.arrayFilter(unwrappedArray, function(item) {\n return includeDestroyed || item === undefined || item === null || !ko.utils.unwrapObservable(item['_destroy']);\n });\n\n // If caption is included, add it to the array\n if (allBindings['has']('optionsCaption')) {\n captionValue = ko.utils.unwrapObservable(allBindings.get('optionsCaption'));\n // If caption value is null or undefined, don't show a caption\n if (captionValue !== null && captionValue !== undefined) {\n filteredArray.unshift(captionPlaceholder);\n }\n }\n } else {\n // If a falsy value is provided (e.g. null), we'll simply empty the select element\n }\n\n function applyToObject(object, predicate, defaultValue) {\n var predicateType = typeof predicate;\n if (predicateType == \"function\") // Given a function; run it against the data value\n return predicate(object);\n else if (predicateType == \"string\") // Given a string; treat it as a property name on the data value\n return object[predicate];\n else // Given no optionsText arg; use the data value itself\n return defaultValue;\n }\n\n // The following functions can run at two different times:\n // The first is when the whole array is being updated directly from this binding handler.\n // The second is when an observable value for a specific array entry is updated.\n // oldOptions will be empty in the first case, but will be filled with the previously generated option in the second.\n var itemUpdate = false;\n function optionForArrayItem(arrayEntry, index, oldOptions) {\n if (oldOptions.length) {\n previousSelectedValues = !valueAllowUnset && oldOptions[0].selected ? [ ko.selectExtensions.readValue(oldOptions[0]) ] : [];\n itemUpdate = true;\n }\n var option = element.ownerDocument.createElement(\"option\");\n if (arrayEntry === captionPlaceholder) {\n ko.utils.setTextContent(option, allBindings.get('optionsCaption'));\n ko.selectExtensions.writeValue(option, undefined);\n } else {\n // Apply a value to the option element\n var optionValue = applyToObject(arrayEntry, allBindings.get('optionsValue'), arrayEntry);\n ko.selectExtensions.writeValue(option, ko.utils.unwrapObservable(optionValue));\n\n // Apply some text to the option element\n var optionText = applyToObject(arrayEntry, allBindings.get('optionsText'), optionValue);\n ko.utils.setTextContent(option, optionText);\n }\n return [option];\n }\n\n // By using a beforeRemove callback, we delay the removal until after new items are added. This fixes a selection\n // problem in IE<=8 and Firefox. See https://github.com/knockout/knockout/issues/1208\n arrayToDomNodeChildrenOptions['beforeRemove'] =\n function (option) {\n element.removeChild(option);\n };\n\n function setSelectionCallback(arrayEntry, newOptions) {\n if (itemUpdate && valueAllowUnset) {\n // The model value is authoritative, so make sure its value is the one selected\n ko.bindingEvent.notify(element, ko.bindingEvent.childrenComplete);\n } else if (previousSelectedValues.length) {\n // IE6 doesn't like us to assign selection to OPTION nodes before they're added to the document.\n // That's why we first added them without selection. Now it's time to set the selection.\n var isSelected = ko.utils.arrayIndexOf(previousSelectedValues, ko.selectExtensions.readValue(newOptions[0])) >= 0;\n ko.utils.setOptionNodeSelectionState(newOptions[0], isSelected);\n\n // If this option was changed from being selected during a single-item update, notify the change\n if (itemUpdate && !isSelected) {\n ko.dependencyDetection.ignore(ko.utils.triggerEvent, null, [element, \"change\"]);\n }\n }\n }\n\n var callback = setSelectionCallback;\n if (allBindings['has']('optionsAfterRender') && typeof allBindings.get('optionsAfterRender') == \"function\") {\n callback = function(arrayEntry, newOptions) {\n setSelectionCallback(arrayEntry, newOptions);\n ko.dependencyDetection.ignore(allBindings.get('optionsAfterRender'), null, [newOptions[0], arrayEntry !== captionPlaceholder ? arrayEntry : undefined]);\n }\n }\n\n ko.utils.setDomNodeChildrenFromArrayMapping(element, filteredArray, optionForArrayItem, arrayToDomNodeChildrenOptions, callback);\n\n if (!valueAllowUnset) {\n // Determine if the selection has changed as a result of updating the options list\n var selectionChanged;\n if (multiple) {\n // For a multiple-select box, compare the new selection count to the previous one\n // But if nothing was selected before, the selection can't have changed\n selectionChanged = previousSelectedValues.length && selectedOptions().length < previousSelectedValues.length;\n } else {\n // For a single-select box, compare the current value to the previous value\n // But if nothing was selected before or nothing is selected now, just look for a change in selection\n selectionChanged = (previousSelectedValues.length && element.selectedIndex >= 0)\n ? (ko.selectExtensions.readValue(element.options[element.selectedIndex]) !== previousSelectedValues[0])\n : (previousSelectedValues.length || element.selectedIndex >= 0);\n }\n\n // Ensure consistency between model value and selected option.\n // If the dropdown was changed so that selection is no longer the same,\n // notify the value or selectedOptions binding.\n if (selectionChanged) {\n ko.dependencyDetection.ignore(ko.utils.triggerEvent, null, [element, \"change\"]);\n }\n }\n\n if (valueAllowUnset || ko.computedContext.isInitial()) {\n ko.bindingEvent.notify(element, ko.bindingEvent.childrenComplete);\n }\n\n // Workaround for IE bug\n ko.utils.ensureSelectElementIsRenderedCorrectly(element);\n\n if (previousScrollTop && Math.abs(previousScrollTop - element.scrollTop) > 20)\n element.scrollTop = previousScrollTop;\n }\n };\n ko.bindingHandlers['options'].optionValueDomDataKey = ko.utils.domData.nextKey();\n ko.bindingHandlers['selectedOptions'] = {\n 'init': function (element, valueAccessor, allBindings) {\n function updateFromView() {\n var value = valueAccessor(), valueToWrite = [];\n ko.utils.arrayForEach(element.getElementsByTagName(\"option\"), function(node) {\n if (node.selected)\n valueToWrite.push(ko.selectExtensions.readValue(node));\n });\n ko.expressionRewriting.writeValueToProperty(value, allBindings, 'selectedOptions', valueToWrite);\n }\n\n function updateFromModel() {\n var newValue = ko.utils.unwrapObservable(valueAccessor()),\n previousScrollTop = element.scrollTop;\n\n if (newValue && typeof newValue.length == \"number\") {\n ko.utils.arrayForEach(element.getElementsByTagName(\"option\"), function(node) {\n var isSelected = ko.utils.arrayIndexOf(newValue, ko.selectExtensions.readValue(node)) >= 0;\n if (node.selected != isSelected) { // This check prevents flashing of the select element in IE\n ko.utils.setOptionNodeSelectionState(node, isSelected);\n }\n });\n }\n\n element.scrollTop = previousScrollTop;\n }\n\n if (ko.utils.tagNameLower(element) != \"select\") {\n throw new Error(\"selectedOptions binding applies only to SELECT elements\");\n }\n\n var updateFromModelComputed;\n ko.bindingEvent.subscribe(element, ko.bindingEvent.childrenComplete, function () {\n if (!updateFromModelComputed) {\n ko.utils.registerEventHandler(element, \"change\", updateFromView);\n updateFromModelComputed = ko.computed(updateFromModel, null, { disposeWhenNodeIsRemoved: element });\n } else {\n updateFromView();\n }\n }, null, { 'notifyImmediately': true });\n },\n 'update': function() {} // Keep for backwards compatibility with code that may have wrapped binding\n };\n ko.expressionRewriting.twoWayBindings['selectedOptions'] = true;\n ko.bindingHandlers['style'] = {\n 'update': function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor() || {});\n ko.utils.objectForEach(value, function(styleName, styleValue) {\n styleValue = ko.utils.unwrapObservable(styleValue);\n\n if (styleValue === null || styleValue === undefined || styleValue === false) {\n // Empty string removes the value, whereas null/undefined have no effect\n styleValue = \"\";\n }\n\n if (jQueryInstance) {\n jQueryInstance(element)['css'](styleName, styleValue);\n } else if (/^--/.test(styleName)) {\n // Is styleName a custom CSS property?\n element.style.setProperty(styleName, styleValue);\n } else {\n styleName = styleName.replace(/-(\\w)/g, function (all, letter) {\n return letter.toUpperCase();\n });\n\n var previousStyle = element.style[styleName];\n element.style[styleName] = styleValue;\n\n if (styleValue !== previousStyle && element.style[styleName] == previousStyle && !isNaN(styleValue)) {\n element.style[styleName] = styleValue + \"px\";\n }\n }\n });\n }\n };\n ko.bindingHandlers['submit'] = {\n 'init': function (element, valueAccessor, allBindings, viewModel, bindingContext) {\n if (typeof valueAccessor() != \"function\")\n throw new Error(\"The value for a submit binding must be a function\");\n ko.utils.registerEventHandler(element, \"submit\", function (event) {\n var handlerReturnValue;\n var value = valueAccessor();\n try { handlerReturnValue = value.call(bindingContext['$data'], element); }\n finally {\n if (handlerReturnValue !== true) { // Normally we want to prevent default action. Developer can override this be explicitly returning true.\n if (event.preventDefault)\n event.preventDefault();\n else\n event.returnValue = false;\n }\n }\n });\n }\n };\n ko.bindingHandlers['text'] = {\n 'init': function() {\n // Prevent binding on the dynamically-injected text node (as developers are unlikely to expect that, and it has security implications).\n // It should also make things faster, as we no longer have to consider whether the text node might be bindable.\n return { 'controlsDescendantBindings': true };\n },\n 'update': function (element, valueAccessor) {\n ko.utils.setTextContent(element, valueAccessor());\n }\n };\n ko.virtualElements.allowedBindings['text'] = true;\n (function () {\n\n if (window && window.navigator) {\n var parseVersion = function (matches) {\n if (matches) {\n return parseFloat(matches[1]);\n }\n };\n\n // Detect various browser versions because some old versions don't fully support the 'input' event\n var userAgent = window.navigator.userAgent,\n operaVersion, chromeVersion, safariVersion, firefoxVersion, ieVersion, edgeVersion;\n\n (operaVersion = window.opera && window.opera.version && parseInt(window.opera.version()))\n || (edgeVersion = parseVersion(userAgent.match(/Edge\\/([^ ]+)$/)))\n || (chromeVersion = parseVersion(userAgent.match(/Chrome\\/([^ ]+)/)))\n || (safariVersion = parseVersion(userAgent.match(/Version\\/([^ ]+) Safari/)))\n || (firefoxVersion = parseVersion(userAgent.match(/Firefox\\/([^ ]+)/)))\n || (ieVersion = ko.utils.ieVersion || parseVersion(userAgent.match(/MSIE ([^ ]+)/))) // Detects up to IE 10\n || (ieVersion = parseVersion(userAgent.match(/rv:([^ )]+)/))); // Detects IE 11\n }\n\n// IE 8 and 9 have bugs that prevent the normal events from firing when the value changes.\n// But it does fire the 'selectionchange' event on many of those, presumably because the\n// cursor is moving and that counts as the selection changing. The 'selectionchange' event is\n// fired at the document level only and doesn't directly indicate which element changed. We\n// set up just one event handler for the document and use 'activeElement' to determine which\n// element was changed.\n if (ieVersion >= 8 && ieVersion < 10) {\n var selectionChangeRegisteredName = ko.utils.domData.nextKey(),\n selectionChangeHandlerName = ko.utils.domData.nextKey();\n var selectionChangeHandler = function(event) {\n var target = this.activeElement,\n handler = target && ko.utils.domData.get(target, selectionChangeHandlerName);\n if (handler) {\n handler(event);\n }\n };\n var registerForSelectionChangeEvent = function (element, handler) {\n var ownerDoc = element.ownerDocument;\n if (!ko.utils.domData.get(ownerDoc, selectionChangeRegisteredName)) {\n ko.utils.domData.set(ownerDoc, selectionChangeRegisteredName, true);\n ko.utils.registerEventHandler(ownerDoc, 'selectionchange', selectionChangeHandler);\n }\n ko.utils.domData.set(element, selectionChangeHandlerName, handler);\n };\n }\n\n ko.bindingHandlers['textInput'] = {\n 'init': function (element, valueAccessor, allBindings) {\n\n var previousElementValue = element.value,\n timeoutHandle,\n elementValueBeforeEvent;\n\n var updateModel = function (event) {\n clearTimeout(timeoutHandle);\n elementValueBeforeEvent = timeoutHandle = undefined;\n\n var elementValue = element.value;\n if (previousElementValue !== elementValue) {\n // Provide a way for tests to know exactly which event was processed\n if (DEBUG && event) element['_ko_textInputProcessedEvent'] = event.type;\n previousElementValue = elementValue;\n ko.expressionRewriting.writeValueToProperty(valueAccessor(), allBindings, 'textInput', elementValue);\n }\n };\n\n var deferUpdateModel = function (event) {\n if (!timeoutHandle) {\n // The elementValueBeforeEvent variable is set *only* during the brief gap between an\n // event firing and the updateModel function running. This allows us to ignore model\n // updates that are from the previous state of the element, usually due to techniques\n // such as rateLimit. Such updates, if not ignored, can cause keystrokes to be lost.\n elementValueBeforeEvent = element.value;\n var handler = DEBUG ? updateModel.bind(element, {type: event.type}) : updateModel;\n timeoutHandle = ko.utils.setTimeout(handler, 4);\n }\n };\n\n // IE9 will mess up the DOM if you handle events synchronously which results in DOM changes (such as other bindings);\n // so we'll make sure all updates are asynchronous\n var ieUpdateModel = ko.utils.ieVersion == 9 ? deferUpdateModel : updateModel,\n ourUpdate = false;\n\n var updateView = function () {\n var modelValue = ko.utils.unwrapObservable(valueAccessor());\n\n if (modelValue === null || modelValue === undefined) {\n modelValue = '';\n }\n\n if (elementValueBeforeEvent !== undefined && modelValue === elementValueBeforeEvent) {\n ko.utils.setTimeout(updateView, 4);\n return;\n }\n\n // Update the element only if the element and model are different. On some browsers, updating the value\n // will move the cursor to the end of the input, which would be bad while the user is typing.\n if (element.value !== modelValue) {\n ourUpdate = true; // Make sure we ignore events (propertychange) that result from updating the value\n element.value = modelValue;\n ourUpdate = false;\n previousElementValue = element.value; // In case the browser changes the value (see #2281)\n }\n };\n\n var onEvent = function (event, handler) {\n ko.utils.registerEventHandler(element, event, handler);\n };\n\n if (DEBUG && ko.bindingHandlers['textInput']['_forceUpdateOn']) {\n // Provide a way for tests to specify exactly which events are bound\n ko.utils.arrayForEach(ko.bindingHandlers['textInput']['_forceUpdateOn'], function(eventName) {\n if (eventName.slice(0,5) == 'after') {\n onEvent(eventName.slice(5), deferUpdateModel);\n } else {\n onEvent(eventName, updateModel);\n }\n });\n } else {\n if (ieVersion) {\n // All versions (including 11) of Internet Explorer have a bug that they don't generate an input or propertychange event when ESC is pressed\n onEvent('keypress', updateModel);\n }\n if (ieVersion < 11) {\n // Internet Explorer <= 8 doesn't support the 'input' event, but does include 'propertychange' that fires whenever\n // any property of an element changes. Unlike 'input', it also fires if a property is changed from JavaScript code,\n // but that's an acceptable compromise for this binding. IE 9 and 10 support 'input', but since they don't always\n // fire it when using autocomplete, we'll use 'propertychange' for them also.\n onEvent('propertychange', function(event) {\n if (!ourUpdate && event.propertyName === 'value') {\n ieUpdateModel(event);\n }\n });\n }\n if (ieVersion == 8) {\n // IE 8 has a bug where it fails to fire 'propertychange' on the first update following a value change from\n // JavaScript code. It also doesn't fire if you clear the entire value. To fix this, we bind to the following\n // events too.\n onEvent('keyup', updateModel); // A single keystoke\n onEvent('keydown', updateModel); // The first character when a key is held down\n }\n if (registerForSelectionChangeEvent) {\n // Internet Explorer 9 doesn't fire the 'input' event when deleting text, including using\n // the backspace, delete, or ctrl-x keys, clicking the 'x' to clear the input, dragging text\n // out of the field, and cutting or deleting text using the context menu. 'selectionchange'\n // can detect all of those except dragging text out of the field, for which we use 'dragend'.\n // These are also needed in IE8 because of the bug described above.\n registerForSelectionChangeEvent(element, ieUpdateModel); // 'selectionchange' covers cut, paste, drop, delete, etc.\n onEvent('dragend', deferUpdateModel);\n }\n\n if (!ieVersion || ieVersion >= 9) {\n // All other supported browsers support the 'input' event, which fires whenever the content of the element is changed\n // through the user interface.\n onEvent('input', ieUpdateModel);\n }\n\n if (safariVersion < 5 && ko.utils.tagNameLower(element) === \"textarea\") {\n // Safari <5 doesn't fire the 'input' event for <textarea> elements (it does fire 'textInput'\n // but only when typing). So we'll just catch as much as we can with keydown, cut, and paste.\n onEvent('keydown', deferUpdateModel);\n onEvent('paste', deferUpdateModel);\n onEvent('cut', deferUpdateModel);\n } else if (operaVersion < 11) {\n // Opera 10 doesn't always fire the 'input' event for cut, paste, undo & drop operations.\n // We can try to catch some of those using 'keydown'.\n onEvent('keydown', deferUpdateModel);\n } else if (firefoxVersion < 4.0) {\n // Firefox <= 3.6 doesn't fire the 'input' event when text is filled in through autocomplete\n onEvent('DOMAutoComplete', updateModel);\n\n // Firefox <=3.5 doesn't fire the 'input' event when text is dropped into the input.\n onEvent('dragdrop', updateModel); // <3.5\n onEvent('drop', updateModel); // 3.5\n } else if (edgeVersion && element.type === \"number\") {\n // Microsoft Edge doesn't fire 'input' or 'change' events for number inputs when\n // the value is changed via the up / down arrow keys\n onEvent('keydown', deferUpdateModel);\n }\n }\n\n // Bind to the change event so that we can catch programmatic updates of the value that fire this event.\n onEvent('change', updateModel);\n\n // To deal with browsers that don't notify any kind of event for some changes (IE, Safari, etc.)\n onEvent('blur', updateModel);\n\n ko.computed(updateView, null, { disposeWhenNodeIsRemoved: element });\n }\n };\n ko.expressionRewriting.twoWayBindings['textInput'] = true;\n\n// textinput is an alias for textInput\n ko.bindingHandlers['textinput'] = {\n // preprocess is the only way to set up a full alias\n 'preprocess': function (value, name, addBinding) {\n addBinding('textInput', value);\n }\n };\n\n })();ko.bindingHandlers['uniqueName'] = {\n 'init': function (element, valueAccessor) {\n if (valueAccessor()) {\n var name = \"ko_unique_\" + (++ko.bindingHandlers['uniqueName'].currentIndex);\n ko.utils.setElementName(element, name);\n }\n }\n };\n ko.bindingHandlers['uniqueName'].currentIndex = 0;\n ko.bindingHandlers['using'] = {\n 'init': function(element, valueAccessor, allBindings, viewModel, bindingContext) {\n var options;\n\n if (allBindings['has']('as')) {\n options = { 'as': allBindings.get('as'), 'noChildContext': allBindings.get('noChildContext') };\n }\n\n var innerContext = bindingContext['createChildContext'](valueAccessor, options);\n ko.applyBindingsToDescendants(innerContext, element);\n\n return { 'controlsDescendantBindings': true };\n }\n };\n ko.virtualElements.allowedBindings['using'] = true;\n ko.bindingHandlers['value'] = {\n 'init': function (element, valueAccessor, allBindings) {\n var tagName = ko.utils.tagNameLower(element),\n isInputElement = tagName == \"input\";\n\n // If the value binding is placed on a radio/checkbox, then just pass through to checkedValue and quit\n if (isInputElement && (element.type == \"checkbox\" || element.type == \"radio\")) {\n ko.applyBindingAccessorsToNode(element, { 'checkedValue': valueAccessor });\n return;\n }\n\n var eventsToCatch = [];\n var requestedEventsToCatch = allBindings.get(\"valueUpdate\");\n var propertyChangedFired = false;\n var elementValueBeforeEvent = null;\n\n if (requestedEventsToCatch) {\n // Allow both individual event names, and arrays of event names\n if (typeof requestedEventsToCatch == \"string\") {\n eventsToCatch = [requestedEventsToCatch];\n } else {\n eventsToCatch = ko.utils.arrayGetDistinctValues(requestedEventsToCatch);\n }\n ko.utils.arrayRemoveItem(eventsToCatch, \"change\"); // We'll subscribe to \"change\" events later\n }\n\n var valueUpdateHandler = function() {\n elementValueBeforeEvent = null;\n propertyChangedFired = false;\n var modelValue = valueAccessor();\n var elementValue = ko.selectExtensions.readValue(element);\n ko.expressionRewriting.writeValueToProperty(modelValue, allBindings, 'value', elementValue);\n }\n\n // Workaround for https://github.com/SteveSanderson/knockout/issues/122\n // IE doesn't fire \"change\" events on textboxes if the user selects a value from its autocomplete list\n var ieAutoCompleteHackNeeded = ko.utils.ieVersion && isInputElement && element.type == \"text\"\n && element.autocomplete != \"off\" && (!element.form || element.form.autocomplete != \"off\");\n if (ieAutoCompleteHackNeeded && ko.utils.arrayIndexOf(eventsToCatch, \"propertychange\") == -1) {\n ko.utils.registerEventHandler(element, \"propertychange\", function () { propertyChangedFired = true });\n ko.utils.registerEventHandler(element, \"focus\", function () { propertyChangedFired = false });\n ko.utils.registerEventHandler(element, \"blur\", function() {\n if (propertyChangedFired) {\n valueUpdateHandler();\n }\n });\n }\n\n ko.utils.arrayForEach(eventsToCatch, function(eventName) {\n // The syntax \"after<eventname>\" means \"run the handler asynchronously after the event\"\n // This is useful, for example, to catch \"keydown\" events after the browser has updated the control\n // (otherwise, ko.selectExtensions.readValue(this) will receive the control's value *before* the key event)\n var handler = valueUpdateHandler;\n if (ko.utils.stringStartsWith(eventName, \"after\")) {\n handler = function() {\n // The elementValueBeforeEvent variable is non-null *only* during the brief gap between\n // a keyX event firing and the valueUpdateHandler running, which is scheduled to happen\n // at the earliest asynchronous opportunity. We store this temporary information so that\n // if, between keyX and valueUpdateHandler, the underlying model value changes separately,\n // we can overwrite that model value change with the value the user just typed. Otherwise,\n // techniques like rateLimit can trigger model changes at critical moments that will\n // override the user's inputs, causing keystrokes to be lost.\n elementValueBeforeEvent = ko.selectExtensions.readValue(element);\n ko.utils.setTimeout(valueUpdateHandler, 0);\n };\n eventName = eventName.substring(\"after\".length);\n }\n ko.utils.registerEventHandler(element, eventName, handler);\n });\n\n var updateFromModel;\n\n if (isInputElement && element.type == \"file\") {\n // For file input elements, can only write the empty string\n updateFromModel = function () {\n var newValue = ko.utils.unwrapObservable(valueAccessor());\n if (newValue === null || newValue === undefined || newValue === \"\") {\n element.value = \"\";\n } else {\n ko.dependencyDetection.ignore(valueUpdateHandler); // reset the model to match the element\n }\n }\n } else {\n updateFromModel = function () {\n var newValue = ko.utils.unwrapObservable(valueAccessor());\n var elementValue = ko.selectExtensions.readValue(element);\n\n if (elementValueBeforeEvent !== null && newValue === elementValueBeforeEvent) {\n ko.utils.setTimeout(updateFromModel, 0);\n return;\n }\n\n var valueHasChanged = newValue !== elementValue;\n\n if (valueHasChanged || elementValue === undefined) {\n if (tagName === \"select\") {\n var allowUnset = allBindings.get('valueAllowUnset');\n ko.selectExtensions.writeValue(element, newValue, allowUnset);\n if (!allowUnset && newValue !== ko.selectExtensions.readValue(element)) {\n // If you try to set a model value that can't be represented in an already-populated dropdown, reject that change,\n // because you're not allowed to have a model value that disagrees with a visible UI selection.\n ko.dependencyDetection.ignore(valueUpdateHandler);\n }\n } else {\n ko.selectExtensions.writeValue(element, newValue);\n }\n }\n };\n }\n\n if (tagName === \"select\") {\n var updateFromModelComputed;\n ko.bindingEvent.subscribe(element, ko.bindingEvent.childrenComplete, function () {\n if (!updateFromModelComputed) {\n ko.utils.registerEventHandler(element, \"change\", valueUpdateHandler);\n updateFromModelComputed = ko.computed(updateFromModel, null, { disposeWhenNodeIsRemoved: element });\n } else if (allBindings.get('valueAllowUnset')) {\n updateFromModel();\n } else {\n valueUpdateHandler();\n }\n }, null, { 'notifyImmediately': true });\n } else {\n ko.utils.registerEventHandler(element, \"change\", valueUpdateHandler);\n ko.computed(updateFromModel, null, { disposeWhenNodeIsRemoved: element });\n }\n },\n 'update': function() {} // Keep for backwards compatibility with code that may have wrapped value binding\n };\n ko.expressionRewriting.twoWayBindings['value'] = true;\n ko.bindingHandlers['visible'] = {\n 'update': function (element, valueAccessor) {\n var value = ko.utils.unwrapObservable(valueAccessor());\n var isCurrentlyVisible = !(element.style.display == \"none\");\n if (value && !isCurrentlyVisible)\n element.style.display = \"\";\n else if ((!value) && isCurrentlyVisible)\n element.style.display = \"none\";\n }\n };\n\n ko.bindingHandlers['hidden'] = {\n 'update': function (element, valueAccessor) {\n ko.bindingHandlers['visible']['update'](element, function() { return !ko.utils.unwrapObservable(valueAccessor()) });\n }\n };\n// 'click' is just a shorthand for the usual full-length event:{click:handler}\n makeEventHandlerShortcut('click');\n// If you want to make a custom template engine,\n//\n// [1] Inherit from this class (like ko.nativeTemplateEngine does)\n// [2] Override 'renderTemplateSource', supplying a function with this signature:\n//\n// function (templateSource, bindingContext, options) {\n// // - templateSource.text() is the text of the template you should render\n// // - bindingContext.$data is the data you should pass into the template\n// // - you might also want to make bindingContext.$parent, bindingContext.$parents,\n// // and bindingContext.$root available in the template too\n// // - options gives you access to any other properties set on \"data-bind: { template: options }\"\n// // - templateDocument is the document object of the template\n// //\n// // Return value: an array of DOM nodes\n// }\n//\n// [3] Override 'createJavaScriptEvaluatorBlock', supplying a function with this signature:\n//\n// function (script) {\n// // Return value: Whatever syntax means \"Evaluate the JavaScript statement 'script' and output the result\"\n// // For example, the jquery.tmpl template engine converts 'someScript' to '${ someScript }'\n// }\n//\n// This is only necessary if you want to allow data-bind attributes to reference arbitrary template variables.\n// If you don't want to allow that, you can set the property 'allowTemplateRewriting' to false (like ko.nativeTemplateEngine does)\n// and then you don't need to override 'createJavaScriptEvaluatorBlock'.\n\n ko.templateEngine = function () { };\n\n ko.templateEngine.prototype['renderTemplateSource'] = function (templateSource, bindingContext, options, templateDocument) {\n throw new Error(\"Override renderTemplateSource\");\n };\n\n ko.templateEngine.prototype['createJavaScriptEvaluatorBlock'] = function (script) {\n throw new Error(\"Override createJavaScriptEvaluatorBlock\");\n };\n\n ko.templateEngine.prototype['makeTemplateSource'] = function(template, templateDocument) {\n // Named template\n if (typeof template == \"string\") {\n templateDocument = templateDocument || document;\n var elem = templateDocument.getElementById(template);\n if (!elem)\n throw new Error(\"Cannot find template with ID \" + template);\n return new ko.templateSources.domElement(elem);\n } else if ((template.nodeType == 1) || (template.nodeType == 8)) {\n // Anonymous template\n return new ko.templateSources.anonymousTemplate(template);\n } else\n throw new Error(\"Unknown template type: \" + template);\n };\n\n ko.templateEngine.prototype['renderTemplate'] = function (template, bindingContext, options, templateDocument) {\n var templateSource = this['makeTemplateSource'](template, templateDocument);\n return this['renderTemplateSource'](templateSource, bindingContext, options, templateDocument);\n };\n\n ko.templateEngine.prototype['isTemplateRewritten'] = function (template, templateDocument) {\n // Skip rewriting if requested\n if (this['allowTemplateRewriting'] === false)\n return true;\n return this['makeTemplateSource'](template, templateDocument)['data'](\"isRewritten\");\n };\n\n ko.templateEngine.prototype['rewriteTemplate'] = function (template, rewriterCallback, templateDocument) {\n var templateSource = this['makeTemplateSource'](template, templateDocument);\n var rewritten = rewriterCallback(templateSource['text']());\n templateSource['text'](rewritten);\n templateSource['data'](\"isRewritten\", true);\n };\n\n ko.exportSymbol('templateEngine', ko.templateEngine);\n\n ko.templateRewriting = (function () {\n var memoizeDataBindingAttributeSyntaxRegex = /(<([a-z]+\\d*)(?:\\s+(?!data-bind\\s*=\\s*)[a-z0-9\\-]+(?:=(?:\\\"[^\\\"]*\\\"|\\'[^\\']*\\'|[^>]*))?)*\\s+)data-bind\\s*=\\s*([\"'])([\\s\\S]*?)\\3/gi;\n var memoizeVirtualContainerBindingSyntaxRegex = /<!--\\s*ko\\b\\s*([\\s\\S]*?)\\s*-->/g;\n\n function validateDataBindValuesForRewriting(keyValueArray) {\n var allValidators = ko.expressionRewriting.bindingRewriteValidators;\n for (var i = 0; i < keyValueArray.length; i++) {\n var key = keyValueArray[i]['key'];\n if (Object.prototype.hasOwnProperty.call(allValidators, key)) {\n var validator = allValidators[key];\n\n if (typeof validator === \"function\") {\n var possibleErrorMessage = validator(keyValueArray[i]['value']);\n if (possibleErrorMessage)\n throw new Error(possibleErrorMessage);\n } else if (!validator) {\n throw new Error(\"This template engine does not support the '\" + key + \"' binding within its templates\");\n }\n }\n }\n }\n\n function constructMemoizedTagReplacement(dataBindAttributeValue, tagToRetain, nodeName, templateEngine) {\n var dataBindKeyValueArray = ko.expressionRewriting.parseObjectLiteral(dataBindAttributeValue);\n validateDataBindValuesForRewriting(dataBindKeyValueArray);\n var rewrittenDataBindAttributeValue = ko.expressionRewriting.preProcessBindings(dataBindKeyValueArray, {'valueAccessors':true});\n\n // For no obvious reason, Opera fails to evaluate rewrittenDataBindAttributeValue unless it's wrapped in an additional\n // anonymous function, even though Opera's built-in debugger can evaluate it anyway. No other browser requires this\n // extra indirection.\n var applyBindingsToNextSiblingScript =\n \"ko.__tr_ambtns(function($context,$element){return(function(){return{ \" + rewrittenDataBindAttributeValue + \" } })()},'\" + nodeName.toLowerCase() + \"')\";\n return templateEngine['createJavaScriptEvaluatorBlock'](applyBindingsToNextSiblingScript) + tagToRetain;\n }\n\n return {\n ensureTemplateIsRewritten: function (template, templateEngine, templateDocument) {\n if (!templateEngine['isTemplateRewritten'](template, templateDocument))\n templateEngine['rewriteTemplate'](template, function (htmlString) {\n return ko.templateRewriting.memoizeBindingAttributeSyntax(htmlString, templateEngine);\n }, templateDocument);\n },\n\n memoizeBindingAttributeSyntax: function (htmlString, templateEngine) {\n return htmlString.replace(memoizeDataBindingAttributeSyntaxRegex, function () {\n return constructMemoizedTagReplacement(/* dataBindAttributeValue: */ arguments[4], /* tagToRetain: */ arguments[1], /* nodeName: */ arguments[2], templateEngine);\n }).replace(memoizeVirtualContainerBindingSyntaxRegex, function() {\n return constructMemoizedTagReplacement(/* dataBindAttributeValue: */ arguments[1], /* tagToRetain: */ \"<!-- ko -->\", /* nodeName: */ \"#comment\", templateEngine);\n });\n },\n\n applyMemoizedBindingsToNextSibling: function (bindings, nodeName) {\n return ko.memoization.memoize(function (domNode, bindingContext) {\n var nodeToBind = domNode.nextSibling;\n if (nodeToBind && nodeToBind.nodeName.toLowerCase() === nodeName) {\n ko.applyBindingAccessorsToNode(nodeToBind, bindings, bindingContext);\n }\n });\n }\n }\n })();\n\n\n// Exported only because it has to be referenced by string lookup from within rewritten template\n ko.exportSymbol('__tr_ambtns', ko.templateRewriting.applyMemoizedBindingsToNextSibling);\n (function() {\n // A template source represents a read/write way of accessing a template. This is to eliminate the need for template loading/saving\n // logic to be duplicated in every template engine (and means they can all work with anonymous templates, etc.)\n //\n // Two are provided by default:\n // 1. ko.templateSources.domElement - reads/writes the text content of an arbitrary DOM element\n // 2. ko.templateSources.anonymousElement - uses ko.utils.domData to read/write text *associated* with the DOM element, but\n // without reading/writing the actual element text content, since it will be overwritten\n // with the rendered template output.\n // You can implement your own template source if you want to fetch/store templates somewhere other than in DOM elements.\n // Template sources need to have the following functions:\n // text() \t\t\t- returns the template text from your storage location\n // text(value)\t\t- writes the supplied template text to your storage location\n // data(key)\t\t\t- reads values stored using data(key, value) - see below\n // data(key, value)\t- associates \"value\" with this template and the key \"key\". Is used to store information like \"isRewritten\".\n //\n // Optionally, template sources can also have the following functions:\n // nodes() - returns a DOM element containing the nodes of this template, where available\n // nodes(value) - writes the given DOM element to your storage location\n // If a DOM element is available for a given template source, template engines are encouraged to use it in preference over text()\n // for improved speed. However, all templateSources must supply text() even if they don't supply nodes().\n //\n // Once you've implemented a templateSource, make your template engine use it by subclassing whatever template engine you were\n // using and overriding \"makeTemplateSource\" to return an instance of your custom template source.\n\n ko.templateSources = {};\n\n // ---- ko.templateSources.domElement -----\n\n // template types\n var templateScript = 1,\n templateTextArea = 2,\n templateTemplate = 3,\n templateElement = 4;\n\n ko.templateSources.domElement = function(element) {\n this.domElement = element;\n\n if (element) {\n var tagNameLower = ko.utils.tagNameLower(element);\n this.templateType =\n tagNameLower === \"script\" ? templateScript :\n tagNameLower === \"textarea\" ? templateTextArea :\n // For browsers with proper <template> element support, where the .content property gives a document fragment\n tagNameLower == \"template\" && element.content && element.content.nodeType === 11 ? templateTemplate :\n templateElement;\n }\n }\n\n ko.templateSources.domElement.prototype['text'] = function(/* valueToWrite */) {\n var elemContentsProperty = this.templateType === templateScript ? \"text\"\n : this.templateType === templateTextArea ? \"value\"\n : \"innerHTML\";\n\n if (arguments.length == 0) {\n return this.domElement[elemContentsProperty];\n } else {\n var valueToWrite = arguments[0];\n if (elemContentsProperty === \"innerHTML\")\n ko.utils.setHtml(this.domElement, valueToWrite);\n else\n this.domElement[elemContentsProperty] = valueToWrite;\n }\n };\n\n var dataDomDataPrefix = ko.utils.domData.nextKey() + \"_\";\n ko.templateSources.domElement.prototype['data'] = function(key /*, valueToWrite */) {\n if (arguments.length === 1) {\n return ko.utils.domData.get(this.domElement, dataDomDataPrefix + key);\n } else {\n ko.utils.domData.set(this.domElement, dataDomDataPrefix + key, arguments[1]);\n }\n };\n\n var templatesDomDataKey = ko.utils.domData.nextKey();\n function getTemplateDomData(element) {\n return ko.utils.domData.get(element, templatesDomDataKey) || {};\n }\n function setTemplateDomData(element, data) {\n ko.utils.domData.set(element, templatesDomDataKey, data);\n }\n\n ko.templateSources.domElement.prototype['nodes'] = function(/* valueToWrite */) {\n var element = this.domElement;\n if (arguments.length == 0) {\n var templateData = getTemplateDomData(element),\n nodes = templateData.containerData || (\n this.templateType === templateTemplate ? element.content :\n this.templateType === templateElement ? element :\n undefined);\n if (!nodes || templateData.alwaysCheckText) {\n // If the template is associated with an element that stores the template as text,\n // parse and cache the nodes whenever there's new text content available. This allows\n // the user to update the template content by updating the text of template node.\n var text = this['text']();\n if (text && text !== templateData.textData) {\n nodes = ko.utils.parseHtmlForTemplateNodes(text, element.ownerDocument);\n setTemplateDomData(element, {containerData: nodes, textData: text, alwaysCheckText: true});\n }\n }\n return nodes;\n } else {\n var valueToWrite = arguments[0];\n if (this.templateType !== undefined) {\n this['text'](\"\"); // clear the text from the node\n }\n setTemplateDomData(element, {containerData: valueToWrite});\n }\n };\n\n // ---- ko.templateSources.anonymousTemplate -----\n // Anonymous templates are normally saved/retrieved as DOM nodes through \"nodes\".\n // For compatibility, you can also read \"text\"; it will be serialized from the nodes on demand.\n // Writing to \"text\" is still supported, but then the template data will not be available as DOM nodes.\n\n ko.templateSources.anonymousTemplate = function(element) {\n this.domElement = element;\n }\n ko.templateSources.anonymousTemplate.prototype = new ko.templateSources.domElement();\n ko.templateSources.anonymousTemplate.prototype.constructor = ko.templateSources.anonymousTemplate;\n ko.templateSources.anonymousTemplate.prototype['text'] = function(/* valueToWrite */) {\n if (arguments.length == 0) {\n var templateData = getTemplateDomData(this.domElement);\n if (templateData.textData === undefined && templateData.containerData)\n templateData.textData = templateData.containerData.innerHTML;\n return templateData.textData;\n } else {\n var valueToWrite = arguments[0];\n setTemplateDomData(this.domElement, {textData: valueToWrite});\n }\n };\n\n ko.exportSymbol('templateSources', ko.templateSources);\n ko.exportSymbol('templateSources.domElement', ko.templateSources.domElement);\n ko.exportSymbol('templateSources.anonymousTemplate', ko.templateSources.anonymousTemplate);\n })();\n (function () {\n var _templateEngine;\n ko.setTemplateEngine = function (templateEngine) {\n if ((templateEngine != undefined) && !(templateEngine instanceof ko.templateEngine))\n throw new Error(\"templateEngine must inherit from ko.templateEngine\");\n _templateEngine = templateEngine;\n }\n\n function invokeForEachNodeInContinuousRange(firstNode, lastNode, action) {\n var node, nextInQueue = firstNode, firstOutOfRangeNode = ko.virtualElements.nextSibling(lastNode);\n while (nextInQueue && ((node = nextInQueue) !== firstOutOfRangeNode)) {\n nextInQueue = ko.virtualElements.nextSibling(node);\n action(node, nextInQueue);\n }\n }\n\n function activateBindingsOnContinuousNodeArray(continuousNodeArray, bindingContext) {\n // To be used on any nodes that have been rendered by a template and have been inserted into some parent element\n // Walks through continuousNodeArray (which *must* be continuous, i.e., an uninterrupted sequence of sibling nodes, because\n // the algorithm for walking them relies on this), and for each top-level item in the virtual-element sense,\n // (1) Does a regular \"applyBindings\" to associate bindingContext with this node and to activate any non-memoized bindings\n // (2) Unmemoizes any memos in the DOM subtree (e.g., to activate bindings that had been memoized during template rewriting)\n\n if (continuousNodeArray.length) {\n var firstNode = continuousNodeArray[0],\n lastNode = continuousNodeArray[continuousNodeArray.length - 1],\n parentNode = firstNode.parentNode,\n provider = ko.bindingProvider['instance'],\n preprocessNode = provider['preprocessNode'];\n\n if (preprocessNode) {\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node, nextNodeInRange) {\n var nodePreviousSibling = node.previousSibling;\n var newNodes = preprocessNode.call(provider, node);\n if (newNodes) {\n if (node === firstNode)\n firstNode = newNodes[0] || nextNodeInRange;\n if (node === lastNode)\n lastNode = newNodes[newNodes.length - 1] || nodePreviousSibling;\n }\n });\n\n // Because preprocessNode can change the nodes, including the first and last nodes, update continuousNodeArray to match.\n // We need the full set, including inner nodes, because the unmemoize step might remove the first node (and so the real\n // first node needs to be in the array).\n continuousNodeArray.length = 0;\n if (!firstNode) { // preprocessNode might have removed all the nodes, in which case there's nothing left to do\n return;\n }\n if (firstNode === lastNode) {\n continuousNodeArray.push(firstNode);\n } else {\n continuousNodeArray.push(firstNode, lastNode);\n ko.utils.fixUpContinuousNodeArray(continuousNodeArray, parentNode);\n }\n }\n\n // Need to applyBindings *before* unmemoziation, because unmemoization might introduce extra nodes (that we don't want to re-bind)\n // whereas a regular applyBindings won't introduce new memoized nodes\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {\n if (node.nodeType === 1 || node.nodeType === 8)\n ko.applyBindings(bindingContext, node);\n });\n invokeForEachNodeInContinuousRange(firstNode, lastNode, function(node) {\n if (node.nodeType === 1 || node.nodeType === 8)\n ko.memoization.unmemoizeDomNodeAndDescendants(node, [bindingContext]);\n });\n\n // Make sure any changes done by applyBindings or unmemoize are reflected in the array\n ko.utils.fixUpContinuousNodeArray(continuousNodeArray, parentNode);\n }\n }\n\n function getFirstNodeFromPossibleArray(nodeOrNodeArray) {\n return nodeOrNodeArray.nodeType ? nodeOrNodeArray\n : nodeOrNodeArray.length > 0 ? nodeOrNodeArray[0]\n : null;\n }\n\n function executeTemplate(targetNodeOrNodeArray, renderMode, template, bindingContext, options) {\n options = options || {};\n var firstTargetNode = targetNodeOrNodeArray && getFirstNodeFromPossibleArray(targetNodeOrNodeArray);\n var templateDocument = (firstTargetNode || template || {}).ownerDocument;\n var templateEngineToUse = (options['templateEngine'] || _templateEngine);\n ko.templateRewriting.ensureTemplateIsRewritten(template, templateEngineToUse, templateDocument);\n var renderedNodesArray = templateEngineToUse['renderTemplate'](template, bindingContext, options, templateDocument);\n\n // Loosely check result is an array of DOM nodes\n if ((typeof renderedNodesArray.length != \"number\") || (renderedNodesArray.length > 0 && typeof renderedNodesArray[0].nodeType != \"number\"))\n throw new Error(\"Template engine must return an array of DOM nodes\");\n\n var haveAddedNodesToParent = false;\n switch (renderMode) {\n case \"replaceChildren\":\n ko.virtualElements.setDomNodeChildren(targetNodeOrNodeArray, renderedNodesArray);\n haveAddedNodesToParent = true;\n break;\n case \"replaceNode\":\n ko.utils.replaceDomNodes(targetNodeOrNodeArray, renderedNodesArray);\n haveAddedNodesToParent = true;\n break;\n case \"ignoreTargetNode\": break;\n default:\n throw new Error(\"Unknown renderMode: \" + renderMode);\n }\n\n if (haveAddedNodesToParent) {\n activateBindingsOnContinuousNodeArray(renderedNodesArray, bindingContext);\n if (options['afterRender']) {\n ko.dependencyDetection.ignore(options['afterRender'], null, [renderedNodesArray, bindingContext[options['as'] || '$data']]);\n }\n if (renderMode == \"replaceChildren\") {\n ko.bindingEvent.notify(targetNodeOrNodeArray, ko.bindingEvent.childrenComplete);\n }\n }\n\n return renderedNodesArray;\n }\n\n function resolveTemplateName(template, data, context) {\n // The template can be specified as:\n if (ko.isObservable(template)) {\n // 1. An observable, with string value\n return template();\n } else if (typeof template === 'function') {\n // 2. A function of (data, context) returning a string\n return template(data, context);\n } else {\n // 3. A string\n return template;\n }\n }\n\n ko.renderTemplate = function (template, dataOrBindingContext, options, targetNodeOrNodeArray, renderMode) {\n options = options || {};\n if ((options['templateEngine'] || _templateEngine) == undefined)\n throw new Error(\"Set a template engine before calling renderTemplate\");\n renderMode = renderMode || \"replaceChildren\";\n\n if (targetNodeOrNodeArray) {\n var firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);\n\n var whenToDispose = function () { return (!firstTargetNode) || !ko.utils.domNodeIsAttachedToDocument(firstTargetNode); }; // Passive disposal (on next evaluation)\n var activelyDisposeWhenNodeIsRemoved = (firstTargetNode && renderMode == \"replaceNode\") ? firstTargetNode.parentNode : firstTargetNode;\n\n return ko.dependentObservable( // So the DOM is automatically updated when any dependency changes\n function () {\n // Ensure we've got a proper binding context to work with\n var bindingContext = (dataOrBindingContext && (dataOrBindingContext instanceof ko.bindingContext))\n ? dataOrBindingContext\n : new ko.bindingContext(dataOrBindingContext, null, null, null, { \"exportDependencies\": true });\n\n var templateName = resolveTemplateName(template, bindingContext['$data'], bindingContext),\n renderedNodesArray = executeTemplate(targetNodeOrNodeArray, renderMode, templateName, bindingContext, options);\n\n if (renderMode == \"replaceNode\") {\n targetNodeOrNodeArray = renderedNodesArray;\n firstTargetNode = getFirstNodeFromPossibleArray(targetNodeOrNodeArray);\n }\n },\n null,\n { disposeWhen: whenToDispose, disposeWhenNodeIsRemoved: activelyDisposeWhenNodeIsRemoved }\n );\n } else {\n // We don't yet have a DOM node to evaluate, so use a memo and render the template later when there is a DOM node\n return ko.memoization.memoize(function (domNode) {\n ko.renderTemplate(template, dataOrBindingContext, options, domNode, \"replaceNode\");\n });\n }\n };\n\n ko.renderTemplateForEach = function (template, arrayOrObservableArray, options, targetNode, parentBindingContext) {\n // Since setDomNodeChildrenFromArrayMapping always calls executeTemplateForArrayItem and then\n // activateBindingsCallback for added items, we can store the binding context in the former to use in the latter.\n var arrayItemContext, asName = options['as'];\n\n // This will be called by setDomNodeChildrenFromArrayMapping to get the nodes to add to targetNode\n var executeTemplateForArrayItem = function (arrayValue, index) {\n // Support selecting template as a function of the data being rendered\n arrayItemContext = parentBindingContext['createChildContext'](arrayValue, {\n 'as': asName,\n 'noChildContext': options['noChildContext'],\n 'extend': function(context) {\n context['$index'] = index;\n if (asName) {\n context[asName + \"Index\"] = index;\n }\n }\n });\n\n var templateName = resolveTemplateName(template, arrayValue, arrayItemContext);\n return executeTemplate(targetNode, \"ignoreTargetNode\", templateName, arrayItemContext, options);\n };\n\n // This will be called whenever setDomNodeChildrenFromArrayMapping has added nodes to targetNode\n var activateBindingsCallback = function(arrayValue, addedNodesArray, index) {\n activateBindingsOnContinuousNodeArray(addedNodesArray, arrayItemContext);\n if (options['afterRender'])\n options['afterRender'](addedNodesArray, arrayValue);\n\n // release the \"cache\" variable, so that it can be collected by\n // the GC when its value isn't used from within the bindings anymore.\n arrayItemContext = null;\n };\n\n var setDomNodeChildrenFromArrayMapping = function (newArray, changeList) {\n // Call setDomNodeChildrenFromArrayMapping, ignoring any observables unwrapped within (most likely from a callback function).\n // If the array items are observables, though, they will be unwrapped in executeTemplateForArrayItem and managed within setDomNodeChildrenFromArrayMapping.\n ko.dependencyDetection.ignore(ko.utils.setDomNodeChildrenFromArrayMapping, null, [targetNode, newArray, executeTemplateForArrayItem, options, activateBindingsCallback, changeList]);\n ko.bindingEvent.notify(targetNode, ko.bindingEvent.childrenComplete);\n };\n\n var shouldHideDestroyed = (options['includeDestroyed'] === false) || (ko.options['foreachHidesDestroyed'] && !options['includeDestroyed']);\n\n if (!shouldHideDestroyed && !options['beforeRemove'] && ko.isObservableArray(arrayOrObservableArray)) {\n setDomNodeChildrenFromArrayMapping(arrayOrObservableArray.peek());\n\n var subscription = arrayOrObservableArray.subscribe(function (changeList) {\n setDomNodeChildrenFromArrayMapping(arrayOrObservableArray(), changeList);\n }, null, \"arrayChange\");\n subscription.disposeWhenNodeIsRemoved(targetNode);\n\n return subscription;\n } else {\n return ko.dependentObservable(function () {\n var unwrappedArray = ko.utils.unwrapObservable(arrayOrObservableArray) || [];\n if (typeof unwrappedArray.length == \"undefined\") // Coerce single value into array\n unwrappedArray = [unwrappedArray];\n\n if (shouldHideDestroyed) {\n // Filter out any entries marked as destroyed\n unwrappedArray = ko.utils.arrayFilter(unwrappedArray, function(item) {\n return item === undefined || item === null || !ko.utils.unwrapObservable(item['_destroy']);\n });\n }\n setDomNodeChildrenFromArrayMapping(unwrappedArray);\n\n }, null, { disposeWhenNodeIsRemoved: targetNode });\n }\n };\n\n var templateComputedDomDataKey = ko.utils.domData.nextKey();\n function disposeOldComputedAndStoreNewOne(element, newComputed) {\n var oldComputed = ko.utils.domData.get(element, templateComputedDomDataKey);\n if (oldComputed && (typeof(oldComputed.dispose) == 'function'))\n oldComputed.dispose();\n ko.utils.domData.set(element, templateComputedDomDataKey, (newComputed && (!newComputed.isActive || newComputed.isActive())) ? newComputed : undefined);\n }\n\n var cleanContainerDomDataKey = ko.utils.domData.nextKey();\n ko.bindingHandlers['template'] = {\n 'init': function(element, valueAccessor) {\n // Support anonymous templates\n var bindingValue = ko.utils.unwrapObservable(valueAccessor());\n if (typeof bindingValue == \"string\" || 'name' in bindingValue) {\n // It's a named template - clear the element\n ko.virtualElements.emptyNode(element);\n } else if ('nodes' in bindingValue) {\n // We've been given an array of DOM nodes. Save them as the template source.\n // There is no known use case for the node array being an observable array (if the output\n // varies, put that behavior *into* your template - that's what templates are for), and\n // the implementation would be a mess, so assert that it's not observable.\n var nodes = bindingValue['nodes'] || [];\n if (ko.isObservable(nodes)) {\n throw new Error('The \"nodes\" option must be a plain, non-observable array.');\n }\n\n // If the nodes are already attached to a KO-generated container, we reuse that container without moving the\n // elements to a new one (we check only the first node, as the nodes are always moved together)\n var container = nodes[0] && nodes[0].parentNode;\n if (!container || !ko.utils.domData.get(container, cleanContainerDomDataKey)) {\n container = ko.utils.moveCleanedNodesToContainerElement(nodes);\n ko.utils.domData.set(container, cleanContainerDomDataKey, true);\n }\n\n new ko.templateSources.anonymousTemplate(element)['nodes'](container);\n } else {\n // It's an anonymous template - store the element contents, then clear the element\n var templateNodes = ko.virtualElements.childNodes(element);\n if (templateNodes.length > 0) {\n var container = ko.utils.moveCleanedNodesToContainerElement(templateNodes); // This also removes the nodes from their current parent\n new ko.templateSources.anonymousTemplate(element)['nodes'](container);\n } else {\n throw new Error(\"Anonymous template defined, but no template content was provided\");\n }\n }\n return { 'controlsDescendantBindings': true };\n },\n 'update': function (element, valueAccessor, allBindings, viewModel, bindingContext) {\n var value = valueAccessor(),\n options = ko.utils.unwrapObservable(value),\n shouldDisplay = true,\n templateComputed = null,\n template;\n\n if (typeof options == \"string\") {\n template = value;\n options = {};\n } else {\n template = 'name' in options ? options['name'] : element;\n\n // Support \"if\"/\"ifnot\" conditions\n if ('if' in options)\n shouldDisplay = ko.utils.unwrapObservable(options['if']);\n if (shouldDisplay && 'ifnot' in options)\n shouldDisplay = !ko.utils.unwrapObservable(options['ifnot']);\n\n // Don't show anything if an empty name is given (see #2446)\n if (shouldDisplay && !template) {\n shouldDisplay = false;\n }\n }\n\n if ('foreach' in options) {\n // Render once for each data point (treating data set as empty if shouldDisplay==false)\n var dataArray = (shouldDisplay && options['foreach']) || [];\n templateComputed = ko.renderTemplateForEach(template, dataArray, options, element, bindingContext);\n } else if (!shouldDisplay) {\n ko.virtualElements.emptyNode(element);\n } else {\n // Render once for this single data point (or use the viewModel if no data was provided)\n var innerBindingContext = bindingContext;\n if ('data' in options) {\n innerBindingContext = bindingContext['createChildContext'](options['data'], {\n 'as': options['as'],\n 'noChildContext': options['noChildContext'],\n 'exportDependencies': true\n });\n }\n templateComputed = ko.renderTemplate(template, innerBindingContext, options, element);\n }\n\n // It only makes sense to have a single template computed per element (otherwise which one should have its output displayed?)\n disposeOldComputedAndStoreNewOne(element, templateComputed);\n }\n };\n\n // Anonymous templates can't be rewritten. Give a nice error message if you try to do it.\n ko.expressionRewriting.bindingRewriteValidators['template'] = function(bindingValue) {\n var parsedBindingValue = ko.expressionRewriting.parseObjectLiteral(bindingValue);\n\n if ((parsedBindingValue.length == 1) && parsedBindingValue[0]['unknown'])\n return null; // It looks like a string literal, not an object literal, so treat it as a named template (which is allowed for rewriting)\n\n if (ko.expressionRewriting.keyValueArrayContainsKey(parsedBindingValue, \"name\"))\n return null; // Named templates can be rewritten, so return \"no error\"\n return \"This template engine does not support anonymous templates nested within its templates\";\n };\n\n ko.virtualElements.allowedBindings['template'] = true;\n })();\n\n ko.exportSymbol('setTemplateEngine', ko.setTemplateEngine);\n ko.exportSymbol('renderTemplate', ko.renderTemplate);\n// Go through the items that have been added and deleted and try to find matches between them.\n ko.utils.findMovesInArrayComparison = function (left, right, limitFailedCompares) {\n if (left.length && right.length) {\n var failedCompares, l, r, leftItem, rightItem;\n for (failedCompares = l = 0; (!limitFailedCompares || failedCompares < limitFailedCompares) && (leftItem = left[l]); ++l) {\n for (r = 0; rightItem = right[r]; ++r) {\n if (leftItem['value'] === rightItem['value']) {\n leftItem['moved'] = rightItem['index'];\n rightItem['moved'] = leftItem['index'];\n right.splice(r, 1); // This item is marked as moved; so remove it from right list\n failedCompares = r = 0; // Reset failed compares count because we're checking for consecutive failures\n break;\n }\n }\n failedCompares += r;\n }\n }\n };\n\n ko.utils.compareArrays = (function () {\n var statusNotInOld = 'added', statusNotInNew = 'deleted';\n\n // Simple calculation based on Levenshtein distance.\n function compareArrays(oldArray, newArray, options) {\n // For backward compatibility, if the third arg is actually a bool, interpret\n // it as the old parameter 'dontLimitMoves'. Newer code should use { dontLimitMoves: true }.\n options = (typeof options === 'boolean') ? { 'dontLimitMoves': options } : (options || {});\n oldArray = oldArray || [];\n newArray = newArray || [];\n\n if (oldArray.length < newArray.length)\n return compareSmallArrayToBigArray(oldArray, newArray, statusNotInOld, statusNotInNew, options);\n else\n return compareSmallArrayToBigArray(newArray, oldArray, statusNotInNew, statusNotInOld, options);\n }\n\n function compareSmallArrayToBigArray(smlArray, bigArray, statusNotInSml, statusNotInBig, options) {\n var myMin = Math.min,\n myMax = Math.max,\n editDistanceMatrix = [],\n smlIndex, smlIndexMax = smlArray.length,\n bigIndex, bigIndexMax = bigArray.length,\n compareRange = (bigIndexMax - smlIndexMax) || 1,\n maxDistance = smlIndexMax + bigIndexMax + 1,\n thisRow, lastRow,\n bigIndexMaxForRow, bigIndexMinForRow;\n\n for (smlIndex = 0; smlIndex <= smlIndexMax; smlIndex++) {\n lastRow = thisRow;\n editDistanceMatrix.push(thisRow = []);\n bigIndexMaxForRow = myMin(bigIndexMax, smlIndex + compareRange);\n bigIndexMinForRow = myMax(0, smlIndex - 1);\n for (bigIndex = bigIndexMinForRow; bigIndex <= bigIndexMaxForRow; bigIndex++) {\n if (!bigIndex)\n thisRow[bigIndex] = smlIndex + 1;\n else if (!smlIndex) // Top row - transform empty array into new array via additions\n thisRow[bigIndex] = bigIndex + 1;\n else if (smlArray[smlIndex - 1] === bigArray[bigIndex - 1])\n thisRow[bigIndex] = lastRow[bigIndex - 1]; // copy value (no edit)\n else {\n var northDistance = lastRow[bigIndex] || maxDistance; // not in big (deletion)\n var westDistance = thisRow[bigIndex - 1] || maxDistance; // not in small (addition)\n thisRow[bigIndex] = myMin(northDistance, westDistance) + 1;\n }\n }\n }\n\n var editScript = [], meMinusOne, notInSml = [], notInBig = [];\n for (smlIndex = smlIndexMax, bigIndex = bigIndexMax; smlIndex || bigIndex;) {\n meMinusOne = editDistanceMatrix[smlIndex][bigIndex] - 1;\n if (bigIndex && meMinusOne === editDistanceMatrix[smlIndex][bigIndex-1]) {\n notInSml.push(editScript[editScript.length] = { // added\n 'status': statusNotInSml,\n 'value': bigArray[--bigIndex],\n 'index': bigIndex });\n } else if (smlIndex && meMinusOne === editDistanceMatrix[smlIndex - 1][bigIndex]) {\n notInBig.push(editScript[editScript.length] = { // deleted\n 'status': statusNotInBig,\n 'value': smlArray[--smlIndex],\n 'index': smlIndex });\n } else {\n --bigIndex;\n --smlIndex;\n if (!options['sparse']) {\n editScript.push({\n 'status': \"retained\",\n 'value': bigArray[bigIndex] });\n }\n }\n }\n\n // Set a limit on the number of consecutive non-matching comparisons; having it a multiple of\n // smlIndexMax keeps the time complexity of this algorithm linear.\n ko.utils.findMovesInArrayComparison(notInBig, notInSml, !options['dontLimitMoves'] && smlIndexMax * 10);\n\n return editScript.reverse();\n }\n\n return compareArrays;\n })();\n\n ko.exportSymbol('utils.compareArrays', ko.utils.compareArrays);\n (function () {\n // Objective:\n // * Given an input array, a container DOM node, and a function from array elements to arrays of DOM nodes,\n // map the array elements to arrays of DOM nodes, concatenate together all these arrays, and use them to populate the container DOM node\n // * Next time we're given the same combination of things (with the array possibly having mutated), update the container DOM node\n // so that its children is again the concatenation of the mappings of the array elements, but don't re-map any array elements that we\n // previously mapped - retain those nodes, and just insert/delete other ones\n\n // \"callbackAfterAddingNodes\" will be invoked after any \"mapping\"-generated nodes are inserted into the container node\n // You can use this, for example, to activate bindings on those nodes.\n\n function mapNodeAndRefreshWhenChanged(containerNode, mapping, valueToMap, callbackAfterAddingNodes, index) {\n // Map this array value inside a dependentObservable so we re-map when any dependency changes\n var mappedNodes = [];\n var dependentObservable = ko.dependentObservable(function() {\n var newMappedNodes = mapping(valueToMap, index, ko.utils.fixUpContinuousNodeArray(mappedNodes, containerNode)) || [];\n\n // On subsequent evaluations, just replace the previously-inserted DOM nodes\n if (mappedNodes.length > 0) {\n ko.utils.replaceDomNodes(mappedNodes, newMappedNodes);\n if (callbackAfterAddingNodes)\n ko.dependencyDetection.ignore(callbackAfterAddingNodes, null, [valueToMap, newMappedNodes, index]);\n }\n\n // Replace the contents of the mappedNodes array, thereby updating the record\n // of which nodes would be deleted if valueToMap was itself later removed\n mappedNodes.length = 0;\n ko.utils.arrayPushAll(mappedNodes, newMappedNodes);\n }, null, { disposeWhenNodeIsRemoved: containerNode, disposeWhen: function() { return !ko.utils.anyDomNodeIsAttachedToDocument(mappedNodes); } });\n return { mappedNodes : mappedNodes, dependentObservable : (dependentObservable.isActive() ? dependentObservable : undefined) };\n }\n\n var lastMappingResultDomDataKey = ko.utils.domData.nextKey(),\n deletedItemDummyValue = ko.utils.domData.nextKey();\n\n ko.utils.setDomNodeChildrenFromArrayMapping = function (domNode, array, mapping, options, callbackAfterAddingNodes, editScript) {\n array = array || [];\n if (typeof array.length == \"undefined\") // Coerce single value into array\n array = [array];\n\n options = options || {};\n var lastMappingResult = ko.utils.domData.get(domNode, lastMappingResultDomDataKey);\n var isFirstExecution = !lastMappingResult;\n\n // Build the new mapping result\n var newMappingResult = [];\n var lastMappingResultIndex = 0;\n var currentArrayIndex = 0;\n\n var nodesToDelete = [];\n var itemsToMoveFirstIndexes = [];\n var itemsForBeforeRemoveCallbacks = [];\n var itemsForMoveCallbacks = [];\n var itemsForAfterAddCallbacks = [];\n var mapData;\n var countWaitingForRemove = 0;\n\n function itemAdded(value) {\n mapData = { arrayEntry: value, indexObservable: ko.observable(currentArrayIndex++) };\n newMappingResult.push(mapData);\n if (!isFirstExecution) {\n itemsForAfterAddCallbacks.push(mapData);\n }\n }\n\n function itemMovedOrRetained(oldPosition) {\n mapData = lastMappingResult[oldPosition];\n if (currentArrayIndex !== mapData.indexObservable.peek())\n itemsForMoveCallbacks.push(mapData);\n // Since updating the index might change the nodes, do so before calling fixUpContinuousNodeArray\n mapData.indexObservable(currentArrayIndex++);\n ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode);\n newMappingResult.push(mapData);\n }\n\n function callCallback(callback, items) {\n if (callback) {\n for (var i = 0, n = items.length; i < n; i++) {\n ko.utils.arrayForEach(items[i].mappedNodes, function(node) {\n callback(node, i, items[i].arrayEntry);\n });\n }\n }\n }\n\n if (isFirstExecution) {\n ko.utils.arrayForEach(array, itemAdded);\n } else {\n if (!editScript || (lastMappingResult && lastMappingResult['_countWaitingForRemove'])) {\n // Compare the provided array against the previous one\n var lastArray = ko.utils.arrayMap(lastMappingResult, function (x) { return x.arrayEntry; }),\n compareOptions = {\n 'dontLimitMoves': options['dontLimitMoves'],\n 'sparse': true\n };\n editScript = ko.utils.compareArrays(lastArray, array, compareOptions);\n }\n\n for (var i = 0, editScriptItem, movedIndex, itemIndex; editScriptItem = editScript[i]; i++) {\n movedIndex = editScriptItem['moved'];\n itemIndex = editScriptItem['index'];\n switch (editScriptItem['status']) {\n case \"deleted\":\n while (lastMappingResultIndex < itemIndex) {\n itemMovedOrRetained(lastMappingResultIndex++);\n }\n if (movedIndex === undefined) {\n mapData = lastMappingResult[lastMappingResultIndex];\n\n // Stop tracking changes to the mapping for these nodes\n if (mapData.dependentObservable) {\n mapData.dependentObservable.dispose();\n mapData.dependentObservable = undefined;\n }\n\n // Queue these nodes for later removal\n if (ko.utils.fixUpContinuousNodeArray(mapData.mappedNodes, domNode).length) {\n if (options['beforeRemove']) {\n newMappingResult.push(mapData);\n countWaitingForRemove++;\n if (mapData.arrayEntry === deletedItemDummyValue) {\n mapData = null;\n } else {\n itemsForBeforeRemoveCallbacks.push(mapData);\n }\n }\n if (mapData) {\n nodesToDelete.push.apply(nodesToDelete, mapData.mappedNodes);\n }\n }\n }\n lastMappingResultIndex++;\n break;\n\n case \"added\":\n while (currentArrayIndex < itemIndex) {\n itemMovedOrRetained(lastMappingResultIndex++);\n }\n if (movedIndex !== undefined) {\n itemsToMoveFirstIndexes.push(newMappingResult.length);\n itemMovedOrRetained(movedIndex);\n } else {\n itemAdded(editScriptItem['value']);\n }\n break;\n }\n }\n\n while (currentArrayIndex < array.length) {\n itemMovedOrRetained(lastMappingResultIndex++);\n }\n\n // Record that the current view may still contain deleted items\n // because it means we won't be able to use a provided editScript.\n newMappingResult['_countWaitingForRemove'] = countWaitingForRemove;\n }\n\n // Store a copy of the array items we just considered so we can difference it next time\n ko.utils.domData.set(domNode, lastMappingResultDomDataKey, newMappingResult);\n\n // Call beforeMove first before any changes have been made to the DOM\n callCallback(options['beforeMove'], itemsForMoveCallbacks);\n\n // Next remove nodes for deleted items (or just clean if there's a beforeRemove callback)\n ko.utils.arrayForEach(nodesToDelete, options['beforeRemove'] ? ko.cleanNode : ko.removeNode);\n\n var i, j, lastNode, nodeToInsert, mappedNodes, activeElement;\n\n // Since most browsers remove the focus from an element when it's moved to another location,\n // save the focused element and try to restore it later.\n try {\n activeElement = domNode.ownerDocument.activeElement;\n } catch(e) {\n // IE9 throws if you access activeElement during page load (see issue #703)\n }\n\n // Try to reduce overall moved nodes by first moving the ones that were marked as moved by the edit script\n if (itemsToMoveFirstIndexes.length) {\n while ((i = itemsToMoveFirstIndexes.shift()) != undefined) {\n mapData = newMappingResult[i];\n for (lastNode = undefined; i; ) {\n if ((mappedNodes = newMappingResult[--i].mappedNodes) && mappedNodes.length) {\n lastNode = mappedNodes[mappedNodes.length-1];\n break;\n }\n }\n for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {\n ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);\n }\n }\n }\n\n // Next add/reorder the remaining items (will include deleted items if there's a beforeRemove callback)\n for (i = 0; mapData = newMappingResult[i]; i++) {\n // Get nodes for newly added items\n if (!mapData.mappedNodes)\n ko.utils.extend(mapData, mapNodeAndRefreshWhenChanged(domNode, mapping, mapData.arrayEntry, callbackAfterAddingNodes, mapData.indexObservable));\n\n // Put nodes in the right place if they aren't there already\n for (j = 0; nodeToInsert = mapData.mappedNodes[j]; lastNode = nodeToInsert, j++) {\n ko.virtualElements.insertAfter(domNode, nodeToInsert, lastNode);\n }\n\n // Run the callbacks for newly added nodes (for example, to apply bindings, etc.)\n if (!mapData.initialized && callbackAfterAddingNodes) {\n callbackAfterAddingNodes(mapData.arrayEntry, mapData.mappedNodes, mapData.indexObservable);\n mapData.initialized = true;\n lastNode = mapData.mappedNodes[mapData.mappedNodes.length - 1]; // get the last node again since it may have been changed by a preprocessor\n }\n }\n\n // Restore the focused element if it had lost focus\n if (activeElement && domNode.ownerDocument.activeElement != activeElement) {\n activeElement.focus();\n }\n\n // If there's a beforeRemove callback, call it after reordering.\n // Note that we assume that the beforeRemove callback will usually be used to remove the nodes using\n // some sort of animation, which is why we first reorder the nodes that will be removed. If the\n // callback instead removes the nodes right away, it would be more efficient to skip reordering them.\n // Perhaps we'll make that change in the future if this scenario becomes more common.\n callCallback(options['beforeRemove'], itemsForBeforeRemoveCallbacks);\n\n // Replace the stored values of deleted items with a dummy value. This provides two benefits: it marks this item\n // as already \"removed\" so we won't call beforeRemove for it again, and it ensures that the item won't match up\n // with an actual item in the array and appear as \"retained\" or \"moved\".\n for (i = 0; i < itemsForBeforeRemoveCallbacks.length; ++i) {\n itemsForBeforeRemoveCallbacks[i].arrayEntry = deletedItemDummyValue;\n }\n\n // Finally call afterMove and afterAdd callbacks\n callCallback(options['afterMove'], itemsForMoveCallbacks);\n callCallback(options['afterAdd'], itemsForAfterAddCallbacks);\n }\n })();\n\n ko.exportSymbol('utils.setDomNodeChildrenFromArrayMapping', ko.utils.setDomNodeChildrenFromArrayMapping);\n ko.nativeTemplateEngine = function () {\n this['allowTemplateRewriting'] = false;\n }\n\n ko.nativeTemplateEngine.prototype = new ko.templateEngine();\n ko.nativeTemplateEngine.prototype.constructor = ko.nativeTemplateEngine;\n ko.nativeTemplateEngine.prototype['renderTemplateSource'] = function (templateSource, bindingContext, options, templateDocument) {\n var useNodesIfAvailable = !(ko.utils.ieVersion < 9), // IE<9 cloneNode doesn't work properly\n templateNodesFunc = useNodesIfAvailable ? templateSource['nodes'] : null,\n templateNodes = templateNodesFunc ? templateSource['nodes']() : null;\n\n if (templateNodes) {\n return ko.utils.makeArray(templateNodes.cloneNode(true).childNodes);\n } else {\n var templateText = templateSource['text']();\n return ko.utils.parseHtmlFragment(templateText, templateDocument);\n }\n };\n\n ko.nativeTemplateEngine.instance = new ko.nativeTemplateEngine();\n ko.setTemplateEngine(ko.nativeTemplateEngine.instance);\n\n ko.exportSymbol('nativeTemplateEngine', ko.nativeTemplateEngine);\n (function() {\n ko.jqueryTmplTemplateEngine = function () {\n // Detect which version of jquery-tmpl you're using. Unfortunately jquery-tmpl\n // doesn't expose a version number, so we have to infer it.\n // Note that as of Knockout 1.3, we only support jQuery.tmpl 1.0.0pre and later,\n // which KO internally refers to as version \"2\", so older versions are no longer detected.\n var jQueryTmplVersion = this.jQueryTmplVersion = (function() {\n if (!jQueryInstance || !(jQueryInstance['tmpl']))\n return 0;\n // Since it exposes no official version number, we use our own numbering system. To be updated as jquery-tmpl evolves.\n try {\n if (jQueryInstance['tmpl']['tag']['tmpl']['open'].toString().indexOf('__') >= 0) {\n // Since 1.0.0pre, custom tags should append markup to an array called \"__\"\n return 2; // Final version of jquery.tmpl\n }\n } catch(ex) { /* Apparently not the version we were looking for */ }\n\n return 1; // Any older version that we don't support\n })();\n\n function ensureHasReferencedJQueryTemplates() {\n if (jQueryTmplVersion < 2)\n throw new Error(\"Your version of jQuery.tmpl is too old. Please upgrade to jQuery.tmpl 1.0.0pre or later.\");\n }\n\n function executeTemplate(compiledTemplate, data, jQueryTemplateOptions) {\n return jQueryInstance['tmpl'](compiledTemplate, data, jQueryTemplateOptions);\n }\n\n this['renderTemplateSource'] = function(templateSource, bindingContext, options, templateDocument) {\n templateDocument = templateDocument || document;\n options = options || {};\n ensureHasReferencedJQueryTemplates();\n\n // Ensure we have stored a precompiled version of this template (don't want to reparse on every render)\n var precompiled = templateSource['data']('precompiled');\n if (!precompiled) {\n var templateText = templateSource['text']() || \"\";\n // Wrap in \"with($whatever.koBindingContext) { ... }\"\n templateText = \"{{ko_with $item.koBindingContext}}\" + templateText + \"{{/ko_with}}\";\n\n precompiled = jQueryInstance['template'](null, templateText);\n templateSource['data']('precompiled', precompiled);\n }\n\n var data = [bindingContext['$data']]; // Prewrap the data in an array to stop jquery.tmpl from trying to unwrap any arrays\n var jQueryTemplateOptions = jQueryInstance['extend']({ 'koBindingContext': bindingContext }, options['templateOptions']);\n\n var resultNodes = executeTemplate(precompiled, data, jQueryTemplateOptions);\n resultNodes['appendTo'](templateDocument.createElement(\"div\")); // Using \"appendTo\" forces jQuery/jQuery.tmpl to perform necessary cleanup work\n\n jQueryInstance['fragments'] = {}; // Clear jQuery's fragment cache to avoid a memory leak after a large number of template renders\n return resultNodes;\n };\n\n this['createJavaScriptEvaluatorBlock'] = function(script) {\n return \"{{ko_code ((function() { return \" + script + \" })()) }}\";\n };\n\n this['addTemplate'] = function(templateName, templateMarkup) {\n document.write(\"<script type='text/html' id='\" + templateName + \"'>\" + templateMarkup + \"<\" + \"/script>\");\n };\n\n if (jQueryTmplVersion > 0) {\n jQueryInstance['tmpl']['tag']['ko_code'] = {\n open: \"__.push($1 || '');\"\n };\n jQueryInstance['tmpl']['tag']['ko_with'] = {\n open: \"with($1) {\",\n close: \"} \"\n };\n }\n };\n\n ko.jqueryTmplTemplateEngine.prototype = new ko.templateEngine();\n ko.jqueryTmplTemplateEngine.prototype.constructor = ko.jqueryTmplTemplateEngine;\n\n // Use this one by default *only if jquery.tmpl is referenced*\n var jqueryTmplTemplateEngineInstance = new ko.jqueryTmplTemplateEngine();\n if (jqueryTmplTemplateEngineInstance.jQueryTmplVersion > 0)\n ko.setTemplateEngine(jqueryTmplTemplateEngineInstance);\n\n ko.exportSymbol('jqueryTmplTemplateEngine', ko.jqueryTmplTemplateEngine);\n })();\n }));\n }());\n})();\n","knockoutjs/knockout-repeat.js":"// REPEAT binding for Knockout http://knockoutjs.com/\n// (c) Michael Best\n// License: MIT (http://www.opensource.org/licenses/mit-license.php)\n// Version 2.1.0\n\n(function(factory) {\n if (typeof define === 'function' && define.amd) {\n // [1] AMD anonymous module\n define(['knockout'], factory);\n } else if (typeof exports === 'object') {\n // [2] commonJS\n factory(require('knockout'));\n } else {\n // [3] No module loader (plain <script> tag) - put directly in global namespace\n factory(window.ko);\n }\n})(function(ko) {\n\nif (!ko.virtualElements)\n throw Error('Repeat requires at least Knockout 2.1');\n\nvar ko_bindingFlags = ko.bindingFlags || {};\nvar ko_unwrap = ko.utils.unwrapObservable;\n\nvar koProtoName = '__ko_proto__';\n\nif (ko.version >= \"3.0.0\") {\n // In Knockout 3.0.0, use the node preprocessor to replace a node with a repeat binding with a virtual element\n var provider = ko.bindingProvider.instance, previousPreprocessFn = provider.preprocessNode;\n provider.preprocessNode = function(node) {\n var newNodes, nodeBinding;\n if (!previousPreprocessFn || !(newNodes = previousPreprocessFn.call(this, node))) {\n if (node.nodeType === 1 && (nodeBinding = node.getAttribute('data-bind'))) {\n if (/^\\s*repeat\\s*:/.test(nodeBinding)) {\n var leadingComment = node.ownerDocument.createComment('ko ' + nodeBinding),\n trailingComment = node.ownerDocument.createComment('/ko');\n node.parentNode.insertBefore(leadingComment, node);\n node.parentNode.insertBefore(trailingComment, node.nextSibling);\n node.removeAttribute('data-bind');\n newNodes = [leadingComment, node, trailingComment];\n }\n }\n }\n return newNodes;\n };\n}\n\nko.virtualElements.allowedBindings.repeat = true;\nko.bindingHandlers.repeat = {\n flags: ko_bindingFlags.contentBind | ko_bindingFlags.canUseVirtual,\n init: function(element, valueAccessor, allBindingsAccessor, xxx, bindingContext) {\n\n // Read and set fixed options--these options cannot be changed\n var repeatParam = ko_unwrap(valueAccessor());\n if (repeatParam && typeof repeatParam == 'object' && !('length' in repeatParam)) {\n var repeatIndex = repeatParam.index,\n repeatData = repeatParam.item,\n repeatStep = repeatParam.step,\n repeatReversed = repeatParam.reverse,\n repeatBind = repeatParam.bind,\n repeatInit = repeatParam.init,\n repeatUpdate = repeatParam.update;\n }\n // Set default values for options that need it\n repeatIndex = repeatIndex || '$index';\n repeatData = repeatData || ko.bindingHandlers.repeat.itemName || '$item';\n repeatStep = repeatStep || 1;\n repeatReversed = repeatReversed || false;\n\n var parent = element.parentNode, placeholder;\n if (element.nodeType == 8) { // virtual element\n // Extract the \"children\" and find the single element node\n var childNodes = ko.utils.arrayFilter(ko.virtualElements.childNodes(element), function(node) { return node.nodeType == 1;});\n if (childNodes.length !== 1) {\n throw Error(\"Repeat binding requires a single element to repeat\");\n }\n ko.virtualElements.emptyNode(element);\n\n // The placeholder is the closing comment normally, or the opening comment if reversed\n placeholder = repeatReversed ? element : element.nextSibling;\n // The element to repeat is the contained element\n element = childNodes[0];\n } else { // regular element\n // First clean the element node and remove node's binding\n var origBindString = element.getAttribute('data-bind');\n ko.cleanNode(element);\n element.removeAttribute('data-bind');\n\n // Original element is no longer needed: delete it and create a placeholder comment\n placeholder = element.ownerDocument.createComment('ko_repeatplaceholder ' + origBindString);\n parent.replaceChild(placeholder, element);\n }\n\n // extract and remove a data-repeat-bind attribute, if present\n if (!repeatBind) {\n repeatBind = element.getAttribute('data-repeat-bind');\n if (repeatBind) {\n element.removeAttribute('data-repeat-bind');\n }\n }\n\n // Make a copy of the element node to be copied for each repetition\n var cleanNode = element.cloneNode(true);\n if (typeof repeatBind == \"string\") {\n cleanNode.setAttribute('data-bind', repeatBind);\n repeatBind = null;\n }\n\n // Set up persistent data\n var lastRepeatCount = 0,\n notificationObservable = ko.observable(),\n repeatArray, arrayObservable;\n\n if (repeatInit) {\n repeatInit(parent);\n }\n\n var subscribable = ko.computed(function() {\n function makeArrayItemAccessor(index) {\n var f = function(newValue) {\n var item = repeatArray[index];\n // Reading the value of the item\n if (!arguments.length) {\n notificationObservable(); // for dependency tracking\n return ko_unwrap(item);\n }\n // Writing a value to the item\n if (ko.isObservable(item)) {\n item(newValue);\n } else if (arrayObservable && arrayObservable.splice) {\n arrayObservable.splice(index, 1, newValue);\n } else {\n repeatArray[index] = newValue;\n }\n return this;\n };\n // Pretend that our accessor function is an observable\n f[koProtoName] = ko.observable;\n return f;\n }\n\n function makeBinding(item, index, context) {\n return repeatArray\n ? function() { return repeatBind.call(bindingContext.$data, item, index, context); }\n : function() { return repeatBind.call(bindingContext.$data, index, context); }\n }\n\n // Read and set up variable options--these options can change and will update the binding\n var paramObservable = valueAccessor(), repeatParam = ko_unwrap(paramObservable), repeatCount = 0;\n if (repeatParam && typeof repeatParam == 'object') {\n if ('length' in repeatParam) {\n repeatArray = repeatParam;\n repeatCount = repeatArray.length;\n } else {\n if ('foreach' in repeatParam) {\n repeatArray = ko_unwrap(paramObservable = repeatParam.foreach);\n if (repeatArray && typeof repeatArray == 'object' && 'length' in repeatArray) {\n repeatCount = repeatArray.length || 0;\n } else {\n repeatCount = repeatArray || 0;\n repeatArray = null;\n }\n }\n // If a count value is provided (>0), always output that number of items\n if ('count' in repeatParam)\n repeatCount = ko_unwrap(repeatParam.count) || repeatCount;\n // If a limit is provided, don't output more than the limit\n if ('limit' in repeatParam)\n repeatCount = Math.min(repeatCount, ko_unwrap(repeatParam.limit)) || repeatCount;\n }\n arrayObservable = repeatArray && ko.isObservable(paramObservable) ? paramObservable : null;\n } else {\n repeatCount = repeatParam || 0;\n }\n\n // Remove nodes from end if array is shorter\n for (; lastRepeatCount > repeatCount; lastRepeatCount-=repeatStep) {\n ko.removeNode(repeatReversed ? placeholder.nextSibling : placeholder.previousSibling);\n }\n\n // Notify existing nodes of change\n notificationObservable.notifySubscribers();\n\n // Add nodes to end if array is longer (also initially populates nodes)\n for (; lastRepeatCount < repeatCount; lastRepeatCount+=repeatStep) {\n // Clone node and add to document\n var newNode = cleanNode.cloneNode(true);\n parent.insertBefore(newNode, repeatReversed ? placeholder.nextSibling : placeholder);\n newNode.setAttribute('data-repeat-index', lastRepeatCount);\n\n // Apply bindings to inserted node\n if (repeatArray && repeatData == '$data') {\n var newContext = bindingContext.createChildContext(makeArrayItemAccessor(lastRepeatCount));\n } else {\n var newContext = bindingContext.extend();\n if (repeatArray)\n newContext[repeatData] = makeArrayItemAccessor(lastRepeatCount);\n }\n newContext[repeatIndex] = lastRepeatCount;\n if (repeatBind) {\n var result = ko.applyBindingsToNode(newNode, makeBinding(newContext[repeatData], lastRepeatCount, newContext), newContext, true),\n shouldBindDescendants = result && result.shouldBindDescendants;\n }\n if (!repeatBind || (result && shouldBindDescendants !== false)) {\n ko.applyBindings(newContext, newNode);\n }\n }\n if (repeatUpdate) {\n repeatUpdate(parent);\n }\n }, null, {disposeWhenNodeIsRemoved: placeholder});\n\n return { controlsDescendantBindings: true, subscribable: subscribable };\n }\n};\n});","knockoutjs/knockout-fast-foreach.js":"/*!\n Knockout Fast Foreach v0.4.1 (2015-07-17T14:06:15.974Z)\n By: Brian M Hunt (C) 2015\n License: MIT\n\n Adds `fastForEach` to `ko.bindingHandlers`.\n*/\n(function (root, factory) {\n if (typeof define === 'function' && define.amd) {\n define(['knockout'], factory);\n } else if (typeof exports === 'object') {\n module.exports = factory(require('knockout'));\n } else {\n root.KnockoutFastForeach = factory(root.ko);\n }\n}(this, function (ko) {\n \"use strict\";\n// index.js\n// --------\n// Fast For Each\n//\n// Employing sound techniques to make a faster Knockout foreach binding.\n// --------\n\n// Utilities\n\n// from https://github.com/jonschlinkert/is-plain-object\nfunction isPlainObject(o) {\n return !!o && typeof o === 'object' && o.constructor === Object;\n}\n\n// From knockout/src/virtualElements.js\nvar commentNodesHaveTextProperty = document && document.createComment(\"test\").text === \"<!--test-->\";\nvar startCommentRegex = commentNodesHaveTextProperty ? /^<!--\\s*ko(?:\\s+([\\s\\S]+))?\\s*-->$/ : /^\\s*ko(?:\\s+([\\s\\S]+))?\\s*$/;\nvar supportsDocumentFragment = document && typeof document.createDocumentFragment === \"function\";\nfunction isVirtualNode(node) {\n return (node.nodeType === 8) && startCommentRegex.test(commentNodesHaveTextProperty ? node.text : node.nodeValue);\n}\n\n\n// Get a copy of the (possibly virtual) child nodes of the given element,\n// put them into a container, then empty the given node.\nfunction makeTemplateNode(sourceNode) {\n var container = document.createElement(\"div\");\n var parentNode;\n if (sourceNode.content) {\n // For e.g. <template> tags\n parentNode = sourceNode.content;\n } else if (sourceNode.tagName === 'SCRIPT') {\n parentNode = document.createElement(\"div\");\n parentNode.innerHTML = sourceNode.text;\n } else {\n // Anything else e.g. <div>\n parentNode = sourceNode;\n }\n ko.utils.arrayForEach(ko.virtualElements.childNodes(parentNode), function (child) {\n // FIXME - This cloneNode could be expensive; we may prefer to iterate over the\n // parentNode children in reverse (so as not to foul the indexes as childNodes are\n // removed from parentNode when inserted into the container)\n if (child) {\n container.insertBefore(child.cloneNode(true), null);\n }\n });\n return container;\n}\n\nfunction insertAllAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode) {\n var frag, len, i;\n // poor man's node and array check, should be enough for this\n if (typeof nodeOrNodeArrayToInsert.nodeType !== \"undefined\" && typeof nodeOrNodeArrayToInsert.length === \"undefined\") {\n throw new Error(\"Expected a single node or a node array\");\n }\n\n if (typeof nodeOrNodeArrayToInsert.nodeType !== \"undefined\") {\n ko.virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert, insertAfterNode);\n return;\n }\n\n if (nodeOrNodeArrayToInsert.length === 1) {\n ko.virtualElements.insertAfter(containerNode, nodeOrNodeArrayToInsert[0], insertAfterNode);\n return;\n }\n\n if (supportsDocumentFragment) {\n frag = document.createDocumentFragment();\n\n for (i = 0, len = nodeOrNodeArrayToInsert.length; i !== len; ++i) {\n frag.appendChild(nodeOrNodeArrayToInsert[i]);\n }\n ko.virtualElements.insertAfter(containerNode, frag, insertAfterNode);\n } else {\n // Nodes are inserted in reverse order - pushed down immediately after\n // the last node for the previous item or as the first node of element.\n for (i = nodeOrNodeArrayToInsert.length - 1; i >= 0; --i) {\n var child = nodeOrNodeArrayToInsert[i];\n if (!child) {\n return;\n }\n ko.virtualElements.insertAfter(containerNode, child, insertAfterNode);\n }\n }\n}\n\n// Mimic a KO change item 'add'\nfunction valueToChangeAddItem(value, index) {\n return {\n status: 'added',\n value: value,\n index: index\n };\n}\n\nfunction isAdditionAdjacentToLast(changeIndex, arrayChanges) {\n return changeIndex > 0 &&\n changeIndex < arrayChanges.length &&\n arrayChanges[changeIndex].status === \"added\" &&\n arrayChanges[changeIndex - 1].status === \"added\" &&\n arrayChanges[changeIndex - 1].index === arrayChanges[changeIndex].index - 1;\n}\n\nfunction FastForEach(spec) {\n this.element = spec.element;\n this.container = isVirtualNode(this.element) ?\n this.element.parentNode : this.element;\n this.$context = spec.$context;\n this.data = spec.data;\n this.as = spec.as;\n this.noContext = spec.noContext;\n this.templateNode = makeTemplateNode(\n spec.name ? document.getElementById(spec.name).cloneNode(true) : spec.element\n );\n this.afterQueueFlush = spec.afterQueueFlush;\n this.beforeQueueFlush = spec.beforeQueueFlush;\n this.changeQueue = [];\n this.lastNodesList = [];\n this.indexesToDelete = [];\n this.rendering_queued = false;\n\n // Remove existing content.\n ko.virtualElements.emptyNode(this.element);\n\n // Prime content\n var primeData = ko.unwrap(this.data);\n if (primeData.map) {\n this.onArrayChange(primeData.map(valueToChangeAddItem));\n }\n\n // Watch for changes\n if (ko.isObservable(this.data)) {\n if (!this.data.indexOf) {\n // Make sure the observable is trackable.\n this.data = this.data.extend({trackArrayChanges: true});\n }\n this.changeSubs = this.data.subscribe(this.onArrayChange, this, 'arrayChange');\n }\n}\n\n\nFastForEach.animateFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||\n window.mozRequestAnimationFrame || window.msRequestAnimationFrame ||\n function(cb) { return window.setTimeout(cb, 1000 / 60); };\n\n\nFastForEach.prototype.dispose = function () {\n if (this.changeSubs) {\n this.changeSubs.dispose();\n }\n};\n\n\n// If the array changes we register the change.\nFastForEach.prototype.onArrayChange = function (changeSet) {\n var self = this;\n var changeMap = {\n added: [],\n deleted: []\n };\n for (var i = 0, len = changeSet.length; i < len; i++) {\n // the change is appended to a last change info object when both are 'added' and have indexes next to each other\n // here I presume that ko is sending changes in monotonic order (in index variable) which happens to be true, tested with push and splice with multiple pushed values\n if (isAdditionAdjacentToLast(i, changeSet)) {\n var batchValues = changeMap.added[changeMap.added.length - 1].values;\n if (!batchValues) {\n // transform the last addition into a batch addition object\n var lastAddition = changeMap.added.pop();\n var batchAddition = {\n isBatch: true,\n status: 'added',\n index: lastAddition.index,\n values: [lastAddition.value]\n };\n batchValues = batchAddition.values;\n changeMap.added.push(batchAddition);\n }\n batchValues.push(changeSet[i].value);\n } else {\n changeMap[changeSet[i].status].push(changeSet[i]);\n }\n }\n if (changeMap.deleted.length > 0) {\n this.changeQueue.push.apply(this.changeQueue, changeMap.deleted);\n this.changeQueue.push({status: 'clearDeletedIndexes'});\n }\n this.changeQueue.push.apply(this.changeQueue, changeMap.added);\n // Once a change is registered, the ticking count-down starts for the processQueue.\n if (this.changeQueue.length > 0 && !this.rendering_queued) {\n this.rendering_queued = true;\n FastForEach.animateFrame.call(window, function () { self.processQueue(); });\n }\n};\n\n\n// Reflect all the changes in the queue in the DOM, then wipe the queue.\nFastForEach.prototype.processQueue = function () {\n var self = this;\n\n // Callback so folks can do things before the queue flush.\n if (typeof this.beforeQueueFlush === 'function') {\n this.beforeQueueFlush(this.changeQueue);\n }\n\n ko.utils.arrayForEach(this.changeQueue, function (changeItem) {\n // console.log(self.data(), \"CI\", JSON.stringify(changeItem, null, 2), JSON.stringify($(self.element).text()))\n self[changeItem.status](changeItem);\n // console.log(\" ==> \", JSON.stringify($(self.element).text()))\n });\n this.rendering_queued = false;\n // Callback so folks can do things.\n if (typeof this.afterQueueFlush === 'function') {\n this.afterQueueFlush(this.changeQueue);\n }\n this.changeQueue = [];\n};\n\n\n// Process a changeItem with {status: 'added', ...}\nFastForEach.prototype.added = function (changeItem) {\n var index = changeItem.index;\n var valuesToAdd = changeItem.isBatch ? changeItem.values : [changeItem.value];\n var referenceElement = this.lastNodesList[index - 1] || null;\n // gather all childnodes for a possible batch insertion\n var allChildNodes = [];\n\n for (var i = 0, len = valuesToAdd.length; i < len; ++i) {\n var templateClone = this.templateNode.cloneNode(true);\n var childContext;\n\n if (this.noContext) {\n childContext = this.$context.extend({\n '$item': valuesToAdd[i]\n });\n } else {\n childContext = this.$context.createChildContext(valuesToAdd[i], this.as || null);\n }\n\n // apply bindings first, and then process child nodes, because bindings can add childnodes\n ko.applyBindingsToDescendants(childContext, templateClone);\n\n var childNodes = ko.virtualElements.childNodes(templateClone);\n // Note discussion at https://github.com/angular/angular.js/issues/7851\n allChildNodes.push.apply(allChildNodes, Array.prototype.slice.call(childNodes));\n this.lastNodesList.splice(index + i, 0, childNodes[childNodes.length - 1]);\n }\n\n insertAllAfter(this.element, allChildNodes, referenceElement);\n};\n\n\n// Process a changeItem with {status: 'deleted', ...}\nFastForEach.prototype.deleted = function (changeItem) {\n var index = changeItem.index;\n var ptr = this.lastNodesList[index],\n // We use this.element because that will be the last previous node\n // for virtual element lists.\n lastNode = this.lastNodesList[index - 1] || this.element;\n do {\n ptr = ptr.previousSibling;\n ko.removeNode((ptr && ptr.nextSibling) || ko.virtualElements.firstChild(this.element));\n } while (ptr && ptr !== lastNode);\n // The \"last node\" in the DOM from which we begin our delets of the next adjacent node is\n // now the sibling that preceded the first node of this item.\n this.lastNodesList[index] = this.lastNodesList[index - 1];\n this.indexesToDelete.push(index);\n};\n\n\n// We batch our deletion of item indexes in our parallel array.\n// See brianmhunt/knockout-fast-foreach#6/#8\nFastForEach.prototype.clearDeletedIndexes = function () {\n // We iterate in reverse on the presumption (following the unit tests) that KO's diff engine\n // processes diffs (esp. deletes) monotonically ascending i.e. from index 0 -> N.\n for (var i = this.indexesToDelete.length - 1; i >= 0; --i) {\n this.lastNodesList.splice(this.indexesToDelete[i], 1);\n }\n this.indexesToDelete = [];\n};\n\n\nko.bindingHandlers.fastForEach = {\n // Valid valueAccessors:\n // []\n // ko.observable([])\n // ko.observableArray([])\n // ko.computed\n // {data: array, name: string, as: string}\n init: function init(element, valueAccessor, bindings, vm, context) {\n var value = valueAccessor(),\n ffe;\n if (isPlainObject(value)) {\n value.element = value.element || element;\n value.$context = context;\n ffe = new FastForEach(value);\n } else {\n ffe = new FastForEach({\n element: element,\n data: ko.unwrap(context.$rawData) === value ? context.$rawData : value,\n $context: context\n });\n }\n ko.utils.domNodeDisposal.addDisposeCallback(element, function () {\n ffe.dispose();\n });\n return {controlsDescendantBindings: true};\n },\n\n // Export for testing, debugging, and overloading.\n FastForEach: FastForEach\n};\n\nko.virtualElements.allowedBindings.fastForEach = true;\n}));","Magento_Catalog/js/price-utils.js":"/**\n * Copyright \u00a9 Magento, Inc. All rights reserved.\n * See COPYING.txt for license details.\n */\n\n/**\n * @api\n */\ndefine([\n 'jquery',\n 'underscore'\n], function ($, _) {\n 'use strict';\n\n var globalPriceFormat = {\n requiredPrecision: 2,\n integerRequired: 1,\n decimalSymbol: ',',\n groupSymbol: ',',\n groupLength: ','\n };\n\n /**\n * Repeats {string} {times} times\n * @param {String} string\n * @param {Number} times\n * @return {String}\n */\n function stringPad(string, times) {\n return (new Array(times + 1)).join(string);\n }\n\n /**\n * Formatter for price amount\n * @param {Number} amount\n * @param {Object} format\n * @param {Boolean} isShowSign\n * @return {String} Formatted value\n */\n function formatPrice(amount, format, isShowSign) {\n var s = '',\n precision, integerRequired, decimalSymbol, groupSymbol, groupLength, pattern, i, pad, j, re, r, am;\n\n format = _.extend(globalPriceFormat, format);\n\n // copied from price-option.js | Could be refactored with varien/js.js\n\n precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;\n integerRequired = isNaN(format.integerRequired = Math.abs(format.integerRequired)) ? 1 : format.integerRequired;\n decimalSymbol = format.decimalSymbol === undefined ? ',' : format.decimalSymbol;\n groupSymbol = format.groupSymbol === undefined ? '.' : format.groupSymbol;\n groupLength = format.groupLength === undefined ? 3 : format.groupLength;\n pattern = format.pattern || '%s';\n\n if (isShowSign === undefined || isShowSign === true) {\n s = amount < 0 ? '-' : isShowSign ? '+' : '';\n } else if (isShowSign === false) {\n s = '';\n }\n pattern = pattern.indexOf('{sign}') < 0 ? s + pattern : pattern.replace('{sign}', s);\n\n // we're avoiding the usage of to fixed, and using round instead with the e representation to address\n // numbers like 1.005 = 1.01. Using ToFixed to only provide trailing zeroes in case we have a whole number\n i = parseInt(\n amount = Number(Math.round(Math.abs(+amount || 0) + 'e+' + precision) + ('e-' + precision)),\n 10\n ) + '';\n pad = i.length < integerRequired ? integerRequired - i.length : 0;\n\n i = stringPad('0', pad) + i;\n\n j = i.length > groupLength ? i.length % groupLength : 0;\n re = new RegExp('(\\\\d{' + groupLength + '})(?=\\\\d)', 'g');\n\n // replace(/-/, 0) is only for fixing Safari bug which appears\n // when Math.abs(0).toFixed() executed on '0' number.\n // Result is '0.-0' :(\n\n am = Number(Math.round(Math.abs(amount - i) + 'e+' + precision) + ('e-' + precision));\n r = (j ? i.substr(0, j) + groupSymbol : '') +\n i.substr(j).replace(re, '$1' + groupSymbol) +\n (precision ? decimalSymbol + am.toFixed(precision).replace(/-/, 0).slice(2) : '');\n\n return pattern.replace('%s', r).replace(/^\\s\\s*/, '').replace(/\\s\\s*$/, '');\n }\n\n /**\n * Deep clone of Object. Doesn't support functions\n * @param {Object} obj\n * @return {Object}\n */\n function objectDeepClone(obj) {\n return JSON.parse(JSON.stringify(obj));\n }\n\n /**\n * Helper to find ID in name attribute\n * @param {jQuery} element\n * @returns {undefined|String}\n */\n function findOptionId(element) {\n var re, id, name;\n\n if (!element) {\n return id;\n }\n name = $(element).attr('name');\n\n if (name.indexOf('[') !== -1) {\n re = /\\[([^\\]]+)?\\]/;\n } else {\n re = /_([^\\]]+)?_/; // just to support file-type-option\n }\n id = re.exec(name) && re.exec(name)[1];\n\n if (id) {\n return id;\n }\n }\n\n return {\n formatPrice: formatPrice,\n deepClone: objectDeepClone,\n strPad: stringPad,\n findOptionId: findOptionId\n };\n});\n","Magento_PageCache/js/form-key-provider.js":"/**\n * Copyright \u00a9 Magento, Inc. All rights reserved.\n * See COPYING.txt for license details.\n */\ndefine(function () {\n 'use strict';\n\n return function () {\n var formKey,\n inputElements,\n inputSelector = 'input[name=\"form_key\"]';\n\n /**\n * Set form_key cookie\n * @private\n */\n function setFormKeyCookie(value) {\n var expires,\n secure,\n date = new Date(),\n cookiesConfig = window.cookiesConfig || {},\n isSecure = !!cookiesConfig.secure,\n samesite = cookiesConfig.samesite || 'lax';\n\n date.setTime(date.getTime() + 86400000);\n expires = '; expires=' + date.toUTCString();\n secure = isSecure ? '; secure' : '';\n samesite = '; samesite=' + samesite;\n\n document.cookie = 'form_key=' + (value || '') + expires + secure + '; path=/' + samesite;\n }\n\n /**\n * Retrieves form key from cookie\n * @private\n */\n function getFormKeyCookie() {\n var cookie,\n i,\n nameEQ = 'form_key=',\n cookieArr = document.cookie.split(';');\n\n for (i = 0; i < cookieArr.length; i++) {\n cookie = cookieArr[i];\n\n while (cookie.charAt(0) === ' ') {\n cookie = cookie.substring(1, cookie.length);\n }\n\n if (cookie.indexOf(nameEQ) === 0) {\n return cookie.substring(nameEQ.length, cookie.length);\n }\n }\n\n return null;\n }\n\n /**\n * Generate form key string\n * @private\n */\n function generateFormKeyString() {\n var result = '',\n length = 16,\n chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';\n\n while (length--) {\n result += chars[Math.round(Math.random() * (chars.length - 1))];\n }\n\n return result;\n }\n\n /**\n * Init form_key inputs with value\n * @private\n */\n function initFormKey() {\n formKey = getFormKeyCookie();\n\n if (!formKey) {\n formKey = generateFormKeyString();\n setFormKeyCookie(formKey);\n }\n inputElements = document.querySelectorAll(inputSelector);\n\n if (inputElements.length) {\n Array.prototype.forEach.call(inputElements, function (element) {\n element.setAttribute('value', formKey);\n });\n }\n }\n\n initFormKey();\n };\n});\n","jquery/jquery.metadata.js":"/*\n * Metadata - jQuery plugin for parsing metadata from elements\n *\n * Copyright (c) 2006 John Resig, Yehuda Katz, J\u00ef\u00bf\u00bd\u00c3\u00b6rn Zaefferer, Paul McLanahan\n *\n * Dual licensed under the MIT and GPL licenses:\n * http://www.opensource.org/licenses/mit-license.php\n * http://www.gnu.org/licenses/gpl.html\n *\n * Revision: $Id: jquery.metadata.js 3640 2007-10-11 18:34:38Z pmclanahan $\n *\n */\n\n/**\n * Sets the type of metadata to use. Metadata is encoded in JSON, and each property\n * in the JSON will become a property of the element itself.\n *\n * There are four supported types of metadata storage:\n *\n * attr: Inside an attribute. The name parameter indicates *which* attribute.\n *\n * class: Inside the class attribute, wrapped in curly braces: { }\n *\n * elem: Inside a child element (e.g. a script tag). The\n * name parameter indicates *which* element.\n * html5: Values are stored in data-* attributes.\n *\n * The metadata for an element is loaded the first time the element is accessed via jQuery.\n *\n * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements\n * matched by expr, then redefine the metadata type and run another $(expr) for other elements.\n *\n * @name $.metadata.setType\n *\n * @example <p id=\"one\" class=\"some_class {item_id: 1, item_label: 'Label'}\">This is a p</p>\n * @before $.metadata.setType(\"class\")\n * @after $(\"#one\").metadata().item_id == 1; $(\"#one\").metadata().item_label == \"Label\"\n * @desc Reads metadata from the class attribute\n *\n * @example <p id=\"one\" class=\"some_class\" data=\"{item_id: 1, item_label: 'Label'}\">This is a p</p>\n * @before $.metadata.setType(\"attr\", \"data\")\n * @after $(\"#one\").metadata().item_id == 1; $(\"#one\").metadata().item_label == \"Label\"\n * @desc Reads metadata from a \"data\" attribute\n *\n * @example <p id=\"one\" class=\"some_class\"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>\n * @before $.metadata.setType(\"elem\", \"script\")\n * @after $(\"#one\").metadata().item_id == 1; $(\"#one\").metadata().item_label == \"Label\"\n * @desc Reads metadata from a nested script element\n *\n * @example <p id=\"one\" class=\"some_class\" data-item_id=\"1\" data-item_label=\"Label\">This is a p</p>\n * @before $.metadata.setType(\"html5\")\n * @after $(\"#one\").metadata().item_id == 1; $(\"#one\").metadata().item_label == \"Label\"\n * @desc Reads metadata from a series of data-* attributes\n *\n * @param String type The encoding type\n * @param String name The name of the attribute to be used to get metadata (optional)\n * @cat Plugins/Metadata\n * @descr Sets the type of encoding to be used when loading metadata for the first time\n * @type undefined\n * @see metadata()\n */\n(function (factory) {\n if (typeof define === 'function' && define.amd) {\n define([\"jquery\"], factory);\n } else {\n factory(jQuery);\n }\n}(function ($) {\n\n\n $.extend({\n metadata : {\n defaults : {\n type: 'class',\n name: 'metadata',\n cre: /({.*})/,\n single: 'metadata',\n meta:'validate'\n },\n setType: function( type, name ){\n this.defaults.type = type;\n this.defaults.name = name;\n },\n get: function( elem, opts ){\n var settings = $.extend({},this.defaults,opts);\n // check for empty string in single property\n if (!settings.single.length) {\n settings.single = 'metadata';\n }\n if (!settings.meta.length) {\n settings.meta = 'validate';\n }\n\n var data = $.data(elem, settings.single);\n // returned cached data if it already exists\n if ( data ) return data;\n\n data = \"{}\";\n\n var getData = function(data) {\n if(typeof data != \"string\") return data;\n\n if( data.indexOf('{') < 0 ) {\n data = eval(\"(\" + data + \")\");\n }\n }\n\n var getObject = function(data) {\n if(typeof data != \"string\") return data;\n\n data = eval(\"(\" + data + \")\");\n return data;\n }\n\n if ( settings.type == \"html5\" ) {\n var object = {};\n $( elem.attributes ).each(function() {\n var name = this.nodeName;\n if (name.indexOf('data-' + settings.meta) === 0) {\n name = name.replace(/^data-/, '');\n }\n else {\n return true;\n }\n object[name] = getObject(this.value);\n });\n } else {\n if ( settings.type == \"class\" ) {\n var m = settings.cre.exec( elem.className );\n if ( m )\n data = m[1];\n } else if ( settings.type == \"elem\" ) {\n if( !elem.getElementsByTagName ) return;\n var e = elem.getElementsByTagName(settings.name);\n if ( e.length )\n data = $.trim(e[0].innerHTML);\n } else if ( elem.getAttribute != undefined ) {\n var attr = elem.getAttribute( settings.name );\n if ( attr )\n data = attr;\n }\n object = getObject(data.indexOf(\"{\") < 0 ? \"{\" + data + \"}\" : data);\n }\n\n $.data( elem, settings.single, object );\n return object;\n }\n }\n });\n\n /**\n * Returns the metadata object for the first member of the jQuery object.\n *\n * @name metadata\n * @descr Returns element's metadata object\n * @param Object opts An object contianing settings to override the defaults\n * @type jQuery\n * @cat Plugins/Metadata\n */\n $.fn.metadata = function( opts ){\n return $.metadata.get( this[0], opts );\n };\n\n}));","jquery/jquery.validate.js":"/**\n * jQuery Validation Plugin @VERSION\n *\n * http://bassistance.de/jquery-plugins/jquery-plugin-validation/\n * http://docs.jquery.com/Plugins/Validation\n *\n * Copyright (c) 2012 J\u00f6rn Zaefferer\n *\n * Dual licensed under the MIT and GPL licenses:\n * http://www.opensource.org/licenses/mit-license.php\n * http://www.gnu.org/licenses/gpl.html\n */\n(function (factory) {\n if (typeof define === 'function' && define.amd) {\n define([\n \"jquery\",\n \"jquery/jquery.metadata\"\n ], factory);\n } else {\n factory(jQuery);\n }\n}(function (jQuery) {\n\n(function ($) {\n\n $.extend($.fn, {\n // http://docs.jquery.com/Plugins/Validation/validate\n validate: function (options) {\n\n // if nothing is selected, return nothing; can't chain anyway\n if (!this.length) {\n if (options && options.debug && window.console) {\n console.warn(\"nothing selected, can't validate, returning nothing\");\n }\n return;\n }\n\n // check if a validator for this form was already created\n var validator = $.data(this[0], 'validator');\n if (validator) {\n return validator;\n }\n\n // Add novalidate tag if HTML5.\n this.attr('novalidate', 'novalidate');\n\n validator = new $.validator(options, this[0]);\n $.data(this[0], 'validator', validator);\n\n if (validator.settings.onsubmit) {\n\n this.validateDelegate(\":submit\", \"click\", function (ev) {\n if (validator.settings.submitHandler) {\n validator.submitButton = ev.target;\n }\n // allow suppressing validation by adding a cancel class to the submit button\n if ($(ev.target).hasClass('cancel')) {\n validator.cancelSubmit = true;\n }\n });\n\n // validate the form on submit\n this.submit(function (event) {\n if (validator.settings.debug) {\n // prevent form submit to be able to see console output\n event.preventDefault();\n }\n function handle() {\n var hidden;\n if (validator.settings.submitHandler) {\n if (validator.submitButton) {\n // insert a hidden input as a replacement for the missing submit button\n hidden = $(\"<input type='hidden'/>\").attr(\"name\", validator.submitButton.name).val(validator.submitButton.value).appendTo(validator.currentForm);\n }\n validator.settings.submitHandler.call(validator, validator.currentForm, event);\n if (validator.submitButton) {\n // and clean up afterwards; thanks to no-block-scope, hidden can be referenced\n hidden.remove();\n }\n return false;\n }\n return true;\n }\n\n // prevent submit for invalid forms or custom submit handlers\n if (validator.cancelSubmit) {\n validator.cancelSubmit = false;\n return handle();\n }\n if (validator.form()) {\n if (validator.pendingRequest) {\n validator.formSubmitted = true;\n return false;\n }\n return handle();\n } else {\n validator.focusInvalid();\n return false;\n }\n });\n }\n\n return validator;\n },\n // http://docs.jquery.com/Plugins/Validation/valid\n valid: function () {\n if ($(this[0]).is('form')) {\n return this.validate().form();\n } else {\n var valid = true;\n var validator = $(this[0].form).validate();\n this.each(function () {\n valid &= validator.element(this);\n });\n return valid;\n }\n },\n // attributes: space seperated list of attributes to retrieve and remove\n removeAttrs: function (attributes) {\n var result = {},\n $element = this;\n $.each(attributes.split(/\\s/), function (index, value) {\n result[value] = $element.attr(value);\n $element.removeAttr(value);\n });\n return result;\n },\n // http://docs.jquery.com/Plugins/Validation/rules\n rules: function (command, argument) {\n var element = this[0];\n\n if (command) {\n var settings = $.data(element.form, 'validator').settings;\n var staticRules = settings.rules;\n var existingRules = $.validator.staticRules(element);\n switch (command) {\n case \"add\":\n $.extend(existingRules, $.validator.normalizeRule(argument));\n staticRules[element.name] = existingRules;\n if (argument.messages) {\n settings.messages[element.name] = $.extend(settings.messages[element.name], argument.messages);\n }\n break;\n case \"remove\":\n if (!argument) {\n delete staticRules[element.name];\n return existingRules;\n }\n var filtered = {};\n $.each(argument.split(/\\s/), function (index, method) {\n filtered[method] = existingRules[method];\n delete existingRules[method];\n });\n return filtered;\n }\n }\n\n var data = $.validator.normalizeRules(\n $.extend(\n {},\n $.validator.metadataRules(element),\n $.validator.classRules(element),\n $.validator.attributeRules(element),\n $.validator.staticRules(element)\n ), element);\n\n // make sure required is at front\n if (data.required) {\n var param = data.required;\n delete data.required;\n data = $.extend({required: param}, data);\n }\n\n return data;\n }\n });\n\n// Custom selectors\n $.extend($.expr[\":\"], {\n // http://docs.jquery.com/Plugins/Validation/blank\n blank: function (a) {\n return !$.trim(\"\" + a.value);\n },\n // http://docs.jquery.com/Plugins/Validation/filled\n filled: function (a) {\n return !!$.trim(\"\" + a.value);\n },\n // http://docs.jquery.com/Plugins/Validation/unchecked\n unchecked: function (a) {\n return !a.checked;\n }\n });\n\n// constructor for validator\n $.validator = function (options, form) {\n this.settings = $.extend(true, {}, $.validator.defaults, options);\n this.currentForm = form;\n this.init();\n };\n\n $.validator.format = function (source, params) {\n if (arguments.length === 1) {\n return function () {\n var args = $.makeArray(arguments);\n args.unshift(source);\n return $.validator.format.apply(this, args);\n };\n }\n if (arguments.length > 2 && params.constructor !== Array) {\n params = $.makeArray(arguments).slice(1);\n }\n if (params.constructor !== Array) {\n params = [ params ];\n }\n $.each(params, function (i, n) {\n source = source.replace(new RegExp(\"\\\\{\" + i + \"\\\\}\", \"g\"), n);\n });\n return source;\n };\n\n $.extend($.validator, {\n\n defaults: {\n messages: {},\n groups: {},\n rules: {},\n errorClass: \"error\",\n validClass: \"valid\",\n errorElement: \"label\",\n focusInvalid: true,\n errorContainer: $([]),\n errorLabelContainer: $([]),\n onsubmit: true,\n ignore: \":hidden\",\n ignoreTitle: false,\n onfocusin: function (element, event) {\n this.lastActive = element;\n\n // hide error label and remove error class on focus if enabled\n if (this.settings.focusCleanup && !this.blockFocusCleanup) {\n if (this.settings.unhighlight) {\n this.settings.unhighlight.call(this, element, this.settings.errorClass, this.settings.validClass);\n }\n this.addWrapper(this.errorsFor(element)).hide();\n }\n },\n onfocusout: function (element, event) {\n if (!this.checkable(element) && (element.name in this.submitted || !this.optional(element))) {\n this.element(element);\n }\n },\n onkeyup: function (element, event) {\n if (event.which == 9 && this.elementValue(element) === '') {\n return;\n } else if (element.name in this.submitted || element === this.lastActive) {\n this.element(element);\n }\n },\n onclick: function (element, event) {\n // click on selects, radiobuttons and checkboxes\n if (element.name in this.submitted) {\n this.element(element);\n }\n // or option elements, check parent select in that case\n else if (element.parentNode.name in this.submitted) {\n this.element(element.parentNode);\n }\n },\n highlight: function (element, errorClass, validClass) {\n if (element.type === 'radio') {\n this.findByName(element.name).addClass(errorClass).removeClass(validClass);\n } else {\n $(element).addClass(errorClass).removeClass(validClass);\n }\n },\n unhighlight: function (element, errorClass, validClass) {\n if (element.type === 'radio') {\n this.findByName(element.name).removeClass(errorClass).addClass(validClass);\n } else {\n $(element).removeClass(errorClass).addClass(validClass);\n }\n }\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/setDefaults\n setDefaults: function (settings) {\n $.extend($.validator.defaults, settings);\n },\n\n messages: {\n required: \"This field is required.\",\n remote: \"Please fix this field.\",\n email: \"Please enter a valid email address.\",\n url: \"Please enter a valid URL.\",\n date: \"Please enter a valid date.\",\n dateISO: \"Please enter a valid date (ISO).\",\n number: \"Please enter a valid number.\",\n digits: \"Please enter only digits.\",\n creditcard: \"Please enter a valid credit card number.\",\n equalTo: \"Please enter the same value again.\",\n maxlength: $.validator.format(\"Please enter no more than {0} characters.\"),\n minlength: $.validator.format(\"Please enter at least {0} characters.\"),\n rangelength: $.validator.format(\"Please enter a value between {0} and {1} characters long.\"),\n range: $.validator.format(\"Please enter a value between {0} and {1}.\"),\n max: $.validator.format(\"Please enter a value less than or equal to {0}.\"),\n min: $.validator.format(\"Please enter a value greater than or equal to {0}.\")\n },\n\n autoCreateRanges: false,\n\n prototype: {\n\n init: function () {\n this.labelContainer = $(this.settings.errorLabelContainer);\n this.errorContext = this.labelContainer.length && this.labelContainer || $(this.currentForm);\n this.containers = $(this.settings.errorContainer).add(this.settings.errorLabelContainer);\n this.submitted = {};\n this.valueCache = {};\n this.pendingRequest = 0;\n this.pending = {};\n this.invalid = {};\n this.reset();\n\n var groups = (this.groups = {});\n $.each(this.settings.groups, function (key, value) {\n $.each(value.split(/\\s/), function (index, name) {\n groups[name] = key;\n });\n });\n var rules = this.settings.rules;\n $.each(rules, function (key, value) {\n rules[key] = $.validator.normalizeRule(value);\n });\n\n function delegate(event) {\n var validator = $.data(this[0].form, \"validator\"),\n eventType = \"on\" + event.type.replace(/^validate/, \"\");\n if (validator.settings[eventType]) {\n validator.settings[eventType].call(validator, this[0], event);\n }\n }\n\n $(this.currentForm)\n .validateDelegate(\":text, [type='password'], [type='file'], select, textarea, \" +\n \"[type='number'], [type='search'], input.search, [type='tel'], [type='url'], \" +\n \"[type='email'], [type='datetime'], [type='date'], [type='month'], \" +\n \"[type='week'], [type='time'], [type='datetime-local'], \" +\n \"[type='range'], [type='color'] \",\n \"focusin focusout keyup\", delegate)\n .validateDelegate(\"[type='radio'], [type='checkbox'], select, option\", \"click\", delegate);\n\n if (this.settings.invalidHandler) {\n $(this.currentForm).bind(\"invalid-form.validate\", this.settings.invalidHandler);\n }\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/form\n form: function () {\n this.checkForm();\n $.extend(this.submitted, this.errorMap);\n this.invalid = $.extend({}, this.errorMap);\n if (!this.valid()) {\n $(this.currentForm).triggerHandler(\"invalid-form\", [this]);\n }\n this.showErrors();\n return this.valid();\n },\n\n checkForm: function () {\n this.prepareForm();\n for (var i = 0, elements = (this.currentElements = this.elements()); elements[i]; i++) {\n this.check(elements[i]);\n }\n return this.valid();\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/element\n element: function (element) {\n element = this.validationTargetFor(this.clean(element));\n this.lastElement = element;\n this.prepareElement(element);\n this.currentElements = $(element);\n var result = this.check(element) !== false;\n if (result) {\n delete this.invalid[element.name];\n } else {\n this.invalid[element.name] = true;\n }\n if (!this.numberOfInvalids()) {\n // Hide error containers on last error\n this.toHide = this.toHide.add(this.containers);\n }\n this.showErrors();\n return result;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/showErrors\n showErrors: function (errors) {\n if (errors) {\n // add items to error list and map\n $.extend(this.errorMap, errors);\n this.errorList = [];\n for (var name in errors) {\n this.errorList.push({\n message: errors[name],\n element: this.findByName(name)[0]\n });\n }\n // remove items from success list\n this.successList = $.grep(this.successList, function (element) {\n return !(element.name in errors);\n });\n }\n if (this.settings.showErrors) {\n this.settings.showErrors.call(this, this.errorMap, this.errorList);\n } else {\n this.defaultShowErrors();\n }\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/resetForm\n resetForm: function () {\n if ($.fn.resetForm) {\n $(this.currentForm).resetForm();\n }\n this.submitted = {};\n this.lastElement = null;\n this.prepareForm();\n this.hideErrors();\n this.elements().removeClass(this.settings.errorClass).removeData(\"previousValue\");\n },\n\n numberOfInvalids: function () {\n return this.objectLength(this.invalid);\n },\n\n objectLength: function (obj) {\n var count = 0;\n for (var i in obj) {\n count++;\n }\n return count;\n },\n\n hideErrors: function () {\n this.addWrapper(this.toHide).hide();\n },\n\n valid: function () {\n return this.size() === 0;\n },\n\n size: function () {\n return this.errorList.length;\n },\n\n focusInvalid: function () {\n if (this.settings.focusInvalid) {\n try {\n $(this.findLastActive() || this.errorList.length && this.errorList[0].element || [])\n .filter(\":visible\")\n .focus()\n // manually trigger focusin event; without it, focusin handler isn't called, findLastActive won't have anything to find\n .trigger(\"focusin\");\n } catch (e) {\n // ignore IE throwing errors when focusing hidden elements\n }\n }\n },\n\n findLastActive: function () {\n var lastActive = this.lastActive;\n return lastActive && $.grep(this.errorList,function (n) {\n return n.element.name === lastActive.name;\n }).length === 1 && lastActive;\n },\n\n elements: function () {\n var validator = this,\n rulesCache = {};\n\n // select all valid inputs inside the form (no submit or reset buttons)\n return $(this.currentForm)\n .find(\"input, select, textarea\")\n .not(\":submit, :reset, :image, [disabled]\")\n .not(this.settings.ignore)\n .filter(function () {\n if (!this.name && validator.settings.debug && window.console) {\n console.error(\"%o has no name assigned\", this);\n }\n\n // select only the first element for each name, and only those with rules specified\n if (this.name in rulesCache || !validator.objectLength($(this).rules())) {\n return false;\n }\n\n rulesCache[this.name] = true;\n return true;\n });\n },\n\n clean: function (selector) {\n return $(selector)[0];\n },\n\n errors: function () {\n var errorClass = this.settings.errorClass.replace(' ', '.');\n return $(this.settings.errorElement + \".\" + errorClass, this.errorContext);\n },\n\n reset: function () {\n this.successList = [];\n this.errorList = [];\n this.errorMap = {};\n this.toShow = $([]);\n this.toHide = $([]);\n this.currentElements = $([]);\n },\n\n prepareForm: function () {\n this.reset();\n this.toHide = this.errors().add(this.containers);\n },\n\n prepareElement: function (element) {\n this.reset();\n this.toHide = this.errorsFor(element);\n },\n\n elementValue: function (element) {\n var type = $(element).attr('type'),\n val = $(element).val();\n\n if (type === 'radio' || type === 'checkbox') {\n return $('input[name=\"' + $(element).attr('name') + '\"]:checked').val();\n }\n\n if (typeof val === 'string') {\n return val.replace(/\\r/g, \"\");\n }\n return val;\n },\n\n check: function (element) {\n element = this.validationTargetFor(this.clean(element));\n\n var rules = $(element).rules();\n var dependencyMismatch = false;\n var val = this.elementValue(element);\n var result;\n\n for (var method in rules) {\n var rule = { method: method, parameters: rules[method] };\n try {\n\n result = $.validator.methods[method].call(this, val, element, rule.parameters);\n\n // if a method indicates that the field is optional and therefore valid,\n // don't mark it as valid when there are no other rules\n if (result === \"dependency-mismatch\") {\n dependencyMismatch = true;\n continue;\n }\n dependencyMismatch = false;\n\n if (result === \"pending\") {\n this.toHide = this.toHide.not(this.errorsFor(element));\n return;\n }\n\n if (!result) {\n this.formatAndAdd(element, rule);\n return false;\n }\n } catch (e) {\n if (this.settings.debug && window.console) {\n console.log(\"exception occurred when checking element \" + element.id + \", check the '\" + rule.method + \"' method\", e);\n }\n throw e;\n }\n }\n if (dependencyMismatch) {\n return;\n }\n if (this.objectLength(rules)) {\n this.successList.push(element);\n }\n return true;\n },\n\n // return the custom message for the given element and validation method\n // specified in the element's \"messages\" metadata\n customMetaMessage: function (element, method) {\n if (!$.metadata) {\n return;\n }\n var meta = this.settings.meta ? $(element).metadata()[this.settings.meta] : $(element).metadata();\n return meta && meta.messages && meta.messages[method];\n },\n\n // return the custom message for the given element and validation method\n // specified in the element's HTML5 data attribute\n customDataMessage: function (element, method) {\n return $(element).data('msg-' + method.toLowerCase()) || (element.attributes && $(element).attr('data-msg-' + method.toLowerCase()));\n },\n\n // return the custom message for the given element name and validation method\n customMessage: function (name, method) {\n var m = this.settings.messages[name];\n return m && (m.constructor === String ? m : m[method]);\n },\n\n // return the first defined argument, allowing empty strings\n findDefined: function () {\n for (var i = 0; i < arguments.length; i++) {\n if (arguments[i] !== undefined) {\n return arguments[i];\n }\n }\n return undefined;\n },\n\n defaultMessage: function (element, method) {\n var noMessage = $.mage.__(\"Warning: No message defined for %s\");\n return this.findDefined(\n this.customMessage(element.name, method),\n this.customDataMessage(element, method),\n this.customMetaMessage(element, method),\n // title is never undefined, so handle empty string as undefined\n !this.settings.ignoreTitle && element.title || undefined,\n $.validator.messages[method],\n \"<strong>\" + noMessage.replace('%s', element.name) + \"</strong>\"\n );\n },\n\n formatAndAdd: function (element, rule) {\n var message = this.defaultMessage(element, rule.method),\n theregex = /\\$?\\{(\\d+)\\}/g;\n if (typeof message === \"function\") {\n message = message.call(this, rule.parameters, element);\n } else if (theregex.test(message)) {\n message = $.validator.format(message.replace(theregex, '{$1}'), rule.parameters);\n }\n this.errorList.push({\n message: message,\n element: element\n });\n\n this.errorMap[element.name] = message;\n this.submitted[element.name] = message;\n },\n\n addWrapper: function (toToggle) {\n if (this.settings.wrapper) {\n toToggle = toToggle.add(toToggle.parent(this.settings.wrapper));\n }\n return toToggle;\n },\n\n defaultShowErrors: function () {\n var i, elements;\n for (i = 0; this.errorList[i]; i++) {\n var error = this.errorList[i];\n if (this.settings.highlight) {\n this.settings.highlight.call(this, error.element, this.settings.errorClass, this.settings.validClass);\n }\n this.showLabel(error.element, error.message);\n }\n if (this.errorList.length) {\n this.toShow = this.toShow.add(this.containers);\n }\n if (this.settings.success) {\n for (i = 0; this.successList[i]; i++) {\n this.showLabel(this.successList[i]);\n }\n }\n if (this.settings.unhighlight) {\n for (i = 0, elements = this.validElements(); elements[i]; i++) {\n this.settings.unhighlight.call(this, elements[i], this.settings.errorClass, this.settings.validClass);\n }\n }\n this.toHide = this.toHide.not(this.toShow);\n this.hideErrors();\n this.addWrapper(this.toShow).show();\n },\n\n validElements: function () {\n return this.currentElements.not(this.invalidElements());\n },\n\n invalidElements: function () {\n return $(this.errorList).map(function () {\n return this.element;\n });\n },\n\n showLabel: function (element, message) {\n var label = this.errorsFor(element);\n if (label.length) {\n // refresh error/success class\n label.removeClass(this.settings.validClass).addClass(this.settings.errorClass);\n\n // check if we have a generated label, replace the message then\n if (label.attr(\"generated\")) {\n label.hide().html(message);\n }\n } else {\n // create label\n label = $(\"<\" + this.settings.errorElement + \"/>\")\n .attr({\"for\": this.idOrName(element), generated: true})\n .addClass(this.settings.errorClass)\n .html(message || \"\");\n if (this.settings.wrapper) {\n // make sure the element is visible, even in IE\n // actually showing the wrapped element is handled elsewhere\n label = label.hide().show().wrap(\"<\" + this.settings.wrapper + \"/>\").parent();\n }\n if (!this.labelContainer.append(label).length) {\n if (this.settings.errorPlacement) {\n this.settings.errorPlacement(label, $(element));\n } else {\n label.insertAfter(element);\n }\n }\n }\n if (!message && this.settings.success) {\n label.text(\"\");\n if (typeof this.settings.success === \"string\") {\n label.addClass(this.settings.success);\n } else {\n this.settings.success(label, element);\n }\n }\n this.toShow = this.toShow.add(label);\n },\n\n errorsFor: function (element) {\n var name = this.idOrName(element);\n return this.errors().filter(function () {\n return $(this).attr('for') === name;\n });\n },\n\n idOrName: function (element) {\n return this.groups[element.name] || (this.checkable(element) ? element.name : element.id || element.name);\n },\n\n validationTargetFor: function (element) {\n // if radio/checkbox, validate first element in group instead\n if (this.checkable(element)) {\n element = this.findByName(element.name).not(this.settings.ignore)[0];\n }\n return element;\n },\n\n checkable: function (element) {\n return (/radio|checkbox/i).test(element.type);\n },\n\n findByName: function (name) {\n return $(this.currentForm).find('[name=\"' + name + '\"]');\n },\n\n getLength: function (value, element) {\n switch (element.nodeName.toLowerCase()) {\n case 'select':\n return $(\"option:selected\", element).length;\n case 'input':\n if (this.checkable(element)) {\n return this.findByName(element.name).filter(':checked').length;\n }\n }\n return value.length;\n },\n\n depend: function (param, element) {\n return this.dependTypes[typeof param] ? this.dependTypes[typeof param](param, element) : true;\n },\n\n dependTypes: {\n \"boolean\": function (param, element) {\n return param;\n },\n \"string\": function (param, element) {\n return !!$(param, element.form).length;\n },\n \"function\": function (param, element) {\n return param(element);\n }\n },\n\n optional: function (element) {\n var val = this.elementValue(element);\n return !$.validator.methods.required.call(this, val, element) && \"dependency-mismatch\";\n },\n\n startRequest: function (element) {\n if (!this.pending[element.name]) {\n this.pendingRequest++;\n this.pending[element.name] = true;\n }\n },\n\n stopRequest: function (element, valid) {\n this.pendingRequest--;\n // sometimes synchronization fails, make sure pendingRequest is never < 0\n if (this.pendingRequest < 0) {\n this.pendingRequest = 0;\n }\n delete this.pending[element.name];\n if (valid && this.pendingRequest === 0 && this.formSubmitted && this.form()) {\n $(this.currentForm).submit();\n this.formSubmitted = false;\n } else if (!valid && this.pendingRequest === 0 && this.formSubmitted) {\n $(this.currentForm).triggerHandler(\"invalid-form\", [this]);\n this.formSubmitted = false;\n }\n },\n\n previousValue: function (element) {\n return $.data(element, \"previousValue\") || $.data(element, \"previousValue\", {\n old: null,\n valid: true,\n message: this.defaultMessage(element, \"remote\")\n });\n }\n\n },\n\n classRuleSettings: {\n required: {required: true},\n email: {email: true},\n url: {url: true},\n date: {date: true},\n dateISO: {dateISO: true},\n number: {number: true},\n digits: {digits: true},\n creditcard: {creditcard: true}\n },\n\n addClassRules: function (className, rules) {\n if (className.constructor === String) {\n this.classRuleSettings[className] = rules;\n } else {\n $.extend(this.classRuleSettings, className);\n }\n },\n\n classRules: function (element) {\n var rules = {};\n var classes = $(element).attr('class');\n if (classes) {\n $.each(classes.split(' '), function () {\n if (this in $.validator.classRuleSettings) {\n $.extend(rules, $.validator.classRuleSettings[this]);\n }\n });\n }\n return rules;\n },\n\n attributeRules: function (element) {\n var rules = {};\n var $element = $(element);\n\n for (var method in $.validator.methods) {\n var value;\n\n // support for <input required> in both html5 and older browsers\n if (method === 'required') {\n value = $element.get(0).getAttribute(method);\n // Some browsers return an empty string for the required attribute\n // and non-HTML5 browsers might have required=\"\" markup\n if (value === \"\") {\n value = true;\n }\n // force non-HTML5 browsers to return bool\n value = !!value;\n } else {\n value = $element.attr(method);\n }\n\n if (value) {\n rules[method] = value;\n } else if ($element[0].getAttribute(\"type\") === method) {\n rules[method] = true;\n }\n }\n\n // maxlength may be returned as -1, 2147483647 (IE) and 524288 (safari) for text inputs\n if (rules.maxlength && /-1|2147483647|524288/.test(rules.maxlength)) {\n delete rules.maxlength;\n }\n\n return rules;\n },\n\n metadataRules: function (element) {\n if (!$.metadata) {\n return {};\n }\n\n var meta = $.data(element.form, 'validator').settings.meta;\n return meta ?\n $(element).metadata()[meta] :\n $(element).metadata();\n },\n\n staticRules: function (element) {\n var rules = {};\n var validator = $.data(element.form, 'validator');\n if (validator.settings.rules) {\n rules = $.validator.normalizeRule(validator.settings.rules[element.name]) || {};\n }\n return rules;\n },\n\n normalizeRules: function (rules, element) {\n // handle dependency check\n $.each(rules, function (prop, val) {\n // ignore rule when param is explicitly false, eg. required:false\n if (val === false) {\n delete rules[prop];\n return;\n }\n if (val.param || val.depends) {\n var keepRule = true;\n switch (typeof val.depends) {\n case \"string\":\n keepRule = !!$(val.depends, element.form).length;\n break;\n case \"function\":\n keepRule = val.depends.call(element, element);\n break;\n }\n if (keepRule) {\n rules[prop] = val.param !== undefined ? val.param : true;\n } else {\n delete rules[prop];\n }\n }\n });\n\n // evaluate parameters\n $.each(rules, function (rule, parameter) {\n rules[rule] = $.isFunction(parameter) ? parameter(element) : parameter;\n });\n\n // clean number parameters\n $.each(['minlength', 'maxlength', 'min', 'max'], function () {\n if (rules[this]) {\n rules[this] = Number(rules[this]);\n }\n });\n $.each(['rangelength', 'range'], function () {\n if (rules[this]) {\n rules[this] = [Number(rules[this][0]), Number(rules[this][1])];\n }\n });\n\n if ($.validator.autoCreateRanges) {\n // auto-create ranges\n if (rules.min && rules.max) {\n rules.range = [rules.min, rules.max];\n delete rules.min;\n delete rules.max;\n }\n if (rules.minlength && rules.maxlength) {\n rules.rangelength = [rules.minlength, rules.maxlength];\n delete rules.minlength;\n delete rules.maxlength;\n }\n }\n\n // To support custom messages in metadata ignore rule methods titled \"messages\"\n if (rules.messages) {\n delete rules.messages;\n }\n\n return rules;\n },\n\n // Converts a simple string to a {string: true} rule, e.g., \"required\" to {required:true}\n normalizeRule: function (data) {\n if (typeof data === \"string\") {\n var transformed = {};\n $.each(data.split(/\\s/), function () {\n transformed[this] = true;\n });\n data = transformed;\n }\n return data;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Validator/addMethod\n addMethod: function (name, method, message) {\n $.validator.methods[name] = method;\n $.validator.messages[name] = message !== undefined ? message : $.validator.messages[name];\n if (method.length < 3) {\n $.validator.addClassRules(name, $.validator.normalizeRule(name));\n }\n },\n\n methods: {\n\n // http://docs.jquery.com/Plugins/Validation/Methods/required\n required: function (value, element, param) {\n // check if dependency is met\n if (!this.depend(param, element)) {\n return \"dependency-mismatch\";\n }\n if (element.nodeName.toLowerCase() === \"select\") {\n // could be an array for select-multiple or a string, both are fine this way\n var val = $(element).val();\n return val && val.length > 0;\n }\n if (this.checkable(element)) {\n return this.getLength(value, element) > 0;\n }\n return $.trim(value).length > 0;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/remote\n remote: function (value, element, param) {\n if (this.optional(element)) {\n return \"dependency-mismatch\";\n }\n\n var previous = this.previousValue(element);\n if (!this.settings.messages[element.name]) {\n this.settings.messages[element.name] = {};\n }\n previous.originalMessage = this.settings.messages[element.name].remote;\n this.settings.messages[element.name].remote = previous.message;\n\n param = typeof param === \"string\" && {url: param} || param;\n\n if (this.pending[element.name]) {\n return \"pending\";\n }\n if (previous.old === value) {\n return previous.valid;\n }\n\n previous.old = value;\n var validator = this;\n this.startRequest(element);\n var data = {};\n data[element.name] = value;\n $.ajax($.extend(true, {\n url: param,\n mode: \"abort\",\n port: \"validate\" + element.name,\n dataType: \"json\",\n data: data,\n success: function (response) {\n validator.settings.messages[element.name].remote = previous.originalMessage;\n var valid = response === true || response === \"true\";\n if (valid) {\n var submitted = validator.formSubmitted;\n validator.prepareElement(element);\n validator.formSubmitted = submitted;\n validator.successList.push(element);\n delete validator.invalid[element.name];\n validator.showErrors();\n } else {\n var errors = {};\n var message = response || validator.defaultMessage(element, \"remote\");\n errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;\n validator.invalid[element.name] = true;\n validator.showErrors(errors);\n }\n previous.valid = valid;\n validator.stopRequest(element, valid);\n }\n }, param));\n return \"pending\";\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/minlength\n minlength: function (value, element, param) {\n var length = $.isArray(value) ? value.length : this.getLength($.trim(value), element);\n return this.optional(element) || length >= param;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/maxlength\n maxlength: function (value, element, param) {\n var length = $.isArray(value) ? value.length : this.getLength($.trim(value), element);\n return this.optional(element) || length <= param;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/rangelength\n rangelength: function (value, element, param) {\n var length = $.isArray(value) ? value.length : this.getLength($.trim(value), element);\n return this.optional(element) || ( length >= param[0] && length <= param[1] );\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/min\n min: function (value, element, param) {\n return this.optional(element) || value >= param;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/max\n max: function (value, element, param) {\n return this.optional(element) || value <= param;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/range\n range: function (value, element, param) {\n return this.optional(element) || ( value >= param[0] && value <= param[1] );\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/email\n email: function (value, element) {\n // contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/\n return this.optional(element) || /^((([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+(\\.([a-z]|\\d|[!#\\$%&'\\*\\+\\-\\/=\\?\\^_`{\\|}~]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])+)*)|((\\x22)((((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(([\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x7f]|\\x21|[\\x23-\\x5b]|[\\x5d-\\x7e]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(\\\\([\\x01-\\x09\\x0b\\x0c\\x0d-\\x7f]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]))))*(((\\x20|\\x09)*(\\x0d\\x0a))?(\\x20|\\x09)+)?(\\x22)))@((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))$/i.test(value);\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/url\n url: function (value, element) {\n // contributed by Scott Gonzalez: http://projects.scottsplayground.com/iri/\n return this.optional(element) || /^(https?|ftp):\\/\\/(((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|\\d|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.)+(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])*([a-z]|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|[\\uE000-\\uF8FF]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|_|~|[\\u00A0-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF])|(%[\\da-f]{2})|[!\\$&'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i.test(value);\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/date\n date: function (value, element) {\n return this.optional(element) || !/Invalid|NaN/.test(new Date(value));\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/dateISO\n dateISO: function (value, element) {\n return this.optional(element) || /^\\d{4}[\\/\\-]\\d{1,2}[\\/\\-]\\d{1,2}$/.test(value);\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/number\n number: function (value, element) {\n return this.optional(element) || /^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)?(?:\\.\\d+)?$/.test(value);\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/digits\n digits: function (value, element) {\n return this.optional(element) || /^\\d+$/.test(value);\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/creditcard\n // based on http://en.wikipedia.org/wiki/Luhn\n creditcard: function (value, element) {\n if (this.optional(element)) {\n return \"dependency-mismatch\";\n }\n // accept only spaces, digits and dashes\n if (/[^0-9 \\-]+/.test(value)) {\n return false;\n }\n var nCheck = 0,\n nDigit = 0,\n bEven = false;\n\n value = value.replace(/\\D/g, \"\");\n\n for (var n = value.length - 1; n >= 0; n--) {\n var cDigit = value.charAt(n);\n nDigit = parseInt(cDigit, 10);\n if (bEven) {\n if ((nDigit *= 2) > 9) {\n nDigit -= 9;\n }\n }\n nCheck += nDigit;\n bEven = !bEven;\n }\n\n return (nCheck % 10) === 0;\n },\n\n // http://docs.jquery.com/Plugins/Validation/Methods/equalTo\n equalTo: function (value, element, param) {\n // bind to the blur event of the target in order to revalidate whenever the target field is updated\n // TODO find a way to bind the event just once, avoiding the unbind-rebind overhead\n var target = $(param);\n if (this.settings.onfocusout) {\n target.unbind(\".validate-equalTo\").bind(\"blur.validate-equalTo\", function () {\n $(element).valid();\n });\n }\n return value === target.val();\n }\n\n }\n\n });\n\n// deprecated, use $.validator.format instead\n $.format = $.validator.format;\n\n}(jQuery));\n\n// ajax mode: abort\n// usage: $.ajax({ mode: \"abort\"[, port: \"uniqueport\"]});\n// if mode:\"abort\" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()\n(function ($) {\n var pendingRequests = {};\n // Use a prefilter if available (1.5+)\n if ($.ajaxPrefilter) {\n $.ajaxPrefilter(function (settings, _, xhr) {\n var port = settings.port;\n if (settings.mode === \"abort\") {\n if (pendingRequests[port]) {\n pendingRequests[port].abort();\n }\n pendingRequests[port] = xhr;\n }\n });\n } else {\n // Proxy ajax\n var ajax = $.ajax;\n $.ajax = function (settings) {\n var mode = ( \"mode\" in settings ? settings : $.ajaxSettings ).mode,\n port = ( \"port\" in settings ? settings : $.ajaxSettings ).port;\n if (mode === \"abort\") {\n if (pendingRequests[port]) {\n pendingRequests[port].abort();\n }\n return (pendingRequests[port] = ajax.apply(this, arguments));\n }\n return ajax.apply(this, arguments);\n };\n }\n}(jQuery));\n\n// provides cross-browser focusin and focusout events\n// IE has native support, in other browsers, use event caputuring (neither bubbles)\n\n// provides delegate(type: String, delegate: Selector, handler: Callback) plugin for easier event delegation\n// handler is only called when $(event.target).is(delegate), in the scope of the jquery-object for event.target\n(function ($) {\n // only implement if not provided by jQuery core (since 1.4)\n // TODO verify if jQuery 1.4's implementation is compatible with older jQuery special-event APIs\n if (!jQuery.event.special.focusin && !jQuery.event.special.focusout && document.addEventListener) {\n $.each({\n focus: 'focusin',\n blur: 'focusout'\n }, function (original, fix) {\n $.event.special[fix] = {\n setup: function () {\n this.addEventListener(original, handler, true);\n },\n teardown: function () {\n this.removeEventListener(original, handler, true);\n },\n handler: function (e) {\n var args = arguments;\n args[0] = $.event.fix(e);\n args[0].type = fix;\n return $.event.handle.apply(this, args);\n }\n };\n function handler(e) {\n e = $.event.fix(e);\n e.type = fix;\n return $.event.handle.call(this, e);\n }\n });\n }\n $.extend($.fn, {\n validateDelegate: function (delegate, type, handler) {\n return this.bind(type, function (event) {\n var target = $(event.target);\n if (target.is(delegate)) {\n return handler.apply(target, arguments);\n }\n });\n }\n });\n}(jQuery));\n\n}));","jquery/jquery-migrate.js":"/*!\n * jQuery Migrate - v1.4.1 - 2016-05-19\n * Copyright jQuery Foundation and other contributors\n */\n(function( jQuery, window, undefined ) {\n// See http://bugs.jquery.com/ticket/13335\n// \"use strict\";\n\n\njQuery.migrateVersion = \"1.4.1\";\n\n\nvar warnedAbout = {};\n\n// List of warnings already given; public read only\njQuery.migrateWarnings = [];\n\n// Set to true to prevent console output; migrateWarnings still maintained\n// jQuery.migrateMute = false;\n\n// Show a message on the console so devs know we're active\nif ( window.console && window.console.log ) {\n\twindow.console.log( \"JQMIGRATE: Migrate is installed\" +\n\t\t( jQuery.migrateMute ? \"\" : \" with logging active\" ) +\n\t\t\", version \" + jQuery.migrateVersion );\n}\n\n// Set to false to disable traces that appear with warnings\nif ( jQuery.migrateTrace === undefined ) {\n\tjQuery.migrateTrace = true;\n}\n\n// Forget any warnings we've already given; public\njQuery.migrateReset = function() {\n\twarnedAbout = {};\n\tjQuery.migrateWarnings.length = 0;\n};\n\nfunction migrateWarn( msg) {\n\tvar console = window.console;\n\tif ( !warnedAbout[ msg ] ) {\n\t\twarnedAbout[ msg ] = true;\n\t\tjQuery.migrateWarnings.push( msg );\n\t\tif ( console && console.warn && !jQuery.migrateMute ) {\n\t\t\tconsole.warn( \"JQMIGRATE: \" + msg );\n\t\t\tif ( jQuery.migrateTrace && console.trace ) {\n\t\t\t\tconsole.trace();\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction migrateWarnProp( obj, prop, value, msg ) {\n\tif ( Object.defineProperty ) {\n\t\t// On ES5 browsers (non-oldIE), warn if the code tries to get prop;\n\t\t// allow property to be overwritten in case some other plugin wants it\n\t\ttry {\n\t\t\tObject.defineProperty( obj, prop, {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: true,\n\t\t\t\tget: function() {\n\t\t\t\t\tmigrateWarn( msg );\n\t\t\t\t\treturn value;\n\t\t\t\t},\n\t\t\t\tset: function( newValue ) {\n\t\t\t\t\tmigrateWarn( msg );\n\t\t\t\t\tvalue = newValue;\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn;\n\t\t} catch( err ) {\n\t\t\t// IE8 is a dope about Object.defineProperty, can't warn there\n\t\t}\n\t}\n\n\t// Non-ES5 (or broken) browser; just set the property\n\tjQuery._definePropertyBroken = true;\n\tobj[ prop ] = value;\n}\n\nif ( document.compatMode === \"BackCompat\" ) {\n\t// jQuery has never supported or tested Quirks Mode\n\tmigrateWarn( \"jQuery is not compatible with Quirks Mode\" );\n}\n\n\nvar attrFn = jQuery( \"<input/>\", { size: 1 } ).attr(\"size\") && jQuery.attrFn,\n\toldAttr = jQuery.attr,\n\tvalueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get ||\n\t\tfunction() { return null; },\n\tvalueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set ||\n\t\tfunction() { return undefined; },\n\trnoType = /^(?:input|button)$/i,\n\trnoAttrNodeType = /^[238]$/,\n\trboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i,\n\truseDefault = /^(?:checked|selected)$/i;\n\n// jQuery.attrFn\nmigrateWarnProp( jQuery, \"attrFn\", attrFn || {}, \"jQuery.attrFn is deprecated\" );\n\njQuery.attr = function( elem, name, value, pass ) {\n\tvar lowerName = name.toLowerCase(),\n\t\tnType = elem && elem.nodeType;\n\n\tif ( pass ) {\n\t\t// Since pass is used internally, we only warn for new jQuery\n\t\t// versions where there isn't a pass arg in the formal params\n\t\tif ( oldAttr.length < 4 ) {\n\t\t\tmigrateWarn(\"jQuery.fn.attr( props, pass ) is deprecated\");\n\t\t}\n\t\tif ( elem && !rnoAttrNodeType.test( nType ) &&\n\t\t\t(attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) {\n\t\t\treturn jQuery( elem )[ name ]( value );\n\t\t}\n\t}\n\n\t// Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking\n\t// for disconnected elements we don't warn on $( \"<button>\", { type: \"button\" } ).\n\tif ( name === \"type\" && value !== undefined && rnoType.test( elem.nodeName ) && elem.parentNode ) {\n\t\tmigrateWarn(\"Can't change the 'type' of an input or button in IE 6/7/8\");\n\t}\n\n\t// Restore boolHook for boolean property/attribute synchronization\n\tif ( !jQuery.attrHooks[ lowerName ] && rboolean.test( lowerName ) ) {\n\t\tjQuery.attrHooks[ lowerName ] = {\n\t\t\tget: function( elem, name ) {\n\t\t\t\t// Align boolean attributes with corresponding properties\n\t\t\t\t// Fall back to attribute presence where some booleans are not supported\n\t\t\t\tvar attrNode,\n\t\t\t\t\tproperty = jQuery.prop( elem, name );\n\t\t\t\treturn property === true || typeof property !== \"boolean\" &&\n\t\t\t\t\t( attrNode = elem.getAttributeNode(name) ) && attrNode.nodeValue !== false ?\n\n\t\t\t\t\tname.toLowerCase() :\n\t\t\t\t\tundefined;\n\t\t\t},\n\t\t\tset: function( elem, value, name ) {\n\t\t\t\tvar propName;\n\t\t\t\tif ( value === false ) {\n\t\t\t\t\t// Remove boolean attributes when set to false\n\t\t\t\t\tjQuery.removeAttr( elem, name );\n\t\t\t\t} else {\n\t\t\t\t\t// value is true since we know at this point it's type boolean and not false\n\t\t\t\t\t// Set boolean attributes to the same name and set the DOM property\n\t\t\t\t\tpropName = jQuery.propFix[ name ] || name;\n\t\t\t\t\tif ( propName in elem ) {\n\t\t\t\t\t\t// Only set the IDL specifically if it already exists on the element\n\t\t\t\t\t\telem[ propName ] = true;\n\t\t\t\t\t}\n\n\t\t\t\t\telem.setAttribute( name, name.toLowerCase() );\n\t\t\t\t}\n\t\t\t\treturn name;\n\t\t\t}\n\t\t};\n\n\t\t// Warn only for attributes that can remain distinct from their properties post-1.9\n\t\tif ( ruseDefault.test( lowerName ) ) {\n\t\t\tmigrateWarn( \"jQuery.fn.attr('\" + lowerName + \"') might use property instead of attribute\" );\n\t\t}\n\t}\n\n\treturn oldAttr.call( jQuery, elem, name, value );\n};\n\n// attrHooks: value\njQuery.attrHooks.value = {\n\tget: function( elem, name ) {\n\t\tvar nodeName = ( elem.nodeName || \"\" ).toLowerCase();\n\t\tif ( nodeName === \"button\" ) {\n\t\t\treturn valueAttrGet.apply( this, arguments );\n\t\t}\n\t\tif ( nodeName !== \"input\" && nodeName !== \"option\" ) {\n\t\t\tmigrateWarn(\"jQuery.fn.attr('value') no longer gets properties\");\n\t\t}\n\t\treturn name in elem ?\n\t\t\telem.value :\n\t\t\tnull;\n\t},\n\tset: function( elem, value ) {\n\t\tvar nodeName = ( elem.nodeName || \"\" ).toLowerCase();\n\t\tif ( nodeName === \"button\" ) {\n\t\t\treturn valueAttrSet.apply( this, arguments );\n\t\t}\n\t\tif ( nodeName !== \"input\" && nodeName !== \"option\" ) {\n\t\t\tmigrateWarn(\"jQuery.fn.attr('value', val) no longer sets properties\");\n\t\t}\n\t\t// Does not return so that setAttribute is also used\n\t\telem.value = value;\n\t}\n};\n\n\nvar matched, browser,\n\toldInit = jQuery.fn.init,\n\toldFind = jQuery.find,\n\toldParseJSON = jQuery.parseJSON,\n\trspaceAngle = /^\\s*</,\n\trattrHashTest = /\\[(\\s*[-\\w]+\\s*)([~|^$*]?=)\\s*([-\\w#]*?#[-\\w#]*)\\s*\\]/,\n\trattrHashGlob = /\\[(\\s*[-\\w]+\\s*)([~|^$*]?=)\\s*([-\\w#]*?#[-\\w#]*)\\s*\\]/g,\n\t// Note: XSS check is done below after string is trimmed\n\trquickExpr = /^([^<]*)(<[\\w\\W]+>)([^>]*)$/;\n\n// $(html) \"looks like html\" rule change\njQuery.fn.init = function( selector, context, rootjQuery ) {\n\tvar match, ret;\n\n\tif ( selector && typeof selector === \"string\" ) {\n\t\tif ( !jQuery.isPlainObject( context ) &&\n\t\t\t\t(match = rquickExpr.exec( jQuery.trim( selector ) )) && match[ 0 ] ) {\n\n\t\t\t// This is an HTML string according to the \"old\" rules; is it still?\n\t\t\tif ( !rspaceAngle.test( selector ) ) {\n\t\t\t\tmigrateWarn(\"$(html) HTML strings must start with '<' character\");\n\t\t\t}\n\t\t\tif ( match[ 3 ] ) {\n\t\t\t\tmigrateWarn(\"$(html) HTML text after last tag is ignored\");\n\t\t\t}\n\n\t\t\t// Consistently reject any HTML-like string starting with a hash (gh-9521)\n\t\t\t// Note that this may break jQuery 1.6.x code that otherwise would work.\n\t\t\tif ( match[ 0 ].charAt( 0 ) === \"#\" ) {\n\t\t\t\tmigrateWarn(\"HTML string cannot start with a '#' character\");\n\t\t\t\tjQuery.error(\"JQMIGRATE: Invalid selector string (XSS)\");\n\t\t\t}\n\n\t\t\t// Now process using loose rules; let pre-1.8 play too\n\t\t\t// Is this a jQuery context? parseHTML expects a DOM element (#178)\n\t\t\tif ( context && context.context && context.context.nodeType ) {\n\t\t\t\tcontext = context.context;\n\t\t\t}\n\n\t\t\tif ( jQuery.parseHTML ) {\n\t\t\t\treturn oldInit.call( this,\n\t\t\t\t\t\tjQuery.parseHTML( match[ 2 ], context && context.ownerDocument ||\n\t\t\t\t\t\t\tcontext || document, true ), context, rootjQuery );\n\t\t\t}\n\t\t}\n\t}\n\n\tret = oldInit.apply( this, arguments );\n\n\t// Fill in selector and context properties so .live() works\n\tif ( selector && selector.selector !== undefined ) {\n\t\t// A jQuery object, copy its properties\n\t\tret.selector = selector.selector;\n\t\tret.context = selector.context;\n\n\t} else {\n\t\tret.selector = typeof selector === \"string\" ? selector : \"\";\n\t\tif ( selector ) {\n\t\t\tret.context = selector.nodeType? selector : context || document;\n\t\t}\n\t}\n\n\treturn ret;\n};\njQuery.fn.init.prototype = jQuery.fn;\n\njQuery.find = function( selector ) {\n\tvar args = Array.prototype.slice.call( arguments );\n\n\t// Support: PhantomJS 1.x\n\t// String#match fails to match when used with a //g RegExp, only on some strings\n\tif ( typeof selector === \"string\" && rattrHashTest.test( selector ) ) {\n\n\t\t// The nonstandard and undocumented unquoted-hash was removed in jQuery 1.12.0\n\t\t// First see if qS thinks it's a valid selector, if so avoid a false positive\n\t\ttry {\n\t\t\tdocument.querySelector( selector );\n\t\t} catch ( err1 ) {\n\n\t\t\t// Didn't *look* valid to qSA, warn and try quoting what we think is the value\n\t\t\tselector = selector.replace( rattrHashGlob, function( _, attr, op, value ) {\n\t\t\t\treturn \"[\" + attr + op + \"\\\"\" + value + \"\\\"]\";\n\t\t\t} );\n\n\t\t\t// If the regexp *may* have created an invalid selector, don't update it\n\t\t\t// Note that there may be false alarms if selector uses jQuery extensions\n\t\t\ttry {\n\t\t\t\tdocument.querySelector( selector );\n\t\t\t\tmigrateWarn( \"Attribute selector with '#' must be quoted: \" + args[ 0 ] );\n\t\t\t\targs[ 0 ] = selector;\n\t\t\t} catch ( err2 ) {\n\t\t\t\tmigrateWarn( \"Attribute selector with '#' was not fixed: \" + args[ 0 ] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn oldFind.apply( this, args );\n};\n\n// Copy properties attached to original jQuery.find method (e.g. .attr, .isXML)\nvar findProp;\nfor ( findProp in oldFind ) {\n\tif ( Object.prototype.hasOwnProperty.call( oldFind, findProp ) ) {\n\t\tjQuery.find[ findProp ] = oldFind[ findProp ];\n\t}\n}\n\n// Let $.parseJSON(falsy_value) return null\njQuery.parseJSON = function( json ) {\n\tif ( !json ) {\n\t\tmigrateWarn(\"jQuery.parseJSON requires a valid JSON string\");\n\t\treturn null;\n\t}\n\treturn oldParseJSON.apply( this, arguments );\n};\n\njQuery.uaMatch = function( ua ) {\n\tua = ua.toLowerCase();\n\n\tvar match = /(chrome)[ \\/]([\\w.]+)/.exec( ua ) ||\n\t\t/(webkit)[ \\/]([\\w.]+)/.exec( ua ) ||\n\t\t/(opera)(?:.*version|)[ \\/]([\\w.]+)/.exec( ua ) ||\n\t\t/(msie) ([\\w.]+)/.exec( ua ) ||\n\t\tua.indexOf(\"compatible\") < 0 && /(mozilla)(?:.*? rv:([\\w.]+)|)/.exec( ua ) ||\n\t\t[];\n\n\treturn {\n\t\tbrowser: match[ 1 ] || \"\",\n\t\tversion: match[ 2 ] || \"0\"\n\t};\n};\n\n// Don't clobber any existing jQuery.browser in case it's different\nif ( !jQuery.browser ) {\n\tmatched = jQuery.uaMatch( navigator.userAgent );\n\tbrowser = {};\n\n\tif ( matched.browser ) {\n\t\tbrowser[ matched.browser ] = true;\n\t\tbrowser.version = matched.version;\n\t}\n\n\t// Chrome is Webkit, but Webkit is also Safari.\n\tif ( browser.chrome ) {\n\t\tbrowser.webkit = true;\n\t} else if ( browser.webkit ) {\n\t\tbrowser.safari = true;\n\t}\n\n\tjQuery.browser = browser;\n}\n\n// Warn if the code tries to get jQuery.browser\nmigrateWarnProp( jQuery, \"browser\", jQuery.browser, \"jQuery.browser is deprecated\" );\n\n// jQuery.boxModel deprecated in 1.3, jQuery.support.boxModel deprecated in 1.7\njQuery.boxModel = jQuery.support.boxModel = (document.compatMode === \"CSS1Compat\");\nmigrateWarnProp( jQuery, \"boxModel\", jQuery.boxModel, \"jQuery.boxModel is deprecated\" );\nmigrateWarnProp( jQuery.support, \"boxModel\", jQuery.support.boxModel, \"jQuery.support.boxModel is deprecated\" );\n\njQuery.sub = function() {\n\tfunction jQuerySub( selector, context ) {\n\t\treturn new jQuerySub.fn.init( selector, context );\n\t}\n\tjQuery.extend( true, jQuerySub, this );\n\tjQuerySub.superclass = this;\n\tjQuerySub.fn = jQuerySub.prototype = this();\n\tjQuerySub.fn.constructor = jQuerySub;\n\tjQuerySub.sub = this.sub;\n\tjQuerySub.fn.init = function init( selector, context ) {\n\t\tvar instance = jQuery.fn.init.call( this, selector, context, rootjQuerySub );\n\t\treturn instance instanceof jQuerySub ?\n\t\t\tinstance :\n\t\t\tjQuerySub( instance );\n\t};\n\tjQuerySub.fn.init.prototype = jQuerySub.fn;\n\tvar rootjQuerySub = jQuerySub(document);\n\tmigrateWarn( \"jQuery.sub() is deprecated\" );\n\treturn jQuerySub;\n};\n\n// The number of elements contained in the matched element set\njQuery.fn.size = function() {\n\tmigrateWarn( \"jQuery.fn.size() is deprecated; use the .length property\" );\n\treturn this.length;\n};\n\n\nvar internalSwapCall = false;\n\n// If this version of jQuery has .swap(), don't false-alarm on internal uses\nif ( jQuery.swap ) {\n\tjQuery.each( [ \"height\", \"width\", \"reliableMarginRight\" ], function( _, name ) {\n\t\tvar oldHook = jQuery.cssHooks[ name ] && jQuery.cssHooks[ name ].get;\n\n\t\tif ( oldHook ) {\n\t\t\tjQuery.cssHooks[ name ].get = function() {\n\t\t\t\tvar ret;\n\n\t\t\t\tinternalSwapCall = true;\n\t\t\t\tret = oldHook.apply( this, arguments );\n\t\t\t\tinternalSwapCall = false;\n\t\t\t\treturn ret;\n\t\t\t};\n\t\t}\n\t});\n}\n\njQuery.swap = function( elem, options, callback, args ) {\n\tvar ret, name,\n\t\told = {};\n\n\tif ( !internalSwapCall ) {\n\t\tmigrateWarn( \"jQuery.swap() is undocumented and deprecated\" );\n\t}\n\n\t// Remember the old values, and insert the new ones\n\tfor ( name in options ) {\n\t\told[ name ] = elem.style[ name ];\n\t\telem.style[ name ] = options[ name ];\n\t}\n\n\tret = callback.apply( elem, args || [] );\n\n\t// Revert the old values\n\tfor ( name in options ) {\n\t\telem.style[ name ] = old[ name ];\n\t}\n\n\treturn ret;\n};\n\n\n// Ensure that $.ajax gets the new parseJSON defined in core.js\njQuery.ajaxSetup({\n\tconverters: {\n\t\t\"text json\": jQuery.parseJSON\n\t}\n});\n\n\nvar oldFnData = jQuery.fn.data;\n\njQuery.fn.data = function( name ) {\n\tvar ret, evt,\n\t\telem = this[0];\n\n\t// Handles 1.7 which has this behavior and 1.8 which doesn't\n\tif ( elem && name === \"events\" && arguments.length === 1 ) {\n\t\tret = jQuery.data( elem, name );\n\t\tevt = jQuery._data( elem, name );\n\t\tif ( ( ret === undefined || ret === evt ) && evt !== undefined ) {\n\t\t\tmigrateWarn(\"Use of jQuery.fn.data('events') is deprecated\");\n\t\t\treturn evt;\n\t\t}\n\t}\n\treturn oldFnData.apply( this, arguments );\n};\n\n\nvar rscriptType = /\\/(java|ecma)script/i;\n\n// Since jQuery.clean is used internally on older versions, we only shim if it's missing\nif ( !jQuery.clean ) {\n\tjQuery.clean = function( elems, context, fragment, scripts ) {\n\t\t// Set context per 1.8 logic\n\t\tcontext = context || document;\n\t\tcontext = !context.nodeType && context[0] || context;\n\t\tcontext = context.ownerDocument || context;\n\n\t\tmigrateWarn(\"jQuery.clean() is deprecated\");\n\n\t\tvar i, elem, handleScript, jsTags,\n\t\t\tret = [];\n\n\t\tjQuery.merge( ret, jQuery.buildFragment( elems, context ).childNodes );\n\n\t\t// Complex logic lifted directly from jQuery 1.8\n\t\tif ( fragment ) {\n\t\t\t// Special handling of each script element\n\t\t\thandleScript = function( elem ) {\n\t\t\t\t// Check if we consider it executable\n\t\t\t\tif ( !elem.type || rscriptType.test( elem.type ) ) {\n\t\t\t\t\t// Detach the script and store it in the scripts array (if provided) or the fragment\n\t\t\t\t\t// Return truthy to indicate that it has been handled\n\t\t\t\t\treturn scripts ?\n\t\t\t\t\t\tscripts.push( elem.parentNode ? elem.parentNode.removeChild( elem ) : elem ) :\n\t\t\t\t\t\tfragment.appendChild( elem );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tfor ( i = 0; (elem = ret[i]) != null; i++ ) {\n\t\t\t\t// Check if we're done after handling an executable script\n\t\t\t\tif ( !( jQuery.nodeName( elem, \"script\" ) && handleScript( elem ) ) ) {\n\t\t\t\t\t// Append to fragment and handle embedded scripts\n\t\t\t\t\tfragment.appendChild( elem );\n\t\t\t\t\tif ( typeof elem.getElementsByTagName !== \"undefined\" ) {\n\t\t\t\t\t\t// handleScript alters the DOM, so use jQuery.merge to ensure snapshot iteration\n\t\t\t\t\t\tjsTags = jQuery.grep( jQuery.merge( [], elem.getElementsByTagName(\"script\") ), handleScript );\n\n\t\t\t\t\t\t// Splice the scripts into ret after their former ancestor and advance our index beyond them\n\t\t\t\t\t\tret.splice.apply( ret, [i + 1, 0].concat( jsTags ) );\n\t\t\t\t\t\ti += jsTags.length;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn ret;\n\t};\n}\n\nvar eventAdd = jQuery.event.add,\n\teventRemove = jQuery.event.remove,\n\teventTrigger = jQuery.event.trigger,\n\toldToggle = jQuery.fn.toggle,\n\toldLive = jQuery.fn.live,\n\toldDie = jQuery.fn.die,\n\toldLoad = jQuery.fn.load,\n\tajaxEvents = \"ajaxStart|ajaxStop|ajaxSend|ajaxComplete|ajaxError|ajaxSuccess\",\n\trajaxEvent = new RegExp( \"\\\\b(?:\" + ajaxEvents + \")\\\\b\" ),\n\trhoverHack = /(?:^|\\s)hover(\\.\\S+|)\\b/,\n\thoverHack = function( events ) {\n\t\tif ( typeof( events ) !== \"string\" || jQuery.event.special.hover ) {\n\t\t\treturn events;\n\t\t}\n\t\tif ( rhoverHack.test( events ) ) {\n\t\t\tmigrateWarn(\"'hover' pseudo-event is deprecated, use 'mouseenter mouseleave'\");\n\t\t}\n\t\treturn events && events.replace( rhoverHack, \"mouseenter$1 mouseleave$1\" );\n\t};\n\n// Event props removed in 1.9, put them back if needed; no practical way to warn them\nif ( jQuery.event.props && jQuery.event.props[ 0 ] !== \"attrChange\" ) {\n\tjQuery.event.props.unshift( \"attrChange\", \"attrName\", \"relatedNode\", \"srcElement\" );\n}\n\n// Undocumented jQuery.event.handle was \"deprecated\" in jQuery 1.7\nif ( jQuery.event.dispatch ) {\n\tmigrateWarnProp( jQuery.event, \"handle\", jQuery.event.dispatch, \"jQuery.event.handle is undocumented and deprecated\" );\n}\n\n// Support for 'hover' pseudo-event and ajax event warnings\njQuery.event.add = function( elem, types, handler, data, selector ){\n\tif ( elem !== document && rajaxEvent.test( types ) ) {\n\t\tmigrateWarn( \"AJAX events should be attached to document: \" + types );\n\t}\n\teventAdd.call( this, elem, hoverHack( types || \"\" ), handler, data, selector );\n};\njQuery.event.remove = function( elem, types, handler, selector, mappedTypes ){\n\teventRemove.call( this, elem, hoverHack( types ) || \"\", handler, selector, mappedTypes );\n};\n\njQuery.each( [ \"load\", \"unload\", \"error\" ], function( _, name ) {\n\n\tjQuery.fn[ name ] = function() {\n\t\tvar args = Array.prototype.slice.call( arguments, 0 );\n\n\t\t// If this is an ajax load() the first arg should be the string URL;\n\t\t// technically this could also be the \"Anything\" arg of the event .load()\n\t\t// which just goes to show why this dumb signature has been deprecated!\n\t\t// jQuery custom builds that exclude the Ajax module justifiably die here.\n\t\tif ( name === \"load\" && typeof args[ 0 ] === \"string\" ) {\n\t\t\treturn oldLoad.apply( this, args );\n\t\t}\n\n\t\tmigrateWarn( \"jQuery.fn.\" + name + \"() is deprecated\" );\n\n\t\targs.splice( 0, 0, name );\n\t\tif ( arguments.length ) {\n\t\t\treturn this.bind.apply( this, args );\n\t\t}\n\n\t\t// Use .triggerHandler here because:\n\t\t// - load and unload events don't need to bubble, only applied to window or image\n\t\t// - error event should not bubble to window, although it does pre-1.7\n\t\t// See http://bugs.jquery.com/ticket/11820\n\t\tthis.triggerHandler.apply( this, args );\n\t\treturn this;\n\t};\n\n});\n\njQuery.fn.toggle = function( fn, fn2 ) {\n\n\t// Don't mess with animation or css toggles\n\tif ( !jQuery.isFunction( fn ) || !jQuery.isFunction( fn2 ) ) {\n\t\treturn oldToggle.apply( this, arguments );\n\t}\n\tmigrateWarn(\"jQuery.fn.toggle(handler, handler...) is deprecated\");\n\n\t// Save reference to arguments for access in closure\n\tvar args = arguments,\n\t\tguid = fn.guid || jQuery.guid++,\n\t\ti = 0,\n\t\ttoggler = function( event ) {\n\t\t\t// Figure out which function to execute\n\t\t\tvar lastToggle = ( jQuery._data( this, \"lastToggle\" + fn.guid ) || 0 ) % i;\n\t\t\tjQuery._data( this, \"lastToggle\" + fn.guid, lastToggle + 1 );\n\n\t\t\t// Make sure that clicks stop\n\t\t\tevent.preventDefault();\n\n\t\t\t// and execute the function\n\t\t\treturn args[ lastToggle ].apply( this, arguments ) || false;\n\t\t};\n\n\t// link all the functions, so any of them can unbind this click handler\n\ttoggler.guid = guid;\n\twhile ( i < args.length ) {\n\t\targs[ i++ ].guid = guid;\n\t}\n\n\treturn this.click( toggler );\n};\n\njQuery.fn.live = function( types, data, fn ) {\n\tmigrateWarn(\"jQuery.fn.live() is deprecated\");\n\tif ( oldLive ) {\n\t\treturn oldLive.apply( this, arguments );\n\t}\n\tjQuery( this.context ).on( types, this.selector, data, fn );\n\treturn this;\n};\n\njQuery.fn.die = function( types, fn ) {\n\tmigrateWarn(\"jQuery.fn.die() is deprecated\");\n\tif ( oldDie ) {\n\t\treturn oldDie.apply( this, arguments );\n\t}\n\tjQuery( this.context ).off( types, this.selector || \"**\", fn );\n\treturn this;\n};\n\n// Turn global events into document-triggered events\njQuery.event.trigger = function( event, data, elem, onlyHandlers ){\n\tif ( !elem && !rajaxEvent.test( event ) ) {\n\t\tmigrateWarn( \"Global events are undocumented and deprecated\" );\n\t}\n\treturn eventTrigger.call( this, event, data, elem || document, onlyHandlers );\n};\njQuery.each( ajaxEvents.split(\"|\"),\n\tfunction( _, name ) {\n\t\tjQuery.event.special[ name ] = {\n\t\t\tsetup: function() {\n\t\t\t\tvar elem = this;\n\n\t\t\t\t// The document needs no shimming; must be !== for oldIE\n\t\t\t\tif ( elem !== document ) {\n\t\t\t\t\tjQuery.event.add( document, name + \".\" + jQuery.guid, function() {\n\t\t\t\t\t\tjQuery.event.trigger( name, Array.prototype.slice.call( arguments, 1 ), elem, true );\n\t\t\t\t\t});\n\t\t\t\t\tjQuery._data( this, name, jQuery.guid++ );\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tteardown: function() {\n\t\t\t\tif ( this !== document ) {\n\t\t\t\t\tjQuery.event.remove( document, name + \".\" + jQuery._data( this, name ) );\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t}\n);\n\njQuery.event.special.ready = {\n\tsetup: function() {\n\t\tif ( this === document ) {\n\t\t\tmigrateWarn( \"'ready' event is deprecated\" );\n\t\t}\n\t}\n};\n\nvar oldSelf = jQuery.fn.andSelf || jQuery.fn.addBack,\n\toldFnFind = jQuery.fn.find;\n\njQuery.fn.andSelf = function() {\n\tmigrateWarn(\"jQuery.fn.andSelf() replaced by jQuery.fn.addBack()\");\n\treturn oldSelf.apply( this, arguments );\n};\n\njQuery.fn.find = function( selector ) {\n\tvar ret = oldFnFind.apply( this, arguments );\n\tret.context = this.context;\n\tret.selector = this.selector ? this.selector + \" \" + selector : selector;\n\treturn ret;\n};\n\n\n// jQuery 1.6 did not support Callbacks, do not warn there\nif ( jQuery.Callbacks ) {\n\n\tvar oldDeferred = jQuery.Deferred,\n\t\ttuples = [\n\t\t\t// action, add listener, callbacks, .then handlers, final state\n\t\t\t[ \"resolve\", \"done\", jQuery.Callbacks(\"once memory\"),\n\t\t\t\tjQuery.Callbacks(\"once memory\"), \"resolved\" ],\n\t\t\t[ \"reject\", \"fail\", jQuery.Callbacks(\"once memory\"),\n\t\t\t\tjQuery.Callbacks(\"once memory\"), \"rejected\" ],\n\t\t\t[ \"notify\", \"progress\", jQuery.Callbacks(\"memory\"),\n\t\t\t\tjQuery.Callbacks(\"memory\") ]\n\t\t];\n\n\tjQuery.Deferred = function( func ) {\n\t\tvar deferred = oldDeferred(),\n\t\t\tpromise = deferred.promise();\n\n\t\tdeferred.pipe = promise.pipe = function( /* fnDone, fnFail, fnProgress */ ) {\n\t\t\tvar fns = arguments;\n\n\t\t\tmigrateWarn( \"deferred.pipe() is deprecated\" );\n\n\t\t\treturn jQuery.Deferred(function( newDefer ) {\n\t\t\t\tjQuery.each( tuples, function( i, tuple ) {\n\t\t\t\t\tvar fn = jQuery.isFunction( fns[ i ] ) && fns[ i ];\n\t\t\t\t\t// deferred.done(function() { bind to newDefer or newDefer.resolve })\n\t\t\t\t\t// deferred.fail(function() { bind to newDefer or newDefer.reject })\n\t\t\t\t\t// deferred.progress(function() { bind to newDefer or newDefer.notify })\n\t\t\t\t\tdeferred[ tuple[1] ](function() {\n\t\t\t\t\t\tvar returned = fn && fn.apply( this, arguments );\n\t\t\t\t\t\tif ( returned && jQuery.isFunction( returned.promise ) ) {\n\t\t\t\t\t\t\treturned.promise()\n\t\t\t\t\t\t\t\t.done( newDefer.resolve )\n\t\t\t\t\t\t\t\t.fail( newDefer.reject )\n\t\t\t\t\t\t\t\t.progress( newDefer.notify );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnewDefer[ tuple[ 0 ] + \"With\" ](\n\t\t\t\t\t\t\t\tthis === promise ? newDefer.promise() : this,\n\t\t\t\t\t\t\t\tfn ? [ returned ] : arguments\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\tfns = null;\n\t\t\t}).promise();\n\n\t\t};\n\n\t\tdeferred.isResolved = function() {\n\t\t\tmigrateWarn( \"deferred.isResolved is deprecated\" );\n\t\t\treturn deferred.state() === \"resolved\";\n\t\t};\n\n\t\tdeferred.isRejected = function() {\n\t\t\tmigrateWarn( \"deferred.isRejected is deprecated\" );\n\t\t\treturn deferred.state() === \"rejected\";\n\t\t};\n\n\t\tif ( func ) {\n\t\t\tfunc.call( deferred, deferred );\n\t\t}\n\n\t\treturn deferred;\n\t};\n\n}\n\n})( jQuery, window );\n\n","jquery/jquery.parsequery.js":"/**\n * Copyright (c) 2010 Conrad Irwin <conrad@rapportive.com> MIT license.\n * Based loosely on original: Copyright (c) 2008 mkmanning MIT license.\n *\n * Parses CGI query strings into javascript objects.\n *\n * See the README for details.\n **/\n/*jshint jquery:true */\n/*global window:true */\ndefine([\n \"jquery\"\n], function($){\n\n $.parseQuery = function(options) {\n var config = {query: window.location.search || \"\"},\n params = {};\n\n if (typeof options === 'string') {\n options = {query: options};\n }\n $.extend(config, $.parseQuery, options);\n config.query = config.query.replace(/^\\?/, '');\n\n $.each(config.query.split(config.separator), function(i, param) {\n var pair = param.split('='),\n key = config.decode(pair.shift(), null).toString(),\n value = config.decode(pair.length ? pair.join('=') : null, key);\n\n if (config.array_keys(key)) {\n params[key] = params[key] || [];\n params[key].push(value);\n } else {\n params[key] = value;\n }\n });\n\n return params;\n };\n\n $.parseQuery.decode = $.parseQuery.default_decode = function(string) {\n return decodeURIComponent((string || \"\").replace('+', ' '));\n };\n\n $.parseQuery.array_keys = function() {\n return false;\n };\n\n $.parseQuery.separator = \"&\";\n\n});\n","jquery/ui-modules/core.js":"/*!\n * jQuery UI Core - v1.10.4\n * http://jqueryui.com\n *\n * Copyright 2014 jQuery Foundation and other contributors\n * Released under the MIT license.\n * http://jquery.org/license\n *\n * http://api.jqueryui.com/category/ui-core/\n */\ndefine([\n 'jquery'\n], function ($, undefined) {\n\n var uuid = 0,\n runiqueId = /^ui-id-\\d+$/;\n\n// $.ui might exist from components with no dependencies, e.g., $.ui.position\n $.ui = $.ui || {};\n\n $.extend($.ui, {\n version: \"1.10.4\",\n\n keyCode: {\n BACKSPACE: 8,\n COMMA: 188,\n DELETE: 46,\n DOWN: 40,\n END: 35,\n ENTER: 13,\n ESCAPE: 27,\n HOME: 36,\n LEFT: 37,\n NUMPAD_ADD: 107,\n NUMPAD_DECIMAL: 110,\n NUMPAD_DIVIDE: 111,\n NUMPAD_ENTER: 108,\n NUMPAD_MULTIPLY: 106,\n NUMPAD_SUBTRACT: 109,\n PAGE_DOWN: 34,\n PAGE_UP: 33,\n PERIOD: 190,\n RIGHT: 39,\n SPACE: 32,\n TAB: 9,\n UP: 38\n }\n });\n\n// plugins\n $.fn.extend({\n focus: (function (orig) {\n return function (delay, fn) {\n return typeof delay === \"number\" ?\n this.each(function () {\n var elem = this;\n setTimeout(function () {\n $(elem).focus();\n if (fn) {\n fn.call(elem);\n }\n }, delay);\n }) :\n orig.apply(this, arguments);\n };\n })($.fn.focus),\n\n scrollParent: function () {\n var scrollParent;\n if (($.ui.ie && (/(static|relative)/).test(this.css(\"position\"))) || (/absolute/).test(this.css(\"position\"))) {\n scrollParent = this.parents().filter(function () {\n return (/(relative|absolute|fixed)/).test($.css(this, \"position\")) && (/(auto|scroll)/).test($.css(this, \"overflow\") + $.css(this, \"overflow-y\") + $.css(this, \"overflow-x\"));\n }).eq(0);\n } else {\n scrollParent = this.parents().filter(function () {\n return (/(auto|scroll)/).test($.css(this, \"overflow\") + $.css(this, \"overflow-y\") + $.css(this, \"overflow-x\"));\n }).eq(0);\n }\n\n return (/fixed/).test(this.css(\"position\")) || !scrollParent.length ? $(document) : scrollParent;\n },\n\n zIndex: function (zIndex) {\n if (zIndex !== undefined) {\n return this.css(\"zIndex\", zIndex);\n }\n\n if (this.length) {\n var elem = $(this[0]), position, value;\n while (elem.length && elem[0] !== document) {\n // Ignore z-index if position is set to a value where z-index is ignored by the browser\n // This makes behavior of this function consistent across browsers\n // WebKit always returns auto if the element is positioned\n position = elem.css(\"position\");\n if (position === \"absolute\" || position === \"relative\" || position === \"fixed\") {\n // IE returns 0 when zIndex is not specified\n // other browsers return a string\n // we ignore the case of nested elements with an explicit value of 0\n // <div style=\"z-index: -10;\"><div style=\"z-index: 0;\"></div></div>\n value = parseInt(elem.css(\"zIndex\"), 10);\n if (!isNaN(value) && value !== 0) {\n return value;\n }\n }\n elem = elem.parent();\n }\n }\n\n return 0;\n },\n\n uniqueId: function () {\n return this.each(function () {\n if (!this.id) {\n this.id = \"ui-id-\" + (++uuid);\n }\n });\n },\n\n removeUniqueId: function () {\n return this.each(function () {\n if (runiqueId.test(this.id)) {\n $(this).removeAttr(\"id\");\n }\n });\n }\n });\n\n// selectors\n function focusable(element, isTabIndexNotNaN) {\n var map, mapName, img,\n nodeName = element.nodeName.toLowerCase();\n if (\"area\" === nodeName) {\n map = element.parentNode;\n mapName = map.name;\n if (!element.href || !mapName || map.nodeName.toLowerCase() !== \"map\") {\n return false;\n }\n img = $(\"img[usemap=#\" + mapName + \"]\")[0];\n return !!img && visible(img);\n }\n return (/input|select|textarea|button|object/.test(nodeName) ?\n !element.disabled :\n \"a\" === nodeName ?\n element.href || isTabIndexNotNaN :\n isTabIndexNotNaN) &&\n // the element and all of its ancestors must be visible\n visible(element);\n }\n\n function visible(element) {\n return $.expr.filters.visible(element) &&\n !$(element).parents().addBack().filter(function () {\n return $.css(this, \"visibility\") === \"hidden\";\n }).length;\n }\n\n $.extend($.expr[\":\"], {\n data: $.expr.createPseudo ?\n $.expr.createPseudo(function (dataName) {\n return function (elem) {\n return !!$.data(elem, dataName);\n };\n }) :\n // support: jQuery <1.8\n function (elem, i, match) {\n return !!$.data(elem, match[3]);\n },\n\n focusable: function (element) {\n return focusable(element, !isNaN($.attr(element, \"tabindex\")));\n },\n\n tabbable: function (element) {\n var tabIndex = $.attr(element, \"tabindex\"),\n isTabIndexNaN = isNaN(tabIndex);\n return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN);\n }\n });\n\n// support: jQuery <1.8\n if (!$(\"<a>\").outerWidth(1).jquery) {\n $.each([\"Width\", \"Height\"], function (i, name) {\n var side = name === \"Width\" ? [\"Left\", \"Right\"] : [\"Top\", \"Bottom\"],\n type = name.toLowerCase(),\n orig = {\n innerWidth: $.fn.innerWidth,\n innerHeight: $.fn.innerHeight,\n outerWidth: $.fn.outerWidth,\n outerHeight: $.fn.outerHeight\n };\n\n function reduce(elem, size, border, margin) {\n $.each(side, function () {\n size -= parseFloat($.css(elem, \"padding\" + this)) || 0;\n if (border) {\n size -= parseFloat($.css(elem, \"border\" + this + \"Width\")) || 0;\n }\n if (margin) {\n size -= parseFloat($.css(elem, \"margin\" + this)) || 0;\n }\n });\n return size;\n }\n\n $.fn[\"inner\" + name] = function (size) {\n if (size === undefined) {\n return orig[\"inner\" + name].call(this);\n }\n\n return this.each(function () {\n $(this).css(type, reduce(this, size) + \"px\");\n });\n };\n\n $.fn[\"outer\" + name] = function (size, margin) {\n if (typeof size !== \"number\") {\n return orig[\"outer\" + name].call(this, size);\n }\n\n return this.each(function () {\n $(this).css(type, reduce(this, size, true, margin) + \"px\");\n });\n };\n });\n }\n\n// support: jQuery <1.8\n if (!$.fn.addBack) {\n $.fn.addBack = function (selector) {\n return this.add(selector == null ?\n this.prevObject : this.prevObject.filter(selector)\n );\n };\n }\n\n// support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)\n if ($(\"<a>\").data(\"a-b\", \"a\").removeData(\"a-b\").data(\"a-b\")) {\n $.fn.removeData = (function (removeData) {\n return function (key) {\n if (arguments.length) {\n return removeData.call(this, $.camelCase(key));\n } else {\n return removeData.call(this);\n }\n };\n })($.fn.removeData);\n }\n\n\n// deprecated\n $.ui.ie = !!/msie [\\w.]+/.exec(navigator.userAgent.toLowerCase());\n\n $.support.selectstart = \"onselectstart\" in document.createElement(\"div\");\n $.fn.extend({\n disableSelection: function () {\n return this.bind(($.support.selectstart ? \"selectstart\" : \"mousedown\") +\n \".ui-disableSelection\", function (event) {\n event.preventDefault();\n });\n },\n\n enableSelection: function () {\n return this.unbind(\".ui-disableSelection\");\n }\n });\n\n $.extend($.ui, {\n // $.ui.plugin is deprecated. Use $.widget() extensions instead.\n plugin: {\n add: function (module, option, set) {\n var i,\n proto = $.ui[module].prototype;\n for (i in set) {\n proto.plugins[i] = proto.plugins[i] || [];\n proto.plugins[i].push([option, set[i]]);\n }\n },\n call: function (instance, name, args) {\n var i,\n set = instance.plugins[name];\n if (!set || !instance.element[0].parentNode || instance.element[0].parentNode.nodeType === 11) {\n return;\n }\n\n for (i = 0; i < set.length; i++) {\n if (instance.options[set[i][0]]) {\n set[i][1].apply(instance.element, args);\n }\n }\n }\n },\n\n // only used by resizable\n hasScroll: function (el, a) {\n\n //If overflow is hidden, the element might have extra content, but the user wants to hide it\n if ($(el).css(\"overflow\") === \"hidden\") {\n return false;\n }\n\n var scroll = (a && a === \"left\") ? \"scrollLeft\" : \"scrollTop\",\n has = false;\n\n if (el[scroll] > 0) {\n return true;\n }\n\n // TODO: determine which cases actually cause this to happen\n // if the element doesn't have the scroll set, see if it's possible to\n // set the scroll\n el[scroll] = 1;\n has = (el[scroll] > 0);\n el[scroll] = 0;\n return has;\n }\n });\n\n});\n","jquery/ui-modules/widget.js":"/*!\n * jQuery UI Widget - v1.10.4\n * http://jqueryui.com\n *\n * Copyright 2014 jQuery Foundation and other contributors\n * Released under the MIT license.\n * http://jquery.org/license\n *\n * http://api.jqueryui.com/jQuery.widget/\n */\n\ndefine([\n 'jquery'\n], function ($, undefined) {\n\n var uuid = 0,\n slice = Array.prototype.slice,\n _cleanData = $.cleanData;\n $.cleanData = function (elems) {\n for (var i = 0, elem; (elem = elems[i]) != null; i++) {\n try {\n $(elem).triggerHandler(\"remove\");\n // http://bugs.jquery.com/ticket/8235\n } catch (e) {\n }\n }\n _cleanData(elems);\n };\n\n $.widget = function (name, base, prototype) {\n var fullName, existingConstructor, constructor, basePrototype,\n // proxiedPrototype allows the provided prototype to remain unmodified\n // so that it can be used as a mixin for multiple widgets (#8876)\n proxiedPrototype = {},\n namespace = name.split(\".\")[0];\n\n name = name.split(\".\")[1];\n fullName = namespace + \"-\" + name;\n\n if (!prototype) {\n prototype = base;\n base = $.Widget;\n }\n\n // create selector for plugin\n $.expr[\":\"][fullName.toLowerCase()] = function (elem) {\n return !!$.data(elem, fullName);\n };\n\n $[namespace] = $[namespace] || {};\n existingConstructor = $[namespace][name];\n constructor = $[namespace][name] = function (options, element) {\n // allow instantiation without \"new\" keyword\n if (!this._createWidget) {\n return new constructor(options, element);\n }\n\n // allow instantiation without initializing for simple inheritance\n // must use \"new\" keyword (the code above always passes args)\n if (arguments.length) {\n this._createWidget(options, element);\n }\n };\n // extend with the existing constructor to carry over any static properties\n $.extend(constructor, existingConstructor, {\n version: prototype.version,\n // copy the object used to create the prototype in case we need to\n // redefine the widget later\n _proto: $.extend({}, prototype),\n // track widgets that inherit from this widget in case this widget is\n // redefined after a widget inherits from it\n _childConstructors: []\n });\n\n basePrototype = new base();\n // we need to make the options hash a property directly on the new instance\n // otherwise we'll modify the options hash on the prototype that we're\n // inheriting from\n basePrototype.options = $.widget.extend({}, basePrototype.options);\n $.each(prototype, function (prop, value) {\n if (!$.isFunction(value)) {\n proxiedPrototype[prop] = value;\n return;\n }\n proxiedPrototype[prop] = (function () {\n var _super = function () {\n return base.prototype[prop].apply(this, arguments);\n },\n _superApply = function (args) {\n return base.prototype[prop].apply(this, args);\n };\n return function () {\n var __super = this._super,\n __superApply = this._superApply,\n returnValue;\n\n this._super = _super;\n this._superApply = _superApply;\n\n returnValue = value.apply(this, arguments);\n\n this._super = __super;\n this._superApply = __superApply;\n\n return returnValue;\n };\n })();\n });\n constructor.prototype = $.widget.extend(basePrototype, {\n // TODO: remove support for widgetEventPrefix\n // always use the name + a colon as the prefix, e.g., draggable:start\n // don't prefix for widgets that aren't DOM-based\n widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name\n }, proxiedPrototype, {\n constructor: constructor,\n namespace: namespace,\n widgetName: name,\n widgetFullName: fullName\n });\n\n // If this widget is being redefined then we need to find all widgets that\n // are inheriting from it and redefine all of them so that they inherit from\n // the new version of this widget. We're essentially trying to replace one\n // level in the prototype chain.\n if (existingConstructor) {\n $.each(existingConstructor._childConstructors, function (i, child) {\n var childPrototype = child.prototype;\n\n // redefine the child widget using the same prototype that was\n // originally used, but inherit from the new version of the base\n $.widget(childPrototype.namespace + \".\" + childPrototype.widgetName, constructor, child._proto);\n });\n // remove the list of existing child constructors from the old constructor\n // so the old child constructors can be garbage collected\n delete existingConstructor._childConstructors;\n } else {\n base._childConstructors.push(constructor);\n }\n\n $.widget.bridge(name, constructor);\n };\n\n $.widget.extend = function (target) {\n var input = slice.call(arguments, 1),\n inputIndex = 0,\n inputLength = input.length,\n key,\n value;\n for (; inputIndex < inputLength; inputIndex++) {\n for (key in input[inputIndex]) {\n value = input[inputIndex][key];\n if (input[inputIndex].hasOwnProperty(key) && value !== undefined) {\n // Clone objects\n if ($.isPlainObject(value)) {\n target[key] = $.isPlainObject(target[key]) ?\n $.widget.extend({}, target[key], value) :\n // Don't extend strings, arrays, etc. with objects\n $.widget.extend({}, value);\n // Copy everything else by reference\n } else {\n target[key] = value;\n }\n }\n }\n }\n return target;\n };\n\n $.widget.bridge = function (name, object) {\n var fullName = object.prototype.widgetFullName || name;\n $.fn[name] = function (options) {\n var isMethodCall = typeof options === \"string\",\n args = slice.call(arguments, 1),\n returnValue = this;\n\n // allow multiple hashes to be passed on init\n options = !isMethodCall && args.length ?\n $.widget.extend.apply(null, [options].concat(args)) :\n options;\n\n if (isMethodCall) {\n this.each(function () {\n var methodValue,\n instance = $.data(this, fullName);\n if (!instance) {\n return $.error(\"cannot call methods on \" + name + \" prior to initialization; \" +\n \"attempted to call method '\" + options + \"'\");\n }\n if (!$.isFunction(instance[options]) || options.charAt(0) === \"_\") {\n return $.error(\"no such method '\" + options + \"' for \" + name + \" widget instance\");\n }\n methodValue = instance[options].apply(instance, args);\n if (methodValue !== instance && methodValue !== undefined) {\n returnValue = methodValue && methodValue.jquery ?\n returnValue.pushStack(methodValue.get()) :\n methodValue;\n return false;\n }\n });\n } else {\n this.each(function () {\n var instance = $.data(this, fullName);\n if (instance) {\n instance.option(options || {})._init();\n } else {\n $.data(this, fullName, new object(options, this));\n }\n });\n }\n\n return returnValue;\n };\n };\n\n $.Widget = function ( /* options, element */) {\n };\n $.Widget._childConstructors = [];\n\n $.Widget.prototype = {\n widgetName: \"widget\",\n widgetEventPrefix: \"\",\n defaultElement: \"<div>\",\n options: {\n disabled: false,\n\n // callbacks\n create: null\n },\n _createWidget: function (options, element) {\n element = $(element || this.defaultElement || this)[0];\n this.element = $(element);\n this.uuid = uuid++;\n this.eventNamespace = \".\" + this.widgetName + this.uuid;\n this.options = $.widget.extend({},\n this.options,\n this._getCreateOptions(),\n options);\n\n this.bindings = $();\n this.hoverable = $();\n this.focusable = $();\n\n if (element !== this) {\n $.data(element, this.widgetFullName, this);\n this._on(true, this.element, {\n remove: function (event) {\n if (event.target === element) {\n this.destroy();\n }\n }\n });\n this.document = $(element.style ?\n // element within the document\n element.ownerDocument :\n // element is window or document\n element.document || element);\n this.window = $(this.document[0].defaultView || this.document[0].parentWindow);\n }\n\n this._create();\n this._trigger(\"create\", null, this._getCreateEventData());\n this._init();\n },\n _getCreateOptions: $.noop,\n _getCreateEventData: $.noop,\n _create: $.noop,\n _init: $.noop,\n\n destroy: function () {\n this._destroy();\n // we can probably remove the unbind calls in 2.0\n // all event bindings should go through this._on()\n this.element\n .unbind(this.eventNamespace)\n // 1.9 BC for #7810\n // TODO remove dual storage\n .removeData(this.widgetName)\n .removeData(this.widgetFullName)\n // support: jquery <1.6.3\n // http://bugs.jquery.com/ticket/9413\n .removeData($.camelCase(this.widgetFullName));\n this.widget()\n .unbind(this.eventNamespace)\n .removeAttr(\"aria-disabled\")\n .removeClass(\n this.widgetFullName + \"-disabled \" +\n \"ui-state-disabled\");\n\n // clean up events and states\n this.bindings.unbind(this.eventNamespace);\n this.hoverable.removeClass(\"ui-state-hover\");\n this.focusable.removeClass(\"ui-state-focus\");\n },\n _destroy: $.noop,\n\n widget: function () {\n return this.element;\n },\n\n option: function (key, value) {\n var options = key,\n parts,\n curOption,\n i;\n\n if (arguments.length === 0) {\n // don't return a reference to the internal hash\n return $.widget.extend({}, this.options);\n }\n\n if (typeof key === \"string\") {\n // handle nested keys, e.g., \"foo.bar\" => { foo: { bar: ___ } }\n options = {};\n parts = key.split(\".\");\n key = parts.shift();\n if (parts.length) {\n curOption = options[key] = $.widget.extend({}, this.options[key]);\n for (i = 0; i < parts.length - 1; i++) {\n curOption[parts[i]] = curOption[parts[i]] || {};\n curOption = curOption[parts[i]];\n }\n key = parts.pop();\n if (arguments.length === 1) {\n return curOption[key] === undefined ? null : curOption[key];\n }\n curOption[key] = value;\n } else {\n if (arguments.length === 1) {\n return this.options[key] === undefined ? null : this.options[key];\n }\n options[key] = value;\n }\n }\n\n this._setOptions(options);\n\n return this;\n },\n _setOptions: function (options) {\n var key;\n\n for (key in options) {\n this._setOption(key, options[key]);\n }\n\n return this;\n },\n _setOption: function (key, value) {\n this.options[key] = value;\n\n if (key === \"disabled\") {\n this.widget()\n .toggleClass(this.widgetFullName + \"-disabled ui-state-disabled\", !!value)\n .attr(\"aria-disabled\", value);\n this.hoverable.removeClass(\"ui-state-hover\");\n this.focusable.removeClass(\"ui-state-focus\");\n }\n\n return this;\n },\n\n enable: function () {\n return this._setOption(\"disabled\", false);\n },\n disable: function () {\n return this._setOption(\"disabled\", true);\n },\n\n _on: function (suppressDisabledCheck, element, handlers) {\n var delegateElement,\n instance = this;\n\n // no suppressDisabledCheck flag, shuffle arguments\n if (typeof suppressDisabledCheck !== \"boolean\") {\n handlers = element;\n element = suppressDisabledCheck;\n suppressDisabledCheck = false;\n }\n\n // no element argument, shuffle and use this.element\n if (!handlers) {\n handlers = element;\n element = this.element;\n delegateElement = this.widget();\n } else {\n // accept selectors, DOM elements\n element = delegateElement = $(element);\n this.bindings = this.bindings.add(element);\n }\n\n $.each(handlers, function (event, handler) {\n function handlerProxy() {\n // allow widgets to customize the disabled handling\n // - disabled as an array instead of boolean\n // - disabled class as method for disabling individual parts\n if (!suppressDisabledCheck &&\n (instance.options.disabled === true ||\n $(this).hasClass(\"ui-state-disabled\"))) {\n return;\n }\n return (typeof handler === \"string\" ? instance[handler] : handler)\n .apply(instance, arguments);\n }\n\n // copy the guid so direct unbinding works\n if (typeof handler !== \"string\") {\n handlerProxy.guid = handler.guid =\n handler.guid || handlerProxy.guid || $.guid++;\n }\n\n var match = event.match(/^(\\w+)\\s*(.*)$/),\n eventName = match[1] + instance.eventNamespace,\n selector = match[2];\n if (selector) {\n delegateElement.delegate(selector, eventName, handlerProxy);\n } else {\n element.bind(eventName, handlerProxy);\n }\n });\n },\n\n _off: function (element, eventName) {\n eventName = (eventName || \"\").split(\" \").join(this.eventNamespace + \" \") + this.eventNamespace;\n element.unbind(eventName).undelegate(eventName);\n },\n\n _delay: function (handler, delay) {\n function handlerProxy() {\n return (typeof handler === \"string\" ? instance[handler] : handler)\n .apply(instance, arguments);\n }\n\n var instance = this;\n return setTimeout(handlerProxy, delay || 0);\n },\n\n _hoverable: function (element) {\n this.hoverable = this.hoverable.add(element);\n this._on(element, {\n mouseenter: function (event) {\n $(event.currentTarget).addClass(\"ui-state-hover\");\n },\n mouseleave: function (event) {\n $(event.currentTarget).removeClass(\"ui-state-hover\");\n }\n });\n },\n\n _focusable: function (element) {\n this.focusable = this.focusable.add(element);\n this._on(element, {\n focusin: function (event) {\n $(event.currentTarget).addClass(\"ui-state-focus\");\n },\n focusout: function (event) {\n $(event.currentTarget).removeClass(\"ui-state-focus\");\n }\n });\n },\n\n _trigger: function (type, event, data) {\n var prop, orig,\n callback = this.options[type];\n\n data = data || {};\n event = $.Event(event);\n event.type = (type === this.widgetEventPrefix ?\n type :\n this.widgetEventPrefix + type).toLowerCase();\n // the original event may come from any element\n // so we need to reset the target on the new event\n event.target = this.element[0];\n\n // copy original event properties over to the new event\n orig = event.originalEvent;\n if (orig) {\n for (prop in orig) {\n if (!(prop in event)) {\n event[prop] = orig[prop];\n }\n }\n }\n\n this.element.trigger(event, data);\n return !($.isFunction(callback) &&\n callback.apply(this.element[0], [event].concat(data)) === false ||\n event.isDefaultPrevented());\n }\n };\n\n $.each({show: \"fadeIn\", hide: \"fadeOut\"}, function (method, defaultEffect) {\n $.Widget.prototype[\"_\" + method] = function (element, options, callback) {\n if (typeof options === \"string\") {\n options = {effect: options};\n }\n var hasOptions,\n effectName = !options ?\n method :\n options === true || typeof options === \"number\" ?\n defaultEffect :\n options.effect || defaultEffect;\n options = options || {};\n if (typeof options === \"number\") {\n options = {duration: options};\n }\n hasOptions = !$.isEmptyObject(options);\n options.complete = callback;\n if (options.delay) {\n element.delay(options.delay);\n }\n if (hasOptions && $.effects && $.effects.effect[effectName]) {\n element[method](options);\n } else if (effectName !== method && element[effectName]) {\n element[effectName](options.duration, options.easing, callback);\n } else {\n element.queue(function (next) {\n $(this)[method]();\n if (callback) {\n callback.call(element[0]);\n }\n next();\n });\n }\n };\n });\n\n});\n","jquery/spectrum/spectrum.js":"// Spectrum Colorpicker v1.8.0\n// https://github.com/bgrins/spectrum\n// Author: Brian Grinstead\n// License: MIT\n\n(function (factory) {\n \"use strict\";\n\n if (typeof define === 'function' && define.amd) { // AMD\n define(['jquery'], factory);\n }\n else if (typeof exports == \"object\" && typeof module == \"object\") { // CommonJS\n module.exports = factory(require('jquery'));\n }\n else { // Browser\n factory(jQuery);\n }\n})(function($, undefined) {\n \"use strict\";\n\n var defaultOpts = {\n\n // Callbacks\n beforeShow: noop,\n move: noop,\n change: noop,\n show: noop,\n hide: noop,\n\n // Options\n color: false,\n flat: false,\n showInput: false,\n allowEmpty: false,\n showButtons: true,\n clickoutFiresChange: true,\n showInitial: false,\n showPalette: false,\n showPaletteOnly: false,\n hideAfterPaletteSelect: false,\n togglePaletteOnly: false,\n showSelectionPalette: true,\n localStorageKey: false,\n appendTo: \"body\",\n maxSelectionSize: 7,\n cancelText: \"cancel\",\n chooseText: \"choose\",\n togglePaletteMoreText: \"more\",\n togglePaletteLessText: \"less\",\n clearText: \"Clear Color Selection\",\n noColorSelectedText: \"No Color Selected\",\n preferredFormat: false,\n className: \"\", // Deprecated - use containerClassName and replacerClassName instead.\n containerClassName: \"\",\n replacerClassName: \"\",\n showAlpha: false,\n theme: \"sp-light\",\n palette: [[\"#ffffff\", \"#000000\", \"#ff0000\", \"#ff8000\", \"#ffff00\", \"#008000\", \"#0000ff\", \"#4b0082\", \"#9400d3\"]],\n selectionPalette: [],\n disabled: false,\n offset: null\n },\n spectrums = [],\n IE = !!/msie/i.exec( window.navigator.userAgent ),\n rgbaSupport = (function() {\n function contains( str, substr ) {\n return !!~('' + str).indexOf(substr);\n }\n\n var elem = document.createElement('div');\n var style = elem.style;\n style.cssText = 'background-color:rgba(0,0,0,.5)';\n return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');\n })(),\n replaceInput = [\n \"<div class='sp-replacer'>\",\n \"<div class='sp-preview'><div class='sp-preview-inner'></div></div>\",\n \"<div class='sp-dd'>▼</div>\",\n \"</div>\"\n ].join(''),\n markup = (function () {\n\n // IE does not support gradients with multiple stops, so we need to simulate\n // that for the rainbow slider with 8 divs that each have a single gradient\n var gradientFix = \"\";\n if (IE) {\n for (var i = 1; i <= 6; i++) {\n gradientFix += \"<div class='sp-\" + i + \"'></div>\";\n }\n }\n\n return [\n \"<div class='sp-container sp-hidden'>\",\n \"<div class='sp-palette-container'>\",\n \"<div class='sp-palette sp-thumb sp-cf'></div>\",\n \"<div class='sp-palette-button-container sp-cf'>\",\n \"<button type='button' class='sp-palette-toggle'></button>\",\n \"</div>\",\n \"</div>\",\n \"<div class='sp-picker-container'>\",\n \"<div class='sp-top sp-cf'>\",\n \"<div class='sp-fill'></div>\",\n \"<div class='sp-top-inner'>\",\n \"<div class='sp-color'>\",\n \"<div class='sp-sat'>\",\n \"<div class='sp-val'>\",\n \"<div class='sp-dragger'></div>\",\n \"</div>\",\n \"</div>\",\n \"</div>\",\n \"<div class='sp-clear sp-clear-display'>\",\n \"</div>\",\n \"<div class='sp-hue'>\",\n \"<div class='sp-slider'></div>\",\n gradientFix,\n \"</div>\",\n \"</div>\",\n \"<div class='sp-alpha'><div class='sp-alpha-inner'><div class='sp-alpha-handle'></div></div></div>\",\n \"</div>\",\n \"<div class='sp-input-container sp-cf'>\",\n \"<input class='sp-input' type='text' spellcheck='false' />\",\n \"</div>\",\n \"<div class='sp-initial sp-thumb sp-cf'></div>\",\n \"<div class='sp-button-container sp-cf'>\",\n \"<a class='sp-cancel' href='#'></a>\",\n \"<button type='button' class='sp-choose'></button>\",\n \"</div>\",\n \"</div>\",\n \"</div>\"\n ].join(\"\");\n })();\n\n function paletteTemplate (p, color, className, opts) {\n var html = [];\n for (var i = 0; i < p.length; i++) {\n var current = p[i];\n if(current) {\n var tiny = tinycolor(current);\n var c = tiny.toHsl().l < 0.5 ? \"sp-thumb-el sp-thumb-dark\" : \"sp-thumb-el sp-thumb-light\";\n c += (tinycolor.equals(color, current)) ? \" sp-thumb-active\" : \"\";\n var formattedString = tiny.toString(opts.preferredFormat || \"rgb\");\n var swatchStyle = rgbaSupport ? (\"background-color:\" + tiny.toRgbString()) : \"filter:\" + tiny.toFilter();\n html.push('<span title=\"' + formattedString + '\" data-color=\"' + tiny.toRgbString() + '\" class=\"' + c + '\"><span class=\"sp-thumb-inner\" style=\"' + swatchStyle + ';\" /></span>');\n } else {\n var cls = 'sp-clear-display';\n html.push($('<div />')\n .append($('<span data-color=\"\" style=\"background-color:transparent;\" class=\"' + cls + '\"></span>')\n .attr('title', opts.noColorSelectedText)\n )\n .html()\n );\n }\n }\n return \"<div class='sp-cf \" + className + \"'>\" + html.join('') + \"</div>\";\n }\n\n function hideAll() {\n for (var i = 0; i < spectrums.length; i++) {\n if (spectrums[i]) {\n spectrums[i].hide();\n }\n }\n }\n\n function instanceOptions(o, callbackContext) {\n var opts = $.extend({}, defaultOpts, o);\n opts.callbacks = {\n 'move': bind(opts.move, callbackContext),\n 'change': bind(opts.change, callbackContext),\n 'show': bind(opts.show, callbackContext),\n 'hide': bind(opts.hide, callbackContext),\n 'beforeShow': bind(opts.beforeShow, callbackContext)\n };\n\n return opts;\n }\n\n function spectrum(element, o) {\n\n var opts = instanceOptions(o, element),\n flat = opts.flat,\n showSelectionPalette = opts.showSelectionPalette,\n localStorageKey = opts.localStorageKey,\n theme = opts.theme,\n callbacks = opts.callbacks,\n resize = throttle(reflow, 10),\n visible = false,\n isDragging = false,\n dragWidth = 0,\n dragHeight = 0,\n dragHelperHeight = 0,\n slideHeight = 0,\n slideWidth = 0,\n alphaWidth = 0,\n alphaSlideHelperWidth = 0,\n slideHelperHeight = 0,\n currentHue = 0,\n currentSaturation = 0,\n currentValue = 0,\n currentAlpha = 1,\n palette = [],\n paletteArray = [],\n paletteLookup = {},\n selectionPalette = opts.selectionPalette.slice(0),\n maxSelectionSize = opts.maxSelectionSize,\n draggingClass = \"sp-dragging\",\n shiftMovementDirection = null;\n\n var doc = element.ownerDocument,\n body = doc.body,\n boundElement = $(element),\n disabled = false,\n container = $(markup, doc).addClass(theme),\n pickerContainer = container.find(\".sp-picker-container\"),\n dragger = container.find(\".sp-color\"),\n dragHelper = container.find(\".sp-dragger\"),\n slider = container.find(\".sp-hue\"),\n slideHelper = container.find(\".sp-slider\"),\n alphaSliderInner = container.find(\".sp-alpha-inner\"),\n alphaSlider = container.find(\".sp-alpha\"),\n alphaSlideHelper = container.find(\".sp-alpha-handle\"),\n textInput = container.find(\".sp-input\"),\n paletteContainer = container.find(\".sp-palette\"),\n initialColorContainer = container.find(\".sp-initial\"),\n cancelButton = container.find(\".sp-cancel\"),\n clearButton = container.find(\".sp-clear\"),\n chooseButton = container.find(\".sp-choose\"),\n toggleButton = container.find(\".sp-palette-toggle\"),\n isInput = boundElement.is(\"input\"),\n isInputTypeColor = isInput && boundElement.attr(\"type\") === \"color\" && inputTypeColorSupport(),\n shouldReplace = isInput && !flat,\n replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),\n offsetElement = (shouldReplace) ? replacer : boundElement,\n previewElement = replacer.find(\".sp-preview-inner\"),\n initialColor = opts.color || (isInput && boundElement.val()),\n colorOnShow = false,\n currentPreferredFormat = opts.preferredFormat,\n clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,\n isEmpty = !initialColor,\n allowEmpty = opts.allowEmpty && !isInputTypeColor;\n\n function applyOptions() {\n\n if (opts.showPaletteOnly) {\n opts.showPalette = true;\n }\n\n toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);\n\n if (opts.palette) {\n palette = opts.palette.slice(0);\n paletteArray = $.isArray(palette[0]) ? palette : [palette];\n paletteLookup = {};\n for (var i = 0; i < paletteArray.length; i++) {\n for (var j = 0; j < paletteArray[i].length; j++) {\n var rgb = tinycolor(paletteArray[i][j]).toRgbString();\n paletteLookup[rgb] = true;\n }\n }\n }\n\n container.toggleClass(\"sp-flat\", flat);\n container.toggleClass(\"sp-input-disabled\", !opts.showInput);\n container.toggleClass(\"sp-alpha-enabled\", opts.showAlpha);\n container.toggleClass(\"sp-clear-enabled\", allowEmpty);\n container.toggleClass(\"sp-buttons-disabled\", !opts.showButtons);\n container.toggleClass(\"sp-palette-buttons-disabled\", !opts.togglePaletteOnly);\n container.toggleClass(\"sp-palette-disabled\", !opts.showPalette);\n container.toggleClass(\"sp-palette-only\", opts.showPaletteOnly);\n container.toggleClass(\"sp-initial-disabled\", !opts.showInitial);\n container.addClass(opts.className).addClass(opts.containerClassName);\n\n reflow();\n }\n\n function initialize() {\n\n if (IE) {\n container.find(\"*:not(input)\").attr(\"unselectable\", \"on\");\n }\n\n applyOptions();\n\n if (shouldReplace) {\n boundElement.after(replacer).hide();\n }\n\n if (!allowEmpty) {\n clearButton.hide();\n }\n\n if (flat) {\n boundElement.after(container).hide();\n }\n else {\n\n var appendTo = opts.appendTo === \"parent\" ? boundElement.parent() : $(opts.appendTo);\n if (appendTo.length !== 1) {\n appendTo = $(\"body\");\n }\n\n appendTo.append(container);\n }\n\n updateSelectionPaletteFromStorage();\n\n offsetElement.bind(\"click.spectrum touchstart.spectrum\", function (e) {\n if (!disabled) {\n toggle();\n }\n\n e.stopPropagation();\n\n if (!$(e.target).is(\"input\")) {\n e.preventDefault();\n }\n });\n\n if(boundElement.is(\":disabled\") || (opts.disabled === true)) {\n disable();\n }\n\n // Prevent clicks from bubbling up to document. This would cause it to be hidden.\n container.click(stopPropagation);\n\n // Handle user typed input\n textInput.change(setFromTextInput);\n textInput.bind(\"paste\", function () {\n setTimeout(setFromTextInput, 1);\n });\n textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });\n\n cancelButton.text(opts.cancelText);\n cancelButton.bind(\"click.spectrum\", function (e) {\n e.stopPropagation();\n e.preventDefault();\n revert();\n hide();\n });\n\n clearButton.attr(\"title\", opts.clearText);\n clearButton.bind(\"click.spectrum\", function (e) {\n e.stopPropagation();\n e.preventDefault();\n isEmpty = true;\n move();\n\n if(flat) {\n //for the flat style, this is a change event\n updateOriginalInput(true);\n }\n });\n\n chooseButton.text(opts.chooseText);\n chooseButton.bind(\"click.spectrum\", function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n if (IE && textInput.is(\":focus\")) {\n textInput.trigger('change');\n }\n\n if (isValid()) {\n updateOriginalInput(true);\n hide();\n }\n });\n\n toggleButton.text(opts.showPaletteOnly ? opts.togglePaletteMoreText : opts.togglePaletteLessText);\n toggleButton.bind(\"click.spectrum\", function (e) {\n e.stopPropagation();\n e.preventDefault();\n\n opts.showPaletteOnly = !opts.showPaletteOnly;\n\n // To make sure the Picker area is drawn on the right, next to the\n // Palette area (and not below the palette), first move the Palette\n // to the left to make space for the picker, plus 5px extra.\n // The 'applyOptions' function puts the whole container back into place\n // and takes care of the button-text and the sp-palette-only CSS class.\n if (!opts.showPaletteOnly && !flat) {\n container.css('left', '-=' + (pickerContainer.outerWidth(true) + 5));\n }\n applyOptions();\n });\n\n draggable(alphaSlider, function (dragX, dragY, e) {\n currentAlpha = (dragX / alphaWidth);\n isEmpty = false;\n if (e.shiftKey) {\n currentAlpha = Math.round(currentAlpha * 10) / 10;\n }\n\n move();\n }, dragStart, dragStop);\n\n draggable(slider, function (dragX, dragY) {\n currentHue = parseFloat(dragY / slideHeight);\n isEmpty = false;\n if (!opts.showAlpha) {\n currentAlpha = 1;\n }\n move();\n }, dragStart, dragStop);\n\n draggable(dragger, function (dragX, dragY, e) {\n\n // shift+drag should snap the movement to either the x or y axis.\n if (!e.shiftKey) {\n shiftMovementDirection = null;\n }\n else if (!shiftMovementDirection) {\n var oldDragX = currentSaturation * dragWidth;\n var oldDragY = dragHeight - (currentValue * dragHeight);\n var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);\n\n shiftMovementDirection = furtherFromX ? \"x\" : \"y\";\n }\n\n var setSaturation = !shiftMovementDirection || shiftMovementDirection === \"x\";\n var setValue = !shiftMovementDirection || shiftMovementDirection === \"y\";\n\n if (setSaturation) {\n currentSaturation = parseFloat(dragX / dragWidth);\n }\n if (setValue) {\n currentValue = parseFloat((dragHeight - dragY) / dragHeight);\n }\n\n isEmpty = false;\n if (!opts.showAlpha) {\n currentAlpha = 1;\n }\n\n move();\n\n }, dragStart, dragStop);\n\n if (!!initialColor) {\n set(initialColor);\n\n // In case color was black - update the preview UI and set the format\n // since the set function will not run (default color is black).\n updateUI();\n currentPreferredFormat = opts.preferredFormat || tinycolor(initialColor).format;\n\n addColorToSelectionPalette(initialColor);\n }\n else {\n updateUI();\n }\n\n if (flat) {\n show();\n }\n\n function paletteElementClick(e) {\n if (e.data && e.data.ignore) {\n set($(e.target).closest(\".sp-thumb-el\").data(\"color\"));\n move();\n }\n else {\n set($(e.target).closest(\".sp-thumb-el\").data(\"color\"));\n move();\n updateOriginalInput(true);\n if (opts.hideAfterPaletteSelect) {\n hide();\n }\n }\n\n return false;\n }\n\n var paletteEvent = IE ? \"mousedown.spectrum\" : \"click.spectrum touchstart.spectrum\";\n paletteContainer.delegate(\".sp-thumb-el\", paletteEvent, paletteElementClick);\n initialColorContainer.delegate(\".sp-thumb-el:nth-child(1)\", paletteEvent, { ignore: true }, paletteElementClick);\n }\n\n function updateSelectionPaletteFromStorage() {\n\n if (localStorageKey && window.localStorage) {\n\n // Migrate old palettes over to new format. May want to remove this eventually.\n try {\n var oldPalette = window.localStorage[localStorageKey].split(\",#\");\n if (oldPalette.length > 1) {\n delete window.localStorage[localStorageKey];\n $.each(oldPalette, function(i, c) {\n addColorToSelectionPalette(c);\n });\n }\n }\n catch(e) { }\n\n try {\n selectionPalette = window.localStorage[localStorageKey].split(\";\");\n }\n catch (e) { }\n }\n }\n\n function addColorToSelectionPalette(color) {\n if (showSelectionPalette) {\n var rgb = tinycolor(color).toRgbString();\n if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {\n selectionPalette.push(rgb);\n while(selectionPalette.length > maxSelectionSize) {\n selectionPalette.shift();\n }\n }\n\n if (localStorageKey && window.localStorage) {\n try {\n window.localStorage[localStorageKey] = selectionPalette.join(\";\");\n }\n catch(e) { }\n }\n }\n }\n\n function getUniqueSelectionPalette() {\n var unique = [];\n if (opts.showPalette) {\n for (var i = 0; i < selectionPalette.length; i++) {\n var rgb = tinycolor(selectionPalette[i]).toRgbString();\n\n if (!paletteLookup[rgb]) {\n unique.push(selectionPalette[i]);\n }\n }\n }\n\n return unique.reverse().slice(0, opts.maxSelectionSize);\n }\n\n function drawPalette() {\n\n var currentColor = get();\n\n var html = $.map(paletteArray, function (palette, i) {\n return paletteTemplate(palette, currentColor, \"sp-palette-row sp-palette-row-\" + i, opts);\n });\n\n updateSelectionPaletteFromStorage();\n\n if (selectionPalette) {\n html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, \"sp-palette-row sp-palette-row-selection\", opts));\n }\n\n paletteContainer.html(html.join(\"\"));\n }\n\n function drawInitial() {\n if (opts.showInitial) {\n var initial = colorOnShow;\n var current = get();\n initialColorContainer.html(paletteTemplate([initial, current], current, \"sp-palette-row-initial\", opts));\n }\n }\n\n function dragStart() {\n if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {\n reflow();\n }\n isDragging = true;\n container.addClass(draggingClass);\n shiftMovementDirection = null;\n boundElement.trigger('dragstart.spectrum', [ get() ]);\n }\n\n function dragStop() {\n isDragging = false;\n container.removeClass(draggingClass);\n boundElement.trigger('dragstop.spectrum', [ get() ]);\n }\n\n function setFromTextInput() {\n\n var value = textInput.val();\n\n if ((value === null || value === \"\") && allowEmpty) {\n set(null);\n updateOriginalInput(true);\n }\n else {\n var tiny = tinycolor(value);\n if (tiny.isValid()) {\n set(tiny);\n updateOriginalInput(true);\n }\n else {\n textInput.addClass(\"sp-validation-error\");\n }\n }\n }\n\n function toggle() {\n if (visible) {\n hide();\n }\n else {\n show();\n }\n }\n\n function show() {\n var event = $.Event('beforeShow.spectrum');\n\n if (visible) {\n reflow();\n return;\n }\n\n boundElement.trigger(event, [ get() ]);\n\n if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {\n return;\n }\n\n hideAll();\n visible = true;\n\n $(doc).bind(\"keydown.spectrum\", onkeydown);\n $(doc).bind(\"click.spectrum\", clickout);\n $(window).bind(\"resize.spectrum\", resize);\n replacer.addClass(\"sp-active\");\n container.removeClass(\"sp-hidden\");\n\n reflow();\n updateUI();\n\n colorOnShow = get();\n\n drawInitial();\n callbacks.show(colorOnShow);\n boundElement.trigger('show.spectrum', [ colorOnShow ]);\n }\n\n function onkeydown(e) {\n // Close on ESC\n if (e.keyCode === 27) {\n hide();\n }\n }\n\n function clickout(e) {\n // Return on right click.\n if (e.button == 2) { return; }\n\n // If a drag event was happening during the mouseup, don't hide\n // on click.\n if (isDragging) { return; }\n\n if (clickoutFiresChange) {\n updateOriginalInput(true);\n }\n else {\n revert();\n }\n hide();\n }\n\n function hide() {\n // Return if hiding is unnecessary\n if (!visible || flat) { return; }\n visible = false;\n\n $(doc).unbind(\"keydown.spectrum\", onkeydown);\n $(doc).unbind(\"click.spectrum\", clickout);\n $(window).unbind(\"resize.spectrum\", resize);\n\n replacer.removeClass(\"sp-active\");\n container.addClass(\"sp-hidden\");\n\n callbacks.hide(get());\n boundElement.trigger('hide.spectrum', [ get() ]);\n }\n\n function revert() {\n set(colorOnShow, true);\n }\n\n function set(color, ignoreFormatChange) {\n if (tinycolor.equals(color, get())) {\n // Update UI just in case a validation error needs\n // to be cleared.\n updateUI();\n return;\n }\n\n var newColor, newHsv;\n if (!color && allowEmpty) {\n isEmpty = true;\n } else {\n isEmpty = false;\n newColor = tinycolor(color);\n newHsv = newColor.toHsv();\n\n currentHue = (newHsv.h % 360) / 360;\n currentSaturation = newHsv.s;\n currentValue = newHsv.v;\n currentAlpha = newHsv.a;\n }\n updateUI();\n\n if (newColor && newColor.isValid() && !ignoreFormatChange) {\n currentPreferredFormat = opts.preferredFormat || newColor.getFormat();\n }\n }\n\n function get(opts) {\n opts = opts || { };\n\n if (allowEmpty && isEmpty) {\n return null;\n }\n\n return tinycolor.fromRatio({\n h: currentHue,\n s: currentSaturation,\n v: currentValue,\n a: Math.round(currentAlpha * 100) / 100\n }, { format: opts.format || currentPreferredFormat });\n }\n\n function isValid() {\n return !textInput.hasClass(\"sp-validation-error\");\n }\n\n function move() {\n updateUI();\n\n callbacks.move(get());\n boundElement.trigger('move.spectrum', [ get() ]);\n }\n\n function updateUI() {\n\n textInput.removeClass(\"sp-validation-error\");\n\n updateHelperLocations();\n\n // Update dragger background color (gradients take care of saturation and value).\n var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });\n dragger.css(\"background-color\", flatColor.toHexString());\n\n // Get a format that alpha will be included in (hex and names ignore alpha)\n var format = currentPreferredFormat;\n if (currentAlpha < 1 && !(currentAlpha === 0 && format === \"name\")) {\n if (format === \"hex\" || format === \"hex3\" || format === \"hex6\" || format === \"name\") {\n format = \"rgb\";\n }\n }\n\n var realColor = get({ format: format }),\n displayColor = '';\n\n //reset background info for preview element\n previewElement.removeClass(\"sp-clear-display\");\n previewElement.css('background-color', 'transparent');\n\n if (!realColor && allowEmpty) {\n // Update the replaced elements background with icon indicating no color selection\n previewElement.addClass(\"sp-clear-display\");\n }\n else {\n var realHex = realColor.toHexString(),\n realRgb = realColor.toRgbString();\n\n // Update the replaced elements background color (with actual selected color)\n if (rgbaSupport || realColor.alpha === 1) {\n previewElement.css(\"background-color\", realRgb);\n }\n else {\n previewElement.css(\"background-color\", \"transparent\");\n previewElement.css(\"filter\", realColor.toFilter());\n }\n\n if (opts.showAlpha) {\n var rgb = realColor.toRgb();\n rgb.a = 0;\n var realAlpha = tinycolor(rgb).toRgbString();\n var gradient = \"linear-gradient(left, \" + realAlpha + \", \" + realHex + \")\";\n\n if (IE) {\n alphaSliderInner.css(\"filter\", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));\n }\n else {\n alphaSliderInner.css(\"background\", \"-webkit-\" + gradient);\n alphaSliderInner.css(\"background\", \"-moz-\" + gradient);\n alphaSliderInner.css(\"background\", \"-ms-\" + gradient);\n // Use current syntax gradient on unprefixed property.\n alphaSliderInner.css(\"background\",\n \"linear-gradient(to right, \" + realAlpha + \", \" + realHex + \")\");\n }\n }\n\n displayColor = realColor.toString(format);\n }\n\n // Update the text entry input as it changes happen\n if (opts.showInput) {\n textInput.val(displayColor);\n }\n\n if (opts.showPalette) {\n drawPalette();\n }\n\n drawInitial();\n }\n\n function updateHelperLocations() {\n var s = currentSaturation;\n var v = currentValue;\n\n if(allowEmpty && isEmpty) {\n //if selected color is empty, hide the helpers\n alphaSlideHelper.hide();\n slideHelper.hide();\n dragHelper.hide();\n }\n else {\n //make sure helpers are visible\n alphaSlideHelper.show();\n slideHelper.show();\n dragHelper.show();\n\n // Where to show the little circle in that displays your current selected color\n var dragX = s * dragWidth;\n var dragY = dragHeight - (v * dragHeight);\n dragX = Math.max(\n -dragHelperHeight,\n Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)\n );\n dragY = Math.max(\n -dragHelperHeight,\n Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)\n );\n dragHelper.css({\n \"top\": dragY + \"px\",\n \"left\": dragX + \"px\"\n });\n\n var alphaX = currentAlpha * alphaWidth;\n alphaSlideHelper.css({\n \"left\": (alphaX - (alphaSlideHelperWidth / 2)) + \"px\"\n });\n\n // Where to show the bar that displays your current selected hue\n var slideY = (currentHue) * slideHeight;\n slideHelper.css({\n \"top\": (slideY - slideHelperHeight) + \"px\"\n });\n }\n }\n\n function updateOriginalInput(fireCallback) {\n var color = get(),\n displayColor = '',\n hasChanged = !tinycolor.equals(color, colorOnShow);\n\n if (color) {\n displayColor = color.toString(currentPreferredFormat);\n // Update the selection palette with the current color\n addColorToSelectionPalette(color);\n }\n\n if (isInput) {\n boundElement.val(displayColor);\n }\n\n if (fireCallback && hasChanged) {\n callbacks.change(color);\n boundElement.trigger('change', [ color ]);\n }\n }\n\n function reflow() {\n if (!visible) {\n return; // Calculations would be useless and wouldn't be reliable anyways\n }\n dragWidth = dragger.width();\n dragHeight = dragger.height();\n dragHelperHeight = dragHelper.height();\n slideWidth = slider.width();\n slideHeight = slider.height();\n slideHelperHeight = slideHelper.height();\n alphaWidth = alphaSlider.width();\n alphaSlideHelperWidth = alphaSlideHelper.width();\n\n if (!flat) {\n container.css(\"position\", \"absolute\");\n if (opts.offset) {\n container.offset(opts.offset);\n } else {\n container.offset(getOffset(container, offsetElement));\n }\n }\n\n updateHelperLocations();\n\n if (opts.showPalette) {\n drawPalette();\n }\n\n boundElement.trigger('reflow.spectrum');\n }\n\n function destroy() {\n boundElement.show();\n offsetElement.unbind(\"click.spectrum touchstart.spectrum\");\n container.remove();\n replacer.remove();\n spectrums[spect.id] = null;\n }\n\n function option(optionName, optionValue) {\n if (optionName === undefined) {\n return $.extend({}, opts);\n }\n if (optionValue === undefined) {\n return opts[optionName];\n }\n\n opts[optionName] = optionValue;\n\n if (optionName === \"preferredFormat\") {\n currentPreferredFormat = opts.preferredFormat;\n }\n applyOptions();\n }\n\n function enable() {\n disabled = false;\n boundElement.attr(\"disabled\", false);\n offsetElement.removeClass(\"sp-disabled\");\n }\n\n function disable() {\n hide();\n disabled = true;\n boundElement.attr(\"disabled\", true);\n offsetElement.addClass(\"sp-disabled\");\n }\n\n function setOffset(coord) {\n opts.offset = coord;\n reflow();\n }\n\n initialize();\n\n var spect = {\n show: show,\n hide: hide,\n toggle: toggle,\n reflow: reflow,\n option: option,\n enable: enable,\n disable: disable,\n offset: setOffset,\n set: function (c) {\n set(c);\n updateOriginalInput();\n },\n get: get,\n destroy: destroy,\n container: container\n };\n\n spect.id = spectrums.push(spect) - 1;\n\n return spect;\n }\n\n /**\n * checkOffset - get the offset below/above and left/right element depending on screen position\n * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js\n */\n function getOffset(picker, input) {\n var extraY = 0;\n var dpWidth = picker.outerWidth();\n var dpHeight = picker.outerHeight();\n var inputHeight = input.outerHeight();\n var doc = picker[0].ownerDocument;\n var docElem = doc.documentElement;\n var viewWidth = docElem.clientWidth + $(doc).scrollLeft();\n var viewHeight = docElem.clientHeight + $(doc).scrollTop();\n var offset = input.offset();\n offset.top += inputHeight;\n\n offset.left -=\n Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?\n Math.abs(offset.left + dpWidth - viewWidth) : 0);\n\n offset.top -=\n Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?\n Math.abs(dpHeight + inputHeight - extraY) : extraY));\n\n return offset;\n }\n\n /**\n * noop - do nothing\n */\n function noop() {\n\n }\n\n /**\n * stopPropagation - makes the code only doing this a little easier to read in line\n */\n function stopPropagation(e) {\n e.stopPropagation();\n }\n\n /**\n * Create a function bound to a given object\n * Thanks to underscore.js\n */\n function bind(func, obj) {\n var slice = Array.prototype.slice;\n var args = slice.call(arguments, 2);\n return function () {\n return func.apply(obj, args.concat(slice.call(arguments)));\n };\n }\n\n /**\n * Lightweight drag helper. Handles containment within the element, so that\n * when dragging, the x is within [0,element.width] and y is within [0,element.height]\n */\n function draggable(element, onmove, onstart, onstop) {\n onmove = onmove || function () { };\n onstart = onstart || function () { };\n onstop = onstop || function () { };\n var doc = document;\n var dragging = false;\n var offset = {};\n var maxHeight = 0;\n var maxWidth = 0;\n var hasTouch = ('ontouchstart' in window);\n\n var duringDragEvents = {};\n duringDragEvents[\"selectstart\"] = prevent;\n duringDragEvents[\"dragstart\"] = prevent;\n duringDragEvents[\"touchmove mousemove\"] = move;\n duringDragEvents[\"touchend mouseup\"] = stop;\n\n function prevent(e) {\n if (e.stopPropagation) {\n e.stopPropagation();\n }\n if (e.preventDefault) {\n e.preventDefault();\n }\n e.returnValue = false;\n }\n\n function move(e) {\n if (dragging) {\n // Mouseup happened outside of window\n if (IE && doc.documentMode < 9 && !e.button) {\n return stop();\n }\n\n var t0 = e.originalEvent && e.originalEvent.touches && e.originalEvent.touches[0];\n var pageX = t0 && t0.pageX || e.pageX;\n var pageY = t0 && t0.pageY || e.pageY;\n\n var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));\n var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));\n\n if (hasTouch) {\n // Stop scrolling in iOS\n prevent(e);\n }\n\n onmove.apply(element, [dragX, dragY, e]);\n }\n }\n\n function start(e) {\n var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);\n\n if (!rightclick && !dragging) {\n if (onstart.apply(element, arguments) !== false) {\n dragging = true;\n maxHeight = $(element).height();\n maxWidth = $(element).width();\n offset = $(element).offset();\n\n $(doc).bind(duringDragEvents);\n $(doc.body).addClass(\"sp-dragging\");\n\n move(e);\n\n prevent(e);\n }\n }\n }\n\n function stop() {\n if (dragging) {\n $(doc).unbind(duringDragEvents);\n $(doc.body).removeClass(\"sp-dragging\");\n\n // Wait a tick before notifying observers to allow the click event\n // to fire in Chrome.\n setTimeout(function() {\n onstop.apply(element, arguments);\n }, 0);\n }\n dragging = false;\n }\n\n $(element).bind(\"touchstart mousedown\", start);\n }\n\n function throttle(func, wait, debounce) {\n var timeout;\n return function () {\n var context = this, args = arguments;\n var throttler = function () {\n timeout = null;\n func.apply(context, args);\n };\n if (debounce) clearTimeout(timeout);\n if (debounce || !timeout) timeout = setTimeout(throttler, wait);\n };\n }\n\n function inputTypeColorSupport() {\n return $.fn.spectrum.inputTypeColorSupport();\n }\n\n /**\n * Define a jQuery plugin\n */\n var dataID = \"spectrum.id\";\n $.fn.spectrum = function (opts, extra) {\n\n if (typeof opts == \"string\") {\n\n var returnValue = this;\n var args = Array.prototype.slice.call( arguments, 1 );\n\n this.each(function () {\n var spect = spectrums[$(this).data(dataID)];\n if (spect) {\n var method = spect[opts];\n if (!method) {\n throw new Error( \"Spectrum: no such method: '\" + opts + \"'\" );\n }\n\n if (opts == \"get\") {\n returnValue = spect.get();\n }\n else if (opts == \"container\") {\n returnValue = spect.container;\n }\n else if (opts == \"option\") {\n returnValue = spect.option.apply(spect, args);\n }\n else if (opts == \"destroy\") {\n spect.destroy();\n $(this).removeData(dataID);\n }\n else {\n method.apply(spect, args);\n }\n }\n });\n\n return returnValue;\n }\n\n // Initializing a new instance of spectrum\n return this.spectrum(\"destroy\").each(function () {\n var options = $.extend({}, opts, $(this).data());\n var spect = spectrum(this, options);\n $(this).data(dataID, spect.id);\n });\n };\n\n $.fn.spectrum.load = true;\n $.fn.spectrum.loadOpts = {};\n $.fn.spectrum.draggable = draggable;\n $.fn.spectrum.defaults = defaultOpts;\n $.fn.spectrum.inputTypeColorSupport = function inputTypeColorSupport() {\n if (typeof inputTypeColorSupport._cachedResult === \"undefined\") {\n var colorInput = $(\"<input type='color'/>\")[0]; // if color element is supported, value will default to not null\n inputTypeColorSupport._cachedResult = colorInput.type === \"color\" && colorInput.value !== \"\";\n }\n return inputTypeColorSupport._cachedResult;\n };\n\n $.spectrum = { };\n $.spectrum.localization = { };\n $.spectrum.palettes = { };\n\n $.fn.spectrum.processNativeColorInputs = function () {\n var colorInputs = $(\"input[type=color]\");\n if (colorInputs.length && !inputTypeColorSupport()) {\n colorInputs.spectrum({\n preferredFormat: \"hex6\"\n });\n }\n };\n\n // TinyColor v1.1.2\n // https://github.com/bgrins/TinyColor\n // Brian Grinstead, MIT License\n\n (function() {\n\n var trimLeft = /^[\\s,#]+/,\n trimRight = /\\s+$/,\n tinyCounter = 0,\n math = Math,\n mathRound = math.round,\n mathMin = math.min,\n mathMax = math.max,\n mathRandom = math.random;\n\n var tinycolor = function(color, opts) {\n\n color = (color) ? color : '';\n opts = opts || { };\n\n // If input is already a tinycolor, return itself\n if (color instanceof tinycolor) {\n return color;\n }\n // If we are called as a function, call using new instead\n if (!(this instanceof tinycolor)) {\n return new tinycolor(color, opts);\n }\n\n var rgb = inputToRGB(color);\n this._originalInput = color,\n this._r = rgb.r,\n this._g = rgb.g,\n this._b = rgb.b,\n this._a = rgb.a,\n this._roundA = mathRound(100*this._a) / 100,\n this._format = opts.format || rgb.format;\n this._gradientType = opts.gradientType;\n\n // Don't let the range of [0,255] come back in [0,1].\n // Potentially lose a little bit of precision here, but will fix issues where\n // .5 gets interpreted as half of the total, instead of half of 1\n // If it was supposed to be 128, this was already taken care of by `inputToRgb`\n if (this._r < 1) { this._r = mathRound(this._r); }\n if (this._g < 1) { this._g = mathRound(this._g); }\n if (this._b < 1) { this._b = mathRound(this._b); }\n\n this._ok = rgb.ok;\n this._tc_id = tinyCounter++;\n };\n\n tinycolor.prototype = {\n isDark: function() {\n return this.getBrightness() < 128;\n },\n isLight: function() {\n return !this.isDark();\n },\n isValid: function() {\n return this._ok;\n },\n getOriginalInput: function() {\n return this._originalInput;\n },\n getFormat: function() {\n return this._format;\n },\n getAlpha: function() {\n return this._a;\n },\n getBrightness: function() {\n var rgb = this.toRgb();\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;\n },\n setAlpha: function(value) {\n this._a = boundAlpha(value);\n this._roundA = mathRound(100*this._a) / 100;\n return this;\n },\n toHsv: function() {\n var hsv = rgbToHsv(this._r, this._g, this._b);\n return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };\n },\n toHsvString: function() {\n var hsv = rgbToHsv(this._r, this._g, this._b);\n var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);\n return (this._a == 1) ?\n \"hsv(\" + h + \", \" + s + \"%, \" + v + \"%)\" :\n \"hsva(\" + h + \", \" + s + \"%, \" + v + \"%, \"+ this._roundA + \")\";\n },\n toHsl: function() {\n var hsl = rgbToHsl(this._r, this._g, this._b);\n return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };\n },\n toHslString: function() {\n var hsl = rgbToHsl(this._r, this._g, this._b);\n var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);\n return (this._a == 1) ?\n \"hsl(\" + h + \", \" + s + \"%, \" + l + \"%)\" :\n \"hsla(\" + h + \", \" + s + \"%, \" + l + \"%, \"+ this._roundA + \")\";\n },\n toHex: function(allow3Char) {\n return rgbToHex(this._r, this._g, this._b, allow3Char);\n },\n toHexString: function(allow3Char) {\n return '#' + this.toHex(allow3Char);\n },\n toHex8: function() {\n return rgbaToHex(this._r, this._g, this._b, this._a);\n },\n toHex8String: function() {\n return '#' + this.toHex8();\n },\n toRgb: function() {\n return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };\n },\n toRgbString: function() {\n return (this._a == 1) ?\n \"rgb(\" + mathRound(this._r) + \", \" + mathRound(this._g) + \", \" + mathRound(this._b) + \")\" :\n \"rgba(\" + mathRound(this._r) + \", \" + mathRound(this._g) + \", \" + mathRound(this._b) + \", \" + this._roundA + \")\";\n },\n toPercentageRgb: function() {\n return { r: mathRound(bound01(this._r, 255) * 100) + \"%\", g: mathRound(bound01(this._g, 255) * 100) + \"%\", b: mathRound(bound01(this._b, 255) * 100) + \"%\", a: this._a };\n },\n toPercentageRgbString: function() {\n return (this._a == 1) ?\n \"rgb(\" + mathRound(bound01(this._r, 255) * 100) + \"%, \" + mathRound(bound01(this._g, 255) * 100) + \"%, \" + mathRound(bound01(this._b, 255) * 100) + \"%)\" :\n \"rgba(\" + mathRound(bound01(this._r, 255) * 100) + \"%, \" + mathRound(bound01(this._g, 255) * 100) + \"%, \" + mathRound(bound01(this._b, 255) * 100) + \"%, \" + this._roundA + \")\";\n },\n toName: function() {\n if (this._a === 0) {\n return \"transparent\";\n }\n\n if (this._a < 1) {\n return false;\n }\n\n return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;\n },\n toFilter: function(secondColor) {\n var hex8String = '#' + rgbaToHex(this._r, this._g, this._b, this._a);\n var secondHex8String = hex8String;\n var gradientType = this._gradientType ? \"GradientType = 1, \" : \"\";\n\n if (secondColor) {\n var s = tinycolor(secondColor);\n secondHex8String = s.toHex8String();\n }\n\n return \"progid:DXImageTransform.Microsoft.gradient(\"+gradientType+\"startColorstr=\"+hex8String+\",endColorstr=\"+secondHex8String+\")\";\n },\n toString: function(format) {\n var formatSet = !!format;\n format = format || this._format;\n\n var formattedString = false;\n var hasAlpha = this._a < 1 && this._a >= 0;\n var needsAlphaFormat = !formatSet && hasAlpha && (format === \"hex\" || format === \"hex6\" || format === \"hex3\" || format === \"name\");\n\n if (needsAlphaFormat) {\n // Special case for \"transparent\", all other non-alpha formats\n // will return rgba when there is transparency.\n if (format === \"name\" && this._a === 0) {\n return this.toName();\n }\n return this.toRgbString();\n }\n if (format === \"rgb\") {\n formattedString = this.toRgbString();\n }\n if (format === \"prgb\") {\n formattedString = this.toPercentageRgbString();\n }\n if (format === \"hex\" || format === \"hex6\") {\n formattedString = this.toHexString();\n }\n if (format === \"hex3\") {\n formattedString = this.toHexString(true);\n }\n if (format === \"hex8\") {\n formattedString = this.toHex8String();\n }\n if (format === \"name\") {\n formattedString = this.toName();\n }\n if (format === \"hsl\") {\n formattedString = this.toHslString();\n }\n if (format === \"hsv\") {\n formattedString = this.toHsvString();\n }\n\n return formattedString || this.toHexString();\n },\n\n _applyModification: function(fn, args) {\n var color = fn.apply(null, [this].concat([].slice.call(args)));\n this._r = color._r;\n this._g = color._g;\n this._b = color._b;\n this.setAlpha(color._a);\n return this;\n },\n lighten: function() {\n return this._applyModification(lighten, arguments);\n },\n brighten: function() {\n return this._applyModification(brighten, arguments);\n },\n darken: function() {\n return this._applyModification(darken, arguments);\n },\n desaturate: function() {\n return this._applyModification(desaturate, arguments);\n },\n saturate: function() {\n return this._applyModification(saturate, arguments);\n },\n greyscale: function() {\n return this._applyModification(greyscale, arguments);\n },\n spin: function() {\n return this._applyModification(spin, arguments);\n },\n\n _applyCombination: function(fn, args) {\n return fn.apply(null, [this].concat([].slice.call(args)));\n },\n analogous: function() {\n return this._applyCombination(analogous, arguments);\n },\n complement: function() {\n return this._applyCombination(complement, arguments);\n },\n monochromatic: function() {\n return this._applyCombination(monochromatic, arguments);\n },\n splitcomplement: function() {\n return this._applyCombination(splitcomplement, arguments);\n },\n triad: function() {\n return this._applyCombination(triad, arguments);\n },\n tetrad: function() {\n return this._applyCombination(tetrad, arguments);\n }\n };\n\n // If input is an object, force 1 into \"1.0\" to handle ratios properly\n // String input requires \"1.0\" as input, so 1 will be treated as 1\n tinycolor.fromRatio = function(color, opts) {\n if (typeof color == \"object\") {\n var newColor = {};\n for (var i in color) {\n if (color.hasOwnProperty(i)) {\n if (i === \"a\") {\n newColor[i] = color[i];\n }\n else {\n newColor[i] = convertToPercentage(color[i]);\n }\n }\n }\n color = newColor;\n }\n\n return tinycolor(color, opts);\n };\n\n // Given a string or object, convert that input to RGB\n // Possible string inputs:\n //\n // \"red\"\n // \"#f00\" or \"f00\"\n // \"#ff0000\" or \"ff0000\"\n // \"#ff000000\" or \"ff000000\"\n // \"rgb 255 0 0\" or \"rgb (255, 0, 0)\"\n // \"rgb 1.0 0 0\" or \"rgb (1, 0, 0)\"\n // \"rgba (255, 0, 0, 1)\" or \"rgba 255, 0, 0, 1\"\n // \"rgba (1.0, 0, 0, 1)\" or \"rgba 1.0, 0, 0, 1\"\n // \"hsl(0, 100%, 50%)\" or \"hsl 0 100% 50%\"\n // \"hsla(0, 100%, 50%, 1)\" or \"hsla 0 100% 50%, 1\"\n // \"hsv(0, 100%, 100%)\" or \"hsv 0 100% 100%\"\n //\n function inputToRGB(color) {\n\n var rgb = { r: 0, g: 0, b: 0 };\n var a = 1;\n var ok = false;\n var format = false;\n\n if (typeof color == \"string\") {\n color = stringInputToObject(color);\n }\n\n if (typeof color == \"object\") {\n if (color.hasOwnProperty(\"r\") && color.hasOwnProperty(\"g\") && color.hasOwnProperty(\"b\")) {\n rgb = rgbToRgb(color.r, color.g, color.b);\n ok = true;\n format = String(color.r).substr(-1) === \"%\" ? \"prgb\" : \"rgb\";\n }\n else if (color.hasOwnProperty(\"h\") && color.hasOwnProperty(\"s\") && color.hasOwnProperty(\"v\")) {\n color.s = convertToPercentage(color.s);\n color.v = convertToPercentage(color.v);\n rgb = hsvToRgb(color.h, color.s, color.v);\n ok = true;\n format = \"hsv\";\n }\n else if (color.hasOwnProperty(\"h\") && color.hasOwnProperty(\"s\") && color.hasOwnProperty(\"l\")) {\n color.s = convertToPercentage(color.s);\n color.l = convertToPercentage(color.l);\n rgb = hslToRgb(color.h, color.s, color.l);\n ok = true;\n format = \"hsl\";\n }\n\n if (color.hasOwnProperty(\"a\")) {\n a = color.a;\n }\n }\n\n a = boundAlpha(a);\n\n return {\n ok: ok,\n format: color.format || format,\n r: mathMin(255, mathMax(rgb.r, 0)),\n g: mathMin(255, mathMax(rgb.g, 0)),\n b: mathMin(255, mathMax(rgb.b, 0)),\n a: a\n };\n }\n\n\n // Conversion Functions\n // --------------------\n\n // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:\n // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>\n\n // `rgbToRgb`\n // Handle bounds / percentage checking to conform to CSS color spec\n // <http://www.w3.org/TR/css3-color/>\n // *Assumes:* r, g, b in [0, 255] or [0, 1]\n // *Returns:* { r, g, b } in [0, 255]\n function rgbToRgb(r, g, b){\n return {\n r: bound01(r, 255) * 255,\n g: bound01(g, 255) * 255,\n b: bound01(b, 255) * 255\n };\n }\n\n // `rgbToHsl`\n // Converts an RGB color value to HSL.\n // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]\n // *Returns:* { h, s, l } in [0,1]\n function rgbToHsl(r, g, b) {\n\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n\n var max = mathMax(r, g, b), min = mathMin(r, g, b);\n var h, s, l = (max + min) / 2;\n\n if(max == min) {\n h = s = 0; // achromatic\n }\n else {\n var d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch(max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n\n h /= 6;\n }\n\n return { h: h, s: s, l: l };\n }\n\n // `hslToRgb`\n // Converts an HSL color value to RGB.\n // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]\n // *Returns:* { r, g, b } in the set [0, 255]\n function hslToRgb(h, s, l) {\n var r, g, b;\n\n h = bound01(h, 360);\n s = bound01(s, 100);\n l = bound01(l, 100);\n\n function hue2rgb(p, q, t) {\n if(t < 0) t += 1;\n if(t > 1) t -= 1;\n if(t < 1/6) return p + (q - p) * 6 * t;\n if(t < 1/2) return q;\n if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;\n return p;\n }\n\n if(s === 0) {\n r = g = b = l; // achromatic\n }\n else {\n var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n var p = 2 * l - q;\n r = hue2rgb(p, q, h + 1/3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1/3);\n }\n\n return { r: r * 255, g: g * 255, b: b * 255 };\n }\n\n // `rgbToHsv`\n // Converts an RGB color value to HSV\n // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]\n // *Returns:* { h, s, v } in [0,1]\n function rgbToHsv(r, g, b) {\n\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n\n var max = mathMax(r, g, b), min = mathMin(r, g, b);\n var h, s, v = max;\n\n var d = max - min;\n s = max === 0 ? 0 : d / max;\n\n if(max == min) {\n h = 0; // achromatic\n }\n else {\n switch(max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h, s: s, v: v };\n }\n\n // `hsvToRgb`\n // Converts an HSV color value to RGB.\n // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]\n // *Returns:* { r, g, b } in the set [0, 255]\n function hsvToRgb(h, s, v) {\n\n h = bound01(h, 360) * 6;\n s = bound01(s, 100);\n v = bound01(v, 100);\n\n var i = math.floor(h),\n f = h - i,\n p = v * (1 - s),\n q = v * (1 - f * s),\n t = v * (1 - (1 - f) * s),\n mod = i % 6,\n r = [v, q, p, p, t, v][mod],\n g = [t, v, v, q, p, p][mod],\n b = [p, p, t, v, v, q][mod];\n\n return { r: r * 255, g: g * 255, b: b * 255 };\n }\n\n // `rgbToHex`\n // Converts an RGB color to hex\n // Assumes r, g, and b are contained in the set [0, 255]\n // Returns a 3 or 6 character hex\n function rgbToHex(r, g, b, allow3Char) {\n\n var hex = [\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16))\n ];\n\n // Return a 3 character hex if possible\n if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {\n return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);\n }\n\n return hex.join(\"\");\n }\n // `rgbaToHex`\n // Converts an RGBA color plus alpha transparency to hex\n // Assumes r, g, b and a are contained in the set [0, 255]\n // Returns an 8 character hex\n function rgbaToHex(r, g, b, a) {\n\n var hex = [\n pad2(convertDecimalToHex(a)),\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16))\n ];\n\n return hex.join(\"\");\n }\n\n // `equals`\n // Can be called with any tinycolor input\n tinycolor.equals = function (color1, color2) {\n if (!color1 || !color2) { return false; }\n return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();\n };\n tinycolor.random = function() {\n return tinycolor.fromRatio({\n r: mathRandom(),\n g: mathRandom(),\n b: mathRandom()\n });\n };\n\n\n // Modification Functions\n // ----------------------\n // Thanks to less.js for some of the basics here\n // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>\n\n function desaturate(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.s -= amount / 100;\n hsl.s = clamp01(hsl.s);\n return tinycolor(hsl);\n }\n\n function saturate(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.s += amount / 100;\n hsl.s = clamp01(hsl.s);\n return tinycolor(hsl);\n }\n\n function greyscale(color) {\n return tinycolor(color).desaturate(100);\n }\n\n function lighten (color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.l += amount / 100;\n hsl.l = clamp01(hsl.l);\n return tinycolor(hsl);\n }\n\n function brighten(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var rgb = tinycolor(color).toRgb();\n rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));\n rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));\n rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));\n return tinycolor(rgb);\n }\n\n function darken (color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.l -= amount / 100;\n hsl.l = clamp01(hsl.l);\n return tinycolor(hsl);\n }\n\n // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.\n // Values outside of this range will be wrapped into this range.\n function spin(color, amount) {\n var hsl = tinycolor(color).toHsl();\n var hue = (mathRound(hsl.h) + amount) % 360;\n hsl.h = hue < 0 ? 360 + hue : hue;\n return tinycolor(hsl);\n }\n\n // Combination Functions\n // ---------------------\n // Thanks to jQuery xColor for some of the ideas behind these\n // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>\n\n function complement(color) {\n var hsl = tinycolor(color).toHsl();\n hsl.h = (hsl.h + 180) % 360;\n return tinycolor(hsl);\n }\n\n function triad(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })\n ];\n }\n\n function tetrad(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })\n ];\n }\n\n function splitcomplement(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),\n tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})\n ];\n }\n\n function analogous(color, results, slices) {\n results = results || 6;\n slices = slices || 30;\n\n var hsl = tinycolor(color).toHsl();\n var part = 360 / slices;\n var ret = [tinycolor(color)];\n\n for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {\n hsl.h = (hsl.h + part) % 360;\n ret.push(tinycolor(hsl));\n }\n return ret;\n }\n\n function monochromatic(color, results) {\n results = results || 6;\n var hsv = tinycolor(color).toHsv();\n var h = hsv.h, s = hsv.s, v = hsv.v;\n var ret = [];\n var modification = 1 / results;\n\n while (results--) {\n ret.push(tinycolor({ h: h, s: s, v: v}));\n v = (v + modification) % 1;\n }\n\n return ret;\n }\n\n // Utility Functions\n // ---------------------\n\n tinycolor.mix = function(color1, color2, amount) {\n amount = (amount === 0) ? 0 : (amount || 50);\n\n var rgb1 = tinycolor(color1).toRgb();\n var rgb2 = tinycolor(color2).toRgb();\n\n var p = amount / 100;\n var w = p * 2 - 1;\n var a = rgb2.a - rgb1.a;\n\n var w1;\n\n if (w * a == -1) {\n w1 = w;\n } else {\n w1 = (w + a) / (1 + w * a);\n }\n\n w1 = (w1 + 1) / 2;\n\n var w2 = 1 - w1;\n\n var rgba = {\n r: rgb2.r * w1 + rgb1.r * w2,\n g: rgb2.g * w1 + rgb1.g * w2,\n b: rgb2.b * w1 + rgb1.b * w2,\n a: rgb2.a * p + rgb1.a * (1 - p)\n };\n\n return tinycolor(rgba);\n };\n\n\n // Readability Functions\n // ---------------------\n // <http://www.w3.org/TR/AERT#color-contrast>\n\n // `readability`\n // Analyze the 2 colors and returns an object with the following properties:\n // `brightness`: difference in brightness between the two colors\n // `color`: difference in color/hue between the two colors\n tinycolor.readability = function(color1, color2) {\n var c1 = tinycolor(color1);\n var c2 = tinycolor(color2);\n var rgb1 = c1.toRgb();\n var rgb2 = c2.toRgb();\n var brightnessA = c1.getBrightness();\n var brightnessB = c2.getBrightness();\n var colorDiff = (\n Math.max(rgb1.r, rgb2.r) - Math.min(rgb1.r, rgb2.r) +\n Math.max(rgb1.g, rgb2.g) - Math.min(rgb1.g, rgb2.g) +\n Math.max(rgb1.b, rgb2.b) - Math.min(rgb1.b, rgb2.b)\n );\n\n return {\n brightness: Math.abs(brightnessA - brightnessB),\n color: colorDiff\n };\n };\n\n // `readable`\n // http://www.w3.org/TR/AERT#color-contrast\n // Ensure that foreground and background color combinations provide sufficient contrast.\n // *Example*\n // tinycolor.isReadable(\"#000\", \"#111\") => false\n tinycolor.isReadable = function(color1, color2) {\n var readability = tinycolor.readability(color1, color2);\n return readability.brightness > 125 && readability.color > 500;\n };\n\n // `mostReadable`\n // Given a base color and a list of possible foreground or background\n // colors for that base, returns the most readable color.\n // *Example*\n // tinycolor.mostReadable(\"#123\", [\"#fff\", \"#000\"]) => \"#000\"\n tinycolor.mostReadable = function(baseColor, colorList) {\n var bestColor = null;\n var bestScore = 0;\n var bestIsReadable = false;\n for (var i=0; i < colorList.length; i++) {\n\n // We normalize both around the \"acceptable\" breaking point,\n // but rank brightness constrast higher than hue.\n\n var readability = tinycolor.readability(baseColor, colorList[i]);\n var readable = readability.brightness > 125 && readability.color > 500;\n var score = 3 * (readability.brightness / 125) + (readability.color / 500);\n\n if ((readable && ! bestIsReadable) ||\n (readable && bestIsReadable && score > bestScore) ||\n ((! readable) && (! bestIsReadable) && score > bestScore)) {\n bestIsReadable = readable;\n bestScore = score;\n bestColor = tinycolor(colorList[i]);\n }\n }\n return bestColor;\n };\n\n\n // Big List of Colors\n // ------------------\n // <http://www.w3.org/TR/css3-color/#svg-color>\n var names = tinycolor.names = {\n aliceblue: \"f0f8ff\",\n antiquewhite: \"faebd7\",\n aqua: \"0ff\",\n aquamarine: \"7fffd4\",\n azure: \"f0ffff\",\n beige: \"f5f5dc\",\n bisque: \"ffe4c4\",\n black: \"000\",\n blanchedalmond: \"ffebcd\",\n blue: \"00f\",\n blueviolet: \"8a2be2\",\n brown: \"a52a2a\",\n burlywood: \"deb887\",\n burntsienna: \"ea7e5d\",\n cadetblue: \"5f9ea0\",\n chartreuse: \"7fff00\",\n chocolate: \"d2691e\",\n coral: \"ff7f50\",\n cornflowerblue: \"6495ed\",\n cornsilk: \"fff8dc\",\n crimson: \"dc143c\",\n cyan: \"0ff\",\n darkblue: \"00008b\",\n darkcyan: \"008b8b\",\n darkgoldenrod: \"b8860b\",\n darkgray: \"a9a9a9\",\n darkgreen: \"006400\",\n darkgrey: \"a9a9a9\",\n darkkhaki: \"bdb76b\",\n darkmagenta: \"8b008b\",\n darkolivegreen: \"556b2f\",\n darkorange: \"ff8c00\",\n darkorchid: \"9932cc\",\n darkred: \"8b0000\",\n darksalmon: \"e9967a\",\n darkseagreen: \"8fbc8f\",\n darkslateblue: \"483d8b\",\n darkslategray: \"2f4f4f\",\n darkslategrey: \"2f4f4f\",\n darkturquoise: \"00ced1\",\n darkviolet: \"9400d3\",\n deeppink: \"ff1493\",\n deepskyblue: \"00bfff\",\n dimgray: \"696969\",\n dimgrey: \"696969\",\n dodgerblue: \"1e90ff\",\n firebrick: \"b22222\",\n floralwhite: \"fffaf0\",\n forestgreen: \"228b22\",\n fuchsia: \"f0f\",\n gainsboro: \"dcdcdc\",\n ghostwhite: \"f8f8ff\",\n gold: \"ffd700\",\n goldenrod: \"daa520\",\n gray: \"808080\",\n green: \"008000\",\n greenyellow: \"adff2f\",\n grey: \"808080\",\n honeydew: \"f0fff0\",\n hotpink: \"ff69b4\",\n indianred: \"cd5c5c\",\n indigo: \"4b0082\",\n ivory: \"fffff0\",\n khaki: \"f0e68c\",\n lavender: \"e6e6fa\",\n lavenderblush: \"fff0f5\",\n lawngreen: \"7cfc00\",\n lemonchiffon: \"fffacd\",\n lightblue: \"add8e6\",\n lightcoral: \"f08080\",\n lightcyan: \"e0ffff\",\n lightgoldenrodyellow: \"fafad2\",\n lightgray: \"d3d3d3\",\n lightgreen: \"90ee90\",\n lightgrey: \"d3d3d3\",\n lightpink: \"ffb6c1\",\n lightsalmon: \"ffa07a\",\n lightseagreen: \"20b2aa\",\n lightskyblue: \"87cefa\",\n lightslategray: \"789\",\n lightslategrey: \"789\",\n lightsteelblue: \"b0c4de\",\n lightyellow: \"ffffe0\",\n lime: \"0f0\",\n limegreen: \"32cd32\",\n linen: \"faf0e6\",\n magenta: \"f0f\",\n maroon: \"800000\",\n mediumaquamarine: \"66cdaa\",\n mediumblue: \"0000cd\",\n mediumorchid: \"ba55d3\",\n mediumpurple: \"9370db\",\n mediumseagreen: \"3cb371\",\n mediumslateblue: \"7b68ee\",\n mediumspringgreen: \"00fa9a\",\n mediumturquoise: \"48d1cc\",\n mediumvioletred: \"c71585\",\n midnightblue: \"191970\",\n mintcream: \"f5fffa\",\n mistyrose: \"ffe4e1\",\n moccasin: \"ffe4b5\",\n navajowhite: \"ffdead\",\n navy: \"000080\",\n oldlace: \"fdf5e6\",\n olive: \"808000\",\n olivedrab: \"6b8e23\",\n orange: \"ffa500\",\n orangered: \"ff4500\",\n orchid: \"da70d6\",\n palegoldenrod: \"eee8aa\",\n palegreen: \"98fb98\",\n paleturquoise: \"afeeee\",\n palevioletred: \"db7093\",\n papayawhip: \"ffefd5\",\n peachpuff: \"ffdab9\",\n peru: \"cd853f\",\n pink: \"ffc0cb\",\n plum: \"dda0dd\",\n powderblue: \"b0e0e6\",\n purple: \"800080\",\n rebeccapurple: \"663399\",\n red: \"f00\",\n rosybrown: \"bc8f8f\",\n royalblue: \"4169e1\",\n saddlebrown: \"8b4513\",\n salmon: \"fa8072\",\n sandybrown: \"f4a460\",\n seagreen: \"2e8b57\",\n seashell: \"fff5ee\",\n sienna: \"a0522d\",\n silver: \"c0c0c0\",\n skyblue: \"87ceeb\",\n slateblue: \"6a5acd\",\n slategray: \"708090\",\n slategrey: \"708090\",\n snow: \"fffafa\",\n springgreen: \"00ff7f\",\n steelblue: \"4682b4\",\n tan: \"d2b48c\",\n teal: \"008080\",\n thistle: \"d8bfd8\",\n tomato: \"ff6347\",\n turquoise: \"40e0d0\",\n violet: \"ee82ee\",\n wheat: \"f5deb3\",\n white: \"fff\",\n whitesmoke: \"f5f5f5\",\n yellow: \"ff0\",\n yellowgreen: \"9acd32\"\n };\n\n // Make it easy to access colors via `hexNames[hex]`\n var hexNames = tinycolor.hexNames = flip(names);\n\n\n // Utilities\n // ---------\n\n // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`\n function flip(o) {\n var flipped = { };\n for (var i in o) {\n if (o.hasOwnProperty(i)) {\n flipped[o[i]] = i;\n }\n }\n return flipped;\n }\n\n // Return a valid alpha value [0,1] with all invalid values being set to 1\n function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n }\n\n // Take input from [0, n] and return it as [0, 1]\n function bound01(n, max) {\n if (isOnePointZero(n)) { n = \"100%\"; }\n\n var processPercent = isPercentage(n);\n n = mathMin(max, mathMax(0, parseFloat(n)));\n\n // Automatically convert percentage into number\n if (processPercent) {\n n = parseInt(n * max, 10) / 100;\n }\n\n // Handle floating point rounding errors\n if ((math.abs(n - max) < 0.000001)) {\n return 1;\n }\n\n // Convert into [0, 1] range if it isn't already\n return (n % max) / parseFloat(max);\n }\n\n // Force a number between 0 and 1\n function clamp01(val) {\n return mathMin(1, mathMax(0, val));\n }\n\n // Parse a base-16 hex value into a base-10 integer\n function parseIntFromHex(val) {\n return parseInt(val, 16);\n }\n\n // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1\n // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>\n function isOnePointZero(n) {\n return typeof n == \"string\" && n.indexOf('.') != -1 && parseFloat(n) === 1;\n }\n\n // Check to see if string passed in is a percentage\n function isPercentage(n) {\n return typeof n === \"string\" && n.indexOf('%') != -1;\n }\n\n // Force a hex value to have 2 characters\n function pad2(c) {\n return c.length == 1 ? '0' + c : '' + c;\n }\n\n // Replace a decimal with it's percentage value\n function convertToPercentage(n) {\n if (n <= 1) {\n n = (n * 100) + \"%\";\n }\n\n return n;\n }\n\n // Converts a decimal to a hex value\n function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) * 255).toString(16);\n }\n // Converts a hex value to a decimal\n function convertHexToDecimal(h) {\n return (parseIntFromHex(h) / 255);\n }\n\n var matchers = (function() {\n\n // <http://www.w3.org/TR/css3-values/#integers>\n var CSS_INTEGER = \"[-\\\\+]?\\\\d+%?\";\n\n // <http://www.w3.org/TR/css3-values/#number-value>\n var CSS_NUMBER = \"[-\\\\+]?\\\\d*\\\\.\\\\d+%?\";\n\n // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.\n var CSS_UNIT = \"(?:\" + CSS_NUMBER + \")|(?:\" + CSS_INTEGER + \")\";\n\n // Actual matching.\n // Parentheses and commas are optional, but not required.\n // Whitespace can take the place of commas or opening paren\n var PERMISSIVE_MATCH3 = \"[\\\\s|\\\\(]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")\\\\s*\\\\)?\";\n var PERMISSIVE_MATCH4 = \"[\\\\s|\\\\(]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")\\\\s*\\\\)?\";\n\n return {\n rgb: new RegExp(\"rgb\" + PERMISSIVE_MATCH3),\n rgba: new RegExp(\"rgba\" + PERMISSIVE_MATCH4),\n hsl: new RegExp(\"hsl\" + PERMISSIVE_MATCH3),\n hsla: new RegExp(\"hsla\" + PERMISSIVE_MATCH4),\n hsv: new RegExp(\"hsv\" + PERMISSIVE_MATCH3),\n hsva: new RegExp(\"hsva\" + PERMISSIVE_MATCH4),\n hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,\n hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,\n hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/\n };\n })();\n\n // `stringInputToObject`\n // Permissive string parsing. Take in a number of formats, and output an object\n // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`\n function stringInputToObject(color) {\n\n color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();\n var named = false;\n if (names[color]) {\n color = names[color];\n named = true;\n }\n else if (color == 'transparent') {\n return { r: 0, g: 0, b: 0, a: 0, format: \"name\" };\n }\n\n // Try to match string input using regular expressions.\n // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]\n // Just return an object and let the conversion functions handle that.\n // This way the result will be the same whether the tinycolor is initialized with string or object.\n var match;\n if ((match = matchers.rgb.exec(color))) {\n return { r: match[1], g: match[2], b: match[3] };\n }\n if ((match = matchers.rgba.exec(color))) {\n return { r: match[1], g: match[2], b: match[3], a: match[4] };\n }\n if ((match = matchers.hsl.exec(color))) {\n return { h: match[1], s: match[2], l: match[3] };\n }\n if ((match = matchers.hsla.exec(color))) {\n return { h: match[1], s: match[2], l: match[3], a: match[4] };\n }\n if ((match = matchers.hsv.exec(color))) {\n return { h: match[1], s: match[2], v: match[3] };\n }\n if ((match = matchers.hsva.exec(color))) {\n return { h: match[1], s: match[2], v: match[3], a: match[4] };\n }\n if ((match = matchers.hex8.exec(color))) {\n return {\n a: convertHexToDecimal(match[1]),\n r: parseIntFromHex(match[2]),\n g: parseIntFromHex(match[3]),\n b: parseIntFromHex(match[4]),\n format: named ? \"name\" : \"hex8\"\n };\n }\n if ((match = matchers.hex6.exec(color))) {\n return {\n r: parseIntFromHex(match[1]),\n g: parseIntFromHex(match[2]),\n b: parseIntFromHex(match[3]),\n format: named ? \"name\" : \"hex\"\n };\n }\n if ((match = matchers.hex3.exec(color))) {\n return {\n r: parseIntFromHex(match[1] + '' + match[1]),\n g: parseIntFromHex(match[2] + '' + match[2]),\n b: parseIntFromHex(match[3] + '' + match[3]),\n format: named ? \"name\" : \"hex\"\n };\n }\n\n return false;\n }\n\n window.tinycolor = tinycolor;\n })();\n\n $(function () {\n if ($.fn.spectrum.load) {\n $.fn.spectrum.processNativeColorInputs();\n }\n });\n\n});\n","jquery/spectrum/tinycolor.js":"// TinyColor v1.4.1\n// https://github.com/bgrins/TinyColor\n// Brian Grinstead, MIT License\n\n(function(Math) {\n\n var trimLeft = /^\\s+/,\n trimRight = /\\s+$/,\n tinyCounter = 0,\n mathRound = Math.round,\n mathMin = Math.min,\n mathMax = Math.max,\n mathRandom = Math.random;\n\n function tinycolor (color, opts) {\n\n color = (color) ? color : '';\n opts = opts || { };\n\n // If input is already a tinycolor, return itself\n if (color instanceof tinycolor) {\n return color;\n }\n // If we are called as a function, call using new instead\n if (!(this instanceof tinycolor)) {\n return new tinycolor(color, opts);\n }\n\n var rgb = inputToRGB(color);\n this._originalInput = color,\n this._r = rgb.r,\n this._g = rgb.g,\n this._b = rgb.b,\n this._a = rgb.a,\n this._roundA = mathRound(100*this._a) / 100,\n this._format = opts.format || rgb.format;\n this._gradientType = opts.gradientType;\n\n // Don't let the range of [0,255] come back in [0,1].\n // Potentially lose a little bit of precision here, but will fix issues where\n // .5 gets interpreted as half of the total, instead of half of 1\n // If it was supposed to be 128, this was already taken care of by `inputToRgb`\n if (this._r < 1) { this._r = mathRound(this._r); }\n if (this._g < 1) { this._g = mathRound(this._g); }\n if (this._b < 1) { this._b = mathRound(this._b); }\n\n this._ok = rgb.ok;\n this._tc_id = tinyCounter++;\n }\n\n tinycolor.prototype = {\n isDark: function() {\n return this.getBrightness() < 128;\n },\n isLight: function() {\n return !this.isDark();\n },\n isValid: function() {\n return this._ok;\n },\n getOriginalInput: function() {\n return this._originalInput;\n },\n getFormat: function() {\n return this._format;\n },\n getAlpha: function() {\n return this._a;\n },\n getBrightness: function() {\n //http://www.w3.org/TR/AERT#color-contrast\n var rgb = this.toRgb();\n return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;\n },\n getLuminance: function() {\n //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef\n var rgb = this.toRgb();\n var RsRGB, GsRGB, BsRGB, R, G, B;\n RsRGB = rgb.r/255;\n GsRGB = rgb.g/255;\n BsRGB = rgb.b/255;\n\n if (RsRGB <= 0.03928) {R = RsRGB / 12.92;} else {R = Math.pow(((RsRGB + 0.055) / 1.055), 2.4);}\n if (GsRGB <= 0.03928) {G = GsRGB / 12.92;} else {G = Math.pow(((GsRGB + 0.055) / 1.055), 2.4);}\n if (BsRGB <= 0.03928) {B = BsRGB / 12.92;} else {B = Math.pow(((BsRGB + 0.055) / 1.055), 2.4);}\n return (0.2126 * R) + (0.7152 * G) + (0.0722 * B);\n },\n setAlpha: function(value) {\n this._a = boundAlpha(value);\n this._roundA = mathRound(100*this._a) / 100;\n return this;\n },\n toHsv: function() {\n var hsv = rgbToHsv(this._r, this._g, this._b);\n return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };\n },\n toHsvString: function() {\n var hsv = rgbToHsv(this._r, this._g, this._b);\n var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);\n return (this._a == 1) ?\n \"hsv(\" + h + \", \" + s + \"%, \" + v + \"%)\" :\n \"hsva(\" + h + \", \" + s + \"%, \" + v + \"%, \"+ this._roundA + \")\";\n },\n toHsl: function() {\n var hsl = rgbToHsl(this._r, this._g, this._b);\n return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };\n },\n toHslString: function() {\n var hsl = rgbToHsl(this._r, this._g, this._b);\n var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);\n return (this._a == 1) ?\n \"hsl(\" + h + \", \" + s + \"%, \" + l + \"%)\" :\n \"hsla(\" + h + \", \" + s + \"%, \" + l + \"%, \"+ this._roundA + \")\";\n },\n toHex: function(allow3Char) {\n return rgbToHex(this._r, this._g, this._b, allow3Char);\n },\n toHexString: function(allow3Char) {\n return '#' + this.toHex(allow3Char);\n },\n toHex8: function(allow4Char) {\n return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);\n },\n toHex8String: function(allow4Char) {\n return '#' + this.toHex8(allow4Char);\n },\n toRgb: function() {\n return { r: mathRound(this._r), g: mathRound(this._g), b: mathRound(this._b), a: this._a };\n },\n toRgbString: function() {\n return (this._a == 1) ?\n \"rgb(\" + mathRound(this._r) + \", \" + mathRound(this._g) + \", \" + mathRound(this._b) + \")\" :\n \"rgba(\" + mathRound(this._r) + \", \" + mathRound(this._g) + \", \" + mathRound(this._b) + \", \" + this._roundA + \")\";\n },\n toPercentageRgb: function() {\n return { r: mathRound(bound01(this._r, 255) * 100) + \"%\", g: mathRound(bound01(this._g, 255) * 100) + \"%\", b: mathRound(bound01(this._b, 255) * 100) + \"%\", a: this._a };\n },\n toPercentageRgbString: function() {\n return (this._a == 1) ?\n \"rgb(\" + mathRound(bound01(this._r, 255) * 100) + \"%, \" + mathRound(bound01(this._g, 255) * 100) + \"%, \" + mathRound(bound01(this._b, 255) * 100) + \"%)\" :\n \"rgba(\" + mathRound(bound01(this._r, 255) * 100) + \"%, \" + mathRound(bound01(this._g, 255) * 100) + \"%, \" + mathRound(bound01(this._b, 255) * 100) + \"%, \" + this._roundA + \")\";\n },\n toName: function() {\n if (this._a === 0) {\n return \"transparent\";\n }\n\n if (this._a < 1) {\n return false;\n }\n\n return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;\n },\n toFilter: function(secondColor) {\n var hex8String = '#' + rgbaToArgbHex(this._r, this._g, this._b, this._a);\n var secondHex8String = hex8String;\n var gradientType = this._gradientType ? \"GradientType = 1, \" : \"\";\n\n if (secondColor) {\n var s = tinycolor(secondColor);\n secondHex8String = '#' + rgbaToArgbHex(s._r, s._g, s._b, s._a);\n }\n\n return \"progid:DXImageTransform.Microsoft.gradient(\"+gradientType+\"startColorstr=\"+hex8String+\",endColorstr=\"+secondHex8String+\")\";\n },\n toString: function(format) {\n var formatSet = !!format;\n format = format || this._format;\n\n var formattedString = false;\n var hasAlpha = this._a < 1 && this._a >= 0;\n var needsAlphaFormat = !formatSet && hasAlpha && (format === \"hex\" || format === \"hex6\" || format === \"hex3\" || format === \"hex4\" || format === \"hex8\" || format === \"name\");\n\n if (needsAlphaFormat) {\n // Special case for \"transparent\", all other non-alpha formats\n // will return rgba when there is transparency.\n if (format === \"name\" && this._a === 0) {\n return this.toName();\n }\n return this.toRgbString();\n }\n if (format === \"rgb\") {\n formattedString = this.toRgbString();\n }\n if (format === \"prgb\") {\n formattedString = this.toPercentageRgbString();\n }\n if (format === \"hex\" || format === \"hex6\") {\n formattedString = this.toHexString();\n }\n if (format === \"hex3\") {\n formattedString = this.toHexString(true);\n }\n if (format === \"hex4\") {\n formattedString = this.toHex8String(true);\n }\n if (format === \"hex8\") {\n formattedString = this.toHex8String();\n }\n if (format === \"name\") {\n formattedString = this.toName();\n }\n if (format === \"hsl\") {\n formattedString = this.toHslString();\n }\n if (format === \"hsv\") {\n formattedString = this.toHsvString();\n }\n\n return formattedString || this.toHexString();\n },\n clone: function() {\n return tinycolor(this.toString());\n },\n\n _applyModification: function(fn, args) {\n var color = fn.apply(null, [this].concat([].slice.call(args)));\n this._r = color._r;\n this._g = color._g;\n this._b = color._b;\n this.setAlpha(color._a);\n return this;\n },\n lighten: function() {\n return this._applyModification(lighten, arguments);\n },\n brighten: function() {\n return this._applyModification(brighten, arguments);\n },\n darken: function() {\n return this._applyModification(darken, arguments);\n },\n desaturate: function() {\n return this._applyModification(desaturate, arguments);\n },\n saturate: function() {\n return this._applyModification(saturate, arguments);\n },\n greyscale: function() {\n return this._applyModification(greyscale, arguments);\n },\n spin: function() {\n return this._applyModification(spin, arguments);\n },\n\n _applyCombination: function(fn, args) {\n return fn.apply(null, [this].concat([].slice.call(args)));\n },\n analogous: function() {\n return this._applyCombination(analogous, arguments);\n },\n complement: function() {\n return this._applyCombination(complement, arguments);\n },\n monochromatic: function() {\n return this._applyCombination(monochromatic, arguments);\n },\n splitcomplement: function() {\n return this._applyCombination(splitcomplement, arguments);\n },\n triad: function() {\n return this._applyCombination(triad, arguments);\n },\n tetrad: function() {\n return this._applyCombination(tetrad, arguments);\n }\n };\n\n// If input is an object, force 1 into \"1.0\" to handle ratios properly\n// String input requires \"1.0\" as input, so 1 will be treated as 1\n tinycolor.fromRatio = function(color, opts) {\n if (typeof color == \"object\") {\n var newColor = {};\n for (var i in color) {\n if (color.hasOwnProperty(i)) {\n if (i === \"a\") {\n newColor[i] = color[i];\n }\n else {\n newColor[i] = convertToPercentage(color[i]);\n }\n }\n }\n color = newColor;\n }\n\n return tinycolor(color, opts);\n };\n\n// Given a string or object, convert that input to RGB\n// Possible string inputs:\n//\n// \"red\"\n// \"#f00\" or \"f00\"\n// \"#ff0000\" or \"ff0000\"\n// \"#ff000000\" or \"ff000000\"\n// \"rgb 255 0 0\" or \"rgb (255, 0, 0)\"\n// \"rgb 1.0 0 0\" or \"rgb (1, 0, 0)\"\n// \"rgba (255, 0, 0, 1)\" or \"rgba 255, 0, 0, 1\"\n// \"rgba (1.0, 0, 0, 1)\" or \"rgba 1.0, 0, 0, 1\"\n// \"hsl(0, 100%, 50%)\" or \"hsl 0 100% 50%\"\n// \"hsla(0, 100%, 50%, 1)\" or \"hsla 0 100% 50%, 1\"\n// \"hsv(0, 100%, 100%)\" or \"hsv 0 100% 100%\"\n//\n function inputToRGB(color) {\n\n var rgb = { r: 0, g: 0, b: 0 };\n var a = 1;\n var s = null;\n var v = null;\n var l = null;\n var ok = false;\n var format = false;\n\n if (typeof color == \"string\") {\n color = stringInputToObject(color);\n }\n\n if (typeof color == \"object\") {\n if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {\n rgb = rgbToRgb(color.r, color.g, color.b);\n ok = true;\n format = String(color.r).substr(-1) === \"%\" ? \"prgb\" : \"rgb\";\n }\n else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {\n s = convertToPercentage(color.s);\n v = convertToPercentage(color.v);\n rgb = hsvToRgb(color.h, s, v);\n ok = true;\n format = \"hsv\";\n }\n else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {\n s = convertToPercentage(color.s);\n l = convertToPercentage(color.l);\n rgb = hslToRgb(color.h, s, l);\n ok = true;\n format = \"hsl\";\n }\n\n if (color.hasOwnProperty(\"a\")) {\n a = color.a;\n }\n }\n\n a = boundAlpha(a);\n\n return {\n ok: ok,\n format: color.format || format,\n r: mathMin(255, mathMax(rgb.r, 0)),\n g: mathMin(255, mathMax(rgb.g, 0)),\n b: mathMin(255, mathMax(rgb.b, 0)),\n a: a\n };\n }\n\n\n// Conversion Functions\n// --------------------\n\n// `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:\n// <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>\n\n// `rgbToRgb`\n// Handle bounds / percentage checking to conform to CSS color spec\n// <http://www.w3.org/TR/css3-color/>\n// *Assumes:* r, g, b in [0, 255] or [0, 1]\n// *Returns:* { r, g, b } in [0, 255]\n function rgbToRgb(r, g, b){\n return {\n r: bound01(r, 255) * 255,\n g: bound01(g, 255) * 255,\n b: bound01(b, 255) * 255\n };\n }\n\n// `rgbToHsl`\n// Converts an RGB color value to HSL.\n// *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]\n// *Returns:* { h, s, l } in [0,1]\n function rgbToHsl(r, g, b) {\n\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n\n var max = mathMax(r, g, b), min = mathMin(r, g, b);\n var h, s, l = (max + min) / 2;\n\n if(max == min) {\n h = s = 0; // achromatic\n }\n else {\n var d = max - min;\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min);\n switch(max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n\n h /= 6;\n }\n\n return { h: h, s: s, l: l };\n }\n\n// `hslToRgb`\n// Converts an HSL color value to RGB.\n// *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]\n// *Returns:* { r, g, b } in the set [0, 255]\n function hslToRgb(h, s, l) {\n var r, g, b;\n\n h = bound01(h, 360);\n s = bound01(s, 100);\n l = bound01(l, 100);\n\n function hue2rgb(p, q, t) {\n if(t < 0) t += 1;\n if(t > 1) t -= 1;\n if(t < 1/6) return p + (q - p) * 6 * t;\n if(t < 1/2) return q;\n if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;\n return p;\n }\n\n if(s === 0) {\n r = g = b = l; // achromatic\n }\n else {\n var q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n var p = 2 * l - q;\n r = hue2rgb(p, q, h + 1/3);\n g = hue2rgb(p, q, h);\n b = hue2rgb(p, q, h - 1/3);\n }\n\n return { r: r * 255, g: g * 255, b: b * 255 };\n }\n\n// `rgbToHsv`\n// Converts an RGB color value to HSV\n// *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]\n// *Returns:* { h, s, v } in [0,1]\n function rgbToHsv(r, g, b) {\n\n r = bound01(r, 255);\n g = bound01(g, 255);\n b = bound01(b, 255);\n\n var max = mathMax(r, g, b), min = mathMin(r, g, b);\n var h, s, v = max;\n\n var d = max - min;\n s = max === 0 ? 0 : d / max;\n\n if(max == min) {\n h = 0; // achromatic\n }\n else {\n switch(max) {\n case r: h = (g - b) / d + (g < b ? 6 : 0); break;\n case g: h = (b - r) / d + 2; break;\n case b: h = (r - g) / d + 4; break;\n }\n h /= 6;\n }\n return { h: h, s: s, v: v };\n }\n\n// `hsvToRgb`\n// Converts an HSV color value to RGB.\n// *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]\n// *Returns:* { r, g, b } in the set [0, 255]\n function hsvToRgb(h, s, v) {\n\n h = bound01(h, 360) * 6;\n s = bound01(s, 100);\n v = bound01(v, 100);\n\n var i = Math.floor(h),\n f = h - i,\n p = v * (1 - s),\n q = v * (1 - f * s),\n t = v * (1 - (1 - f) * s),\n mod = i % 6,\n r = [v, q, p, p, t, v][mod],\n g = [t, v, v, q, p, p][mod],\n b = [p, p, t, v, v, q][mod];\n\n return { r: r * 255, g: g * 255, b: b * 255 };\n }\n\n// `rgbToHex`\n// Converts an RGB color to hex\n// Assumes r, g, and b are contained in the set [0, 255]\n// Returns a 3 or 6 character hex\n function rgbToHex(r, g, b, allow3Char) {\n\n var hex = [\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16))\n ];\n\n // Return a 3 character hex if possible\n if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {\n return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);\n }\n\n return hex.join(\"\");\n }\n\n// `rgbaToHex`\n// Converts an RGBA color plus alpha transparency to hex\n// Assumes r, g, b are contained in the set [0, 255] and\n// a in [0, 1]. Returns a 4 or 8 character rgba hex\n function rgbaToHex(r, g, b, a, allow4Char) {\n\n var hex = [\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16)),\n pad2(convertDecimalToHex(a))\n ];\n\n // Return a 4 character hex if possible\n if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {\n return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);\n }\n\n return hex.join(\"\");\n }\n\n// `rgbaToArgbHex`\n// Converts an RGBA color to an ARGB Hex8 string\n// Rarely used, but required for \"toFilter()\"\n function rgbaToArgbHex(r, g, b, a) {\n\n var hex = [\n pad2(convertDecimalToHex(a)),\n pad2(mathRound(r).toString(16)),\n pad2(mathRound(g).toString(16)),\n pad2(mathRound(b).toString(16))\n ];\n\n return hex.join(\"\");\n }\n\n// `equals`\n// Can be called with any tinycolor input\n tinycolor.equals = function (color1, color2) {\n if (!color1 || !color2) { return false; }\n return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();\n };\n\n tinycolor.random = function() {\n return tinycolor.fromRatio({\n r: mathRandom(),\n g: mathRandom(),\n b: mathRandom()\n });\n };\n\n\n// Modification Functions\n// ----------------------\n// Thanks to less.js for some of the basics here\n// <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>\n\n function desaturate(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.s -= amount / 100;\n hsl.s = clamp01(hsl.s);\n return tinycolor(hsl);\n }\n\n function saturate(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.s += amount / 100;\n hsl.s = clamp01(hsl.s);\n return tinycolor(hsl);\n }\n\n function greyscale(color) {\n return tinycolor(color).desaturate(100);\n }\n\n function lighten (color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.l += amount / 100;\n hsl.l = clamp01(hsl.l);\n return tinycolor(hsl);\n }\n\n function brighten(color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var rgb = tinycolor(color).toRgb();\n rgb.r = mathMax(0, mathMin(255, rgb.r - mathRound(255 * - (amount / 100))));\n rgb.g = mathMax(0, mathMin(255, rgb.g - mathRound(255 * - (amount / 100))));\n rgb.b = mathMax(0, mathMin(255, rgb.b - mathRound(255 * - (amount / 100))));\n return tinycolor(rgb);\n }\n\n function darken (color, amount) {\n amount = (amount === 0) ? 0 : (amount || 10);\n var hsl = tinycolor(color).toHsl();\n hsl.l -= amount / 100;\n hsl.l = clamp01(hsl.l);\n return tinycolor(hsl);\n }\n\n// Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.\n// Values outside of this range will be wrapped into this range.\n function spin(color, amount) {\n var hsl = tinycolor(color).toHsl();\n var hue = (hsl.h + amount) % 360;\n hsl.h = hue < 0 ? 360 + hue : hue;\n return tinycolor(hsl);\n }\n\n// Combination Functions\n// ---------------------\n// Thanks to jQuery xColor for some of the ideas behind these\n// <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>\n\n function complement(color) {\n var hsl = tinycolor(color).toHsl();\n hsl.h = (hsl.h + 180) % 360;\n return tinycolor(hsl);\n }\n\n function triad(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })\n ];\n }\n\n function tetrad(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),\n tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })\n ];\n }\n\n function splitcomplement(color) {\n var hsl = tinycolor(color).toHsl();\n var h = hsl.h;\n return [\n tinycolor(color),\n tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),\n tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})\n ];\n }\n\n function analogous(color, results, slices) {\n results = results || 6;\n slices = slices || 30;\n\n var hsl = tinycolor(color).toHsl();\n var part = 360 / slices;\n var ret = [tinycolor(color)];\n\n for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {\n hsl.h = (hsl.h + part) % 360;\n ret.push(tinycolor(hsl));\n }\n return ret;\n }\n\n function monochromatic(color, results) {\n results = results || 6;\n var hsv = tinycolor(color).toHsv();\n var h = hsv.h, s = hsv.s, v = hsv.v;\n var ret = [];\n var modification = 1 / results;\n\n while (results--) {\n ret.push(tinycolor({ h: h, s: s, v: v}));\n v = (v + modification) % 1;\n }\n\n return ret;\n }\n\n// Utility Functions\n// ---------------------\n\n tinycolor.mix = function(color1, color2, amount) {\n amount = (amount === 0) ? 0 : (amount || 50);\n\n var rgb1 = tinycolor(color1).toRgb();\n var rgb2 = tinycolor(color2).toRgb();\n\n var p = amount / 100;\n\n var rgba = {\n r: ((rgb2.r - rgb1.r) * p) + rgb1.r,\n g: ((rgb2.g - rgb1.g) * p) + rgb1.g,\n b: ((rgb2.b - rgb1.b) * p) + rgb1.b,\n a: ((rgb2.a - rgb1.a) * p) + rgb1.a\n };\n\n return tinycolor(rgba);\n };\n\n\n// Readability Functions\n// ---------------------\n// <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)\n\n// `contrast`\n// Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)\n tinycolor.readability = function(color1, color2) {\n var c1 = tinycolor(color1);\n var c2 = tinycolor(color2);\n return (Math.max(c1.getLuminance(),c2.getLuminance())+0.05) / (Math.min(c1.getLuminance(),c2.getLuminance())+0.05);\n };\n\n// `isReadable`\n// Ensure that foreground and background color combinations meet WCAG2 guidelines.\n// The third argument is an optional Object.\n// the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';\n// the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.\n// If the entire object is absent, isReadable defaults to {level:\"AA\",size:\"small\"}.\n\n// *Example*\n// tinycolor.isReadable(\"#000\", \"#111\") => false\n// tinycolor.isReadable(\"#000\", \"#111\",{level:\"AA\",size:\"large\"}) => false\n tinycolor.isReadable = function(color1, color2, wcag2) {\n var readability = tinycolor.readability(color1, color2);\n var wcag2Parms, out;\n\n out = false;\n\n wcag2Parms = validateWCAG2Parms(wcag2);\n switch (wcag2Parms.level + wcag2Parms.size) {\n case \"AAsmall\":\n case \"AAAlarge\":\n out = readability >= 4.5;\n break;\n case \"AAlarge\":\n out = readability >= 3;\n break;\n case \"AAAsmall\":\n out = readability >= 7;\n break;\n }\n return out;\n\n };\n\n// `mostReadable`\n// Given a base color and a list of possible foreground or background\n// colors for that base, returns the most readable color.\n// Optionally returns Black or White if the most readable color is unreadable.\n// *Example*\n// tinycolor.mostReadable(tinycolor.mostReadable(\"#123\", [\"#124\", \"#125\"],{includeFallbackColors:false}).toHexString(); // \"#112255\"\n// tinycolor.mostReadable(tinycolor.mostReadable(\"#123\", [\"#124\", \"#125\"],{includeFallbackColors:true}).toHexString(); // \"#ffffff\"\n// tinycolor.mostReadable(\"#a8015a\", [\"#faf3f3\"],{includeFallbackColors:true,level:\"AAA\",size:\"large\"}).toHexString(); // \"#faf3f3\"\n// tinycolor.mostReadable(\"#a8015a\", [\"#faf3f3\"],{includeFallbackColors:true,level:\"AAA\",size:\"small\"}).toHexString(); // \"#ffffff\"\n tinycolor.mostReadable = function(baseColor, colorList, args) {\n var bestColor = null;\n var bestScore = 0;\n var readability;\n var includeFallbackColors, level, size ;\n args = args || {};\n includeFallbackColors = args.includeFallbackColors ;\n level = args.level;\n size = args.size;\n\n for (var i= 0; i < colorList.length ; i++) {\n readability = tinycolor.readability(baseColor, colorList[i]);\n if (readability > bestScore) {\n bestScore = readability;\n bestColor = tinycolor(colorList[i]);\n }\n }\n\n if (tinycolor.isReadable(baseColor, bestColor, {\"level\":level,\"size\":size}) || !includeFallbackColors) {\n return bestColor;\n }\n else {\n args.includeFallbackColors=false;\n return tinycolor.mostReadable(baseColor,[\"#fff\", \"#000\"],args);\n }\n };\n\n\n// Big List of Colors\n// ------------------\n// <http://www.w3.org/TR/css3-color/#svg-color>\n var names = tinycolor.names = {\n aliceblue: \"f0f8ff\",\n antiquewhite: \"faebd7\",\n aqua: \"0ff\",\n aquamarine: \"7fffd4\",\n azure: \"f0ffff\",\n beige: \"f5f5dc\",\n bisque: \"ffe4c4\",\n black: \"000\",\n blanchedalmond: \"ffebcd\",\n blue: \"00f\",\n blueviolet: \"8a2be2\",\n brown: \"a52a2a\",\n burlywood: \"deb887\",\n burntsienna: \"ea7e5d\",\n cadetblue: \"5f9ea0\",\n chartreuse: \"7fff00\",\n chocolate: \"d2691e\",\n coral: \"ff7f50\",\n cornflowerblue: \"6495ed\",\n cornsilk: \"fff8dc\",\n crimson: \"dc143c\",\n cyan: \"0ff\",\n darkblue: \"00008b\",\n darkcyan: \"008b8b\",\n darkgoldenrod: \"b8860b\",\n darkgray: \"a9a9a9\",\n darkgreen: \"006400\",\n darkgrey: \"a9a9a9\",\n darkkhaki: \"bdb76b\",\n darkmagenta: \"8b008b\",\n darkolivegreen: \"556b2f\",\n darkorange: \"ff8c00\",\n darkorchid: \"9932cc\",\n darkred: \"8b0000\",\n darksalmon: \"e9967a\",\n darkseagreen: \"8fbc8f\",\n darkslateblue: \"483d8b\",\n darkslategray: \"2f4f4f\",\n darkslategrey: \"2f4f4f\",\n darkturquoise: \"00ced1\",\n darkviolet: \"9400d3\",\n deeppink: \"ff1493\",\n deepskyblue: \"00bfff\",\n dimgray: \"696969\",\n dimgrey: \"696969\",\n dodgerblue: \"1e90ff\",\n firebrick: \"b22222\",\n floralwhite: \"fffaf0\",\n forestgreen: \"228b22\",\n fuchsia: \"f0f\",\n gainsboro: \"dcdcdc\",\n ghostwhite: \"f8f8ff\",\n gold: \"ffd700\",\n goldenrod: \"daa520\",\n gray: \"808080\",\n green: \"008000\",\n greenyellow: \"adff2f\",\n grey: \"808080\",\n honeydew: \"f0fff0\",\n hotpink: \"ff69b4\",\n indianred: \"cd5c5c\",\n indigo: \"4b0082\",\n ivory: \"fffff0\",\n khaki: \"f0e68c\",\n lavender: \"e6e6fa\",\n lavenderblush: \"fff0f5\",\n lawngreen: \"7cfc00\",\n lemonchiffon: \"fffacd\",\n lightblue: \"add8e6\",\n lightcoral: \"f08080\",\n lightcyan: \"e0ffff\",\n lightgoldenrodyellow: \"fafad2\",\n lightgray: \"d3d3d3\",\n lightgreen: \"90ee90\",\n lightgrey: \"d3d3d3\",\n lightpink: \"ffb6c1\",\n lightsalmon: \"ffa07a\",\n lightseagreen: \"20b2aa\",\n lightskyblue: \"87cefa\",\n lightslategray: \"789\",\n lightslategrey: \"789\",\n lightsteelblue: \"b0c4de\",\n lightyellow: \"ffffe0\",\n lime: \"0f0\",\n limegreen: \"32cd32\",\n linen: \"faf0e6\",\n magenta: \"f0f\",\n maroon: \"800000\",\n mediumaquamarine: \"66cdaa\",\n mediumblue: \"0000cd\",\n mediumorchid: \"ba55d3\",\n mediumpurple: \"9370db\",\n mediumseagreen: \"3cb371\",\n mediumslateblue: \"7b68ee\",\n mediumspringgreen: \"00fa9a\",\n mediumturquoise: \"48d1cc\",\n mediumvioletred: \"c71585\",\n midnightblue: \"191970\",\n mintcream: \"f5fffa\",\n mistyrose: \"ffe4e1\",\n moccasin: \"ffe4b5\",\n navajowhite: \"ffdead\",\n navy: \"000080\",\n oldlace: \"fdf5e6\",\n olive: \"808000\",\n olivedrab: \"6b8e23\",\n orange: \"ffa500\",\n orangered: \"ff4500\",\n orchid: \"da70d6\",\n palegoldenrod: \"eee8aa\",\n palegreen: \"98fb98\",\n paleturquoise: \"afeeee\",\n palevioletred: \"db7093\",\n papayawhip: \"ffefd5\",\n peachpuff: \"ffdab9\",\n peru: \"cd853f\",\n pink: \"ffc0cb\",\n plum: \"dda0dd\",\n powderblue: \"b0e0e6\",\n purple: \"800080\",\n rebeccapurple: \"663399\",\n red: \"f00\",\n rosybrown: \"bc8f8f\",\n royalblue: \"4169e1\",\n saddlebrown: \"8b4513\",\n salmon: \"fa8072\",\n sandybrown: \"f4a460\",\n seagreen: \"2e8b57\",\n seashell: \"fff5ee\",\n sienna: \"a0522d\",\n silver: \"c0c0c0\",\n skyblue: \"87ceeb\",\n slateblue: \"6a5acd\",\n slategray: \"708090\",\n slategrey: \"708090\",\n snow: \"fffafa\",\n springgreen: \"00ff7f\",\n steelblue: \"4682b4\",\n tan: \"d2b48c\",\n teal: \"008080\",\n thistle: \"d8bfd8\",\n tomato: \"ff6347\",\n turquoise: \"40e0d0\",\n violet: \"ee82ee\",\n wheat: \"f5deb3\",\n white: \"fff\",\n whitesmoke: \"f5f5f5\",\n yellow: \"ff0\",\n yellowgreen: \"9acd32\"\n };\n\n// Make it easy to access colors via `hexNames[hex]`\n var hexNames = tinycolor.hexNames = flip(names);\n\n\n// Utilities\n// ---------\n\n// `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`\n function flip(o) {\n var flipped = { };\n for (var i in o) {\n if (o.hasOwnProperty(i)) {\n flipped[o[i]] = i;\n }\n }\n return flipped;\n }\n\n// Return a valid alpha value [0,1] with all invalid values being set to 1\n function boundAlpha(a) {\n a = parseFloat(a);\n\n if (isNaN(a) || a < 0 || a > 1) {\n a = 1;\n }\n\n return a;\n }\n\n// Take input from [0, n] and return it as [0, 1]\n function bound01(n, max) {\n if (isOnePointZero(n)) { n = \"100%\"; }\n\n var processPercent = isPercentage(n);\n n = mathMin(max, mathMax(0, parseFloat(n)));\n\n // Automatically convert percentage into number\n if (processPercent) {\n n = parseInt(n * max, 10) / 100;\n }\n\n // Handle floating point rounding errors\n if ((Math.abs(n - max) < 0.000001)) {\n return 1;\n }\n\n // Convert into [0, 1] range if it isn't already\n return (n % max) / parseFloat(max);\n }\n\n// Force a number between 0 and 1\n function clamp01(val) {\n return mathMin(1, mathMax(0, val));\n }\n\n// Parse a base-16 hex value into a base-10 integer\n function parseIntFromHex(val) {\n return parseInt(val, 16);\n }\n\n// Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1\n// <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>\n function isOnePointZero(n) {\n return typeof n == \"string\" && n.indexOf('.') != -1 && parseFloat(n) === 1;\n }\n\n// Check to see if string passed in is a percentage\n function isPercentage(n) {\n return typeof n === \"string\" && n.indexOf('%') != -1;\n }\n\n// Force a hex value to have 2 characters\n function pad2(c) {\n return c.length == 1 ? '0' + c : '' + c;\n }\n\n// Replace a decimal with it's percentage value\n function convertToPercentage(n) {\n if (n <= 1) {\n n = (n * 100) + \"%\";\n }\n\n return n;\n }\n\n// Converts a decimal to a hex value\n function convertDecimalToHex(d) {\n return Math.round(parseFloat(d) * 255).toString(16);\n }\n// Converts a hex value to a decimal\n function convertHexToDecimal(h) {\n return (parseIntFromHex(h) / 255);\n }\n\n var matchers = (function() {\n\n // <http://www.w3.org/TR/css3-values/#integers>\n var CSS_INTEGER = \"[-\\\\+]?\\\\d+%?\";\n\n // <http://www.w3.org/TR/css3-values/#number-value>\n var CSS_NUMBER = \"[-\\\\+]?\\\\d*\\\\.\\\\d+%?\";\n\n // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.\n var CSS_UNIT = \"(?:\" + CSS_NUMBER + \")|(?:\" + CSS_INTEGER + \")\";\n\n // Actual matching.\n // Parentheses and commas are optional, but not required.\n // Whitespace can take the place of commas or opening paren\n var PERMISSIVE_MATCH3 = \"[\\\\s|\\\\(]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")\\\\s*\\\\)?\";\n var PERMISSIVE_MATCH4 = \"[\\\\s|\\\\(]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")[,|\\\\s]+(\" + CSS_UNIT + \")\\\\s*\\\\)?\";\n\n return {\n CSS_UNIT: new RegExp(CSS_UNIT),\n rgb: new RegExp(\"rgb\" + PERMISSIVE_MATCH3),\n rgba: new RegExp(\"rgba\" + PERMISSIVE_MATCH4),\n hsl: new RegExp(\"hsl\" + PERMISSIVE_MATCH3),\n hsla: new RegExp(\"hsla\" + PERMISSIVE_MATCH4),\n hsv: new RegExp(\"hsv\" + PERMISSIVE_MATCH3),\n hsva: new RegExp(\"hsva\" + PERMISSIVE_MATCH4),\n hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,\n hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,\n hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,\n hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/\n };\n })();\n\n// `isValidCSSUnit`\n// Take in a single string / number and check to see if it looks like a CSS unit\n// (see `matchers` above for definition).\n function isValidCSSUnit(color) {\n return !!matchers.CSS_UNIT.exec(color);\n }\n\n// `stringInputToObject`\n// Permissive string parsing. Take in a number of formats, and output an object\n// based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`\n function stringInputToObject(color) {\n\n color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();\n var named = false;\n if (names[color]) {\n color = names[color];\n named = true;\n }\n else if (color == 'transparent') {\n return { r: 0, g: 0, b: 0, a: 0, format: \"name\" };\n }\n\n // Try to match string input using regular expressions.\n // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]\n // Just return an object and let the conversion functions handle that.\n // This way the result will be the same whether the tinycolor is initialized with string or object.\n var match;\n if ((match = matchers.rgb.exec(color))) {\n return { r: match[1], g: match[2], b: match[3] };\n }\n if ((match = matchers.rgba.exec(color))) {\n return { r: match[1], g: match[2], b: match[3], a: match[4] };\n }\n if ((match = matchers.hsl.exec(color))) {\n return { h: match[1], s: match[2], l: match[3] };\n }\n if ((match = matchers.hsla.exec(color))) {\n return { h: match[1], s: match[2], l: match[3], a: match[4] };\n }\n if ((match = matchers.hsv.exec(color))) {\n return { h: match[1], s: match[2], v: match[3] };\n }\n if ((match = matchers.hsva.exec(color))) {\n return { h: match[1], s: match[2], v: match[3], a: match[4] };\n }\n if ((match = matchers.hex8.exec(color))) {\n return {\n r: parseIntFromHex(match[1]),\n g: parseIntFromHex(match[2]),\n b: parseIntFromHex(match[3]),\n a: convertHexToDecimal(match[4]),\n format: named ? \"name\" : \"hex8\"\n };\n }\n if ((match = matchers.hex6.exec(color))) {\n return {\n r: parseIntFromHex(match[1]),\n g: parseIntFromHex(match[2]),\n b: parseIntFromHex(match[3]),\n format: named ? \"name\" : \"hex\"\n };\n }\n if ((match = matchers.hex4.exec(color))) {\n return {\n r: parseIntFromHex(match[1] + '' + match[1]),\n g: parseIntFromHex(match[2] + '' + match[2]),\n b: parseIntFromHex(match[3] + '' + match[3]),\n a: convertHexToDecimal(match[4] + '' + match[4]),\n format: named ? \"name\" : \"hex8\"\n };\n }\n if ((match = matchers.hex3.exec(color))) {\n return {\n r: parseIntFromHex(match[1] + '' + match[1]),\n g: parseIntFromHex(match[2] + '' + match[2]),\n b: parseIntFromHex(match[3] + '' + match[3]),\n format: named ? \"name\" : \"hex\"\n };\n }\n\n return false;\n }\n\n function validateWCAG2Parms(parms) {\n // return valid WCAG2 parms for isReadable.\n // If input parms are invalid, return {\"level\":\"AA\", \"size\":\"small\"}\n var level, size;\n parms = parms || {\"level\":\"AA\", \"size\":\"small\"};\n level = (parms.level || \"AA\").toUpperCase();\n size = (parms.size || \"small\").toLowerCase();\n if (level !== \"AA\" && level !== \"AAA\") {\n level = \"AA\";\n }\n if (size !== \"small\" && size !== \"large\") {\n size = \"small\";\n }\n return {\"level\":level, \"size\":size};\n }\n\n// Node: Export function\n if (typeof module !== \"undefined\" && module.exports) {\n module.exports = tinycolor;\n }\n// AMD/requirejs: Define the module\n else if (typeof define === 'function' && define.amd) {\n define(function () {return tinycolor;});\n }\n// Browser: Expose to window\n else {\n window.tinycolor = tinycolor;\n }\n\n})(Math);\n","jquery/patches/jquery.js":"/**\n * Copyright \u00a9 Magento, Inc. All rights reserved.\n * See COPYING.txt for license details.\n */\n\ndefine([], function () {\n 'use strict';\n\n /**\n * Patch for CVE-2015-9251 (XSS vulnerability).\n * Can safely remove only when jQuery UI is upgraded to >= 3.3.x.\n * https://www.cvedetails.com/cve/CVE-2015-9251/\n */\n function ajaxResponsePatch(jQuery) {\n jQuery.ajaxPrefilter(function (s) {\n if (s.crossDomain) {\n s.contents.script = false;\n }\n });\n }\n\n return function ($) {\n var majorVersion = $.fn.jquery.split('.')[0];\n\n if (majorVersion >= 3) {\n console.warn('jQuery patch for CVE-2015-9251 is no longer necessary, and should be removed');\n }\n\n ajaxResponsePatch($);\n\n return $;\n };\n});\n","Magento_Translation/js/mage-translation-dictionary.js":"/**\n * Copyright \u00a9 Magento, Inc. All rights reserved.\n * See COPYING.txt for license details.\n */\n\ndefine([\n 'text!js-translation.json'\n], function (dict) {\n 'use strict';\n\n return JSON.parse(dict);\n});\n"}
}});