import { _ as h, a as p, b as r } from "./tslib.es6-CJ7TUrOc.mjs";
import "./inert.esm-C8R-X3j4.mjs";
import { B as b } from "./base-element-DUJkJh_y.mjs";
import { o as F } from "./observer-DQ8OfVDQ.mjs";
import { x as c } from "./query-assigned-elements-D930kELM.mjs";
import { n as l } from "./property-DJzm_oB9.mjs";
import { i as C } from "./query-CDOd1Kwm.mjs";
import { o as g } from "./class-map-DPUylGZM.mjs";
import { a as N } from "./utils-Dr5MegQq.mjs";
/**
 * @license
 * Copyright 2016 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
var i = {
  ANIMATE: "mdc-drawer--animate",
  CLOSING: "mdc-drawer--closing",
  DISMISSIBLE: "mdc-drawer--dismissible",
  MODAL: "mdc-drawer--modal",
  OPEN: "mdc-drawer--open",
  OPENING: "mdc-drawer--opening",
  ROOT: "mdc-drawer"
}, u = {
  APP_CONTENT_SELECTOR: ".mdc-drawer-app-content",
  CLOSE_EVENT: "MDCDrawer:closed",
  OPEN_EVENT: "MDCDrawer:opened",
  SCRIM_SELECTOR: ".mdc-drawer-scrim",
  LIST_SELECTOR: ".mdc-list,.mdc-deprecated-list",
  LIST_ITEM_ACTIVATED_SELECTOR: ".mdc-list-item--activated,.mdc-deprecated-list-item--activated"
};
/**
 * @license
 * Copyright 2016 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
var T = (
  /** @class */
  function() {
    function n(e) {
      e === void 0 && (e = {}), this.adapter = e;
    }
    return Object.defineProperty(n, "cssClasses", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(n, "strings", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(n, "numbers", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(n, "defaultAdapter", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), n.prototype.init = function() {
    }, n.prototype.destroy = function() {
    }, n;
  }()
);
/**
 * @license
 * Copyright 2018 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
var v = (
  /** @class */
  function(n) {
    h(e, n);
    function e(t) {
      var s = n.call(this, p(p({}, e.defaultAdapter), t)) || this;
      return s.animationFrame = 0, s.animationTimer = 0, s;
    }
    return Object.defineProperty(e, "strings", {
      get: function() {
        return u;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e, "cssClasses", {
      get: function() {
        return i;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e, "defaultAdapter", {
      get: function() {
        return {
          addClass: function() {
          },
          removeClass: function() {
          },
          hasClass: function() {
            return !1;
          },
          elementHasClass: function() {
            return !1;
          },
          notifyClose: function() {
          },
          notifyOpen: function() {
          },
          saveFocus: function() {
          },
          restoreFocus: function() {
          },
          focusActiveNavigationItem: function() {
          },
          trapFocus: function() {
          },
          releaseFocus: function() {
          }
        };
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.destroy = function() {
      this.animationFrame && cancelAnimationFrame(this.animationFrame), this.animationTimer && clearTimeout(this.animationTimer);
    }, e.prototype.open = function() {
      var t = this;
      this.isOpen() || this.isOpening() || this.isClosing() || (this.adapter.addClass(i.OPEN), this.adapter.addClass(i.ANIMATE), this.runNextAnimationFrame(function() {
        t.adapter.addClass(i.OPENING);
      }), this.adapter.saveFocus());
    }, e.prototype.close = function() {
      !this.isOpen() || this.isOpening() || this.isClosing() || this.adapter.addClass(i.CLOSING);
    }, e.prototype.isOpen = function() {
      return this.adapter.hasClass(i.OPEN);
    }, e.prototype.isOpening = function() {
      return this.adapter.hasClass(i.OPENING) || this.adapter.hasClass(i.ANIMATE);
    }, e.prototype.isClosing = function() {
      return this.adapter.hasClass(i.CLOSING);
    }, e.prototype.handleKeydown = function(t) {
      var s = t.keyCode, o = t.key, d = o === "Escape" || s === 27;
      d && this.close();
    }, e.prototype.handleTransitionEnd = function(t) {
      var s = i.OPENING, o = i.CLOSING, d = i.OPEN, E = i.ANIMATE, y = i.ROOT, O = this.isElement(t.target) && this.adapter.elementHasClass(t.target, y);
      O && (this.isClosing() ? (this.adapter.removeClass(d), this.closed(), this.adapter.restoreFocus(), this.adapter.notifyClose()) : (this.adapter.focusActiveNavigationItem(), this.opened(), this.adapter.notifyOpen()), this.adapter.removeClass(E), this.adapter.removeClass(s), this.adapter.removeClass(o));
    }, e.prototype.opened = function() {
    }, e.prototype.closed = function() {
    }, e.prototype.runNextAnimationFrame = function(t) {
      var s = this;
      cancelAnimationFrame(this.animationFrame), this.animationFrame = requestAnimationFrame(function() {
        s.animationFrame = 0, clearTimeout(s.animationTimer), s.animationTimer = setTimeout(t, 0);
      });
    }, e.prototype.isElement = function(t) {
      return !!t.classList;
    }, e;
  }(T)
);
/**
 * @license
 * Copyright 2018 Google Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
var m = (
  /** @class */
  function(n) {
    h(e, n);
    function e() {
      return n !== null && n.apply(this, arguments) || this;
    }
    return e.prototype.handleScrimClick = function() {
      this.close();
    }, e.prototype.opened = function() {
      this.adapter.trapFocus();
    }, e.prototype.closed = function() {
      this.adapter.releaseFocus();
    }, e;
  }(v)
);
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
const f = document.$blockingElements;
class a extends b {
  constructor() {
    super(...arguments), this._previousFocus = null, this.open = !1, this.hasHeader = !1, this.type = "";
  }
  get mdcFoundationClass() {
    return this.type === "modal" ? m : v;
  }
  createAdapter() {
    return Object.assign(Object.assign({}, N(this.mdcRoot)), { elementHasClass: (e, t) => e.classList.contains(t), saveFocus: () => {
      this._previousFocus = this.getRootNode().activeElement;
    }, restoreFocus: () => {
      this._previousFocus && this._previousFocus.focus && this._previousFocus.focus();
    }, notifyClose: () => {
      this.open = !1, this.dispatchEvent(new Event(u.CLOSE_EVENT, { bubbles: !0, cancelable: !0 }));
    }, notifyOpen: () => {
      this.open = !0, this.dispatchEvent(new Event(u.OPEN_EVENT, { bubbles: !0, cancelable: !0 }));
    }, focusActiveNavigationItem: () => {
    }, trapFocus: () => {
      f.push(this), this.appContent.inert = !0;
    }, releaseFocus: () => {
      f.remove(this), this.appContent.inert = !1;
    } });
  }
  _handleScrimClick() {
    this.mdcFoundation instanceof m && this.mdcFoundation.handleScrimClick();
  }
  render() {
    const e = this.type === "dismissible" || this.type === "modal", t = this.type === "modal", s = this.hasHeader ? c`
      <div class="mdc-drawer__header">
        <h3 class="mdc-drawer__title"><slot name="title"></slot></h3>
        <h6 class="mdc-drawer__subtitle"><slot name="subtitle"></slot></h6>
        <slot name="header"></slot>
      </div>
      ` : "";
    return c`
      <aside class="mdc-drawer ${g({
      "mdc-drawer--dismissible": e,
      "mdc-drawer--modal": t
    })}">
        ${s}
        <div class="mdc-drawer__content"><slot></slot></div>
      </aside>
      ${t ? c`<div class="mdc-drawer-scrim"
                          @click="${this._handleScrimClick}"></div>` : ""}
      <div class="mdc-drawer-app-content">
        <slot name="appContent"></slot>
      </div>
      `;
  }
  // note, we avoid calling `super.firstUpdated()` to control when
  // `createFoundation()` is called.
  firstUpdated() {
    this.mdcRoot.addEventListener("keydown", (e) => this.mdcFoundation.handleKeydown(e)), this.mdcRoot.addEventListener("transitionend", (e) => this.mdcFoundation.handleTransitionEnd(e));
  }
  updated(e) {
    e.has("type") && this.createFoundation();
  }
}
r([
  C(".mdc-drawer")
], a.prototype, "mdcRoot", void 0);
r([
  C(".mdc-drawer-app-content")
], a.prototype, "appContent", void 0);
r([
  F(function(n) {
    this.type !== "" && (n ? this.mdcFoundation.open() : this.mdcFoundation.close());
  }),
  l({ type: Boolean, reflect: !0 })
], a.prototype, "open", void 0);
r([
  l({ type: Boolean })
], a.prototype, "hasHeader", void 0);
r([
  l({ reflect: !0 })
], a.prototype, "type", void 0);
export {
  a as D
};
