import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-ClISz4NF.js';
import { v as validateProp } from './props-CJZgTDla.js';
import { a as AccordionClass, A as AccordionItemClass, b as AccordionSizes } from './constants-DbTQsVRc.js';
import { g as govHost, t as toBoolAttrIfDefined, b as booleanString } from './template-CoD1xawt.js';
import { i as inheritAriaAttributes } from './accessibility-wqNV8djF.js';
import { t as tick } from './stencil.utils-Cjg0wpDG.js';
import './gov.log-BtqD9K8d.js';
import './utils-CQvUntGY.js';
import './sizes-BcQO4NH2.js';
import './attribute-Bz_RzYFb.js';

const GovAccordionItem = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.govChange = createEvent(this, "gov-change");
        this.inheritedAttributes = {};
        /**
         * Makes the button component disabled.
         */
        this.disabled = false;
        /**
         * Defines whether the accordion is open or closed by button
         */
        this.open = false;
        this.h = govHost(this.host);
    }
    validateSize(newValue) {
        validateProp(AccordionSizes, newValue, AccordionItemClass.root);
    }
    componentWillLoad() {
        this.validateSize(this.size);
        this.inheritedAttributes = inheritAriaAttributes(this.host);
    }
    componentDidRender() {
        tick(() => this.getPropsFromParents());
    }
    getPropsFromParents() {
        const accordion = this.h.getParent(AccordionClass.root);
        if (accordion) {
            this.size = accordion.getAttribute("size");
        }
    }
    render() {
        return (h(Host, { key: '322aca243fd956d90542c23ffd384969a3e702ba', class: this.h.classes([AccordionItemClass.root,
                this.disabled && AccordionItemClass.disabled]), size: this.size, role: "listitem" }, h("details", { key: '80befb8ec6ecc9e1718d9e94fc693e382a384512', class: AccordionItemClass.details, id: this.identifier, "aria-disabled": toBoolAttrIfDefined(this.disabled), open: this.open }, h("summary", Object.assign({ key: 'f04df2d0a5c29c9c6621e69ab15c1ac72bc95912', onClick: (e) => {
                e.stopPropagation();
                e.preventDefault();
                !this.disabled && this.toggle().finally();
            }, class: AccordionItemClass.summary, tabIndex: this.disabled ? -1 : 0, "aria-expanded": booleanString(this.open) }, this.inheritedAttributes), this.h.hasSlot('icon') &&
            h("span", { key: '0889615c3b616615947e09cb7dc82a45f5bf3c36', class: AccordionItemClass.icon }, h("slot", { key: '204ee8071c84d94fe44f06781a169c6ed6548748', name: "icon" })), h("span", { key: '2558df9bfa5b027fd78858bc07c59c812144f7b0', class: AccordionItemClass.title }, h("slot", { key: 'ce4fc19e7bcd801e789fa920b75726ac2e6d64fa', name: "label" }), h("slot", { key: '6493bed9d3ff025212c6ddd483c6afc66e4e2555', name: "annotation" })), h("span", { key: '86bb4f277aa23a921803d1b15b19ddc1f9bef788', class: AccordionItemClass.right }, h("slot", { key: '6125404df4e25f638b3c0a2dc10d13cc58d5a2db', name: "suffix" }), h("span", { key: '4ec7fde2af7b5648b033440a646af0fa9cdb575a', class: AccordionItemClass.arrow }, h("slot", { key: 'cf5ace176c8c7cd53e8bad7c8155e396d37ca6fa', name: "toggle-icon" }, h("gov-icon", { key: '0d5e06a98c5ac069c3680ed5442064aed996eb46', name: "chevron-down", type: "components" }))))), h("div", { key: '6ce82f8da04142d8330f9da035f046272deffd4d', class: AccordionItemClass.content }, h("slot", { key: '47790abbe664864a3cf1d456762fb414d7c63418' })))));
    }
    /**
     * Accordion switch
     */
    async toggle() {
        this.open = !this.open;
        this.govChange.emit({
            open: this.open,
            component: AccordionItemClass.root,
            ref: this.host,
        });
    }
    /**
     * Returns the current state of the component
     */
    async currentState() {
        return this.open;
    }
    get host() { return getElement(this); }
    static get watchers() { return {
        "size": ["validateSize"]
    }; }
};

export { GovAccordionItem as gov_accordion_item };
//# sourceMappingURL=gov-accordion-item.entry.js.map

//# sourceMappingURL=gov-accordion-item.entry.js.map