import { defineComponent, h, inject } from 'vue';
import { render } from '../../_utils';
import { dropdownInjectionKey } from './Dropdown';
import { dropdownMenuInjectionKey } from './DropdownMenu';
export default defineComponent({
    name: 'DropdownGroupHeader',
    props: {
        clsPrefix: {
            type: String,
            required: true
        },
        tmNode: {
            type: Object,
            required: true
        }
    },
    setup() {
        const { showIconRef, hasSubmenuRef
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
         } = inject(dropdownMenuInjectionKey);
        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
        const { renderLabelRef, labelFieldRef } = inject(dropdownInjectionKey);
        return {
            labelField: labelFieldRef,
            showIcon: showIconRef,
            hasSubmenu: hasSubmenuRef,
            renderLabel: renderLabelRef
        };
    },
    render() {
        var _a;
        const { clsPrefix, hasSubmenu, showIcon, renderLabel } = this;
        const { rawNode } = this.tmNode;
        return (h("div", { class: `${clsPrefix}-dropdown-option` },
            h("div", { class: `${clsPrefix}-dropdown-option-body ${clsPrefix}-dropdown-option-body--group` },
                h("div", { "__dropdown-option": true, class: [
                        `${clsPrefix}-dropdown-option-body__prefix`,
                        showIcon && `${clsPrefix}-dropdown-option-body__prefix--show-icon`
                    ] }, render(rawNode.icon)),
                h("div", { class: `${clsPrefix}-dropdown-option-body__label`, "__dropdown-option": true }, renderLabel
                    ? renderLabel(rawNode)
                    : render((_a = rawNode.title) !== null && _a !== void 0 ? _a : rawNode[this.labelField])),
                h("div", { class: [
                        `${clsPrefix}-dropdown-option-body__suffix`,
                        hasSubmenu &&
                            `${clsPrefix}-dropdown-option-body__suffix--has-submenu`
                    ], "__dropdown-option": true }))));
    }
});
