// #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 { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { AutoFlow } from '../../../Types/AutoFlow';
import { CustomElement } from '../../Abstracts/CustomElement';
import { tileListElementTemplate } from './TileListElementTemplate';
import { TileListItemElement } from './TileListItemElement';
import { tileListElementJoyStyle } from './Themes/TileListElement.Joy';
import { tileListElementRetroStyle } from './Themes/TileListElement.Retro';
import { tileListElementCosmopolitanStyle } from './Themes/TileListElement.Cosmopolitan';
import { Themeable } from '../../../Behaviors/Themeable';
// #endregion
/**
 * Tile List - A layout component that arranges its child elements in a grid-like fashion, often used for displaying images, cards, or other content in a visually appealing way.
 *
 * @element mosaik-tile-list
 *
 * @public
 */
let TileListElement = class TileListElement extends Themeable(CustomElement) {
    // #region Fields
    _cols = 4;
    _rowHeight = '100px';
    _gutterSize = '16px';
    _autoFlow = AutoFlow.Column;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
    }
    // #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-tile-list';
    }
    /**
     * Gets or sets the `cols` property.
     *
     * @public
     * @attr
     */
    get cols() {
        return this._cols;
    }
    set cols(value) {
        if (this._cols !== value) {
            this._cols = value;
            this.requestUpdate('cols');
        }
    }
    /**
     * Gets or sets the `rowHeight` property.
     *
     * @public
     * @attr
     */
    get rowHeight() {
        return this._rowHeight;
    }
    set rowHeight(value) {
        if (this._rowHeight !== value) {
            this._rowHeight = value;
            this.requestUpdate('rowHeight');
        }
    }
    /**
     * Gets or sets the `gutterSize` property.
     *
     * @public
     * @attr
     */
    get gutterSize() {
        return this._gutterSize;
    }
    set gutterSize(value) {
        if (this._gutterSize !== value) {
            this._gutterSize = value;
            this.requestUpdate('gutterSize');
        }
    }
    /**
     * Gets or sets the `autoFlow` property.
     *
     * @public
     * @attr
     */
    get autoFlow() {
        return this._autoFlow;
    }
    set autoFlow(value) {
        if (this._autoFlow !== value) {
            this._autoFlow = value;
            this.requestUpdate('autoFlow');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @protected
     * @override
     */
    updated(changedProperties) {
        super.updated(changedProperties);
        this.style.setProperty('--tile-list-gutter-size', this._gutterSize);
        this.style.setProperty('grid-template-columns', `repeat(${this._cols}, 1fr)`);
        this.style.setProperty('grid-auto-rows', this._rowHeight);
        this.style.setProperty('grid-auto-flow', this._autoFlow);
    }
    /**
     * @private
     */
    onDrop(event) {
        event.preventDefault();
        event.target.classList.remove('dragover');
        const draggedTile = this.querySelector('.dragging');
        if (draggedTile) {
            const targetTile = event.target;
            this.insertBefore(draggedTile, targetTile);
        }
    }
    /**
     * @private
     */
    onDragOver(event) {
        event.preventDefault();
        event.target.classList.add('dragover');
    }
    /**
     * @private
     */
    onDragLeave(event) {
        event.target.classList.remove('dragover');
    }
};
__decorate([
    Attribute({ type: Number }),
    __metadata("design:type", Number),
    __metadata("design:paramtypes", [Number])
], TileListElement.prototype, "cols", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], TileListElement.prototype, "rowHeight", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], TileListElement.prototype, "gutterSize", null);
__decorate([
    Attribute({ type: String }),
    __metadata("design:type", String),
    __metadata("design:paramtypes", [String])
], TileListElement.prototype, "autoFlow", null);
TileListElement = __decorate([
    Component({
        selector: 'mosaik-tile-list',
        template: tileListElementTemplate,
        themes: {
            joy: tileListElementJoyStyle,
            retro: tileListElementRetroStyle,
            cosmopolitan: tileListElementCosmopolitanStyle
        },
        imports: [
            TileListItemElement
        ]
    }),
    __metadata("design:paramtypes", [])
], TileListElement);
export { TileListElement };
//# sourceMappingURL=TileListElement.js.map