// #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 { Disableable } from '../../../Behaviors/Disableable';
import { Themeable } from '../../../Behaviors/Themeable';
import { Attribute } from '../../../Decorators/AttributeDecorator';
import { Component } from '../../../Decorators/ComponentDecorator';
import { Property } from '../../../Decorators/PropertyDecorator';
import { TextElement } from '../../Primitives/Text/TextElement';
import { ItemsElement } from '../Abstracts/Items/ItemsElement';
import { ListElement } from '../List/ListElement';
import { dataListElementTemplate } from './DataListElementTemplate';
import { dataListElementCosmopolitanStyle } from './Themes/DataListElement.Cosmopolitan';
import { dataListElementJoyStyle } from './Themes/DataListElement.Joy';
import { dataListElementMemphisStyle } from './Themes/DataListElement.Memphis';
// #endregion
/**
 * Data List - A structured list component for displaying tabular data with configurable columns.
 *
 * @description
 * The Data List component provides a flexible way to display tabular data in a list format.
 * It supports dynamic item definitions with configurable columns, alternating row styles, and
 * data binding from various sources. Each row is rendered as a list item with cells corresponding
 * to the defined item definitions. The component is ideal for displaying structured data sets
 * where each record has multiple fields that need to be presented in a consistent format.
 *
 * @name Data List
 * @element mosaik-data-list
 * @category Selectors
 *
 * @csspart list - The inner list container element
 *
 * @cssprop {String} --data-list-font-family - The list font family CSS custom property.
 * @cssprop {String} --data-list-font-letter-spacing - The list font letter spacing CSS custom property.
 * @cssprop {String} --data-list-font-line-height - The list font line height CSS custom property.
 * @cssprop {String} --data-list-font-size - The list font size CSS custom property.
 * @cssprop {String} --data-list-font-text-decoration - The list font text decoration CSS custom property.
 * @cssprop {String} --data-list-font-text-transform - The list font text transform CSS custom property.
 * @cssprop {String} --data-list-font-weight - The list font weight CSS custom property.
 * @cssprop {String} --data-list-gap - The list gap CSS custom property.
 * @cssprop {String} --data-list-padding-bottom - The list padding bottom CSS custom property.
 * @cssprop {String} --data-list-padding-left - The list padding left CSS custom property.
 * @cssprop {String} --data-list-padding-right - The list padding right CSS custom property.
 * @cssprop {String} --data-list-padding-top - The list padding top CSS custom property.
 * @cssprop {String} --data-list-shadow - The list shadow CSS custom property.
 * @cssprop {String} --data-list-shadow-blur - The list shadow blur CSS custom property.
 * @cssprop {String} --data-list-shadow-color - The list shadow color CSS custom property.
 * @cssprop {String} --data-list-shadow-offset-x - The list shadow offset x CSS custom property.
 * @cssprop {String} --data-list-shadow-offset-y - The list shadow offset y CSS custom property.
 * @cssprop {String} --data-list-shadow-spread - The list shadow spread CSS custom property.
 * @cssprop {String} --data-list-transition-duration - The list transition duration CSS custom property.
 * @cssprop {String} --data-list-transition-mode - The list transition mode CSS custom property.
 * @cssprop {String} --data-list-transition-property - The list transition property CSS custom property.
 * @cssprop {String} --data-list-translate - The list translate CSS custom property.
 *
 * @fires connected {ConnectedEvent} - Fired when the data list is connected to the DOM
 * @fires changed {PropertyChangedEvent} - Fired when data list properties change
 *
 * @dependency mosaik-list - The List element.
 * @dependency mosaik-list-item - The List Item element.
 * @dependency mosaik-text - The Text element.
 *
 * @example
 * Basic data list with item definitions:
 * ```html
 * <mosaik-data-list id="userList"></mosaik-data-list>
 * <script>
 *   const list = document.getElementById('userList');
 *   list.itemDefinitions = [
 *     { key: 'name', pathFn: 'name' },
 *     { key: 'email', pathFn: 'email' },
 *     { key: 'role', pathFn: 'role' }
 *   ];
 *   list.source = [
 *     { name: 'John Doe', email: 'john@example.com', role: 'Admin' },
 *     { name: 'Jane Smith', email: 'jane@example.com', role: 'User' }
 *   ];
 * </script>
 * ```
 *
 * @example
 * Data list with alternating rows:
 * ```html
 * <mosaik-data-list alternating id="products"></mosaik-data-list>
 * <script>
 *   const list = document.getElementById('products');
 *   list.itemDefinitions = [
 *     { key: 'sku', pathFn: 'sku' },
 *     { key: 'product', pathFn: 'name' },
 *     { key: 'price', pathFn: 'price' }
 *   ];
 *   list.source = productData;
 * </script>
 * ```
 *
 * @public
 */
let DataListElement = class DataListElement extends Themeable(Disableable(ItemsElement)) {
    // #region Fields
    _alternating;
    _itemDefinitions;
    // #endregion
    // #region Ctor
    /**
     * @public
     */
    constructor() {
        super();
        this._alternating = false;
        this._itemDefinitions = new Array();
    }
    // #endregion
    // #region Properties
    /**
     * Returns the `is` property.
     * The `is` property represents natural name of this element.
     *
     * @public
     * @static
     * @readonly
     */
    static get is() {
        return 'mosaik-data-list';
    }
    /**
     * Gets or sets the `alternating` property.
     *
     * @public
     * @attr
     */
    get alternating() {
        return this._alternating;
    }
    set alternating(value) {
        if (this._alternating !== value) {
            this._alternating = value;
            this.requestUpdate('alternating');
        }
    }
    /**
     * Gets or sets the `itemDefinitions` property.
     *
     * @public
     */
    get itemDefinitions() {
        return this._itemDefinitions;
    }
    set itemDefinitions(value) {
        if (this._itemDefinitions !== value) {
            this._itemDefinitions = value;
            this.requestUpdate('itemDefinitions');
        }
    }
    // #endregion
    // #region Methods
    /**
     * @template
     * @private
     */
    getItemDefinitions() {
        // let definitions;
        // if (this._autoGenerateColumns) {
        //     // TODO: find a way to get all object keys of array.
        //     // const first = this.source[0];
        //     // const firstKeys = Object.keys(first);
        //     // return firstKeys;
        //     const row = this.source[0];
        //     columns = Object.getOwnPropertyNames(row).map(x => ({
        //         key: x,
        //         path: x
        //     }));
        //     return;
        // }
        const definitions = this._itemDefinitions.map((x) => ({
            ...x,
            ...{ pathFn: x.pathFn ?? x.key }
        }));
        return definitions;
    }
};
__decorate([
    Attribute({
        type: Boolean,
        useDefault: true
    }),
    __metadata("design:type", Boolean),
    __metadata("design:paramtypes", [Boolean])
], DataListElement.prototype, "alternating", null);
__decorate([
    Property({ type: Array }),
    __metadata("design:type", Array),
    __metadata("design:paramtypes", [Array])
], DataListElement.prototype, "itemDefinitions", null);
DataListElement = __decorate([
    Component({
        selector: 'mosaik-data-list',
        template: dataListElementTemplate,
        themes: {
            joy: dataListElementJoyStyle,
            memphis: dataListElementMemphisStyle,
            cosmopolitan: dataListElementCosmopolitanStyle
        },
        imports: [
            ListElement,
            TextElement
        ]
    }),
    __metadata("design:paramtypes", [])
], DataListElement);
export { DataListElement };
//# sourceMappingURL=DataListElement.js.map