import { r as registerInstance, h, H as Host } from './index-BdVwMG9u.js';
import { _ as __decorate, a as __metadata } from './tslib.es6-dfXERft2.js';
import { l as loadFooterLinks, a as loadSocialMediaLinks, L as Language } from './index.esm-Btc0yydR.js';
import { B as BEM } from './bem-ByiN-QjD.js';
import { r as rIC } from './helpers-BNj87EbG.js';
import { L as Logger } from './log-CwssmmaV.js';
import { s as sanitizeSvg } from './svg-DhNz-XmR.js';
import { e as updateBalLanguage } from './config.utils-B7jugjyM.js';
import { d as defaultConfig } from './config.default-RE8-gLMQ.js';
import { L as ListenToConfig } from './config.decorator-3bfyZ-0Y.js';
import './index-zWZxKBfo.js';
import './_commonjsHelpers-BFTU3MAI.js';
import './index-B4k_dH6V.js';
import './index-BU7FUSdu.js';
import './index-D6JOtC1P.js';
import './browser-B1u-Mq75.js';

const i18nBalFooter = {
    en: {
        name: 'English',
    },
    fr: {
        name: 'Français',
    },
    it: {
        name: 'Italiano',
    },
    nl: {
        name: 'Nederlands',
    },
    es: {
        name: 'Español',
    },
    pt: {
        name: 'Português',
    },
    sv: {
        name: 'Svenska',
    },
    fi: {
        name: 'Suomi',
    },
    de: {
        name: 'Deutsch',
    },
    pl: {
        name: 'Polski',
    },
};

const balFooterCss = ":root{--bal-footer-font-family:var(--bal-font-family-text);--bal-footer-background:var(--bal-color-primary);--bal-footer-color:var(--bal-color-text-white);--bal-footer-language-color:var(--bal-color-text-white);--bal-footer-language-color-hover:var(--bal-color-light-blue-2);--bal-footer-language-color-active:var(--bal-color-light-blue-3);--bal-footer-language-background:var(--bal-color-text-white);--bal-footer-language-background-hover:var(--bal-color-light-blue-2);--bal-footer-language-background-active:var(--bal-color-light-blue-3);--bal-footer-logo-image-max-height:64px}.bal-footer{-webkit-touch-callout:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;position:static;-webkit-user-select:auto;-moz-user-select:auto;-ms-user-select:auto;user-select:auto}.bal-footer__slot{color:var(--bal-footer-color)}.bal-footer__inner{position:relative;font-family:var(--bal-footer-font-family);background-color:var(--bal-footer-background);padding-top:var(--bal-space-x-small);padding-bottom:var(--bal-space-large)}@media screen and (min-width: 769px),print{.bal-footer__inner{padding-top:var(--bal-space-large);padding-bottom:var(--bal-space-large)}}@media screen and (min-width: 1024px){.bal-footer__inner{padding-top:var(--bal-space-large);padding-bottom:var(--bal-space-large)}}.bal-footer__inner__wrapper{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;gap:var(--bal-space-large)}@media screen and (min-width: 769px)and (max-width: 1023px){.bal-footer__inner__wrapper{gap:var(--bal-space-medium-tablet)}}@media screen and (max-width: 768px){.bal-footer__inner__wrapper{gap:var(--bal-space-medium-tablet)}}.bal-footer__inner__wrapper__header-container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-direction:row;flex-direction:row}.bal-footer__inner__wrapper__header-container__language{display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-ms-flex-align:center;align-items:center}.bal-footer__inner__wrapper__header-container__language__wrapper{display:-ms-flexbox;display:flex;gap:1rem;cursor:pointer}.bal-footer__inner__wrapper__header-container__language__wrapper svg,.bal-footer__inner__wrapper__header-container__language__wrapper g,.bal-footer__inner__wrapper__header-container__language__wrapper path,.bal-footer__inner__wrapper__header-container__language__wrapper circle{fill:var(--bal-footer-language-background) !important}.bal-footer__inner__wrapper__header-container__language__wrapper select{padding-left:2px;padding-right:2px;background:rgba(0,0,0,0);-webkit-appearance:none;border:none;color:var(--bal-footer-language-color);font-weight:var(--bal-font-weight-bold);font-family:var(--bal-font-family-title);cursor:pointer}.bal-footer__inner__wrapper__header-container__language__wrapper select option{background:var(--bal-color-white) !important;color:var(--bal-color-primary) !important;font-weight:var(--bal-font-weight-bold) !important;font-family:var(--bal-font-family-text) !important}.bal-footer__inner__wrapper__header-container__language__wrapper:hover svg,.bal-footer__inner__wrapper__header-container__language__wrapper:hover g,.bal-footer__inner__wrapper__header-container__language__wrapper:hover path,.bal-footer__inner__wrapper__header-container__language__wrapper:hover circle{fill:var(--bal-footer-language-background-hover) !important}.bal-footer__inner__wrapper__header-container__language__wrapper:hover select{color:var(--bal-footer-language-color-hover)}.bal-footer__inner__wrapper__header-container__language__wrapper:active svg,.bal-footer__inner__wrapper__header-container__language__wrapper:active g,.bal-footer__inner__wrapper__header-container__language__wrapper:active path,.bal-footer__inner__wrapper__header-container__language__wrapper:active circle{fill:var(--bal-footer-language-background-active) !important}.bal-footer__inner__wrapper__header-container__language__wrapper:active select{color:var(--bal-footer-language-color-active)}.bal-footer__inner__wrapper__header-container__logo{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}.bal-footer__inner__wrapper__header-container__logo img{max-height:var(--bal-footer-logo-image-max-height)}.bal-footer__inner__wrapper__header-container__logo div{height:var(--bal-footer-logo-image-max-height);min-width:var(--bal-footer-logo-image-max-height)}.bal-footer__inner__wrapper__links-container{display:-ms-flexbox;display:flex;-ms-flex-pack:justify;justify-content:space-between;-ms-flex-wrap:wrap;flex-wrap:wrap}@media screen and (min-width: 769px),print{.bal-footer__inner__wrapper__links-container{-ms-flex-direction:column;flex-direction:column}}@media screen and (min-width: 1024px){.bal-footer__inner__wrapper__links-container{-ms-flex-direction:row;flex-direction:row}}.bal-footer__inner__wrapper__links-container__legal-links{display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;gap:var(--bal-space-large-desktop)}.bal-footer__inner__wrapper__links-container__legal-links a{font-size:var(--bal-text-size-small) !important}@media screen and (max-width: 768px){.bal-footer__inner__wrapper__links-container__legal-links{-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center;width:100%;gap:var(--bal-space-normal)}}.bal-footer__inner__wrapper__links-container__social-media-links{-ms-flex-align:center;align-items:center;gap:var(--bal-space-large-desktop);padding:var(--bal-space-normal) var(--bal-space-normal) var(--bal-space-normal) 0}@media screen and (min-width: 769px)and (max-width: 1023px){.bal-footer__inner__wrapper__links-container__social-media-links{padding-bottom:var(--bal-space-large)}}@media screen and (max-width: 768px){.bal-footer__inner__wrapper__links-container__social-media-links{padding-bottom:var(--bal-space-large);-ms-flex-pack:center;justify-content:center;width:100%;padding:var(--bal-space-normal) 0 var(--bal-space-normal) 0}}";

