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 { L as Locale } from './locale-e5107fad.js';

const restoreVersionCss = ":host{display:grid;block-size:100%}.opacity-0{opacity:0}.gxi-hidden{display:none !important}.align-center{display:flex;align-items:center}.align-end{display:flex;align-items:end}.overflow-auto{overflow:auto}:host(.gx-ide-component){height:100% !important;display:flex !important;flex-direction:column !important}.gx-ide-main-wrapper{color:var(--gx-ide-component-text-color);font-weight:var(--font-style-regular);font-size:var(--font-size-body-m);font-family:var(--font-family-body);height:100%;display:flex;flex-direction:column;flex-grow:1;box-sizing:border-box}.buttons-container{display:flex;gap:var(--spacing-gap-m)}.giu-static-pill-icon-and-text,.giu-static-pill{background-color:var(--elevation-background-color, var(--color-accent-surface-elevation-1));padding-inline:var(--spacing-padding-m);color:var(--color-text-neutral-default);font-size:var(--font-size-body-s);line-height:var(--line-height-relaxed);font-weight:var(--font-style-regular);border-radius:4px;min-block-size:25px;display:inline-grid;align-items:center;pointer-events:none;inline-size:max-content}.giu-static-pill-icon-and-text{display:inline-grid;grid-auto-flow:column;grid-auto-columns:max-content;gap:var(--spacing-gap-m)}.tab-full-width-buttons::part(tab-list block-start),.tab-full-width-buttons::part(tab-list block-end){grid-auto-columns:1fr}.tab-full-width-buttons::part(tab block-start){justify-content:center}.tree-view::part(item__header){--icon__system_warning_warning--disabled:var(\n    --icon__system_warning_warning--enabled\n  )}.tabular-grid{--focus-outline-width:1px}button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;grid-template-rows:1fr max-content}.main-container{display:grid;grid-template-rows:max-content max-content max-content;gap:var(--spacing-gap-xl)}.versions-container{display:grid;grid-template-columns:1fr max-content;gap:var(--spacing-gap-m)}";

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 _GxIdeRestoreVersion_componentLocale, _GxIdeRestoreVersion_chShortcutsEl, _GxIdeRestoreVersion_shortcutsSrc, _GxIdeRestoreVersion_confirmHandler, _GxIdeRestoreVersion_cancelHandler, _GxIdeRestoreVersion_versionsToComboBoxItemModel, _GxIdeRestoreVersion_handleComboBoxInput, _GxIdeRestoreVersion_selectSourceVersionHandler, _GxIdeRestoreVersion_renderFooter;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/form--full",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "utils/elevation",
    "chameleon/scrollbar"
];
const SHOW_MORE_ICON = getIconPath({
    category: "gemini-tools",
    name: "show-more-horizontal",
    colorType: "interactive"
});
const VERSION_FROZEN_OBJECT_ICON = getIconPath({
    category: "objects",
    name: "version-frozen"
});
const VERSION_OBJECT_ICON = getIconPath({
    category: "objects",
    name: "version"
});
const VERSION_ICON = getIconPath({
    category: "system",
    name: "version",
    colorType: "on-surface"
});
const GxIdeRestoreVersion = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        _GxIdeRestoreVersion_componentLocale.set(this, void 0);
        _GxIdeRestoreVersion_chShortcutsEl.set(this, void 0);
        _GxIdeRestoreVersion_shortcutsSrc.set(this, getAssetPath(`./gx-ide-assets/restore-version/shortcuts.json`));
        _GxIdeRestoreVersion_confirmHandler.set(this, async () => {
            const restoreVersionData = {
                toVersionGuid: this.toVersionInfo.guid,
                toVersionName: this.toVersionInfo.name,
                fromVersionGuid: this.versions.find(version => version.name === this.selectedSourceVersionName).guid,
                fromVersionName: this.selectedSourceVersionName,
                syncEnvironments: this.syncEnvironments
            };
            await this.confirmCallback(restoreVersionData);
        });
        _GxIdeRestoreVersion_cancelHandler.set(this, async () => {
            await this.cancelCallback();
        });
        _GxIdeRestoreVersion_versionsToComboBoxItemModel.set(this, (versions) => {
            this.versionsComboBoxModel = versions.map(version => ({
                caption: version.name,
                value: version.guid,
                startImgSrc: version.isFrozen
                    ? VERSION_FROZEN_OBJECT_ICON
                    : VERSION_OBJECT_ICON
            }));
        });
        _GxIdeRestoreVersion_handleComboBoxInput.set(this, (event) => {
            this.selectedSourceVersionName = event.detail;
        });
        // Uncomment this when the sync environments feature is available
        // #handleCheckBoxValueChange = (
        //   event: ChCheckboxCustomEvent<any> | InputEvent
        // ) => {
        //   this.syncEnvironments = event.detail === CHECKBOX_CHECKED_VALUE;
        // };
        _GxIdeRestoreVersion_selectSourceVersionHandler.set(this, async () => {
            this.selectedSourceVersion = await this.selectSourceVersionCallback();
            this.selectedSourceVersionName = this.selectedSourceVersion[0].name;
        });
        _GxIdeRestoreVersion_renderFooter.set(this, () => {
            const disableConfirmButton = !this.selectedSourceVersionName ||
                !this.versionsComboBoxModel.some(v => v.caption === this.selectedSourceVersionName);
            return (h("footer", { class: "footer dialog-footer dialog-footer-with-border spacing-body" }, h("div", { class: "buttons-spacer" }, h("button", { id: "cancel-button", class: "button-secondary", onClick: __classPrivateFieldGet(this, _GxIdeRestoreVersion_cancelHandler, "f") }, __classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").footer.cancel), h("button", { id: "confirm-button", class: "button-primary", onClick: __classPrivateFieldGet(this, _GxIdeRestoreVersion_confirmHandler, "f"), disabled: disableConfirmButton }, __classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").footer.confirm))));
        });
        this.syncEnvironments = false;
        this.selectedSourceVersionName = "";
        this.selectedSourceVersion = [];
        this.versionsComboBoxModel = [];
        this.selectSourceVersionCallback = undefined;
        this.confirmCallback = undefined;
        this.cancelCallback = undefined;
        this.toVersionInfo = undefined;
        this.versions = undefined;
    }
    versionsChanged() {
        __classPrivateFieldGet(this, _GxIdeRestoreVersion_versionsToComboBoxItemModel, "f").call(this, this.versions);
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeRestoreVersion_componentLocale, await Locale.getComponentStrings(this.el), "f");
        __classPrivateFieldGet(this, _GxIdeRestoreVersion_versionsToComboBoxItemModel, "f").call(this, this.versions || []);
    }
    /**
     * Suspends or reactivates the shortcuts
     */
    async suspendShortcuts(suspendShortcuts) {
        if (suspendShortcuts) {
            __classPrivateFieldGet(this, _GxIdeRestoreVersion_chShortcutsEl, "f").suspend = true;
        }
        else {
            __classPrivateFieldGet(this, _GxIdeRestoreVersion_chShortcutsEl, "f").suspend = false;
        }
    }
    render() {
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("ch-shortcuts", { src: __classPrivateFieldGet(this, _GxIdeRestoreVersion_shortcutsSrc, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeRestoreVersion_chShortcutsEl, el, "f")) }), h("div", { class: "main-container spacing-body" }, h("p", { class: "giu-static-pill-icon-and-text elevation-2" }, h("ch-image", { class: "icon-m", type: "mask", src: VERSION_ICON }), h("span", null, `${__classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").descriptions.pill} - ${this.toVersionInfo.name}`)), h("p", { class: "body-regular-m" }, __classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").descriptions.summary), h("div", { class: "field field-block" }, h("label", { class: "label", htmlFor: "versions-combo-box" }, __classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").labels.fromVersion), h("div", { class: "versions-container" }, h("ch-combo-box-render", { class: "combo-box", id: "versions-combo-box", model: this.versionsComboBoxModel, placeholder: __classPrivateFieldGet(this, _GxIdeRestoreVersion_componentLocale, "f").placeHolders.fromVersion, value: this.selectedSourceVersionName, suggest: true, onInput: __classPrivateFieldGet(this, _GxIdeRestoreVersion_handleComboBoxInput, "f") }), h("button", { id: "select-version-button", class: "button-secondary button-icon-only", onClick: __classPrivateFieldGet(this, _GxIdeRestoreVersion_selectSourceVersionHandler, "f") }, h("ch-image", { src: SHOW_MORE_ICON, class: "icon-m" }))))), __classPrivateFieldGet(this, _GxIdeRestoreVersion_renderFooter, "f").call(this)));
    }
    static get assetsDirs() { return ["gx-ide-assets/restore-version"]; }
    get el() { return getElement(this); }
    static get watchers() { return {
        "versions": ["versionsChanged"]
    }; }
};
_GxIdeRestoreVersion_componentLocale = new WeakMap(), _GxIdeRestoreVersion_chShortcutsEl = new WeakMap(), _GxIdeRestoreVersion_shortcutsSrc = new WeakMap(), _GxIdeRestoreVersion_confirmHandler = new WeakMap(), _GxIdeRestoreVersion_cancelHandler = new WeakMap(), _GxIdeRestoreVersion_versionsToComboBoxItemModel = new WeakMap(), _GxIdeRestoreVersion_handleComboBoxInput = new WeakMap(), _GxIdeRestoreVersion_selectSourceVersionHandler = new WeakMap(), _GxIdeRestoreVersion_renderFooter = new WeakMap();
GxIdeRestoreVersion.style = restoreVersionCss;

export { GxIdeRestoreVersion as gx_ide_restore_version };

//# sourceMappingURL=gx-ide-restore-version.entry.js.map