import { h, r as registerInstance, H as Host, a as getElement } from './index-b153bfd0.js';
import { L as Locale } from './locale-e5107fad.js';
import { u as uncheckIgnoredObjects, a as areSetsEqual } from './uncheck-ignored-4ba48c9e.js';
import { r as renderTabularGridColumns, a as renderTabularGridRows, C as COLUMNS_IDS } from './tabular-grid-render-adb3f7e5.js';
import { s as sortTabularGridColumn } from './tabular-grid-column-sort-1d503b27.js';
import { A as ALL_VALUE, C as CSS_SELECTORS, I as ICONS } from './constants-ae6a35f5.js';
import './helpers-b443f9e9.js';
import './helpers-102277ef.js';
import './config-5a775b7a.js';
import './assets-manager-7d6fc08f.js';
import './mer-animated-dots-7cbae6ef.js';
import 'lit';
import 'lit/directives/when.js';
import 'lit/directives/if-defined.js';

/**
 * Filters a grid selection to only include rows from the given source ("pending" or "ignored").
 * Rows from the other category are unselected.
 *
 * @param {SourceType} gridSource - The source category of the selection.
 * @param {string[]} selectedRowsIds - The currently selected row IDs.
 * @returns {string[]} Filtered row IDs belonging to the specified source.
 */
const clearGridSelection = (gridSource, selectedRowsIds, pendingIdsSet, ignoredIdsSet, gridReference) => {
    let filteredSelectedRowsIds = [];
    if (selectedRowsIds.length > 1 && gridSource === "pending") {
        selectedRowsIds.forEach(async (selectedRowId) => {
            if (ignoredIdsSet.has(selectedRowId)) {
                await gridReference.selectRow(selectedRowId, false);
            }
            else {
                filteredSelectedRowsIds.push(selectedRowId);
            }
        });
    }
    else if (selectedRowsIds.length > 1 && gridSource === "ignored") {
        selectedRowsIds.forEach(async (selectedRowId) => {
            if (pendingIdsSet.has(selectedRowId)) {
                await gridReference.selectRow(selectedRowId, false);
            }
            else {
                filteredSelectedRowsIds.push(selectedRowId);
            }
        });
    }
    else {
        filteredSelectedRowsIds = selectedRowsIds;
    }
    return filteredSelectedRowsIds;
};

const headerDetail = (type = "text", caption, description, callback, cssClass) => {
    return (h("div", { class: { [cssClass]: true, "field field-block": true } },
        h("span", { class: "detail__label body-semi-bold-s" }, caption),
        type === "text" ? (h("p", { class: "body-regular-s" }, description)) : (h("button", { class: "detail__link body-regular-s", onClick: callback }, description))));
};
const headerTitle = (caption, cssClass) => {
    return (h("h2", { class: { [cssClass]: true, "header__title subtitle-semi-bold-s": true } }, caption));
};

const changesetToComboBoxModel = (changesetModel) => {
    if (!changesetModel)
        return [];
    return changesetModel.map(changeset => ({
        value: changeset.id,
        caption: changeset.name === "All"
            ? "All Changesets"
            : changeset.label || changeset.name || ""
    }));
};

const foldersToComboBoxModel = (foldersModel) => foldersModel.map(folder => ({
    value: folder.name,
    caption: folder.name === "All" ? "All Modules" : folder.label || folder.name || ""
}));

const typesToComboBoxItemModel = (objectTypeModel) => objectTypeModel.map(objectType => ({
    value: objectType.id,
    caption: objectType.name === "All" ? "All Types" : objectType.name || "",
    startImgSrc: objectType.icon
}));

