"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const cssTag = require("./css-tag.js");
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */
var s;
const e = window, r = e.trustedTypes, h = r ? r.emptyScript : "", o = e.reactiveElementPolyfillSupport, n = { toAttribute(t, i) {
  switch (i) {
    case Boolean:
      t = t ? h : null;
      break;
    case Object:
    case Array:
      t = null == t ? t : JSON.stringify(t);
  }
  return t;
}, fromAttribute(t, i) {
  let s2 = t;
  switch (i) {
    case Boolean:
      s2 = null !== t;
      break;
    case Number:
      s2 = null === t ? null : Number(t);
      break;
    case Object:
    case Array:
      try {
        s2 = JSON.parse(t);
      } catch (t2) {
        s2 = null;
      }
  }
  return s2;
} }, a = (t, i) => i !== t && (i == i || t == t), l = { attribute: true, type: String, converter: n, reflect: false, hasChanged: a }, d = "finalized";
class u extends HTMLElement {
  constructor() {
    super(), this._$Ei = /* @__PURE__ */ new Map(), this.isUpdatePending = false, this.hasUpdated = false, this._$El = null, this._$Eu();
  }
  static addInitializer(t) {
    var i;
    this.finalize(), (null !== (i = this.h) && void 0 !== i ? i : this.h = []).push(t);
  }
  static get observedAttributes() {
    this.finalize();
    const t = [];
    return this.elementProperties.forEach((i, s2) => {
      const e2 = this._$Ep(s2, i);
      void 0 !== e2 && (this._$Ev.set(e2, s2), t.push(e2));
    }), t;
  }
  static createProperty(t, i = l) {
    if (i.state && (i.attribute = false), this.finalize(), this.elementProperties.set(t, i), !i.noAccessor && !this.prototype.hasOwnProperty(t)) {
      const s2 = "symbol" == typeof t ? Symbol() : "__" + t, e2 = this.getPropertyDescriptor(t, s2, i);
      void 0 !== e2 && Object.defineProperty(this.prototype, t, e2);
    }
  }
  static getPropertyDescriptor(t, i, s2) {
    return { get() {
      return this[i];
    }, set(e2) {
      const r2 = this[t];
      this[i] = e2, this.requestUpdate(t, r2, s2);
    }, configurable: true, enumerable: true };
  }
  static getPropertyOptions(t) {
    return this.elementProperties.get(t) || l;
  }
  static finalize() {
    if (this.hasOwnProperty(d))
      return false;
    this[d] = true;
    const t = Object.getPrototypeOf(this);
    if (t.finalize(), void 0 !== t.h && (this.h = [...t.h]), this.elementProperties = new Map(t.elementProperties), this._$Ev = /* @__PURE__ */ new Map(), this.hasOwnProperty("properties")) {
      const t2 = this.properties, i = [...Object.getOwnPropertyNames(t2), ...Object.getOwnPropertySymbols(t2)];
      for (const s2 of i)
        this.createProperty(s2, t2[s2]);
    }
    return this.elementStyles = this.finalizeStyles(this.styles), true;
  }
  static finalizeStyles(i) {
    const s2 = [];
    if (Array.isArray(i)) {
      const e2 = new Set(i.flat(1 / 0).reverse());
      for (const i2 of e2)
        s2.unshift(cssTag.getCompatibleStyle(i2));
    } else
      void 0 !== i && s2.push(cssTag.getCompatibleStyle(i));
    return s2;
  }
  static _$Ep(t, i) {
    const s2 = i.attribute;
    return false === s2 ? void 0 : "string" == typeof s2 ? s2 : "string" == typeof t ? t.toLowerCase() : void 0;
  }
  _$Eu() {
    var t;
    this._$E_ = new Promise((t2) => this.enableUpdating = t2), this._$AL = /* @__PURE__ */ new Map(), this._$Eg(), this.requestUpdate(), null === (t = this.constructor.h) || void 0 === t || t.forEach((t2) => t2(this));
  }
  addController(t) {
    var i, s2;
    (null !== (i = this._$ES) && void 0 !== i ? i : this._$ES = []).push(t), void 0 !== this.renderRoot && this.isConnected && (null === (s2 = t.hostConnected) || void 0 === s2 || s2.call(t));
  }
  removeController(t) {
    var i;
    null === (i = this._$ES) || void 0 === i || i.splice(this._$ES.indexOf(t) >>> 0, 1);
  }
  _$Eg() {
    this.constructor.elementProperties.forEach((t, i) => {
      this.hasOwnProperty(i) && (this._$Ei.set(i, this[i]), delete this[i]);
    });
  }
  createRenderRoot() {
    var t;
    const s2 = null !== (t = this.shadowRoot) && void 0 !== t ? t : this.attachShadow(this.constructor.shadowRootOptions);
    return cssTag.adoptStyles(s2, this.constructor.elementStyles), s2;
  }
  connectedCallback() {
    var t;
    void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(true), null === (t = this._$ES) || void 0 === t || t.forEach((t2) => {
      var i;
      return null === (i = t2.hostConnected) || void 0 === i ? void 0 : i.call(t2);
    });
  }
  enableUpdating(t) {
  }
  disconnectedCallback() {
    var t;
    null === (t = this._$ES) || void 0 === t || t.forEach((t2) => {
      var i;
      return null === (i = t2.hostDisconnected) || void 0 === i ? void 0 : i.call(t2);
    });
  }
  attributeChangedCallback(t, i, s2) {
    this._$AK(t, s2);
  }
  _$EO(t, i, s2 = l) {
    var e2;
    const r2 = this.constructor._$Ep(t, s2);
    if (void 0 !== r2 && true === s2.reflect) {
      const h2 = (void 0 !== (null === (e2 = s2.converter) || void 0 === e2 ? void 0 : e2.toAttribute) ? s2.converter : n).toAttribute(i, s2.type);
      this._$El = t, null == h2 ? this.removeAttribute(r2) : this.setAttribute(r2, h2), this._$El = null;
    }
  }
  _$AK(t, i) {
    var s2;
    const e2 = this.constructor, r2 = e2._$Ev.get(t);
    if (void 0 !== r2 && this._$El !== r2) {
      const t2 = e2.getPropertyOptions(r2), h2 = "function" == typeof t2.converter ? { fromAttribute: t2.converter } : void 0 !== (null === (s2 = t2.converter) || void 0 === s2 ? void 0 : s2.fromAttribute) ? t2.converter : n;
      this._$El = r2, this[r2] = h2.fromAttribute(i, t2.type), this._$El = null;
    }
  }
  requestUpdate(t, i, s2) {
    let e2 = true;
    void 0 !== t && (((s2 = s2 || this.constructor.getPropertyOptions(t)).hasChanged || a)(this[t], i) ? (this._$AL.has(t) || this._$AL.set(t, i), true === s2.reflect && this._$El !== t && (void 0 === this._$EC && (this._$EC = /* @__PURE__ */ new Map()), this._$EC.set(t, s2))) : e2 = false), !this.isUpdatePending && e2 && (this._$E_ = this._$Ej());
  }
  async _$Ej() {
    this.isUpdatePending = true;
    try {
      await this._$E_;
    } catch (t2) {
      Promise.reject(t2);
    }
    const t = this.scheduleUpdate();
    return null != t && await t, !this.isUpdatePending;
  }
  scheduleUpdate() {
    return this.performUpdate();
  }
  performUpdate() {
    var t;
    if (!this.isUpdatePending)
      return;
    this.hasUpdated, this._$Ei && (this._$Ei.forEach((t2, i2) => this[i2] = t2), this._$Ei = void 0);
    let i = false;
    const s2 = this._$AL;
    try {
      i = this.shouldUpdate(s2), i ? (this.willUpdate(s2), null === (t = this._$ES) || void 0 === t || t.forEach((t2) => {
        var i2;
        return null === (i2 = t2.hostUpdate) || void 0 === i2 ? void 0 : i2.call(t2);
      }), this.update(s2)) : this._$Ek();
    } catch (t2) {
      throw i = false, this._$Ek(), t2;
    }
    i && this._$AE(s2);
  }
  willUpdate(t) {
  }
  _$AE(t) {
    var i;
    null === (i = this._$ES) || void 0 === i || i.forEach((t2) => {
      var i2;
      return null === (i2 = t2.hostUpdated) || void 0 === i2 ? void 0 : i2.call(t2);
    }), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t);
  }
  _$Ek() {
    this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = false;
  }
  get updateComplete() {
    return this.getUpdateComplete();
  }
  getUpdateComplete() {
    return this._$E_;
  }
  shouldUpdate(t) {
    return true;
  }
  update(t) {
    void 0 !== this._$EC && (this._$EC.forEach((t2, i) => this._$EO(i, this[i], t2)), this._$EC = void 0), this._$Ek();
  }
  updated(t) {
  }
  firstUpdated(t) {
  }
}
u[d] = true, u.elementProperties = /* @__PURE__ */ new Map(), u.elementStyles = [], u.shadowRootOptions = { mode: "open" }, null == o || o({ ReactiveElement: u }), (null !== (s = e.reactiveElementVersions) && void 0 !== s ? s : e.reactiveElementVersions = []).push("1.6.3");
exports.CSSResult = cssTag.CSSResult;
exports.adoptStyles = cssTag.adoptStyles;
exports.getCompatibleStyle = cssTag.getCompatibleStyle;
exports.supportsAdoptingStyleSheets = cssTag.supportsAdoptingStyleSheets;
exports.unsafeCSS = cssTag.unsafeCSS;
exports.ReactiveElement = u;
exports.defaultConverter = n;
exports.notEqual = a;
//# sourceMappingURL=reactive-element.js.map
