/**
 * @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, ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, Output, TemplateRef, 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/checkbox";
import * as i4 from "ng-zorro-antd/empty";
import * as i5 from "./nz-transfer-search.component";
function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    var item_r2067 = i0.ɵɵnextContext(2).$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(item_r2067.title);
} }
function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_ng_template_3_Template(rf, ctx) { }
var _c0 = function (a0) { return { "ant-transfer-list-content-item-disabled": a0 }; };
var _c1 = function (a0) { return { $implicit: a0 }; };
function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_Template(rf, ctx) { if (rf & 1) {
    var _r2075 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "li", 15);
    i0.ɵɵlistener("click", function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_Template_li_click_0_listener() { i0.ɵɵrestoreView(_r2075); var item_r2067 = i0.ɵɵnextContext().$implicit; var ctx_r2073 = i0.ɵɵnextContext(3); return ctx_r2073.onItemSelect(item_r2067); });
    i0.ɵɵelementStart(1, "label", 16);
    i0.ɵɵlistener("nzCheckedChange", function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_Template_label_nzCheckedChange_1_listener() { i0.ɵɵrestoreView(_r2075); var item_r2067 = i0.ɵɵnextContext().$implicit; var ctx_r2076 = i0.ɵɵnextContext(3); return ctx_r2076.onItemSelect(item_r2067); })("click", function NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_Template_label_click_1_listener($event) { i0.ɵɵrestoreView(_r2075); return $event.stopPropagation(); });
    i0.ɵɵtemplate(2, NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_ng_container_2_Template, 2, 1, "ng-container", 7);
    i0.ɵɵtemplate(3, NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_ng_template_3_Template, 0, 0, "ng-template", 17, 18, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var _r2070 = i0.ɵɵreference(4);
    var item_r2067 = i0.ɵɵnextContext().$implicit;
    var ctx_r2068 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(7, _c0, ctx_r2068.disabled || item_r2067.disabled));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzChecked", item_r2067.checked)("nzDisabled", ctx_r2068.disabled || item_r2067.disabled);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r2068.render)("ngIfElse", _r2070);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2068.render)("ngTemplateOutletContext", i0.ɵɵpureFunction1(9, _c1, item_r2067));
} }
function NzTransferListComponent_ng_template_0_ul_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 13);
    i0.ɵɵtemplate(1, NzTransferListComponent_ng_template_0_ul_0_div_1_li_1_Template, 5, 11, "li", 14);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var item_r2067 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !item_r2067.hide);
} }
function NzTransferListComponent_ng_template_0_ul_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "ul", 11);
    i0.ɵɵtemplate(1, NzTransferListComponent_ng_template_0_ul_0_div_1_Template, 2, 1, "div", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2064 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r2064.dataSource);
} }
function NzTransferListComponent_ng_template_0_div_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 19);
    i0.ɵɵelement(1, "nz-embed-empty", 20);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2065 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("nzComponentName", "transfer")("specificContent", ctx_r2065.notFoundContent);
} }
function NzTransferListComponent_ng_template_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, NzTransferListComponent_ng_template_0_ul_0_Template, 2, 1, "ul", 9);
    i0.ɵɵtemplate(1, NzTransferListComponent_ng_template_0_div_1_Template, 2, 2, "div", 10);
} if (rf & 2) {
    var ctx_r2058 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngIf", ctx_r2058.stat.shownCount > 0);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2058.stat.shownCount === 0);
} }
function NzTransferListComponent_label_3_Template(rf, ctx) { if (rf & 1) {
    var _r2081 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "label", 21);
    i0.ɵɵlistener("nzCheckedChange", function NzTransferListComponent_label_3_Template_label_nzCheckedChange_0_listener($event) { i0.ɵɵrestoreView(_r2081); var ctx_r2080 = i0.ɵɵnextContext(); return ctx_r2080.onItemSelectAll($event); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2059 = i0.ɵɵnextContext();
    i0.ɵɵproperty("nzChecked", ctx_r2059.stat.checkAll)("nzIndeterminate", ctx_r2059.stat.checkHalf)("nzDisabled", ctx_r2059.stat.shownCount == 0 || ctx_r2059.disabled);
} }
function NzTransferListComponent_span_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span", 22);
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2060 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate(ctx_r2060.titleText);
} }
function NzTransferListComponent_div_9_Template(rf, ctx) { if (rf & 1) {
    var _r2083 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 23);
    i0.ɵɵelementStart(1, "div", 24);
    i0.ɵɵlistener("valueChanged", function NzTransferListComponent_div_9_Template_div_valueChanged_1_listener($event) { i0.ɵɵrestoreView(_r2083); var ctx_r2082 = i0.ɵɵnextContext(); return ctx_r2082.handleFilter($event); })("valueClear", function NzTransferListComponent_div_9_Template_div_valueClear_1_listener() { i0.ɵɵrestoreView(_r2083); var ctx_r2084 = i0.ɵɵnextContext(); return ctx_r2084.handleClear(); });
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2061 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("placeholder", ctx_r2061.searchPlaceholder)("disabled", ctx_r2061.disabled)("value", ctx_r2061.filter);
} }
function NzTransferListComponent_ng_container_10_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
var _c2 = function (a0, a1, a2, a3, a4, a5) { return { $implicit: a0, direction: a1, disabled: a2, onItemSelectAll: a3, onItemSelect: a4, stat: a5 }; };
function NzTransferListComponent_ng_container_10_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "div", 25);
    i0.ɵɵtemplate(2, NzTransferListComponent_ng_container_10_ng_container_2_Template, 1, 0, "ng-container", 26);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    var ctx_r2062 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2062.renderList)("ngTemplateOutletContext", i0.ɵɵpureFunction6(2, _c2, ctx_r2062.dataSource, ctx_r2062.direction, ctx_r2062.disabled, ctx_r2062.onItemSelectAll, ctx_r2062.onItemSelect, ctx_r2062.stat));
} }
function NzTransferListComponent_div_11_ng_template_1_Template(rf, ctx) { }
function NzTransferListComponent_div_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 27);
    i0.ɵɵtemplate(1, NzTransferListComponent_div_11_ng_template_1_Template, 0, 0, "ng-template", 17);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    var ctx_r2063 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r2063.footer)("ngTemplateOutletContext", i0.ɵɵpureFunction1(2, _c1, ctx_r2063.direction));
} }
var _c3 = function (a0) { return { "ant-transfer__nodata": a0 }; };
var NzTransferListComponent = /** @class */ (function () {
    // #endregion
    function NzTransferListComponent(el, updateHostClassService, cdr) {
        var _this = this;
        this.el = el;
        this.updateHostClassService = updateHostClassService;
        this.cdr = cdr;
        // #region fields
        this.direction = '';
        this.titleText = '';
        this.showSelectAll = true;
        this.dataSource = [];
        this.itemUnit = '';
        this.itemsUnit = '';
        this.filter = '';
        // events
        this.handleSelectAll = new EventEmitter();
        this.handleSelect = new EventEmitter();
        this.filterChange = new EventEmitter();
        // #endregion
        // #region styles
        this.prefixCls = 'ant-transfer-list';
        // #endregion
        // #region select all
        this.stat = {
            checkAll: false,
            checkHalf: false,
            checkCount: 0,
            shownCount: 0
        };
        this.onItemSelect = function (item) {
            if (_this.disabled || item.disabled) {
                return;
            }
            item.checked = !item.checked;
            _this.updateCheckStatus();
            _this.handleSelect.emit(item);
        };
        this.onItemSelectAll = function (status) {
            _this.dataSource.forEach(function (item) {
                if (!item.disabled && !item.hide) {
                    item.checked = status;
                }
            });
            _this.updateCheckStatus();
            _this.handleSelectAll.emit(status);
        };
    }
    NzTransferListComponent.prototype.setClassMap = function () {
        var _a;
        var classMap = (_a = {},
            _a[this.prefixCls] = true,
            _a[this.prefixCls + "-with-footer"] = !!this.footer,
            _a);
        this.updateHostClassService.updateHostClass(this.el.nativeElement, classMap);
    };
    NzTransferListComponent.prototype.updateCheckStatus = function () {
        var validCount = this.dataSource.filter(function (w) { return !w.disabled; }).length;
        this.stat.checkCount = this.dataSource.filter(function (w) { return w.checked && !w.disabled; }).length;
        this.stat.shownCount = this.dataSource.filter(function (w) { return !w.hide; }).length;
        this.stat.checkAll = validCount > 0 && validCount === this.stat.checkCount;
        this.stat.checkHalf = this.stat.checkCount > 0 && !this.stat.checkAll;
    };
    // #endregion
    // #region search
    NzTransferListComponent.prototype.handleFilter = function (value) {
        var _this = this;
        this.filter = value;
        this.dataSource.forEach(function (item) {
            item.hide = value.length > 0 && !_this.matchFilter(value, item);
        });
        this.stat.shownCount = this.dataSource.filter(function (w) { return !w.hide; }).length;
        this.filterChange.emit({ direction: this.direction, value: value });
    };
    NzTransferListComponent.prototype.handleClear = function () {
        this.handleFilter('');
    };
    NzTransferListComponent.prototype.matchFilter = function (text, item) {
        if (this.filterOption) {
            return this.filterOption(text, item);
        }
        return item.title.includes(text);
    };
    NzTransferListComponent.prototype.ngOnChanges = function (changes) {
        if ('footer' in changes) {
            this.setClassMap();
        }
    };
    NzTransferListComponent.prototype.ngOnInit = function () {
        this.setClassMap();
    };
    NzTransferListComponent.prototype.markForCheck = function () {
        this.updateCheckStatus();
        this.cdr.markForCheck();
    };
    /** @nocollapse */ NzTransferListComponent.ɵfac = function NzTransferListComponent_Factory(t) { return new (t || NzTransferListComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i1.NzUpdateHostClassService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef)); };
    /** @nocollapse */ NzTransferListComponent.ɵcmp = i0.ɵɵdefineComponent({ type: NzTransferListComponent, selectors: [["nz-transfer-list"]], inputs: { direction: "direction", titleText: "titleText", showSelectAll: "showSelectAll", dataSource: "dataSource", itemUnit: "itemUnit", itemsUnit: "itemsUnit", filter: "filter", disabled: "disabled", showSearch: "showSearch", searchPlaceholder: "searchPlaceholder", notFoundContent: "notFoundContent", filterOption: "filterOption", renderList: "renderList", render: "render", footer: "footer" }, outputs: { handleSelectAll: "handleSelectAll", handleSelect: "handleSelect", filterChange: "filterChange" }, exportAs: ["nzTransferList"], features: [i0.ɵɵProvidersFeature([NzUpdateHostClassService]), i0.ɵɵNgOnChangesFeature], decls: 12, vars: 14, consts: [["defaultRenderList", ""], [1, "ant-transfer-list-header"], ["nz-checkbox", "", 3, "nzChecked", "nzIndeterminate", "nzDisabled", "nzCheckedChange", 4, "ngIf"], [1, "ant-transfer-list-header-selected"], ["class", "ant-transfer-list-header-title", 4, "ngIf"], [3, "ngClass"], ["class", "ant-transfer-list-body-search-wrapper", 4, "ngIf"], [4, "ngIf", "ngIfElse"], ["class", "ant-transfer-list-footer", 4, "ngIf"], ["class", "ant-transfer-list-content", 4, "ngIf"], ["class", "ant-transfer-list-body-not-found", 4, "ngIf"], [1, "ant-transfer-list-content"], ["class", "LazyLoad", 4, "ngFor", "ngForOf"], [1, "LazyLoad"], ["class", "ant-transfer-list-content-item", 3, "ngClass", "click", 4, "ngIf"], [1, "ant-transfer-list-content-item", 3, "ngClass", "click"], ["nz-checkbox", "", 3, "nzChecked", "nzDisabled", "nzCheckedChange", "click"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["renderContainer", ""], [1, "ant-transfer-list-body-not-found"], [3, "nzComponentName", "specificContent"], ["nz-checkbox", "", 3, "nzChecked", "nzIndeterminate", "nzDisabled", "nzCheckedChange"], [1, "ant-transfer-list-header-title"], [1, "ant-transfer-list-body-search-wrapper"], ["nz-transfer-search", "", 3, "placeholder", "disabled", "value", "valueChanged", "valueClear"], [1, "ant-transfer-list-body-customize-wrapper"], [4, "ngTemplateOutlet", "ngTemplateOutletContext"], [1, "ant-transfer-list-footer"]], template: function NzTransferListComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, NzTransferListComponent_ng_template_0_Template, 2, 2, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
            i0.ɵɵelementStart(2, "div", 1);
            i0.ɵɵtemplate(3, NzTransferListComponent_label_3_Template, 1, 3, "label", 2);
            i0.ɵɵelementStart(4, "span", 3);
            i0.ɵɵelementStart(5, "span");
            i0.ɵɵtext(6);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(7, NzTransferListComponent_span_7_Template, 2, 1, "span", 4);
            i0.ɵɵelementEnd();
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(8, "div", 5);
            i0.ɵɵtemplate(9, NzTransferListComponent_div_9_Template, 2, 3, "div", 6);
            i0.ɵɵtemplate(10, NzTransferListComponent_ng_container_10_Template, 3, 9, "ng-container", 7);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(11, NzTransferListComponent_div_11_Template, 2, 4, "div", 8);
        } if (rf & 2) {
            var _r2057 = i0.ɵɵreference(1);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.showSelectAll);
            i0.ɵɵadvance(3);
            i0.ɵɵtextInterpolate2("", (ctx.stat.checkCount > 0 ? ctx.stat.checkCount + "/" : "") + ctx.stat.shownCount, " ", ctx.dataSource.length > 1 ? ctx.itemsUnit : ctx.itemUnit, "");
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.titleText);
            i0.ɵɵadvance(1);
            i0.ɵɵclassMap(ctx.showSearch ? "ant-transfer-list-body ant-transfer-list-body-with-search" : "ant-transfer-list-body");
            i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(12, _c3, ctx.stat.shownCount === 0));
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.showSearch);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.renderList)("ngIfElse", _r2057);
            i0.ɵɵadvance(1);
            i0.ɵɵproperty("ngIf", ctx.footer);
        } }, directives: [i2.NgIf, i2.NgClass, i2.NgForOf, i3.NzCheckboxComponent, i2.NgTemplateOutlet, i4.NzEmbedEmptyComponent, i5.NzTransferSearchComponent], encapsulation: 2, changeDetection: 0 });
    return NzTransferListComponent;
}());
export { NzTransferListComponent };
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(NzTransferListComponent, [{
        type: Component,
        args: [{
                selector: 'nz-transfer-list',
                exportAs: 'nzTransferList',
                preserveWhitespaces: false,
                providers: [NzUpdateHostClassService],
                templateUrl: './nz-transfer-list.component.html',
                encapsulation: ViewEncapsulation.None,
                changeDetection: ChangeDetectionStrategy.OnPush
            }]
    }], function () { return [{ type: i0.ElementRef }, { type: i1.NzUpdateHostClassService }, { type: i0.ChangeDetectorRef }]; }, { direction: [{
            type: Input
        }], titleText: [{
            type: Input
        }], showSelectAll: [{
            type: Input
        }], dataSource: [{
            type: Input
        }], itemUnit: [{
            type: Input
        }], itemsUnit: [{
            type: Input
        }], filter: [{
            type: Input
        }], disabled: [{
            type: Input
        }], showSearch: [{
            type: Input
        }], searchPlaceholder: [{
            type: Input
        }], notFoundContent: [{
            type: Input
        }], filterOption: [{
            type: Input
        }], renderList: [{
            type: Input
        }], render: [{
            type: Input
        }], footer: [{
            type: Input
        }], handleSelectAll: [{
            type: Output
        }], handleSelect: [{
            type: Output
        }], filterChange: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 