import { OverlayRef, OverlayConfig, Overlay, OverlayModule } from '@angular/cdk/overlay';
import { BasePortalOutlet, CdkPortalOutlet, PortalInjector, ComponentPortal, TemplatePortal, PortalModule } from '@angular/cdk/portal';
import { EventEmitter, ɵɵelementContainerStart, ɵɵelement, ɵɵelementContainerEnd, ɵɵnextContext, ɵɵadvance, ɵɵproperty, ɵɵdirectiveInject, ɵɵdefineComponent, ɵɵelementStart, ɵɵtemplate, ɵɵelementEnd, ɵsetClassMetadata, Component, ChangeDetectionStrategy, ɵɵgetCurrentView, ɵɵlistener, ɵɵrestoreView, ɵɵsanitizeHtml, ɵɵtext, ɵɵattribute, ɵɵtextInterpolate1, ElementRef, ChangeDetectorRef, Renderer2, NgZone, ɵɵstaticViewQuery, ɵɵqueryRefresh, ɵɵloadQuery, ɵɵcomponentHostSyntheticListener, ɵɵupdateSyntheticHostBinding, ɵɵclassMap, ɵɵstyleProp, ɵɵInheritDefinitionFeature, ɵɵpipe, ɵɵpipeBind1, Optional, Inject, ViewChild, Output, ɵɵtemplateRefExtractor, ɵɵreference, Input, TemplateRef, ɵɵinject, Injector, ɵɵdefineInjectable, Injectable, SkipSelf, InjectionToken, ɵɵdefineDirective, Directive, ɵɵprojection, ViewContainerRef, ɵɵcontentQuery, ɵɵNgOnChangesFeature, ɵɵprojectionDef, ContentChild, ɵɵdefineNgModule, ɵɵdefineInjector, ɵɵsetNgModuleScope, NgModule } from '@angular/core';
import { Subject, defer } from 'rxjs';
import { takeUntil, filter, take, startWith } from 'rxjs/operators';
import { getElementOffset, NzStringTemplateOutletDirective, NzWaveDirective, NzToCssUnitPipe, isPromise, warn, isNotNil, NzConfigService, WithConfig, InputBoolean, NzOutletModule, NzPipesModule, NzNoAnimationModule } from 'ng-zorro-antd/core';
import { __extends, __assign, __rest, __decorate, __metadata } from 'tslib';
import { FocusTrapFactory } from '@angular/cdk/a11y';
import { DOCUMENT, NgStyle, NgIf, NgForOf, CommonModule } from '@angular/common';
import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
import { NzI18nService, NzI18nModule } from 'ng-zorro-antd/i18n';
import { trigger, state, style, transition, animate } from '@angular/animations';
import { ɵNzTransitionPatchDirective } from 'ng-zorro-antd/core/transition-patch';
import { NzIconDirective, NzIconModule } from 'ng-zorro-antd/icon';
import { NzButtonComponent, NzButtonModule } from 'ng-zorro-antd/button';
import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';

/**
 * @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 noopFun = function () { return void 0; };
// tslint:disable-next-line:no-any
var ModalOptions = /** @class */ (function () {
    function ModalOptions() {
        this.nzClosable = true;
        this.nzOkLoading = false;
        this.nzOkDisabled = false;
        this.nzCancelDisabled = false;
        this.nzCancelLoading = false;
        this.nzNoAnimation = false;
        this.nzAutofocus = 'auto';
        this.nzMask = true;
        this.nzMaskClosable = true;
        this.nzKeyboard = true;
        this.nzZIndex = 1000;
        this.nzWidth = 520;
        this.nzCloseIcon = 'close';
        this.nzOkType = 'primary';
        this.nzModalType = 'default';
        this.nzOnCancel = noopFun;
        this.nzOnOk = noopFun;
        this.nzCloseOnNavigation = true;
        // Confirm
        this.nzIconType = 'question-circle';
    }
    return ModalOptions;
}());

/**
 * @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 nzModalAnimations = {
    modalContainer: trigger('modalContainer', [
        state('void, exit', style({})),
        state('enter', style({})),
        transition('* => enter', animate('.24s', style({}))),
        transition('* => void, * => exit', animate('.2s', style({})))
    ])
};

/**
 * @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
 */
function throwNzModalContentAlreadyAttachedError() {
    throw Error('Attempting to attach modal content after content is already attached');
}
var ZOOM_CLASS_NAME_MAP = {
    enter: 'zoom-enter',
    enterActive: 'zoom-enter-active',
    leave: 'zoom-leave',
    leaveActive: 'zoom-leave-active'
};
var FADE_CLASS_NAME_MAP = {
    enter: 'fade-enter',
    enterActive: 'fade-enter-active',
    leave: 'fade-leave',
    leaveActive: 'fade-leave-active'
};
var BaseModalContainer = /** @class */ (function (_super) {
    __extends(BaseModalContainer, _super);
    function BaseModalContainer(elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, 
    // tslint:disable-next-line:no-any
    document, animationType) {
        var _this = _super.call(this) || this;
        _this.elementRef = elementRef;
        _this.focusTrapFactory = focusTrapFactory;
        _this.cdr = cdr;
        _this.render = render;
        _this.zone = zone;
        _this.overlayRef = overlayRef;
        _this.config = config;
        _this.animationType = animationType;
        _this.animationStateChanged = new EventEmitter();
        _this.containerClick = new EventEmitter();
        _this.cancelTriggered = new EventEmitter();
        _this.okTriggered = new EventEmitter();
        _this.state = 'enter';
        _this.isStringContent = false;
        _this.elementFocusedBeforeModalWasOpened = null;
        _this.latestMousedownTarget = null;
        _this.oldMaskStyle = null;
        _this.document = document;
        _this.isStringContent = typeof config.nzContent === 'string';
        _this.setContainer();
        return _this;
    }
    BaseModalContainer.prototype.onMousedown = function (e) {
        this.latestMousedownTarget = e.target || null;
    };
    BaseModalContainer.prototype.onMouseup = function (e) {
        if (e.target === this.latestMousedownTarget && e.target === this.elementRef.nativeElement) {
            this.containerClick.emit();
        }
        this.latestMousedownTarget = null;
    };
    BaseModalContainer.prototype.onCloseClick = function () {
        this.cancelTriggered.emit();
    };
    BaseModalContainer.prototype.onOkClick = function () {
        this.okTriggered.emit();
    };
    BaseModalContainer.prototype.attachComponentPortal = function (portal) {
        if (this.portalOutlet.hasAttached()) {
            throwNzModalContentAlreadyAttachedError();
        }
        this.savePreviouslyFocusedElement();
        this.setModalTransformOrigin();
        return this.portalOutlet.attachComponentPortal(portal);
    };
    BaseModalContainer.prototype.attachTemplatePortal = function (portal) {
        if (this.portalOutlet.hasAttached()) {
            throwNzModalContentAlreadyAttachedError();
        }
        this.savePreviouslyFocusedElement();
        return this.portalOutlet.attachTemplatePortal(portal);
    };
    BaseModalContainer.prototype.getNativeElement = function () {
        return this.elementRef.nativeElement;
    };
    BaseModalContainer.prototype.animationDisabled = function () {
        return this.config.nzNoAnimation || this.animationType === 'NoopAnimations';
    };
    BaseModalContainer.prototype.setModalTransformOrigin = function () {
        var modalElement = this.modalElementRef.nativeElement;
        if (this.elementFocusedBeforeModalWasOpened) {
            var previouslyDOMRect = this.elementFocusedBeforeModalWasOpened.getBoundingClientRect();
            var lastPosition = getElementOffset(this.elementFocusedBeforeModalWasOpened);
            var x = lastPosition.left + previouslyDOMRect.width / 2;
            var y = lastPosition.top + previouslyDOMRect.height / 2;
            var transformOrigin = x - modalElement.offsetLeft + "px " + (y - modalElement.offsetTop) + "px 0px";
            this.render.setStyle(modalElement, 'transform-origin', transformOrigin);
        }
    };
    BaseModalContainer.prototype.savePreviouslyFocusedElement = function () {
        var _this = this;
        if (this.document) {
            this.elementFocusedBeforeModalWasOpened = this.document.activeElement;
            if (this.elementRef.nativeElement.focus) {
                Promise.resolve().then(function () { return _this.elementRef.nativeElement.focus(); });
            }
        }
    };
    BaseModalContainer.prototype.trapFocus = function () {
        var element = this.elementRef.nativeElement;
        if (!this.focusTrap) {
            this.focusTrap = this.focusTrapFactory.create(element);
        }
        if (this.config.nzAutofocus) {
            this.focusTrap.focusInitialElementWhenReady().then();
        }
        else {
            var activeElement = this.document.activeElement;
            if (activeElement !== element && !element.contains(activeElement)) {
                element.focus();
            }
        }
    };
    BaseModalContainer.prototype.restoreFocus = function () {
        var toFocus = this.elementFocusedBeforeModalWasOpened;
        // We need the extra check, because IE can set the `activeElement` to null in some cases.
        if (toFocus && typeof toFocus.focus === 'function') {
            var activeElement = this.document.activeElement;
            var element = this.elementRef.nativeElement;
            if (!activeElement || activeElement === this.document.body || activeElement === element || element.contains(activeElement)) {
                toFocus.focus();
            }
        }
        if (this.focusTrap) {
            this.focusTrap.destroy();
        }
    };
    BaseModalContainer.prototype.setEnterAnimationClass = function () {
        var _this = this;
        if (this.animationDisabled()) {
            return;
        }
        this.zone.runOutsideAngular(function () {
            // Make sure to set the `TransformOrigin` style before set the modelElement's class names
            _this.setModalTransformOrigin();
            var modalElement = _this.modalElementRef.nativeElement;
            var backdropElement = _this.overlayRef.backdropElement;
            _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.enter);
            _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.enterActive);
            _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.enter);
            _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.enterActive);
        });
    };
    BaseModalContainer.prototype.setExitAnimationClass = function () {
        var _this = this;
        if (this.animationDisabled()) {
            return;
        }
        this.zone.runOutsideAngular(function () {
            var modalElement = _this.modalElementRef.nativeElement;
            var backdropElement = _this.overlayRef.backdropElement;
            _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.leave);
            _this.render.addClass(modalElement, ZOOM_CLASS_NAME_MAP.leaveActive);
            _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.leave);
            _this.render.addClass(backdropElement, FADE_CLASS_NAME_MAP.leaveActive);
        });
    };
    BaseModalContainer.prototype.cleanAnimationClass = function () {
        var _this = this;
        if (this.animationDisabled()) {
            return;
        }
        this.zone.runOutsideAngular(function () {
            var backdropElement = _this.overlayRef.backdropElement;
            var modalElement = _this.modalElementRef.nativeElement;
            _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.enter);
            _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.enterActive);
            _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.leave);
            _this.render.removeClass(modalElement, ZOOM_CLASS_NAME_MAP.leaveActive);
            _this.render.removeClass(backdropElement, FADE_CLASS_NAME_MAP.enter);
            _this.render.removeClass(backdropElement, FADE_CLASS_NAME_MAP.enterActive);
        });
    };
    BaseModalContainer.prototype.bindBackdropStyle = function () {
        var _this = this;
        this.zone.runOutsideAngular(function () {
            if (_this.oldMaskStyle) {
                var backdropElement_1 = _this.overlayRef.backdropElement;
                var styles = _this.oldMaskStyle;
                Object.keys(styles).forEach(function (key) {
                    _this.render.removeStyle(backdropElement_1, key);
                });
                _this.oldMaskStyle = null;
            }
            if (typeof _this.config.nzMaskStyle === 'object' && Object.keys(_this.config.nzMaskStyle).length) {
                var backdropElement_2 = _this.overlayRef.backdropElement;
                var styles_1 = __assign({}, _this.config.nzMaskStyle);
                Object.keys(styles_1).forEach(function (key) {
                    _this.render.setStyle(backdropElement_2, key, styles_1[key]);
                });
                _this.oldMaskStyle = styles_1;
            }
        });
    };
    /**
     * Set the container element.
     * @deprecated Not supported.
     * @breaking-change 10.0.0
     */
    BaseModalContainer.prototype.setContainer = function () {
        var container = this.getContainer();
        if (container) {
            this.render.appendChild(container, this.elementRef.nativeElement);
        }
    };
    /**
     * Reset the container element.
     * @deprecated Not supported.
     * @breaking-change 10.0.0
     */
    BaseModalContainer.prototype.resetContainer = function () {
        var container = this.getContainer();
        if (container) {
            this.render.appendChild(this.overlayRef.overlayElement, this.elementRef.nativeElement);
        }
    };
    BaseModalContainer.prototype.getContainer = function () {
        var nzGetContainer = this.config.nzGetContainer;
        var container = typeof nzGetContainer === 'function' ? nzGetContainer() : nzGetContainer;
        return container instanceof HTMLElement ? container : null;
    };
    BaseModalContainer.prototype.onAnimationDone = function (event) {
        if (event.toState === 'enter') {
            this.setContainer();
            this.trapFocus();
        }
        else if (event.toState === 'exit') {
            this.restoreFocus();
        }
        this.cleanAnimationClass();
        this.animationStateChanged.emit(event);
    };
    BaseModalContainer.prototype.onAnimationStart = function (event) {
        if (event.toState === 'enter') {
            this.setEnterAnimationClass();
            this.bindBackdropStyle();
        }
        else if (event.toState === 'exit') {
            this.resetContainer();
            this.setExitAnimationClass();
        }
        this.animationStateChanged.emit(event);
    };
    BaseModalContainer.prototype.startExitAnimation = function () {
        this.state = 'exit';
        this.cdr.markForCheck();
    };
    return BaseModalContainer;
}(BasePortalOutlet));