const Footer = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.logoSvgContent = '';
        this.links = [];
        this.socialMediaLinks = [];
        this.language = defaultConfig.language;
        this.region = defaultConfig.region;
        this.allowedLanguages = defaultConfig.allowedLanguages;
        /**
         * PUBLIC PROPERTY API
         * ------------------------------------------------------
         */
        /**
         * Image address for the logo.
         */
        this.logoHref = '';
        /**
         * Svg content for the logo.
         */
        this.logoSvg = '';
        /**
         * If `true` the legal Baloise links will be hidden.
         */
        this.hideLinks = false;
        /**
         * If provided, the footer links will be overridden.
         */
        this.overrideLinks = undefined;
        /**
         * If `true` the social media links will be shown.
         */
        this.showSocialMedia = false;
        /**
         * If `true` the language selection will be hidden.
         */
        this.hideLanguageSelection = false;
    }
    createLogger(log) {
        this.log = log;
    }
    logoSvgChanged() {
        this.logoSvgContent = sanitizeSvg(this.logoSvg);
    }
    /**
     * LIFECYCLE
     * ------------------------------------------------------
     */
    connectedCallback() {
        this.updateFooterLinks();
        this.updateSocialMediaLinks();
        this.logoSvgChanged();
    }
    /**
     * LISTENERS
     * ------------------------------------------------------
     */
    /**
     * @internal define config for the component
     */
    async configChanged(state) {
        if (this.language !== state.language || this.region !== state.region) {
            this.language = state.language;
            this.region = state.region;
            this.allowedLanguages = state.allowedLanguages;
            this.updateFooterLinks();
            this.updateSocialMediaLinks();
        }
    }
    /**
     * PRIVATE METHODS
     * ------------------------------------------------------
     */
    changeLanguage(language) {
        updateBalLanguage(language);
    }
    updateFooterLinks() {
        if (this.overrideLinks) {
            this.links = this.overrideLinks;
        }
        else if (!this.hideLinks && (this.region === 'CH' || this.region === 'DE')) {
            // The following footer links only apply to swiss and german applications
            const region = this.region;
            rIC(() => {
                loadFooterLinks(new Language(this.language), region).then(links => (this.links = links));
            });
        }
    }
    updateSocialMediaLinks() {
        if (this.showSocialMedia && (this.region === 'CH' || this.region === 'DE')) {
            // The following footer links only apply to swiss and german applications
            const region = this.region;
            rIC(() => {
                loadSocialMediaLinks(new Language(this.language), region).then(links => (this.socialMediaLinks = links));
            });
        }
    }
    /**
     * RENDER
     * ------------------------------------------------------
     */
    render() {
        const block = BEM.block('footer');
        const elSlot = block.element('slot');
        const elInner = block.element('inner');
        const elInnerWrapper = elInner.element('wrapper');
        const elContainer = elInnerWrapper.element('container');
        const elLinksContainer = elInnerWrapper.element('links-container');
        const elHeaderContainer = elInnerWrapper.element('header-container');
        const elLogo = elHeaderContainer.element('logo');
        const elLanguage = elHeaderContainer.element('language');
        const elWrapper = elLanguage.element('wrapper');
        const elLegalLinks = elLinksContainer.element('legal-links');
        const elSocialMediaLinks = elLinksContainer.element('social-media-links');
        return (h(Host, { key: 'ca5dacc6c906754b6bb466c448be4f6bb5b38dff', class: Object.assign({}, block.class()) }, h("footer", { key: '8d42cfff788350c5e5ae26f86b613fcd5144085d', class: Object.assign({}, elInner.class()) }, h("div", { key: 'a60281af0dcf73da3901cb605b49d35b3bb3e6ed', class: Object.assign({}, elInnerWrapper.class()) }, h("div", { key: '857d35746558b5b0a5ec79562b3f2c0e30037141', class: Object.assign(Object.assign({ container: true }, elContainer.class()), elHeaderContainer.class()) }, h("div", { key: 'c1e5bae12ba5449888156244789fd79dbdc3a388', class: Object.assign({}, elLogo.class()) }, this.logoHref ? (h("img", { src: this.logoHref, alt: "Logo" })) : this.logoSvgContent ? (h("div", { innerHTML: this.logoSvgContent })) : (h("bal-logo", { color: "white" }))), h("div", { key: 'de3b93d01ad75facf4219df8954016095aa143ab', class: Object.assign({}, elLanguage.class()), style: {
                display: this.hideLanguageSelection || this.allowedLanguages.length <= 1 ? 'none' : 'flex',
            } }, h("div", { key: '7be8f0588d5da5e436b72214c67542316d325481', class: Object.assign({}, elWrapper.class()) }, h("bal-icon", { key: '935dfaa39b97f40cd946ce8c8a0a0f421b3876b6', class: Object.assign({}, elWrapper.element('icon').class()), name: "web", color: "white" }), h("select", { key: 'd8408623006a257fa422b0789bc1e021461f1b1e', class: Object.assign({}, elWrapper.element('select').class()), onChange: event => this.changeLanguage(event.target.value), "data-testid": "bal-footer-language" }, this.allowedLanguages.map(language => (h("option", { key: language, value: language, selected: language === this.language }, language.toLocaleUpperCase() + ' - ' + i18nBalFooter[language].name))))))), h("div", { key: '422e8cae4fd1cd625afb3cc81bc7c0cfac99fe65', class: Object.assign({}, elSlot.class()) }, h("slot", { key: 'b7c73e907ffbe0b64eb4608143774bcf7c56ff30' })), h("div", { key: '7bc64923fe79674a26e96f263785abf96dba1af6', class: Object.assign(Object.assign({ container: true }, elContainer.class()), elLinksContainer.class()) }, h("div", { key: '5e5c86e58b3df89978657217ba145555786becfb', class: Object.assign({}, elSocialMediaLinks.class()), style: {
                display: !this.showSocialMedia ? 'none' : 'flex',
            } }, this.socialMediaLinks.map(link => (h("a", { key: link.link, href: link.link, target: "_blank", class: {
                'link': true,
                'is-inverted': true,
            } }, h("bal-icon", { name: link.label.toLowerCase() }))))), h("div", { key: '610e34f952fd08cba92099a213371e45c5f7ebc6', class: Object.assign({}, elLegalLinks.class()), style: { display: this.hideLinks ? 'none' : 'flex' } }, this.links &&
            this.links.map(link => (h("a", { key: link.link, href: link.link, target: "_blank", class: {
                    'link': true,
                    'is-light': true,
                } }, link.label)))))))));
    }
    static get watchers() { return {
        "logoSvg": ["logoSvgChanged"]
    }; }
};
__decorate([
    Logger('bal-footer'),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Function]),
    __metadata("design:returntype", void 0)
], Footer.prototype, "createLogger", null);
__decorate([
    ListenToConfig(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", [Object]),
    __metadata("design:returntype", Promise)
], Footer.prototype, "configChanged", null);
Footer.style = balFooterCss;

export { Footer as bal_footer };
