import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
import { f as renderHeaderSiteSelector, i as renderHeaderMenuSwitcher, h as renderHeaderLogo, r as renderHeaderLogin, d as renderHeaderLanguageSelector } from './pn-marketweb-header-shared.js';
import { d as defineCustomElement$c } from './pn-language-selector2.js';
import { d as defineCustomElement$b } from './pn-language-selector-option2.js';
import { d as defineCustomElement$a } from './pn-marketweb-header-toggle2.js';
import { d as defineCustomElement$9 } from './pn-marketweb-siteheader-login2.js';
import { d as defineCustomElement$8 } from './pn-marketweb-siteheader-login-button2.js';
import { d as defineCustomElement$7 } from './pn-marketweb-siteheader-login-linklist2.js';
import { d as defineCustomElement$6 } from './pn-marketweb-siteheader-login-links2.js';
import { d as defineCustomElement$5 } from './pn-marketweb-siteheader-login-profileselection2.js';
import { d as defineCustomElement$4 } from './pn-marketweb-siteheader-search2.js';
import { d as defineCustomElement$3 } from './pn-marketweb-siteheader-unified-login2.js';
import { d as defineCustomElement$2 } from './pn-site-selector2.js';
import { d as defineCustomElement$1 } from './pn-site-selector-item2.js';

function normalizeHeaderTheme(theme) {
    switch (theme?.toLowerCase()) {
        case 'business':
            return 'business';
        case 'private':
            return 'private';
        default:
            return 'private';
    }
}
function getAppearanceForTheme(theme) {
    switch (normalizeHeaderTheme(theme)) {
        case 'private':
            return 'light';
        case 'business':
            return 'dark';
        default:
            return 'light';
    }
}
function resolveHeaderMenuThemes(menuThemes, menuModeOptions) {
    //1. Prop override
    if (menuThemes) {
        try {
            const parsed = JSON.parse(menuThemes);
            if (Array.isArray(parsed)) {
                const filtered = parsed
                    .filter((item) => typeof item === 'string')
                    .map(item => normalizeHeaderTheme(item));
                if (filtered.length > 0) {
                    return filtered;
                }
            }
        }
        catch (error) {
            console.warn('[pn-marketweb-header] Invalid menu-themes value', error);
        }
    }
    // 2. Fallback → VM
    if (!Array.isArray(menuModeOptions)) {
        return [];
    }
    return menuModeOptions
        .map(option => option?.root?.toggleTheme)
        .filter((theme) => typeof theme === 'string')
        .map(theme => normalizeHeaderTheme(theme));
}

const pnMarketwebHeaderTopRowCss = "pn-button-dropdown .pn-button-dropdown>pn-button>.pn-button{min-height:initial}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}@media screen and (max-width: 767px){.sr-only-mobile{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);white-space:nowrap;border-width:0}}pn-marketweb-header-top-row{display:contents}pn-marketweb-header-top-row .siteheader-row-top{border-bottom:0.1rem solid var(--siteheader-top-row-border-color, #f3f2f2);color:var(--siteheader-top-text-color, var(--siteheader-text-color, inherit));background-color:var(--siteheader-top-row-bg, transparent)}pn-marketweb-header-top-row .siteheader-topleft{display:flex;align-items:center;min-width:0;gap:0.8rem}pn-marketweb-header-top-row .siteheader-topleft pn-marketweb-header-toggle{display:flex;align-items:center;margin-left:1rem}pn-marketweb-header-top-row .siteheader-topleft pn-site-selector{display:none;padding:1rem 0;margin-left:0}pn-marketweb-header-top-row .siteheader-topright{display:flex;flex-direction:row;align-items:center;min-width:0;margin-right:0}pn-marketweb-header-top-row .siteheader-topright>pn-language-selector,pn-marketweb-header-top-row .siteheader-topright>pn-marketweb-siteheader-login,pn-marketweb-header-top-row .siteheader-topright>a,pn-marketweb-header-top-row .siteheader-topright>button,pn-marketweb-header-top-row .siteheader-topright>[slot=header-top-right-start],pn-marketweb-header-top-row .siteheader-topright>[slot=toprightend]{display:none;align-self:center;padding:1rem 0;margin-left:0;color:var(--siteheader-top-link-color, inherit)}pn-marketweb-header-top-row .siteheader-menu-top-search{display:none}@media screen and (min-width: 769px){pn-marketweb-header-top-row .siteheader-topleft pn-site-selector{display:block}pn-marketweb-header-top-row .siteheader-topright>pn-language-selector,pn-marketweb-header-top-row .siteheader-topright>pn-marketweb-siteheader-login,pn-marketweb-header-top-row .siteheader-topright>a,pn-marketweb-header-top-row .siteheader-topright>button,pn-marketweb-header-top-row .siteheader-topright>[slot=header-top-right-start],pn-marketweb-header-top-row .siteheader-topright>[slot=toprightend]{display:block;margin-left:1rem}}@media screen and (min-width: 1024px){pn-marketweb-header-top-row .siteheader-topleft pn-marketweb-header-toggle{margin-left:1.6rem}pn-marketweb-header-top-row .siteheader-topleft pn-site-selector{margin-left:1.3rem}pn-marketweb-header-top-row .siteheader-logocontainer{min-height:3em;position:absolute;left:50%;transform:translateX(-50%)}pn-marketweb-header-top-row .siteheader-topright{margin-right:1.6rem}pn-marketweb-header-top-row .siteheader-topright>pn-language-selector,pn-marketweb-header-top-row .siteheader-topright>pn-marketweb-siteheader-login,pn-marketweb-header-top-row .siteheader-topright>a,pn-marketweb-header-top-row .siteheader-topright>button,pn-marketweb-header-top-row .siteheader-topright>[slot=header-top-right-start],pn-marketweb-header-top-row .siteheader-topright>[slot=toprightend]{margin-left:1.6rem}}";
const PnMarketwebHeaderTopRowStyle0 = pnMarketwebHeaderTopRowCss;