const commitCss = ".detail__knowledge-base{padding-inline:var(--spacing-padding-xxl);border-inline-end:1px solid var(--color-border-surface-on-elevation-1)}.detail__genexus-server{padding-inline-end:var(--spacing-padding-xxl);border-inline-end:1px solid var(--color-border-surface-on-elevation-1)}.detail__version{padding-inline-start:var(--spacing-padding-xxl)}.filter,.filter-secondary>div{display:grid;gap:var(--spacing-gap-l)}:host{display:grid;block-size:100%;overflow:auto;grid-template-rows:max-content max-content 1fr;--pill-border-radius:12px;--pill-padding-inline:var(--spacing-padding-m);--pill-padding-block:var(--spacing-padding-xxs);--pill-font-size:var(--font-size-body-s)}.section{display:grid;display:contents}.header__details{display:grid;row-gap:var(--spacing-gap-xl);grid-auto-columns:max-content;grid-auto-rows:max-content;margin-block-end:var(--spacing-padding-xxl)}.detail__label{color:var(--color-text-neutral-disabled)}.detail__link{align-items:start;color:var(--color-text-primary-default);text-decoration:underline}.detail__link:hover{color:var(--color-text-primary-hover)}.detail__link:active{color:var(--color-text-primary-pressed)}.filter__combo{max-block-size:minmax(0, 200px)}.main{position:relative;display:grid;overflow:auto}.loader{position:relative;inline-size:100%;block-size:100%;inset-block-start:0;--elevation-background-color:var(--color-accent-surface-elevation-1)}.empty-state{block-size:100%}.tabular-grid.disabled-custom-selector .tabular-grid-cell::part(selector-label),.tabular-grid.disabled-custom-selector .tabular-grid-column::part(bar-selector),.tabular-grid.disabled-custom-selector .tabular-grid-cell::part(actions-icon){pointer-events:none;opacity:0.5}.tabular-grid-cell.no-checkbox-custom-selector::part(selector-label){visibility:hidden;pointer-events:none}.tabular-grid{border-radius:4px;overflow:hidden}.tabular-grid .tabular-grid-cell--for-pill{padding-block:0;align-items:center;justify-content:center}.tabular-grid .button-action-custom-selector{--control-padding-block:var(--pill-padding-block);--control-padding-inline:var(--pill-padding-inline);font-size:inherit;font-weight:inherit;}.tabular-grid.empty-result::part(main){overflow:hidden}.messages-list{margin:0;padding:0;list-style:none;max-inline-size:800px;padding:var(--spacing-padding-m) 0;list-style-type:none;display:flex;flex-direction:column;gap:var(--spacing-gap-xxs)}.message-description{line-height:var(--line-height-spacious);display:flex;align-items:center;gap:var(--spacing-gap-m)}.message-icon{flex-shrink:0}.pill{--pill-background-color:transparent;--pill-color:transparent;--pill-border-color:transparent;background-color:var(--pill-background-color);color:var(--pill-color);border:1px solid var(--pill-border-color);inline-size:100%;padding:var(--pill-padding-block) var(--pill-padding-inline);display:flex;align-items:center;justify-content:center;border-radius:var(--pill-border-radius);position:relative;font-weight:var(--font-style-semi-bold)}.pill--update,.pill--pending{--pill-background-color:var();--pill-color:var(--color-text-neutral-disabled);--pill-border-color:var()}.pill--to-merge-marked{--pill-background-color:var();--pill-color:var(--color-border-primary-default);--pill-border-color:var()}.pill--ignored{--pill-background-color:var(--color-accent-surface-elevation-2);--pill-color:var(--color-text-neutral-on-disabled);--pill-border-color:var(--color-border-neutral-default)}.pill--pending{--pill-background-color:var(--color-accent-neutral-contrast);--pill-color:var(--color-border-primary-default);--pill-border-color:var(--color-accent-primary-pressed)}.pill--warning{--pill-background-color:var(--color-accent-warning-contrast);--pill-color:var(--color-border-warning-default);--pill-border-color:var(--color-border-warning-default)}.pill--error{--pill-background-color:var(--color-accent-error-contrast);--pill-color:var(--color-border-error-default);--pill-border-color:var(--color-border-error-light)}.pill--committed{--pill-background-color:var(--color-accent-success-contrast);--pill-color:var(--color-border-success-default);--pill-border-color:var(--color-accent-success-default)}.pill--transitioning{--pill-color:transparent}.spinner-caption{display:flex;align-items:center;gap:var(--spacing-gap-m);--status-circle-color:transparent;--status-circle-size:$size;--status-circle-inset-inline-start:16px;--pill-color:var(--color-border-primary-default)}.spinner-caption::before{display:inline-block;content:\"\";width:16px;height:16px;border:calc(16px / 7) solid var(--color-accent-primary-pressed);border-top:calc(16px / 7) solid var(--color-border-primary-on-default);border-radius:50%;animation:spin var(--timing-regular) linear infinite}@keyframes spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}.hiChar{color:var(--color-text-primary-default);filter:brightness(1.3)}.custom-icon-text-wrapper{display:flex;align-items:center;gap:var(--spacing-gap-m)}.warning-error-description{display:flex;align-items:center;gap:var(--spacing-gap-m);padding:var(--spacing-padding-m);max-inline-size:800px;line-height:var(--line-height-spacious)}.warning-error-icon{flex-shrink:0}button.button-secondary{border-color:var(--color-border-neutral-default)}.header__details{grid-template-areas:\"detail-heading-gx . . .\" \"detail-genexus-server detail-knowledge-base detail-version detail-last-full-update\"}.detail__heading-genexus-server{grid-area:detail-heading-gx}.detail__genexus-server{grid-area:detail-genexus-server}.detail__knowledge-base{grid-area:detail-knowledge-base}.detail__version{grid-area:detail-version}.filter-container{container-type:inline-size;box-sizing:border-box;display:grid;column-gap:var(--spacing-gap-l);grid-template-areas:\"filter-primary filter-toggle-button filter-action-buttons\" \"filter-secondary . .\" \"comments comments comments\";grid-template-columns:minmax(0, max-content) max-content 1fr}.filter-primary{grid-area:filter-primary;grid-template-columns:minmax(0, 200px) minmax(0, 200px) minmax(0, 200px)}.filter-container>:nth-child(2){grid-area:filter-toggle-button}.filter-container>:nth-child(3){grid-area:filter-action-buttons;justify-content:end}.filter__toggle-secondary-filter-btn{grid-area:filter-toggle-button}.filter__buttons{grid-area:filter-buttons;margin-inline-start:auto}.filter-secondary{display:grid;grid-template-rows:0fr;grid-area:filter-secondary;transition:grid-template-rows var(--timing-fast)}.filter-secondary--visible{grid-template-rows:1fr}.filter-secondary>div{display:grid;overflow:hidden;font-size:0;grid-template-columns:repeat(3, minmax(0, 200px))}.filter-secondary>div>.combo-box,.comments{margin-block-start:var(--spacing-gap-l)}.comments{grid-area:comments}.input-comments-container{position:relative}.input-comments{--control-border-color:transparent;padding-block:0 !important;padding-inline:0 !important;--line-height-tight:1.4;block-size:100%;background-color:var(--color-accent-surface-surface);transition:var(--timing-super-fast) block-size, var(--timing-super-fast) background-color, var(--timing-super-fast) padding-block, var(--timing-super-fast) padding-inline}.input-comments:focus{position:absolute;block-size:minmax(0, 200px);inline-size:100%;z-index:99;background-color:var(--color-accent-surface-elevation-1);padding-block:var(--control-padding-block) !important;padding-inline:var(--control-padding-inline) !important}";

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 __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 _GxIdeTeamDevCommit_componentLocale, _GxIdeTeamDevCommit_localStatesComboBoxModel, _GxIdeTeamDevCommit_rowCheckedChangedByTheUser, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, _GxIdeTeamDevCommit_commitCheckedClickedHandler, _GxIdeTeamDevCommit_commitSingleObject, _GxIdeTeamDevCommit_commitObjectsHandler, _GxIdeTeamDevCommit_rowMarkingChangedHandler, _GxIdeTeamDevCommit_rowSelectionChangedHandler, _GxIdeTeamDevCommit_commentsInputHandler, _GxIdeTeamDevCommit_applyClientFilter, _GxIdeTeamDevCommit_filteredObjects, _GxIdeTeamDevCommit_evaluateSecondaryFilterHasConditions, _GxIdeTeamDevCommit_toggleFiltersHandler, _GxIdeTeamDevCommit_searchInputHandler, _GxIdeTeamDevCommit_typeChangedHandler, _GxIdeTeamDevCommit_stateChangedHandler, _GxIdeTeamDevCommit_folderChanged, _GxIdeTeamDevCommit_onRowContextMenuHandler, _GxIdeTeamDevCommit_updatePendingCheckedItems, _GxIdeTeamDevCommit_setInitialObjectsStatus, _GxIdeTeamDevCommit_loadData, _GxIdeTeamDevCommit_markPendingObjects, _GxIdeTeamDevCommit_revertPendingCommitsCheckboxes, _GxIdeTeamDevCommit_togglePendingCommitsCheckboxes, _GxIdeTeamDevCommit_sortTabularGridColumnCallback, _GxIdeTeamDevCommit_columnSelectorClickedCallback;
const FILTER_SECONDARY_CONTAINER_ID = "filters-secondary-container";
const FILTER_SECONDARY_BUTTON_ID = "filter-toggle-button";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/tabular-grid",
    "utils/form--full",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "chameleon/scrollbar"
];
const GxIdeTeamDevCommit = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        /**
         * The component hard-coded strings translations.
         */
        // eslint-disable-next-line @stencil-community/own-props-must-be-private
        _GxIdeTeamDevCommit_componentLocale.set(this, void 0);
        /**
         * The ComboBoxModel for "Local State" filter.
         */
        _GxIdeTeamDevCommit_localStatesComboBoxModel.set(this, void 0);
        /**
         * Used to determine if pendingItemsCheckedCallback callback has to be
         * called or not. It should be ignored if the grid checkboxes state is
         * changed programmatically, by setting markRow to false once the object
         * has been successfully updated, for example.
         */
        _GxIdeTeamDevCommit_rowCheckedChangedByTheUser.set(this, true);
        /**
         * A reference to the tablar grid. Used to call methods.
         */
        _GxIdeTeamDevCommit_chGridPendingForUpdateEl.set(this, void 0);
        // commit related
        _GxIdeTeamDevCommit_commitCheckedClickedHandler.set(this, () => {
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commitObjectsHandler, "f").call(this, [...this.markedObjectsSet]);
        });
        _GxIdeTeamDevCommit_commitSingleObject.set(this, objectId => async () => {
            const newobjectsStatusMap = new Map(this.objectsStatusMap);
            newobjectsStatusMap.set(objectId, "committing");
            this.objectsStatusMap = newobjectsStatusMap;
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commitObjectsHandler, "f").call(this, [objectId]);
        });
        _GxIdeTeamDevCommit_commitObjectsHandler.set(this, async (selection) => {
            if (this.commentsValue.length === 0) {
                // A comment is required to commit.
                this.commentInputHasError = true;
                return;
            }
            this.commentInputHasError = false;
            this.committing = true;
            selection.forEach(itemToUpdate => {
                this.objectsStatusMap.set(itemToUpdate, "committing");
            });
            const commitResult = await this.commitCallback(selection, this.commentsValue);
            commitResult.forEach(async (objectResult) => {
                const messages = objectResult.messages;
                if (messages.length) {
                    this.objectsMessagesDataMap.set(objectResult.id, objectResult.messages);
                }
                else {
                    // clear messages
                    this.objectsMessagesDataMap.delete(objectResult.id);
                }
                if (objectResult.result === "committed") {
                    // Apply a new Set to "alreadyCommittedObjectsIdsSet" in order for the Watch to fire.
                    this.alreadyCommittedObjectsIdsSet = new Set([
                        ...this.alreadyCommittedObjectsIdsSet,
                        objectResult.id
                    ]);
                    this.objectsStatusMap.set(objectResult.id, "committed");
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").markRow(objectResult.id, false);
                }
                else {
                    this.objectsStatusMap.set(objectResult.id, "pending");
                }
            });
            this.committing = false;
            this.commentsValue = "";
        });
        // handlers
        _GxIdeTeamDevCommit_rowMarkingChangedHandler.set(this, async (event) => {
            const markedRowsIds = event.detail.rowsId;
            this.markedObjectsSet = new Set(markedRowsIds.filter(markedObjectId => !this.alreadyCommittedObjectsIdsSet.has(markedObjectId)));
            if (__classPrivateFieldGet(this, _GxIdeTeamDevCommit_rowCheckedChangedByTheUser, "f")) {
                __classPrivateFieldGet(this, _GxIdeTeamDevCommit_updatePendingCheckedItems, "f").call(this, event);
            }
        });
        _GxIdeTeamDevCommit_rowSelectionChangedHandler.set(this, async (event) => {
            const selectedRowsIds = event.detail.rowsId;
            const firstSelectedRowId = selectedRowsIds[0];
            const gridSource = this.pendingIdsSet.has(firstSelectedRowId)
                ? "pending"
                : "ignored";
            const filteredSelectedRowsIds = clearGridSelection(gridSource, selectedRowsIds, this.pendingIdsSet, this.ignoredIdsSet, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f"));
            await this.selectCallback(gridSource, filteredSelectedRowsIds);
        });
        _GxIdeTeamDevCommit_commentsInputHandler.set(this, (event) => {
            this.commentsValue = event.detail;
            if (this.commentsValue.length && this.commentInputHasError) {
                // remove error style and tooltip
                this.commentInputHasError = false;
            }
        });
        // filter related
        _GxIdeTeamDevCommit_applyClientFilter.set(this, () => {
            this.pendingObjectsAfterFilter = __classPrivateFieldGet(this, _GxIdeTeamDevCommit_filteredObjects, "f").call(this, this.pendingAndIgnored.pendingForCommit);
            this.ignoredObjectsAfterFilter = __classPrivateFieldGet(this, _GxIdeTeamDevCommit_filteredObjects, "f").call(this, this.pendingAndIgnored.ignoredObjects);
        });
        _GxIdeTeamDevCommit_filteredObjects.set(this, (objects) => {
            let filtered = objects;
            // name or description
            if (this.searchValue.length) {
                filtered = filtered.filter(object => {
                    const nameFiltered = object.name
                        .toLowerCase()
                        .includes(this.searchValue.toLowerCase());
                    const descriptionFiltered = object.description
                        .toLowerCase()
                        .includes(this.searchValue.toLowerCase());
                    return nameFiltered || descriptionFiltered;
                });
            }
            // status
            if (this.selectedState && this.selectedState !== ALL_VALUE) {
                filtered = filtered.filter(object => object.state === this.selectedState);
            }
            return filtered;
        });
        _GxIdeTeamDevCommit_evaluateSecondaryFilterHasConditions.set(this, () => {
            if (
            // this.selectedChangeset !== ALL_VALUE ||
            this.selectedFolder !== ALL_VALUE
            // this.selectedCategory !== ALL_VALUE
            ) {
                this.filterSecondaryHasConditions = true;
            }
            else {
                this.filterSecondaryHasConditions = false;
            }
        });
        _GxIdeTeamDevCommit_toggleFiltersHandler.set(this, () => {
            this.filterSecondaryIsHidden = !this.filterSecondaryIsHidden;
        });
        _GxIdeTeamDevCommit_searchInputHandler.set(this, (event) => {
            this.searchValue = event.detail.trim();
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_applyClientFilter, "f").call(this);
        });
        _GxIdeTeamDevCommit_typeChangedHandler.set(this, (event) => {
            this.selectedType = event.detail;
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_loadData, "f").call(this);
        });
        _GxIdeTeamDevCommit_stateChangedHandler.set(this, (event) => {
            this.selectedState = event.detail;
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_applyClientFilter, "f").call(this);
        });
        // changeset is a WIP.
        // #changesetChangedHandler = (event: CustomEvent<string> | InputEvent) => {
        //   this.selectedChangeset = event.detail as string;
        //   this.#loadData();
        //   this.#evaluateSecondaryFilterHasConditions();
        // };
        _GxIdeTeamDevCommit_folderChanged.set(this, (event) => {
            this.selectedFolder = event.detail;
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_loadData, "f").call(this);
            __classPrivateFieldGet(this, _GxIdeTeamDevCommit_evaluateSecondaryFilterHasConditions, "f").call(this);
        });
        // #categoryChangedHandler = (event: CustomEvent<string> | InputEvent) => {
        //   this.selectedCategory = event.detail as string;
        //   this.#loadData();
        //   this.#evaluateSecondaryFilterHasConditions();
        // };
        _GxIdeTeamDevCommit_onRowContextMenuHandler.set(this, () => async (ev) => {
            ev.preventDefault();
            ev.stopPropagation();
            const selectedRowsIds = await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").getSelectedRows();
            const firstSelectedRowId = selectedRowsIds[0];
            const gridSource = this.pendingIdsSet.has(firstSelectedRowId)
                ? "pending"
                : "ignored";
            await this.objectsContextMenuCallback(gridSource, {
                selection: selectedRowsIds,
                clientX: ev.detail.clientX,
                clientY: ev.detail.clientY
            });
        });
        // other methods
        _GxIdeTeamDevCommit_updatePendingCheckedItems.set(this, async (event) => {
            __classPrivateFieldSet(this, _GxIdeTeamDevCommit_rowCheckedChangedByTheUser, false, "f");
            const addedRowsIds = event.detail.addedRowsId;
            const removedRowsId = event.detail.removedRowsId;
            try {
                const pendingItemCheckedResult = await this.pendingItemsCheckedCallback({
                    itemsChecked: addedRowsIds,
                    itemsUnchecked: removedRowsId
                });
                if (pendingItemCheckedResult === undefined) {
                    // undo check/uncheck
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_revertPendingCommitsCheckboxes, "f").call(this, addedRowsIds, removedRowsId);
                }
                else {
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_togglePendingCommitsCheckboxes, "f").call(this, pendingItemCheckedResult);
                }
            }
            catch (_a) {
                //catch exception if necessary
            }
            finally {
                __classPrivateFieldSet(this, _GxIdeTeamDevCommit_rowCheckedChangedByTheUser, true, "f");
            }
        });
        _GxIdeTeamDevCommit_setInitialObjectsStatus.set(this, () => {
            this.pendingAndIgnored.pendingForCommit.forEach(pendingObject => {
                const status = "pending";
                this.objectsStatusMap.set(pendingObject.id, status);
            });
            this.pendingAndIgnored.ignoredObjects.forEach(ignoredObject => {
                const status = "ignored";
                this.objectsStatusMap.set(ignoredObject.id, status);
            });
        });
        _GxIdeTeamDevCommit_loadData.set(this, async () => {
            this.loading = true;
            this.pendingAndIgnored = await this.loadCallback({
                search: this.searchValue,
                type: this.selectedType,
                changeset: this.selectedChangeset,
                folder: this.selectedFolder,
                category: this.selectedCategory
            });
            this.loading = false;
            // Is is required to mark/check all objects after loadCallback.
            // this.#markPendingObjects();
        });
        /**
         * Marks all pending objects that have not been committed yet.
         *
         * Iterates through all pending object IDs and adds them to the marked objects set
         * if they are not already in the committed objects set. This effectively identifies
         * and marks all the pending objects that still need to be processed.
         **/
        _GxIdeTeamDevCommit_markPendingObjects.set(this, () => {
            for (const pendingId of this.pendingIdsSet) {
                if (!this.alreadyCommittedObjectsIdsSet.has(pendingId)) {
                    this.markedObjectsSet = new Set([...this.markedObjectsSet, pendingId]);
                }
            }
        });
        // render methods
        _GxIdeTeamDevCommit_revertPendingCommitsCheckboxes.set(this, async (addedRowsIds, removedRowsId) => {
            if (__classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f")) {
                for (const rowId of addedRowsIds) {
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").markRow(rowId, false);
                }
                for (const rowId of removedRowsId) {
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").markRow(rowId, true);
                }
            }
        });
        _GxIdeTeamDevCommit_togglePendingCommitsCheckboxes.set(this, async (itemsToToggle) => {
            if (__classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f")) {
                const itemsToCheck = itemsToToggle.itemsToCheck;
                const itemsToUncheck = itemsToToggle.itemsToUncheck;
                // check
                for (const rowId of itemsToCheck) {
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").markRow(rowId, true);
                }
                // uncheck
                for (const rowId of itemsToUncheck) {
                    await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").markRow(rowId, false);
                }
            }
        });
        _GxIdeTeamDevCommit_sortTabularGridColumnCallback.set(this, (e) => {
            const columnId = e.detail.columnId;
            let objectProperty;
            let dateType = "string";
            if (columnId === COLUMNS_IDS.type) {
                objectProperty = "name"; // the type name
                dateType = "object";
            }
            else if (columnId === COLUMNS_IDS.modifiedOn ||
                columnId === COLUMNS_IDS.lastSynchronized) {
                dateType = "dateString";
            }
            this.pendingObjectsAfterFilter = [
                ...sortTabularGridColumn(e, this.pendingObjectsAfterFilter, dateType, objectProperty)
            ];
            this.ignoredObjectsAfterFilter = [
                ...sortTabularGridColumn(e, this.ignoredObjectsAfterFilter, dateType, objectProperty)
            ];
        });
        /**
         * WA: Ignored objects must always remain unchecked.
         * Because `tabular-grid` selects all rows when the checkbox column is toggled,
         * we need to manually unselect the ignored IDs. // TODO: Move this function
         * to common
         */
        _GxIdeTeamDevCommit_columnSelectorClickedCallback.set(this, async (e) => {
            const allRowsChecked = e.detail;
            if (allRowsChecked) {
                const markedRowsIds = await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f").getMarkedRows();
                const ignoredMarkedRowsIds = markedRowsIds.filter(rowId => {
                    return this.ignoredIdsSet.has(rowId);
                });
                if (ignoredMarkedRowsIds.length) {
                    uncheckIgnoredObjects(ignoredMarkedRowsIds, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, "f"));
                }
            }
        });
        this.allPendingAreCommitted = false;
        this.alreadyCommittedObjectsIdsSet = new Set([]);
        this.ignoredIdsSet = new Set([]);
        this.pendingIdsSet = new Set([]);
        this.markedObjectsSet = new Set([]);
        this.objectsStatusMap = new Map();
        this.objectsMessagesDataMap = new Map();
        this.atLeastOneObjectIsChecked = false;
        this.commentInputHasError = false;
        this.committing = false;
        this.filterSecondaryIsHidden = true;
        this.filterSecondaryHasConditions = false;
        this.loading = true;
        this.changesetsComboBoxModel = undefined;
        this.pendingObjectsAfterFilter = [];
        this.ignoredObjectsAfterFilter = [];
        this.typesComboBoxModel = [];
        this.pendingAndIgnored = {
            pendingForCommit: [],
            ignoredObjects: []
        };
        this.commentsValue = "";
        this.searchValue = "";
        this.selectedType = undefined;
        this.selectedState = ALL_VALUE;
        this.selectedChangeset = undefined;
        this.selectedFolder = undefined;
        this.selectedCategory = undefined;
        this.foldersComboBoxModel = undefined;
        this.isCommitDisabled = false;
        this.commitCallback = undefined;
        this.objectsContextMenuCallback = undefined;
        this.loadCallback = undefined;
        this.openServerCallback = undefined;
        this.pendingItemsCheckedCallback = undefined;
        this.selectCallback = undefined;
        this.types = undefined;
        this.changeset = undefined;
        this.folders = undefined;
        this.updatePillAsButton = false;
        this.serverDetails = undefined;
    }
    alreadyCommittedObjectsIdsSetChanged(newCommittedObjectsIdsSet) {
        const pendingIdsSetAndCommittedIdsSetAreEqual = areSetsEqual(newCommittedObjectsIdsSet, this.pendingIdsSet);
        this.allPendingAreCommitted =
            pendingIdsSetAndCommittedIdsSetAreEqual && this.pendingIdsSet.size > 0;
    }
    markedObjectsSetChanged(newMarkedObjectsSet) {
        this.atLeastOneObjectIsChecked = newMarkedObjectsSet.size > 0;
    }
    objectsStatusMapChanged(newObjectsStatusMap) {
        const someObjectIsUpdating = [...newObjectsStatusMap.entries()].find(([, state]) => state === "committing");
        if (!someObjectIsUpdating) {
            this.committing = false;
        }
    }
    pendingAndIgnoredChanged(newPendingAndIgnored) {
        var _a, _b;
        // clear previous state
        this.pendingIdsSet.clear(); // before pendingIdsSet.add
        this.ignoredIdsSet.clear(); // before ignoredIdsSet.add
        this.objectsMessagesDataMap = new Map();
        this.alreadyCommittedObjectsIdsSet = new Set();
        this.commentInputHasError = false;
        this.markedObjectsSet = new Set(); // before #markPendingObjects
        (_a = newPendingAndIgnored.pendingForCommit) === null || _a === void 0 ? void 0 : _a.forEach(pending => {
            this.pendingIdsSet.add(pending.id);
        });
        (_b = newPendingAndIgnored.ignoredObjects) === null || _b === void 0 ? void 0 : _b.forEach(ignored => {
            this.ignoredIdsSet.add(ignored.id);
        });
        __classPrivateFieldGet(this, _GxIdeTeamDevCommit_markPendingObjects, "f").call(this); // after pendingIdsSet.add and ignoredIdsSet.add
        __classPrivateFieldGet(this, _GxIdeTeamDevCommit_setInitialObjectsStatus, "f").call(this); // after pendingIdsSet.add and ignoredIdsSet.add
        __classPrivateFieldGet(this, _GxIdeTeamDevCommit_applyClientFilter, "f").call(this);
    }
    typesChanged(newTypes) {
        this.typesComboBoxModel = typesToComboBoxItemModel(newTypes);
    }
    changesetChanged(newChangesetOptions) {
        this.changesetsComboBoxModel =
            changesetToComboBoxModel(newChangesetOptions);
    }
    folderChanged(newFolderOptions) {
        this.foldersComboBoxModel = foldersToComboBoxModel(newFolderOptions);
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeTeamDevCommit_componentLocale, await Locale.getComponentStrings(this.el), "f");
        // Initiate "actions" combo box filter
        __classPrivateFieldSet(this, _GxIdeTeamDevCommit_localStatesComboBoxModel, [
            {
                caption: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").states.all,
                value: ALL_VALUE
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").states.inserted,
                value: "inserted"
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").states.modified,
                value: "modified"
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").states.conflicted,
                value: "conflicted"
            },
            {
                caption: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").states.deleted,
                value: "deleted"
            }
        ], "f");
        // intialize combo-box models
        this.typesComboBoxModel = typesToComboBoxItemModel(this.types);
        this.selectedType = this.typesComboBoxModel[0].value;
        this.selectedState = __classPrivateFieldGet(this, _GxIdeTeamDevCommit_localStatesComboBoxModel, "f")[0].value;
        this.changesetChanged(this.changeset);
        this.selectedChangeset =
            this.changesetsComboBoxModel.length > 0
                ? this.changesetsComboBoxModel[0].value
                : ALL_VALUE;
        this.folderChanged(this.folders);
        this.selectedFolder =
            this.foldersComboBoxModel && this.foldersComboBoxModel.length > 0
                ? this.foldersComboBoxModel[0].value
                : ALL_VALUE;
        // this.categoryChanged(this.categories);
        // this.selectedCategory =
        //   this.categoriesComboBoxModel.length > 0
        //     ? this.categoriesComboBoxModel[0].value
        //     : ALL_VALUE;
        __classPrivateFieldGet(this, _GxIdeTeamDevCommit_evaluateSecondaryFilterHasConditions, "f").call(this);
    }
    async componentDidLoad() {
        await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_loadData, "f").call(this);
        // initialize "allPendingAreCommitted"
        this.alreadyCommittedObjectsIdsSetChanged(this.alreadyCommittedObjectsIdsSet);
    }
    /**
     * Used by the host to instruct the component to force a data reload in the grids.
     */
    async reload() {
        await __classPrivateFieldGet(this, _GxIdeTeamDevCommit_loadData, "f").call(this);
    }
    /**
     * Used by the host to instruct the component to disable the commit button.
     */
    async disableCommit(value) {
        this.isCommitDisabled = value;
    }
    render() {
        const disableControls = this.committing || this.loading || this.isCommitDisabled;
        const gridIsEmpty = this.pendingObjectsAfterFilter.length === 0 &&
            this.ignoredObjectsAfterFilter.length === 0;
        const filterIcon = this.filterSecondaryHasConditions
            ? ICONS.filterWithConditions
            : ICONS.filter;
        const commitButtonEnabled = this.atLeastOneObjectIsChecked &&
            this.commentsValue.length > 0 &&
            !this.allPendingAreCommitted &&
            !this.isCommitDisabled;
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("section", { class: "section" }, h("header", { class: { [CSS_SELECTORS.HEADER]: true } }, h("div", {
            // header details
            class: { [CSS_SELECTORS.HEADER_DETAILS]: true }
        }, headerTitle(__classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").commitDetail.title), 
        // genexus server
        headerDetail("link", __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").commitDetail.genexusServer, this.serverDetails ? this.serverDetails.serverUrl : "", this.openServerCallback, "detail__genexus-server"), 
        // knowledge base
        headerDetail("text", __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").commitDetail.knowledgeBase, this.serverDetails ? this.serverDetails.kbName : "", undefined, "detail__knowledge-base"), 
        // version
        headerDetail("text", __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").commitDetail.version, this.serverDetails ? this.serverDetails.versionName : "", undefined, "detail__version"))), h("div", { class: "filter-container spacing-body-inline" }, h("div", { class: { [CSS_SELECTORS.FILTER]: true, "filter-primary": true } }, h("ch-edit", {
            // searchch-edit
            class: "input filter__combo", disabled: disableControls, startImgSrc: ICONS.search, accessibleName: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.searchAccessibleName, placeholder: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.searchPlaceholder, type: "search", onInput: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_searchInputHandler, "f")
        }), h("ch-combo-box-render", {
            // types
            class: "combo-box filter__combo", disabled: disableControls, model: this.typesComboBoxModel, value: this.selectedType, accessibleName: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.typeAccesibleName, placeholder: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.typePlaceholder, onInput: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_typeChangedHandler, "f")
        }), h("ch-combo-box-render", {
            // local states
            class: "combo-box filter__combo", disabled: disableControls, model: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_localStatesComboBoxModel, "f"), value: this.selectedState, onInput: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_stateChangedHandler, "f"), accessibleName: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.localStateAccesibleName, placeholder: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.localStatePlaceholder
        })), h("button", {
            // toggle secondary filter button
            id: FILTER_SECONDARY_BUTTON_ID, class: "button-secondary button-icon-only", disabled: disableControls, "aria-label": __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.secondaryFilterAriaLabel, "aria-expanded": this.filterSecondaryIsHidden ? "false" : "true", "aria-controls": FILTER_SECONDARY_CONTAINER_ID, onClick: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_toggleFiltersHandler, "f"), title: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.secondaryFilterAriaLabel
        }, h("ch-image", { class: "icon-m", src: filterIcon })), h("div", { class: "buttons-spacer" }, h("button", {
            // reload button
            class: "button-secondary button-icon-and-text", disabled: disableControls, onClick: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_loadData, "f")
        }, h("ch-image", { class: "icon-m", src: ICONS.refresh }), __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.reload), h("button", {
            // commit button
            class: "button-primary", disabled: !commitButtonEnabled || disableControls, onClick: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commitCheckedClickedHandler, "f")
        }, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.commit)), h("div", {
            // secondary filter
            id: FILTER_SECONDARY_CONTAINER_ID, "aria-labelledby": FILTER_SECONDARY_BUTTON_ID, class: {
                [CSS_SELECTORS.FILTER]: true,
                "filter-secondary": true,
                "filter-secondary--visible": !this.filterSecondaryIsHidden
            }, inert: this.filterSecondaryIsHidden, hidden: this.filterSecondaryIsHidden
        }, h("div", null, h("ch-combo-box-render", {
            // folder
            class: "combo-box", disabled: disableControls, model: this.foldersComboBoxModel, value: this.selectedFolder, onInput: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_folderChanged, "f"), accessibleName: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.folderAccesibleName, placeholder: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").filter.folderPlaceholder
        }))), h("ch-edit", {
            // commit comments
            class: "input comments", multiline: true, autoGrow: true, placeholder: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").commitCommentPlaceholder, onInput: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commentsInputHandler, "f"), value: this.commentsValue
        })), h("div", { class: CSS_SELECTORS.MAIN }, !this.loading ? (h("ch-tabular-grid", { class: {
                "tabular-grid": true,
                "objects-tabular-grid": true,
                "disabled-custom-selector": this.committing,
                "empty-result": gridIsEmpty
            }, keyboardNavigationMode: "focus", rowSelectionMode: "multiple", onSelectionChanged: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_rowSelectionChangedHandler, "f"), onRowMarkingChanged: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_rowMarkingChangedHandler, "f"), onRowContextMenu: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_onRowContextMenuHandler, "f").call(this), ref: (el) => (__classPrivateFieldSet(this, _GxIdeTeamDevCommit_chGridPendingForUpdateEl, el, "f")) }, renderTabularGridColumns(["action"], gridIsEmpty, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_sortTabularGridColumnCallback, "f"), __classPrivateFieldGet(this, _GxIdeTeamDevCommit_columnSelectorClickedCallback, "f"), __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f"), !this.allPendingAreCommitted), !gridIsEmpty
            ? [
                h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, h("ch-tabular-grid-rowset-legend", { class: "tabular-grid-rowset-legend" }, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").objects.pendingCommits), renderTabularGridRows("pending", this.pendingObjectsAfterFilter, this.ignoredObjectsAfterFilter, this.alreadyCommittedObjectsIdsSet, this.markedObjectsSet, this.objectsMessagesDataMap, this.updatePillAsButton, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commitSingleObject, "f"), this.objectsStatusMap, this.searchValue, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f"))),
                h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, h("ch-tabular-grid-rowset-legend", { class: "tabular-grid-rowset-legend" }, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").objects.ignoredObjects), renderTabularGridRows("ignored", this.pendingObjectsAfterFilter, this.ignoredObjectsAfterFilter, this.alreadyCommittedObjectsIdsSet, this.markedObjectsSet, this.objectsMessagesDataMap, this.updatePillAsButton, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_commitSingleObject, "f"), this.objectsStatusMap, this.searchValue, __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f")))
            ]
            : null, h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, gridIsEmpty && (h("ch-tabular-grid-rowset-empty", null, h("gx-ide-empty-state", { class: "empty-state", isAnimated: true, stateIconSrc: ICONS.filter, stateTitle: "No object matched your filter" })))))) : (h("gx-ide-loader", { cancelLabel: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").loader.cancelLabel, loaderTitle: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").loader.title, description: __classPrivateFieldGet(this, _GxIdeTeamDevCommit_componentLocale, "f").loader.description, show: true, class: "loader" }))))));
    }
    static get assetsDirs() { return ["gx-ide-assets/team-dev-commit"]; }
    get el() { return getElement(this); }
    static get watchers() { return {
        "alreadyCommittedObjectsIdsSet": ["alreadyCommittedObjectsIdsSetChanged"],
        "markedObjectsSet": ["markedObjectsSetChanged"],
        "objectsStatusMap": ["objectsStatusMapChanged"],
        "pendingAndIgnored": ["pendingAndIgnoredChanged"],
        "types": ["typesChanged"],
        "changeset": ["changesetChanged"],
        "folders": ["folderChanged"]
    }; }
};
_GxIdeTeamDevCommit_componentLocale = new WeakMap(), _GxIdeTeamDevCommit_localStatesComboBoxModel = new WeakMap(), _GxIdeTeamDevCommit_rowCheckedChangedByTheUser = new WeakMap(), _GxIdeTeamDevCommit_chGridPendingForUpdateEl = new WeakMap(), _GxIdeTeamDevCommit_commitCheckedClickedHandler = new WeakMap(), _GxIdeTeamDevCommit_commitSingleObject = new WeakMap(), _GxIdeTeamDevCommit_commitObjectsHandler = new WeakMap(), _GxIdeTeamDevCommit_rowMarkingChangedHandler = new WeakMap(), _GxIdeTeamDevCommit_rowSelectionChangedHandler = new WeakMap(), _GxIdeTeamDevCommit_commentsInputHandler = new WeakMap(), _GxIdeTeamDevCommit_applyClientFilter = new WeakMap(), _GxIdeTeamDevCommit_filteredObjects = new WeakMap(), _GxIdeTeamDevCommit_evaluateSecondaryFilterHasConditions = new WeakMap(), _GxIdeTeamDevCommit_toggleFiltersHandler = new WeakMap(), _GxIdeTeamDevCommit_searchInputHandler = new WeakMap(), _GxIdeTeamDevCommit_typeChangedHandler = new WeakMap(), _GxIdeTeamDevCommit_stateChangedHandler = new WeakMap(), _GxIdeTeamDevCommit_folderChanged = new WeakMap(), _GxIdeTeamDevCommit_onRowContextMenuHandler = new WeakMap(), _GxIdeTeamDevCommit_updatePendingCheckedItems = new WeakMap(), _GxIdeTeamDevCommit_setInitialObjectsStatus = new WeakMap(), _GxIdeTeamDevCommit_loadData = new WeakMap(), _GxIdeTeamDevCommit_markPendingObjects = new WeakMap(), _GxIdeTeamDevCommit_revertPendingCommitsCheckboxes = new WeakMap(), _GxIdeTeamDevCommit_togglePendingCommitsCheckboxes = new WeakMap(), _GxIdeTeamDevCommit_sortTabularGridColumnCallback = new WeakMap(), _GxIdeTeamDevCommit_columnSelectorClickedCallback = new WeakMap();
GxIdeTeamDevCommit.style = commitCss;

export { GxIdeTeamDevCommit as gx_ide_team_dev_commit };

//# sourceMappingURL=gx-ide-team-dev-commit.entry.js.map