import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, Injector, Input, Output, Renderer2 } from '@angular/core';
import { TableRowClassesEnum, ROW_HOVERED_CLASS_NAME } from '@ironsource/fusion-ui/components/table/common/entities';
import { TableService } from '@ironsource/fusion-ui/components/table/common/services';
import { fromEvent, Subject, from } from 'rxjs';
import { filter, mergeMap, takeUntil } from 'rxjs/operators';
import { TableTestIdModifiers } from '@ironsource/fusion-ui/entities';
import { TestIdsService } from '@ironsource/fusion-ui/services/test-ids';
import * as i0 from "@angular/core";
import * as i1 from "@ironsource/fusion-ui/components/table/common/services";
import * as i2 from "@angular/common";
import * as i3 from "@ironsource/fusion-ui/directives/load-more";
import * as i4 from "../table-loading/table-loading.component";
import * as i5 from "../table-row/table-row.component";
import * as i6 from "@ironsource/fusion-ui/pipes/generic";
const _c0 = ["fusionTableBasic", ""];
const _c1 = (a0, a1, a2) => ({ $implicit: a0, rowIndex: a1, rowSpanData: a2 });
function TableBasicComponent_ng_container_0_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 5);
} if (rf & 2) {
    const rowSpanData_r9 = ctx.ngIf;
    const ctx_r10 = i0.ɵɵnextContext();
    const row_r1 = ctx_r10.$implicit;
    const rowIndex_r2 = ctx_r10.index;
    const _r8 = i0.ɵɵreference(9);
    i0.ɵɵproperty("ngTemplateOutlet", _r8)("ngTemplateOutletContext", i0.ɵɵpureFunction3(2, _c1, row_r1, rowIndex_r2, rowSpanData_r9));
} }
const _c2 = (a0, a1) => ({ $implicit: a0, parentIndex: a1 });
function TableBasicComponent_ng_container_0_ng_container_5_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 5);
} if (rf & 2) {
    const ctx_r11 = i0.ɵɵnextContext();
    const row_r1 = ctx_r11.$implicit;
    const rowIndex_r2 = ctx_r11.index;
    const _r6 = i0.ɵɵreference(7);
    const ctx_r4 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngTemplateOutlet", _r6)("ngTemplateOutletContext", i0.ɵɵpureFunction2(2, _c2, row_r1[ctx_r4.options.rowsExpandableOptions.key], rowIndex_r2));
} }
function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_tr_4_Template(rf, ctx) { if (rf & 1) {
    const _r28 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 11)(1, "td")(2, "a", 12);
    i0.ɵɵlistener("click", function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_tr_4_Template_a_click_2_listener() { i0.ɵɵrestoreView(_r28); const loadMore_r18 = i0.ɵɵnextContext(2).loadMore; return i0.ɵɵresetView(loadMore_r18()); });
    i0.ɵɵtext(3, "Load more");
    i0.ɵɵelementEnd()()();
} if (rf & 2) {
    const ctx_r24 = i0.ɵɵnextContext(5);
    i0.ɵɵadvance();
    i0.ɵɵattribute("colspan", ctx_r24.fullCellColspan);
    i0.ɵɵadvance();
    i0.ɵɵstyleProp("margin-left", ctx_r24.getHalfTableClientWidth, "px");
} }
function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 5);
} if (rf & 2) {
    const innerRows_r29 = ctx.ngIf;
    const innerRowIndex_r22 = i0.ɵɵnextContext().index;
    const parentIndex_r13 = i0.ɵɵnextContext(2).parentIndex;
    i0.ɵɵnextContext();
    const _r6 = i0.ɵɵreference(7);
    i0.ɵɵproperty("ngTemplateOutlet", _r6)("ngTemplateOutletContext", i0.ɵɵpureFunction2(2, _c2, innerRows_r29, parentIndex_r13 + "_" + innerRowIndex_r22));
} }
function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    const _r33 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "tr", 9);
    i0.ɵɵlistener("expandRow", function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_Template_tr_expandRow_1_listener($event) { i0.ɵɵrestoreView(_r33); const ctx_r32 = i0.ɵɵnextContext(4); return i0.ɵɵresetView(ctx_r32.onExpandRow($event)); });
    i0.ɵɵpipe(2, "generic");
    i0.ɵɵpipe(3, "async");
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(4, TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_tr_4_Template, 4, 3, "tr", 10);
    i0.ɵɵpipe(5, "async");
    i0.ɵɵtemplate(6, TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_ng_container_6_Template, 1, 5, "ng-container", 2);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const innerRow_r21 = ctx.$implicit;
    const innerRowIndex_r22 = ctx.index;
    const last_r23 = ctx.last;
    const hasMore$_r19 = i0.ɵɵnextContext().hasMore$;
    const parentIndex_r13 = i0.ɵɵnextContext().parentIndex;
    const ctx_r20 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵproperty("rowIndex", parentIndex_r13 + "_" + innerRowIndex_r22)("row", innerRow_r21)("columns", ctx_r20.options.rowsExpandableOptions.columns)("options", ctx_r20.childRowOptions)("isExpanded", ctx_r20.isExpanded(parentIndex_r13 + "_" + innerRowIndex_r22))("isInnerRow", true)("ngClass", i0.ɵɵpipeBind3(2, 11, ctx_r20.rowClass, innerRow_r21, innerRowIndex_r22))("hasAfterSticky", ctx_r20.hasAfterSticky(last_r23, i0.ɵɵpipeBind1(3, 15, hasMore$_r19), parentIndex_r13 + "_" + innerRowIndex_r22))("ngStyle", !!ctx_r20.options.rowsOptions && !!ctx_r20.options.rowsOptions.global ? ctx_r20.options.rowsOptions.global.style : null);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", !ctx_r20.loadingChildRows[parentIndex_r13] && i0.ɵɵpipeBind1(5, 17, hasMore$_r19) && last_r23);
    i0.ɵɵadvance(2);
    i0.ɵɵproperty("ngIf", ctx_r20.displayExpandableRows(parentIndex_r13 + "_" + innerRowIndex_r22) && ctx_r20.getInnerRows(parentIndex_r13 + "_" + innerRowIndex_r22));
} }
function TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_ng_container_1_Template, 7, 19, "ng-container", 0);
    i0.ɵɵpipe(2, "async");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const displayRows$_r17 = ctx.$implicit;
    const ctx_r14 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind1(2, 2, displayRows$_r17))("ngForTrackBy", ctx_r14.trackByRowInvoke());
} }
function TableBasicComponent_ng_container_0_ng_template_6_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "tr", 13);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r15 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵproperty("fusionTableLoading", ctx_r15.fullCellColspan)("fusionTableLoadingExpanding", true);
} }
function TableBasicComponent_ng_container_0_ng_template_6_tr_2_Template(rf, ctx) { if (rf & 1) {
    const _r38 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "tr", 14)(1, "td")(2, "p");
    i0.ɵɵtext(3, " Failed to load data... ");
    i0.ɵɵelementStart(4, "a", 12);
    i0.ɵɵlistener("click", function TableBasicComponent_ng_container_0_ng_template_6_tr_2_Template_a_click_4_listener() { i0.ɵɵrestoreView(_r38); const ctx_r37 = i0.ɵɵnextContext(2); const rowIndex_r2 = ctx_r37.index; const row_r1 = ctx_r37.$implicit; const ctx_r36 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r36.onExpandRow({ rowIndex: rowIndex_r2, row: row_r1, isExpanded: true })); });
    i0.ɵɵtext(5, "Try again");
    i0.ɵɵelementEnd()()()();
} if (rf & 2) {
    const ctx_r16 = i0.ɵɵnextContext(3);
    i0.ɵɵadvance();
    i0.ɵɵattribute("colspan", ctx_r16.fullCellColspan);
    i0.ɵɵadvance();
    i0.ɵɵstyleProp("margin-left", ctx_r16.getHalfTableClientWidth - 80, "px");
} }
function TableBasicComponent_ng_container_0_ng_template_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, TableBasicComponent_ng_container_0_ng_template_6_ng_container_0_Template, 3, 4, "ng-container", 6)(1, TableBasicComponent_ng_container_0_ng_template_6_ng_container_1_Template, 2, 2, "ng-container", 7)(2, TableBasicComponent_ng_container_0_ng_template_6_tr_2_Template, 6, 3, "tr", 8);
} if (rf & 2) {
    const parentRowChildren_r12 = ctx.$implicit;
    const parentIndex_r13 = ctx.parentIndex;
    const ctx_r5 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("fusionLoadMoreOf", parentRowChildren_r12)("fusionLoadMoreChunkSize", (ctx_r5.options.rowsExpandableOptions == null ? null : ctx_r5.options.rowsExpandableOptions.expendChunkSize) || 10);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", ctx_r5.loadingChildRows[parentIndex_r13]);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", ctx_r5.failedChildRows[parentIndex_r13]);
} }
function TableBasicComponent_ng_container_0_ng_template_8_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelement(1, "tr", 16);
    i0.ɵɵpipe(2, "generic");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const idx_r43 = ctx.$implicit;
    const ctx_r44 = i0.ɵɵnextContext();
    const row_r39 = ctx_r44.$implicit;
    const rowIndex_r40 = ctx_r44.rowIndex;
    const ctx_r42 = i0.ɵɵnextContext(2);
    i0.ɵɵadvance();
    i0.ɵɵclassProp("is-row-in-request", ctx_r42.tableService.rowsMetadata[row_r39["_rowId"]] == null ? null : ctx_r42.tableService.rowsMetadata[row_r39["_rowId"]].inRequest);
    i0.ɵɵproperty("rowIndex", rowIndex_r40)("rowSpanIndex", idx_r43)("row", row_r39)("columns", ctx_r42.columns)("options", ctx_r42.options)("ngClass", i0.ɵɵpipeBind3(2, 9, ctx_r42.rowClass, row_r39, rowIndex_r40))("ngStyle", !!ctx_r42.options.rowsOptions && !!ctx_r42.options.rowsOptions.global ? ctx_r42.options.rowsOptions.global.style : null);
} }
function TableBasicComponent_ng_container_0_ng_template_8_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵtemplate(0, TableBasicComponent_ng_container_0_ng_template_8_ng_container_0_Template, 3, 13, "ng-container", 15);
    i0.ɵɵpipe(1, "generic");
} if (rf & 2) {
    const row_r39 = ctx.$implicit;
    const ctx_r7 = i0.ɵɵnextContext(2);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(1, 1, ctx_r7.rowRowspanIndexes, row_r39));
} }
function TableBasicComponent_ng_container_0_Template(rf, ctx) { if (rf & 1) {
    const _r46 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "tr", 1);
    i0.ɵɵlistener("rowRemoved", function TableBasicComponent_ng_container_0_Template_tr_rowRemoved_1_listener() { const restoredCtx = i0.ɵɵrestoreView(_r46); const rowIndex_r2 = restoredCtx.index; const row_r1 = restoredCtx.$implicit; const ctx_r45 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r45.tableService.removeRow({ rows: ctx_r45.rows, rowIndex: rowIndex_r2, row: row_r1, options: ctx_r45.options })); })("selectedChange", function TableBasicComponent_ng_container_0_Template_tr_selectedChange_1_listener($event) { const restoredCtx = i0.ɵɵrestoreView(_r46); const row_r1 = restoredCtx.$implicit; const ctx_r47 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r47.tableService.onRowSelectChanged($event, row_r1)); })("expandRow", function TableBasicComponent_ng_container_0_Template_tr_expandRow_1_listener($event) { i0.ɵɵrestoreView(_r46); const ctx_r48 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r48.onExpandRow($event)); });
    i0.ɵɵpipe(2, "generic");
    i0.ɵɵpipe(3, "generic");
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(4, TableBasicComponent_ng_container_0_ng_container_4_Template, 1, 6, "ng-container", 2)(5, TableBasicComponent_ng_container_0_ng_container_5_Template, 1, 5, "ng-container", 2)(6, TableBasicComponent_ng_container_0_ng_template_6_Template, 3, 4, "ng-template", null, 3, i0.ɵɵtemplateRefExtractor)(8, TableBasicComponent_ng_container_0_ng_template_8_Template, 2, 4, "ng-template", null, 4, i0.ɵɵtemplateRefExtractor);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const row_r1 = ctx.$implicit;
    const rowIndex_r2 = ctx.index;
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵclassProp("is-row-in-request", ctx_r0.tableService.rowsMetadata[row_r1["_rowId"]] == null ? null : ctx_r0.tableService.rowsMetadata[row_r1["_rowId"]].inRequest);
    i0.ɵɵproperty("rowIndex", rowIndex_r2)("row", row_r1)("columns", ctx_r0.columns)("options", ctx_r0.options)("isRowSelected", i0.ɵɵpipeBind2(2, 14, ctx_r0.rowIsSelected, row_r1))("isExpanded", ctx_r0.isExpanded(rowIndex_r2))("isInnerRow", false)("testId", ctx_r0.testId)("ngClass", i0.ɵɵpipeBind3(3, 17, ctx_r0.rowClass, row_r1, rowIndex_r2))("ngStyle", !!ctx_r0.options.rowsOptions && !!ctx_r0.options.rowsOptions.global ? ctx_r0.options.rowsOptions.global.style : null);
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", ctx_r0.tableService.rowsMetadata[row_r1["_rowId"]] == null ? null : ctx_r0.tableService.rowsMetadata[row_r1["_rowId"]].rowspanColumnsData);
    i0.ɵɵadvance();
    i0.ɵɵproperty("ngIf", ctx_r0.displayExpandableRows(rowIndex_r2));
} }
export class TableBasicComponent {
    set options(value) {
        this.tableOptions = value;
        this.childRowOptions = { ...value, hasTotalsRow: false };
    }
    set tableClientWidth(value) {
        this._halfTableClientWidth = value ? value / 2 : 0;
    }
    get options() {
        return this.tableOptions;
    }
    get fullCellColspan() {
        if (!!this.tableService.expandLevels) {
            return this.columns.length + this.tableService.expandLevels;
        }
        return this.columns.length;
    }
    get getHalfTableClientWidth() {
        return this._halfTableClientWidth;
    }
    constructor(tableService, cdr, elementRef, renderer, injector) {
        this.tableService = tableService;
        this.cdr = cdr;
        this.elementRef = elementRef;
        this.renderer = renderer;
        this.injector = injector;
        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 = this.injector.get(TestIdsService);
        this._halfTableClientWidth = 0;
        this.onDestroy$ = new Subject();
    }
    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);
    }
    getInnerRows(index) {
        const innerKey = this.options.rowsExpandableOptions.key;
        const indexes = index.split('_').map(Number);
        let retRow = this.rows;
        indexes.forEach((item, idx) => {
            retRow = !!idx ? retRow[innerKey][item] : retRow[item];
        });
        return retRow[innerKey] || [];
    }
    isExpanded(rowIndex) {
        // check if has row index keys in expandedRows / loadingChildRows / failedChildRows;
        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(t) { return new (t || TableBasicComponent)(i0.ɵɵdirectiveInject(i1.TableService), i0.ɵɵdirectiveInject(i0.ChangeDetectorRef), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.Injector)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TableBasicComponent, selectors: [["", "fusionTableBasic", ""]], inputs: { rows: "rows", columns: "columns", expandedRows: "expandedRows", options: "options", tableClientWidth: "tableClientWidth", testId: "testId" }, outputs: { rowSelected: "rowSelected", expandRow: "expandRow" }, attrs: _c0, decls: 1, vars: 2, consts: [[4, "ngFor", "ngForOf", "ngForTrackBy"], ["fusionTableRow", "", 3, "rowIndex", "row", "columns", "options", "isRowSelected", "isExpanded", "isInnerRow", "testId", "ngClass", "ngStyle", "rowRemoved", "selectedChange", "expandRow"], [3, "ngTemplateOutlet", "ngTemplateOutletContext", 4, "ngIf"], ["childRowsTemplate", ""], ["multiRowColumns", ""], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], [4, "fusionLoadMore", "fusionLoadMoreOf", "fusionLoadMoreChunkSize"], [4, "ngIf"], ["class", "full-cell failed", 4, "ngIf"], ["fusionTableRow", "", 1, "is-inner-row", 3, "rowIndex", "row", "columns", "options", "isExpanded", "isInnerRow", "ngClass", "hasAfterSticky", "ngStyle", "expandRow"], ["class", "full-cell load-more", 4, "ngIf"], [1, "full-cell", "load-more"], [3, "click"], [3, "fusionTableLoading", "fusionTableLoadingExpanding"], [1, "full-cell", "failed"], [4, "ngFor", "ngForOf"], ["fusionTableRow", "", 3, "rowIndex", "rowSpanIndex", "row", "columns", "options", "ngClass", "ngStyle"]], template: function TableBasicComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, TableBasicComponent_ng_container_0_Template, 10, 21, "ng-container", 0);
        } if (rf & 2) {
            i0.ɵɵproperty("ngForOf", ctx.rows)("ngForTrackBy", ctx.trackByRowInvoke());
        } }, dependencies: [i2.NgClass, i2.NgForOf, i2.NgIf, i2.NgTemplateOutlet, i2.NgStyle, i3.LoadMoreDirective, i4.TableLoadingComponent, i5.TableRowComponent, i2.AsyncPipe, i6.GenericPipe], styles: ["@font-face{font-family:NHaasGroteskDSPro;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.ttf) format(\"truetype\")}@font-face{font-family:NHaasGroteskDSPro-65Md;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue-Medium;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.ttf) format(\"truetype\")}.font-heading-6[_ngcontent-%COMP%], .font-heading-5[_ngcontent-%COMP%], .font-heading-4[_ngcontent-%COMP%], .font-heading-3[_ngcontent-%COMP%], .font-heading-2[_ngcontent-%COMP%], .font-heading-1[_ngcontent-%COMP%]{font-family:NHaasGroteskDSPro,sans-serif}.font-heading-1[_ngcontent-%COMP%]{font-size:60px}.font-heading-2[_ngcontent-%COMP%]{font-size:32px}.font-heading-3[_ngcontent-%COMP%]{font-size:22px}.font-heading-4[_ngcontent-%COMP%]{font-size:18px}.font-heading-5[_ngcontent-%COMP%]{font-size:15px}.font-heading-6[_ngcontent-%COMP%]{font-size:13px}.font-heading-label[_ngcontent-%COMP%]{font-size:11px;font-family:NHaasGroteskDSPro-65Md,sans-serif;letter-spacing:.25px}.font-caption[_ngcontent-%COMP%], .font-bodyXSmall[_ngcontent-%COMP%], .font-bodySmall[_ngcontent-%COMP%], .font-bodyMedium[_ngcontent-%COMP%], .font-bodyLarge[_ngcontent-%COMP%]{font-family:HelveticaNeue,helvetica,sans-serif;line-height:1.5}[_nghost-%COMP%]   a[_ngcontent-%COMP%], .font-bodyXSmallStrong[_ngcontent-%COMP%], .font-bodySmallStrong[_ngcontent-%COMP%], .font-bodyMediumStrong[_ngcontent-%COMP%], .font-bodyLargeStrong[_ngcontent-%COMP%]{font-family:HelveticaNeue-Medium,helvetica,sans-serif;line-height:1.5}.font-bodyLarge[_ngcontent-%COMP%], .font-bodyLargeStrong[_ngcontent-%COMP%]{font-size:16px}.font-bodyMedium[_ngcontent-%COMP%], .font-bodyMediumStrong[_ngcontent-%COMP%]{font-size:14px}.font-bodySmall[_ngcontent-%COMP%], .font-bodySmallStrong[_ngcontent-%COMP%]{font-size:13px;letter-spacing:.24px}.font-bodyXSmall[_ngcontent-%COMP%], .font-bodyXSmallStrong[_ngcontent-%COMP%]{font-size:12px;letter-spacing:.24px}.font-caption[_ngcontent-%COMP%]{font-size:11px}[_nghost-%COMP%]   a[_ngcontent-%COMP%]{text-decoration:none;color:var(--fu-primary-500, #3083FF);cursor:pointer}[_nghost-%COMP%]   a[_ngcontent-%COMP%]:link, [_nghost-%COMP%]   a[_ngcontent-%COMP%]:visited, [_nghost-%COMP%]   a[_ngcontent-%COMP%]:hover, [_nghost-%COMP%]   a[_ngcontent-%COMP%]:active{color:var(--fu-primary-500, #3083FF)}@keyframes _ngcontent-%COMP%_rotation{0%{transform:rotate(0)}to{transform:rotate(359deg)}}@keyframes _ngcontent-%COMP%_shineAnimation{0%{background-position:-750px 0}to{background-position:750px 0}}[_nghost-%COMP%]   .full-cell[_ngcontent-%COMP%]{height:48px}[_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]{height:27px}[_nghost-%COMP%]   .full-cell.load-more[_ngcontent-%COMP%]   p[_ngcontent-%COMP%], [_nghost-%COMP%]   .full-cell.failed[_ngcontent-%COMP%]   p[_ngcontent-%COMP%]{margin:0}[_nghost-%COMP%]   tr.is-row-in-request[_ngcontent-%COMP%]{pointer-events:none}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TableBasicComponent, [{
        type: Component,
        args: [{ selector: '[fusionTableBasic]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container *ngFor=\"let row of rows; trackBy: 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    <!--Rowspan rows if any-->\n    <ng-container *ngIf=\"tableService.rowsMetadata[row['_rowId']]?.rowspanColumnsData as rowSpanData\"\n                  [ngTemplateOutlet]=\"multiRowColumns\"\n                  [ngTemplateOutletContext]=\"{$implicit: row, rowIndex: rowIndex, rowSpanData: rowSpanData}\">\n\n    </ng-container>\n    <!--Rowspan rows if any END-->\n    <!--Child rows-->\n    <ng-container\n        *ngIf=\"displayExpandableRows(rowIndex)\"\n        [ngTemplateOutlet]=\"childRowsTemplate\"\n        [ngTemplateOutletContext]=\"{$implicit: row[options.rowsExpandableOptions.key], parentIndex: rowIndex}\"\n    >\n    </ng-container>\n    <!--Child rows END-->\n    <!--Recursive template for 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            <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 && !!options.rowsOptions.global ? options.rowsOptions.global.style : null\"\n                    (expandRow)=\"onExpandRow($event)\"\n                ></tr>\n                <tr class=\"full-cell load-more\" *ngIf=\"!loadingChildRows[parentIndex] && (hasMore$ | async) && last\">\n                    <td [attr.colspan]=\"fullCellColspan\">\n                        <a [style.margin-left.px]=\"getHalfTableClientWidth\" (click)=\"loadMore()\">Load more</a>\n                    </td>\n                </tr>\n                <!--recursive template invocation-->\n                <ng-container\n                    *ngIf=\"displayExpandableRows(parentIndex + '_' + innerRowIndex) && getInnerRows(parentIndex + '_' + innerRowIndex) as innerRows\"\n                    [ngTemplateOutlet]=\"childRowsTemplate\"\n                    [ngTemplateOutletContext]=\"{\n                        $implicit: innerRows,\n                        parentIndex: parentIndex + '_' + innerRowIndex\n                    }\"\n                >\n                </ng-container>\n            </ng-container>\n        </ng-container>\n        <ng-container *ngIf=\"loadingChildRows[parentIndex]\">\n            <tr [fusionTableLoading]=\"fullCellColspan\" [fusionTableLoadingExpanding]=\"true\"></tr>\n        </ng-container>\n        <tr class=\"full-cell failed\" *ngIf=\"failedChildRows[parentIndex]\">\n            <td [attr.colspan]=\"fullCellColspan\">\n                <p [style.margin-left.px]=\"getHalfTableClientWidth - 80\">\n                    Failed to load data...\n                    <a (click)=\"onExpandRow({rowIndex: rowIndex, row: row, isExpanded: true})\">Try again</a>\n                </p>\n            </td>\n        </tr>\n    </ng-template>\n    <!--Recursive template for child rows render END-->\n    <!--additional row-span rows-->\n    <ng-template #multiRowColumns let-row let-rowIndex=\"rowIndex\" let-rowSpanData=rowSpanData>\n        <ng-container *ngFor=\"let idx of rowRowspanIndexes | generic:row\">\n            <tr\n                fusionTableRow\n                [rowIndex]=\"rowIndex\"\n                [rowSpanIndex]=\"idx\"\n                [row]=\"row\"\n                [columns]=\"columns\"\n                [options]=\"options\"\n                [class.is-row-in-request]=\"tableService.rowsMetadata[row['_rowId']]?.inRequest\"\n                [ngClass]=\"rowClass | generic:row:rowIndex\"\n                [ngStyle]=\"!!options.rowsOptions && !!options.rowsOptions.global ? options.rowsOptions.global.style : null\"\n            ></tr>\n        </ng-container>\n    </ng-template>\n    <!--additional rows END`-->\n</ng-container>\n", styles: ["@font-face{font-family:NHaasGroteskDSPro;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.ttf) format(\"truetype\")}@font-face{font-family:NHaasGroteskDSPro-65Md;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue-Medium;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.ttf) format(\"truetype\")}.font-heading-6,.font-heading-5,.font-heading-4,.font-heading-3,.font-heading-2,.font-heading-1{font-family:NHaasGroteskDSPro,sans-serif}.font-heading-1{font-size:60px}.font-heading-2{font-size:32px}.font-heading-3{font-size:22px}.font-heading-4{font-size:18px}.font-heading-5{font-size:15px}.font-heading-6{font-size:13px}.font-heading-label{font-size:11px;font-family:NHaasGroteskDSPro-65Md,sans-serif;letter-spacing:.25px}.font-caption,.font-bodyXSmall,.font-bodySmall,.font-bodyMedium,.font-bodyLarge{font-family:HelveticaNeue,helvetica,sans-serif;line-height:1.5}:host a,.font-bodyXSmallStrong,.font-bodySmallStrong,.font-bodyMediumStrong,.font-bodyLargeStrong{font-family:HelveticaNeue-Medium,helvetica,sans-serif;line-height:1.5}.font-bodyLarge,.font-bodyLargeStrong{font-size:16px}.font-bodyMedium,.font-bodyMediumStrong{font-size:14px}.font-bodySmall,.font-bodySmallStrong{font-size:13px;letter-spacing:.24px}.font-bodyXSmall,.font-bodyXSmallStrong{font-size:12px;letter-spacing:.24px}.font-caption{font-size:11px}:host a{text-decoration:none;color:var(--fu-primary-500, #3083FF);cursor:pointer}:host a:link,:host a:visited,:host a:hover,:host a:active{color:var(--fu-primary-500, #3083FF)}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(359deg)}}@keyframes shineAnimation{0%{background-position:-750px 0}to{background-position:750px 0}}:host .full-cell{height:48px}:host .full-cell.load-more,:host .full-cell.failed{height:27px}:host .full-cell.load-more p,:host .full-cell.failed p{margin:0}:host tr.is-row-in-request{pointer-events:none}\n"] }]
    }], () => [{ type: i1.TableService }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.Injector }], { rows: [{
            type: Input
        }], columns: [{
            type: Input
        }], expandedRows: [{
            type: Input
        }], options: [{
            type: Input
        }], tableClientWidth: [{
            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: 35 }); })();
//# sourceMappingURL=data:application/json;base64, 