'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-b499856a.js');

const teliaFooterNavigationCss = ".telia-footer-navigation{color:#e8e8ed;display:block}.telia-footer-navigation__list-container{display:none}@media screen and (min-width: 64em){.telia-footer-navigation__list-container{display:block}}.telia-footer-navigation__list-container .telia-footer-navigation__list-header{font-family:\"TeliaSans\", Helvetica, Arial, \"Lucida Grande\", sans-serif;font-weight:normal;font-size:calc(1.4rem * var(--voca-rem-multiplier));line-height:1.5;margin-bottom:calc(0.8rem * var(--voca-rem-multiplier));margin-top:0;color:rgba(255, 255, 255, 0.6)}.telia-footer-navigation__list-container telia-row{row-gap:calc(4.8rem * var(--voca-rem-multiplier))}.telia-footer-navigation__list-item{margin-bottom:calc(0.8rem * var(--voca-rem-multiplier))}.telia-footer-navigation__list-item:last-of-type{margin-bottom:0}.telia-footer-navigation__list-item telia-style-link a{font-family:\"TeliaSans\", Helvetica, Arial, \"Lucida Grande\", sans-serif;font-weight:normal;font-size:calc(1.6rem * var(--voca-rem-multiplier));line-height:1.5;font-weight:500}.telia-footer-navigation__accordion-container{display:block}@media screen and (min-width: 64em){.telia-footer-navigation__accordion-container{display:none}}";

const TeliaFooterNavigation = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    /**
     * An array of lists of links or a stringified
     * representation of the same.
     */
    this.links = [];
    /** Tracking id is used to identify and count Component usage */
    this.dataTrackingId = 'telia-footer-navigation';
    this.maxRenderedItems = 6;
    this.componentClass = 'telia-footer-navigation';
  }
  getLinks() {
    let data = [];
    if (typeof this.links === 'object') {
      data = this.links;
    }
    else {
      data = JSON.parse(this.links);
    }
    // Print a console warning if number of provided items exceeds our current allowed limit
    if (data.length > this.maxRenderedItems) {
      console.warn(`[VDS:telia-footer-navigation] The amount of "links" provided exceeds out current limit of ${this.maxRenderedItems} items, items above the limit are discarded.`);
    }
    return data.slice(0, this.maxRenderedItems);
  }
  renderLinkList(list) {
    return (index.h("telia-list", null, list.map(link => (index.h("li", { class: `${this.componentClass}__list-item` }, index.h("telia-style-link", { variant: "navigation", "dark-background": true, "disable-visited": true }, index.h("a", { href: link.href }, link.name)))))));
  }
  getListColumnWidth(links = []) {
    if (links.length > 4)
      return 2;
    return 3;
  }
  render() {
    const links = this.getLinks();
    const listColumnWidth = this.getListColumnWidth(links);
    return (index.h("div", { class: this.componentClass, "data-testid": this.dataTestid }, index.h("section", { class: `${this.componentClass}__list-container` }, index.h("telia-row", null, 
    // Limiting rendering to only the first 6 columns
    links.map(list => (index.h("telia-col", { width: listColumnWidth }, index.h("h2", { class: `${this.componentClass}__list-header` }, list.header), this.renderLinkList(list.links)))))), index.h("section", { class: `${this.componentClass}__accordion-container` }, index.h("telia-accordion", { "dark-background": true }, links.map(list => (index.h("telia-accordion-item", { "heading-tag": "h2", heading: list.header, "dark-background": true }, this.renderLinkList(list.links)))))), index.h("telia-vst", { dataTrackingId: this.dataTrackingId })));
  }
};
TeliaFooterNavigation.style = teliaFooterNavigationCss;

exports.telia_footer_navigation = TeliaFooterNavigation;
