import { h } from "@stencil/core";
import NewsTicker from "@ecl/news-ticker";
export class EclNewsTicker {
    constructor() {
        this.noScript = false;
    }
    getClass() {
        return [
            `ecl-news-ticker`,
            this.styleClass
        ].join(' ');
    }
    componentWillLoad() {
        var _a;
        this.theme =
            (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    componentDidLoad() {
        const counterMax = this.el.querySelector('.ecl-news-ticker__counter--max');
        const countMax = this.el.querySelectorAll('.ecl-news-ticker__slide').length;
        counterMax.innerHTML = countMax;
        if (this.el.querySelector('.ecl-news-ticker__slides')) {
            // Clean the html so that the script finds what it expects.
            const slides = this.el.querySelectorAll('.ecl-news-ticker__slide');
            this.el.querySelector('.ecl-news-ticker__slides').innerHTML = '';
            this.el.querySelector('.ecl-news-ticker__slides').append(...slides);
        }
        if (this.el.querySelector('.ecl-news-ticker__controls')) {
            const controls = this.el.querySelectorAll('.ecl-news-ticker__actions button');
            const counter = this.el.querySelectorAll('.ecl-news-ticker__counter');
            this.el.querySelector('.ecl-news-ticker__actions').innerHTML = '';
            this.el.querySelector('.ecl-news-ticker__actions').append(...controls);
            this.el.querySelector('.ecl-news-ticker__controls').append(...counter);
        }
        ;
        window.ECL = window.ECL || {};
        ECL.NewsTicker = NewsTicker;
        const newsTicker = new NewsTicker(this.el.firstElementChild, { playSelector: '.ecl-news-ticker__play',
            pauseSelector: '.ecl-news-ticker__pause',
            prevSelector: '.ecl-news-ticker__prev',
            nextSelector: '.ecl-news-ticker__next',
        });
        newsTicker.init();
    }
    render() {
        return (h("div", { key: '40d35765c8677d818de86f841ca4d929ebc78167', class: this.getClass() }, h("div", { key: 'a44fb4ef9b82ce5bc720d4f7f6bbda4675442af6', class: "ecl-news-ticker__container" }, h("div", { key: '9cff876daa871e77ae811963fb2a6910c5eeddb4', class: "ecl-news-ticker__content" }, h("ul", { key: 'cabf7dd87bc349a247e035cfdfd5b5881349a3ba', class: "ecl-news-ticker__slides" }, h("slot", { key: 'd495e27e1c7d72bc387fef41202bb339109659ec' })))), h("div", { key: '6ed293b7367f0c74564f082036acb7283f4ebe54', class: "ecl-news-ticker__controls" }, h("div", { key: 'e053c76a984e0a0fae5324a4d49ec2850f705d53', class: "ecl-news-ticker__actions" }, h("ecl-button", { key: 'a822a286485fb77d8a26859679a713767a663f50', theme: this.theme, styleClass: `ecl-news-ticker__prev sc-ecl-news-ticker-${this.theme}`, "data-ecl-news-ticker-prev": true, hideLabel: true, type: "button", variant: "tertiary" }, h("ecl-icon", { key: 'ffe21fe5cbae3d2276776ca0e6c4ac869da1068d', styleClass: `sc-ecl-news-ticker-${this.theme}`, slot: "icon-after", icon: "corner-arrow", size: "l", rotate: "270", theme: this.theme }), this.srPrev), h("ecl-button", { key: '518910b1d6fb8e33a8c467519b87ab54be44e0ff', theme: this.theme, styleClass: `ecl-news-ticker__play sc-ecl-news-ticker-${this.theme}`, "data-ecl-news-ticker-play": true, type: "button", hideLabel: true, variant: "tertiary" }, h("ecl-icon", { key: 'bb1a7849630e1c2882d975780f85e0bdf387855e', styleClass: `ecl-news-ticker__icon-active sc-ecl-news-ticker-${this.theme}`, slot: "icon-after", icon: "play-outline", size: "l", theme: this.theme }), this.srPlay), h("ecl-button", { key: '57ff335ddea868b266362a67676fb3f4f24beaea', variant: "tertiary", theme: this.theme, styleClass: `ecl-news-ticker__pause sc-ecl-news-ticker-${this.theme}`, "data-ecl-news-ticker-pause": true, hideLabel: true, type: "button" }, h("ecl-icon", { key: 'a975f44ad884f6164309453090f90c6f5eb147ea', styleClass: `ecl-news-ticker__icon-active sc-ecl-news-ticker-${this.theme}`, slot: "icon-after", icon: "pause-outline", size: "l", theme: this.theme }), this.srPause), h("ecl-button", { key: '9f260b206a0e7b4e3655db0de7588b6fe389f80b', theme: this.theme, styleClass: `ecl-news-ticker__next sc-ecl-news-ticker-${this.theme}`, "data-ecl-news-ticker-next": true, type: "button", variant: "tertiary", hideLabel: true }, h("ecl-icon", { key: '5ac21ad325e399b6c3ddd91371f3cffee394fb5d', styleClass: `sc-ecl-news-ticker-${this.theme}`, slot: "icon-after", icon: "corner-arrow", size: "l", rotate: "90", theme: this.theme }), this.srNext)), h("div", { key: '32cfde4deb62b7b2d96c11323c45e7e4c0e73f4d', class: "ecl-news-ticker__counter" }, h("span", { key: '30c68d583c5ce74094e5dac6a536dc9b1ab6ba16', class: "ecl-news-ticker__counter--current" }, "1"), ` ${this.counterLabel} `, h("span", { key: '45be6ce8f0d9e632afe1e079fdebe7839b4f9232', class: "ecl-news-ticker__counter--max" })))));
    }
    static get is() { return "ecl-news-ticker"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-news-ticker-ec.css"],
            "eu": ["./build/styles/ecl-news-ticker-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-news-ticker-ec.css"],
            "eu": ["build/styles/ecl-news-ticker-eu.css"]
        };
    }
    static get assetsDirs() { return ["build"]; }
    static get properties() {
        return {
            "theme": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "theme"
            },
            "styleClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "style-class"
            },
            "counterLabel": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "counter-label"
            },
            "srNext": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sr-next"
            },
            "srPrev": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sr-prev"
            },
            "srPause": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sr-pause"
            },
            "srPlay": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sr-play"
            },
            "noScript": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "no-script",
                "defaultValue": "false"
            }
        };
    }
    static get elementRef() { return "el"; }
}
