import * as i0 from '@angular/core';
import { Component, Input, NgModule } from '@angular/core';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i1 from '@seniorsistemas/angular-components/locale';

class ProgressBarDeterminateComponent {
    localeService;
    value;
    activeColor;
    numberFormatOptions;
    targetValue;
    targetLabel;
    showValue = true;
    numberFormat = new Intl.NumberFormat('pt-BR');
    constructor(localeService) {
        this.localeService = localeService;
    }
    ngOnInit() {
        this.validateValues();
        this.onGetLocale();
    }
    onGetLocale() {
        this.localeService.getLocale().subscribe({
            next: (locale) => {
                this.numberFormat = new Intl.NumberFormat(locale ?? 'pt-BR', this.numberFormatOptions);
            },
            error: () => {
                this.numberFormat = new Intl.NumberFormat('pt-BR', this.numberFormatOptions);
            },
        });
    }
    validateValues() {
        if (this.value < 0 || this.value > 100) {
            throw new Error('Invalid value for value');
        }
        if (this.targetValue && (this.targetValue < 0 || this.targetValue > 100)) {
            throw new Error('Invalid value for targetValue');
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarDeterminateComponent, deps: [{ token: i1.LocaleService }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ProgressBarDeterminateComponent, selector: "s-progressbar-determinate", inputs: { value: "value", activeColor: "activeColor", numberFormatOptions: "numberFormatOptions", targetValue: "targetValue", targetLabel: "targetLabel", showValue: "showValue" }, ngImport: i0, template: "<div class=\"progressbar-determinate\">\n    <div class=\"progressbar-container\">\n        <div\n            class=\"progressbar-active\"\n            [ngClass]=\"{\n                'progressbar-active--blue': activeColor === 'blue',\n                'progressbar-active--green': activeColor === 'green',\n                'progressbar-active--red': activeColor === 'red',\n                'progressbar-active--yellow': activeColor === 'yellow',\n            }\"\n            [ngStyle]=\"{ width: value + '%' }\"\n        >\n            {{ showValue && value ? numberFormat?.format(value) + '%' : '' }}\n        </div>\n    </div>\n    @if (targetValue) {\n        <div\n            class=\"target\"\n            [ngStyle]=\"{\n                left: targetValue <= 50 ? targetValue + '%' : 'unset',\n                right: targetValue > 50 ? 100 - targetValue + '%' : 'unset',\n                'align-items': targetValue > 50 ? 'flex-end' : 'flex-start',\n            }\"\n        >\n            <span class=\"target-line\"></span>\n            <span class=\"target-label\">\n                {{ targetLabel || numberFormat?.format(value) + '%' }}\n            </span>\n        </div>\n    }\n</div>\n", styles: [".progressbar-determinate{position:relative}.progressbar-determinate .progressbar-container{background-color:#d8d8d8;border-radius:4px;height:24px;overflow:hidden;width:100%}.progressbar-determinate .progressbar-container .progressbar-active{align-items:center;color:#fff;display:flex;font-family:Open Sans,sans-serif;font-size:14px;height:100%;justify-content:center;line-height:150%;-webkit-user-select:none;user-select:none;width:80%}.progressbar-determinate .progressbar-container .progressbar-active--blue{background-color:#428bca}.progressbar-determinate .progressbar-container .progressbar-active--green{background-color:#0c9348}.progressbar-determinate .progressbar-container .progressbar-active--red{background-color:#c13018}.progressbar-determinate .progressbar-container .progressbar-active--yellow{background-color:#fcbf10;color:#212533}.progressbar-determinate .target{align-items:flex-start;bottom:-38px;display:flex;flex-direction:column;position:absolute}.progressbar-determinate .target .target-line{background-color:#333;height:40px;margin:8px 0;width:1px}.progressbar-determinate .target .target-label{background-color:#426e78;border-radius:10px;color:#e5eaea;font-family:Open Sans,sans-serif;font-size:12px;line-height:150%;padding:2px 12px}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarDeterminateComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-progressbar-determinate', template: "<div class=\"progressbar-determinate\">\n    <div class=\"progressbar-container\">\n        <div\n            class=\"progressbar-active\"\n            [ngClass]=\"{\n                'progressbar-active--blue': activeColor === 'blue',\n                'progressbar-active--green': activeColor === 'green',\n                'progressbar-active--red': activeColor === 'red',\n                'progressbar-active--yellow': activeColor === 'yellow',\n            }\"\n            [ngStyle]=\"{ width: value + '%' }\"\n        >\n            {{ showValue && value ? numberFormat?.format(value) + '%' : '' }}\n        </div>\n    </div>\n    @if (targetValue) {\n        <div\n            class=\"target\"\n            [ngStyle]=\"{\n                left: targetValue <= 50 ? targetValue + '%' : 'unset',\n                right: targetValue > 50 ? 100 - targetValue + '%' : 'unset',\n                'align-items': targetValue > 50 ? 'flex-end' : 'flex-start',\n            }\"\n        >\n            <span class=\"target-line\"></span>\n            <span class=\"target-label\">\n                {{ targetLabel || numberFormat?.format(value) + '%' }}\n            </span>\n        </div>\n    }\n</div>\n", styles: [".progressbar-determinate{position:relative}.progressbar-determinate .progressbar-container{background-color:#d8d8d8;border-radius:4px;height:24px;overflow:hidden;width:100%}.progressbar-determinate .progressbar-container .progressbar-active{align-items:center;color:#fff;display:flex;font-family:Open Sans,sans-serif;font-size:14px;height:100%;justify-content:center;line-height:150%;-webkit-user-select:none;user-select:none;width:80%}.progressbar-determinate .progressbar-container .progressbar-active--blue{background-color:#428bca}.progressbar-determinate .progressbar-container .progressbar-active--green{background-color:#0c9348}.progressbar-determinate .progressbar-container .progressbar-active--red{background-color:#c13018}.progressbar-determinate .progressbar-container .progressbar-active--yellow{background-color:#fcbf10;color:#212533}.progressbar-determinate .target{align-items:flex-start;bottom:-38px;display:flex;flex-direction:column;position:absolute}.progressbar-determinate .target .target-line{background-color:#333;height:40px;margin:8px 0;width:1px}.progressbar-determinate .target .target-label{background-color:#426e78;border-radius:10px;color:#e5eaea;font-family:Open Sans,sans-serif;font-size:12px;line-height:150%;padding:2px 12px}\n"] }]
        }], ctorParameters: () => [{ type: i1.LocaleService }], propDecorators: { value: [{
                type: Input,
                args: [{ required: true }]
            }], activeColor: [{
                type: Input,
                args: [{ required: true }]
            }], numberFormatOptions: [{
                type: Input
            }], targetValue: [{
                type: Input
            }], targetLabel: [{
                type: Input
            }], showValue: [{
                type: Input
            }] } });

