import { p as proxyCustomElement, H, h } from './index.js';

const navbarItemCss = ":host(.hidden){display:none}.navbar__item{position:relative;display:flex;flex-direction:row;align-items:center;padding:0px 8px;flex:none;order:0;flex-grow:0;font-family:var(--ifx-font-family);text-decoration:none;font-weight:400;font-size:16px;color:#1D1D1D}.navbar__item.hide{display:none}.navbar__item.isParent{gap:8px}.navbar__item .navItemIconWrapper{transition:0.3s;display:flex}.navbar__item.open .navItemIconWrapper{transform:rotate(-180deg);transition:0.3s}.navbar__item:hover{color:#0A8276;cursor:pointer}.navbar__item:hover .username__tooltip{display:block}.navbar__item:hover .navbar__container-right-content-navigation-item-icon-wrapper .initials__wrapper{cursor:pointer;background-color:#08665C}.navbar__item.remove{display:none}.navbar__item.removeLabel .label__wrapper{display:none}.navbar__item .number__indicator-wrapper{position:relative;top:-11px}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper{position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;padding:0px;gap:8px;flex:none;order:0;flex-grow:0}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper .username__tooltip{display:none;position:absolute;top:35px;right:0;text-wrap:nowrap;padding:1px 5px;font-size:13px;font-family:\"Source Sans 3\";background-color:black;color:#fff;z-index:99}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper:hover .username__tooltip{display:block}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper .initials__wrapper{display:flex;width:24px;height:24px;justify-content:center;align-items:center;border-radius:100%;background-color:#0A8276}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper .initials__wrapper .initials{color:#FFF;text-align:center;font-family:\"Source Sans 3\";font-size:14px;font-style:normal;font-weight:600;line-height:20px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper img{width:24px;height:24px;border-radius:100%}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper.removeWrapper{display:none}.navbar__item .navbar__container-right-content-navigation-item-icon-wrapper.hide{display:none}.container{position:relative}.container:focus{outline:none;box-shadow:0 0 0 2px #FFFFFF, 0 0 0 4px #0A8276}.container .sub__layer-back-button{display:none}.container .sub__layer-back-button.show{display:flex;justify-content:flex-start}.container .sub__layer-back-button.show .back__button-wrapper{display:flex;align-items:center;gap:8px;padding:8px 0 16px 0;color:#0A8276;font-size:16px;font-style:normal;font-weight:600;line-height:24px}.container .sub__layer-back-button.show .back__button-wrapper span:hover,.container .sub__layer-back-button.show .back__button-wrapper ifx-icon:hover{cursor:pointer}.container.hide{display:none}.container .inner__content-wrapper{position:relative;display:flex;justify-content:space-between;align-items:center;gap:8px}.container .inner__content-wrapper.no-gap{gap:0px}.container .inner__content-wrapper .navbar__container-right-content-navigation-item-icon-wrapper.no-gap{gap:0px}.container .inner__content-wrapper .number__indicator-wrapper{position:relative;top:-11px}.navbar-menu{position:absolute;display:none;list-style-type:none;visibility:visible;flex-direction:column;width:224px;min-width:224px;background:#FFFFFF;box-shadow:0px 6px 9px 0px rgba(29, 29, 29, 0.1019607843);border:1px solid #EEEDED;padding:8px 0px;font-family:var(--ifx-font-family)}.navbar-menu.open:not(.itemInMobileMenu){display:flex}.navbar-menu.itemInMobileMenu{display:none}.navbar-menu.right{left:100%;top:-40%}.navbar-menu.left{top:-40%;right:100%}.navbar-menu.rightSideItemMenu{left:initial;right:0px}.navbar__item.layer__item-parent{color:#1D1D1D;font-size:24px;font-style:normal;font-weight:600;line-height:32px;letter-spacing:-0.24px;cursor:initial}.navbar__item.layer__item-parent .navbar__container-right-content-navigation-item-icon-wrapper ifx-icon svg{width:24px;height:24px}.navbar__item.sidebarMenuItem{justify-content:space-between;padding:0}.navbar__item.menuItem{text-decoration:none;color:#1D1D1D;display:flex;align-items:center;justify-content:space-between;padding:8px 16px;gap:8px;font-family:var(--ifx-font-family)}.navbar__item.menuItem.hide{display:none}.navbar__item.menuItem .label__wrapper{color:#1D1D1D;font-size:16px;font-style:normal;font-weight:400;line-height:24px}.navbar__item.menuItem:hover{cursor:pointer;background-color:#EEEDED}.navbar__item.menuItem:active{background-color:#BFBBBB}.sub__layer-menu{padding:5px;display:none}.sub__layer-menu.remove__margin{margin:0;padding:0}.sub__layer-menu.open{display:block}.navbar__item.hide{display:none}.menuItemRightIconWrapper.hide{display:none}.navItemIconWrapper.hide{display:none}";

