/* eslint-disable no-multi-assign */
// #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 { HTMLElementEventEmitter } from '@breadstone/mosaik-elements';
import { CustomElement } from '../../Controls/Components/Abstracts/CustomElement';
import { Attribute } from '../../Controls/Decorators/AttributeDecorator';
import { Component } from '../../Controls/Decorators/ComponentDecorator';
import { Emit } from '../../Events/Decorators/EmitDecorator';
import { BreakpointController } from './BreakpointController';
import { breakpointElementStyle } from './BreakpointElementStyle';
import { breakpointElementTemplate } from './BreakpointElementTemplate';
// #endregion
/**
 * The `{@link BreakpointElement}` element.
 *
 * @fires matched - Fired when the breakpoint is matched.
 *
 * @public
 */
let BreakpointElement = class BreakpointElement extends CustomElement {
    // #region Fields
    _breakpointController;
    _matched;
    _query;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._query = '';
        this._matched = new HTMLElementEventEmitter(this, 'matched');
        this._breakpointController = new BreakpointController(this, {
            query: this.query,
            callback: (match, query) => {
                this._matched.emit({
                    match,
                    query
                });
            }
        });
    }
    // #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-breakpoint';
    }
    /**
     * Gets or sets the `query` property.
     *
     * @public
     * @attr
     */
    get query() {
        return this._query;
    }
    set query(value) {
        if (this._query !== value) {
            this._breakpointController.query = this._query = value;
            this.requestUpdate('query');
        }
    }
    /**
     * Called when <ACTION>.
     * Provides reference to `{@link IBreakpointMatchedEventDetail}` as event detail.
     *
     * @public
     * @readonly
     * @eventProperty
     */
    get matched() {
        return this._matched;
    }
};
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [Object])
], BreakpointElement.prototype, "query", null);
__decorate([
    Emit({ eventName: 'matched' }),
    __metadata("design:type", Object),
    __metadata("design:paramtypes", [])
], BreakpointElement.prototype, "matched", null);
BreakpointElement = __decorate([
    Component({
        selector: 'mosaik-breakpoint',
        template: breakpointElementTemplate,
        styles: breakpointElementStyle
    }),
    __metadata("design:paramtypes", [])
], BreakpointElement);
export { BreakpointElement };
//# sourceMappingURL=BreakpointElement.js.map