/**
 * @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 _c0 = ["nz-modal-close", ""];
function NzModalCloseComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵelement(1, "i", 2);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1980 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵproperty("nzType", ctx_r1980.config == null ? null : ctx_r1980.config.nzCloseIcon);
} }
var NzModalCloseComponent = /** @class */ (function () {
    function NzModalCloseComponent(config) {
        this.config = config;
    }
    /** @nocollapse */ NzModalCloseComponent.ɵfac = function NzModalCloseComponent_Factory(t) { return new (t || NzModalCloseComponent)(ɵɵdirectiveInject(ModalOptions)); };
    /** @nocollapse */ NzModalCloseComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalCloseComponent, selectors: [["button", "nz-modal-close", ""]], hostAttrs: ["aria-label", "Close", 1, "ant-modal-close"], exportAs: ["NzModalCloseBuiltin"], attrs: _c0, decls: 2, vars: 1, consts: [[1, "ant-modal-close-x"], [4, "nzStringTemplateOutlet"], ["nz-icon", "", 1, "ant-modal-close-icon", 3, "nzType"]], template: function NzModalCloseComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵelementStart(0, "span", 0);
            ɵɵtemplate(1, NzModalCloseComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            ɵɵelementEnd();
        } if (rf & 2) {
            ɵɵadvance(1);
            ɵɵproperty("nzStringTemplateOutlet", ctx.config == null ? null : ctx.config.nzCloseIcon);
        } }, directives: [NzStringTemplateOutletDirective, ɵNzTransitionPatchDirective, NzIconDirective], encapsulation: 2, changeDetection: 0 });
    return NzModalCloseComponent;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalCloseComponent, [{
        type: Component,
        args: [{
                selector: 'button[nz-modal-close]',
                exportAs: 'NzModalCloseBuiltin',
                template: "\n    <span class=\"ant-modal-close-x\">\n      <ng-container *nzStringTemplateOutlet=\"config?.nzCloseIcon\">\n        <i nz-icon [nzType]=\"config?.nzCloseIcon\" class=\"ant-modal-close-icon\"></i>\n      </ng-container>\n    </span>\n  ",
                host: {
                    class: 'ant-modal-close',
                    'aria-label': 'Close'
                },
                changeDetection: ChangeDetectionStrategy.OnPush
            }]
    }], function () { return [{ type: ModalOptions }]; }, null); })();

