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 _GxIdeNewEnvironment_componentLocale, _GxIdeNewEnvironment_initials, _GxIdeNewEnvironment_menuDropdownModel, _GxIdeNewEnvironment_userLoginButton, _GxIdeNewEnvironment_dropDownitemClickHandler;
/* STENCIL IMPORTS */
import { Host, h } from "@stencil/core";
import { getIconPath } from "@genexus/mercury";
import { Locale } from "../../common/locale";
import { getInitialsFromName, limitFullName } from "./helpers";
const CSS_BUNDLES = [
    // TODO: review if "utils/form--full" is required.
    "resets/box-sizing",
    "components/tooltip",
    "components/switch",
    "components/icon",
    "components/dropdown",
    "utils/layout",
    "utils/typography",
    "utils/spacing",
    "chameleon/scrollbar"
];
const CHEVRON_DOWN_ICON = getIconPath({
    category: "navigation",
    name: "chevron-down",
    colorType: "interactive"
});
const MY_ACCOUNT_ID = "my-account";
const CHANGE_TEAM_ID = "change-team";
const SIGN_OUT_ID = "sign-out";
const LANGUAGE_ID = "language";
export class GxIdeNewEnvironment {
    constructor() {
        _GxIdeNewEnvironment_componentLocale.set(this, void 0);
        _GxIdeNewEnvironment_initials.set(this, "");
        // #mode: Mode;
        _GxIdeNewEnvironment_menuDropdownModel.set(this, void 0);
        _GxIdeNewEnvironment_userLoginButton.set(this, void 0);
        // #handleModeSwitch = () => {
        //   this.#mode = this.#mode === "dark" ? "light" : "dark";
        //   if (this.changeModeCallback) {
        //     this.changeModeCallback(this.#mode);
        //   }
        // };
        _GxIdeNewEnvironment_dropDownitemClickHandler.set(this, (event) => {
            const id = event.detail.id;
            if (id === MY_ACCOUNT_ID) {
                // this.myAccountCallback();
            }
            else if (id === CHANGE_TEAM_ID) {
                this.changeTeamCallback();
            }
            else if (id === SIGN_OUT_ID) {
                this.signOutCallback();
            }
            else if (id === LANGUAGE_ID) {
                this.changeLanguageCallback();
            }
        });
        this.showMenu = false;
        this.userInfo = undefined;
        this.myAccountCallback = undefined;
        this.changeTeamCallback = undefined;
        this.changeLanguageCallback = undefined;
        this.changeModeCallback = undefined;
        this.menuAlign = undefined;
        this.signOutCallback = undefined;
        this.termsCallback = undefined;
        this.privacyCallback = undefined;
    }
    async componentWillLoad() {
        __classPrivateFieldSet(this, _GxIdeNewEnvironment_componentLocale, await Locale.getComponentStrings(this.el), "f");
        __classPrivateFieldSet(this, _GxIdeNewEnvironment_initials, getInitialsFromName(this.userInfo.name), "f");
        __classPrivateFieldSet(this, _GxIdeNewEnvironment_menuDropdownModel, [
            // {
            //   id: MY_ACCOUNT_ID,
            //   caption: this.#componentLocale.myAccountLabel,
            //   showSeparator: false
            // },
            {
                id: CHANGE_TEAM_ID,
                caption: __classPrivateFieldGet(this, _GxIdeNewEnvironment_componentLocale, "f").changeTeamLabel
            },
            {
                id: SIGN_OUT_ID,
                caption: __classPrivateFieldGet(this, _GxIdeNewEnvironment_componentLocale, "f").signOutLabel
            },
            {
                type: "separator"
            },
            {
                type: "slot",
                id: "agreement"
            }
        ], "f");
    }
    render() {
        var _a, _b;
        const userName = limitFullName((_a = this.userInfo) === null || _a === void 0 ? void 0 : _a.name);
        return (h(Host, { class: "widget" }, h("ch-theme", { model: CSS_BUNDLES }), h("ch-action-menu-render", { class: "dropdown user-login__button", model: __classPrivateFieldGet(this, _GxIdeNewEnvironment_menuDropdownModel, "f"), inlineAlign: "inside-end", blockAlign: "outside-end", onButtonClick: __classPrivateFieldGet(this, _GxIdeNewEnvironment_dropDownitemClickHandler, "f") }, h("div", { class: "user-login__details" }, userName ? (h("span", { class: "body-semi-bold-s user-login__name" }, userName)) : null, ((_b = this.userInfo) === null || _b === void 0 ? void 0 : _b.team) ? (h("span", { class: "body-regular-xs user-login__organization" }, this.userInfo.team)) : null), h("div", { class: "user-login__avatar" }, __classPrivateFieldGet(this, _GxIdeNewEnvironment_initials, "f")), h("ch-image", { src: CHEVRON_DOWN_ICON, class: "icon-m", containerRef: __classPrivateFieldGet(this, _GxIdeNewEnvironment_userLoginButton, "f") }), h("div", { class: "user-login__footer footer-slot", slot: "agreement" }, h("button", { class: "body-regular-s agreement-link", onClick: this.termsCallback }, __classPrivateFieldGet(this, _GxIdeNewEnvironment_componentLocale, "f").termsAndConditionsCaption), h("button", { class: "body-regular-s\tagreement-link", onClick: this.privacyCallback }, __classPrivateFieldGet(this, _GxIdeNewEnvironment_componentLocale, "f").privacyPolicyCaption)))));
    }
    static get is() { return "gx-ide-current-user-info"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["current-user-info.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["current-user-info.css"]
        };
    }
    static get assetsDirs() { return ["gx-ide-assets/current-user-info"]; }
    static get properties() {
        return {
            "userInfo": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "UserInfo",
                    "resolved": "{ name: string; team: string; }",
                    "references": {
                        "UserInfo": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/current-user-info/current-user-info.tsx",
                            "id": "src/components/current-user-info/current-user-info.tsx::UserInfo"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "User data"
                }
            },
            "myAccountCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback executed when the user click \"My Account\" link"
                }
            },
            "changeTeamCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback executed when the user click \"change team\" link"
                }
            },
            "changeLanguageCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback executed when the user click \"Language\" link"
                }
            },
            "changeModeCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "(mode: Mode) => Promise<void>",
                    "resolved": "(mode: Mode) => Promise<void>",
                    "references": {
                        "Mode": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/current-user-info/current-user-info.tsx",
                            "id": "src/components/current-user-info/current-user-info.tsx::Mode"
                        },
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback executed when the user switch the \"Mode\" status"
                }
            },
            "menuAlign": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "MenuAlign",
                    "resolved": "{ blockAlign: ChPopoverAlign; inlineAlign: ChPopoverAlign; }",
                    "references": {
                        "MenuAlign": {
                            "location": "local",
                            "path": "/home/runner/work/genexus-ide-ui/genexus-ide-ui/src/components/current-user-info/current-user-info.tsx",
                            "id": "src/components/current-user-info/current-user-info.tsx::MenuAlign"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Defines the menu block and inline alignment"
                }
            },
            "signOutCallback": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "() => Promise<void>",
                    "resolved": "() => Promise<void>",
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    }
                },
                "required": true,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Callback executed when the user click \"Sign Out\" link"
                }
            },
            "termsCallback": {
                "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 executed when the user clicks on the \"term and conditions\" link"
                }
            },
            "privacyCallback": {
                "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 executed when the user clicks on the \"privacy policy\" link"
                }
            }
        };
    }
    static get states() {
        return {
            "showMenu": {}
        };
    }
    static get elementRef() { return "el"; }
}
_GxIdeNewEnvironment_componentLocale = new WeakMap(), _GxIdeNewEnvironment_initials = new WeakMap(), _GxIdeNewEnvironment_menuDropdownModel = new WeakMap(), _GxIdeNewEnvironment_userLoginButton = new WeakMap(), _GxIdeNewEnvironment_dropDownitemClickHandler = new WeakMap();
//# sourceMappingURL=current-user-info.js.map