class ProgressBarIndeterminateComponent {
    activeColor;
    label;
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarIndeterminateComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ProgressBarIndeterminateComponent, selector: "s-progressbar-indeterminate", inputs: { activeColor: "activeColor", label: "label" }, ngImport: i0, template: "<div class=\"progressbar-indeterminate\">\n    <div class=\"progressbar-container\">\n        <div class=\"indeterminate-bar\" [ngClass]=\"{\n            'indeterminate-bar--blue': activeColor === 'blue',\n            'indeterminate-bar--green': activeColor === 'green',\n            'indeterminate-bar--red': activeColor === 'red',\n            'indeterminate-bar--yellow': activeColor === 'yellow'\n        }\"></div>\n    </div>\n\n    @if (label) {\n        <span class=\"progressbar-label\">{{ label }}</span>\n    }\n</div>\n", styles: [".progressbar-indeterminate{display:flex;flex-direction:column;align-items:center}.progressbar-indeterminate .progressbar-container{background-color:#d8d8d8;border-radius:4px;height:24px;margin:8px 0;overflow:hidden;width:100%}.progressbar-indeterminate .indeterminate-bar{animation:indeterminate-progress 5s infinite;background-color:#428bca;height:100%;width:40%}.progressbar-indeterminate .indeterminate-bar--blue{background-color:#428bca}.progressbar-indeterminate .indeterminate-bar--green{background-color:#0c9348}.progressbar-indeterminate .indeterminate-bar--red{background-color:#c13018}.progressbar-indeterminate .indeterminate-bar--yellow{background-color:#fcbf10}.progressbar-indeterminate .progressbar-label{font-family:\"Open Sans\" sans-serif;font-size:12px;line-height:150%;color:#212533}@keyframes indeterminate-progress{0%{transform:translate(-250%)}to{transform:translate(250%)}}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarIndeterminateComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-progressbar-indeterminate', template: "<div class=\"progressbar-indeterminate\">\n    <div class=\"progressbar-container\">\n        <div class=\"indeterminate-bar\" [ngClass]=\"{\n            'indeterminate-bar--blue': activeColor === 'blue',\n            'indeterminate-bar--green': activeColor === 'green',\n            'indeterminate-bar--red': activeColor === 'red',\n            'indeterminate-bar--yellow': activeColor === 'yellow'\n        }\"></div>\n    </div>\n\n    @if (label) {\n        <span class=\"progressbar-label\">{{ label }}</span>\n    }\n</div>\n", styles: [".progressbar-indeterminate{display:flex;flex-direction:column;align-items:center}.progressbar-indeterminate .progressbar-container{background-color:#d8d8d8;border-radius:4px;height:24px;margin:8px 0;overflow:hidden;width:100%}.progressbar-indeterminate .indeterminate-bar{animation:indeterminate-progress 5s infinite;background-color:#428bca;height:100%;width:40%}.progressbar-indeterminate .indeterminate-bar--blue{background-color:#428bca}.progressbar-indeterminate .indeterminate-bar--green{background-color:#0c9348}.progressbar-indeterminate .indeterminate-bar--red{background-color:#c13018}.progressbar-indeterminate .indeterminate-bar--yellow{background-color:#fcbf10}.progressbar-indeterminate .progressbar-label{font-family:\"Open Sans\" sans-serif;font-size:12px;line-height:150%;color:#212533}@keyframes indeterminate-progress{0%{transform:translate(-250%)}to{transform:translate(250%)}}\n"] }]
        }], propDecorators: { activeColor: [{
                type: Input,
                args: [{ required: true }]
            }], label: [{
                type: Input
            }] } });

