import { h } from "@stencil/core";
import { getInitiallySelectedItems } from "../utils";
export class FilterAccordion {
    constructor() {
        this.initialized = false;
        this.expanded = false;
        this.count = 0;
        this.totalItems = 0;
        this.filterGroupName = "";
        this.handleCheckedChange = (event) => {
            const selectedItems = event.detail.selectedItems;
            this.count = selectedItems.length;
            this.ifxFilterAccordionChange.emit({ filterGroupName: this.filterGroupName, selectedItems });
        };
        this.toggleAccordion = (event) => {
            event.stopPropagation();
            this.expanded = !this.expanded;
        };
    }
    componentWillLoad() {
        this.el.addEventListener('ifxListUpdate', this.handleCheckedChange);
    }
    componentDidLoad() {
        if (!this.initialized) {
            const selectedItems = getInitiallySelectedItems(this.el);
            this.count = selectedItems.length;
            this.initialized = true; // Prevent further execution in future calls
        }
    }
    componentWillUnload() {
        this.el.removeEventListener('ifxListUpdate', this.handleCheckedChange);
    }
    render() {
        return (h("div", { key: '6cbfe75fad6e0ca5809f3094ea6357a896e5c02f', class: `accordion ${this.expanded ? 'expanded' : ''}` }, h("div", { key: 'a9aba4373768d85837132a3bf984033ab80e2fd8', class: `header ${this.expanded ? 'expanded' : ''}`, onClick: this.toggleAccordion }, h("div", { key: '9bbfa75f1d6b55c6f14b4934d0cf9906120075d2', class: `text-and-icon ${this.expanded ? 'expanded' : ''}` }, h("div", { key: 'd7775c4c711efd6d00f8ef8f384e49f0554fb74b', class: "text" }, h("span", { key: 'b11e0152875bf988e8a6cf36909cf5b839d560ac' }, this.filterGroupName), h("ifx-indicator", { key: 'a3abb8630d0069b2fa98293c1cb76ae7172b73ab', variant: 'number', number: this.count })), h("ifx-icon", { key: '94e6aa786f4a1ecb8322fb22edd9948c2d41857b', class: this.expanded ? '' : 'hidden', icon: "minus-16", onClick: this.toggleAccordion }), h("ifx-icon", { key: '8edeb3a9686adf291a52aff6a57d3af10c83d5c9', class: this.expanded ? 'hidden' : '', icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded &&
            h("div", { key: 'c557ca1e3aa2ef881425bb475166c2d49be0758f', class: "filter-accordion-container" }, h("slot", { key: '21f27e28cbd82d95dd3722067034c8f1866f1766', name: "list" }))));
    }
    static get is() { return "ifx-filter-accordion"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["filter-accordion.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["filter-accordion.css"]
        };
    }
    static get properties() {
        return {
            "maxVisibleItems": {
                "type": "number",
                "attribute": "max-visible-items",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "filterGroupName": {
                "type": "string",
                "attribute": "filter-group-name",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "\"\""
            }
        };
    }
    static get states() {
        return {
            "expanded": {},
            "count": {},
            "totalItems": {}
        };
    }
    static get events() {
        return [{
                "method": "ifxFilterAccordionChange",
                "name": "ifxFilterAccordionChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=filter-accordion.js.map
