import { Component } from '@angular/core';
import { plainToClassFromExist } from 'class-transformer';
import { SortOrder } from '../../../domain';
import { CaseField } from '../../../domain/definition';
import { AbstractFieldReadComponent } from '../base-field/abstract-field-read.component';
import * as i0 from "@angular/core";
function ReadComplexFieldCollectionTableComponent_th_10_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "th", 8)(1, "span", 4);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "a", 9);
    i0.ɵɵpipe(5, "rpxTranslate");
    i0.ɵɵlistener("click", function ReadComplexFieldCollectionTableComponent_th_10_Template_a_click_4_listener($event) { const heading_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); ctx_r2.sortRowsByColumns(heading_r2); return i0.ɵɵresetView($event.preventDefault()); })("keyup.enter", function ReadComplexFieldCollectionTableComponent_th_10_Template_a_keyup_enter_4_listener() { const heading_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.sortRowsByColumns(heading_r2)); });
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const heading_r2 = ctx.$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 3, ctx_r2.columnsAllLabels[heading_r2].label));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("innerHTML", ctx_r2.sortWidget(ctx_r2.columnsAllLabels[heading_r2]), i0.ɵɵsanitizeHtml);
    i0.ɵɵattribute("aria-label", i0.ɵɵpipeBind1(5, 5, "Sort " + ctx_r2.columnsAllLabels[heading_r2].label));
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_div_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵelement(1, "ccd-field-read", 18);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const heading_r6 = i0.ɵɵnextContext().$implicit;
    const item_r7 = i0.ɵɵnextContext().$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("caseField", ctx_r2.toCaseField(heading_r6, item_r7[heading_r6].label, ctx_r2.columnsHorizontalLabel[heading_r6].type, item_r7[heading_r6]))("context", ctx_r2.context);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵtext(1, "\u00A0");
    i0.ɵɵelementEnd();
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "td", 4);
    i0.ɵɵtemplate(2, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_div_2_Template, 2, 2, "div", 17)(3, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_ng_template_3_Template, 2, 0, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementEnd();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const heading_r6 = ctx.$implicit;
    const showEmptyTd_r8 = i0.ɵɵreference(4);
    const item_r7 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", item_r7[heading_r6])("ngIfElse", showEmptyTd_r8);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_1_td_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td", 4);
    i0.ɵɵelement(1, "ccd-field-read", 18);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vLabel_r9 = i0.ɵɵnextContext(2).$implicit;
    const item_r7 = i0.ɵɵnextContext().$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("caseField", ctx_r2.toCaseField("", vLabel_r9.label, vLabel_r9.field_type, item_r7[vLabel_r9.id]))("context", ctx_r2.context);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 21)(1, "th", 8)(2, "span", 4);
    i0.ɵɵtext(3);
    i0.ɵɵpipe(4, "rpxTranslate");
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(5, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_1_td_5_Template, 2, 2, "td", 22);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const vLabel_r9 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("hidden", vLabel_r9.hidden);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 3, vLabel_r9.label));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", vLabel_r9["type"] !== "Complex");
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_tr_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 25)(1, "td", 23)(2, "span", 4);
    i0.ɵɵelement(3, "ccd-field-read", 18);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const caseField_r10 = i0.ɵɵnextContext().$implicit;
    const ctx_r2 = i0.ɵɵnextContext(4);
    i0.ɵɵproperty("hidden", caseField_r10);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("caseField", caseField_r10)("context", ctx_r2.context);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_td_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td")(1, "span", 4);
    i0.ɵɵelement(2, "ccd-field-read", 18);
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const caseField_r10 = i0.ɵɵnextContext(2).$implicit;
    const ctx_r2 = i0.ɵɵnextContext(4);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("caseField", caseField_r10)("context", ctx_r2.context);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_td_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "td");
    i0.ɵɵelement(1, "ccd-read-case-link-field", 18);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const caseField_r10 = i0.ɵɵnextContext(2).$implicit;
    const vLabel_r9 = i0.ɵɵnextContext(2).$implicit;
    const item_r7 = i0.ɵɵnextContext().$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("caseField", ctx_r2.addCaseReferenceValue(caseField_r10, item_r7[vLabel_r9.id].CaseReference))("context", ctx_r2.context);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 26)(1, "th", 8)(2, "span", 4);
    i0.ɵɵtext(3);
    i0.ɵɵpipe(4, "rpxTranslate");
    i0.ɵɵelementEnd()();
    i0.ɵɵtemplate(5, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_td_5_Template, 3, 2, "td", 27)(6, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_td_6_Template, 2, 2, "td", 27);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const caseField_r10 = i0.ɵɵnextContext().$implicit;
    const vLabel_r9 = i0.ɵɵnextContext(2).$implicit;
    const item_r7 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("hidden", caseField_r10.hidden);
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(4, 4, caseField_r10.label));
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", !(item_r7[vLabel_r9.id] == null ? null : item_r7[vLabel_r9.id].hasOwnProperty("CaseReference")));
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", item_r7[vLabel_r9.id] == null ? null : item_r7[vLabel_r9.id].hasOwnProperty("CaseReference"));
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_tr_1_Template, 4, 3, "tr", 24);
    i0.ɵɵpipe(2, "ccdIsCompound");
    i0.ɵɵtemplate(3, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_ng_template_3_Template, 7, 6, "ng-template", null, 1, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const caseField_r10 = ctx.$implicit;
    const SimpleRow_r11 = i0.ɵɵreference(4);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(2, 2, caseField_r10))("ngIfElse", SimpleRow_r11);
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 14)(1, "td", 23);
    i0.ɵɵtemplate(2, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_ng_container_2_Template, 5, 4, "ng-container", 7);
    i0.ɵɵpipe(3, "ccdReadFieldsFilter");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const vLabel_r9 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("hidden", vLabel_r9.hidden);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind4(3, 2, vLabel_r9, true, undefined, true));
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_1_Template, 6, 5, "tr", 19)(2, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_tr_2_Template, 4, 7, "tr", 20);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const vLabel_r9 = ctx.$implicit;
    const item_r7 = i0.ɵɵnextContext().$implicit;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", item_r7[vLabel_r9.id]);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", vLabel_r9["type"] === "Complex" && ctx_r2.addCaseFieldValue(vLabel_r9, item_r7[vLabel_r9.id]));
} }
function ReadComplexFieldCollectionTableComponent_ng_container_12_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "tr", 10);
    i0.ɵɵlistener("keyup", function ReadComplexFieldCollectionTableComponent_ng_container_12_Template_tr_keyup_1_listener($event) { const i_r5 = i0.ɵɵrestoreView(_r4).index; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView($event.key === "Enter" ? (ctx_r2.isHidden[i_r5] = !ctx_r2.isHidden[i_r5]) : null); })("click", function ReadComplexFieldCollectionTableComponent_ng_container_12_Template_tr_click_1_listener() { const i_r5 = i0.ɵɵrestoreView(_r4).index; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView((ctx_r2.isHidden[i_r5] = !ctx_r2.isHidden[i_r5])); });
    i0.ɵɵtemplate(2, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_2_Template, 5, 2, "ng-container", 7);
    i0.ɵɵelementStart(3, "td")(4, "div", 11)(5, "a", 12);
    i0.ɵɵlistener("click", function ReadComplexFieldCollectionTableComponent_ng_container_12_Template_a_click_5_listener($event) { i0.ɵɵrestoreView(_r4); return i0.ɵɵresetView($event.preventDefault()); });
    i0.ɵɵelement(6, "img", 13);
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementStart(7, "tr", 14)(8, "td", 15)(9, "table", 16)(10, "tbody");
    i0.ɵɵtemplate(11, ReadComplexFieldCollectionTableComponent_ng_container_12_ng_container_11_Template, 3, 2, "ng-container", 7);
    i0.ɵɵpipe(12, "keyvalue");
    i0.ɵɵpipe(13, "ccdCollectionTableCaseFieldsFilter");
    i0.ɵɵpipe(14, "ccdReadFieldsFilter");
    i0.ɵɵelementEnd()()()();
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const i_r5 = ctx.index;
    const ctx_r2 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵclassProp("last-accordion", ctx_r2.isHidden[i_r5]);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngForOf", ctx_r2.columns);
    i0.ɵɵadvance(4);
    i0.ɵɵpropertyInterpolate("src", ctx_r2.getImage(i_r5), i0.ɵɵsanitizeUrl);
    i0.ɵɵadvance();
    i0.ɵɵproperty("hidden", ctx_r2.isHidden[i_r5]);
    i0.ɵɵadvance();
    i0.ɵɵproperty("colSpan", ctx_r2.columns.length + 1);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind4(14, 14, i0.ɵɵpipeBind3(13, 10, i0.ɵɵpipeBind2(12, 7, ctx_r2.columnsVerticalLabel, ctx_r2.keepOriginalOrder), ctx_r2.caseField, ctx_r2.rows[i_r5]), true, undefined, true));
} }
export class ReadComplexFieldCollectionTableComponent extends AbstractFieldReadComponent {
    columns;
    columnsVerticalLabel;
    columnsHorizontalLabel;
    columnsAllLabels;
    rows = [];
    isHidden = [];
    static isSortAscending(column) {
        return !(column.sortOrder === SortOrder.UNSORTED || column.sortOrder === SortOrder.DESCENDING);
    }
    ngOnInit() {
        super.ngOnInit();
        if (this.caseField.display_context_parameter
            && this.caseField.display_context_parameter.trim().startsWith('#TABLE(')) {
            const displayContextParameter = this.caseField.display_context_parameter.trim();
            const result = displayContextParameter.replace('#TABLE(', '');
            this.columns = result.replace(')', '').split(',').map((c) => c.trim());
            const labelsVertical = {};
            const labelsHorizontal = {};
            const allLabels = {};
            this.populateCaseFieldValuesIntoRows();
            this.populateLabels(labelsVertical, allLabels);
            this.populateHorizontalLabels(labelsHorizontal, allLabels, labelsVertical);
            this.columnsVerticalLabel = labelsVertical;
            this.columnsHorizontalLabel = labelsHorizontal;
            this.columnsAllLabels = allLabels;
        }
    }
    getImage(row) {
        if (this.isHidden[row]) {
            return 'assets/img/accordion-plus.png';
        }
        else {
            if (this.isVerticleDataNotEmpty(row)) {
                return 'assets/img/accordion-minus.png';
            }
            else {
                this.isHidden[row] = true;
                return 'assets/img/accordion-plus.png';
            }
        }
    }
    /**
     * Needs to be called before 'ccdFieldsFilter' pipe is used, as it needs a caseField value.
     */
    addCaseFieldValue(field, value) {
        field.value = value;
        return true;
    }
    isNotBlank(value) {
        return value !== null && value !== '';
    }
    addCaseReferenceValue(field, value) {
        field.value = { CaseReference: value };
        return field;
    }
    toCaseField(id, label, fieldType, value) {
        return plainToClassFromExist(new CaseField(), {
            id,
            label,
            display_context: 'READONLY',
            value,
            field_type: fieldType
        });
    }
    keepOriginalOrder = (a, b) => a.key;
    sortRowsByColumns(column) {
        const shouldSortInAscendingOrder = this.columnsHorizontalLabel[column].sortOrder === SortOrder.UNSORTED
            || this.columnsHorizontalLabel[column].sortOrder === SortOrder.DESCENDING;
        // tslint:disable-next-line:switch-default
        switch (this.columnsHorizontalLabel[column].type.type) {
            case 'Number':
            case 'MoneyGBP': {
                if (shouldSortInAscendingOrder) {
                    this.rows.sort((a, b) => a[column] - b[column]);
                    this.columnsHorizontalLabel[column].sortOrder = SortOrder.ASCENDING;
                }
                else {
                    this.rows.sort((a, b) => b[column] - a[column]);
                    this.columnsHorizontalLabel[column].sortOrder = SortOrder.DESCENDING;
                }
                break;
            }
            case 'Text':
            case 'TextArea':
            case 'Email':
            case 'Date':
            case 'DateTime':
            case 'Label':
            case 'Postcode':
            case 'YesOrNo':
            case 'PhoneUK':
            case 'FixedList':
                {
                    if (shouldSortInAscendingOrder) {
                        this.rows.sort((a, b) => a[column] < b[column] ? -1 : a[column] > b[column] ? 1 : 0);
                        this.columnsHorizontalLabel[column].sortOrder = SortOrder.ASCENDING;
                    }
                    else {
                        this.rows.sort((a, b) => a[column] < b[column] ? 1 : a[column] > b[column] ? -1 : 0);
                        this.columnsHorizontalLabel[column].sortOrder = SortOrder.DESCENDING;
                    }
                }
                break;
        }
    }
    sortWidget(column) {
        return ReadComplexFieldCollectionTableComponent.isSortAscending(column) ? '&#9660;' : '&#9650;';
    }
    populateHorizontalLabels(labelsHorizontal, allLabels, labelsVertical) {
        for (const id of this.columns) {
            const trimmedId = id.trim();
            labelsHorizontal[trimmedId] = allLabels[trimmedId];
            labelsHorizontal[trimmedId].sortOrder = SortOrder.UNSORTED;
            delete labelsVertical[trimmedId];
        }
    }
    populateLabels(labelsVertical, allLabels) {
        for (const obj of this.caseField.field_type.complex_fields) {
            if (obj.field_type.type === 'FixedList' ||
                obj.field_type.type === 'MultiSelectList' ||
                obj.field_type.type === 'FixedRadioList') {
                labelsVertical[obj.id] = { label: obj.label, type: obj.field_type, caseField: obj };
                allLabels[obj.id] = { label: obj.label, type: obj.field_type };
            }
            else if (obj.isComplex()) {
                labelsVertical[obj.id] = { label: obj.label, type: obj.field_type.type, caseField: obj };
                allLabels[obj.id] = { label: obj.label, type: obj.field_type.type, caseField: obj };
            }
            else {
                labelsVertical[obj.id] = { label: obj.label, type: { type: obj.field_type.type }, caseField: obj };
                allLabels[obj.id] = { label: obj.label, type: { type: obj.field_type.type }, caseField: obj };
            }
        }
    }
    populateCaseFieldValuesIntoRows() {
        for (const obj of this.caseField.value) {
            this.rows.push(obj.value);
            this.isHidden.push(true);
        }
    }
    isVerticleDataNotEmpty(row) {
        let result = false;
        for (const key in this.columnsVerticalLabel) {
            if (this.rows[row][key]) {
                result = true;
            }
        }
        return result;
    }
    static ɵfac = /*@__PURE__*/ (() => { let ɵReadComplexFieldCollectionTableComponent_BaseFactory; return function ReadComplexFieldCollectionTableComponent_Factory(__ngFactoryType__) { return (ɵReadComplexFieldCollectionTableComponent_BaseFactory || (ɵReadComplexFieldCollectionTableComponent_BaseFactory = i0.ɵɵgetInheritedFactory(ReadComplexFieldCollectionTableComponent)))(__ngFactoryType__ || ReadComplexFieldCollectionTableComponent); }; })();
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ReadComplexFieldCollectionTableComponent, selectors: [["ccd-read-complex-field-collection-table"]], features: [i0.ɵɵInheritDefinitionFeature], decls: 13, vars: 6, consts: [["showEmptyTd", ""], ["SimpleRow", ""], [1, "complex-panel", 3, "hidden"], [1, "complex-panel-title"], [1, "text-16"], ["aria-describedby", "complex panel table", 1, "complex-panel-table"], ["scope", "col", 4, "ngFor", "ngForOf"], [4, "ngFor", "ngForOf"], ["scope", "col"], ["href", "#", 1, "sort-widget", 3, "click", "keyup.enter", "innerHTML"], [1, "new-table-row", "accordion-heading", 3, "keyup", "click"], [2, "float", "right"], ["href", "#", 3, "click"], ["alt", "accordion-img", 1, "accordion-image", 3, "src"], [3, "hidden"], [3, "colSpan"], ["aria-describedby", "complex panel table expanded", 1, "complex-panel-table"], [4, "ngIf", "ngIfElse"], [3, "caseField", "context"], ["class", "complex-panel-simple-field accordion-body", 3, "hidden", 4, "ngIf"], [3, "hidden", 4, "ngIf"], [1, "complex-panel-simple-field", "accordion-body", 3, "hidden"], ["class", "text-16", 4, "ngIf"], ["colspan", "2"], ["class", "complex-panel-compound-field", 3, "hidden", 4, "ngIf", "ngIfElse"], [1, "complex-panel-compound-field", 3, "hidden"], [1, "complex-panel-nested-field", 3, "hidden"], [4, "ngIf"]], template: function ReadComplexFieldCollectionTableComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 2)(1, "dl", 3)(2, "dt")(3, "span", 4);
            i0.ɵɵtext(4);
            i0.ɵɵpipe(5, "rpxTranslate");
            i0.ɵɵelementEnd()();
            i0.ɵɵelement(6, "dd");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(7, "table", 5)(8, "tbody")(9, "tr");
            i0.ɵɵtemplate(10, ReadComplexFieldCollectionTableComponent_th_10_Template, 6, 7, "th", 6);
            i0.ɵɵelement(11, "th");
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(12, ReadComplexFieldCollectionTableComponent_ng_container_12_Template, 15, 19, "ng-container", 7);
            i0.ɵɵelementEnd()()();
        } if (rf & 2) {
            i0.ɵɵproperty("hidden", ctx.caseField.hidden);
            i0.ɵɵadvance(4);
            i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(5, 4, ctx.caseField.label));
            i0.ɵɵadvance(6);
            i0.ɵɵproperty("ngForOf", ctx.columns);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngForOf", ctx.rows);
        } }, styles: [".complex-panel[_ngcontent-%COMP%]{margin:13px 0;border:1px solid #bfc1c3}.complex-panel[_ngcontent-%COMP%]   .complex-panel-title[_ngcontent-%COMP%]{background-color:#dee0e2;padding:5px 5px 2px;border-bottom:1px solid #bfc1c3;display:block;color:#0b0c0c;font-family:nta,Arial,sans-serif;font-weight:700;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.complex-panel[_ngcontent-%COMP%]   .complex-panel-title[_ngcontent-%COMP%]{font-size:19px;line-height:1.3157894737}}.complex-panel[_ngcontent-%COMP%]   .complex-panel-table[_ngcontent-%COMP%] > tbody[_ngcontent-%COMP%] > tr[_ngcontent-%COMP%] > th[_ngcontent-%COMP%]{vertical-align:top}.complex-panel[_ngcontent-%COMP%]   .complex-panel-table[_ngcontent-%COMP%] > tbody[_ngcontent-%COMP%] > tr[_ngcontent-%COMP%]:last-child > th[_ngcontent-%COMP%]{border-bottom:none}.complex-panel[_ngcontent-%COMP%]   .complex-panel-table[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]{padding-left:5px;font-weight:700;border-bottom:none}.complex-panel[_ngcontent-%COMP%]   .complex-panel-table[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{padding-left:5px;padding-top:0;padding-bottom:0;border-bottom:none}.complex-panel[_ngcontent-%COMP%]   .new-table-row[_ngcontent-%COMP%]{border-top:1px solid #bfc1c3}.complex-panel[_ngcontent-%COMP%]   .complex-panel-simple-field[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]{padding-left:5px;padding-top:0;padding-bottom:0;width:295px}.complex-panel[_ngcontent-%COMP%]   .complex-panel-nested-field[_ngcontent-%COMP%]   th[_ngcontent-%COMP%]{padding-left:33px;padding-top:0;padding-bottom:0;width:200px}.complex-panel[_ngcontent-%COMP%]   .complex-panel-compound-field[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{padding:5px;border-bottom:none}.sort-widget[_ngcontent-%COMP%]{cursor:pointer;text-decoration:none;color:#0b0c0c}.accordion-wrapper[_ngcontent-%COMP%]{margin-bottom:20px}.accordion-wrapper[_ngcontent-%COMP%]   .heading-medium[_ngcontent-%COMP%]{margin:0}.accordion-wrapper[_ngcontent-%COMP%]   .accordion-heading[_ngcontent-%COMP%]{border-top:1px solid #bfc1c3;padding-top:20px;padding-bottom:10px;height:20px;cursor:pointer}.accordion-wrapper[_ngcontent-%COMP%]   .accordion-heading[_ngcontent-%COMP%]   .accordion-image[_ngcontent-%COMP%]{width:25px;margin-right:20px}.accordion-wrapper[_ngcontent-%COMP%]   .accordion-body[_ngcontent-%COMP%]{margin-top:20px;margin-right:20px}.accordion-wrapper[_ngcontent-%COMP%]   .last-accordion[_ngcontent-%COMP%]{border-bottom:1px solid #bfc1c3;padding-bottom:30px}"] });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ReadComplexFieldCollectionTableComponent, [{
        type: Component,
        args: [{ selector: 'ccd-read-complex-field-collection-table', template: "<div class=\"complex-panel\" [hidden]=\"caseField.hidden\">\n  <dl class=\"complex-panel-title\">\n    <dt><span class=\"text-16\">{{caseField.label | rpxTranslate}}</span></dt>\n    <dd></dd>\n  </dl>\n  <table class=\"complex-panel-table\" aria-describedby=\"complex panel table\">\n    <tbody>\n    <!-- <COMPLEX table field header>-->\n    <tr>\n      <th *ngFor=\"let heading of columns\" scope=\"col\">\n        <span class=\"text-16\">{{columnsAllLabels[heading].label | rpxTranslate}}</span>\n        <a href=\"#\"\n           (click)=\"sortRowsByColumns(heading); $event.preventDefault()\"\n           (keyup.enter)=\"sortRowsByColumns(heading)\"\n           class=\"sort-widget\"\n           [attr.aria-label]=\"'Sort ' + columnsAllLabels[heading].label | rpxTranslate\"\n           [innerHTML]=\"sortWidget(columnsAllLabels[heading])\"></a>\n      </th>\n      <th></th>\n    </tr>\n    <!-- </COMPLEX table field header>-->\n    <ng-container *ngFor=\"let item of rows; let i = index;\">\n      <!-- <COMPLEX table collapsed view>-->\n      <tr class=\"new-table-row accordion-heading\" (keyup)=\"$event.key === 'Enter' ? (isHidden[i] = !isHidden[i]) : null\" (click)=\"isHidden[i] = !isHidden[i]\"\n          [class.last-accordion]=\"isHidden[i]\">\n        <ng-container *ngFor=\"let heading of columns\">\n          <td class=\"text-16\">\n            <div *ngIf=\"item[heading]; else showEmptyTd\">\n              <ccd-field-read\n                [caseField]=\"toCaseField(heading, item[heading].label, columnsHorizontalLabel[heading].type, item[heading])\"\n                [context]=\"context\"></ccd-field-read>\n            </div>\n            <ng-template #showEmptyTd>\n              <div>&nbsp;</div>\n            </ng-template>\n          </td>\n        </ng-container>\n        <td>\n          <div style=\"float: right;\">\n            <a href=\"#\" (click)=\"$event.preventDefault()\"> <img src=\"{{ getImage(i) }}\" alt=\"accordion-img\" class=\"accordion-image\"/></a>\n          </div>\n        </td>\n      </tr>\n      <!-- </COMPLEX table collapsed view>-->\n      <!-- <COMPLEX table expanded view>-->\n      <tr [hidden]=\"isHidden[i]\">\n        <td [colSpan]=\"columns.length + 1\">\n          <table class=\"complex-panel-table\" aria-describedby=\"complex panel table expanded\">\n            <tbody>\n            <ng-container\n              *ngFor=\"let vLabel of columnsVerticalLabel | keyvalue: keepOriginalOrder | ccdCollectionTableCaseFieldsFilter: caseField: rows[i] | ccdReadFieldsFilter:true :undefined :true\">\n              <!-- <COMPLEX table expandable body simple field>-->\n              <tr class=\"complex-panel-simple-field accordion-body\" *ngIf=\"item[vLabel.id]\" [hidden]=\"vLabel.hidden\">\n                <th scope=\"col\"><span class=\"text-16\">{{ vLabel.label | rpxTranslate }}</span></th>\n                <td *ngIf=\"vLabel['type'] !== 'Complex'\" class=\"text-16\">\n                  <ccd-field-read [caseField]=\"toCaseField('', vLabel.label, vLabel.field_type, item[vLabel.id])\"\n                                  [context]=\"context\"></ccd-field-read>\n                </td>\n              </tr>\n              <!-- </COMPLEX table expandable body simple field>-->\n\n              <!-- <COMPLEX table expandable body complex field>-->\n              <tr *ngIf=\"vLabel['type'] === 'Complex' && addCaseFieldValue(vLabel, item[vLabel.id])\" [hidden]=\"vLabel.hidden\">\n                <td colspan=\"2\">\n                  <ng-container *ngFor=\"let caseField of vLabel | ccdReadFieldsFilter:true :undefined :true\">\n                      <tr class=\"complex-panel-compound-field\" *ngIf=\"(caseField | ccdIsCompound); else SimpleRow\" [hidden]=\"caseField\">\n                        <td colspan=\"2\">\n                          <span class=\"text-16\"><ccd-field-read [caseField]=\"caseField\" [context]=\"context\"></ccd-field-read></span>\n                        </td>\n                      </tr>\n                      <ng-template #SimpleRow>\n                        <tr class=\"complex-panel-nested-field\" [hidden]=\"caseField.hidden\">\n                          <th scope=\"col\"><span class=\"text-16\">{{caseField.label | rpxTranslate}}</span></th>\n                          <td *ngIf=\"!item[vLabel.id]?.hasOwnProperty('CaseReference')\">\n                            <span class=\"text-16\"><ccd-field-read [caseField]=\"caseField\" [context]=\"context\"></ccd-field-read></span>\n                          </td>\n                          <td *ngIf=\"item[vLabel.id]?.hasOwnProperty('CaseReference')\">\n                            <ccd-read-case-link-field [caseField]=\"addCaseReferenceValue(caseField, item[vLabel.id].CaseReference)\" [context]=\"context\"></ccd-read-case-link-field>\n                          </td>\n                        </tr>\n                      </ng-template>\n                  </ng-container>\n                </td>\n              </tr>\n              <!-- <COMPLEX table expandable body complex field>-->\n            </ng-container>\n            </tbody>\n          </table>\n        </td>\n      </tr>\n      <!-- </COMPLEX table expanded view>-->\n    </ng-container>\n    </tbody>\n  </table>\n</div>\n", styles: [".complex-panel{margin:13px 0;border:1px solid #bfc1c3}.complex-panel .complex-panel-title{background-color:#dee0e2;padding:5px 5px 2px;border-bottom:1px solid #bfc1c3;display:block;color:#0b0c0c;font-family:nta,Arial,sans-serif;font-weight:700;text-transform:none;font-size:16px;line-height:1.25}@media (min-width: 641px){.complex-panel .complex-panel-title{font-size:19px;line-height:1.3157894737}}.complex-panel .complex-panel-table>tbody>tr>th{vertical-align:top}.complex-panel .complex-panel-table>tbody>tr:last-child>th{border-bottom:none}.complex-panel .complex-panel-table th{padding-left:5px;font-weight:700;border-bottom:none}.complex-panel .complex-panel-table td{padding-left:5px;padding-top:0;padding-bottom:0;border-bottom:none}.complex-panel .new-table-row{border-top:1px solid #bfc1c3}.complex-panel .complex-panel-simple-field th{padding-left:5px;padding-top:0;padding-bottom:0;width:295px}.complex-panel .complex-panel-nested-field th{padding-left:33px;padding-top:0;padding-bottom:0;width:200px}.complex-panel .complex-panel-compound-field td{padding:5px;border-bottom:none}.sort-widget{cursor:pointer;text-decoration:none;color:#0b0c0c}.accordion-wrapper{margin-bottom:20px}.accordion-wrapper .heading-medium{margin:0}.accordion-wrapper .accordion-heading{border-top:1px solid #bfc1c3;padding-top:20px;padding-bottom:10px;height:20px;cursor:pointer}.accordion-wrapper .accordion-heading .accordion-image{width:25px;margin-right:20px}.accordion-wrapper .accordion-body{margin-top:20px;margin-right:20px}.accordion-wrapper .last-accordion{border-bottom:1px solid #bfc1c3;padding-bottom:30px}\n"] }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ReadComplexFieldCollectionTableComponent, { className: "ReadComplexFieldCollectionTableComponent", filePath: "lib/shared/components/palette/complex/read-complex-field-collection-table.component.ts", lineNumber: 12 }); })();
//# sourceMappingURL=data:application/json;base64, 