class ProgressBarComponent {
    value;
    activeColor;
    numberFormatOptions = {
        style: "decimal",
        minimumFractionDigits: 0,
        maximumFractionDigits: 2,
        roundingMode: "trunc",
    };
    targetValue;
    label;
    targetLabel;
    showValue = true;
    mode = 'determinate';
    ngOnInit() {
        this.validateInputs();
    }
    validateInputs() {
        if (this.value < 0 || this.value > 100) {
            throw new Error('Invalid value for value');
        }
        if (this.targetValue && (this.targetValue < 0 || this.targetValue > 100)) {
            throw new Error('Invalid value for targetValue');
        }
        if (this.mode === 'indeterminate' && (this.value || this.targetValue || this.targetLabel)) {
            throw new Error('When the mode is indeterminate, the value, targetValue and targetLabel parameters are not expected.');
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: ProgressBarComponent, selector: "s-progressbar", inputs: { value: "value", activeColor: "activeColor", numberFormatOptions: "numberFormatOptions", targetValue: "targetValue", label: "label", targetLabel: "targetLabel", showValue: "showValue", mode: "mode" }, ngImport: i0, template: "@if (mode === 'determinate') {\n    <s-progressbar-determinate\n        [value]=\"value\"\n        [numberFormatOptions]=\"numberFormatOptions\"\n        [targetValue]=\"targetValue\"\n        [targetLabel]=\"targetLabel\"\n        [activeColor]=\"activeColor\"\n        [showValue]=\"showValue\"\n    >\n    </s-progressbar-determinate>\n} @else {\n    <s-progressbar-indeterminate\n        [activeColor]=\"activeColor\"\n        [label]=\"label\"\n    >\n    </s-progressbar-indeterminate>\n}\n", styles: [".progress-bar{position:relative}.progress-bar .progress-bar-all{background-color:#d8d8d8;border-radius:4px;height:24px;overflow:hidden;width:100%}.progress-bar .progress-bar-all .progress-bar-active{align-items:center;color:#fff;display:flex;font-family:Open Sans,sans-serif;font-size:14px;height:100%;justify-content:center;line-height:150%;-webkit-user-select:none;user-select:none;width:80%}.progress-bar .progress-bar-all .progress-bar-active--blue{background-color:#428bca}.progress-bar .progress-bar-all .progress-bar-active--green{background-color:#0c9348}.progress-bar .progress-bar-all .progress-bar-active--red{background-color:#c13018}.progress-bar .progress-bar-all .progress-bar-active--yellow{background-color:#fcbf10}.progress-bar .target{align-items:flex-start;bottom:-38px;display:flex;flex-direction:column;position:absolute}.progress-bar .target .target-line{background-color:#333;height:40px;margin:8px 0;width:1px}.progress-bar .target .target-label{background-color:#426e78;border-radius:10px;color:#e5eaea;font-family:Open Sans,sans-serif;font-size:12px;line-height:150%;padding:2px 12px}\n"], dependencies: [{ kind: "component", type: ProgressBarDeterminateComponent, selector: "s-progressbar-determinate", inputs: ["value", "activeColor", "numberFormatOptions", "targetValue", "targetLabel", "showValue"] }, { kind: "component", type: ProgressBarIndeterminateComponent, selector: "s-progressbar-indeterminate", inputs: ["activeColor", "label"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarComponent, decorators: [{
            type: Component,
            args: [{ selector: 's-progressbar', template: "@if (mode === 'determinate') {\n    <s-progressbar-determinate\n        [value]=\"value\"\n        [numberFormatOptions]=\"numberFormatOptions\"\n        [targetValue]=\"targetValue\"\n        [targetLabel]=\"targetLabel\"\n        [activeColor]=\"activeColor\"\n        [showValue]=\"showValue\"\n    >\n    </s-progressbar-determinate>\n} @else {\n    <s-progressbar-indeterminate\n        [activeColor]=\"activeColor\"\n        [label]=\"label\"\n    >\n    </s-progressbar-indeterminate>\n}\n", styles: [".progress-bar{position:relative}.progress-bar .progress-bar-all{background-color:#d8d8d8;border-radius:4px;height:24px;overflow:hidden;width:100%}.progress-bar .progress-bar-all .progress-bar-active{align-items:center;color:#fff;display:flex;font-family:Open Sans,sans-serif;font-size:14px;height:100%;justify-content:center;line-height:150%;-webkit-user-select:none;user-select:none;width:80%}.progress-bar .progress-bar-all .progress-bar-active--blue{background-color:#428bca}.progress-bar .progress-bar-all .progress-bar-active--green{background-color:#0c9348}.progress-bar .progress-bar-all .progress-bar-active--red{background-color:#c13018}.progress-bar .progress-bar-all .progress-bar-active--yellow{background-color:#fcbf10}.progress-bar .target{align-items:flex-start;bottom:-38px;display:flex;flex-direction:column;position:absolute}.progress-bar .target .target-line{background-color:#333;height:40px;margin:8px 0;width:1px}.progress-bar .target .target-label{background-color:#426e78;border-radius:10px;color:#e5eaea;font-family:Open Sans,sans-serif;font-size:12px;line-height:150%;padding:2px 12px}\n"] }]
        }], propDecorators: { value: [{
                type: Input
            }], activeColor: [{
                type: Input,
                args: [{ required: true }]
            }], numberFormatOptions: [{
                type: Input
            }], targetValue: [{
                type: Input
            }], label: [{
                type: Input
            }], targetLabel: [{
                type: Input
            }], showValue: [{
                type: Input
            }], mode: [{
                type: Input
            }] } });

/* eslint-disable max-len */
class ProgressBarModule {
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
    static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarModule, declarations: [ProgressBarComponent, ProgressBarDeterminateComponent, ProgressBarIndeterminateComponent], imports: [CommonModule], exports: [ProgressBarComponent] });
    static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarModule, imports: [CommonModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ProgressBarModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule],
                    declarations: [ProgressBarComponent, ProgressBarDeterminateComponent, ProgressBarIndeterminateComponent],
                    exports: [ProgressBarComponent],
                }]
        }] });

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

export { ProgressBarComponent, ProgressBarModule };
//# sourceMappingURL=seniorsistemas-angular-components-progressbar.mjs.map
