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 _IdeLoader_timeoutReference, _IdeLoader_cancelProcess, _IdeLoader_renderCancelButton, _IdeLoader_renderDescription, _IdeLoader_renderTitle;
import { Host, h } from "@stencil/core";
const CSS_BUNDLES = [
    "resets/box-sizing",
    "components/button",
    "utils/typography"
];
export class IdeLoader {
    constructor() {
        _IdeLoader_timeoutReference.set(this, void 0);
        _IdeLoader_cancelProcess.set(this, () => {
            if (this.cancelCallback) {
                this.cancelCallback();
            }
            clearTimeout(__classPrivateFieldGet(this, _IdeLoader_timeoutReference, "f"));
            this.show = false;
        });
        _IdeLoader_renderCancelButton.set(this, () => this.cancelLabel && (h("div", null, h("button", { class: "button-secondary loader__cancel-button", type: "button", onClick: __classPrivateFieldGet(this, _IdeLoader_cancelProcess, "f") }, this.cancelLabel))));
        _IdeLoader_renderDescription.set(this, () => this.description && h("p", { class: "body-regular-italic-s" }, this.description));
        _IdeLoader_renderTitle.set(this, () => this.loaderTitle && h("p", { class: "body-regular-l" }, this.loaderTitle));
        this.showWrapper = true;
        this.abortTime = 5 * 60 * 1000;
        this.cancelCallback = undefined;
        this.cancelLabel = undefined;
        this.description = undefined;
        this.loaderTitle = undefined;
        this.show = false;
    }
    render() {
        return (h(Host, null, h("ch-theme", { model: CSS_BUNDLES }), this.show && (h("div", { class: {
                [`loader__wrapper`]: true,
                "loader__wrapper--visible": this.showWrapper
            }, part: "loader-wrapper", popover: "" }, h("div", { class: "loader__spinner" }), h("div", { class: {
                "loader__content-wrapper": true,
                "loader__content-wrapper--hidden": !this.description && !this.loaderTitle && !this.cancelLabel
            } }, __classPrivateFieldGet(this, _IdeLoader_renderTitle, "f").call(this), __classPrivateFieldGet(this, _IdeLoader_renderDescription, "f").call(this), __classPrivateFieldGet(this, _IdeLoader_renderCancelButton, "f").call(this))))));
    }
    static get is() { return "gx-ide-loader"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["ide-loader.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["ide-loader.css"]
        };
    }
    static get properties() {
        return {
            "abortTime": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The time the loader will await before abort."
                },
                "attribute": "abort-time",
                "reflect": false,
                "defaultValue": "5 * 60 * 1000"
            },
            "cancelCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IdeLoaderCancelCallback",
                    "resolved": "() => void",
                    "references": {
                        "IdeLoaderCancelCallback": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/_helpers/ide-loader/ide-loader.tsx",
                            "id": "src/components/_helpers/ide-loader/ide-loader.tsx::IdeLoaderCancelCallback"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The cancel callback"
                }
            },
            "cancelLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The cancel button label (optional)"
                },
                "attribute": "cancel-label",
                "reflect": false
            },
            "description": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The loader description (optional)"
                },
                "attribute": "description",
                "reflect": false
            },
            "loaderTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "The loader title (optional)"
                },
                "attribute": "loader-title",
                "reflect": false
            },
            "show": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "It shows the loader"
                },
                "attribute": "show",
                "reflect": false,
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "showWrapper": {}
        };
    }
    static get events() {
        return [{
                "method": "loaderFinished",
                "name": "loaderFinished",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "This event is emitted when \"show\" is false."
                },
                "complexType": {
                    "original": "void",
                    "resolved": "void",
                    "references": {}
                }
            }];
    }
}
_IdeLoader_timeoutReference = new WeakMap(), _IdeLoader_cancelProcess = new WeakMap(), _IdeLoader_renderCancelButton = new WeakMap(), _IdeLoader_renderDescription = new WeakMap(), _IdeLoader_renderTitle = new WeakMap();
//# sourceMappingURL=ide-loader.js.map
