text: import { __decorate } from 'tslib';
  import { Directionality, BidiModule } from '@angular/cdk/bidi';
  import { Component, ChangeDetectionStrategy, ViewEncapsulation, NgZone, ElementRef, ChangeDetectorRef, Renderer2, Optional, ContentChild, Input, NgModule } from '@angular/core';
  import { Subject, fromEvent } from 'rxjs';
  import { takeUntil, startWith, filter } from 'rxjs/operators';
  import { NzConfigService, WithConfig } from 'ng-zorro-antd/core/config';
  import { InputBoolean } from 'ng-zorro-antd/core/util';
  import { NzIconDirective, NzIconModule } from 'ng-zorro-antd/icon';
  import { CommonModule } from '@angular/common';
  import { ɵNzTransitionPatchModule } from 'ng-zorro-antd/core/transition-patch';
  import { NzWaveModule } from 'ng-zorro-antd/core/wave';
  
  /**
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
   */
  import * as ɵngcc0 from '@angular/core';
  import * as ɵngcc1 from 'ng-zorro-antd/core/config';
  import * as ɵngcc2 from '@angular/cdk/bidi';
  import * as ɵngcc3 from '@angular/common';
  import * as ɵngcc4 from 'ng-zorro-antd/icon';
  import * as ɵngcc5 from 'ng-zorro-antd/core/transition-patch';
  
  const _c0 = ["nz-button", ""];
  function NzButtonComponent_i_0_Template(rf, ctx) { if (rf & 1) {
      ɵngcc0.ɵɵelement(0, "i", 1);
  } }
  const _c1 = ["*"];
  const NZ_CONFIG_MODULE_NAME = 'button';
  class NzButtonComponent {
      constructor(ngZone, elementRef, cdr, renderer, nzConfigService, directionality) {
          this.ngZone = ngZone;
          this.elementRef = elementRef;
          this.cdr = cdr;
          this.renderer = renderer;
          this.nzConfigService = nzConfigService;
          this.directionality = directionality;
          this._nzModuleName = NZ_CONFIG_MODULE_NAME;
          this.nzBlock = false;
          this.nzGhost = false;
          this.nzSearch = false;
          this.nzLoading = false;
          this.nzDanger = false;
          this.disabled = false;
          this.tabIndex = null;
          this.nzType = null;
          this.nzShape = null;
          this.nzSize = 'default';
          this.dir = 'ltr';
          this.destroy$ = new Subject();
          this.loading$ = new Subject();
          // TODO: move to host after View Engine deprecation
          this.elementRef.nativeElement.classList.add('ant-btn');
          this.nzConfigService
              .getConfigChangeEventForComponent(NZ_CONFIG_MODULE_NAME)
              .pipe(takeUntil(this.destroy$))
              .subscribe(() => {
              this.cdr.markForCheck();
          });
      }
      insertSpan(nodes, renderer) {
          nodes.forEach(node => {
              if (node.nodeName === '#text') {
                  const span = renderer.createElement('span');
                  const parent = renderer.parentNode(node);
                  renderer.insertBefore(parent, span, node);
                  renderer.appendChild(span, node);
              }
          });
      }
      assertIconOnly(element, renderer) {
          const listOfNode = Array.from(element.childNodes);
          const iconCount = listOfNode.filter(node => node.nodeName === 'I').length;
          const noText = listOfNode.every(node => node.nodeName !== '#text');
          const noSpan = listOfNode.every(node => node.nodeName !== 'SPAN');
          const isIconOnly = noSpan && noText && iconCount >= 1;
          if (isIconOnly) {
              renderer.addClass(element, 'ant-btn-icon-only');
          }
      }
      ngOnInit() {
          var _a;
          (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
              this.dir = direction;
              this.cdr.detectChanges();
          });
          this.dir = this.directionality.value;
          this.ngZone.runOutsideAngular(() => {
              // Caretaker note: this event listener could've been added through `host.click` or `HostListener`.
              // The compiler generates the `ɵɵlistener` instruction which wraps the actual listener internally into the
              // function, which runs `markDirty()` before running the actual listener (the decorated class method).
              // Since we're preventing the default behavior and stopping event propagation this doesn't require Angular to run the change detection.
              fromEvent(this.elementRef.nativeElement, 'click')
                  .pipe(takeUntil(this.destroy$))
                  .subscribe(event => {
                  var _a;
                  if (this.disabled && ((_a = event.target) === null || _a === void 0 ? void 0 : _a.tagName) === 'A') {
                      event.preventDefault();
                      event.stopImmediatePropagation();
                  }
              });
          });
      }
      ngOnChanges(changes) {
          const { nzLoading } = changes;
          if (nzLoading) {
              this.loading$.next(this.nzLoading);
          }
      }
      ngAfterViewInit() {
          this.assertIconOnly(this.elementRef.nativeElement, this.renderer);
          this.insertSpan(this.elementRef.nativeElement.childNodes, this.renderer);
      }
      ngAfterContentInit() {
          this.loading$
              .pipe(startWith(this.nzLoading), filter(() => !!this.nzIconDirectiveElement), takeUntil(this.destroy$))
              .subscribe(loading => {
              const nativeElement = this.nzIconDirectiveElement.nativeElement;
              if (loading) {
                  this.renderer.setStyle(nativeElement, 'display', 'none');
              }
              else {
                  this.renderer.removeStyle(nativeElement, 'display');
              }
          });
      }
      ngOnDestroy() {
          this.destroy$.next();
          this.destroy$.complete();
      }
  }
  NzButtonComponent.ɵfac = function NzButtonComponent_Factory(t) { return new (t || NzButtonComponent)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.NgZone), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ChangeDetectorRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc0.Renderer2), ɵngcc0.ɵɵdirectiveInject(ɵngcc1.NzConfigService), ɵngcc0.ɵɵdirectiveInject(ɵngcc2.Directionality, 8)); };
  NzButtonComponent.ɵcmp = /*@__PURE__*/ ɵngcc0.ɵɵdefineComponent({ type: NzButtonComponent, selectors: [["button", "nz-button", ""], ["a", "nz-button", ""]], contentQueries: function NzButtonComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
          ɵngcc0.ɵɵcontentQuery(dirIndex, NzIconDirective, 5, ElementRef);
      } if (rf & 2) {
          let _t;
          ɵngcc0.ɵɵqueryRefresh(_t = ɵngcc0.ɵɵloadQuery()) && (ctx.nzIconDirectiveElement = _t.first);
      } }, hostVars: 30, hostBindings: function NzButtonComponent_HostBindings(rf, ctx) { if (rf & 2) {
          ɵngcc0.ɵɵattribute("tabindex", ctx.disabled ? -1 : ctx.tabIndex === null ? null : ctx.tabIndex)("disabled", ctx.disabled || null);
          ɵngcc0.ɵɵclassProp("ant-btn-primary", ctx.nzType === "primary")("ant-btn-dashed", ctx.nzType === "dashed")("ant-btn-link", ctx.nzType === "link")("ant-btn-text", ctx.nzType === "text")("ant-btn-circle", ctx.nzShape === "circle")("ant-btn-round", ctx.nzShape === "round")("ant-btn-lg", ctx.nzSize === "large")("ant-btn-sm", ctx.nzSize === "small")("ant-btn-dangerous", ctx.nzDanger)("ant-btn-loading", ctx.nzLoading)("ant-btn-background-ghost", ctx.nzGhost)("ant-btn-block", ctx.nzBlock)("ant-input-search-button", ctx.nzSearch)("ant-btn-rtl", ctx.dir === "rtl");
      } }, inputs: { nzBlock: "nzBlock", nzGhost: "nzGhost", nzSearch: "nzSearch", nzLoading: "nzLoading", nzDanger: "nzDanger", disabled: "disabled", tabIndex: "tabIndex", nzType: "nzType", nzShape: "nzShape", nzSize: "nzSize" }, exportAs: ["nzButton"], features: [ɵngcc0.ɵɵNgOnChangesFeature], attrs: _c0, ngContentSelectors: _c1, decls: 2, vars: 1, consts: [["nz-icon", "", "nzType", "loading", 4, "ngIf"], ["nz-icon", "", "nzType", "loading"]], template: function NzButtonComponent_Template(rf, ctx) { if (rf & 1) {
          ɵngcc0.ɵɵprojectionDef();
          ɵngcc0.ɵɵtemplate(0, NzButtonComponent_i_0_Template, 1, 0, "i", 0);
          ɵngcc0.ɵɵprojection(1);
      } if (rf & 2) {
          ɵngcc0.ɵɵproperty("ngIf", ctx.nzLoading);
      } }, directives: [ɵngcc3.NgIf, ɵngcc4.NzIconDirective, ɵngcc5.ɵNzTransitionPatchDirective], encapsulation: 2, changeDetection: 0 });
  NzButtonComponent.ctorParameters = () => [
      { type: NgZone },
      { type: ElementRef },
      { type: ChangeDetectorRef },
      { type: Renderer2 },
      { type: NzConfigService },
      { type: Directionality, decorators: [{ type: Optional }] }
  ];
  NzButtonComponent.propDecorators = {
      nzIconDirectiveElement: [{ type: ContentChild, args: [NzIconDirective, { read: ElementRef },] }],
      nzBlock: [{ type: Input }],
      nzGhost: [{ type: Input }],
      nzSearch: [{ type: Input }],
      nzLoading: [{ type: Input }],
      nzDanger: [{ type: Input }],
      disabled: [{ type: Input }],
      tabIndex: [{ type: Input }],
      nzType: [{ type: Input }],
      nzShape: [{ type: Input }],
      nzSize: [{ type: Input }]
  };
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "nzBlock", void 0);
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "nzGhost", void 0);
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "nzSearch", void 0);
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "nzLoading", void 0);
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "nzDanger", void 0);
  __decorate([
      InputBoolean()
  ], NzButtonComponent.prototype, "disabled", void 0);
  __decorate([
      WithConfig()
  ], NzButtonComponent.prototype, "nzSize", void 0);
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(NzButtonComponent, [{
          type: Component,
          args: [{
                  selector: 'button[nz-button], a[nz-button]',
                  exportAs: 'nzButton',
                  preserveWhitespaces: false,
                  changeDetection: ChangeDetectionStrategy.OnPush,
                  encapsulation: ViewEncapsulation.None,
                  template: `
      <i nz-icon nzType="loading" *ngIf="nzLoading"></i>
      <ng-content></ng-content>
    `,
                  host: {
                      '[class.ant-btn-primary]': `nzType === 'primary'`,
                      '[class.ant-btn-dashed]': `nzType === 'dashed'`,
                      '[class.ant-btn-link]': `nzType === 'link'`,
                      '[class.ant-btn-text]': `nzType === 'text'`,
                      '[class.ant-btn-circle]': `nzShape === 'circle'`,
                      '[class.ant-btn-round]': `nzShape === 'round'`,
                      '[class.ant-btn-lg]': `nzSize === 'large'`,
                      '[class.ant-btn-sm]': `nzSize === 'small'`,
                      '[class.ant-btn-dangerous]': `nzDanger`,
                      '[class.ant-btn-loading]': `nzLoading`,
                      '[class.ant-btn-background-ghost]': `nzGhost`,
                      '[class.ant-btn-block]': `nzBlock`,
                      '[class.ant-input-search-button]': `nzSearch`,
                      '[class.ant-btn-rtl]': `dir === 'rtl'`,
                      '[attr.tabindex]': 'disabled ? -1 : (tabIndex === null ? null : tabIndex)',
                      '[attr.disabled]': 'disabled || null'
                  }
              }]
      }], function () { return [{ type: ɵngcc0.NgZone }, { type: ɵngcc0.ElementRef }, { type: ɵngcc0.ChangeDetectorRef }, { type: ɵngcc0.Renderer2 }, { type: ɵngcc1.NzConfigService }, { type: ɵngcc2.Directionality, decorators: [{
                  type: Optional
              }] }]; }, { nzBlock: [{
              type: Input
          }], nzGhost: [{
              type: Input
          }], nzSearch: [{
              type: Input
          }], nzLoading: [{
              type: Input
          }], nzDanger: [{
              type: Input
          }], disabled: [{
              type: Input
          }], tabIndex: [{
              type: Input
          }], nzType: [{
              type: Input
          }], nzShape: [{
              type: Input
          }], nzSize: [{
              type: Input
          }], nzIconDirectiveElement: [{
              type: ContentChild,
              args: [NzIconDirective, { read: ElementRef }]
          }] }); })();
  
  /**
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
   */
  class NzButtonGroupComponent {
      constructor(elementRef, directionality) {
          this.elementRef = elementRef;
          this.directionality = directionality;
          this.nzSize = 'default';
          this.dir = 'ltr';
          this.destroy$ = new Subject();
          // TODO: move to host after View Engine deprecation
          this.elementRef.nativeElement.classList.add('ant-btn-group');
      }
      ngOnInit() {
          var _a;
          this.dir = this.directionality.value;
          (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
              this.dir = direction;
          });
      }
      ngOnDestroy() {
          this.destroy$.next();
          this.destroy$.complete();
      }
  }
  NzButtonGroupComponent.ɵfac = function NzButtonGroupComponent_Factory(t) { return new (t || NzButtonGroupComponent)(ɵngcc0.ɵɵdirectiveInject(ɵngcc0.ElementRef), ɵngcc0.ɵɵdirectiveInject(ɵngcc2.Directionality, 8)); };
  NzButtonGroupComponent.ɵcmp = /*@__PURE__*/ ɵngcc0.ɵɵdefineComponent({ type: NzButtonGroupComponent, selectors: [["nz-button-group"]], hostVars: 6, hostBindings: function NzButtonGroupComponent_HostBindings(rf, ctx) { if (rf & 2) {
          ɵngcc0.ɵɵclassProp("ant-btn-group-lg", ctx.nzSize === "large")("ant-btn-group-sm", ctx.nzSize === "small")("ant-btn-group-rtl", ctx.dir === "rtl");
      } }, inputs: { nzSize: "nzSize" }, exportAs: ["nzButtonGroup"], ngContentSelectors: _c1, decls: 1, vars: 0, template: function NzButtonGroupComponent_Template(rf, ctx) { if (rf & 1) {
          ɵngcc0.ɵɵprojectionDef();
          ɵngcc0.ɵɵprojection(0);
      } }, encapsulation: 2, changeDetection: 0 });
  NzButtonGroupComponent.ctorParameters = () => [
      { type: ElementRef },
      { type: Directionality, decorators: [{ type: Optional }] }
  ];
  NzButtonGroupComponent.propDecorators = {
      nzSize: [{ type: Input }]
  };
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(NzButtonGroupComponent, [{
          type: Component,
          args: [{
                  selector: 'nz-button-group',
                  exportAs: 'nzButtonGroup',
                  changeDetection: ChangeDetectionStrategy.OnPush,
                  encapsulation: ViewEncapsulation.None,
                  host: {
                      '[class.ant-btn-group-lg]': `nzSize === 'large'`,
                      '[class.ant-btn-group-sm]': `nzSize === 'small'`,
                      '[class.ant-btn-group-rtl]': `dir === 'rtl'`
                  },
                  preserveWhitespaces: false,
                  template: ` <ng-content></ng-content> `
              }]
      }], function () { return [{ type: ɵngcc0.ElementRef }, { type: ɵngcc2.Directionality, decorators: [{
                  type: Optional
              }] }]; }, { nzSize: [{
              type: Input
          }] }); })();
  
  /**
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
   */
  class NzButtonModule {
  }
  NzButtonModule.ɵfac = function NzButtonModule_Factory(t) { return new (t || NzButtonModule)(); };
  NzButtonModule.ɵmod = /*@__PURE__*/ ɵngcc0.ɵɵdefineNgModule({ type: NzButtonModule });
  NzButtonModule.ɵinj = /*@__PURE__*/ ɵngcc0.ɵɵdefineInjector({ imports: [[BidiModule, CommonModule, NzWaveModule, NzIconModule, ɵNzTransitionPatchModule], ɵNzTransitionPatchModule, NzWaveModule] });
  (function () { (typeof ngDevMode === "undefined" || ngDevMode) && ɵngcc0.ɵsetClassMetadata(NzButtonModule, [{
          type: NgModule,
          args: [{
                  declarations: [NzButtonComponent, NzButtonGroupComponent],
                  exports: [NzButtonComponent, NzButtonGroupComponent, ɵNzTransitionPatchModule, NzWaveModule],
                  imports: [BidiModule, CommonModule, NzWaveModule, NzIconModule, ɵNzTransitionPatchModule]
              }]
      }], null, null); })();
  (function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵngcc0.ɵɵsetNgModuleScope(NzButtonModule, { declarations: function () { return [NzButtonComponent, NzButtonGroupComponent]; }, imports: function () { return [BidiModule, CommonModule, NzWaveModule, NzIconModule, ɵNzTransitionPatchModule]; }, exports: function () { return [NzButtonComponent, NzButtonGroupComponent, ɵNzTransitionPatchModule, NzWaveModule]; } }); })();
  
  /**
   * Use of this source code is governed by an MIT-style license that can be
   * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
   */
  
  /**
   * Generated bundle index. Do not edit.
   */
  
  export { NzButtonComponent, NzButtonGroupComponent, NzButtonModule };
  
  //# sourceMappingURL=ng-zorro-antd-button.js.map