var __classPrivateFieldSet = (this && this.__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 __classPrivateFieldGet = (this && this.__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 _GxIdeUiSplash_componentLocale;
// Stencil
import { Host, h, getAssetPath } from "@stencil/core";
import { getIconPath } from "@genexus/mercury";
import { Locale } from "../../common/locale";
import { ANIMATION_DOTS } from "../../common/common";
const COPYRIGHTS_ILLUSTRATION = getAssetPath(`./gx-ide-assets/splash/images/copyrights-illustration.svg`);
const LOGO_NEXT = getAssetPath(`./gx-ide-assets/welcome-page/images/icon-next.svg`);
const CSS_BUNDLES = [
    "resets/box-sizing",
    "utils/typography",
    "components/button",
    "components/icon",
    "chameleon/scrollbar"
];
const OPEN_LOG_ICON = getIconPath({
    category: "system",
    name: "launch",
    colorType: "primary"
});
export class GxIdeUiSplash {
    constructor() {
        /**
         * The component hard-coded strings translations.
         */
        // eslint-disable-next-line @stencil-community/own-props-must-be-private
        _GxIdeUiSplash_componentLocale.set(this, void 0);
        this.ariaBusy = true;
        this.appVersion = undefined;
        this.downloadDockerCallback = undefined;
        this.quitCallback = undefined;
        this.messages = [];
        this.openLogCallback = undefined;
        this.showQuitButton = false;
        this.showOpenLogLink = false;
        this.showDockerMissingError = false;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeUiSplash_componentLocale, await Locale.getComponentStrings(this.el), "f");
    }
    render() {
        var _a, _b;
        const renderOpenLogLink = this.showOpenLogLink && this.openLogCallback;
        const renderInstallationErrorMessage = this.showQuitButton && this.quitCallback && this.messages.length > 0;
        const renderInitializingMessage = !(this.showQuitButton && this.quitCallback) && ((_a = this.messages) === null || _a === void 0 ? void 0 : _a.length) > 0;
        const renderErrorMessage = this.showDockerMissingError || !renderInitializingMessage;
        let installationErrorMessage = __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").warnings.installationFailed;
        if (renderOpenLogLink) {
            installationErrorMessage = `${installationErrorMessage} ${__classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").warnings.checkTheLog}`;
        }
        return (h(Host, null, h("ch-theme", { model: CSS_BUNDLES }), h("div", { class: {
                scrollable: true,
                wrapper: true
            } }, h("div", { class: "side-inline-start", style: { backgroundImage: `url(${COPYRIGHTS_ILLUSTRATION})` }, role: "img" }), h("section", { class: "side-inline-end scrollable" }, h("header", { class: "header" }, h("img", { src: LOGO_NEXT, alt: __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").illustrationAlternativeText }), h("h2", { class: "title heading-2" }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").title), this.appVersion && (h("p", { class: "body-regular-m next-version" }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").nextVersion, " ", this.appVersion)), h("p", { class: "body-italic-m header__description" }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").allRightsReserved), h("p", { class: "body-italic-m header__description" }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").copyright)), h("main", { class: "main" }, renderInitializingMessage && (h("p", { class: {
                "body-regular-m": true,
                "status--processing": true
            } }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").initializingServices, ANIMATION_DOTS("tiny", "on-surface"))), h("code", { class: "log__container scrollable", role: "status", "aria-live": "polite", "aria-busy": this.ariaBusy }, (_b = this.messages) === null || _b === void 0 ? void 0 : _b.reverse().map((message, i) => {
            return (h("p", { class: {
                    "caption-regular-l": true,
                    "log__message": true,
                    "log__message--error": message.type === "error"
                }, key: this.messages.length - i }, message.text));
        })), renderErrorMessage && (h("p", { class: "error-message status--error body-regular-m" }, renderInstallationErrorMessage && (h("span", null, installationErrorMessage)), renderInstallationErrorMessage &&
            this.showDockerMissingError && h("span", null, " - "), this.showDockerMissingError && (h("span", null, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").warnings.dockerMissing))))), h("footer", { class: "footer" }, h("div", { class: "buttons-spacer" }, this.showDockerMissingError && (h("button", { key: "download-docker", class: "button-secondary button-icon-and-text download-docker-button", onClick: this.downloadDockerCallback }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").downloadDocker)), renderOpenLogLink && (h("button", { key: "open-log", class: "button-tertiary button-icon-and-text", onClick: this.openLogCallback }, h("ch-image", { class: "icon-m", src: OPEN_LOG_ICON }), __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").openLog)), this.quitCallback && this.showQuitButton && (h("button", { class: "button-secondary", onClick: this.quitCallback }, __classPrivateFieldGet(this, _GxIdeUiSplash_componentLocale, "f").quitGenexus))))))));
    }
    static get is() { return "gx-ide-splash"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["splash.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["splash.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/splash"]; }
    static get properties() {
        return {
            "appVersion": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The application version to display in the dialog."
                },
                "attribute": "app-version",
                "reflect": false
            },
            "downloadDockerCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => void",
                    "resolved": "() => void",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user clicks the 'Download Docker' button."
                }
            },
            "quitCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => void",
                    "resolved": "() => void",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user clicks the quit button."
                }
            },
            "messages": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "MessageType[]",
                    "resolved": "MessageType[]",
                    "references": {
                        "MessageType": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/splash/splash.tsx",
                            "id": "src/components/splash/splash.tsx::MessageType"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Array of messages to display in the text box.\nThis property updates whenever a message is added,\nand the scroll should position itself at the bottom to keep the last message visible."
                },
                "defaultValue": "[]"
            },
            "openLogCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => void",
                    "resolved": "() => void",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback invoked when the user clicks the 'Open log' link."
                }
            },
            "showQuitButton": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to display the quit button."
                },
                "attribute": "show-quit-button",
                "reflect": false,
                "defaultValue": "false"
            },
            "showOpenLogLink": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to display the 'Open log' link."
                },
                "attribute": "show-open-log-link",
                "reflect": false,
                "defaultValue": "false"
            },
            "showDockerMissingError": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Set to `true` to display \"Docker is not installed\" error message and to display \"Download Docker\" button."
                },
                "attribute": "show-docker-missing-error",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "ariaBusy": {}
        };
    }
    static get elementRef() { return "el"; }
}
_GxIdeUiSplash_componentLocale = new WeakMap();
//# sourceMappingURL=splash.js.map