const PnMarketwebHeaderTopRow = /*@__PURE__*/ proxyCustomElement(class PnMarketwebHeaderTopRow extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.vm = undefined;
        this.i18n = undefined;
        this.language = undefined;
        this.siteid = undefined;
        this.endpoint = undefined;
        this.environment = undefined;
        this.userToken = undefined;
        this.userFullname = undefined;
        this.userLoggedin = undefined;
        this.hideSiteSelector = undefined;
        this.hideLanguageSelector = undefined;
        this.hideSearch = undefined;
        this.hideLogin = undefined;
        this.showProfileSelection = undefined;
        this.showUnifiedLogin = undefined;
        this.spaMode = undefined;
        this.checkUserLoggedInStateInterval = undefined;
        this.useMarketwebLogin = undefined;
        this.activeMenuMode = undefined;
        this.navigateOnMenuToggle = undefined;
        this.theme = undefined;
        this.logoUrl = undefined;
        this.menuToggleChangeHandler = undefined;
        this.adjustSiteSelectorUrl = undefined;
    }
    render() {
        const appearance = getAppearanceForTheme(this.theme);
        return (h("div", { key: '6dae77d3315a7697c3f75e310cef8632f277a08f', class: "siteheader-row siteheader-row-top" }, h("div", { key: 'b3eb662b1f9057ed750e585a31e2b06c05f5c925', class: "siteheader-topleft" }, h("slot", { key: 'ff34efaa83b0429de351e704eb04a31fd9f5259a', name: "header-top-left" }), renderHeaderSiteSelector({
            vm: this.vm,
            hideSiteSelector: this.hideSiteSelector,
            language: this.language,
            buttonText: this.vm.siteSelector?.currentSiteTitle ?? 'postnord',
            appearance,
            adjustSiteSelectorUrl: this.adjustSiteSelectorUrl,
        }), renderHeaderMenuSwitcher({
            vm: this.vm,
            activeMenuMode: this.activeMenuMode,
            navigateOnMenuToggle: this.navigateOnMenuToggle,
            onMenuToggleChange: this.menuToggleChangeHandler,
        })), renderHeaderLogo({
            homePageLink: this.logoUrl, //this.vm.homePageLink,
            homeLabel: this.i18n.home,
        }), h("div", { key: '6efe812bcda3ef96ab6a06d7aa8c7a41150a509b', class: "siteheader-topright" }, h("slot", { key: '5b8834f095b01c52bab5f6134ebf9d26f048cfc1', name: "header-top-right-start" }), renderHeaderLogin({
            vm: this.vm,
            hideLogin: this.hideLogin,
            userToken: this.userToken,
            userFullname: this.userFullname,
            userLoggedin: this.userLoggedin,
            endpoint: this.endpoint,
            environment: this.environment,
            i18n: this.i18n,
            showProfileSelection: this.showProfileSelection,
            showUnifiedLogin: this.showUnifiedLogin,
            checkUserLoggedInStateInterval: this.checkUserLoggedInStateInterval,
            useMarketwebLogin: this.useMarketwebLogin,
            appearance
        }), renderHeaderLanguageSelector({
            vm: this.vm,
            hideLanguageSelector: this.hideLanguageSelector,
            language: this.language,
            spaMode: this.spaMode,
            appearance
        }), h("slot", { key: '76c5fdb2fc354c09532d23bbd01063460006795c', name: "toprightend" }), h("div", { key: '44ec76b8051220fc7b56115247c431e7533c8d0f', class: "siteheader-menu-top-search" }, h("pn-marketweb-siteheader-search", { key: '2fe35c9ec19f6f19a81c06aa15f6b9423bf1a5fb', language: this.language, siteid: this.siteid, search: this.vm.search, "hide-search": this.hideSearch, i18n: this.i18n, icononly: true })))));
    }
    static get style() { return PnMarketwebHeaderTopRowStyle0; }
}, [4, "pn-marketweb-header-top-row", {
        "vm": [16],
        "i18n": [16],
        "language": [1],
        "siteid": [1],
        "endpoint": [1],
        "environment": [1],
        "userToken": [1, "user-token"],
        "userFullname": [1, "user-fullname"],
        "userLoggedin": [4, "user-loggedin"],
        "hideSiteSelector": [4, "hide-site-selector"],
        "hideLanguageSelector": [4, "hide-language-selector"],
        "hideSearch": [4, "hide-search"],
        "hideLogin": [4, "hide-login"],
        "showProfileSelection": [4, "show-profile-selection"],
        "showUnifiedLogin": [4, "show-unified-login"],
        "spaMode": [4, "spa-mode"],
        "checkUserLoggedInStateInterval": [2, "check-user-logged-in-state-interval"],
        "useMarketwebLogin": [4, "use-marketweb-login"],
        "activeMenuMode": [2, "active-menu-mode"],
        "navigateOnMenuToggle": [4, "navigate-on-menu-toggle"],
        "theme": [1],
        "logoUrl": [1, "logo-url"],
        "menuToggleChangeHandler": [16],
        "adjustSiteSelectorUrl": [16]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["pn-marketweb-header-top-row", "pn-language-selector", "pn-language-selector-option", "pn-marketweb-header-toggle", "pn-marketweb-siteheader-login", "pn-marketweb-siteheader-login-button", "pn-marketweb-siteheader-login-linklist", "pn-marketweb-siteheader-login-links", "pn-marketweb-siteheader-login-profileselection", "pn-marketweb-siteheader-search", "pn-marketweb-siteheader-unified-login", "pn-site-selector", "pn-site-selector-item"];
    components.forEach(tagName => { switch (tagName) {
        case "pn-marketweb-header-top-row":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, PnMarketwebHeaderTopRow);
            }
            break;
        case "pn-language-selector":
            if (!customElements.get(tagName)) {
                defineCustomElement$c();
            }
            break;
        case "pn-language-selector-option":
            if (!customElements.get(tagName)) {
                defineCustomElement$b();
            }
            break;
        case "pn-marketweb-header-toggle":
            if (!customElements.get(tagName)) {
                defineCustomElement$a();
            }
            break;
        case "pn-marketweb-siteheader-login":
            if (!customElements.get(tagName)) {
                defineCustomElement$9();
            }
            break;
        case "pn-marketweb-siteheader-login-button":
            if (!customElements.get(tagName)) {
                defineCustomElement$8();
            }
            break;
        case "pn-marketweb-siteheader-login-linklist":
            if (!customElements.get(tagName)) {
                defineCustomElement$7();
            }
            break;
        case "pn-marketweb-siteheader-login-links":
            if (!customElements.get(tagName)) {
                defineCustomElement$6();
            }
            break;
        case "pn-marketweb-siteheader-login-profileselection":
            if (!customElements.get(tagName)) {
                defineCustomElement$5();
            }
            break;
        case "pn-marketweb-siteheader-search":
            if (!customElements.get(tagName)) {
                defineCustomElement$4();
            }
            break;
        case "pn-marketweb-siteheader-unified-login":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "pn-site-selector":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "pn-site-selector-item":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { PnMarketwebHeaderTopRow as P, defineCustomElement as d, resolveHeaderMenuThemes as r };

//# sourceMappingURL=pn-marketweb-header-top-row2.js.map