import { h, Host } from "@stencil/core";
export class PnBonusProgressbarLevel {
    constructor() {
        this.current = false;
        this.value = 0;
        this.bonuspercentage = '';
        this.visualpercentage = 0;
        this.percentage = 0;
        this.max = 0;
        this.min = 0;
        this.currency = '';
    }
    hostElement;
    componentWillLoad() {
        this.max = parseInt(this.hostElement.parentElement.parentElement.getAttribute('max'), 10);
        this.min = parseInt(this.hostElement.parentElement.parentElement.getAttribute('min'), 10);
        this.currency = this.hostElement.parentElement.parentElement.getAttribute('currency');
        this.percentage = (this.value / this.max) * 100;
        if (this.visualpercentage > 0) {
            // Visual percentage has been overriden
            return;
        }
        this.visualpercentage = this.value === 0 ? 0 : ((this.value - this.min) / (this.max - this.min)) * 100;
    }
    formatValue() {
        return `${this.value.toLocaleString('sv-SE', { maximumFractionDigits: 0 })} ${this.currency}`;
    }
    render() {
        return (h(Host, { key: '00b80f6a445e99d2ba395fcef54e4138c4485d53', style: { left: `${this.visualpercentage}%` } }, h("div", { key: '4a04a5b11d281fb92b94ea0dfb423df01a59b1f4', class: "progressbar-level-percentage" }, this.bonuspercentage), h("div", { key: 'de57ec39c15545fb1e854f9c2a9540c49885676e', class: "progressbar-level-value" }, this.formatValue())));
    }
    static get is() { return "pn-bonus-progressbar-level"; }
    static get originalStyleUrls() {
        return {
            "$": ["pn-bonus-progressbar-level.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pn-bonus-progressbar-level.css"]
        };
    }
    static get properties() {
        return {
            "current": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "current",
                "reflect": true,
                "defaultValue": "false"
            },
            "value": {
                "type": "number",
                "mutable": true,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "value",
                "reflect": true,
                "defaultValue": "0"
            },
            "bonuspercentage": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "bonuspercentage",
                "reflect": true,
                "defaultValue": "''"
            },
            "visualpercentage": {
                "type": "number",
                "mutable": true,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "attribute": "visualpercentage",
                "reflect": true,
                "defaultValue": "0"
            }
        };
    }
    static get states() {
        return {
            "percentage": {},
            "max": {},
            "min": {},
            "currency": {}
        };
    }
    static get elementRef() { return "hostElement"; }
}
//# sourceMappingURL=pn-bonus-progressbar-level.js.map
