// #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 { Themeable } from '../../../Behaviors/Themeable';
import { Component } from '../../../Decorators/ComponentDecorator';
import { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { indicatorElementTemplate } from './IndicatorElementTemplate';
import { Disableable } from '../../../Behaviors/Disableable';
import { Variantable } from '../../../Behaviors/Variantable';
import { CustomElement } from '../../Abstracts/CustomElement';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Emit } from '../../../../Events/Decorators/EmitDecorator';
import { Orientable } from '../../../Behaviors/Orientable';
import { indicatorElementJoyStyle } from './Themes/IndicatorElement.Joy';
import { indicatorElementRetroStyle } from './Themes/IndicatorElement.Retro';
import { indicatorElementCosmopolitanStyle } from './Themes/IndicatorElement.Cosmopolitan';
// #endregion
/**
 * Indicator - A visual element that indicates the current position within a set of items, often used in carousels or pagination.
 *
 * @element mosaik-indicator
 *
 * @fires indicated - Fired when the indicator is changed.
 *
 * @public
 */
let IndicatorElement = class IndicatorElement extends Themeable(Disableable(Variantable(Orientable(CustomElement)))) {
    // #region Fields
    _indicated;
    _total;
    _selected;
    // #endregion
    // #region Ctor
    constructor() {
        super();
        this._total = 0;
        this._selected = 0;
        this._indicated = new HTMLElementEventEmitter(this, 'indicated');
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     *
     * @public
     * @static
     * @readonly
    */
    static get is() {
        return 'mosaik-indicator';
    }
    /**
     * Gets or sets the `total` count of indicators.
     *
     * @attr
     * @public
     */
    get total() {
        return this._total;
    }
    set total(value) {
        if (this._total !== value) {
            this._total = value;
            this.requestUpdate('total');
        }
    }
    /**
     * Gets or sets the `selected` indicator.
     *
     * @attr
     * @public
     */
    get selected() {
        return this._selected;
    }
    set selected(value) {
        if (this._selected !== value) {
            this._selected = value;
            this.requestUpdate('selected');
        }
    }
    /**
     * Called when the indicated value changes.
     * Provides reference to `any` as event argument.
     *
     * @public
     * @readonly
     * @eventProperty
     * @type EventEmitter<any>
     */
    get indicated() {
        return this._indicated;
    }
    // #endregion
    // #region Methods
    /**
     * @private
     * @template
     */
    onItemClick(index) {
        if (this.disabled || index < 0 || index >= this.total) {
            return;
        }
        this.selected = index;
        this.onIndicated({ index: index });
    }
    /**
     * Emits the {@link indicated} event.
     *
     * @protected
     */
    onIndicated(args) {
        this._indicated.emit(args);
    }
};
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], IndicatorElement.prototype, "total", null);
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], IndicatorElement.prototype, "selected", null);
__decorate([
    Emit({ eventName: 'indicated' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], IndicatorElement.prototype, "indicated", null);
IndicatorElement = __decorate([
    Component({
        selector: 'mosaik-indicator',
        template: indicatorElementTemplate,
        themes: {
            joy: indicatorElementJoyStyle,
            retro: indicatorElementRetroStyle,
            cosmopolitan: indicatorElementCosmopolitanStyle
        }
    }),
    __metadata("design:paramtypes", [])
], IndicatorElement);
export { IndicatorElement };
//# sourceMappingURL=IndicatorElement.js.map