import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { EventEmitter, Component, ViewEncapsulation, Input, Output, NgModule } from '@angular/core';
import { BigNumber } from 'bignumber.js';
import * as i2 from '@seniorsistemas/angular-components/tooltip';
import { TooltipModule } from '@seniorsistemas/angular-components/tooltip';

class StatsCardComponent {
    static nextId = 0;
    id = `s-stats-card-${StatsCardComponent.nextId++}`;
    label;
    alwaysWithBorder = false;
    lightVersion = false;
    lightMode = true;
    iconClass = 'fa fa-bar-chart';
    color = '#339966';
    animateNumbers = true;
    clickable = false;
    tooltip = '';
    clicked = new EventEmitter();
    displayValue;
    _ANIMATION_DURATION_MS = 200;
    _STEP_DURATION_MS = 20;
    _previousValue = '0';
    _intervalId;
    _value = '0';
    get value() {
        return this._value;
    }
    set value(value) {
        this._previousValue = this._value;
        this._value = String(value);
        if (this.animateNumbers)
            this._updateDisplayValue();
        else
            this.displayValue = this.value;
    }
    replaceNumericPositions(value, newValue) {
        const rawValue = value.replace(/[^\d]/g, '');
        const newValueString = newValue ? newValue.toString() : '';
        const formattedNewValue = newValueString
            .toString()
            .replace(/\D/g, '')
            .padStart(rawValue.length, '0');
        let newValueIndex = 0;
        return value
            .split('')
            .map((char) => {
            const number = Number(char);
            if (number || char === '0')
                return formattedNewValue[newValueIndex++];
            return char;
        })
            .join('');
    }
    _updateDisplayValue() {
        const animationDuration = new BigNumber(this._ANIMATION_DURATION_MS);
        const stepDuration = new BigNumber(this._STEP_DURATION_MS);
        const animationCount = animationDuration.dividedBy(stepDuration);
        const previousRawValue = new BigNumber(this._previousValue.replace(/\D/g, ''));
        const rawValue = new BigNumber(this.value.replace(/\D/g, ''));
        const incrementValue = rawValue
            .minus(previousRawValue)
            .absoluteValue()
            .dividedBy(animationCount);
        const incremental = previousRawValue.isLessThan(rawValue);
        clearInterval(this._intervalId);
        this.displayValue = this.replaceNumericPositions(this.value);
        let counter = previousRawValue;
        this._intervalId = setInterval(() => {
            if (incremental && counter.isLessThan(rawValue)) {
                if (this.displayValue) {
                    this.displayValue = this.replaceNumericPositions(this.displayValue, counter);
                }
                counter = counter.plus(incrementValue);
            }
            else if (!incremental && counter.isGreaterThan(rawValue)) {
                if (this.displayValue) {
                    this.displayValue = this.replaceNumericPositions(this.displayValue, counter);
                }
                counter = counter.minus(incrementValue);
            }
            else {
                this.displayValue = this.value;
                clearInterval(this._intervalId);
            }
        }, this._STEP_DURATION_MS);
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StatsCardComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: StatsCardComponent, selector: "s-stats-card", inputs: { id: "id", label: "label", alwaysWithBorder: "alwaysWithBorder", lightVersion: "lightVersion", lightMode: "lightMode", iconClass: "iconClass", color: "color", animateNumbers: "animateNumbers", clickable: "clickable", tooltip: "tooltip", value: "value" }, outputs: { clicked: "clicked" }, ngImport: i0, template: "<div\n    [id]=\"id\"\n    class=\"s-stats-card\"\n    [ngClass]=\"{\n        's-stats-card--always-border': alwaysWithBorder,\n        's-stats-card--light': lightMode,\n        's-stats-card--color': !lightMode,\n        's-stats-card--light-version': lightVersion,\n        's-stats-card--clickable': clickable,\n    }\"\n    (click)=\"clickable && clicked.next($event)\"\n>\n    <div\n        [id]=\"id + '-background'\"\n        class=\"s-stats-card-background\"\n        [ngStyle]=\"{ 'background-color': (!lightMode && color) || '' }\"\n    ></div>\n    <div\n        [id]=\"id + '-overlay'\"\n        class=\"s-stats-card-overlay\"\n    ></div>\n\n    <div\n        [id]=\"id + '-info-container'\"\n        class=\"s-stats-card-info-container\"\n    >\n        <div class=\"s-stats-card-info-inner-container\">\n            <div\n                [id]=\"id + '-icon-container'\"\n                class=\"s-stats-card-icon-container\"\n                [ngStyle]=\"{ 'background-color': (lightMode && color) || '' }\"\n            >\n                <span\n                    [id]=\"id + '-icon'\"\n                    [class]=\"iconClass\"\n                    [ngClass]=\"{ 's-stats-card-icon': true }\"\n                    [ngStyle]=\"{ color: (!lightMode && color) || '' }\"\n                    aria-hidden=\"true\"\n                ></span>\n            </div>\n\n            <div\n                [id]=\"id + '-text-container'\"\n                class=\"s-stats-card-text-container\"\n            >\n                <h4\n                    [id]=\"id + '-label'\"\n                    class=\"s-stats-card-label\"\n                    [sTooltip]=\"label\"\n                >\n                    {{ label }}\n                </h4>\n                <span\n                    [id]=\"id + '-value'\"\n                    class=\"s-stats-card-value\"\n                    [sTooltip]=\"displayValue\"\n                >\n                    {{ displayValue }}\n                </span>\n            </div>\n        </div>\n        <div class=\"s-stats-card-content-inner-container\">\n            <div\n                #content\n                class=\"s-stats-card-content-container\"\n            >\n                <ng-content></ng-content>\n            </div>\n            @if (content.children.length) {\n                <div class=\"s-stats-card-content-separator\"></div>\n            }\n        </div>\n        @if (tooltip) {\n            <span\n                class=\"s-status-card-tooltip\"\n                [sTooltip]=\"tooltip\"\n            >\n                <i class=\"fa fa-info-circle s-status-card-tooltip-icon\"></i>\n            </span>\n        }\n    </div>\n</div>\n", styles: ["s-stats-card{display:block;height:auto;position:relative}s-stats-card .s-stats-card{border:1px solid transparent;min-width:120px;overflow:hidden;position:relative}s-stats-card .s-stats-card .s-stats-card-overlay,s-stats-card .s-stats-card .s-stats-card-background{height:calc(100% - 2px);left:1px;position:absolute;top:1px;width:calc(100% - 2px)}s-stats-card .s-stats-card .s-stats-card-background{background-color:#fff}s-stats-card .s-stats-card .s-stats-card-overlay{background-color:#000;opacity:0;transition:opacity .2s ease-out}s-stats-card .s-stats-card .s-stats-card-info-container{overflow:auto;padding:15px;position:relative}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container{overflow:hidden;position:relative}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container{float:left;font-size:24px;height:50px;line-height:50px;text-align:center;transition:width .2s ease-out;width:50px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container{align-items:flex-start;color:#fff;display:flex;flex-direction:column;float:left;height:50px;justify-content:center;max-width:calc(100% - 65px);padding-left:15px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label{font-weight:400;width:100%}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{display:inline-block;font-size:20px;font-weight:700;width:100%}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container{display:flex;flex-direction:column}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container .s-stats-card-content-separator{border-top:1px solid #ccc;margin:15px 0;order:1}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container .s-stats-card-content-container{order:2}s-stats-card .s-stats-card .s-stats-card-info-container .s-status-card-tooltip{font-size:1rem;line-height:0;margin:.3rem;position:absolute;right:0;top:0}s-stats-card .s-stats-card .s-stats-card-info-container .s-status-card-tooltip .s-status-card-tooltip-icon{color:#fff}s-stats-card .s-stats-card.s-stats-card--color .s-stats-card-icon-container{background-color:#fff}s-stats-card .s-stats-card.s-stats-card--light *{color:#333}s-stats-card .s-stats-card.s-stats-card--light *.s-stats-card-icon{color:#fff}s-stats-card .s-stats-card.s-stats-card--light *.s-stats-card-label{color:#999}s-stats-card .s-stats-card.s-stats-card--light * .s-status-card-tooltip .s-status-card-tooltip-icon{color:#999}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-icon-container{height:100%;left:0;position:absolute;right:0;width:10px}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-icon-container .s-stats-card-icon{display:none}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-text-container{height:auto;max-width:calc(100% - 25px);padding-left:25px}s-stats-card .s-stats-card.s-stats-card--clickable{cursor:pointer}s-stats-card .s-stats-card.s-stats-card--clickable:hover .s-stats-card-overlay{opacity:.2}s-stats-card .s-stats-card.s-stats-card--clickable.s-stats-card--light:hover .s-stats-card-overlay{opacity:.08}s-stats-card .s-stats-card.s-stats-card--light{border-color:#ccc}p-panel .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),s-panel .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),.ui-dialog-content .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),.s-sidebar-content .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border){border-color:transparent}@media (max-width: 767px){s-stats-card .s-stats-card{height:auto}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container{height:100%;left:0;position:absolute;right:0;width:10px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container .s-stats-card-icon{display:none}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container{height:auto;max-width:calc(100% - 25px);padding-left:25px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{overflow:visible;white-space:normal;word-break:break-all}}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StatsCardComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-stats-card', encapsulation: ViewEncapsulation.None, template: "<div\n    [id]=\"id\"\n    class=\"s-stats-card\"\n    [ngClass]=\"{\n        's-stats-card--always-border': alwaysWithBorder,\n        's-stats-card--light': lightMode,\n        's-stats-card--color': !lightMode,\n        's-stats-card--light-version': lightVersion,\n        's-stats-card--clickable': clickable,\n    }\"\n    (click)=\"clickable && clicked.next($event)\"\n>\n    <div\n        [id]=\"id + '-background'\"\n        class=\"s-stats-card-background\"\n        [ngStyle]=\"{ 'background-color': (!lightMode && color) || '' }\"\n    ></div>\n    <div\n        [id]=\"id + '-overlay'\"\n        class=\"s-stats-card-overlay\"\n    ></div>\n\n    <div\n        [id]=\"id + '-info-container'\"\n        class=\"s-stats-card-info-container\"\n    >\n        <div class=\"s-stats-card-info-inner-container\">\n            <div\n                [id]=\"id + '-icon-container'\"\n                class=\"s-stats-card-icon-container\"\n                [ngStyle]=\"{ 'background-color': (lightMode && color) || '' }\"\n            >\n                <span\n                    [id]=\"id + '-icon'\"\n                    [class]=\"iconClass\"\n                    [ngClass]=\"{ 's-stats-card-icon': true }\"\n                    [ngStyle]=\"{ color: (!lightMode && color) || '' }\"\n                    aria-hidden=\"true\"\n                ></span>\n            </div>\n\n            <div\n                [id]=\"id + '-text-container'\"\n                class=\"s-stats-card-text-container\"\n            >\n                <h4\n                    [id]=\"id + '-label'\"\n                    class=\"s-stats-card-label\"\n                    [sTooltip]=\"label\"\n                >\n                    {{ label }}\n                </h4>\n                <span\n                    [id]=\"id + '-value'\"\n                    class=\"s-stats-card-value\"\n                    [sTooltip]=\"displayValue\"\n                >\n                    {{ displayValue }}\n                </span>\n            </div>\n        </div>\n        <div class=\"s-stats-card-content-inner-container\">\n            <div\n                #content\n                class=\"s-stats-card-content-container\"\n            >\n                <ng-content></ng-content>\n            </div>\n            @if (content.children.length) {\n                <div class=\"s-stats-card-content-separator\"></div>\n            }\n        </div>\n        @if (tooltip) {\n            <span\n                class=\"s-status-card-tooltip\"\n                [sTooltip]=\"tooltip\"\n            >\n                <i class=\"fa fa-info-circle s-status-card-tooltip-icon\"></i>\n            </span>\n        }\n    </div>\n</div>\n", styles: ["s-stats-card{display:block;height:auto;position:relative}s-stats-card .s-stats-card{border:1px solid transparent;min-width:120px;overflow:hidden;position:relative}s-stats-card .s-stats-card .s-stats-card-overlay,s-stats-card .s-stats-card .s-stats-card-background{height:calc(100% - 2px);left:1px;position:absolute;top:1px;width:calc(100% - 2px)}s-stats-card .s-stats-card .s-stats-card-background{background-color:#fff}s-stats-card .s-stats-card .s-stats-card-overlay{background-color:#000;opacity:0;transition:opacity .2s ease-out}s-stats-card .s-stats-card .s-stats-card-info-container{overflow:auto;padding:15px;position:relative}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container{overflow:hidden;position:relative}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container{float:left;font-size:24px;height:50px;line-height:50px;text-align:center;transition:width .2s ease-out;width:50px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container{align-items:flex-start;color:#fff;display:flex;flex-direction:column;float:left;height:50px;justify-content:center;max-width:calc(100% - 65px);padding-left:15px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label{font-weight:400;width:100%}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{display:inline-block;font-size:20px;font-weight:700;width:100%}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container{display:flex;flex-direction:column}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container .s-stats-card-content-separator{border-top:1px solid #ccc;margin:15px 0;order:1}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-content-inner-container .s-stats-card-content-container{order:2}s-stats-card .s-stats-card .s-stats-card-info-container .s-status-card-tooltip{font-size:1rem;line-height:0;margin:.3rem;position:absolute;right:0;top:0}s-stats-card .s-stats-card .s-stats-card-info-container .s-status-card-tooltip .s-status-card-tooltip-icon{color:#fff}s-stats-card .s-stats-card.s-stats-card--color .s-stats-card-icon-container{background-color:#fff}s-stats-card .s-stats-card.s-stats-card--light *{color:#333}s-stats-card .s-stats-card.s-stats-card--light *.s-stats-card-icon{color:#fff}s-stats-card .s-stats-card.s-stats-card--light *.s-stats-card-label{color:#999}s-stats-card .s-stats-card.s-stats-card--light * .s-status-card-tooltip .s-status-card-tooltip-icon{color:#999}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-icon-container{height:100%;left:0;position:absolute;right:0;width:10px}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-icon-container .s-stats-card-icon{display:none}s-stats-card .s-stats-card.s-stats-card--light-version .s-stats-card-info-inner-container .s-stats-card-text-container{height:auto;max-width:calc(100% - 25px);padding-left:25px}s-stats-card .s-stats-card.s-stats-card--clickable{cursor:pointer}s-stats-card .s-stats-card.s-stats-card--clickable:hover .s-stats-card-overlay{opacity:.2}s-stats-card .s-stats-card.s-stats-card--clickable.s-stats-card--light:hover .s-stats-card-overlay{opacity:.08}s-stats-card .s-stats-card.s-stats-card--light{border-color:#ccc}p-panel .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),s-panel .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),.ui-dialog-content .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border),.s-sidebar-content .s-stats-card.s-stats-card--light:not(.s-stats-card--always-border){border-color:transparent}@media (max-width: 767px){s-stats-card .s-stats-card{height:auto}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container{height:100%;left:0;position:absolute;right:0;width:10px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-icon-container .s-stats-card-icon{display:none}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container{height:auto;max-width:calc(100% - 25px);padding-left:25px}s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-label,s-stats-card .s-stats-card .s-stats-card-info-container .s-stats-card-info-inner-container .s-stats-card-text-container .s-stats-card-value{overflow:visible;white-space:normal;word-break:break-all}}\n"] }]
        }], propDecorators: { id: [{
                type: Input
            }], label: [{
                type: Input,
                args: [{ required: true }]
            }], alwaysWithBorder: [{
                type: Input
            }], lightVersion: [{
                type: Input
            }], lightMode: [{
                type: Input
            }], iconClass: [{
                type: Input
            }], color: [{
                type: Input
            }], animateNumbers: [{
                type: Input
            }], clickable: [{
                type: Input
            }], tooltip: [{
                type: Input
            }], clicked: [{
                type: Output
            }], value: [{
                type: Input
            }] } });

class StatsCardModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StatsCardModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: StatsCardModule, declarations: [StatsCardComponent], imports: [CommonModule, TooltipModule], exports: [StatsCardComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StatsCardModule, imports: [CommonModule, TooltipModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: StatsCardModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, TooltipModule],
                    declarations: [StatsCardComponent],
                    exports: [StatsCardComponent],
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { StatsCardComponent, StatsCardModule };
//# sourceMappingURL=seniorsistemas-angular-components-stats-card.mjs.map
