import { r as registerInstance, h, g as getElement } from './index-148a7577.js';
import { E as ExpandableFaqHeadingLevel, a as ExpandableFaqVariation } from './expandable-faq-variation.enum-6934c367.js';
import { l as logger } from './logger.util-ede3c48a.js';

const expandableFaqCss = ".sc-digi-expandable-faq-h{display:block}";
const DigiExpandableFaqStyle0 = expandableFaqCss;

const ExpandableFaq = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.isExpanded = undefined;
        this.afHeading = undefined;
        this.afHeadingLevel = ExpandableFaqHeadingLevel.H2;
        this.afVariation = ExpandableFaqVariation.PRIMARY;
        this.listItems = [];
    }
    componentWillLoad() {
        this.getListItems();
        this.setFaqItemProps();
    }
    componentWillUpdate() {
        this.getListItems();
        this.setFaqItemProps();
    }
    getListItems() {
        const menuItems = this.hostElement.querySelectorAll('digi-expandable-faq-item');
        if (!menuItems || menuItems.length <= 0) {
            logger.warn(`The slot contains no children elements.`, this.hostElement);
            return;
        }
        this.listItems = [...Array.from(menuItems)].map((faqItem) => {
            return {
                outerHTML: faqItem.outerHTML,
                ref: faqItem
            };
        });
    }
    setFaqItemProps() {
        this.listItems &&
            this.listItems.forEach((faqItem) => {
                faqItem.ref.afVariation = this.afVariation;
                try {
                    const topLevel = Number.parseInt(this.afHeadingLevel.split('h')[1]);
                    faqItem.ref.afHeadingLevel = 'h' + (topLevel + 1);
                }
                catch (e) {
                    // Nothing
                }
            });
    }
    render() {
        return (h("div", { key: 'fde7684ab703ddbe07b156035ba37050ed3dda1b', class: {
                'digi-expandable-faq': true
            } }, h(this.afHeadingLevel, { key: 'f2e2dfac429cdfed99c9f71071770918cf38df70' }, this.afHeading), h("slot", { key: 'a9289be94c96e969748c8bc76a701efb2e2b56d7' })));
    }
    get hostElement() { return getElement(this); }
};
ExpandableFaq.style = DigiExpandableFaqStyle0;

export { ExpandableFaq as digi_expandable_faq };
