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;
};
import { customElement } from '../../../../../../external/lit/index.js';
import { UmbSortChildrenOfModalElement } from '../../../../../core/tree/index.js';
let UmbSortChildrenOfContentModalElement = class UmbSortChildrenOfContentModalElement extends UmbSortChildrenOfModalElement {
    #localizeDateOptions = {
        day: 'numeric',
        month: 'short',
        year: 'numeric',
        hour: 'numeric',
        minute: '2-digit',
    };
    _setTableColumns() {
        this._tableColumns = [
            {
                name: this.localize.term('general_name'),
                alias: 'name',
                allowSorting: this._hasMorePages() === false,
            },
            {
                name: this.localize.term('content_createDate'),
                alias: 'createDate',
                allowSorting: this._hasMorePages() === false,
            },
        ];
    }
    _createTableItems() {
        this._tableItems = this._children.map((treeItem) => {
            // TODO: implement ItemDataResolver for document and media
            // This will fix both the icon and the variant name
            return {
                id: treeItem.unique,
                icon: 'icon-document',
                data: [
                    {
                        columnAlias: 'name',
                        value: treeItem.name,
                    },
                    {
                        columnAlias: 'createDate',
                        value: this.localize.date(treeItem.createDate, this.#localizeDateOptions),
                    },
                ],
            };
        });
    }
    _sortCompare(columnAlias, valueA, valueB) {
        if (columnAlias === 'createDate') {
            return Date.parse(valueA) - Date.parse(valueB);
        }
        return super._sortCompare(columnAlias, valueA, valueB);
    }
    _onLoadMore(event) {
        super._onLoadMore(event);
        // TODO: make nicer API for enable/disable orderBy for individual columns
        const allowOrderBy = this._hasMorePages() === false;
        this._tableColumns[0].allowSorting = allowOrderBy;
        this._tableColumns[1].allowSorting = allowOrderBy;
    }
};
UmbSortChildrenOfContentModalElement = __decorate([
    customElement('umb-sort-children-of-content-modal')
], UmbSortChildrenOfContentModalElement);
export { UmbSortChildrenOfContentModalElement };
export { UmbSortChildrenOfContentModalElement as element };
