text: /**
   * @fileoverview added by tsickle
   * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
   */
  import * as tslib_1 from "tslib";
  /**
   * @license
   * Copyright Google LLC All Rights Reserved.
   *
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://angular.io/license
   */
  import { coerceBooleanProperty } from '@angular/cdk/coercion';
  import { BACKSPACE, DELETE, SPACE } from '@angular/cdk/keycodes';
  import { Platform } from '@angular/cdk/platform';
  import { ContentChild, Directive, ElementRef, EventEmitter, forwardRef, Inject, Input, NgZone, Optional, Output, } from '@angular/core';
  import { MAT_RIPPLE_GLOBAL_OPTIONS, mixinColor, mixinDisabled, mixinDisableRipple, RippleRenderer, } from '@angular/material/core';
  import { Subject } from 'rxjs';
  import { take } from 'rxjs/operators';
  /**
   * Represents an event fired on an individual `mat-chip`.
   * @record
   */
  export function MatChipEvent() { }
  if (false) {
      /**
       * The chip the event was fired on.
       * @type {?}
       */
      MatChipEvent.prototype.chip;
  }
  /**
   * Event object emitted by MatChip when selected or deselected.
   */
  var /**
   * Event object emitted by MatChip when selected or deselected.
   */
  MatChipSelectionChange = /** @class */ (function () {
      function MatChipSelectionChange(source, selected, isUserInput) {
          if (isUserInput === void 0) { isUserInput = false; }
          this.source = source;
          this.selected = selected;
          this.isUserInput = isUserInput;
      }
      return MatChipSelectionChange;
  }());
  /**
   * Event object emitted by MatChip when selected or deselected.
   */
  export { MatChipSelectionChange };
  if (false) {
      /**
       * Reference to the chip that emitted the event.
       * @type {?}
       */
      MatChipSelectionChange.prototype.source;
      /**
       * Whether the chip that emitted the event is selected.
       * @type {?}
       */
      MatChipSelectionChange.prototype.selected;
      /**
       * Whether the selection change was a result of a user interaction.
       * @type {?}
       */
      MatChipSelectionChange.prototype.isUserInput;
  }
  // Boilerplate for applying mixins to MatChip.
  /**
   * \@docs-private
   */
  var 
  // Boilerplate for applying mixins to MatChip.
  /**
   * \@docs-private
   */
  MatChipBase = /** @class */ (function () {
      function MatChipBase(_elementRef) {
          this._elementRef = _elementRef;
      }
      return MatChipBase;
  }());
  // Boilerplate for applying mixins to MatChip.
  /**
   * \@docs-private
   */
  export { MatChipBase };
  if (false) {
      /** @type {?} */
      MatChipBase.prototype._elementRef;
  }
  /** @type {?} */
  export var _MatChipMixinBase = mixinColor(mixinDisableRipple(mixinDisabled(MatChipBase)), 'primary');
  /** @type {?} */
  var CHIP_ATTRIBUTE_NAMES = ['mat-basic-chip'];
  /**
   * Dummy directive to add CSS class to chip avatar.
   * \@docs-private
   */
  var MatChipAvatar = /** @class */ (function () {
      function MatChipAvatar() {
      }
      MatChipAvatar.decorators = [
          { type: Directive, args: [{
                      selector: 'mat-chip-avatar, [matChipAvatar]',
                      host: { 'class': 'mat-chip-avatar' }
                  },] },
      ];
      return MatChipAvatar;
  }());
  export { MatChipAvatar };
  /**
   * Dummy directive to add CSS class to chip trailing icon.
   * \@docs-private
   */
  var MatChipTrailingIcon = /** @class */ (function () {
      function MatChipTrailingIcon() {
      }
      MatChipTrailingIcon.decorators = [
          { type: Directive, args: [{
                      selector: 'mat-chip-trailing-icon, [matChipTrailingIcon]',
                      host: { 'class': 'mat-chip-trailing-icon' }
                  },] },
      ];
      return MatChipTrailingIcon;
  }());
  export { MatChipTrailingIcon };
  /**
   * Material design styled Chip component. Used inside the MatChipList component.
   */
  var MatChip = /** @class */ (function (_super) {
      tslib_1.__extends(MatChip, _super);
      function MatChip(_elementRef, _ngZone, platform, globalRippleOptions) {
          var _this = _super.call(this, _elementRef) || this;
          _this._elementRef = _elementRef;
          _this._ngZone = _ngZone;
          /**
           * Whether the chip has focus.
           */
          _this._hasFocus = false;
          /**
           * Whether the chip list is selectable
           */
          _this.chipListSelectable = true;
          _this._selected = false;
          _this._selectable = true;
          _this._removable = true;
          /**
           * Emits when the chip is focused.
           */
          _this._onFocus = new Subject();
          /**
           * Emits when the chip is blured.
           */
          _this._onBlur = new Subject();
          /**
           * Emitted when the chip is selected or deselected.
           */
          _this.selectionChange = new EventEmitter();
          /**
           * Emitted when the chip is destroyed.
           */
          _this.destroyed = new EventEmitter();
          /**
           * Emitted when a chip is to be removed.
           */
          _this.removed = new EventEmitter();
          _this._addHostClassName();
          _this._chipRipple = new RippleRenderer(_this, _ngZone, _elementRef, platform);
          _this._chipRipple.setupTriggerEvents(_elementRef.nativeElement);
          _this.rippleConfig = globalRippleOptions || {};
          return _this;
      }
      Object.defineProperty(MatChip.prototype, "rippleDisabled", {
          /**
           * Whether ripples are disabled on interaction
           * @docs-private
           */
          get: /**
           * Whether ripples are disabled on interaction
           * \@docs-private
           * @return {?}
           */
          function () {
              return this.disabled || this.disableRipple || !!this.rippleConfig.disabled;
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MatChip.prototype, "selected", {
          /** Whether the chip is selected. */
          get: /**
           * Whether the chip is selected.
           * @return {?}
           */
          function () { return this._selected; },
          set: /**
           * @param {?} value
           * @return {?}
           */
          function (value) {
              /** @type {?} */
              var coercedValue = coerceBooleanProperty(value);
              if (coercedValue !== this._selected) {
                  this._selected = coercedValue;
                  this._dispatchSelectionChange();
              }
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MatChip.prototype, "value", {
          /** The value of the chip. Defaults to the content inside `<mat-chip>` tags. */
          get: /**
           * The value of the chip. Defaults to the content inside `<mat-chip>` tags.
           * @return {?}
           */
          function () {
              return this._value != undefined
                  ? this._value
                  : this._elementRef.nativeElement.textContent;
          },
          set: /**
           * @param {?} value
           * @return {?}
           */
          function (value) { this._value = value; },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MatChip.prototype, "selectable", {
          /**
           * Whether or not the chip is selectable. When a chip is not selectable,
           * changes to its selected state are always ignored. By default a chip is
           * selectable, and it becomes non-selectable if its parent chip list is
           * not selectable.
           */
          get: /**
           * Whether or not the chip is selectable. When a chip is not selectable,
           * changes to its selected state are always ignored. By default a chip is
           * selectable, and it becomes non-selectable if its parent chip list is
           * not selectable.
           * @return {?}
           */
          function () { return this._selectable && this.chipListSelectable; },
          set: /**
           * @param {?} value
           * @return {?}
           */
          function (value) {
              this._selectable = coerceBooleanProperty(value);
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MatChip.prototype, "removable", {
          /**
           * Determines whether or not the chip displays the remove styling and emits (removed) events.
           */
          get: /**
           * Determines whether or not the chip displays the remove styling and emits (removed) events.
           * @return {?}
           */
          function () { return this._removable; },
          set: /**
           * @param {?} value
           * @return {?}
           */
          function (value) {
              this._removable = coerceBooleanProperty(value);
          },
          enumerable: true,
          configurable: true
      });
      Object.defineProperty(MatChip.prototype, "ariaSelected", {
          /** The ARIA selected applied to the chip. */
          get: /**
           * The ARIA selected applied to the chip.
           * @return {?}
           */
          function () {
              return this.selectable ? this.selected.toString() : null;
          },
          enumerable: true,
          configurable: true
      });
      /**
       * @return {?}
       */
      MatChip.prototype._addHostClassName = /**
       * @return {?}
       */
      function () {
          // Add class for the different chips
          for (var _i = 0, CHIP_ATTRIBUTE_NAMES_1 = CHIP_ATTRIBUTE_NAMES; _i < CHIP_ATTRIBUTE_NAMES_1.length; _i++) {
              var attr = CHIP_ATTRIBUTE_NAMES_1[_i];
              if (this._elementRef.nativeElement.hasAttribute(attr) ||
                  this._elementRef.nativeElement.tagName.toLowerCase() === attr) {
                  ((/** @type {?} */ (this._elementRef.nativeElement))).classList.add(attr);
                  return;
              }
          }
          ((/** @type {?} */ (this._elementRef.nativeElement))).classList.add('mat-standard-chip');
      };
      /**
       * @return {?}
       */
      MatChip.prototype.ngOnDestroy = /**
       * @return {?}
       */
      function () {
          this.destroyed.emit({ chip: this });
          this._chipRipple._removeTriggerEvents();
      };
      /** Selects the chip. */
      /**
       * Selects the chip.
       * @return {?}
       */
      MatChip.prototype.select = /**
       * Selects the chip.
       * @return {?}
       */
      function () {
          if (!this._selected) {
              this._selected = true;
              this._dispatchSelectionChange();
          }
      };
      /** Deselects the chip. */
      /**
       * Deselects the chip.
       * @return {?}
       */
      MatChip.prototype.deselect = /**
       * Deselects the chip.
       * @return {?}
       */
      function () {
          if (this._selected) {
              this._selected = false;
              this._dispatchSelectionChange();
          }
      };
      /** Select this chip and emit selected event */
      /**
       * Select this chip and emit selected event
       * @return {?}
       */
      MatChip.prototype.selectViaInteraction = /**
       * Select this chip and emit selected event
       * @return {?}
       */
      function () {
          if (!this._selected) {
              this._selected = true;
              this._dispatchSelectionChange(true);
          }
      };
      /** Toggles the current selected state of this chip. */
      /**
       * Toggles the current selected state of this chip.
       * @param {?=} isUserInput
       * @return {?}
       */
      MatChip.prototype.toggleSelected = /**
       * Toggles the current selected state of this chip.
       * @param {?=} isUserInput
       * @return {?}
       */
      function (isUserInput) {
          if (isUserInput === void 0) { isUserInput = false; }
          this._selected = !this.selected;
          this._dispatchSelectionChange(isUserInput);
          return this.selected;
      };
      /** Allows for programmatic focusing of the chip. */
      /**
       * Allows for programmatic focusing of the chip.
       * @return {?}
       */
      MatChip.prototype.focus = /**
       * Allows for programmatic focusing of the chip.
       * @return {?}
       */
      function () {
          if (!this._hasFocus) {
              this._elementRef.nativeElement.focus();
              this._onFocus.next({ chip: this });
          }
          this._hasFocus = true;
      };
      /**
       * Allows for programmatic removal of the chip. Called by the MatChipList when the DELETE or
       * BACKSPACE keys are pressed.
       *
       * Informs any listeners of the removal request. Does not remove the chip from the DOM.
       */
      /**
       * Allows for programmatic removal of the chip. Called by the MatChipList when the DELETE or
       * BACKSPACE keys are pressed.
       *
       * Informs any listeners of the removal request. Does not remove the chip from the DOM.
       * @return {?}
       */
      MatChip.prototype.remove = /**
       * Allows for programmatic removal of the chip. Called by the MatChipList when the DELETE or
       * BACKSPACE keys are pressed.
       *
       * Informs any listeners of the removal request. Does not remove the chip from the DOM.
       * @return {?}
       */
      function () {
          if (this.removable) {
              this.removed.emit({ chip: this });
          }
      };
      /** Handles click events on the chip. */
      /**
       * Handles click events on the chip.
       * @param {?} event
       * @return {?}
       */
      MatChip.prototype._handleClick = /**
       * Handles click events on the chip.
       * @param {?} event
       * @return {?}
       */
      function (event) {
          if (this.disabled) {
              event.preventDefault();
          }
          else {
              event.stopPropagation();
          }
      };
      /** Handle custom key presses. */
      /**
       * Handle custom key presses.
       * @param {?} event
       * @return {?}
       */
      MatChip.prototype._handleKeydown = /**
       * Handle custom key presses.
       * @param {?} event
       * @return {?}
       */
      function (event) {
          if (this.disabled) {
              return;
          }
          switch (event.keyCode) {
              case DELETE:
              case BACKSPACE:
                  // If we are removable, remove the focused chip
                  this.remove();
                  // Always prevent so page navigation does not occur
                  event.preventDefault();
                  break;
              case SPACE:
                  // If we are selectable, toggle the focused chip
                  if (this.selectable) {
                      this.toggleSelected(true);
                  }
                  // Always prevent space from scrolling the page since the list has focus
                  event.preventDefault();
                  break;
          }
      };
      /**
       * @return {?}
       */
      MatChip.prototype._blur = /**
       * @return {?}
       */
      function () {
          var _this = this;
          // When animations are enabled, Angular may end up removing the chip from the DOM a little
          // earlier than usual, causing it to be blurred and throwing off the logic in the chip list
          // that moves focus not the next item. To work around the issue, we defer marking the chip
          // as not focused until the next time the zone stabilizes.
          this._ngZone.onStable
              .asObservable()
              .pipe(take(1))
              .subscribe(function () {
              _this._ngZone.run(function () {
                  _this._hasFocus = false;
                  _this._onBlur.next({ chip: _this });
              });
          });
      };
      /**
       * @private
       * @param {?=} isUserInput
       * @return {?}
       */
      MatChip.prototype._dispatchSelectionChange = /**
       * @private
       * @param {?=} isUserInput
       * @return {?}
       */
      function (isUserInput) {
          if (isUserInput === void 0) { isUserInput = false; }
          this.selectionChange.emit({
              source: this,
              isUserInput: isUserInput,
              selected: this._selected
          });
      };
      MatChip.decorators = [
          { type: Directive, args: [{
                      selector: "mat-basic-chip, [mat-basic-chip], mat-chip, [mat-chip]",
                      inputs: ['color', 'disabled', 'disableRipple'],
                      exportAs: 'matChip',
                      host: {
                          'class': 'mat-chip',
                          '[attr.tabindex]': 'disabled ? null : -1',
                          'role': 'option',
                          '[class.mat-chip-selected]': 'selected',
                          '[class.mat-chip-with-avatar]': 'avatar',
                          '[class.mat-chip-with-trailing-icon]': 'trailingIcon || removeIcon',
                          '[class.mat-chip-disabled]': 'disabled',
                          '[attr.disabled]': 'disabled || null',
                          '[attr.aria-disabled]': 'disabled.toString()',
                          '[attr.aria-selected]': 'ariaSelected',
                          '(click)': '_handleClick($event)',
                          '(keydown)': '_handleKeydown($event)',
                          '(focus)': 'focus()',
                          '(blur)': '_blur()',
                      },
                  },] },
      ];
      /** @nocollapse */
      MatChip.ctorParameters = function () { return [
          { type: ElementRef },
          { type: NgZone },
          { type: Platform },
          { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_RIPPLE_GLOBAL_OPTIONS,] }] }
      ]; };
      MatChip.propDecorators = {
          avatar: [{ type: ContentChild, args: [MatChipAvatar,] }],
          trailingIcon: [{ type: ContentChild, args: [MatChipTrailingIcon,] }],
          removeIcon: [{ type: ContentChild, args: [forwardRef(function () { return MatChipRemove; }),] }],
          selected: [{ type: Input }],
          value: [{ type: Input }],
          selectable: [{ type: Input }],
          removable: [{ type: Input }],
          selectionChange: [{ type: Output }],
          destroyed: [{ type: Output }],
          removed: [{ type: Output }]
      };
      return MatChip;
  }(_MatChipMixinBase));
  export { MatChip };
  if (false) {
      /**
       * Reference to the RippleRenderer for the chip.
       * @type {?}
       * @private
       */
      MatChip.prototype._chipRipple;
      /**
       * Ripple configuration for ripples that are launched on pointer down. The ripple config
       * is set to the global ripple options since we don't have any configurable options for
       * the chip ripples.
       * \@docs-private
       * @type {?}
       */
      MatChip.prototype.rippleConfig;
      /**
       * Whether the chip has focus.
       * @type {?}
       */
      MatChip.prototype._hasFocus;
      /**
       * Whether the chip list is selectable
       * @type {?}
       */
      MatChip.prototype.chipListSelectable;
      /**
       * The chip avatar
       * @type {?}
       */
      MatChip.prototype.avatar;
      /**
       * The chip's trailing icon.
       * @type {?}
       */
      MatChip.prototype.trailingIcon;
      /**
       * The chip's remove toggler.
       * @type {?}
       */
      MatChip.prototype.removeIcon;
      /**
       * @type {?}
       * @protected
       */
      MatChip.prototype._selected;
      /**
       * @type {?}
       * @protected
       */
      MatChip.prototype._value;
      /**
       * @type {?}
       * @protected
       */
      MatChip.prototype._selectable;
      /**
       * @type {?}
       * @protected
       */
      MatChip.prototype._removable;
      /**
       * Emits when the chip is focused.
       * @type {?}
       */
      MatChip.prototype._onFocus;
      /**
       * Emits when the chip is blured.
       * @type {?}
       */
      MatChip.prototype._onBlur;
      /**
       * Emitted when the chip is selected or deselected.
       * @type {?}
       */
      MatChip.prototype.selectionChange;
      /**
       * Emitted when the chip is destroyed.
       * @type {?}
       */
      MatChip.prototype.destroyed;
      /**
       * Emitted when a chip is to be removed.
       * @type {?}
       */
      MatChip.prototype.removed;
      /** @type {?} */
      MatChip.prototype._elementRef;
      /**
       * @type {?}
       * @private
       */
      MatChip.prototype._ngZone;
  }
  /**
   * Applies proper (click) support and adds styling for use with the Material Design "cancel" icon
   * available at https://material.io/icons/#ic_cancel.
   *
   * Example:
   *
   *     `<mat-chip>
   *       <mat-icon matChipRemove>cancel</mat-icon>
   *     </mat-chip>`
   *
   * You *may* use a custom icon, but you may need to override the `mat-chip-remove` positioning
   * styles to properly center the icon within the chip.
   */
  var MatChipRemove = /** @class */ (function () {
      function MatChipRemove(_parentChip) {
          this._parentChip = _parentChip;
      }
      /** Calls the parent chip's public `remove()` method if applicable. */
      /**
       * Calls the parent chip's public `remove()` method if applicable.
       * @param {?} event
       * @return {?}
       */
      MatChipRemove.prototype._handleClick = /**
       * Calls the parent chip's public `remove()` method if applicable.
       * @param {?} event
       * @return {?}
       */
      function (event) {
          if (this._parentChip.removable) {
              this._parentChip.remove();
          }
          // We need to stop event propagation because otherwise the event will bubble up to the
          // form field and cause the `onContainerClick` method to be invoked. This method would then
          // reset the focused chip that has been focused after chip removal. Usually the parent
          // the parent click listener of the `MatChip` would prevent propagation, but it can happen
          // that the chip is being removed before the event bubbles up.
          event.stopPropagation();
      };
      MatChipRemove.decorators = [
          { type: Directive, args: [{
                      selector: '[matChipRemove]',
                      host: {
                          'class': 'mat-chip-remove mat-chip-trailing-icon',
                          '(click)': '_handleClick($event)',
                      }
                  },] },
      ];
      /** @nocollapse */
      MatChipRemove.ctorParameters = function () { return [
          { type: MatChip }
      ]; };
      return MatChipRemove;
  }());
  export { MatChipRemove };
  if (false) {
      /**
       * @type {?}
       * @protected
       */
      MatChipRemove.prototype._parentChip;
  }
  //# sourceMappingURL=chip.js.map