/**
 * @license
 * Copyright 2016 Google Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
(() => {
  var S, w, v;
  const l = Symbol(), y = Symbol(), b = Symbol(), c = Symbol(), p = Symbol(), N = Symbol(), k = Symbol(), T = Symbol(), u = Symbol(), n = Symbol(), e = Symbol(), i = Symbol(), o = Symbol();
  class d {
    constructor() {
      this[S] = [], this[w] = [], this[v] = /* @__PURE__ */ new Set();
    }
    destructor() {
      this[u](this[b]);
      const t = this;
      t[l] = null, t[b] = null, t[y] = null;
    }
    get top() {
      const t = this[l];
      return t[t.length - 1] || null;
    }
    push(t) {
      !t || t === this.top || (this.remove(t), this[N](t), this[l].push(t));
    }
    remove(t) {
      const r = this[l].indexOf(t);
      return r === -1 ? !1 : (this[l].splice(r, 1), r === this[l].length && this[N](this.top), !0);
    }
    pop() {
      const t = this.top;
      return t && this.remove(t), t;
    }
    has(t) {
      return this[l].indexOf(t) !== -1;
    }
    /**
     * Sets `inert` to all document elements except the new top element, its
     * parents, and its distributed content.
     */
    [(S = l, w = b, v = y, N)](t) {
      const r = this[y], s = this[b];
      if (!t) {
        this[u](s), r.clear(), this[b] = [];
        return;
      }
      const a = this[n](t);
      if (a[a.length - 1].parentNode !== document.body)
        throw Error("Non-connected element cannot be a blocking element");
      this[b] = a;
      const h = this[e](t);
      if (!s.length) {
        this[T](a, h, r);
        return;
      }
      let _ = s.length - 1, f = a.length - 1;
      for (; _ > 0 && f > 0 && s[_] === a[f]; )
        _--, f--;
      s[_] !== a[f] && this[k](s[_], a[f]), _ > 0 && this[u](s.slice(0, _)), f > 0 && this[T](a.slice(0, f), h, null);
    }
    /**
     * Swaps inertness between two sibling elements.
     * Sets the property `inert` over the attribute since the inert spec
     * doesn't specify if it should be reflected.
     * https://html.spec.whatwg.org/multipage/interaction.html#inert
     */
    [k](t, r) {
      const s = t[c];
      this[i](t) && !t.inert && (t.inert = !0, s.add(t)), s.has(r) && (r.inert = !1, s.delete(r)), r[p] = t[p], r[c] = s, t[p] = void 0, t[c] = void 0;
    }
    /**
     * Restores original inertness to the siblings of the elements.
     * Sets the property `inert` over the attribute since the inert spec
     * doesn't specify if it should be reflected.
     * https://html.spec.whatwg.org/multipage/interaction.html#inert
     */
    [u](t) {
      for (const r of t) {
        r[p].disconnect(), r[p] = void 0;
        const a = r[c];
        for (const h of a)
          h.inert = !1;
        r[c] = void 0;
      }
    }
    /**
     * Inerts the siblings of the elements except the elements to skip. Stores
     * the inerted siblings into the element's symbol `_siblingsToRestore`.
     * Pass `toKeepInert` to collect the already inert elements.
     * Sets the property `inert` over the attribute since the inert spec
     * doesn't specify if it should be reflected.
     * https://html.spec.whatwg.org/multipage/interaction.html#inert
     */
    [T](t, r, s) {
      for (const a of t) {
        const h = a.parentNode, _ = h.children, f = /* @__PURE__ */ new Set();
        for (let R = 0; R < _.length; R++) {
          const I = _[R];
          I === a || !this[i](I) || r && r.has(I) || (s && I.inert ? s.add(I) : (I.inert = !0, f.add(I)));
        }
        a[c] = f;
        const M = new MutationObserver(this[o].bind(this));
        a[p] = M;
        let E = h;
        const g = E;
        g.__shady && g.host && (E = g.host), M.observe(E, {
          childList: !0
        });
      }
    }
    /**
     * Handles newly added/removed nodes by toggling their inertness.
     * It also checks if the current top Blocking Element has been removed,
     * notifying and removing it.
     */
    [o](t) {
      const r = this[b], s = this[y];
      for (const a of t) {
        const h = a.target.host || a.target, _ = h === document.body ? r.length : r.indexOf(h), f = r[_ - 1], M = f[c];
        for (let E = 0; E < a.removedNodes.length; E++) {
          const g = a.removedNodes[E];
          if (g === f) {
            console.info("Detected removal of the top Blocking Element."), this.pop();
            return;
          }
          M.has(g) && (g.inert = !1, M.delete(g));
        }
        for (let E = 0; E < a.addedNodes.length; E++) {
          const g = a.addedNodes[E];
          this[i](g) && (s && g.inert ? s.add(g) : (g.inert = !0, M.add(g)));
        }
      }
    }
    /**
     * Returns if the element is inertable.
     */
    [i](t) {
      return /^(style|template|script)$/.test(t.localName) === !1;
    }
    /**
     * Returns the list of newParents of an element, starting from element
     * (included) up to `document.body` (excluded).
     */
    [n](t) {
      const r = [];
      let s = t;
      for (; s && s !== document.body; ) {
        if (s.nodeType === Node.ELEMENT_NODE && r.push(s), s.assignedSlot) {
          for (; s = s.assignedSlot; )
            r.push(s);
          s = r.pop();
          continue;
        }
        s = s.parentNode || s.host;
      }
      return r;
    }
    /**
     * Returns the distributed children of the element's shadow root.
     * Returns null if the element doesn't have a shadow root.
     */
    [e](t) {
      const r = t.shadowRoot;
      if (!r)
        return null;
      const s = /* @__PURE__ */ new Set();
      let a, h, _;
      const f = r.querySelectorAll("slot");
      if (f.length && f[0].assignedNodes)
        for (a = 0; a < f.length; a++)
          for (_ = f[a].assignedNodes({
            flatten: !0
          }), h = 0; h < _.length; h++)
            _[h].nodeType === Node.ELEMENT_NODE && s.add(_[h]);
      return s;
    }
  }
  document.$blockingElements = new d();
})();
var A = {}, x;
function D() {
  if (x) return A;
  x = 1;
  var S = /* @__PURE__ */ function() {
    function v(l, y) {
      for (var b = 0; b < y.length; b++) {
        var c = y[b];
        c.enumerable = c.enumerable || !1, c.configurable = !0, "value" in c && (c.writable = !0), Object.defineProperty(l, c.key, c);
      }
    }
    return function(l, y, b) {
      return y && v(l.prototype, y), b && v(l, b), l;
    };
  }();
  function w(v, l) {
    if (!(v instanceof l))
      throw new TypeError("Cannot call a class as a function");
  }
  return function() {
    if (typeof window > "u" || typeof Element > "u")
      return;
    var v = Array.prototype.slice, l = Element.prototype.matches || Element.prototype.msMatchesSelector, y = ["a[href]", "area[href]", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", "button:not([disabled])", "details", "summary", "iframe", "object", "embed", "video", "[contenteditable]"].join(","), b = function() {
      function u(n, e) {
        w(this, u), this._inertManager = e, this._rootElement = n, this._managedNodes = /* @__PURE__ */ new Set(), this._rootElement.hasAttribute("aria-hidden") ? this._savedAriaHidden = this._rootElement.getAttribute("aria-hidden") : this._savedAriaHidden = null, this._rootElement.setAttribute("aria-hidden", "true"), this._makeSubtreeUnfocusable(this._rootElement), this._observer = new MutationObserver(this._onMutation.bind(this)), this._observer.observe(this._rootElement, { attributes: !0, childList: !0, subtree: !0 });
      }
      return S(u, [{
        key: "destructor",
        value: function() {
          this._observer.disconnect(), this._rootElement && (this._savedAriaHidden !== null ? this._rootElement.setAttribute("aria-hidden", this._savedAriaHidden) : this._rootElement.removeAttribute("aria-hidden")), this._managedNodes.forEach(function(e) {
            this._unmanageNode(e.node);
          }, this), this._observer = /** @type {?} */
          null, this._rootElement = /** @type {?} */
          null, this._managedNodes = /** @type {?} */
          null, this._inertManager = /** @type {?} */
          null;
        }
        /**
         * @return {!Set<!InertNode>} A copy of this InertRoot's managed nodes set.
         */
      }, {
        key: "_makeSubtreeUnfocusable",
        /**
         * @param {!Node} startNode
         */
        value: function(e) {
          var i = this;
          N(e, function(t) {
            return i._visitNode(t);
          });
          var o = document.activeElement;
          if (!document.body.contains(e)) {
            for (var d = e, m = void 0; d; ) {
              if (d.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
                m = /** @type {!ShadowRoot} */
                d;
                break;
              }
              d = d.parentNode;
            }
            m && (o = m.activeElement);
          }
          e.contains(o) && (o.blur(), o === document.activeElement && document.body.focus());
        }
        /**
         * @param {!Node} node
         */
      }, {
        key: "_visitNode",
        value: function(e) {
          if (e.nodeType === Node.ELEMENT_NODE) {
            var i = (
              /** @type {!HTMLElement} */
              e
            );
            i !== this._rootElement && i.hasAttribute("inert") && this._adoptInertRoot(i), (l.call(i, y) || i.hasAttribute("tabindex")) && this._manageNode(i);
          }
        }
        /**
         * Register the given node with this InertRoot and with InertManager.
         * @param {!Node} node
         */
      }, {
        key: "_manageNode",
        value: function(e) {
          var i = this._inertManager.register(e, this);
          this._managedNodes.add(i);
        }
        /**
         * Unregister the given node with this InertRoot and with InertManager.
         * @param {!Node} node
         */
      }, {
        key: "_unmanageNode",
        value: function(e) {
          var i = this._inertManager.deregister(e, this);
          i && this._managedNodes.delete(i);
        }
        /**
         * Unregister the entire subtree starting at `startNode`.
         * @param {!Node} startNode
         */
      }, {
        key: "_unmanageSubtree",
        value: function(e) {
          var i = this;
          N(e, function(o) {
            return i._unmanageNode(o);
          });
        }
        /**
         * If a descendant node is found with an `inert` attribute, adopt its managed nodes.
         * @param {!HTMLElement} node
         */
      }, {
        key: "_adoptInertRoot",
        value: function(e) {
          var i = this._inertManager.getInertRoot(e);
          i || (this._inertManager.setInert(e, !0), i = this._inertManager.getInertRoot(e)), i.managedNodes.forEach(function(o) {
            this._manageNode(o.node);
          }, this);
        }
        /**
         * Callback used when mutation observer detects subtree additions, removals, or attribute changes.
         * @param {!Array<!MutationRecord>} records
         * @param {!MutationObserver} self
         */
      }, {
        key: "_onMutation",
        value: function(e, i) {
          e.forEach(function(o) {
            var d = (
              /** @type {!HTMLElement} */
              o.target
            );
            if (o.type === "childList")
              v.call(o.addedNodes).forEach(function(t) {
                this._makeSubtreeUnfocusable(t);
              }, this), v.call(o.removedNodes).forEach(function(t) {
                this._unmanageSubtree(t);
              }, this);
            else if (o.type === "attributes") {
              if (o.attributeName === "tabindex")
                this._manageNode(d);
              else if (d !== this._rootElement && o.attributeName === "inert" && d.hasAttribute("inert")) {
                this._adoptInertRoot(d);
                var m = this._inertManager.getInertRoot(d);
                this._managedNodes.forEach(function(t) {
                  d.contains(t.node) && m._manageNode(t.node);
                });
              }
            }
          }, this);
        }
      }, {
        key: "managedNodes",
        get: function() {
          return new Set(this._managedNodes);
        }
        /** @return {boolean} */
      }, {
        key: "hasSavedAriaHidden",
        get: function() {
          return this._savedAriaHidden !== null;
        }
        /** @param {?string} ariaHidden */
      }, {
        key: "savedAriaHidden",
        set: function(e) {
          this._savedAriaHidden = e;
        },
        get: function() {
          return this._savedAriaHidden;
        }
      }]), u;
    }(), c = function() {
      function u(n, e) {
        w(this, u), this._node = n, this._overrodeFocusMethod = !1, this._inertRoots = /* @__PURE__ */ new Set([e]), this._savedTabIndex = null, this._destroyed = !1, this.ensureUntabbable();
      }
      return S(u, [{
        key: "destructor",
        value: function() {
          if (this._throwIfDestroyed(), this._node && this._node.nodeType === Node.ELEMENT_NODE) {
            var e = (
              /** @type {!HTMLElement} */
              this._node
            );
            this._savedTabIndex !== null ? e.setAttribute("tabindex", this._savedTabIndex) : e.removeAttribute("tabindex"), this._overrodeFocusMethod && delete e.focus;
          }
          this._node = /** @type {?} */
          null, this._inertRoots = /** @type {?} */
          null, this._destroyed = !0;
        }
        /**
         * @type {boolean} Whether this object is obsolete because the managed node is no longer inert.
         * If the object has been destroyed, any attempt to access it will cause an exception.
         */
      }, {
        key: "_throwIfDestroyed",
        /**
         * Throw if user tries to access destroyed InertNode.
         */
        value: function() {
          if (this.destroyed)
            throw new Error("Trying to access destroyed InertNode");
        }
        /** @return {boolean} */
      }, {
        key: "ensureUntabbable",
        /** Save the existing tabindex value and make the node untabbable and unfocusable */
        value: function() {
          if (this.node.nodeType === Node.ELEMENT_NODE) {
            var e = (
              /** @type {!HTMLElement} */
              this.node
            );
            if (l.call(e, y)) {
              if (
                /** @type {!HTMLElement} */
                e.tabIndex === -1 && this.hasSavedTabIndex
              )
                return;
              e.hasAttribute("tabindex") && (this._savedTabIndex = /** @type {!HTMLElement} */
              e.tabIndex), e.setAttribute("tabindex", "-1"), e.nodeType === Node.ELEMENT_NODE && (e.focus = function() {
              }, this._overrodeFocusMethod = !0);
            } else e.hasAttribute("tabindex") && (this._savedTabIndex = /** @type {!HTMLElement} */
            e.tabIndex, e.removeAttribute("tabindex"));
          }
        }
        /**
         * Add another inert root to this inert node's set of managing inert roots.
         * @param {!InertRoot} inertRoot
         */
      }, {
        key: "addInertRoot",
        value: function(e) {
          this._throwIfDestroyed(), this._inertRoots.add(e);
        }
        /**
         * Remove the given inert root from this inert node's set of managing inert roots.
         * If the set of managing inert roots becomes empty, this node is no longer inert,
         * so the object should be destroyed.
         * @param {!InertRoot} inertRoot
         */
      }, {
        key: "removeInertRoot",
        value: function(e) {
          this._throwIfDestroyed(), this._inertRoots.delete(e), this._inertRoots.size === 0 && this.destructor();
        }
      }, {
        key: "destroyed",
        get: function() {
          return (
            /** @type {!InertNode} */
            this._destroyed
          );
        }
      }, {
        key: "hasSavedTabIndex",
        get: function() {
          return this._savedTabIndex !== null;
        }
        /** @return {!Node} */
      }, {
        key: "node",
        get: function() {
          return this._throwIfDestroyed(), this._node;
        }
        /** @param {?number} tabIndex */
      }, {
        key: "savedTabIndex",
        set: function(e) {
          this._throwIfDestroyed(), this._savedTabIndex = e;
        },
        get: function() {
          return this._throwIfDestroyed(), this._savedTabIndex;
        }
      }]), u;
    }(), p = function() {
      function u(n) {
        if (w(this, u), !n)
          throw new Error("Missing required argument; InertManager needs to wrap a document.");
        this._document = n, this._managedNodes = /* @__PURE__ */ new Map(), this._inertRoots = /* @__PURE__ */ new Map(), this._observer = new MutationObserver(this._watchForInert.bind(this)), k(n.head || n.body || n.documentElement), n.readyState === "loading" ? n.addEventListener("DOMContentLoaded", this._onDocumentLoaded.bind(this)) : this._onDocumentLoaded();
      }
      return S(u, [{
        key: "setInert",
        value: function(e, i) {
          if (i) {
            if (this._inertRoots.has(e))
              return;
            var o = new b(e, this);
            if (e.setAttribute("inert", ""), this._inertRoots.set(e, o), !this._document.body.contains(e))
              for (var d = e.parentNode; d; )
                d.nodeType === 11 && k(d), d = d.parentNode;
          } else {
            if (!this._inertRoots.has(e))
              return;
            var m = this._inertRoots.get(e);
            m.destructor(), this._inertRoots.delete(e), e.removeAttribute("inert");
          }
        }
        /**
         * Get the InertRoot object corresponding to the given inert root element, if any.
         * @param {!Node} element
         * @return {!InertRoot|undefined}
         */
      }, {
        key: "getInertRoot",
        value: function(e) {
          return this._inertRoots.get(e);
        }
        /**
         * Register the given InertRoot as managing the given node.
         * In the case where the node has a previously existing inert root, this inert root will
         * be added to its set of inert roots.
         * @param {!Node} node
         * @param {!InertRoot} inertRoot
         * @return {!InertNode} inertNode
         */
      }, {
        key: "register",
        value: function(e, i) {
          var o = this._managedNodes.get(e);
          return o !== void 0 ? o.addInertRoot(i) : o = new c(e, i), this._managedNodes.set(e, o), o;
        }
        /**
         * De-register the given InertRoot as managing the given inert node.
         * Removes the inert root from the InertNode's set of managing inert roots, and remove the inert
         * node from the InertManager's set of managed nodes if it is destroyed.
         * If the node is not currently managed, this is essentially a no-op.
         * @param {!Node} node
         * @param {!InertRoot} inertRoot
         * @return {?InertNode} The potentially destroyed InertNode associated with this node, if any.
         */
      }, {
        key: "deregister",
        value: function(e, i) {
          var o = this._managedNodes.get(e);
          return o ? (o.removeInertRoot(i), o.destroyed && this._managedNodes.delete(e), o) : null;
        }
        /**
         * Callback used when document has finished loading.
         */
      }, {
        key: "_onDocumentLoaded",
        value: function() {
          var e = v.call(this._document.querySelectorAll("[inert]"));
          e.forEach(function(i) {
            this.setInert(i, !0);
          }, this), this._observer.observe(this._document.body || this._document.documentElement, { attributes: !0, subtree: !0, childList: !0 });
        }
        /**
         * Callback used when mutation observer detects attribute changes.
         * @param {!Array<!MutationRecord>} records
         * @param {!MutationObserver} self
         */
      }, {
        key: "_watchForInert",
        value: function(e, i) {
          var o = this;
          e.forEach(function(d) {
            switch (d.type) {
              case "childList":
                v.call(d.addedNodes).forEach(function(r) {
                  if (r.nodeType === Node.ELEMENT_NODE) {
                    var s = v.call(r.querySelectorAll("[inert]"));
                    l.call(r, "[inert]") && s.unshift(r), s.forEach(function(a) {
                      this.setInert(a, !0);
                    }, o);
                  }
                }, o);
                break;
              case "attributes":
                if (d.attributeName !== "inert")
                  return;
                var m = (
                  /** @type {!HTMLElement} */
                  d.target
                ), t = m.hasAttribute("inert");
                o.setInert(m, t);
                break;
            }
          }, this);
        }
      }]), u;
    }();
    function N(u, n, e) {
      if (u.nodeType == Node.ELEMENT_NODE) {
        var i = (
          /** @type {!HTMLElement} */
          u
        );
        n && n(i);
        var o = (
          /** @type {!HTMLElement} */
          i.shadowRoot
        );
        if (o) {
          N(o, n);
          return;
        }
        if (i.localName == "content") {
          for (var d = (
            /** @type {!HTMLContentElement} */
            i
          ), m = d.getDistributedNodes ? d.getDistributedNodes() : [], t = 0; t < m.length; t++)
            N(m[t], n);
          return;
        }
        if (i.localName == "slot") {
          for (var r = (
            /** @type {!HTMLSlotElement} */
            i
          ), s = r.assignedNodes ? r.assignedNodes({ flatten: !0 }) : [], a = 0; a < s.length; a++)
            N(s[a], n);
          return;
        }
      }
      for (var h = u.firstChild; h != null; )
        N(h, n), h = h.nextSibling;
    }
    function k(u) {
      if (!u.querySelector("style#inert-style, link#inert-style")) {
        var n = document.createElement("style");
        n.setAttribute("id", "inert-style"), n.textContent = `
[inert] {
  pointer-events: none;
  cursor: default;
}

[inert], [inert] * {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}
`, u.appendChild(n);
      }
    }
    if (!HTMLElement.prototype.hasOwnProperty("inert")) {
      var T = new p(document);
      Object.defineProperty(HTMLElement.prototype, "inert", {
        enumerable: !0,
        /** @this {!HTMLElement} */
        get: function() {
          return this.hasAttribute("inert");
        },
        /** @this {!HTMLElement} */
        set: function(n) {
          T.setInert(this, n);
        }
      });
    }
  }(), A;
}
D();
