text: /**
   * @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.
   */
  import * as tslib_1 from "tslib/tslib.es6.js";
  import { MDCFoundation } from "../../base/foundation.js";
  import { cssClasses, strings } from "../constants.js";
  
  var MDCDismissibleDrawerFoundation =
  /** @class */
  function (_super) {
    tslib_1.__extends(MDCDismissibleDrawerFoundation, _super);
  
    function MDCDismissibleDrawerFoundation(adapter) {
      var _this = _super.call(this, tslib_1.__assign({}, MDCDismissibleDrawerFoundation.defaultAdapter, adapter)) || this;
  
      _this.animationFrame_ = 0;
      _this.animationTimer_ = 0;
      return _this;
    }
  
    Object.defineProperty(MDCDismissibleDrawerFoundation, "strings", {
      get: function () {
        return strings;
      },
      enumerable: true,
      configurable: true
    });
    Object.defineProperty(MDCDismissibleDrawerFoundation, "cssClasses", {
      get: function () {
        return cssClasses;
      },
      enumerable: true,
      configurable: true
    });
    Object.defineProperty(MDCDismissibleDrawerFoundation, "defaultAdapter", {
      get: function () {
        // tslint:disable:object-literal-sort-keys Methods should be in the same order as the adapter interface.
        return {
          addClass: function () {
            return undefined;
          },
          removeClass: function () {
            return undefined;
          },
          hasClass: function () {
            return false;
          },
          elementHasClass: function () {
            return false;
          },
          notifyClose: function () {
            return undefined;
          },
          notifyOpen: function () {
            return undefined;
          },
          saveFocus: function () {
            return undefined;
          },
          restoreFocus: function () {
            return undefined;
          },
          focusActiveNavigationItem: function () {
            return undefined;
          },
          trapFocus: function () {
            return undefined;
          },
          releaseFocus: function () {
            return undefined;
          }
        }; // tslint:enable:object-literal-sort-keys
      },
      enumerable: true,
      configurable: true
    });
  
    MDCDismissibleDrawerFoundation.prototype.destroy = function () {
      if (this.animationFrame_) {
        cancelAnimationFrame(this.animationFrame_);
      }
  
      if (this.animationTimer_) {
        clearTimeout(this.animationTimer_);
      }
    };
    /**
     * Opens the drawer from the closed state.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.open = function () {
      var _this = this;
  
      if (this.isOpen() || this.isOpening() || this.isClosing()) {
        return;
      }
  
      this.adapter_.addClass(cssClasses.OPEN);
      this.adapter_.addClass(cssClasses.ANIMATE); // Wait a frame once display is no longer "none", to establish basis for animation
  
      this.runNextAnimationFrame_(function () {
        _this.adapter_.addClass(cssClasses.OPENING);
      });
      this.adapter_.saveFocus();
    };
    /**
     * Closes the drawer from the open state.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.close = function () {
      if (!this.isOpen() || this.isOpening() || this.isClosing()) {
        return;
      }
  
      this.adapter_.addClass(cssClasses.CLOSING);
    };
    /**
     * Returns true if the drawer is in the open position.
     * @return true if drawer is in open state.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.isOpen = function () {
      return this.adapter_.hasClass(cssClasses.OPEN);
    };
    /**
     * Returns true if the drawer is animating open.
     * @return true if drawer is animating open.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.isOpening = function () {
      return this.adapter_.hasClass(cssClasses.OPENING) || this.adapter_.hasClass(cssClasses.ANIMATE);
    };
    /**
     * Returns true if the drawer is animating closed.
     * @return true if drawer is animating closed.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.isClosing = function () {
      return this.adapter_.hasClass(cssClasses.CLOSING);
    };
    /**
     * Keydown handler to close drawer when key is escape.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.handleKeydown = function (evt) {
      var keyCode = evt.keyCode,
          key = evt.key;
      var isEscape = key === 'Escape' || keyCode === 27;
  
      if (isEscape) {
        this.close();
      }
    };
    /**
     * Handles the `transitionend` event when the drawer finishes opening/closing.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.handleTransitionEnd = function (evt) {
      var OPENING = cssClasses.OPENING,
          CLOSING = cssClasses.CLOSING,
          OPEN = cssClasses.OPEN,
          ANIMATE = cssClasses.ANIMATE,
          ROOT = cssClasses.ROOT; // In Edge, transitionend on ripple pseudo-elements yields a target without classList, so check for Element first.
  
      var isRootElement = this.isElement_(evt.target) && this.adapter_.elementHasClass(evt.target, ROOT);
  
      if (!isRootElement) {
        return;
      }
  
      if (this.isClosing()) {
        this.adapter_.removeClass(OPEN);
        this.closed_();
        this.adapter_.restoreFocus();
        this.adapter_.notifyClose();
      } else {
        this.adapter_.focusActiveNavigationItem();
        this.opened_();
        this.adapter_.notifyOpen();
      }
  
      this.adapter_.removeClass(ANIMATE);
      this.adapter_.removeClass(OPENING);
      this.adapter_.removeClass(CLOSING);
    };
    /**
     * Extension point for when drawer finishes open animation.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.opened_ = function () {}; // tslint:disable-line:no-empty
  
    /**
     * Extension point for when drawer finishes close animation.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.closed_ = function () {}; // tslint:disable-line:no-empty
  
    /**
     * Runs the given logic on the next animation frame, using setTimeout to factor in Firefox reflow behavior.
     */
  
  
    MDCDismissibleDrawerFoundation.prototype.runNextAnimationFrame_ = function (callback) {
      var _this = this;
  
      cancelAnimationFrame(this.animationFrame_);
      this.animationFrame_ = requestAnimationFrame(function () {
        _this.animationFrame_ = 0;
        clearTimeout(_this.animationTimer_);
        _this.animationTimer_ = setTimeout(callback, 0);
      });
    };
  
    MDCDismissibleDrawerFoundation.prototype.isElement_ = function (element) {
      // In Edge, transitionend on ripple pseudo-elements yields a target without classList.
      return Boolean(element.classList);
    };
  
    return MDCDismissibleDrawerFoundation;
  }(MDCFoundation);
  
  export { MDCDismissibleDrawerFoundation }; // tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
  
  export default MDCDismissibleDrawerFoundation; //# sourceMappingURL=foundation.js.map