const NavbarProfile = /*@__PURE__*/ proxyCustomElement(class NavbarProfile extends H {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.showLabel = true;
        this.href = "";
        this.imageUrl = "";
        this.target = "_self";
        this.alt = "";
        this.userName = "";
        this.internalHref = "";
        this.isMenuItem = false;
        this.hasChildNavItems = false;
        this.internalImageUrl = { type: "", value: "" };
        this.defaultProfileImage = `<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="48" height="48" fill="#0A8276"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 14C21.7909 14 20 15.7909 20 18C20 20.2091 21.7909 22 24 22C26.2091 22 28 20.2091 28 18C28 15.7909 26.2091 14 24 14ZM18 18C18 14.6863 20.6863 12 24 12C27.3137 12 30 14.6863 30 18C30 21.3137 27.3137 24 24 24C20.6863 24 18 21.3137 18 18ZM16.5869 28.3984C18.2683 27.0179 20.7466 26 24 26C27.2541 26 29.7324 27.0209 31.4134 28.4024C33.0562 29.7526 34 31.5119 34 33V35C34 35.5523 33.5523 36 33 36H15C14.4477 36 14 35.5523 14 35V33C14 31.5074 14.9433 29.7479 16.5869 28.3984ZM17.8561 29.9441C16.5187 31.0421 16 32.2826 16 33V34H32V33C32 32.2881 31.4818 31.0474 30.1436 29.9476C28.8436 28.8791 26.8219 28 24 28C21.1774 28 19.1557 28.8771 17.8561 29.9441Z" fill="white"/>
</svg>`;
    }
    handleOutsideClick(event) {
        const path = event.composedPath();
        const itemMenu = this.getItemMenu();
        if (itemMenu) {
            if (itemMenu.classList.contains('open')) {
                if (!path.includes(this.el)) {
                    this.closeItemMenu();
                }
            }
        }
    }
    componentWillLoad() {
        this.setHref();
        this.setImage();
        const sidebarItems = this.getNavbarItems();
        if (sidebarItems.length !== 0) {
            this.hasChildNavItems = true;
        }
        else {
            this.hasChildNavItems = false;
        }
    }
    componentDidLoad() {
        this.setProfileGap();
        if (this.hasChildNavItems) {
            const navItems = this.getNavbarItems();
            this.appendNavItemToMenu(navItems);
        }
    }
    async hideComponent() {
        this.el.style.display = 'none';
    }
    async showComponent() {
        this.el.style.display = '';
    }
    handleClassList(el, type, className) {
        el.classList[type](className);
        if (type === 'contains') {
            return el.classList.contains(className);
        }
    }
    getNavbarItems() {
        const navItems = this.el.querySelectorAll('ifx-navbar-item');
        return navItems;
    }
    getNavBarItem() {
        const navItem = this.el.shadowRoot.querySelector('.navbar__item');
        return navItem;
    }
    relocateUsingSlot(navItems) {
        navItems.forEach(item => {
            item.setAttribute('slot', 'first__layer');
        });
    }
    appendNavItemToMenu(navItems) {
        this.relocateUsingSlot(navItems);
    }
    isValidHttpUrl(string) {
        let url;
        try {
            url = new URL(string);
        }
        catch (_) {
            return false;
        }
        return url.protocol === "http:" || url.protocol === "https:";
    }
    setImage() {
        if (this.imageUrl.toLowerCase().trim() === "") {
            this.internalImageUrl = { type: undefined, value: "" };
        }
        else if (this.isValidHttpUrl(this.imageUrl)) {
            this.internalImageUrl = { type: 'url', value: this.imageUrl };
        }
        else {
            this.internalImageUrl = { type: 'initials', value: this.imageUrl };
        }
    }
    setHref() {
        if (this.href.toLowerCase().trim() === "") {
            this.internalHref = undefined;
        }
        else
            this.internalHref = this.href;
    }
    setProfileGap() {
        const innerContentWrapper = this.el.shadowRoot.querySelector('.inner__content-wrapper');
        const labelWrapper = this.el.shadowRoot.querySelector('.label__wrapper');
        const labelSlot = labelWrapper.querySelector('slot');
        const nodes = labelSlot.assignedNodes();
        if (!nodes.length) {
            this.handleClassList(innerContentWrapper, 'add', 'no-gap');
        }
        else {
            this.handleClassList(innerContentWrapper, 'remove', 'no-gap');
        }
    }
    getItemMenu() {
        const menu = this.el.shadowRoot.querySelector('.navbar-menu');
        return menu;
    }
    closeItemMenu() {
        const itemMenu = this.getItemMenu();
        const menuItem = this.getNavBarItem();
        if (itemMenu) {
            this.handleClassList(itemMenu, 'remove', 'open');
            this.handleClassList(menuItem, 'remove', 'open');
        }
    }
    toggleItemMenu() {
        if (!this.internalHref) {
            if (this.isMenuItem && this.hasChildNavItems) {
                const itemMenu = this.getItemMenu();
                this.handleClassList(itemMenu, 'add', 'right');
            }
            if (this.hasChildNavItems) {
                const itemMenu = this.getItemMenu();
                const menuItem = this.getNavBarItem();
                this.handleClassList(itemMenu, 'toggle', 'open');
                this.handleClassList(menuItem, 'toggle', 'open');
            }
        }
    }
    itemHasNestedItems() {
        const childNavItem = this.el.shadowRoot.querySelector('ifx-navbar-item');
        if (childNavItem) {
            return true;
        }
        else {
            return false;
        }
    }
    render() {
        return (h("div", { key: '837122b11b554e17b60c07c303944a11b17a1eae', class: "container" }, h("a", { key: 'fde977c00f830b4a070edad21927393d5a79c117', href: this.internalHref, target: this.target, onClick: () => this.toggleItemMenu(), class: `navbar__item ${!this.showLabel ? 'removeLabel' : ""} ${this.hasChildNavItems ? 'isParent' : ""}` }, h("div", { key: 'd4d190de3cf180bef8579d362a28519ddaa5fe3b', class: "inner__content-wrapper" }, h("div", { key: 'af01f7621f00de51db3ce906164c008778324ef5', class: `navbar__container-right-content-navigation-item-icon-wrapper` }, this.userName.trim() !== "" && h("div", { key: '5df6af9768a82cc9265b252b36f7927c37b51539', class: 'username__tooltip' }, this.userName), this.internalImageUrl.type !== 'initials' &&
            h("img", { key: 'c9748a87892e169c9b472d21fbdb2d4957bb6bfb', src: this.internalImageUrl.type === 'url' ? this.internalImageUrl.value : `data:image/svg+xml,${encodeURIComponent(this.defaultProfileImage)}`, alt: this.alt }), this.internalImageUrl.type === 'initials' &&
            h("div", { key: '604c7d5245f09daba9b19a890eaabbde87951d8b', class: "initials__wrapper" }, h("span", { key: '2bc213ff673fc4af3d10da3caa99275ba38d276c', class: "initials" }, this.internalImageUrl.value))), h("span", { key: 'e073d5b6763d3b716980c598b78f0ed099fc4791', class: "label__wrapper" }, h("slot", { key: '051f2cc80248b847944a03b04651786785d2fa4f', onSlotchange: () => this.setProfileGap() })))), this.hasChildNavItems && h("ul", { key: 'cefecb5bef10e87e336aa8c0620cb996da674ea3', class: 'navbar-menu rightSideItemMenu' }, " ", h("slot", { key: 'ae09e66ce2dedcec664c7d1d8c351cfca2c6a647', name: "first__layer" }), " ")));
    }
    static get assetsDirs() { return ["assets"]; }
    get el() { return this; }
    static get style() { return navbarItemCss; }
}, [257, "ifx-navbar-profile", {
        "showLabel": [4, "show-label"],
        "href": [1],
        "imageUrl": [1, "image-url"],
        "target": [1],
        "alt": [1],
        "userName": [1, "user-name"],
        "internalHref": [32],
        "isMenuItem": [32],
        "hasChildNavItems": [32],
        "internalImageUrl": [32],
        "hideComponent": [64],
        "showComponent": [64]
    }, [[5, "mousedown", "handleOutsideClick"]]]);
function defineCustomElement$1() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["ifx-navbar-profile"];
    components.forEach(tagName => { switch (tagName) {
        case "ifx-navbar-profile":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, NavbarProfile);
            }
            break;
    } });
}

const IfxNavbarProfile = NavbarProfile;
const defineCustomElement = defineCustomElement$1;

export { IfxNavbarProfile, defineCustomElement };
//# sourceMappingURL=ifx-navbar-profile.js.map

//# sourceMappingURL=ifx-navbar-profile.js.map