import { p as proxyCustomElement, H, h } from './p-a53686b3.js';
import { E as ExpandableFaqHeadingLevel, a as ExpandableFaqVariation } from './p-1f68d501.js';
import { l as logger } from './p-e3d2e899.js';

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

const ExpandableFaq = /*@__PURE__*/ proxyCustomElement(class ExpandableFaq extends H {
    constructor() {
        super();
        this.__registerHost();
        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 this; }
    static get style() { return DigiExpandableFaqStyle0; }
}, [6, "digi-expandable-faq", {
        "afHeading": [1, "af-heading"],
        "afHeadingLevel": [1, "af-heading-level"],
        "afVariation": [1, "af-variation"],
        "isExpanded": [32],
        "listItems": [32]
    }]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["digi-expandable-faq"];
    components.forEach(tagName => { switch (tagName) {
        case "digi-expandable-faq":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, ExpandableFaq);
            }
            break;
    } });
}

const DigiExpandableFaq = ExpandableFaq;
const defineCustomElement = defineCustomElement$1;

export { DigiExpandableFaq, defineCustomElement };
