import { __decorate, __metadata } from "tslib";
/**
 * @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, ContentChild, ElementRef, Input, TemplateRef, ViewEncapsulation } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { InputBoolean, NzUpdateHostClassService } from 'ng-zorro-antd/core';
import { NzListFooterComponent, NzListLoadMoreDirective, NzListPaginationComponent } from './list-cell';
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/spin";
import * as i4 from "./list-cell";
import * as i5 from "ng-zorro-antd/grid";
function NzListComponent_ng_template_0_ng_container_1_ng_template_1_Template(rf, ctx) { }
const _c0 = function (a0, a1) { return { $implicit: a0, index: a1 }; };
function NzListComponent_ng_template_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, NzListComponent_ng_template_0_ng_container_1_ng_template_1_Template, 0, 0, "ng-template", 9);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const item_r2230 = ctx.$implicit;
    const index_r2231 = ctx.index;
    const ctx_r2229 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2229.nzRenderItem)("ngTemplateOutletContext", i0.ɵɵpureFunction2(2, _c0, item_r2230, index_r2231));
} }
function NzListComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 7);
    i0.ɵɵtemplate(1, NzListComponent_ng_template_0_ng_container_1_Template, 2, 5, "ng-container", 8);
    i0.ɵɵprojection(2, 5);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2221 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2221.nzDataSource);
} }
function NzListComponent_nz_list_header_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2233 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r2233.nzHeader);
} }
function NzListComponent_nz_list_header_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "nz-list-header");
    i0.ɵɵtemplate(1, NzListComponent_nz_list_header_2_ng_container_1_Template, 2, 1, "ng-container", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2222 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r2222.nzHeader);
} }
function NzListComponent_div_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "div");
} if (rf & 2) {
    i0.ɵɵstyleProp("min-height", 53, "px");
} }
function NzListComponent_div_7_div_1_ng_template_1_Template(rf, ctx) { }
function NzListComponent_div_7_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵtemplate(1, NzListComponent_div_7_div_1_ng_template_1_Template, 0, 0, "ng-template", 9);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const item_r2235 = ctx.$implicit;
    const index_r2236 = ctx.index;
    const ctx_r2234 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("nzSpan", ctx_r2234.nzGrid.span)("nzXs", ctx_r2234.nzGrid.xs)("nzSm", ctx_r2234.nzGrid.sm)("nzMd", ctx_r2234.nzGrid.md)("nzLg", ctx_r2234.nzGrid.lg)("nzXl", ctx_r2234.nzGrid.xl)("nzXXl", ctx_r2234.nzGrid.xxl);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2234.nzRenderItem)("ngTemplateOutletContext", i0.ɵɵpureFunction2(9, _c0, item_r2235, index_r2236));
} }
function NzListComponent_div_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 11);
    i0.ɵɵtemplate(1, NzListComponent_div_7_div_1_Template, 2, 12, "div", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2224 = i0.ɵɵnextContext();
    i0.ɵɵproperty("nzGutter", ctx_r2224.nzGrid.gutter);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2224.nzDataSource);
} }
function NzListComponent_nz_list_empty_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "nz-list-empty", 14);
} if (rf & 2) {
    const ctx_r2225 = i0.ɵɵnextContext();
    i0.ɵɵproperty("nzNoResult", ctx_r2225.nzNoResult);
} }
function NzListComponent_nz_list_footer_10_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r2238 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r2238.nzFooter);
} }
function NzListComponent_nz_list_footer_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "nz-list-footer");
    i0.ɵɵtemplate(1, NzListComponent_nz_list_footer_10_ng_container_1_Template, 2, 1, "ng-container", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2226 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzStringTemplateOutlet", ctx_r2226.nzFooter);
} }
function NzListComponent_ng_template_12_Template(rf, ctx) { }
function NzListComponent_nz_list_pagination_14_ng_template_1_Template(rf, ctx) { }
function NzListComponent_nz_list_pagination_14_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "nz-list-pagination");
    i0.ɵɵtemplate(1, NzListComponent_nz_list_pagination_14_ng_template_1_Template, 0, 0, "ng-template", 6);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r2228 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2228.nzPagination);
} }
const _c1 = [[["nz-list-header"]], "*", [["nz-list-footer"], ["", "nz-list-footer", ""]], [["nz-list-load-more"], ["", "nz-list-load-more", ""]], [["nz-list-pagination"], ["", "nz-list-pagination", ""]], [["nz-list-item"], ["", "nz-list-item", ""]]];
const _c2 = ["nz-list-header", "*", "nz-list-footer, [nz-list-footer]", "nz-list-load-more, [nz-list-load-more]", "nz-list-pagination, [nz-list-pagination]", "nz-list-item, [nz-list-item]"];
export class NzListComponent {
    constructor(el, updateHostClassService) {
        this.el = el;
        this.updateHostClassService = updateHostClassService;
        this.nzBordered = false;
        this.nzItemLayout = 'horizontal';
        this.nzLoading = false;
        this.nzSize = 'default';
        this.nzSplit = true;
        this.hasSomethingAfterLastItem = false;
        this.prefixCls = 'ant-list';
        // #endregion
        this.itemLayoutNotifySource = new BehaviorSubject(this.nzItemLayout);
    }
    _setClassMap() {
        const classMap = {
            [this.prefixCls]: true
        };
        this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap);
    }
    get itemLayoutNotify$() {
        return this.itemLayoutNotifySource.asObservable();
    }
    getSomethingAfterLastItem() {
        return !!(this.nzLoadMore ||
            this.nzPagination ||
            this.nzFooter ||
            this.nzListFooterComponent ||
            this.nzListPaginationComponent ||
            this.nzListLoadMoreDirective);
    }
    ngOnInit() {
        this._setClassMap();
    }
    ngOnChanges(changes) {
        this._setClassMap();
        if (changes.nzItemLayout) {
            this.itemLayoutNotifySource.next(this.nzItemLayout);
        }
    }
    ngOnDestroy() {
        this.itemLayoutNotifySource.unsubscribe();
    }
    ngAfterContentInit() {
        this.hasSomethingAfterLastItem = this.getSomethingAfterLastItem();
    }
}
/** @nocollapse */ NzListComponent.ɵfac = function NzListComponent_Factory(t) { return new (t || NzListComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1.NzUpdateHostClassService)); };
/** @nocollapse */ NzListComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzListComponent, selectors: [["nz-list"], ["", "nz-list", ""]], contentQueries: function NzListComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
        i0.ɵɵcontentQuery(dirIndex, NzListFooterComponent, true);
        i0.ɵɵcontentQuery(dirIndex, NzListPaginationComponent, true);
        i0.ɵɵcontentQuery(dirIndex, NzListLoadMoreDirective, true);
    } if (rf & 2) {
        var _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.nzListFooterComponent = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.nzListPaginationComponent = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.nzListLoadMoreDirective = _t.first);
    } }, hostVars: 14, hostBindings: function NzListComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassProp("ant-list-vertical", ctx.nzItemLayout === "vertical")("ant-list-lg", ctx.nzSize === "large")("ant-list-sm", ctx.nzSize === "small")("ant-list-split", ctx.nzSplit)("ant-list-bordered", ctx.nzBordered)("ant-list-loading", ctx.nzLoading)("ant-list-something-after-last-item", ctx.hasSomethingAfterLastItem);
    } }, inputs: { nzDataSource: "nzDataSource", nzBordered: "nzBordered", nzGrid: "nzGrid", nzHeader: "nzHeader", nzFooter: "nzFooter", nzItemLayout: "nzItemLayout", nzRenderItem: "nzRenderItem", nzLoading: "nzLoading", nzLoadMore: "nzLoadMore", nzPagination: "nzPagination", nzSize: "nzSize", nzSplit: "nzSplit", nzNoResult: "nzNoResult" }, exportAs: ["nzList"], features: [i0.ɵɵProvidersFeature([NzUpdateHostClassService]), i0.ɵɵNgOnChangesFeature], ngContentSelectors: _c2, decls: 16, vars: 9, consts: [["itemsTpl", ""], [4, "ngIf"], [3, "nzSpinning"], [3, "min-height", 4, "ngIf"], ["nz-row", "", 3, "nzGutter", 4, "ngIf", "ngIfElse"], [3, "nzNoResult", 4, "ngIf"], [3, "ngTemplateOutlet"], [1, "ant-list-items"], [4, "ngFor", "ngForOf"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [4, "nzStringTemplateOutlet"], ["nz-row", "", 3, "nzGutter"], ["nz-col", "", 3, "nzSpan", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl", 4, "ngFor", "ngForOf"], ["nz-col", "", 3, "nzSpan", "nzXs", "nzSm", "nzMd", "nzLg", "nzXl", "nzXXl"], [3, "nzNoResult"]], template: function NzListComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵprojectionDef(_c1);
        i0.ɵɵtemplate(0, NzListComponent_ng_template_0_Template, 3, 1, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
        i0.ɵɵtemplate(2, NzListComponent_nz_list_header_2_Template, 2, 1, "nz-list-header", 1);
        i0.ɵɵprojection(3);
        i0.ɵɵelementStart(4, "nz-spin", 2);
        i0.ɵɵelementContainerStart(5);
        i0.ɵɵtemplate(6, NzListComponent_div_6_Template, 1, 2, "div", 3);
        i0.ɵɵtemplate(7, NzListComponent_div_7_Template, 2, 2, "div", 4);
        i0.ɵɵtemplate(8, NzListComponent_nz_list_empty_8_Template, 1, 1, "nz-list-empty", 5);
        i0.ɵɵelementContainerEnd();
        i0.ɵɵprojection(9, 1);
        i0.ɵɵelementEnd();
        i0.ɵɵtemplate(10, NzListComponent_nz_list_footer_10_Template, 2, 1, "nz-list-footer", 1);
        i0.ɵɵprojection(11, 2);
        i0.ɵɵtemplate(12, NzListComponent_ng_template_12_Template, 0, 0, "ng-template", 6);
        i0.ɵɵprojection(13, 3);
        i0.ɵɵtemplate(14, NzListComponent_nz_list_pagination_14_Template, 2, 1, "nz-list-pagination", 1);
        i0.ɵɵprojection(15, 4);
    } if (rf & 2) {
        const _r2220 = i0.ɵɵreference(1);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.nzHeader);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("nzSpinning", ctx.nzLoading);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.nzLoading && ctx.nzDataSource && ctx.nzDataSource.length === 0);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.nzGrid && ctx.nzDataSource)("ngIfElse", _r2220);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.nzLoading && ctx.nzDataSource && ctx.nzDataSource.length === 0);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.nzFooter);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngTemplateOutlet", ctx.nzLoadMore);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.nzPagination);
    } }, directives: [i2.NgIf, i3.NzSpinComponent, i2.NgTemplateOutlet, i2.NgForOf, i4.NzListHeaderComponent, i1.NzStringTemplateOutletDirective, i5.NzRowDirective, i5.NzColDirective, i4.NzListEmptyComponent, i4.NzListFooterComponent, i4.NzListPaginationComponent], encapsulation: 2, changeDetection: 0 });
