import { r as registerInstance, c as createEvent, a as getElement, h } from './index-Cby2wKoI.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) {
        registerInstance(this, hostRef);
        this.ifxFilterAccordionChange = createEvent(this, "ifxFilterAccordionChange", 7);
    }
    initialized = false;
    get el() { return getElement(this); }
    expanded = false;
    maxVisibleItems;
    count = 0;
    totalItems = 0;
    filterGroupName = "";
    ifxFilterAccordionChange;
    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
        }
    }
    handleCheckedChange = (event) => {
        const selectedItems = event.detail.selectedItems;
        this.count = selectedItems.length;
        this.ifxFilterAccordionChange.emit({
            filterGroupName: this.filterGroupName,
            selectedItems,
        });
    };
    disconnectedCallback() {
        this.el.removeEventListener("ifxListUpdate", this.handleCheckedChange);
    }
    toggleAccordion = (event) => {
        event.stopPropagation();
        this.expanded = !this.expanded;
    };
    render() {
        return (h("div", { key: 'be328324ef844c69ff554dfff6b46ed1961cf40a', class: `accordion ${this.expanded ? "expanded" : ""}` }, h("div", { key: '287a3b866d340ae41c768351fdfeaf6252eaf80e', class: `header ${this.expanded ? "expanded" : ""}`, onClick: this.toggleAccordion }, h("div", { key: 'd7b9ca315a87219312695915a7ce36220c4f28be', class: `text-and-icon ${this.expanded ? "expanded" : ""}` }, h("div", { key: 'f810c8079bc7af490cc273e7d2f3a18f3080cd44', class: "text" }, h("span", { key: 'd6f1addaefd9c42a78380d7fb8f9c790ae375096' }, this.filterGroupName), h("ifx-indicator", { key: '437405d71307200633a421d2cea773741f2c1220', variant: "number", number: this.count })), h("ifx-icon", { key: '3a2b72d74688d9ec37ff2b70f42d54794f5f0987', class: this.expanded ? "" : "hidden", icon: "minus-16", onClick: this.toggleAccordion }), h("ifx-icon", { key: '20af9c2c8e3b7ed3164385958114d08093fc38bb', class: this.expanded ? "hidden" : "", icon: "plus-16", onClick: this.toggleAccordion }))), this.expanded && (h("div", { key: 'ac85b656a1df3b8a2c229ce00f70974f6e694f6b', class: "filter-accordion-container" }, h("slot", { key: '06606c2914759f180b22554dfc76394c823144f6', name: "list" })))));
    }
};
FilterAccordion.style = filterAccordionCss();

export { FilterAccordion as ifx_filter_accordion };
//# sourceMappingURL=ifx-filter-accordion.entry.js.map

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