/**
 * @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
 */
import { ChangeDetectorRef, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
import { notificationMotion } from 'ng-zorro-antd/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "ng-zorro-antd/icon";
import * as i3 from "ng-zorro-antd/core";
function NzNotificationComponent_div_1_i_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 16);
} }
function NzNotificationComponent_div_1_i_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 17);
} }
function NzNotificationComponent_div_1_i_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 18);
} }
function NzNotificationComponent_div_1_i_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 19);
} }
var _c0 = function (a0) { return { "ant-notification-notice-with-icon": a0 }; };
function NzNotificationComponent_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵelementStart(1, "div", 8);
    i0.ɵɵelementStart(2, "div");
    i0.ɵɵelementContainerStart(3, 9);
    i0.ɵɵtemplate(4, NzNotificationComponent_div_1_i_4_Template, 1, 0, "i", 10);
    i0.ɵɵtemplate(5, NzNotificationComponent_div_1_i_5_Template, 1, 0, "i", 11);
    i0.ɵɵtemplate(6, NzNotificationComponent_div_1_i_6_Template, 1, 0, "i", 12);
    i0.ɵɵtemplate(7, NzNotificationComponent_div_1_i_7_Template, 1, 0, "i", 13);
    i0.ɵɵelementContainerEnd();
    i0.ɵɵelement(8, "div", 14);
    i0.ɵɵelement(9, "div", 15);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r692 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(10, _c0, ctx_r692.nzMessage.type !== "blank"));
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("ant-notification-notice-with-icon", ctx_r692.nzMessage.type !== "blank");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitch", ctx_r692.nzMessage.type);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "success");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "info");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "warning");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "error");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("innerHTML", ctx_r692.nzMessage.title, i0.ɵɵsanitizeHtml);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("innerHTML", ctx_r692.nzMessage.content, i0.ɵɵsanitizeHtml);
} }
function NzNotificationComponent_ng_template_2_Template(rf, ctx) { }
function NzNotificationComponent_ng_container_5_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "i", 21);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r701 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzType", ctx_r701.nzMessage.options == null ? null : ctx_r701.nzMessage.options.nzCloseIcon);
} }
function NzNotificationComponent_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzNotificationComponent_ng_container_5_ng_container_1_Template, 2, 1, "ng-container", 20);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r694 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r694.nzMessage.options == null ? null : ctx_r694.nzMessage.options.nzCloseIcon);
} }
function NzNotificationComponent_ng_template_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "i", 22);
} }
var _c1 = function (a0, a1) { return { $implicit: a0, data: a1 }; };
var NzNotificationComponent = /** @class */ (function () {
    function NzNotificationComponent(cdr) {
        this.cdr = cdr;
        this.messageDestroy = new EventEmitter();
        this.eraseTimer = null;
    }
    NzNotificationComponent.prototype.ngOnInit = function () {
        // `NzMessageContainer` does its job so all properties cannot be undefined.
        this.options = this.nzMessage.options;
        if (this.options.nzAnimate) {
            this.nzMessage.state = 'enter';
        }
        this.autoClose = this.options.nzDuration > 0;
        if (this.autoClose) {
            this.initErase();
            this.startEraseTimeout();
        }
    };
    NzNotificationComponent.prototype.ngOnDestroy = function () {
        if (this.autoClose) {
            this.clearEraseTimeout();
        }
    };
    NzNotificationComponent.prototype.onEnter = function () {
        if (this.autoClose && this.options.nzPauseOnHover) {
            this.clearEraseTimeout();
            this.updateTTL();
        }
    };
    NzNotificationComponent.prototype.onLeave = function () {
        if (this.autoClose && this.options.nzPauseOnHover) {
            this.startEraseTimeout();
        }
    };
    // Remove self
    NzNotificationComponent.prototype.destroy = function (userAction) {
        var _this = this;
        if (userAction === void 0) { userAction = false; }
        if (this.options.nzAnimate) {
            this.nzMessage.state = 'leave';
            this.cdr.detectChanges();
            setTimeout(function () {
                _this.messageDestroy.next({ id: _this.nzMessage.messageId, userAction: userAction });
            }, 200);
        }
        else {
            this.messageDestroy.next({ id: this.nzMessage.messageId, userAction: userAction });
        }
    };
    NzNotificationComponent.prototype.initErase = function () {
        this.eraseTTL = this.options.nzDuration;
        this.eraseTimingStart = Date.now();
    };
    NzNotificationComponent.prototype.updateTTL = function () {
        if (this.autoClose) {
            this.eraseTTL -= Date.now() - this.eraseTimingStart;
        }
    };
    NzNotificationComponent.prototype.startEraseTimeout = function () {
        var _this = this;
        if (this.eraseTTL > 0) {
            this.clearEraseTimeout();
            this.eraseTimer = setTimeout(function () { return _this.destroy(); }, this.eraseTTL);
            this.eraseTimingStart = Date.now();
        }
        else {
            this.destroy();
        }
    };
    NzNotificationComponent.prototype.clearEraseTimeout = function () {
        if (this.eraseTimer !== null) {
            clearTimeout(this.eraseTimer);
            this.eraseTimer = null;
        }
    };
    NzNotificationComponent.prototype.close = function () {
        this.destroy(true);
    };
    Object.defineProperty(NzNotificationComponent.prototype, "state", {
        get: function () {
            if (this.nzMessage.state === 'enter') {
                if (this.nzPlacement === 'topLeft' || this.nzPlacement === 'bottomLeft') {
                    return 'enterLeft';
                }
                else {
                    return 'enterRight';
                }
            }
            else {
                return this.nzMessage.state;
            }
        },
        enumerable: true,
        configurable: true
    });
    /** @nocollapse */ NzNotificationComponent.ɵfac = function NzNotificationComponent_Factory(t) { return new (t || NzNotificationComponent)(i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    /** @nocollapse */ NzNotificationComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzNotificationComponent, selectors: [["nz-notification"]], inputs: { nzMessage: "nzMessage", nzIndex: "nzIndex", nzPlacement: "nzPlacement" }, outputs: { messageDestroy: "messageDestroy" }, exportAs: ["nzNotification"], decls: 8, vars: 12, consts: [[1, "ant-notification-notice", "ant-notification-notice-closable", 3, "ngStyle", "ngClass", "mouseenter", "mouseleave"], ["class", "ant-notification-notice-content", 4, "ngIf"], [3, "ngIf", "ngTemplateOutlet", "ngTemplateOutletContext"], ["tabindex", "0", 1, "ant-notification-notice-close", 3, "click"], [1, "ant-notification-notice-close-x"], [4, "ngIf", "ngIfElse"], ["iconTpl", ""], [1, "ant-notification-notice-content"], [1, "ant-notification-notice-content", 3, "ngClass"], [3, "ngSwitch"], ["nz-icon", "", "nzType", "check-circle", "class", "ant-notification-notice-icon ant-notification-notice-icon-success", 4, "ngSwitchCase"], ["nz-icon", "", "nzType", "info-circle", "class", "ant-notification-notice-icon ant-notification-notice-icon-info", 4, "ngSwitchCase"], ["nz-icon", "", "nzType", "exclamation-circle", "class", "ant-notification-notice-icon ant-notification-notice-icon-warning", 4, "ngSwitchCase"], ["nz-icon", "", "nzType", "close-circle", "class", "ant-notification-notice-icon ant-notification-notice-icon-error", 4, "ngSwitchCase"], [1, "ant-notification-notice-message", 3, "innerHTML"], [1, "ant-notification-notice-description", 3, "innerHTML"], ["nz-icon", "", "nzType", "check-circle", 1, "ant-notification-notice-icon", "ant-notification-notice-icon-success"], ["nz-icon", "", "nzType", "info-circle", 1, "ant-notification-notice-icon", "ant-notification-notice-icon-info"], ["nz-icon", "", "nzType", "exclamation-circle", 1, "ant-notification-notice-icon", "ant-notification-notice-icon-warning"], ["nz-icon", "", "nzType", "close-circle", 1, "ant-notification-notice-icon", "ant-notification-notice-icon-error"], [4, "nzStringTemplateOutlet"], ["nz-icon", "", 3, "nzType"], ["nz-icon", "", "nzType", "close", 1, "ant-notification-close-icon"]], template: function NzNotificationComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵlistener("mouseenter", function NzNotificationComponent_Template_div_mouseenter_0_listener() { return ctx.onEnter(); })("mouseleave", function NzNotificationComponent_Template_div_mouseleave_0_listener() { return ctx.onLeave(); });
            i0.ɵɵtemplate(1, NzNotificationComponent_div_1_Template, 10, 12, "div", 1);
            i0.ɵɵtemplate(2, NzNotificationComponent_ng_template_2_Template, 0, 0, "ng-template", 2);
            i0.ɵɵelementStart(3, "a", 3);
            i0.ɵɵlistener("click", function NzNotificationComponent_Template_a_click_3_listener() { return ctx.close(); });
            i0.ɵɵelementStart(4, "span", 4);
            i0.ɵɵtemplate(5, NzNotificationComponent_ng_container_5_Template, 2, 1, "ng-container", 5);
            i0.ɵɵtemplate(6, NzNotificationComponent_ng_template_6_Template, 1, 0, "ng-template", null, 6, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementEnd();
            i0.ɵɵelementEnd();
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            var _r695 = i0.ɵɵreference(7);
            i0.ɵɵproperty("ngStyle", ctx.nzMessage.options == null ? null : ctx.nzMessage.options.nzStyle)("ngClass", ctx.nzMessage.options == null ? null : ctx.nzMessage.options.nzClass)("@notificationMotion", ctx.state);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", !ctx.nzMessage.template);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.nzMessage.template)("ngTemplateOutlet", ctx.nzMessage.template)("ngTemplateOutletContext", i0.ɵɵpureFunction2(9, _c1, ctx, ctx.nzMessage.options == null ? null : ctx.nzMessage.options.nzData));
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.nzMessage.options == null ? null : ctx.nzMessage.options.nzCloseIcon)("ngIfElse", _r695);
        } }, directives: [i1.NgStyle, i1.NgClass, i1.NgIf, i1.NgTemplateOutlet, i1.NgSwitch, i1.NgSwitchCase, i2.NzIconDirective, i3.NzStringTemplateOutletDirective], encapsulation: 2, data: { animation: [notificationMotion] } });
    return NzNotificationComponent;
}());
export { NzNotificationComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzNotificationComponent, [{
        type: Component,
        args: [{
                encapsulation: ViewEncapsulation.None,
                selector: 'nz-notification',
                exportAs: 'nzNotification',
                preserveWhitespaces: false,
                animations: [notificationMotion],
                template: "\n    <div\n      class=\"ant-notification-notice ant-notification-notice-closable\"\n      [ngStyle]=\"nzMessage.options?.nzStyle\"\n      [ngClass]=\"nzMessage.options?.nzClass\"\n      [@notificationMotion]=\"state\"\n      (mouseenter)=\"onEnter()\"\n      (mouseleave)=\"onLeave()\"\n    >\n      <div *ngIf=\"!nzMessage.template\" class=\"ant-notification-notice-content\">\n        <div class=\"ant-notification-notice-content\" [ngClass]=\"{ 'ant-notification-notice-with-icon': nzMessage.type !== 'blank' }\">\n          <div [class.ant-notification-notice-with-icon]=\"nzMessage.type !== 'blank'\">\n            <ng-container [ngSwitch]=\"nzMessage.type\">\n              <i\n                *ngSwitchCase=\"'success'\"\n                nz-icon\n                nzType=\"check-circle\"\n                class=\"ant-notification-notice-icon ant-notification-notice-icon-success\"\n              ></i>\n              <i\n                *ngSwitchCase=\"'info'\"\n                nz-icon\n                nzType=\"info-circle\"\n                class=\"ant-notification-notice-icon ant-notification-notice-icon-info\"\n              ></i>\n              <i\n                *ngSwitchCase=\"'warning'\"\n                nz-icon\n                nzType=\"exclamation-circle\"\n                class=\"ant-notification-notice-icon ant-notification-notice-icon-warning\"\n              ></i>\n              <i\n                *ngSwitchCase=\"'error'\"\n                nz-icon\n                nzType=\"close-circle\"\n                class=\"ant-notification-notice-icon ant-notification-notice-icon-error\"\n              ></i>\n            </ng-container>\n            <div class=\"ant-notification-notice-message\" [innerHTML]=\"nzMessage.title\"></div>\n            <div class=\"ant-notification-notice-description\" [innerHTML]=\"nzMessage.content\"></div>\n          </div>\n        </div>\n      </div>\n      <ng-template\n        [ngIf]=\"nzMessage.template\"\n        [ngTemplateOutlet]=\"nzMessage.template\"\n        [ngTemplateOutletContext]=\"{ $implicit: this, data: nzMessage.options?.nzData }\"\n      >\n      </ng-template>\n      <a tabindex=\"0\" class=\"ant-notification-notice-close\" (click)=\"close()\">\n        <span class=\"ant-notification-notice-close-x\">\n          <ng-container *ngIf=\"nzMessage.options?.nzCloseIcon; else iconTpl\">\n            <ng-container *nzStringTemplateOutlet=\"nzMessage.options?.nzCloseIcon\">\n              <i nz-icon [nzType]=\"nzMessage.options?.nzCloseIcon\"></i>\n            </ng-container>\n          </ng-container>\n          <ng-template #iconTpl>\n            <i nz-icon nzType=\"close\" class=\"ant-notification-close-icon\"></i>\n          </ng-template>\n        </span>\n      </a>\n    </div>\n  "
            }]
    }], function () { return [{ type: i0.ChangeDetectorRef }]; }, { nzMessage: [{
            type: Input
        }], nzIndex: [{
            type: Input
        }], nzPlacement: [{
            type: Input
        }], messageDestroy: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 