import { h, Host } from "@stencil/core";
import { abbreviate } from "./format";
/**
 * The Badge component can be used to display a notification badge,
 * optionally with a number or a text label.
 *
 * @exampleComponent limel-example-badge
 * @exampleComponent limel-example-badge-number
 * @exampleComponent limel-example-badge-string
 */
export class Badge {
    render() {
        return (h(Host, { key: '7baae3b39c121c8cb873bcae7a7e4820155fda40', title: this.labelIsLarge() ? this.label : '', class: {
                'has-large-label': this.labelIsLarge(),
            } }, h("span", { key: 'fc9a31d38d71bfde094582bfd8c24eb0a7d19cc1' }, this.renderLabel())));
    }
    renderLabel() {
        if (typeof this.label === 'number') {
            return abbreviate(this.label);
        }
        return this.label;
    }
    labelIsLarge() {
        const largeNumericLabel = 999;
        const largeStringLabel = 6;
        if ((typeof this.label === 'number' &&
            this.label > largeNumericLabel) ||
            (typeof this.label === 'string' &&
                this.label.length > largeStringLabel)) {
            return true;
        }
    }
    static get is() { return "limel-badge"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["badge.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["badge.css"]
        };
    }
    static get properties() {
        return {
            "label": {
                "type": "any",
                "mutable": false,
                "complexType": {
                    "original": "number | string",
                    "resolved": "number | string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Label to display in the badge.\nNumeric labels larger than 999 will be rounded and abbreviated.\nString labels get truncated if their length is longer than\nsix characters."
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "label"
            }
        };
    }
}
