'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-75aef097.js');
const assetsManager = require('./assets-manager-089e91b1.js');
require('./mer-animated-dots-78490ca4.js');
require('lit');
require('lit/directives/when.js');
require('lit/directives/if-defined.js');
const locale = require('./locale-ff30a5f3.js');
const config = require('./config-3bb95f39.js');
const helpers$1 = require('./helpers-08ee1e78.js');
const helpers = require('./helpers-bb6622f5.js');

const wwFilesCss = "button.button-secondary{border-color:var(--color-border-neutral-default)}:host{container-type:inline-size;display:grid;block-size:100%;overflow:auto;grid-template-rows:max-content 1fr max-content}.section{display:contents}.header{grid-template-areas:\"name module-folder\" \"advanced-filter advanced-filter\";grid-template-columns:1fr 1fr;grid-auto-rows:max-content max-content}.name{grid-area:name}.module-folder{grid-area:module-folder}.advanced-filter{grid-area:advanced-filter}.advanced-filter__container{display:grid;grid-auto-rows:max-content}.advanced-filter__first-row{grid-template-columns:1fr 1fr}.advanced-filter__second-row{grid-template-columns:1fr 1fr 1fr}.advanced-filter .all-descendants__modified{display:flex;flex-direction:row;align-items:center;block-size:32px;gap:var(--spacing-gap-xl);align-self:self-end}.field-date{grid-template-areas:\"label-date-time label-date-time\" \"input-date-time icon-clear-date-time\";grid-template-columns:1fr max-content;column-gap:var(--spacing-gap-xs)}.label-date-time{display:flex;align-items:center;gap:var(--spacing-gap-m);grid-area:label-date-time}.input-date-time{block-size:32px;grid-area:input-date-time}.icon-clear-date-time{grid-area:icon-clear-date-time}.tabular-grid{overflow:auto;inline-size:100%;border-inline-end:var(--section-common-border)}.tabular-grid.empty::part(main),.tabular-grid.loading::part(main){overflow:hidden}ch-tabular-grid-rowset-empty{position:relative}.main__files-container{display:grid;grid-template-columns:repeat(4, 1fr);gap:var(--spacing-gap-m);position:relative;z-index:1}.hiChar{color:var(--color-text-primary-default);filter:brightness(1.3)}.tabular-grid ch-tabular-grid-cell:is(:nth-child(4)){align-items:start;justify-content:start;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-inline-size:0}.tabular-grid-cell-description{min-inline-size:max-content !important}.hiChar{color:var(--color-text-primary-default);filter:brightness(1.3)}";

