/**
 * @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 { ChangeDetectionStrategy, Component, ElementRef, Input, ViewEncapsulation } from '@angular/core';
import { NzUpdateHostClassService } from 'ng-zorro-antd/core';
import * as i0 from "@angular/core";
import * as i1 from "ng-zorro-antd/core";
import * as i2 from "@angular/common";
import * as i3 from "ng-zorro-antd/icon";
import * as i4 from "./partial/not-found";
import * as i5 from "./partial/server-error.component";
import * as i6 from "./partial/unauthorized";
function NzResultComponent_ng_container_1_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "i", 6);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r831 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzType", ctx_r831.icon);
} }
function NzResultComponent_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzResultComponent_ng_container_1_ng_container_1_ng_container_1_Template, 2, 1, "ng-container", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r829 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r829.icon);
} }
function NzResultComponent_ng_container_1_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0, 1, ["*ngIf", "!icon"]);
} }
function NzResultComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzResultComponent_ng_container_1_ng_container_1_Template, 2, 1, "ng-container", 2);
    i0.ɵɵtemplate(2, NzResultComponent_ng_container_1_2_Template, 1, 0, undefined, 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r820 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r820.icon);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r820.icon);
} }
function NzResultComponent_ng_container_2_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 8);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r832 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r832.nzTitle, " ");
} }
function NzResultComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzResultComponent_ng_container_2_div_1_Template, 2, 1, "div", 7);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r821 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r821.nzTitle);
} }
function NzResultComponent_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0, 2, ["*ngIf", "!nzTitle"]);
} }
function NzResultComponent_ng_container_4_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r833 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r833.nzSubTitle, " ");
} }
function NzResultComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzResultComponent_ng_container_4_div_1_Template, 2, 1, "div", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r823 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r823.nzSubTitle);
} }
function NzResultComponent_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0, 3, ["*ngIf", "!nzSubTitle"]);
} }
function NzResultComponent_div_7_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r834 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", ctx_r834.nzExtra, " ");
} }
function NzResultComponent_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtemplate(1, NzResultComponent_div_7_ng_container_1_Template, 2, 1, "ng-container", 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r825 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r825.nzExtra);
} }
function NzResultComponent_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵprojection(0, 4, ["*ngIf", "!nzExtra"]);
} }
function NzResultComponent_ng_template_9_nz_result_not_found_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-result-not-found");
} }
function NzResultComponent_ng_template_9_nz_result_server_error_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-result-server-error");
} }
function NzResultComponent_ng_template_9_nz_result_unauthorized_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-result-unauthorized");
} }
function NzResultComponent_ng_template_9_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0, 12);
    i0.ɵɵtemplate(1, NzResultComponent_ng_template_9_nz_result_not_found_1_Template, 1, 0, "nz-result-not-found", 13);
    i0.ɵɵtemplate(2, NzResultComponent_ng_template_9_nz_result_server_error_2_Template, 1, 0, "nz-result-server-error", 13);
    i0.ɵɵtemplate(3, NzResultComponent_ng_template_9_nz_result_unauthorized_3_Template, 1, 0, "nz-result-unauthorized", 13);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r828 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngSwitch", ctx_r828.nzStatus);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "404");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "500");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngSwitchCase", "403");
} }
const _c0 = [[["nz-result-content"], ["", "nz-result-content", ""]], [["", "nz-result-icon", ""]], [["div", "nz-result-title", ""]], [["div", "nz-result-subtitle", ""]], [["div", "nz-result-extra", ""]]];
const _c1 = ["nz-result-content, [nz-result-content]", "[nz-result-icon]", "div[nz-result-title]", "div[nz-result-subtitle]", "div[nz-result-extra]"];
const IconMap = {
    success: 'check-circle',
    error: 'close-circle',
    info: 'exclamation-circle',
    warning: 'warning'
};
const ExceptionStatus = ['404', '500', '403'];
export class NzResultComponent {
    constructor(nzUpdateHostClassService, elementRef) {
        this.nzUpdateHostClassService = nzUpdateHostClassService;
        this.elementRef = elementRef;
        this.nzStatus = 'info';
        this.isException = false;
    }
    ngOnChanges() {
        this.setStatusIcon();
        this.setClassMap();
    }
    setStatusIcon() {
        const icon = this.nzIcon;
        this.isException = ExceptionStatus.indexOf(this.nzStatus) !== -1;
        this.icon = icon
            ? typeof icon === 'string'
                ? IconMap[icon] || icon
                : icon
            : this.isException
                ? undefined
                : IconMap[this.nzStatus];
    }
    setClassMap() {
        const prefix = 'ant-result';
        this.nzUpdateHostClassService.updateHostClass(this.elementRef.nativeElement, {
            [prefix]: true,
            [`${prefix}-${this.nzStatus}`]: true
        });
    }
}
/** @nocollapse */ NzResultComponent.ɵfac = function NzResultComponent_Factory(t) { return new (t || NzResultComponent)(i0.ɵɵdirectiveInject(i1.NzUpdateHostClassService), i0.ɵɵdirectiveInject(i0.ElementRef)); };
/** @nocollapse */ NzResultComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzResultComponent, selectors: [["nz-result"]], inputs: { nzIcon: "nzIcon", nzTitle: "nzTitle", nzStatus: "nzStatus", nzSubTitle: "nzSubTitle", nzExtra: "nzExtra" }, exportAs: ["nzResult"], features: [i0.ɵɵProvidersFeature([NzUpdateHostClassService]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c1, decls: 11, vars: 8, consts: [[1, "ant-result-icon"], [4, "ngIf", "ngIfElse"], [4, "ngIf"], ["class", "ant-result-extra", 4, "ngIf"], ["exceptionTpl", ""], [4, "nzStringTemplateOutlet"], ["nz-icon", "", "nzTheme", "fill", 3, "nzType"], ["class", "ant-result-title", 4, "nzStringTemplateOutlet"], [1, "ant-result-title"], ["class", "ant-result-subtitle", 4, "nzStringTemplateOutlet"], [1, "ant-result-subtitle"], [1, "ant-result-extra"], [3, "ngSwitch"], [4, "ngSwitchCase"]], template: function NzResultComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c0);
        i0.ɵɵelementStart(0, "div", 0);
        i0.ɵɵtemplate(1, NzResultComponent_ng_container_1_Template, 3, 2, "ng-container", 1);
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(2, NzResultComponent_ng_container_2_Template, 2, 1, "ng-container", 2);
        i0.ɵɵtemplate(3, NzResultComponent_3_Template, 1, 0, undefined, 2);
        i0.ɵɵtemplate(4, NzResultComponent_ng_container_4_Template, 2, 1, "ng-container", 2);
        i0.ɵɵtemplate(5, NzResultComponent_5_Template, 1, 0, undefined, 2);
        i0.ɵɵprojection(6);
        i0.ɵɵtemplate(7, NzResultComponent_div_7_Template, 2, 1, "div", 3);
        i0.ɵɵtemplate(8, NzResultComponent_8_Template, 1, 0, undefined, 2);
        i0.ɵɵtemplate(9, NzResultComponent_ng_template_9_Template, 4, 4, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
    } if (rf & 2) {
        const _r827 = i0.ɵɵreference(10);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.isException)("ngIfElse", _r827);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.nzTitle);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.nzTitle);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.nzSubTitle);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.nzSubTitle);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.nzExtra);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.nzExtra);
    } }, directives: [i2.NgIf, i1.NzStringTemplateOutletDirective, i3.NzIconDirective, i2.NgSwitch, i2.NgSwitchCase, i4.NzResultNotFoundComponent, i5.NzResultServerErrorComponent, i6.NzResultUnauthorizedComponent], styles: ["\n      nz-result {\n        display: block;\n      }\n    "], encapsulation: 2, changeDetection: 0 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzResultComponent, [{
        type: Component,
        args: [{
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                selector: 'nz-result',
                exportAs: 'nzResult',
                providers: [NzUpdateHostClassService],
                template: `
    <div class="ant-result-icon">
      <ng-container *ngIf="!isException; else exceptionTpl">
        <ng-container *ngIf="icon">
          <ng-container *nzStringTemplateOutlet="icon">
            <i nz-icon [nzType]="icon" nzTheme="fill"></i>
          </ng-container>
        </ng-container>
        <ng-content *ngIf="!icon" select="[nz-result-icon]"></ng-content>
      </ng-container>
    </div>
    <ng-container *ngIf="nzTitle">
      <div class="ant-result-title" *nzStringTemplateOutlet="nzTitle">
        {{ nzTitle }}
      </div>
    </ng-container>
    <ng-content *ngIf="!nzTitle" select="div[nz-result-title]"></ng-content>
    <ng-container *ngIf="nzSubTitle">
      <div class="ant-result-subtitle" *nzStringTemplateOutlet="nzSubTitle">
        {{ nzSubTitle }}
      </div>
    </ng-container>
    <ng-content *ngIf="!nzSubTitle" select="div[nz-result-subtitle]"></ng-content>
    <ng-content select="nz-result-content, [nz-result-content]"></ng-content>
    <div class="ant-result-extra" *ngIf="nzExtra">
      <ng-container *nzStringTemplateOutlet="nzExtra">
        {{ nzExtra }}
      </ng-container>
    </div>
    <ng-content *ngIf="!nzExtra" select="div[nz-result-extra]"></ng-content>

    <ng-template #exceptionTpl>
      <ng-container [ngSwitch]="nzStatus">
        <nz-result-not-found *ngSwitchCase="'404'"></nz-result-not-found>
        <nz-result-server-error *ngSwitchCase="'500'"></nz-result-server-error>
        <nz-result-unauthorized *ngSwitchCase="'403'"></nz-result-unauthorized>
      </ng-container>
    </ng-template>
  `,
                styles: [
                    `
      nz-result {
        display: block;
      }
    `
                ]
            }]
    }], function () { return [{ type: i1.NzUpdateHostClassService }, { type: i0.ElementRef }]; }, { nzIcon: [{
            type: Input
        }], nzTitle: [{
            type: Input
        }], nzStatus: [{
            type: Input
        }], nzSubTitle: [{
            type: Input
        }], nzExtra: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 