import { r as registerInstance, g as getElement, h } from './index-fdf7135e.js';
import { i as isActivationKey } from './a11y-f9ab2964.js';

const CollapseItem = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
    }
    get el() { return getElement(this); }
    /** 唯一标识（手风琴模式协调用） */
    key = '';
    /** 标题 */
    title = '';
    /** 是否禁用 */
    disabled = false;
    /** 是否展开（受控；由父级 hb-collapse 在手风琴模式下联动） */
    active = false;
    isOpen = false;
    componentDidLoad() {
        this.isOpen = this.active;
    }
    handleActiveChange(val) {
        this.isOpen = val;
    }
    toggle = () => {
        if (this.disabled)
            return;
        this.isOpen = !this.isOpen;
        this.active = this.isOpen;
        // 通知父级 hb-collapse（composed 穿越 shadow 边界，用于手风琴协调）
        this.el.dispatchEvent(new CustomEvent('hbCollapseItemToggle', {
            detail: { key: this.key, active: this.isOpen },
            bubbles: true,
            composed: true,
        }));
    };
    handleHeaderKeydown = (e) => {
        if (this.disabled)
            return;
        if (isActivationKey(e.key)) {
            e.preventDefault();
            this.toggle();
        }
    };
    render() {
        return (h("div", { key: '37cf0afe29b3a3b6bb538a8dc962804a71c9dce9', class: { 'hb-collapse-item': true, 'hb-collapse-item--active': this.isOpen, 'hb-collapse-item--disabled': this.disabled } }, h("div", { key: 'be864927a75dc717aab21745f728adbd149fd3b8', class: "hb-collapse-item__header", role: "button", tabindex: this.disabled ? -1 : 0, "aria-expanded": this.isOpen ? 'true' : 'false', "aria-disabled": this.disabled ? 'true' : undefined, onClick: this.toggle, onKeyDown: this.handleHeaderKeydown }, h("span", { key: 'afea7c20f59efc964aeebfb995d0b713ebb28542', class: "hb-collapse-item__title" }, this.title), h("span", { key: '1aa30ec50c6105f8a07a2ac30ea8108d19923eb8', class: { 'hb-collapse-item__arrow': true, 'hb-collapse-item__arrow--open': this.isOpen } }, "\u25B6")), h("div", { key: '6e6d66dd8477019c7dc8dbc66fd81646e8c3899a', class: { 'hb-collapse-item__wrapper': true, 'hb-collapse-item__wrapper--open': this.isOpen } }, h("div", { key: '776a67a054ea8fd5b664f2e475843ff2344b41c4', class: "hb-collapse-item__content" }, h("slot", { key: '1fc2c8492891d16fef88b83c2f46207a2508a81e' })))));
    }
    static get watchers() { return {
        "active": ["handleActiveChange"]
    }; }
};

export { CollapseItem as hb_collapse_item };

//# sourceMappingURL=hb-collapse-item.entry.js.map