var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { html, state, property, customElement, nothing } from '../../../../../../external/lit/index.js';
import { UmbLitElement } from '../../../../lit-element/index.js';
import { UmbTextStyles } from '../../../../style/index.js';
import { getItemFallbackIcon, getItemFallbackName } from '../../../../entity-item/index.js';
let UmbDefaultCollectionMenuItemElement = class UmbDefaultCollectionMenuItemElement extends UmbLitElement {
    constructor() {
        super(...arguments);
        this._isActive = false;
        this._isSelected = false;
        this._isSelectable = false;
    }
    set item(newVal) {
        this._item = newVal;
        if (this._item) {
            this.#initItem();
        }
    }
    get item() {
        return this._item;
    }
    set api(value) {
        this.#api = value;
        if (this.#api) {
            this.observe(this.#api.isSelectable, (value) => (this._isSelectable = value));
            this.observe(this.#api.isSelected, (value) => (this._isSelected = value));
            this.#initItem();
        }
    }
    get api() {
        return this.#api;
    }
    #api;
    #initItem() {
        if (!this.#api)
            return;
        if (!this._item)
            return;
        this.#api.setItem(this._item);
    }
    render() {
        const item = this._item;
        if (!item)
            return nothing;
        return html `
			<uui-menu-item
				label=${item?.name ?? getItemFallbackName(item)}
				?selectable=${this._isSelectable}
				?selected=${this._isSelected}
				@selected=${() => this.#api?.select()}
				@deselected=${() => this.#api?.deselect()}>
				<umb-icon slot="icon" name=${item.icon ?? getItemFallbackIcon()}></umb-icon>
			</uui-menu-item>
		`;
    }
    static { this.styles = [UmbTextStyles]; }
};
__decorate([
    property({ type: Object, attribute: false })
], UmbDefaultCollectionMenuItemElement.prototype, "item", null);
__decorate([
    property({ type: Object, attribute: false })
], UmbDefaultCollectionMenuItemElement.prototype, "api", null);
__decorate([
    state()
], UmbDefaultCollectionMenuItemElement.prototype, "_isActive", void 0);
__decorate([
    state()
], UmbDefaultCollectionMenuItemElement.prototype, "_isSelected", void 0);
__decorate([
    state()
], UmbDefaultCollectionMenuItemElement.prototype, "_isSelectable", void 0);
UmbDefaultCollectionMenuItemElement = __decorate([
    customElement('umb-default-collection-menu-item')
], UmbDefaultCollectionMenuItemElement);
export { UmbDefaultCollectionMenuItemElement };
export { UmbDefaultCollectionMenuItemElement as element };
