import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, inject, Input, Output, Renderer2 } from '@angular/core';
import { CommonModule } from '@angular/common';
import { fromEvent, Subject, from } from 'rxjs';
import { filter, mergeMap, takeUntil } from 'rxjs/operators';
import { GenericPipe } from '@ironsource/fusion-ui/pipes/generic';
import { TestIdsService } from '@ironsource/fusion-ui/services/test-ids';
import { TableRowClassesEnum, ROW_HOVERED_CLASS_NAME } from '@ironsource/fusion-ui/components/table/common/entities';
import { TableTestIdModifiers } from '@ironsource/fusion-ui/entities';
import { TableService } from '@ironsource/fusion-ui/components/table';
import { TableRowComponent } from '../table-row/table-row.component';
import { TableLoadingComponent } from '../table-loading/table-loading.component';
import { LoadMoreModule } from '@ironsource/fusion-ui/directives/load-more';
import { LinkComponent } from '@ironsource/fusion-ui/components/link';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@ironsource/fusion-ui/directives/load-more";
const _c0 = ["fusionTableBasic", ""];
function _forTrack0($index, $item) { return this.trackByRowInvoke(); }
const _c1 = (a0, a1) => ({ $implicit: a0, parentIndex: a1 });
function TableBasicComponent_For_1_Conditional_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 2);
} if (rf & 2) {
    const ctx_r5 = i0.ɵɵnextContext();
    const row_r3 = ctx_r5.$implicit;
    const ɵ$index_1_r4 = ctx_r5.$index;
    const childRowsTemplate_r7 = i0.ɵɵreference(5);
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngTemplateOutlet", childRowsTemplate_r7)("ngTemplateOutletContext", i0.ɵɵpureFunction2(2, _c1, row_r3[ctx_r4.options.rowsExpandableOptions.key], ɵ$index_1_r4));
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Conditional_1_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0);
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "tr", 7)(1, "td")(2, "div", 8);
    i0.ɵɵtemplate(3, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Conditional_1_ng_container_3_Template, 1, 0, "ng-container", 9);
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const innerEntity_r8 = i0.ɵɵnextContext().ngIf;
    const ctx_r4 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance();
    i0.ɵɵattribute("colspan", ctx_r4.fullCellColspan);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngComponentOutlet", innerEntity_r8[0] == null ? null : innerEntity_r8[0].component == null ? null : innerEntity_r8[0].component.type)("ngComponentOutletInputs", innerEntity_r8[0] == null ? null : innerEntity_r8[0].component == null ? null : innerEntity_r8[0].component.data);
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Conditional_1_Template, 4, 3, "tr", 7);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const innerEntity_r8 = ctx.ngIf;
    i0.ɵɵadvance();
    i0.ɵɵconditional(innerEntity_r8.length ? 1 : -1);
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_ng_container_0_Template, 2, 1, "ng-container", 6);
    i0.ɵɵpipe(1, "async");
} if (rf & 2) {
    const displayRows$_r9 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("ngIf", i0.ɵɵpipeBind1(1, 1, displayRows$_r9));
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Conditional_4_Template(rf, ctx) { if (rf & 1) {
    const _r11 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 12)(1, "td")(2, "div", 13)(3, "fusion-link", 14);
    i0.ɵɵlistener("click", function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Conditional_4_Template_fusion_link_click_3_listener() { i0.ɵɵrestoreView(_r11); const loadMore_r12 = i0.ɵɵnextContext(3).loadMore; return i0.ɵɵresetView(loadMore_r12()); });
    i0.ɵɵtext(4, "Load more");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(6);
    i0.ɵɵadvance();
    i0.ɵɵattribute("colspan", ctx_r4.fullCellColspan);
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r10 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "tr", 11);
    i0.ɵɵpipe(2, "generic");
    i0.ɵɵpipe(3, "async");
    i0.ɵɵlistener("expandRow", function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Template_tr_expandRow_1_listener($event) { i0.ɵɵrestoreView(_r10); const ctx_r4 = i0.ɵɵnextContext(5); return i0.ɵɵresetView(ctx_r4.onExpandRow($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(4, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Conditional_4_Template, 5, 1, "tr", 12);
    i0.ɵɵpipe(5, "async");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const innerRow_r13 = ctx.$implicit;
    const innerRowIndex_r14 = ctx.index;
    const last_r15 = ctx.last;
    const hasMore$_r16 = i0.ɵɵnextContext(2).hasMore$;
    const parentIndex_r17 = i0.ɵɵnextContext().parentIndex;
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵproperty("rowIndex", parentIndex_r17 + "_" + innerRowIndex_r14)("row", innerRow_r13)("columns", ctx_r4.options.rowsExpandableOptions.columns)("options", ctx_r4.childRowOptions)("isExpanded", ctx_r4.isExpanded(parentIndex_r17 + "_" + innerRowIndex_r14))("isInnerRow", true)("ngClass", i0.ɵɵpipeBind3(2, 10, ctx_r4.rowClass, innerRow_r13, innerRowIndex_r14))("hasAfterSticky", ctx_r4.hasAfterSticky(last_r15, i0.ɵɵpipeBind1(3, 14, hasMore$_r16), parentIndex_r17 + "_" + innerRowIndex_r14))("ngStyle", !!(ctx_r4.options == null ? null : ctx_r4.options.rowsOptions == null ? null : ctx_r4.options.rowsOptions.global) ? ctx_r4.options.rowsOptions.global.style : null);
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(!ctx_r4.loadingChildRows[parentIndex_r17] && i0.ɵɵpipeBind1(5, 16, hasMore$_r16) && last_r15 ? 4 : -1);
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_ng_container_0_Template, 6, 18, "ng-container", 10);
    i0.ɵɵpipe(1, "async");
} if (rf & 2) {
    const displayRows$_r9 = i0.ɵɵnextContext().$implicit;
    const ctx_r4 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(1, 2, displayRows$_r9))("ngForTrackBy", ctx_r4.trackByRowInvoke());
} }
function TableBasicComponent_For_1_ng_template_4_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_1_Template, 2, 3, "ng-container")(2, TableBasicComponent_For_1_ng_template_4_ng_container_0_Conditional_2_Template, 2, 4, "ng-container");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r4.isInnerEntityType("dynamicComponent") ? 1 : 2);
} }
function TableBasicComponent_For_1_ng_template_4_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "tr", 4);
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(3);
    i0.ɵɵproperty("fusionTableLoading", ctx_r4.fullCellColspan)("fusionTableLoadingExpanding", true);
} }
function TableBasicComponent_For_1_ng_template_4_Conditional_2_Template(rf, ctx) { if (rf & 1) {
    const _r18 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 5)(1, "td")(2, "div", 15)(3, "span");
    i0.ɵɵtext(4, "Failed to load data.");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "fusion-link", 14);
    i0.ɵɵlistener("click", function TableBasicComponent_For_1_ng_template_4_Conditional_2_Template_fusion_link_click_5_listener() { i0.ɵɵrestoreView(_r18); const ctx_r5 = i0.ɵɵnextContext(2); const row_r3 = ctx_r5.$implicit; const ɵ$index_1_r4 = ctx_r5.$index; const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.onExpandRow({ rowIndex: ɵ$index_1_r4, row: row_r3, isExpanded: true })); });
    i0.ɵɵtext(6, " Try again ");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const ctx_r4 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵattribute("colspan", ctx_r4.fullCellColspan);
} }
function TableBasicComponent_For_1_ng_template_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, TableBasicComponent_For_1_ng_template_4_ng_container_0_Template, 3, 1, "ng-container", 3)(1, TableBasicComponent_For_1_ng_template_4_Conditional_1_Template, 1, 2, "tr", 4)(2, TableBasicComponent_For_1_ng_template_4_Conditional_2_Template, 7, 1, "tr", 5);
} if (rf & 2) {
    const parentRowChildren_r19 = ctx.$implicit;
    const parentIndex_r17 = ctx.parentIndex;
    const ctx_r4 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("fusionLoadMoreOf", parentRowChildren_r19)("fusionLoadMoreChunkSize", (ctx_r4.options.rowsExpandableOptions == null ? null : ctx_r4.options.rowsExpandableOptions.expendChunkSize) || 10);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r4.loadingChildRows[parentIndex_r17] ? 1 : -1);
    i0.ɵɵadvance();
    i0.ɵɵconditional(ctx_r4.failedChildRows[parentIndex_r17] ? 2 : -1);
} }
function TableBasicComponent_For_1_Template(rf, ctx) { if (rf & 1) {
    const _r1 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 1);
    i0.ɵɵpipe(1, "generic");
    i0.ɵɵpipe(2, "generic");
    i0.ɵɵlistener("rowRemoved", function TableBasicComponent_For_1_Template_tr_rowRemoved_0_listener() { const ctx_r1 = i0.ɵɵrestoreView(_r1); const row_r3 = ctx_r1.$implicit; const ɵ$index_1_r4 = ctx_r1.$index; const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.tableService.removeRow({ rows: ctx_r4.rows, rowIndex: ɵ$index_1_r4, row: row_r3, options: ctx_r4.options })); })("selectedChange", function TableBasicComponent_For_1_Template_tr_selectedChange_0_listener($event) { const row_r3 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.tableService.onRowSelectChanged($event, row_r3)); })("expandRow", function TableBasicComponent_For_1_Template_tr_expandRow_0_listener($event) { i0.ɵɵrestoreView(_r1); const ctx_r4 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r4.onExpandRow($event)); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(3, TableBasicComponent_For_1_Conditional_3_Template, 1, 5, "ng-container", 2)(4, TableBasicComponent_For_1_ng_template_4_Template, 3, 4, "ng-template", null, 0, i0.ɵɵtemplateRefExtractor);
} if (rf & 2) {
    const row_r3 = ctx.$implicit;
    const ɵ$index_1_r4 = ctx.$index;
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵclassProp("is-row-in-request", ctx_r4.tableService.rowsMetadata[row_r3["_rowId"]] == null ? null : ctx_r4.tableService.rowsMetadata[row_r3["_rowId"]].inRequest);
    i0.ɵɵproperty("rowIndex", ɵ$index_1_r4)("row", row_r3)("columns", ctx_r4.columns)("options", ctx_r4.options)("isRowSelected", i0.ɵɵpipeBind2(1, 13, ctx_r4.rowIsSelected, row_r3))("isExpanded", ctx_r4.isExpanded(ɵ$index_1_r4))("isInnerRow", false)("testId", ctx_r4.testId)("ngClass", i0.ɵɵpipeBind3(2, 16, ctx_r4.rowClass, row_r3, ɵ$index_1_r4))("ngStyle", !!ctx_r4.options.rowsOptions && !!ctx_r4.options.rowsOptions.global ? ctx_r4.options.rowsOptions.global.style : null);
    i0.ɵɵadvance(3);
    i0.ɵɵconditional(ctx_r4.displayExpandableRows(ɵ$index_1_r4) ? 3 : -1);
} }
export class TableBasicComponent {
    constructor() {
        this.rowSelected = new EventEmitter();
        this.expandRow = new EventEmitter();
        this.loadingChildRows = {};
        this.failedChildRows = {};
        this.rowIsSelected = this.isRowSelected.bind(this);
        this.rowClass = this.getRowClass.bind(this);
        this.rowRowspanIndexes = this.getRowspanIndexes.bind(this);
        /** @internal */
        this.tableTestIdModifiers = TableTestIdModifiers;
        /** @internal */
        this.testIdsService = inject(TestIdsService);
        this.tableService = inject(TableService);
        this.onDestroy$ = new Subject();
        this.cdr = inject(ChangeDetectorRef);
        this.elementRef = inject(ElementRef);
        this.renderer = inject(Renderer2);
    }
    set options(value) {
        this.tableOptions = value;
        this.childRowOptions = { ...value, hasTotalsRow: false };
    }
    get options() {
        return this.tableOptions;
    }
    get fullCellColspan() {
        if (!!this.tableService.expandLevels) {
            return this.columns.length + this.tableService.expandLevels;
        }
        return this.columns.length;
    }
    ngOnInit() {
        this.tableService.selectionChanged.pipe(takeUntil(this.onDestroy$)).subscribe(val => {
            this.cdr.markForCheck();
        });
    }
    ngOnDestroy() {
        this.onDestroy$.next();
        this.onDestroy$.complete();
    }
    ngAfterViewInit() {
        if (this.tableService.hasRowspanRows) {
            this.setHoverForRowspan();
        }
    }
    trackByRowInvoke() {
        return this.trackByRow.bind(this);
    }
    trackByRow(index, row) {
        const keyOption = this.options && this.options.rowTrackingOption ? this.options.rowTrackingOption : 'id';
        return row && row[keyOption] ? row[keyOption] : row;
    }
    isRowDisabled(row) {
        return row._options && row._options.some(options => 'disabled');
    }
    isRowSelected(row) {
        return this.tableService.isRowSelected(row);
    }
    getRowClass(row, rowIndex) {
        const rowClasses = this.options.rowsOptions || {};
        const classes = {};
        classes[TableRowClassesEnum.Selected] = this.tableService.isRowSelected(row);
        classes[TableRowClassesEnum.Disabled] = this.isRowDisabled(row);
        return [
            ...Object.keys(classes).filter((item) => !!classes[item]),
            !!rowClasses[rowIndex] && !!rowClasses[rowIndex].class ? rowClasses[rowIndex].class : null
        ].filter(Boolean);
    }
    onExpandRow({ rowIndex, row, isExpanded }, updateMap = true) {
        if (!!row) {
            this.loadingChildRows[rowIndex] = isExpanded;
            delete this.failedChildRows[rowIndex];
            const successCallback = this.onExpendRowSuccess(rowIndex).bind(this);
            const failedCallback = this.onExpendRowFailed(rowIndex).bind(this);
            this.expandRow.emit({ rowIndex, row, isExpanded, successCallback, failedCallback, updateMap: updateMap });
        }
    }
    displayExpandableRows(rowIndex) {
        return !!this.options?.rowsExpandableOptions?.key && this.isExpanded(rowIndex);
    }
    isInnerEntityType(innerType) {
        return this.options.rowsExpandableOptions.innerEntityType === innerType;
    }
    isExpanded(rowIndex) {
        if (this.expandedRows?.hasOwnProperty(rowIndex) ||
            this.loadingChildRows.hasOwnProperty(rowIndex) ||
            this.failedChildRows.hasOwnProperty(rowIndex)) {
            return this.expandedRows[rowIndex] || this.loadingChildRows[rowIndex] || this.failedChildRows[rowIndex];
        }
        return this.expandedRows['default'];
    }
    hasAfterSticky(isLast, hasMore, rowIndex) {
        return isLast && (hasMore || this.loadingChildRows[rowIndex] || this.failedChildRows[rowIndex]);
    }
    getRowspanIndexes(row) {
        return [...Array(this.tableService.getMaxRowspanInColumn(row)).keys()].filter(Boolean);
    }
    setHoverForRowspan() {
        const rowElements = this.elementRef.nativeElement.querySelectorAll('tr[data-row-idx]');
        const events = ['mouseenter', 'mouseleave'];
        from(events)
            .pipe(mergeMap(event => fromEvent(rowElements, event)), filter((event) => {
            return ((event.type === 'mouseenter' && !event.target.classList.contains(ROW_HOVERED_CLASS_NAME)) ||
                (event.type === 'mouseleave' && event.target.classList.contains(ROW_HOVERED_CLASS_NAME)));
        }), takeUntil(this.onDestroy$))
            .subscribe(this.toggleHoverClassForRowspan.bind(this));
    }
    toggleHoverClassForRowspan(event) {
        const eventType = event.type;
        const rowIndex = event.target.dataset.rowIdx;
        const sameRowIndexSelector = 'tr[data-row-idx="' + rowIndex + '"]';
        const rows = [...this.elementRef.nativeElement.querySelectorAll(sameRowIndexSelector)];
        switch (eventType) {
            case 'mouseenter':
                rows.forEach(row => {
                    this.renderer.addClass(row, ROW_HOVERED_CLASS_NAME);
                });
                break;
            case 'mouseleave':
                rows.forEach(row => {
                    this.renderer.removeClass(row, ROW_HOVERED_CLASS_NAME);
                });
                break;
        }
    }
    onExpendRowSuccess(rowIndex) {
        return () => {
            delete this.loadingChildRows[rowIndex];
        };
    }
    onExpendRowFailed(rowIndex) {
        return () => {
            delete this.loadingChildRows[rowIndex];
            this.failedChildRows[rowIndex] = true;
            this.cdr.detectChanges();
        };
    }
    static { this.ɵfac = function TableBasicComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || TableBasicComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableBasicComponent, selectors: [["", "fusionTableBasic", ""]], inputs: { rows: "rows", columns: "columns", expandedRows: "expandedRows", options: "options", testId: "testId" }, outputs: { rowSelected: "rowSelected", expandRow: "expandRow" }, standalone: true, features: [i0.ɵɵStandaloneFeature], attrs: _c0, decls: 2, vars: 0, consts: [["childRowsTemplate", ""], ["fusionTableRow", "", 3, "rowRemoved", "selectedChange", "expandRow", "rowIndex", "row", "columns", "options", "isRowSelected", "isExpanded", "isInnerRow", "testId", "ngClass", "ngStyle"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [4, "fusionLoadMore", "fusionLoadMoreOf", "fusionLoadMoreChunkSize"], ["fusionTableLoadingRows", "1", 3, "fusionTableLoading", "fusionTableLoadingExpanding"], [1, "full-cell", "failed"], [4, "ngIf"], [1, "is-inner-row", "fu-inner-object"], [1, "fu-inner-object-wrapper"], [4, "ngComponentOutlet", "ngComponentOutletInputs"], [4, "ngFor", "ngForOf", "ngForTrackBy"], ["fusionTableRow", "", 1, "is-inner-row", 3, "expandRow", "rowIndex", "row", "columns", "options", "isExpanded", "isInnerRow", "ngClass", "hasAfterSticky", "ngStyle"], [1, "full-cell", "load-more"], [1, "fu-load-more-button-wrapper"], ["color", "primary", 3, "click"], [1, "fu-load-failed"]], template: function TableBasicComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵrepeaterCreate(0, TableBasicComponent_For_1_Template, 6, 20, null, null, _forTrack0, true);
        } if (rf & 2) {
            i0.ɵɵrepeater(ctx.rows);
        } }, dependencies: [CommonModule, i1.NgClass, i1.NgComponentOutlet, i1.NgForOf, i1.NgIf, i1.NgTemplateOutlet, i1.NgStyle, i1.AsyncPipe, GenericPipe, TableRowComponent, TableLoadingComponent, LoadMoreModule, i2.LoadMoreDirective, LinkComponent], styles: ["@import\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\";.font-v4-bold[_ngcontent-%COMP%], .font-v4-tab-label-2[_ngcontent-%COMP%], .font-v4-chart-2[_ngcontent-%COMP%], .font-v4-chart-1[_ngcontent-%COMP%]{font-family:Inter,sans-serif;font-weight:700;-webkit-font-smoothing:antialiased}.font-v4-semibold[_ngcontent-%COMP%], .font-v4-chip-label[_ngcontent-%COMP%], .font-v4-table-label[_ngcontent-%COMP%], .font-v4-button[_ngcontent-%COMP%], .font-v4-heading-6[_ngcontent-%COMP%], .font-v4-heading-5[_ngcontent-%COMP%], .font-v4-heading-4[_ngcontent-%COMP%], .font-v4-heading-3[_ngcontent-%COMP%], .font-v4-heading-2[_ngcontent-%COMP%], .font-v4-heading-1[_ngcontent-%COMP%], .font-v4-title[_ngcontent-%COMP%]{font-family:Inter,sans-serif;font-weight:600;-webkit-font-smoothing:antialiased}.font-v4-medium[_ngcontent-%COMP%], .font-v4-tab-label-1[_ngcontent-%COMP%], .font-v4-input-label[_ngcontent-%COMP%], .font-v4-overline[_ngcontent-%COMP%], .font-v4-subtitle-2[_ngcontent-%COMP%], .font-v4-subtitle-1[_ngcontent-%COMP%]{font-family:Inter,sans-serif;font-weight:500;-webkit-font-smoothing:antialiased}.font-v4-regular[_ngcontent-%COMP%], .font-v4-caption[_ngcontent-%COMP%], .font-v4-body-2[_ngcontent-%COMP%], .font-v4-body-1[_ngcontent-%COMP%]{font-family:Inter,sans-serif;font-weight:400;-webkit-font-smoothing:antialiased}.font-v4-title[_ngcontent-%COMP%]{font-size:2.5rem;line-height:3rem;letter-spacing:-.055rem}.font-v4-heading-1[_ngcontent-%COMP%]{font-size:1.5rem;line-height:1.75rem;letter-spacing:-.0285rem}.font-v4-heading-2[_ngcontent-%COMP%]{font-size:1.125rem;line-height:1.75rem;letter-spacing:-.01575rem}.font-v4-heading-3[_ngcontent-%COMP%]{font-size:1rem;line-height:1.5rem;letter-spacing:-.011rem}.font-v4-heading-4[_ngcontent-%COMP%]{font-size:.875rem;line-height:1rem;letter-spacing:unset}.font-v4-heading-5[_ngcontent-%COMP%]{font-size:.8125rem;line-height:16px;letter-spacing:unset}.font-v4-heading-6[_ngcontent-%COMP%]{font-size:.75rem;line-height:.75rem;letter-spacing:0}.font-v4-body-1[_ngcontent-%COMP%]{font-size:.875rem;line-height:1.25rem;letter-spacing:-.00525rem}.font-v4-body-2[_ngcontent-%COMP%]{font-size:.8125rem;line-height:1.25rem;letter-spacing:-.00244rem}.font-v4-subtitle-1[_ngcontent-%COMP%]{font-size:.875rem;line-height:1.25rem;letter-spacing:-.00525rem}.font-v4-subtitle-2[_ngcontent-%COMP%]{font-size:.8125rem;line-height:1.25rem;letter-spacing:-.00244rem}.font-v4-chart-1[_ngcontent-%COMP%]{font-size:1.5rem;line-height:1.5rem;letter-spacing:-.015rem}.font-v4-chart-2[_ngcontent-%COMP%]{font-size:1.25rem;line-height:1.25rem;letter-spacing:-.0125rem}.font-v4-button[_ngcontent-%COMP%]{font-size:.875rem;line-height:1.25rem;letter-spacing:.00875rem}.font-v4-overline[_ngcontent-%COMP%]{font-size:.75rem;line-height:1rem;letter-spacing:.045rem;text-transform:uppercase}.font-v4-caption[_ngcontent-%COMP%]{font-size:.75rem;line-height:1rem}.font-v4-table-label[_ngcontent-%COMP%]{font-size:.8125rem;line-height:1.25rem;letter-spacing:.00813rem}.font-v4-input-label[_ngcontent-%COMP%]{font-size:.8125rem;line-height:1rem;letter-spacing:.00813rem}.font-v4-tab-label-1[_ngcontent-%COMP%], .font-v4-tab-label-2[_ngcontent-%COMP%]{font-size:.875rem;line-height:1rem}.font-v4-chip-label[_ngcontent-%COMP%]{font-size:.75rem;line-height:1rem;letter-spacing:normal}[_nghost-%COMP%]   .full-cell[_ngcontent-%COMP%]{background-color:var(--table-header-cell-bg-color)}[_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%]   td[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]{height:36px;padding:var(--table-row-cell-padding);border-bottom:var(--table-border)}[_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-more-button-wrapper[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-failed[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-more-button-wrapper[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-failed[_ngcontent-%COMP%]{display:flex;justify-content:center;align-items:center;height:100%;width:100%}[_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-failed[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]   td[_ngcontent-%COMP%]   .fu-load-failed[_ngcontent-%COMP%]{padding:16px;flex-direction:column;gap:8px}[_nghost-%COMP%]   tr.is-row-in-request[_ngcontent-%COMP%]{pointer-events:none}[_nghost-%COMP%]   tr.fu-inner-object[_ngcontent-%COMP%]{border-bottom:var(--table-border)}[_nghost-%COMP%]   tr.fu-inner-object[_ngcontent-%COMP%]   .fu-inner-object-wrapper[_ngcontent-%COMP%]{display:flex;align-items:center;justify-content:center}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableBasicComponent, [{
        type: Component,
        args: [{ selector: '[fusionTableBasic]', standalone: true, imports: [CommonModule, GenericPipe, TableRowComponent, TableLoadingComponent, LoadMoreModule, LinkComponent], changeDetection: ChangeDetectionStrategy.OnPush, template: "@for (row of rows; track trackByRowInvoke(); let rowIndex = $index) {\n    <!--First parent row-->\n    <tr\n        fusionTableRow\n        [rowIndex]=\"rowIndex\"\n        [row]=\"row\"\n        [columns]=\"columns\"\n        [options]=\"options\"\n        [isRowSelected]=\"rowIsSelected | generic:row\"\n        [isExpanded]=\"isExpanded(rowIndex)\"\n        [isInnerRow]=\"false\"\n        [class.is-row-in-request]=\"tableService.rowsMetadata[row['_rowId']]?.inRequest\"\n        [testId]=\"testId\"\n        (rowRemoved)=\"tableService.removeRow({rows: rows, rowIndex: rowIndex, row: row, options: options})\"\n        (selectedChange)=\"tableService.onRowSelectChanged($event, row)\"\n        (expandRow)=\"onExpandRow($event)\"\n        [ngClass]=\"rowClass | generic:row:rowIndex\"\n        [ngStyle]=\"!!options.rowsOptions && !!options.rowsOptions.global ? options.rowsOptions.global.style : null\"\n    ></tr>\n    <!--First parent row END-->\n    <!--Child rows-->\n    @if(displayExpandableRows(rowIndex)){\n        <ng-container\n                [ngTemplateOutlet]=\"childRowsTemplate\"\n                [ngTemplateOutletContext]=\"{$implicit: row[options.rowsExpandableOptions.key], parentIndex: rowIndex}\"\n        ></ng-container>\n    }\n    <!--Child rows END-->\n\n    <!--Template Child rows render-->\n    <ng-template #childRowsTemplate let-parentRowChildren let-parentIndex=\"parentIndex\">\n        <ng-container *fusionLoadMore=\"let displayRows$ of parentRowChildren; chunkSize: options.rowsExpandableOptions?.expendChunkSize || 10; let loadMore = loadMore; let hasMore$ = hasMore$;\">\n            @if(isInnerEntityType('dynamicComponent')){\n                <ng-container *ngIf=\"(displayRows$ | async) as innerEntity\">\n                    @if(innerEntity.length){\n                        <tr class=\"is-inner-row fu-inner-object\">\n                            <td [attr.colspan]=\"fullCellColspan\">\n                                <div class=\"fu-inner-object-wrapper\">\n                                    <ng-container *ngComponentOutlet=\"innerEntity[0]?.component?.type; inputs: innerEntity[0]?.component?.data\"></ng-container>\n                                </div>\n                            </td>\n                        </tr>\n                    }\n                </ng-container>\n            } @else {\n                <ng-container\n                        *ngFor=\"let innerRow of displayRows$ | async; trackBy: trackByRowInvoke(); let innerRowIndex = index; let last = last\"\n                >\n                    <tr\n                            fusionTableRow\n                            class=\"is-inner-row\"\n                            [rowIndex]=\"parentIndex + '_' + innerRowIndex\"\n                            [row]=\"innerRow\"\n                            [columns]=\"options.rowsExpandableOptions.columns\"\n                            [options]=\"childRowOptions\"\n                            [isExpanded]=\"isExpanded(parentIndex + '_' + innerRowIndex)\"\n                            [isInnerRow]=\"true\"\n                            [ngClass]=\"rowClass | generic:innerRow:innerRowIndex\"\n                            [hasAfterSticky]=\"hasAfterSticky(last, hasMore$ | async, parentIndex + '_' + innerRowIndex)\"\n                            [ngStyle]=\"!!options?.rowsOptions?.global ? options.rowsOptions.global.style : null\"\n                            (expandRow)=\"onExpandRow($event)\"\n                    ></tr>\n                    @if(!loadingChildRows[parentIndex] && (hasMore$ | async) && last){\n                        <tr class=\"full-cell load-more\">\n                            <td [attr.colspan]=\"fullCellColspan\">\n                                <div class=\"fu-load-more-button-wrapper\">\n                                    <fusion-link color=\"primary\" (click)=\"loadMore()\">Load more</fusion-link>\n                                </div>\n                            </td>\n                        </tr>\n                    }\n                </ng-container>\n            }\n        </ng-container>\n        @if(loadingChildRows[parentIndex]){\n            <tr [fusionTableLoading]=\"fullCellColspan\" [fusionTableLoadingExpanding]=\"true\" fusionTableLoadingRows=\"1\"></tr>\n        }\n        @if (failedChildRows[parentIndex]){\n            <tr class=\"full-cell failed\">\n                <td [attr.colspan]=\"fullCellColspan\">\n                    <div class=\"fu-load-failed\">\n                        <span>Failed to load data.</span>\n                        <fusion-link color=\"primary\" (click)=\"onExpandRow({rowIndex: rowIndex, row: row, isExpanded: true})\">\n                            Try again\n                        </fusion-link>\n                    </div>\n                </td>\n            </tr>\n        }\n    </ng-template>\n    <!--additional rows END`-->\n}\n", styles: ["@import\"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap\";.font-v4-bold,.font-v4-tab-label-2,.font-v4-chart-2,.font-v4-chart-1{font-family:Inter,sans-serif;font-weight:700;-webkit-font-smoothing:antialiased}.font-v4-semibold,.font-v4-chip-label,.font-v4-table-label,.font-v4-button,.font-v4-heading-6,.font-v4-heading-5,.font-v4-heading-4,.font-v4-heading-3,.font-v4-heading-2,.font-v4-heading-1,.font-v4-title{font-family:Inter,sans-serif;font-weight:600;-webkit-font-smoothing:antialiased}.font-v4-medium,.font-v4-tab-label-1,.font-v4-input-label,.font-v4-overline,.font-v4-subtitle-2,.font-v4-subtitle-1{font-family:Inter,sans-serif;font-weight:500;-webkit-font-smoothing:antialiased}.font-v4-regular,.font-v4-caption,.font-v4-body-2,.font-v4-body-1{font-family:Inter,sans-serif;font-weight:400;-webkit-font-smoothing:antialiased}.font-v4-title{font-size:2.5rem;line-height:3rem;letter-spacing:-.055rem}.font-v4-heading-1{font-size:1.5rem;line-height:1.75rem;letter-spacing:-.0285rem}.font-v4-heading-2{font-size:1.125rem;line-height:1.75rem;letter-spacing:-.01575rem}.font-v4-heading-3{font-size:1rem;line-height:1.5rem;letter-spacing:-.011rem}.font-v4-heading-4{font-size:.875rem;line-height:1rem;letter-spacing:unset}.font-v4-heading-5{font-size:.8125rem;line-height:16px;letter-spacing:unset}.font-v4-heading-6{font-size:.75rem;line-height:.75rem;letter-spacing:0}.font-v4-body-1{font-size:.875rem;line-height:1.25rem;letter-spacing:-.00525rem}.font-v4-body-2{font-size:.8125rem;line-height:1.25rem;letter-spacing:-.00244rem}.font-v4-subtitle-1{font-size:.875rem;line-height:1.25rem;letter-spacing:-.00525rem}.font-v4-subtitle-2{font-size:.8125rem;line-height:1.25rem;letter-spacing:-.00244rem}.font-v4-chart-1{font-size:1.5rem;line-height:1.5rem;letter-spacing:-.015rem}.font-v4-chart-2{font-size:1.25rem;line-height:1.25rem;letter-spacing:-.0125rem}.font-v4-button{font-size:.875rem;line-height:1.25rem;letter-spacing:.00875rem}.font-v4-overline{font-size:.75rem;line-height:1rem;letter-spacing:.045rem;text-transform:uppercase}.font-v4-caption{font-size:.75rem;line-height:1rem}.font-v4-table-label{font-size:.8125rem;line-height:1.25rem;letter-spacing:.00813rem}.font-v4-input-label{font-size:.8125rem;line-height:1rem;letter-spacing:.00813rem}.font-v4-tab-label-1,.font-v4-tab-label-2{font-size:.875rem;line-height:1rem}.font-v4-chip-label{font-size:.75rem;line-height:1rem;letter-spacing:normal}:host .full-cell{background-color:var(--table-header-cell-bg-color)}:host .full-cell.load-more td,:host .full-cell.failed td{height:36px;padding:var(--table-row-cell-padding);border-bottom:var(--table-border)}:host .full-cell.load-more td .fu-load-more-button-wrapper,:host .full-cell.load-more td .fu-load-failed,:host .full-cell.failed td .fu-load-more-button-wrapper,:host .full-cell.failed td .fu-load-failed{display:flex;justify-content:center;align-items:center;height:100%;width:100%}:host .full-cell.load-more td .fu-load-failed,:host .full-cell.failed td .fu-load-failed{padding:16px;flex-direction:column;gap:8px}:host tr.is-row-in-request{pointer-events:none}:host tr.fu-inner-object{border-bottom:var(--table-border)}:host tr.fu-inner-object .fu-inner-object-wrapper{display:flex;align-items:center;justify-content:center}\n"] }]
    }], null, { rows: [{
            type: Input
        }], columns: [{
            type: Input
        }], expandedRows: [{
            type: Input
        }], options: [{
            type: Input
        }], testId: [{
            type: Input
        }], rowSelected: [{
            type: Output
        }], expandRow: [{
            type: Output
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TableBasicComponent, { className: "TableBasicComponent", filePath: "components/table-basic/table-basic.component.ts", lineNumber: 44 }); })();
//# sourceMappingURL=data:application/json;base64, 