import { rgbColor } from '@alauda/ui';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, Directive, EventEmitter, Injector, Input, Output, QueryList, TemplateRef, } from '@angular/core';
import { UntypedFormArray, UntypedFormGroup, FormGroupDirective, NgForm, } from '@angular/forms';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
function ArrayFormTableComponent_thead_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function ArrayFormTableComponent_thead_1_th_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "th", 6);
} }
function ArrayFormTableComponent_thead_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "thead")(1, "tr");
    i0.ɵɵtemplate(2, ArrayFormTableComponent_thead_1_ng_container_2_Template, 1, 0, "ng-container", 4);
    i0.ɵɵtemplate(3, ArrayFormTableComponent_thead_1_th_3_Template, 1, 0, "th", 5);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.headerTemplate);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r0.readonly && ctx_r0.minRow !== ctx_r0.maxRow);
} }
function ArrayFormTableComponent_ng_container_3_ng_container_1_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_ng_container_1_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
const _c0 = function (a0, a1) { return { $implicit: a0, index: a1 }; };
function ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_ng_container_1_ng_container_1_Template, 1, 0, "ng-container", 8);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r17 = i0.ɵɵnextContext(3);
    const row_r6 = ctx_r17.$implicit;
    const index_r7 = ctx_r17.index;
    const ctx_r14 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r14.rowControlTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(2, _c0, row_r6, index_r7));
} }
function ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_button_2_Template(rf, ctx) { if (rf & 1) {
    const _r20 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 11);
    i0.ɵɵlistener("click", function ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_button_2_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r20); const index_r7 = i0.ɵɵnextContext(3).index; const ctx_r18 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r18.remove.emit(index_r7)); });
    i0.ɵɵelement(1, "aui-icon", 12);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r15 = i0.ɵɵnextContext(4);
    i0.ɵɵproperty("disabled", (ctx_r15.rows == null ? null : ctx_r15.rows.length) <= ctx_r15.minRow)("square", true)("plain", true);
} }
function ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td", 6);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_ng_container_1_Template, 2, 5, "ng-container", 1);
    i0.ɵɵtemplate(2, ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_button_2_Template, 2, 3, "button", 10);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r13 = i0.ɵɵnextContext(3);
    i0.ɵɵclassProp("acl-array-form-table__action-col-divider", ctx_r13.actionColumnDivider);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r13.rowControlTemplate);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r13.rowControlTemplate);
} }
function ArrayFormTableComponent_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "tr");
    i0.ɵɵtemplate(2, ArrayFormTableComponent_ng_container_3_ng_container_1_ng_container_2_Template, 1, 0, "ng-container", 8);
    i0.ɵɵtemplate(3, ArrayFormTableComponent_ng_container_3_ng_container_1_td_3_Template, 3, 4, "td", 9);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const rowTemplate_r10 = ctx.$implicit;
    const templateIndex_r11 = ctx.index;
    const ctx_r21 = i0.ɵɵnextContext();
    const row_r6 = ctx_r21.$implicit;
    const index_r7 = ctx_r21.index;
    const ctx_r8 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵclassProp("acl-array-form-table__row-error", ctx_r8.shouldShowRowError(row_r6));
    i0.ɵɵattribute("rowtemplateindex", templateIndex_r11);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", rowTemplate_r10)("ngTemplateOutletContext", i0.ɵɵpureFunction2(6, _c0, row_r6, index_r7));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", templateIndex_r11 === 0 && !ctx_r8.readonly && ctx_r8.minRow !== ctx_r8.maxRow);
} }
function ArrayFormTableComponent_ng_container_3_tr_2_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function ArrayFormTableComponent_ng_container_3_tr_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 13);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_ng_container_3_tr_2_ng_container_1_Template, 1, 0, "ng-container", 8);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r23 = i0.ɵɵnextContext();
    const row_r6 = ctx_r23.$implicit;
    const index_r7 = ctx_r23.index;
    const ctx_r9 = i0.ɵɵnextContext();
    i0.ɵɵclassProp("acl-array-form-table__row-error", ctx_r9.shouldShowRowError(row_r6));
    i0.ɵɵproperty("hidden", !ctx_r9.shouldShowRowError(row_r6));
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r9.rowErrorTemplate)("ngTemplateOutletContext", i0.ɵɵpureFunction2(5, _c0, row_r6, index_r7));
} }
function ArrayFormTableComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_ng_container_3_ng_container_1_Template, 4, 9, "ng-container", 2);
    i0.ɵɵtemplate(2, ArrayFormTableComponent_ng_container_3_tr_2_Template, 2, 8, "tr", 7);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngForOf", ctx_r1.rowTemplates);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.rowErrorTemplate && !ctx_r1.readonly);
} }
function ArrayFormTableComponent_tr_4_acl_zero_state_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "acl-zero-state", 16);
} if (rf & 2) {
    const ctx_r24 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("zeroState", true)("resourceName", ctx_r24.resourceName)("minHeight", 48);
} }
function ArrayFormTableComponent_tr_4_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function ArrayFormTableComponent_tr_4_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_tr_4_ng_container_3_ng_container_1_Template, 1, 0, "ng-container", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r25 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r25.zeroStateTemplate);
} }
function ArrayFormTableComponent_tr_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr")(1, "td", 14);
    i0.ɵɵtemplate(2, ArrayFormTableComponent_tr_4_acl_zero_state_2_Template, 1, 3, "acl-zero-state", 15);
    i0.ɵɵtemplate(3, ArrayFormTableComponent_tr_4_ng_container_3_Template, 2, 1, "ng-container", 1);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !ctx_r2.zeroStateTemplate);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r2.zeroStateTemplate);
} }
function ArrayFormTableComponent_tr_5_ng_container_3_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function ArrayFormTableComponent_tr_5_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ArrayFormTableComponent_tr_5_ng_container_3_ng_container_1_Template, 1, 0, "ng-container", 4);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r27 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r27.footerTemplate);
} }
function ArrayFormTableComponent_tr_5_button_4_Template(rf, ctx) { if (rf & 1) {
    const _r31 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "button", 21);
    i0.ɵɵlistener("click", function ArrayFormTableComponent_tr_5_button_4_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r31); const ctx_r30 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r30.add.emit()); });
    i0.ɵɵelement(1, "aui-icon", 22);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "translate");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r28 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("plain", true)("disabled", (ctx_r28.rows == null ? null : ctx_r28.rows.length) >= ctx_r28.maxRow || ctx_r28.addDisabled);
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(3, 3, "add"), " ");
} }
function ArrayFormTableComponent_tr_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 17)(1, "td", 18)(2, "div", 19);
    i0.ɵɵtemplate(3, ArrayFormTableComponent_tr_5_ng_container_3_Template, 2, 1, "ng-container", 1);
    i0.ɵɵtemplate(4, ArrayFormTableComponent_tr_5_button_4_Template, 4, 5, "button", 20);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r3 = i0.ɵɵnextContext();
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r3.footerTemplate);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !ctx_r3.footerTemplate);
} }
export const ARRAY_TABLE_FORM_ERROR_BG = rgbColor('r-6');
export const rowBackgroundColorFn = ({ invalid, }) => (invalid ? ARRAY_TABLE_FORM_ERROR_BG : '');
export const noShowRowError = () => false;
export class ArrayFormTableHeaderDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableHeaderDirective.ɵfac = function ArrayFormTableHeaderDirective_Factory(t) { return new (t || ArrayFormTableHeaderDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableHeaderDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableHeaderDirective, selectors: [["", "aclArrayFormTableHeader", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableHeaderDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableHeader]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
export class ArrayFormTableRowErrorDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableRowErrorDirective.ɵfac = function ArrayFormTableRowErrorDirective_Factory(t) { return new (t || ArrayFormTableRowErrorDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableRowErrorDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableRowErrorDirective, selectors: [["", "aclArrayFormTableRowError", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableRowErrorDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableRowError]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
export class ArrayFormTableRowDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableRowDirective.ɵfac = function ArrayFormTableRowDirective_Factory(t) { return new (t || ArrayFormTableRowDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableRowDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableRowDirective, selectors: [["", "aclArrayFormTableRow", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableRowDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableRow]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
export class ArrayFormTableZeroStateDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableZeroStateDirective.ɵfac = function ArrayFormTableZeroStateDirective_Factory(t) { return new (t || ArrayFormTableZeroStateDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableZeroStateDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableZeroStateDirective, selectors: [["", "aclArrayFormTableZeroState", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableZeroStateDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableZeroState]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
export class ArrayFormTableRowControlDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableRowControlDirective.ɵfac = function ArrayFormTableRowControlDirective_Factory(t) { return new (t || ArrayFormTableRowControlDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableRowControlDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableRowControlDirective, selectors: [["", "aclArrayFormTableRowControl", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableRowControlDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableRowControl]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
export class ArrayFormTableFooterDirective {
    constructor(templateRef) {
        this.templateRef = templateRef;
    }
}
ArrayFormTableFooterDirective.ɵfac = function ArrayFormTableFooterDirective_Factory(t) { return new (t || ArrayFormTableFooterDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef)); };
ArrayFormTableFooterDirective.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ArrayFormTableFooterDirective, selectors: [["", "aclArrayFormTableFooter", ""]] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableFooterDirective, [{
        type: Directive,
        args: [{
                selector: '[aclArrayFormTableFooter]',
            }]
    }], function () { return [{ type: i0.TemplateRef }]; }, null); })();
// 递归验证 control 是否有问题，group 内部可能会有嵌套的情况
function _isFormControlInvalid(control) {
    if (control instanceof UntypedFormGroup ||
        control instanceof UntypedFormArray) {
        return ((control.dirty && !!control.errors) ||
            Object.values(control.controls).some(_isFormControlInvalid));
    }
    return control.dirty && control.invalid;
}
export class ArrayFormTableComponent {
    constructor(injector) {
        this.injector = injector;
        // 将使用这个值来渲染无数据提示
        this.resourceName = 'data';
        this.add = new EventEmitter();
        this.remove = new EventEmitter(); // Returns the index to be removed
        this.readonly = false;
        this.addDisabled = false;
        this.actionColumnDivider = false;
        this.minRow = 0;
        this.maxRow = Infinity;
        this.destroy$$ = new Subject();
        this.cdr = this.injector.get(ChangeDetectorRef);
    }
    get formDirective() {
        return (this.injector.get(FormGroupDirective, null) ||
            this.injector.get(NgForm, null));
    }
    /**
     * 自定义是否展示错误内容
     * 例如 control 是 FormGroup，只有在内部子 control 错误时才需要展示错误内容
     */
    showRowError(control, formDirective) {
        if (formDirective) {
            return (control.invalid &&
                (formDirective.submitted || _isFormControlInvalid(control)));
        }
        return false;
    }
    /**
     * @deprecated use `showRowError` instead
     */
    rowBackgroundColorFn(control, formDirective) {
        return this.showRowError(control, formDirective)
            ? ARRAY_TABLE_FORM_ERROR_BG
            : null;
    }
    ngOnDestroy() {
        this.destroy$$.next();
        this.destroy$$.complete();
    }
    shouldShowRowError(control) {
        return this.showRowError(control, this.formDirective);
    }
}
ArrayFormTableComponent.ɵfac = function ArrayFormTableComponent_Factory(t) { return new (t || ArrayFormTableComponent)(i0.ɵɵdirectiveInject(i0.Injector)); };
ArrayFormTableComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ArrayFormTableComponent, selectors: [["acl-array-form-table"]], contentQueries: function ArrayFormTableComponent_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableHeaderDirective, 7, TemplateRef);
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableRowErrorDirective, 5, TemplateRef);
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableRowControlDirective, 7, TemplateRef);
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableFooterDirective, 7, TemplateRef);
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableZeroStateDirective, 5, TemplateRef);
        i0.ɵɵcontentQuery(dirIndex, FormGroupDirective, 5);
        i0.ɵɵcontentQuery(dirIndex, ArrayFormTableRowDirective, 4, TemplateRef);
    } if (rf & 2) {
        let _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.headerTemplate = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rowErrorTemplate = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rowControlTemplate = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.footerTemplate = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.zeroStateTemplate = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.ngFormGroupDirective = _t.first);
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.rowTemplates = _t);
    } }, inputs: { rows: "rows", resourceName: "resourceName", readonly: "readonly", addDisabled: "addDisabled", actionColumnDivider: "actionColumnDivider", showRowError: "showRowError", rowBackgroundColorFn: "rowBackgroundColorFn", minRow: "minRow", maxRow: "maxRow" }, outputs: { add: "add", remove: "remove" }, decls: 6, vars: 6, consts: [[1, "acl-array-form-table"], [4, "ngIf"], [4, "ngFor", "ngForOf"], ["class", "acl-array-form-table--row-action", 4, "ngIf"], [4, "ngTemplateOutlet"], ["class", "acl-array-form-table__action-col", 4, "ngIf"], [1, "acl-array-form-table__action-col"], [3, "acl-array-form-table__row-error", "hidden", 4, "ngIf"], [4, "ngTemplateOutlet", "ngTemplateOutletContext"], ["class", "acl-array-form-table__action-col", 3, "acl-array-form-table__action-col-divider", 4, "ngIf"], ["aui-button", "text", "type", "button", 3, "disabled", "square", "plain", "click", 4, "ngIf"], ["aui-button", "text", "type", "button", 3, "disabled", "square", "plain", "click"], ["icon", "basic:minus_circle"], [3, "hidden"], ["colspan", "100", 2, "padding", "unset"], [3, "zeroState", "resourceName", "minHeight", 4, "ngIf"], [3, "zeroState", "resourceName", "minHeight"], [1, "acl-array-form-table--row-action"], ["colspan", "100"], [1, "acl-array-form-table__bottom-control-buttons"], ["aui-button", "primary", "type", "button", "size", "mini", 3, "plain", "disabled", "click", 4, "ngIf"], ["aui-button", "primary", "type", "button", "size", "mini", 3, "plain", "disabled", "click"], ["icon", "basic:add_circle"]], template: function ArrayFormTableComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "table", 0);
        i0.ɵɵtemplate(1, ArrayFormTableComponent_thead_1_Template, 4, 2, "thead", 1);
        i0.ɵɵelementStart(2, "tbody");
        i0.ɵɵtemplate(3, ArrayFormTableComponent_ng_container_3_Template, 3, 2, "ng-container", 2);
        i0.ɵɵtemplate(4, ArrayFormTableComponent_tr_4_Template, 4, 2, "tr", 1);
        i0.ɵɵtemplate(5, ArrayFormTableComponent_tr_5_Template, 5, 2, "tr", 3);
        i0.ɵɵelementEnd()();
    } if (rf & 2) {
        i0.ɵɵclassProp("acl-array-form-table__readonly-mode", ctx.readonly);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", ctx.headerTemplate);
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngForOf", ctx.rows);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.rows || ctx.rows.length === 0);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("ngIf", !ctx.readonly && ctx.minRow !== ctx.maxRow);
    } }, encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ArrayFormTableComponent, [{
        type: Component,
        args: [{ selector: 'acl-array-form-table', changeDetection: ChangeDetectionStrategy.Default, template: "<table\n  class=\"acl-array-form-table\"\n  [class.acl-array-form-table__readonly-mode]=\"readonly\"\n>\n  <thead *ngIf=\"headerTemplate\">\n    <tr>\n      <ng-container *ngTemplateOutlet=\"headerTemplate\"></ng-container>\n      <th\n        *ngIf=\"!readonly && minRow !== maxRow\"\n        class=\"acl-array-form-table__action-col\"\n      ></th>\n    </tr>\n  </thead>\n  <tbody>\n    <ng-container *ngFor=\"let row of rows; let index = index\">\n      <ng-container\n        *ngFor=\"let rowTemplate of rowTemplates; let templateIndex = index\"\n      >\n        <tr\n          [class.acl-array-form-table__row-error]=\"shouldShowRowError(row)\"\n          [attr.rowtemplateindex]=\"templateIndex\"\n        >\n          <ng-container\n            *ngTemplateOutlet=\"\n              rowTemplate;\n              context: { $implicit: row, index: index }\n            \"\n          ></ng-container>\n          <td\n            *ngIf=\"templateIndex === 0 && !readonly && minRow !== maxRow\"\n            class=\"acl-array-form-table__action-col\"\n            [class.acl-array-form-table__action-col-divider]=\"\n              actionColumnDivider\n            \"\n          >\n            <ng-container *ngIf=\"rowControlTemplate\">\n              <ng-container\n                *ngTemplateOutlet=\"\n                  rowControlTemplate;\n                  context: { $implicit: row, index: index }\n                \"\n              ></ng-container>\n            </ng-container>\n            <button\n              *ngIf=\"!rowControlTemplate\"\n              aui-button=\"text\"\n              type=\"button\"\n              [disabled]=\"rows?.length <= minRow\"\n              [square]=\"true\"\n              [plain]=\"true\"\n              (click)=\"remove.emit(index)\"\n            >\n              <aui-icon icon=\"basic:minus_circle\"></aui-icon>\n            </button>\n          </td>\n        </tr>\n      </ng-container>\n\n      <tr\n        *ngIf=\"rowErrorTemplate && !readonly\"\n        [class.acl-array-form-table__row-error]=\"shouldShowRowError(row)\"\n        [hidden]=\"!shouldShowRowError(row)\"\n      >\n        <ng-container\n          *ngTemplateOutlet=\"\n            rowErrorTemplate;\n            context: { $implicit: row, index: index }\n          \"\n        ></ng-container>\n      </tr>\n    </ng-container>\n\n    <tr *ngIf=\"!rows || rows.length === 0\">\n      <td\n        colspan=\"100\"\n        style=\"padding: unset\"\n      >\n        <acl-zero-state\n          *ngIf=\"!zeroStateTemplate\"\n          [zeroState]=\"true\"\n          [resourceName]=\"resourceName\"\n          [minHeight]=\"48\"\n        ></acl-zero-state>\n\n        <ng-container *ngIf=\"zeroStateTemplate\">\n          <ng-container *ngTemplateOutlet=\"zeroStateTemplate\"></ng-container>\n        </ng-container>\n      </td>\n    </tr>\n\n    <tr\n      *ngIf=\"!readonly && minRow !== maxRow\"\n      class=\"acl-array-form-table--row-action\"\n    >\n      <td colspan=\"100\">\n        <div class=\"acl-array-form-table__bottom-control-buttons\">\n          <ng-container *ngIf=\"footerTemplate\">\n            <ng-container *ngTemplateOutlet=\"footerTemplate\"></ng-container>\n          </ng-container>\n          <button\n            *ngIf=\"!footerTemplate\"\n            aui-button=\"primary\"\n            type=\"button\"\n            [plain]=\"true\"\n            size=\"mini\"\n            (click)=\"add.emit()\"\n            [disabled]=\"rows?.length >= maxRow || addDisabled\"\n          >\n            <aui-icon icon=\"basic:add_circle\"></aui-icon>\n            {{ 'add' | translate }}\n          </button>\n        </div>\n      </td>\n    </tr>\n  </tbody>\n</table>\n" }]
    }], function () { return [{ type: i0.Injector }]; }, { headerTemplate: [{
            type: ContentChild,
            args: [ArrayFormTableHeaderDirective, {
                    read: TemplateRef,
                    static: true,
                }]
        }], rowTemplates: [{
            type: ContentChildren,
            args: [ArrayFormTableRowDirective, { read: TemplateRef }]
        }], rowErrorTemplate: [{
            type: ContentChild,
            args: [ArrayFormTableRowErrorDirective, { read: TemplateRef }]
        }], rowControlTemplate: [{
            type: ContentChild,
            args: [ArrayFormTableRowControlDirective, {
                    read: TemplateRef,
                    static: true,
                }]
        }], footerTemplate: [{
            type: ContentChild,
            args: [ArrayFormTableFooterDirective, {
                    read: TemplateRef,
                    static: true,
                }]
        }], zeroStateTemplate: [{
            type: ContentChild,
            args: [ArrayFormTableZeroStateDirective, {
                    read: TemplateRef,
                    static: false,
                }]
        }], ngFormGroupDirective: [{
            type: ContentChild,
            args: [FormGroupDirective, { static: false }]
        }], rows: [{
            type: Input
        }], resourceName: [{
            type: Input
        }], add: [{
            type: Output
        }], remove: [{
            type: Output
        }], readonly: [{
            type: Input
        }], addDisabled: [{
            type: Input
        }], actionColumnDivider: [{
            type: Input
        }], showRowError: [{
            type: Input
        }], rowBackgroundColorFn: [{
            type: Input
        }], minRow: [{
            type: Input
        }], maxRow: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 