UNPKG

begin-widgets

Version:

Easily embed powerful workflow building and running capabilities into your web applications with Lit-based web components. Includes HTML export for server-side PDF generation.

1,180 lines 276 kB
/** * @license * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const ee = globalThis, Ce = ee.ShadowRoot && (ee.ShadyCSS === void 0 || ee.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, Ee = Symbol(), Ue = /* @__PURE__ */ new WeakMap(); class et { constructor(e, t, n) { if (this._$cssResult$ = !0, n !== Ee) throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead."); this.cssText = e, this._strings = t; } // This is a getter so that it's lazy. In practice, this means stylesheets // are not created until the first element instance is made. get styleSheet() { let e = this._styleSheet; const t = this._strings; if (Ce && e === void 0) { const n = t !== void 0 && t.length === 1; n && (e = Ue.get(t)), e === void 0 && ((this._styleSheet = e = new CSSStyleSheet()).replaceSync(this.cssText), n && Ue.set(t, e)); } return e; } toString() { return this.cssText; } } const pt = (i) => { if (i._$cssResult$ === !0) return i.cssText; if (typeof i == "number") return i; throw new Error(`Value passed to 'css' function must be a 'css' function result: ${i}. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`); }, ct = (i) => new et(typeof i == "string" ? i : String(i), void 0, Ee), j = (i, ...e) => { const t = i.length === 1 ? i[0] : e.reduce((n, s, r) => n + pt(s) + i[r + 1], i[0]); return new et(t, i, Ee); }, ut = (i, e) => { if (Ce) i.adoptedStyleSheets = e.map((t) => t instanceof CSSStyleSheet ? t : t.styleSheet); else for (const t of e) { const n = document.createElement("style"), s = ee.litNonce; s !== void 0 && n.setAttribute("nonce", s), n.textContent = t.cssText, i.appendChild(n); } }, ht = (i) => { let e = ""; for (const t of i.cssRules) e += t.cssText; return ct(e); }, Ae = Ce ? (i) => i : (i) => i instanceof CSSStyleSheet ? ht(i) : i; /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const { is: mt, defineProperty: gt, getOwnPropertyDescriptor: Ne, getOwnPropertyNames: ft, getOwnPropertySymbols: bt, getPrototypeOf: Le } = Object, y = globalThis; let M; const Re = y.trustedTypes, xt = Re ? Re.emptyScript : "", te = y.reactiveElementPolyfillSupportDevMode; y.litIssuedWarnings ?? (y.litIssuedWarnings = /* @__PURE__ */ new Set()), M = (i, e) => { e += ` See https://lit.dev/msg/${i} for more information.`, !y.litIssuedWarnings.has(e) && !y.litIssuedWarnings.has(i) && (console.warn(e), y.litIssuedWarnings.add(e)); }, queueMicrotask(() => { var i; M("dev-mode", "Lit is in dev mode. Not recommended for production!"), (i = y.ShadyDOM) != null && i.inUse && te === void 0 && M("polyfill-support-missing", "Shadow DOM is being polyfilled via `ShadyDOM` but the `polyfill-support` module has not been loaded."); }); const ue = (i) => { y.emitLitDebugLogEvents && y.dispatchEvent(new CustomEvent("lit-debug", { detail: i })); }, V = (i, e) => i, ne = { toAttribute(i, e) { switch (e) { case Boolean: i = i ? xt : null; break; case Object: case Array: i = i == null ? i : JSON.stringify(i); break; } return i; }, fromAttribute(i, e) { let t = i; switch (e) { case Boolean: t = i !== null; break; case Number: t = i === null ? null : Number(i); break; case Object: case Array: try { t = JSON.parse(i); } catch { t = null; } break; } return t; } }, Te = (i, e) => !mt(i, e), Oe = { attribute: !0, type: String, converter: ne, reflect: !1, useDefault: !1, hasChanged: Te }; Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")); y.litPropertyMetadata ?? (y.litPropertyMetadata = /* @__PURE__ */ new WeakMap()); class U extends HTMLElement { /** * Adds an initializer function to the class that is called during instance * construction. * * This is useful for code that runs against a `ReactiveElement` * subclass, such as a decorator, that needs to do work for each * instance, such as setting up a `ReactiveController`. * * ```ts * const myDecorator = (target: typeof ReactiveElement, key: string) => { * target.addInitializer((instance: ReactiveElement) => { * // This is run during construction of the element * new MyController(instance); * }); * } * ``` * * Decorating a field will then cause each instance to run an initializer * that adds a controller: * * ```ts * class MyElement extends LitElement { * @myDecorator foo; * } * ``` * * Initializers are stored per-constructor. Adding an initializer to a * subclass does not add it to a superclass. Since initializers are run in * constructors, initializers will run in order of the class hierarchy, * starting with superclasses and progressing to the instance's class. * * @nocollapse */ static addInitializer(e) { this.__prepare(), (this._initializers ?? (this._initializers = [])).push(e); } /** * Returns a list of attributes corresponding to the registered properties. * @nocollapse * @category attributes */ static get observedAttributes() { return this.finalize(), this.__attributeToPropertyMap && [...this.__attributeToPropertyMap.keys()]; } /** * Creates a property accessor on the element prototype if one does not exist * and stores a {@linkcode PropertyDeclaration} for the property with the * given options. The property setter calls the property's `hasChanged` * property option or uses a strict identity check to determine whether or not * to request an update. * * This method may be overridden to customize properties; however, * when doing so, it's important to call `super.createProperty` to ensure * the property is setup correctly. This method calls * `getPropertyDescriptor` internally to get a descriptor to install. * To customize what properties do when they are get or set, override * `getPropertyDescriptor`. To customize the options for a property, * implement `createProperty` like this: * * ```ts * static createProperty(name, options) { * options = Object.assign(options, {myOption: true}); * super.createProperty(name, options); * } * ``` * * @nocollapse * @category properties */ static createProperty(e, t = Oe) { if (t.state && (t.attribute = !1), this.__prepare(), this.prototype.hasOwnProperty(e) && (t = Object.create(t), t.wrapped = !0), this.elementProperties.set(e, t), !t.noAccessor) { const n = ( // Use Symbol.for in dev mode to make it easier to maintain state // when doing HMR. Symbol.for(`${String(e)} (@property() cache)`) ), s = this.getPropertyDescriptor(e, n, t); s !== void 0 && gt(this.prototype, e, s); } } /** * Returns a property descriptor to be defined on the given named property. * If no descriptor is returned, the property will not become an accessor. * For example, * * ```ts * class MyElement extends LitElement { * static getPropertyDescriptor(name, key, options) { * const defaultDescriptor = * super.getPropertyDescriptor(name, key, options); * const setter = defaultDescriptor.set; * return { * get: defaultDescriptor.get, * set(value) { * setter.call(this, value); * // custom action. * }, * configurable: true, * enumerable: true * } * } * } * ``` * * @nocollapse * @category properties */ static getPropertyDescriptor(e, t, n) { const { get: s, set: r } = Ne(this.prototype, e) ?? { get() { return this[t]; }, set(o) { this[t] = o; } }; if (s == null) { if ("value" in (Ne(this.prototype, e) ?? {})) throw new Error(`Field ${JSON.stringify(String(e))} on ${this.name} was declared as a reactive property but it's actually declared as a value on the prototype. Usually this is due to using @property or @state on a method.`); M("reactive-property-without-getter", `Field ${JSON.stringify(String(e))} on ${this.name} was declared as a reactive property but it does not have a getter. This will be an error in a future version of Lit.`); } return { get: s, set(o) { const a = s == null ? void 0 : s.call(this); r == null || r.call(this, o), this.requestUpdate(e, a, n); }, configurable: !0, enumerable: !0 }; } /** * Returns the property options associated with the given property. * These options are defined with a `PropertyDeclaration` via the `properties` * object or the `@property` decorator and are registered in * `createProperty(...)`. * * Note, this method should be considered "final" and not overridden. To * customize the options for a given property, override * {@linkcode createProperty}. * * @nocollapse * @final * @category properties */ static getPropertyOptions(e) { return this.elementProperties.get(e) ?? Oe; } /** * Initializes static own properties of the class used in bookkeeping * for element properties, initializers, etc. * * Can be called multiple times by code that needs to ensure these * properties exist before using them. * * This method ensures the superclass is finalized so that inherited * property metadata can be copied down. * @nocollapse */ static __prepare() { if (this.hasOwnProperty(V("elementProperties"))) return; const e = Le(this); e.finalize(), e._initializers !== void 0 && (this._initializers = [...e._initializers]), this.elementProperties = new Map(e.elementProperties); } /** * Finishes setting up the class so that it's ready to be registered * as a custom element and instantiated. * * This method is called by the ReactiveElement.observedAttributes getter. * If you override the observedAttributes getter, you must either call * super.observedAttributes to trigger finalization, or call finalize() * yourself. * * @nocollapse */ static finalize() { if (this.hasOwnProperty(V("finalized"))) return; if (this.finalized = !0, this.__prepare(), this.hasOwnProperty(V("properties"))) { const t = this.properties, n = [ ...ft(t), ...bt(t) ]; for (const s of n) this.createProperty(s, t[s]); } const e = this[Symbol.metadata]; if (e !== null) { const t = litPropertyMetadata.get(e); if (t !== void 0) for (const [n, s] of t) this.elementProperties.set(n, s); } this.__attributeToPropertyMap = /* @__PURE__ */ new Map(); for (const [t, n] of this.elementProperties) { const s = this.__attributeNameForProperty(t, n); s !== void 0 && this.__attributeToPropertyMap.set(s, t); } this.elementStyles = this.finalizeStyles(this.styles), this.hasOwnProperty("createProperty") && M("no-override-create-property", "Overriding ReactiveElement.createProperty() is deprecated. The override will not be called with standard decorators"), this.hasOwnProperty("getPropertyDescriptor") && M("no-override-get-property-descriptor", "Overriding ReactiveElement.getPropertyDescriptor() is deprecated. The override will not be called with standard decorators"); } /** * Takes the styles the user supplied via the `static styles` property and * returns the array of styles to apply to the element. * Override this method to integrate into a style management system. * * Styles are deduplicated preserving the _last_ instance in the list. This * is a performance optimization to avoid duplicated styles that can occur * especially when composing via subclassing. The last item is kept to try * to preserve the cascade order with the assumption that it's most important * that last added styles override previous styles. * * @nocollapse * @category styles */ static finalizeStyles(e) { const t = []; if (Array.isArray(e)) { const n = new Set(e.flat(1 / 0).reverse()); for (const s of n) t.unshift(Ae(s)); } else e !== void 0 && t.push(Ae(e)); return t; } /** * Returns the property name for the given attribute `name`. * @nocollapse */ static __attributeNameForProperty(e, t) { const n = t.attribute; return n === !1 ? void 0 : typeof n == "string" ? n : typeof e == "string" ? e.toLowerCase() : void 0; } constructor() { super(), this.__instanceProperties = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this.__reflectingProperty = null, this.__initialize(); } /** * Internal only override point for customizing work done when elements * are constructed. */ __initialize() { var e; this.__updatePromise = new Promise((t) => this.enableUpdating = t), this._$changedProperties = /* @__PURE__ */ new Map(), this.__saveInstanceProperties(), this.requestUpdate(), (e = this.constructor._initializers) == null || e.forEach((t) => t(this)); } /** * Registers a `ReactiveController` to participate in the element's reactive * update cycle. The element automatically calls into any registered * controllers during its lifecycle callbacks. * * If the element is connected when `addController()` is called, the * controller's `hostConnected()` callback will be immediately called. * @category controllers */ addController(e) { var t; (this.__controllers ?? (this.__controllers = /* @__PURE__ */ new Set())).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e)); } /** * Removes a `ReactiveController` from the element. * @category controllers */ removeController(e) { var t; (t = this.__controllers) == null || t.delete(e); } /** * Fixes any properties set on the instance before upgrade time. * Otherwise these would shadow the accessor and break these properties. * The properties are stored in a Map which is played back after the * constructor runs. */ __saveInstanceProperties() { const e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties; for (const n of t.keys()) this.hasOwnProperty(n) && (e.set(n, this[n]), delete this[n]); e.size > 0 && (this.__instanceProperties = e); } /** * Returns the node into which the element should render and by default * creates and returns an open shadowRoot. Implement to customize where the * element's DOM is rendered. For example, to render into the element's * childNodes, return `this`. * * @return Returns a node into which to render. * @category rendering */ createRenderRoot() { const e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions); return ut(e, this.constructor.elementStyles), e; } /** * On first connection, creates the element's renderRoot, sets up * element styling, and enables updating. * @category lifecycle */ connectedCallback() { var e; this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (e = this.__controllers) == null || e.forEach((t) => { var n; return (n = t.hostConnected) == null ? void 0 : n.call(t); }); } /** * Note, this method should be considered final and not overridden. It is * overridden on the element instance with a function that triggers the first * update. * @category updates */ enableUpdating(e) { } /** * Allows for `super.disconnectedCallback()` in extensions while * reserving the possibility of making non-breaking feature additions * when disconnecting at some point in the future. * @category lifecycle */ disconnectedCallback() { var e; (e = this.__controllers) == null || e.forEach((t) => { var n; return (n = t.hostDisconnected) == null ? void 0 : n.call(t); }); } /** * Synchronizes property values when attributes change. * * Specifically, when an attribute is set, the corresponding property is set. * You should rarely need to implement this callback. If this method is * overridden, `super.attributeChangedCallback(name, _old, value)` must be * called. * * See [responding to attribute changes](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#responding_to_attribute_changes) * on MDN for more information about the `attributeChangedCallback`. * @category attributes */ attributeChangedCallback(e, t, n) { this._$attributeToProperty(e, n); } __propertyToAttribute(e, t) { var o; const s = this.constructor.elementProperties.get(e), r = this.constructor.__attributeNameForProperty(e, s); if (r !== void 0 && s.reflect === !0) { const d = (((o = s.converter) == null ? void 0 : o.toAttribute) !== void 0 ? s.converter : ne).toAttribute(t, s.type); this.constructor.enabledWarnings.includes("migration") && d === void 0 && M("undefined-attribute-value", `The attribute value for the ${e} property is undefined on element ${this.localName}. The attribute will be removed, but in the previous version of \`ReactiveElement\`, the attribute would not have changed.`), this.__reflectingProperty = e, d == null ? this.removeAttribute(r) : this.setAttribute(r, d), this.__reflectingProperty = null; } } /** @internal */ _$attributeToProperty(e, t) { var r, o; const n = this.constructor, s = n.__attributeToPropertyMap.get(e); if (s !== void 0 && this.__reflectingProperty !== s) { const a = n.getPropertyOptions(s), d = typeof a.converter == "function" ? { fromAttribute: a.converter } : ((r = a.converter) == null ? void 0 : r.fromAttribute) !== void 0 ? a.converter : ne; this.__reflectingProperty = s, this[s] = d.fromAttribute(t, a.type) ?? ((o = this.__defaultValues) == null ? void 0 : o.get(s)) ?? // eslint-disable-next-line @typescript-eslint/no-explicit-any null, this.__reflectingProperty = null; } } /** * Requests an update which is processed asynchronously. This should be called * when an element should update based on some state not triggered by setting * a reactive property. In this case, pass no arguments. It should also be * called when manually implementing a property setter. In this case, pass the * property `name` and `oldValue` to ensure that any configured property * options are honored. * * @param name name of requesting property * @param oldValue old value of requesting property * @param options property options to use instead of the previously * configured options * @category updates */ requestUpdate(e, t, n) { var s; if (e !== void 0) { e instanceof Event && M("", "The requestUpdate() method was called with an Event as the property name. This is probably a mistake caused by binding this.requestUpdate as an event listener. Instead bind a function that will call it with no arguments: () => this.requestUpdate()"); const r = this.constructor, o = this[e]; if (n ?? (n = r.getPropertyOptions(e)), (n.hasChanged ?? Te)(o, t) || // When there is no change, check a corner case that can occur when // 1. there's a initial value which was not reflected // 2. the property is subsequently set to this value. // For example, `prop: {useDefault: true, reflect: true}` // and el.prop = 'foo'. This should be considered a change if the // attribute is not set because we will now reflect the property to the attribute. n.useDefault && n.reflect && o === ((s = this.__defaultValues) == null ? void 0 : s.get(e)) && !this.hasAttribute(r.__attributeNameForProperty(e, n))) this._$changeProperty(e, t, n); else return; } this.isUpdatePending === !1 && (this.__updatePromise = this.__enqueueUpdate()); } /** * @internal */ _$changeProperty(e, t, { useDefault: n, reflect: s, wrapped: r }, o) { n && !(this.__defaultValues ?? (this.__defaultValues = /* @__PURE__ */ new Map())).has(e) && (this.__defaultValues.set(e, o ?? t ?? this[e]), r !== !0 || o !== void 0) || (this._$changedProperties.has(e) || (!this.hasUpdated && !n && (t = void 0), this._$changedProperties.set(e, t)), s === !0 && this.__reflectingProperty !== e && (this.__reflectingProperties ?? (this.__reflectingProperties = /* @__PURE__ */ new Set())).add(e)); } /** * Sets up the element to asynchronously update. */ async __enqueueUpdate() { this.isUpdatePending = !0; try { await this.__updatePromise; } catch (t) { Promise.reject(t); } const e = this.scheduleUpdate(); return e != null && await e, !this.isUpdatePending; } /** * Schedules an element update. You can override this method to change the * timing of updates by returning a Promise. The update will await the * returned Promise, and you should resolve the Promise to allow the update * to proceed. If this method is overridden, `super.scheduleUpdate()` * must be called. * * For instance, to schedule updates to occur just before the next frame: * * ```ts * override protected async scheduleUpdate(): Promise<unknown> { * await new Promise((resolve) => requestAnimationFrame(() => resolve())); * super.scheduleUpdate(); * } * ``` * @category updates */ scheduleUpdate() { const e = this.performUpdate(); return this.constructor.enabledWarnings.includes("async-perform-update") && typeof (e == null ? void 0 : e.then) == "function" && M("async-perform-update", `Element ${this.localName} returned a Promise from performUpdate(). This behavior is deprecated and will be removed in a future version of ReactiveElement.`), e; } /** * Performs an element update. Note, if an exception is thrown during the * update, `firstUpdated` and `updated` will not be called. * * Call `performUpdate()` to immediately process a pending update. This should * generally not be needed, but it can be done in rare cases when you need to * update synchronously. * * @category updates */ performUpdate() { var n; if (!this.isUpdatePending) return; if (ue == null || ue({ kind: "update" }), !this.hasUpdated) { this.renderRoot ?? (this.renderRoot = this.createRenderRoot()); { const o = [...this.constructor.elementProperties.keys()].filter((a) => this.hasOwnProperty(a) && a in Le(this)); if (o.length) throw new Error(`The following properties on element ${this.localName} will not trigger updates as expected because they are set using class fields: ${o.join(", ")}. Native class fields and some compiled output will overwrite accessors used for detecting changes. See https://lit.dev/msg/class-field-shadowing for more information.`); } if (this.__instanceProperties) { for (const [r, o] of this.__instanceProperties) this[r] = o; this.__instanceProperties = void 0; } const s = this.constructor.elementProperties; if (s.size > 0) for (const [r, o] of s) { const { wrapped: a } = o, d = this[r]; a === !0 && !this._$changedProperties.has(r) && d !== void 0 && this._$changeProperty(r, void 0, o, d); } } let e = !1; const t = this._$changedProperties; try { e = this.shouldUpdate(t), e ? (this.willUpdate(t), (n = this.__controllers) == null || n.forEach((s) => { var r; return (r = s.hostUpdate) == null ? void 0 : r.call(s); }), this.update(t)) : this.__markUpdated(); } catch (s) { throw e = !1, this.__markUpdated(), s; } e && this._$didUpdate(t); } /** * Invoked before `update()` to compute values needed during the update. * * Implement `willUpdate` to compute property values that depend on other * properties and are used in the rest of the update process. * * ```ts * willUpdate(changedProperties) { * // only need to check changed properties for an expensive computation. * if (changedProperties.has('firstName') || changedProperties.has('lastName')) { * this.sha = computeSHA(`${this.firstName} ${this.lastName}`); * } * } * * render() { * return html`SHA: ${this.sha}`; * } * ``` * * @category updates */ willUpdate(e) { } // Note, this is an override point for polyfill-support. // @internal _$didUpdate(e) { var t; (t = this.__controllers) == null || t.forEach((n) => { var s; return (s = n.hostUpdated) == null ? void 0 : s.call(n); }), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e), this.isUpdatePending && this.constructor.enabledWarnings.includes("change-in-update") && M("change-in-update", `Element ${this.localName} scheduled an update (generally because a property was set) after an update completed, causing a new update to be scheduled. This is inefficient and should be avoided unless the next update can only be scheduled as a side effect of the previous update.`); } __markUpdated() { this._$changedProperties = /* @__PURE__ */ new Map(), this.isUpdatePending = !1; } /** * Returns a Promise that resolves when the element has completed updating. * The Promise value is a boolean that is `true` if the element completed the * update without triggering another update. The Promise result is `false` if * a property was set inside `updated()`. If the Promise is rejected, an * exception was thrown during the update. * * To await additional asynchronous work, override the `getUpdateComplete` * method. For example, it is sometimes useful to await a rendered element * before fulfilling this Promise. To do this, first await * `super.getUpdateComplete()`, then any subsequent state. * * @return A promise of a boolean that resolves to true if the update completed * without triggering another update. * @category updates */ get updateComplete() { return this.getUpdateComplete(); } /** * Override point for the `updateComplete` promise. * * It is not safe to override the `updateComplete` getter directly due to a * limitation in TypeScript which means it is not possible to call a * superclass getter (e.g. `super.updateComplete.then(...)`) when the target * language is ES5 (https://github.com/microsoft/TypeScript/issues/338). * This method should be overridden instead. For example: * * ```ts * class MyElement extends LitElement { * override async getUpdateComplete() { * const result = await super.getUpdateComplete(); * await this._myChild.updateComplete; * return result; * } * } * ``` * * @return A promise of a boolean that resolves to true if the update completed * without triggering another update. * @category updates */ getUpdateComplete() { return this.__updatePromise; } /** * Controls whether or not `update()` should be called when the element requests * an update. By default, this method always returns `true`, but this can be * customized to control when to update. * * @param _changedProperties Map of changed properties with old values * @category updates */ shouldUpdate(e) { return !0; } /** * Updates the element. This method reflects property values to attributes. * It can be overridden to render and keep updated element DOM. * Setting properties inside this method will *not* trigger * another update. * * @param _changedProperties Map of changed properties with old values * @category updates */ update(e) { this.__reflectingProperties && (this.__reflectingProperties = this.__reflectingProperties.forEach((t) => this.__propertyToAttribute(t, this[t]))), this.__markUpdated(); } /** * Invoked whenever the element is updated. Implement to perform * post-updating tasks via DOM APIs, for example, focusing an element. * * Setting properties inside this method will trigger the element to update * again after this update cycle completes. * * @param _changedProperties Map of changed properties with old values * @category updates */ updated(e) { } /** * Invoked when the element is first updated. Implement to perform one time * work on the element after update. * * ```ts * firstUpdated() { * this.renderRoot.getElementById('my-text-area').focus(); * } * ``` * * Setting properties inside this method will trigger the element to update * again after this update cycle completes. * * @param _changedProperties Map of changed properties with old values * @category updates */ firstUpdated(e) { } } U.elementStyles = []; U.shadowRootOptions = { mode: "open" }; U[V("elementProperties")] = /* @__PURE__ */ new Map(); U[V("finalized")] = /* @__PURE__ */ new Map(); te == null || te({ ReactiveElement: U }); { U.enabledWarnings = [ "change-in-update", "async-perform-update" ]; const i = function(e) { e.hasOwnProperty(V("enabledWarnings")) || (e.enabledWarnings = e.enabledWarnings.slice()); }; U.enableWarning = function(e) { i(this), this.enabledWarnings.includes(e) || this.enabledWarnings.push(e); }, U.disableWarning = function(e) { i(this); const t = this.enabledWarnings.indexOf(e); t >= 0 && this.enabledWarnings.splice(t, 1); }; } (y.reactiveElementVersions ?? (y.reactiveElementVersions = [])).push("2.1.0"); y.reactiveElementVersions.length > 1 && queueMicrotask(() => { M("multiple-versions", "Multiple versions of Lit loaded. Loading multiple versions is not recommended."); }); /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ const k = globalThis, g = (i) => { k.emitLitDebugLogEvents && k.dispatchEvent(new CustomEvent("lit-debug", { detail: i })); }; let vt = 0, q; k.litIssuedWarnings ?? (k.litIssuedWarnings = /* @__PURE__ */ new Set()), q = (i, e) => { e += i ? ` See https://lit.dev/msg/${i} for more information.` : "", !k.litIssuedWarnings.has(e) && !k.litIssuedWarnings.has(i) && (console.warn(e), k.litIssuedWarnings.add(e)); }, queueMicrotask(() => { q("dev-mode", "Lit is in dev mode. Not recommended for production!"); }); var Ke, Xe; const P = (Ke = k.ShadyDOM) != null && Ke.inUse && ((Xe = k.ShadyDOM) == null ? void 0 : Xe.noPatch) === !0 ? k.ShadyDOM.wrap : (i) => i, se = k.trustedTypes, Ve = se ? se.createPolicy("lit-html", { createHTML: (i) => i }) : void 0, _t = (i) => i, pe = (i, e, t) => _t, yt = (i) => { if (O !== pe) throw new Error("Attempted to overwrite existing lit-html security policy. setSanitizeDOMValueFactory should be called at most once."); O = i; }, St = () => { O = pe; }, Se = (i, e, t) => O(i, e, t), tt = "$lit$", I = `lit$${Math.random().toFixed(9).slice(2)}$`, it = "?" + I, wt = `<${it}>`, L = document, G = () => L.createComment(""), Y = (i) => i === null || typeof i != "object" && typeof i != "function", Pe = Array.isArray, kt = (i) => Pe(i) || // eslint-disable-next-line @typescript-eslint/no-explicit-any typeof (i == null ? void 0 : i[Symbol.iterator]) == "function", he = `[ \f\r]`, $t = `[^ \f\r"'\`<>=]`, Dt = `[^\\s"'>=/]`, Q = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, We = 1, me = 2, Ct = 3, je = /-->/g, He = />/g, A = new RegExp(`>|${he}(?:(${Dt}+)(${he}*=${he}*(?:${$t}|("|')|))|$)`, "g"), Et = 0, Qe = 1, Tt = 2, Be = 3, ge = /'/g, fe = /"/g, nt = /^(?:script|style|textarea|title)$/i, Pt = 1, we = 2, ke = 3, Me = 1, re = 2, Mt = 3, Ft = 4, zt = 5, Fe = 6, It = 7, Ut = (i) => (e, ...t) => (e.some((n) => n === void 0) && console.warn(`Some template strings are undefined. This is probably caused by illegal octal escape sequences.`), t.some((n) => n == null ? void 0 : n._$litStatic$) && q("", `Static values 'literal' or 'unsafeStatic' cannot be used as values to non-static templates. Please use the static 'html' tag function. See https://lit.dev/docs/templates/expressions/#static-expressions`), { // This property needs to remain unminified. _$litType$: i, strings: e, values: t }), l = Ut(Pt), R = Symbol.for("lit-noChange"), v = Symbol.for("lit-nothing"), qe = /* @__PURE__ */ new WeakMap(), N = L.createTreeWalker( L, 129 /* NodeFilter.SHOW_{ELEMENT|COMMENT} */ ); let O = pe; function st(i, e) { if (!Pe(i) || !i.hasOwnProperty("raw")) { let t = "invalid template strings array"; throw t = ` Internal Error: expected template strings to be an array with a 'raw' field. Faking a template strings array by calling html or svg like an ordinary function is effectively the same as calling unsafeHtml and can lead to major security issues, e.g. opening your code up to XSS attacks. If you're using the html or svg tagged template functions normally and still seeing this error, please file a bug at https://github.com/lit/lit/issues/new?template=bug_report.md and include information about your build tooling, if any. `.trim().replace(/\n */g, ` `), new Error(t); } return Ve !== void 0 ? Ve.createHTML(e) : e; } const At = (i, e) => { const t = i.length - 1, n = []; let s = e === we ? "<svg>" : e === ke ? "<math>" : "", r, o = Q; for (let d = 0; d < t; d++) { const p = i[d]; let c = -1, u, h = 0, m; for (; h < p.length && (o.lastIndex = h, m = o.exec(p), m !== null); ) if (h = o.lastIndex, o === Q) { if (m[We] === "!--") o = je; else if (m[We] !== void 0) o = He; else if (m[me] !== void 0) nt.test(m[me]) && (r = new RegExp(`</${m[me]}`, "g")), o = A; else if (m[Ct] !== void 0) throw new Error("Bindings in tag names are not supported. Please use static templates instead. See https://lit.dev/docs/templates/expressions/#static-expressions"); } else o === A ? m[Et] === ">" ? (o = r ?? Q, c = -1) : m[Qe] === void 0 ? c = -2 : (c = o.lastIndex - m[Tt].length, u = m[Qe], o = m[Be] === void 0 ? A : m[Be] === '"' ? fe : ge) : o === fe || o === ge ? o = A : o === je || o === He ? o = Q : (o = A, r = void 0); console.assert(c === -1 || o === A || o === ge || o === fe, "unexpected parse state B"); const x = o === A && i[d + 1].startsWith("/>") ? " " : ""; s += o === Q ? p + wt : c >= 0 ? (n.push(u), p.slice(0, c) + tt + p.slice(c) + I + x) : p + I + (c === -2 ? d : x); } const a = s + (i[t] || "<?>") + (e === we ? "</svg>" : e === ke ? "</math>" : ""); return [st(i, a), n]; }; class J { constructor({ strings: e, ["_$litType$"]: t }, n) { this.parts = []; let s, r = 0, o = 0; const a = e.length - 1, d = this.parts, [p, c] = At(e, t); if (this.el = J.createElement(p, n), N.currentNode = this.el.content, t === we || t === ke) { const u = this.el.content.firstChild; u.replaceWith(...u.childNodes); } for (; (s = N.nextNode()) !== null && d.length < a; ) { if (s.nodeType === 1) { { const u = s.localName; if (/^(?:textarea|template)$/i.test(u) && s.innerHTML.includes(I)) { const h = `Expressions are not supported inside \`${u}\` elements. See https://lit.dev/msg/expression-in-${u} for more information.`; if (u === "template") throw new Error(h); q("", h); } } if (s.hasAttributes()) for (const u of s.getAttributeNames()) if (u.endsWith(tt)) { const h = c[o++], x = s.getAttribute(u).split(I), $ = /([.?@])?(.*)/.exec(h); d.push({ type: Me, index: r, name: $[2], strings: x, ctor: $[1] === "." ? Lt : $[1] === "?" ? Rt : $[1] === "@" ? Ot : ce }), s.removeAttribute(u); } else u.startsWith(I) && (d.push({ type: Fe, index: r }), s.removeAttribute(u)); if (nt.test(s.tagName)) { const u = s.textContent.split(I), h = u.length - 1; if (h > 0) { s.textContent = se ? se.emptyScript : ""; for (let m = 0; m < h; m++) s.append(u[m], G()), N.nextNode(), d.push({ type: re, index: ++r }); s.append(u[h], G()); } } } else if (s.nodeType === 8) if (s.data === it) d.push({ type: re, index: r }); else { let h = -1; for (; (h = s.data.indexOf(I, h + 1)) !== -1; ) d.push({ type: It, index: r }), h += I.length - 1; } r++; } if (c.length !== o) throw new Error('Detected duplicate attribute bindings. This occurs if your template has duplicate attributes on an element tag. For example "<input ?disabled=${true} ?disabled=${false}>" contains a duplicate "disabled" attribute. The error was detected in the following template: \n`' + e.join("${...}") + "`"); g && g({ kind: "template prep", template: this, clonableTemplate: this.el, parts: this.parts, strings: e }); } // Overridden via `litHtmlPolyfillSupport` to provide platform support. /** @nocollapse */ static createElement(e, t) { const n = L.createElement("template"); return n.innerHTML = e, n; } } function W(i, e, t = i, n) { var o, a; if (e === R) return e; let s = n !== void 0 ? (o = t.__directives) == null ? void 0 : o[n] : t.__directive; const r = Y(e) ? void 0 : ( // This property needs to remain unminified. e._$litDirective$ ); return (s == null ? void 0 : s.constructor) !== r && ((a = s == null ? void 0 : s._$notifyDirectiveConnectionChanged) == null || a.call(s, !1), r === void 0 ? s = void 0 : (s = new r(i), s._$initialize(i, t, n)), n !== void 0 ? (t.__directives ?? (t.__directives = []))[n] = s : t.__directive = s), s !== void 0 && (e = W(i, s._$resolve(i, e.values), s, n)), e; } class Nt { constructor(e, t) { this._$parts = [], this._$disconnectableChildren = void 0, this._$template = e, this._$parent = t; } // Called by ChildPart parentNode getter get parentNode() { return this._$parent.parentNode; } // See comment in Disconnectable interface for why this is a getter get _$isConnected() { return this._$parent._$isConnected; } // This method is separate from the constructor because we need to return a // DocumentFragment and we don't want to hold onto it with an instance field. _clone(e) { const { el: { content: t }, parts: n } = this._$template, s = ((e == null ? void 0 : e.creationScope) ?? L).importNode(t, !0); N.currentNode = s; let r = N.nextNode(), o = 0, a = 0, d = n[0]; for (; d !== void 0; ) { if (o === d.index) { let p; d.type === re ? p = new K(r, r.nextSibling, this, e) : d.type === Me ? p = new d.ctor(r, d.name, d.strings, this, e) : d.type === Fe && (p = new Vt(r, this, e)), this._$parts.push(p), d = n[++a]; } o !== (d == null ? void 0 : d.index) && (r = N.nextNode(), o++); } return N.currentNode = L, s; } _update(e) { let t = 0; for (const n of this._$parts) n !== void 0 && (g && g({ kind: "set part", part: n, value: e[t], valueIndex: t, values: e, templateInstance: this }), n.strings !== void 0 ? (n._$setValue(e, n, t), t += n.strings.length - 2) : n._$setValue(e[t])), t++; } } class K { // See comment in Disconnectable interface for why this is a getter get _$isConnected() { var e; return ((e = this._$parent) == null ? void 0 : e._$isConnected) ?? this.__isConnected; } constructor(e, t, n, s) { this.type = re, this._$committedValue = v, this._$disconnectableChildren = void 0, this._$startNode = e, this._$endNode = t, this._$parent = n, this.options = s, this.__isConnected = (s == null ? void 0 : s.isConnected) ?? !0, this._textSanitizer = void 0; } /** * The parent node into which the part renders its content. * * A ChildPart's content consists of a range of adjacent child nodes of * `.parentNode`, possibly bordered by 'marker nodes' (`.startNode` and * `.endNode`). * * - If both `.startNode` and `.endNode` are non-null, then the part's content * consists of all siblings between `.startNode` and `.endNode`, exclusively. * * - If `.startNode` is non-null but `.endNode` is null, then the part's * content consists of all siblings following `.startNode`, up to and * including the last child of `.parentNode`. If `.endNode` is non-null, then * `.startNode` will always be non-null. * * - If both `.endNode` and `.startNode` are null, then the part's content * consists of all child nodes of `.parentNode`. */ get parentNode() { let e = P(this._$startNode).parentNode; const t = this._$parent; return t !== void 0 && (e == null ? void 0 : e.nodeType) === 11 && (e = t.parentNode), e; } /** * The part's leading marker node, if any. See `.parentNode` for more * information. */ get startNode() { return this._$startNode; } /** * The part's trailing marker node, if any. See `.parentNode` for more * information. */ get endNode() { return this._$endNode; } _$setValue(e, t = this) { var n; if (this.parentNode === null) throw new Error("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."); if (e = W(this, e, t), Y(e)) e === v || e == null || e === "" ? (this._$committedValue !== v && (g && g({ kind: "commit nothing to child", start: this._$startNode, end: this._$endNode, parent: this._$parent, options: this.options }), this._$clear()), this._$committedValue = v) : e !== this._$committedValue && e !== R && this._commitText(e); else if (e._$litType$ !== void 0) this._commitTemplateResult(e); else if (e.nodeType !== void 0) { if (((n = this.options) == null ? void 0 : n.host) === e) { this._commitText("[probable mistake: rendered a template's host in itself (commonly caused by writing ${this} in a template]"), console.warn("Attempted to render the template host", e, "inside itself. This is almost always a mistake, and in dev mode ", "we render some warning text. In production however, we'll ", "render it, which will usually result in an error, and sometimes ", "in the element disappearing from the DOM."); return; } this._commitNode(e); } else kt(e) ? this._commitIterable(e) : this._commitText(e); } _insert(e) { return P(P(this._$startNode).parentNode).insertBefore(e, this._$endNode); } _commitNode(e) { var t; if (this._$committedValue !== e) { if (this._$clear(), O !== pe) { const n = (t = this._$startNode.parentNode) == null ? void 0 : t.nodeName; if (n === "STYLE" || n === "SCRIPT") { let s = "Forbidden"; throw n === "STYLE" ? s = "Lit does not support binding inside style nodes. This is a security risk, as style injection attacks can exfiltrate data and spoof UIs. Consider instead using css`...` literals to compose styles, and do dynamic styling with css custom properties, ::parts, <slot>s, and by mutating the DOM rather than stylesheets." : s = "Lit does not support binding inside script nodes. This is a security risk, as it could allow arbitrary code execution.", new Error(s); } } g && g({ kind: "commit node", start: this._$startNode, parent: this._$parent, value: e, options: this.options }), this._$committedValue = this._insert(e); } } _commitText(e) { if (this._$committedValue !== v && Y(this._$committedValue)) { const t = P(this._$startNode).nextSibling; this._textSanitizer === void 0 && (this._textSanitizer = Se(t, "data", "property")), e = this._textSanitizer(e), g && g({ kind: "commit text", node: t, value: e, options: this.options }), t.data = e; } else { const t = L.createTextNode(""); this._commitNode(t), this._textSanitizer === void 0 && (this._textSanitizer = Se(t, "data", "property")), e = this._textSanitizer(e), g && g({ kind: "commit text", node: t, value: e, options: this.options }), t.data = e; } this._$committedValue = e; } _commitTemplateResult(e) { var r; const { values: t, ["_$litType$"]: n } = e, s = typeof n == "number" ? this._$getTemplate(e) : (n.el === void 0 && (n.el = J.createElement(st(n.h, n.h[0]), this.options)), n); if (((r = this._$committedValue) == null ? void 0 : r._$template) === s) g && g({ kind: "template updating", template: s, instance: this._$committedValue, parts: this._$committedValue._$parts, options: this.options, values: t }), this._$committedValue._update(t); else { const o = new Nt(s, this), a = o._clone(this.options); g && g({ kind: "template instantiated", template: s, instance: o, parts: o._$parts, options: this.options, fragment: a, values: t }), o._update(t), g && g({ kind: "template instantiated and updated", template: s, instance: o, parts: o._$parts, options: this.options, fragment: a, values: t }), this._commitNode(a), this._$committedValue = o; } } // Overridden via `litHtmlPolyfillSupport` to provide platform support. /** @internal */ _$getTemplate(e) { let t = qe.get(e.strings); return t === void 0 && qe.set(e.strings, t = new J(e)), t; } _commitIterable(e) { Pe(this._$committedValue) || (this._$committedValue = [], this._$clear()); const t = this._$committedValue; let n = 0, s; for (const r of e) n === t.length ? t.push(s = new K(this._insert(G()), this._insert(G()), this, this.options)) : s = t[n], s._$setValue(r), n++; n < t.length && (this._$clear(s && P(s._$endNode).nextSibling, n), t.length = n); } /** * Removes the nodes contained within this Part from the DOM. * * @param start Start node to clear from, for clearing a subset of the part's * DOM (used when truncating iterables) * @param from When `start` is specified, the index within the iterable from * which ChildParts are being removed, used for disconnecting directives in * those Parts. * * @internal */ _$clear(e = P(this._$startNode).nextSibling, t) { var n; for ((n = this._$notifyConnectionChanged) == null || n.call(this, !1, !0, t); e && e !== this._$endNode; ) { const s = P(e).nextSibling; P(e).remove(), e = s; } } /** * Implementation of RootPart's `isConnected`. Note that this method * should only be called on `RootPart`s (the `ChildPart` returned from a * top-level `render()` call). It has no effect on non-root ChildParts. * @param isConnected Whether to set * @internal */ setConnected(e) { var t; if (this._$parent === void 0) this.__isConnected = e, (t = this._$notifyConnectionChanged) == null || t.call(this, e); else throw new Error("part.setConnected() may only be called on a RootPart returned from render()."); } } class ce { get tagName() { return this.element.tagName; } // See comment in Disconnectable interface for why this is a getter get _$isConnected() { return this._$parent._$isConnected; } constructor(e, t, n, s, r) { this.type = Me, this._$committedValue = v, this._$disconnectableChildren = void 0, this.element = e, this.name = t, this._$parent = s, this.options = r, n.length > 2 || n[0] !== "" || n[1] !== "" ? (this._$committedValue = new Array(n.length - 1).fill(new String()), this.strings = n) : this._$committedValue = v, this._sanitizer = void 0; } /** * Sets the value of this part by resolving the value from possibly multiple * values and static strings and committing it to the DOM. * If this part is single-valued, `this._strings` will be undefined, and the * method will be called with a single value argument. If this part is * multi-value, `this._strings` will be defined, and the method is called * with the value array of the part's owning TemplateInstance, and an offset * into the value array from which the values should be read. * This method is overloaded this way to eliminate short-lived array slices * of the template instance values, and allow a fast-path for single-valued * parts. * * @param value The part value, or an array of values for multi-valued parts * @param valueIndex the index to start reading values from. `undefined` for * single-valued parts * @param noCommit causes the part to not commit its value to the DOM. Used * in hydration to prime attribute parts with their first-rendered value, * but not set the attribute, and in SSR to no-op the DOM operation and * capture the value for serialization. * * @internal */ _$setValue(e, t = this, n, s) { const r = this.strings; let o = !1; if (r === void 0) e = W(this, e, t, 0), o = !Y(e) || e !== this._$committedValue && e !== R, o && (this._$committedValue = e); else { const a = e; e = r[0]; let d, p; fo