// #region Imports
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Emit } from '../../../../Events/Decorators/EmitDecorator';
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { Disableable } from '../../../Behaviors/Disableable';
import { Focusable } from '../../../Behaviors/Focusable';
import { Labelable } from '../../../Behaviors/Labelable';
import { Slottable } from '../../../Behaviors/Slottable';
import { Valueable } from '../../../Behaviors/Valueable';
import { Variantable } from '../../../Behaviors/Variantable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { ButtonElement } from '../../Buttons/Button/ButtonElement';
import { RippleElement } from '../../Effects/Ripple/RippleElement';
import { StackElement } from '../../Layouts/Stack/StackElement';
import { IconElement } from '../../Media/Icon/IconElement';
import { CheckmarkElement } from '../../Primitives/Checkmark/CheckmarkElement';
import { ExpandableElement } from '../../Primitives/Expandable/ExpandableElement';
import { FocusRingElement } from '../../Primitives/FocusRing/FocusRingElement';
import { TextElement } from '../../Primitives/Text/TextElement';
import { menuItemElementTemplate } from './MenuItemElementTemplate';
import { menuItemElementJoyStyle } from './Themes/MenuItemElement.Joy';
import { menuItemElementRetroStyle } from './Themes/MenuItemElement.Retro';
import { menuItemElementCosmopolitanStyle } from './Themes/MenuItemElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
import { TextOverflow } from '../../../Types/TextOverflow';
import { Appearanceable } from '../../../Behaviors/Appearanceable';
// #endregion
/**
 * Menu Item - An individual option or choice within a menu.
 *
 * @element mosaik-menu-item
 *
 * @slot - The default slot for child menu items.
 * @slot start - The start slot.
 * @slot icon - The icon slot.
 * @slot label - The label slot.
 * @slot subLabel - The subLabel slot.
 * @slot end - The end slot.
 *
 * @fires activated - Called when the element is activated.
 *
 * @public
 */
let MenuItemElement = class MenuItemElement extends Themeable(Disableable(Valueable(Variantable(Appearanceable(Focusable(Slottable(Labelable(CustomElement)))))))) {
    // #region Fields
    _activated;
    _subLabel;
    _icon;
    _isActive;
    _isChecked;
    _hasChildren;
    _isExpanded;
    _textOverflow;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._subLabel = '';
        this._icon = '';
        this._isActive = false;
        this._isChecked = false;
        this._hasChildren = false;
        this._isExpanded = false;
        this._textOverflow = TextOverflow.Truncate;
        this._activated = new HTMLElementEventEmitter(this, 'activated');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-menu-item';
    }
    /**
     * Gets or sets the `subLabel` property.
     *
     * @public
     * @attr
     */
    get subLabel() {
        return this._subLabel;
    }
    set subLabel(value) {
        if (this._subLabel !== value) {
            this._subLabel = value;
            this.requestUpdate('subLabel');
        }
    }
    /**
     * Gets or sets the `icon` property.
     *
     * @public
     */
    get icon() {
        return this._icon;
    }
    set icon(value) {
        if (this._icon !== value) {
            this._icon = value;
            this.requestUpdate('icon');
        }
    }
    /**
     * Gets or sets the `isActive` property.
     *
     * @public
     * @attr
     */
    get isActive() {
        return this._isActive;
    }
    set isActive(value) {
        if (this._isActive !== value) {
            this._isActive = value;
            this.requestUpdate('isActive');
        }
    }
    /**
     * Gets or sets the `isChecked` property.
     *
     * @public
     * @attr
     */
    get isChecked() {
        return this._isChecked;
    }
    set isChecked(value) {
        if (this._isChecked !== value) {
            this._isChecked = value;
            this.requestUpdate('isChecked');
        }
    }
    /**
     * Gets or sets the `isExpanded` property.
     *
     * @public
     * @attr
     */
    get isExpanded() {
        return this._isExpanded;
    }
    set isExpanded(value) {
        if (this._isExpanded !== value) {
            this._isExpanded = value;
            this.requestUpdate('isExpanded');
        }
    }
    /**
     * The `hasChildren` property represents whether the element has children or not.
     *
     * @public
     * @readonly
     * @attr
     */
    get hasChildren() {
        return this._hasChildren;
    }
    set hasChildren(value) {
        if (this._hasChildren !== value) {
            this._hasChildren = value;
            this.requestUpdate('hasChildren');
        }
    }
    /**
     * Gets or sets the `textOverflow` property.
     *
     * @public
     * @attr
     */
    get textOverflow() {
        return this._textOverflow;
    }
    set textOverflow(value) {
        if (this._textOverflow !== value) {
            this._textOverflow = value;
            this.requestUpdate('textOverflow');
        }
    }
    /**
     * Called when the element is activated.
     * Provides reference to `{@link IEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get activated() {
        return this._activated;
    }
    // #endregion
    // #region Methods
    /**
     * Expands the menu item.
     *
     * @public
     */
    expand() {
        if (this.disabled) {
            return;
        }
        if (!this.hasChildren) {
            return;
        }
        this.isExpanded = true;
    }
    /**
     * Collapses the menu item.
     *
     * @public
     */
    collapse() {
        if (this.disabled) {
            return;
        }
        if (!this.hasChildren) {
            return;
        }
        this.isExpanded = false;
    }
    /**
     * Toggles the expanded state of the menu item.
     *
     * @public
     */
    toggle() {
        if (this.disabled) {
            return;
        }
        if (!this.hasChildren) {
            return;
        }
        this.isExpanded = !this.isExpanded;
    }
    /**
     * @public
     * @overload
     */
    onSlotChanges(slotName) {
        // this is the slot to react on child menu changes
        if (slotName === '') {
            this.hasChildren = this.hasSlotContent('');
        }
    }
    /**
     * Emits the {@link activated} event.
     *
     * @protected
     */
    onActivated(args) {
        this._activated.emit(args);
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MenuItemElement.prototype, "subLabel", null);
__decorate([
    Property({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MenuItemElement.prototype, "icon", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], MenuItemElement.prototype, "isActive", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], MenuItemElement.prototype, "isChecked", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], MenuItemElement.prototype, "isExpanded", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], MenuItemElement.prototype, "hasChildren", null);
__decorate([
    Attribute({ type: TextOverflow }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], MenuItemElement.prototype, "textOverflow", null);
__decorate([
    Emit({ eventName: 'activated' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], MenuItemElement.prototype, "activated", null);
MenuItemElement = __decorate([
    Component({
        selector: 'mosaik-menu-item',
        template: menuItemElementTemplate,
        themes: {
            joy: menuItemElementJoyStyle,
            retro: menuItemElementRetroStyle,
            cosmopolitan: menuItemElementCosmopolitanStyle
        },
        host: {
            tabIndex: '0'
        },
        imports: [
            IconElement,
            ButtonElement,
            TextElement,
            RippleElement,
            FocusRingElement,
            StackElement,
            CheckmarkElement,
            ExpandableElement
        ]
    }),
    __metadata("design:paramtypes", [])
], MenuItemElement);
export { MenuItemElement };
//# sourceMappingURL=MenuItemElement.js.map