// #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 { CssLength } from '@breadstone/mosaik-themes';
import { Dimensionable } from '../../../Behaviors/Dimensionable';
import { Fitable } from '../../../Behaviors/Fitable';
import { Insetable } from '../../../Behaviors/Insetable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Watch } from '../../../Decorators/WatchDecorator';
import { CustomElement } from '../../Abstracts/CustomElement';
import { boxElementTemplate } from './BoxElementTemplate';
import { boxElementJoyStyle } from './Themes/BoxElement.Joy';
import { boxElementRetroStyle } from './Themes/BoxElement.Retro';
import { boxElementCosmopolitanStyle } from './Themes/BoxElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
import { InlineStyleController } from '../../../Controllers/InlineStyleController';
// #endregion
/**
 * Box - A rectangular container used to group or layout other elements.
 *
 * @description
 * Is a equivalent to a `<div>` element with additional features.
 * Also known as a "container" or "panel".
 *
 * @name Box
 * @element mosaik-box
 * @category Primitives
 *
 * @slot - Default slot for child elements.
 * @slot dismiss - Slot for dismiss button.
 *
 * @public
 */
let BoxElement = class BoxElement extends Themeable(Fitable(Dimensionable(Insetable(CustomElement)))) {
    // #region Fields
    _inlineStyleController;
    _highlighted;
    _cornered;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._highlighted = false;
        this._cornered = false;
        this._inlineStyleController = new InlineStyleController(this);
    }
    // #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-box';
    }
    /**
     * Gets or sets the `highlighted` property.
     *
     * @public
     * @attr
     */
    get highlighted() {
        return this._highlighted;
    }
    set highlighted(value) {
        if (this._highlighted !== value) {
            this._highlighted = value;
            this.requestUpdate('highlighted');
        }
    }
    /**
     * Gets or sets the `cornered` property.
     *
     * @public
     * @attr
     */
    get cornered() {
        return this._cornered;
    }
    set cornered(value) {
        if (this._cornered !== value) {
            this._cornered = value;
            this.requestUpdate('cornered');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     */
    onWidthPropertyChanged(_prev, next) {
        if (this.fit !== 'width' && this.fit !== 'both') {
            this._inlineStyleController.set('min-width', next);
            this._inlineStyleController.set('width', next);
        }
    }
    /**
     * @protected
     */
    onHeightPropertyChanged(_prev, next) {
        if (this.fit !== 'height' && this.fit !== 'both') {
            this._inlineStyleController.set('min-height', next);
            this._inlineStyleController.set('height', next);
        }
    }
    /**
     * @protected
     */
    onFitPropertyChanged(_prev, next) {
        if (next === 'width') {
            this._inlineStyleController.set('min-width', this.width);
            this._inlineStyleController.set('width', this.width);
            this._inlineStyleController.set('min-height', 'auto');
            this._inlineStyleController.set('height', 'auto');
        }
        else if (next === 'height') {
            this._inlineStyleController.set('min-width', 'auto');
            this._inlineStyleController.set('width', 'auto');
            this._inlineStyleController.set('min-height', this.height);
            this._inlineStyleController.set('height', this.height);
        }
        else if (next === 'both') {
            this._inlineStyleController.set('min-width', this.width);
            this._inlineStyleController.set('width', this.width);
            this._inlineStyleController.set('min-height', this.height);
            this._inlineStyleController.set('height', this.height);
        }
        else {
            this._inlineStyleController.set('min-width', 'auto');
            this._inlineStyleController.set('width', 'auto');
            this._inlineStyleController.set('min-height', 'auto');
            this._inlineStyleController.set('height', 'auto');
        }
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], BoxElement.prototype, "highlighted", null);
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], BoxElement.prototype, "cornered", null);
__decorate([
    Watch('width'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", void 0)
], BoxElement.prototype, "onWidthPropertyChanged", null);
__decorate([
    Watch('height'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object, Object]),
    __metadata("design:returntype", void 0)
], BoxElement.prototype, "onHeightPropertyChanged", null);
__decorate([
    Watch('fit'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [String, String]),
    __metadata("design:returntype", void 0)
], BoxElement.prototype, "onFitPropertyChanged", null);
BoxElement = __decorate([
    Component({
        selector: 'mosaik-box',
        template: boxElementTemplate,
        themes: {
            joy: boxElementJoyStyle,
            retro: boxElementRetroStyle,
            cosmopolitan: boxElementCosmopolitanStyle
        },
        imports: []
    }),
    __metadata("design:paramtypes", [])
], BoxElement);
export { BoxElement };
//# sourceMappingURL=BoxElement.js.map