/*!
 * Built with Stencil
 * By PostNord.
 */
import { t as transformTag, r as registerInstance, g as getElement, f as forceUpdate, h, a as Host } from './index-CAEP792y.js';

const pnAccordionCss = () => `${transformTag("pn-accordion")}{position:relative;background-color:#ffffff;display:flex;align-items:stretch;flex-direction:column;gap:0.25em}${transformTag("pn-accordion")}[data-transparent]{background-color:transparent}${transformTag("pn-accordion")}>${transformTag("pn-accordion-row")}+${transformTag("pn-accordion-row")}:after{content:"";position:absolute;top:-0.125em;left:0.25em;width:calc(100% - 0.5em);height:0;border-top:0.0625em solid #d3cecb}`;

const PnAccordion = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    mo;
    closeEvent = new CustomEvent('rowstate', { detail: false });
    get hostElement() { return getElement(this); }
    /** Only allow a single row to be open at once. @since v7.8.0 */
    single = false;
    /** Optional prop that removes the default white background on the accordion row. @since v7.10.0 */
    transparent = false;
    connectedCallback() {
        this.mo = new MutationObserver(() => forceUpdate(this.hostElement));
        this.mo.observe(this.hostElement, { childList: true, subtree: true });
    }
    disconnectedCallback() {
        this.mo.disconnect();
    }
    handleSingleRow({ detail }) {
        if (!this.single)
            return;
        const element = detail.element;
        const activeRow = element.closest(`${transformTag("pn-accordion-row")}`);
        const rows = Array.from(this.hostElement.querySelectorAll(`${transformTag("pn-accordion-row")}`));
        rows.forEach(row => !row.isSameNode(activeRow) && row.dispatchEvent(this.closeEvent));
    }
    render() {
        return (h(Host, { key: 'd8cd9ef7bd0d93aafda0e6955a9ad35ec81d55ae', class: "pn-accordion", "data-transparent": this.transparent }, h("slot", { key: '43233bb6107dcc4608edb0086ef347d7c936556f' })));
    }
};
PnAccordion.style = pnAccordionCss();

export { PnAccordion as pn_accordion };