var _c0$1 = ["modalElement"];
function NzModalConfirmContainerComponent_button_4_Template(rf, ctx) { if (rf & 1) {
    var _r1963 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 16);
    ɵɵlistener("click", function NzModalConfirmContainerComponent_button_4_Template_button_click_0_listener() { ɵɵrestoreView(_r1963); var ctx_r1962 = ɵɵnextContext(); return ctx_r1962.onCloseClick(); });
    ɵɵelementEnd();
} }
function NzModalConfirmContainerComponent_ng_container_10_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵelement(1, "span", 17);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1957 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵproperty("innerHTML", ctx_r1957.config.nzTitle, ɵɵsanitizeHtml);
} }
function NzModalConfirmContainerComponent_ng_template_12_Template(rf, ctx) { }
function NzModalConfirmContainerComponent_div_13_Template(rf, ctx) { if (rf & 1) {
    ɵɵelement(0, "div", 17);
} if (rf & 2) {
    var ctx_r1959 = ɵɵnextContext();
    ɵɵproperty("innerHTML", ctx_r1959.config.nzContent, ɵɵsanitizeHtml);
} }
function NzModalConfirmContainerComponent_button_15_Template(rf, ctx) { if (rf & 1) {
    var _r1965 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 18);
    ɵɵlistener("click", function NzModalConfirmContainerComponent_button_15_Template_button_click_0_listener() { ɵɵrestoreView(_r1965); var ctx_r1964 = ɵɵnextContext(); return ctx_r1964.onCancel(); });
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1960 = ɵɵnextContext();
    ɵɵproperty("nzLoading", ctx_r1960.config.nzCancelLoading)("disabled", ctx_r1960.config.nzCancelDisabled);
    ɵɵattribute("cdkFocusInitial", ctx_r1960.config.nzAutofocus === "cancel");
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", ctx_r1960.config.nzCancelText || ctx_r1960.locale.cancelText, " ");
} }
function NzModalConfirmContainerComponent_button_16_Template(rf, ctx) { if (rf & 1) {
    var _r1967 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 19);
    ɵɵlistener("click", function NzModalConfirmContainerComponent_button_16_Template_button_click_0_listener() { ɵɵrestoreView(_r1967); var ctx_r1966 = ɵɵnextContext(); return ctx_r1966.onOk(); });
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1961 = ɵɵnextContext();
    ɵɵproperty("nzType", ctx_r1961.config.nzOkType)("nzLoading", ctx_r1961.config.nzOkLoading)("disabled", ctx_r1961.config.nzOkDisabled);
    ɵɵattribute("cdkFocusInitial", ctx_r1961.config.nzAutofocus === "ok");
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", ctx_r1961.config.nzOkText || ctx_r1961.locale.okText, " ");
} }
var NzModalConfirmContainerComponent = /** @class */ (function (_super) {
    __extends(NzModalConfirmContainerComponent, _super);
    function NzModalConfirmContainerComponent(i18n, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, 
    // tslint:disable-next-line:no-any
    document, animationType) {
        var _this = _super.call(this, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) || this;
        _this.i18n = i18n;
        _this.config = config;
        _this.cancelTriggered = new EventEmitter();
        _this.okTriggered = new EventEmitter();
        _this.locale = {};
        _this.destroy$ = new Subject();
        _this.i18n.localeChange.pipe(takeUntil(_this.destroy$)).subscribe(function () {
            _this.locale = _this.i18n.getLocaleData('Modal');
        });
        return _this;
    }
    NzModalConfirmContainerComponent.prototype.onCancel = function () {
        this.cancelTriggered.emit();
    };
    NzModalConfirmContainerComponent.prototype.onOk = function () {
        this.okTriggered.emit();
    };
    NzModalConfirmContainerComponent.prototype.attachComponentPortal = function (_portal) {
        throw new Error('The confirm mode does not support using component as content');
    };
    NzModalConfirmContainerComponent.prototype.ngOnDestroy = function () {
        this.destroy$.next();
        this.destroy$.complete();
    };
    /** @nocollapse */ NzModalConfirmContainerComponent.ɵfac = function NzModalConfirmContainerComponent_Factory(t) { return new (t || NzModalConfirmContainerComponent)(ɵɵdirectiveInject(NzI18nService), ɵɵdirectiveInject(ElementRef), ɵɵdirectiveInject(FocusTrapFactory), ɵɵdirectiveInject(ChangeDetectorRef), ɵɵdirectiveInject(Renderer2), ɵɵdirectiveInject(NgZone), ɵɵdirectiveInject(OverlayRef), ɵɵdirectiveInject(ModalOptions), ɵɵdirectiveInject(DOCUMENT, 8), ɵɵdirectiveInject(ANIMATION_MODULE_TYPE, 8)); };
    /** @nocollapse */ NzModalConfirmContainerComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalConfirmContainerComponent, selectors: [["nz-modal-confirm-container"]], viewQuery: function NzModalConfirmContainerComponent_Query(rf, ctx) { if (rf & 1) {
            ɵɵstaticViewQuery(CdkPortalOutlet, true);
            ɵɵstaticViewQuery(_c0$1, true);
        } if (rf & 2) {
            var _t;
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.portalOutlet = _t.first);
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.modalElementRef = _t.first);
        } }, hostAttrs: ["tabindex", "-1", "role", "dialog", 1, "ant-modal-wrap"], hostVars: 6, hostBindings: function NzModalConfirmContainerComponent_HostBindings(rf, ctx) { if (rf & 1) {
            ɵɵcomponentHostSyntheticListener("@modalContainer.start", function NzModalConfirmContainerComponent_animation_modalContainer_start_HostBindingHandler($event) { return ctx.onAnimationStart($event); })("@modalContainer.done", function NzModalConfirmContainerComponent_animation_modalContainer_done_HostBindingHandler($event) { return ctx.onAnimationDone($event); });
            ɵɵlistener("mousedown", function NzModalConfirmContainerComponent_mousedown_HostBindingHandler($event) { return ctx.onMousedown($event); })("mouseup", function NzModalConfirmContainerComponent_mouseup_HostBindingHandler($event) { return ctx.onMouseup($event); });
        } if (rf & 2) {
            ɵɵupdateSyntheticHostBinding("@.disabled", ctx.config.nzNoAnimation)("@modalContainer", ctx.state);
            ɵɵclassMap(ctx.config.nzWrapClassName);
            ɵɵstyleProp("z-index", ctx.config.nzZIndex);
        } }, outputs: { cancelTriggered: "cancelTriggered", okTriggered: "okTriggered" }, exportAs: ["nzModalConfirmContainer"], features: [ɵɵInheritDefinitionFeature], decls: 17, vars: 14, consts: [["role", "document", 1, "ant-modal", 3, "ngStyle"], ["modalElement", ""], [1, "ant-modal-content"], ["nz-modal-close", "", 3, "click", 4, "ngIf"], [1, "ant-modal-body", 3, "ngStyle"], [1, "ant-modal-confirm-body-wrapper"], [1, "ant-modal-confirm-body"], ["nz-icon", "", 3, "nzType"], [1, "ant-modal-confirm-title"], [4, "nzStringTemplateOutlet"], [1, "ant-modal-confirm-content"], ["cdkPortalOutlet", ""], [3, "innerHTML", 4, "ngIf"], [1, "ant-modal-confirm-btns"], ["nz-button", "", 3, "nzLoading", "disabled", "click", 4, "ngIf"], ["nz-button", "", 3, "nzType", "nzLoading", "disabled", "click", 4, "ngIf"], ["nz-modal-close", "", 3, "click"], [3, "innerHTML"], ["nz-button", "", 3, "nzLoading", "disabled", "click"], ["nz-button", "", 3, "nzType", "nzLoading", "disabled", "click"]], template: function NzModalConfirmContainerComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵelementStart(0, "div", 0, 1);
            ɵɵpipe(2, "nzToCssUnit");
            ɵɵelementStart(3, "div", 2);
            ɵɵtemplate(4, NzModalConfirmContainerComponent_button_4_Template, 1, 0, "button", 3);
            ɵɵelementStart(5, "div", 4);
            ɵɵelementStart(6, "div", 5);
            ɵɵelementStart(7, "div", 6);
            ɵɵelement(8, "i", 7);
            ɵɵelementStart(9, "span", 8);
            ɵɵtemplate(10, NzModalConfirmContainerComponent_ng_container_10_Template, 2, 1, "ng-container", 9);
            ɵɵelementEnd();
            ɵɵelementStart(11, "div", 10);
            ɵɵtemplate(12, NzModalConfirmContainerComponent_ng_template_12_Template, 0, 0, "ng-template", 11);
            ɵɵtemplate(13, NzModalConfirmContainerComponent_div_13_Template, 1, 1, "div", 12);
            ɵɵelementEnd();
            ɵɵelementEnd();
            ɵɵelementStart(14, "div", 13);
            ɵɵtemplate(15, NzModalConfirmContainerComponent_button_15_Template, 2, 4, "button", 14);
            ɵɵtemplate(16, NzModalConfirmContainerComponent_button_16_Template, 2, 5, "button", 15);
            ɵɵelementEnd();
            ɵɵelementEnd();
            ɵɵelementEnd();
            ɵɵelementEnd();
            ɵɵelementEnd();
        } if (rf & 2) {
            ɵɵclassMap(ctx.config.nzClassName);
            ɵɵstyleProp("width", ɵɵpipeBind1(2, 12, ctx.config == null ? null : ctx.config.nzWidth));
            ɵɵproperty("ngStyle", ctx.config.nzStyle);
            ɵɵadvance(4);
            ɵɵproperty("ngIf", ctx.config.nzClosable);
            ɵɵadvance(1);
            ɵɵproperty("ngStyle", ctx.config.nzBodyStyle);
            ɵɵadvance(3);
            ɵɵproperty("nzType", ctx.config.nzIconType);
            ɵɵadvance(2);
            ɵɵproperty("nzStringTemplateOutlet", ctx.config.nzTitle);
            ɵɵadvance(3);
            ɵɵproperty("ngIf", ctx.isStringContent);
            ɵɵadvance(2);
            ɵɵproperty("ngIf", ctx.config.nzCancelText !== null);
            ɵɵadvance(1);
            ɵɵproperty("ngIf", ctx.config.nzOkText !== null);
        } }, directives: [NgStyle, NgIf, ɵNzTransitionPatchDirective, NzIconDirective, NzStringTemplateOutletDirective, CdkPortalOutlet, NzModalCloseComponent, NzButtonComponent, NzWaveDirective], pipes: [NzToCssUnitPipe], encapsulation: 2, data: { animation: [nzModalAnimations.modalContainer] } });
    return NzModalConfirmContainerComponent;
}(BaseModalContainer));
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalConfirmContainerComponent, [{
        type: Component,
        args: [{
                selector: 'nz-modal-confirm-container',
                exportAs: 'nzModalConfirmContainer',
                template: "\n    <div\n      #modalElement\n      role=\"document\"\n      class=\"ant-modal\"\n      [class]=\"config.nzClassName\"\n      [ngStyle]=\"config.nzStyle\"\n      [style.width]=\"config?.nzWidth | nzToCssUnit\"\n    >\n      <div class=\"ant-modal-content\">\n        <button *ngIf=\"config.nzClosable\" nz-modal-close (click)=\"onCloseClick()\"></button>\n        <div class=\"ant-modal-body\" [ngStyle]=\"config.nzBodyStyle\">\n          <div class=\"ant-modal-confirm-body-wrapper\">\n            <div class=\"ant-modal-confirm-body\">\n              <i nz-icon [nzType]=\"config.nzIconType\"></i>\n              <span class=\"ant-modal-confirm-title\">\n                <ng-container *nzStringTemplateOutlet=\"config.nzTitle\">\n                  <span [innerHTML]=\"config.nzTitle\"></span>\n                </ng-container>\n              </span>\n              <div class=\"ant-modal-confirm-content\">\n                <ng-template cdkPortalOutlet></ng-template>\n                <div *ngIf=\"isStringContent\" [innerHTML]=\"config.nzContent\"></div>\n              </div>\n            </div>\n            <div class=\"ant-modal-confirm-btns\">\n              <button\n                *ngIf=\"config.nzCancelText !== null\"\n                [attr.cdkFocusInitial]=\"config.nzAutofocus === 'cancel'\"\n                nz-button\n                (click)=\"onCancel()\"\n                [nzLoading]=\"config.nzCancelLoading\"\n                [disabled]=\"config.nzCancelDisabled\"\n              >\n                {{ config.nzCancelText || locale.cancelText }}\n              </button>\n              <button\n                *ngIf=\"config.nzOkText !== null\"\n                [attr.cdkFocusInitial]=\"config.nzAutofocus === 'ok'\"\n                nz-button\n                [nzType]=\"config.nzOkType\"\n                (click)=\"onOk()\"\n                [nzLoading]=\"config.nzOkLoading\"\n                [disabled]=\"config.nzOkDisabled\"\n              >\n                {{ config.nzOkText || locale.okText }}\n              </button>\n            </div>\n          </div>\n        </div>\n      </div>\n    </div>\n  ",
                animations: [nzModalAnimations.modalContainer],
                // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x.
                changeDetection: ChangeDetectionStrategy.Default,
                host: {
                    tabindex: '-1',
                    role: 'dialog',
                    class: 'ant-modal-wrap',
                    '[class]': 'config.nzWrapClassName',
                    '[style.zIndex]': 'config.nzZIndex',
                    '[@.disabled]': 'config.nzNoAnimation',
                    '[@modalContainer]': 'state',
                    '(@modalContainer.start)': 'onAnimationStart($event)',
                    '(@modalContainer.done)': 'onAnimationDone($event)',
                    '(mousedown)': 'onMousedown($event)',
                    '(mouseup)': 'onMouseup($event)'
                }
            }]
    }], function () { return [{ type: NzI18nService }, { type: ElementRef }, { type: FocusTrapFactory }, { type: ChangeDetectorRef }, { type: Renderer2 }, { type: NgZone }, { type: OverlayRef }, { type: ModalOptions }, { type: undefined, decorators: [{
                type: Optional
            }, {
                type: Inject,
                args: [DOCUMENT]
            }] }, { type: undefined, decorators: [{
                type: Optional
            }, {
                type: Inject,
                args: [ANIMATION_MODULE_TYPE]
            }] }]; }, { portalOutlet: [{
            type: ViewChild,
            args: [CdkPortalOutlet, { static: true }]
        }], modalElementRef: [{
            type: ViewChild,
            args: ['modalElement', { static: true }]
        }], cancelTriggered: [{
            type: Output
        }], okTriggered: [{
            type: Output
        }] }); })();

