@webtides/element-js 1.0.0-alpha.3 → 1.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/util/AttributeParser.js", "../src/util/DOMHelper.js", "../src/util/SerializeStateHelper.js", "../src/util/Store.js", "../src/util/defineElement.js", "../src/util/toString.js", "../src/BaseElement.js", "../src/util/GlobalStylesStore.js", "../src/StyledElement.js", "../src/dom-parts/Part.js", "../src/dom-parts/AttributePart.js", "../src/dom-parts/ChildNodePart.js", "../src/dom-parts/NodePart.js", "../src/dom-parts/TemplatePart.js", "../src/dom-parts/TemplateResult.js", "../src/dom-parts/html.js", "../src/dom-parts/render.js", "../src/TemplateElement.js", "../src/util/Directive.js"],
4
- "sourcesContent": ["/**\n * Tests if a value is of type `object`\n * @param {any} value\n * @returns {boolean}\n */\nexport function isObjectLike(value) {\n\treturn typeof value == 'object' && value !== null;\n}\n\n/**\n * Tests if a value can be parsed as JSON\n * @param {any} value\n * @returns {boolean}\n */\nexport function isJSON(value) {\n\ttry {\n\t\treturn JSON.parse(value) && !!value;\n\t} catch (e) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Tests if a value is `boolean`\n * @param {any} value\n * @returns {boolean}\n */\nexport function isBoolean(value) {\n\treturn value === 'true' || value === 'false';\n}\n\n/**\n * Parses a value to `boolean`\n * @param {any} value\n * @returns {boolean}\n */\nexport function parseBoolean(value) {\n\treturn value === 'true';\n}\n\n/**\n * Tests if a value is of type `string`\n * @param {any} value\n * @returns {boolean}\n */\nexport function isString(value) {\n\treturn (\n\t\ttypeof value === 'string' ||\n\t\t(!!value && typeof value === 'object' && Object.prototype.toString.call(value) === '[object String]')\n\t);\n}\n\n/**\n * Tests if a value is of type `number`\n * @param {any} value\n * @returns {boolean}\n */\nexport function isNumber(value) {\n\treturn new RegExp('^-?(0|0\\\\.\\\\d+|[1-9]\\\\d*(\\\\.\\\\d+)?)$').test(value);\n}\n\n/**\n * Tests if a value is of type `NaN`\n * @param {any} value\n * @returns {boolean}\n */\nexport function isNaN(value) {\n\treturn Number.isNaN(value);\n}\n\n/**\n * Compare two values (deep). It compares primitive or complex values with JSON stringify.\n * @param {any} valueA\n * @param {any} valueB\n * @returns {boolean}\n */\nexport function deepEquals(valueA, valueB) {\n\treturn JSON.stringify(valueA) === JSON.stringify(valueB);\n}\n\n/**\n * Parses an attribute value that comes in as a `string` to its corresponding type\n * @param {string} value\n * @param {PropertyOptions} options\n * @returns {string | number | boolean | object | array}\n */\nexport function parseAttribute(value, options = {}) {\n\tif (options.parse === false || !isString(value)) {\n\t\t// no-op\n\t\treturn value;\n\t}\n\tif (typeof options.parse === 'function') {\n\t\t// custom parse fn\n\t\treturn options.parse(value);\n\t}\n\n\t// default parse\n\tlet parsedValue = value;\n\n\tif (isJSON(value)) parsedValue = JSON.parse(value);\n\telse if (isBoolean(value)) parsedValue = parseBoolean(value);\n\telse if (isNumber(value)) parsedValue = parseFloat(value);\n\n\treturn parsedValue;\n}\n\n/**\n * Replaces dashed-expression (i.e. some-value) to a camel-cased expression (i.e. someValue)\n * @param {string} string\n * @returns {string}\n */\nexport function dashToCamel(string) {\n\tif (string.indexOf('-') === -1) return string;\n\n\treturn string.replace(/-[a-z]/g, (matches) => matches[1].toUpperCase());\n}\n\n/**\n * Replaces camel-cased expression (i.e. someValue) to a dashed-expression (i.e. some-value)\n * @param {string} string\n * @returns {string}\n */\nexport function camelToDash(string) {\n\treturn string.replace(/([A-Z])/g, '-$1').toLowerCase();\n}\n\n/**\n * Decodes an attribute.\n * @param {string} attribute\n * @returns {string}\n */\nexport function decodeAttribute(attribute) {\n\treturn `${attribute}`\n\t\t.replace(/&lt;/g, '<')\n\t\t.replace(/&gt;/g, '>')\n\t\t.replace(/&quot;/g, '\"')\n\t\t.replace(/&apos;/g, \"'\");\n}\n\n/**\n * Encodes an attribute.\n * @param {string} attribute\n * @returns {string}\n */\nexport function encodeAttribute(attribute) {\n\treturn `${attribute}`\n\t\t.replace(/'/g, '&apos;')\n\t\t.replace(/\"/g, '&quot;')\n\t\t.replace(/</g, '&lt;')\n\t\t.replace(/>/g, '&gt;')\n\t\t.replace(/\\r\\n/g, '\\n')\n\t\t.replace(/[\\r\\n]/g, '\\n');\n}\n", "/* An Element node like <p> or <div> */\nexport const ELEMENT_NODE = 1;\n/* An Attribute of an Element */\nexport const ATTRIBUTE_NODE = 2;\n/* The actual Text inside an Element or Attr */\nexport const TEXT_NODE = 3;\n/* A Comment node, such as <!-- \u2026 --> */\nexport const COMMENT_NODE = 8;\n/* A Document Fragment, a document without a parent */\nexport const DOCUMENT_FRAGMENT_NODE = 11;\n\n/**\n * Gets a list of (childNode) indexes for the given node\n * @param {Node} node\n * @return {number[]}\n */\nexport const getNodePath = (node) => {\n\tconst path = [];\n\tlet parentNode = node.parentNode;\n\twhile (parentNode) {\n\t\tpath.push([...parentNode.childNodes].indexOf(node));\n\t\tnode = parentNode;\n\t\tparentNode = node.parentNode;\n\t}\n\treturn path;\n};\n\n/**\n * Get a list of all parent nodes up the DOM tree\n * @param {Node} domNode\n * @returns {Node[]}\n */\nexport function getAllParentNodes(domNode) {\n\tlet node = domNode.parentElement;\n\tlet parents = [];\n\twhile (node) {\n\t\tparents.unshift(node); // adds node to the beginning of parents\n\t\tnode = node.parentElement;\n\t}\n\n\treturn parents;\n}\n\n/**\n * Gets the parent/root element of a shadow root or the global document body if not in shadow root.\n * https://stackoverflow.com/questions/27453617/how-can-i-tell-if-an-element-is-in-a-shadow-dom\n * @param {Node} element\n * @returns {ShadowRoot | HTMLElement}\n */\nexport function getShadowParentOrBody(element) {\n\tif (element instanceof ShadowRoot) {\n\t\treturn element;\n\t}\n\n\twhile (element.parentNode && (element = element.parentNode)) {\n\t\tif (element instanceof ShadowRoot) {\n\t\t\treturn element;\n\t\t}\n\t}\n\treturn document.body;\n}\n\n// TODO: add function for getClosestParentOfNodeType('custom-element')\n\n/**\n * Get the closest/first parent node that is a custom element\n * @param {Node} domNode\n * @returns {Node}\n */\nexport function getClosestParentCustomElementNode(domNode) {\n\tconst customElementParents = getAllParentNodes(domNode).filter((node) => {\n\t\treturn node.localName && node.localName.indexOf('-') !== -1;\n\t});\n\n\treturn customElementParents.pop();\n}\n\n/**\n * Get all\n * @param {Node} domNode\n * @param {{prototype: HTMLElement, new()}} instanceOfFilter\n * @return {Node[]}\n */\nexport function getAllElementChildren(domNode, instanceOfFilter = HTMLElement) {\n\tconst nodeIterator = document.createNodeIterator(domNode, NodeFilter.SHOW_ELEMENT, (node) =>\n\t\tnode.nodeName.includes('-') && node instanceof instanceOfFilter\n\t\t\t? NodeFilter.FILTER_ACCEPT\n\t\t\t: NodeFilter.FILTER_REJECT,\n\t);\n\tconst customElements = [];\n\tlet currentNode;\n\twhile ((currentNode = nodeIterator.nextNode())) {\n\t\tcustomElements.push(currentNode);\n\t}\n\treturn customElements;\n}\n\n/**\n * Checks whether two nodes are of the same node type\n * @param {Node} nodeA\n * @param {Node} nodeB\n * @returns {boolean}\n */\nexport function isOfSameNodeType(nodeA, nodeB) {\n\tif (!nodeA && !nodeA.localName) return false;\n\tif (!nodeB && !nodeB.localName) return false;\n\treturn nodeA.localName === nodeB.localName;\n}\n\n/**\n * Checks if adopting style sheets is supported in browser\n * @returns {boolean}\n */\nexport const supportsAdoptingStyleSheets = () => {\n\treturn 'adoptedStyleSheets' in Document.prototype && 'replace' in CSSStyleSheet.prototype;\n};\n\n/**\n * Better implementation of hasChildNodes check because the native check will also count for empty whitespace as child nodes... :(\n * @param {Node} node\n * @returns {boolean}\n */\nexport const hasChildNodes = (node) => {\n\tconst childNodesLength = node.childNodes.length;\n\n\tif (childNodesLength === 0) return false;\n\n\tif (childNodesLength === 1 && node.firstChild.nodeType === 3 && node.firstChild.textContent.trim() === '')\n\t\treturn false;\n\n\t// children will not contain text nodes...\n\tif (childNodesLength > 0) return true;\n\n\t// TODO: check if more than 1 child nodes, but all childnodes are whitespace text ndoes?!\n};\n\n/**\n * Parses the given string as HTML template and returns a real DOM element\n * @param {string} template\n * @returns {HTMLElement}\n */\nexport const convertStringToHTML = (template) => {\n\tconst parser = new DOMParser();\n\tconst document = parser.parseFromString(template.toString(), 'text/html');\n\treturn document.body;\n};\n\n/**\n * Parses the given string and returns a DocumentFragment which contains the DOM subtree\n * representing the <template> element's template contents.\n * @param {string} string\n * @return {DocumentFragment}\n */\nexport const convertStringToTemplate = (string) => {\n\tconst template = globalThis.document?.createElement('template');\n\t// TODO: ensure that SSRed and CSRed templates have the same amount of whitespace text nodes\n\ttemplate.innerHTML = string.trimStart().trimEnd();\n\treturn template.content;\n};\n\n/**\n * Diff the attributes for a live DOM element against a template DOM element\n * @param {Element} templateElement - The new template\n * @param {Element} domElement - The existing DOM node\n */\nexport const diffAttributes = function (templateElement, domElement) {\n\t// remove or update previous attributes\n\tfor (/** @type {Attr} */ const attribute of Array.from(domElement.attributes)) {\n\t\tif (templateElement.hasAttribute(attribute.name)) {\n\t\t\tconst oldValue = attribute.value;\n\t\t\tconst newValue = templateElement.getAttribute(attribute.name) || '';\n\t\t\tif (oldValue !== newValue) {\n\t\t\t\tdomElement.setAttribute(attribute.name, newValue);\n\t\t\t}\n\t\t} else {\n\t\t\tdomElement.removeAttribute(attribute.name);\n\t\t}\n\t}\n\n\t// set newly added attributes\n\tfor (/** @type {Attr} */ const attribute of Array.from(templateElement.attributes)) {\n\t\tif (!domElement.hasAttribute(attribute.name)) {\n\t\t\tdomElement.setAttribute(attribute.name, attribute.value);\n\t\t}\n\t}\n};\n\n/**\n * Diff a live DOM node against a template DOM node\n * @param {Node} templateNode\n * @param {Node} domNode\n * @param {(Node) => Boolean} shouldDiffChildNodes\n */\nexport const diffNodes = function (templateNode, domNode, shouldDiffChildNodes = (templateChildNode) => true) {\n\t// If the DOM node should be empty, remove all child nodes\n\tif (hasChildNodes(domNode) && !hasChildNodes(templateNode)) {\n\t\tdomNode.replaceChildren();\n\t\treturn;\n\t}\n\n\t// If the DOM node is empty, but should have children, add child nodes from the template node\n\tif (!hasChildNodes(domNode) && hasChildNodes(templateNode)) {\n\t\tdomNode.replaceChildren(...templateNode.childNodes);\n\t\treturn;\n\t}\n\n\tconst templateChildNodes = [...templateNode.childNodes];\n\tconst domChildNodes = [...domNode.childNodes];\n\n\t// Diff each node in the child node lists\n\tlet length = Math.max(templateChildNodes.length, domChildNodes.length);\n\tfor (let index = 0; index < length; index++) {\n\t\tconst templateChildNode = templateChildNodes[index];\n\t\tconst domChildNode = domChildNodes[index];\n\n\t\t// If the DOM node doesn't exist, append/copy the template node\n\t\tif (!domChildNode) {\n\t\t\tdomNode.appendChild(templateChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the template node doesn't exist, remove the node in the DOM\n\t\tif (!templateChildNode) {\n\t\t\tdomNode.removeChild(domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If DOM node is equal to the template node, don't do anything\n\t\tif (domChildNode.isEqualNode(templateChildNode)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// the following two checks don't have to be correct, but it could bring as back to the fast path\n\t\t// in the worst case we still have to compare and swap all the elements\n\t\t// but in the best case we find the one element that should actually be inserted or removed\n\t\t// and from there on, every node that comes after should be equal again\n\n\t\t// fast path for removing DOM nodes - we delete the node now instead of at the end\n\t\tif (domNode.childNodes.length > templateNode.childNodes.length) {\n\t\t\tdomChildNodes.splice(index, 1);\n\t\t\tdomNode.removeChild(domChildNode);\n\t\t\t// because domChildNodes will get shorter by splicing it, everything moves up by one\n\t\t\t// so the (actual) next element will have the same index now as we currently have\n\t\t\t// therefore we have to adjust our counters\n\t\t\tlength--;\n\t\t\tindex--;\n\n\t\t\t// we might have corrected everything and the parent nodes could be equal again\n\t\t\t// if so, we can skip the rest of the child node checks\n\t\t\tif (domNode.childNodes.length === templateNode.childNodes.length && domNode.isEqualNode(templateNode)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// fast path for adding DOM nodes - we insert the node now instead of at the end\n\t\t// but NOT if we already are at the end of the list of child nodes\n\t\tif (index !== domNode.childNodes.length - 1 && domNode.childNodes.length < templateNode.childNodes.length) {\n\t\t\tdomChildNodes.splice(index, 0, templateChildNode);\n\t\t\tdomNode.insertBefore(templateChildNode, domChildNode);\n\n\t\t\t// we might have corrected everything and the parent nodes could be equal again\n\t\t\t// if so, we can skip the rest of the child node checks\n\t\t\tif (domNode.childNodes.length === templateNode.childNodes.length && domNode.isEqualNode(templateNode)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If node types are not the same, replace the DOM node with the template node\n\t\tif (templateChildNode.nodeType !== domChildNode.nodeType) {\n\t\t\tdomNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the node is a Text node or a Comment node, update it\n\t\tif (domChildNode.nodeType === TEXT_NODE || domChildNode.nodeType === COMMENT_NODE) {\n\t\t\tdomChildNode.textContent = templateChildNode.textContent;\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the element tag names are not the same, replace the DOM node with the template node\n\t\tif (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName !== domChildNode.tagName) {\n\t\t\tdomNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the node is an SVG element, don't even think about diffing it, just replace it\n\t\tif (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName === 'SVG') {\n\t\t\tdomNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the node is an Element node, diff the attributes\n\t\tif (templateChildNode.nodeType === ELEMENT_NODE) {\n\t\t\tdiffAttributes(templateChildNode, domChildNode);\n\t\t}\n\n\t\t// If there are child nodes, diff them recursively\n\t\tif (templateChildNode.hasChildNodes()) {\n\t\t\tif (shouldDiffChildNodes(templateChildNode)) {\n\t\t\t\tdiffNodes(templateChildNode, domChildNode);\n\t\t\t}\n\t\t}\n\t}\n};\n", "import { Store } from './Store.js';\n\n/**\n * @typedef {Object} Serializable\n * An interface that classes should implement to enable serialization and deserialization of their state.\n * @property {string} _serializationKey - a unique key to be used for serialization.\n * @property {function} serializeState - Function to retrieve the state for serialization.\n * @property {function} restoreState - Function to set the state during deserialization.\n */\n\n// TODO: is it ok to expose this like this? Or should we wrap the cache in helper methods also?\n/** @type {Map<string, Serializable>} */\nexport const serializableObjectsCache = new Map();\n\n/** @type {HTMLScriptElement} */\nlet globalElementJsState;\n\n/**\n * Initializes the global script element that holds the state for all `Serializable` objects.\n */\nfunction initGlobalStateObject() {\n\tif (!globalElementJsState) {\n\t\tglobalElementJsState = Array.from(globalThis.document.scripts).find((script) => script.type === 'ejs/json');\n\t\tif (!globalElementJsState) {\n\t\t\tconst script = document.createElement('script');\n\t\t\tscript.setAttribute('type', 'ejs/json');\n\t\t\tscript.textContent = '{}';\n\t\t\tdocument.body.appendChild(script);\n\t\t\tglobalElementJsState = script;\n\t\t}\n\t}\n}\n\n/**\n * Takes an object that implements the `Serializable` interface and serializes its state.\n * @param {Serializable} serializableObject\n */\nexport function serializeState(serializableObject) {\n\tif (!globalThis.elementJsConfig?.serializeState) return;\n\n\tif (!serializableObject._serializationKey && !serializableObject.serializeState) {\n\t\tthrow new Error('serializableObject does not implement the Serializable interface');\n\t}\n\n\tinitGlobalStateObject();\n\n\tconst currentState = JSON.parse(globalElementJsState.textContent);\n\tcurrentState[serializableObject._serializationKey] = serializableObject.serializeState();\n\tglobalElementJsState.textContent = JSON.stringify(currentState, (key, value) => {\n\t\tif (value instanceof Store) {\n\t\t\treturn 'Store/' + value._serializationKey;\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t});\n}\n\n/**\n * Takes an object that implements the `Serializable` interface and deserializes its state and restores the object.\n * @param {Serializable} serializableObject\n * @param {{[string: any]: *}} [serializedState]\n */\nexport function deserializeState(serializableObject, serializedState) {\n\tif (!globalThis.elementJsConfig?.serializeState) return;\n\n\tif (!serializableObject._serializationKey && !serializableObject.restoreState) {\n\t\tthrow new Error('serializableObject does not implement the Serializable interface');\n\t}\n\n\tif (serializedState) {\n\t\tserializableObject.restoreState(serializedState);\n\t\treturn;\n\t}\n\n\tinitGlobalStateObject();\n\n\tconst unresolvedState = JSON.parse(globalElementJsState.textContent);\n\tconst currentState = JSON.parse(globalElementJsState.textContent, (key, value) => {\n\t\tif (typeof value === 'string' && value.startsWith('Store/')) {\n\t\t\tconst [_, storeUuid] = value.split('/');\n\t\t\tconst serializedState = unresolvedState[storeUuid];\n\t\t\treturn new Store(serializedState, { key: storeUuid, serializedState });\n\t\t} else {\n\t\t\treturn value;\n\t\t}\n\t});\n\n\tserializableObject.restoreState(currentState[serializableObject._serializationKey]);\n}\n\n/**\n * Checks if a serialized state is available for a given key.\n * @param key\n * @return {boolean}\n */\nexport function hasSerializedState(key) {\n\tif (!globalThis.elementJsConfig?.serializeState) return false;\n\n\tinitGlobalStateObject();\n\n\tconst serializedState = JSON.parse(globalElementJsState.textContent);\n\treturn serializedState.hasOwnProperty(key);\n}\n", "import { deepEquals, isObjectLike } from './AttributeParser.js';\nimport {\n\thasSerializedState,\n\tserializeState,\n\tdeserializeState,\n\tserializableObjectsCache,\n} from './SerializeStateHelper.js';\nimport { BaseElement } from '../BaseElement.js';\n\n/**\n * Options object for the Store\n * @typedef {Object} StoreOptions\n * @property {string} [key] - A unique key so that the store instance can be serialized and deserialized correctly across multiple shared parents/hosts.\n */\n\n/**\n * @implements {Serializable}\n */\nexport class Store {\n\t_serializationKey;\n\t_observer = new Set([]);\n\t_singlePropertyMode = false;\n\t_state = {};\n\n\t/**\n\t * @param {* | object} [value]\n\t * @param {StoreOptions} [options]\n\t */\n\tconstructor(value, options) {\n\t\tif (options?.key && serializableObjectsCache.has(options?.key)) {\n\t\t\treturn serializableObjectsCache.get(options?.key);\n\t\t}\n\n\t\tthis._singlePropertyMode = arguments.length > 0 && !isObjectLike(value);\n\n\t\tif (options?.key) {\n\t\t\tthis._serializationKey = options?.key;\n\t\t} else {\n\t\t\tthis._serializationKey = globalThis.crypto.randomUUID();\n\t\t}\n\n\t\tif (options?.serializedState) {\n\t\t\tdeserializeState(this, options.serializedState);\n\t\t} else if (hasSerializedState(this._serializationKey)) {\n\t\t\tdeserializeState(this);\n\t\t}\n\n\t\t// wrap primitives with a generic \"value\" field to generate getter and setter\n\t\tconst specificValues = this._singlePropertyMode ? { value } : value;\n\t\tconst properties = { ...(!this._singlePropertyMode && this.properties()), ...specificValues };\n\n\t\tconst serializationKeys = Object.keys(this.serializeState());\n\t\tObject.entries(properties).map(([key, value]) => {\n\t\t\tthis._state[key] =\n\t\t\t\thasSerializedState(this._serializationKey) && serializationKeys.includes(key) ? this[key] : value;\n\n\t\t\tif (value instanceof Store) {\n\t\t\t\tvalue.subscribe(this);\n\t\t\t}\n\n\t\t\tObject.defineProperty(this, key, {\n\t\t\t\tget: () => {\n\t\t\t\t\treturn this._state[key];\n\t\t\t\t},\n\t\t\t\tset: (newValue) => {\n\t\t\t\t\tconst oldValue = this._state[key];\n\t\t\t\t\tthis._state[key] = newValue;\n\t\t\t\t\tif (value instanceof Store) {\n\t\t\t\t\t\tvalue.subscribe(this);\n\t\t\t\t\t}\n\n\t\t\t\t\tserializeState(this);\n\n\t\t\t\t\tif (!deepEquals(newValue, oldValue)) {\n\t\t\t\t\t\tconst watch = this.watch();\n\t\t\t\t\t\tif (watch.hasOwnProperty(key) && typeof watch[key] === 'function') {\n\t\t\t\t\t\t\twatch[key](newValue, oldValue);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tthis.requestUpdate();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t});\n\t\t});\n\n\t\tserializableObjectsCache.set(this._serializationKey, this);\n\t}\n\n\t/**\n\t * Properties to be defined and assigned on the store. Can be overridden in extended classes.\n\t * Properties defined here will also trigger an update cycle when changed.\n\t * @return {{}}\n\t */\n\tproperties() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * When a property as the key was changed in the store, the callback function defined as value\n\t * will be called with `newValue` and `oldValue`\n\t * @return {{}}\n\t */\n\twatch() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Overrides `valueOf` to automatically return .value\n\t * @returns {* | {}}\n\t */\n\tvalueOf() {\n\t\treturn this._singlePropertyMode ? this._state.value : this._state;\n\t}\n\n\t/**\n\t * Overrides `toString` to automatically return .value\n\t * @returns {string}\n\t */\n\ttoString() {\n\t\treturn `${this._singlePropertyMode ? this._state.value : this._state}`;\n\t}\n\n\t/**\n\t * Add an observer\n\t * @param {BaseElement|Function|Store} observer\n\t */\n\tsubscribe(observer) {\n\t\tthis._observer.add(observer);\n\t}\n\n\t/**\n\t * Remove an observer\n\t * @param {BaseElement | Function} observer\n\t */\n\tunsubscribe(observer) {\n\t\tthis._observer.delete(observer);\n\t}\n\n\t/**\n\t * Request and batch an asynchronous update cycle\n\t */\n\trequestUpdate() {\n\t\tthis._observer.forEach(async (observer) => {\n\t\t\tif (observer instanceof BaseElement || observer instanceof Store) {\n\t\t\t\tif (observer?._options?.autoUpdate !== false) {\n\t\t\t\t\tawait observer.requestUpdate();\n\t\t\t\t}\n\t\t\t\t// check if store is watched by an observer\n\t\t\t\tif (Object.keys(observer.watch() ?? {}).length > 0) {\n\t\t\t\t\t// observer actually has watched properties\n\t\t\t\t\tObject.keys(observer.watch() ?? {}).forEach((key) => {\n\t\t\t\t\t\tif (observer._state[key] === this) {\n\t\t\t\t\t\t\t// observer is actually watching store changes provide new and old values\n\t\t\t\t\t\t\tif (observer instanceof Store) {\n\t\t\t\t\t\t\t\t// observer is a foreign store / call watcher\n\t\t\t\t\t\t\t\tobserver.watch?.()[key](this, this);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tobserver.callPropertyWatcher(key, this, this);\n\t\t\t\t\t\t\t\tobserver.notifyPropertyChange(key, this);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} else if (typeof observer === 'function') {\n\t\t\t\tobserver();\n\t\t\t} else {\n\t\t\t\tconsole.error('Store: observer type is not supported.', observer);\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * This method will be used to serialize this stores state.\n\t * By default, it will generate an object with all properties from this.properties().\n\t * You can override this and return a different object with more/less/different properties.\n\t * @return {{[string: any]: *}}\n\t */\n\tserializeState() {\n\t\tconst keys = Object.keys(this.properties());\n\t\treturn Object.fromEntries(keys.map((key) => [key, this[key]]));\n\t}\n\n\t/**\n\t * This method will be used to restore properties on the store from a previously serialized state.\n\t * You can override this and handle the deserialization differently if the default is not enough.\n\t * @param {{[string: any]: *}} serializedState\n\t */\n\trestoreState(serializedState) {\n\t\tObject.assign(this, serializedState);\n\t}\n}\n", "/**\n * Wrapper for defining custom elements so that registering an element multiple times won't crash\n * @param {string} name - name for the element tag\n * @param {CustomElementConstructor} constructor for the custom element\n */\nexport function defineElement(name, constructor) {\n\ttry {\n\t\tcustomElements.define(name, constructor);\n\t} catch (e) {\n\t\t// console.log('error defining custom element', e);\n\t}\n}\n", "/**\n * Little wrapper function for JSON.stringify() to easily convert objects and arrays to strings\n * to be able to set them as attributes on custom elements\n * @param {object | array} value - to be stringified\n * @return {string}\n */\nexport function toString(value) {\n\ttry {\n\t\treturn JSON.stringify(value);\n\t} catch (e) {\n\t\treturn '';\n\t}\n}\n", "import { parseAttribute, isNaN, dashToCamel, camelToDash, isObjectLike } from './util/AttributeParser.js';\nimport { getAllElementChildren, getClosestParentCustomElementNode, isOfSameNodeType } from './util/DOMHelper.js';\nimport { Store } from './util/Store.js';\nimport { serializeState, deserializeState, hasSerializedState } from './util/SerializeStateHelper.js';\nexport { defineElement } from './util/defineElement.js';\nexport { toString } from './util/toString.js';\n\n/**\n * Options object for the BaseElement\n * @typedef {Object} BaseElementOptions\n * @property {boolean} [autoUpdate] - When set to true the element will call the requestUpdate() method on the instance every time a property or attribute was changed. This will re-evaluate everything on the element and trigger a re-render (if a template is provided) and trigger the watchers for the affected properties/attributes. Default is `true`\n * @property {boolean} [deferUpdate] - When set to true the element will not call the requestUpdate() method upon connecting and therefore will not render (if template was provided) initially. Default is `true`\n * @property {MutationObserverOptions} [mutationObserverOptions]\n * @property {PropertyOptions} [propertyOptions]\n */\n\n/**\n * Options object for the BaseElement mutationObserverOptions option\n * @typedef {Object} MutationObserverOptions\n * @property {boolean} [childList] - When childList is set to true the element will also call the requestUpdate method for childList modifications (eg. Adding or removing child elements). Default is `true`\n * @property {boolean} [subtree] - Please note that observing subtree mutations might have performance implications and use it only if necessary. Default is `false`\n */\n\n/**\n * Options object for the BaseElement propertyOptions option\n * @typedef {Object} PropertyOptions\n * @property {undefined | boolean | function} [reflect] - When set to true the element will reflect property changes back to attributes if the attribute was not present when connecting the element. By default, all attributes that are present when connecting the element will be reflected anyway. Default is `undefined`\n * @property {undefined | boolean | function} [parse] - When set to false the element will not automatically try to parse the attributes string value to a complex type (number, array, object). Default is `undefined`\n * @property {undefined | boolean | function} [notify] - When set to true the element will dispatch CustomEvents for every property/attribute change. The event name will be the property name all lowercase and camel to dashes with a postfix of -changed. Default is `undefined`\n */\n\n/**\n * Options object for updating properties\n * @typedef {Object} PropertyUpdateOptions\n * @property {boolean} [notify] - Whether the update should trigger the lifecycle methods. The default is `true`\n * @property {string} property - The property name\n * @property {any} newValue - The new value for the property\n * @property {string} newValueString - The new value as `string` for the property (for comparison reasons)\n * @property {any} oldValue - The old value for the property\n */\n\n/**\n * @implements {Serializable}\n */\nclass BaseElement extends HTMLElement {\n\t_serializationKey;\n\n\t/**\n\t * @param {BaseElementOptions} options\n\t */\n\tconstructor(options = {}) {\n\t\tsuper();\n\t\tthis.$refs = {};\n\t\tthis._state = {};\n\t\tthis._mutationObserver = null;\n\t\tthis._registeredEvents = [];\n\t\tthis._batchUpdate = null;\n\t\tthis._requestedUpdates = [];\n\t\tthis._options = {\n\t\t\tautoUpdate: true,\n\t\t\tdeferUpdate: true,\n\t\t\tdeferConnected: false,\n\t\t\tmutationObserverOptions: {\n\t\t\t\tattributes: true,\n\t\t\t\tchildList: true,\n\t\t\t\tsubtree: false,\n\t\t\t\t...options.mutationObserverOptions,\n\t\t\t},\n\t\t\tpropertyOptions: {},\n\t\t\t...options,\n\t\t};\n\n\t\tif (this.hasAttribute('defer-update')) {\n\t\t\tthis._options.deferUpdate = true;\n\t\t}\n\t\tif (this.hasAttribute('defer-connected')) {\n\t\t\tthis._options.deferConnected = true;\n\t\t}\n\t}\n\n\t/**\n\t * Overrides the native `connectedCallback` of the HTMLElement to set up and initialize our element.\n\t * This will define the attributes and properties as reactive getters and setter,\n\t * register observers, refs and events.\n\t */\n\tconnectedCallback() {\n\t\tif (this._options.deferConnected) {\n\t\t\tthis._options.deferConnected = false;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.hasAttribute('ejs:key')) {\n\t\t\tthis._serializationKey = this.getAttribute('ejs:key');\n\t\t\tdeserializeState(this);\n\t\t} else {\n\t\t\tthis._serializationKey = globalThis.crypto.randomUUID();\n\t\t\tif (globalThis.elementJsConfig?.serializeState) {\n\t\t\t\tthis.setAttribute('ejs:key', this._serializationKey);\n\t\t\t}\n\t\t}\n\n\t\t// define all attributes to \"this\" as properties\n\t\tthis.defineAttributesAsProperties();\n\n\t\t// define all properties to \"this\"\n\t\tthis.defineProperties();\n\n\t\t// define context\n\t\tthis.definePropertyInjection();\n\n\t\t// define everything that should be observed\n\t\tthis.defineObserver();\n\n\t\tif (this.hasAttribute('defer-update') || this._options.deferUpdate) {\n\t\t\t// don't update/render, but register refs and events\n\t\t\tthis.registerEventsAndRefs();\n\n\t\t\tthis.triggerHook('connected');\n\t\t} else {\n\t\t\tthis.requestUpdate({ notify: false }).then(() => {\n\t\t\t\tthis.triggerHook('connected');\n\t\t\t\tthis.triggerHook('afterUpdate');\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Define a MutationObserver on the element to get notified on attribute changes and childList updates according to the options specified via the constructor options.\n\t */\n\tdefineObserver() {\n\t\t// see: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver#Example_usage\n\t\tthis._mutationObserver = new MutationObserver((mutations) => {\n\t\t\tmutations.forEach((mutation) => {\n\t\t\t\tif (\n\t\t\t\t\tmutation.type === 'attributes' &&\n\t\t\t\t\tmutation.target === this &&\n\t\t\t\t\tthis._state.hasOwnProperty(dashToCamel(mutation.attributeName))\n\t\t\t\t) {\n\t\t\t\t\t// update property by invoking the setter\n\t\t\t\t\tthis[dashToCamel(mutation.attributeName)] = parseAttribute(\n\t\t\t\t\t\tthis.getAttribute(mutation.attributeName),\n\t\t\t\t\t\tthis._options.propertyOptions[dashToCamel(mutation.attributeName)],\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (mutation.type === 'attributes' && mutation.target !== this) {\n\t\t\t\t\tthis.requestUpdate();\n\t\t\t\t}\n\t\t\t\tif (mutation.type === 'childList') {\n\t\t\t\t\tthis.requestUpdate();\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\n\t\tthis._mutationObserver.observe(this, {\n\t\t\tattributes: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: false,\n\t\t\t...this._options.mutationObserverOptions,\n\t\t});\n\t}\n\n\t/**\n\t * Native `disconnectedCallback` of the HTMLElement\n\t */\n\tdisconnectedCallback() {\n\t\t// remove events for elements in the component\n\t\tthis.removeEvents();\n\n\t\tif (Object.keys(this.provideProperties()).length > 0) {\n\t\t\tthis.removeEventListener('request-context', this.onRequestContext);\n\t\t}\n\n\t\t// remove observers\n\t\tif (this._mutationObserver) this._mutationObserver.disconnect();\n\n\t\t// unsubscribe from stores\n\t\tObject.values(this.properties()).forEach((property) => {\n\t\t\tif (property instanceof Store) {\n\t\t\t\tproperty.unsubscribe(this);\n\t\t\t}\n\t\t});\n\n\t\tthis.triggerHook('disconnected');\n\t}\n\n\t/**\n\t * Request and batch an asynchronous update cycle\n\t * @param {PropertyUpdateOptions} options\n\t * @returns {Promise<unknown>}\n\t */\n\trequestUpdate(options = { notify: true }) {\n\t\tif (options.notify === true) {\n\t\t\tthis.triggerHook('beforeUpdate');\n\t\t}\n\n\t\tif (this._batchUpdate) {\n\t\t\tcancelAnimationFrame(this._batchUpdate);\n\t\t\tthis._batchUpdate = false;\n\t\t}\n\n\t\treturn new Promise((resolve, reject) => {\n\t\t\tthis._requestedUpdates.push({ resolve, reject });\n\t\t\tthis._batchUpdate = requestAnimationFrame(() => {\n\t\t\t\ttry {\n\t\t\t\t\tthis.update(options);\n\t\t\t\t\tthis._requestedUpdates.forEach(({ resolve, reject }) => resolve());\n\t\t\t\t} catch (e) {\n\t\t\t\t\t// console.error('Update error', e)\n\t\t\t\t\tthis._requestedUpdates.forEach(({ resolve, reject }) => reject(e));\n\t\t\t\t}\n\t\t\t\tthis._requestedUpdates = [];\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * This should be called by the template component AFTER adding the template to\n\t * the DOM.\n\t * Here we will register the events and the refs for the element.\n\t * @param {PropertyUpdateOptions} options\n\t */\n\tupdate(options = { notify: true }) {\n\t\tthis.registerEventsAndRefs();\n\t\tif (options.notify === true) {\n\t\t\tthis.triggerHook('afterUpdate');\n\t\t}\n\t}\n\n\t/**\n\t * Register events and refs for the component\n\t */\n\tregisterEventsAndRefs() {\n\t\t// register events for elements in the component\n\t\tthis.registerEvents();\n\n\t\t// register $refs\n\t\tthis.registerRefs();\n\t}\n\n\t/**\n\t * Defines all attributes assigned in the HTML for the element as properties on the element\n\t * If the value for an attribute can be parsed to an object or array, it will do so\n\t */\n\tdefineAttributesAsProperties() {\n\t\tconst ignoreAttributes = ['class', 'style'];\n\t\tArray.from(this.attributes)\n\t\t\t.filter((attribute) => {\n\t\t\t\treturn !ignoreAttributes.includes(attribute.name);\n\t\t\t})\n\t\t\t.forEach((attribute) => {\n\t\t\t\tconst name = dashToCamel(attribute.name);\n\t\t\t\tconst parseOptions = this._options.propertyOptions[name];\n\t\t\t\tthis.defineProperty(name, parseAttribute(attribute.value, parseOptions), true);\n\t\t\t});\n\t}\n\n\t/**\n\t * Properties to be defined and assigned on the element. Should be overwritten in child components\n\t * Properties defined here will also trigger a update() when changed.\n\t * eg. { stringProperty: 'value', numberProperty: 13, booleanProperty: true } }\n\t * @return {{}}\n\t */\n\tproperties() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Defines properties on the element based on keys from this.properties()\n\t * Will trigger update() when a property was changed\n\t */\n\tdefineProperties() {\n\t\tObject.keys({ ...this.injectProperties(), ...this.properties() }).forEach((prop) => {\n\t\t\t// when mixing shadow dom elements with light dom elements and nesting custom elements\n\t\t\t// it might occur that properties where set on an element before it was\n\t\t\t// registered or connected. To avoid such timing issues we check\n\t\t\t// if a value was set for that specific property on the\n\t\t\t// prototype before assigning a default value\n\t\t\tconst value = this[prop] || this.properties()[prop];\n\t\t\tthis.defineProperty(prop, value);\n\t\t});\n\t}\n\n\t/**\n\t * Define a property on the element\n\t * Will trigger watch() function when a property was changed\n\t * Will trigger update() when a property was changed\n\t * @param {string} property\n\t * @param {any} value\n\t * @param {boolean} reflectAttribute\n\t */\n\tdefineProperty(property, value, reflectAttribute = false) {\n\t\tif (this._state.hasOwnProperty(property)) {\n\t\t\t// property has already been defined as an attribute nothing to do here\n\t\t\treturn;\n\t\t}\n\n\t\t// if property did not come from an attribute but has the option to reflect // enabled or custom fn\n\t\tif (!reflectAttribute && this._options.propertyOptions[property]?.reflect) {\n\t\t\tthis.reflectProperty({ property: property, newValue: value });\n\t\t}\n\n\t\t// remove attribute if reflect is set to false explicitly in options\n\t\tif (this._options.propertyOptions[property]?.reflect === false) {\n\t\t\tthis.removeAttribute(camelToDash(property));\n\t\t}\n\n\t\tif (hasSerializedState(this._serializationKey) && Object.keys(this.serializeState())?.includes(property)) {\n\t\t\tvalue = this[property];\n\t\t}\n\n\t\tthis._state[property] = value;\n\n\t\tif (this._state[property] instanceof Store) {\n\t\t\tthis._state[property].subscribe(this);\n\t\t}\n\n\t\tObject.defineProperty(this, property, {\n\t\t\tget: () => {\n\t\t\t\treturn this._state[property];\n\t\t\t},\n\t\t\tset: (newValue) => {\n\t\t\t\tconst oldValue = this._state[property];\n\t\t\t\tconst newValueString = JSON.stringify(newValue);\n\t\t\t\tif (JSON.stringify(oldValue) !== newValueString) {\n\t\t\t\t\tthis._state[property] = newValue;\n\n\t\t\t\t\tserializeState(this);\n\n\t\t\t\t\tif (newValue instanceof Store) {\n\t\t\t\t\t\tnewValue.subscribe(this);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (reflectAttribute || this._options.propertyOptions[property]?.reflect) {\n\t\t\t\t\t\tthis.reflectProperty({ property, newValue, newValueString });\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._options.autoUpdate) {\n\t\t\t\t\t\tthis.requestUpdate({\n\t\t\t\t\t\t\tnotify: true,\n\t\t\t\t\t\t\tproperty: property,\n\t\t\t\t\t\t\tnewValue: newValue,\n\t\t\t\t\t\t\tnewValueString: newValueString,\n\t\t\t\t\t\t\toldValue: oldValue,\n\t\t\t\t\t\t}).finally(() => {\n\t\t\t\t\t\t\tthis.callPropertyWatcher(property, newValue, oldValue);\n\t\t\t\t\t\t\tthis.notifyPropertyChange(property, newValue);\n\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.callPropertyWatcher(property, newValue, oldValue);\n\t\t\t\t\t\tthis.notifyPropertyChange(property, newValue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn this;\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Call the watch callbacks on property changes\n\t * @param {string} property property that changes\n\t * @param {any} newValue\n\t * @param {any} oldValue\n\t */\n\tcallPropertyWatcher(property, newValue, oldValue) {\n\t\t// notify watched properties (after update())\n\t\tconst watch = this.watch();\n\t\tif (property in watch) {\n\t\t\twatch[property](newValue, oldValue);\n\t\t}\n\t}\n\n\t/**\n\t * Notify property observer via change event\n\t * @param {string} property property that changes\n\t * @param {any} newValue\n\t */\n\tnotifyPropertyChange(property, newValue) {\n\t\t// dispatch change event\n\t\tif (\n\t\t\tproperty in this._options['propertyOptions'] &&\n\t\t\tthis._options['propertyOptions'][property]['notify'] === true\n\t\t) {\n\t\t\tthis.dispatch(`${camelToDash(property)}-changed`, newValue, true);\n\t\t}\n\t}\n\n\t/**\n\t * Reflects a property as attribute on the element\n\t * @param {PropertyUpdateOptions} options\n\t */\n\treflectProperty(options) {\n\t\tconst { property, newValue } = options;\n\t\tconst newValueString = options.newValueString || JSON.stringify(newValue);\n\n\t\tif (newValue === undefined || newValue === null || isNaN(newValue)) {\n\t\t\t// these would be reflected as strings: \"undefined\" || \"null\" || \"NaN\"\n\t\t\t// which is not the desired behaviour. Therefore we reflect them as empty strings\n\t\t\tthis.setAttribute(camelToDash(property), '');\n\t\t} else {\n\t\t\tlet attributeValue = isObjectLike(newValue) ? newValueString : newValue;\n\t\t\tif (typeof this._options.propertyOptions[property]?.reflect === 'function') {\n\t\t\t\tattributeValue = this._options.propertyOptions[property].reflect(newValue);\n\t\t\t}\n\t\t\tthis.setAttribute(camelToDash(property), attributeValue);\n\t\t}\n\t}\n\n\t/**\n\t * Context Properties to issue Context Requests and to pull contextual properties into the elements scope\n\t * @return {{}}\n\t */\n\tinjectProperties() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Define which properties that can be provided to children\n\t * @return {{}}\n\t */\n\tprovideProperties() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Defines context on the element based on keys from this.injectProperties()\n\t */\n\tdefinePropertyInjection() {\n\t\tObject.entries(this.injectProperties()).forEach(([key, value]) => {\n\t\t\tthis.requestContext(key, value);\n\t\t});\n\t\t// define context provider\n\t\tconst providedKeys = Object.keys(this.provideProperties());\n\t\tif (providedKeys.length > 0) {\n\t\t\tthis.addEventListener('request-context', this.onRequestContext);\n\t\t\t// check if there are already connected elements in child dom and restart requests\n\t\t\tgetAllElementChildren(this.getRoot(), BaseElement).forEach((customChild) => {\n\t\t\t\t// if injectProperties?.() is defined it means that the child got connected BEFORE the parent (Runtime Issue)\n\t\t\t\tconst requestedProperties = customChild.injectProperties?.() ?? {};\n\t\t\t\tObject.entries(requestedProperties).forEach(([key, value]) => {\n\t\t\t\t\t// iterate over requested properties to find missed context requests\n\t\t\t\t\tif (providedKeys.includes(key)) {\n\t\t\t\t\t\t// owns the provided key -> replay request\n\t\t\t\t\t\tcustomChild.requestContext(key, value);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t}\n\t}\n\n\t/**\n\t * Helper Function to initialize the context requests\n\t * @param {string} propertyName\n\t * @param {any | function} valueOrCallback\n\t */\n\trequestContext(propertyName, valueOrCallback) {\n\t\tthis.dispatch('request-context', { [propertyName]: valueOrCallback }, true, true, true);\n\t}\n\n\t/**\n\t * Internal Context Request Handler\n\t * This will check if the current/receiving instance actually provides a value under the requested name.\n\t * If there is something to provide it will either assign the value to the requesting element or call the callback.\n\t * @param {CustomEvent} event\n\t */\n\tonRequestContext(event) {\n\t\tconst provideProperties = this.provideProperties();\n\n\t\tObject.entries(event.detail ?? {}).forEach(([key, valueOrCallback]) => {\n\t\t\tif (key in provideProperties) {\n\t\t\t\t// found it, provide it\n\t\t\t\tconst providedValue = provideProperties[key];\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tif (typeof valueOrCallback === 'function') {\n\t\t\t\t\t// call function with context value\n\t\t\t\t\tvalueOrCallback(providedValue);\n\t\t\t\t} else {\n\t\t\t\t\t// assign to prop\n\t\t\t\t\tconst eventPath = event.composedPath();\n\t\t\t\t\tconst target = eventPath[0] || event.target;\n\t\t\t\t\ttarget[key] = providedValue;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Connected lifecycle hook\n\t */\n\tconnected() {}\n\n\t/**\n\t * BeforeUpdate lifecycle hook\n\t */\n\tbeforeUpdate() {}\n\n\t/**\n\t * AfterUpdate lifecycle hook\n\t */\n\tafterUpdate() {}\n\n\t/**\n\t * Disconnected lifecycle hook\n\t */\n\tdisconnected() {}\n\n\t/**\n\t * Triggers a lifecycle hook based on the name\n\t * @param {string} name\n\t */\n\ttriggerHook(name) {\n\t\tif (name in this) {\n\t\t\tthis[name]();\n\t\t}\n\t}\n\n\t/**\n\t * Watched attributes & properties to be notified to the element when changed. Should be overwritten in child components\n\t * When an attribute or property as the key was changed on the element, the callback function defined as value\n\t * will be called with `newValue` and `oldValue`\n\t * eg. { property: (oldValue, newValue) => { console.log('property changed!, oldValue, newValue); } }\n\t * @return {{}}\n\t */\n\twatch() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Return a map of events that should be registered on the element.\n\t * eg. { '.link': {\n\t * 'click': (e) => {console.log('MyElement.link - clicked', e)},\n\t * 'mouseover': (e) => {console.log('MyElement.link - mouseover()', e)},\n\t * }\n\t * }\n\t */\n\tevents() {\n\t\treturn {};\n\t}\n\n\t/**\n\t * Registers events on the element based on events().\n\t * Removes all previously registered events before adding them.\n\t */\n\tregisterEvents() {\n\t\t// remove all previously registered events to prevent duplicate triggers\n\t\tthis.removeEvents();\n\n\t\t// register events\n\t\tconst eventDefinitions = this.events();\n\t\tObject.keys(eventDefinitions).forEach((elementSelector) => {\n\t\t\tconst events = eventDefinitions[elementSelector];\n\t\t\tconst selectorWhiteList = { window, document, this: this.getRoot() };\n\t\t\tconst whiteListElement = selectorWhiteList[elementSelector];\n\t\t\tconst eventTargets = whiteListElement\n\t\t\t\t? [whiteListElement]\n\t\t\t\t: this.getRoot().querySelectorAll(elementSelector);\n\n\t\t\teventTargets.forEach((eventTarget) => {\n\t\t\t\tObject.keys(events).forEach((eventName) => {\n\t\t\t\t\tconst notation = events[eventName];\n\t\t\t\t\tif (typeof notation === 'function') {\n\t\t\t\t\t\tconst callback = notation.bind(this);\n\t\t\t\t\t\teventTarget.addEventListener(eventName, callback);\n\t\t\t\t\t\tthis._registeredEvents.push({ eventTarget, eventName, callback });\n\t\t\t\t\t} else if (typeof notation === 'object' && typeof notation.listener === 'function') {\n\t\t\t\t\t\tconst callback = notation.listener.bind(this);\n\t\t\t\t\t\teventTarget.addEventListener(eventName, callback, notation.options ?? {});\n\t\t\t\t\t\tthis._registeredEvents.push({ eventTarget, eventName, callback });\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Removes all events from the element that where previously registered from the events() map.\n\t */\n\tremoveEvents() {\n\t\tthis._registeredEvents.forEach(({ eventTarget, eventName, callback }) => {\n\t\t\tif (eventTarget === window || eventTarget === document || this.getRoot().contains(eventTarget)) {\n\t\t\t\teventTarget.removeEventListener(eventName, callback);\n\t\t\t}\n\t\t});\n\t\tthis._registeredEvents = [];\n\t}\n\n\t/**\n\t * Stores an object that references child elements & DOM nodes that have a ref attribute defined.\n\t * References will be accessible on the element under this.$refs\n\t */\n\tregisterRefs() {\n\t\tconst refsNodeList = this.getRoot().querySelectorAll('[ref]');\n\t\tconst refsArray = Array.from(refsNodeList);\n\t\tconst refsMap = {};\n\n\t\trefsArray.forEach((refNode) => {\n\t\t\tconst refKey = refNode.getAttribute('ref');\n\t\t\tconst isListKey = refKey.endsWith('[]');\n\t\t\tconst cleanKey = isListKey ? refKey.slice(0, -2) : refKey;\n\t\t\tconst hasListRef = Array.isArray(refsMap[cleanKey]);\n\n\t\t\tif (isListKey) {\n\t\t\t\tif (!refsMap[cleanKey] || !hasListRef) {\n\t\t\t\t\t// create or overwrite previously registered single ref\n\t\t\t\t\trefsMap[cleanKey] = [];\n\t\t\t\t}\n\t\t\t\trefsMap[cleanKey].push(refNode);\n\t\t\t} else if (!hasListRef) {\n\t\t\t\trefsMap[refKey] = refNode;\n\t\t\t} else {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`Did not register singular ref ${refKey}, ${refNode} as a ref list is already registered under the same name.`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tthis.$refs = refsMap;\n\t}\n\n\t/**\n\t * Helper function for dispatching custom events\n\t * @param {string} name\n\t * @param {Object} data\n\t * @param {CustomEventInit} options\n\t * @param {boolean} cancelable - DEPRECATED\n\t * @param {boolean} composed - DEPRECATED\n\t */\n\tdispatch(name, data, options, cancelable = false, composed = false) {\n\t\tlet eventInit = {};\n\n\t\tif (options !== undefined && typeof options === 'boolean') {\n\t\t\teventInit['bubbles'] = options;\n\t\t\teventInit['cancelable'] = cancelable;\n\t\t\teventInit['composed'] = composed;\n\t\t\teventInit['detail'] = data;\n\t\t\tconsole.warn(\n\t\t\t\t`[${this.localName}] Using the old parameter options for the event is deprecated and will be removed in v2.0! Please use the new options object that is in line with the \"CustomEventInit\" options`,\n\t\t\t);\n\t\t} else {\n\t\t\teventInit = {\n\t\t\t\tbubbles: true,\n\t\t\t\tcancelable: true,\n\t\t\t\tcomposed: true,\n\t\t\t\tdetail: data,\n\t\t\t\t...options,\n\t\t\t};\n\t\t}\n\n\t\tconst event = new CustomEvent(name, eventInit);\n\t\tthis.dispatchEvent(event);\n\t}\n\n\t/**\n\t * Get the root element\n\t * @returns {HTMLElement}\n\t */\n\tgetRoot() {\n\t\treturn this;\n\t}\n\n\t/**\n\t * This method will be used to serialize this elements state.\n\t * By default, it will generate an object with all properties from this.properties().\n\t * You can override this and return a different object with more/less/different properties.\n\t * @return {{[string: any]: *}}\n\t */\n\tserializeState() {\n\t\tconst keys = Object.keys(this.properties());\n\t\treturn Object.fromEntries(keys.map((key) => [key, this[key]]));\n\t}\n\n\t/**\n\t * This method will be used to restore properties on the element from a previously serialized state.\n\t * You can override this and handle the deserialization differently if the default is not enough.\n\t * @param {{[string: any]: *}} serializedState\n\t */\n\trestoreState(serializedState) {\n\t\tObject.assign(this, serializedState);\n\t}\n}\n\nexport { BaseElement, getClosestParentCustomElementNode, isOfSameNodeType };\n", "import { Store } from './Store.js';\n\n/**\n * @property {CSSStyleSheet[]} cssStyleSheets\n */\nclass GlobalStylesStore extends Store {\n\t/** @type {Map<Node, CSSStyleSheet>} */\n\tglobalStyleSheetsCache = new WeakMap();\n\n\tconstructor() {\n\t\tsuper();\n\t\tif (globalThis.elementJsConfig?.observeGlobalStyles) {\n\t\t\tconst mutationObserver = new MutationObserver((mutationRecord) => {\n\t\t\t\tif (!mutationRecord[0]) return;\n\t\t\t\tconst filteredNodes = Array.from(mutationRecord[0].addedNodes).filter(\n\t\t\t\t\t(node) => node.tagName === 'STYLE' || node.tagName === 'LINK',\n\t\t\t\t);\n\t\t\t\tif (filteredNodes && filteredNodes[0] && filteredNodes[0].tagName === 'LINK') {\n\t\t\t\t\tfilteredNodes[0].onload = () => {\n\t\t\t\t\t\tthis.requestUpdate();\n\t\t\t\t\t};\n\t\t\t\t} else if (filteredNodes && filteredNodes[0] && filteredNodes[0].tagName === 'STYLE') {\n\t\t\t\t\tthis.requestUpdate();\n\t\t\t\t}\n\t\t\t});\n\t\t\tmutationObserver.observe(globalThis.document, { subtree: true, childList: true });\n\t\t}\n\t}\n\n\tgetGlobalStyleSheets(selector) {\n\t\t/** @type {CSSStyleSheet[]}*/\n\t\tconst cssStyleSheets = [];\n\n\t\tif (selector === false) return cssStyleSheets;\n\n\t\tif (typeof selector === 'string') {\n\t\t\tselector = [selector];\n\t\t}\n\n\t\tif (selector === true || selector.includes('document')) {\n\t\t\tcssStyleSheets.push(...globalThis.document?.adoptedStyleSheets);\n\t\t}\n\n\t\tArray.from(globalThis.document?.styleSheets).map((styleSheet) => {\n\t\t\tif (Array.isArray(selector) && !selector.some((cssSelector) => styleSheet.ownerNode.matches(cssSelector))) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// TODO: this will always be null as we never set anything to the cache...\n\t\t\tlet cssStyleSheet = this.globalStyleSheetsCache.get(styleSheet.ownerNode);\n\t\t\tif (!cssStyleSheet) {\n\t\t\t\tcssStyleSheet = new CSSStyleSheet();\n\t\t\t\tlet cssText = '';\n\t\t\t\tif (styleSheet.ownerNode.tagName === 'STYLE') {\n\t\t\t\t\tcssText = styleSheet.ownerNode.textContent;\n\t\t\t\t} else if (styleSheet.ownerNode.tagName === 'LINK') {\n\t\t\t\t\tcssText = Array.from(styleSheet.cssRules)\n\t\t\t\t\t\t.map((rule) => rule.cssText)\n\t\t\t\t\t\t.join('');\n\t\t\t\t}\n\t\t\t\tcssStyleSheet.replaceSync(cssText);\n\t\t\t}\n\t\t\tcssStyleSheets.push(cssStyleSheet);\n\t\t});\n\n\t\treturn cssStyleSheets;\n\t}\n}\n\nexport const globalStylesStore = new GlobalStylesStore();\n", "import { BaseElement } from './BaseElement.js';\nimport { supportsAdoptingStyleSheets, getShadowParentOrBody } from './util/DOMHelper.js';\nimport { globalStylesStore } from './util/GlobalStylesStore.js';\n\n/**\n * Options object for the StyledElement\n * @typedef {Object} StyledElementOptions\n * @extends BaseElementOptions\n * @property {boolean} [shadowRender] - When set to true the element will render the template (if provided) in the Shadow DOM and therefore encapsulate the element and styles from the rest of the document. Default is `false`\n * @property {[]} [styles] - Via the styles option you can add multiple styles/stylesheets to your element. Default is `[]`\n * @property {boolean | string | string[]} [adoptGlobalStyles] - When set to true element-js will look for all style elements in the global document with and apply them before any custom/element styles inside the shadow DOM. Default is `true`.\n */\n\nclass StyledElement extends BaseElement {\n\t/**\n\t * @param {StyledElementOptions} options\n\t */\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tdeferUpdate: false,\n\t\t\tshadowRender: false,\n\t\t\tstyles: [],\n\t\t\tadoptGlobalStyles: true,\n\t\t\t...options,\n\t\t});\n\t\tthis._styles = [...this._options.styles, ...this.styles()];\n\t}\n\n\t/**\n\t * Overrides the `connectedCallback` to adopt optional styles when the element is connected\n\t */\n\tconnectedCallback() {\n\t\tsuper.connectedCallback();\n\n\t\tif (!this.constructor['elementStyleSheets']) {\n\t\t\tthis.constructor['elementStyleSheets'] = this._styles.map((style) => {\n\t\t\t\tconst cssStyleSheet = new CSSStyleSheet();\n\t\t\t\tcssStyleSheet.replaceSync(style);\n\t\t\t\treturn cssStyleSheet;\n\t\t\t});\n\t\t}\n\n\t\tif (supportsAdoptingStyleSheets() && this._options.shadowRender) {\n\t\t\t// adopting does only make sense in shadow dom. Fall back to append for light elements\n\t\t\tthis.adoptStyleSheets();\n\n\t\t\tif (this._options.adoptGlobalStyles !== false) {\n\t\t\t\tglobalStylesStore.subscribe(() => {\n\t\t\t\t\tthis.adoptStyleSheets();\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * The styles method is another way to return a list of styles to be adopted when the element is connected.\n\t * You can either provide a list in the constructor options or return it here.\n\t * @returns {string[]}\n\t */\n\tstyles() {\n\t\treturn [];\n\t}\n\n\t/**\n\t * Overrides the `update` method to adopt optional styles\n\t * @param {PropertyUpdateOptions} options\n\t */\n\tupdate(options) {\n\t\t// We cannot do this in connectedCallback() since the whole template will be overridden in update/render afterward\n\t\tif (!supportsAdoptingStyleSheets() || this._options.shadowRender === false) {\n\t\t\tthis.appendStyleSheets();\n\t\t}\n\t\tsuper.update(options);\n\t}\n\n\t/**\n\t * Adopt stylesheets\n\t */\n\tadoptStyleSheets() {\n\t\tconst adoptGlobalStyleSheets = this._options.shadowRender && this._options.adoptGlobalStyles !== false;\n\n\t\tthis.getRoot().adoptedStyleSheets = [\n\t\t\t...(adoptGlobalStyleSheets ? globalStylesStore.getGlobalStyleSheets(this._options.adoptGlobalStyles) : []),\n\t\t\t...this.constructor['elementStyleSheets'],\n\t\t];\n\t}\n\n\t/**\n\t * Custom polyfill for constructable stylesheets by appending styles to the end of an element\n\t */\n\tappendStyleSheets() {\n\t\tconst parentDocument = getShadowParentOrBody(this.getRoot());\n\n\t\tconst adoptGlobalStyleSheets =\n\t\t\tthis._options.shadowRender && this._options.adoptGlobalStyles !== false && parentDocument !== document.body;\n\n\t\tconst appendableStyles = [\n\t\t\t...(adoptGlobalStyleSheets ? globalStylesStore.getGlobalStyleSheets(this._options.adoptGlobalStyles) : []),\n\t\t\t...this.constructor['elementStyleSheets'],\n\t\t];\n\n\t\tappendableStyles.forEach((styleSheet, index) => {\n\t\t\tconst identifier = this.tagName + index;\n\n\t\t\t// only append stylesheet if not already appended to shadowRoot or document\n\t\t\tif (!parentDocument.querySelector(`#${identifier}`)) {\n\t\t\t\tconst styleElement = globalThis.document?.createElement('style');\n\t\t\t\tstyleElement.id = identifier;\n\t\t\t\tstyleElement.style.display = 'none';\n\t\t\t\tstyleElement.textContent = Array.from(styleSheet.cssRules)\n\t\t\t\t\t.map((rule) => rule.cssText)\n\t\t\t\t\t.join('');\n\t\t\t\tparentDocument.appendChild(styleElement);\n\t\t\t}\n\t\t});\n\t}\n}\n\nexport { StyledElement };\n", "/**\n * @abstract\n */\nexport class Part {\n\tprocessor = undefined;\n\n\t/**\n\t * @abstract\n\t * @param {TemplateResult | any[] | any} value\n\t */\n\tupdate(value) {}\n}\n", "import { Part } from './Part.js';\n\n/**\n * @param {Element} node\n * @param {String} name\n * @param {Boolean} oldValue\n * @return {(function(*): void)|*}\n */\nconst processBooleanAttribute = (node, name, oldValue) => {\n\t// TODO: It would be better if the ?boolean= attribute would not be there in the first place...\n\tnode.removeAttribute(`?${name}`);\n\treturn (newValue) => {\n\t\tconst value = !!newValue?.valueOf() && newValue !== 'false';\n\t\tif (oldValue !== value) {\n\t\t\tnode.toggleAttribute(name, (oldValue = !!value));\n\t\t}\n\t};\n};\n\n/**\n * @param {Element} node\n * @param {String} name\n * @return {(function(*): void)|*}\n */\nconst processPropertyAttribute = (node, name) => {\n\t// TODO: It would be better if the .property= attribute would not be there in the first place...\n\tnode.removeAttribute(`.${name}`);\n\treturn (value) => {\n\t\tnode[name] = value;\n\t};\n};\n\n/**\n * @param {Element} node\n * @param {String} name\n * @return {(function(*): void)|*}\n */\nconst processEventAttribute = (node, name) => {\n\t// TODO: It would be better if the event attribute would not be there in the first place...\n\tnode.removeAttribute(name);\n\n\tlet oldValue = undefined;\n\tlet type = name.startsWith('@') ? name.slice(1) : name.toLowerCase().slice(2);\n\n\treturn (newValue) => {\n\t\tif (oldValue !== newValue) {\n\t\t\tif (oldValue) node.removeEventListener(type, oldValue);\n\t\t\tif ((oldValue = newValue)) node.addEventListener(type, oldValue);\n\t\t}\n\t};\n};\n\n/**\n * @param {Element} node\n * @param {String} name\n * @return {(function(*): void)|*}\n */\nconst processAttribute = (node, name) => {\n\tlet oldValue,\n\t\torphan = true;\n\tconst attributeNode = globalThis.document?.createAttributeNS(null, name);\n\treturn (newValue) => {\n\t\tconst value = newValue?.valueOf();\n\t\tif (oldValue !== value) {\n\t\t\tif ((oldValue = value) == null) {\n\t\t\t\tif (!orphan) {\n\t\t\t\t\tnode.removeAttributeNode(attributeNode);\n\t\t\t\t\torphan = true;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tattributeNode.value = value;\n\t\t\t\tif (orphan) {\n\t\t\t\t\tnode.setAttributeNodeNS(attributeNode);\n\t\t\t\t\torphan = false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n};\n\n/**\n * @param {Element} node\n * @param {String} name\n * @return {(function(*): void)|*}\n */\nexport const processAttributePart = (node, name) => {\n\t// boolean attribute: ?boolean=${...}\n\tif (name.startsWith('?')) {\n\t\treturn processBooleanAttribute(node, name.slice(1), false);\n\t}\n\n\t// property attribute: .property=${...}\n\tif (name.startsWith('.')) {\n\t\treturn processPropertyAttribute(node, name.slice(1));\n\t}\n\n\t// event attribute: @event=${...} || \"old school\" event attribute: onevent=${...}\n\tif (name.startsWith('@') || name.startsWith('on')) {\n\t\treturn processEventAttribute(node, name);\n\t}\n\n\t// normal \"string\" attribute: attribute=${...}\n\treturn processAttribute(node, name);\n};\n\n/**\n * For updating a single attribute\n */\nexport class AttributePart extends Part {\n\tname = undefined;\n\tinterpolations = 1;\n\tvalues = [];\n\tcurrentValueIndex = 0;\n\tinitialValue = undefined;\n\n\t/**\n\t * @param {Node} node\n\t * @param {String} name\n\t * @param {String} initialValue\n\t */\n\tconstructor(node, name, initialValue) {\n\t\tsuper();\n\t\tthis.name = name;\n\t\tthis.initialValue = initialValue;\n\t\tthis.processor = processAttributePart(node.nextElementSibling, this.name);\n\t}\n\n\t/**\n\t * @param {Node} node\n\t */\n\taddNode(node) {\n\t\tthis.interpolations++;\n\t\t// TODO: what about the comment node? It will always be the first for now...\n\t}\n\n\t/**\n\t * @param {string | number | bigint | boolean | undefined | symbol | null} value\n\t */\n\tupdate(value) {\n\t\t// If we only have one sole interpolation, we can just apply the update\n\t\tif (this.initialValue === '\\x03') {\n\t\t\tthis.processor(value);\n\t\t\treturn;\n\t\t}\n\n\t\t// Instead of applying the update immediately, we check if the part has multiple interpolations\n\t\t// and store the values for each interpolation in a list\n\t\tthis.values[this.currentValueIndex++] = value;\n\n\t\t// Only the last call to update (for the last interpolation) will actually trigger the update\n\t\t// on the DOM processor. Here we can reset everything before the next round of updates\n\t\tif (this.interpolations === this.currentValueIndex) {\n\t\t\tthis.currentValueIndex = 0;\n\t\t\tlet replaceIndex = 0;\n\t\t\t// Note: this will coarse the values into strings, but it's probably ok since there can only be multiple values in string attributes?!\n\t\t\tconst parsedValue = this.initialValue.replace(/\\x03/g, () => this.values[replaceIndex++]);\n\t\t\tthis.processor(parsedValue);\n\t\t}\n\t}\n}\n", "import { COMMENT_NODE, ELEMENT_NODE } from '../util/DOMHelper.js';\nimport { Part } from './Part.js';\nimport { TemplateResult } from './TemplateResult.js';\nimport { TemplatePart } from './TemplatePart.js';\n\n/**\n * @param {Node | TemplatePart | any[]} node\n * @return {ChildNode}\n */\nconst removeChildNodes = (node) => {\n\tconst range = globalThis.document?.createRange();\n\tconst firstChild = Array.isArray(node)\n\t\t? node[0]\n\t\t: node instanceof TemplatePart\n\t\t? node.childNodes[0]\n\t\t: node.firstChild;\n\tconst lastChild = Array.isArray(node)\n\t\t? node[node.length - 1]\n\t\t: node instanceof TemplatePart\n\t\t? node.childNodes[node.childNodes.length - 1]\n\t\t: node.lastChild;\n\trange.setStartAfter(firstChild);\n\trange.setEndAfter(lastChild);\n\trange.deleteContents();\n\treturn firstChild;\n};\n\n/**\n * @param {Element} commentNode\n */\nconst removeNodesBetweenComments = (commentNode) => {\n\twhile (commentNode.previousSibling) {\n\t\tif (\n\t\t\tcommentNode.previousSibling.nodeType === COMMENT_NODE &&\n\t\t\tcommentNode.previousSibling.data === commentNode.data.replace('/', '')\n\t\t) {\n\t\t\tbreak;\n\t\t}\n\t\tcommentNode.parentNode.removeChild(commentNode.previousSibling);\n\t}\n};\n\n/**\n * @param {Node} parentNode\n * @param {Node[]} domChildNodes\n * @param {Node[]} templateChildNodes\n * @param {Node} anchorNode\n * @return {Node[]}\n */\nconst diffChildNodes = function (parentNode, domChildNodes, templateChildNodes, anchorNode) {\n\t// Diff each node in the child node lists\n\tlet length = Math.max(templateChildNodes.length, domChildNodes.length);\n\tfor (let index = 0; index < length; index++) {\n\t\tlet domChildNode = domChildNodes[index];\n\t\tlet templateChildNode = templateChildNodes[index];\n\n\t\t// If the DOM node doesn't exist, append/copy the template node\n\t\tif (!domChildNode) {\n\t\t\tif (templateChildNode instanceof TemplatePart) {\n\t\t\t\tanchorNode.before(...templateChildNode.childNodes);\n\t\t\t} else if (typeof templateChildNode === 'object' && 'ELEMENT_NODE' in templateChildNode) {\n\t\t\t\tparentNode.insertBefore(templateChildNode, anchorNode);\n\t\t\t} else {\n\t\t\t\t// TODO: this might not be performant?! Can we maybe handle this in processDomNode?!\n\t\t\t\t// TODO: I think that we need to make ChildNodeParts from all primitive values as well\n\t\t\t\tparentNode.insertBefore(document.createTextNode(templateChildNode), anchorNode);\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the template node doesn't exist, remove the node in the DOM\n\t\tif (!templateChildNode) {\n\t\t\tparentNode.removeChild(removeChildNodes(domChildNode));\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If DOM node is equal to the template node, don't do anything\n\t\t// if (domChildNode.isEqualNode(templateChildNode)) {\n\t\tif (domChildNode === templateChildNode) {\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If node types are not the same, replace the DOM node with the template node\n\t\tif (templateChildNode.nodeType !== domChildNode.nodeType) {\n\t\t\tparentNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the element tag names are not the same, replace the DOM node with the template node\n\t\tif (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName !== domChildNode.tagName) {\n\t\t\tparentNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\n\t\t// If the node is an SVG element, don't even think about diffing it, just replace it\n\t\tif (templateChildNode.nodeType === ELEMENT_NODE && templateChildNode.tagName === 'SVG') {\n\t\t\tparentNode.replaceChild(templateChildNode, domChildNode);\n\t\t\tcontinue;\n\t\t}\n\t}\n\treturn templateChildNodes;\n};\n\n/**\n * @param {Node} comment\n * @param {TemplatePart | any[] | any} initialValue\n * @return {(function(*): void)|*}\n */\nexport const processNodePart = (comment, initialValue) => {\n\tlet nodes = [];\n\tlet oldValue = initialValue instanceof TemplatePart ? [...initialValue.childNodes] : initialValue;\n\t// this is for string values to be inserted into the DOM. A cached TextNode will be used so that we don't have to constantly create new DOM nodes.\n\tlet cachedTextNode = undefined;\n\n\tconst processNodeValue = (newValue) => {\n\t\tswitch (typeof newValue) {\n\t\t\t// primitives are handled as text content\n\t\t\tcase 'string':\n\t\t\tcase 'number':\n\t\t\tcase 'boolean':\n\t\t\t\tif (oldValue !== newValue) {\n\t\t\t\t\toldValue = newValue;\n\t\t\t\t\tif (!cachedTextNode) cachedTextNode = globalThis.document?.createTextNode('');\n\t\t\t\t\tcachedTextNode.data = newValue;\n\n\t\t\t\t\tif (comment.previousSibling?.data === comment.data.replace('/', '')) {\n\t\t\t\t\t\t// the part is empty - we haven't rendered it yet\n\t\t\t\t\t\tcomment.parentNode.insertBefore(cachedTextNode, comment);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// the part was already rendered (either server side or on the client)\n\t\t\t\t\t\tcomment.previousSibling.data = newValue;\n\t\t\t\t\t}\n\n\t\t\t\t\tnodes = [cachedTextNode];\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t// null (= typeof \"object\") and undefined are used to clean up previous content\n\t\t\tcase 'object':\n\t\t\tcase 'undefined':\n\t\t\t\tif (newValue === null || newValue === undefined) {\n\t\t\t\t\tif (oldValue !== newValue) {\n\t\t\t\t\t\toldValue = newValue;\n\t\t\t\t\t\tremoveNodesBetweenComments(comment);\n\t\t\t\t\t\tnodes = [];\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (Array.isArray(newValue)) {\n\t\t\t\t\tif (newValue.length === 0) {\n\t\t\t\t\t\tremoveNodesBetweenComments(comment);\n\t\t\t\t\t\tnodes = [];\n\t\t\t\t\t} else {\n\t\t\t\t\t\tnodes = diffChildNodes(comment.parentNode, oldValue || [], newValue, comment);\n\t\t\t\t\t}\n\t\t\t\t\toldValue = newValue;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// if the new value is a node or a fragment, and it's different from the live node, then it's diffed.\n\t\t\t\tif (oldValue !== newValue) {\n\t\t\t\t\tif ('ELEMENT_NODE' in newValue) {\n\t\t\t\t\t\toldValue = newValue;\n\t\t\t\t\t\tnodes = diffChildNodes(comment.parentNode, nodes, [newValue], comment);\n\t\t\t\t\t} else if (newValue instanceof TemplatePart) {\n\t\t\t\t\t\toldValue = newValue;\n\t\t\t\t\t\tnodes = diffChildNodes(comment.parentNode, nodes, [...newValue.childNodes], comment);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.warn('Could not process value', newValue);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tcase 'function':\n\t\t\t\tprocessNodeValue(newValue(comment));\n\t\t\t\tbreak;\n\t\t}\n\t};\n\n\treturn processNodeValue;\n};\n\n/**\n * For updating a text node, a sequence of child nodes or an array of `any` values\n */\nexport class ChildNodePart extends Part {\n\t/** @type {Node | undefined} */\n\tstartNode = undefined;\n\n\t/** @type {Node | undefined} */\n\tendNode = undefined;\n\n\t// TODO: this is only for array values\n\t/** @type {Part[]} */\n\tparts = [];\n\n\t// TODO: this is only for TemplatePart values\n\ttemplatePart = undefined;\n\n\t// TODO: maybe we can store a generic vale|parsedValue that can be either parts[] | templatePart | any\n\n\t/** @type {Node[]} */\n\tchildNodes = [];\n\n\t/**\n\t * @param {Node} startNode - the start comment marker node\n\t * @param {any | any[]} value\n\t */\n\tconstructor(startNode, value) {\n\t\tif (startNode && startNode?.nodeType !== COMMENT_NODE) {\n\t\t\tthrow new Error('ChildNodePart: startNode is not a comment node');\n\t\t}\n\n\t\tsuper();\n\n\t\tlet serverSideRendered = false;\n\t\tif (startNode) {\n\t\t\tconst placeholder = startNode.data;\n\t\t\tconst childNodes = [startNode];\n\t\t\tlet childNode = startNode.nextSibling;\n\t\t\twhile (childNode && childNode.data !== `/${placeholder}`) {\n\t\t\t\tchildNodes.push(childNode);\n\t\t\t\tchildNode = childNode.nextSibling;\n\t\t\t}\n\n\t\t\tconst endNode = childNode;\n\t\t\tchildNodes.push(endNode);\n\n\t\t\t// if not SSRed, childNodes will only ever have two comment nodes, the start and the end marker\n\t\t\tif (childNodes.length > 2) {\n\t\t\t\tserverSideRendered = true;\n\t\t\t}\n\n\t\t\tthis.childNodes = childNodes;\n\t\t\tthis.startNode = startNode;\n\t\t\tthis.endNode = endNode;\n\t\t}\n\n\t\t// value can become array | TemplatePart | any\n\t\tconst initialValue = this.parseValue(value);\n\n\t\tif (this.endNode) {\n\t\t\tthis.processor = processNodePart(this.endNode, serverSideRendered ? initialValue : undefined);\n\t\t}\n\n\t\tif (!serverSideRendered) {\n\t\t\tif (value instanceof TemplateResult || Array.isArray(value)) {\n\t\t\t\tthis.updateParts(value);\n\t\t\t}\n\n\t\t\t// We need a childNodes list that is NOT live so that we don't lose elements when they get removed from the dom and we can (re)add them back in later.\n\t\t\tthis.childNodes = [...this.childNodes];\n\t\t\tthis.processor?.(initialValue);\n\t\t}\n\t}\n\n\t/**\n\t * @param {any} value\n\t * @return {*}\n\t */\n\tupdate(value) {\n\t\tconst parsedValue = this.parseValue(value);\n\n\t\tif (value instanceof TemplateResult || Array.isArray(value)) {\n\t\t\tthis.updateParts(value);\n\t\t}\n\n\t\tthis.processor?.(parsedValue);\n\t}\n\n\t/**\n\t * @param {TemplateResult | any[]} value\n\t */\n\tupdateParts(value) {\n\t\tif (value instanceof TemplateResult) {\n\t\t\tthis.templatePart.update(value);\n\t\t}\n\t\tif (Array.isArray(value)) {\n\t\t\tfor (let index = 0; index < value.length; index++) {\n\t\t\t\tthis.parts[index]?.update(value[index]);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * @param {TemplateResult | any[] | any} value\n\t * @return {TemplatePart | any[] | any}\n\t */\n\tparseValue(value) {\n\t\tif (value instanceof TemplateResult) {\n\t\t\tif (!this.templatePart) {\n\t\t\t\tconst templatePartCommentNodes = this.childNodes?.filter(\n\t\t\t\t\t(node) => node && node.nodeType === COMMENT_NODE && node.data === 'template-part',\n\t\t\t\t);\n\t\t\t\tconst startNode = templatePartCommentNodes[0];\n\t\t\t\tthis.templatePart = new TemplatePart(startNode, value);\n\t\t\t}\n\t\t\treturn this.templatePart;\n\t\t}\n\t\tif (Array.isArray(value)) {\n\t\t\treturn this.parseArray(value);\n\t\t}\n\t\treturn value;\n\t}\n\n\t/**\n\t * Nested TemplateResults values need to be unrolled in order for update functions to be able to process them\n\t * @param {any[]} values\n\t * @return {any[]}\n\t */\n\tparseArray(values) {\n\t\tconst parsedValues = [];\n\t\tfor (let index = 0; index < values.length; index++) {\n\t\t\tlet value = values[index];\n\n\t\t\tif (value instanceof TemplateResult) {\n\t\t\t\tlet templatePart = this.parts[index];\n\t\t\t\tif (!templatePart) {\n\t\t\t\t\tconst templatePartCommentNodes = this.childNodes?.filter(\n\t\t\t\t\t\t(node) => node && node.nodeType === COMMENT_NODE && node.data === 'template-part',\n\t\t\t\t\t);\n\t\t\t\t\tconst startNode = templatePartCommentNodes[index];\n\t\t\t\t\ttemplatePart = new TemplatePart(startNode, value);\n\t\t\t\t\tthis.parts[index] = templatePart;\n\t\t\t\t}\n\t\t\t\tparsedValues[index] = templatePart;\n\t\t\t} else if (Array.isArray(value)) {\n\t\t\t\tlet childNodePart = this.parts[index];\n\t\t\t\tif (!childNodePart) {\n\t\t\t\t\t// TODO: this seems not correct :(\n\t\t\t\t\tconst templatePartCommentNodes = this.childNodes?.filter(\n\t\t\t\t\t\t(node) => node && node.nodeType === COMMENT_NODE && node.data === 'template-part',\n\t\t\t\t\t);\n\t\t\t\t\tconst startNode = templatePartCommentNodes[index];\n\t\t\t\t\tchildNodePart = new ChildNodePart(startNode, value);\n\t\t\t\t\tthis.parts[index] = childNodePart;\n\t\t\t\t}\n\t\t\t\tparsedValues[index] = childNodePart;\n\t\t\t} else {\n\t\t\t\tparsedValues[index] = typeof value === 'function' ? value() : value;\n\t\t\t}\n\t\t}\n\n\t\treturn parsedValues;\n\t}\n}\n", "import { Part } from './Part.js';\nimport { isObjectLike } from '../util/AttributeParser.js';\n\n/**\n * For updating a directive on a node\n */\nexport class NodePart extends Part {\n\t/** @type {Node} */\n\tnode = undefined;\n\n\t/** @type {Directive} */\n\tdirective = undefined;\n\n\t/**\n\t * @param {Node} node\n\t * @param {() => {}} initialValue\n\t */\n\tconstructor(node, initialValue) {\n\t\tif (!isObjectLike(initialValue) && !initialValue.directiveClass) {\n\t\t\tthrow new Error(\n\t\t\t\t'NodePart: value is not a wrapped directive function. You must wrap you custom directive class with the defineDirective function.',\n\t\t\t);\n\t\t}\n\t\tsuper();\n\t\tthis.node = node.nextElementSibling;\n\t\tconst { directiveClass, values } = initialValue;\n\t\tthis.directive = new directiveClass(node.nextElementSibling);\n\t}\n\n\t/**\n\t * @param {() => {}} value\n\t */\n\tupdate(value) {\n\t\tconst { directiveClass, values } = value;\n\t\tthis.directive.update(...values);\n\t}\n}\n", "import { COMMENT_NODE, convertStringToTemplate } from '../util/DOMHelper.js';\nimport { Part } from './Part.js';\nimport { TemplateResult } from './TemplateResult.js';\nimport { AttributePart } from './AttributePart.js';\nimport { ChildNodePart } from './ChildNodePart.js';\nimport { NodePart } from './NodePart.js';\n\n/** @type {Map<TemplateStringsArray, Part[]>} */\nconst partsCache = new WeakMap();\n\n/** @type {Map<TemplateStringsArray, DocumentFragment>} */\nconst fragmentsCache = new WeakMap();\n\nexport class TemplatePart extends Part {\n\t/** @type {Part[]} */\n\tparts = [];\n\n\t/** @type {TemplateStringsArray} */\n\tstrings = undefined;\n\n\t/** @type {Node[]} */\n\tchildNodes = [];\n\n\t/**\n\t * @param {Node} startNode - the start comment marker node\n\t * @param {TemplateResult} value\n\t */\n\tconstructor(startNode, value) {\n\t\tif (startNode && startNode?.nodeType !== COMMENT_NODE) {\n\t\t\tthrow new Error('TemplatePart: startNode is not a comment node');\n\t\t}\n\n\t\tsuper();\n\n\t\tlet serverSideRendered = false;\n\t\tif (startNode) {\n\t\t\tconst placeholder = startNode.data;\n\t\t\tconst childNodes = [startNode];\n\t\t\tlet childNode = startNode.nextSibling;\n\t\t\twhile (childNode && childNode.data !== `/${placeholder}`) {\n\t\t\t\tchildNodes.push(childNode);\n\t\t\t\tchildNode = childNode.nextSibling;\n\t\t\t}\n\n\t\t\tconst endNode = childNode;\n\t\t\tchildNodes.push(endNode);\n\n\t\t\t// if not SSRed, childNodes will only ever have two comment nodes, the start and the end marker\n\t\t\tif (childNodes.length > 2) {\n\t\t\t\tserverSideRendered = true;\n\t\t\t\tthis.childNodes = childNodes;\n\t\t\t}\n\t\t}\n\n\t\tthis.parseValue(value);\n\n\t\tif (!serverSideRendered) {\n\t\t\tthis.updateParts(value.values);\n\t\t\t// We need a childNodes list that is NOT live so that we don't loose elements when they get removed from the dom and we can (re)add them back in later.\n\t\t\tthis.childNodes = [...this.childNodes];\n\t\t}\n\t}\n\n\t/**\n\t * @param {TemplateResult} value\n\t */\n\tupdate(value) {\n\t\tthis.parseValue(value);\n\t\tthis.updateParts(value.values);\n\t}\n\n\t/**\n\t * @param {any[]} values\n\t */\n\tupdateParts(values) {\n\t\tfor (let index = 0; index < values.length; index++) {\n\t\t\tthis.parts[index]?.update(values[index]);\n\t\t}\n\t}\n\n\t/**\n\t * @param {TemplateResult} templateResult\n\t */\n\tparseValue(templateResult) {\n\t\tif (this.strings !== templateResult.strings) {\n\t\t\tif (this.childNodes.length === 0) {\n\t\t\t\tlet fragment = fragmentsCache.get(templateResult.strings);\n\t\t\t\tif (!fragment) {\n\t\t\t\t\tfragment = this.parseFragment(templateResult);\n\t\t\t\t\tfragmentsCache.set(templateResult.strings, fragment);\n\t\t\t\t}\n\t\t\t\tconst importedFragment = globalThis.document?.importNode(fragment, true);\n\t\t\t\tthis.childNodes = importedFragment.childNodes;\n\t\t\t}\n\n\t\t\tlet parts = partsCache.get(templateResult.strings);\n\t\t\tif (!parts) {\n\t\t\t\tparts = templateResult.parseParts(this.childNodes);\n\t\t\t\tpartsCache.set(templateResult.strings, parts);\n\t\t\t}\n\n\t\t\t/** @type AttributePart */\n\t\t\tlet previousAttributePart = undefined;\n\t\t\tthis.parts = parts.map((part, index) => {\n\t\t\t\t// We currently need the path because the fragment will be cloned via importNode and therefore the node will be a different one\n\t\t\t\tconst node = part.path.reduceRight(({ childNodes }, i) => childNodes[i], this);\n\n\t\t\t\tif (part.type === 'node') {\n\t\t\t\t\treturn new ChildNodePart(node, templateResult.values[index]);\n\t\t\t\t\t// TODO: the nodes in the parts array also have nested parts information... could we start creating the nested parts here as well?\n\t\t\t\t}\n\t\t\t\tif (part.type === 'attribute') {\n\t\t\t\t\t// If we have multiple attribute parts with the same name, it means we have multiple\n\t\t\t\t\t// interpolations inside that attribute. Instead of creating a new part, we will return the same\n\t\t\t\t\t// as before and let it defer the update until the last interpolation gets updated\n\t\t\t\t\tif (previousAttributePart && previousAttributePart.name === part.name) {\n\t\t\t\t\t\tpreviousAttributePart.addNode(node);\n\t\t\t\t\t\treturn previousAttributePart;\n\t\t\t\t\t}\n\t\t\t\t\treturn (previousAttributePart = new AttributePart(node, part.name, part.initialValue));\n\t\t\t\t}\n\t\t\t\tif (part.type === 'directive') {\n\t\t\t\t\treturn new NodePart(node, templateResult.values[index]);\n\t\t\t\t}\n\n\t\t\t\tthrow `cannot map part: ${part}`;\n\t\t\t});\n\t\t\tthis.strings = templateResult.strings;\n\t\t}\n\t}\n\n\t/**\n\t * @param {TemplateResult} templateResult\n\t * @return {DocumentFragment}\n\t */\n\tparseFragment(templateResult) {\n\t\tconst templateString = templateResult.templateString;\n\t\treturn convertStringToTemplate(templateString);\n\t}\n}\n", "import { COMMENT_NODE, getNodePath } from '../util/DOMHelper';\nimport { encodeAttribute, isObjectLike } from '../util/AttributeParser.js';\nimport { TemplatePart } from './TemplatePart.js';\n\nconst voidElements = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;\nconst elements = /<([a-z]+[a-z0-9:._-]*)([^>]*?)(\\/?)>/g;\n// TODO: v this will not match any values with escaped quotes like onClick='console.log(\"\\'test\")'\nconst attributes = /([^\\s]*)=((?:\")[^\"]*(?:\")|(?:')[^']*(?:')|[^\\s\\/>]*)|([^\\s\\/>]*)/g;\nconst partPositions = /[\\x01\\x02]/g;\n// \\x01 Node.ELEMENT_NODE\n// \\x02 Node.ATTRIBUTE_NODE\n// \\x03 COMMENT.ATTRIBUTE_TOKEN\n// \\x04 Node.ATTRIBUTE_TOKEN\n\nconst interpolation = new RegExp(`(<!--dom-part-(\\\\d+)--><!--/dom-part-(\\\\d+)-->|(\\\\S\\\\w+)=\"\\x04(\")?|\\x04)`, 'g');\n\n/**\n * Given a template, find part positions as both nodes and attributes and\n * return a string with placeholders as either comment nodes or named attributes.\n * @param {TemplateStringsArray | string[]} templateStrings a template literal tag array\n * @param {string} attributePlaceholders replace placeholders inside attribute values with this value\n * @returns {string} X/HTML with prefixed comments or attributes\n */\nexport const createTemplateString = (templateStrings, attributePlaceholders = '') => {\n\t// TODO: make it easier to identify attribute and node parts for SSR and leave the comments at those positions to be replaced in toString()\n\tlet partIndex = 0;\n\t// join all interpolations (for values) with a special placeholder and remove any whitespace\n\tlet template = templateStrings.join('\\x01').trim();\n\t// find (match) all elements to identify their attributes\n\ttemplate = template.replace(elements, (_, name, attributesString, trailingSlash) => {\n\t\tlet elementTagWithAttributes = name + attributesString.replaceAll('\\x01', attributePlaceholders).trimEnd();\n\t\tif (trailingSlash.length) elementTagWithAttributes += voidElements.test(name) ? ' /' : '></' + name;\n\t\t// collect all attribute parts so that we can place matching comment nodes\n\t\tconst attributeParts = attributesString.replace(attributes, (attribute, name, valueWithQuotes, directive) => {\n\t\t\tif (directive) {\n\t\t\t\treturn `<!--\\x02$-->`;\n\t\t\t}\n\n\t\t\t// remove quotes from attribute value to normalize the value\n\t\t\tconst value =\n\t\t\t\tvalueWithQuotes?.startsWith('\"') || valueWithQuotes?.startsWith(\"'\")\n\t\t\t\t\t? valueWithQuotes.slice(1, -1)\n\t\t\t\t\t: valueWithQuotes;\n\t\t\tconst partsCount = (attribute.match(/\\x01/g) || []).length;\n\t\t\tconst parts = [];\n\t\t\tfor (let index = 0; index < partsCount; index++) {\n\t\t\t\tparts.push(`<!--\\x02:${name}=${value.replaceAll('\\x01', '\\x03')}-->`);\n\t\t\t}\n\t\t\treturn parts.join('');\n\t\t});\n\t\treturn `\n\t\t\t\t${attributesString.includes('\\x01') ? attributeParts : ''}\n\t\t\t\t<${elementTagWithAttributes}>\n\t\t\t`;\n\t});\n\t// replace interpolation placeholders with our indexed markers\n\ttemplate = template.replace(partPositions, (partPosition) => {\n\t\tif (partPosition === '\\x01') {\n\t\t\treturn `<!--dom-part-${partIndex}--><!--/dom-part-${partIndex++}-->`;\n\t\t}\n\t\tif (partPosition === '\\x02') {\n\t\t\treturn `dom-part-${partIndex++}`;\n\t\t}\n\t});\n\treturn `\n\t\t<!--template-part-->\n\t\t${template}\n\t\t<!--/template-part-->\n\t`;\n\t// TODO: ^ this is actually important because of the whitespace\n};\n\n/**\n * @param {String} name\n * @param {any} value\n * @param {Boolean} isSingleValue\n * @return {String}\n */\nconst attribute = (name, value, isSingleValue = true) => {\n\treturn ` ${name}=\"${encodeAttribute(isObjectLike(value) ? JSON.stringify(value) : value)}${\n\t\tisSingleValue ? '\"' : ''\n\t}`;\n};\n\n/**\n * @param {any} value\n * @return {String}\n */\nconst getValue = (value) => {\n\tswitch (typeof value) {\n\t\tcase 'string':\n\t\t\treturn encodeAttribute(value);\n\t\tcase 'boolean':\n\t\tcase 'number':\n\t\t\treturn String(value);\n\t\tcase 'object':\n\t\t\tswitch (true) {\n\t\t\t\tcase Array.isArray(value):\n\t\t\t\t\treturn value.map(getValue).join('');\n\t\t\t\tcase value instanceof TemplateResult:\n\t\t\t\t\treturn value.toString();\n\t\t\t}\n\t\t\tbreak;\n\t\tcase 'function':\n\t\t\treturn getValue(value());\n\t}\n\treturn value == null ? '' : encodeAttribute(String(value));\n};\n\n/** @type {Map<TemplateStringsArray, *[]>} */\nconst parsedUpdates = new WeakMap();\n\n/** @type {Map<Element, TemplatePart>} */\nconst templateParts = new WeakMap();\n\nexport class TemplateResult {\n\t/**\n\t * @param {TemplateStringsArray} strings\n\t * @param {any[]} values\n\t */\n\tconstructor(strings, ...values) {\n\t\tthis.strings = strings;\n\t\tthis.values = values;\n\t}\n\n\t/**\n\t * @param {Element} domNode\n\t */\n\trenderInto(domNode) {\n\t\tlet serverSideRendered = false;\n\t\tlet templatePart = templateParts.get(domNode);\n\t\tif (!templatePart) {\n\t\t\tconst startNode = Array.from(domNode.childNodes)\n\t\t\t\t.filter((node) => node.nodeType === COMMENT_NODE)\n\t\t\t\t.find((node) => node.data === 'template-part');\n\n\t\t\tserverSideRendered = startNode !== undefined;\n\n\t\t\ttemplatePart = new TemplatePart(startNode, this);\n\t\t\ttemplateParts.set(domNode, templatePart);\n\n\t\t\tif (!serverSideRendered) {\n\t\t\t\tdomNode.replaceChildren(...templatePart.childNodes);\n\t\t\t}\n\t\t} else {\n\t\t\ttemplatePart.update(this);\n\t\t}\n\t}\n\n\t/**\n\t * @param {String[]} strings\n\t * @return {(() => String)[]}\n\t */\n\tparse(strings) {\n\t\tconst html = createTemplateString(strings, '\\x04');\n\t\tconst parts = [];\n\t\tlet i = 0;\n\t\tlet match = null;\n\t\twhile ((match = interpolation.exec(html))) {\n\t\t\tconst pre = html.slice(i, match.index);\n\t\t\ti = match.index + match[0].length;\n\t\t\tif (match[2]) {\n\t\t\t\t// ChildNodePart\n\t\t\t\tconst index = match[2];\n\t\t\t\tparts.push((value) => `${pre}<!--dom-part-${index}-->${getValue(value)}<!--/dom-part-${index}-->`);\n\t\t\t} else if (match[4]) {\n\t\t\t\t// AttributePart with single interpolation or the first interpolation right after the attribute=\n\t\t\t\tconst isSingleValue = match[5] !== undefined;\n\t\t\t\tlet name = match[4];\n\t\t\t\tswitch (true) {\n\t\t\t\t\tcase name[0] === '?':\n\t\t\t\t\t\tconst booleanName = name.slice(1).toLowerCase();\n\t\t\t\t\t\tparts.push((value) => {\n\t\t\t\t\t\t\tif (!value) return '';\n\t\t\t\t\t\t\treturn `${pre} ${booleanName}=\"\"`;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase name[0] === '.':\n\t\t\t\t\t\tconst lower = name.slice(1).toLowerCase();\n\t\t\t\t\t\tparts.push((value) => {\n\t\t\t\t\t\t\tlet result = pre;\n\t\t\t\t\t\t\t// null, undefined, and false are not shown at all\n\t\t\t\t\t\t\tif (value === null || value === undefined || value === '') {\n\t\t\t\t\t\t\t\tresult += attribute(lower, '');\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// in all other cases, just escape it in quotes\n\t\t\t\t\t\t\t\tresult += attribute(lower, value, isSingleValue);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase name[0] === '@':\n\t\t\t\t\t\tname = 'on' + name.slice(1);\n\t\t\t\t\tcase name[0] === 'o' && name[1] === 'n':\n\t\t\t\t\t\tparts.push((value) => {\n\t\t\t\t\t\t\treturn pre;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tparts.push((value) => {\n\t\t\t\t\t\t\tlet result = pre;\n\t\t\t\t\t\t\tif (value != null) {\n\t\t\t\t\t\t\t\tresult += attribute(name, value, isSingleValue);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn result;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\t// AttributePart in the middle of an attribute value or NodePart\n\t\t\t\tparts.push((value) => {\n\t\t\t\t\tlet result = pre;\n\t\t\t\t\t// TODO: we currently cannot distinguish between NodeParts and AttributeParts before\n\t\t\t\t\tif (isObjectLike(value) && value.directiveClass) {\n\t\t\t\t\t\t// NodePart\n\t\t\t\t\t\tconst directive = new value.directiveClass();\n\t\t\t\t\t\tresult += directive.stringify(...value.values);\n\t\t\t\t\t} else if (value != null) {\n\t\t\t\t\t\tresult += encodeAttribute(isObjectLike(value) ? JSON.stringify(value) : value);\n\t\t\t\t\t}\n\t\t\t\t\treturn result;\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\t// We couldn't correctly parse parts from the template\n\t\tif (parts.length !== strings.length - 1) {\n\t\t\tthrow {\n\t\t\t\tname: 'ParseTemplateError',\n\t\t\t\tmessage: 'Could not parse parts from template correctly. Parts length has not the expected length.',\n\t\t\t\tstrings,\n\t\t\t\ttemplateString: html,\n\t\t\t\tparts,\n\t\t\t};\n\t\t}\n\n\t\tif (parts.length) {\n\t\t\tconst last = parts[parts.length - 1];\n\t\t\tconst chunk = html.slice(i);\n\t\t\tparts[parts.length - 1] = (value) => last(value) + chunk;\n\t\t} else {\n\t\t\tparts.push(() => html);\n\t\t}\n\t\treturn parts;\n\t}\n\n\t/**\n\t * @param {Node[]} childNodes\n\t * @return {object[]}\n\t */\n\tparseParts(childNodes) {\n\t\t// we always create a template fragment so that we can start at the root for traversing the node path\n\t\tconst range = globalThis.document?.createRange();\n\t\trange.setStartBefore(childNodes[0]);\n\t\trange.setEndAfter(childNodes[childNodes.length - 1]);\n\t\tconst template = range.cloneContents();\n\n\t\tconst treeWalker = globalThis.document?.createTreeWalker(template, 128);\n\t\tlet node = treeWalker.currentNode;\n\n\t\t// this is kinda freaky because the tree walker is shared throughout the recursion - but YOLO\n\t\tconst getParts = () => {\n\t\t\tconst parts = [];\n\t\t\tlet currentPart = undefined;\n\t\t\t// search for parts through numbered comment nodes with placeholders\n\t\t\twhile ((node = treeWalker.nextNode())) {\n\t\t\t\tif (/^template-part$/.test(node.data) && currentPart) {\n\t\t\t\t\t// start recursion -> add nested parts to previous part\n\t\t\t\t\tcurrentPart.parts = getParts();\n\t\t\t\t}\n\t\t\t\tif (/^\\/template-part$/.test(node.data)) {\n\t\t\t\t\t// end recursion\n\t\t\t\t\treturn parts;\n\t\t\t\t}\n\t\t\t\tif (/^dom-part-\\d+$/.test(node.data)) {\n\t\t\t\t\tparts.push((currentPart = { type: 'node', path: getNodePath(node), parts: [] }));\n\t\t\t\t}\n\t\t\t\tif (/^dom-part-\\d+:/.test(node.data)) {\n\t\t\t\t\tconst [_, attribute] = node.data.split(':');\n\t\t\t\t\tconst [name, initialValue] = attribute.split('=');\n\t\t\t\t\tcurrentPart = undefined;\n\t\t\t\t\tparts.push({ type: 'attribute', path: getNodePath(node), name: name, initialValue });\n\t\t\t\t}\n\t\t\t\tif (/^dom-part-\\d+\\$/.test(node.data)) {\n\t\t\t\t\tcurrentPart = undefined;\n\t\t\t\t\tparts.push({ type: 'directive', path: getNodePath(node) });\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn parts;\n\t\t};\n\n\t\tconst parts = getParts();\n\n\t\t// We couldn't correctly parse parts from the template\n\t\tif (parts.length !== this.strings.length - 1) {\n\t\t\tthrow {\n\t\t\t\tname: 'ParseTemplateError',\n\t\t\t\tmessage:\n\t\t\t\t\t'Could not parse parts from template correctly. Parts length has not the expected length. -> ' +\n\t\t\t\t\tJSON.stringify({\n\t\t\t\t\t\tstrings: this.strings,\n\t\t\t\t\t\ttemplateString: this.templateString,\n\t\t\t\t\t\tchildNodes,\n\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\tparts,\n\t\t\t\t\t}),\n\t\t\t};\n\t\t}\n\n\t\treturn parts;\n\t}\n\n\t/**\n\t * find interpolations in the given template for nodes and attributes and\n\t * return a string with placeholders as either comment nodes or named attributes.\n\t * @returns {string} template with tagged placeholders for values\n\t */\n\tget templateString() {\n\t\treturn createTemplateString(this.strings);\n\t}\n\n\ttoString() {\n\t\tlet updates = parsedUpdates.get(this.strings);\n\n\t\tif (!updates) {\n\t\t\tupdates = this.parse(this.strings);\n\t\t\tparsedUpdates.set(this.strings, updates);\n\t\t}\n\n\t\treturn this.values.length ? this.values.map((value, index) => updates[index](value)).join('') : updates[0]();\n\t}\n}\n", "import { TemplateResult } from './TemplateResult';\n\n/**\n * @param {TemplateStringsArray} strings\n * @param {any[]} values\n * @return {TemplateResult}\n */\nconst html = function (strings, ...values) {\n\treturn new TemplateResult(strings, ...values);\n};\n\nexport { html };\n", "/**\n * Render a template string into the given DOM node\n * @param {TemplateResult | string} template\n * @param {Element} domNode\n */\nconst render = (template, domNode) => {\n\ttemplate.renderInto(domNode);\n};\n\nexport { render };\n", "import { StyledElement } from './StyledElement.js';\nimport { html } from './dom-parts/html.js';\nimport { render } from './dom-parts/render.js';\n\n/**\n * Options object for the TemplateElement\n * @typedef {Object} TemplateElementOptions\n * @extends StyledElementOptions\n */\n\nclass TemplateElement extends StyledElement {\n\t/**\n\t * @param {TemplateElementOptions} options\n\t */\n\tconstructor(options) {\n\t\tsuper({\n\t\t\tdeferUpdate: false,\n\t\t\tshadowRender: false,\n\t\t\tstyles: [],\n\t\t\tadoptGlobalStyles: true,\n\t\t\tmutationObserverOptions: {\n\t\t\t\tchildList: false,\n\t\t\t},\n\t\t\t...options,\n\t\t});\n\t\tthis._template = this._options.template;\n\n\t\tif (this._options.shadowRender) this.attachShadow({ mode: 'open' });\n\t}\n\n\t/**\n\t * The template method should be overridden in extending elements and return the template to be rendered to the root\n\t * @returns {TemplateResult}\n\t */\n\ttemplate() {\n\t\treturn html``;\n\t}\n\n\t/**\n\t * Override update method to render the template to the root\n\t * @param {PropertyUpdateOptions} options\n\t */\n\tupdate(options) {\n\t\tthis.renderTemplate();\n\t\tsuper.update(options);\n\t}\n\n\t/**\n\t * Render the template to the root\n\t */\n\trenderTemplate() {\n\t\tconst template = this._template || this.template();\n\t\tif (typeof template === 'string') {\n\t\t\t// just a plain string literal. no lit-html required\n\t\t\tthis.getRoot().innerHTML = `${template}`;\n\t\t} else {\n\t\t\trender(template, this.getRoot());\n\t\t}\n\t}\n\n\t/**\n\t * Get the root element - either the element or the shadow root\n\t * @returns {ShadowRoot | HTMLElement}\n\t */\n\tgetRoot() {\n\t\treturn this.shadowRoot !== null ? this.shadowRoot : this;\n\t}\n}\n\nexport { TemplateElement, html, render };\n", "export class Directive {\n\t/** @type {Element} */\n\tnode = undefined;\n\n\t/**\n\t * @param {Node} node\n\t */\n\tconstructor(node) {\n\t\tthis.node = node;\n\t}\n\n\t/**\n\t * @abstract\n\t */\n\tupdate() {}\n\n\t// TODO: this is somewhat custom... maybe we could set the initial values in the constructor and then simply override the default toString() method?!\n\t/**\n\t * Implement the stringify method and return a string for rendering the directive in SSR mode\n\t * @param {...any} values\n\t * @returns {string}\n\t */\n\tstringify(...values) {\n\t\treturn '';\n\t}\n}\n\n/**\n * @param {Class<Directive>} directiveClass\n */\nexport const defineDirective = (directiveClass) => {\n\treturn (...values) => {\n\t\treturn { directiveClass, values };\n\t};\n};\n"],
5
- "mappings": ";;;;;;;;AAKO,SAAS,aAAa,OAAO;AACnC,SAAO,OAAO,SAAS,YAAY,UAAU;AAC9C;AAOO,SAAS,OAAO,OAAO;AAC7B,MAAI;AACH,WAAO,KAAK,MAAM,KAAK,KAAK,CAAC,CAAC;AAAA,EAC/B,SAAS,GAAP;AACD,WAAO;AAAA,EACR;AACD;AAOO,SAAS,UAAU,OAAO;AAChC,SAAO,UAAU,UAAU,UAAU;AACtC;AAOO,SAAS,aAAa,OAAO;AACnC,SAAO,UAAU;AA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", "attribute", "name", "html", "parts"]
7
- }