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 MDCFoundation from '@material/base/foundation';
  import MDCSelectIconAdapter from './adapter';
  import {strings} from './constants';
  
  
  /**
   * @extends {MDCFoundation<!MDCSelectIconAdapter>}
   * @final
   */
  class MDCSelectIconFoundation extends MDCFoundation {
    /** @return enum {string} */
    static get strings() {
      return strings;
    }
  
    /**
     * {@see MDCSelectIconAdapter} for typing information on parameters and return
     * types.
     * @return {!MDCSelectIconAdapter}
     */
    static get defaultAdapter() {
      return /** @type {!MDCSelectIconAdapter} */ ({
        getAttr: () => {},
        setAttr: () => {},
        removeAttr: () => {},
        setContent: () => {},
        registerInteractionHandler: () => {},
        deregisterInteractionHandler: () => {},
        notifyIconAction: () => {},
      });
    }
  
    /**
     * @param {!MDCSelectIconAdapter} adapter
     */
    constructor(adapter) {
      super(Object.assign(MDCSelectIconFoundation.defaultAdapter, adapter));
  
      /** @private {string?} */
      this.savedTabIndex_ = null;
  
      /** @private {function(!Event): undefined} */
      this.interactionHandler_ = (evt) => this.handleInteraction(evt);
    }
  
    init() {
      this.savedTabIndex_ = this.adapter_.getAttr('tabindex');
  
      ['click', 'keydown'].forEach((evtType) => {
        this.adapter_.registerInteractionHandler(evtType, this.interactionHandler_);
      });
    }
  
    destroy() {
      ['click', 'keydown'].forEach((evtType) => {
        this.adapter_.deregisterInteractionHandler(evtType, this.interactionHandler_);
      });
    }
  
    /** @param {boolean} disabled */
    setDisabled(disabled) {
      if (!this.savedTabIndex_) {
        return;
      }
  
      if (disabled) {
        this.adapter_.setAttr('tabindex', '-1');
        this.adapter_.removeAttr('role');
      } else {
        this.adapter_.setAttr('tabindex', this.savedTabIndex_);
        this.adapter_.setAttr('role', strings.ICON_ROLE);
      }
    }
  
    /** @param {string} label */
    setAriaLabel(label) {
      this.adapter_.setAttr('aria-label', label);
    }
  
    /** @param {string} content */
    setContent(content) {
      this.adapter_.setContent(content);
    }
  
    /**
     * Handles an interaction event
     * @param {!Event} evt
     */
    handleInteraction(evt) {
      if (evt.type === 'click' || evt.key === 'Enter' || evt.keyCode === 13) {
        this.adapter_.notifyIconAction();
      }
    }
  }
  
  export default MDCSelectIconFoundation;
  