/**
 * @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 _c0$2 = ["nz-modal-title", ""];
function NzModalTitleComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵelement(1, "div", 2);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1997 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵproperty("innerHTML", ctx_r1997.config.nzTitle, ɵɵsanitizeHtml);
} }
var NzModalTitleComponent = /** @class */ (function () {
    function NzModalTitleComponent(config) {
        this.config = config;
    }
    /** @nocollapse */ NzModalTitleComponent.ɵfac = function NzModalTitleComponent_Factory(t) { return new (t || NzModalTitleComponent)(ɵɵdirectiveInject(ModalOptions)); };
    /** @nocollapse */ NzModalTitleComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalTitleComponent, selectors: [["div", "nz-modal-title", ""]], hostAttrs: [1, "ant-modal-header"], exportAs: ["NzModalTitleBuiltin"], attrs: _c0$2, decls: 2, vars: 1, consts: [[1, "ant-modal-title"], [4, "nzStringTemplateOutlet"], [3, "innerHTML"]], template: function NzModalTitleComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵelementStart(0, "div", 0);
            ɵɵtemplate(1, NzModalTitleComponent_ng_container_1_Template, 2, 1, "ng-container", 1);
            ɵɵelementEnd();
        } if (rf & 2) {
            ɵɵadvance(1);
            ɵɵproperty("nzStringTemplateOutlet", ctx.config.nzTitle);
        } }, directives: [NzStringTemplateOutletDirective], encapsulation: 2, changeDetection: 0 });
    return NzModalTitleComponent;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalTitleComponent, [{
        type: Component,
        args: [{
                selector: 'div[nz-modal-title]',
                exportAs: 'NzModalTitleBuiltin',
                template: "\n    <div class=\"ant-modal-title\">\n      <ng-container *nzStringTemplateOutlet=\"config.nzTitle\">\n        <div [innerHTML]=\"config.nzTitle\"></div>\n      </ng-container>\n    </div>\n  ",
                host: {
                    class: 'ant-modal-header'
                },
                changeDetection: ChangeDetectionStrategy.OnPush
            }]
    }], function () { return [{ type: ModalOptions }]; }, 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
 */
// tslint:disable-next-line:no-any
var NzModalRef = /** @class */ (function () {
    function NzModalRef(overlayRef, config, containerInstance) {
        var _this = this;
        this.overlayRef = overlayRef;
        this.config = config;
        this.containerInstance = containerInstance;
        this.state = 0 /* OPEN */;
        this.afterClose = new Subject();
        this.afterOpen = new Subject();
        containerInstance.animationStateChanged
            .pipe(filter(function (event) { return event.phaseName === 'done' && event.toState === 'enter'; }), take(1))
            .subscribe(function () {
            _this.afterOpen.next();
            _this.afterOpen.complete();
            if (config.nzAfterOpen instanceof EventEmitter) {
                config.nzAfterOpen.emit();
            }
        });
        containerInstance.animationStateChanged
            .pipe(filter(function (event) { return event.phaseName === 'done' && event.toState === 'exit'; }), take(1))
            .subscribe(function () {
            clearTimeout(_this.closeTimeout);
            _this.overlayRef.dispose();
        });
        containerInstance.containerClick.pipe(take(1)).subscribe(function () {
            var cancelable = !_this.config.nzCancelLoading && !_this.config.nzOkLoading && config.nzMask && config.nzMaskClosable;
            if (cancelable) {
                _this.trigger("cancel" /* CANCEL */);
            }
        });
        overlayRef
            .keydownEvents()
            .pipe(filter(function (event) {
            return (_this.config.nzKeyboard &&
                !_this.config.nzCancelLoading &&
                !_this.config.nzOkLoading &&
                event.keyCode === ESCAPE &&
                !hasModifierKey(event));
        }))
            .subscribe(function (event) {
            event.preventDefault();
            _this.trigger("cancel" /* CANCEL */);
        });
        containerInstance.cancelTriggered.subscribe(function () { return _this.trigger("cancel" /* CANCEL */); });
        containerInstance.okTriggered.subscribe(function () { return _this.trigger("ok" /* OK */); });
        overlayRef.detachments().subscribe(function () {
            _this.afterClose.next(_this.result);
            _this.afterClose.complete();
            if (config.nzAfterClose instanceof EventEmitter) {
                config.nzAfterClose.emit(_this.result);
            }
            _this.componentInstance = null;
            _this.overlayRef.dispose();
        });
    }
    NzModalRef.prototype.getContentComponent = function () {
        return this.componentInstance;
    };
    NzModalRef.prototype.getElement = function () {
        return this.containerInstance.getNativeElement();
    };
    NzModalRef.prototype.destroy = function (result) {
        this.close(result);
    };
    NzModalRef.prototype.triggerOk = function () {
        this.trigger("ok" /* OK */);
    };
    NzModalRef.prototype.triggerCancel = function () {
        this.trigger("cancel" /* CANCEL */);
    };
    /**
     * Open the modal.
     * @deprecated Opened when create, this method is useless.
     * @breaking-change 10.0.0
     */
    NzModalRef.prototype.open = function () {
        // noop
    };
    NzModalRef.prototype.close = function (result) {
        var _this = this;
        this.result = result;
        this.containerInstance.animationStateChanged
            .pipe(filter(function (event) { return event.phaseName === 'start'; }), take(1))
            .subscribe(function (event) {
            _this.state = 2 /* CLOSED */;
            _this.overlayRef.detachBackdrop();
            _this.closeTimeout = setTimeout(function () {
                _this.overlayRef.dispose();
            }, event.totalTime + 100);
        });
        this.containerInstance.startExitAnimation();
        this.state = 1 /* CLOSING */;
    };
    NzModalRef.prototype.updateConfig = function (config) {
        Object.assign(this.config, config);
        this.containerInstance.cdr.markForCheck();
    };
    NzModalRef.prototype.getState = function () {
        return this.state;
    };
    NzModalRef.prototype.getConfig = function () {
        return this.config;
    };
    NzModalRef.prototype.getBackdropElement = function () {
        return this.overlayRef.backdropElement;
    };
    NzModalRef.prototype.trigger = function (action) {
        var _this = this;
        var trigger = { ok: this.config.nzOnOk, cancel: this.config.nzOnCancel }[action];
        var loadingKey = { ok: 'nzOkLoading', cancel: 'nzCancelLoading' }[action];
        var loading = this.config[loadingKey];
        if (loading) {
            return;
        }
        if (trigger instanceof EventEmitter) {
            trigger.emit(this.getContentComponent());
        }
        else if (typeof trigger === 'function') {
            var result = trigger(this.getContentComponent());
            var caseClose = function (doClose) { return doClose !== false && _this.close(doClose); };
            if (isPromise(result)) {
                this.config[loadingKey] = true;
                var handleThen = function (doClose) {
                    _this.config[loadingKey] = false;
                    _this.closeWhitResult(doClose);
                };
                result.then(handleThen).catch(handleThen);
            }
            else {
                caseClose(result);
            }
        }
    };
    // tslint:disable-next-line:no-any
    NzModalRef.prototype.closeWhitResult = function (result) {
        if (result !== false) {
            this.close(result);
        }
    };
    return NzModalRef;
}());