__decorate([
    InputBoolean(),
    __metadata("design:type", Object)
], NzListComponent.prototype, "nzBordered", void 0);
__decorate([
    InputBoolean(),
    __metadata("design:type", Object)
], NzListComponent.prototype, "nzLoading", void 0);
__decorate([
    InputBoolean(),
    __metadata("design:type", Object)
], NzListComponent.prototype, "nzSplit", void 0);
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzListComponent, [{
        type: Component,
        args: [{
                selector: 'nz-list, [nz-list]',
                exportAs: 'nzList',
                template: `
    <ng-template #itemsTpl>
      <div class="ant-list-items">
        <ng-container *ngFor="let item of nzDataSource; let index = index">
          <ng-template [ngTemplateOutlet]="nzRenderItem" [ngTemplateOutletContext]="{ $implicit: item, index: index }"></ng-template>
        </ng-container>
        <ng-content select="nz-list-item, [nz-list-item]"></ng-content>
      </div>
    </ng-template>

    <nz-list-header *ngIf="nzHeader">
      <ng-container *nzStringTemplateOutlet="nzHeader">{{ nzHeader }}</ng-container>
    </nz-list-header>
    <ng-content select="nz-list-header"></ng-content>

    <nz-spin [nzSpinning]="nzLoading">
      <ng-container>
        <div *ngIf="nzLoading && nzDataSource && nzDataSource.length === 0" [style.min-height.px]="53"></div>
        <div *ngIf="nzGrid && nzDataSource; else itemsTpl" nz-row [nzGutter]="nzGrid.gutter">
          <div
            nz-col
            [nzSpan]="nzGrid.span"
            [nzXs]="nzGrid.xs"
            [nzSm]="nzGrid.sm"
            [nzMd]="nzGrid.md"
            [nzLg]="nzGrid.lg"
            [nzXl]="nzGrid.xl"
            [nzXXl]="nzGrid.xxl"
            *ngFor="let item of nzDataSource; let index = index"
          >
            <ng-template [ngTemplateOutlet]="nzRenderItem" [ngTemplateOutletContext]="{ $implicit: item, index: index }"></ng-template>
          </div>
        </div>
        <nz-list-empty *ngIf="!nzLoading && nzDataSource && nzDataSource.length === 0" [nzNoResult]="nzNoResult"></nz-list-empty>
      </ng-container>
      <ng-content></ng-content>
    </nz-spin>

    <nz-list-footer *ngIf="nzFooter">
      <ng-container *nzStringTemplateOutlet="nzFooter">{{ nzFooter }}</ng-container>
    </nz-list-footer>
    <ng-content select="nz-list-footer, [nz-list-footer]"></ng-content>

    <ng-template [ngTemplateOutlet]="nzLoadMore"></ng-template>
    <ng-content select="nz-list-load-more, [nz-list-load-more]"></ng-content>

    <nz-list-pagination *ngIf="nzPagination">
      <ng-template [ngTemplateOutlet]="nzPagination"></ng-template>
    </nz-list-pagination>
    <ng-content select="nz-list-pagination, [nz-list-pagination]"></ng-content>
  `,
                providers: [NzUpdateHostClassService],
                preserveWhitespaces: false,
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush,
                host: {
                    '[class.ant-list-vertical]': 'nzItemLayout === "vertical"',
                    '[class.ant-list-lg]': 'nzSize === "large"',
                    '[class.ant-list-sm]': 'nzSize === "small"',
                    '[class.ant-list-split]': 'nzSplit',
                    '[class.ant-list-bordered]': 'nzBordered',
                    '[class.ant-list-loading]': 'nzLoading',
                    '[class.ant-list-something-after-last-item]': 'hasSomethingAfterLastItem'
                }
            }]
    }], function () { return [{ type: i0.ElementRef }, { type: i1.NzUpdateHostClassService }]; }, { nzDataSource: [{
            type: Input
        }], nzBordered: [{
            type: Input
        }], nzGrid: [{
            type: Input
        }], nzHeader: [{
            type: Input
        }], nzFooter: [{
            type: Input
        }], nzItemLayout: [{
            type: Input
        }], nzRenderItem: [{
            type: Input
        }], nzLoading: [{
            type: Input
        }], nzLoadMore: [{
            type: Input
        }], nzPagination: [{
            type: Input
        }], nzSize: [{
            type: Input
        }], nzSplit: [{
            type: Input
        }], nzNoResult: [{
            type: Input
        }], nzListFooterComponent: [{
            type: ContentChild,
            args: [NzListFooterComponent]
        }], nzListPaginationComponent: [{
            type: ContentChild,
            args: [NzListPaginationComponent]
        }], nzListLoadMoreDirective: [{
            type: ContentChild,
            args: [NzListLoadMoreDirective]
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 