// #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 { Property } from '../../../../Decorators/PropertyDecorator';
import { SelectorElement } from '../Selector/SelectorElement';
// #endregion
/**
 * The `{@link MultiSelectorElement}` element.
 *
 * @fires selectionChanged - Fired when the selection has changed.
 * @fires itemsChanged - Fired when the items has changed.
 *
 * @public
 * @abstract
 */
export class MultiSelectorElement extends SelectorElement {
    // #region Fields
    _selectedItems;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._selectedItems = new Array();
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `{@link is}` property.
     * The `{@link is}` property represents natural name of this element.
     *
     * @public
     * @static
     * @override
     * @readonly
     */
    static get is() {
        return 'mosaik-MultiSelector';
    }
    /**
     * Gets the first item in the current selection or returns null if the selection is empty.
     *
     * @private
     * @readonly
     */
    get selectedItems() {
        return this._selectedItems;
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @override
     */
    onSelectionChanged(oldIndex, newIndex, cb) {
        const item = this.items[newIndex];
        if (item) {
            if (this._selectedItems.includes(item)) {
                this._selectedItems.splice(this._selectedItems.indexOf(item), 1);
            }
            else {
                this._selectedItems.push(item);
            }
            // TODO: prepare display text
            // mybe we can implement formatter method/property for this.
            // same as in avatar element for initals.
            this.requestUpdate('selectedItems');
        }
        super.onSelectionChanged(oldIndex, newIndex, cb);
    }
}
__decorate([
    Property({ type: (Array) }),
    __metadata("design:type", Array),
    __metadata("design:paramtypes", [])
], MultiSelectorElement.prototype, "selectedItems", null);
//# sourceMappingURL=MultiSelectorElement.js.map