import { Component, ViewEncapsulation, Input, EventEmitter, Output, ViewChild } from '@angular/core';
import { Attribute } from '../../data-model/attribute';
import { AttributeData } from '../../fields/attribute-data';
import { AxFilter } from '../../filters/ax-filter';
import { ScreenType } from '../../filters/condition-type';
import { ElementProperty } from '../../property/element-property';
import { Page } from '../graphical-report/page/page';
import { TabularComponent } from './tabular/tabular.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/cdk/drag-drop";
import * as i2 from "@angular/common";
import * as i3 from "./tabular/tabular.component";
import * as i4 from "@angular/material/icon";
function TabularReportComponent_ng_container_2_mat_icon_2_Template(rf, ctx) { if (rf & 1) {
    const _r4 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-icon", 6);
    i0.ɵɵlistener("click", function TabularReportComponent_ng_container_2_mat_icon_2_Template_mat_icon_click_0_listener() { i0.ɵɵrestoreView(_r4); const ctx_r3 = i0.ɵɵnextContext(2); return ctx_r3.nextPage(); });
    i0.ɵɵelementEnd();
} if (rf & 2) {
    i0.ɵɵproperty("svgIcon", "axo_back_arrow");
} }
function TabularReportComponent_ng_container_2_Template(rf, ctx) { if (rf & 1) {
    const _r6 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵelementStart(1, "mat-icon", 4);
    i0.ɵɵlistener("click", function TabularReportComponent_ng_container_2_Template_mat_icon_click_1_listener() { i0.ɵɵrestoreView(_r6); const ctx_r5 = i0.ɵɵnextContext(); return ctx_r5.previousPage(); });
    i0.ɵɵelementEnd();
    i0.ɵɵtemplate(2, TabularReportComponent_ng_container_2_mat_icon_2_Template, 1, 1, "mat-icon", 5);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("svgIcon", "axo_back_arrow");
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", ctx_r1.hasNextPage);
} }
const _c0 = function (a0) { return { "flex items-center justify-center": a0 }; };
export class TabularReportComponent {
    constructor() {
        this.pageClickedEvent = new EventEmitter();
        this.sendExcelReportEvent = new EventEmitter();
        this.previousPageClicked = new EventEmitter();
        this.nextPageClicked = new EventEmitter();
        /**
         * Constructor
         *
         */
        this.elements = [];
    }
    get screenTypes() {
        return ScreenType;
    }
    // -----------------------------------------------------------------------------------------------------
    // @ Lifecycle hooks start
    // -----------------------------------------------------------------------------------------------------
    ngOnInit() {
    }
    /**
     * On Change
     */
    ngOnChanges(changes) {
        this.tabularReport = this.page.elements[0];
        this.tabularReport.pageIndex = 0;
        this.tabularReport.pageLength = 0;
        this.tabularReport.pageSize = 10;
    }
    ngAfterViewInit() {
        this.page.elements.forEach((element) => {
            this.elements.push(element);
        });
    }
    /**
     * On destroy
     */
    ngOnDestroy() {
    }
    // -----------------------------------------------------------------------------------------------------
    // @ Lifecycle hooks end
    // -----------------------------------------------------------------------------------------------------
    attributeDropped($event) {
        if ($event.item.data instanceof Attribute) {
            const attribute = new AttributeData($event.item.data);
            attribute.aggregateFn = '';
            this.tabularReportComponentRef.addColumn(attribute);
        }
    }
    /**
     * Called when a page is clicked on graphical report builder
     */
    onPageClicked() {
        const data = new ElementProperty();
        data.page = this.page;
        this.pageClickedEvent.emit(data);
    }
    previousPage() {
        this.previousPageClicked.emit();
    }
    nextPage() {
        this.nextPageClicked.emit();
    }
}
TabularReportComponent.ɵfac = function TabularReportComponent_Factory(t) { return new (t || TabularReportComponent)(); };
TabularReportComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TabularReportComponent, selectors: [["tabular-report"]], viewQuery: function TabularReportComponent_Query(rf, ctx) { if (rf & 1) {
        i0.ɵɵviewQuery(TabularComponent, 5);
    } if (rf & 2) {
        let _t;
        i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tabularReportComponentRef = _t.first);
    } }, inputs: { page: "page", x1ImageMediaUrl: "x1ImageMediaUrl", screenType: "screenType", drillThroughParentType: "drillThroughParentType", drillThroughFilterInput: "drillThroughFilterInput", userEmail: "userEmail", hasNextPage: "hasNextPage", x1MediaUrl: "x1MediaUrl", appVersionId: "appVersionId" }, outputs: { pageClickedEvent: "pageClickedEvent", sendExcelReportEvent: "sendExcelReportEvent", previousPageClicked: "previousPageClicked", nextPageClicked: "nextPageClicked" }, features: [i0.ɵɵNgOnChangesFeature], decls: 4, vars: 15, consts: [["id", "central-page", "cdkDropList", "", "cdkDropListSortingDisabled", "true", 1, "page", "customscroll-x", 3, "cdkDropListData", "ngClass", "cdkDropListDropped", "click"], ["tabularReportDropZone", ""], [4, "ngIf"], [1, "tabular-report", 3, "x1MediaUrl", "x1ImageMediaUrl", "tabularReport", "page", "appVersionId", "isEditable", "userEmail", "screenType", "drillThroughFilterInput", "drillThroughParentType", "sendExcelReportEvent"], [1, "back-btn", 3, "svgIcon", "click"], ["class", "next-btn", 3, "svgIcon", "click", 4, "ngIf"], [1, "next-btn", 3, "svgIcon", "click"]], template: function TabularReportComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵelementStart(0, "div", 0, 1);
        i0.ɵɵlistener("cdkDropListDropped", function TabularReportComponent_Template_div_cdkDropListDropped_0_listener($event) { return ctx.attributeDropped($event); })("click", function TabularReportComponent_Template_div_click_0_listener() { return ctx.onPageClicked(); });
        i0.ɵɵtemplate(2, TabularReportComponent_ng_container_2_Template, 3, 2, "ng-container", 2);
        i0.ɵɵelementStart(3, "tabular", 3);
        i0.ɵɵlistener("sendExcelReportEvent", function TabularReportComponent_Template_tabular_sendExcelReportEvent_3_listener($event) { return ctx.sendExcelReportEvent.emit($event); });
        i0.ɵɵelementEnd();
        i0.ɵɵelementEnd();
    } if (rf & 2) {
        i0.ɵɵproperty("cdkDropListData", ctx.elements)("ngClass", i0.ɵɵpureFunction1(13, _c0, ctx.tabularReport.matrix.attributes.length === 0));
        i0.ɵɵadvance(2);
        i0.ɵɵproperty("ngIf", ctx.screenType === ctx.screenTypes.drillThrough);
        i0.ɵɵadvance(1);
        i0.ɵɵproperty("x1MediaUrl", ctx.x1MediaUrl)("x1ImageMediaUrl", ctx.x1ImageMediaUrl)("tabularReport", ctx.tabularReport)("page", ctx.page)("appVersionId", ctx.appVersionId)("isEditable", true)("userEmail", ctx.userEmail)("screenType", ctx.screenType)("drillThroughFilterInput", ctx.drillThroughFilterInput)("drillThroughParentType", ctx.drillThroughParentType);
    } }, directives: [i1.CdkDropList, i2.NgClass, i2.NgIf, i3.TabularComponent, i4.MatIcon], styles: ["tabular-report{display:block;height:calc(100% - 4.063rem);min-height:calc(100% - 4.063rem);max-height:calc(100% - 4.063rem);box-shadow:#0000001a 0 0 5px,#0000001a 0 0 1px}tabular-report .page{width:auto;min-height:auto;border:1px #D3D3D3 solid;background:white;box-shadow:0 0 5px #0000001a;position:relative;overflow:hidden}tabular-report .tabular-report{display:block;height:100%;min-height:100%;max-height:100%;width:100%;position:relative}.th[_ngcontent-svl-c211]{font-size:12px}.example-action-buttons{padding-bottom:20px}.example-headers-align .mat-expansion-panel-header-title,.example-headers-align .mat-expansion-panel-header-description{flex-basis:0}.example-headers-align .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}.example-headers-align .mat-form-field+.mat-form-field{margin-left:8px}.footer-toggle .mat-slide-toggle-content{font-size:12px}\n"], encapsulation: 2 });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TabularReportComponent, [{
        type: Component,
        args: [{ selector: 'tabular-report', encapsulation: ViewEncapsulation.None, template: "<!-- This is tabular report component -->\n<div id=\"central-page\" class=\"page customscroll-x\" cdkDropList [cdkDropListData]=\"elements\"\n    (cdkDropListDropped)=\"attributeDropped($event)\" cdkDropListSortingDisabled=\"true\" #tabularReportDropZone\n    (click)=\"onPageClicked()\" [ngClass]=\"{'flex items-center justify-center': tabularReport.matrix.attributes.length===0}\">\n    <ng-container *ngIf=\"screenType === screenTypes.drillThrough\">\n        <mat-icon (click)=\"previousPage()\" class=\"back-btn\" [svgIcon]=\"'axo_back_arrow'\"></mat-icon>\n        <mat-icon (click)=\"nextPage()\" *ngIf=\"hasNextPage\" class=\"next-btn\" [svgIcon]=\"'axo_back_arrow'\"></mat-icon>\n</ng-container>\n\t\t<!-- Dynamically the tabular report will be rendered here. -->\n        <tabular\n          [x1MediaUrl]=\"x1MediaUrl\"\n          [x1ImageMediaUrl]='x1ImageMediaUrl' \n          [tabularReport]=\"tabularReport\" \n          [page]=\"page\"\n          [appVersionId]=\"appVersionId\"\n          [isEditable]='true'\n          [userEmail]=\"userEmail\" \n          (sendExcelReportEvent)=\"sendExcelReportEvent.emit($event)\" \n          [screenType]=\"screenType\"\n          [drillThroughFilterInput]=\"drillThroughFilterInput\"\n          [drillThroughParentType]=\"drillThroughParentType\"\n          class=\"tabular-report\"\n          ></tabular>\n</div>", styles: ["tabular-report{display:block;height:calc(100% - 4.063rem);min-height:calc(100% - 4.063rem);max-height:calc(100% - 4.063rem);box-shadow:#0000001a 0 0 5px,#0000001a 0 0 1px}tabular-report .page{width:auto;min-height:auto;border:1px #D3D3D3 solid;background:white;box-shadow:0 0 5px #0000001a;position:relative;overflow:hidden}tabular-report .tabular-report{display:block;height:100%;min-height:100%;max-height:100%;width:100%;position:relative}.th[_ngcontent-svl-c211]{font-size:12px}.example-action-buttons{padding-bottom:20px}.example-headers-align .mat-expansion-panel-header-title,.example-headers-align .mat-expansion-panel-header-description{flex-basis:0}.example-headers-align .mat-expansion-panel-header-description{justify-content:space-between;align-items:center}.example-headers-align .mat-form-field+.mat-form-field{margin-left:8px}.footer-toggle .mat-slide-toggle-content{font-size:12px}\n"] }]
    }], function () { return []; }, { tabularReportComponentRef: [{
            type: ViewChild,
            args: [TabularComponent]
        }], pageClickedEvent: [{
            type: Output
        }], sendExcelReportEvent: [{
            type: Output
        }], previousPageClicked: [{
            type: Output
        }], nextPageClicked: [{
            type: Output
        }], page: [{
            type: Input
        }], x1ImageMediaUrl: [{
            type: Input
        }], screenType: [{
            type: Input
        }], drillThroughParentType: [{
            type: Input
        }], drillThroughFilterInput: [{
            type: Input
        }], userEmail: [{
            type: Input
        }], hasNextPage: [{
            type: Input
        }], x1MediaUrl: [{
            type: Input
        }], appVersionId: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 