'use strict';

var index = require('./index-n_pDKBY2.js');

// utils.ts
function getInitiallySelectedItems(el) {
    return Array.from(el.querySelectorAll('ifx-list-entry'))
        .filter(entry => entry.getAttribute('value') === 'true')
        .map(entry => {
        return {
            label: entry.getAttribute('label'),
            value: entry.getAttribute('value'),
            type: entry.getAttribute('type')
        };
    });
}

const filterAccordionCss = ".header{display:flex;align-items:flex-start;align-self:stretch;cursor:pointer;border-left:3px solid transparent}.text-and-icon{display:flex;padding:12px 16px 12px 20px;align-items:center;gap:16px;flex:1 0 0}.header.expanded{border-left:3px solid #0A8276}.text{display:flex;align-items:center;gap:8px;flex:1 0 0;color:#1D1D1D;font-size:16px;font-style:normal;font-weight:600;line-height:24px}.hidden{display:none}.accordion{border-bottom:1px solid #EEEDED}.filter-accordion-container{display:flex;padding:8px 16px 16px 20px;flex-direction:column;align-items:flex-start;gap:12px;align-self:stretch;border-left:3px solid #0A8276}::slotted(ifx-filter-entry:nth-child(n+7)){display:none}.link{display:flex;align-items:center;gap:8px}.show-more ::slotted(ifx-filter-entry:nth-child(n+7)){display:block}.show-more .show-more-link{display:none}";

const FilterAccordion = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.ifxFilterAccordionChange = index.createEvent(this, "ifxFilterAccordionChange", 7);
        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 (index.h("div", { key: '70376ec184dcd378c6c595d5b30cdb82c8082de6', class: `accordion ${this.expanded ? 'expanded' : ''}` }, index.h("div", { key: 'c056174028a70bb2f4e28ced5dd81dca18f1a395', class: `header ${this.expanded ? 'expanded' : ''}`, onClick: this.toggleAccordion }, index.h("div", { key: 'dcdce6679b05c5acad3ba2216270564ea41cc451', class: `text-and-icon ${this.expanded ? 'expanded' : ''}` }, index.h("div", { key: '49c6ebef37a4b6798210425c694b4ade083a8216', class: "text" }, index.h("span", { key: 'd027e2e2cc48441b93d490321ac1b5cb2e8d8103' }, this.filterGroupName), index.h("ifx-indicator", { key: 'b9c83f3318aadd8c25a232233a83448713c80495', variant: 'number', number: this.count })), index.h("ifx-icon", { key: 'e4759317302f8f4c876a4f9bb87f1295b816a8a4', class: this.expanded ? '' : 'hidden', icon: "minus-16", onClick: this.toggleAccordion }), index.h("ifx-icon", { key: '4eb6119e32b9b8871d2b1f77d362499e6d9948ce', class: this.expanded ? 'hidden' : '', icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded &&
            index.h("div", { key: '833bcbac536f4d39419682e217f1c398c43b8e3b', class: "filter-accordion-container" }, index.h("slot", { key: '9b6fd50774992f88098423ca1ff8e91587bae9b6', name: "list" }))));
    }
    get el() { return index.getElement(this); }
};
FilterAccordion.style = filterAccordionCss;

exports.ifx_filter_accordion = FilterAccordion;
//# sourceMappingURL=ifx-filter-accordion.entry.cjs.js.map

//# sourceMappingURL=ifx-filter-accordion.cjs.entry.js.map