import { r as registerInstance, g as getAssetPath, h, H as Host, a as getElement } from './index-b153bfd0.js';
import { g as getIconPath } from './assets-manager-7d6fc08f.js';
import './mer-animated-dots-7cbae6ef.js';
import 'lit';
import 'lit/directives/when.js';
import 'lit/directives/if-defined.js';
import { c as config } from './config-5a775b7a.js';
import { v as validateControls, c as clearControlError } from './form-validation-21ab3766.js';
import { L as Locale } from './locale-e5107fad.js';
import { s as sortTabularGridColumn } from './tabular-grid-column-sort-1d503b27.js';

const serverSelectorCss = "button.button-secondary{border-color:var(--color-border-neutral-default)}.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}:host{display:grid;block-size:100%;grid-template-rows:max-content max-content 1fr max-content;row-gap:var(--spacing-gap-xl);overflow:auto}:host(.new-connection){grid-template-rows:max-content 1fr}:host(.recently-used-empty){grid-template-rows:max-content 1fr}.section{display:contents}ch-tabular-grid.tabular-grid{border-radius:4px;overflow:hidden;overflow:auto;border:1px solid var(--color-border-surface-on-elevation-1)}ch-tabular-grid-rowset-empty{position:relative;border-block-end:1px solid var(--grid-cell-border-color);overflow:hidden;min-block-size:200px}.tabular-grid ch-tabular-grid-cell:is(:nth-child(2),:nth-child(3),:nth-child(4)){align-items:start;justify-content:start;display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-inline-size:0}.text-neutral-gray-400,.tabular-grid-cell.text-neutral-gray-400{color:var(--color-text-neutral-disabled)}.search-server{inline-size:50%}.tabular-grid{overflow:auto;border-block:1px solid var(--grid-cell-border-color)}.tabular-grid-all-servers .tabular-grid-column:first-child::part(bar){--grid-common__gap:0}.field-block-all-servers{overflow:auto}.tabular-grid-wrapper{position:relative;overflow:auto}.border-patch{--tabular-grid-border-radius:4px;position:absolute;inset-block-start:0;inline-size:calc(100% - var(--tabular-grid-border-radius) * 2);inset-inline-start:var(--tabular-grid-border-radius);block-size:2px;background-color:var(--items-container__bg-color);z-index:9999;border-block-start:1px solid var(--color-border-surface-on-surface)}.tooltip{position:absolute}.recently-used-card{border:1px solid var(--color-border-surface-on-elevation-1);border-radius:4px;cursor:pointer}.recently-used-card:hover{background-color:var(--color-accent-item-hover)}.recently-used-card:focus-visible{outline:var(--focus-outline-width) solid var(--color-border-primary-focused);outline-offset:calc(2px * -1)}.recently-used-card--selected{background-color:var(--color-accent-neutral-contrast);border-color:var(--color-border-item-pressed)}.recently-used-card-content{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;padding:var(--spacing-padding-m);gap:var(--spacing-gap-xxs);overflow:hidden}.recently-used-card-content .text-decoration-line-underline{display:inline-block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%;text-decoration:underline}.delete-server-icon{margin-inline:calc((30.39px - var(--ch-image-size)) / 2)}.tabular-grid ch-tabular-grid-cell:is(:nth-child(5)){--control-border-width:0;--control-border-color:transparent;--control-border-radius:0;padding-block:0;padding-inline:0;--control-padding-inline:var(--spacing-padding-l);--control-padding-block:6.5px;display:grid;align-items:stretch;justify-content:stretch;min-inline-size:0}.tabular-grid ch-tabular-grid-cell:is(:nth-child(5)):hover{outline:1px solid var(--color-border-primary-focused);outline-offset:calc(var(--size-2) * -1)}";

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 _GxIdeServerSelector__componentLocale, _GxIdeServerSelector_chGridAllServersEl, _GxIdeServerSelector_serverUrlEL, _GxIdeServerSelector_serverFriendlyNameEL, _GxIdeServerSelector_updatedServerName, _GxIdeServerSelector_serverNameEditElsMap, _GxIdeServerSelector_versionsSelect, _GxIdeServerSelector_shortcutsSrc, _GxIdeServerSelector_cancelHandler, _GxIdeServerSelector_confirmHandler, _GxIdeServerSelector_evaluateTooltipRender, _GxIdeServerSelector_initializeValidatableControls, _GxIdeServerSelector_filterValueChangedHandler, _GxIdeServerSelector_inputHandler, _GxIdeServerSelector_handleRecentlyUsedCardClick, _GxIdeServerSelector_handleDeleteServer, _GxIdeServerSelector_onServerNameInput, _GxIdeServerSelector_onServerNameChange, _GxIdeServerSelector_enableConfirmButton, _GxIdeServerSelector_onRecentlyUsedDoubleClickHandler, _GxIdeServerSelector_onServersRowClickHandler, _GxIdeServerSelector_handleServerSelection, _GxIdeServerSelector_connectionTypeChangedHandler, _GxIdeServerSelector_sortTabularGridColumnCallback, _GxIdeServerSelector_renderTabularGridColumnSet, _GxIdeServerSelector_renderTooltip, _GxIdeServerSelector_renderServerNameErrorMessage, _GxIdeServerSelector_renderTabularGridCommonCells, _GxIdeServerSelector_renderAllServersGrid, _GxIdeServerSelector_renderIcon, _GxIdeServerSelector_renderFooter, _GxIdeServerSelector_renderRecentlyUsed, _GxIdeServerSelector_renderAllServers;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/form--full",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "components/tooltip",
    "chameleon/scrollbar",
    "components/tabular-grid"
];
const INFO_ICON = getIconPath({
    category: "system",
    name: "information",
    colorType: "on-surface"
});
const LOCK_ICON = getIconPath({
    category: "system",
    name: "lock",
    colorType: "on-surface"
});
const LANGUAGE_ICON = getIconPath({
    category: "system",
    name: "language",
    colorType: "on-surface"
});
const DELETE_ICON = getIconPath({
    category: "system",
    name: "delete-outlined",
    colorType: "interactive"
});
const ERROR_ICON = getIconPath({
    category: "system",
    name: "error",
    colorType: "error"
});
const SEARCH_ICON = getIconPath({
    category: "system",
    name: "search",
    colorType: "on-surface"
});
const SERVER_NAME_PREFIX = "server-name-";
const GxIdeServerSelector = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        _GxIdeServerSelector__componentLocale.set(this, void 0);
        _GxIdeServerSelector_chGridAllServersEl.set(this, void 0);
        _GxIdeServerSelector_serverUrlEL.set(this, void 0);
        _GxIdeServerSelector_serverFriendlyNameEL.set(this, void 0);
        _GxIdeServerSelector_updatedServerName.set(this, void 0);
        _GxIdeServerSelector_serverNameEditElsMap.set(this, new Map());
        _GxIdeServerSelector_versionsSelect.set(this, []);
        _GxIdeServerSelector_shortcutsSrc.set(this, getAssetPath(`./gx-ide-assets/server-selector/shortcuts.json`));
        _GxIdeServerSelector_cancelHandler.set(this, () => {
            this.cancelCallback();
        });
        _GxIdeServerSelector_confirmHandler.set(this, async () => {
            let formSubmitResult;
            if (this.selectedConnectionType === "select") {
                formSubmitResult = await this.selectServerCallback({
                    uri: this.selectedServerUri,
                    name: this.selectedServerName
                }, this.selectedConnectionType);
            }
            else {
                formSubmitResult = await this.selectServerCallback({
                    uri: this.serverUrlInputValue,
                    name: this.serverNameInputValue
                }, this.selectedConnectionType);
                this.validatableControls = validateControls(formSubmitResult, this.validatableControls);
            }
        });
        // TODO: evaluate if this should be a global helper function.
        // It is used on other dialogs as well.
        _GxIdeServerSelector_evaluateTooltipRender.set(this, (controlReference) => {
            var _a, _b, _c;
            return ((_b = (_a = this.validatableControls) === null || _a === void 0 ? void 0 : _a.get(controlReference === null || controlReference === void 0 ? void 0 : controlReference.id)) === null || _b === void 0 ? void 0 : _b.hasError) &&
                ((_c = this.validatableControls.get(controlReference.id)) === null || _c === void 0 ? void 0 : _c.message) && (h("ch-tooltip", { class: "tooltip", actionElement: controlReference, blockAlign: config.tooltipSettings.blockAlign, inlineAlign: config.tooltipSettings.inlineAlign, delay: config.tooltipSettings.delay }, this.validatableControls.get(controlReference.id).message));
        });
        _GxIdeServerSelector_initializeValidatableControls.set(this, (validatableControls) => {
            validatableControls.forEach(validatableControl => {
                if (validatableControl.id &&
                    !this.validatableControls.has(validatableControl.id)) {
                    this.validatableControls.set(validatableControl.id, {
                        reference: validatableControl,
                        hasError: false,
                        message: undefined
                    });
                }
            });
        });
        _GxIdeServerSelector_filterValueChangedHandler.set(this, (event) => {
            this.filterValue = event.detail.toLowerCase();
            this.filteredServersData = this.serversData.filter(item => item.serverName.toLowerCase().includes(this.filterValue));
        });
        _GxIdeServerSelector_inputHandler.set(this, (event, field) => {
            this.enableConfirmButton = false;
            this[field] = event.detail.trim();
            const controlId = field === "serverUrlInputValue" ? "server-url" : "server-name";
            clearControlError(this.validatableControls, controlId);
            __classPrivateFieldGet(this, _GxIdeServerSelector_enableConfirmButton, "f").call(this);
        });
        _GxIdeServerSelector_handleRecentlyUsedCardClick.set(this, async (server) => {
            var _a;
            this.selectedRecentlyUsedId = server.id;
            await ((_a = __classPrivateFieldGet(this, _GxIdeServerSelector_chGridAllServersEl, "f")) === null || _a === void 0 ? void 0 : _a.selectRow(server.id));
            await __classPrivateFieldGet(this, _GxIdeServerSelector_handleServerSelection, "f").call(this, server.id);
        });
        _GxIdeServerSelector_handleDeleteServer.set(this, async (serverData) => {
            if (serverData.accessLevel === "private") {
                const result = await this.deleteServerCallback(serverData);
                if (result) {
                    this.selectedServerName = "None";
                    this.enableConfirmButton = false;
                }
            }
        });
        _GxIdeServerSelector_onServerNameInput.set(this, async (event) => {
            __classPrivateFieldSet(this, _GxIdeServerSelector_updatedServerName, event.detail, "f");
        });
        _GxIdeServerSelector_onServerNameChange.set(this, async (serverData) => {
            let result = {
                fieldErrors: [],
                success: false
            };
            if (serverData.serverName !== __classPrivateFieldGet(this, _GxIdeServerSelector_updatedServerName, "f") &&
                serverData.accessLevel === "private") {
                result = await this.updateServerCallback(Object.assign(Object.assign({}, serverData), { serverName: __classPrivateFieldGet(this, _GxIdeServerSelector_updatedServerName, "f") }));
            }
            this.validatableControls = validateControls(result, this.validatableControls);
            if (result.success || serverData.serverName === __classPrivateFieldGet(this, _GxIdeServerSelector_updatedServerName, "f")) {
                this.selectedServerName = __classPrivateFieldGet(this, _GxIdeServerSelector_updatedServerName, "f");
                clearControlError(this.validatableControls, `${SERVER_NAME_PREFIX}${serverData.id}`);
            }
        });
        _GxIdeServerSelector_enableConfirmButton.set(this, () => {
            if (this.serverUrlInputValue &&
                this.serverUrlInputValue.length > 0 &&
                this.serverNameInputValue &&
                this.serverNameInputValue.length > 0) {
                this.enableConfirmButton = true;
            }
            else {
                this.enableConfirmButton = false;
            }
        });
        _GxIdeServerSelector_onRecentlyUsedDoubleClickHandler.set(this, (serverData) => {
            __classPrivateFieldGet(this, _GxIdeServerSelector_handleServerSelection, "f").call(this, serverData.id);
            __classPrivateFieldGet(this, _GxIdeServerSelector_confirmHandler, "f").call(this);
        });
        _GxIdeServerSelector_onServersRowClickHandler.set(this, (event) => __classPrivateFieldGet(this, _GxIdeServerSelector_handleServerSelection, "f").call(this, event.detail.rowId));
        _GxIdeServerSelector_handleServerSelection.set(this, async (selectedRowId) => {
            if (selectedRowId === undefined) {
                this.enableConfirmButton = false;
                this.selectedServerUri = undefined;
                this.selectedServerName = undefined;
                return;
            }
            const selectedServer = this.serversData.find(server => server.id === selectedRowId);
            this.enableConfirmButton = true;
            this.selectedServerName = selectedServer === null || selectedServer === void 0 ? void 0 : selectedServer.serverName;
            this.selectedServerUri = selectedServer === null || selectedServer === void 0 ? void 0 : selectedServer.serverUrl;
            this.userName = (selectedServer === null || selectedServer === void 0 ? void 0 : selectedServer.gxServerUsername) || "";
            this.selectedRecentlyUsedId = selectedServer === null || selectedServer === void 0 ? void 0 : selectedServer.id;
        });
        _GxIdeServerSelector_connectionTypeChangedHandler.set(this, (event) => {
            this.selectedConnectionType = event.detail;
            if (this.selectedConnectionType === "new") {
                this.enableConfirmButton = false;
                this.serverUrlInputValue = "";
            }
            this.selectedServerName = "None";
        });
        _GxIdeServerSelector_sortTabularGridColumnCallback.set(this, (e) => {
            this.filteredServersData = [
                ...sortTabularGridColumn(e, this.filteredServersData, "string", undefined)
            ];
        });
        _GxIdeServerSelector_renderTabularGridColumnSet.set(this, (hideColumnName = false) => {
            return (h("ch-tabular-grid-columnset", { class: "tabular-grid-column-set" }, h("ch-tabular-grid-column", { columnId: "icon", class: "tabular-grid-column tabular-grid-column-icon", columnName: "Icon", settingable: false, columnNameHidden: true, size: config.tabularGrid.colSize.maxContent, resizable: false, sortable: false }), h("ch-tabular-grid-column", { columnId: "serverName", class: "tabular-grid-column", columnName: "Server Name", settingable: false, columnNameHidden: hideColumnName, size: config.tabularGrid.colSize.serverName, resizable: false, sortable: !hideColumnName, onColumnSortChanged: __classPrivateFieldGet(this, _GxIdeServerSelector_sortTabularGridColumnCallback, "f") }), h("ch-tabular-grid-column", { columnId: "serverUrl", class: "tabular-grid-column", columnName: "Server Url", settingable: false, columnNameHidden: hideColumnName, size: config.tabularGrid.colSize.auto, resizable: false, sortable: !hideColumnName, onColumnSortChanged: __classPrivateFieldGet(this, _GxIdeServerSelector_sortTabularGridColumnCallback, "f") }), h("ch-tabular-grid-column", { columnId: "userName", class: "tabular-grid-column", columnName: "Connected", settingable: false, columnNameHidden: hideColumnName, size: config.tabularGrid.colSize.userName, resizable: false, sortable: !hideColumnName, onColumnSortChanged: __classPrivateFieldGet(this, _GxIdeServerSelector_sortTabularGridColumnCallback, "f") }), h("ch-tabular-grid-column", { columnId: "action", class: "tabular-grid-column tabular-grid-column-icon", columnName: "Action", settingable: false, columnNameHidden: true, size: config.tabularGrid.colSize.maxContent, resizable: false, sortable: false })));
        });
        _GxIdeServerSelector_renderTooltip.set(this, (text) => {
            return text !== "" ? (h("ch-tooltip", { class: "tooltip", actionElement: null, blockAlign: "outside-end", inlineAlign: config.tooltipSettings.inlineAlign, delay: config.tooltipSettings.delayLong }, text)) : null;
        });
        _GxIdeServerSelector_renderServerNameErrorMessage.set(this, (errorMsg) => {
            return (h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, h("ch-tabular-grid-rowset-empty", null, h("p", { class: "warning-error-description" }, h("ch-image", { class: "icon-m warning-error-icon", src: ERROR_ICON }), errorMsg))));
        });
        _GxIdeServerSelector_renderTabularGridCommonCells.set(this, (serverData) => {
            return [
                h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, __classPrivateFieldGet(this, _GxIdeServerSelector_renderIcon, "f").call(this, serverData.accessLevel)),
                h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, serverData.accessLevel === "private" ? (h("ch-edit", { id: `${SERVER_NAME_PREFIX}${serverData.id}`, value: serverData.serverName, onInput: __classPrivateFieldGet(this, _GxIdeServerSelector_onServerNameInput, "f"), onChange: () => __classPrivateFieldGet(this, _GxIdeServerSelector_onServerNameChange, "f").call(this, serverData), maxLength: 18, ref: el => {
                        const key = `${SERVER_NAME_PREFIX}${serverData.id}`;
                        if (el) {
                            __classPrivateFieldGet(this, _GxIdeServerSelector_serverNameEditElsMap, "f").set(key, el);
                        }
                        else {
                            __classPrivateFieldGet(this, _GxIdeServerSelector_serverNameEditElsMap, "f").delete(key);
                        }
                    } })) : (serverData.serverName)),
                h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, serverData.serverUrl, __classPrivateFieldGet(this, _GxIdeServerSelector_renderTooltip, "f").call(this, serverData.serverUrl)),
                h("ch-tabular-grid-cell", { class: "tabular-grid-cell" }, serverData.gxServerUsername),
                h("ch-tabular-grid-cell", { class: "tabular-grid-cell", onClick: () => __classPrivateFieldGet(this, _GxIdeServerSelector_handleDeleteServer, "f").call(this, serverData) }, h("button", { id: "delete-button", class: "button-tertiary button-icon-only", "aria-label": __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").actions.deleteServer, disabled: serverData.accessLevel === "public" }, h("ch-image", { disabled: serverData.accessLevel === "public", class: "icon-m delete-server-icon", src: DELETE_ICON })))
            ];
        });
        _GxIdeServerSelector_renderAllServersGrid.set(this, () => {
            return (h("div", { class: "tabular-grid-wrapper" }, h("div", { class: "border-patch" }), h("ch-tabular-grid", { class: "tabular-grid tabular-grid-all-servers", rowSelectionMode: "single", ref: (el) => (__classPrivateFieldSet(this, _GxIdeServerSelector_chGridAllServersEl, el, "f")), allowColumnReorder: false, onRowClicked: __classPrivateFieldGet(this, _GxIdeServerSelector_onServersRowClickHandler, "f"), id: "all-servers" }, __classPrivateFieldGet(this, _GxIdeServerSelector_renderTabularGridColumnSet, "f").call(this), this.filteredServersData.length > 0 ? (h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, this.filteredServersData.map((serverData) => {
                var _a, _b;
                const serverNameEditKey = `${SERVER_NAME_PREFIX}${serverData.id}`;
                const hasError = ((_a = this.validatableControls.get(serverNameEditKey)) === null || _a === void 0 ? void 0 : _a.hasError) ===
                    true;
                const errorMsg = (_b = this.validatableControls.get(serverNameEditKey)) === null || _b === void 0 ? void 0 : _b.message;
                return (h("ch-tabular-grid-row", { rowid: serverData.id, class: "tabular-grid-row" }, __classPrivateFieldGet(this, _GxIdeServerSelector_renderTabularGridCommonCells, "f").call(this, serverData), hasError && __classPrivateFieldGet(this, _GxIdeServerSelector_renderServerNameErrorMessage, "f").call(this, errorMsg)));
            }))) : (h("ch-tabular-grid-rowset", { class: "tabular-grid-rowset" }, h("ch-tabular-grid-rowset-empty", null, h("gx-ide-empty-state", { class: "empty-state", stateIconSrc: INFO_ICON, stateTitle: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").emptyConnectedServers, isAnimated: true })))))));
        });
        _GxIdeServerSelector_renderIcon.set(this, (accessLevel) => {
            const icon = accessLevel === "private" ? LOCK_ICON : LANGUAGE_ICON;
            return h("ch-image", { class: "icon-m", src: icon });
        });
        _GxIdeServerSelector_renderFooter.set(this, () => {
            const isSelectionMode = this.selectedConnectionType === "select";
            return (h("footer", { class: {
                    "dialog-footer-with-border": true,
                    "dialog-footer-space-between": this.selectedConnectionType === "select",
                    "space-between": isSelectionMode,
                    "spacing-body-inline": true,
                    "spacing-body-block": true
                } }, isSelectionMode && (h("p", { class: "body-italic-m" }, "Selected: ", this.selectedServerName)), h("div", { class: "buttons-spacer" }, h("button", {
                // cancel button
                id: "cancel-button", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeServerSelector_cancelHandler, "f")
            }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").footer.cancel), h("button", {
                // confirm button
                id: "confirm-button", class: "button-primary", onClick: this.enableConfirmButton && __classPrivateFieldGet(this, _GxIdeServerSelector_confirmHandler, "f"), disabled: !this.enableConfirmButton
            }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").footer.confirm))));
        });
        _GxIdeServerSelector_renderRecentlyUsed.set(this, () => {
            const renderRecentlyUsed = this.selectedConnectionType === "select" &&
                this.recentlyUsedServersData.length > 0;
            return (renderRecentlyUsed && (h("div", { class: "field field-block spacing-body-inline" }, h("label", { class: "label", htmlFor: "recently-used-servers" }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").recentlyUsed.title), h("div", { class: {
                    "layout": true,
                    "layout--cols-3": this.recentlyUsedServersData.length >= 3,
                    "layout--cols-2": this.recentlyUsedServersData.length <= 2
                } }, this.recentlyUsedServersData.map((server, index) => (h("button", { id: "recently-used-server-" + index, class: {
                    "layout__panel": true,
                    "recently-used-card": true,
                    "recently-used-card--selected": this.selectedRecentlyUsedId === server.id
                }, onClick: () => __classPrivateFieldGet(this, _GxIdeServerSelector_handleRecentlyUsedCardClick, "f").call(this, server), onDblClick: () => __classPrivateFieldGet(this, _GxIdeServerSelector_onRecentlyUsedDoubleClickHandler, "f").call(this, server) }, h("div", { class: "recently-used-card-content" }, h("p", { class: "body-regular-s text-neutral-gray-400" }, server.serverName), h("p", { class: "body-regular-s text-neutral-gray-400 text-decoration-line-underline" }, server.serverUrl)), __classPrivateFieldGet(this, _GxIdeServerSelector_renderTooltip, "f").call(this, server.serverUrl))))))));
        });
        _GxIdeServerSelector_renderAllServers.set(this, () => {
            return (h("div", { class: "field field-block field-block-all-servers spacing-body-inline" }, h("label", { class: "label", htmlFor: "all-servers" }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").allServers.title), __classPrivateFieldGet(this, _GxIdeServerSelector_renderAllServersGrid, "f").call(this)));
        });
        this.enableConfirmButton = false;
        this.serverUrlInputValue = "";
        this.serverNameInputValue = "";
        this.selectedServerUri = undefined;
        this.selectedServerName = "None";
        this.userName = undefined;
        this.filterValue = "";
        this.filteredServersData = [];
        this.validatableControls = new Map();
        this.selectedConnectionType = "select";
        this.selectedRecentlyUsedId = undefined;
        this.serversData = [];
        this.recentlyUsedServersData = [];
        this.cancelCallback = undefined;
        this.selectServerCallback = undefined;
        this.deleteServerCallback = undefined;
        this.updateServerCallback = undefined;
    }
    serversDataChanged(newValue) {
        this.filteredServersData = newValue;
    }
    async componentWillLoad() {
        var _a, _b;
        __classPrivateFieldSet(this, _GxIdeServerSelector__componentLocale, await Locale.getComponentStrings(this.el), "f");
        __classPrivateFieldSet(this, _GxIdeServerSelector_versionsSelect, [
            {
                value: "select",
                caption: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").captions.selectServer
            },
            {
                value: "new",
                caption: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").captions.addServer
            }
        ], "f");
        this.selectedServerUri = (_a = this.serversData[0]) === null || _a === void 0 ? void 0 : _a.serverUrl;
        this.userName = (_b = this.serversData[0]) === null || _b === void 0 ? void 0 : _b.gxServerUsername;
        this.filteredServersData = this.serversData;
    }
    componentDidRender() {
        if (this.selectedConnectionType === "new" &&
            __classPrivateFieldGet(this, _GxIdeServerSelector_serverUrlEL, "f") &&
            __classPrivateFieldGet(this, _GxIdeServerSelector_serverFriendlyNameEL, "f")) {
            __classPrivateFieldGet(this, _GxIdeServerSelector_initializeValidatableControls, "f").call(this, [
                __classPrivateFieldGet(this, _GxIdeServerSelector_serverUrlEL, "f"),
                __classPrivateFieldGet(this, _GxIdeServerSelector_serverFriendlyNameEL, "f")
            ]);
            __classPrivateFieldGet(this, _GxIdeServerSelector_serverNameEditElsMap, "f").clear();
        }
        if (this.selectedConnectionType === "select" &&
            __classPrivateFieldGet(this, _GxIdeServerSelector_serverNameEditElsMap, "f").size > 0) {
            __classPrivateFieldGet(this, _GxIdeServerSelector_initializeValidatableControls, "f").call(this, [
                ...__classPrivateFieldGet(this, _GxIdeServerSelector_serverNameEditElsMap, "f").values()
            ]);
        }
    }
    render() {
        return (h(Host, { class: {
                "widget elevation-1": true,
                "new-connection": this.selectedConnectionType === "new",
                "recently-used-empty": this.recentlyUsedServersData.length === 0
            } }, h("ch-theme", { model: CSS_BUNDLES }), h("ch-shortcuts", { src: __classPrivateFieldGet(this, _GxIdeServerSelector_shortcutsSrc, "f") }), h("main", { class: "section" }, h("header", { class: "header spacing-body-block-start spacing-body-inline" }, h("div", { class: "field-group" }, h("label", { class: "body-regular-m text-neutral-gray-400" }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").header.title), h("ch-radio-group-render", { class: "radio-group", model: __classPrivateFieldGet(this, _GxIdeServerSelector_versionsSelect, "f"), onChange: __classPrivateFieldGet(this, _GxIdeServerSelector_connectionTypeChangedHandler, "f"), value: __classPrivateFieldGet(this, _GxIdeServerSelector_versionsSelect, "f")[0].value }), this.selectedConnectionType === "select" && (h("ch-edit", { class: "input search-server", id: "server-name-search", startImgSrc: SEARCH_ICON, onInput: __classPrivateFieldGet(this, _GxIdeServerSelector_filterValueChangedHandler, "f"), placeholder: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").placeholders.searchServers, accessibleName: "search server", type: "search" })))), this.selectedConnectionType === "select" && [
            __classPrivateFieldGet(this, _GxIdeServerSelector_renderRecentlyUsed, "f").call(this),
            __classPrivateFieldGet(this, _GxIdeServerSelector_renderAllServers, "f").call(this)
        ], this.selectedConnectionType === "new" && (h("section", { class: "spacing-body-inline" }, h("div", { class: "layout layout--cols-2" }, h("div", { class: "field field-block layout__panel" }, h("label", { class: "label", htmlFor: "server-url" }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").labels.serverUrl), h("ch-edit", {
            // server url
            class: "input", id: "server-url", value: this.serverUrlInputValue, onInput: event => __classPrivateFieldGet(this, _GxIdeServerSelector_inputHandler, "f").call(this, event, "serverUrlInputValue"), placeholder: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").placeholders.serverUrl, ref: el => (__classPrivateFieldSet(this, _GxIdeServerSelector_serverUrlEL, el, "f"))
        }), __classPrivateFieldGet(this, _GxIdeServerSelector_evaluateTooltipRender, "f").call(this, __classPrivateFieldGet(this, _GxIdeServerSelector_serverUrlEL, "f"))), h("div", { class: "field field-block layout__panel" }, h("label", { class: "label", htmlFor: "server-name" }, __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").labels.serverName), h("ch-edit", {
            // server friendly name
            class: "input", id: "server-name", value: this.serverNameInputValue, onInput: event => __classPrivateFieldGet(this, _GxIdeServerSelector_inputHandler, "f").call(this, event, "serverNameInputValue"), placeholder: __classPrivateFieldGet(this, _GxIdeServerSelector__componentLocale, "f").placeholders.serverName, maxLength: 18, ref: el => (__classPrivateFieldSet(this, _GxIdeServerSelector_serverFriendlyNameEL, el, "f"))
        }), __classPrivateFieldGet(this, _GxIdeServerSelector_evaluateTooltipRender, "f").call(this, __classPrivateFieldGet(this, _GxIdeServerSelector_serverFriendlyNameEL, "f")))))), __classPrivateFieldGet(this, _GxIdeServerSelector_renderFooter, "f").call(this))));
    }
    static get assetsDirs() { return ["gx-ide-assets/server-selector"]; }
    get el() { return getElement(this); }
    static get watchers() { return {
        "serversData": ["serversDataChanged"]
    }; }
};
_GxIdeServerSelector__componentLocale = new WeakMap(), _GxIdeServerSelector_chGridAllServersEl = new WeakMap(), _GxIdeServerSelector_serverUrlEL = new WeakMap(), _GxIdeServerSelector_serverFriendlyNameEL = new WeakMap(), _GxIdeServerSelector_updatedServerName = new WeakMap(), _GxIdeServerSelector_serverNameEditElsMap = new WeakMap(), _GxIdeServerSelector_versionsSelect = new WeakMap(), _GxIdeServerSelector_shortcutsSrc = new WeakMap(), _GxIdeServerSelector_cancelHandler = new WeakMap(), _GxIdeServerSelector_confirmHandler = new WeakMap(), _GxIdeServerSelector_evaluateTooltipRender = new WeakMap(), _GxIdeServerSelector_initializeValidatableControls = new WeakMap(), _GxIdeServerSelector_filterValueChangedHandler = new WeakMap(), _GxIdeServerSelector_inputHandler = new WeakMap(), _GxIdeServerSelector_handleRecentlyUsedCardClick = new WeakMap(), _GxIdeServerSelector_handleDeleteServer = new WeakMap(), _GxIdeServerSelector_onServerNameInput = new WeakMap(), _GxIdeServerSelector_onServerNameChange = new WeakMap(), _GxIdeServerSelector_enableConfirmButton = new WeakMap(), _GxIdeServerSelector_onRecentlyUsedDoubleClickHandler = new WeakMap(), _GxIdeServerSelector_onServersRowClickHandler = new WeakMap(), _GxIdeServerSelector_handleServerSelection = new WeakMap(), _GxIdeServerSelector_connectionTypeChangedHandler = new WeakMap(), _GxIdeServerSelector_sortTabularGridColumnCallback = new WeakMap(), _GxIdeServerSelector_renderTabularGridColumnSet = new WeakMap(), _GxIdeServerSelector_renderTooltip = new WeakMap(), _GxIdeServerSelector_renderServerNameErrorMessage = new WeakMap(), _GxIdeServerSelector_renderTabularGridCommonCells = new WeakMap(), _GxIdeServerSelector_renderAllServersGrid = new WeakMap(), _GxIdeServerSelector_renderIcon = new WeakMap(), _GxIdeServerSelector_renderFooter = new WeakMap(), _GxIdeServerSelector_renderRecentlyUsed = new WeakMap(), _GxIdeServerSelector_renderAllServers = new WeakMap();
GxIdeServerSelector.style = serverSelectorCss;

export { GxIdeServerSelector as gx_ide_server_selector };

//# sourceMappingURL=gx-ide-server-selector.entry.js.map