var _c0$3 = ["nz-modal-footer", ""];
function NzModalFooterComponent_ng_container_0_ng_container_1_div_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelement(0, "div", 5);
} if (rf & 2) {
    var ctx_r1985 = ɵɵnextContext(3);
    ɵɵproperty("innerHTML", ctx_r1985.config.nzTitle, ɵɵsanitizeHtml);
} }
function NzModalFooterComponent_ng_container_0_ng_container_1_ng_container_2_button_1_Template(rf, ctx) { if (rf & 1) {
    var _r1990 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 7);
    ɵɵlistener("click", function NzModalFooterComponent_ng_container_0_ng_container_1_ng_container_2_button_1_Template_button_click_0_listener() { ɵɵrestoreView(_r1990); var button_r1988 = ctx.$implicit; var ctx_r1989 = ɵɵnextContext(4); return ctx_r1989.onButtonClick(button_r1988); });
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var button_r1988 = ctx.$implicit;
    var ctx_r1987 = ɵɵnextContext(4);
    ɵɵproperty("hidden", !ctx_r1987.getButtonCallableProp(button_r1988, "show"))("nzLoading", ctx_r1987.getButtonCallableProp(button_r1988, "loading"))("disabled", ctx_r1987.getButtonCallableProp(button_r1988, "disabled"))("nzType", button_r1988.type)("nzShape", button_r1988.shape)("nzSize", button_r1988.size)("nzGhost", button_r1988.ghost);
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", button_r1988.label, " ");
} }
function NzModalFooterComponent_ng_container_0_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzModalFooterComponent_ng_container_0_ng_container_1_ng_container_2_button_1_Template, 2, 8, "button", 6);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1986 = ɵɵnextContext(3);
    ɵɵadvance(1);
    ɵɵproperty("ngForOf", ctx_r1986.buttons);
} }
function NzModalFooterComponent_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzModalFooterComponent_ng_container_0_ng_container_1_div_1_Template, 1, 1, "div", 3);
    ɵɵtemplate(2, NzModalFooterComponent_ng_container_0_ng_container_1_ng_container_2_Template, 2, 1, "ng-container", 4);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1984 = ɵɵnextContext(2);
    ɵɵadvance(1);
    ɵɵproperty("ngIf", !ctx_r1984.buttonsFooter);
    ɵɵadvance(1);
    ɵɵproperty("ngIf", ctx_r1984.buttonsFooter);
} }
function NzModalFooterComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    ɵɵelementContainerStart(0);
    ɵɵtemplate(1, NzModalFooterComponent_ng_container_0_ng_container_1_Template, 3, 2, "ng-container", 2);
    ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r1981 = ɵɵnextContext();
    ɵɵadvance(1);
    ɵɵproperty("nzStringTemplateOutlet", ctx_r1981.config.nzFooter);
} }
function NzModalFooterComponent_ng_template_1_button_0_Template(rf, ctx) { if (rf & 1) {
    var _r1994 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 10);
    ɵɵlistener("click", function NzModalFooterComponent_ng_template_1_button_0_Template_button_click_0_listener() { ɵɵrestoreView(_r1994); var ctx_r1993 = ɵɵnextContext(2); return ctx_r1993.onCancel(); });
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1991 = ɵɵnextContext(2);
    ɵɵproperty("nzLoading", ctx_r1991.config.nzCancelLoading)("disabled", ctx_r1991.config.nzCancelDisabled);
    ɵɵattribute("cdkFocusInitial", ctx_r1991.config.nzAutofocus === "cancel");
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", ctx_r1991.config.nzCancelText || ctx_r1991.locale.cancelText, " ");
} }
function NzModalFooterComponent_ng_template_1_button_1_Template(rf, ctx) { if (rf & 1) {
    var _r1996 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 11);
    ɵɵlistener("click", function NzModalFooterComponent_ng_template_1_button_1_Template_button_click_0_listener() { ɵɵrestoreView(_r1996); var ctx_r1995 = ɵɵnextContext(2); return ctx_r1995.onOk(); });
    ɵɵtext(1);
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1992 = ɵɵnextContext(2);
    ɵɵproperty("nzType", ctx_r1992.config.nzOkType)("nzLoading", ctx_r1992.config.nzOkLoading)("disabled", ctx_r1992.config.nzOkDisabled);
    ɵɵattribute("cdkFocusInitial", ctx_r1992.config.nzAutofocus === "ok");
    ɵɵadvance(1);
    ɵɵtextInterpolate1(" ", ctx_r1992.config.nzOkText || ctx_r1992.locale.okText, " ");
} }
function NzModalFooterComponent_ng_template_1_Template(rf, ctx) { if (rf & 1) {
    ɵɵtemplate(0, NzModalFooterComponent_ng_template_1_button_0_Template, 2, 4, "button", 8);
    ɵɵtemplate(1, NzModalFooterComponent_ng_template_1_button_1_Template, 2, 5, "button", 9);
} if (rf & 2) {
    var ctx_r1983 = ɵɵnextContext();
    ɵɵproperty("ngIf", ctx_r1983.config.nzCancelText !== null);
    ɵɵadvance(1);
    ɵɵproperty("ngIf", ctx_r1983.config.nzOkText !== null);
} }
var NzModalFooterComponent = /** @class */ (function () {
    function NzModalFooterComponent(i18n, config) {
        var _this = this;
        this.i18n = i18n;
        this.config = config;
        this.buttonsFooter = false;
        this.buttons = [];
        this.locale = {};
        this.cancelTriggered = new EventEmitter();
        this.okTriggered = new EventEmitter();
        this.destroy$ = new Subject();
        if (Array.isArray(config.nzFooter)) {
            this.buttonsFooter = true;
            this.buttons = config.nzFooter.map(mergeDefaultOption);
        }
        this.i18n.localeChange.pipe(takeUntil(this.destroy$)).subscribe(function () {
            _this.locale = _this.i18n.getLocaleData('Modal');
        });
    }
    NzModalFooterComponent.prototype.onCancel = function () {
        this.cancelTriggered.emit();
    };
    NzModalFooterComponent.prototype.onOk = function () {
        this.okTriggered.emit();
    };
    /**
     * Returns the value of the specified key.
     * If it is a function, run and return the return value of the function.
     * @deprecated Not support use function type.
     * @breaking-change 10.0.0
     */
    NzModalFooterComponent.prototype.getButtonCallableProp = function (options, prop) {
        var value = options[prop];
        var componentInstance = this.modalRef.getContentComponent();
        return typeof value === 'function' ? value.apply(options, componentInstance && [componentInstance]) : value;
    };
    /**
     * Run function based on the type and set its `loading` prop if needed.
     * @deprecated Should be set options' value by the user, not library.
     * @breaking-change 10.0.0
     */
    NzModalFooterComponent.prototype.onButtonClick = function (options) {
        var loading = this.getButtonCallableProp(options, 'loading');
        if (!loading) {
            var result = this.getButtonCallableProp(options, 'onClick');
            if (options.autoLoading && isPromise(result)) {
                options.loading = true;
                result.then(function () { return (options.loading = false); }).catch(function () { return (options.loading = false); });
            }
        }
    };
    NzModalFooterComponent.prototype.ngOnDestroy = function () {
        this.destroy$.next();
        this.destroy$.complete();
    };
    /** @nocollapse */ NzModalFooterComponent.ɵfac = function NzModalFooterComponent_Factory(t) { return new (t || NzModalFooterComponent)(ɵɵdirectiveInject(NzI18nService), ɵɵdirectiveInject(ModalOptions)); };
    /** @nocollapse */ NzModalFooterComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalFooterComponent, selectors: [["div", "nz-modal-footer", ""]], hostAttrs: [1, "ant-modal-footer"], inputs: { modalRef: "modalRef" }, outputs: { cancelTriggered: "cancelTriggered", okTriggered: "okTriggered" }, exportAs: ["NzModalFooterBuiltin"], attrs: _c0$3, decls: 3, vars: 2, consts: [[4, "ngIf", "ngIfElse"], ["defaultFooterButtons", ""], [4, "nzStringTemplateOutlet"], [3, "innerHTML", 4, "ngIf"], [4, "ngIf"], [3, "innerHTML"], ["nz-button", "", 3, "hidden", "nzLoading", "disabled", "nzType", "nzShape", "nzSize", "nzGhost", "click", 4, "ngFor", "ngForOf"], ["nz-button", "", 3, "hidden", "nzLoading", "disabled", "nzType", "nzShape", "nzSize", "nzGhost", "click"], ["nz-button", "", 3, "nzLoading", "disabled", "click", 4, "ngIf"], ["nz-button", "", 3, "nzType", "nzLoading", "disabled", "click", 4, "ngIf"], ["nz-button", "", 3, "nzLoading", "disabled", "click"], ["nz-button", "", 3, "nzType", "nzLoading", "disabled", "click"]], template: function NzModalFooterComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵtemplate(0, NzModalFooterComponent_ng_container_0_Template, 2, 1, "ng-container", 0);
            ɵɵtemplate(1, NzModalFooterComponent_ng_template_1_Template, 2, 2, "ng-template", null, 1, ɵɵtemplateRefExtractor);
        } if (rf & 2) {
            var _r1982 = ɵɵreference(2);
            ɵɵproperty("ngIf", ctx.config.nzFooter)("ngIfElse", _r1982);
        } }, directives: [NgIf, NzStringTemplateOutletDirective, NgForOf, NzButtonComponent, NzWaveDirective, ɵNzTransitionPatchDirective], encapsulation: 2 });
    return NzModalFooterComponent;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalFooterComponent, [{
        type: Component,
        args: [{
                selector: 'div[nz-modal-footer]',
                exportAs: 'NzModalFooterBuiltin',
                template: "\n    <ng-container *ngIf=\"config.nzFooter; else defaultFooterButtons\">\n      <ng-container *nzStringTemplateOutlet=\"config.nzFooter\">\n        <div *ngIf=\"!buttonsFooter\" [innerHTML]=\"config.nzTitle\"></div>\n        <ng-container *ngIf=\"buttonsFooter\">\n          <button\n            *ngFor=\"let button of buttons\"\n            nz-button\n            (click)=\"onButtonClick(button)\"\n            [hidden]=\"!getButtonCallableProp(button, 'show')\"\n            [nzLoading]=\"getButtonCallableProp(button, 'loading')\"\n            [disabled]=\"getButtonCallableProp(button, 'disabled')\"\n            [nzType]=\"button.type\"\n            [nzShape]=\"button.shape\"\n            [nzSize]=\"button.size\"\n            [nzGhost]=\"button.ghost\"\n          >\n            {{ button.label }}\n          </button>\n        </ng-container>\n      </ng-container>\n    </ng-container>\n    <ng-template #defaultFooterButtons>\n      <button\n        *ngIf=\"config.nzCancelText !== null\"\n        [attr.cdkFocusInitial]=\"config.nzAutofocus === 'cancel'\"\n        nz-button\n        (click)=\"onCancel()\"\n        [nzLoading]=\"config.nzCancelLoading\"\n        [disabled]=\"config.nzCancelDisabled\"\n      >\n        {{ config.nzCancelText || locale.cancelText }}\n      </button>\n      <button\n        *ngIf=\"config.nzOkText !== null\"\n        [attr.cdkFocusInitial]=\"config.nzAutofocus === 'ok'\"\n        nz-button\n        [nzType]=\"config.nzOkType\"\n        (click)=\"onOk()\"\n        [nzLoading]=\"config.nzOkLoading\"\n        [disabled]=\"config.nzOkDisabled\"\n      >\n        {{ config.nzOkText || locale.okText }}\n      </button>\n    </ng-template>\n  ",
                host: {
                    class: 'ant-modal-footer'
                },
                changeDetection: ChangeDetectionStrategy.Default
            }]
    }], function () { return [{ type: NzI18nService }, { type: ModalOptions }]; }, { cancelTriggered: [{
            type: Output
        }], okTriggered: [{
            type: Output
        }], modalRef: [{
            type: Input
        }] }); })();
function mergeDefaultOption(options) {
    return __assign({ type: null, size: 'default', autoLoading: true, show: true, loading: false, disabled: false }, options);
}

