import { h } from "@stencil/core";
export class Download {
    /** Type of file to download. */
    tokens = "css";
    render() {
        const fileMap = {
            css: "https://raw.githubusercontent.com/Infineon/public-assets/main/ifx-tokens/css-variables.css",
            scss: "https://raw.githubusercontent.com/Infineon/public-assets/main/ifx-tokens/scss-variables.scss",
            json: "https://raw.githubusercontent.com/Infineon/public-assets/main/ifx-echarts-theme/dds-echarts-theme.json",
            js: "https://raw.githubusercontent.com/Infineon/public-assets/main/ifx-echarts-theme/dds-echarts-theme.js",
        };
        const fileUrl = fileMap[this.tokens];
        const fileName = this.tokens === "json" || this.tokens === "js"
            ? `dds-echarts-theme.${this.tokens}`
            : `infineon-tokens.${this.tokens}`;
        return (h("ifx-link", { key: 'a9fffebdef92640797f0ad864ccc5ead2756ce32', onClick: (e) => {
                e.preventDefault();
                fetch(fileUrl)
                    .then((res) => res.blob())
                    .then((blob) => {
                    const link = document.createElement("a");
                    link.href = URL.createObjectURL(blob);
                    link.download = fileName;
                    link.click();
                });
            }, href: fileUrl, download: fileName, class: "download__wrapper", size: "m", variant: "bold" }, h("slot", { key: 'a58203ac50f21518b2f9b0f5c54b84c9ae454188' })));
    }
    static get is() { return "ifx-download"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["./download.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["download.css"]
        };
    }
    static get properties() {
        return {
            "tokens": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "\"css\" | \"scss\" | \"json\" | \"js\"",
                    "resolved": "\"css\" | \"js\" | \"json\" | \"scss\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Type of file to download."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tokens",
                "defaultValue": "\"css\""
            }
        };
    }
}
