/* STENCIL IMPORTS */
import { Host, h } from "@stencil/core";
/* OTHER LIBRARIES IMPORTS */
/* CUSTOM IMPORTS */
import { config } from "../../common/config";
import { Locale } from "../../common/locale";
export class GxIdeWFSettings {
    constructor() {
        this.renderedFirstTime = false;
        // 7.LISTENERS //
        // 8.PUBLIC METHODS API //
        // 9.LOCAL METHODS //
        this.cancelHandler = () => {
            if (this.cancelCallback) {
                this.cancelCallback();
            }
        };
        this.saveCallbackHandler = () => {
            if (this.saveCallback) {
                const wfConfigData = {
                    installClient: this.installGxFlowEl.checked,
                    futureUpgrades: this.futureUpgradesEl.value
                };
                this.saveCallback(wfConfigData);
            }
        };
        this.displayTitle = false;
        this.configurationType = "installation";
        this.defaultConfiguration = {
            installClient: true,
            futureUpgrades: "automatic"
        };
        this.saveCallback = undefined;
        this.cancelCallback = undefined;
    }
    // 6.COMPONENT LIFECYCLE METHODS //
    async componentWillLoad() {
        this._componentLocale = await Locale.getComponentStrings(this.el);
    }
    componentDidRender() {
        if (!this.renderedFirstTime) {
            this.componentDidRenderFirstTime.emit(this._componentLocale.componentName);
            this.renderedFirstTime = true;
        }
    }
    // 10.RENDER() FUNCTION //
    render() {
        return (h(Host, { class: "gx-ide-component" }, h("div", { class: "gx-ide-main-wrapper" }, h("gx-ide-container", { slimmerFooter: config.gxIdeContainer.slimmerFooter }, h("div", { class: "message-item" }, h("gxg-icon", { type: "gx-server/changes-commit-pending", color: "auto", size: "small" }), h("gxg-text", null, this._componentLocale.description[this.configurationType])), h("div", { class: "options" }, h("gxg-form-checkbox", { label: this._componentLocale.installGxFlow, checked: this.defaultConfiguration.installClient, ref: el => (this.installGxFlowEl = el) }), h("gxg-combo-box", { class: "upgrades-options", label: this._componentLocale.manageUpgrades, disableFilter: true, value: this.defaultConfiguration.futureUpgrades, ref: el => (this.futureUpgradesEl = el) }, h("gxg-combo-box-item", { value: "automatic" }, this._componentLocale.upgradesOptions[0]), h("gxg-combo-box-item", { value: "prompt" }, this._componentLocale.upgradesOptions[1]), h("gxg-combo-box-item", { value: "never" }, this._componentLocale.upgradesOptions[2]))), h("gxg-text", { textAlign: "end", type: "text-regular" }, this._componentLocale.prompt[this.configurationType]), h("gxg-button", { slot: "footer-end", type: "outlined", onClick: this.cancelHandler }, "Cancel"), h("gxg-button", { slot: "footer-end", onClick: this.saveCallbackHandler }, this._componentLocale.footer.confirmButton[this.configurationType])))));
    }
    static get is() { return "gx-ide-wf-settings"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["wf-settings.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["wf-settings.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/wf-settings"]; }
    static get properties() {
        return {
            "displayTitle": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "false",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If true it displays the component title on the header"
                },
                "attribute": "display-title",
                "reflect": false,
                "defaultValue": "false"
            },
            "configurationType": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "\"installation\" | \"update\"",
                    "resolved": "\"installation\" | \"update\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Indicates the type of configuration being run, the value of this property should be used to determine\nwhat long text should be displayed in this dialog."
                },
                "attribute": "configuration-type",
                "reflect": false,
                "defaultValue": "\"installation\""
            },
            "defaultConfiguration": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "WFConfigData | undefined",
                    "resolved": "{ installClient: boolean; futureUpgrades: \"prompt\" | \"never\" | \"automatic\"; }",
                    "references": {
                        "WFConfigData": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/wf-settings/wf-settings.tsx",
                            "id": "src/components/wf-settings/wf-settings.tsx::WFConfigData"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines default config to initialize dialog"
                },
                "defaultValue": "{\n    installClient: true,\n    futureUpgrades: \"automatic\"\n  }"
            },
            "saveCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(config: WFConfigData) => Promise<void>",
                    "resolved": "(config: WFConfigData) => Promise<void>",
                    "references": {
                        "WFConfigData": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/wf-settings/wf-settings.tsx",
                            "id": "src/components/wf-settings/wf-settings.tsx::WFConfigData"
                        },
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user presses the 'OK' button. As a parameter, it receives the data entered by the user"
                }
            },
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user presses the 'Cancel' button."
                }
            }
        };
    }
    static get events() {
        return [{
                "method": "componentDidRenderFirstTime",
                "name": "componentDidRenderFirstTime",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [{
                            "name": "description",
                            "text": "Gets fired when the component has rendered for the first time."
                        }],
                    "text": ""
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=wf-settings.js.map
