'use strict';

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

const index = require('./index-75aef097.js');
const locale = require('./locale-ff30a5f3.js');

const mapTypesToComboBoxItemModel = (synchronizationTypes) => {
    const syncTypes = [];
    synchronizationTypes.forEach(synchronizationType => {
        const newSynchType = {
            value: synchronizationType.value,
            caption: synchronizationType.caption
        };
        syncTypes.push(newSynchType);
    });
    return syncTypes;
};

const bpmSyncGamRolesCss = "button.button-secondary{border-color:var(--color-border-neutral-default)}:host{display:grid;block-size:100%;overflow:hidden;grid-template-rows:1fr max-content}.checkbox{inline-size:max-content}";

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 _GxIdeBpmSyncGamRoles__componentLocale, _GxIdeBpmSyncGamRoles_shortcutsSrc, _GxIdeBpmSyncGamRoles_synchronizationTypes, _GxIdeBpmSyncGamRoles_automaticBackupCheckBoxEl, _GxIdeBpmSyncGamRoles_chShortcutsEl, _GxIdeBpmSyncGamRoles_synchTypeComboBoxEl, _GxIdeBpmSyncGamRoles_cancelButtonHandler, _GxIdeBpmSyncGamRoles_okButtonHandler, _GxIdeBpmSyncGamRoles_renderFooter;
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/tooltip",
    "utils/form--full",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "chameleon/scrollbar"
];
const GxIdeBpmSyncGamRoles = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        _GxIdeBpmSyncGamRoles__componentLocale.set(this, void 0);
        _GxIdeBpmSyncGamRoles_shortcutsSrc.set(this, index.getAssetPath(`./gx-ide-assets/bpm-sync-gam-roles/shortcuts.json`));
        _GxIdeBpmSyncGamRoles_synchronizationTypes.set(this, []);
        _GxIdeBpmSyncGamRoles_automaticBackupCheckBoxEl.set(this, void 0);
        _GxIdeBpmSyncGamRoles_chShortcutsEl.set(this, void 0);
        _GxIdeBpmSyncGamRoles_synchTypeComboBoxEl.set(this, void 0);
        _GxIdeBpmSyncGamRoles_cancelButtonHandler.set(this, () => {
            if (this.cancelCallback) {
                this.cancelCallback();
            }
        });
        _GxIdeBpmSyncGamRoles_okButtonHandler.set(this, async () => {
            var _a;
            if (this.saveCallback) {
                const syncData = {
                    automaticBackup: !!((_a = __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_automaticBackupCheckBoxEl, "f")) === null || _a === void 0 ? void 0 : _a.value),
                    syncType: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_synchTypeComboBoxEl, "f").value
                };
                await this.saveCallback(syncData);
            }
        });
        _GxIdeBpmSyncGamRoles_renderFooter.set(this, () => {
            return (index.h("footer", { class: "dialog-footer dialog-footer-with-border spacing-body-block-end spacing-body-inline" }, index.h("div", { class: "buttons-spacer" }, index.h("button", { class: "button-secondary", id: "button-cancel", onClick: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_cancelButtonHandler, "f"), part: "button-cancel" }, __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles__componentLocale, "f").footer.cancelButtonText), index.h("button", { class: "button-primary", id: "button-create", onClick: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_okButtonHandler, "f"), part: "button-ok" }, __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles__componentLocale, "f").footer.okButtonText))));
        });
        this.cancelCallback = undefined;
        this.saveCallback = undefined;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeBpmSyncGamRoles__componentLocale, await locale.Locale.getComponentStrings(this.el), "f");
        __classPrivateFieldSet(this, _GxIdeBpmSyncGamRoles_synchronizationTypes, mapTypesToComboBoxItemModel(__classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles__componentLocale, "f").main.synchronizationTypeOptions), "f");
    }
    /**
     * Suspends or reactivates the shortcuts
     */
    async suspendShortcuts(suspendShortcuts) {
        if (suspendShortcuts) {
            __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_chShortcutsEl, "f").suspend = true;
        }
        else {
            __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_chShortcutsEl, "f").suspend = false;
        }
    }
    render() {
        return (index.h(index.Host, { class: "widget" }, index.h("ch-theme", { model: CSS_BUNDLES }), index.h("ch-shortcuts", { src: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_shortcutsSrc, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeBpmSyncGamRoles_chShortcutsEl, el, "f")) }), index.h("section", { class: "section spacing-body" }, index.h("div", { class: "main field-group" }, index.h("div", { class: "field field-block" }, index.h("label", { class: "label", htmlFor: "synch-type" }, __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles__componentLocale, "f").main.synchronizationTypeLabel), index.h("ch-combo-box-render", { accessibleName: "Synchronization types", class: "combo-box", id: "synch-type", value: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_synchronizationTypes, "f")[0].caption, model: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_synchronizationTypes, "f"), ref: (el) => (__classPrivateFieldSet(this, _GxIdeBpmSyncGamRoles_synchTypeComboBoxEl, el, "f")) })), index.h("ch-checkbox", { class: "checkbox", caption: __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles__componentLocale, "f").main.checkBoxLabel, checkedValue: "true", ref: (el) => (__classPrivateFieldSet(this, _GxIdeBpmSyncGamRoles_automaticBackupCheckBoxEl, el, "f")) }))), __classPrivateFieldGet(this, _GxIdeBpmSyncGamRoles_renderFooter, "f").call(this)));
    }
    static get assetsDirs() { return ["gx-ide-assets/bpm-sync-gam-roles"]; }
    get el() { return index.getElement(this); }
};
_GxIdeBpmSyncGamRoles__componentLocale = new WeakMap(), _GxIdeBpmSyncGamRoles_shortcutsSrc = new WeakMap(), _GxIdeBpmSyncGamRoles_synchronizationTypes = new WeakMap(), _GxIdeBpmSyncGamRoles_automaticBackupCheckBoxEl = new WeakMap(), _GxIdeBpmSyncGamRoles_chShortcutsEl = new WeakMap(), _GxIdeBpmSyncGamRoles_synchTypeComboBoxEl = new WeakMap(), _GxIdeBpmSyncGamRoles_cancelButtonHandler = new WeakMap(), _GxIdeBpmSyncGamRoles_okButtonHandler = new WeakMap(), _GxIdeBpmSyncGamRoles_renderFooter = new WeakMap();
GxIdeBpmSyncGamRoles.style = bpmSyncGamRolesCss;

exports.gx_ide_bpm_sync_gam_roles = GxIdeBpmSyncGamRoles;

//# sourceMappingURL=gx-ide-bpm-sync-gam-roles.cjs.entry.js.map