import { __decorate, __metadata } from 'tslib';
import { ContentObserver, ObserversModule } from '@angular/cdk/observers';
import { ɵɵelement, ɵɵnextContext, ɵɵclassMapInterpolate1, ɵɵstyleProp, ɵɵdefaultStyleSanitizer, ɵɵproperty, ɵɵelementStart, ɵɵtext, ɵɵelementEnd, ɵɵadvance, ɵɵtextInterpolate, ɵɵclassProp, ɵɵtextInterpolate1, ɵɵelementContainerStart, ɵɵtemplate, ɵɵelementContainerEnd, ɵɵattribute, TemplateRef, ɵɵdirectiveInject, Renderer2, ElementRef, ChangeDetectorRef, NgZone, ɵɵdefineComponent, ɵɵviewQuery, ɵɵqueryRefresh, ɵɵloadQuery, ɵɵNgOnChangesFeature, ɵɵprojectionDef, ɵɵprojection, ɵsetClassMetadata, Component, ViewEncapsulation, ChangeDetectionStrategy, ViewChild, Input, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
import { isEmpty, NzConfigService, NzStringTemplateOutletDirective, zoomBadgeMotion, InputBoolean, WithConfig, NzOutletModule } from 'ng-zorro-antd/core';
import { Subject } from 'rxjs';
import { take, startWith, takeUntil } from 'rxjs/operators';
import { NgIf, NgStyle, NgForOf, CommonModule } from '@angular/common';

var _c0 = ["contentElement"];
function NzBadgeComponent_span_3_Template(rf, ctx) { if (rf & 1) {
    ɵɵelement(0, "span", 4);
} if (rf & 2) {
    var ctx_r66 = ɵɵnextContext();
    ɵɵclassMapInterpolate1("ant-badge-status-dot ant-badge-status-", ctx_r66.nzStatus || ctx_r66.presetColor, "");
    ɵɵstyleProp("background", !ctx_r66.presetColor && ctx_r66.nzColor, ɵɵdefaultStyleSanitizer);
    ɵɵproperty("ngStyle", ctx_r66.nzStyle);
} }
function NzBadgeComponent_span_4_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementStart(0, "span", 5);
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r67 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵtextInterpolate(ctx_r67.nzText);
} }
function NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_ng_container_1_p_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementStart(0, "p", 13);
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var p_r77 = ctx.$implicit;
    var i_r73 = ɵɵnextContext(3).index;
    var ctx_r76 = ɵɵnextContext(3);
    ɵɵclassProp("current", p_r77 === ctx_r76.countArray[i_r73]);
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", p_r77, " ");
} }
function NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_ng_container_1_p_1_Template, 2, 3, "p", 12);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r75 = ɵɵnextContext(5);
    ɵɵadvance(1);
    ɵɵproperty("ngForOf", ctx_r75.countSingleArray);
} }
function NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementStart(0, "span", 11);
    ɵɵtemplate(1, NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_ng_container_1_Template, 2, 1, "ng-container", 9);
    ɵɵelementEnd();
} if (rf & 2) {
    var i_r73 = ɵɵnextContext().index;
    var ctx_r74 = ɵɵnextContext(3);
    ɵɵstyleProp("transform", "translateY(" + (0 - ctx_r74.countArray[i_r73]) * 100 + "%)");
    ɵɵadvance(1);
    ɵɵproperty("ngIf", !ctx_r74.nzDot && ctx_r74.countArray[i_r73] !== undefined);
} }
function NzBadgeComponent_ng_container_5_sup_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzBadgeComponent_ng_container_5_sup_1_ng_container_1_span_1_Template, 2, 3, "span", 10);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r70 = ɵɵnextContext(3);
    ɵɵadvance(1);
    ɵɵproperty("ngIf", ctx_r70.count <= ctx_r70.nzOverflowCount);
} }
function NzBadgeComponent_ng_container_5_sup_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtext(1);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r71 = ɵɵnextContext(3);
    ɵɵadvance(1);
    ɵɵtextInterpolate1("", ctx_r71.nzOverflowCount, "+");
} }
function NzBadgeComponent_ng_container_5_sup_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementStart(0, "sup", 7);
    ɵɵtemplate(1, NzBadgeComponent_ng_container_5_sup_1_ng_container_1_Template, 2, 1, "ng-container", 8);
    ɵɵtemplate(2, NzBadgeComponent_ng_container_5_sup_1_ng_container_2_Template, 2, 1, "ng-container", 9);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r69 = ɵɵnextContext(2);
    ɵɵstyleProp("right", ctx_r69.nzOffset && ctx_r69.nzOffset[0] ? 0 - ctx_r69.nzOffset[0] : null, "px")("margin-top", ctx_r69.nzOffset && ctx_r69.nzOffset[1] ? ctx_r69.nzOffset[1] : null, "px");
    ɵɵclassProp("ant-badge-count", !ctx_r69.nzDot)("ant-badge-dot", ctx_r69.nzDot)("ant-badge-multiple-words", ctx_r69.countArray.length >= 2);
    ɵɵproperty("@.disabled", ctx_r69.notWrapper)("@zoomBadgeMotion", undefined)("ngStyle", ctx_r69.nzStyle);
    ɵɵattribute("title", ctx_r69.nzTitle || ctx_r69.nzCount);
    ɵɵadvance(1);
    ɵɵproperty("ngForOf", ctx_r69.maxNumberArray);
    ɵɵadvance(1);
    ɵɵproperty("ngIf", ctx_r69.count > ctx_r69.nzOverflowCount);
} }
function NzBadgeComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzBadgeComponent_ng_container_5_sup_1_Template, 3, 16, "sup", 6);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r68 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵproperty("ngIf", ctx_r68.showSup && ctx_r68.viewInit);
} }
var _c1 = ["*"];
var NZ_CONFIG_COMPONENT_NAME = 'backTop';
var NZ_BADGE_COLORS = [
    'pink',
    'red',
    'yellow',
    'orange',
    'cyan',
    'green',
    'blue',
    'purple',
    'geekblue',
    'magenta',
    'volcano',
    'gold',
    'lime'
];
var NzBadgeComponent = /** @class */ (function () {
    function NzBadgeComponent(nzConfigService, renderer, elementRef, contentObserver, cdr, ngZone) {
        this.nzConfigService = nzConfigService;
        this.renderer = renderer;
        this.elementRef = elementRef;
        this.contentObserver = contentObserver;
        this.cdr = cdr;
        this.ngZone = ngZone;
        this.destroy$ = new Subject();
        this.notWrapper = true;
        this.viewInit = false;
        this.maxNumberArray = [];
        this.countArray = [];
        this.countSingleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        this.colorArray = NZ_BADGE_COLORS;
        this.presetColor = null;
        this.nzShowZero = false;
        this.nzShowDot = true;
        this.nzDot = false;
    }
    NzBadgeComponent.prototype.checkContent = function () {
        this.notWrapper = isEmpty(this.contentElement.nativeElement);
        if (this.notWrapper) {
            this.renderer.addClass(this.elementRef.nativeElement, 'ant-badge-not-a-wrapper');
        }
        else {
            this.renderer.removeClass(this.elementRef.nativeElement, 'ant-badge-not-a-wrapper');
        }
    };
    Object.defineProperty(NzBadgeComponent.prototype, "showSup", {
        get: function () {
            return (this.nzShowDot && this.nzDot) || this.count > 0 || (this.count === 0 && this.nzShowZero);
        },
        enumerable: true,
        configurable: true
    });
    NzBadgeComponent.prototype.generateMaxNumberArray = function () {
        this.maxNumberArray = this.nzOverflowCount.toString().split('');
    };
    NzBadgeComponent.prototype.ngOnInit = function () {
        this.generateMaxNumberArray();
    };
    NzBadgeComponent.prototype.ngAfterViewInit = function () {
        var _this = this;
        this.ngZone.onStable.pipe(take(1)).subscribe(function () {
            _this.viewInit = true;
            _this.cdr.markForCheck();
        });
        this.contentObserver
            .observe(this.contentElement)
            .pipe(startWith(true), takeUntil(this.destroy$))
            .subscribe(function () {
            _this.checkContent();
        });
    };
    NzBadgeComponent.prototype.ngOnChanges = function (changes) {
        var nzOverflowCount = changes.nzOverflowCount, nzCount = changes.nzCount, nzColor = changes.nzColor;
        if (nzCount && !(nzCount.currentValue instanceof TemplateRef)) {
            this.count = Math.max(0, nzCount.currentValue);
            this.countArray = this.count
                .toString()
                .split('')
                .map(function (item) { return +item; });
        }
        if (nzOverflowCount) {
            this.generateMaxNumberArray();
        }
        if (nzColor) {
            this.presetColor = this.colorArray.indexOf(this.nzColor) !== -1 ? this.nzColor : null;
        }
    };
    NzBadgeComponent.prototype.ngOnDestroy = function () {
        this.destroy$.next();
        this.destroy$.complete();
    };
    /** @nocollapse */ NzBadgeComponent.ɵfac = function NzBadgeComponent_Factory(t) { return new (t || NzBadgeComponent)(ɵɵdirectiveInject(NzConfigService), ɵɵdirectiveInject(Renderer2), ɵɵdirectiveInject(ElementRef), ɵɵdirectiveInject(ContentObserver), ɵɵdirectiveInject(ChangeDetectorRef), ɵɵdirectiveInject(NgZone)); };
    /** @nocollapse */ NzBadgeComponent.ɵcmp = ɵɵdefineComponent({ type: NzBadgeComponent, selectors: [["nz-badge"]], viewQuery: function NzBadgeComponent_Query(rf, ctx) { if (rf & 1) {
            ɵɵviewQuery(_c0, true);
        } if (rf & 2) {
            var _t;
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.contentElement = _t.first);
        } }, hostAttrs: [1, "ant-badge"], hostVars: 2, hostBindings: function NzBadgeComponent_HostBindings(rf, ctx) { if (rf & 2) {
            ɵɵclassProp("ant-badge-status", ctx.nzStatus);
        } }, inputs: { nzShowZero: "nzShowZero", nzShowDot: "nzShowDot", nzDot: "nzDot", nzOverflowCount: "nzOverflowCount", nzText: "nzText", nzColor: "nzColor", nzTitle: "nzTitle", nzStyle: "nzStyle", nzStatus: "nzStatus", nzCount: "nzCount", nzOffset: "nzOffset" }, exportAs: ["nzBadge"], features: [ɵɵNgOnChangesFeature], ngContentSelectors: _c1, decls: 6, vars: 3, consts: [["contentElement", ""], [3, "class", "background", "ngStyle", 4, "ngIf"], ["class", "ant-badge-status-text", 4, "ngIf"], [4, "nzStringTemplateOutlet"], [3, "ngStyle"], [1, "ant-badge-status-text"], ["class", "ant-scroll-number", 3, "ngStyle", "right", "marginTop", "ant-badge-count", "ant-badge-dot", "ant-badge-multiple-words", 4, "ngIf"], [1, "ant-scroll-number", 3, "ngStyle"], [4, "ngFor", "ngForOf"], [4, "ngIf"], ["class", "ant-scroll-number-only", 3, "transform", 4, "ngIf"], [1, "ant-scroll-number-only"], ["class", "ant-scroll-number-only-unit", 3, "current", 4, "ngFor", "ngForOf"], [1, "ant-scroll-number-only-unit"]], template: function NzBadgeComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵprojectionDef();
            ɵɵelementStart(0, "span", null, 0);
            ɵɵprojection(2);
            ɵɵelementEnd();
            ɵɵtemplate(3, NzBadgeComponent_span_3_Template, 1, 6, "span", 1);
            ɵɵtemplate(4, NzBadgeComponent_span_4_Template, 2, 1, "span", 2);
            ɵɵtemplate(5, NzBadgeComponent_ng_container_5_Template, 2, 1, "ng-container", 3);
        } if (rf & 2) {
            ɵɵadvance(3);
            ɵɵproperty("ngIf", ctx.nzStatus || ctx.nzColor);
            ɵɵadvance(1);
            ɵɵproperty("ngIf", ctx.nzStatus || ctx.nzColor);
            ɵɵadvance(1);
            ɵɵproperty("nzStringTemplateOutlet", ctx.nzCount);
        } }, directives: [NgIf, NzStringTemplateOutletDirective, NgStyle, NgForOf], encapsulation: 2, data: { animation: [zoomBadgeMotion] }, changeDetection: 0 });
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzBadgeComponent.prototype, "nzShowZero", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzBadgeComponent.prototype, "nzShowDot", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzBadgeComponent.prototype, "nzDot", void 0);
    __decorate([
        WithConfig(NZ_CONFIG_COMPONENT_NAME, 99),
        __metadata("design:type", Number)
    ], NzBadgeComponent.prototype, "nzOverflowCount", void 0);
    __decorate([
        WithConfig(NZ_CONFIG_COMPONENT_NAME),
        __metadata("design:type", String)
    ], NzBadgeComponent.prototype, "nzColor", void 0);
    return NzBadgeComponent;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzBadgeComponent, [{
        type: Component,
        args: [{
                selector: 'nz-badge',
                exportAs: 'nzBadge',
                preserveWhitespaces: false,
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
                animations: [zoomBadgeMotion],
                template: "\n    <span #contentElement><ng-content></ng-content></span>\n    <span\n      class=\"ant-badge-status-dot ant-badge-status-{{ nzStatus || presetColor }}\"\n      [style.background]=\"!presetColor && nzColor\"\n      *ngIf=\"nzStatus || nzColor\"\n      [ngStyle]=\"nzStyle\"\n    ></span>\n    <span class=\"ant-badge-status-text\" *ngIf=\"nzStatus || nzColor\">{{ nzText }}</span>\n    <ng-container *nzStringTemplateOutlet=\"nzCount\">\n      <sup\n        class=\"ant-scroll-number\"\n        *ngIf=\"showSup && viewInit\"\n        [@.disabled]=\"notWrapper\"\n        [@zoomBadgeMotion]\n        [ngStyle]=\"nzStyle\"\n        [attr.title]=\"nzTitle || nzCount\"\n        [style.right.px]=\"nzOffset && nzOffset[0] ? -nzOffset[0] : null\"\n        [style.marginTop.px]=\"nzOffset && nzOffset[1] ? nzOffset[1] : null\"\n        [class.ant-badge-count]=\"!nzDot\"\n        [class.ant-badge-dot]=\"nzDot\"\n        [class.ant-badge-multiple-words]=\"countArray.length >= 2\"\n      >\n        <ng-container *ngFor=\"let n of maxNumberArray; let i = index\">\n          <span\n            class=\"ant-scroll-number-only\"\n            *ngIf=\"count <= nzOverflowCount\"\n            [style.transform]=\"'translateY(' + -countArray[i] * 100 + '%)'\"\n          >\n            <ng-container *ngIf=\"!nzDot && countArray[i] !== undefined\">\n              <p *ngFor=\"let p of countSingleArray\" class=\"ant-scroll-number-only-unit\" [class.current]=\"p === countArray[i]\">\n                {{ p }}\n              </p>\n            </ng-container>\n          </span>\n        </ng-container>\n        <ng-container *ngIf=\"count > nzOverflowCount\">{{ nzOverflowCount }}+</ng-container>\n      </sup>\n    </ng-container>\n  ",
                host: {
                    class: 'ant-badge',
                    '[class.ant-badge-status]': 'nzStatus'
                }
            }]
    }], function () { return [{ type: NzConfigService }, { type: Renderer2 }, { type: ElementRef }, { type: ContentObserver }, { type: ChangeDetectorRef }, { type: NgZone }]; }, { contentElement: [{
            type: ViewChild,
            args: ['contentElement', { static: false }]
        }], nzShowZero: [{
            type: Input
        }], nzShowDot: [{
            type: Input
        }], nzDot: [{
            type: Input
        }], nzOverflowCount: [{
            type: Input
        }], nzText: [{
            type: Input
        }], nzColor: [{
            type: Input
        }], nzTitle: [{
            type: Input
        }], nzStyle: [{
            type: Input
        }], nzStatus: [{
            type: Input
        }], nzCount: [{
            type: Input
        }], nzOffset: [{
            type: Input
        }] }); })();

/**
 * @license
 * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */
var NzBadgeModule = /** @class */ (function () {
    function NzBadgeModule() {
    }
    /** @nocollapse */ NzBadgeModule.ɵmod = ɵɵdefineNgModule({ type: NzBadgeModule });
    /** @nocollapse */ NzBadgeModule.ɵinj = ɵɵdefineInjector({ factory: function NzBadgeModule_Factory(t) { return new (t || NzBadgeModule)(); }, imports: [[CommonModule, ObserversModule, NzOutletModule]] });
    return NzBadgeModule;
}());
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(NzBadgeModule, { declarations: [NzBadgeComponent], imports: [CommonModule, ObserversModule, NzOutletModule], exports: [NzBadgeComponent] }); })();
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzBadgeModule, [{
        type: NgModule,
        args: [{
                declarations: [NzBadgeComponent],
                exports: [NzBadgeComponent],
                imports: [CommonModule, ObserversModule, NzOutletModule]
            }]
    }], null, null); })();

/**
 * @license
 * Copyright Alibaba.com 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://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE
 */

/**
 * Generated bundle index. Do not edit.
 */

export { NzBadgeComponent, NzBadgeModule };
//# sourceMappingURL=ng-zorro-antd-badge.js.map