var _c0$4 = ["modalElement"];
function NzModalContainerComponent_button_4_Template(rf, ctx) { if (rf & 1) {
    var _r1975 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "button", 9);
    ɵɵlistener("click", function NzModalContainerComponent_button_4_Template_button_click_0_listener() { ɵɵrestoreView(_r1975); var ctx_r1974 = ɵɵnextContext(); return ctx_r1974.onCloseClick(); });
    ɵɵelementEnd();
} }
function NzModalContainerComponent_div_5_Template(rf, ctx) { if (rf & 1) {
    ɵɵelement(0, "div", 10);
} }
function NzModalContainerComponent_ng_template_7_Template(rf, ctx) { }
function NzModalContainerComponent_div_8_Template(rf, ctx) { if (rf & 1) {
    ɵɵelement(0, "div", 11);
} if (rf & 2) {
    var ctx_r1972 = ɵɵnextContext();
    ɵɵproperty("innerHTML", ctx_r1972.config.nzContent, ɵɵsanitizeHtml);
} }
function NzModalContainerComponent_div_9_Template(rf, ctx) { if (rf & 1) {
    var _r1977 = ɵɵgetCurrentView();
    ɵɵelementStart(0, "div", 12);
    ɵɵlistener("cancelTriggered", function NzModalContainerComponent_div_9_Template_div_cancelTriggered_0_listener() { ɵɵrestoreView(_r1977); var ctx_r1976 = ɵɵnextContext(); return ctx_r1976.onCloseClick(); })("okTriggered", function NzModalContainerComponent_div_9_Template_div_okTriggered_0_listener() { ɵɵrestoreView(_r1977); var ctx_r1978 = ɵɵnextContext(); return ctx_r1978.onOkClick(); });
    ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r1973 = ɵɵnextContext();
    ɵɵproperty("modalRef", ctx_r1973.modalRef);
} }
var NzModalContainerComponent = /** @class */ (function (_super) {
    __extends(NzModalContainerComponent, _super);
    function NzModalContainerComponent(elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, 
    // tslint:disable-next-line:no-any
    document, animationType) {
        var _this = _super.call(this, elementRef, focusTrapFactory, cdr, render, zone, overlayRef, config, document, animationType) || this;
        _this.config = config;
        return _this;
    }
    /** @nocollapse */ NzModalContainerComponent.ɵfac = function NzModalContainerComponent_Factory(t) { return new (t || NzModalContainerComponent)(ɵɵdirectiveInject(ElementRef), ɵɵdirectiveInject(FocusTrapFactory), ɵɵdirectiveInject(ChangeDetectorRef), ɵɵdirectiveInject(Renderer2), ɵɵdirectiveInject(NgZone), ɵɵdirectiveInject(OverlayRef), ɵɵdirectiveInject(ModalOptions), ɵɵdirectiveInject(DOCUMENT, 8), ɵɵdirectiveInject(ANIMATION_MODULE_TYPE, 8)); };
    /** @nocollapse */ NzModalContainerComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalContainerComponent, selectors: [["nz-modal-container"]], viewQuery: function NzModalContainerComponent_Query(rf, ctx) { if (rf & 1) {
            ɵɵstaticViewQuery(CdkPortalOutlet, true);
            ɵɵstaticViewQuery(_c0$4, true);
        } if (rf & 2) {
            var _t;
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.portalOutlet = _t.first);
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.modalElementRef = _t.first);
        } }, hostAttrs: ["tabindex", "-1", "role", "dialog", 1, "ant-modal-wrap"], hostVars: 6, hostBindings: function NzModalContainerComponent_HostBindings(rf, ctx) { if (rf & 1) {
            ɵɵcomponentHostSyntheticListener("@modalContainer.start", function NzModalContainerComponent_animation_modalContainer_start_HostBindingHandler($event) { return ctx.onAnimationStart($event); })("@modalContainer.done", function NzModalContainerComponent_animation_modalContainer_done_HostBindingHandler($event) { return ctx.onAnimationDone($event); });
            ɵɵlistener("mousedown", function NzModalContainerComponent_mousedown_HostBindingHandler($event) { return ctx.onMousedown($event); })("mouseup", function NzModalContainerComponent_mouseup_HostBindingHandler($event) { return ctx.onMouseup($event); });
        } if (rf & 2) {
            ɵɵupdateSyntheticHostBinding("@.disabled", ctx.config.nzNoAnimation)("@modalContainer", ctx.state);
            ɵɵclassMap(ctx.config.nzWrapClassName);
            ɵɵstyleProp("z-index", ctx.config.nzZIndex);
        } }, exportAs: ["nzModalContainer"], features: [ɵɵInheritDefinitionFeature], decls: 10, vars: 12, consts: [["role", "document", 1, "ant-modal", 3, "ngStyle"], ["modalElement", ""], [1, "ant-modal-content"], ["nz-modal-close", "", 3, "click", 4, "ngIf"], ["nz-modal-title", "", 4, "ngIf"], [1, "ant-modal-body", 3, "ngStyle"], ["cdkPortalOutlet", ""], [3, "innerHTML", 4, "ngIf"], ["nz-modal-footer", "", 3, "modalRef", "cancelTriggered", "okTriggered", 4, "ngIf"], ["nz-modal-close", "", 3, "click"], ["nz-modal-title", ""], [3, "innerHTML"], ["nz-modal-footer", "", 3, "modalRef", "cancelTriggered", "okTriggered"]], template: function NzModalContainerComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵelementStart(0, "div", 0, 1);
            ɵɵpipe(2, "nzToCssUnit");
            ɵɵelementStart(3, "div", 2);
            ɵɵtemplate(4, NzModalContainerComponent_button_4_Template, 1, 0, "button", 3);
            ɵɵtemplate(5, NzModalContainerComponent_div_5_Template, 1, 0, "div", 4);
            ɵɵelementStart(6, "div", 5);
            ɵɵtemplate(7, NzModalContainerComponent_ng_template_7_Template, 0, 0, "ng-template", 6);
            ɵɵtemplate(8, NzModalContainerComponent_div_8_Template, 1, 1, "div", 7);
            ɵɵelementEnd();
            ɵɵtemplate(9, NzModalContainerComponent_div_9_Template, 1, 1, "div", 8);
            ɵɵelementEnd();
            ɵɵelementEnd();
        } if (rf & 2) {
            ɵɵclassMap(ctx.config.nzClassName);
            ɵɵstyleProp("width", ɵɵpipeBind1(2, 10, ctx.config == null ? null : ctx.config.nzWidth));
            ɵɵproperty("ngStyle", ctx.config.nzStyle);
            ɵɵadvance(4);
            ɵɵproperty("ngIf", ctx.config.nzClosable);
            ɵɵadvance(1);
            ɵɵproperty("ngIf", ctx.config.nzTitle);
            ɵɵadvance(1);
            ɵɵproperty("ngStyle", ctx.config.nzBodyStyle);
            ɵɵadvance(2);
            ɵɵproperty("ngIf", ctx.isStringContent);
            ɵɵadvance(1);
            ɵɵproperty("ngIf", ctx.config.nzFooter !== null);
        } }, directives: [NgStyle, NgIf, CdkPortalOutlet, NzModalCloseComponent, NzModalTitleComponent, NzModalFooterComponent], pipes: [NzToCssUnitPipe], encapsulation: 2, data: { animation: [nzModalAnimations.modalContainer] } });
    return NzModalContainerComponent;
}(BaseModalContainer));
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalContainerComponent, [{
        type: Component,
        args: [{
                selector: 'nz-modal-container',
                exportAs: 'nzModalContainer',
                template: "\n    <div\n      #modalElement\n      role=\"document\"\n      class=\"ant-modal\"\n      [class]=\"config.nzClassName\"\n      [ngStyle]=\"config.nzStyle\"\n      [style.width]=\"config?.nzWidth | nzToCssUnit\"\n    >\n      <div class=\"ant-modal-content\">\n        <button *ngIf=\"config.nzClosable\" nz-modal-close (click)=\"onCloseClick()\"></button>\n        <div *ngIf=\"config.nzTitle\" nz-modal-title></div>\n        <div class=\"ant-modal-body\" [ngStyle]=\"config.nzBodyStyle\">\n          <ng-template cdkPortalOutlet></ng-template>\n          <div *ngIf=\"isStringContent\" [innerHTML]=\"config.nzContent\"></div>\n        </div>\n        <div\n          *ngIf=\"config.nzFooter !== null\"\n          nz-modal-footer\n          [modalRef]=\"modalRef\"\n          (cancelTriggered)=\"onCloseClick()\"\n          (okTriggered)=\"onOkClick()\"\n        ></div>\n      </div>\n    </div>\n  ",
                animations: [nzModalAnimations.modalContainer],
                // Using OnPush for modal caused footer can not to detect changes. we can fix it when 8.x.
                changeDetection: ChangeDetectionStrategy.Default,
                host: {
                    tabindex: '-1',
                    role: 'dialog',
                    class: 'ant-modal-wrap',
                    '[class]': 'config.nzWrapClassName',
                    '[style.zIndex]': 'config.nzZIndex',
                    '[@.disabled]': 'config.nzNoAnimation',
                    '[@modalContainer]': 'state',
                    '(@modalContainer.start)': 'onAnimationStart($event)',
                    '(@modalContainer.done)': 'onAnimationDone($event)',
                    '(mousedown)': 'onMousedown($event)',
                    '(mouseup)': 'onMouseup($event)'
                }
            }]
    }], function () { return [{ type: ElementRef }, { type: FocusTrapFactory }, { type: ChangeDetectorRef }, { type: Renderer2 }, { type: NgZone }, { type: OverlayRef }, { type: ModalOptions }, { type: undefined, decorators: [{
                type: Optional
            }, {
                type: Inject,
                args: [DOCUMENT]
            }] }, { type: undefined, decorators: [{
                type: Optional
            }, {
                type: Inject,
                args: [ANIMATION_MODULE_TYPE]
            }] }]; }, { portalOutlet: [{
            type: ViewChild,
            args: [CdkPortalOutlet, { static: true }]
        }], modalElementRef: [{
            type: ViewChild,
            args: ['modalElement', { static: true }]
        }] }); })();

/**
 * @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
 */
function applyConfigDefaults(config, defaultOptions) {
    return __assign(__assign({}, defaultOptions), config);
}
/**
 * Assign the params into the content component instance.
 * @deprecated Should use dependency injection to get the params for user
 * @breaking-change 10.0.0
 */
function setContentInstanceParams(instance, 
// tslint:disable-next-line:no-any
params) {
    Object.assign(instance, params);
}
function getConfigFromComponent(component) {
    var nzMask = component.nzMask, nzMaskClosable = component.nzMaskClosable, nzClosable = component.nzClosable, nzOkLoading = component.nzOkLoading, nzOkDisabled = component.nzOkDisabled, nzCancelDisabled = component.nzCancelDisabled, nzCancelLoading = component.nzCancelLoading, nzKeyboard = component.nzKeyboard, nzNoAnimation = component.nzNoAnimation, nzContent = component.nzContent, nzComponentParams = component.nzComponentParams, nzFooter = component.nzFooter, nzGetContainer = component.nzGetContainer, nzZIndex = component.nzZIndex, nzWidth = component.nzWidth, nzWrapClassName = component.nzWrapClassName, nzClassName = component.nzClassName, nzStyle = component.nzStyle, nzTitle = component.nzTitle, nzCloseIcon = component.nzCloseIcon, nzMaskStyle = component.nzMaskStyle, nzBodyStyle = component.nzBodyStyle, nzOkText = component.nzOkText, nzCancelText = component.nzCancelText, nzOkType = component.nzOkType, nzIconType = component.nzIconType, nzModalType = component.nzModalType, nzOnOk = component.nzOnOk, nzOnCancel = component.nzOnCancel, nzAfterOpen = component.nzAfterOpen, nzAfterClose = component.nzAfterClose;
    return {
        nzMask: nzMask,
        nzMaskClosable: nzMaskClosable,
        nzClosable: nzClosable,
        nzOkLoading: nzOkLoading,
        nzOkDisabled: nzOkDisabled,
        nzCancelDisabled: nzCancelDisabled,
        nzCancelLoading: nzCancelLoading,
        nzKeyboard: nzKeyboard,
        nzNoAnimation: nzNoAnimation,
        nzContent: nzContent,
        nzComponentParams: nzComponentParams,
        nzFooter: nzFooter,
        nzGetContainer: nzGetContainer,
        nzZIndex: nzZIndex,
        nzWidth: nzWidth,
        nzWrapClassName: nzWrapClassName,
        nzClassName: nzClassName,
        nzStyle: nzStyle,
        nzTitle: nzTitle,
        nzCloseIcon: nzCloseIcon,
        nzMaskStyle: nzMaskStyle,
        nzBodyStyle: nzBodyStyle,
        nzOkText: nzOkText,
        nzCancelText: nzCancelText,
        nzOkType: nzOkType,
        nzIconType: nzIconType,
        nzModalType: nzModalType,
        nzOnOk: nzOnOk,
        nzOnCancel: nzOnCancel,
        nzAfterOpen: nzAfterOpen,
        nzAfterClose: nzAfterClose
    };
}

