// #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 { InlineStyleController } from '../../../Controllers/InlineStyleController';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { AutoFlow } from '../../../Types/AutoFlow';
import { CustomElement } from '../../Abstracts/CustomElement';
import { tileListElementCosmopolitanStyle } from './Themes/TileListElement.Cosmopolitan';
import { tileListElementJoyStyle } from './Themes/TileListElement.Joy';
import { tileListElementMemphisStyle } from './Themes/TileListElement.Memphis';
import { tileListElementTemplate } from './TileListElementTemplate';
import { TileListItemElement } from './TileListItemElement';
// #endregion
/**
 * TileList - A responsive grid container that arranges child items in a configurable tile layout.
 *
 * Creates a CSS Grid-based layout with customizable columns, row heights, and spacing.
 * Ideal for displaying cards, images, or other content in an organized grid pattern.
 * Supports drag-and-drop reordering of tiles.
 *
 * @name TileListElement
 * @element mosaik-tile-list
 * @category Layout
 *
 * @slot  - The default slot.
 *
 * @cssprop {String} --tile-list-font-family - The list font family CSS custom property.
 * @cssprop {String} --tile-list-font-letter-spacing - The list font letter spacing CSS custom property.
 * @cssprop {String} --tile-list-font-line-height - The list font line height CSS custom property.
 * @cssprop {String} --tile-list-font-size - The list font size CSS custom property.
 * @cssprop {String} --tile-list-font-text-decoration - The list font text decoration CSS custom property.
 * @cssprop {String} --tile-list-font-text-transform - The list font text transform CSS custom property.
 * @cssprop {String} --tile-list-font-weight - The list font weight CSS custom property.
 * @cssprop {String} --tile-list-gap - Spacing between grid items
 * @cssprop {String} --tile-list-gutter-size - The list gutter size CSS custom property.
 * @cssprop {String} --tile-list-padding-bottom - The list padding bottom CSS custom property.
 * @cssprop {String} --tile-list-padding-left - The list padding left CSS custom property.
 * @cssprop {String} --tile-list-padding-right - The list padding right CSS custom property.
 * @cssprop {String} --tile-list-padding-top - The list padding top CSS custom property.
 * @cssprop {String} --tile-list-shadow - The list shadow CSS custom property.
 * @cssprop {String} --tile-list-shadow-blur - The list shadow blur CSS custom property.
 * @cssprop {String} --tile-list-shadow-color - The list shadow color CSS custom property.
 * @cssprop {String} --tile-list-shadow-offset-x - The list shadow offset x CSS custom property.
 * @cssprop {String} --tile-list-shadow-offset-y - The list shadow offset y CSS custom property.
 * @cssprop {String} --tile-list-shadow-spread - The list shadow spread CSS custom property.
 * @cssprop {String} --tile-list-transition-duration - The list transition duration CSS custom property.
 * @cssprop {String} --tile-list-transition-mode - The list transition mode CSS custom property.
 * @cssprop {String} --tile-list-transition-property - The list transition property CSS custom property.
 * @cssprop {String} --tile-list-translate - The list translate CSS custom property.
 *
 * @example
 * ```html
 * <!-- Basic tile grid -->
 * <mosaik-tile-list cols="3" row-height="200px" gutter-size="16px">
 *   <mosaik-tile-list-item>
 *     <img src="image1.jpg" alt="Image 1">
 *   </mosaik-tile-list-item>
 *   <mosaik-tile-list-item>
 *     <img src="image2.jpg" alt="Image 2">
 *   </mosaik-tile-list-item>
 *   <mosaik-tile-list-item>
 *     <img src="image3.jpg" alt="Image 3">
 *   </mosaik-tile-list-item>
 * </mosaik-tile-list>
 *
 * <!-- Responsive card grid -->
 * <mosaik-tile-list cols="4" auto-flow="row" gutter-size="24px">
 *   <mosaik-tile-list-item>
 *     <div class="card">Card content 1</div>
 *   </mosaik-tile-list-item>
 *   <mosaik-tile-list-item>
 *     <div class="card">Card content 2</div>
 *   </mosaik-tile-list-item>
 * </mosaik-tile-list>
 * ```
 *
 * @public
 */
let TileListElement = class TileListElement extends Themeable(CustomElement) {
    // #region Fields
    _cols = 4;
    _rowHeight = '100px';
    _gutterSize = '16px';
    _autoFlow = AutoFlow.Column;
    _inlineStyleController;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._inlineStyleController = new InlineStyleController(this);
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `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
    /**
     * @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');
    }
    /**
     * @protected
     * @override
     */
    updated(changedProperties) {
        super.updated(changedProperties);
        this._inlineStyleController.set('tile-list-gutter-size', this._gutterSize);
        this._inlineStyleController.setStyle('grid-template-columns', `repeat(${this._cols}, 1fr)`);
        this._inlineStyleController.setStyle('grid-auto-rows', this._rowHeight);
        this._inlineStyleController.setStyle('grid-auto-flow', this._autoFlow);
    }
};
__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,
            memphis: tileListElementMemphisStyle,
            cosmopolitan: tileListElementCosmopolitanStyle
        },
        imports: [
            TileListItemElement
        ]
    }),
    __metadata("design:paramtypes", [])
], TileListElement);
export { TileListElement };
//# sourceMappingURL=TileListElement.js.map