import { _ as f, a as u, b as s } from "./tslib.es6-CJ7TUrOc.mjs";
import { n as a } from "./property-DJzm_oB9.mjs";
import { x as l } from "./query-assigned-elements-D930kELM.mjs";
import { B as _ } from "./base-element-DUJkJh_y.mjs";
import { a as S, s as A } from "./utils-Dr5MegQq.mjs";
import { i as g } from "./query-CDOd1Kwm.mjs";
import { o as h } from "./class-map-DPUylGZM.mjs";
/**
 * @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 = {
  FIXED_CLASS: "mdc-top-app-bar--fixed",
  FIXED_SCROLLED_CLASS: "mdc-top-app-bar--fixed-scrolled",
  SHORT_CLASS: "mdc-top-app-bar--short",
  SHORT_COLLAPSED_CLASS: "mdc-top-app-bar--short-collapsed",
  SHORT_HAS_ACTION_ITEM_CLASS: "mdc-top-app-bar--short-has-action-item"
}, c = {
  DEBOUNCE_THROTTLE_RESIZE_TIME_MS: 100,
  MAX_TOP_APP_BAR_HEIGHT: 128
}, T = {
  ACTION_ITEM_SELECTOR: ".mdc-top-app-bar__action-item",
  NAVIGATION_EVENT: "MDCTopAppBar:nav",
  NAVIGATION_ICON_SELECTOR: ".mdc-top-app-bar__navigation-icon",
  ROOT_SELECTOR: ".mdc-top-app-bar",
  TITLE_SELECTOR: ".mdc-top-app-bar__title"
};
/**
 * @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 y = (
  /** @class */
  function() {
    function r(e) {
      e === void 0 && (e = {}), this.adapter = e;
    }
    return Object.defineProperty(r, "cssClasses", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(r, "strings", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(r, "numbers", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(r, "defaultAdapter", {
      get: function() {
        return {};
      },
      enumerable: !1,
      configurable: !0
    }), r.prototype.init = function() {
    }, r.prototype.destroy = function() {
    }, r;
  }()
);
/**
 * @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 B = (
  /** @class */
  function(r) {
    f(e, r);
    function e(t) {
      return r.call(this, u(u({}, e.defaultAdapter), t)) || this;
    }
    return Object.defineProperty(e, "strings", {
      get: function() {
        return T;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e, "cssClasses", {
      get: function() {
        return v;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e, "numbers", {
      get: function() {
        return c;
      },
      enumerable: !1,
      configurable: !0
    }), Object.defineProperty(e, "defaultAdapter", {
      /**
       * See {@link MDCTopAppBarAdapter} for typing information on parameters and return types.
       */
      get: function() {
        return {
          addClass: function() {
          },
          removeClass: function() {
          },
          hasClass: function() {
            return !1;
          },
          setStyle: function() {
          },
          getTopAppBarHeight: function() {
            return 0;
          },
          notifyNavigationIconClicked: function() {
          },
          getViewportScrollY: function() {
            return 0;
          },
          getTotalActionItems: function() {
            return 0;
          }
        };
      },
      enumerable: !1,
      configurable: !0
    }), e.prototype.handleTargetScroll = function() {
    }, e.prototype.handleWindowResize = function() {
    }, e.prototype.handleNavigationClick = function() {
      this.adapter.notifyNavigationIconClicked();
    }, e;
  }(y)
);
/**
 * @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 n = 0, C = (
  /** @class */
  function(r) {
    f(e, r);
    function e(t) {
      var i = r.call(this, t) || this;
      return i.wasDocked = !0, i.isDockedShowing = !0, i.currentAppBarOffsetTop = 0, i.isCurrentlyBeingResized = !1, i.resizeThrottleId = n, i.resizeDebounceId = n, i.lastScrollPosition = i.adapter.getViewportScrollY(), i.topAppBarHeight = i.adapter.getTopAppBarHeight(), i;
    }
    return e.prototype.destroy = function() {
      r.prototype.destroy.call(this), this.adapter.setStyle("top", "");
    }, e.prototype.handleTargetScroll = function() {
      var t = Math.max(this.adapter.getViewportScrollY(), 0), i = t - this.lastScrollPosition;
      this.lastScrollPosition = t, this.isCurrentlyBeingResized || (this.currentAppBarOffsetTop -= i, this.currentAppBarOffsetTop > 0 ? this.currentAppBarOffsetTop = 0 : Math.abs(this.currentAppBarOffsetTop) > this.topAppBarHeight && (this.currentAppBarOffsetTop = -this.topAppBarHeight), this.moveTopAppBar());
    }, e.prototype.handleWindowResize = function() {
      var t = this;
      this.resizeThrottleId || (this.resizeThrottleId = setTimeout(function() {
        t.resizeThrottleId = n, t.throttledResizeHandler();
      }, c.DEBOUNCE_THROTTLE_RESIZE_TIME_MS)), this.isCurrentlyBeingResized = !0, this.resizeDebounceId && clearTimeout(this.resizeDebounceId), this.resizeDebounceId = setTimeout(function() {
        t.handleTargetScroll(), t.isCurrentlyBeingResized = !1, t.resizeDebounceId = n;
      }, c.DEBOUNCE_THROTTLE_RESIZE_TIME_MS);
    }, e.prototype.checkForUpdate = function() {
      var t = -this.topAppBarHeight, i = this.currentAppBarOffsetTop < 0, p = this.currentAppBarOffsetTop > t, d = i && p;
      if (d)
        this.wasDocked = !1;
      else if (this.wasDocked) {
        if (this.isDockedShowing !== p)
          return this.isDockedShowing = p, !0;
      } else return this.wasDocked = !0, !0;
      return d;
    }, e.prototype.moveTopAppBar = function() {
      if (this.checkForUpdate()) {
        var t = this.currentAppBarOffsetTop;
        Math.abs(t) >= this.topAppBarHeight && (t = -128), this.adapter.setStyle("top", t + "px");
      }
    }, e.prototype.throttledResizeHandler = function() {
      var t = this.adapter.getTopAppBarHeight();
      this.topAppBarHeight !== t && (this.wasDocked = !1, this.currentAppBarOffsetTop -= this.topAppBarHeight - t, this.topAppBarHeight = t), this.handleTargetScroll();
    }, e;
  }(B)
);
/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
const m = A ? { passive: !0 } : void 0;
class o extends _ {
  constructor() {
    super(...arguments), this.centerTitle = !1, this.handleTargetScroll = () => {
      this.mdcFoundation.handleTargetScroll();
    }, this.handleNavigationClick = () => {
      this.mdcFoundation.handleNavigationClick();
    };
  }
  get scrollTarget() {
    return this._scrollTarget || window;
  }
  set scrollTarget(e) {
    this.unregisterScrollListener();
    const t = this.scrollTarget;
    this._scrollTarget = e, this.updateRootPosition(), this.requestUpdate("scrollTarget", t), this.registerScrollListener();
  }
  updateRootPosition() {
    if (this.mdcRoot) {
      const e = this.scrollTarget === window;
      this.mdcRoot.style.position = e ? "" : "absolute";
    }
  }
  render() {
    let e = l`<span class="mdc-top-app-bar__title"><slot name="title"></slot></span>`;
    return this.centerTitle && (e = l`<section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-center">${e}</section>`), l`
      <header class="mdc-top-app-bar ${h(this.barClasses())}">
      <div class="mdc-top-app-bar__row">
        <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-start" id="navigation">
          <slot name="navigationIcon"
            @click=${this.handleNavigationClick}></slot>
          ${this.centerTitle ? null : e}
        </section>
        ${this.centerTitle ? e : null}
        <section class="mdc-top-app-bar__section mdc-top-app-bar__section--align-end" id="actions" role="toolbar">
          <slot name="actionItems"></slot>
        </section>
      </div>
    </header>
    <div class="${h(this.contentClasses())}">
      <slot></slot>
    </div>
    `;
  }
  createAdapter() {
    return Object.assign(Object.assign({}, S(this.mdcRoot)), { setStyle: (e, t) => this.mdcRoot.style.setProperty(e, t), getTopAppBarHeight: () => this.mdcRoot.clientHeight, notifyNavigationIconClicked: () => {
      this.dispatchEvent(new Event(T.NAVIGATION_EVENT, { bubbles: !0, cancelable: !0 }));
    }, getViewportScrollY: () => this.scrollTarget instanceof Window ? this.scrollTarget.pageYOffset : this.scrollTarget.scrollTop, getTotalActionItems: () => this._actionItemsSlot.assignedNodes({ flatten: !0 }).length });
  }
  registerListeners() {
    this.registerScrollListener();
  }
  unregisterListeners() {
    this.unregisterScrollListener();
  }
  registerScrollListener() {
    this.scrollTarget.addEventListener("scroll", this.handleTargetScroll, m);
  }
  unregisterScrollListener() {
    this.scrollTarget.removeEventListener("scroll", this.handleTargetScroll);
  }
  firstUpdated() {
    super.firstUpdated(), this.updateRootPosition(), this.registerListeners();
  }
  disconnectedCallback() {
    super.disconnectedCallback(), this.unregisterListeners();
  }
}
s([
  g(".mdc-top-app-bar")
], o.prototype, "mdcRoot", void 0);
s([
  g('slot[name="actionItems"]')
], o.prototype, "_actionItemsSlot", void 0);
s([
  a({ type: Boolean })
], o.prototype, "centerTitle", void 0);
s([
  a({ type: Object })
], o.prototype, "scrollTarget", null);
/**
 * @license
 * Copyright 2018 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
class b extends o {
  constructor() {
    super(...arguments), this.mdcFoundationClass = C, this.prominent = !1, this.dense = !1, this.handleResize = () => {
      this.mdcFoundation.handleWindowResize();
    };
  }
  barClasses() {
    return {
      "mdc-top-app-bar--dense": this.dense,
      "mdc-top-app-bar--prominent": this.prominent,
      "center-title": this.centerTitle
    };
  }
  contentClasses() {
    return {
      "mdc-top-app-bar--fixed-adjust": !this.dense && !this.prominent,
      "mdc-top-app-bar--dense-fixed-adjust": this.dense && !this.prominent,
      "mdc-top-app-bar--prominent-fixed-adjust": !this.dense && this.prominent,
      "mdc-top-app-bar--dense-prominent-fixed-adjust": this.dense && this.prominent
    };
  }
  registerListeners() {
    super.registerListeners(), window.addEventListener("resize", this.handleResize, m);
  }
  unregisterListeners() {
    super.unregisterListeners(), window.removeEventListener("resize", this.handleResize);
  }
}
s([
  a({ type: Boolean, reflect: !0 })
], b.prototype, "prominent", void 0);
s([
  a({ type: Boolean, reflect: !0 })
], b.prototype, "dense", void 0);
export {
  b as T,
  m as p
};
