import { h } from "@stencil/core";
export class EclTag {
    constructor() {
        this.external = false;
        this.variant = 'link';
        this.url = '';
        this.noWrap = false;
        this.toBeRemoved = false;
    }
    getClass() {
        const styleClasses = [
            `ecl-tag`,
            `ecl-tag--${this.variant}`,
            this.styleClass
        ];
        if (this.colorMode) {
            styleClasses.push(`ecl-color-mode--${this.colorMode}`);
        }
        if (this.noWrap) {
            styleClasses.push('ecl-tag--nowrap');
        }
        return styleClasses.join(' ');
    }
    getTag(variant) {
        switch (variant) {
            case 'link':
                return 'a';
            case 'removable':
                return 'button';
            default:
        }
    }
    getExternal() {
        return (h("ecl-icon", { icon: "external", "style-class": `ecl-tag__icon ecl-tag__icon--external sc-ecl-tag-${this.theme}`, size: "2xs" }));
    }
    getRemovable() {
        return (h("span", { class: "ecl-tag__icon", onClick: () => {
                this.toBeRemoved = true;
                this.removeTag.emit(true); // Emit the custom event
            } }, h("ecl-icon", { icon: "close-outline", "style-class": `ecl-tag__icon-close sc-ecl-tag-${this.theme}`, size: "xs" })));
    }
    componentWillLoad() {
        var _a;
        this.theme = (_a = document.documentElement.getAttribute('data-ecl-theme')) !== null && _a !== void 0 ? _a : (this.theme || 'ec');
    }
    render() {
        const Element = this.getTag(this.variant);
        return (h(Element, Object.assign({ key: '296901fb9f5082b40d146abdcbf09b91d5b519e5', class: this.getClass() }, (this.variant === 'link' && { href: this.url }), (this.variant === 'removable' && { type: 'button' })), h("slot", { key: 'bbf5b9b4bbedd390c77456c822333492645926c7' }), this.variant === 'link' && this.external ? this.getExternal() : '', this.variant === 'removable' ? this.getRemovable() : ''));
    }
    static get is() { return "ecl-tag"; }
    static get encapsulation() { return "scoped"; }
    static get originalStyleUrls() {
        return {
            "ec": ["./build/styles/ecl-tag-ec.css"],
            "eu": ["./build/styles/ecl-tag-eu.css"]
        };
    }
    static get styleUrls() {
        return {
            "ec": ["build/styles/ecl-tag-ec.css"],
            "eu": ["build/styles/ecl-tag-eu.css"]
        };
    }
    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"
            },
            "external": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "external",
                "defaultValue": "false"
            },
            "colorMode": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "color-mode"
            },
            "variant": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "variant",
                "defaultValue": "'link'"
            },
            "url": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "url",
                "defaultValue": "''"
            },
            "noWrap": {
                "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-wrap",
                "defaultValue": "false"
            }
        };
    }
    static get states() {
        return {
            "toBeRemoved": {}
        };
    }
    static get events() {
        return [{
                "method": "removeTag",
                "name": "removeTag",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }];
    }
}
