tildefriends/apps/cory/ssb/lit-all.min.js.map

1 line
296 KiB
Plaintext

{"version":3,"file":"lit-all.min.js","sources":["lit-all.min.js/reactive-element/src/css-tag.ts","lit-all.min.js/reactive-element/src/reactive-element.ts","lit-all.min.js/lit-html/src/lit-html.ts","lit-all.min.js/lit-element/src/lit-element.ts","lit-all.min.js/lit-html/src/is-server.ts","lit-all.min.js/lit-html/src/directive-helpers.ts","lit-all.min.js/lit-html/src/directive.ts","lit-all.min.js/lit-html/src/async-directive.ts","lit-all.min.js/lit-html/src/directives/private-async-helpers.ts","lit-all.min.js/lit-html/src/directives/async-replace.ts","lit-all.min.js/lit-html/src/directives/async-append.ts","lit-all.min.js/lit-html/src/directives/cache.ts","lit-all.min.js/lit-html/src/directives/choose.ts","lit-all.min.js/lit-html/src/directives/class-map.ts","lit-all.min.js/lit-html/src/directives/guard.ts","lit-all.min.js/lit-html/src/directives/if-defined.ts","lit-all.min.js/lit-html/src/directives/join.ts","lit-all.min.js/lit-html/src/directives/keyed.ts","lit-all.min.js/lit-html/src/directives/live.ts","lit-all.min.js/lit-html/src/directives/map.ts","lit-all.min.js/lit-html/src/directives/range.ts","lit-all.min.js/lit-html/src/directives/ref.ts","lit-all.min.js/lit-html/src/directives/repeat.ts","lit-all.min.js/lit-html/src/directives/style-map.ts","lit-all.min.js/lit-html/src/directives/template-content.ts","lit-all.min.js/lit-html/src/directives/unsafe-html.ts","lit-all.min.js/lit-html/src/directives/unsafe-svg.ts","lit-all.min.js/lit-html/src/directives/until.ts","lit-all.min.js/lit-html/src/directives/when.ts","lit-all.min.js/lit-html/src/static.ts","lit-all.min.js/lit/src/index.all.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2019 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nconst NODE_MODE = false;\nconst global = NODE_MODE ? globalThis : window;\n\n/**\n * Whether the current browser supports `adoptedStyleSheets`.\n */\nexport const supportsAdoptingStyleSheets =\n global.ShadowRoot &&\n (global.ShadyCSS === undefined || global.ShadyCSS.nativeShadow) &&\n 'adoptedStyleSheets' in Document.prototype &&\n 'replace' in CSSStyleSheet.prototype;\n\n/**\n * A CSSResult or native CSSStyleSheet.\n *\n * In browsers that support constructible CSS style sheets, CSSStyleSheet\n * object can be used for styling along side CSSResult from the `css`\n * template tag.\n */\nexport type CSSResultOrNative = CSSResult | CSSStyleSheet;\n\nexport type CSSResultArray = Array<CSSResultOrNative | CSSResultArray>;\n\n/**\n * A single CSSResult, CSSStyleSheet, or an array or nested arrays of those.\n */\nexport type CSSResultGroup = CSSResultOrNative | CSSResultArray;\n\nconst constructionToken = Symbol();\n\nconst cssTagCache = new WeakMap<TemplateStringsArray, CSSStyleSheet>();\n\n/**\n * A container for a string of CSS text, that may be used to create a CSSStyleSheet.\n *\n * CSSResult is the return value of `css`-tagged template literals and\n * `unsafeCSS()`. In order to ensure that CSSResults are only created via the\n * `css` tag and `unsafeCSS()`, CSSResult cannot be constructed directly.\n */\nexport class CSSResult {\n // This property needs to remain unminified.\n ['_$cssResult$'] = true;\n readonly cssText: string;\n private _styleSheet?: CSSStyleSheet;\n private _strings: TemplateStringsArray | undefined;\n\n private constructor(\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ) {\n if (safeToken !== constructionToken) {\n throw new Error(\n 'CSSResult is not constructable. Use `unsafeCSS` or `css` instead.'\n );\n }\n this.cssText = cssText;\n this._strings = strings;\n }\n\n // This is a getter so that it's lazy. In practice, this means stylesheets\n // are not created until the first element instance is made.\n get styleSheet(): CSSStyleSheet | undefined {\n // If `supportsAdoptingStyleSheets` is true then we assume CSSStyleSheet is\n // constructable.\n let styleSheet = this._styleSheet;\n const strings = this._strings;\n if (supportsAdoptingStyleSheets && styleSheet === undefined) {\n const cacheable = strings !== undefined && strings.length === 1;\n if (cacheable) {\n styleSheet = cssTagCache.get(strings);\n }\n if (styleSheet === undefined) {\n (this._styleSheet = styleSheet = new CSSStyleSheet()).replaceSync(\n this.cssText\n );\n if (cacheable) {\n cssTagCache.set(strings, styleSheet);\n }\n }\n }\n return styleSheet;\n }\n\n toString(): string {\n return this.cssText;\n }\n}\n\ntype ConstructableCSSResult = CSSResult & {\n new (\n cssText: string,\n strings: TemplateStringsArray | undefined,\n safeToken: symbol\n ): CSSResult;\n};\n\nconst textFromCSSResult = (value: CSSResultGroup | number) => {\n // This property needs to remain unminified.\n if ((value as CSSResult)['_$cssResult$'] === true) {\n return (value as CSSResult).cssText;\n } else if (typeof value === 'number') {\n return value;\n } else {\n throw new Error(\n `Value passed to 'css' function must be a 'css' function result: ` +\n `${value}. Use 'unsafeCSS' to pass non-literal values, but take care ` +\n `to ensure page security.`\n );\n }\n};\n\n/**\n * Wrap a value for interpolation in a {@linkcode css} tagged template literal.\n *\n * This is unsafe because untrusted CSS text can be used to phone home\n * or exfiltrate data to an attacker controlled site. Take care to only use\n * this with trusted input.\n */\nexport const unsafeCSS = (value: unknown) =>\n new (CSSResult as ConstructableCSSResult)(\n typeof value === 'string' ? value : String(value),\n undefined,\n constructionToken\n );\n\n/**\n * A template literal tag which can be used with LitElement's\n * {@linkcode LitElement.styles} property to set element styles.\n *\n * For security reasons, only literal string values and number may be used in\n * embedded expressions. To incorporate non-literal values {@linkcode unsafeCSS}\n * may be used inside an expression.\n */\nexport const css = (\n strings: TemplateStringsArray,\n ...values: (CSSResultGroup | number)[]\n): CSSResult => {\n const cssText =\n strings.length === 1\n ? strings[0]\n : values.reduce(\n (acc, v, idx) => acc + textFromCSSResult(v) + strings[idx + 1],\n strings[0]\n );\n return new (CSSResult as ConstructableCSSResult)(\n cssText,\n strings,\n constructionToken\n );\n};\n\n/**\n * Applies the given styles to a `shadowRoot`. When Shadow DOM is\n * available but `adoptedStyleSheets` is not, styles are appended to the\n * `shadowRoot` to [mimic spec behavior](https://wicg.github.io/construct-stylesheets/#using-constructed-stylesheets).\n * Note, when shimming is used, any styles that are subsequently placed into\n * the shadowRoot should be placed *before* any shimmed adopted styles. This\n * will match spec behavior that gives adopted sheets precedence over styles in\n * shadowRoot.\n */\nexport const adoptStyles = (\n renderRoot: ShadowRoot,\n styles: Array<CSSResultOrNative>\n) => {\n if (supportsAdoptingStyleSheets) {\n (renderRoot as ShadowRoot).adoptedStyleSheets = styles.map((s) =>\n s instanceof CSSStyleSheet ? s : s.styleSheet!\n );\n } else {\n styles.forEach((s) => {\n const style = document.createElement('style');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const nonce = (global as any)['litNonce'];\n if (nonce !== undefined) {\n style.setAttribute('nonce', nonce);\n }\n style.textContent = (s as CSSResult).cssText;\n renderRoot.appendChild(style);\n });\n }\n};\n\nconst cssResultFromStyleSheet = (sheet: CSSStyleSheet) => {\n let cssText = '';\n for (const rule of sheet.cssRules) {\n cssText += rule.cssText;\n }\n return unsafeCSS(cssText);\n};\n\nexport const getCompatibleStyle =\n supportsAdoptingStyleSheets ||\n (NODE_MODE && global.CSSStyleSheet === undefined)\n ? (s: CSSResultOrNative) => s\n : (s: CSSResultOrNative) =>\n s instanceof CSSStyleSheet ? cssResultFromStyleSheet(s) : s;\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Use this module if you want to create your own base class extending\n * {@link ReactiveElement}.\n * @packageDocumentation\n */\n\nimport {\n getCompatibleStyle,\n adoptStyles,\n CSSResultGroup,\n CSSResultOrNative,\n} from './css-tag.js';\nimport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\n// In the Node build, this import will be injected by Rollup:\n// import {HTMLElement, customElements} from '@lit-labs/ssr-dom-shim';\n\nexport * from './css-tag.js';\nexport type {\n ReactiveController,\n ReactiveControllerHost,\n} from './reactive-controller.js';\n\nconst NODE_MODE = false;\nconst global = NODE_MODE ? globalThis : window;\n\nif (NODE_MODE) {\n global.customElements ??= customElements;\n}\n\nconst DEV_MODE = true;\n\nlet requestUpdateThenable: (name: string) => {\n then: (\n onfulfilled?: (value: boolean) => void,\n _onrejected?: () => void\n ) => void;\n};\n\nlet issueWarning: (code: string, warning: string) => void;\n\nconst trustedTypes = (global as unknown as {trustedTypes?: {emptyScript: ''}})\n .trustedTypes;\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nconst polyfillSupport = DEV_MODE\n ? global.reactiveElementPolyfillSupportDevMode\n : global.reactiveElementPolyfillSupport;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> = (global.litIssuedWarnings ??=\n new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n\n // Issue polyfill support warning.\n if (global.ShadyDOM?.inUse && polyfillSupport === undefined) {\n issueWarning(\n 'polyfill-support-missing',\n `Shadow DOM is being polyfilled via \\`ShadyDOM\\` but ` +\n `the \\`polyfill-support\\` module has not been loaded.`\n );\n }\n\n requestUpdateThenable = (name) => ({\n then: (\n onfulfilled?: (value: boolean) => void,\n _onrejected?: () => void\n ) => {\n issueWarning(\n 'request-update-promise',\n `The \\`requestUpdate\\` method should no longer return a Promise but ` +\n `does so on \\`${name}\\`. Use \\`updateComplete\\` instead.`\n );\n if (onfulfilled !== undefined) {\n onfulfilled(false);\n }\n },\n });\n}\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace ReactiveUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry = Update;\n export interface Update {\n kind: 'update';\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: ReactiveUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<ReactiveUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n\n/*\n * When using Closure Compiler, JSCompiler_renameProperty(property, object) is\n * replaced at compile time by the munged name for object[property]. We cannot\n * alias this function, so we have to use a small shim that has the same\n * behavior when not compiling.\n */\n/*@__INLINE__*/\nconst JSCompiler_renameProperty = <P extends PropertyKey>(\n prop: P,\n _obj: unknown\n): P => prop;\n\n/**\n * Converts property values to and from attribute values.\n */\nexport interface ComplexAttributeConverter<Type = unknown, TypeHint = unknown> {\n /**\n * Called to convert an attribute value to a property\n * value.\n */\n fromAttribute?(value: string | null, type?: TypeHint): Type;\n\n /**\n * Called to convert a property value to an attribute\n * value.\n *\n * It returns unknown instead of string, to be compatible with\n * https://github.com/WICG/trusted-types (and similar efforts).\n */\n toAttribute?(value: Type, type?: TypeHint): unknown;\n}\n\ntype AttributeConverter<Type = unknown, TypeHint = unknown> =\n | ComplexAttributeConverter<Type>\n | ((value: string | null, type?: TypeHint) => Type);\n\n/**\n * Defines options for a property accessor.\n */\nexport interface PropertyDeclaration<Type = unknown, TypeHint = unknown> {\n /**\n * When set to `true`, indicates the property is internal private state. The\n * property should not be set by users. When using TypeScript, this property\n * should be marked as `private` or `protected`, and it is also a common\n * practice to use a leading `_` in the name. The property is not added to\n * `observedAttributes`.\n */\n readonly state?: boolean;\n\n /**\n * Indicates how and whether the property becomes an observed attribute.\n * If the value is `false`, the property is not added to `observedAttributes`.\n * If true or absent, the lowercased property name is observed (e.g. `fooBar`\n * becomes `foobar`). If a string, the string value is observed (e.g\n * `attribute: 'foo-bar'`).\n */\n readonly attribute?: boolean | string;\n\n /**\n * Indicates the type of the property. This is used only as a hint for the\n * `converter` to determine how to convert the attribute\n * to/from a property.\n */\n readonly type?: TypeHint;\n\n /**\n * Indicates how to convert the attribute to/from a property. If this value\n * is a function, it is used to convert the attribute value a the property\n * value. If it's an object, it can have keys for `fromAttribute` and\n * `toAttribute`. If no `toAttribute` function is provided and\n * `reflect` is set to `true`, the property value is set directly to the\n * attribute. A default `converter` is used if none is provided; it supports\n * `Boolean`, `String`, `Number`, `Object`, and `Array`. Note,\n * when a property changes and the converter is used to update the attribute,\n * the property is never updated again as a result of the attribute changing,\n * and vice versa.\n */\n readonly converter?: AttributeConverter<Type, TypeHint>;\n\n /**\n * Indicates if the property should reflect to an attribute.\n * If `true`, when the property is set, the attribute is set using the\n * attribute name determined according to the rules for the `attribute`\n * property option and the value of the property converted using the rules\n * from the `converter` property option.\n */\n readonly reflect?: boolean;\n\n /**\n * A function that indicates if a property should be considered changed when\n * it is set. The function should take the `newValue` and `oldValue` and\n * return `true` if an update should be requested.\n */\n hasChanged?(value: Type, oldValue: Type): boolean;\n\n /**\n * Indicates whether an accessor will be created for this property. By\n * default, an accessor will be generated for this property that requests an\n * update when set. If this flag is `true`, no accessor will be created, and\n * it will be the user's responsibility to call\n * `this.requestUpdate(propertyName, oldValue)` to request an update when\n * the property changes.\n */\n readonly noAccessor?: boolean;\n}\n\n/**\n * Map of properties to PropertyDeclaration options. For each property an\n * accessor is made, and the property is processed according to the\n * PropertyDeclaration options.\n */\nexport interface PropertyDeclarations {\n readonly [key: string]: PropertyDeclaration;\n}\n\ntype PropertyDeclarationMap = Map<PropertyKey, PropertyDeclaration>;\n\ntype AttributeMap = Map<string, PropertyKey>;\n\n/**\n * A Map of property keys to values.\n *\n * Takes an optional type parameter T, which when specified as a non-any,\n * non-unknown type, will make the Map more strongly-typed, associating the map\n * keys with their corresponding value type on T.\n *\n * Use `PropertyValues<this>` when overriding ReactiveElement.update() and\n * other lifecycle methods in order to get stronger type-checking on keys\n * and values.\n */\n// This type is conditional so that if the parameter T is not specified, or\n// is `any`, the type will include `Map<PropertyKey, unknown>`. Since T is not\n// given in the uses of PropertyValues in this file, all uses here fallback to\n// meaning `Map<PropertyKey, unknown>`, but if a developer uses\n// `PropertyValues<this>` (or any other value for T) they will get a\n// strongly-typed Map type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type PropertyValues<T = any> = T extends object\n ? PropertyValueMap<T>\n : Map<PropertyKey, unknown>;\n\n/**\n * Do not use, instead prefer {@linkcode PropertyValues}.\n */\n// This type must be exported such that JavaScript generated by the Google\n// Closure Compiler can import a type reference.\nexport interface PropertyValueMap<T> extends Map<PropertyKey, unknown> {\n get<K extends keyof T>(k: K): T[K];\n set<K extends keyof T>(key: K, value: T[K]): this;\n has<K extends keyof T>(k: K): boolean;\n delete<K extends keyof T>(k: K): boolean;\n}\n\nexport const defaultConverter: ComplexAttributeConverter = {\n toAttribute(value: unknown, type?: unknown): unknown {\n switch (type) {\n case Boolean:\n value = value ? emptyStringForBooleanAttribute : null;\n break;\n case Object:\n case Array:\n // if the value is `null` or `undefined` pass this through\n // to allow removing/no change behavior.\n value = value == null ? value : JSON.stringify(value);\n break;\n }\n return value;\n },\n\n fromAttribute(value: string | null, type?: unknown) {\n let fromValue: unknown = value;\n switch (type) {\n case Boolean:\n fromValue = value !== null;\n break;\n case Number:\n fromValue = value === null ? null : Number(value);\n break;\n case Object:\n case Array:\n // Do *not* generate exception when invalid JSON is set as elements\n // don't normally complain on being mis-configured.\n // TODO(sorvell): Do generate exception in *dev mode*.\n try {\n // Assert to adhere to Bazel's \"must type assert JSON parse\" rule.\n fromValue = JSON.parse(value!) as unknown;\n } catch (e) {\n fromValue = null;\n }\n break;\n }\n return fromValue;\n },\n};\n\nexport interface HasChanged {\n (value: unknown, old: unknown): boolean;\n}\n\n/**\n * Change function that returns true if `value` is different from `oldValue`.\n * This method is used as the default for a property's `hasChanged` function.\n */\nexport const notEqual: HasChanged = (value: unknown, old: unknown): boolean => {\n // This ensures (old==NaN, value==NaN) always returns false\n return old !== value && (old === old || value === value);\n};\n\nconst defaultPropertyDeclaration: PropertyDeclaration = {\n attribute: true,\n type: String,\n converter: defaultConverter,\n reflect: false,\n hasChanged: notEqual,\n};\n\n/**\n * The Closure JS Compiler doesn't currently have good support for static\n * property semantics where \"this\" is dynamic (e.g.\n * https://github.com/google/closure-compiler/issues/3177 and others) so we use\n * this hack to bypass any rewriting by the compiler.\n */\nconst finalized = 'finalized';\n\n/**\n * A string representing one of the supported dev mode warning categories.\n */\nexport type WarningKind = 'change-in-update' | 'migration';\n\nexport type Initializer = (element: ReactiveElement) => void;\n\n/**\n * Base element class which manages element properties and attributes. When\n * properties change, the `update` method is asynchronously called. This method\n * should be supplied by subclassers to render updates as desired.\n * @noInheritDoc\n */\nexport abstract class ReactiveElement\n // In the Node build, this `extends` clause will be substituted with\n // `(globalThis.HTMLElement ?? HTMLElement)`.\n //\n // This way, we will first prefer any global `HTMLElement` polyfill that the\n // user has assigned, and then fall back to the `HTMLElement` shim which has\n // been imported (see note at the top of this file about how this import is\n // generated by Rollup). Note that the `HTMLElement` variable has been\n // shadowed by this import, so it no longer refers to the global.\n extends HTMLElement\n implements ReactiveControllerHost\n{\n // Note: these are patched in only in DEV_MODE.\n /**\n * Read or set all the enabled warning categories for this class.\n *\n * This property is only used in development builds.\n *\n * @nocollapse\n * @category dev-mode\n */\n static enabledWarnings?: WarningKind[];\n\n /**\n * Enable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Enable for all ReactiveElement subclasses\n * ReactiveElement.enableWarning?.('migration');\n *\n * // Enable for only MyElement and subclasses\n * MyElement.enableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static enableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Disable the given warning category for this class.\n *\n * This method only exists in development builds, so it should be accessed\n * with a guard like:\n *\n * ```ts\n * // Disable for all ReactiveElement subclasses\n * ReactiveElement.disableWarning?.('migration');\n *\n * // Disable for only MyElement and subclasses\n * MyElement.disableWarning?.('migration');\n * ```\n *\n * @nocollapse\n * @category dev-mode\n */\n static disableWarning?: (warningKind: WarningKind) => void;\n\n /**\n * Adds an initializer function to the class that is called during instance\n * construction.\n *\n * This is useful for code that runs against a `ReactiveElement`\n * subclass, such as a decorator, that needs to do work for each\n * instance, such as setting up a `ReactiveController`.\n *\n * ```ts\n * const myDecorator = (target: typeof ReactiveElement, key: string) => {\n * target.addInitializer((instance: ReactiveElement) => {\n * // This is run during construction of the element\n * new MyController(instance);\n * });\n * }\n * ```\n *\n * Decorating a field will then cause each instance to run an initializer\n * that adds a controller:\n *\n * ```ts\n * class MyElement extends LitElement {\n * @myDecorator foo;\n * }\n * ```\n *\n * Initializers are stored per-constructor. Adding an initializer to a\n * subclass does not add it to a superclass. Since initializers are run in\n * constructors, initializers will run in order of the class hierarchy,\n * starting with superclasses and progressing to the instance's class.\n *\n * @nocollapse\n */\n static addInitializer(initializer: Initializer) {\n this.finalize();\n (this._initializers ??= []).push(initializer);\n }\n\n static _initializers?: Initializer[];\n\n /*\n * Due to closure compiler ES6 compilation bugs, @nocollapse is required on\n * all static methods and properties with initializers. Reference:\n * - https://github.com/google/closure-compiler/issues/1776\n */\n\n /**\n * Maps attribute names to properties; for example `foobar` attribute to\n * `fooBar` property. Created lazily on user subclasses when finalizing the\n * class.\n * @nocollapse\n */\n private static __attributeToPropertyMap: AttributeMap;\n\n /**\n * Marks class as having finished creating properties.\n */\n protected static [finalized] = true;\n\n /**\n * Memoized list of all element properties, including any superclass properties.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category properties\n */\n static elementProperties: PropertyDeclarationMap = new Map();\n\n /**\n * User-supplied object that maps property names to `PropertyDeclaration`\n * objects containing options for configuring reactive properties. When\n * a reactive property is set the element will update and render.\n *\n * By default properties are public fields, and as such, they should be\n * considered as primarily settable by element users, either via attribute or\n * the property itself.\n *\n * Generally, properties that are changed by the element should be private or\n * protected fields and should use the `state: true` option. Properties\n * marked as `state` do not reflect from the corresponding attribute\n *\n * However, sometimes element code does need to set a public property. This\n * should typically only be done in response to user interaction, and an event\n * should be fired informing the user; for example, a checkbox sets its\n * `checked` property when clicked and fires a `changed` event. Mutating\n * public properties should typically not be done for non-primitive (object or\n * array) properties. In other cases when an element needs to manage state, a\n * private property set with the `state: true` option should be used. When\n * needed, state properties can be initialized via public properties to\n * facilitate complex interactions.\n * @nocollapse\n * @category properties\n */\n static properties: PropertyDeclarations;\n\n /**\n * Memoized list of all element styles.\n * Created lazily on user subclasses when finalizing the class.\n * @nocollapse\n * @category styles\n */\n static elementStyles: Array<CSSResultOrNative> = [];\n\n /**\n * Array of styles to apply to the element. The styles should be defined\n * using the {@linkcode css} tag function, via constructible stylesheets, or\n * imported from native CSS module scripts.\n *\n * Note on Content Security Policy:\n *\n * Element styles are implemented with `<style>` tags when the browser doesn't\n * support adopted StyleSheets. To use such `<style>` tags with the style-src\n * CSP directive, the style-src value must either include 'unsafe-inline' or\n * `nonce-<base64-value>` with `<base64-value>` replaced be a server-generated\n * nonce.\n *\n * To provide a nonce to use on generated `<style>` elements, set\n * `window.litNonce` to a server-generated nonce in your page's HTML, before\n * loading application code:\n *\n * ```html\n * <script>\n * // Generated and unique per request:\n * window.litNonce = 'a1b2c3d4';\n * </script>\n * ```\n * @nocollapse\n * @category styles\n */\n static styles?: CSSResultGroup;\n\n /**\n * The set of properties defined by this class that caused an accessor to be\n * added during `createProperty`.\n * @nocollapse\n */\n private static __reactivePropertyKeys?: Set<PropertyKey>;\n\n /**\n * Returns a list of attributes corresponding to the registered properties.\n * @nocollapse\n * @category attributes\n */\n static get observedAttributes() {\n // note: piggy backing on this to ensure we're finalized.\n this.finalize();\n const attributes: string[] = [];\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n this.elementProperties.forEach((v, p) => {\n const attr = this.__attributeNameForProperty(p, v);\n if (attr !== undefined) {\n this.__attributeToPropertyMap.set(attr, p);\n attributes.push(attr);\n }\n });\n return attributes;\n }\n\n /**\n * Creates a property accessor on the element prototype if one does not exist\n * and stores a {@linkcode PropertyDeclaration} for the property with the\n * given options. The property setter calls the property's `hasChanged`\n * property option or uses a strict identity check to determine whether or not\n * to request an update.\n *\n * This method may be overridden to customize properties; however,\n * when doing so, it's important to call `super.createProperty` to ensure\n * the property is setup correctly. This method calls\n * `getPropertyDescriptor` internally to get a descriptor to install.\n * To customize what properties do when they are get or set, override\n * `getPropertyDescriptor`. To customize the options for a property,\n * implement `createProperty` like this:\n *\n * ```ts\n * static createProperty(name, options) {\n * options = Object.assign(options, {myOption: true});\n * super.createProperty(name, options);\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n static createProperty(\n name: PropertyKey,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n // if this is a state property, force the attribute to false.\n if (options.state) {\n // Cast as any since this is readonly.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (options as any).attribute = false;\n }\n // Note, since this can be called by the `@property` decorator which\n // is called before `finalize`, we ensure finalization has been kicked off.\n this.finalize();\n this.elementProperties.set(name, options);\n // Do not generate an accessor if the prototype already has one, since\n // it would be lost otherwise and that would never be the user's intention;\n // Instead, we expect users to call `requestUpdate` themselves from\n // user-defined accessors. Note that if the super has an accessor we will\n // still overwrite it\n if (!options.noAccessor && !this.prototype.hasOwnProperty(name)) {\n const key = typeof name === 'symbol' ? Symbol() : `__${name}`;\n const descriptor = this.getPropertyDescriptor(name, key, options);\n if (descriptor !== undefined) {\n Object.defineProperty(this.prototype, name, descriptor);\n if (DEV_MODE) {\n // If this class doesn't have its own set, create one and initialize\n // with the values in the set from the nearest ancestor class, if any.\n if (!this.hasOwnProperty('__reactivePropertyKeys')) {\n this.__reactivePropertyKeys = new Set(\n this.__reactivePropertyKeys ?? []\n );\n }\n this.__reactivePropertyKeys!.add(name);\n }\n }\n }\n }\n\n /**\n * Returns a property descriptor to be defined on the given named property.\n * If no descriptor is returned, the property will not become an accessor.\n * For example,\n *\n * ```ts\n * class MyElement extends LitElement {\n * static getPropertyDescriptor(name, key, options) {\n * const defaultDescriptor =\n * super.getPropertyDescriptor(name, key, options);\n * const setter = defaultDescriptor.set;\n * return {\n * get: defaultDescriptor.get,\n * set(value) {\n * setter.call(this, value);\n * // custom action.\n * },\n * configurable: true,\n * enumerable: true\n * }\n * }\n * }\n * ```\n *\n * @nocollapse\n * @category properties\n */\n protected static getPropertyDescriptor(\n name: PropertyKey,\n key: string | symbol,\n options: PropertyDeclaration\n ): PropertyDescriptor | undefined {\n return {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n get(): any {\n return (this as {[key: string]: unknown})[key as string];\n },\n set(this: ReactiveElement, value: unknown) {\n const oldValue = (this as {} as {[key: string]: unknown})[\n name as string\n ];\n (this as {} as {[key: string]: unknown})[key as string] = value;\n (this as unknown as ReactiveElement).requestUpdate(\n name,\n oldValue,\n options\n );\n },\n configurable: true,\n enumerable: true,\n };\n }\n\n /**\n * Returns the property options associated with the given property.\n * These options are defined with a `PropertyDeclaration` via the `properties`\n * object or the `@property` decorator and are registered in\n * `createProperty(...)`.\n *\n * Note, this method should be considered \"final\" and not overridden. To\n * customize the options for a given property, override\n * {@linkcode createProperty}.\n *\n * @nocollapse\n * @final\n * @category properties\n */\n static getPropertyOptions(name: PropertyKey) {\n return this.elementProperties.get(name) || defaultPropertyDeclaration;\n }\n\n /**\n * Creates property accessors for registered properties, sets up element\n * styling, and ensures any superclasses are also finalized. Returns true if\n * the element was finalized.\n * @nocollapse\n */\n protected static finalize() {\n if (this.hasOwnProperty(finalized)) {\n return false;\n }\n this[finalized] = true;\n // finalize any superclasses\n const superCtor = Object.getPrototypeOf(this) as typeof ReactiveElement;\n superCtor.finalize();\n // Create own set of initializers for this class if any exist on the\n // superclass and copy them down. Note, for a small perf boost, avoid\n // creating initializers unless needed.\n if (superCtor._initializers !== undefined) {\n this._initializers = [...superCtor._initializers];\n }\n this.elementProperties = new Map(superCtor.elementProperties);\n // initialize Map populated in observedAttributes\n this.__attributeToPropertyMap = new Map();\n // make any properties\n // Note, only process \"own\" properties since this element will inherit\n // any properties defined on the superClass, and finalization ensures\n // the entire prototype chain is finalized.\n if (this.hasOwnProperty(JSCompiler_renameProperty('properties', this))) {\n const props = this.properties;\n // support symbols in properties (IE11 does not support this)\n const propKeys = [\n ...Object.getOwnPropertyNames(props),\n ...Object.getOwnPropertySymbols(props),\n ];\n // This for/of is ok because propKeys is an array\n for (const p of propKeys) {\n // note, use of `any` is due to TypeScript lack of support for symbol in\n // index types\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.createProperty(p, (props as any)[p]);\n }\n }\n this.elementStyles = this.finalizeStyles(this.styles);\n // DEV mode warnings\n if (DEV_MODE) {\n const warnRemovedOrRenamed = (name: string, renamed = false) => {\n if (this.prototype.hasOwnProperty(name)) {\n issueWarning(\n renamed ? 'renamed-api' : 'removed-api',\n `\\`${name}\\` is implemented on class ${this.name}. It ` +\n `has been ${renamed ? 'renamed' : 'removed'} ` +\n `in this version of LitElement.`\n );\n }\n };\n warnRemovedOrRenamed('initialize');\n warnRemovedOrRenamed('requestUpdateInternal');\n warnRemovedOrRenamed('_getUpdateComplete', true);\n }\n return true;\n }\n\n /**\n * Options used when calling `attachShadow`. Set this property to customize\n * the options for the shadowRoot; for example, to create a closed\n * shadowRoot: `{mode: 'closed'}`.\n *\n * Note, these options are used in `createRenderRoot`. If this method\n * is customized, options should be respected if possible.\n * @nocollapse\n * @category rendering\n */\n static shadowRootOptions: ShadowRootInit = {mode: 'open'};\n\n /**\n * Takes the styles the user supplied via the `static styles` property and\n * returns the array of styles to apply to the element.\n * Override this method to integrate into a style management system.\n *\n * Styles are deduplicated preserving the _last_ instance in the list. This\n * is a performance optimization to avoid duplicated styles that can occur\n * especially when composing via subclassing. The last item is kept to try\n * to preserve the cascade order with the assumption that it's most important\n * that last added styles override previous styles.\n *\n * @nocollapse\n * @category styles\n */\n protected static finalizeStyles(\n styles?: CSSResultGroup\n ): Array<CSSResultOrNative> {\n const elementStyles = [];\n if (Array.isArray(styles)) {\n // Dedupe the flattened array in reverse order to preserve the last items.\n // Casting to Array<unknown> works around TS error that\n // appears to come from trying to flatten a type CSSResultArray.\n const set = new Set((styles as Array<unknown>).flat(Infinity).reverse());\n // Then preserve original order by adding the set items in reverse order.\n for (const s of set) {\n elementStyles.unshift(getCompatibleStyle(s as CSSResultOrNative));\n }\n } else if (styles !== undefined) {\n elementStyles.push(getCompatibleStyle(styles));\n }\n return elementStyles;\n }\n\n /**\n * Node or ShadowRoot into which element DOM should be rendered. Defaults\n * to an open shadowRoot.\n * @category rendering\n */\n readonly renderRoot!: HTMLElement | ShadowRoot;\n\n /**\n * Returns the property name for the given attribute `name`.\n * @nocollapse\n */\n private static __attributeNameForProperty(\n name: PropertyKey,\n options: PropertyDeclaration\n ) {\n const attribute = options.attribute;\n return attribute === false\n ? undefined\n : typeof attribute === 'string'\n ? attribute\n : typeof name === 'string'\n ? name.toLowerCase()\n : undefined;\n }\n\n private __instanceProperties?: PropertyValues = new Map();\n // Initialize to an unresolved Promise so we can make sure the element has\n // connected before first update.\n private __updatePromise!: Promise<boolean>;\n\n /**\n * True if there is a pending update as a result of calling `requestUpdate()`.\n * Should only be read.\n * @category updates\n */\n isUpdatePending = false;\n\n /**\n * Is set to `true` after the first update. The element code cannot assume\n * that `renderRoot` exists before the element `hasUpdated`.\n * @category updates\n */\n hasUpdated = false;\n\n /**\n * Map with keys for any properties that have changed since the last\n * update cycle with previous values.\n *\n * @internal\n */\n _$changedProperties!: PropertyValues;\n\n /**\n * Map with keys of properties that should be reflected when updated.\n */\n private __reflectingProperties?: Map<PropertyKey, PropertyDeclaration>;\n\n /**\n * Name of currently reflecting property\n */\n private __reflectingProperty: PropertyKey | null = null;\n\n /**\n * Set of controllers.\n */\n private __controllers?: ReactiveController[];\n\n constructor() {\n super();\n this._initialize();\n }\n\n /**\n * Internal only override point for customizing work done when elements\n * are constructed.\n *\n * @internal\n */\n _initialize() {\n this.__updatePromise = new Promise<boolean>(\n (res) => (this.enableUpdating = res)\n );\n this._$changedProperties = new Map();\n this.__saveInstanceProperties();\n // ensures first update will be caught by an early access of\n // `updateComplete`\n this.requestUpdate();\n (this.constructor as typeof ReactiveElement)._initializers?.forEach((i) =>\n i(this)\n );\n }\n\n /**\n * Registers a `ReactiveController` to participate in the element's reactive\n * update cycle. The element automatically calls into any registered\n * controllers during its lifecycle callbacks.\n *\n * If the element is connected when `addController()` is called, the\n * controller's `hostConnected()` callback will be immediately called.\n * @category controllers\n */\n addController(controller: ReactiveController) {\n (this.__controllers ??= []).push(controller);\n // If a controller is added after the element has been connected,\n // call hostConnected. Note, re-using existence of `renderRoot` here\n // (which is set in connectedCallback) to avoid the need to track a\n // first connected state.\n if (this.renderRoot !== undefined && this.isConnected) {\n controller.hostConnected?.();\n }\n }\n\n /**\n * Removes a `ReactiveController` from the element.\n * @category controllers\n */\n removeController(controller: ReactiveController) {\n // Note, if the indexOf is -1, the >>> will flip the sign which makes the\n // splice do nothing.\n this.__controllers?.splice(this.__controllers.indexOf(controller) >>> 0, 1);\n }\n\n /**\n * Fixes any properties set on the instance before upgrade time.\n * Otherwise these would shadow the accessor and break these properties.\n * The properties are stored in a Map which is played back after the\n * constructor runs. Note, on very old versions of Safari (<=9) or Chrome\n * (<=41), properties created for native platform properties like (`id` or\n * `name`) may not have default values set in the element constructor. On\n * these browsers native properties appear on instances and therefore their\n * default value will overwrite any element default (e.g. if the element sets\n * this.id = 'id' in the constructor, the 'id' will become '' since this is\n * the native platform default).\n */\n private __saveInstanceProperties() {\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n (this.constructor as typeof ReactiveElement).elementProperties.forEach(\n (_v, p) => {\n if (this.hasOwnProperty(p)) {\n this.__instanceProperties!.set(p, this[p as keyof this]);\n delete this[p as keyof this];\n }\n }\n );\n }\n\n /**\n * Returns the node into which the element should render and by default\n * creates and returns an open shadowRoot. Implement to customize where the\n * element's DOM is rendered. For example, to render into the element's\n * childNodes, return `this`.\n *\n * @return Returns a node into which to render.\n * @category rendering\n */\n protected createRenderRoot(): Element | ShadowRoot {\n const renderRoot =\n this.shadowRoot ??\n this.attachShadow(\n (this.constructor as typeof ReactiveElement).shadowRootOptions\n );\n adoptStyles(\n renderRoot,\n (this.constructor as typeof ReactiveElement).elementStyles\n );\n return renderRoot;\n }\n\n /**\n * On first connection, creates the element's renderRoot, sets up\n * element styling, and enables updating.\n * @category lifecycle\n */\n connectedCallback() {\n // create renderRoot before first update.\n if (this.renderRoot === undefined) {\n (\n this as {\n renderRoot: Element | DocumentFragment;\n }\n ).renderRoot = this.createRenderRoot();\n }\n this.enableUpdating(true);\n this.__controllers?.forEach((c) => c.hostConnected?.());\n }\n\n /**\n * Note, this method should be considered final and not overridden. It is\n * overridden on the element instance with a function that triggers the first\n * update.\n * @category updates\n */\n protected enableUpdating(_requestedUpdate: boolean) {}\n\n /**\n * Allows for `super.disconnectedCallback()` in extensions while\n * reserving the possibility of making non-breaking feature additions\n * when disconnecting at some point in the future.\n * @category lifecycle\n */\n disconnectedCallback() {\n this.__controllers?.forEach((c) => c.hostDisconnected?.());\n }\n\n /**\n * Synchronizes property values when attributes change.\n *\n * Specifically, when an attribute is set, the corresponding property is set.\n * You should rarely need to implement this callback. If this method is\n * overridden, `super.attributeChangedCallback(name, _old, value)` must be\n * called.\n *\n * See [using the lifecycle callbacks](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks)\n * on MDN for more information about the `attributeChangedCallback`.\n * @category attributes\n */\n attributeChangedCallback(\n name: string,\n _old: string | null,\n value: string | null\n ) {\n this._$attributeToProperty(name, value);\n }\n\n private __propertyToAttribute(\n name: PropertyKey,\n value: unknown,\n options: PropertyDeclaration = defaultPropertyDeclaration\n ) {\n const attr = (\n this.constructor as typeof ReactiveElement\n ).__attributeNameForProperty(name, options);\n if (attr !== undefined && options.reflect === true) {\n const converter =\n (options.converter as ComplexAttributeConverter)?.toAttribute !==\n undefined\n ? (options.converter as ComplexAttributeConverter)\n : defaultConverter;\n const attrValue = converter.toAttribute!(value, options.type);\n if (\n DEV_MODE &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.indexOf(\n 'migration'\n ) >= 0 &&\n attrValue === undefined\n ) {\n issueWarning(\n 'undefined-attribute-value',\n `The attribute value for the ${name as string} property is ` +\n `undefined on element ${this.localName}. The attribute will be ` +\n `removed, but in the previous version of \\`ReactiveElement\\`, ` +\n `the attribute would not have changed.`\n );\n }\n // Track if the property is being reflected to avoid\n // setting the property again via `attributeChangedCallback`. Note:\n // 1. this takes advantage of the fact that the callback is synchronous.\n // 2. will behave incorrectly if multiple attributes are in the reaction\n // stack at time of calling. However, since we process attributes\n // in `update` this should not be possible (or an extreme corner case\n // that we'd like to discover).\n // mark state reflecting\n this.__reflectingProperty = name;\n if (attrValue == null) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, attrValue as string);\n }\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /** @internal */\n _$attributeToProperty(name: string, value: string | null) {\n const ctor = this.constructor as typeof ReactiveElement;\n // Note, hint this as an `AttributeMap` so closure clearly understands\n // the type; it has issues with tracking types through statics\n const propName = (ctor.__attributeToPropertyMap as AttributeMap).get(name);\n // Use tracking info to avoid reflecting a property value to an attribute\n // if it was just set because the attribute changed.\n if (propName !== undefined && this.__reflectingProperty !== propName) {\n const options = ctor.getPropertyOptions(propName);\n const converter =\n typeof options.converter === 'function'\n ? {fromAttribute: options.converter}\n : options.converter?.fromAttribute !== undefined\n ? options.converter\n : defaultConverter;\n // mark state reflecting\n this.__reflectingProperty = propName;\n this[propName as keyof this] = converter.fromAttribute!(\n value,\n options.type\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ) as any;\n // mark state not reflecting\n this.__reflectingProperty = null;\n }\n }\n\n /**\n * Requests an update which is processed asynchronously. This should be called\n * when an element should update based on some state not triggered by setting\n * a reactive property. In this case, pass no arguments. It should also be\n * called when manually implementing a property setter. In this case, pass the\n * property `name` and `oldValue` to ensure that any configured property\n * options are honored.\n *\n * @param name name of requesting property\n * @param oldValue old value of requesting property\n * @param options property options to use instead of the previously\n * configured options\n * @category updates\n */\n requestUpdate(\n name?: PropertyKey,\n oldValue?: unknown,\n options?: PropertyDeclaration\n ): void {\n let shouldRequestUpdate = true;\n // If we have a property key, perform property update steps.\n if (name !== undefined) {\n options =\n options ||\n (this.constructor as typeof ReactiveElement).getPropertyOptions(name);\n const hasChanged = options.hasChanged || notEqual;\n if (hasChanged(this[name as keyof this], oldValue)) {\n if (!this._$changedProperties.has(name)) {\n this._$changedProperties.set(name, oldValue);\n }\n // Add to reflecting properties set.\n // Note, it's important that every change has a chance to add the\n // property to `_reflectingProperties`. This ensures setting\n // attribute + property reflects correctly.\n if (options.reflect === true && this.__reflectingProperty !== name) {\n if (this.__reflectingProperties === undefined) {\n this.__reflectingProperties = new Map();\n }\n this.__reflectingProperties.set(name, options);\n }\n } else {\n // Abort the request if the property should not be considered changed.\n shouldRequestUpdate = false;\n }\n }\n if (!this.isUpdatePending && shouldRequestUpdate) {\n this.__updatePromise = this.__enqueueUpdate();\n }\n // Note, since this no longer returns a promise, in dev mode we return a\n // thenable which warns if it's called.\n return DEV_MODE\n ? (requestUpdateThenable(this.localName) as unknown as void)\n : undefined;\n }\n\n /**\n * Sets up the element to asynchronously update.\n */\n private async __enqueueUpdate() {\n this.isUpdatePending = true;\n try {\n // Ensure any previous update has resolved before updating.\n // This `await` also ensures that property changes are batched.\n await this.__updatePromise;\n } catch (e) {\n // Refire any previous errors async so they do not disrupt the update\n // cycle. Errors are refired so developers have a chance to observe\n // them, and this can be done by implementing\n // `window.onunhandledrejection`.\n Promise.reject(e);\n }\n const result = this.scheduleUpdate();\n // If `scheduleUpdate` returns a Promise, we await it. This is done to\n // enable coordinating updates with a scheduler. Note, the result is\n // checked to avoid delaying an additional microtask unless we need to.\n if (result != null) {\n await result;\n }\n return !this.isUpdatePending;\n }\n\n /**\n * Schedules an element update. You can override this method to change the\n * timing of updates by returning a Promise. The update will await the\n * returned Promise, and you should resolve the Promise to allow the update\n * to proceed. If this method is overridden, `super.scheduleUpdate()`\n * must be called.\n *\n * For instance, to schedule updates to occur just before the next frame:\n *\n * ```ts\n * override protected async scheduleUpdate(): Promise<unknown> {\n * await new Promise((resolve) => requestAnimationFrame(() => resolve()));\n * super.scheduleUpdate();\n * }\n * ```\n * @category updates\n */\n protected scheduleUpdate(): void | Promise<unknown> {\n return this.performUpdate();\n }\n\n /**\n * Performs an element update. Note, if an exception is thrown during the\n * update, `firstUpdated` and `updated` will not be called.\n *\n * Call `performUpdate()` to immediately process a pending update. This should\n * generally not be needed, but it can be done in rare cases when you need to\n * update synchronously.\n *\n * Note: To ensure `performUpdate()` synchronously completes a pending update,\n * it should not be overridden. In LitElement 2.x it was suggested to override\n * `performUpdate()` to also customizing update scheduling. Instead, you should now\n * override `scheduleUpdate()`. For backwards compatibility with LitElement 2.x,\n * scheduling updates via `performUpdate()` continues to work, but will make\n * also calling `performUpdate()` to synchronously process updates difficult.\n *\n * @category updates\n */\n protected performUpdate(): void | Promise<unknown> {\n // Abort any update if one is not pending when this is called.\n // This can happen if `performUpdate` is called early to \"flush\"\n // the update.\n if (!this.isUpdatePending) {\n return;\n }\n debugLogEvent?.({kind: 'update'});\n // create renderRoot before first update.\n if (!this.hasUpdated) {\n // Produce warning if any class properties are shadowed by class fields\n if (DEV_MODE) {\n const shadowedProperties: string[] = [];\n (\n this.constructor as typeof ReactiveElement\n ).__reactivePropertyKeys?.forEach((p) => {\n if (this.hasOwnProperty(p) && !this.__instanceProperties?.has(p)) {\n shadowedProperties.push(p as string);\n }\n });\n if (shadowedProperties.length) {\n throw new Error(\n `The following properties on element ${this.localName} will not ` +\n `trigger updates as expected because they are set using class ` +\n `fields: ${shadowedProperties.join(', ')}. ` +\n `Native class fields and some compiled output will overwrite ` +\n `accessors used for detecting changes. See ` +\n `https://lit.dev/msg/class-field-shadowing ` +\n `for more information.`\n );\n }\n }\n }\n // Mixin instance properties once, if they exist.\n if (this.__instanceProperties) {\n // Use forEach so this works even if for/of loops are compiled to for loops\n // expecting arrays\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n this.__instanceProperties!.forEach((v, p) => ((this as any)[p] = v));\n this.__instanceProperties = undefined;\n }\n let shouldUpdate = false;\n const changedProperties = this._$changedProperties;\n try {\n shouldUpdate = this.shouldUpdate(changedProperties);\n if (shouldUpdate) {\n this.willUpdate(changedProperties);\n this.__controllers?.forEach((c) => c.hostUpdate?.());\n this.update(changedProperties);\n } else {\n this.__markUpdated();\n }\n } catch (e) {\n // Prevent `firstUpdated` and `updated` from running when there's an\n // update exception.\n shouldUpdate = false;\n // Ensure element can accept additional updates after an exception.\n this.__markUpdated();\n throw e;\n }\n // The update is no longer considered pending and further updates are now allowed.\n if (shouldUpdate) {\n this._$didUpdate(changedProperties);\n }\n }\n\n /**\n * Invoked before `update()` to compute values needed during the update.\n *\n * Implement `willUpdate` to compute property values that depend on other\n * properties and are used in the rest of the update process.\n *\n * ```ts\n * willUpdate(changedProperties) {\n * // only need to check changed properties for an expensive computation.\n * if (changedProperties.has('firstName') || changedProperties.has('lastName')) {\n * this.sha = computeSHA(`${this.firstName} ${this.lastName}`);\n * }\n * }\n *\n * render() {\n * return html`SHA: ${this.sha}`;\n * }\n * ```\n *\n * @category updates\n */\n protected willUpdate(_changedProperties: PropertyValues): void {}\n\n // Note, this is an override point for polyfill-support.\n // @internal\n _$didUpdate(changedProperties: PropertyValues) {\n this.__controllers?.forEach((c) => c.hostUpdated?.());\n if (!this.hasUpdated) {\n this.hasUpdated = true;\n this.firstUpdated(changedProperties);\n }\n this.updated(changedProperties);\n if (\n DEV_MODE &&\n this.isUpdatePending &&\n (this.constructor as typeof ReactiveElement).enabledWarnings!.indexOf(\n 'change-in-update'\n ) >= 0\n ) {\n issueWarning(\n 'change-in-update',\n `Element ${this.localName} scheduled an update ` +\n `(generally because a property was set) ` +\n `after an update completed, causing a new update to be scheduled. ` +\n `This is inefficient and should be avoided unless the next update ` +\n `can only be scheduled as a side effect of the previous update.`\n );\n }\n }\n\n private __markUpdated() {\n this._$changedProperties = new Map();\n this.isUpdatePending = false;\n }\n\n /**\n * Returns a Promise that resolves when the element has completed updating.\n * The Promise value is a boolean that is `true` if the element completed the\n * update without triggering another update. The Promise result is `false` if\n * a property was set inside `updated()`. If the Promise is rejected, an\n * exception was thrown during the update.\n *\n * To await additional asynchronous work, override the `getUpdateComplete`\n * method. For example, it is sometimes useful to await a rendered element\n * before fulfilling this Promise. To do this, first await\n * `super.getUpdateComplete()`, then any subsequent state.\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n get updateComplete(): Promise<boolean> {\n return this.getUpdateComplete();\n }\n\n /**\n * Override point for the `updateComplete` promise.\n *\n * It is not safe to override the `updateComplete` getter directly due to a\n * limitation in TypeScript which means it is not possible to call a\n * superclass getter (e.g. `super.updateComplete.then(...)`) when the target\n * language is ES5 (https://github.com/microsoft/TypeScript/issues/338).\n * This method should be overridden instead. For example:\n *\n * ```ts\n * class MyElement extends LitElement {\n * override async getUpdateComplete() {\n * const result = await super.getUpdateComplete();\n * await this._myChild.updateComplete;\n * return result;\n * }\n * }\n * ```\n *\n * @return A promise of a boolean that resolves to true if the update completed\n * without triggering another update.\n * @category updates\n */\n protected getUpdateComplete(): Promise<boolean> {\n return this.__updatePromise;\n }\n\n /**\n * Controls whether or not `update()` should be called when the element requests\n * an update. By default, this method always returns `true`, but this can be\n * customized to control when to update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected shouldUpdate(_changedProperties: PropertyValues): boolean {\n return true;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes.\n * It can be overridden to render and keep updated element DOM.\n * Setting properties inside this method will *not* trigger\n * another update.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected update(_changedProperties: PropertyValues) {\n if (this.__reflectingProperties !== undefined) {\n // Use forEach so this works even if for/of loops are compiled to for\n // loops expecting arrays\n this.__reflectingProperties.forEach((v, k) =>\n this.__propertyToAttribute(k, this[k as keyof this], v)\n );\n this.__reflectingProperties = undefined;\n }\n this.__markUpdated();\n }\n\n /**\n * Invoked whenever the element is updated. Implement to perform\n * post-updating tasks via DOM APIs, for example, focusing an element.\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected updated(_changedProperties: PropertyValues) {}\n\n /**\n * Invoked when the element is first updated. Implement to perform one time\n * work on the element after update.\n *\n * ```ts\n * firstUpdated() {\n * this.renderRoot.getElementById('my-text-area').focus();\n * }\n * ```\n *\n * Setting properties inside this method will trigger the element to update\n * again after this update cycle completes.\n *\n * @param _changedProperties Map of changed properties with old values\n * @category updates\n */\n protected firstUpdated(_changedProperties: PropertyValues) {}\n}\n\n// Apply polyfills if available\npolyfillSupport?.({ReactiveElement});\n\n// Dev mode warnings...\nif (DEV_MODE) {\n // Default warning set.\n ReactiveElement.enabledWarnings = ['change-in-update'];\n const ensureOwnWarnings = function (ctor: typeof ReactiveElement) {\n if (\n !ctor.hasOwnProperty(JSCompiler_renameProperty('enabledWarnings', ctor))\n ) {\n ctor.enabledWarnings = ctor.enabledWarnings!.slice();\n }\n };\n ReactiveElement.enableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n if (this.enabledWarnings!.indexOf(warning) < 0) {\n this.enabledWarnings!.push(warning);\n }\n };\n ReactiveElement.disableWarning = function (\n this: typeof ReactiveElement,\n warning: WarningKind\n ) {\n ensureOwnWarnings(this);\n const i = this.enabledWarnings!.indexOf(warning);\n if (i >= 0) {\n this.enabledWarnings!.splice(i, 1);\n }\n };\n}\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for ReactiveElement usage.\n(global.reactiveElementVersions ??= []).push('1.6.1');\nif (DEV_MODE && global.reactiveElementVersions.length > 1) {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// IMPORTANT: these imports must be type-only\nimport type {Directive, DirectiveResult, PartInfo} from './directive.js';\n\nconst DEV_MODE = true;\nconst ENABLE_EXTRA_SECURITY_HOOKS = true;\nconst ENABLE_SHADYDOM_NOPATCH = true;\nconst NODE_MODE = false;\n// Use window for browser builds because IE11 doesn't have globalThis.\nconst global = NODE_MODE ? globalThis : window;\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace LitUnstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | TemplatePrep\n | TemplateInstantiated\n | TemplateInstantiatedAndUpdated\n | TemplateUpdating\n | BeginRender\n | EndRender\n | CommitPartEntry\n | SetPartValue;\n export interface TemplatePrep {\n kind: 'template prep';\n template: Template;\n strings: TemplateStringsArray;\n clonableTemplate: HTMLTemplateElement;\n parts: TemplatePart[];\n }\n export interface BeginRender {\n kind: 'begin render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart | undefined;\n }\n export interface EndRender {\n kind: 'end render';\n id: number;\n value: unknown;\n container: HTMLElement | DocumentFragment;\n options: RenderOptions | undefined;\n part: ChildPart;\n }\n export interface TemplateInstantiated {\n kind: 'template instantiated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateInstantiatedAndUpdated {\n kind: 'template instantiated and updated';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n fragment: Node;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface TemplateUpdating {\n kind: 'template updating';\n template: Template | CompiledTemplate;\n instance: TemplateInstance;\n options: RenderOptions | undefined;\n parts: Array<Part | undefined>;\n values: unknown[];\n }\n export interface SetPartValue {\n kind: 'set part';\n part: Part;\n value: unknown;\n valueIndex: number;\n values: unknown[];\n templateInstance: TemplateInstance;\n }\n\n export type CommitPartEntry =\n | CommitNothingToChildEntry\n | CommitText\n | CommitNode\n | CommitAttribute\n | CommitProperty\n | CommitBooleanAttribute\n | CommitEventListener\n | CommitToElementBinding;\n\n export interface CommitNothingToChildEntry {\n kind: 'commit nothing to child';\n start: ChildNode;\n end: ChildNode | null;\n parent: Disconnectable | undefined;\n options: RenderOptions | undefined;\n }\n\n export interface CommitText {\n kind: 'commit text';\n node: Text;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitNode {\n kind: 'commit node';\n start: Node;\n parent: Disconnectable | undefined;\n value: Node;\n options: RenderOptions | undefined;\n }\n\n export interface CommitAttribute {\n kind: 'commit attribute';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitProperty {\n kind: 'commit property';\n element: Element;\n name: string;\n value: unknown;\n options: RenderOptions | undefined;\n }\n\n export interface CommitBooleanAttribute {\n kind: 'commit boolean attribute';\n element: Element;\n name: string;\n value: boolean;\n options: RenderOptions | undefined;\n }\n\n export interface CommitEventListener {\n kind: 'commit event listener';\n element: Element;\n name: string;\n value: unknown;\n oldListener: unknown;\n options: RenderOptions | undefined;\n // True if we're removing the old event listener (e.g. because settings changed, or value is nothing)\n removeListener: boolean;\n // True if we're adding a new event listener (e.g. because first render, or settings changed)\n addListener: boolean;\n }\n\n export interface CommitToElementBinding {\n kind: 'commit to element binding';\n element: Element;\n value: unknown;\n options: RenderOptions | undefined;\n }\n }\n}\n\ninterface DebugLoggingWindow {\n // Even in dev mode, we generally don't want to emit these events, as that's\n // another level of cost, so only emit them when DEV_MODE is true _and_ when\n // window.emitLitDebugEvents is true.\n emitLitDebugLogEvents?: boolean;\n}\n\n/**\n * Useful for visualizing and logging insights into what the Lit template system is doing.\n *\n * Compiled out of prod mode builds.\n */\nconst debugLogEvent = DEV_MODE\n ? (event: LitUnstable.DebugLog.Entry) => {\n const shouldEmit = (global as unknown as DebugLoggingWindow)\n .emitLitDebugLogEvents;\n if (!shouldEmit) {\n return;\n }\n global.dispatchEvent(\n new CustomEvent<LitUnstable.DebugLog.Entry>('lit-debug', {\n detail: event,\n })\n );\n }\n : undefined;\n// Used for connecting beginRender and endRender events when there are nested\n// renders when errors are thrown preventing an endRender event from being\n// called.\nlet debugLogRenderId = 0;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n global.litIssuedWarnings ??= new Set();\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += code\n ? ` See https://lit.dev/msg/${code} for more information.`\n : '';\n if (!global.litIssuedWarnings!.has(warning)) {\n console.warn(warning);\n global.litIssuedWarnings!.add(warning);\n }\n };\n\n issueWarning(\n 'dev-mode',\n `Lit is in dev mode. Not recommended for production!`\n );\n}\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n global.ShadyDOM?.inUse &&\n global.ShadyDOM?.noPatch === true\n ? global.ShadyDOM!.wrap\n : (node: Node) => node;\n\nconst trustedTypes = (global as unknown as Partial<Window>).trustedTypes;\n\n/**\n * Our TrustedTypePolicy for HTML which is declared using the html template\n * tag function.\n *\n * That HTML is a developer-authored constant, and is parsed with innerHTML\n * before any untrusted expressions have been mixed in. Therefor it is\n * considered safe by construction.\n */\nconst policy = trustedTypes\n ? trustedTypes.createPolicy('lit-html', {\n createHTML: (s) => s,\n })\n : undefined;\n\n/**\n * Used to sanitize any value before it is written into the DOM. This can be\n * used to implement a security policy of allowed and disallowed values in\n * order to prevent XSS attacks.\n *\n * One way of using this callback would be to check attributes and properties\n * against a list of high risk fields, and require that values written to such\n * fields be instances of a class which is safe by construction. Closure's Safe\n * HTML Types is one implementation of this technique (\n * https://github.com/google/safe-html-types/blob/master/doc/safehtml-types.md).\n * The TrustedTypes polyfill in API-only mode could also be used as a basis\n * for this technique (https://github.com/WICG/trusted-types).\n *\n * @param node The HTML node (usually either a #text node or an Element) that\n * is being written to. Note that this is just an exemplar node, the write\n * may take place against another instance of the same class of node.\n * @param name The name of an attribute or property (for example, 'href').\n * @param type Indicates whether the write that's about to be performed will\n * be to a property or a node.\n * @return A function that will sanitize this class of writes.\n */\nexport type SanitizerFactory = (\n node: Node,\n name: string,\n type: 'property' | 'attribute'\n) => ValueSanitizer;\n\n/**\n * A function which can sanitize values that will be written to a specific kind\n * of DOM sink.\n *\n * See SanitizerFactory.\n *\n * @param value The value to sanitize. Will be the actual value passed into\n * the lit-html template literal, so this could be of any type.\n * @return The value to write to the DOM. Usually the same as the input value,\n * unless sanitization is needed.\n */\nexport type ValueSanitizer = (value: unknown) => unknown;\n\nconst identityFunction: ValueSanitizer = (value: unknown) => value;\nconst noopSanitizer: SanitizerFactory = (\n _node: Node,\n _name: string,\n _type: 'property' | 'attribute'\n) => identityFunction;\n\n/** Sets the global sanitizer factory. */\nconst setSanitizer = (newSanitizer: SanitizerFactory) => {\n if (!ENABLE_EXTRA_SECURITY_HOOKS) {\n return;\n }\n if (sanitizerFactoryInternal !== noopSanitizer) {\n throw new Error(\n `Attempted to overwrite existing lit-html security policy.` +\n ` setSanitizeDOMValueFactory should be called at most once.`\n );\n }\n sanitizerFactoryInternal = newSanitizer;\n};\n\n/**\n * Only used in internal tests, not a part of the public API.\n */\nconst _testOnlyClearSanitizerFactoryDoNotCallOrElse = () => {\n sanitizerFactoryInternal = noopSanitizer;\n};\n\nconst createSanitizer: SanitizerFactory = (node, name, type) => {\n return sanitizerFactoryInternal(node, name, type);\n};\n\n// Added to an attribute name to mark the attribute as bound so we can find\n// it easily.\nconst boundAttributeSuffix = '$lit$';\n\n// This marker is used in many syntactic positions in HTML, so it must be\n// a valid element name and attribute name. We don't support dynamic names (yet)\n// but this at least ensures that the parse tree is closer to the template\n// intention.\nconst marker = `lit$${String(Math.random()).slice(9)}$`;\n\n// String used to tell if a comment is a marker comment\nconst markerMatch = '?' + marker;\n\n// Text used to insert a comment marker node. We use processing instruction\n// syntax because it's slightly smaller, but parses as a comment node.\nconst nodeMarker = `<${markerMatch}>`;\n\nconst d =\n NODE_MODE && global.document === undefined\n ? ({\n createTreeWalker() {\n return {};\n },\n } as unknown as Document)\n : document;\n\n// Creates a dynamic marker. We never have to search for these in the DOM.\nconst createMarker = (v = '') => d.createComment(v);\n\n// https://tc39.github.io/ecma262/#sec-typeof-operator\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\nconst isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\nconst isArray = Array.isArray;\nconst isIterable = (value: unknown): value is Iterable<unknown> =>\n isArray(value) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n typeof (value as any)?.[Symbol.iterator] === 'function';\n\nconst SPACE_CHAR = `[ \\t\\n\\f\\r]`;\nconst ATTR_VALUE_CHAR = `[^ \\t\\n\\f\\r\"'\\`<>=]`;\nconst NAME_CHAR = `[^\\\\s\"'>=/]`;\n\n// These regexes represent the five parsing states that we care about in the\n// Template's HTML scanner. They match the *end* of the state they're named\n// after.\n// Depending on the match, we transition to a new state. If there's no match,\n// we stay in the same state.\n// Note that the regexes are stateful. We utilize lastIndex and sync it\n// across the multiple regexes used. In addition to the five regexes below\n// we also dynamically create a regex to find the matching end tags for raw\n// text elements.\n\n/**\n * End of text is: `<` followed by:\n * (comment start) or (tag) or (dynamic tag binding)\n */\nconst textEndRegex = /<(?:(!--|\\/[^a-zA-Z])|(\\/?[a-zA-Z][^>\\s]*)|(\\/?$))/g;\nconst COMMENT_START = 1;\nconst TAG_NAME = 2;\nconst DYNAMIC_TAG_NAME = 3;\n\nconst commentEndRegex = /-->/g;\n/**\n * Comments not started with <!--, like </{, can be ended by a single `>`\n */\nconst comment2EndRegex = />/g;\n\n/**\n * The tagEnd regex matches the end of the \"inside an opening\" tag syntax\n * position. It either matches a `>`, an attribute-like sequence, or the end\n * of the string after a space (attribute-name position ending).\n *\n * See attributes in the HTML spec:\n * https://www.w3.org/TR/html5/syntax.html#elements-attributes\n *\n * \" \\t\\n\\f\\r\" are HTML space characters:\n * https://infra.spec.whatwg.org/#ascii-whitespace\n *\n * So an attribute is:\n * * The name: any character except a whitespace character, (\"), ('), \">\",\n * \"=\", or \"/\". Note: this is different from the HTML spec which also excludes control characters.\n * * Followed by zero or more space characters\n * * Followed by \"=\"\n * * Followed by zero or more space characters\n * * Followed by:\n * * Any character except space, ('), (\"), \"<\", \">\", \"=\", (`), or\n * * (\") then any non-(\"), or\n * * (') then any non-(')\n */\nconst tagEndRegex = new RegExp(\n `>|${SPACE_CHAR}(?:(${NAME_CHAR}+)(${SPACE_CHAR}*=${SPACE_CHAR}*(?:${ATTR_VALUE_CHAR}|(\"|')|))|$)`,\n 'g'\n);\nconst ENTIRE_MATCH = 0;\nconst ATTRIBUTE_NAME = 1;\nconst SPACES_AND_EQUALS = 2;\nconst QUOTE_CHAR = 3;\n\nconst singleQuoteAttrEndRegex = /'/g;\nconst doubleQuoteAttrEndRegex = /\"/g;\n/**\n * Matches the raw text elements.\n *\n * Comments are not parsed within raw text elements, so we need to search their\n * text content for marker strings.\n */\nconst rawTextElement = /^(?:script|style|textarea|title)$/i;\n\n/** TemplateResult types */\nconst HTML_RESULT = 1;\nconst SVG_RESULT = 2;\n\ntype ResultType = typeof HTML_RESULT | typeof SVG_RESULT;\n\n// TemplatePart types\n// IMPORTANT: these must match the values in PartType\nconst ATTRIBUTE_PART = 1;\nconst CHILD_PART = 2;\nconst PROPERTY_PART = 3;\nconst BOOLEAN_ATTRIBUTE_PART = 4;\nconst EVENT_PART = 5;\nconst ELEMENT_PART = 6;\nconst COMMENT_PART = 7;\n\n/**\n * The return type of the template tag functions, {@linkcode html} and\n * {@linkcode svg}.\n *\n * A `TemplateResult` object holds all the information about a template\n * expression required to render it: the template strings, expression values,\n * and type of template (html or svg).\n *\n * `TemplateResult` objects do not create any DOM on their own. To create or\n * update DOM you need to render the `TemplateResult`. See\n * [Rendering](https://lit.dev/docs/components/rendering) for more information.\n *\n */\nexport type TemplateResult<T extends ResultType = ResultType> = {\n // This property needs to remain unminified.\n ['_$litType$']: T;\n strings: TemplateStringsArray;\n values: unknown[];\n};\n\nexport type HTMLTemplateResult = TemplateResult<typeof HTML_RESULT>;\n\nexport type SVGTemplateResult = TemplateResult<typeof SVG_RESULT>;\n\nexport interface CompiledTemplateResult {\n // This is a factory in order to make template initialization lazy\n // and allow ShadyRenderOptions scope to be passed in.\n // This property needs to remain unminified.\n ['_$litType$']: CompiledTemplate;\n values: unknown[];\n}\n\nexport interface CompiledTemplate extends Omit<Template, 'el'> {\n // el is overridden to be optional. We initialize it on first render\n el?: HTMLTemplateElement;\n\n // The prepared HTML string to create a template element from.\n h: TrustedHTML;\n}\n\n/**\n * Generates a template literal tag function that returns a TemplateResult with\n * the given result type.\n */\nconst tag =\n <T extends ResultType>(type: T) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult<T> => {\n // Warn against templates octal escape sequences\n // We do this here rather than in render so that the warning is closer to the\n // template definition.\n if (DEV_MODE && strings.some((s) => s === undefined)) {\n console.warn(\n 'Some template strings are undefined.\\n' +\n 'This is probably caused by illegal octal escape sequences.'\n );\n }\n return {\n // This property needs to remain unminified.\n ['_$litType$']: type,\n strings,\n values,\n };\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const header = (title: string) => html`<h1>${title}</h1>`;\n * ```\n *\n * The `html` tag returns a description of the DOM to render as a value. It is\n * lazy, meaning no work is done until the template is rendered. When rendering,\n * if a template comes from the same expression as a previously rendered result,\n * it's efficiently updated instead of replaced.\n */\nexport const html = tag(HTML_RESULT);\n\n/**\n * Interprets a template literal as an SVG fragment that can efficiently\n * render to and update a container.\n *\n * ```ts\n * const rect = svg`<rect width=\"10\" height=\"10\"></rect>`;\n *\n * const myImage = html`\n * <svg viewBox=\"0 0 10 10\" xmlns=\"http://www.w3.org/2000/svg\">\n * ${rect}\n * </svg>`;\n * ```\n *\n * The `svg` *tag function* should only be used for SVG fragments, or elements\n * that would be contained **inside** an `<svg>` HTML element. A common error is\n * placing an `<svg>` *element* in a template tagged with the `svg` tag\n * function. The `<svg>` element is an HTML element and should be used within a\n * template tagged with the {@linkcode html} tag function.\n *\n * In LitElement usage, it's invalid to return an SVG fragment from the\n * `render()` method, as the SVG fragment will be contained within the element's\n * shadow root and thus cannot be used within an `<svg>` HTML element.\n */\nexport const svg = tag(SVG_RESULT);\n\n/**\n * A sentinel value that signals that a value was handled by a directive and\n * should not be written to the DOM.\n */\nexport const noChange = Symbol.for('lit-noChange');\n\n/**\n * A sentinel value that signals a ChildPart to fully clear its content.\n *\n * ```ts\n * const button = html`${\n * user.isAdmin\n * ? html`<button>DELETE</button>`\n * : nothing\n * }`;\n * ```\n *\n * Prefer using `nothing` over other falsy values as it provides a consistent\n * behavior between various expression binding contexts.\n *\n * In child expressions, `undefined`, `null`, `''`, and `nothing` all behave the\n * same and render no nodes. In attribute expressions, `nothing` _removes_ the\n * attribute, while `undefined` and `null` will render an empty string. In\n * property expressions `nothing` becomes `undefined`.\n */\nexport const nothing = Symbol.for('lit-nothing');\n\n/**\n * The cache of prepared templates, keyed by the tagged TemplateStringsArray\n * and _not_ accounting for the specific template tag used. This means that\n * template tags cannot be dynamic - the must statically be one of html, svg,\n * or attr. This restriction simplifies the cache lookup, which is on the hot\n * path for rendering.\n */\nconst templateCache = new WeakMap<TemplateStringsArray, Template>();\n\n/**\n * Object specifying options for controlling lit-html rendering. Note that\n * while `render` may be called multiple times on the same `container` (and\n * `renderBefore` reference node) to efficiently update the rendered content,\n * only the options passed in during the first render are respected during\n * the lifetime of renders to that unique `container` + `renderBefore`\n * combination.\n */\nexport interface RenderOptions {\n /**\n * An object to use as the `this` value for event listeners. It's often\n * useful to set this to the host component rendering a template.\n */\n host?: object;\n /**\n * A DOM node before which to render content in the container.\n */\n renderBefore?: ChildNode | null;\n /**\n * Node used for cloning the template (`importNode` will be called on this\n * node). This controls the `ownerDocument` of the rendered DOM, along with\n * any inherited context. Defaults to the global `document`.\n */\n creationScope?: {importNode(node: Node, deep?: boolean): Node};\n /**\n * The initial connected state for the top-level part being rendered. If no\n * `isConnected` option is set, `AsyncDirective`s will be connected by\n * default. Set to `false` if the initial render occurs in a disconnected tree\n * and `AsyncDirective`s should see `isConnected === false` for their initial\n * render. The `part.setConnected()` method must be used subsequent to initial\n * render to change the connected state of the part.\n */\n isConnected?: boolean;\n}\n\nconst walker = d.createTreeWalker(\n d,\n 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */,\n null,\n false\n);\n\nlet sanitizerFactoryInternal: SanitizerFactory = noopSanitizer;\n\n//\n// Classes only below here, const variable declarations only above here...\n//\n// Keeping variable declarations and classes together improves minification.\n// Interfaces and type aliases can be interleaved freely.\n//\n\n// Type for classes that have a `_directive` or `_directives[]` field, used by\n// `resolveDirective`\nexport interface DirectiveParent {\n _$parent?: DirectiveParent;\n _$isConnected: boolean;\n __directive?: Directive;\n __directives?: Array<Directive | undefined>;\n}\n\n/**\n * Returns an HTML string for the given TemplateStringsArray and result type\n * (HTML or SVG), along with the case-sensitive bound attribute names in\n * template order. The HTML contains comment markers denoting the `ChildPart`s\n * and suffixes on bound attributes denoting the `AttributeParts`.\n *\n * @param strings template strings array\n * @param type HTML or SVG\n * @return Array containing `[html, attrNames]` (array returned for terseness,\n * to avoid object fields since this code is shared with non-minified SSR\n * code)\n */\nconst getTemplateHtml = (\n strings: TemplateStringsArray,\n type: ResultType\n): [TrustedHTML, Array<string | undefined>] => {\n // Insert makers into the template HTML to represent the position of\n // bindings. The following code scans the template strings to determine the\n // syntactic position of the bindings. They can be in text position, where\n // we insert an HTML comment, attribute value position, where we insert a\n // sentinel string and re-write the attribute name, or inside a tag where\n // we insert the sentinel string.\n const l = strings.length - 1;\n // Stores the case-sensitive bound attribute names in the order of their\n // parts. ElementParts are also reflected in this array as undefined\n // rather than a string, to disambiguate from attribute bindings.\n const attrNames: Array<string | undefined> = [];\n let html = type === SVG_RESULT ? '<svg>' : '';\n\n // When we're inside a raw text tag (not it's text content), the regex\n // will still be tagRegex so we can find attributes, but will switch to\n // this regex when the tag ends.\n let rawTextEndRegex: RegExp | undefined;\n\n // The current parsing state, represented as a reference to one of the\n // regexes\n let regex = textEndRegex;\n\n for (let i = 0; i < l; i++) {\n const s = strings[i];\n // The index of the end of the last attribute name. When this is\n // positive at end of a string, it means we're in an attribute value\n // position and need to rewrite the attribute name.\n // We also use a special value of -2 to indicate that we encountered\n // the end of a string in attribute name position.\n let attrNameEndIndex = -1;\n let attrName: string | undefined;\n let lastIndex = 0;\n let match!: RegExpExecArray | null;\n\n // The conditions in this loop handle the current parse state, and the\n // assignments to the `regex` variable are the state transitions.\n while (lastIndex < s.length) {\n // Make sure we start searching from where we previously left off\n regex.lastIndex = lastIndex;\n match = regex.exec(s);\n if (match === null) {\n break;\n }\n lastIndex = regex.lastIndex;\n if (regex === textEndRegex) {\n if (match[COMMENT_START] === '!--') {\n regex = commentEndRegex;\n } else if (match[COMMENT_START] !== undefined) {\n // We started a weird comment, like </{\n regex = comment2EndRegex;\n } else if (match[TAG_NAME] !== undefined) {\n if (rawTextElement.test(match[TAG_NAME])) {\n // Record if we encounter a raw-text element. We'll switch to\n // this regex at the end of the tag.\n rawTextEndRegex = new RegExp(`</${match[TAG_NAME]}`, 'g');\n }\n regex = tagEndRegex;\n } else if (match[DYNAMIC_TAG_NAME] !== undefined) {\n if (DEV_MODE) {\n throw new Error(\n 'Bindings in tag names are not supported. Please use static templates instead. ' +\n 'See https://lit.dev/docs/templates/expressions/#static-expressions'\n );\n }\n regex = tagEndRegex;\n }\n } else if (regex === tagEndRegex) {\n if (match[ENTIRE_MATCH] === '>') {\n // End of a tag. If we had started a raw-text element, use that\n // regex\n regex = rawTextEndRegex ?? textEndRegex;\n // We may be ending an unquoted attribute value, so make sure we\n // clear any pending attrNameEndIndex\n attrNameEndIndex = -1;\n } else if (match[ATTRIBUTE_NAME] === undefined) {\n // Attribute name position\n attrNameEndIndex = -2;\n } else {\n attrNameEndIndex = regex.lastIndex - match[SPACES_AND_EQUALS].length;\n attrName = match[ATTRIBUTE_NAME];\n regex =\n match[QUOTE_CHAR] === undefined\n ? tagEndRegex\n : match[QUOTE_CHAR] === '\"'\n ? doubleQuoteAttrEndRegex\n : singleQuoteAttrEndRegex;\n }\n } else if (\n regex === doubleQuoteAttrEndRegex ||\n regex === singleQuoteAttrEndRegex\n ) {\n regex = tagEndRegex;\n } else if (regex === commentEndRegex || regex === comment2EndRegex) {\n regex = textEndRegex;\n } else {\n // Not one of the five state regexes, so it must be the dynamically\n // created raw text regex and we're at the close of that element.\n regex = tagEndRegex;\n rawTextEndRegex = undefined;\n }\n }\n\n if (DEV_MODE) {\n // If we have a attrNameEndIndex, which indicates that we should\n // rewrite the attribute name, assert that we're in a valid attribute\n // position - either in a tag, or a quoted attribute value.\n console.assert(\n attrNameEndIndex === -1 ||\n regex === tagEndRegex ||\n regex === singleQuoteAttrEndRegex ||\n regex === doubleQuoteAttrEndRegex,\n 'unexpected parse state B'\n );\n }\n\n // We have four cases:\n // 1. We're in text position, and not in a raw text element\n // (regex === textEndRegex): insert a comment marker.\n // 2. We have a non-negative attrNameEndIndex which means we need to\n // rewrite the attribute name to add a bound attribute suffix.\n // 3. We're at the non-first binding in a multi-binding attribute, use a\n // plain marker.\n // 4. We're somewhere else inside the tag. If we're in attribute name\n // position (attrNameEndIndex === -2), add a sequential suffix to\n // generate a unique attribute name.\n\n // Detect a binding next to self-closing tag end and insert a space to\n // separate the marker from the tag end:\n const end =\n regex === tagEndRegex && strings[i + 1].startsWith('/>') ? ' ' : '';\n html +=\n regex === textEndRegex\n ? s + nodeMarker\n : attrNameEndIndex >= 0\n ? (attrNames.push(attrName!),\n s.slice(0, attrNameEndIndex) +\n boundAttributeSuffix +\n s.slice(attrNameEndIndex)) +\n marker +\n end\n : s +\n marker +\n (attrNameEndIndex === -2 ? (attrNames.push(undefined), i) : end);\n }\n\n const htmlResult: string | TrustedHTML =\n html + (strings[l] || '<?>') + (type === SVG_RESULT ? '</svg>' : '');\n\n // A security check to prevent spoofing of Lit template results.\n // In the future, we may be able to replace this with Array.isTemplateObject,\n // though we might need to make that check inside of the html and svg\n // functions, because precompiled templates don't come in as\n // TemplateStringArray objects.\n if (!Array.isArray(strings) || !strings.hasOwnProperty('raw')) {\n let message = 'invalid template strings array';\n if (DEV_MODE) {\n message = `\n Internal Error: expected template strings to be an array\n with a 'raw' field. Faking a template strings array by\n calling html or svg like an ordinary function is effectively\n the same as calling unsafeHtml and can lead to major security\n issues, e.g. opening your code up to XSS attacks.\n\n If you're using the html or svg tagged template functions normally\n and and still seeing this error, please file a bug at\n https://github.com/lit/lit/issues/new?template=bug_report.md\n and include information about your build tooling, if any.\n `\n .trim()\n .replace(/\\n */g, '\\n');\n }\n throw new Error(message);\n }\n // Returned as an array for terseness\n return [\n policy !== undefined\n ? policy.createHTML(htmlResult)\n : (htmlResult as unknown as TrustedHTML),\n attrNames,\n ];\n};\n\n/** @internal */\nexport type {Template};\nclass Template {\n /** @internal */\n el!: HTMLTemplateElement;\n /** @internal */\n parts: Array<TemplatePart> = [];\n\n constructor(\n // This property needs to remain unminified.\n {strings, ['_$litType$']: type}: TemplateResult,\n options?: RenderOptions\n ) {\n let node: Node | null;\n let nodeIndex = 0;\n let attrNameIndex = 0;\n const partCount = strings.length - 1;\n const parts = this.parts;\n\n // Create template element\n const [html, attrNames] = getTemplateHtml(strings, type);\n this.el = Template.createElement(html, options);\n walker.currentNode = this.el.content;\n\n // Reparent SVG nodes into template root\n if (type === SVG_RESULT) {\n const content = this.el.content;\n const svgElement = content.firstChild!;\n svgElement.remove();\n content.append(...svgElement.childNodes);\n }\n\n // Walk the template to find binding markers and create TemplateParts\n while ((node = walker.nextNode()) !== null && parts.length < partCount) {\n if (node.nodeType === 1) {\n if (DEV_MODE) {\n const tag = (node as Element).localName;\n // Warn if `textarea` includes an expression and throw if `template`\n // does since these are not supported. We do this by checking\n // innerHTML for anything that looks like a marker. This catches\n // cases like bindings in textarea there markers turn into text nodes.\n if (\n /^(?:textarea|template)$/i!.test(tag) &&\n (node as Element).innerHTML.includes(marker)\n ) {\n const m =\n `Expressions are not supported inside \\`${tag}\\` ` +\n `elements. See https://lit.dev/msg/expression-in-${tag} for more ` +\n `information.`;\n if (tag === 'template') {\n throw new Error(m);\n } else issueWarning('', m);\n }\n }\n // TODO (justinfagnani): for attempted dynamic tag names, we don't\n // increment the bindingIndex, and it'll be off by 1 in the element\n // and off by two after it.\n if ((node as Element).hasAttributes()) {\n // We defer removing bound attributes because on IE we might not be\n // iterating attributes in their template order, and would sometimes\n // remove an attribute that we still need to create a part for.\n const attrsToRemove = [];\n for (const name of (node as Element).getAttributeNames()) {\n // `name` is the name of the attribute we're iterating over, but not\n // _neccessarily_ the name of the attribute we will create a part\n // for. They can be different in browsers that don't iterate on\n // attributes in source order. In that case the attrNames array\n // contains the attribute name we'll process next. We only need the\n // attribute name here to know if we should process a bound attribute\n // on this element.\n if (\n name.endsWith(boundAttributeSuffix) ||\n name.startsWith(marker)\n ) {\n const realName = attrNames[attrNameIndex++];\n attrsToRemove.push(name);\n if (realName !== undefined) {\n // Lowercase for case-sensitive SVG attributes like viewBox\n const value = (node as Element).getAttribute(\n realName.toLowerCase() + boundAttributeSuffix\n )!;\n const statics = value.split(marker);\n const m = /([.?@])?(.*)/.exec(realName)!;\n parts.push({\n type: ATTRIBUTE_PART,\n index: nodeIndex,\n name: m[2],\n strings: statics,\n ctor:\n m[1] === '.'\n ? PropertyPart\n : m[1] === '?'\n ? BooleanAttributePart\n : m[1] === '@'\n ? EventPart\n : AttributePart,\n });\n } else {\n parts.push({\n type: ELEMENT_PART,\n index: nodeIndex,\n });\n }\n }\n }\n for (const name of attrsToRemove) {\n (node as Element).removeAttribute(name);\n }\n }\n // TODO (justinfagnani): benchmark the regex against testing for each\n // of the 3 raw text element names.\n if (rawTextElement.test((node as Element).tagName)) {\n // For raw text elements we need to split the text content on\n // markers, create a Text node for each segment, and create\n // a TemplatePart for each marker.\n const strings = (node as Element).textContent!.split(marker);\n const lastIndex = strings.length - 1;\n if (lastIndex > 0) {\n (node as Element).textContent = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n // Generate a new text node for each literal section\n // These nodes are also used as the markers for node parts\n // We can't use empty text nodes as markers because they're\n // normalized when cloning in IE (could simplify when\n // IE is no longer supported)\n for (let i = 0; i < lastIndex; i++) {\n (node as Element).append(strings[i], createMarker());\n // Walk past the marker node we just added\n walker.nextNode();\n parts.push({type: CHILD_PART, index: ++nodeIndex});\n }\n // Note because this marker is added after the walker's current\n // node, it will be walked to in the outer loop (and ignored), so\n // we don't need to adjust nodeIndex here\n (node as Element).append(strings[lastIndex], createMarker());\n }\n }\n } else if (node.nodeType === 8) {\n const data = (node as Comment).data;\n if (data === markerMatch) {\n parts.push({type: CHILD_PART, index: nodeIndex});\n } else {\n let i = -1;\n while ((i = (node as Comment).data.indexOf(marker, i + 1)) !== -1) {\n // Comment node has a binding marker inside, make an inactive part\n // The binding won't work, but subsequent bindings will\n parts.push({type: COMMENT_PART, index: nodeIndex});\n // Move to the end of the match\n i += marker.length - 1;\n }\n }\n }\n nodeIndex++;\n }\n debugLogEvent?.({\n kind: 'template prep',\n template: this,\n clonableTemplate: this.el,\n parts: this.parts,\n strings,\n });\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @nocollapse */\n static createElement(html: TrustedHTML, _options?: RenderOptions) {\n const el = d.createElement('template');\n el.innerHTML = html as unknown as string;\n return el;\n }\n}\n\nexport interface Disconnectable {\n _$parent?: Disconnectable;\n _$disconnectableChildren?: Set<Disconnectable>;\n // Rather than hold connection state on instances, Disconnectables recursively\n // fetch the connection state from the RootPart they are connected in via\n // getters up the Disconnectable tree via _$parent references. This pushes the\n // cost of tracking the isConnected state to `AsyncDirectives`, and avoids\n // needing to pass all Disconnectables (parts, template instances, and\n // directives) their connection state each time it changes, which would be\n // costly for trees that have no AsyncDirectives.\n _$isConnected: boolean;\n}\n\nfunction resolveDirective(\n part: ChildPart | AttributePart | ElementPart,\n value: unknown,\n parent: DirectiveParent = part,\n attributeIndex?: number\n): unknown {\n // Bail early if the value is explicitly noChange. Note, this means any\n // nested directive is still attached and is not run.\n if (value === noChange) {\n return value;\n }\n let currentDirective =\n attributeIndex !== undefined\n ? (parent as AttributePart).__directives?.[attributeIndex]\n : (parent as ChildPart | ElementPart | Directive).__directive;\n const nextDirectiveConstructor = isPrimitive(value)\n ? undefined\n : // This property needs to remain unminified.\n (value as DirectiveResult)['_$litDirective$'];\n if (currentDirective?.constructor !== nextDirectiveConstructor) {\n // This property needs to remain unminified.\n currentDirective?.['_$notifyDirectiveConnectionChanged']?.(false);\n if (nextDirectiveConstructor === undefined) {\n currentDirective = undefined;\n } else {\n currentDirective = new nextDirectiveConstructor(part as PartInfo);\n currentDirective._$initialize(part, parent, attributeIndex);\n }\n if (attributeIndex !== undefined) {\n ((parent as AttributePart).__directives ??= [])[attributeIndex] =\n currentDirective;\n } else {\n (parent as ChildPart | Directive).__directive = currentDirective;\n }\n }\n if (currentDirective !== undefined) {\n value = resolveDirective(\n part,\n currentDirective._$resolve(part, (value as DirectiveResult).values),\n currentDirective,\n attributeIndex\n );\n }\n return value;\n}\n\n/**\n * An updateable instance of a Template. Holds references to the Parts used to\n * update the template instance.\n */\nclass TemplateInstance implements Disconnectable {\n /** @internal */\n _$template: Template;\n /** @internal */\n _parts: Array<Part | undefined> = [];\n\n /** @internal */\n _$parent: ChildPart;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n constructor(template: Template, parent: ChildPart) {\n this._$template = template;\n this._$parent = parent;\n }\n\n // Called by ChildPart parentNode getter\n get parentNode() {\n return this._$parent.parentNode;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n // This method is separate from the constructor because we need to return a\n // DocumentFragment and we don't want to hold onto it with an instance field.\n _clone(options: RenderOptions | undefined) {\n const {\n el: {content},\n parts: parts,\n } = this._$template;\n const fragment = (options?.creationScope ?? d).importNode(content, true);\n walker.currentNode = fragment;\n\n let node = walker.nextNode()!;\n let nodeIndex = 0;\n let partIndex = 0;\n let templatePart = parts[0];\n\n while (templatePart !== undefined) {\n if (nodeIndex === templatePart.index) {\n let part: Part | undefined;\n if (templatePart.type === CHILD_PART) {\n part = new ChildPart(\n node as HTMLElement,\n node.nextSibling,\n this,\n options\n );\n } else if (templatePart.type === ATTRIBUTE_PART) {\n part = new templatePart.ctor(\n node as HTMLElement,\n templatePart.name,\n templatePart.strings,\n this,\n options\n );\n } else if (templatePart.type === ELEMENT_PART) {\n part = new ElementPart(node as HTMLElement, this, options);\n }\n this._parts.push(part);\n templatePart = parts[++partIndex];\n }\n if (nodeIndex !== templatePart?.index) {\n node = walker.nextNode()!;\n nodeIndex++;\n }\n }\n return fragment;\n }\n\n _update(values: Array<unknown>) {\n let i = 0;\n for (const part of this._parts) {\n if (part !== undefined) {\n debugLogEvent?.({\n kind: 'set part',\n part,\n value: values[i],\n valueIndex: i,\n values,\n templateInstance: this,\n });\n if ((part as AttributePart).strings !== undefined) {\n (part as AttributePart)._$setValue(values, part as AttributePart, i);\n // The number of values the part consumes is part.strings.length - 1\n // since values are in between template spans. We increment i by 1\n // later in the loop, so increment it by part.strings.length - 2 here\n i += (part as AttributePart).strings!.length - 2;\n } else {\n part._$setValue(values[i]);\n }\n }\n i++;\n }\n }\n}\n\n/*\n * Parts\n */\ntype AttributeTemplatePart = {\n readonly type: typeof ATTRIBUTE_PART;\n readonly index: number;\n readonly name: string;\n /** @internal */\n readonly ctor: typeof AttributePart;\n /** @internal */\n readonly strings: ReadonlyArray<string>;\n};\ntype NodeTemplatePart = {\n readonly type: typeof CHILD_PART;\n readonly index: number;\n};\ntype ElementTemplatePart = {\n readonly type: typeof ELEMENT_PART;\n readonly index: number;\n};\ntype CommentTemplatePart = {\n readonly type: typeof COMMENT_PART;\n readonly index: number;\n};\n\n/**\n * A TemplatePart represents a dynamic part in a template, before the template\n * is instantiated. When a template is instantiated Parts are created from\n * TemplateParts.\n */\ntype TemplatePart =\n | NodeTemplatePart\n | AttributeTemplatePart\n | ElementTemplatePart\n | CommentTemplatePart;\n\nexport type Part =\n | ChildPart\n | AttributePart\n | PropertyPart\n | BooleanAttributePart\n | ElementPart\n | EventPart;\n\nexport type {ChildPart};\nclass ChildPart implements Disconnectable {\n readonly type = CHILD_PART;\n readonly options: RenderOptions | undefined;\n _$committedValue: unknown = nothing;\n /** @internal */\n __directive?: Directive;\n /** @internal */\n _$startNode: ChildNode;\n /** @internal */\n _$endNode: ChildNode | null;\n private _textSanitizer: ValueSanitizer | undefined;\n /** @internal */\n _$parent: Disconnectable | undefined;\n /**\n * Connection state for RootParts only (i.e. ChildPart without _$parent\n * returned from top-level `render`). This field is unsed otherwise. The\n * intention would clearer if we made `RootPart` a subclass of `ChildPart`\n * with this field (and a different _$isConnected getter), but the subclass\n * caused a perf regression, possibly due to making call sites polymorphic.\n * @internal\n */\n __isConnected: boolean;\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n // ChildParts that are not at the root should always be created with a\n // parent; only RootChildNode's won't, so they return the local isConnected\n // state\n return this._$parent?._$isConnected ?? this.__isConnected;\n }\n\n // The following fields will be patched onto ChildParts when required by\n // AsyncDirective\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /** @internal */\n _$notifyConnectionChanged?(\n isConnected: boolean,\n removeFromParent?: boolean,\n from?: number\n ): void;\n /** @internal */\n _$reparentDisconnectables?(parent: Disconnectable): void;\n\n constructor(\n startNode: ChildNode,\n endNode: ChildNode | null,\n parent: TemplateInstance | ChildPart | undefined,\n options: RenderOptions | undefined\n ) {\n this._$startNode = startNode;\n this._$endNode = endNode;\n this._$parent = parent;\n this.options = options;\n // Note __isConnected is only ever accessed on RootParts (i.e. when there is\n // no _$parent); the value on a non-root-part is \"don't care\", but checking\n // for parent would be more code\n this.__isConnected = options?.isConnected ?? true;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n // Explicitly initialize for consistent class shape.\n this._textSanitizer = undefined;\n }\n }\n\n /**\n * The parent node into which the part renders its content.\n *\n * A ChildPart's content consists of a range of adjacent child nodes of\n * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and\n * `.endNode`).\n *\n * - If both `.startNode` and `.endNode` are non-null, then the part's content\n * consists of all siblings between `.startNode` and `.endNode`, exclusively.\n *\n * - If `.startNode` is non-null but `.endNode` is null, then the part's\n * content consists of all siblings following `.startNode`, up to and\n * including the last child of `.parentNode`. If `.endNode` is non-null, then\n * `.startNode` will always be non-null.\n *\n * - If both `.endNode` and `.startNode` are null, then the part's content\n * consists of all child nodes of `.parentNode`.\n */\n get parentNode(): Node {\n let parentNode: Node = wrap(this._$startNode).parentNode!;\n const parent = this._$parent;\n if (\n parent !== undefined &&\n parentNode.nodeType === 11 /* Node.DOCUMENT_FRAGMENT */\n ) {\n // If the parentNode is a DocumentFragment, it may be because the DOM is\n // still in the cloned fragment during initial render; if so, get the real\n // parentNode the part will be committed into by asking the parent.\n parentNode = (parent as ChildPart | TemplateInstance).parentNode;\n }\n return parentNode;\n }\n\n /**\n * The part's leading marker node, if any. See `.parentNode` for more\n * information.\n */\n get startNode(): Node | null {\n return this._$startNode;\n }\n\n /**\n * The part's trailing marker node, if any. See `.parentNode` for more\n * information.\n */\n get endNode(): Node | null {\n return this._$endNode;\n }\n\n _$setValue(value: unknown, directiveParent: DirectiveParent = this): void {\n if (DEV_MODE && this.parentNode === null) {\n throw new Error(\n `This \\`ChildPart\\` has no \\`parentNode\\` and therefore cannot accept a value. This likely means the element containing the part was manipulated in an unsupported way outside of Lit's control such that the part's marker nodes were ejected from DOM. For example, setting the element's \\`innerHTML\\` or \\`textContent\\` can do this.`\n );\n }\n value = resolveDirective(this, value, directiveParent);\n if (isPrimitive(value)) {\n // Non-rendering child values. It's important that these do not render\n // empty text nodes to avoid issues with preventing default <slot>\n // fallback content.\n if (value === nothing || value == null || value === '') {\n if (this._$committedValue !== nothing) {\n debugLogEvent?.({\n kind: 'commit nothing to child',\n start: this._$startNode,\n end: this._$endNode,\n parent: this._$parent,\n options: this.options,\n });\n this._$clear();\n }\n this._$committedValue = nothing;\n } else if (value !== this._$committedValue && value !== noChange) {\n this._commitText(value);\n }\n // This property needs to remain unminified.\n } else if ((value as TemplateResult)['_$litType$'] !== undefined) {\n this._commitTemplateResult(value as TemplateResult);\n } else if ((value as Node).nodeType !== undefined) {\n if (DEV_MODE && this.options?.host === value) {\n this._commitText(\n `[probable mistake: rendered a template's host in itself ` +\n `(commonly caused by writing \\${this} in a template]`\n );\n console.warn(\n `Attempted to render the template host`,\n value,\n `inside itself. This is almost always a mistake, and in dev mode `,\n `we render some warning text. In production however, we'll `,\n `render it, which will usually result in an error, and sometimes `,\n `in the element disappearing from the DOM.`\n );\n return;\n }\n this._commitNode(value as Node);\n } else if (isIterable(value)) {\n this._commitIterable(value);\n } else {\n // Fallback, will render the string representation\n this._commitText(value);\n }\n }\n\n private _insert<T extends Node>(node: T, ref = this._$endNode) {\n return wrap(wrap(this._$startNode).parentNode!).insertBefore(node, ref);\n }\n\n private _commitNode(value: Node): void {\n if (this._$committedValue !== value) {\n this._$clear();\n if (\n ENABLE_EXTRA_SECURITY_HOOKS &&\n sanitizerFactoryInternal !== noopSanitizer\n ) {\n const parentNodeName = this._$startNode.parentNode?.nodeName;\n if (parentNodeName === 'STYLE' || parentNodeName === 'SCRIPT') {\n let message = 'Forbidden';\n if (DEV_MODE) {\n if (parentNodeName === 'STYLE') {\n message =\n `Lit does not support binding inside style nodes. ` +\n `This is a security risk, as style injection attacks can ` +\n `exfiltrate data and spoof UIs. ` +\n `Consider instead using css\\`...\\` literals ` +\n `to compose styles, and make do dynamic styling with ` +\n `css custom properties, ::parts, <slot>s, ` +\n `and by mutating the DOM rather than stylesheets.`;\n } else {\n message =\n `Lit does not support binding inside script nodes. ` +\n `This is a security risk, as it could allow arbitrary ` +\n `code execution.`;\n }\n }\n throw new Error(message);\n }\n }\n debugLogEvent?.({\n kind: 'commit node',\n start: this._$startNode,\n parent: this._$parent,\n value: value,\n options: this.options,\n });\n this._$committedValue = this._insert(value);\n }\n }\n\n private _commitText(value: unknown): void {\n // If the committed value is a primitive it means we called _commitText on\n // the previous render, and we know that this._$startNode.nextSibling is a\n // Text node. We can now just replace the text content (.data) of the node.\n if (\n this._$committedValue !== nothing &&\n isPrimitive(this._$committedValue)\n ) {\n const node = wrap(this._$startNode).nextSibling as Text;\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(node, 'data', 'property');\n }\n value = this._textSanitizer(value);\n }\n debugLogEvent?.({\n kind: 'commit text',\n node,\n value,\n options: this.options,\n });\n (node as Text).data = value as string;\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n const textNode = document.createTextNode('');\n this._commitNode(textNode);\n // When setting text content, for security purposes it matters a lot\n // what the parent is. For example, <style> and <script> need to be\n // handled with care, while <span> does not. So first we need to put a\n // text node into the document, then we can sanitize its content.\n if (this._textSanitizer === undefined) {\n this._textSanitizer = createSanitizer(textNode, 'data', 'property');\n }\n value = this._textSanitizer(value);\n debugLogEvent?.({\n kind: 'commit text',\n node: textNode,\n value,\n options: this.options,\n });\n textNode.data = value as string;\n } else {\n this._commitNode(d.createTextNode(value as string));\n debugLogEvent?.({\n kind: 'commit text',\n node: wrap(this._$startNode).nextSibling as Text,\n value,\n options: this.options,\n });\n }\n }\n this._$committedValue = value;\n }\n\n private _commitTemplateResult(\n result: TemplateResult | CompiledTemplateResult\n ): void {\n // This property needs to remain unminified.\n const {values, ['_$litType$']: type} = result;\n // If $litType$ is a number, result is a plain TemplateResult and we get\n // the template from the template cache. If not, result is a\n // CompiledTemplateResult and _$litType$ is a CompiledTemplate and we need\n // to create the <template> element the first time we see it.\n const template: Template | CompiledTemplate =\n typeof type === 'number'\n ? this._$getTemplate(result as TemplateResult)\n : (type.el === undefined &&\n (type.el = Template.createElement(type.h, this.options)),\n type);\n\n if ((this._$committedValue as TemplateInstance)?._$template === template) {\n debugLogEvent?.({\n kind: 'template updating',\n template,\n instance: this._$committedValue as TemplateInstance,\n parts: (this._$committedValue as TemplateInstance)._parts,\n options: this.options,\n values,\n });\n (this._$committedValue as TemplateInstance)._update(values);\n } else {\n const instance = new TemplateInstance(template as Template, this);\n const fragment = instance._clone(this.options);\n debugLogEvent?.({\n kind: 'template instantiated',\n template,\n instance,\n parts: instance._parts,\n options: this.options,\n fragment,\n values,\n });\n instance._update(values);\n debugLogEvent?.({\n kind: 'template instantiated and updated',\n template,\n instance,\n parts: instance._parts,\n options: this.options,\n fragment,\n values,\n });\n this._commitNode(fragment);\n this._$committedValue = instance;\n }\n }\n\n // Overridden via `litHtmlPolyfillSupport` to provide platform support.\n /** @internal */\n _$getTemplate(result: TemplateResult) {\n let template = templateCache.get(result.strings);\n if (template === undefined) {\n templateCache.set(result.strings, (template = new Template(result)));\n }\n return template;\n }\n\n private _commitIterable(value: Iterable<unknown>): void {\n // For an Iterable, we create a new InstancePart per item, then set its\n // value to the item. This is a little bit of overhead for every item in\n // an Iterable, but it lets us recurse easily and efficiently update Arrays\n // of TemplateResults that will be commonly returned from expressions like:\n // array.map((i) => html`${i}`), by reusing existing TemplateInstances.\n\n // If value is an array, then the previous render was of an\n // iterable and value will contain the ChildParts from the previous\n // render. If value is not an array, clear this part and make a new\n // array for ChildParts.\n if (!isArray(this._$committedValue)) {\n this._$committedValue = [];\n this._$clear();\n }\n\n // Lets us keep track of how many items we stamped so we can clear leftover\n // items from a previous render\n const itemParts = this._$committedValue as ChildPart[];\n let partIndex = 0;\n let itemPart: ChildPart | undefined;\n\n for (const item of value) {\n if (partIndex === itemParts.length) {\n // If no existing part, create a new one\n // TODO (justinfagnani): test perf impact of always creating two parts\n // instead of sharing parts between nodes\n // https://github.com/lit/lit/issues/1266\n itemParts.push(\n (itemPart = new ChildPart(\n this._insert(createMarker()),\n this._insert(createMarker()),\n this,\n this.options\n ))\n );\n } else {\n // Reuse an existing part\n itemPart = itemParts[partIndex];\n }\n itemPart._$setValue(item);\n partIndex++;\n }\n\n if (partIndex < itemParts.length) {\n // itemParts always have end nodes\n this._$clear(\n itemPart && wrap(itemPart._$endNode!).nextSibling,\n partIndex\n );\n // Truncate the parts array so _value reflects the current state\n itemParts.length = partIndex;\n }\n }\n\n /**\n * Removes the nodes contained within this Part from the DOM.\n *\n * @param start Start node to clear from, for clearing a subset of the part's\n * DOM (used when truncating iterables)\n * @param from When `start` is specified, the index within the iterable from\n * which ChildParts are being removed, used for disconnecting directives in\n * those Parts.\n *\n * @internal\n */\n _$clear(\n start: ChildNode | null = wrap(this._$startNode).nextSibling,\n from?: number\n ) {\n this._$notifyConnectionChanged?.(false, true, from);\n while (start && start !== this._$endNode) {\n const n = wrap(start!).nextSibling;\n (wrap(start!) as Element).remove();\n start = n;\n }\n }\n /**\n * Implementation of RootPart's `isConnected`. Note that this metod\n * should only be called on `RootPart`s (the `ChildPart` returned from a\n * top-level `render()` call). It has no effect on non-root ChildParts.\n * @param isConnected Whether to set\n * @internal\n */\n setConnected(isConnected: boolean) {\n if (this._$parent === undefined) {\n this.__isConnected = isConnected;\n this._$notifyConnectionChanged?.(isConnected);\n } else if (DEV_MODE) {\n throw new Error(\n 'part.setConnected() may only be called on a ' +\n 'RootPart returned from render().'\n );\n }\n }\n}\n\n/**\n * A top-level `ChildPart` returned from `render` that manages the connected\n * state of `AsyncDirective`s created throughout the tree below it.\n */\nexport interface RootPart extends ChildPart {\n /**\n * Sets the connection state for `AsyncDirective`s contained within this root\n * ChildPart.\n *\n * lit-html does not automatically monitor the connectedness of DOM rendered;\n * as such, it is the responsibility of the caller to `render` to ensure that\n * `part.setConnected(false)` is called before the part object is potentially\n * discarded, to ensure that `AsyncDirective`s have a chance to dispose of\n * any resources being held. If a `RootPart` that was prevously\n * disconnected is subsequently re-connected (and its `AsyncDirective`s should\n * re-connect), `setConnected(true)` should be called.\n *\n * @param isConnected Whether directives within this tree should be connected\n * or not\n */\n setConnected(isConnected: boolean): void;\n}\n\nexport type {AttributePart};\nclass AttributePart implements Disconnectable {\n readonly type = ATTRIBUTE_PART as\n | typeof ATTRIBUTE_PART\n | typeof PROPERTY_PART\n | typeof BOOLEAN_ATTRIBUTE_PART\n | typeof EVENT_PART;\n readonly element: HTMLElement;\n readonly name: string;\n readonly options: RenderOptions | undefined;\n\n /**\n * If this attribute part represents an interpolation, this contains the\n * static strings of the interpolation. For single-value, complete bindings,\n * this is undefined.\n */\n readonly strings?: ReadonlyArray<string>;\n /** @internal */\n _$committedValue: unknown | Array<unknown> = nothing;\n /** @internal */\n __directives?: Array<Directive | undefined>;\n /** @internal */\n _$parent: Disconnectable;\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n protected _sanitizer: ValueSanitizer | undefined;\n\n get tagName() {\n return this.element.tagName;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this.element = element;\n this.name = name;\n this._$parent = parent;\n this.options = options;\n if (strings.length > 2 || strings[0] !== '' || strings[1] !== '') {\n this._$committedValue = new Array(strings.length - 1).fill(new String());\n this.strings = strings;\n } else {\n this._$committedValue = nothing;\n }\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n this._sanitizer = undefined;\n }\n }\n\n /**\n * Sets the value of this part by resolving the value from possibly multiple\n * values and static strings and committing it to the DOM.\n * If this part is single-valued, `this._strings` will be undefined, and the\n * method will be called with a single value argument. If this part is\n * multi-value, `this._strings` will be defined, and the method is called\n * with the value array of the part's owning TemplateInstance, and an offset\n * into the value array from which the values should be read.\n * This method is overloaded this way to eliminate short-lived array slices\n * of the template instance values, and allow a fast-path for single-valued\n * parts.\n *\n * @param value The part value, or an array of values for multi-valued parts\n * @param valueIndex the index to start reading values from. `undefined` for\n * single-valued parts\n * @param noCommit causes the part to not commit its value to the DOM. Used\n * in hydration to prime attribute parts with their first-rendered value,\n * but not set the attribute, and in SSR to no-op the DOM operation and\n * capture the value for serialization.\n *\n * @internal\n */\n _$setValue(\n value: unknown | Array<unknown>,\n directiveParent: DirectiveParent = this,\n valueIndex?: number,\n noCommit?: boolean\n ) {\n const strings = this.strings;\n\n // Whether any of the values has changed, for dirty-checking\n let change = false;\n\n if (strings === undefined) {\n // Single-value binding case\n value = resolveDirective(this, value, directiveParent, 0);\n change =\n !isPrimitive(value) ||\n (value !== this._$committedValue && value !== noChange);\n if (change) {\n this._$committedValue = value;\n }\n } else {\n // Interpolation case\n const values = value as Array<unknown>;\n value = strings[0];\n\n let i, v;\n for (i = 0; i < strings.length - 1; i++) {\n v = resolveDirective(this, values[valueIndex! + i], directiveParent, i);\n\n if (v === noChange) {\n // If the user-provided value is `noChange`, use the previous value\n v = (this._$committedValue as Array<unknown>)[i];\n }\n change ||=\n !isPrimitive(v) || v !== (this._$committedValue as Array<unknown>)[i];\n if (v === nothing) {\n value = nothing;\n } else if (value !== nothing) {\n value += (v ?? '') + strings[i + 1];\n }\n // We always record each value, even if one is `nothing`, for future\n // change detection.\n (this._$committedValue as Array<unknown>)[i] = v;\n }\n }\n if (change && !noCommit) {\n this._commitValue(value);\n }\n }\n\n /** @internal */\n _commitValue(value: unknown) {\n if (value === nothing) {\n (wrap(this.element) as Element).removeAttribute(this.name);\n } else {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'attribute'\n );\n }\n value = this._sanitizer(value ?? '');\n }\n debugLogEvent?.({\n kind: 'commit attribute',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n (wrap(this.element) as Element).setAttribute(\n this.name,\n (value ?? '') as string\n );\n }\n }\n}\n\nexport type {PropertyPart};\nclass PropertyPart extends AttributePart {\n override readonly type = PROPERTY_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n if (ENABLE_EXTRA_SECURITY_HOOKS) {\n if (this._sanitizer === undefined) {\n this._sanitizer = sanitizerFactoryInternal(\n this.element,\n this.name,\n 'property'\n );\n }\n value = this._sanitizer(value);\n }\n debugLogEvent?.({\n kind: 'commit property',\n element: this.element,\n name: this.name,\n value,\n options: this.options,\n });\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.element as any)[this.name] = value === nothing ? undefined : value;\n }\n}\n\n// Temporary workaround for https://crbug.com/993268\n// Currently, any attribute starting with \"on\" is considered to be a\n// TrustedScript source. Such boolean attributes must be set to the equivalent\n// trusted emptyScript value.\nconst emptyStringForBooleanAttribute = trustedTypes\n ? (trustedTypes.emptyScript as unknown as '')\n : '';\n\nexport type {BooleanAttributePart};\nclass BooleanAttributePart extends AttributePart {\n override readonly type = BOOLEAN_ATTRIBUTE_PART;\n\n /** @internal */\n override _commitValue(value: unknown) {\n debugLogEvent?.({\n kind: 'commit boolean attribute',\n element: this.element,\n name: this.name,\n value: !!(value && value !== nothing),\n options: this.options,\n });\n if (value && value !== nothing) {\n (wrap(this.element) as Element).setAttribute(\n this.name,\n emptyStringForBooleanAttribute\n );\n } else {\n (wrap(this.element) as Element).removeAttribute(this.name);\n }\n }\n}\n\ntype EventListenerWithOptions = EventListenerOrEventListenerObject &\n Partial<AddEventListenerOptions>;\n\n/**\n * An AttributePart that manages an event listener via add/removeEventListener.\n *\n * This part works by adding itself as the event listener on an element, then\n * delegating to the value passed to it. This reduces the number of calls to\n * add/removeEventListener if the listener changes frequently, such as when an\n * inline function is used as a listener.\n *\n * Because event options are passed when adding listeners, we must take case\n * to add and remove the part as a listener when the event options change.\n */\nexport type {EventPart};\nclass EventPart extends AttributePart {\n override readonly type = EVENT_PART;\n\n constructor(\n element: HTMLElement,\n name: string,\n strings: ReadonlyArray<string>,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n super(element, name, strings, parent, options);\n\n if (DEV_MODE && this.strings !== undefined) {\n throw new Error(\n `A \\`<${element.localName}>\\` has a \\`@${name}=...\\` listener with ` +\n 'invalid content. Event listeners in templates must have exactly ' +\n 'one expression and no surrounding text.'\n );\n }\n }\n\n // EventPart does not use the base _$setValue/_resolveValue implementation\n // since the dirty checking is more complex\n /** @internal */\n override _$setValue(\n newListener: unknown,\n directiveParent: DirectiveParent = this\n ) {\n newListener =\n resolveDirective(this, newListener, directiveParent, 0) ?? nothing;\n if (newListener === noChange) {\n return;\n }\n const oldListener = this._$committedValue;\n\n // If the new value is nothing or any options change we have to remove the\n // part as a listener.\n const shouldRemoveListener =\n (newListener === nothing && oldListener !== nothing) ||\n (newListener as EventListenerWithOptions).capture !==\n (oldListener as EventListenerWithOptions).capture ||\n (newListener as EventListenerWithOptions).once !==\n (oldListener as EventListenerWithOptions).once ||\n (newListener as EventListenerWithOptions).passive !==\n (oldListener as EventListenerWithOptions).passive;\n\n // If the new value is not nothing and we removed the listener, we have\n // to add the part as a listener.\n const shouldAddListener =\n newListener !== nothing &&\n (oldListener === nothing || shouldRemoveListener);\n\n debugLogEvent?.({\n kind: 'commit event listener',\n element: this.element,\n name: this.name,\n value: newListener,\n options: this.options,\n removeListener: shouldRemoveListener,\n addListener: shouldAddListener,\n oldListener,\n });\n if (shouldRemoveListener) {\n this.element.removeEventListener(\n this.name,\n this,\n oldListener as EventListenerWithOptions\n );\n }\n if (shouldAddListener) {\n // Beware: IE11 and Chrome 41 don't like using the listener as the\n // options object. Figure out how to deal w/ this in IE11 - maybe\n // patch addEventListener?\n this.element.addEventListener(\n this.name,\n this,\n newListener as EventListenerWithOptions\n );\n }\n this._$committedValue = newListener;\n }\n\n handleEvent(event: Event) {\n if (typeof this._$committedValue === 'function') {\n this._$committedValue.call(this.options?.host ?? this.element, event);\n } else {\n (this._$committedValue as EventListenerObject).handleEvent(event);\n }\n }\n}\n\nexport type {ElementPart};\nclass ElementPart implements Disconnectable {\n readonly type = ELEMENT_PART;\n\n /** @internal */\n __directive?: Directive;\n\n // This is to ensure that every Part has a _$committedValue\n _$committedValue: undefined;\n\n /** @internal */\n _$parent!: Disconnectable;\n\n /** @internal */\n _$disconnectableChildren?: Set<Disconnectable> = undefined;\n\n options: RenderOptions | undefined;\n\n constructor(\n public element: Element,\n parent: Disconnectable,\n options: RenderOptions | undefined\n ) {\n this._$parent = parent;\n this.options = options;\n }\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n _$setValue(value: unknown): void {\n debugLogEvent?.({\n kind: 'commit to element binding',\n element: this.element,\n value,\n options: this.options,\n });\n resolveDirective(this, value);\n }\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LH object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-element, which re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LH = {\n // Used in lit-ssr\n _boundAttributeSuffix: boundAttributeSuffix,\n _marker: marker,\n _markerMatch: markerMatch,\n _HTML_RESULT: HTML_RESULT,\n _getTemplateHtml: getTemplateHtml,\n // Used in hydrate\n _TemplateInstance: TemplateInstance,\n _isIterable: isIterable,\n _resolveDirective: resolveDirective,\n // Used in tests and private-ssr-support\n _ChildPart: ChildPart,\n _AttributePart: AttributePart,\n _BooleanAttributePart: BooleanAttributePart,\n _EventPart: EventPart,\n _PropertyPart: PropertyPart,\n _ElementPart: ElementPart,\n};\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? global.litHtmlPolyfillSupportDevMode\n : global.litHtmlPolyfillSupport;\npolyfillSupport?.(Template, ChildPart);\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for lit-html usage.\n(global.litHtmlVersions ??= []).push('2.6.1');\nif (DEV_MODE && global.litHtmlVersions.length > 1) {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. ` +\n `Loading multiple versions is not recommended.`\n );\n}\n\n/**\n * Renders a value, usually a lit-html TemplateResult, to the container.\n *\n * This example renders the text \"Hello, Zoe!\" inside a paragraph tag, appending\n * it to the container `document.body`.\n *\n * ```js\n * import {html, render} from 'lit';\n *\n * const name = \"Zoe\";\n * render(html`<p>Hello, ${name}!</p>`, document.body);\n * ```\n *\n * @param value Any [renderable\n * value](https://lit.dev/docs/templates/expressions/#child-expressions),\n * typically a {@linkcode TemplateResult} created by evaluating a template tag\n * like {@linkcode html} or {@linkcode svg}.\n * @param container A DOM container to render to. The first render will append\n * the rendered value to the container, and subsequent renders will\n * efficiently update the rendered value if the same result type was\n * previously rendered there.\n * @param options See {@linkcode RenderOptions} for options documentation.\n * @see\n * {@link https://lit.dev/docs/libraries/standalone-templates/#rendering-lit-html-templates| Rendering Lit HTML Templates}\n */\nexport const render = (\n value: unknown,\n container: HTMLElement | DocumentFragment,\n options?: RenderOptions\n): RootPart => {\n if (DEV_MODE && container == null) {\n // Give a clearer error message than\n // Uncaught TypeError: Cannot read properties of null (reading\n // '_$litPart$')\n // which reads like an internal Lit error.\n throw new TypeError(`The container to render into may not be ${container}`);\n }\n const renderId = DEV_MODE ? debugLogRenderId++ : 0;\n const partOwnerNode = options?.renderBefore ?? container;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let part: ChildPart = (partOwnerNode as any)['_$litPart$'];\n debugLogEvent?.({\n kind: 'begin render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n if (part === undefined) {\n const endNode = options?.renderBefore ?? null;\n // This property needs to remain unminified.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (partOwnerNode as any)['_$litPart$'] = part = new ChildPart(\n container.insertBefore(createMarker(), endNode),\n endNode,\n undefined,\n options ?? {}\n );\n }\n part._$setValue(value);\n debugLogEvent?.({\n kind: 'end render',\n id: renderId,\n value,\n container,\n options,\n part,\n });\n return part as RootPart;\n};\n\nif (ENABLE_EXTRA_SECURITY_HOOKS) {\n render.setSanitizer = setSanitizer;\n render.createSanitizer = createSanitizer;\n if (DEV_MODE) {\n render._testOnlyClearSanitizerFactoryDoNotCallOrElse =\n _testOnlyClearSanitizerFactoryDoNotCallOrElse;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * The main LitElement module, which defines the {@linkcode LitElement} base\n * class and related APIs.\n *\n * LitElement components can define a template and a set of observed\n * properties. Changing an observed property triggers a re-render of the\n * element.\n *\n * Import {@linkcode LitElement} and {@linkcode html} from this module to\n * create a component:\n *\n * ```js\n * import {LitElement, html} from 'lit-element';\n *\n * class MyElement extends LitElement {\n *\n * // Declare observed properties\n * static get properties() {\n * return {\n * adjective: {}\n * }\n * }\n *\n * constructor() {\n * this.adjective = 'awesome';\n * }\n *\n * // Define the element's template\n * render() {\n * return html`<p>your ${adjective} template here</p>`;\n * }\n * }\n *\n * customElements.define('my-element', MyElement);\n * ```\n *\n * `LitElement` extends {@linkcode ReactiveElement} and adds lit-html\n * templating. The `ReactiveElement` class is provided for users that want to\n * build their own custom element base classes that don't use lit-html.\n *\n * @packageDocumentation\n */\nimport {PropertyValues, ReactiveElement} from '@lit/reactive-element';\nimport {render, RenderOptions, noChange, RootPart} from 'lit-html';\nexport * from '@lit/reactive-element';\nexport * from 'lit-html';\n\nimport {LitUnstable} from 'lit-html';\nimport {ReactiveUnstable} from '@lit/reactive-element';\n\n/**\n * Contains types that are part of the unstable debug API.\n *\n * Everything in this API is not stable and may change or be removed in the future,\n * even on patch releases.\n */\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace Unstable {\n /**\n * When Lit is running in dev mode and `window.emitLitDebugLogEvents` is true,\n * we will emit 'lit-debug' events to window, with live details about the update and render\n * lifecycle. These can be useful for writing debug tooling and visualizations.\n *\n * Please be aware that running with window.emitLitDebugLogEvents has performance overhead,\n * making certain operations that are normally very cheap (like a no-op render) much slower,\n * because we must copy data and dispatch events.\n */\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace DebugLog {\n export type Entry =\n | LitUnstable.DebugLog.Entry\n | ReactiveUnstable.DebugLog.Entry;\n }\n}\n\n// For backwards compatibility export ReactiveElement as UpdatingElement. Note,\n// IE transpilation requires exporting like this.\nexport const UpdatingElement = ReactiveElement;\n\nconst DEV_MODE = true;\n\nlet issueWarning: (code: string, warning: string) => void;\n\nif (DEV_MODE) {\n // Ensure warnings are issued only 1x, even if multiple versions of Lit\n // are loaded.\n const issuedWarnings: Set<string | undefined> =\n (globalThis.litIssuedWarnings ??= new Set());\n\n // Issue a warning, if we haven't already.\n issueWarning = (code: string, warning: string) => {\n warning += ` See https://lit.dev/msg/${code} for more information.`;\n if (!issuedWarnings.has(warning)) {\n console.warn(warning);\n issuedWarnings.add(warning);\n }\n };\n}\n\n/**\n * Base element class that manages element properties and attributes, and\n * renders a lit-html template.\n *\n * To define a component, subclass `LitElement` and implement a\n * `render` method to provide the component's template. Define properties\n * using the {@linkcode LitElement.properties properties} property or the\n * {@linkcode property} decorator.\n */\nexport class LitElement extends ReactiveElement {\n /**\n * Ensure this class is marked as `finalized` as an optimization ensuring\n * it will not needlessly try to `finalize`.\n *\n * Note this property name is a string to prevent breaking Closure JS Compiler\n * optimizations. See @lit/reactive-element for more information.\n */\n protected static override ['finalized'] = true;\n\n // This property needs to remain unminified.\n static ['_$litElement$'] = true;\n\n /**\n * @category rendering\n */\n readonly renderOptions: RenderOptions = {host: this};\n\n private __childPart: RootPart | undefined = undefined;\n\n /**\n * @category rendering\n */\n protected override createRenderRoot() {\n const renderRoot = super.createRenderRoot();\n // When adoptedStyleSheets are shimmed, they are inserted into the\n // shadowRoot by createRenderRoot. Adjust the renderBefore node so that\n // any styles in Lit content render before adoptedStyleSheets. This is\n // important so that adoptedStyleSheets have precedence over styles in\n // the shadowRoot.\n this.renderOptions.renderBefore ??= renderRoot!.firstChild as ChildNode;\n return renderRoot;\n }\n\n /**\n * Updates the element. This method reflects property values to attributes\n * and calls `render` to render DOM via lit-html. Setting properties inside\n * this method will *not* trigger another update.\n * @param changedProperties Map of changed properties with old values\n * @category updates\n */\n protected override update(changedProperties: PropertyValues) {\n // Setting properties in `render` should not trigger an update. Since\n // updates are allowed after super.update, it's important to call `render`\n // before that.\n const value = this.render();\n if (!this.hasUpdated) {\n this.renderOptions.isConnected = this.isConnected;\n }\n super.update(changedProperties);\n this.__childPart = render(value, this.renderRoot, this.renderOptions);\n }\n\n /**\n * Invoked when the component is added to the document's DOM.\n *\n * In `connectedCallback()` you should setup tasks that should only occur when\n * the element is connected to the document. The most common of these is\n * adding event listeners to nodes external to the element, like a keydown\n * event handler added to the window.\n *\n * ```ts\n * connectedCallback() {\n * super.connectedCallback();\n * addEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * Typically, anything done in `connectedCallback()` should be undone when the\n * element is disconnected, in `disconnectedCallback()`.\n *\n * @category lifecycle\n */\n override connectedCallback() {\n super.connectedCallback();\n this.__childPart?.setConnected(true);\n }\n\n /**\n * Invoked when the component is removed from the document's DOM.\n *\n * This callback is the main signal to the element that it may no longer be\n * used. `disconnectedCallback()` should ensure that nothing is holding a\n * reference to the element (such as event listeners added to nodes external\n * to the element), so that it is free to be garbage collected.\n *\n * ```ts\n * disconnectedCallback() {\n * super.disconnectedCallback();\n * window.removeEventListener('keydown', this._handleKeydown);\n * }\n * ```\n *\n * An element may be re-connected after being disconnected.\n *\n * @category lifecycle\n */\n override disconnectedCallback() {\n super.disconnectedCallback();\n this.__childPart?.setConnected(false);\n }\n\n /**\n * Invoked on each update to perform rendering tasks. This method may return\n * any value renderable by lit-html's `ChildPart` - typically a\n * `TemplateResult`. Setting properties inside this method will *not* trigger\n * the element to update.\n * @category rendering\n */\n protected render(): unknown {\n return noChange;\n }\n}\n\n// Install hydration if available\nglobalThis.litElementHydrateSupport?.({LitElement});\n\n// Apply polyfills if available\nconst polyfillSupport = DEV_MODE\n ? globalThis.litElementPolyfillSupportDevMode\n : globalThis.litElementPolyfillSupport;\npolyfillSupport?.({LitElement});\n\n// DEV mode warnings\nif (DEV_MODE) {\n /* eslint-disable @typescript-eslint/no-explicit-any */\n // Note, for compatibility with closure compilation, this access\n // needs to be as a string property index.\n (LitElement as any)['finalize'] = function (this: typeof LitElement) {\n const finalized = (ReactiveElement as any).finalize.call(this);\n if (!finalized) {\n return false;\n }\n const warnRemovedOrRenamed = (obj: any, name: string, renamed = false) => {\n if (obj.hasOwnProperty(name)) {\n const ctorName = (typeof obj === 'function' ? obj : obj.constructor)\n .name;\n issueWarning(\n renamed ? 'renamed-api' : 'removed-api',\n `\\`${name}\\` is implemented on class ${ctorName}. It ` +\n `has been ${renamed ? 'renamed' : 'removed'} ` +\n `in this version of LitElement.`\n );\n }\n };\n warnRemovedOrRenamed(this, 'render');\n warnRemovedOrRenamed(this, 'getStyles', true);\n warnRemovedOrRenamed((this as typeof LitElement).prototype, 'adoptStyles');\n return true;\n };\n /* eslint-enable @typescript-eslint/no-explicit-any */\n}\n\n/**\n * END USERS SHOULD NOT RELY ON THIS OBJECT.\n *\n * Private exports for use by other Lit packages, not intended for use by\n * external users.\n *\n * We currently do not make a mangled rollup build of the lit-ssr code. In order\n * to keep a number of (otherwise private) top-level exports mangled in the\n * client side code, we export a _$LE object containing those members (or\n * helper methods for accessing private fields of those members), and then\n * re-export them for use in lit-ssr. This keeps lit-ssr agnostic to whether the\n * client-side code is being used in `dev` mode or `prod` mode.\n *\n * This has a unique name, to disambiguate it from private exports in\n * lit-html, since this module re-exports all of lit-html.\n *\n * @private\n */\nexport const _$LE = {\n _$attributeToProperty: (\n el: LitElement,\n name: string,\n value: string | null\n ) => {\n // eslint-disable-next-line\n (el as any)._$attributeToProperty(name, value);\n },\n // eslint-disable-next-line\n _$changedProperties: (el: LitElement) => (el as any)._$changedProperties,\n};\n\n// IMPORTANT: do not change the property name or the assignment expression.\n// This line will be used in regexes to search for LitElement usage.\n(globalThis.litElementVersions ??= []).push('3.2.2');\nif (DEV_MODE && globalThis.litElementVersions.length > 1) {\n issueWarning!(\n 'multiple-versions',\n `Multiple versions of Lit loaded. Loading multiple versions ` +\n `is not recommended.`\n );\n}\n","/**\n * @license\n * Copyright 2022 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * @fileoverview\n *\n * This file exports a boolean const whose value will depend on what environment\n * the module is being imported from.\n */\n\nconst NODE_MODE = false;\n\n/**\n * A boolean that will be `true` in server environments like Node, and `false`\n * in browser environments. Note that your server environment or toolchain must\n * support the `\"node\"` export condition for this to be `true`.\n *\n * This can be used when authoring components to change behavior based on\n * whether or not the component is executing in an SSR context.\n */\nexport const isServer = NODE_MODE;\n","/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {_$LH, Part, DirectiveParent, TemplateResult} from './lit-html.js';\nimport {\n DirectiveResult,\n DirectiveClass,\n PartInfo,\n AttributePartInfo,\n} from './directive.js';\ntype Primitive = null | undefined | boolean | number | string | symbol | bigint;\n\nconst {_ChildPart: ChildPart} = _$LH;\n\ntype ChildPart = InstanceType<typeof ChildPart>;\n\nconst ENABLE_SHADYDOM_NOPATCH = true;\n\nconst wrap =\n ENABLE_SHADYDOM_NOPATCH &&\n window.ShadyDOM?.inUse &&\n window.ShadyDOM?.noPatch === true\n ? window.ShadyDOM!.wrap\n : (node: Node) => node;\n\n/**\n * Tests if a value is a primitive value.\n *\n * See https://tc39.github.io/ecma262/#sec-typeof-operator\n */\nexport const isPrimitive = (value: unknown): value is Primitive =>\n value === null || (typeof value != 'object' && typeof value != 'function');\n\nexport const TemplateResultType = {\n HTML: 1,\n SVG: 2,\n} as const;\n\nexport type TemplateResultType =\n typeof TemplateResultType[keyof typeof TemplateResultType];\n\n/**\n * Tests if a value is a TemplateResult.\n */\nexport const isTemplateResult = (\n value: unknown,\n type?: TemplateResultType\n): value is TemplateResult =>\n type === undefined\n ? // This property needs to remain unminified.\n (value as TemplateResult)?.['_$litType$'] !== undefined\n : (value as TemplateResult)?.['_$litType$'] === type;\n\n/**\n * Tests if a value is a DirectiveResult.\n */\nexport const isDirectiveResult = (value: unknown): value is DirectiveResult =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'] !== undefined;\n\n/**\n * Retrieves the Directive class for a DirectiveResult\n */\nexport const getDirectiveClass = (value: unknown): DirectiveClass | undefined =>\n // This property needs to remain unminified.\n (value as DirectiveResult)?.['_$litDirective$'];\n\n/**\n * Tests whether a part has only a single-expression with no strings to\n * interpolate between.\n *\n * Only AttributePart and PropertyPart can have multiple expressions.\n * Multi-expression parts have a `strings` property and single-expression\n * parts do not.\n */\nexport const isSingleExpression = (part: PartInfo) =>\n (part as AttributePartInfo).strings === undefined;\n\nconst createMarker = () => document.createComment('');\n\n/**\n * Inserts a ChildPart into the given container ChildPart's DOM, either at the\n * end of the container ChildPart, or before the optional `refPart`.\n *\n * This does not add the part to the containerPart's committed value. That must\n * be done by callers.\n *\n * @param containerPart Part within which to add the new ChildPart\n * @param refPart Part before which to add the new ChildPart; when omitted the\n * part added to the end of the `containerPart`\n * @param part Part to insert, or undefined to create a new part\n */\nexport const insertPart = (\n containerPart: ChildPart,\n refPart?: ChildPart,\n part?: ChildPart\n): ChildPart => {\n const container = wrap(containerPart._$startNode).parentNode!;\n\n const refNode =\n refPart === undefined ? containerPart._$endNode : refPart._$startNode;\n\n if (part === undefined) {\n const startNode = wrap(container).insertBefore(createMarker(), refNode);\n const endNode = wrap(container).insertBefore(createMarker(), refNode);\n part = new ChildPart(\n startNode,\n endNode,\n containerPart,\n containerPart.options\n );\n } else {\n const endNode = wrap(part._$endNode!).nextSibling;\n const oldParent = part._$parent;\n const parentChanged = oldParent !== containerPart;\n if (parentChanged) {\n part._$reparentDisconnectables?.(containerPart);\n // Note that although `_$reparentDisconnectables` updates the part's\n // `_$parent` reference after unlinking from its current parent, that\n // method only exists if Disconnectables are present, so we need to\n // unconditionally set it here\n part._$parent = containerPart;\n // Since the _$isConnected getter is somewhat costly, only\n // read it once we know the subtree has directives that need\n // to be notified\n let newConnectionState;\n if (\n part._$notifyConnectionChanged !== undefined &&\n (newConnectionState = containerPart._$isConnected) !==\n oldParent!._$isConnected\n ) {\n part._$notifyConnectionChanged(newConnectionState);\n }\n }\n if (endNode !== refNode || parentChanged) {\n let start: Node | null = part._$startNode;\n while (start !== endNode) {\n const n: Node | null = wrap(start!).nextSibling;\n wrap(container).insertBefore(start!, refNode);\n start = n;\n }\n }\n }\n\n return part;\n};\n\n/**\n * Sets the value of a Part.\n *\n * Note that this should only be used to set/update the value of user-created\n * parts (i.e. those created using `insertPart`); it should not be used\n * by directives to set the value of the directive's container part. Directives\n * should return a value from `update`/`render` to update their part state.\n *\n * For directives that require setting their part value asynchronously, they\n * should extend `AsyncDirective` and call `this.setValue()`.\n *\n * @param part Part to set\n * @param value Value to set\n * @param index For `AttributePart`s, the index to set\n * @param directiveParent Used internally; should not be set by user\n */\nexport const setChildPartValue = <T extends ChildPart>(\n part: T,\n value: unknown,\n directiveParent: DirectiveParent = part\n): T => {\n part._$setValue(value, directiveParent);\n return part;\n};\n\n// A sentinal value that can never appear as a part value except when set by\n// live(). Used to force a dirty-check to fail and cause a re-render.\nconst RESET_VALUE = {};\n\n/**\n * Sets the committed value of a ChildPart directly without triggering the\n * commit stage of the part.\n *\n * This is useful in cases where a directive needs to update the part such\n * that the next update detects a value change or not. When value is omitted,\n * the next update will be guaranteed to be detected as a change.\n *\n * @param part\n * @param value\n */\nexport const setCommittedValue = (part: Part, value: unknown = RESET_VALUE) =>\n (part._$committedValue = value);\n\n/**\n * Returns the committed value of a ChildPart.\n *\n * The committed value is used for change detection and efficient updates of\n * the part. It can differ from the value set by the template or directive in\n * cases where the template value is transformed before being commited.\n *\n * - `TemplateResult`s are committed as a `TemplateInstance`\n * - Iterables are committed as `Array<ChildPart>`\n * - All other types are committed as the template value or value returned or\n * set by a directive.\n *\n * @param part\n */\nexport const getCommittedValue = (part: ChildPart) => part._$committedValue;\n\n/**\n * Removes a ChildPart from the DOM, including any of its content.\n *\n * @param part The Part to remove\n */\nexport const removePart = (part: ChildPart) => {\n part._$notifyConnectionChanged?.(false, true);\n let start: ChildNode | null = part._$startNode;\n const end: ChildNode | null = wrap(part._$endNode!).nextSibling;\n while (start !== end) {\n const n: ChildNode | null = wrap(start!).nextSibling;\n (wrap(start!) as ChildNode).remove();\n start = n;\n }\n};\n\nexport const clearPart = (part: ChildPart) => {\n part._$clear();\n};\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Disconnectable, Part} from './lit-html.js';\n\nexport {\n AttributePart,\n BooleanAttributePart,\n ChildPart,\n ElementPart,\n EventPart,\n Part,\n PropertyPart,\n} from './lit-html.js';\n\nexport interface DirectiveClass {\n new (part: PartInfo): Directive;\n}\n\n/**\n * This utility type extracts the signature of a directive class's render()\n * method so we can use it for the type of the generated directive function.\n */\nexport type DirectiveParameters<C extends Directive> = Parameters<C['render']>;\n\n/**\n * A generated directive function doesn't evaluate the directive, but just\n * returns a DirectiveResult object that captures the arguments.\n */\nexport interface DirectiveResult<C extends DirectiveClass = DirectiveClass> {\n /**\n * This property needs to remain unminified.\n * @internal */\n ['_$litDirective$']: C;\n /** @internal */\n values: DirectiveParameters<InstanceType<C>>;\n}\n\nexport const PartType = {\n ATTRIBUTE: 1,\n CHILD: 2,\n PROPERTY: 3,\n BOOLEAN_ATTRIBUTE: 4,\n EVENT: 5,\n ELEMENT: 6,\n} as const;\n\nexport type PartType = typeof PartType[keyof typeof PartType];\n\nexport interface ChildPartInfo {\n readonly type: typeof PartType.CHILD;\n}\n\nexport interface AttributePartInfo {\n readonly type:\n | typeof PartType.ATTRIBUTE\n | typeof PartType.PROPERTY\n | typeof PartType.BOOLEAN_ATTRIBUTE\n | typeof PartType.EVENT;\n readonly strings?: ReadonlyArray<string>;\n readonly name: string;\n readonly tagName: string;\n}\n\nexport interface ElementPartInfo {\n readonly type: typeof PartType.ELEMENT;\n}\n\n/**\n * Information about the part a directive is bound to.\n *\n * This is useful for checking that a directive is attached to a valid part,\n * such as with directive that can only be used on attribute bindings.\n */\nexport type PartInfo = ChildPartInfo | AttributePartInfo | ElementPartInfo;\n\n/**\n * Creates a user-facing directive function from a Directive class. This\n * function has the same parameters as the directive's render() method.\n */\nexport const directive =\n <C extends DirectiveClass>(c: C) =>\n (...values: DirectiveParameters<InstanceType<C>>): DirectiveResult<C> => ({\n // This property needs to remain unminified.\n ['_$litDirective$']: c,\n values,\n });\n\n/**\n * Base class for creating custom directives. Users should extend this class,\n * implement `render` and/or `update`, and then pass their subclass to\n * `directive`.\n */\nexport abstract class Directive implements Disconnectable {\n //@internal\n __part!: Part;\n //@internal\n __attributeIndex: number | undefined;\n //@internal\n __directive?: Directive;\n\n //@internal\n _$parent!: Disconnectable;\n\n // These will only exist on the AsyncDirective subclass\n //@internal\n _$disconnectableChildren?: Set<Disconnectable>;\n // This property needs to remain unminified.\n //@internal\n ['_$notifyDirectiveConnectionChanged']?(isConnected: boolean): void;\n\n constructor(_partInfo: PartInfo) {}\n\n // See comment in Disconnectable interface for why this is a getter\n get _$isConnected() {\n return this._$parent._$isConnected;\n }\n\n /** @internal */\n _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n this.__part = part;\n this._$parent = parent;\n this.__attributeIndex = attributeIndex;\n }\n /** @internal */\n _$resolve(part: Part, props: Array<unknown>): unknown {\n return this.update(part, props);\n }\n\n abstract render(...props: Array<unknown>): unknown;\n\n update(_part: Part, props: Array<unknown>): unknown {\n return this.render(...props);\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Overview:\n *\n * This module is designed to add support for an async `setValue` API and\n * `disconnected` callback to directives with the least impact on the core\n * runtime or payload when that feature is not used.\n *\n * The strategy is to introduce a `AsyncDirective` subclass of\n * `Directive` that climbs the \"parent\" tree in its constructor to note which\n * branches of lit-html's \"logical tree\" of data structures contain such\n * directives and thus need to be crawled when a subtree is being cleared (or\n * manually disconnected) in order to run the `disconnected` callback.\n *\n * The \"nodes\" of the logical tree include Parts, TemplateInstances (for when a\n * TemplateResult is committed to a value of a ChildPart), and Directives; these\n * all implement a common interface called `DisconnectableChild`. Each has a\n * `_$parent` reference which is set during construction in the core code, and a\n * `_$disconnectableChildren` field which is initially undefined.\n *\n * The sparse tree created by means of the `AsyncDirective` constructor\n * crawling up the `_$parent` tree and placing a `_$disconnectableChildren` Set\n * on each parent that includes each child that contains a\n * `AsyncDirective` directly or transitively via its children. In order to\n * notify connection state changes and disconnect (or reconnect) a tree, the\n * `_$notifyConnectionChanged` API is patched onto ChildParts as a directive\n * climbs the parent tree, which is called by the core when clearing a part if\n * it exists. When called, that method iterates over the sparse tree of\n * Set<DisconnectableChildren> built up by AsyncDirectives, and calls\n * `_$notifyDirectiveConnectionChanged` on any directives that are encountered\n * in that tree, running the required callbacks.\n *\n * A given \"logical tree\" of lit-html data-structures might look like this:\n *\n * ChildPart(N1) _$dC=[D2,T3]\n * ._directive\n * AsyncDirective(D2)\n * ._value // user value was TemplateResult\n * TemplateInstance(T3) _$dC=[A4,A6,N10,N12]\n * ._parts[]\n * AttributePart(A4) _$dC=[D5]\n * ._directives[]\n * AsyncDirective(D5)\n * AttributePart(A6) _$dC=[D7,D8]\n * ._directives[]\n * AsyncDirective(D7)\n * Directive(D8) _$dC=[D9]\n * ._directive\n * AsyncDirective(D9)\n * ChildPart(N10) _$dC=[D11]\n * ._directive\n * AsyncDirective(D11)\n * ._value\n * string\n * ChildPart(N12) _$dC=[D13,N14,N16]\n * ._directive\n * AsyncDirective(D13)\n * ._value // user value was iterable\n * Array<ChildPart>\n * ChildPart(N14) _$dC=[D15]\n * ._value\n * string\n * ChildPart(N16) _$dC=[D17,T18]\n * ._directive\n * AsyncDirective(D17)\n * ._value // user value was TemplateResult\n * TemplateInstance(T18) _$dC=[A19,A21,N25]\n * ._parts[]\n * AttributePart(A19) _$dC=[D20]\n * ._directives[]\n * AsyncDirective(D20)\n * AttributePart(A21) _$dC=[22,23]\n * ._directives[]\n * AsyncDirective(D22)\n * Directive(D23) _$dC=[D24]\n * ._directive\n * AsyncDirective(D24)\n * ChildPart(N25) _$dC=[D26]\n * ._directive\n * AsyncDirective(D26)\n * ._value\n * string\n *\n * Example 1: The directive in ChildPart(N12) updates and returns `nothing`. The\n * ChildPart will _clear() itself, and so we need to disconnect the \"value\" of\n * the ChildPart (but not its directive). In this case, when `_clear()` calls\n * `_$notifyConnectionChanged()`, we don't iterate all of the\n * _$disconnectableChildren, rather we do a value-specific disconnection: i.e.\n * since the _value was an Array<ChildPart> (because an iterable had been\n * committed), we iterate the array of ChildParts (N14, N16) and run\n * `setConnected` on them (which does recurse down the full tree of\n * `_$disconnectableChildren` below it, and also removes N14 and N16 from N12's\n * `_$disconnectableChildren`). Once the values have been disconnected, we then\n * check whether the ChildPart(N12)'s list of `_$disconnectableChildren` is empty\n * (and would remove it from its parent TemplateInstance(T3) if so), but since\n * it would still contain its directive D13, it stays in the disconnectable\n * tree.\n *\n * Example 2: In the course of Example 1, `setConnected` will reach\n * ChildPart(N16); in this case the entire part is being disconnected, so we\n * simply iterate all of N16's `_$disconnectableChildren` (D17,T18) and\n * recursively run `setConnected` on them. Note that we only remove children\n * from `_$disconnectableChildren` for the top-level values being disconnected\n * on a clear; doing this bookkeeping lower in the tree is wasteful since it's\n * all being thrown away.\n *\n * Example 3: If the LitElement containing the entire tree above becomes\n * disconnected, it will run `childPart.setConnected()` (which calls\n * `childPart._$notifyConnectionChanged()` if it exists); in this case, we\n * recursively run `setConnected()` over the entire tree, without removing any\n * children from `_$disconnectableChildren`, since this tree is required to\n * re-connect the tree, which does the same operation, simply passing\n * `isConnected: true` down the tree, signaling which callback to run.\n */\n\nimport {AttributePart, ChildPart, Disconnectable, Part} from './lit-html.js';\nimport {isSingleExpression} from './directive-helpers.js';\nimport {Directive, PartInfo, PartType} from './directive.js';\nexport * from './directive.js';\n\nconst DEV_MODE = true;\n\n/**\n * Recursively walks down the tree of Parts/TemplateInstances/Directives to set\n * the connected state of directives and run `disconnected`/ `reconnected`\n * callbacks.\n *\n * @return True if there were children to disconnect; false otherwise\n */\nconst notifyChildrenConnectedChanged = (\n parent: Disconnectable,\n isConnected: boolean\n): boolean => {\n const children = parent._$disconnectableChildren;\n if (children === undefined) {\n return false;\n }\n for (const obj of children) {\n // The existence of `_$notifyDirectiveConnectionChanged` is used as a \"brand\" to\n // disambiguate AsyncDirectives from other DisconnectableChildren\n // (as opposed to using an instanceof check to know when to call it); the\n // redundancy of \"Directive\" in the API name is to avoid conflicting with\n // `_$notifyConnectionChanged`, which exists `ChildParts` which are also in\n // this list\n // Disconnect Directive (and any nested directives contained within)\n // This property needs to remain unminified.\n (obj as AsyncDirective)['_$notifyDirectiveConnectionChanged']?.(\n isConnected,\n false\n );\n // Disconnect Part/TemplateInstance\n notifyChildrenConnectedChanged(obj, isConnected);\n }\n return true;\n};\n\n/**\n * Removes the given child from its parent list of disconnectable children, and\n * if the parent list becomes empty as a result, removes the parent from its\n * parent, and so forth up the tree when that causes subsequent parent lists to\n * become empty.\n */\nconst removeDisconnectableFromParent = (obj: Disconnectable) => {\n let parent, children;\n do {\n if ((parent = obj._$parent) === undefined) {\n break;\n }\n children = parent._$disconnectableChildren!;\n children.delete(obj);\n obj = parent;\n } while (children?.size === 0);\n};\n\nconst addDisconnectableToParent = (obj: Disconnectable) => {\n // Climb the parent tree, creating a sparse tree of children needing\n // disconnection\n for (let parent; (parent = obj._$parent); obj = parent) {\n let children = parent._$disconnectableChildren;\n if (children === undefined) {\n parent._$disconnectableChildren = children = new Set();\n } else if (children.has(obj)) {\n // Once we've reached a parent that already contains this child, we\n // can short-circuit\n break;\n }\n children.add(obj);\n installDisconnectAPI(parent);\n }\n};\n\n/**\n * Changes the parent reference of the ChildPart, and updates the sparse tree of\n * Disconnectable children accordingly.\n *\n * Note, this method will be patched onto ChildPart instances and called from\n * the core code when parts are moved between different parents.\n */\nfunction reparentDisconnectables(this: ChildPart, newParent: Disconnectable) {\n if (this._$disconnectableChildren !== undefined) {\n removeDisconnectableFromParent(this);\n this._$parent = newParent;\n addDisconnectableToParent(this);\n } else {\n this._$parent = newParent;\n }\n}\n\n/**\n * Sets the connected state on any directives contained within the committed\n * value of this part (i.e. within a TemplateInstance or iterable of\n * ChildParts) and runs their `disconnected`/`reconnected`s, as well as within\n * any directives stored on the ChildPart (when `valueOnly` is false).\n *\n * `isClearingValue` should be passed as `true` on a top-level part that is\n * clearing itself, and not as a result of recursively disconnecting directives\n * as part of a `clear` operation higher up the tree. This both ensures that any\n * directive on this ChildPart that produced a value that caused the clear\n * operation is not disconnected, and also serves as a performance optimization\n * to avoid needless bookkeeping when a subtree is going away; when clearing a\n * subtree, only the top-most part need to remove itself from the parent.\n *\n * `fromPartIndex` is passed only in the case of a partial `_clear` running as a\n * result of truncating an iterable.\n *\n * Note, this method will be patched onto ChildPart instances and called from the\n * core code when parts are cleared or the connection state is changed by the\n * user.\n */\nfunction notifyChildPartConnectedChanged(\n this: ChildPart,\n isConnected: boolean,\n isClearingValue = false,\n fromPartIndex = 0\n) {\n const value = this._$committedValue;\n const children = this._$disconnectableChildren;\n if (children === undefined || children.size === 0) {\n return;\n }\n if (isClearingValue) {\n if (Array.isArray(value)) {\n // Iterable case: Any ChildParts created by the iterable should be\n // disconnected and removed from this ChildPart's disconnectable\n // children (starting at `fromPartIndex` in the case of truncation)\n for (let i = fromPartIndex; i < value.length; i++) {\n notifyChildrenConnectedChanged(value[i], false);\n removeDisconnectableFromParent(value[i]);\n }\n } else if (value != null) {\n // TemplateInstance case: If the value has disconnectable children (will\n // only be in the case that it is a TemplateInstance), we disconnect it\n // and remove it from this ChildPart's disconnectable children\n notifyChildrenConnectedChanged(value as Disconnectable, false);\n removeDisconnectableFromParent(value as Disconnectable);\n }\n } else {\n notifyChildrenConnectedChanged(this, isConnected);\n }\n}\n\n/**\n * Patches disconnection API onto ChildParts.\n */\nconst installDisconnectAPI = (obj: Disconnectable) => {\n if ((obj as ChildPart).type == PartType.CHILD) {\n (obj as ChildPart)._$notifyConnectionChanged ??=\n notifyChildPartConnectedChanged;\n (obj as ChildPart)._$reparentDisconnectables ??= reparentDisconnectables;\n }\n};\n\n/**\n * An abstract `Directive` base class whose `disconnected` method will be\n * called when the part containing the directive is cleared as a result of\n * re-rendering, or when the user calls `part.setConnected(false)` on\n * a part that was previously rendered containing the directive (as happens\n * when e.g. a LitElement disconnects from the DOM).\n *\n * If `part.setConnected(true)` is subsequently called on a\n * containing part, the directive's `reconnected` method will be called prior\n * to its next `update`/`render` callbacks. When implementing `disconnected`,\n * `reconnected` should also be implemented to be compatible with reconnection.\n *\n * Note that updates may occur while the directive is disconnected. As such,\n * directives should generally check the `this.isConnected` flag during\n * render/update to determine whether it is safe to subscribe to resources\n * that may prevent garbage collection.\n */\nexport abstract class AsyncDirective extends Directive {\n // As opposed to other Disconnectables, AsyncDirectives always get notified\n // when the RootPart connection changes, so the public `isConnected`\n // is a locally stored variable initialized via its part's getter and synced\n // via `_$notifyDirectiveConnectionChanged`. This is cheaper than using\n // the _$isConnected getter, which has to look back up the tree each time.\n /**\n * The connection state for this Directive.\n */\n isConnected!: boolean;\n\n // @internal\n override _$disconnectableChildren?: Set<Disconnectable> = undefined;\n /**\n * Initialize the part with internal fields\n * @param part\n * @param parent\n * @param attributeIndex\n */\n override _$initialize(\n part: Part,\n parent: Disconnectable,\n attributeIndex: number | undefined\n ) {\n super._$initialize(part, parent, attributeIndex);\n addDisconnectableToParent(this);\n this.isConnected = part._$isConnected;\n }\n // This property needs to remain unminified.\n /**\n * Called from the core code when a directive is going away from a part (in\n * which case `shouldRemoveFromParent` should be true), and from the\n * `setChildrenConnected` helper function when recursively changing the\n * connection state of a tree (in which case `shouldRemoveFromParent` should\n * be false).\n *\n * @param isConnected\n * @param isClearingDirective - True when the directive itself is being\n * removed; false when the tree is being disconnected\n * @internal\n */\n override ['_$notifyDirectiveConnectionChanged'](\n isConnected: boolean,\n isClearingDirective = true\n ) {\n if (isConnected !== this.isConnected) {\n this.isConnected = isConnected;\n if (isConnected) {\n this.reconnected?.();\n } else {\n this.disconnected?.();\n }\n }\n if (isClearingDirective) {\n notifyChildrenConnectedChanged(this, isConnected);\n removeDisconnectableFromParent(this);\n }\n }\n\n /**\n * Sets the value of the directive's Part outside the normal `update`/`render`\n * lifecycle of a directive.\n *\n * This method should not be called synchronously from a directive's `update`\n * or `render`.\n *\n * @param directive The directive to update\n * @param value The value to set\n */\n setValue(value: unknown) {\n if (isSingleExpression(this.__part as unknown as PartInfo)) {\n this.__part._$setValue(value, this);\n } else {\n // this.__attributeIndex will be defined in this case, but\n // assert it in dev mode\n if (DEV_MODE && this.__attributeIndex === undefined) {\n throw new Error(`Expected this.__attributeIndex to be a number`);\n }\n const newValues = [...(this.__part._$committedValue as Array<unknown>)];\n newValues[this.__attributeIndex!] = value;\n (this.__part as AttributePart)._$setValue(newValues, this, 0);\n }\n }\n\n /**\n * User callbacks for implementing logic to release any resources/subscriptions\n * that may have been retained by this directive. Since directives may also be\n * re-connected, `reconnected` should also be implemented to restore the\n * working state of the directive prior to the next render.\n */\n protected disconnected() {}\n protected reconnected() {}\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// Note, this module is not included in package exports so that it's private to\n// our first-party directives. If it ends up being useful, we can open it up and\n// export it.\n\n/**\n * Helper to iterate an AsyncIterable in its own closure.\n * @param iterable The iterable to iterate\n * @param callback The callback to call for each value. If the callback returns\n * `false`, the loop will be broken.\n */\nexport const forAwaitOf = async <T>(\n iterable: AsyncIterable<T>,\n callback: (value: T) => Promise<boolean>\n) => {\n for await (const v of iterable) {\n if ((await callback(v)) === false) {\n return;\n }\n }\n};\n\n/**\n * Holds a reference to an instance that can be disconnected and reconnected,\n * so that a closure over the ref (e.g. in a then function to a promise) does\n * not strongly hold a ref to the instance. Approximates a WeakRef but must\n * be manually connected & disconnected to the backing instance.\n */\nexport class PseudoWeakRef<T> {\n private _ref?: T;\n constructor(ref: T) {\n this._ref = ref;\n }\n /**\n * Disassociates the ref with the backing instance.\n */\n disconnect() {\n this._ref = undefined;\n }\n /**\n * Reassociates the ref with the backing instance.\n */\n reconnect(ref: T) {\n this._ref = ref;\n }\n /**\n * Retrieves the backing instance (will be undefined when disconnected)\n */\n deref() {\n return this._ref;\n }\n}\n\n/**\n * A helper to pause and resume waiting on a condition in an async function\n */\nexport class Pauser {\n private _promise?: Promise<void> = undefined;\n private _resolve?: () => void = undefined;\n /**\n * When paused, returns a promise to be awaited; when unpaused, returns\n * undefined. Note that in the microtask between the pauser being resumed\n * an an await of this promise resolving, the pauser could be paused again,\n * hence callers should check the promise in a loop when awaiting.\n * @returns A promise to be awaited when paused or undefined\n */\n get() {\n return this._promise;\n }\n /**\n * Creates a promise to be awaited\n */\n pause() {\n this._promise ??= new Promise((resolve) => (this._resolve = resolve));\n }\n /**\n * Resolves the promise which may be awaited\n */\n resume() {\n this._resolve?.();\n this._promise = this._resolve = undefined;\n }\n}\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {\n AsyncDirective,\n directive,\n DirectiveParameters,\n} from '../async-directive.js';\nimport {Pauser, PseudoWeakRef, forAwaitOf} from './private-async-helpers.js';\n\ntype Mapper<T> = (v: T, index?: number) => unknown;\n\nexport class AsyncReplaceDirective extends AsyncDirective {\n private __value?: AsyncIterable<unknown>;\n private __weakThis = new PseudoWeakRef(this);\n private __pauser = new Pauser();\n\n // @ts-expect-error value not used, but we want a nice parameter for docs\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>) {\n return noChange;\n }\n\n override update(\n _part: ChildPart,\n [value, mapper]: DirectiveParameters<this>\n ) {\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n // If we've already set up this particular iterable, we don't need\n // to do anything.\n if (value === this.__value) {\n return;\n }\n this.__value = value;\n let i = 0;\n const {__weakThis: weakThis, __pauser: pauser} = this;\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n forAwaitOf(value, async (v: unknown) => {\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n // Check to make sure that value is the still the current value of\n // the part, and if not bail because a new value owns this part\n if (_this.__value !== value) {\n return false;\n }\n\n // As a convenience, because functional-programming-style\n // transforms of iterables and async iterables requires a library,\n // we accept a mapper function. This is especially convenient for\n // rendering a template for each item.\n if (mapper !== undefined) {\n v = mapper(v, i);\n }\n\n _this.commitValue(v, i);\n i++;\n }\n return true;\n });\n return noChange;\n }\n\n // Override point for AsyncAppend to append rather than replace\n protected commitValue(value: unknown, _index: number) {\n this.setValue(value);\n }\n\n override disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n\n override reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], replacing\n * previous values with new values, so that only one value is ever rendered\n * at a time. This directive may be used in any expression type.\n *\n * Async iterables are objects with a `[Symbol.asyncIterator]` method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is rendered to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncReplace = directive(AsyncReplaceDirective);\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart} from '../lit-html.js';\nimport {\n directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {AsyncReplaceDirective} from './async-replace.js';\nimport {\n clearPart,\n insertPart,\n setChildPartValue,\n} from '../directive-helpers.js';\n\nclass AsyncAppendDirective extends AsyncReplaceDirective {\n private __childPart!: ChildPart;\n\n // Override AsyncReplace to narrow the allowed part type to ChildPart only\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('asyncAppend can only be used in child expressions');\n }\n }\n\n // Override AsyncReplace to save the part since we need to append into it\n override update(part: ChildPart, params: DirectiveParameters<this>) {\n this.__childPart = part;\n return super.update(part, params);\n }\n\n // Override AsyncReplace to append rather than replace\n protected override commitValue(value: unknown, index: number) {\n // When we get the first value, clear the part. This lets the\n // previous value display until we can replace it.\n if (index === 0) {\n clearPart(this.__childPart);\n }\n // Create and insert a new part and set its value to the next value\n const newPart = insertPart(this.__childPart);\n setChildPartValue(newPart, value);\n }\n}\n\n/**\n * A directive that renders the items of an async iterable[1], appending new\n * values after previous values, similar to the built-in support for iterables.\n * This directive is usable only in child expressions.\n *\n * Async iterables are objects with a [Symbol.asyncIterator] method, which\n * returns an iterator who's `next()` method returns a Promise. When a new\n * value is available, the Promise resolves and the value is appended to the\n * Part controlled by the directive. If another value other than this\n * directive has been set on the Part, the iterable will no longer be listened\n * to and new values won't be written to the Part.\n *\n * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n *\n * @param value An async iterable\n * @param mapper An optional function that maps from (value, index) to another\n * value. Useful for generating templates for each item in the iterable.\n */\nexport const asyncAppend = directive(AsyncAppendDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {AsyncAppendDirective};\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {\n TemplateResult,\n ChildPart,\n RootPart,\n render,\n nothing,\n} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n} from '../directive.js';\nimport {\n clearPart,\n getCommittedValue,\n insertPart,\n isTemplateResult,\n setCommittedValue,\n} from '../directive-helpers.js';\n\nclass CacheDirective extends Directive {\n private _templateCache = new WeakMap<TemplateStringsArray, RootPart>();\n private _value?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n }\n\n render(v: unknown) {\n // Return an array of the value to induce lit-html to create a ChildPart\n // for the value that we can move into the cache.\n return [v];\n }\n\n override update(containerPart: ChildPart, [v]: DirectiveParameters<this>) {\n // If the previous value is a TemplateResult and the new value is not,\n // or is a different Template as the previous value, move the child part\n // into the cache.\n if (\n isTemplateResult(this._value) &&\n (!isTemplateResult(v) || this._value.strings !== v.strings)\n ) {\n // This is always an array because we return [v] in render()\n const partValue = getCommittedValue(containerPart) as Array<ChildPart>;\n const childPart = partValue.pop()!;\n let cachedContainerPart = this._templateCache.get(this._value.strings);\n if (cachedContainerPart === undefined) {\n const fragment = document.createDocumentFragment();\n cachedContainerPart = render(nothing, fragment);\n cachedContainerPart.setConnected(false);\n this._templateCache.set(this._value.strings, cachedContainerPart);\n }\n // Move into cache\n setCommittedValue(cachedContainerPart, [childPart]);\n insertPart(cachedContainerPart, undefined, childPart);\n }\n // If the new value is a TemplateResult and the previous value is not,\n // or is a different Template as the previous value, restore the child\n // part from the cache.\n if (isTemplateResult(v)) {\n if (!isTemplateResult(this._value) || this._value.strings !== v.strings) {\n const cachedContainerPart = this._templateCache.get(v.strings);\n if (cachedContainerPart !== undefined) {\n // Move the cached part back into the container part value\n const partValue = getCommittedValue(\n cachedContainerPart\n ) as Array<ChildPart>;\n const cachedPart = partValue.pop()!;\n // Move cached part back into DOM\n clearPart(containerPart);\n insertPart(containerPart, undefined, cachedPart);\n setCommittedValue(containerPart, [cachedPart]);\n }\n }\n this._value = v;\n } else {\n this._value = undefined;\n }\n return this.render(v);\n }\n}\n\n/**\n * Enables fast switching between multiple templates by caching the DOM nodes\n * and TemplateInstances produced by the templates.\n *\n * Example:\n *\n * ```js\n * let checked = false;\n *\n * html`\n * ${cache(checked ? html`input is checked` : html`input is not checked`)}\n * `\n * ```\n */\nexport const cache = directive(CacheDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {CacheDirective};\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Chooses and evaluates a template function from a list based on matching\n * the given `value` to a case.\n *\n * Cases are structured as `[caseValue, func]`. `value` is matched to\n * `caseValue` by strict equality. The first match is selected. Case values\n * can be of any type including primitives, objects, and symbols.\n *\n * This is similar to a switch statement, but as an expression and without\n * fallthrough.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * ${choose(this.section, [\n * ['home', () => html`<h1>Home</h1>`],\n * ['about', () => html`<h1>About</h1>`]\n * ],\n * () => html`<h1>Error</h1>`)}\n * `;\n * }\n * ```\n */\nexport const choose = <T, V>(\n value: T,\n cases: Array<[T, () => V]>,\n defaultCase?: () => V\n) => {\n for (const c of cases) {\n const caseValue = c[0];\n if (caseValue === value) {\n const fn = c[1];\n return fn();\n }\n }\n return defaultCase?.();\n};\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of class names to truthy values.\n */\nexport interface ClassInfo {\n readonly [name: string]: string | boolean | number;\n}\n\nclass ClassMapDirective extends Directive {\n /**\n * Stores the ClassInfo object applied to a given AttributePart.\n * Used to unset existing values when a new ClassInfo object is applied.\n */\n private _previousClasses?: Set<string>;\n private _staticClasses?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'class' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n '`classMap()` can only be used in the `class` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(classInfo: ClassInfo) {\n // Add spaces to ensure separation from static classes\n return (\n ' ' +\n Object.keys(classInfo)\n .filter((key) => classInfo[key])\n .join(' ') +\n ' '\n );\n }\n\n override update(part: AttributePart, [classInfo]: DirectiveParameters<this>) {\n // Remember dynamic classes on the first render\n if (this._previousClasses === undefined) {\n this._previousClasses = new Set();\n if (part.strings !== undefined) {\n this._staticClasses = new Set(\n part.strings\n .join(' ')\n .split(/\\s/)\n .filter((s) => s !== '')\n );\n }\n for (const name in classInfo) {\n if (classInfo[name] && !this._staticClasses?.has(name)) {\n this._previousClasses.add(name);\n }\n }\n return this.render(classInfo);\n }\n\n const classList = part.element.classList;\n\n // Remove old classes that no longer apply\n // We use forEach() instead of for-of so that we don't require down-level\n // iteration.\n this._previousClasses.forEach((name) => {\n if (!(name in classInfo)) {\n classList.remove(name);\n this._previousClasses!.delete(name);\n }\n });\n\n // Add or remove classes based on their classMap value\n for (const name in classInfo) {\n // We explicitly want a loose truthy check of `value` because it seems\n // more convenient that '' and 0 are skipped.\n const value = !!classInfo[name];\n if (\n value !== this._previousClasses.has(name) &&\n !this._staticClasses?.has(name)\n ) {\n if (value) {\n classList.add(name);\n this._previousClasses.add(name);\n } else {\n classList.remove(name);\n this._previousClasses.delete(name);\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies dynamic CSS classes.\n *\n * This must be used in the `class` attribute and must be the only part used in\n * the attribute. It takes each property in the `classInfo` argument and adds\n * the property name to the element's `classList` if the property value is\n * truthy; if the property value is falsey, the property name is removed from\n * the element's `class`.\n *\n * For example `{foo: bar}` applies the class `foo` if the value of `bar` is\n * truthy.\n *\n * @param classInfo\n */\nexport const classMap = directive(ClassMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {ClassMapDirective};\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {noChange, Part} from '../lit-html.js';\nimport {directive, Directive, DirectiveParameters} from '../directive.js';\n\n// A sentinal that indicates guard() hasn't rendered anything yet\nconst initialValue = {};\n\nclass GuardDirective extends Directive {\n private _previousValue: unknown = initialValue;\n\n render(_value: unknown, f: () => unknown) {\n return f();\n }\n\n override update(_part: Part, [value, f]: DirectiveParameters<this>) {\n if (Array.isArray(value)) {\n // Dirty-check arrays by item\n if (\n Array.isArray(this._previousValue) &&\n this._previousValue.length === value.length &&\n value.every((v, i) => v === (this._previousValue as Array<unknown>)[i])\n ) {\n return noChange;\n }\n } else if (this._previousValue === value) {\n // Dirty-check non-arrays by identity\n return noChange;\n }\n\n // Copy the value if it's an array so that if it's mutated we don't forget\n // what the previous values were.\n this._previousValue = Array.isArray(value) ? Array.from(value) : value;\n const r = this.render(value, f);\n return r;\n }\n}\n\n/**\n * Prevents re-render of a template function until a single value or an array of\n * values changes.\n *\n * Values are checked against previous values with strict equality (`===`), and\n * so the check won't detect nested property changes inside objects or arrays.\n * Arrays values have each item checked against the previous value at the same\n * index with strict equality. Nested arrays are also checked only by strict\n * equality.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([user.id, company.id], () => html`...`)}\n * </div>\n * `\n * ```\n *\n * In this case, the template only rerenders if either `user.id` or `company.id`\n * changes.\n *\n * guard() is useful with immutable data patterns, by preventing expensive work\n * until data updates.\n *\n * Example:\n *\n * ```js\n * html`\n * <div>\n * ${guard([immutableItems], () => immutableItems.map(i => html`${i}`))}\n * </div>\n * `\n * ```\n *\n * In this case, items are mapped over only when the array reference changes.\n *\n * @param value the value to check before re-rendering\n * @param f the template function\n */\nexport const guard = directive(GuardDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {GuardDirective};\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\n\n/**\n * For AttributeParts, sets the attribute if the value is defined and removes\n * the attribute if the value is undefined.\n *\n * For other part types, this directive is a no-op.\n */\nexport const ifDefined = <T>(value: T) => value ?? nothing;\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Returns an iterable containing the values in `items` interleaved with the\n * `joiner` value.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * ${join(items, html`<span class=\"separator\">|</span>`)}\n * `;\n * }\n */\nexport function join<I, J>(\n items: Iterable<I> | undefined,\n joiner: (index: number) => J\n): Iterable<I | J>;\nexport function join<I, J>(\n items: Iterable<I> | undefined,\n joiner: J\n): Iterable<I | J>;\nexport function* join<I, J>(items: Iterable<I> | undefined, joiner: J) {\n const isFunction = typeof joiner === 'function';\n if (items !== undefined) {\n let i = -1;\n for (const value of items) {\n if (i > -1) {\n yield isFunction ? joiner(i) : joiner;\n }\n i++;\n yield value;\n }\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n ChildPart,\n DirectiveParameters,\n} from '../directive.js';\nimport {setCommittedValue} from '../directive-helpers.js';\n\nclass Keyed extends Directive {\n key: unknown = nothing;\n\n render(k: unknown, v: unknown) {\n this.key = k;\n return v;\n }\n\n override update(part: ChildPart, [k, v]: DirectiveParameters<this>) {\n if (k !== this.key) {\n // Clear the part before returning a value. The one-arg form of\n // setCommittedValue sets the value to a sentinel which forces a\n // commit the next render.\n setCommittedValue(part);\n this.key = k;\n }\n return v;\n }\n}\n\n/**\n * Associates a renderable value with a unique key. When the key changes, the\n * previous DOM is removed and disposed before rendering the next value, even\n * if the value - such as a template - is the same.\n *\n * This is useful for forcing re-renders of stateful components, or working\n * with code that expects new data to generate new HTML elements, such as some\n * animation techniques.\n */\nexport const keyed = directive(Keyed);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {Keyed};\n","/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange, nothing} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\nimport {isSingleExpression, setCommittedValue} from '../directive-helpers.js';\n\nclass LiveDirective extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n !(\n partInfo.type === PartType.PROPERTY ||\n partInfo.type === PartType.ATTRIBUTE ||\n partInfo.type === PartType.BOOLEAN_ATTRIBUTE\n )\n ) {\n throw new Error(\n 'The `live` directive is not allowed on child or event bindings'\n );\n }\n if (!isSingleExpression(partInfo)) {\n throw new Error('`live` bindings can only contain a single expression');\n }\n }\n\n render(value: unknown) {\n return value;\n }\n\n override update(part: AttributePart, [value]: DirectiveParameters<this>) {\n if (value === noChange || value === nothing) {\n return value;\n }\n const element = part.element;\n const name = part.name;\n\n if (part.type === PartType.PROPERTY) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n if (value === (element as any)[name]) {\n return noChange;\n }\n } else if (part.type === PartType.BOOLEAN_ATTRIBUTE) {\n if (!!value === element.hasAttribute(name)) {\n return noChange;\n }\n } else if (part.type === PartType.ATTRIBUTE) {\n if (element.getAttribute(name) === String(value)) {\n return noChange;\n }\n }\n // Resets the part's value, causing its dirty-check to fail so that it\n // always sets the value.\n setCommittedValue(part);\n return value;\n }\n}\n\n/**\n * Checks binding values against live DOM values, instead of previously bound\n * values, when determining whether to update the value.\n *\n * This is useful for cases where the DOM value may change from outside of\n * lit-html, such as with a binding to an `<input>` element's `value` property,\n * a content editable elements text, or to a custom element that changes it's\n * own properties or attributes.\n *\n * In these cases if the DOM value changes, but the value set through lit-html\n * bindings hasn't, lit-html won't know to update the DOM value and will leave\n * it alone. If this is not what you want--if you want to overwrite the DOM\n * value with the bound value no matter what--use the `live()` directive:\n *\n * ```js\n * html`<input .value=${live(x)}>`\n * ```\n *\n * `live()` performs a strict equality check against the live DOM value, and if\n * the new value is equal to the live value, does nothing. This means that\n * `live()` should not be used when the binding will cause a type conversion. If\n * you use `live()` with an attribute binding, make sure that only strings are\n * passed in, or the binding will update every render.\n */\nexport const live = directive(LiveDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {LiveDirective};\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Returns an iterable containing the result of calling `f(value)` on each\n * value in `items`.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * <ul>\n * ${map(items, (i) => html`<li>${i}</li>`)}\n * </ul>\n * `;\n * }\n * ```\n */\nexport function* map<T>(\n items: Iterable<T> | undefined,\n f: (value: T, index: number) => unknown\n) {\n if (items !== undefined) {\n let i = 0;\n for (const value of items) {\n yield f(value, i++);\n }\n }\n}\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Returns an iterable of integers from `start` to `end` (exclusive)\n * incrementing by `step`.\n *\n * If `start` is omitted, the range starts at `0`. `step` defaults to `1`.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * ${map(range(8), () => html`<div class=\"cell\"></div>`)}\n * `;\n * }\n * ```\n */\nexport function range(end: number): Iterable<number>;\nexport function range(\n start: number,\n end: number,\n step?: number\n): Iterable<number>;\nexport function* range(startOrEnd: number, end?: number, step = 1) {\n const start = end === undefined ? 0 : startOrEnd;\n end ??= startOrEnd;\n for (let i = start; step > 0 ? i < end : end < i; i += step) {\n yield i;\n }\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\nimport {nothing, ElementPart} from '../lit-html.js';\nimport {directive, AsyncDirective} from '../async-directive.js';\n\n/**\n * Creates a new Ref object, which is container for a reference to an element.\n */\nexport const createRef = <T = Element>() => new Ref<T>();\n\n/**\n * An object that holds a ref value.\n */\nclass Ref<T = Element> {\n /**\n * The current Element value of the ref, or else `undefined` if the ref is no\n * longer rendered.\n */\n readonly value?: T;\n}\n\nexport type {Ref};\n\ninterface RefInternal {\n value: Element | undefined;\n}\n\n// When callbacks are used for refs, this map tracks the last value the callback\n// was called with, for ensuring a directive doesn't clear the ref if the ref\n// has already been rendered to a new spot. It is double-keyed on both the\n// context (`options.host`) and the callback, since we auto-bind class methods\n// to `options.host`.\nconst lastElementForContextAndCallback: WeakMap<\n object,\n WeakMap<Function, Element | undefined>\n> = new WeakMap();\n\nexport type RefOrCallback = Ref | ((el: Element | undefined) => void);\n\nclass RefDirective extends AsyncDirective {\n private _element?: Element;\n private _ref?: RefOrCallback;\n private _context?: object;\n\n render(_ref: RefOrCallback) {\n return nothing;\n }\n\n override update(part: ElementPart, [ref]: Parameters<this['render']>) {\n const refChanged = ref !== this._ref;\n if (refChanged && this._ref !== undefined) {\n // The ref passed to the directive has changed;\n // unset the previous ref's value\n this._updateRefValue(undefined);\n }\n if (refChanged || this._lastElementForRef !== this._element) {\n // We either got a new ref or this is the first render;\n // store the ref/element & update the ref value\n this._ref = ref;\n this._context = part.options?.host;\n this._updateRefValue((this._element = part.element));\n }\n return nothing;\n }\n\n private _updateRefValue(element: Element | undefined) {\n if (typeof this._ref === 'function') {\n // If the current ref was called with a previous value, call with\n // `undefined`; We do this to ensure callbacks are called in a consistent\n // way regardless of whether a ref might be moving up in the tree (in\n // which case it would otherwise be called with the new value before the\n // previous one unsets it) and down in the tree (where it would be unset\n // before being set). Note that element lookup is keyed by\n // both the context and the callback, since we allow passing unbound\n // functions that are called on options.host, and we want to treat\n // these as unique \"instances\" of a function.\n const context = this._context ?? globalThis;\n let lastElementForCallback =\n lastElementForContextAndCallback.get(context);\n if (lastElementForCallback === undefined) {\n lastElementForCallback = new WeakMap();\n lastElementForContextAndCallback.set(context, lastElementForCallback);\n }\n if (lastElementForCallback.get(this._ref) !== undefined) {\n this._ref.call(this._context, undefined);\n }\n lastElementForCallback.set(this._ref, element);\n // Call the ref with the new element value\n if (element !== undefined) {\n this._ref.call(this._context, element);\n }\n } else {\n (this._ref as RefInternal)!.value = element;\n }\n }\n\n private get _lastElementForRef() {\n return typeof this._ref === 'function'\n ? lastElementForContextAndCallback\n .get(this._context ?? globalThis)\n ?.get(this._ref)\n : this._ref?.value;\n }\n\n override disconnected() {\n // Only clear the box if our element is still the one in it (i.e. another\n // directive instance hasn't rendered its element to it before us); that\n // only happens in the event of the directive being cleared (not via manual\n // disconnection)\n if (this._lastElementForRef === this._element) {\n this._updateRefValue(undefined);\n }\n }\n\n override reconnected() {\n // If we were manually disconnected, we can safely put our element back in\n // the box, since no rendering could have occurred to change its state\n this._updateRefValue(this._element);\n }\n}\n\n/**\n * Sets the value of a Ref object or calls a ref callback with the element it's\n * bound to.\n *\n * A Ref object acts as a container for a reference to an element. A ref\n * callback is a function that takes an element as its only argument.\n *\n * The ref directive sets the value of the Ref object or calls the ref callback\n * during rendering, if the referenced element changed.\n *\n * Note: If a ref callback is rendered to a different element position or is\n * removed in a subsequent render, it will first be called with `undefined`,\n * followed by another call with the new element it was rendered to (if any).\n *\n * ```js\n * // Using Ref object\n * const inputRef = createRef();\n * render(html`<input ${ref(inputRef)}>`, container);\n * inputRef.value.focus();\n *\n * // Using callback\n * const callback = (inputElement) => inputElement.focus();\n * render(html`<input ${ref(callback)}>`, container);\n * ```\n */\nexport const ref = directive(RefDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RefDirective};\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {ChildPart, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\nimport {\n insertPart,\n getCommittedValue,\n removePart,\n setCommittedValue,\n setChildPartValue,\n} from '../directive-helpers.js';\n\nexport type KeyFn<T> = (item: T, index: number) => unknown;\nexport type ItemTemplate<T> = (item: T, index: number) => unknown;\n\n// Helper for generating a map of array item to its index over a subset\n// of an array (used to lazily generate `newKeyToIndexMap` and\n// `oldKeyToIndexMap`)\nconst generateMap = (list: unknown[], start: number, end: number) => {\n const map = new Map<unknown, number>();\n for (let i = start; i <= end; i++) {\n map.set(list[i], i);\n }\n return map;\n};\n\nclass RepeatDirective extends Directive {\n private _itemKeys?: unknown[];\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('repeat() can only be used in text expressions');\n }\n }\n\n private _getValuesAndKeys<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n let keyFn: KeyFn<T> | undefined;\n if (template === undefined) {\n template = keyFnOrTemplate;\n } else if (keyFnOrTemplate !== undefined) {\n keyFn = keyFnOrTemplate as KeyFn<T>;\n }\n const keys = [];\n const values = [];\n let index = 0;\n for (const item of items) {\n keys[index] = keyFn ? keyFn(item, index) : index;\n values[index] = template!(item, index);\n index++;\n }\n return {\n values,\n keys,\n };\n }\n\n render<T>(items: Iterable<T>, template: ItemTemplate<T>): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): Array<unknown>;\n render<T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ) {\n return this._getValuesAndKeys(items, keyFnOrTemplate, template).values;\n }\n\n override update<T>(\n containerPart: ChildPart,\n [items, keyFnOrTemplate, template]: [\n Iterable<T>,\n KeyFn<T> | ItemTemplate<T>,\n ItemTemplate<T>\n ]\n ) {\n // Old part & key lists are retrieved from the last update (which may\n // be primed by hydration)\n const oldParts = getCommittedValue(\n containerPart\n ) as Array<ChildPart | null>;\n const {values: newValues, keys: newKeys} = this._getValuesAndKeys(\n items,\n keyFnOrTemplate,\n template\n );\n\n // We check that oldParts, the committed value, is an Array as an\n // indicator that the previous value came from a repeat() call. If\n // oldParts is not an Array then this is the first render and we return\n // an array for lit-html's array handling to render, and remember the\n // keys.\n if (!Array.isArray(oldParts)) {\n this._itemKeys = newKeys;\n return newValues;\n }\n\n // In SSR hydration it's possible for oldParts to be an arrray but for us\n // to not have item keys because the update() hasn't run yet. We set the\n // keys to an empty array. This will cause all oldKey/newKey comparisons\n // to fail and execution to fall to the last nested brach below which\n // reuses the oldPart.\n const oldKeys = (this._itemKeys ??= []);\n\n // New part list will be built up as we go (either reused from\n // old parts or created for new keys in this update). This is\n // saved in the above cache at the end of the update.\n const newParts: ChildPart[] = [];\n\n // Maps from key to index for current and previous update; these\n // are generated lazily only when needed as a performance\n // optimization, since they are only required for multiple\n // non-contiguous changes in the list, which are less common.\n let newKeyToIndexMap!: Map<unknown, number>;\n let oldKeyToIndexMap!: Map<unknown, number>;\n\n // Head and tail pointers to old parts and new values\n let oldHead = 0;\n let oldTail = oldParts.length - 1;\n let newHead = 0;\n let newTail = newValues.length - 1;\n\n // Overview of O(n) reconciliation algorithm (general approach\n // based on ideas found in ivi, vue, snabbdom, etc.):\n //\n // * We start with the list of old parts and new values (and\n // arrays of their respective keys), head/tail pointers into\n // each, and we build up the new list of parts by updating\n // (and when needed, moving) old parts or creating new ones.\n // The initial scenario might look like this (for brevity of\n // the diagrams, the numbers in the array reflect keys\n // associated with the old parts or new values, although keys\n // and parts/values are actually stored in parallel arrays\n // indexed using the same head/tail pointers):\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [ , , , , , , ]\n // newKeys: [0, 2, 1, 4, 3, 7, 6] <- reflects the user's new\n // item order\n // newHead ^ ^ newTail\n //\n // * Iterate old & new lists from both sides, updating,\n // swapping, or removing parts at the head/tail locations\n // until neither head nor tail can move.\n //\n // * Example below: keys at head pointers match, so update old\n // part 0 in-place (no need to move it) and record part 0 in\n // the `newParts` list. The last thing we do is advance the\n // `oldHead` and `newHead` pointers (will be reflected in the\n // next diagram).\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , ] <- heads matched: update 0\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: head pointers don't match, but tail\n // pointers do, so update part 6 in place (no need to move\n // it), and record part 6 in the `newParts` list. Last,\n // advance the `oldTail` and `oldHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- tails matched: update 6\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldTail\n // & newTail\n // newHead ^ ^ newTail\n //\n // * If neither head nor tail match; next check if one of the\n // old head/tail items was removed. We first need to generate\n // the reverse map of new keys to index (`newKeyToIndexMap`),\n // which is done once lazily as a performance optimization,\n // since we only hit this case if multiple non-contiguous\n // changes were made. Note that for contiguous removal\n // anywhere in the list, the head and tails would advance\n // from either end and pass each other before we get to this\n // case and removals would be handled in the final while loop\n // without needing to generate the map.\n //\n // * Example below: The key at `oldTail` was removed (no longer\n // in the `newKeyToIndexMap`), so remove that part from the\n // DOM and advance just the `oldTail` pointer.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, 2, 3, 4, 5, 6]\n // newParts: [0, , , , , , 6] <- 5 not in new map: remove\n // newKeys: [0, 2, 1, 4, 3, 7, 6] 5 and advance oldTail\n // newHead ^ ^ newTail\n //\n // * Once head and tail cannot move, any mismatches are due to\n // either new or moved items; if a new key is in the previous\n // \"old key to old index\" map, move the old part to the new\n // location, otherwise create and insert a new part. Note\n // that when moving an old part we null its position in the\n // oldParts array if it lies between the head and tail so we\n // know to skip it when the pointers get there.\n //\n // * Example below: neither head nor tail match, and neither\n // were removed; so find the `newHead` key in the\n // `oldKeyToIndexMap`, and move that old part's DOM into the\n // next head position (before `oldParts[oldHead]`). Last,\n // null the part in the `oldPart` array since it was\n // somewhere in the remaining oldParts still to be scanned\n // (between the head and tail pointers) so that we know to\n // skip that old part on future iterations.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, , , , , 6] <- stuck: update & move 2\n // newKeys: [0, 2, 1, 4, 3, 7, 6] into place and advance\n // newHead\n // newHead ^ ^ newTail\n //\n // * Note that for moves/insertions like the one above, a part\n // inserted at the head pointer is inserted before the\n // current `oldParts[oldHead]`, and a part inserted at the\n // tail pointer is inserted before `newParts[newTail+1]`. The\n // seeming asymmetry lies in the fact that new parts are\n // moved into place outside in, so to the right of the head\n // pointer are old parts, and to the right of the tail\n // pointer are new parts.\n //\n // * We always restart back from the top of the algorithm,\n // allowing matching and simple updates in place to\n // continue...\n //\n // * Example below: the head pointers once again match, so\n // simply update part 1 and record it in the `newParts`\n // array. Last, advance both head pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, , , , 6] <- heads matched: update 1\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance both oldHead\n // & newHead\n // newHead ^ ^ newTail\n //\n // * As mentioned above, items that were moved as a result of\n // being stuck (the final else clause in the code below) are\n // marked with null, so we always advance old pointers over\n // these so we're comparing the next actual old value on\n // either end.\n //\n // * Example below: `oldHead` is null (already placed in\n // newParts), so advance `oldHead`.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6] <- old head already used:\n // newParts: [0, 2, 1, , , , 6] advance oldHead\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ ^ newTail\n //\n // * Note it's not critical to mark old parts as null when they\n // are moved from head to tail or tail to head, since they\n // will be outside the pointer range and never visited again.\n //\n // * Example below: Here the old tail key matches the new head\n // key, so the part at the `oldTail` position and move its\n // DOM to the new head position (before `oldParts[oldHead]`).\n // Last, advance `oldTail` and `newHead` pointers.\n //\n // oldHead v v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, , , 6] <- old tail matches new\n // newKeys: [0, 2, 1, 4, 3, 7, 6] head: update & move 4,\n // advance oldTail & newHead\n // newHead ^ ^ newTail\n //\n // * Example below: Old and new head keys match, so update the\n // old head part in place, and advance the `oldHead` and\n // `newHead` pointers.\n //\n // oldHead v oldTail\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, ,6] <- heads match: update 3\n // newKeys: [0, 2, 1, 4, 3, 7, 6] and advance oldHead &\n // newHead\n // newHead ^ ^ newTail\n //\n // * Once the new or old pointers move past each other then all\n // we have left is additions (if old list exhausted) or\n // removals (if new list exhausted). Those are handled in the\n // final while loops at the end.\n //\n // * Example below: `oldHead` exceeded `oldTail`, so we're done\n // with the main loop. Create the remaining part and insert\n // it at the new head position, and the update is complete.\n //\n // (oldHead > oldTail)\n // oldKeys: [0, 1, -, 3, 4, 5, 6]\n // newParts: [0, 2, 1, 4, 3, 7 ,6] <- create and insert 7\n // newKeys: [0, 2, 1, 4, 3, 7, 6]\n // newHead ^ newTail\n //\n // * Note that the order of the if/else clauses is not\n // important to the algorithm, as long as the null checks\n // come first (to ensure we're always working on valid old\n // parts) and that the final else clause comes last (since\n // that's where the expensive moves occur). The order of\n // remaining clauses is is just a simple guess at which cases\n // will be most common.\n //\n // * Note, we could calculate the longest\n // increasing subsequence (LIS) of old items in new position,\n // and only move those not in the LIS set. However that costs\n // O(nlogn) time and adds a bit more code, and only helps\n // make rare types of mutations require fewer moves. The\n // above handles removes, adds, reversal, swaps, and single\n // moves of contiguous items in linear time, in the minimum\n // number of moves. As the number of multiple moves where LIS\n // might help approaches a random shuffle, the LIS\n // optimization becomes less helpful, so it seems not worth\n // the code at this point. Could reconsider if a compelling\n // case arises.\n\n while (oldHead <= oldTail && newHead <= newTail) {\n if (oldParts[oldHead] === null) {\n // `null` means old part at head has already been used\n // below; skip\n oldHead++;\n } else if (oldParts[oldTail] === null) {\n // `null` means old part at tail has already been used\n // below; skip\n oldTail--;\n } else if (oldKeys[oldHead] === newKeys[newHead]) {\n // Old head matches new head; update in place\n newParts[newHead] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newHead]\n );\n oldHead++;\n newHead++;\n } else if (oldKeys[oldTail] === newKeys[newTail]) {\n // Old tail matches new tail; update in place\n newParts[newTail] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newTail]\n );\n oldTail--;\n newTail--;\n } else if (oldKeys[oldHead] === newKeys[newTail]) {\n // Old head matches new tail; update and move to new tail\n newParts[newTail] = setChildPartValue(\n oldParts[oldHead]!,\n newValues[newTail]\n );\n insertPart(containerPart, newParts[newTail + 1], oldParts[oldHead]!);\n oldHead++;\n newTail--;\n } else if (oldKeys[oldTail] === newKeys[newHead]) {\n // Old tail matches new head; update and move to new head\n newParts[newHead] = setChildPartValue(\n oldParts[oldTail]!,\n newValues[newHead]\n );\n insertPart(containerPart, oldParts[oldHead]!, oldParts[oldTail]!);\n oldTail--;\n newHead++;\n } else {\n if (newKeyToIndexMap === undefined) {\n // Lazily generate key-to-index maps, used for removals &\n // moves below\n newKeyToIndexMap = generateMap(newKeys, newHead, newTail);\n oldKeyToIndexMap = generateMap(oldKeys, oldHead, oldTail);\n }\n if (!newKeyToIndexMap.has(oldKeys[oldHead])) {\n // Old head is no longer in new list; remove\n removePart(oldParts[oldHead]!);\n oldHead++;\n } else if (!newKeyToIndexMap.has(oldKeys[oldTail])) {\n // Old tail is no longer in new list; remove\n removePart(oldParts[oldTail]!);\n oldTail--;\n } else {\n // Any mismatches at this point are due to additions or\n // moves; see if we have an old part we can reuse and move\n // into place\n const oldIndex = oldKeyToIndexMap.get(newKeys[newHead]);\n const oldPart = oldIndex !== undefined ? oldParts[oldIndex] : null;\n if (oldPart === null) {\n // No old part for this value; create a new one and\n // insert it\n const newPart = insertPart(containerPart, oldParts[oldHead]!);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead] = newPart;\n } else {\n // Reuse old part\n newParts[newHead] = setChildPartValue(oldPart, newValues[newHead]);\n insertPart(containerPart, oldParts[oldHead]!, oldPart);\n // This marks the old part as having been used, so that\n // it will be skipped in the first two checks above\n oldParts[oldIndex as number] = null;\n }\n newHead++;\n }\n }\n }\n // Add parts for any remaining new values\n while (newHead <= newTail) {\n // For all remaining additions, we insert before last new\n // tail, since old pointers are no longer valid\n const newPart = insertPart(containerPart, newParts[newTail + 1]);\n setChildPartValue(newPart, newValues[newHead]);\n newParts[newHead++] = newPart;\n }\n // Remove any remaining unused old parts\n while (oldHead <= oldTail) {\n const oldPart = oldParts[oldHead++];\n if (oldPart !== null) {\n removePart(oldPart);\n }\n }\n\n // Save order of new parts for next round\n this._itemKeys = newKeys;\n // Directly set part value, bypassing it's dirty-checking\n setCommittedValue(containerPart, newParts);\n return noChange;\n }\n}\n\nexport interface RepeatDirectiveFn {\n <T>(\n items: Iterable<T>,\n keyFnOrTemplate: KeyFn<T> | ItemTemplate<T>,\n template?: ItemTemplate<T>\n ): unknown;\n <T>(items: Iterable<T>, template: ItemTemplate<T>): unknown;\n <T>(\n items: Iterable<T>,\n keyFn: KeyFn<T> | ItemTemplate<T>,\n template: ItemTemplate<T>\n ): unknown;\n}\n\n/**\n * A directive that repeats a series of values (usually `TemplateResults`)\n * generated from an iterable, and updates those items efficiently when the\n * iterable changes based on user-provided `keys` associated with each item.\n *\n * Note that if a `keyFn` is provided, strict key-to-DOM mapping is maintained,\n * meaning previous DOM for a given key is moved into the new position if\n * needed, and DOM will never be reused with values for different keys (new DOM\n * will always be created for new keys). This is generally the most efficient\n * way to use `repeat` since it performs minimum unnecessary work for insertions\n * and removals.\n *\n * The `keyFn` takes two parameters, the item and its index, and returns a unique key value.\n *\n * ```js\n * html`\n * <ol>\n * ${repeat(this.items, (item) => item.id, (item, index) => {\n * return html`<li>${index}: ${item.name}</li>`;\n * })}\n * </ol>\n * `\n * ```\n *\n * **Important**: If providing a `keyFn`, keys *must* be unique for all items in a\n * given call to `repeat`. The behavior when two or more items have the same key\n * is undefined.\n *\n * If no `keyFn` is provided, this directive will perform similar to mapping\n * items to values, and DOM will be reused against potentially different items.\n */\nexport const repeat = directive(RepeatDirective) as RepeatDirectiveFn;\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {RepeatDirective};\n","/**\n * @license\n * Copyright 2018 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {AttributePart, noChange} from '../lit-html.js';\nimport {\n directive,\n Directive,\n DirectiveParameters,\n PartInfo,\n PartType,\n} from '../directive.js';\n\n/**\n * A key-value set of CSS properties and values.\n *\n * The key should be either a valid CSS property name string, like\n * `'background-color'`, or a valid JavaScript camel case property name\n * for CSSStyleDeclaration like `backgroundColor`.\n */\nexport interface StyleInfo {\n [name: string]: string | undefined | null;\n}\n\nclass StyleMapDirective extends Directive {\n _previousStyleProperties?: Set<string>;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (\n partInfo.type !== PartType.ATTRIBUTE ||\n partInfo.name !== 'style' ||\n (partInfo.strings?.length as number) > 2\n ) {\n throw new Error(\n 'The `styleMap` directive must be used in the `style` attribute ' +\n 'and must be the only part in the attribute.'\n );\n }\n }\n\n render(styleInfo: Readonly<StyleInfo>) {\n return Object.keys(styleInfo).reduce((style, prop) => {\n const value = styleInfo[prop];\n if (value == null) {\n return style;\n }\n // Convert property names from camel-case to dash-case, i.e.:\n // `backgroundColor` -> `background-color`\n // Vendor-prefixed names need an extra `-` appended to front:\n // `webkitAppearance` -> `-webkit-appearance`\n // Exception is any property name containing a dash, including\n // custom properties; we assume these are already dash-cased i.e.:\n // `--my-button-color` --> `--my-button-color`\n prop = prop\n .replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g, '-$&')\n .toLowerCase();\n return style + `${prop}:${value};`;\n }, '');\n }\n\n override update(part: AttributePart, [styleInfo]: DirectiveParameters<this>) {\n const {style} = part.element as HTMLElement;\n\n if (this._previousStyleProperties === undefined) {\n this._previousStyleProperties = new Set();\n for (const name in styleInfo) {\n this._previousStyleProperties.add(name);\n }\n return this.render(styleInfo);\n }\n\n // Remove old properties that no longer exist in styleInfo\n // We use forEach() instead of for-of so that re don't require down-level\n // iteration.\n this._previousStyleProperties!.forEach((name) => {\n // If the name isn't in styleInfo or it's null/undefined\n if (styleInfo[name] == null) {\n this._previousStyleProperties!.delete(name);\n if (name.includes('-')) {\n style.removeProperty(name);\n } else {\n // Note reset using empty string (vs null) as IE11 does not always\n // reset via null (https://developer.mozilla.org/en-US/docs/Web/API/ElementCSSInlineStyle/style#setting_styles)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = '';\n }\n }\n });\n\n // Add or update properties\n for (const name in styleInfo) {\n const value = styleInfo[name];\n if (value != null) {\n this._previousStyleProperties.add(name);\n if (name.includes('-')) {\n style.setProperty(name, value);\n } else {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (style as any)[name] = value;\n }\n }\n }\n return noChange;\n }\n}\n\n/**\n * A directive that applies CSS properties to an element.\n *\n * `styleMap` can only be used in the `style` attribute and must be the only\n * expression in the attribute. It takes the property names in the\n * {@link StyleInfo styleInfo} object and adds the property values as CSS\n * properties. Property names with dashes (`-`) are assumed to be valid CSS\n * property names and set on the element's style object using `setProperty()`.\n * Names without dashes are assumed to be camelCased JavaScript property names\n * and set on the element's style object using property assignment, allowing the\n * style object to translate JavaScript-style names to CSS property names.\n *\n * For example `styleMap({backgroundColor: 'red', 'border-top': '5px', '--size':\n * '0'})` sets the `background-color`, `border-top` and `--size` properties.\n *\n * @param styleInfo\n * @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}\n */\nexport const styleMap = directive(StyleMapDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {StyleMapDirective};\n","/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\n\nclass TemplateContentDirective extends Directive {\n private _previousTemplate?: HTMLTemplateElement;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error('templateContent can only be used in child bindings');\n }\n }\n\n render(template: HTMLTemplateElement) {\n if (this._previousTemplate === template) {\n return noChange;\n }\n this._previousTemplate = template;\n return document.importNode(template.content, true);\n }\n}\n\n/**\n * Renders the content of a template element as HTML.\n *\n * Note, the template should be developer controlled and not user controlled.\n * Rendering a user-controlled template with this directive\n * could lead to cross-site-scripting vulnerabilities.\n */\nexport const templateContent = directive(TemplateContentDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {TemplateContentDirective};\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {nothing, TemplateResult, noChange} from '../lit-html.js';\nimport {directive, Directive, PartInfo, PartType} from '../directive.js';\n\nconst HTML_RESULT = 1;\n\nexport class UnsafeHTMLDirective extends Directive {\n static directiveName = 'unsafeHTML';\n static resultType = HTML_RESULT;\n\n private _value: unknown = nothing;\n private _templateResult?: TemplateResult;\n\n constructor(partInfo: PartInfo) {\n super(partInfo);\n if (partInfo.type !== PartType.CHILD) {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() can only be used in child bindings`\n );\n }\n }\n\n render(value: string | typeof nothing | typeof noChange | undefined | null) {\n if (value === nothing || value == null) {\n this._templateResult = undefined;\n return (this._value = value);\n }\n if (value === noChange) {\n return value;\n }\n if (typeof value != 'string') {\n throw new Error(\n `${\n (this.constructor as typeof UnsafeHTMLDirective).directiveName\n }() called with a non-string value`\n );\n }\n if (value === this._value) {\n return this._templateResult;\n }\n this._value = value;\n const strings = [value] as unknown as TemplateStringsArray;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (strings as any).raw = strings;\n // WARNING: impersonating a TemplateResult like this is extremely\n // dangerous. Third-party directives should not do this.\n return (this._templateResult = {\n // Cast to a known set of integers that satisfy ResultType so that we\n // don't have to export ResultType and possibly encourage this pattern.\n // This property needs to remain unminified.\n ['_$litType$']: (this.constructor as typeof UnsafeHTMLDirective)\n .resultType as 1 | 2,\n strings,\n values: [],\n });\n }\n}\n\n/**\n * Renders the result as HTML, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeHTML = directive(UnsafeHTMLDirective);\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {directive} from '../directive.js';\nimport {UnsafeHTMLDirective} from './unsafe-html.js';\n\nconst SVG_RESULT = 2;\n\nclass UnsafeSVGDirective extends UnsafeHTMLDirective {\n static override directiveName = 'unsafeSVG';\n static override resultType = SVG_RESULT;\n}\n\n/**\n * Renders the result as SVG, rather than text.\n *\n * The values `undefined`, `null`, and `nothing`, will all result in no content\n * (empty string) being rendered.\n *\n * Note, this is unsafe to use with any user-provided input that hasn't been\n * sanitized or escaped, as it may lead to cross-site-scripting\n * vulnerabilities.\n */\nexport const unsafeSVG = directive(UnsafeSVGDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\nexport type {UnsafeSVGDirective};\n","/**\n * @license\n * Copyright 2017 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nimport {Part, noChange} from '../lit-html.js';\nimport {isPrimitive} from '../directive-helpers.js';\nimport {directive, AsyncDirective} from '../async-directive.js';\nimport {Pauser, PseudoWeakRef} from './private-async-helpers.js';\n\nconst isPromise = (x: unknown) => {\n return !isPrimitive(x) && typeof (x as {then?: unknown}).then === 'function';\n};\n// Effectively infinity, but a SMI.\nconst _infinity = 0x3fffffff;\n\nexport class UntilDirective extends AsyncDirective {\n private __lastRenderedIndex: number = _infinity;\n private __values: unknown[] = [];\n private __weakThis = new PseudoWeakRef(this);\n private __pauser = new Pauser();\n\n render(...args: Array<unknown>) {\n return args.find((x) => !isPromise(x)) ?? noChange;\n }\n\n override update(_part: Part, args: Array<unknown>) {\n const previousValues = this.__values;\n let previousLength = previousValues.length;\n this.__values = args;\n\n const weakThis = this.__weakThis;\n const pauser = this.__pauser;\n\n // If our initial render occurs while disconnected, ensure that the pauser\n // and weakThis are in the disconnected state\n if (!this.isConnected) {\n this.disconnected();\n }\n\n for (let i = 0; i < args.length; i++) {\n // If we've rendered a higher-priority value already, stop.\n if (i > this.__lastRenderedIndex) {\n break;\n }\n\n const value = args[i];\n\n // Render non-Promise values immediately\n if (!isPromise(value)) {\n this.__lastRenderedIndex = i;\n // Since a lower-priority value will never overwrite a higher-priority\n // synchronous value, we can stop processing now.\n return value;\n }\n\n // If this is a Promise we've already handled, skip it.\n if (i < previousLength && value === previousValues[i]) {\n continue;\n }\n\n // We have a Promise that we haven't seen before, so priorities may have\n // changed. Forget what we rendered before.\n this.__lastRenderedIndex = _infinity;\n previousLength = 0;\n\n // Note, the callback avoids closing over `this` so that the directive\n // can be gc'ed before the promise resolves; instead `this` is retrieved\n // from `weakThis`, which can break the hard reference in the closure when\n // the directive disconnects\n Promise.resolve(value).then(async (result: unknown) => {\n // If we're disconnected, wait until we're (maybe) reconnected\n // The while loop here handles the case that the connection state\n // thrashes, causing the pauser to resume and then get re-paused\n while (pauser.get()) {\n await pauser.get();\n }\n // If the callback gets here and there is no `this`, it means that the\n // directive has been disconnected and garbage collected and we don't\n // need to do anything else\n const _this = weakThis.deref();\n if (_this !== undefined) {\n const index = _this.__values.indexOf(value);\n // If state.values doesn't contain the value, we've re-rendered without\n // the value, so don't render it. Then, only render if the value is\n // higher-priority than what's already been rendered.\n if (index > -1 && index < _this.__lastRenderedIndex) {\n _this.__lastRenderedIndex = index;\n _this.setValue(result);\n }\n }\n });\n }\n\n return noChange;\n }\n\n override disconnected() {\n this.__weakThis.disconnect();\n this.__pauser.pause();\n }\n\n override reconnected() {\n this.__weakThis.reconnect(this);\n this.__pauser.resume();\n }\n}\n\n/**\n * Renders one of a series of values, including Promises, to a Part.\n *\n * Values are rendered in priority order, with the first argument having the\n * highest priority and the last argument having the lowest priority. If a\n * value is a Promise, low-priority values will be rendered until it resolves.\n *\n * The priority of values can be used to create placeholder content for async\n * data. For example, a Promise with pending content can be the first,\n * highest-priority, argument, and a non_promise loading indicator template can\n * be used as the second, lower-priority, argument. The loading indicator will\n * render immediately, and the primary content will render when the Promise\n * resolves.\n *\n * Example:\n *\n * ```js\n * const content = fetch('./content.txt').then(r => r.text());\n * html`${until(content, html`<span>Loading...</span>`)}`\n * ```\n */\nexport const until = directive(UntilDirective);\n\n/**\n * The type of the class that powers this directive. Necessary for naming the\n * directive's return type.\n */\n// export type {UntilDirective};\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * When `condition` is true, returns the result of calling `trueCase()`, else\n * returns the result of calling `falseCase()` if `falseCase` is defined.\n *\n * This is a convenience wrapper around a ternary expression that makes it a\n * little nicer to write an inline conditional without an else.\n *\n * @example\n *\n * ```ts\n * render() {\n * return html`\n * ${when(this.user, () => html`User: ${this.user.username}`, () => html`Sign In...`)}\n * `;\n * }\n * ```\n */\nexport function when<T, F>(\n condition: true,\n trueCase: () => T,\n falseCase?: () => F\n): T;\nexport function when<T, F = undefined>(\n condition: false,\n trueCase: () => T,\n falseCase?: () => F\n): F;\nexport function when<T, F = undefined>(\n condition: unknown,\n trueCase: () => T,\n falseCase?: () => F\n): T | F;\nexport function when(\n condition: unknown,\n trueCase: () => unknown,\n falseCase?: () => unknown\n): unknown {\n return condition ? trueCase() : falseCase?.();\n}\n","/**\n * @license\n * Copyright 2020 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n// Any new exports need to be added to the export statement in\n// `packages/lit/src/index.all.ts`.\n\nimport {html as coreHtml, svg as coreSvg, TemplateResult} from './lit-html.js';\n\nexport interface StaticValue {\n /** The value to interpolate as-is into the template. */\n _$litStatic$: string;\n\n /**\n * A value that can't be decoded from ordinary JSON, make it harder for\n * a attacker-controlled data that goes through JSON.parse to produce a valid\n * StaticValue.\n */\n r: typeof brand;\n}\n\n/**\n * Prevents JSON injection attacks.\n *\n * The goals of this brand:\n * 1) fast to check\n * 2) code is small on the wire\n * 3) multiple versions of Lit in a single page will all produce mutually\n * interoperable StaticValues\n * 4) normal JSON.parse (without an unusual reviver) can not produce a\n * StaticValue\n *\n * Symbols satisfy (1), (2), and (4). We use Symbol.for to satisfy (3), but\n * we don't care about the key, so we break ties via (2) and use the empty\n * string.\n */\nconst brand = Symbol.for('');\n\n/** Safely extracts the string part of a StaticValue. */\nconst unwrapStaticValue = (value: unknown): string | undefined => {\n if ((value as Partial<StaticValue>)?.r !== brand) {\n return undefined;\n }\n return (value as Partial<StaticValue>)?.['_$litStatic$'];\n};\n\n/**\n * Wraps a string so that it behaves like part of the static template\n * strings instead of a dynamic value.\n *\n * Users must take care to ensure that adding the static string to the template\n * results in well-formed HTML, or else templates may break unexpectedly.\n *\n * Note that this function is unsafe to use on untrusted content, as it will be\n * directly parsed into HTML. Do not pass user input to this function\n * without sanitizing it.\n *\n * Static values can be changed, but they will cause a complete re-render\n * since they effectively create a new template.\n */\nexport const unsafeStatic = (value: string): StaticValue => ({\n ['_$litStatic$']: value,\n r: brand,\n});\n\nconst textFromStatic = (value: StaticValue) => {\n if (value['_$litStatic$'] !== undefined) {\n return value['_$litStatic$'];\n } else {\n throw new Error(\n `Value passed to 'literal' function must be a 'literal' result: ${value}. Use 'unsafeStatic' to pass non-literal values, but\n take care to ensure page security.`\n );\n }\n};\n\n/**\n * Tags a string literal so that it behaves like part of the static template\n * strings instead of a dynamic value.\n *\n * The only values that may be used in template expressions are other tagged\n * `literal` results or `unsafeStatic` values (note that untrusted content\n * should never be passed to `unsafeStatic`).\n *\n * Users must take care to ensure that adding the static string to the template\n * results in well-formed HTML, or else templates may break unexpectedly.\n *\n * Static values can be changed, but they will cause a complete re-render since\n * they effectively create a new template.\n */\nexport const literal = (\n strings: TemplateStringsArray,\n ...values: unknown[]\n): StaticValue => ({\n ['_$litStatic$']: values.reduce(\n (acc, v, idx) => acc + textFromStatic(v as StaticValue) + strings[idx + 1],\n strings[0]\n ) as string,\n r: brand,\n});\n\nconst stringsCache = new Map<string, TemplateStringsArray>();\n\n/**\n * Wraps a lit-html template tag (`html` or `svg`) to add static value support.\n */\nexport const withStatic =\n (coreTag: typeof coreHtml | typeof coreSvg) =>\n (strings: TemplateStringsArray, ...values: unknown[]): TemplateResult => {\n const l = values.length;\n let staticValue: string | undefined;\n let dynamicValue: unknown;\n const staticStrings: Array<string> = [];\n const dynamicValues: Array<unknown> = [];\n let i = 0;\n let hasStatics = false;\n let s: string;\n\n while (i < l) {\n s = strings[i];\n // Collect any unsafeStatic values, and their following template strings\n // so that we treat a run of template strings and unsafe static values as\n // a single template string.\n while (\n i < l &&\n ((dynamicValue = values[i]),\n (staticValue = unwrapStaticValue(dynamicValue))) !== undefined\n ) {\n s += staticValue + strings[++i];\n hasStatics = true;\n }\n dynamicValues.push(dynamicValue);\n staticStrings.push(s);\n i++;\n }\n // If the last value isn't static (which would have consumed the last\n // string), then we need to add the last string.\n if (i === l) {\n staticStrings.push(strings[l]);\n }\n\n if (hasStatics) {\n const key = staticStrings.join('$$lit$$');\n strings = stringsCache.get(key)!;\n if (strings === undefined) {\n // Beware: in general this pattern is unsafe, and doing so may bypass\n // lit's security checks and allow an attacker to execute arbitrary\n // code and inject arbitrary content.\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (staticStrings as any).raw = staticStrings;\n stringsCache.set(\n key,\n (strings = staticStrings as unknown as TemplateStringsArray)\n );\n }\n values = dynamicValues;\n }\n return coreTag(strings, ...values);\n };\n\n/**\n * Interprets a template literal as an HTML template that can efficiently\n * render to and update a container.\n *\n * Includes static value support from `lit-html/static.js`.\n */\nexport const html = withStatic(coreHtml);\n\n/**\n * Interprets a template literal as an SVG template that can efficiently\n * render to and update a container.\n *\n * Includes static value support from `lit-html/static.js`.\n */\nexport const svg = withStatic(coreSvg);\n","/**\n * @license\n * Copyright 2021 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\nexport * from './index.js';\n\nexport * from './async-directive.js';\nexport * from './directive-helpers.js';\nexport * from './directive.js';\nexport * from './directives/async-append.js';\nexport * from './directives/async-replace.js';\nexport * from './directives/cache.js';\nexport * from './directives/choose.js';\nexport * from './directives/class-map.js';\nexport * from './directives/guard.js';\nexport * from './directives/if-defined.js';\nexport * from './directives/join.js';\nexport * from './directives/keyed.js';\nexport * from './directives/live.js';\nexport * from './directives/map.js';\nexport * from './directives/range.js';\nexport * from './directives/ref.js';\nexport * from './directives/repeat.js';\nexport * from './directives/style-map.js';\nexport * from './directives/template-content.js';\nexport * from './directives/unsafe-html.js';\nexport * from './directives/unsafe-svg.js';\nexport * from './directives/until.js';\nexport * from './directives/when.js';\n// Any new exports in `packages/lit-html/src/static.ts` need to be added here.\nexport {\n html as staticHtml,\n literal,\n svg as staticSvg,\n unsafeStatic,\n withStatic,\n} from './static-html.js';\n\nif (!window.litDisableBundleWarning) {\n console.warn(\n 'Lit has been loaded from a bundle that combines all core features into ' +\n 'a single file. To reduce transfer size and parsing cost, consider ' +\n 'using the `lit` npm package directly in your project.'\n );\n}\n"],"names":["global","window","supportsAdoptingStyleSheets","ShadowRoot","undefined","ShadyCSS","nativeShadow","Document","prototype","CSSStyleSheet","constructionToken","Symbol","cssTagCache","WeakMap","CSSResult","constructor","cssText","strings","safeToken","this","Error","_strings","styleSheet","_styleSheet","cacheable","length","get","replaceSync","set","toString","unsafeCSS","value","String","css","values","reduce","acc","v","idx","textFromCSSResult","adoptStyles","renderRoot","styles","adoptedStyleSheets","map","s","forEach","style","document","createElement","nonce","setAttribute","textContent","appendChild","getCompatibleStyle","sheet","rule","cssRules","cssResultFromStyleSheet","trustedTypes","emptyStringForBooleanAttribute","emptyScript","polyfillSupport","reactiveElementPolyfillSupport","defaultConverter","toAttribute","type","Boolean","Object","Array","JSON","stringify","fromAttribute","fromValue","Number","parse","e","notEqual","old","defaultPropertyDeclaration","attribute","converter","reflect","hasChanged","ReactiveElement","HTMLElement","super","__instanceProperties","Map","isUpdatePending","hasUpdated","__reflectingProperty","_initialize","static","initializer","finalize","_a","_initializers","push","observedAttributes","attributes","elementProperties","p","attr","__attributeNameForProperty","__attributeToPropertyMap","name","options","state","noAccessor","hasOwnProperty","key","descriptor","getPropertyDescriptor","defineProperty","oldValue","requestUpdate","configurable","enumerable","superCtor","getPrototypeOf","props","properties","propKeys","getOwnPropertyNames","getOwnPropertySymbols","createProperty","elementStyles","finalizeStyles","isArray","Set","flat","Infinity","reverse","unshift","toLowerCase","__updatePromise","Promise","res","enableUpdating","_$changedProperties","__saveInstanceProperties","i","addController","controller","__controllers","isConnected","_b","hostConnected","call","removeController","splice","indexOf","_v","createRenderRoot","shadowRoot","attachShadow","shadowRootOptions","connectedCallback","c","_requestedUpdate","disconnectedCallback","hostDisconnected","attributeChangedCallback","_old","_$attributeToProperty","__propertyToAttribute","attrValue","removeAttribute","ctor","propName","getPropertyOptions","shouldRequestUpdate","has","__reflectingProperties","__enqueueUpdate","async","reject","result","scheduleUpdate","performUpdate","shouldUpdate","changedProperties","willUpdate","hostUpdate","update","__markUpdated","_$didUpdate","_changedProperties","hostUpdated","firstUpdated","updated","updateComplete","getUpdateComplete","k","mode","_d","reactiveElementVersions","policy","createPolicy","createHTML","marker","Math","random","slice","markerMatch","nodeMarker","d","createMarker","createComment","isPrimitive","isIterable","iterator","textEndRegex","commentEndRegex","comment2EndRegex","tagEndRegex","RegExp","singleQuoteAttrEndRegex","doubleQuoteAttrEndRegex","rawTextElement","tag","_$litType$","html","svg","noChange","for","nothing","templateCache","walker","createTreeWalker","getTemplateHtml","l","attrNames","rawTextEndRegex","regex","attrName","match","attrNameEndIndex","lastIndex","exec","test","end","startsWith","htmlResult","Template","node","parts","nodeIndex","attrNameIndex","partCount","el","currentNode","content","svgElement","firstChild","remove","append","childNodes","nextNode","nodeType","hasAttributes","attrsToRemove","getAttributeNames","endsWith","realName","statics","getAttribute","split","m","index","PropertyPart","BooleanAttributePart","EventPart","AttributePart","tagName","data","_options","innerHTML","resolveDirective","part","parent","attributeIndex","currentDirective","__directives","__directive","nextDirectiveConstructor","_$initialize","_c","_$resolve","TemplateInstance","template","_parts","_$disconnectableChildren","_$template","_$parent","parentNode","_$isConnected","_clone","fragment","creationScope","importNode","partIndex","templatePart","ChildPart","nextSibling","ElementPart","_update","_$setValue","startNode","endNode","_$committedValue","_$startNode","_$endNode","__isConnected","directiveParent","_$clear","_commitText","_commitTemplateResult","_commitNode","_commitIterable","_insert","ref","insertBefore","createTextNode","_$getTemplate","h","instance","itemParts","itemPart","item","start","from","_$notifyConnectionChanged","n","setConnected","element","fill","valueIndex","noCommit","change","_commitValue","newListener","oldListener","shouldRemoveListener","capture","once","passive","shouldAddListener","removeEventListener","addEventListener","handleEvent","event","host","_$LH","_boundAttributeSuffix","_marker","_markerMatch","_HTML_RESULT","_getTemplateHtml","_TemplateInstance","_isIterable","_resolveDirective","_ChildPart","_AttributePart","_BooleanAttributePart","_EventPart","_PropertyPart","_ElementPart","litHtmlPolyfillSupport","litHtmlVersions","render","container","partOwnerNode","renderBefore","UpdatingElement","LitElement","renderOptions","__childPart","globalThis","litElementHydrateSupport","litElementPolyfillSupport","_$LE","litElementVersions","isServer","TemplateResultType","HTML","SVG","isTemplateResult","isDirectiveResult","getDirectiveClass","isSingleExpression","insertPart","containerPart","refPart","refNode","oldParent","parentChanged","newConnectionState","_$reparentDisconnectables","setChildPartValue","RESET_VALUE","setCommittedValue","getCommittedValue","removePart","clearPart","PartType","ATTRIBUTE","CHILD","PROPERTY","BOOLEAN_ATTRIBUTE","EVENT","ELEMENT","directive","_$litDirective$","Directive","_partInfo","__part","__attributeIndex","_part","notifyChildrenConnectedChanged","children","obj","removeDisconnectableFromParent","delete","size","addDisconnectableToParent","add","installDisconnectAPI","reparentDisconnectables","newParent","notifyChildPartConnectedChanged","isClearingValue","fromPartIndex","AsyncDirective","_$AO","isClearingDirective","reconnected","disconnected","setValue","newValues","PseudoWeakRef","_ref","disconnect","reconnect","deref","Pauser","_promise","_resolve","pause","resolve","resume","AsyncReplaceDirective","__weakThis","__pauser","_mapper","mapper","__value","weakThis","pauser","iterable","callback","forAwaitOf","_this","commitValue","_index","asyncReplace","asyncAppend","partInfo","params","newPart","cache","_templateCache","_value","childPart","pop","cachedContainerPart","createDocumentFragment","cachedPart","choose","cases","defaultCase","fn","classMap","classInfo","keys","filter","join","_previousClasses","_staticClasses","classList","initialValue","guard","_previousValue","f","every","ifDefined","items","joiner","isFunction","keyed","live","hasAttribute","range","startOrEnd","step","createRef","Ref","lastElementForContextAndCallback","refChanged","_updateRefValue","_lastElementForRef","_element","_context","context","lastElementForCallback","generateMap","list","repeat","_getValuesAndKeys","keyFnOrTemplate","keyFn","oldParts","newKeys","_itemKeys","oldKeys","newParts","newKeyToIndexMap","oldKeyToIndexMap","oldHead","oldTail","newHead","newTail","oldIndex","oldPart","styleMap","styleInfo","prop","replace","_previousStyleProperties","includes","removeProperty","setProperty","templateContent","_previousTemplate","UnsafeHTMLDirective","directiveName","_templateResult","raw","resultType","unsafeHTML","UnsafeSVGDirective","unsafeSVG","isPromise","x","then","UntilDirective","__lastRenderedIndex","__values","args","find","previousValues","previousLength","until","when","condition","trueCase","falseCase","brand","unwrapStaticValue","r","unsafeStatic","_$litStatic$","literal","textFromStatic","stringsCache","withStatic","coreTag","staticValue","dynamicValue","staticStrings","dynamicValues","hasStatics","coreHtml","coreSvg","litDisableBundleWarning","console","warn"],"mappings":";;;;;AAMA,MACMA,EAAkCC,OAK3BC,EACXF,EAAOG,kBACcC,IAApBJ,EAAOK,UAA0BL,EAAOK,SAASC,eAClD,uBAAwBC,SAASC,WACjC,YAAaC,cAAcD,UAkBvBE,EAAoBC,SAEpBC,EAAc,IAAIC,cASXC,EAOXC,YACEC,EACAC,EACAC,GAEA,GAVFC,KAAe,cAAI,EAUbD,IAAcR,EAChB,MAAUU,MACR,qEAGJD,KAAKH,QAAUA,EACfG,KAAKE,EAAWJ,CACjB,CAIGK,iBAGF,IAAIA,EAAaH,KAAKI,EACtB,MAAMN,EAAUE,KAAKE,EACrB,GAAInB,QAA8CE,IAAfkB,EAA0B,CAC3D,MAAME,OAAwBpB,IAAZa,GAA4C,IA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