`). The attribute value, if it exists, is then used\n * as the default key when importing an element.\n * If null, no attribute value is used as the default key.\n */\nlet keyAttributeName = \"key\";\nfunction getKeyAttributeName() {\n return keyAttributeName;\n}\nfunction setKeyAttributeName(name) {\n keyAttributeName = name;\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Keeps track whether or not we are in an attributes declaration (after\n * elementOpenStart, but before elementOpenEnd).\n */\nlet inAttributes = false;\n/**\n * Keeps track whether or not we are in an element that should not have its\n * children cleared.\n */\nlet inSkip = false;\n/**\n * Keeps track of whether or not we are in a patch.\n */\nlet inPatch = false;\n/**\n * Asserts that a value exists and is not null or undefined. goog.asserts\n * is not used in order to avoid dependencies on external code.\n * @param val The value to assert is truthy.\n * @returns The value.\n */\nfunction assert(val) {\n if (!val) {\n throw new Error(\"Expected value to be defined\");\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return val;\n}\n/**\n * Makes sure that there is a current patch context.\n * @param functionName The name of the caller, for the error message.\n */\nfunction assertInPatch(functionName) {\n if (!inPatch) {\n throw new Error(\"Cannot call \" + functionName + \"() unless in patch.\");\n }\n}\n/**\n * Makes sure that a patch closes every node that it opened.\n * @param openElement\n * @param root\n */\nfunction assertNoUnclosedTags(openElement, root) {\n if (openElement === root) {\n return;\n }\n let currentElement = openElement;\n const openTags = [];\n while (currentElement && currentElement !== root) {\n openTags.push(currentElement.nodeName.toLowerCase());\n currentElement = currentElement.parentNode;\n }\n throw new Error(\"One or more tags were not closed:\\n\" + openTags.join(\"\\n\"));\n}\n/**\n * Makes sure that node being outer patched has a parent node.\n * @param parent\n */\nfunction assertPatchOuterHasParentNode(parent) {\n if (!parent) {\n console.warn(\"patchOuter requires the node have a parent if there is a key.\");\n }\n}\n/**\n * Makes sure that the caller is not where attributes are expected.\n * @param functionName The name of the caller, for the error message.\n */\nfunction assertNotInAttributes(functionName) {\n if (inAttributes) {\n throw new Error(functionName +\n \"() can not be called between \" +\n \"elementOpenStart() and elementOpenEnd().\");\n }\n}\n/**\n * Makes sure that the caller is not inside an element that has declared skip.\n * @param functionName The name of the caller, for the error message.\n */\nfunction assertNotInSkip(functionName) {\n if (inSkip) {\n throw new Error(functionName +\n \"() may not be called inside an element \" +\n \"that has called skip().\");\n }\n}\n/**\n * Makes sure that the caller is where attributes are expected.\n * @param functionName The name of the caller, for the error message.\n */\nfunction assertInAttributes(functionName) {\n if (!inAttributes) {\n throw new Error(functionName +\n \"() can only be called after calling \" +\n \"elementOpenStart().\");\n }\n}\n/**\n * Makes sure the patch closes virtual attributes call\n */\nfunction assertVirtualAttributesClosed() {\n if (inAttributes) {\n throw new Error(\"elementOpenEnd() must be called after calling \" + \"elementOpenStart().\");\n }\n}\n/**\n * Makes sure that tags are correctly nested.\n * @param currentNameOrCtor\n * @param nameOrCtor\n */\nfunction assertCloseMatchesOpenTag(currentNameOrCtor, nameOrCtor) {\n if (currentNameOrCtor !== nameOrCtor) {\n throw new Error('Received a call to close \"' +\n nameOrCtor +\n '\" but \"' +\n currentNameOrCtor +\n '\" was open.');\n }\n}\n/**\n * Makes sure that no children elements have been declared yet in the current\n * element.\n * @param functionName The name of the caller, for the error message.\n * @param previousNode\n */\nfunction assertNoChildrenDeclaredYet(functionName, previousNode) {\n if (previousNode !== null) {\n throw new Error(functionName +\n \"() must come before any child \" +\n \"declarations inside the current element.\");\n }\n}\n/**\n * Checks that a call to patchOuter actually patched the element.\n * @param maybeStartNode The value for the currentNode when the patch\n * started.\n * @param maybeCurrentNode The currentNode when the patch finished.\n * @param expectedNextNode The Node that is expected to follow the\n * currentNode after the patch;\n * @param expectedPrevNode The Node that is expected to preceed the\n * currentNode after the patch.\n */\nfunction assertPatchElementNoExtras(maybeStartNode, maybeCurrentNode, expectedNextNode, expectedPrevNode) {\n const startNode = assert(maybeStartNode);\n const currentNode = assert(maybeCurrentNode);\n const wasUpdated = currentNode.nextSibling === expectedNextNode &&\n currentNode.previousSibling === expectedPrevNode;\n const wasChanged = currentNode.nextSibling === startNode.nextSibling &&\n currentNode.previousSibling === expectedPrevNode;\n const wasRemoved = currentNode === startNode;\n if (!wasUpdated && !wasChanged && !wasRemoved) {\n throw new Error(\"There must be exactly one top level call corresponding \" +\n \"to the patched element.\");\n }\n}\n/**\n * @param newContext The current patch context.\n */\nfunction updatePatchContext(newContext) {\n inPatch = newContext != null;\n}\n/**\n * Updates the state of being in an attribute declaration.\n * @param value Whether or not the patch is in an attribute declaration.\n * @return the previous value.\n */\nfunction setInAttributes(value) {\n const previous = inAttributes;\n inAttributes = value;\n return previous;\n}\n/**\n * Updates the state of being in a skip element.\n * @param value Whether or not the patch is skipping the children of a\n * parent node.\n * @return the previous value.\n */\nfunction setInSkip(value) {\n const previous = inSkip;\n inSkip = value;\n return previous;\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A cached reference to the hasOwnProperty function.\n */\nconst hasOwnProperty = Object.prototype.hasOwnProperty;\n/**\n * A constructor function that will create blank objects.\n */\nfunction Blank() { }\nBlank.prototype = Object.create(null);\n/**\n * Used to prevent property collisions between our \"map\" and its prototype.\n * @param map The map to check.\n * @param property The property to check.\n * @return Whether map has property.\n */\nfunction has(map, property) {\n return hasOwnProperty.call(map, property);\n}\n/**\n * Creates an map object without a prototype.\n * @returns An Object that can be used as a map.\n */\nfunction createMap() {\n return new Blank();\n}\n/**\n * Truncates an array, removing items up until length.\n * @param arr The array to truncate.\n * @param length The new length of the array.\n */\nfunction truncateArray(arr, length) {\n while (arr.length > length) {\n arr.pop();\n }\n}\n/**\n * Creates an array for a desired initial size. Note that the array will still\n * be empty.\n * @param initialAllocationSize The initial size to allocate.\n * @returns An empty array, with an initial allocation for the desired size.\n */\nfunction createArray(initialAllocationSize) {\n const arr = new Array(initialAllocationSize);\n truncateArray(arr, 0);\n return arr;\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst symbols = {\n default: \"__default\"\n};\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * @param name The name of the attribute. For example \"tabindex\" or\n * \"xlink:href\".\n * @returns The namespace to use for the attribute, or null if there is\n * no namespace.\n */\nfunction getNamespace(name) {\n if (name.lastIndexOf(\"xml:\", 0) === 0) {\n return \"http://www.w3.org/XML/1998/namespace\";\n }\n if (name.lastIndexOf(\"xlink:\", 0) === 0) {\n return \"http://www.w3.org/1999/xlink\";\n }\n return null;\n}\n/**\n * Applies an attribute or property to a given Element. If the value is null\n * or undefined, it is removed from the Element. Otherwise, the value is set\n * as an attribute.\n * @param el The element to apply the attribute to.\n * @param name The attribute's name.\n * @param value The attribute's value.\n */\nfunction applyAttr(el, name, value) {\n if (value == null) {\n el.removeAttribute(name);\n }\n else {\n const attrNS = getNamespace(name);\n if (attrNS) {\n el.setAttributeNS(attrNS, name, String(value));\n }\n else {\n el.setAttribute(name, String(value));\n }\n }\n}\n/**\n * Applies a property to a given Element.\n * @param el The element to apply the property to.\n * @param name The property's name.\n * @param value The property's value.\n */\nfunction applyProp(el, name, value) {\n el[name] = value;\n}\n/**\n * Applies a value to a style declaration. Supports CSS custom properties by\n * setting properties containing a dash using CSSStyleDeclaration.setProperty.\n * @param style A style declaration.\n * @param prop The property to apply. This can be either camelcase or dash\n * separated. For example: \"backgroundColor\" and \"background-color\" are both\n * supported.\n * @param value The value of the property.\n */\nfunction setStyleValue(style, prop, value) {\n if (prop.indexOf(\"-\") >= 0) {\n style.setProperty(prop, value);\n }\n else {\n style[prop] = value;\n }\n}\n/**\n * Applies a style to an Element. No vendor prefix expansion is done for\n * property names/values.\n * @param el The Element to apply the style for.\n * @param name The attribute's name.\n * @param style The style to set. Either a string of css or an object\n * containing property-value pairs.\n */\nfunction applyStyle(el, name, style) {\n // MathML elements inherit from Element, which does not have style. We cannot\n // do `instanceof HTMLElement` / `instanceof SVGElement`, since el can belong\n // to a different document, so just check that it has a style.\n assert(\"style\" in el);\n const elStyle = el.style;\n if (typeof style === \"string\") {\n elStyle.cssText = style;\n }\n else {\n elStyle.cssText = \"\";\n for (const prop in style) {\n if (has(style, prop)) {\n setStyleValue(elStyle, prop, style[prop]);\n }\n }\n }\n}\n/**\n * Updates a single attribute on an Element.\n * @param el The Element to apply the attribute to.\n * @param name The attribute's name.\n * @param value The attribute's value. If the value is an object or\n * function it is set on the Element, otherwise, it is set as an HTML\n * attribute.\n */\nfunction applyAttributeTyped(el, name, value) {\n const type = typeof value;\n if (type === \"object\" || type === \"function\") {\n applyProp(el, name, value);\n }\n else {\n applyAttr(el, name, value);\n }\n}\n/**\n * A publicly mutable object to provide custom mutators for attributes.\n * NB: The result of createMap() has to be recast since closure compiler\n * will just assume attributes is \"any\" otherwise and throws away\n * the type annotation set by tsickle.\n */\nconst attributes = createMap();\n// Special generic mutator that's called for any attribute that does not\n// have a specific mutator.\nattributes[symbols.default] = applyAttributeTyped;\nattributes[\"style\"] = applyStyle;\n/**\n * Calls the appropriate attribute mutator for this attribute.\n * @param el The Element to apply the attribute to.\n * @param name The attribute's name.\n * @param value The attribute's value. If the value is an object or\n * function it is set on the Element, otherwise, it is set as an HTML\n * attribute.\n */\nfunction updateAttribute(el, name, value) {\n const mutator = attributes[name] || attributes[symbols.default];\n mutator(el, name, value);\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst notifications = {\n nodesCreated: null,\n nodesDeleted: null\n};\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * A context object keeps track of the state of a patch.\n */\nclass Context {\n constructor() {\n this.created = [];\n this.deleted = [];\n }\n markCreated(node) {\n this.created.push(node);\n }\n markDeleted(node) {\n this.deleted.push(node);\n }\n /**\n * Notifies about nodes that were created during the patch operation.\n */\n notifyChanges() {\n if (notifications.nodesCreated && this.created.length > 0) {\n notifications.nodesCreated(this.created);\n }\n if (notifications.nodesDeleted && this.deleted.length > 0) {\n notifications.nodesDeleted(this.deleted);\n }\n }\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Checks if the node is the root of a document. This is either a Document\n * or ShadowRoot. DocumentFragments are included for simplicity of the\n * implementation, though we only want to consider Documents or ShadowRoots.\n * @param node The node to check.\n * @return True if the node the root of a document, false otherwise.\n */\nfunction isDocumentRoot(node) {\n return node.nodeType === 11 || node.nodeType === 9;\n}\n/**\n * Checks if the node is an Element. This is faster than an instanceof check.\n * @param node The node to check.\n * @return Whether or not the node is an Element.\n */\nfunction isElement(node) {\n return node.nodeType === 1;\n}\n/**\n * @param node The node to start at, inclusive.\n * @param root The root ancestor to get until, exclusive.\n * @return The ancestry of DOM nodes.\n */\nfunction getAncestry(node, root) {\n const ancestry = [];\n let cur = node;\n while (cur !== root) {\n const n = assert(cur);\n ancestry.push(n);\n cur = n.parentNode;\n }\n return ancestry;\n}\n/**\n * @param this\n * @returns The root node of the DOM tree that contains this node.\n */\nconst getRootNode = (typeof Node !== \"undefined\" && Node.prototype.getRootNode) ||\n function () {\n let cur = this;\n let prev = cur;\n while (cur) {\n prev = cur;\n cur = cur.parentNode;\n }\n return prev;\n };\n/**\n * @param node The node to get the activeElement for.\n * @returns The activeElement in the Document or ShadowRoot\n * corresponding to node, if present.\n */\nfunction getActiveElement(node) {\n const root = getRootNode.call(node);\n return isDocumentRoot(root) ? root.activeElement : null;\n}\n/**\n * Gets the path of nodes that contain the focused node in the same document as\n * a reference node, up until the root.\n * @param node The reference node to get the activeElement for.\n * @param root The root to get the focused path until.\n * @returns The path of focused parents, if any exist.\n */\nfunction getFocusedPath(node, root) {\n const activeElement = getActiveElement(node);\n if (!activeElement || !node.contains(activeElement)) {\n return [];\n }\n return getAncestry(activeElement, root);\n}\n/**\n * Like insertBefore, but instead instead of moving the desired node, instead\n * moves all the other nodes after.\n * @param parentNode\n * @param node\n * @param referenceNode\n */\nfunction moveBefore(parentNode, node, referenceNode) {\n const insertReferenceNode = node.nextSibling;\n let cur = referenceNode;\n while (cur !== null && cur !== node) {\n const next = cur.nextSibling;\n parentNode.insertBefore(cur, insertReferenceNode);\n cur = next;\n }\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Keeps track of information needed to perform diffs for a given DOM node.\n */\nclass NodeData {\n constructor(nameOrCtor, key, text) {\n /**\n * An array of attribute name/value pairs, used for quickly diffing the\n * incomming attributes to see if the DOM node's attributes need to be\n * updated.\n */\n this._attrsArr = null;\n /**\n * Whether or not the statics have been applied for the node yet.\n */\n this.staticsApplied = false;\n this.nameOrCtor = nameOrCtor;\n this.key = key;\n this.text = text;\n }\n hasEmptyAttrsArr() {\n const attrs = this._attrsArr;\n return !attrs || !attrs.length;\n }\n getAttrsArr(length) {\n return this._attrsArr || (this._attrsArr = createArray(length));\n }\n}\n/**\n * Initializes a NodeData object for a Node.\n * @param node The Node to initialized data for.\n * @param nameOrCtor The NameOrCtorDef to use when diffing.\n * @param key The Key for the Node.\n * @param text The data of a Text node, if importing a Text node.\n * @returns A NodeData object with the existing attributes initialized.\n */\nfunction initData(node, nameOrCtor, key, text) {\n const data = new NodeData(nameOrCtor, key, text);\n node[\"__incrementalDOMData\"] = data;\n return data;\n}\n/**\n * @param node The node to check.\n * @returns True if the NodeData already exists, false otherwise.\n */\nfunction isDataInitialized(node) {\n return Boolean(node[\"__incrementalDOMData\"]);\n}\n/**\n * Records the element's attributes.\n * @param node The Element that may have attributes\n * @param data The Element's data\n */\nfunction recordAttributes(node, data) {\n const attributes = node.attributes;\n const length = attributes.length;\n if (!length) {\n return;\n }\n const attrsArr = data.getAttrsArr(length);\n // Use a cached length. The attributes array is really a live NamedNodeMap,\n // which exists as a DOM \"Host Object\" (probably as C++ code). This makes the\n // usual constant length iteration very difficult to optimize in JITs.\n for (let i = 0, j = 0; i < length; i += 1, j += 2) {\n const attr = attributes[i];\n const name = attr.name;\n const value = attr.value;\n attrsArr[j] = name;\n attrsArr[j + 1] = value;\n }\n}\n/**\n * Imports single node and its subtree, initializing caches, if it has not\n * already been imported.\n * @param node The node to import.\n * @param fallbackKey A key to use if importing and no key was specified.\n * Useful when not transmitting keys from serverside render and doing an\n * immediate no-op diff.\n * @returns The NodeData for the node.\n */\nfunction importSingleNode(node, fallbackKey) {\n if (node[\"__incrementalDOMData\"]) {\n return node[\"__incrementalDOMData\"];\n }\n const nodeName = isElement(node) ? node.localName : node.nodeName;\n const keyAttrName = getKeyAttributeName();\n const keyAttr = isElement(node) && keyAttrName != null\n ? node.getAttribute(keyAttrName)\n : null;\n const key = isElement(node) ? keyAttr || fallbackKey : null;\n const data = initData(node, nodeName, key);\n if (isElement(node)) {\n recordAttributes(node, data);\n }\n return data;\n}\n/**\n * Imports node and its subtree, initializing caches.\n * @param node The Node to import.\n */\nfunction importNode(node) {\n importSingleNode(node);\n for (let child = node.firstChild; child; child = child.nextSibling) {\n importNode(child);\n }\n}\n/**\n * Retrieves the NodeData object for a Node, creating it if necessary.\n * @param node The node to get data for.\n * @param fallbackKey A key to use if importing and no key was specified.\n * Useful when not transmitting keys from serverside render and doing an\n * immediate no-op diff.\n * @returns The NodeData for the node.\n */\nfunction getData(node, fallbackKey) {\n return importSingleNode(node, fallbackKey);\n}\n/**\n * Gets the key for a Node. note that the Node should have been imported\n * by now.\n * @param node The node to check.\n * @returns The key used to create the node.\n */\nfunction getKey(node) {\n assert(node[\"__incrementalDOMData\"]);\n return getData(node).key;\n}\n/**\n * Clears all caches from a node and all of its children.\n * @param node The Node to clear the cache for.\n */\nfunction clearCache(node) {\n node[\"__incrementalDOMData\"] = null;\n for (let child = node.firstChild; child; child = child.nextSibling) {\n clearCache(child);\n }\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Gets the namespace to create an element (of a given tag) in.\n * @param tag The tag to get the namespace for.\n * @param parent The current parent Node, if any.\n * @returns The namespace to use,\n */\nfunction getNamespaceForTag(tag, parent) {\n if (tag === \"svg\") {\n return \"http://www.w3.org/2000/svg\";\n }\n if (tag === \"math\") {\n return \"http://www.w3.org/1998/Math/MathML\";\n }\n if (parent == null) {\n return null;\n }\n if (getData(parent).nameOrCtor === \"foreignObject\") {\n return null;\n }\n return parent.namespaceURI;\n}\n/**\n * Creates an Element and initializes the NodeData.\n * @param doc The document with which to create the Element.\n * @param parent The parent of new Element.\n * @param nameOrCtor The tag or constructor for the Element.\n * @param key A key to identify the Element.\n * @returns The newly created Element.\n */\nfunction createElement(doc, parent, nameOrCtor, key) {\n let el;\n if (typeof nameOrCtor === \"function\") {\n el = new nameOrCtor();\n }\n else {\n const namespace = getNamespaceForTag(nameOrCtor, parent);\n if (namespace) {\n el = doc.createElementNS(namespace, nameOrCtor);\n }\n else {\n el = doc.createElement(nameOrCtor);\n }\n }\n initData(el, nameOrCtor, key);\n return el;\n}\n/**\n * Creates a Text Node.\n * @param doc The document with which to create the Element.\n * @returns The newly created Text.\n */\nfunction createText(doc) {\n const node = doc.createTextNode(\"\");\n initData(node, \"#text\", null);\n return node;\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * The default match function to use, if one was not specified when creating\n * the patcher.\n * @param matchNode The node to match against, unused.\n * @param nameOrCtor The name or constructor as declared.\n * @param expectedNameOrCtor The name or constructor of the existing node.\n * @param key The key as declared.\n * @param expectedKey The key of the existing node.\n * @returns True if the node matches, false otherwise.\n */\nfunction defaultMatchFn(matchNode, nameOrCtor, expectedNameOrCtor, key, expectedKey) {\n // Key check is done using double equals as we want to treat a null key the\n // same as undefined. This should be okay as the only values allowed are\n // strings, null and undefined so the == semantics are not too weird.\n return nameOrCtor == expectedNameOrCtor && key == expectedKey;\n}\nlet context = null;\nlet currentNode = null;\nlet currentParent = null;\nlet doc = null;\nlet focusPath = [];\nlet matchFn = defaultMatchFn;\n/**\n * Used to build up call arguments. Each patch call gets a separate copy, so\n * this works with nested calls to patch.\n */\nlet argsBuilder = [];\n/**\n * Used to build up attrs for the an element.\n */\nlet attrsBuilder = [];\n/**\n * TODO(sparhami) We should just export argsBuilder directly when Closure\n * Compiler supports ES6 directly.\n * @returns The Array used for building arguments.\n */\nfunction getArgsBuilder() {\n return argsBuilder;\n}\n/**\n * TODO(sparhami) We should just export attrsBuilder directly when Closure\n * Compiler supports ES6 directly.\n * @returns The Array used for building arguments.\n */\nfunction getAttrsBuilder() {\n return attrsBuilder;\n}\n/**\n * Checks whether or not the current node matches the specified nameOrCtor and\n * key. This uses the specified match function when creating the patcher.\n * @param matchNode A node to match the data to.\n * @param nameOrCtor The name or constructor to check for.\n * @param key The key used to identify the Node.\n * @return True if the node matches, false otherwise.\n */\nfunction matches(matchNode, nameOrCtor, key) {\n const data = getData(matchNode, key);\n return matchFn(matchNode, nameOrCtor, data.nameOrCtor, key, data.key);\n}\n/**\n * Finds the matching node, starting at `node` and looking at the subsequent\n * siblings if a key is used.\n * @param matchNode The node to start looking at.\n * @param nameOrCtor The name or constructor for the Node.\n * @param key The key used to identify the Node.\n * @returns The matching Node, if any exists.\n */\nfunction getMatchingNode(matchNode, nameOrCtor, key) {\n if (!matchNode) {\n return null;\n }\n let cur = matchNode;\n do {\n if (matches(cur, nameOrCtor, key)) {\n return cur;\n }\n } while (key && (cur = cur.nextSibling));\n return null;\n}\n/**\n * Clears out any unvisited Nodes in a given range.\n * @param maybeParentNode\n * @param startNode The node to start clearing from, inclusive.\n * @param endNode The node to clear until, exclusive.\n */\nfunction clearUnvisitedDOM(maybeParentNode, startNode, endNode) {\n const parentNode = maybeParentNode;\n let child = startNode;\n while (child !== endNode) {\n const next = child.nextSibling;\n parentNode.removeChild(child);\n context.markDeleted(child);\n child = next;\n }\n}\n/**\n * @return The next Node to be patched.\n */\nfunction getNextNode() {\n if (currentNode) {\n return currentNode.nextSibling;\n }\n else {\n return currentParent.firstChild;\n }\n}\n/**\n * Changes to the first child of the current node.\n */\nfunction enterNode() {\n currentParent = currentNode;\n currentNode = null;\n}\n/**\n * Changes to the parent of the current node, removing any unvisited children.\n */\nfunction exitNode() {\n clearUnvisitedDOM(currentParent, getNextNode(), null);\n currentNode = currentParent;\n currentParent = currentParent.parentNode;\n}\n/**\n * Changes to the next sibling of the current node.\n */\nfunction nextNode() {\n currentNode = getNextNode();\n}\n/**\n * Creates a Node and marking it as created.\n * @param nameOrCtor The name or constructor for the Node.\n * @param key The key used to identify the Node.\n * @return The newly created node.\n */\nfunction createNode(nameOrCtor, key) {\n let node;\n if (nameOrCtor === \"#text\") {\n node = createText(doc);\n }\n else {\n node = createElement(doc, currentParent, nameOrCtor, key);\n }\n context.markCreated(node);\n return node;\n}\n/**\n * Aligns the virtual Node definition with the actual DOM, moving the\n * corresponding DOM node to the correct location or creating it if necessary.\n * @param nameOrCtor The name or constructor for the Node.\n * @param key The key used to identify the Node.\n */\nfunction alignWithDOM(nameOrCtor, key) {\n nextNode();\n const existingNode = getMatchingNode(currentNode, nameOrCtor, key);\n const node = existingNode || createNode(nameOrCtor, key);\n // If we are at the matching node, then we are done.\n if (node === currentNode) {\n return;\n }\n // Re-order the node into the right position, preserving focus if either\n // node or currentNode are focused by making sure that they are not detached\n // from the DOM.\n if (focusPath.indexOf(node) >= 0) {\n // Move everything else before the node.\n moveBefore(currentParent, node, currentNode);\n }\n else {\n currentParent.insertBefore(node, currentNode);\n }\n currentNode = node;\n}\n/**\n * Makes sure that the current node is an Element with a matching nameOrCtor and\n * key.\n *\n * @param nameOrCtor The tag or constructor for the Element.\n * @param key The key used to identify this element. This can be an\n * empty string, but performance may be better if a unique value is used\n * when iterating over an array of items.\n * @return The corresponding Element.\n */\nfunction open(nameOrCtor, key) {\n alignWithDOM(nameOrCtor, key);\n enterNode();\n return currentParent;\n}\n/**\n * Closes the currently open Element, removing any unvisited children if\n * necessary.\n * @returns The Element that was just closed.\n */\nfunction close() {\n {\n setInSkip(false);\n }\n exitNode();\n return currentNode;\n}\n/**\n * Makes sure the current node is a Text node and creates a Text node if it is\n * not.\n * @returns The Text node that was aligned or created.\n */\nfunction text() {\n alignWithDOM(\"#text\", null);\n return currentNode;\n}\n/**\n * @returns The current Element being patched.\n */\nfunction currentElement() {\n {\n assertInPatch(\"currentElement\");\n assertNotInAttributes(\"currentElement\");\n }\n return currentParent;\n}\n/**\n * @return The Node that will be evaluated for the next instruction.\n */\nfunction currentPointer() {\n {\n assertInPatch(\"currentPointer\");\n assertNotInAttributes(\"currentPointer\");\n }\n // TODO(tomnguyen): assert that this is not null\n return getNextNode();\n}\n/**\n * Skips the children in a subtree, allowing an Element to be closed without\n * clearing out the children.\n */\nfunction skip() {\n {\n assertNoChildrenDeclaredYet(\"skip\", currentNode);\n setInSkip(true);\n }\n currentNode = currentParent.lastChild;\n}\n/**\n * Returns a patcher function that sets up and restores a patch context,\n * running the run function with the provided data.\n * @param run The function that will run the patch.\n * @param patchConfig The configuration to use for the patch.\n * @returns The created patch function.\n */\nfunction createPatcher(run, patchConfig = {}) {\n const { matches = defaultMatchFn } = patchConfig;\n const f = (node, fn, data) => {\n const prevContext = context;\n const prevDoc = doc;\n const prevFocusPath = focusPath;\n const prevArgsBuilder = argsBuilder;\n const prevAttrsBuilder = attrsBuilder;\n const prevCurrentNode = currentNode;\n const prevCurrentParent = currentParent;\n const prevMatchFn = matchFn;\n let previousInAttributes = false;\n let previousInSkip = false;\n doc = node.ownerDocument;\n context = new Context();\n matchFn = matches;\n argsBuilder = [];\n attrsBuilder = [];\n currentNode = null;\n currentParent = node.parentNode;\n focusPath = getFocusedPath(node, currentParent);\n {\n previousInAttributes = setInAttributes(false);\n previousInSkip = setInSkip(false);\n updatePatchContext(context);\n }\n try {\n const retVal = run(node, fn, data);\n {\n assertVirtualAttributesClosed();\n }\n return retVal;\n }\n finally {\n context.notifyChanges();\n doc = prevDoc;\n context = prevContext;\n matchFn = prevMatchFn;\n argsBuilder = prevArgsBuilder;\n attrsBuilder = prevAttrsBuilder;\n currentNode = prevCurrentNode;\n currentParent = prevCurrentParent;\n focusPath = prevFocusPath;\n // Needs to be done after assertions because assertions rely on state\n // from these methods.\n {\n setInAttributes(previousInAttributes);\n setInSkip(previousInSkip);\n updatePatchContext(context);\n }\n }\n };\n return f;\n}\n/**\n * Creates a patcher that patches the document starting at node with a\n * provided function. This function may be called during an existing patch operation.\n * @param patchConfig The config to use for the patch.\n * @returns The created function for patching an Element's children.\n */\nfunction createPatchInner(patchConfig) {\n return createPatcher((node, fn, data) => {\n currentNode = node;\n enterNode();\n fn(data);\n exitNode();\n {\n assertNoUnclosedTags(currentNode, node);\n }\n return node;\n }, patchConfig);\n}\n/**\n * Creates a patcher that patches an Element with the the provided function.\n * Exactly one top level element call should be made corresponding to `node`.\n * @param patchConfig The config to use for the patch.\n * @returns The created function for patching an Element.\n */\nfunction createPatchOuter(patchConfig) {\n return createPatcher((node, fn, data) => {\n const startNode = { nextSibling: node };\n let expectedNextNode = null;\n let expectedPrevNode = null;\n {\n expectedNextNode = node.nextSibling;\n expectedPrevNode = node.previousSibling;\n }\n currentNode = startNode;\n fn(data);\n {\n assertPatchOuterHasParentNode(currentParent);\n assertPatchElementNoExtras(startNode, currentNode, expectedNextNode, expectedPrevNode);\n }\n if (currentParent) {\n clearUnvisitedDOM(currentParent, getNextNode(), node.nextSibling);\n }\n return startNode === currentNode ? null : currentNode;\n }, patchConfig);\n}\nconst patchInner = createPatchInner();\nconst patchOuter = createPatchOuter();\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nconst buffer = [];\nlet bufferStart = 0;\n/**\n * TODO(tomnguyen): This is a bit silly and really needs to be better typed.\n * @param fn A function to call.\n * @param a The first argument to the function.\n * @param b The second argument to the function.\n * @param c The third argument to the function.\n */\nfunction queueChange(fn, a, b, c) {\n buffer.push(fn);\n buffer.push(a);\n buffer.push(b);\n buffer.push(c);\n}\n/**\n * Flushes the changes buffer, calling the functions for each change.\n */\nfunction flush() {\n // A change may cause this function to be called re-entrantly. Keep track of\n // the portion of the buffer we are consuming. Updates the start pointer so\n // that the next call knows where to start from.\n const start = bufferStart;\n const end = buffer.length;\n bufferStart = end;\n for (let i = start; i < end; i += 4) {\n const fn = buffer[i];\n fn(buffer[i + 1], buffer[i + 2], buffer[i + 3]);\n }\n bufferStart = start;\n truncateArray(buffer, start);\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * Used to keep track of the previous values when a 2-way diff is necessary.\n * This object is cleared out and reused.\n */\nconst prevValuesMap = createMap();\n/**\n * Calculates the diff between previous and next values, calling the update\n * function when an item has changed value. If an item from the previous values\n * is not present in the the next values, the update function is called with a\n * value of `undefined`.\n * @param prev The previous values, alternating name, value pairs.\n * @param next The next values, alternating name, value pairs.\n * @param updateCtx The context for the updateFn.\n * @param updateFn A function to call when a value has changed.\n */\nfunction calculateDiff(prev, next, updateCtx, updateFn) {\n const isNew = !prev.length;\n let i = 0;\n for (; i < next.length; i += 2) {\n const name = next[i];\n if (isNew) {\n prev[i] = name;\n }\n else if (prev[i] !== name) {\n break;\n }\n const value = next[i + 1];\n if (isNew || prev[i + 1] !== value) {\n prev[i + 1] = value;\n queueChange(updateFn, updateCtx, name, value);\n }\n }\n // Items did not line up exactly as before, need to make sure old items are\n // removed. This should be a rare case.\n if (i < next.length || i < prev.length) {\n const startIndex = i;\n for (i = startIndex; i < prev.length; i += 2) {\n prevValuesMap[prev[i]] = prev[i + 1];\n }\n for (i = startIndex; i < next.length; i += 2) {\n const name = next[i];\n const value = next[i + 1];\n if (prevValuesMap[name] !== value) {\n queueChange(updateFn, updateCtx, name, value);\n }\n prev[i] = name;\n prev[i + 1] = value;\n delete prevValuesMap[name];\n }\n truncateArray(prev, next.length);\n for (const name in prevValuesMap) {\n queueChange(updateFn, updateCtx, name, undefined);\n delete prevValuesMap[name];\n }\n }\n flush();\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n/**\n * The offset in the virtual element declaration where the attributes are\n * specified.\n */\nconst ATTRIBUTES_OFFSET = 3;\n/**\n * Used to keep track of the previous values when a 2-way diff is necessary.\n * This object is reused.\n * TODO(sparhamI) Scope this to a patch so you can call patch from an attribute\n * update.\n */\nconst prevAttrsMap = createMap();\n/**\n * @param element The Element to diff the attrs for.\n * @param data The NodeData associated with the Element.\n */\nfunction diffAttrs(element, data) {\n const attrsBuilder = getAttrsBuilder();\n const prevAttrsArr = data.getAttrsArr(attrsBuilder.length);\n calculateDiff(prevAttrsArr, attrsBuilder, element, updateAttribute);\n truncateArray(attrsBuilder, 0);\n}\n/**\n * Applies the statics. When importing an Element, any existing attributes that\n * match a static are converted into a static attribute.\n * @param node The Element to apply statics for.\n * @param data The NodeData associated with the Element.\n * @param statics The statics array.\n */\nfunction diffStatics(node, data, statics) {\n if (data.staticsApplied) {\n return;\n }\n data.staticsApplied = true;\n if (!statics || !statics.length) {\n return;\n }\n if (data.hasEmptyAttrsArr()) {\n for (let i = 0; i < statics.length; i += 2) {\n updateAttribute(node, statics[i], statics[i + 1]);\n }\n return;\n }\n for (let i = 0; i < statics.length; i += 2) {\n prevAttrsMap[statics[i]] = i + 1;\n }\n const attrsArr = data.getAttrsArr(0);\n let j = 0;\n for (let i = 0; i < attrsArr.length; i += 2) {\n const name = attrsArr[i];\n const value = attrsArr[i + 1];\n const staticsIndex = prevAttrsMap[name];\n if (staticsIndex) {\n // For any attrs that are static and have the same value, make sure we do\n // not set them again.\n if (statics[staticsIndex] === value) {\n delete prevAttrsMap[name];\n }\n continue;\n }\n // For any attrs that are dynamic, move them up to the right place.\n attrsArr[j] = name;\n attrsArr[j + 1] = value;\n j += 2;\n }\n // Anything after `j` was either moved up already or static.\n truncateArray(attrsArr, j);\n for (const name in prevAttrsMap) {\n updateAttribute(node, name, statics[prevAttrsMap[name]]);\n delete prevAttrsMap[name];\n }\n}\n/**\n * Declares a virtual Element at the current location in the document. This\n * corresponds to an opening tag and a elementClose tag is required. This is\n * like elementOpen, but the attributes are defined using the attr function\n * rather than being passed as arguments. Must be folllowed by 0 or more calls\n * to attr, then a call to elementOpenEnd.\n * @param nameOrCtor The Element's tag or constructor.\n * @param key The key used to identify this element. This can be an\n * empty string, but performance may be better if a unique value is used\n * when iterating over an array of items.\n * @param statics An array of attribute name/value pairs of the static\n * attributes for the Element. Attributes will only be set once when the\n * Element is created.\n */\nfunction elementOpenStart(nameOrCtor, key, statics) {\n const argsBuilder = getArgsBuilder();\n {\n assertNotInAttributes(\"elementOpenStart\");\n setInAttributes(true);\n }\n argsBuilder[0] = nameOrCtor;\n argsBuilder[1] = key;\n argsBuilder[2] = statics;\n}\n/**\n * Allows you to define a key after an elementOpenStart. This is useful in\n * templates that define key after an element has been opened ie\n * `
`.\n * @param key The key to use for the next call.\n */\nfunction key(key) {\n const argsBuilder = getArgsBuilder();\n {\n assertInAttributes(\"key\");\n assert(argsBuilder);\n }\n argsBuilder[1] = key;\n}\n/**\n * Buffers an attribute, which will get applied during the next call to\n * `elementOpen`, `elementOpenEnd` or `applyAttrs`.\n * @param name The of the attribute to buffer.\n * @param value The value of the attribute to buffer.\n */\nfunction attr(name, value) {\n const attrsBuilder = getAttrsBuilder();\n {\n assertInPatch(\"attr\");\n }\n attrsBuilder.push(name);\n attrsBuilder.push(value);\n}\n/**\n * Closes an open tag started with elementOpenStart.\n * @return The corresponding Element.\n */\nfunction elementOpenEnd() {\n const argsBuilder = getArgsBuilder();\n {\n assertInAttributes(\"elementOpenEnd\");\n setInAttributes(false);\n }\n const node = open(argsBuilder[0], argsBuilder[1]);\n const data = getData(node);\n diffStatics(node, data, argsBuilder[2]);\n diffAttrs(node, data);\n truncateArray(argsBuilder, 0);\n return node;\n}\n/**\n * @param nameOrCtor The Element's tag or constructor.\n * @param key The key used to identify this element. This can be an\n * empty string, but performance may be better if a unique value is used\n * when iterating over an array of items.\n * @param statics An array of attribute name/value pairs of the static\n * attributes for the Element. Attributes will only be set once when the\n * Element is created.\n * @param varArgs, Attribute name/value pairs of the dynamic attributes\n * for the Element.\n * @return The corresponding Element.\n */\nfunction elementOpen(nameOrCtor, key, \n// Ideally we could tag statics and varArgs as an array where every odd\n// element is a string and every even element is any, but this is hard.\nstatics, ...varArgs) {\n {\n assertNotInAttributes(\"elementOpen\");\n assertNotInSkip(\"elementOpen\");\n }\n elementOpenStart(nameOrCtor, key, statics);\n for (let i = ATTRIBUTES_OFFSET; i < arguments.length; i += 2) {\n attr(arguments[i], arguments[i + 1]);\n }\n return elementOpenEnd();\n}\n/**\n * Applies the currently buffered attrs to the currently open element. This\n * clears the buffered attributes.\n */\nfunction applyAttrs() {\n const node = currentElement();\n const data = getData(node);\n diffAttrs(node, data);\n}\n/**\n * Applies the current static attributes to the currently open element. Note:\n * statics should be applied before calling `applyAtrs`.\n * @param statics The statics to apply to the current element.\n */\nfunction applyStatics(statics) {\n const node = currentElement();\n const data = getData(node);\n diffStatics(node, data, statics);\n}\n/**\n * Closes an open virtual Element.\n *\n * @param nameOrCtor The Element's tag or constructor.\n * @return The corresponding Element.\n */\nfunction elementClose(nameOrCtor) {\n {\n assertNotInAttributes(\"elementClose\");\n }\n const node = close();\n {\n assertCloseMatchesOpenTag(getData(node).nameOrCtor, nameOrCtor);\n }\n return node;\n}\n/**\n * Declares a virtual Element at the current location in the document that has\n * no children.\n * @param nameOrCtor The Element's tag or constructor.\n * @param key The key used to identify this element. This can be an\n * empty string, but performance may be better if a unique value is used\n * when iterating over an array of items.\n * @param statics An array of attribute name/value pairs of the static\n * attributes for the Element. Attributes will only be set once when the\n * Element is created.\n * @param varArgs Attribute name/value pairs of the dynamic attributes\n * for the Element.\n * @return The corresponding Element.\n */\nfunction elementVoid(nameOrCtor, key, \n// Ideally we could tag statics and varArgs as an array where every odd\n// element is a string and every even element is any, but this is hard.\nstatics, ...varArgs) {\n elementOpen.apply(null, arguments);\n return elementClose(nameOrCtor);\n}\n/**\n * Declares a virtual Text at this point in the document.\n *\n * @param value The value of the Text.\n * @param varArgs\n * Functions to format the value which are called only when the value has\n * changed.\n * @return The corresponding text node.\n */\nfunction text$1(value, ...varArgs) {\n {\n assertNotInAttributes(\"text\");\n assertNotInSkip(\"text\");\n }\n const node = text();\n const data = getData(node);\n if (data.text !== value) {\n data.text = value;\n let formatted = value;\n for (let i = 1; i < arguments.length; i += 1) {\n /*\n * Call the formatter function directly to prevent leaking arguments.\n * https://github.com/google/incremental-dom/pull/204#issuecomment-178223574\n */\n const fn = arguments[i];\n formatted = fn(formatted);\n }\n // Setting node.data resets the cursor in IE/Edge.\n if (node.data !== formatted) {\n node.data = formatted;\n }\n }\n return node;\n}\n\n/**\n * Copyright 2018 The Incremental DOM Authors. All Rights Reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS-IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexports.applyAttr = applyAttr;\nexports.applyProp = applyProp;\nexports.attributes = attributes;\nexports.alignWithDOM = alignWithDOM;\nexports.close = close;\nexports.createPatchInner = createPatchInner;\nexports.createPatchOuter = createPatchOuter;\nexports.currentElement = currentElement;\nexports.currentPointer = currentPointer;\nexports.open = open;\nexports.patch = patchInner;\nexports.patchInner = patchInner;\nexports.patchOuter = patchOuter;\nexports.skip = skip;\nexports.skipNode = nextNode;\nexports.setKeyAttributeName = setKeyAttributeName;\nexports.clearCache = clearCache;\nexports.getKey = getKey;\nexports.importNode = importNode;\nexports.isDataInitialized = isDataInitialized;\nexports.notifications = notifications;\nexports.symbols = symbols;\nexports.applyAttrs = applyAttrs;\nexports.applyStatics = applyStatics;\nexports.attr = attr;\nexports.elementClose = elementClose;\nexports.elementOpen = elementOpen;\nexports.elementOpenEnd = elementOpenEnd;\nexports.elementOpenStart = elementOpenStart;\nexports.elementVoid = elementVoid;\nexports.key = key;\nexports.text = text$1;\n\n});\n\nunwrapExports(incrementalDomCjs);\nvar incrementalDomCjs_1 = incrementalDomCjs.applyAttr;\nvar incrementalDomCjs_2 = incrementalDomCjs.applyProp;\nvar incrementalDomCjs_3 = incrementalDomCjs.attributes;\nvar incrementalDomCjs_4 = incrementalDomCjs.alignWithDOM;\nvar incrementalDomCjs_5 = incrementalDomCjs.close;\nvar incrementalDomCjs_6 = incrementalDomCjs.createPatchInner;\nvar incrementalDomCjs_7 = incrementalDomCjs.createPatchOuter;\nvar incrementalDomCjs_8 = incrementalDomCjs.currentElement;\nvar incrementalDomCjs_9 = incrementalDomCjs.currentPointer;\nvar incrementalDomCjs_10 = incrementalDomCjs.open;\nvar incrementalDomCjs_11 = incrementalDomCjs.patch;\nvar incrementalDomCjs_12 = incrementalDomCjs.patchInner;\nvar incrementalDomCjs_13 = incrementalDomCjs.patchOuter;\nvar incrementalDomCjs_14 = incrementalDomCjs.skip;\nvar incrementalDomCjs_15 = incrementalDomCjs.skipNode;\nvar incrementalDomCjs_16 = incrementalDomCjs.setKeyAttributeName;\nvar incrementalDomCjs_17 = incrementalDomCjs.clearCache;\nvar incrementalDomCjs_18 = incrementalDomCjs.getKey;\nvar incrementalDomCjs_19 = incrementalDomCjs.importNode;\nvar incrementalDomCjs_20 = incrementalDomCjs.isDataInitialized;\nvar incrementalDomCjs_21 = incrementalDomCjs.notifications;\nvar incrementalDomCjs_22 = incrementalDomCjs.symbols;\nvar incrementalDomCjs_23 = incrementalDomCjs.applyAttrs;\nvar incrementalDomCjs_24 = incrementalDomCjs.applyStatics;\nvar incrementalDomCjs_25 = incrementalDomCjs.attr;\nvar incrementalDomCjs_26 = incrementalDomCjs.elementClose;\nvar incrementalDomCjs_27 = incrementalDomCjs.elementOpen;\nvar incrementalDomCjs_28 = incrementalDomCjs.elementOpenEnd;\nvar incrementalDomCjs_29 = incrementalDomCjs.elementOpenStart;\nvar incrementalDomCjs_30 = incrementalDomCjs.elementVoid;\nvar incrementalDomCjs_31 = incrementalDomCjs.key;\nvar incrementalDomCjs_32 = incrementalDomCjs.text;\n\nincrementalDomCjs_3.caretpos = function (element, name, value) {\n element.setSelectionRange(value, value);\n};\nincrementalDomCjs_3.value = incrementalDomCjs_2;\nvar renderIncrementalDOM = function renderIncrementalDOM(data, onSelect, multiline) {\n if (data.suggestions.length > 0 && data.focused) {\n // unselectable=on is a IE11 workaround,\n // which makes it possible to use an eventual scroll bar on suggestions list.\n incrementalDomCjs_27('ul', '', ['class', 'dawa-autocomplete-suggestions', 'role', 'listbox', 'unselectable', 'on']);\n var _loop = function _loop(i) {\n var suggestion = data.suggestions[i];\n var className = 'dawa-autocomplete-suggestion';\n if (data.selected === i) {\n className += ' dawa-selected';\n }\n incrementalDomCjs_27('li', '', ['role', 'option'], 'class', className, 'onmousedown', function (e) {\n onSelect(i);\n e.preventDefault();\n });\n var rows = suggestion.forslagstekst.split('\\n');\n rows = rows.map(function (row) {\n return row.replace(/ /g, \"\\xA0\");\n });\n if (multiline) {\n incrementalDomCjs_32(rows[0]);\n for (var _i = 1; _i < rows.length; ++_i) {\n incrementalDomCjs_30('br');\n incrementalDomCjs_32(rows[_i]);\n }\n } else {\n incrementalDomCjs_32(rows.join(', '));\n }\n incrementalDomCjs_26('li');\n };\n for (var i = 0; i < data.suggestions.length; ++i) {\n _loop(i);\n }\n incrementalDomCjs_26('ul');\n }\n};\nvar defaultRender = function defaultRender(containerElm, data, onSelect, multiline) {\n incrementalDomCjs_11(containerElm, function () {\n renderIncrementalDOM(data, onSelect, multiline);\n });\n};\nvar autocompleteUi = function autocompleteUi(inputElm, options) {\n var onSelect = options.onSelect;\n var onTextChange = options.onTextChange;\n var render = options.render || defaultRender;\n var destroyed = false;\n var lastEmittedText = '';\n var lastEmittedCaretpos = 0;\n var suggestionContainerElm = document.createElement('div');\n inputElm.parentNode.insertBefore(suggestionContainerElm, inputElm.nextSibling);\n var emitTextChange = function emitTextChange(newText, newCaretpos) {\n if (lastEmittedText !== newText || lastEmittedCaretpos !== newCaretpos) {\n onTextChange(newText, newCaretpos);\n lastEmittedText = newText;\n lastEmittedCaretpos = newCaretpos;\n }\n };\n var data = {\n caretpos: 2,\n inputText: '',\n selected: 0,\n focused: document.activeElement === inputElm,\n suggestions: []\n };\n var handleInputChanged = function handleInputChanged(inputElm) {\n var newText = inputElm.value;\n var newCaretPos = inputElm.selectionStart;\n data.caretpos = newCaretPos;\n data.inputText = newText;\n emitTextChange(newText, newCaretPos);\n };\n var update;\n var selectSuggestion = function selectSuggestion(index) {\n var selectedSuggestion = data.suggestions[index];\n data.inputText = selectedSuggestion.tekst;\n data.caretpos = selectedSuggestion.caretpos;\n data.suggestions = [];\n onSelect(selectedSuggestion);\n update(true);\n };\n var keydownHandler = function keydownHandler(e) {\n var key = window.event ? e.keyCode : e.which;\n if (data.suggestions.length > 0 && data.focused) {\n // down (40)\n if (key === 40) {\n data.selected = (data.selected + 1) % data.suggestions.length;\n update();\n }\n //up (38)\n else if (key === 38) {\n data.selected = (data.selected - 1 + data.suggestions.length) % data.suggestions.length;\n update();\n }\n // enter\n else if (key === 13 || key === 9) {\n selectSuggestion(data.selected);\n } else {\n return true;\n }\n e.preventDefault();\n return false;\n }\n };\n var focusHandler = function focusHandler() {\n data.focused = true;\n update();\n };\n var blurHandler = function blurHandler() {\n data.focused = false;\n update();\n return false;\n };\n var inputChangeHandler = function inputChangeHandler(e) {\n handleInputChanged(e.target);\n };\n var inputMouseUpHandler = function inputMouseUpHandler(e) {\n return handleInputChanged(e.target);\n };\n var updateScheduled = false;\n var updateInput = false;\n update = function update(shouldUpdateInput) {\n if (shouldUpdateInput) {\n updateInput = true;\n }\n if (!updateScheduled) {\n updateScheduled = true;\n requestAnimationFrame(function () {\n if (destroyed) {\n return;\n }\n updateScheduled = false;\n if (updateInput) {\n inputElm.value = data.inputText;\n inputElm.setSelectionRange(data.caretpos, data.caretpos);\n }\n updateInput = false;\n render(suggestionContainerElm, data, function (i) {\n return selectSuggestion(i);\n }, options.multiline);\n });\n }\n };\n update();\n var destroy = function destroy() {\n destroyed = true;\n inputElm.removeEventListener('keydown', keydownHandler);\n inputElm.removeEventListener('blur', blurHandler);\n inputElm.removeEventListener('focus', focusHandler);\n inputElm.removeEventListener('input', inputChangeHandler);\n inputElm.removeEventListener('mouseup', inputMouseUpHandler);\n incrementalDomCjs_11(suggestionContainerElm, function () {});\n suggestionContainerElm.remove();\n };\n var setSuggestions = function setSuggestions(suggestions) {\n data.suggestions = suggestions;\n data.selected = 0;\n update();\n };\n var selectAndClose = function selectAndClose(text) {\n data.inputText = text;\n data.caretpos = text.length;\n data.suggestions = [];\n data.selected = 0;\n update(true);\n };\n inputElm.addEventListener('keydown', keydownHandler);\n inputElm.addEventListener('blur', blurHandler);\n inputElm.addEventListener('focus', focusHandler);\n inputElm.addEventListener('input', inputChangeHandler);\n inputElm.addEventListener('mouseup', inputMouseUpHandler);\n inputElm.setAttribute('aria-autocomplete', 'list');\n inputElm.setAttribute('autocomplete', 'off');\n return {\n destroy: destroy,\n setSuggestions: setSuggestions,\n selectAndClose: selectAndClose\n };\n};\n\nfunction _classCallCheck(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);\n }\n}\nfunction _createClass(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n Object.defineProperty(Constructor, \"prototype\", {\n writable: false\n });\n return Constructor;\n}\nfunction _toPrimitive$1(input, hint) {\n if (typeof input !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (typeof res !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}\nfunction _toPropertyKey(arg) {\n var key = _toPrimitive$1(arg, \"string\");\n return typeof key === \"symbol\" ? key : String(key);\n}\n\n// most Object methods by ES6 should accept primitives\n\n\n\nvar _objectSap = function (KEY, exec) {\n var fn = (_core.Object || {})[KEY] || Object[KEY];\n var exp = {};\n exp[KEY] = exec(fn);\n _export(_export.S + _export.F * _fails(function () { fn(1); }), 'Object', exp);\n};\n\n// 19.1.2.14 Object.keys(O)\n\n\n\n_objectSap('keys', function () {\n return function keys(it) {\n return _objectKeys(_toObject(it));\n };\n});\n\n// 19.1.3.6 Object.prototype.toString()\n\nvar test = {};\ntest[_wks('toStringTag')] = 'z';\nif (test + '' != '[object z]') {\n _redefine(Object.prototype, 'toString', function toString() {\n return '[object ' + _classof(this) + ']';\n }, true);\n}\n\nvar _anInstance = function (it, Constructor, name, forbiddenField) {\n if (!(it instanceof Constructor) || (forbiddenField !== undefined && forbiddenField in it)) {\n throw TypeError(name + ': incorrect invocation!');\n } return it;\n};\n\n// call something on iterator step with safe closing on error\n\nvar _iterCall = function (iterator, fn, value, entries) {\n try {\n return entries ? fn(_anObject(value)[0], value[1]) : fn(value);\n // 7.4.6 IteratorClose(iterator, completion)\n } catch (e) {\n var ret = iterator['return'];\n if (ret !== undefined) _anObject(ret.call(iterator));\n throw e;\n }\n};\n\nvar _iterators = {};\n\n// check on default Array iterator\n\nvar ITERATOR = _wks('iterator');\nvar ArrayProto = Array.prototype;\n\nvar _isArrayIter = function (it) {\n return it !== undefined && (_iterators.Array === it || ArrayProto[ITERATOR] === it);\n};\n\nvar ITERATOR$1 = _wks('iterator');\n\nvar core_getIteratorMethod = _core.getIteratorMethod = function (it) {\n if (it != undefined) return it[ITERATOR$1]\n || it['@@iterator']\n || _iterators[_classof(it)];\n};\n\nvar _forOf = createCommonjsModule(function (module) {\nvar BREAK = {};\nvar RETURN = {};\nvar exports = module.exports = function (iterable, entries, fn, that, ITERATOR) {\n var iterFn = ITERATOR ? function () { return iterable; } : core_getIteratorMethod(iterable);\n var f = _ctx(fn, that, entries ? 2 : 1);\n var index = 0;\n var length, step, iterator, result;\n if (typeof iterFn != 'function') throw TypeError(iterable + ' is not iterable!');\n // fast case for arrays with default iterator\n if (_isArrayIter(iterFn)) for (length = _toLength(iterable.length); length > index; index++) {\n result = entries ? f(_anObject(step = iterable[index])[0], step[1]) : f(iterable[index]);\n if (result === BREAK || result === RETURN) return result;\n } else for (iterator = iterFn.call(iterable); !(step = iterator.next()).done;) {\n result = _iterCall(iterator, f, step.value, entries);\n if (result === BREAK || result === RETURN) return result;\n }\n};\nexports.BREAK = BREAK;\nexports.RETURN = RETURN;\n});\n\n// fast apply, http://jsperf.lnkit.com/fast-apply/5\nvar _invoke = function (fn, args, that) {\n var un = that === undefined;\n switch (args.length) {\n case 0: return un ? fn()\n : fn.call(that);\n case 1: return un ? fn(args[0])\n : fn.call(that, args[0]);\n case 2: return un ? fn(args[0], args[1])\n : fn.call(that, args[0], args[1]);\n case 3: return un ? fn(args[0], args[1], args[2])\n : fn.call(that, args[0], args[1], args[2]);\n case 4: return un ? fn(args[0], args[1], args[2], args[3])\n : fn.call(that, args[0], args[1], args[2], args[3]);\n } return fn.apply(that, args);\n};\n\nvar document$2 = _global.document;\nvar _html = document$2 && document$2.documentElement;\n\nvar process = _global.process;\nvar setTask = _global.setImmediate;\nvar clearTask = _global.clearImmediate;\nvar MessageChannel = _global.MessageChannel;\nvar Dispatch = _global.Dispatch;\nvar counter = 0;\nvar queue = {};\nvar ONREADYSTATECHANGE = 'onreadystatechange';\nvar defer, channel, port;\nvar run = function () {\n var id = +this;\n // eslint-disable-next-line no-prototype-builtins\n if (queue.hasOwnProperty(id)) {\n var fn = queue[id];\n delete queue[id];\n fn();\n }\n};\nvar listener = function (event) {\n run.call(event.data);\n};\n// Node.js 0.9+ & IE10+ has setImmediate, otherwise:\nif (!setTask || !clearTask) {\n setTask = function setImmediate(fn) {\n var args = [];\n var i = 1;\n while (arguments.length > i) args.push(arguments[i++]);\n queue[++counter] = function () {\n // eslint-disable-next-line no-new-func\n _invoke(typeof fn == 'function' ? fn : Function(fn), args);\n };\n defer(counter);\n return counter;\n };\n clearTask = function clearImmediate(id) {\n delete queue[id];\n };\n // Node.js 0.8-\n if (_cof(process) == 'process') {\n defer = function (id) {\n process.nextTick(_ctx(run, id, 1));\n };\n // Sphere (JS game engine) Dispatch API\n } else if (Dispatch && Dispatch.now) {\n defer = function (id) {\n Dispatch.now(_ctx(run, id, 1));\n };\n // Browsers with MessageChannel, includes WebWorkers\n } else if (MessageChannel) {\n channel = new MessageChannel();\n port = channel.port2;\n channel.port1.onmessage = listener;\n defer = _ctx(port.postMessage, port, 1);\n // Browsers with postMessage, skip WebWorkers\n // IE8 has postMessage, but it's sync & typeof its postMessage is 'object'\n } else if (_global.addEventListener && typeof postMessage == 'function' && !_global.importScripts) {\n defer = function (id) {\n _global.postMessage(id + '', '*');\n };\n _global.addEventListener('message', listener, false);\n // IE8-\n } else if (ONREADYSTATECHANGE in _domCreate('script')) {\n defer = function (id) {\n _html.appendChild(_domCreate('script'))[ONREADYSTATECHANGE] = function () {\n _html.removeChild(this);\n run.call(id);\n };\n };\n // Rest old browsers\n } else {\n defer = function (id) {\n setTimeout(_ctx(run, id, 1), 0);\n };\n }\n}\nvar _task = {\n set: setTask,\n clear: clearTask\n};\n\nvar macrotask = _task.set;\nvar Observer = _global.MutationObserver || _global.WebKitMutationObserver;\nvar process$1 = _global.process;\nvar Promise$1 = _global.Promise;\nvar isNode = _cof(process$1) == 'process';\n\nvar _microtask = function () {\n var head, last, notify;\n\n var flush = function () {\n var parent, fn;\n if (isNode && (parent = process$1.domain)) parent.exit();\n while (head) {\n fn = head.fn;\n head = head.next;\n try {\n fn();\n } catch (e) {\n if (head) notify();\n else last = undefined;\n throw e;\n }\n } last = undefined;\n if (parent) parent.enter();\n };\n\n // Node.js\n if (isNode) {\n notify = function () {\n process$1.nextTick(flush);\n };\n // browsers with MutationObserver, except iOS Safari - https://github.com/zloirock/core-js/issues/339\n } else if (Observer && !(_global.navigator && _global.navigator.standalone)) {\n var toggle = true;\n var node = document.createTextNode('');\n new Observer(flush).observe(node, { characterData: true }); // eslint-disable-line no-new\n notify = function () {\n node.data = toggle = !toggle;\n };\n // environments with maybe non-completely correct, but existent Promise\n } else if (Promise$1 && Promise$1.resolve) {\n // Promise.resolve without an argument throws an error in LG WebOS 2\n var promise = Promise$1.resolve(undefined);\n notify = function () {\n promise.then(flush);\n };\n // for other environments - macrotask based on:\n // - setImmediate\n // - MessageChannel\n // - window.postMessag\n // - onreadystatechange\n // - setTimeout\n } else {\n notify = function () {\n // strange IE + webpack dev server bug - use .call(global)\n macrotask.call(_global, flush);\n };\n }\n\n return function (fn) {\n var task = { fn: fn, next: undefined };\n if (last) last.next = task;\n if (!head) {\n head = task;\n notify();\n } last = task;\n };\n};\n\n// 25.4.1.5 NewPromiseCapability(C)\n\n\nfunction PromiseCapability(C) {\n var resolve, reject;\n this.promise = new C(function ($$resolve, $$reject) {\n if (resolve !== undefined || reject !== undefined) throw TypeError('Bad Promise constructor');\n resolve = $$resolve;\n reject = $$reject;\n });\n this.resolve = _aFunction(resolve);\n this.reject = _aFunction(reject);\n}\n\nvar f$3 = function (C) {\n return new PromiseCapability(C);\n};\n\nvar _newPromiseCapability = {\n\tf: f$3\n};\n\nvar _perform = function (exec) {\n try {\n return { e: false, v: exec() };\n } catch (e) {\n return { e: true, v: e };\n }\n};\n\nvar navigator = _global.navigator;\n\nvar _userAgent = navigator && navigator.userAgent || '';\n\nvar _promiseResolve = function (C, x) {\n _anObject(C);\n if (_isObject(x) && x.constructor === C) return x;\n var promiseCapability = _newPromiseCapability.f(C);\n var resolve = promiseCapability.resolve;\n resolve(x);\n return promiseCapability.promise;\n};\n\nvar _redefineAll = function (target, src, safe) {\n for (var key in src) _redefine(target, key, src[key], safe);\n return target;\n};\n\nvar def = _objectDp.f;\n\nvar TAG$1 = _wks('toStringTag');\n\nvar _setToStringTag = function (it, tag, stat) {\n if (it && !_has(it = stat ? it : it.prototype, TAG$1)) def(it, TAG$1, { configurable: true, value: tag });\n};\n\nvar SPECIES$3 = _wks('species');\n\nvar _setSpecies = function (KEY) {\n var C = _global[KEY];\n if (_descriptors && C && !C[SPECIES$3]) _objectDp.f(C, SPECIES$3, {\n configurable: true,\n get: function () { return this; }\n });\n};\n\nvar ITERATOR$2 = _wks('iterator');\nvar SAFE_CLOSING = false;\n\ntry {\n var riter = [7][ITERATOR$2]();\n riter['return'] = function () { SAFE_CLOSING = true; };\n // eslint-disable-next-line no-throw-literal\n Array.from(riter, function () { throw 2; });\n} catch (e) { /* empty */ }\n\nvar _iterDetect = function (exec, skipClosing) {\n if (!skipClosing && !SAFE_CLOSING) return false;\n var safe = false;\n try {\n var arr = [7];\n var iter = arr[ITERATOR$2]();\n iter.next = function () { return { done: safe = true }; };\n arr[ITERATOR$2] = function () { return iter; };\n exec(arr);\n } catch (e) { /* empty */ }\n return safe;\n};\n\nvar task = _task.set;\nvar microtask = _microtask();\n\n\n\n\nvar PROMISE = 'Promise';\nvar TypeError$1 = _global.TypeError;\nvar process$2 = _global.process;\nvar versions = process$2 && process$2.versions;\nvar v8 = versions && versions.v8 || '';\nvar $Promise = _global[PROMISE];\nvar isNode$1 = _classof(process$2) == 'process';\nvar empty = function () { /* empty */ };\nvar Internal, newGenericPromiseCapability, OwnPromiseCapability, Wrapper;\nvar newPromiseCapability = newGenericPromiseCapability = _newPromiseCapability.f;\n\nvar USE_NATIVE = !!function () {\n try {\n // correct subclassing with @@species support\n var promise = $Promise.resolve(1);\n var FakePromise = (promise.constructor = {})[_wks('species')] = function (exec) {\n exec(empty, empty);\n };\n // unhandled rejections tracking support, NodeJS Promise without it fails @@species test\n return (isNode$1 || typeof PromiseRejectionEvent == 'function')\n && promise.then(empty) instanceof FakePromise\n // v8 6.6 (Node 10 and Chrome 66) have a bug with resolving custom thenables\n // https://bugs.chromium.org/p/chromium/issues/detail?id=830565\n // we can't detect it synchronously, so just check versions\n && v8.indexOf('6.6') !== 0\n && _userAgent.indexOf('Chrome/66') === -1;\n } catch (e) { /* empty */ }\n}();\n\n// helpers\nvar isThenable = function (it) {\n var then;\n return _isObject(it) && typeof (then = it.then) == 'function' ? then : false;\n};\nvar notify = function (promise, isReject) {\n if (promise._n) return;\n promise._n = true;\n var chain = promise._c;\n microtask(function () {\n var value = promise._v;\n var ok = promise._s == 1;\n var i = 0;\n var run = function (reaction) {\n var handler = ok ? reaction.ok : reaction.fail;\n var resolve = reaction.resolve;\n var reject = reaction.reject;\n var domain = reaction.domain;\n var result, then, exited;\n try {\n if (handler) {\n if (!ok) {\n if (promise._h == 2) onHandleUnhandled(promise);\n promise._h = 1;\n }\n if (handler === true) result = value;\n else {\n if (domain) domain.enter();\n result = handler(value); // may throw\n if (domain) {\n domain.exit();\n exited = true;\n }\n }\n if (result === reaction.promise) {\n reject(TypeError$1('Promise-chain cycle'));\n } else if (then = isThenable(result)) {\n then.call(result, resolve, reject);\n } else resolve(result);\n } else reject(value);\n } catch (e) {\n if (domain && !exited) domain.exit();\n reject(e);\n }\n };\n while (chain.length > i) run(chain[i++]); // variable length - can't use forEach\n promise._c = [];\n promise._n = false;\n if (isReject && !promise._h) onUnhandled(promise);\n });\n};\nvar onUnhandled = function (promise) {\n task.call(_global, function () {\n var value = promise._v;\n var unhandled = isUnhandled(promise);\n var result, handler, console;\n if (unhandled) {\n result = _perform(function () {\n if (isNode$1) {\n process$2.emit('unhandledRejection', value, promise);\n } else if (handler = _global.onunhandledrejection) {\n handler({ promise: promise, reason: value });\n } else if ((console = _global.console) && console.error) {\n console.error('Unhandled promise rejection', value);\n }\n });\n // Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should\n promise._h = isNode$1 || isUnhandled(promise) ? 2 : 1;\n } promise._a = undefined;\n if (unhandled && result.e) throw result.v;\n });\n};\nvar isUnhandled = function (promise) {\n return promise._h !== 1 && (promise._a || promise._c).length === 0;\n};\nvar onHandleUnhandled = function (promise) {\n task.call(_global, function () {\n var handler;\n if (isNode$1) {\n process$2.emit('rejectionHandled', promise);\n } else if (handler = _global.onrejectionhandled) {\n handler({ promise: promise, reason: promise._v });\n }\n });\n};\nvar $reject = function (value) {\n var promise = this;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n promise._v = value;\n promise._s = 2;\n if (!promise._a) promise._a = promise._c.slice();\n notify(promise, true);\n};\nvar $resolve = function (value) {\n var promise = this;\n var then;\n if (promise._d) return;\n promise._d = true;\n promise = promise._w || promise; // unwrap\n try {\n if (promise === value) throw TypeError$1(\"Promise can't be resolved itself\");\n if (then = isThenable(value)) {\n microtask(function () {\n var wrapper = { _w: promise, _d: false }; // wrap\n try {\n then.call(value, _ctx($resolve, wrapper, 1), _ctx($reject, wrapper, 1));\n } catch (e) {\n $reject.call(wrapper, e);\n }\n });\n } else {\n promise._v = value;\n promise._s = 1;\n notify(promise, false);\n }\n } catch (e) {\n $reject.call({ _w: promise, _d: false }, e); // wrap\n }\n};\n\n// constructor polyfill\nif (!USE_NATIVE) {\n // 25.4.3.1 Promise(executor)\n $Promise = function Promise(executor) {\n _anInstance(this, $Promise, PROMISE, '_h');\n _aFunction(executor);\n Internal.call(this);\n try {\n executor(_ctx($resolve, this, 1), _ctx($reject, this, 1));\n } catch (err) {\n $reject.call(this, err);\n }\n };\n // eslint-disable-next-line no-unused-vars\n Internal = function Promise(executor) {\n this._c = []; // <- awaiting reactions\n this._a = undefined; // <- checked in isUnhandled reactions\n this._s = 0; // <- state\n this._d = false; // <- done\n this._v = undefined; // <- value\n this._h = 0; // <- rejection state, 0 - default, 1 - handled, 2 - unhandled\n this._n = false; // <- notify\n };\n Internal.prototype = _redefineAll($Promise.prototype, {\n // 25.4.5.3 Promise.prototype.then(onFulfilled, onRejected)\n then: function then(onFulfilled, onRejected) {\n var reaction = newPromiseCapability(_speciesConstructor(this, $Promise));\n reaction.ok = typeof onFulfilled == 'function' ? onFulfilled : true;\n reaction.fail = typeof onRejected == 'function' && onRejected;\n reaction.domain = isNode$1 ? process$2.domain : undefined;\n this._c.push(reaction);\n if (this._a) this._a.push(reaction);\n if (this._s) notify(this, false);\n return reaction.promise;\n },\n // 25.4.5.1 Promise.prototype.catch(onRejected)\n 'catch': function (onRejected) {\n return this.then(undefined, onRejected);\n }\n });\n OwnPromiseCapability = function () {\n var promise = new Internal();\n this.promise = promise;\n this.resolve = _ctx($resolve, promise, 1);\n this.reject = _ctx($reject, promise, 1);\n };\n _newPromiseCapability.f = newPromiseCapability = function (C) {\n return C === $Promise || C === Wrapper\n ? new OwnPromiseCapability(C)\n : newGenericPromiseCapability(C);\n };\n}\n\n_export(_export.G + _export.W + _export.F * !USE_NATIVE, { Promise: $Promise });\n_setToStringTag($Promise, PROMISE);\n_setSpecies(PROMISE);\nWrapper = _core[PROMISE];\n\n// statics\n_export(_export.S + _export.F * !USE_NATIVE, PROMISE, {\n // 25.4.4.5 Promise.reject(r)\n reject: function reject(r) {\n var capability = newPromiseCapability(this);\n var $$reject = capability.reject;\n $$reject(r);\n return capability.promise;\n }\n});\n_export(_export.S + _export.F * ( !USE_NATIVE), PROMISE, {\n // 25.4.4.6 Promise.resolve(x)\n resolve: function resolve(x) {\n return _promiseResolve( this, x);\n }\n});\n_export(_export.S + _export.F * !(USE_NATIVE && _iterDetect(function (iter) {\n $Promise.all(iter)['catch'](empty);\n})), PROMISE, {\n // 25.4.4.1 Promise.all(iterable)\n all: function all(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var resolve = capability.resolve;\n var reject = capability.reject;\n var result = _perform(function () {\n var values = [];\n var index = 0;\n var remaining = 1;\n _forOf(iterable, false, function (promise) {\n var $index = index++;\n var alreadyCalled = false;\n values.push(undefined);\n remaining++;\n C.resolve(promise).then(function (value) {\n if (alreadyCalled) return;\n alreadyCalled = true;\n values[$index] = value;\n --remaining || resolve(values);\n }, reject);\n });\n --remaining || resolve(values);\n });\n if (result.e) reject(result.v);\n return capability.promise;\n },\n // 25.4.4.4 Promise.race(iterable)\n race: function race(iterable) {\n var C = this;\n var capability = newPromiseCapability(C);\n var reject = capability.reject;\n var result = _perform(function () {\n _forOf(iterable, false, function (promise) {\n C.resolve(promise).then(capability.resolve, reject);\n });\n });\n if (result.e) reject(result.v);\n return capability.promise;\n }\n});\n\nfunction fetch(e,n){return n=n||{},new Promise(function(t,r){var s=new XMLHttpRequest,o=[],u=[],i={},a=function(){return {ok:2==(s.status/100|0),statusText:s.statusText,status:s.status,url:s.responseURL,text:function(){return Promise.resolve(s.responseText)},json:function(){return Promise.resolve(s.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([s.response]))},clone:a,headers:{keys:function(){return o},entries:function(){return u},get:function(e){return i[e.toLowerCase()]},has:function(e){return e.toLowerCase()in i}}}};for(var l in s.open(n.method||\"get\",e,!0),s.onload=function(){s.getAllResponseHeaders().replace(/^(.*?):[^\\S\\n]*([\\s\\S]*?)$/gm,function(e,n,t){o.push(n=n.toLowerCase()),u.push([n,t]),i[n]=i[n]?i[n]+\",\"+t:t;}),t(a());},s.onerror=r,s.withCredentials=\"include\"==n.credentials,n.headers)s.setRequestHeader(l,n.headers[l]);s.send(n.body||null);})}\n\nvar formatParams = function formatParams(params) {\n return Object.keys(params).map(function (paramName) {\n var paramValue = params[paramName];\n return \"\".concat(paramName, \"=\").concat(encodeURIComponent(paramValue));\n }).join('&');\n};\nvar delay = function delay(ms) {\n return new Promise(function (resolve) {\n return setTimeout(resolve, ms);\n });\n};\nvar defaultOptions = {\n params: {},\n minLength: 2,\n retryDelay: 500,\n renderCallback: function renderCallback() {\n /*eslint no-console: 0*/\n console.error('No renderCallback supplied');\n },\n initialRenderCallback: function initialRenderCallback() {\n /*eslint no-console: 0*/\n console.error('No initialRenderCallback supplied');\n },\n type: 'adresse',\n baseUrl: 'https://dawa.aws.dk',\n adgangsadresserOnly: false,\n stormodtagerpostnumre: true,\n supplerendebynavn: true,\n fuzzy: true,\n fetchImpl: function fetchImpl(url, params) {\n return fetch(\"\".concat(url, \"?\").concat(formatParams(params)), {\n mode: 'cors'\n }).then(function (result) {\n return result.json();\n });\n }\n};\nvar AutocompleteController = /*#__PURE__*/function () {\n function AutocompleteController(options) {\n _classCallCheck(this, AutocompleteController);\n options = Object.assign({}, defaultOptions, options || {});\n this.options = options;\n this.state = {\n currentRequest: null,\n pendingRequest: null\n };\n this.selected = null;\n }\n _createClass(AutocompleteController, [{\n key: \"_getAutocompleteResponse\",\n value: function _getAutocompleteResponse(text, caretpos, skipVejnavn, adgangsadresseid, supplerendebynavn, stormodtagerpostnumre) {\n var params = Object.assign({}, this.options.params, {\n q: text,\n type: this.options.type,\n caretpos: caretpos,\n supplerendebynavn: supplerendebynavn,\n stormodtagerpostnumre: stormodtagerpostnumre,\n multilinje: true\n });\n if (this.options.fuzzy) {\n params.fuzzy = '';\n }\n if (adgangsadresseid) {\n params.adgangsadresseid = adgangsadresseid;\n }\n if (skipVejnavn) {\n params.startfra = 'adgangsadresse';\n }\n return this.options.fetchImpl(\"\".concat(this.options.baseUrl, \"/autocomplete\"), params);\n }\n }, {\n key: \"_scheduleRequest\",\n value: function _scheduleRequest(request) {\n if (this.state.currentRequest !== null) {\n this.state.pendingRequest = request;\n } else {\n this.state.currentRequest = request;\n this._executeRequest();\n }\n }\n }, {\n key: \"_executeRequest\",\n value: function _executeRequest() {\n var _this = this;\n var request = this.state.currentRequest;\n var adgangsadresseid = null;\n var skipVejnavn = false;\n var text, caretpos;\n if (request.selected) {\n var item = request.selected;\n if (item.type !== this.options.type) {\n adgangsadresseid = item.type === 'adgangsadresse' ? item.data.id : null;\n skipVejnavn = item.type === 'vejnavn';\n text = item.tekst;\n caretpos = item.caretpos;\n } else {\n this.options.selectCallback(item);\n this.selected = item;\n this._requestCompleted();\n return;\n }\n } else {\n text = request.text;\n caretpos = request.caretpos;\n }\n if (request.selectedId) {\n var params = {\n id: request.selectedId,\n type: this.options.type\n };\n return this.options.fetchImpl(\"\".concat(this.options.baseUrl, \"/autocomplete\"), params).then(function (result) {\n return _this._handleResponse(request, result);\n }, function (error) {\n return _this._handleFailedRequest(request, error);\n });\n } else if (request.selected || request.text.length >= this.options.minLength) {\n this._getAutocompleteResponse(text, caretpos, skipVejnavn, adgangsadresseid, this.options.supplerendebynavn, this.options.stormodtagerpostnumre).then(function (result) {\n return _this._handleResponse(request, result);\n }, function (error) {\n return _this._handleFailedRequest(request, error);\n });\n } else {\n this._handleResponse(request, []);\n }\n }\n }, {\n key: \"_handleFailedRequest\",\n value: function _handleFailedRequest(request, error) {\n var _this2 = this;\n console.error('DAWA request failed', error);\n return delay(this.options.retryDelay).then(function () {\n if (!_this2.state.pendingRequest) {\n _this2._scheduleRequest(request);\n }\n _this2._requestCompleted();\n });\n }\n }, {\n key: \"_handleResponse\",\n value: function _handleResponse(request, result) {\n if (request.selected) {\n if (result.length === 1) {\n var item = result[0];\n if (item.type === this.options.type) {\n this.options.selectCallback(item);\n } else {\n if (!this.state.pendingRequest) {\n this.state.pendingRequest = {\n selected: item\n };\n }\n }\n } else if (this.options.renderCallback) {\n this.options.renderCallback(result);\n }\n } else if (request.selectedId) {\n if (result.length === 1) {\n this.selected = result[0];\n this.options.initialRenderCallback(result[0].tekst);\n }\n } else {\n if (this.options.renderCallback) {\n this.options.renderCallback(result);\n }\n }\n this._requestCompleted();\n }\n }, {\n key: \"_requestCompleted\",\n value: function _requestCompleted() {\n this.state.currentRequest = this.state.pendingRequest;\n this.state.pendingRequest = null;\n if (this.state.currentRequest) {\n this._executeRequest();\n }\n }\n }, {\n key: \"setRenderCallback\",\n value: function setRenderCallback(renderCallback) {\n this.options.renderCallback = renderCallback;\n }\n }, {\n key: \"setInitialRenderCallback\",\n value: function setInitialRenderCallback(renderCallback) {\n this.options.initialRenderCallback = renderCallback;\n }\n }, {\n key: \"setSelectCallback\",\n value: function setSelectCallback(selectCallback) {\n this.options.selectCallback = selectCallback;\n }\n }, {\n key: \"update\",\n value: function update(text, caretpos) {\n var request = {\n text: text,\n caretpos: caretpos\n };\n this._scheduleRequest(request);\n }\n }, {\n key: \"select\",\n value: function select(item) {\n var request = {\n selected: item\n };\n this._scheduleRequest(request);\n }\n }, {\n key: \"selectInitial\",\n value: function selectInitial(id) {\n var request = {\n selectedId: id\n };\n this._scheduleRequest(request);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {}\n }]);\n return AutocompleteController;\n}();\n\n/**\n * lodash (Custom Build)
\n * Build: `lodash modularize exports=\"npm\" -o ./`\n * Copyright jQuery Foundation and other contributors
\n * Released under MIT license
\n * Based on Underscore.js 1.8.3 \n * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n */\n\n/** Used as the `TypeError` message for \"Functions\" methods. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/** Used to match leading and trailing whitespace. */\nvar reTrim = /^\\s+|\\s+$/g;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar objectToString = objectProto.toString;\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n result = wait - timeSinceLastCall;\n\n return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\n/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return !!value && (type == 'object' || type == 'function');\n}\n\n/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return !!value && typeof value == 'object';\n}\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && objectToString.call(value) == symbolTag);\n}\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = value.replace(reTrim, '');\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nvar lodash_debounce = debounce;\n\nfunction dawaAutocomplete(inputElm, options) {\n options = Object.assign({\n select: function select() {\n return null;\n }\n }, options);\n var controllerOptions = ['baseUrl', 'minLength', 'params', 'fuzzy', 'stormodtagerpostnumre', 'supplerendebynavn', 'type'].reduce(function (memo, optionName) {\n if (options.hasOwnProperty(optionName)) {\n memo[optionName] = options[optionName];\n }\n return memo;\n }, {});\n if (!controllerOptions.type) {\n if (options.adgangsadresserOnly) {\n controllerOptions.type = 'adgangsadresse';\n } else {\n controllerOptions.type = 'adresse';\n }\n }\n var controller = new AutocompleteController(controllerOptions);\n var updateControllerOnTextChange = function updateControllerOnTextChange(newText, newCaretpos) {\n return controller.update(newText, newCaretpos);\n };\n updateControllerOnTextChange = options.debounce ? lodash_debounce(updateControllerOnTextChange, options.debounce, {\n maxWait: 500\n }) : updateControllerOnTextChange;\n var ui = autocompleteUi(inputElm, {\n onSelect: function onSelect(suggestion) {\n controller.select(suggestion);\n },\n onTextChange: updateControllerOnTextChange,\n render: options.render,\n multiline: options.multiline || false\n });\n controller.setRenderCallback(function (suggestions) {\n return ui.setSuggestions(suggestions);\n });\n controller.setSelectCallback(function (selected) {\n ui.selectAndClose(selected.tekst);\n options.select(selected);\n });\n controller.setInitialRenderCallback(function (text) {\n return ui.selectAndClose(text);\n });\n if (options.id) {\n controller.selectInitial(options.id);\n }\n return {\n id: function id(_id) {\n return controller.selectInitial(_id);\n },\n destroy: function destroy() {\n return ui.destroy();\n },\n selected: function selected() {\n return controller.selected;\n }\n };\n}\n\nexport { dawaAutocomplete };\n", "\uFEFF\"use strict\";\r\n\r\nimport * as dawaAutocomplete2 from 'dawa-autocomplete2';\r\nconst utmgeoconv = require(\"utmgeoconv\");\r\n\r\nclass ConnectionCalculator {\r\n constructor(calculator) {\r\n this.calculator = calculator;\r\n if (!this.calculator) return;\r\n\r\n this.step1 = calculator.querySelector(\"#connectioncalculator__step1\");\r\n this.step2 = calculator.querySelector(\"#connectioncalculator__step2\");\r\n this.step3 = calculator.querySelector(\"#connectioncalculator__step3\");\r\n\r\n if (!this.step1 || !this.step2 || !this.step3) {\r\n this.calculator.remove();\r\n console.error(\"ConnectionCalculator: Steps not found\");\r\n return;\r\n }\r\n\r\n if (!window.jQuery) {\r\n this.calculator.remove();\r\n console.error(\"ConnectionCalculator: jQuery not found\");\r\n return;\r\n }\r\n\r\n this.doAllTheJQueryStuff();\r\n\r\n this.addressInput = calculator.querySelector(\"#addressSearch\");\r\n\r\n if (this.addressInput) {\r\n\r\n dawaAutocomplete2.dawaAutocomplete(this.addressInput, {\r\n select: selected => {\r\n this.getCoordinatesBySelected(selected);\r\n }\r\n });\r\n }\r\n }\r\n\r\n doAllTheJQueryStuff() {\r\n\r\n\r\n this.$ = window.jQuery;\r\n\r\n var that = this;\r\n\r\n this.$(\"#connectioncalculator__step2, #connectioncalculator__step2-1, #connectioncalculator__step2-9, #connectioncalculator__step3\").hide();\r\n\r\n this.$(\"#connectioncalculator__step1 form\").validate({\r\n rules: {\r\n arealKaelderplan: {\r\n required: true,\r\n depends: function (element) {\r\n that.$(\"#kaelder1Sal-kaelder\").is(\":checked\");\r\n }\r\n },\r\n areal1salsplan: {\r\n required: true,\r\n depends: function (element) {\r\n that.$(\"#kaelder1Sal-1sal\").is(\":checked\");\r\n }\r\n }\r\n }\r\n });\r\n\r\n this.$(\"#kaelder1Sal-kaelder\").click(function () {\r\n if (that.$(this).is(\":checked\")) {\r\n that.$(\"#inp__arealKaelderplan\").show();\r\n }\r\n else {\r\n that.$(\"#inp__arealKaelderplan\").hide();\r\n }\r\n });\r\n\r\n this.$(\"#connectioncalculator__step1 form\").on(\"submit\", function (e) {\r\n\r\n e.preventDefault();\r\n\r\n var errors = [];\r\n var isExtension = that.$(this).find(\"#eksisterendeNet-ja-udvidelse:checked\").length > 0;\r\n if (that.$(this).find(\"[name=eksisterendeNet]:checked\").length == 0) {\r\n that.$(this).find(\"#eksisterendeNet-vedikke\").attr(\"checked\", \"checked\");\r\n }\r\n\r\n if (that.$(this).valid()) {\r\n var antalMeter = parseInt(that.$(this).find(\"[name=antalMeter]\").val());\r\n var arealGrund = parseFloat(that.$(this).find(\"[name=arealGrundplan]\").val().replace(/\\./g, \"\").replace(/\\,/g, \".\"));\r\n var arealKaelder = that.$(this).find(\"#kaelder1Sal-kaelder:checked\").length > 0 ? parseFloat(\"0\" + that.$(this).find(\"[name=arealKaelderplan]\").val().replace(/\\./g, \"\").replace(/\\,/g, \".\")) * .25 : 0;\r\n\r\n var arealTotal = arealGrund + arealKaelder;\r\n\r\n var price = 0;\r\n\r\n // investeringsbidrag\r\n for (let i = 0; i < prices.length; i++) {\r\n\r\n // find hvor grundareal er mere en fra og mindre end til\r\n if (parseFloat(\"0\" + prices[i].from) <= arealTotal && parseFloat(\"0\" + prices[i].to) >= arealTotal) {\r\n\r\n // effektbidrag\r\n price = parseFloat(prices[i].baseprice.replace(/\\./g, \"\").replace(/\\,/g, \".\"));\r\n console.log(\"effektbidrag\", price);\r\n\r\n // hvis fra er mere end nul, l\u00E6gges der pris pr. yderligere m2 p\u00E5\r\n // alt udover \"fra\" ganges med unitprice\r\n if (parseInt(prices[i].from) > 0) {\r\n var extensionSqMeters = arealTotal - parseInt(prices[i].from);\r\n var unitPrice = parseFloat(prices[i].unitprice.replace(/\\./g, \"\").replace(/\\,/g, \".\"));\r\n var extensionAmount = (extensionSqMeters * unitPrice);\r\n console.log(\"yderligere m2\", extensionSqMeters, unitPrice, extensionAmount);\r\n price = price + extensionAmount;\r\n }\r\n }\r\n\r\n }\r\n\r\n // stikledningsbidrag\r\n var tenPct = price * 0.1;\r\n console.log(\"10% till\u00E6g\", tenPct);\r\n var pipeMeters = Math.max(antalMeter, 5);\r\n var pipeAmount = pipeMeters * pipePrice;\r\n console.log(\"stikledning\", pipeMeters, pipePrice, pipeAmount);\r\n console.log(\"afslutning i hus\", housePrice);\r\n console.log(\"opstartstill\u00E6g\", initialPrice);\r\n \r\n var extensionAmount = (isExtension ? arealTotal * extensionPrice : 0);\r\n var newAreaDiscountAmount = (isExtension ? discountNewArea : 0);\r\n \r\n console.log(\"byggemodning\", arealTotal, extensionPrice, extensionAmount);\r\n console.log(\"rabat ved nye omr\u00E5der\", newAreaDiscountAmount);\r\n \r\n price = price + tenPct + pipeAmount + housePrice + initialPrice + extensionAmount + newAreaDiscountAmount;\r\n \r\n console.log(\"total pris\", price);\r\n\r\n // afrund pris til n\u00E6rmeste 100\r\n price = Math.round(price / 100) * 100;\r\n \r\n console.log(\"n\u00E6rmeste 100\", price);\r\n\r\n that.$(\"#connectioncalculator__price\").text(that.formatNumber(price, 0, 3, '.', ',') + \" kr.\");\r\n that.$(\"#connectioncalculator__arealGrund\").text(arealGrund);\r\n that.$(\"#connectioncalculator__antalMeter\").text(antalMeter);\r\n\r\n that.$(\"#connectioncalculator__boligHar\").text(\"\");\r\n\r\n that.$(this).find(\"[name=kaelder1Sal]:checked\").each(function (index) {\r\n\r\n if (index > 0) {\r\n $(\"#connectioncalculator__boligHar\").html($(\"#connectioncalculator__boligHar\").html() + \" og \");\r\n }\r\n if (index == 0) {\r\n $(\"#connectioncalculator__boligHar\").html(\"Boligen har \");\r\n }\r\n\r\n that.$(\"#connectioncalculator__boligHar\").html($(\"#connectioncalculator__boligHar\").html() + that.$(this).val());\r\n\r\n var input = \"\";\r\n\r\n input = (that.$(this).val() == \"k\u00E6lder\" ? \"#inp__kaelder\" : input);\r\n\r\n that.$(\"#connectioncalculator__boligHar\").html($(\"#connectioncalculator__boligHar\").html() + \" (\" + that.$(input).val() + \" m2)\");\r\n });\r\n\r\n if (that.$(\"#connectioncalculator__boligHar\").html() != \"\") {\r\n\r\n that.$(\"#connectioncalculator__boligHar\").html($(\"#connectioncalculator__boligHar\").html() + \".\");\r\n }\r\n\r\n if (that.$(this).find(\"[name=eksisterendeNet]:checked\").val() == \"Ja\") {\r\n that.$(\"#connectioncalculator__boligStik\").text(\"gammelt fjernvarmeomr\u00E5de\");\r\n }\r\n\r\n if (that.$(this).find(\"[name=eksisterendeNet]:checked\").val() == \"Ja, udvidelsesomr\u00E5de\") {\r\n that.$(\"#connectioncalculator__boligStik\").text(\"nyetableret fjernvarmeomr\u00E5de\");\r\n }\r\n\r\n if (that.$(this).find(\"[name=eksisterendeNet]:checked\").val() == \"Nej\") {\r\n that.$(\"#connectioncalculator__boligStik\").text(\"ikke\");\r\n }\r\n\r\n if (that.$(this).find(\"[name=eksisterendeNet]:checked\").val() == \"Ved ikke\") {\r\n that.$(\"#connectioncalculator__boligStik\").text(\"m\u00E5ske\");\r\n }\r\n\r\n\r\n that.$(\"#connectioncalculator__step1 type[submit]\").html(\" Beregner\");\r\n\r\n setTimeout(\r\n function () {\r\n // preudfyld formular i step 3\r\n that.$(\".umbraco-forms-field.boligoplysninger textarea\").val(that.$(\"#connectioncalculator__result\").text().replace(/^\\s+|\\s+$/gm, '').replace(/( {2,})/g, \" \").replace(\"\\r\\n\", \"\"));\r\n\r\n // go to result\r\n that.$(\"#connectioncalculator__step1\").slideUp(200).fadeOut(200);\r\n\r\n that.$(\"#connectioncalculator__step2\").slideDown(200).fadeIn(200);\r\n\r\n\r\n that.$(\"#connectioncalculator__step1 .connectioncalculator__button\").html(\"Udregn pris\");\r\n }, 350);\r\n\r\n //}\r\n }\r\n return false;\r\n\r\n });\r\n\r\n that.$(\"[data-connectioncalculator__go]\").on(\"click\", function () {\r\n var goto = that.$(this).attr(\"data-connectioncalculator__go\").split(\",\");\r\n that.goToStep(goto[0], goto[1]);\r\n });\r\n }\r\n\r\n goToStep(to, from) {\r\n this.$(\"#connectioncalculator__\" + from).slideUp(200).fadeOut(200);\r\n this.$(\"#connectioncalculator__\" + to).slideDown(200).fadeIn(200);\r\n }\r\n\r\n formatNumber(inp, n, x, s, c) {\r\n var re = '\\\\d(?=(\\\\d{' + (x || 3) + '})+' + (n > 0 ? '\\\\D' : '$') + ')',\r\n num = inp.toFixed(Math.max(0, ~~n));\r\n\r\n return (c ? num.replace('.', c) : num).replace(new RegExp(re, 'g'), '$&' + (s || ','));\r\n }\r\n\r\n getCoordinatesBySelected(selected) {\r\n\r\n let url = new URL(\"https://dawa.aws.dk/adgangsadresser\");\r\n url.search = new URLSearchParams({\r\n vejnavn: selected.data.vejnavn,\r\n husnr: selected.data.husnr,\r\n postnr: selected.data.postnr,\r\n struktur: \"mini\"\r\n }).toString();\r\n\r\n fetch(url, {\r\n method: \"GET\",\r\n headers: {\r\n \"Accept\": \"application/json\"\r\n }\r\n })\r\n .then(response => response.json())\r\n .then(json => {\r\n\r\n if (json[0]) {\r\n var coords = this.calculateUtm32Coords(json[0]);\r\n this.searchInGis(coords, json[0]);\r\n\r\n this.$(\".umbraco-forms-field.adresse input\").val(selected.data.vejnavn + \" \" + selected.data.husnr);\r\n this.$(\".umbraco-forms-field.postnrogby input\").val(selected.data.postnr + \" \" + selected.data.postnrnavn);\r\n }\r\n })\r\n .catch(err => console.log(err));\r\n }\r\n\r\n\r\n calculateUtm32Coords(selectedItem) {\r\n return utmgeoconv.latLonToUtm(selectedItem.y, selectedItem.x, 32);\r\n }\r\n\r\n searchInGis(coords, selectedItem) {\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").removeClass(\"hidden\");\r\n this.$(\"#connectioncalculator__step1-1:visible\").slideUp(200).fadeOut(200);\r\n this.$(\"#connectioncalculator__step1-9:visible\").slideUp(200).fadeOut(200);\r\n this.$(\"#connectioncalculator__step1-3:visible\").slideUp(200).fadeOut(200);\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").prop(\"disabled\", true).addClass(\"opacity-50\");\r\n this.$(\"#connectioncalculator__step1 [type=submit]>span\").text(\"Vent, finder omr\u00E5de for din adresse\");\r\n\r\n fetch(`/umbraco/api/AreaMap/GetArea?x=${coords.x}&y=${coords.y}`)\r\n .then(response => response.json())\r\n .then(data => {\r\n this.$(\"#connectioncalculator__step1 [type=submit]>span\").text(\"Udregn pris\");\r\n this.setAndShowResult(data);\r\n })\r\n .catch(err => console.log(err));\r\n }\r\n\r\n\r\n setAndShowResult(status) {\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").removeClass(\"hidden\");\r\n \r\n /*\r\n \u2022\tLag 0 = eksisterende omr\u00E5der = Aktiv HER SKAL DET V\u00C6RE MULIGT AT KLIKKE P\u00C5 KNAPPEN UDREGN PRIS\r\n \u2022\tLag 1 = konverterings omr\u00E5der = Aktiv (er der noget med prisen der) HER SKAL DET V\u00C6RE MULIGT AT KLIKKE P\u00C5 KNAPPEN UDREGN PRIS\r\n \u2022\tLag 2 = tilmeldings omr\u00E5der = Aktiv? Skal de selv kunne beregne en pris? SKAL V\u00C6RE AKTIV OG LINKE TIL DENNE SIDE: https://www.fjernvarmefyn.dk/overvejer-du-fjernvarme/omraader\r\n \u2022\tLag 3 = unders\u00F8gelses omr\u00E5der inaktiv? SKAL V\u00C6RE AKTIV OG LINKE TIL DENNE SIDE: https://www.fjernvarmefyn.dk/overvejer-du-fjernvarme/overblik/undersogelsesomraader\r\n\r\n */\r\n\r\n if (status.status === 8 || status.status === 0) {\r\n // eksisterende\r\n this.$(\"#eksisterendeNet-ja\").prop(\"checked\", true);\r\n }\r\n else if (status.status === 9 || status.status === 1) {\r\n // nyt eller unders\u00F8gelse\r\n this.$(\"#eksisterendeNet-ja-udvidelse\").prop(\"checked\", true);\r\n }\r\n\r\n if (status.status === 8 || status.status === 9 || status.status === 0 || status.status === 1) {\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").prop(\"disabled\", false).removeClass(\"opacity-50\");\r\n }\r\n else {\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").prop(\"disabled\", true).addClass(\"opacity-50\");\r\n this.$(\"#eksisterendeNet-ja\").prop(\"checked\", false);\r\n this.$(\"#eksisterendeNet-ja-udvidelse\").prop(\"checked\", false);\r\n }\r\n\r\n if (status.status === -1) {\r\n this.$(\"#connectioncalculator__step1-1\").slideDown(200).fadeIn(200);\r\n }\r\n\r\n if (status.status === 10 || status.status === 2) {\r\n\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").addClass(\"hidden\");\r\n\r\n var link = status.nextStepLink;\r\n if (!link) {\r\n link = this.$(\"#connectioncalculator__step1-9-link\").attr(\"href\");\r\n }\r\n\r\n if (link) {\r\n this.$(\"#connectioncalculator__step1-9-link\").attr(\"href\", link).removeClass(\"hidden\");\r\n }\r\n else {\r\n this.$(\"#connectioncalculator__step1-9-link\").addClass(\"hidden\");\r\n }\r\n this.$(\"#connectioncalculator__step1-9\").slideDown(200).fadeIn(200);\r\n }\r\n\r\n if (status.status === 3) {\r\n\r\n this.$(\"#connectioncalculator__step1 [type=submit]\").addClass(\"hidden\");\r\n\r\n var link = status.nextStepLink;\r\n if (!link) {\r\n link = this.$(\"#connectioncalculator__step1-3-link\").attr(\"href\");\r\n }\r\n\r\n if (link) {\r\n this.$(\"#connectioncalculator__step1-3-link\").attr(\"href\", link).removeClass(\"hidden\");\r\n }\r\n else {\r\n this.$(\"#connectioncalculator__step1-3-link\").addClass(\"hidden\");\r\n }\r\n this.$(\"#connectioncalculator__step1-3\").slideDown(200).fadeIn(200);\r\n }\r\n\r\n }\r\n}\r\n\r\nconst connectionCalculatorInit = function () {\r\n [...document.querySelectorAll(\".connectioncalculator\")].map(cc => new ConnectionCalculator(cc));\r\n}\r\nexport default connectionCalculatorInit();\r\n", "var win = window;\n\nexport var raf = win.requestAnimationFrame\n || win.webkitRequestAnimationFrame\n || win.mozRequestAnimationFrame\n || win.msRequestAnimationFrame\n || function(cb) { return setTimeout(cb, 16); };\n", "var win = window;\n\nexport var caf = win.cancelAnimationFrame\n || win.mozCancelAnimationFrame\n || function(id){ clearTimeout(id); };\n", "export function extend() {\n var obj, name, copy,\n target = arguments[0] || {},\n i = 1,\n length = arguments.length;\n\n for (; i < length; i++) {\n if ((obj = arguments[i]) !== null) {\n for (name in obj) {\n copy = obj[name];\n\n if (target === copy) {\n continue;\n } else if (copy !== undefined) {\n target[name] = copy;\n }\n }\n }\n }\n return target;\n}", "export function checkStorageValue (value) {\n return ['true', 'false'].indexOf(value) >= 0 ? JSON.parse(value) : value;\n}", "export function setLocalStorage(storage, key, value, access) {\n if (access) {\n try { storage.setItem(key, value); } catch (e) {}\n }\n return value;\n}", "export function getSlideId() {\n var id = window.tnsId;\n window.tnsId = !id ? 1 : id + 1;\n \n return 'tns' + window.tnsId;\n}", "export function getBody () {\n var doc = document,\n body = doc.body;\n\n if (!body) {\n body = doc.createElement('body');\n body.fake = true;\n }\n\n return body;\n}", "export var docElement = document.documentElement;", "import { docElement } from './docElement.js';\n\nexport function setFakeBody (body) {\n var docOverflow = '';\n if (body.fake) {\n docOverflow = docElement.style.overflow;\n //avoid crashing IE8, if background image is used\n body.style.background = '';\n //Safari 5.13/5.1.4 OSX stops loading if ::-webkit-scrollbar is used and scrollbars are visible\n body.style.overflow = docElement.style.overflow = 'hidden';\n docElement.appendChild(body);\n }\n\n return docOverflow;\n}", "import { docElement } from './docElement.js';\n\nexport function resetFakeBody (body, docOverflow) {\n if (body.fake) {\n body.remove();\n docElement.style.overflow = docOverflow;\n // Trigger layout so kinetic scrolling isn't disabled in iOS6+\n // eslint-disable-next-line\n docElement.offsetHeight;\n }\n}", "// get css-calc \n// @return - false | calc | -webkit-calc | -moz-calc\n// @usage - var calc = getCalc(); \nimport { getBody } from './getBody.js';\nimport { setFakeBody } from './setFakeBody.js';\nimport { resetFakeBody } from './resetFakeBody.js';\n\nexport function calc() {\n var doc = document, \n body = getBody(),\n docOverflow = setFakeBody(body),\n div = doc.createElement('div'), \n result = false;\n\n body.appendChild(div);\n try {\n var str = '(10px * 10)',\n vals = ['calc' + str, '-moz-calc' + str, '-webkit-calc' + str],\n val;\n for (var i = 0; i < 3; i++) {\n val = vals[i];\n div.style.width = val;\n if (div.offsetWidth === 100) { \n result = val.replace(str, ''); \n break;\n }\n }\n } catch (e) {}\n \n body.fake ? resetFakeBody(body, docOverflow) : div.remove();\n\n return result;\n}", "// get subpixel support value\n// @return - boolean\nimport { getBody } from './getBody.js';\nimport { setFakeBody } from './setFakeBody.js';\nimport { resetFakeBody } from './resetFakeBody.js';\n\nexport function percentageLayout() {\n // check subpixel layout supporting\n var doc = document,\n body = getBody(),\n docOverflow = setFakeBody(body),\n wrapper = doc.createElement('div'),\n outer = doc.createElement('div'),\n str = '',\n count = 70,\n perPage = 3,\n supported = false;\n\n wrapper.className = \"tns-t-subp2\";\n outer.className = \"tns-t-ct\";\n\n for (var i = 0; i < count; i++) {\n str += '';\n }\n\n outer.innerHTML = str;\n wrapper.appendChild(outer);\n body.appendChild(wrapper);\n\n supported = Math.abs(wrapper.getBoundingClientRect().left - outer.children[count - perPage].getBoundingClientRect().left) < 2;\n\n body.fake ? resetFakeBody(body, docOverflow) : wrapper.remove();\n\n return supported;\n}", "import { getBody } from './getBody.js';\nimport { setFakeBody } from './setFakeBody.js';\nimport { resetFakeBody } from './resetFakeBody.js';\n\nexport function mediaquerySupport () {\n if (window.matchMedia || window.msMatchMedia) {\n return true;\n }\n \n var doc = document,\n body = getBody(),\n docOverflow = setFakeBody(body),\n div = doc.createElement('div'),\n style = doc.createElement('style'),\n rule = '@media all and (min-width:1px){.tns-mq-test{position:absolute}}',\n position;\n\n style.type = 'text/css';\n div.className = 'tns-mq-test';\n\n body.appendChild(style);\n body.appendChild(div);\n\n if (style.styleSheet) {\n style.styleSheet.cssText = rule;\n } else {\n style.appendChild(doc.createTextNode(rule));\n }\n\n position = window.getComputedStyle ? window.getComputedStyle(div).position : div.currentStyle['position'];\n\n body.fake ? resetFakeBody(body, docOverflow) : div.remove();\n\n return position === \"absolute\";\n}\n", "// create and append style sheet\nexport function createStyleSheet (media, nonce) {\n // Create the