import { Component, Input, Output, EventEmitter } from '@angular/core';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/material/expansion";
import * as i3 from "@angular/material/list";
import * as i4 from "@angular/material/tooltip";
import * as i5 from "../../../axo-utils/search-pipe";
function CategoriesTreeComponent_div_0_label_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "label", 7);
    i0.ɵɵtext(1, "Category");
    i0.ɵɵelementEnd();
} }
function CategoriesTreeComponent_div_0_ng_container_7_mat_list_option_1_Template(rf, ctx) { if (rf & 1) {
    const _r9 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "mat-list-option", 9);
    i0.ɵɵlistener("selectedChange", function CategoriesTreeComponent_div_0_ng_container_7_mat_list_option_1_Template_mat_list_option_selectedChange_0_listener($event) { i0.ɵɵrestoreView(_r9); const category_r4 = i0.ɵɵnextContext().$implicit; return category_r4.isSelected = $event; });
    i0.ɵɵelementStart(1, "span", 10);
    i0.ɵɵtext(2);
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const category_r4 = i0.ɵɵnextContext().$implicit;
    i0.ɵɵproperty("value", category_r4)("selected", category_r4.isSelected);
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("matTooltip", category_r4.name);
    i0.ɵɵadvance(1);
    i0.ɵɵtextInterpolate1(" ", category_r4.name, "");
} }
function CategoriesTreeComponent_div_0_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtemplate(1, CategoriesTreeComponent_div_0_ng_container_7_mat_list_option_1_Template, 3, 4, "mat-list-option", 8);
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const category_r4 = ctx.$implicit;
    i0.ɵɵadvance(1);
    i0.ɵɵproperty("ngIf", !category_r4.isHidden);
} }
const _c0 = function (a0) { return { "field-container": a0 }; };
function CategoriesTreeComponent_div_0_Template(rf, ctx) { if (rf & 1) {
    const _r12 = i0.ɵɵgetCurrentView();
    i0.ɵɵelementStart(0, "div", 1);
    i0.ɵɵelementStart(1, "mat-expansion-panel", 2);
    i0.ɵɵelementStart(2, "mat-expansion-panel-header");
    i0.ɵɵtemplate(3, CategoriesTreeComponent_div_0_label_3_Template, 2, 0, "label", 3);
    i0.ɵɵpipe(4, "search");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(5, "mat-selection-list", 4, 5);
    i0.ɵɵlistener("selectionChange", function CategoriesTreeComponent_div_0_Template_mat_selection_list_selectionChange_5_listener($event) { i0.ɵɵrestoreView(_r12); const ctx_r11 = i0.ɵɵnextContext(); return ctx_r11.categorySelectionChange($event); });
    i0.ɵɵtemplate(7, CategoriesTreeComponent_div_0_ng_container_7_Template, 2, 1, "ng-container", 6);
    i0.ɵɵpipe(8, "search");
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    let tmp_1_0;
    i0.ɵɵproperty("ngClass", i0.ɵɵpureFunction1(9, _c0, ctx_r0.showSearchBox));
    i0.ɵɵadvance(3);
    i0.ɵɵproperty("ngIf", (tmp_1_0 = i0.ɵɵpipeBind2(4, 3, ctx_r0.categories, ctx_r0.searchedTerm)) == null ? null : tmp_1_0.length);
    i0.ɵɵadvance(4);
    i0.ɵɵproperty("ngForOf", i0.ɵɵpipeBind2(8, 6, ctx_r0.categories, ctx_r0.searchedTerm));
} }
export class CategoriesTreeComponent {
    /**
     * Constructor
     */
    constructor() {
        // <----------(Inputs)---------------------------->
        this.categories = [];
        this.searchedTerm = ''; // Search Text
        //<----------------(Outputs) --------------------->
        this.categorySelected = new EventEmitter();
        this.categoryDeselected = new EventEmitter();
    }
    /**
     * On init life cycle hook.
     */
    ngOnInit() {
    }
    /**
     * categorySelectionChange get called on category selection box changed
     * @param event
     */
    categorySelectionChange(event) {
        if (event.option.selected) {
            this.categorySelected.emit(event.option.value);
        }
        else {
            this.categoryDeselected.emit(event.option.value);
        }
    }
}
CategoriesTreeComponent.ɵfac = function CategoriesTreeComponent_Factory(t) { return new (t || CategoriesTreeComponent)(); };
CategoriesTreeComponent.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CategoriesTreeComponent, selectors: [["lib-categories-tree"]], inputs: { categories: "categories", searchedTerm: "searchedTerm" }, outputs: { categorySelected: "categorySelected", categoryDeselected: "categoryDeselected" }, decls: 2, vars: 4, consts: [[3, "ngClass", 4, "ngIf"], [3, "ngClass"], [1, "mb-6"], ["class", "axo-font font-normal", 4, "ngIf"], [3, "selectionChange"], ["category", ""], [4, "ngFor", "ngForOf"], [1, "axo-font", "font-normal"], ["checkboxPosition", "after", "color", "primary", 3, "value", "selected", "selectedChange", 4, "ngIf"], ["checkboxPosition", "after", "color", "primary", 3, "value", "selected", "selectedChange"], [1, "list-field", 3, "matTooltip"]], template: function CategoriesTreeComponent_Template(rf, ctx) { if (rf & 1) {
        i0.ɵɵtemplate(0, CategoriesTreeComponent_div_0_Template, 9, 11, "div", 0);
        i0.ɵɵpipe(1, "search");
    } if (rf & 2) {
        let tmp_0_0;
        i0.ɵɵproperty("ngIf", (tmp_0_0 = i0.ɵɵpipeBind2(1, 1, ctx.categories, ctx.searchedTerm)) == null ? null : tmp_0_0.length);
    } }, directives: [i1.NgIf, i1.NgClass, i2.MatExpansionPanel, i2.MatExpansionPanelHeader, i3.MatSelectionList, i1.NgForOf, i3.MatListOption, i4.MatTooltip], pipes: [i5.SearchPipe], styles: [""] });
(function () { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CategoriesTreeComponent, [{
        type: Component,
        args: [{ selector: 'lib-categories-tree', template: "<div [ngClass]=\"{'field-container' : showSearchBox}\"*ngIf=\"(categories | search: searchedTerm)?.length\" >\n    <mat-expansion-panel class=\"mb-6\">\n        <mat-expansion-panel-header>\n            <label class=\"axo-font font-normal\" *ngIf=\"(categories | search: searchedTerm)?.length\">Category</label>\n        </mat-expansion-panel-header>\n        <mat-selection-list #category\n        (selectionChange)=\"categorySelectionChange($event)\">\n            <ng-container *ngFor=\"let category of categories| search: searchedTerm;let i=index \">\n                <mat-list-option *ngIf=\"!category.isHidden\" checkboxPosition=\"after\"   [value]='category' [(selected)]=\"category.isSelected\" color=\"primary\">\n                    <span class=\"list-field\"  [matTooltip]=\"category.name\"> {{category.name}}</span>\n                </mat-list-option>\n            </ng-container>\n        </mat-selection-list>\n    </mat-expansion-panel>\n</div>\n", styles: [""] }]
    }], function () { return []; }, { categories: [{
            type: Input
        }], searchedTerm: [{
            type: Input
        }], categorySelected: [{
            type: Output
        }], categoryDeselected: [{
            type: Output
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 