/**
 * @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 MODAL_MASK_CLASS_NAME = 'ant-modal-mask';
var NzModalService = /** @class */ (function () {
    function NzModalService(overlay, injector, parentModal) {
        var _this = this;
        this.overlay = overlay;
        this.injector = injector;
        this.parentModal = parentModal;
        this.openModalsAtThisLevel = [];
        this.afterAllClosedAtThisLevel = new Subject();
        this.afterAllClose = defer(function () {
            return _this.openModals.length ? _this._afterAllClosed : _this._afterAllClosed.pipe(startWith(undefined));
        });
    }
    Object.defineProperty(NzModalService.prototype, "openModals", {
        get: function () {
            return this.parentModal ? this.parentModal.openModals : this.openModalsAtThisLevel;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzModalService.prototype, "_afterAllClosed", {
        get: function () {
            var parent = this.parentModal;
            return parent ? parent._afterAllClosed : this.afterAllClosedAtThisLevel;
        },
        enumerable: true,
        configurable: true
    });
    // tslint:disable-next-line:no-any
    NzModalService.prototype.create = function (config) {
        return this.open(config.nzContent, config);
    };
    NzModalService.prototype.closeAll = function () {
        this.closeModals(this.openModals);
    };
    NzModalService.prototype.confirm = function (options, confirmType) {
        if (options === void 0) { options = {}; }
        if (confirmType === void 0) { confirmType = 'confirm'; }
        if ('nzFooter' in options) {
            warn("The Confirm-Modal doesn't support \"nzFooter\", this property will be ignored.");
        }
        if (!('nzWidth' in options)) {
            options.nzWidth = 416;
        }
        if (!('nzMaskClosable' in options)) {
            options.nzMaskClosable = false;
        }
        options.nzModalType = 'confirm';
        options.nzClassName = "ant-modal-confirm ant-modal-confirm-" + confirmType + " " + (options.nzClassName || '');
        return this.create(options);
    };
    NzModalService.prototype.info = function (options) {
        if (options === void 0) { options = {}; }
        return this.confirmFactory(options, 'info');
    };
    NzModalService.prototype.success = function (options) {
        if (options === void 0) { options = {}; }
        return this.confirmFactory(options, 'success');
    };
    NzModalService.prototype.error = function (options) {
        if (options === void 0) { options = {}; }
        return this.confirmFactory(options, 'error');
    };
    NzModalService.prototype.warning = function (options) {
        if (options === void 0) { options = {}; }
        return this.confirmFactory(options, 'warning');
    };
    NzModalService.prototype.open = function (componentOrTemplateRef, config) {
        var _this = this;
        var configMerged = applyConfigDefaults(config || {}, new ModalOptions());
        var overlayRef = this.createOverlay(configMerged);
        var modalContainer = this.attachModalContainer(overlayRef, configMerged);
        var modalRef = this.attachModalContent(componentOrTemplateRef, modalContainer, overlayRef, configMerged);
        modalContainer.modalRef = modalRef;
        this.openModals.push(modalRef);
        modalRef.afterClose.subscribe(function () { return _this.removeOpenModal(modalRef); });
        return modalRef;
    };
    NzModalService.prototype.removeOpenModal = function (modalRef) {
        var index = this.openModals.indexOf(modalRef);
        if (index > -1) {
            this.openModals.splice(index, 1);
            if (!this.openModals.length) {
                this._afterAllClosed.next();
            }
        }
    };
    NzModalService.prototype.closeModals = function (dialogs) {
        var i = dialogs.length;
        while (i--) {
            dialogs[i].close();
            if (!this.openModals.length) {
                this._afterAllClosed.next();
            }
        }
    };
    NzModalService.prototype.createOverlay = function (config) {
        var overlayConfig = new OverlayConfig({
            hasBackdrop: true,
            scrollStrategy: this.overlay.scrollStrategies.block(),
            positionStrategy: this.overlay.position().global(),
            disposeOnNavigation: config.nzCloseOnNavigation
        });
        if (config.nzMask) {
            overlayConfig.backdropClass = MODAL_MASK_CLASS_NAME;
        }
        return this.overlay.create(overlayConfig);
    };
    NzModalService.prototype.attachModalContainer = function (overlayRef, config) {
        var userInjector = config && config.nzViewContainerRef && config.nzViewContainerRef.injector;
        var injector = new PortalInjector(userInjector || this.injector, 
        // tslint:disable-next-line:no-any
        new WeakMap([
            [OverlayRef, overlayRef],
            [ModalOptions, config]
        ]));
        var ContainerComponent = config.nzModalType === 'confirm'
            ? // If the mode is `confirm`, use `NzModalConfirmContainerComponent`
                NzModalConfirmContainerComponent
            : // If the mode is not `confirm`, use `NzModalContainerComponent`
                NzModalContainerComponent;
        var containerPortal = new ComponentPortal(ContainerComponent, config.nzViewContainerRef, injector);
        var containerRef = overlayRef.attach(containerPortal);
        return containerRef.instance;
    };
    NzModalService.prototype.attachModalContent = function (componentOrTemplateRef, modalContainer, overlayRef, config) {
        var modalRef = new NzModalRef(overlayRef, config, modalContainer);
        if (componentOrTemplateRef instanceof TemplateRef) {
            modalContainer.attachTemplatePortal(
            // tslint:disable-next-line:no-any
            new TemplatePortal(componentOrTemplateRef, null, { $implicit: config.nzComponentParams, modalRef: modalRef }));
        }
        else if (isNotNil(componentOrTemplateRef) && typeof componentOrTemplateRef !== 'string') {
            var injector = this.createInjector(modalRef, config);
            var contentRef = modalContainer.attachComponentPortal(new ComponentPortal(componentOrTemplateRef, config.nzViewContainerRef, injector));
            setContentInstanceParams(contentRef.instance, config.nzComponentParams);
            modalRef.componentInstance = contentRef.instance;
        }
        return modalRef;
    };
    NzModalService.prototype.createInjector = function (modalRef, config) {
        var userInjector = config && config.nzViewContainerRef && config.nzViewContainerRef.injector;
        // tslint:disable-next-line:no-any
        var injectionTokens = new WeakMap([[NzModalRef, modalRef]]);
        return new PortalInjector(userInjector || this.injector, injectionTokens);
    };
    NzModalService.prototype.confirmFactory = function (options, confirmType) {
        if (options === void 0) { options = {}; }
        var iconMap = {
            info: 'info-circle',
            success: 'check-circle',
            error: 'close-circle',
            warning: 'exclamation-circle'
        };
        if (!('nzIconType' in options)) {
            options.nzIconType = iconMap[confirmType];
        }
        if (!('nzCancelText' in options)) {
            // Remove the Cancel button if the user not specify a Cancel button
            options.nzCancelText = null;
        }
        return this.confirm(options, confirmType);
    };
    NzModalService.prototype.ngOnDestroy = function () {
        this.closeModals(this.openModalsAtThisLevel);
        this.afterAllClosedAtThisLevel.complete();
    };
    /** @nocollapse */ NzModalService.ɵfac = function NzModalService_Factory(t) { return new (t || NzModalService)(ɵɵinject(Overlay), ɵɵinject(Injector), ɵɵinject(NzModalService, 12)); };
    /** @nocollapse */ NzModalService.ɵprov = ɵɵdefineInjectable({ token: NzModalService, factory: NzModalService.ɵfac });
    return NzModalService;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalService, [{
        type: Injectable
    }], function () { return [{ type: Overlay }, { type: Injector }, { type: NzModalService, decorators: [{
                type: Optional
            }, {
                type: SkipSelf
            }] }]; }, 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
 */
var NZ_MODAL_CONFIG = new InjectionToken('NZ_MODAL_CONFIG');

/**
 * @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 NzModalFooterDirective = /** @class */ (function () {
    function NzModalFooterDirective(nzModalRef, templateRef) {
        this.nzModalRef = nzModalRef;
        this.templateRef = templateRef;
        if (this.nzModalRef) {
            this.nzModalRef.updateConfig({
                nzFooter: this.templateRef
            });
        }
    }
    /** @nocollapse */ NzModalFooterDirective.ɵfac = function NzModalFooterDirective_Factory(t) { return new (t || NzModalFooterDirective)(ɵɵdirectiveInject(NzModalRef, 8), ɵɵdirectiveInject(TemplateRef)); };
    /** @nocollapse */ NzModalFooterDirective.ɵdir = ɵɵdefineDirective({ type: NzModalFooterDirective, selectors: [["", "nzModalFooter", ""]], exportAs: ["nzModalFooter"] });
    return NzModalFooterDirective;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalFooterDirective, [{
        type: Directive,
        args: [{
                selector: '[nzModalFooter]',
                exportAs: 'nzModalFooter'
            }]
    }], function () { return [{ type: NzModalRef, decorators: [{
                type: Optional
            }] }, { type: TemplateRef }]; }, null); })();

function NzModalComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    ɵɵprojection(0);
} }
var _c0$5 = ["*"];
var NZ_CONFIG_COMPONENT_NAME = 'modal';
var NzModalComponent = /** @class */ (function () {
    function NzModalComponent(nzConfigService, cdr, modal, viewContainerRef) {
        this.nzConfigService = nzConfigService;
        this.cdr = cdr;
        this.modal = modal;
        this.viewContainerRef = viewContainerRef;
        this.nzVisible = false;
        this.nzClosable = true;
        this.nzOkLoading = false;
        this.nzOkDisabled = false;
        this.nzCancelDisabled = false;
        this.nzCancelLoading = false;
        this.nzKeyboard = true;
        this.nzNoAnimation = false;
        this.nzZIndex = 1000;
        this.nzWidth = 520;
        this.nzCloseIcon = 'close';
        this.nzOkType = 'primary';
        this.nzIconType = 'question-circle'; // Confirm Modal ONLY
        this.nzModalType = 'default';
        this.nzOnOk = new EventEmitter();
        this.nzOnCancel = new EventEmitter();
        this.nzAfterOpen = new EventEmitter();
        this.nzAfterClose = new EventEmitter();
        this.nzVisibleChange = new EventEmitter();
        this.modalRef = null;
    }
    Object.defineProperty(NzModalComponent.prototype, "modalFooter", {
        set: function (value) {
            if (value && value.templateRef) {
                this.setFooterWithTemplate(value.templateRef);
            }
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzModalComponent.prototype, "afterOpen", {
        get: function () {
            // Observable alias for nzAfterOpen
            return this.nzAfterOpen.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(NzModalComponent.prototype, "afterClose", {
        get: function () {
            // Observable alias for nzAfterClose
            return this.nzAfterClose.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    NzModalComponent.prototype.open = function () {
        if (!this.nzVisible) {
            this.nzVisible = true;
            this.nzVisibleChange.emit(true);
        }
        if (!this.modalRef) {
            var config = this.getConfig();
            this.modalRef = this.modal.create(config);
        }
    };
    NzModalComponent.prototype.close = function (result) {
        if (this.nzVisible) {
            this.nzVisible = false;
            this.nzVisibleChange.emit(false);
        }
        if (this.modalRef) {
            this.modalRef.close(result);
            this.modalRef = null;
        }
    };
    NzModalComponent.prototype.destroy = function (result) {
        this.close(result);
    };
    NzModalComponent.prototype.triggerOk = function () {
        if (this.modalRef) {
            this.modalRef.triggerOk();
        }
    };
    NzModalComponent.prototype.triggerCancel = function () {
        if (this.modalRef) {
            this.modalRef.triggerCancel();
        }
    };
    NzModalComponent.prototype.getContentComponent = function () {
        if (this.modalRef) {
            return this.modalRef.getContentComponent();
        }
    };
    NzModalComponent.prototype.getElement = function () {
        if (this.modalRef) {
            return this.modalRef.getElement();
        }
    };
    NzModalComponent.prototype.getModalRef = function () {
        return this.modalRef;
    };
    NzModalComponent.prototype.setFooterWithTemplate = function (templateRef) {
        this.nzFooter = templateRef;
        this.cdr.markForCheck();
    };
    NzModalComponent.prototype.getConfig = function () {
        var componentConfig = getConfigFromComponent(this);
        componentConfig.nzViewContainerRef = this.viewContainerRef;
        if (!this.nzContent) {
            componentConfig.nzContent = this.contentTemplateRef;
        }
        return componentConfig;
    };
    NzModalComponent.prototype.ngOnChanges = function (changes) {
        var nzVisible = changes.nzVisible, otherChanges = __rest(changes, ["nzVisible"]);
        if (Object.keys(otherChanges).length && this.modalRef) {
            this.modalRef.updateConfig(getConfigFromComponent(this));
        }
        if (nzVisible) {
            if (this.nzVisible) {
                this.open();
            }
            else {
                this.close();
            }
        }
    };
    /** @nocollapse */ NzModalComponent.ɵfac = function NzModalComponent_Factory(t) { return new (t || NzModalComponent)(ɵɵdirectiveInject(NzConfigService), ɵɵdirectiveInject(ChangeDetectorRef), ɵɵdirectiveInject(NzModalService), ɵɵdirectiveInject(ViewContainerRef)); };
    /** @nocollapse */ NzModalComponent.ɵcmp = ɵɵdefineComponent({ type: NzModalComponent, selectors: [["nz-modal"]], contentQueries: function NzModalComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
            ɵɵcontentQuery(dirIndex, NzModalFooterDirective, true);
        } if (rf & 2) {
            var _t;
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.modalFooter = _t.first);
        } }, viewQuery: function NzModalComponent_Query(rf, ctx) { if (rf & 1) {
            ɵɵstaticViewQuery(TemplateRef, true);
        } if (rf & 2) {
            var _t;
            ɵɵqueryRefresh(_t = ɵɵloadQuery()) && (ctx.contentTemplateRef = _t.first);
        } }, inputs: { nzMask: "nzMask", nzMaskClosable: "nzMaskClosable", nzVisible: "nzVisible", nzClosable: "nzClosable", nzOkLoading: "nzOkLoading", nzOkDisabled: "nzOkDisabled", nzCancelDisabled: "nzCancelDisabled", nzCancelLoading: "nzCancelLoading", nzKeyboard: "nzKeyboard", nzNoAnimation: "nzNoAnimation", nzContent: "nzContent", nzComponentParams: "nzComponentParams", nzFooter: "nzFooter", nzGetContainer: "nzGetContainer", nzZIndex: "nzZIndex", nzWidth: "nzWidth", nzWrapClassName: "nzWrapClassName", nzClassName: "nzClassName", nzStyle: "nzStyle", nzTitle: "nzTitle", nzCloseIcon: "nzCloseIcon", nzMaskStyle: "nzMaskStyle", nzBodyStyle: "nzBodyStyle", nzOkText: "nzOkText", nzCancelText: "nzCancelText", nzOkType: "nzOkType", nzIconType: "nzIconType", nzModalType: "nzModalType", nzOnOk: "nzOnOk", nzOnCancel: "nzOnCancel" }, outputs: { nzOnOk: "nzOnOk", nzOnCancel: "nzOnCancel", nzAfterOpen: "nzAfterOpen", nzAfterClose: "nzAfterClose", nzVisibleChange: "nzVisibleChange" }, exportAs: ["nzModal"], features: [ɵɵNgOnChangesFeature], ngContentSelectors: _c0$5, decls: 1, vars: 0, template: function NzModalComponent_Template(rf, ctx) { if (rf & 1) {
            ɵɵprojectionDef();
            ɵɵtemplate(0, NzModalComponent_ng_template_0_Template, 1, 0, "ng-template");
        } }, encapsulation: 2, changeDetection: 0 });
    __decorate([
        WithConfig(NZ_CONFIG_COMPONENT_NAME, true), InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzMask", void 0);
    __decorate([
        WithConfig(NZ_CONFIG_COMPONENT_NAME, true), InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzMaskClosable", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzVisible", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzClosable", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzOkLoading", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzOkDisabled", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzCancelDisabled", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzCancelLoading", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Boolean)
    ], NzModalComponent.prototype, "nzKeyboard", void 0);
    __decorate([
        InputBoolean(),
        __metadata("design:type", Object)
    ], NzModalComponent.prototype, "nzNoAnimation", void 0);
    return NzModalComponent;
}());
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalComponent, [{
        type: Component,
        args: [{
                selector: 'nz-modal',
                exportAs: 'nzModal',
                template: "\n    <ng-template><ng-content></ng-content></ng-template>\n  ",
                changeDetection: ChangeDetectionStrategy.OnPush
            }]
    }], function () { return [{ type: NzConfigService }, { type: ChangeDetectorRef }, { type: NzModalService }, { type: ViewContainerRef }]; }, { nzMask: [{
            type: Input
        }], nzMaskClosable: [{
            type: Input
        }], nzVisible: [{
            type: Input
        }], nzClosable: [{
            type: Input
        }], nzOkLoading: [{
            type: Input
        }], nzOkDisabled: [{
            type: Input
        }], nzCancelDisabled: [{
            type: Input
        }], nzCancelLoading: [{
            type: Input
        }], nzKeyboard: [{
            type: Input
        }], nzNoAnimation: [{
            type: Input
        }], nzContent: [{
            type: Input
        }], nzComponentParams: [{
            type: Input
        }], nzFooter: [{
            type: Input
        }], nzGetContainer: [{
            type: Input
        }], nzZIndex: [{
            type: Input
        }], nzWidth: [{
            type: Input
        }], nzWrapClassName: [{
            type: Input
        }], nzClassName: [{
            type: Input
        }], nzStyle: [{
            type: Input
        }], nzTitle: [{
            type: Input
        }], nzCloseIcon: [{
            type: Input
        }], nzMaskStyle: [{
            type: Input
        }], nzBodyStyle: [{
            type: Input
        }], nzOkText: [{
            type: Input
        }], nzCancelText: [{
            type: Input
        }], nzOkType: [{
            type: Input
        }], nzIconType: [{
            type: Input
        }], nzModalType: [{
            type: Input
        }], nzOnOk: [{
            type: Input
        }, {
            type: Output
        }], nzOnCancel: [{
            type: Input
        }, {
            type: Output
        }], nzAfterOpen: [{
            type: Output
        }], nzAfterClose: [{
            type: Output
        }], nzVisibleChange: [{
            type: Output
        }], contentTemplateRef: [{
            type: ViewChild,
            args: [TemplateRef, { static: true }]
        }], modalFooter: [{
            type: ContentChild,
            args: [NzModalFooterDirective]
        }] }); })();

/**
 * @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 NzModalModule = /** @class */ (function () {
    function NzModalModule() {
    }
    /** @nocollapse */ NzModalModule.ɵmod = ɵɵdefineNgModule({ type: NzModalModule });
    /** @nocollapse */ NzModalModule.ɵinj = ɵɵdefineInjector({ factory: function NzModalModule_Factory(t) { return new (t || NzModalModule)(); }, providers: [NzModalService], imports: [[
                CommonModule,
                OverlayModule,
                NzOutletModule,
                PortalModule,
                NzI18nModule,
                NzButtonModule,
                NzIconModule,
                NzPipesModule,
                NzNoAnimationModule
            ]] });
    return NzModalModule;
}());
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && ɵɵsetNgModuleScope(NzModalModule, { declarations: [NzModalComponent,
        NzModalFooterDirective,
        NzModalCloseComponent,
        NzModalFooterComponent,
        NzModalTitleComponent,
        NzModalContainerComponent,
        NzModalConfirmContainerComponent,
        NzModalComponent], imports: [CommonModule,
        OverlayModule,
        NzOutletModule,
        PortalModule,
        NzI18nModule,
        NzButtonModule,
        NzIconModule,
        NzPipesModule,
        NzNoAnimationModule], exports: [NzModalComponent, NzModalFooterDirective] }); })();
/*@__PURE__*/ (function () { ɵsetClassMetadata(NzModalModule, [{
        type: NgModule,
        args: [{
                imports: [
                    CommonModule,
                    OverlayModule,
                    NzOutletModule,
                    PortalModule,
                    NzI18nModule,
                    NzButtonModule,
                    NzIconModule,
                    NzPipesModule,
                    NzNoAnimationModule
                ],
                exports: [NzModalComponent, NzModalFooterDirective],
                providers: [NzModalService],
                declarations: [
                    NzModalComponent,
                    NzModalFooterDirective,
                    NzModalCloseComponent,
                    NzModalFooterComponent,
                    NzModalTitleComponent,
                    NzModalContainerComponent,
                    NzModalConfirmContainerComponent,
                    NzModalComponent
                ]
            }]
    }], 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 { ModalOptions, NZ_MODAL_CONFIG, NzModalComponent, NzModalFooterDirective, NzModalModule, NzModalRef, NzModalService };
//# sourceMappingURL=ng-zorro-antd-modal.js.map
