'use strict';

var index = require('./index-DQjemDtV.js');
var tslib_es6 = require('./tslib.es6-DrfCPgT9.js');
var index_esm = require('./index.esm-CKDqUwIC.js');
var bem = require('./bem-p0PWVN8n.js');
var config_decorator = require('./config.decorator-BHeu_GTu.js');
var svg = require('./svg-Bw61tXih.js');
require('./index-BZ67Dcnb.js');
require('./_commonjsHelpers-BJu3ubxk.js');
require('./index-BobQkZjn.js');
require('./index-C413E-IK.js');
require('./index-ifu9fMyU.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) {
        index.registerInstance(this, hostRef);
        this.logoSvgContent = '';
        this.links = [];
        this.socialMediaLinks = [];
        this.language = index.defaultConfig.language;
        this.region = index.defaultConfig.region;
        this.allowedLanguages = index.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 = svg.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) {
        index.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;
            index.rIC(() => {
                index_esm.loadFooterLinks(new index_esm.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;
            index.rIC(() => {
                index_esm.loadSocialMediaLinks(new index_esm.Language(this.language), region).then(links => (this.socialMediaLinks = links));
            });
        }
    }
    /**
     * RENDER
     * ------------------------------------------------------
     */
    render() {
        const block = bem.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 (index.h(index.Host, { key: '04ec38780841ea9902e3f465b8fd4e3561a9092e', class: Object.assign({}, block.class()) }, index.h("footer", { key: 'dc1fa3c156ad78d3d05d3f5d219c81801bca5044', class: Object.assign({}, elInner.class()) }, index.h("div", { key: 'e8f1144c09a1b52fb956bc03438671086e801895', class: Object.assign({}, elInnerWrapper.class()) }, index.h("div", { key: 'b6d1e0c4deed43eec0e0889cc4011cc5465db527', class: Object.assign(Object.assign({ container: true }, elContainer.class()), elHeaderContainer.class()) }, index.h("div", { key: '6102cc926e8542a0a2802b1fa8914b054a9391b4', class: Object.assign({}, elLogo.class()) }, this.logoHref ? (index.h("img", { src: this.logoHref, alt: "Logo" })) : this.logoSvgContent ? (index.h("div", { innerHTML: this.logoSvgContent })) : (index.h("bal-logo", { color: "white" }))), index.h("div", { key: '5cd3a29dd8d40a4704f85635e32bcca1d0af0546', class: Object.assign({}, elLanguage.class()), style: {
                display: this.hideLanguageSelection || this.allowedLanguages.length <= 1 ? 'none' : 'flex',
            } }, index.h("div", { key: '023ba95e77cc80681af23b8a0ed50b49a94b81fd', class: Object.assign({}, elWrapper.class()) }, index.h("bal-icon", { key: '3c5ce093f139a07def8c73fdfbcf6060de8893b3', class: Object.assign({}, elWrapper.element('icon').class()), name: "web", color: "white" }), index.h("select", { key: '7cd8af0cb134b8b8a9733333df37a1c9f909e9fb', class: Object.assign({}, elWrapper.element('select').class()), onChange: event => this.changeLanguage(event.target.value), "data-testid": "bal-footer-language" }, this.allowedLanguages.map(language => (index.h("option", { key: language, value: language, selected: language === this.language }, language.toLocaleUpperCase() + ' - ' + i18nBalFooter[language].name))))))), index.h("div", { key: '017b017c8d5714e5b8568cf10e12a96a468b722e', class: Object.assign({}, elSlot.class()) }, index.h("slot", { key: 'e09a963ac71e749cecfe38751ae330759e626080' })), index.h("div", { key: '993161e25ae9c3fccc18fd7f2b032b74b3120106', class: Object.assign(Object.assign({ container: true }, elContainer.class()), elLinksContainer.class()) }, index.h("div", { key: 'eee88e5f349aebf4d16333462f7e18a029bfe82e', class: Object.assign({}, elSocialMediaLinks.class()), style: {
                display: !this.showSocialMedia ? 'none' : 'flex',
            } }, this.socialMediaLinks.map(link => (index.h("a", { key: link.link, href: link.link, target: "_blank", class: {
                'link': true,
                'is-inverted': true,
            } }, index.h("bal-icon", { name: link.label.toLowerCase() }))))), index.h("div", { key: 'fdd8006cd0d1ec2f6e3fa6ee418705a7d607f9c8', class: Object.assign({}, elLegalLinks.class()), style: { display: this.hideLinks ? 'none' : 'flex' } }, this.links &&
            this.links.map(link => (index.h("a", { key: link.link, href: link.link, target: "_blank", class: {
                    'link': true,
                    'is-light': true,
                } }, link.label)))))))));
    }
    static get watchers() { return {
        "logoSvg": ["logoSvgChanged"]
    }; }
};
tslib_es6.__decorate([
    index.Logger('bal-footer'),
    tslib_es6.__metadata("design:type", Function),
    tslib_es6.__metadata("design:paramtypes", [Function]),
    tslib_es6.__metadata("design:returntype", void 0)
], Footer.prototype, "createLogger", null);
tslib_es6.__decorate([
    config_decorator.ListenToConfig(),
    tslib_es6.__metadata("design:type", Function),
    tslib_es6.__metadata("design:paramtypes", [Object]),
    tslib_es6.__metadata("design:returntype", Promise)
], Footer.prototype, "configChanged", null);
Footer.style = balFooterCss;

exports.bal_footer = Footer;