var __classPrivateFieldSet = (undefined && undefined.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
    if (kind === "m")
        throw new TypeError("Private method is not writable");
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a setter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot write private member to an object whose class did not declare it");
    return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (undefined && undefined.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f)
        throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
        throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _GxIdeWWFiles_componentLocale, _GxIdeWWFiles_ACCORDION_MODEL, _GxIdeWWFiles_nameValue, _GxIdeWWFiles_moduleValue, _GxIdeWWFiles_searchContentsValue, _GxIdeWWFiles_categoryValue, _GxIdeWWFiles_allDescendants, _GxIdeWWFiles_userValue, _GxIdeWWFiles_selectedObjectsIds, _GxIdeWWFiles_chGridEl, _GxIdeWWFiles_setFilterDefaultValues, _GxIdeWWFiles_allDescendantsCheckboxHandler, _GxIdeWWFiles_handleSelectionChanged, _GxIdeWWFiles_handleRowDoubleClicked, _GxIdeWWFiles_handleRowContextMenu, _GxIdeWWFiles_attachGridListeners, _GxIdeWWFiles_categoryInputHandler, _GxIdeWWFiles_clearDateTimeValue, _GxIdeWWFiles_dateTimeInputHandler, _GxIdeWWFiles_deleteSelectionCallbackHandler, _GxIdeWWFiles_deselectAll, _GxIdeWWFiles_evaluateModifiedDates, _GxIdeWWFiles_filterAfterTypeCallbackHandler, _GxIdeWWFiles_formatDate, _GxIdeWWFiles_getObjects, _GxIdeWWFiles_renderHeader, _GxIdeWWFiles_renderObjects, _GxIdeWWFiles_moduleValueChangedHandler, _GxIdeWWFiles_nameInputHandler, _GxIdeWWFiles_newFileCallbackHandler, _GxIdeWWFiles_openSelectionCallbackHandler, _GxIdeWWFiles_searchContentsInputHandler, _GxIdeWWFiles_setLoadingState, _GxIdeWWFiles_userInputHandler, _GxIdeWWFiles_showModifiedCheckboxHandler, _GxIdeWWFiles_selectAll;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "components/checkbox",
    "components/combo-box",
    "components/accordion",
    "components/edit",
    "components/icon",
    "components/tooltip",
    "components/tabular-grid",
    "utils/form",
    "utils/layout",
    "utils/typography",
    "utils/spacing"
];
const CLEAR_ICON = assetsManager.getIconPath({
    category: "system",
    name: "close",
    colorType: "interactive"
});
const FILTER_ICON = assetsManager.getIconPath({
    category: "window-tools",
    name: "filter",
    colorType: "on-surface"
});
const INFO_ICON = assetsManager.getIconPath({
    category: "system",
    name: "information",
    colorType: "on-surface"
});
const ACCORDION_FILTER_ID = "advanced-filter";
const FILTER_AFTER_DATE_TIME = "afterDateTime";
const FILTER_AFTER_LAST_BUILD = "afterLastBuild";
const FILTER_AFTER_IMPORT = "afterImport";
const CHECKBOX_CHECKED_VALUE = "checked";
const CHECKBOX_UNCHECKED_VALUE = "unchecked";
const GxIdeWWFiles = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        _GxIdeWWFiles_componentLocale.set(this, void 0);
        _GxIdeWWFiles_ACCORDION_MODEL.set(this, []);
        // Filter Values
        _GxIdeWWFiles_nameValue.set(this, void 0);
        _GxIdeWWFiles_moduleValue.set(this, void 0);
        // Advanced Filter Values
        _GxIdeWWFiles_searchContentsValue.set(this, void 0);
        _GxIdeWWFiles_categoryValue.set(this, void 0);
        _GxIdeWWFiles_allDescendants.set(this, void 0);
        _GxIdeWWFiles_userValue.set(this, void 0);
        // Other
        _GxIdeWWFiles_selectedObjectsIds.set(this, []);
        _GxIdeWWFiles_chGridEl.set(this, void 0);
        _GxIdeWWFiles_setFilterDefaultValues.set(this, () => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_nameValue, "", "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_moduleValue, Object.assign({}, this.defaultModule), "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_searchContentsValue, "", "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_categoryValue, this.defaultCategory ||
                (this.categoriesComboBoxModel && this.categoriesComboBoxModel.length > 0
                    ? this.categoriesComboBoxModel[0].value
                    : ""), "f");
            __classPrivateFieldSet(this, _GxIdeWWFiles_allDescendants, CHECKBOX_UNCHECKED_VALUE, "f");
            this.afterValue =
                this.filterAfterComboBoxModel && this.filterAfterComboBoxModel.length > 0
                    ? this.filterAfterComboBoxModel[0].value
                    : FILTER_AFTER_DATE_TIME;
            __classPrivateFieldSet(this, _GxIdeWWFiles_userValue, "", "f");
            this.dateTimeValue = undefined;
        });
        _GxIdeWWFiles_allDescendantsCheckboxHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_allDescendants, event.detail === CHECKBOX_CHECKED_VALUE
                ? CHECKBOX_CHECKED_VALUE
                : CHECKBOX_UNCHECKED_VALUE, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_handleSelectionChanged.set(this, (ev) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_selectedObjectsIds, ev.detail.rowsId, "f");
            this.selectionChangeCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_handleRowDoubleClicked.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_openSelectionCallbackHandler, "f").call(this);
        });
        _GxIdeWWFiles_handleRowContextMenu.set(this, (ev) => {
            ev.preventDefault();
            ev.stopPropagation();
            this.contextMenuCallback({
                selection: ev.detail.selectedRowsId,
                clientX: ev.detail.clientX,
                clientY: ev.detail.clientY
            });
        });
        _GxIdeWWFiles_attachGridListeners.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("selectionChanged", __classPrivateFieldGet(this, _GxIdeWWFiles_handleSelectionChanged, "f"));
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("rowDoubleClicked", __classPrivateFieldGet(this, _GxIdeWWFiles_handleRowDoubleClicked, "f"));
            __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").addEventListener("rowContextMenu", __classPrivateFieldGet(this, _GxIdeWWFiles_handleRowContextMenu, "f"));
        });
        _GxIdeWWFiles_categoryInputHandler.set(this, async (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_categoryValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_clearDateTimeValue.set(this, () => {
            this.dateTimeValue = undefined;
        });
        _GxIdeWWFiles_dateTimeInputHandler.set(this, (event) => {
            this.dateTimeValue = event.detail;
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_deleteSelectionCallbackHandler.set(this, () => {
            this.deleteSelectionCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_deselectAll.set(this, () => {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f") &&
                typeof __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows ===
                    "function") {
                __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows(false);
            }
        });
        _GxIdeWWFiles_evaluateModifiedDates.set(this, (objectModifiedDate, filterSelectedModifiedDate) => {
            const filterSelectedModifiedDateAsDate = new Date(filterSelectedModifiedDate);
            if (filterSelectedModifiedDateAsDate >= objectModifiedDate) {
                // Object modifed date matches with filter date, or was modified after that date.
                // Highlight to show that it matches.
                return index.h("span", { class: "hiChar" }, __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, objectModifiedDate));
            }
            else {
                return __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, objectModifiedDate);
            }
        });
        _GxIdeWWFiles_filterAfterTypeCallbackHandler.set(this, (event) => {
            this.afterValue = event.detail;
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_formatDate.set(this, (date) => {
            return helpers.formatDate(date, "date-time-short");
        });
        _GxIdeWWFiles_getObjects.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeWWFiles_setLoadingState, "f").call(this);
            const parentId = __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f") ? __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f").id : "";
            const filtersValues = {
                name: __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"),
                searchContents: __classPrivateFieldGet(this, _GxIdeWWFiles_searchContentsValue, "f"),
                category: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryValue, "f"),
                parent: parentId,
                allDescendants: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendants, "f") === CHECKBOX_CHECKED_VALUE,
                modifiedAfter: this.showModified ? this.afterValue : undefined,
                modifiedBy: this.showModified ? __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f") : undefined,
                modifiedDate: this.showModified ? new Date(this.dateTimeValue) : undefined
            };
            this.loadCallback(filtersValues).then((items) => {
                this.objects = items;
                __classPrivateFieldSet(this, _GxIdeWWFiles_selectedObjectsIds, [], "f");
                if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f")) {
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deselectAll, "f").call(this);
                }
                this.isLoading = false;
            });
        });
        _GxIdeWWFiles_renderHeader.set(this, () => {
            return [
                index.h("div", {
                    // Name
                    class: "field field-block field-name"
                }, index.h("label", { class: "label", htmlFor: "name" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.name), index.h("ch-edit", { id: "name", class: "input", value: __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_nameInputHandler, "f"), part: "filter-files", debounce: config.config.inputDebounce, disabled: this.isLoading })),
                index.h("div", {
                    // Module
                    class: "field field-block field-module-folder"
                }, index.h("label", { class: "label", htmlFor: "module-folder" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.moduleFolder), index.h("gx-ide-entity-selector", { part: "filter-module-folder", id: "module/folder", labelPosition: "none", value: __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValue, "f"), defaultValue: this.defaultModule, selectEntityCallback: this.selectModuleCallback, onValueChanged: __classPrivateFieldGet(this, _GxIdeWWFiles_moduleValueChangedHandler, "f"), disabled: this.isLoading })),
                index.h("ch-accordion-render", { class: "accordion-outlined advanced-filter", model: __classPrivateFieldGet(this, _GxIdeWWFiles_ACCORDION_MODEL, "f") }, index.h("div", { slot: ACCORDION_FILTER_ID, class: "spacing-body field-group advanced-filter__container" }, this.showSearchContents && (index.h("div", {
                    // Search contents
                    class: "field field-block field-search-contents"
                }, index.h("label", { class: "label", htmlFor: "filter-content" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.content), index.h("ch-edit", { id: "filter-content", class: "input", onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_searchContentsInputHandler, "f"), part: "filter-content" }))), index.h("div", { class: "field-group advanced-filter__first-row" }, index.h("div", {
                    // Category
                    class: "field field-block field-category"
                }, index.h("label", { class: "label", htmlFor: "filter-category" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.category), index.h("ch-combo-box-render", { id: "filter-category", class: "combo-box disabled", value: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryValue, "f"), disabled: !this.categories || this.isLoading, model: this.categoriesComboBoxModel, part: "filter-category", onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_categoryInputHandler, "f") })), index.h("div", {
                    // All descendants / Modified
                    class: "all-descendants__modified field field-inline"
                }, index.h("ch-checkbox", {
                    // All descendants
                    class: "checkbox", caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.allDescendants, checkedValue: CHECKBOX_CHECKED_VALUE, unCheckedValue: CHECKBOX_UNCHECKED_VALUE, value: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendants, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_allDescendantsCheckboxHandler, "f"), part: "filter-all-descendants", disabled: this.isLoading
                }), index.h("ch-checkbox", {
                    // Modified
                    class: "checkbox align-center", caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.modified, checkedValue: CHECKBOX_CHECKED_VALUE, unCheckedValue: CHECKBOX_UNCHECKED_VALUE, value: this.showModified, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_showModifiedCheckboxHandler, "f"), part: "filter-modified"
                }))), this.showModified === CHECKBOX_CHECKED_VALUE && (index.h("div", { class: "field-group advanced-filter__second-row" }, index.h("div", {
                    // After
                    class: "field field-block field-after"
                }, index.h("label", { class: "label", htmlFor: "filter-after-type" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.after), index.h("ch-combo-box-render", { id: "filter-after-type", class: "combo-box", value: this.afterValue, model: this.filterAfterComboBoxModel, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_filterAfterTypeCallbackHandler, "f"), part: "filter-after-type", disabled: this.isLoading })), index.h("div", {
                    // User
                    class: "field field-block field-user"
                }, index.h("label", { class: "label", htmlFor: "filter-user" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.user), index.h("ch-edit", { id: "filter-user", class: "input", value: __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f"), onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_userInputHandler, "f"), part: "filter-user", debounce: config.config.inputDebounce, disabled: this.isLoading })), this.afterValue === FILTER_AFTER_DATE_TIME && (index.h("div", {
                    // Date/Time
                    class: {
                        "field field-block field-date": true,
                        "hide": this.afterValue !== FILTER_AFTER_DATE_TIME
                    }
                }, index.h("label", { class: "label label-date-time", htmlFor: "filter-date-time" }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.dateTime, index.h("ch-image", { class: "icon-s icon-clear-date-time", src: INFO_ICON }), index.h("ch-tooltip", { class: "tooltip", actionElement: null, blockAlign: "outside-start", inlineAlign: "inside-start", delay: config.config.tooltipSettings.delay }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.dateTimeTooltip)), index.h("ch-edit", { id: "filter-date-time", type: "datetime-local", class: "input input-date-time", value: this.dateTimeValue, onInput: __classPrivateFieldGet(this, _GxIdeWWFiles_dateTimeInputHandler, "f"), part: "filter-date-time", disabled: this.isLoading }), index.h("button", { class: "button-tertiary button-icon-only", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_clearDateTimeValue, "f"), disabled: this.isLoading }, index.h("ch-image", { class: "icon-m", src: CLEAR_ICON, type: "mask" }))))))))
            ];
        });
        _GxIdeWWFiles_renderObjects.set(this, () => {
            var _a;
            const gridIsEmpty = !this.objects.length;
            return (index.h("ch-tabular-grid", { ref: (el) => (__classPrivateFieldSet(this, _GxIdeWWFiles_chGridEl, el, "f")), class: {
                    "tabular-grid": true,
                    "loading": this.isLoading,
                    "empty": this.objects.length === 0
                }, rowSelectionMode: "multiple", part: "ch-grid-files" }, index.h("ch-tabular-grid-columnset", { class: "tabular-grid-column-set" }, index.h("ch-tabular-grid-column", { columnName: "", columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.name, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.module, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }), this.gridColumnsVisibility.description && (index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.description, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.auto, class: "tabular-grid-column" })), this.gridColumnsVisibility.modifiedDate && (index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.modifiedDate, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.lastUser && (index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.lastUser, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.importDate && (index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.importDate, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" })), this.gridColumnsVisibility.lastBuildDate && (index.h("ch-tabular-grid-column", { columnName: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").tableHead.lastBuildDate, columnNameHidden: false, settingable: false, sortable: false, size: config.config.tabularGrid.colSize.maxContent, class: "tabular-grid-column" }))), !gridIsEmpty ? (index.h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, (_a = this.objects) === null || _a === void 0 ? void 0 : _a.map((object) => {
                var _a;
                return (index.h("ch-tabular-grid-row", { rowid: object.id, class: "tabular-grid-row" }, index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, index.h("ch-image", { src: object.icon })), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, helpers$1.hiChar(object.name.toLowerCase(), __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f").toLowerCase())), index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, object.parent), this.gridColumnsVisibility.description && (index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell tabular-grid-cell-description" }, object.description)), this.gridColumnsVisibility.modifiedDate && (index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, __classPrivateFieldGet(this, _GxIdeWWFiles_evaluateModifiedDates, "f").call(this, object.modifiedDate, this.dateTimeValue))), this.gridColumnsVisibility.lastUser && (index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, helpers$1.hiChar((_a = object.lastUser) === null || _a === void 0 ? void 0 : _a.toLowerCase(), __classPrivateFieldGet(this, _GxIdeWWFiles_userValue, "f")))), this.gridColumnsVisibility.importDate && (index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, helpers$1.hiChar(object.importDate
                    ? __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, object.importDate)
                    : "", __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f")))), this.gridColumnsVisibility.lastBuildDate && (index.h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, helpers$1.hiChar(object.lastBuildDate
                    ? __classPrivateFieldGet(this, _GxIdeWWFiles_formatDate, "f").call(this, object.lastBuildDate)
                    : "", __classPrivateFieldGet(this, _GxIdeWWFiles_nameValue, "f"))))));
            }))) : (index.h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, index.h("ch-tabular-grid-rowset-empty", null, this.isLoading ? (index.h("gx-ide-loader", { loaderTitle: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").loader.title, description: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").loader.description, show: true })) : (index.h("gx-ide-empty-state", { isAnimated: true, stateIconSrc: FILTER_ICON, stateTitle: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").emptyState.title })))))));
        });
        _GxIdeWWFiles_moduleValueChangedHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_moduleValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_nameInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_nameValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_newFileCallbackHandler.set(this, () => {
            this.newFileCallback();
        });
        _GxIdeWWFiles_openSelectionCallbackHandler.set(this, () => {
            this.openSelectionCallback(__classPrivateFieldGet(this, _GxIdeWWFiles_selectedObjectsIds, "f"));
        });
        _GxIdeWWFiles_searchContentsInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_searchContentsValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_setLoadingState.set(this, () => {
            // Only clear if no objects or first load
            if (!this.objects || this.objects.length === 0) {
                this.objects = [];
            }
            this.isLoading = true;
        });
        _GxIdeWWFiles_userInputHandler.set(this, (event) => {
            __classPrivateFieldSet(this, _GxIdeWWFiles_userValue, event.detail, "f");
            __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
        });
        _GxIdeWWFiles_showModifiedCheckboxHandler.set(this, (event) => {
            this.showModified = event.detail;
        });
        _GxIdeWWFiles_selectAll.set(this, () => {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f") &&
                typeof __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows ===
                    "function") {
                __classPrivateFieldGet(this, _GxIdeWWFiles_chGridEl, "f").selectAllRows();
            }
        });
        this.afterValue = undefined;
        this.categoriesComboBoxModel = [];
        this.dateTimeValue = undefined;
        this.isLoading = true;
        this.filterAfterComboBoxModel = undefined;
        this.showModified = CHECKBOX_CHECKED_VALUE;
        this.objects = [];
        this.categories = undefined;
        this.contextMenuCallback = undefined;
        this.defaultCategory = undefined;
        this.defaultModule = undefined;
        this.deleteSelectionCallback = undefined;
        this.gridColumnsVisibility = {
            description: true,
            importDate: true,
            lastBuildDate: true,
            lastUser: true,
            modifiedDate: true
        };
        this.loadCallback = undefined;
        this.newFileCallback = undefined;
        this.openSelectionCallback = undefined;
        this.selectModuleCallback = undefined;
        this.selectionChangeCallback = undefined;
        this.showSearchContents = false;
    }
    dateTimeValueChanged() {
        __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
    }
    categoriesChanged(newCategories) {
        this.categoriesComboBoxModel = helpers$1.mapOptionsToComboBoxItemModel(newCategories);
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeWWFiles_componentLocale, await locale.Locale.getComponentStrings(this.el), "f");
        // initialize combo-box models∂
        this.categoriesChanged(this.categories);
        // initialize "After" combo-box options
        this.filterAfterComboBoxModel = [
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_DATE_TIME],
                value: FILTER_AFTER_DATE_TIME
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_LAST_BUILD],
                value: FILTER_AFTER_LAST_BUILD
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter[FILTER_AFTER_IMPORT],
                value: FILTER_AFTER_IMPORT
            }
        ];
        // initialize accordion model with proper configuration
        __classPrivateFieldSet(this, _GxIdeWWFiles_ACCORDION_MODEL, [
            {
                id: ACCORDION_FILTER_ID,
                caption: __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").filter.accordionCaption,
                expanded: false
            }
        ], "f");
        __classPrivateFieldGet(this, _GxIdeWWFiles_setFilterDefaultValues, "f").call(this);
    }
    componentDidLoad() {
        __classPrivateFieldGet(this, _GxIdeWWFiles_attachGridListeners, "f").call(this);
        __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
    }
    keyDownHandler(eventInfo) {
        if (document.activeElement === this.el) {
            switch (eventInfo.key) {
                case "Enter":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_openSelectionCallbackHandler, "f").call(this);
                    break;
                case "Delete":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deleteSelectionCallbackHandler, "f").call(this);
                    break;
                case "Escape":
                    eventInfo.preventDefault();
                    __classPrivateFieldGet(this, _GxIdeWWFiles_deselectAll, "f").call(this);
                    break;
            }
        }
    }
    /**
     * Reloads the view, refreshing the filters and the table of files.
     */
    async reload() {
        try {
            if (__classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f") && this.filterAfterComboBoxModel) {
                __classPrivateFieldGet(this, _GxIdeWWFiles_setFilterDefaultValues, "f").call(this);
                __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
            }
        }
        catch (error) {
            console.error("Error in reload method:");
            // Fallback: try only getObjects if setFilterDefaultValues fails
            try {
                __classPrivateFieldGet(this, _GxIdeWWFiles_getObjects, "f").call(this);
            }
            catch (fallbackError) {
                console.error("Fallback also failed:");
            }
        }
    }
    render() {
        var _a;
        return (index.h(index.Host, { class: "widget" }, index.h("ch-theme", { model: CSS_BUNDLES }), index.h("section", { class: "section" }, index.h("header", { class: "header dialog-header-with-border spacing-body-inline spacing-body-block-start field-group" }, __classPrivateFieldGet(this, _GxIdeWWFiles_renderHeader, "f").call(this)), __classPrivateFieldGet(this, _GxIdeWWFiles_renderObjects, "f").call(this), index.h("footer", { class: "dialog-footer-with-border dialog-footer-space-between spacing-body" }, index.h("p", {
            // matching objects
            class: "text-body", part: "objects-matching"
        }, `${(_a = this.objects) === null || _a === void 0 ? void 0 : _a.length} ${__classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").objCount.matching}`), index.h("div", { class: "buttons-spacer" }, index.h("button", {
            // select all button
            id: "button-select-all", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_selectAll, "f"), part: "button button--select-all", disabled: this.isLoading
        }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").footer.btnSelectAll), index.h("button", {
            // new file button
            id: "button-new-file", class: "button-primary button-icon-and-text", onClick: __classPrivateFieldGet(this, _GxIdeWWFiles_newFileCallbackHandler, "f"), part: "button button--new-file", disabled: this.isLoading
        }, __classPrivateFieldGet(this, _GxIdeWWFiles_componentLocale, "f").footer.btnNew))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/ww-files"]; }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "dateTimeValue": ["dateTimeValueChanged"],
        "categories": ["categoriesChanged"]
    }; }
};
_GxIdeWWFiles_componentLocale = new WeakMap(), _GxIdeWWFiles_ACCORDION_MODEL = new WeakMap(), _GxIdeWWFiles_nameValue = new WeakMap(), _GxIdeWWFiles_moduleValue = new WeakMap(), _GxIdeWWFiles_searchContentsValue = new WeakMap(), _GxIdeWWFiles_categoryValue = new WeakMap(), _GxIdeWWFiles_allDescendants = new WeakMap(), _GxIdeWWFiles_userValue = new WeakMap(), _GxIdeWWFiles_selectedObjectsIds = new WeakMap(), _GxIdeWWFiles_chGridEl = new WeakMap(), _GxIdeWWFiles_setFilterDefaultValues = new WeakMap(), _GxIdeWWFiles_allDescendantsCheckboxHandler = new WeakMap(), _GxIdeWWFiles_handleSelectionChanged = new WeakMap(), _GxIdeWWFiles_handleRowDoubleClicked = new WeakMap(), _GxIdeWWFiles_handleRowContextMenu = new WeakMap(), _GxIdeWWFiles_attachGridListeners = new WeakMap(), _GxIdeWWFiles_categoryInputHandler = new WeakMap(), _GxIdeWWFiles_clearDateTimeValue = new WeakMap(), _GxIdeWWFiles_dateTimeInputHandler = new WeakMap(), _GxIdeWWFiles_deleteSelectionCallbackHandler = new WeakMap(), _GxIdeWWFiles_deselectAll = new WeakMap(), _GxIdeWWFiles_evaluateModifiedDates = new WeakMap(), _GxIdeWWFiles_filterAfterTypeCallbackHandler = new WeakMap(), _GxIdeWWFiles_formatDate = new WeakMap(), _GxIdeWWFiles_getObjects = new WeakMap(), _GxIdeWWFiles_renderHeader = new WeakMap(), _GxIdeWWFiles_renderObjects = new WeakMap(), _GxIdeWWFiles_moduleValueChangedHandler = new WeakMap(), _GxIdeWWFiles_nameInputHandler = new WeakMap(), _GxIdeWWFiles_newFileCallbackHandler = new WeakMap(), _GxIdeWWFiles_openSelectionCallbackHandler = new WeakMap(), _GxIdeWWFiles_searchContentsInputHandler = new WeakMap(), _GxIdeWWFiles_setLoadingState = new WeakMap(), _GxIdeWWFiles_userInputHandler = new WeakMap(), _GxIdeWWFiles_showModifiedCheckboxHandler = new WeakMap(), _GxIdeWWFiles_selectAll = new WeakMap();
GxIdeWWFiles.style = wwFilesCss;

exports.gx_ide_ww_files = GxIdeWWFiles;

//# sourceMappingURL=gx-ide-ww-files.cjs.entry.js.map