import { ChangeDetectionStrategy, Component, inject, Input, ViewEncapsulation } from '@angular/core';
import { getValueInRange, isNumber } from '../util/util';
import { NgbProgressbarConfig } from './progressbar-config';
import { PercentPipe } from '@angular/common';
import * as i0 from "@angular/core";
const _c0 = ["*"];
function NgbProgressbar_Conditional_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵi18n(1, 0);
    i0.ɵɵpipe(2, "percent");
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵi18nExp(i0.ɵɵpipeBind1(2, 1, ctx_r0.getValue() / ctx_r0.max));
    i0.ɵɵi18nApply(1);
} }
/**
 * A directive that provides feedback on the progress of a workflow or an action.
 */
export class NgbProgressbar {
    /**
     * The maximal value to be displayed in the progress bar.
     *
     * Should be a positive number. Will default to 100 otherwise.
     */
    set max(max) {
        this._max = !isNumber(max) || max <= 0 ? 100 : max;
    }
    get max() {
        return this._max;
    }
    constructor() {
        this._config = inject(NgbProgressbarConfig);
        this.stacked = inject(NgbProgressbarStacked, { optional: true });
        /**
         * If `true`, the stripes on the progress bar are animated.
         *
         * Takes effect only for browsers supporting CSS3 animations, and if `striped` is `true`.
         */
        this.animated = this._config.animated;
        /**
         * The accessible progress bar name.
         *
         * @since 13.1.0
         */
        this.ariaLabel = this._config.ariaLabel;
        /**
         * If `true`, the progress bars will be displayed as striped.
         */
        this.striped = this._config.striped;
        /**
         * If `true`, the current percentage will be shown in the `xx%` format.
         */
        this.showValue = this._config.showValue;
        /**
         * Optional text variant type of the progress bar.
         *
         * Supports types based on Bootstrap background color variants, like:
         *  `"success"`, `"info"`, `"warning"`, `"danger"`, `"primary"`, `"secondary"`, `"dark"` and so on.
         *
         * @since 5.2.0
         */
        this.textType = this._config.textType;
        /**
         * The type of the progress bar.
         *
         * Supports types based on Bootstrap background color variants, like:
         *  `"success"`, `"info"`, `"warning"`, `"danger"`, `"primary"`, `"secondary"`, `"dark"` and so on.
         */
        this.type = this._config.type;
        /**
         * The current value for the progress bar.
         *
         * Should be in the `[0, max]` range.
         */
        this.value = 0;
        /**
         * The height of the progress bar.
         *
         * Accepts any valid CSS height values, ex. `"2rem"`
         */
        this.height = this._config.height;
        this.max = this._config.max;
    }
    getValue() {
        return getValueInRange(this.value, this.max);
    }
    getPercentValue() {
        return (100 * this.getValue()) / this.max;
    }
    static { this.ɵfac = function NgbProgressbar_Factory(t) { return new (t || NgbProgressbar)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NgbProgressbar, selectors: [["ngb-progressbar"]], hostAttrs: ["role", "progressbar", "aria-valuemin", "0", 1, "progress"], hostVars: 7, hostBindings: function NgbProgressbar_HostBindings(rf, ctx) { if (rf & 2) {
            i0.ɵɵattribute("aria-valuenow", ctx.getValue())("aria-valuemax", ctx.max)("aria-label", ctx.ariaLabel);
            i0.ɵɵstyleProp("width", ctx.stacked ? ctx.getPercentValue() : null, "%")("height", ctx.height);
        } }, inputs: { max: "max", animated: "animated", ariaLabel: "ariaLabel", striped: "striped", showValue: "showValue", textType: "textType", type: "type", value: "value", height: "height" }, standalone: true, features: [i0.ɵɵStandaloneFeature], ngContentSelectors: _c0, decls: 3, vars: 11, consts: () => { let i18n_0; if (typeof ngI18nClosureMode !== "undefined" && ngI18nClosureMode) {
            /**
             * @suppress {msgDescriptions}
             */
            const MSG_EXTERNAL_ngb_progressbar_value$$PROGRESSBAR_PROGRESSBAR_TS_0 = goog.getMsg("{$interpolation}", { "interpolation": "\uFFFD0\uFFFD" }, { original_code: { "interpolation": "{{ getValue() / max | percent }}" } });
            i18n_0 = MSG_EXTERNAL_ngb_progressbar_value$$PROGRESSBAR_PROGRESSBAR_TS_0;
        }
        else {
            i18n_0 = $localize `:@@ngb.progressbar.value:${"\uFFFD0\uFFFD"}:INTERPOLATION:`;
        } return [i18n_0]; }, template: function NgbProgressbar_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵelementStart(0, "div");
            i0.ɵɵtemplate(1, NgbProgressbar_Conditional_1_Template, 3, 3, "span");
            i0.ɵɵprojection(2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵclassMapInterpolate2("progress-bar", ctx.type ? ctx.textType ? " bg-" + ctx.type : " text-bg-" + ctx.type : "", "", ctx.textType ? " text-" + ctx.textType : "", "");
            i0.ɵɵstyleProp("width", !ctx.stacked ? ctx.getPercentValue() : null, "%");
            i0.ɵɵclassProp("progress-bar-animated", ctx.animated)("progress-bar-striped", ctx.striped);
            i0.ɵɵadvance();
            i0.ɵɵconditional(ctx.showValue ? 1 : -1);
        } }, dependencies: [PercentPipe], encapsulation: 2, changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NgbProgressbar, [{
        type: Component,
        args: [{
                selector: 'ngb-progressbar',
                standalone: true,
                imports: [PercentPipe],
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                host: {
                    class: 'progress',
                    role: 'progressbar',
                    '[attr.aria-valuenow]': 'getValue()',
                    'aria-valuemin': '0',
                    '[attr.aria-valuemax]': 'max',
                    '[attr.aria-label]': 'ariaLabel',
                    '[style.width.%]': 'stacked ? getPercentValue() : null',
                    '[style.height]': 'height',
                },
                template: `
		<div
			class="progress-bar{{ type ? (textType ? ' bg-' + type : ' text-bg-' + type) : '' }}{{
				textType ? ' text-' + textType : ''
			}}"
			[class.progress-bar-animated]="animated"
			[class.progress-bar-striped]="striped"
			[style.width.%]="!stacked ? getPercentValue() : null"
		>
			@if (showValue) {
				<span i18n="@@ngb.progressbar.value">{{ getValue() / max | percent }}</span>
			}
			<ng-content />
		</div>
	`,
            }]
    }], () => [], { max: [{
            type: Input
        }], animated: [{
            type: Input
        }], ariaLabel: [{
            type: Input
        }], striped: [{
            type: Input
        }], showValue: [{
            type: Input
        }], textType: [{
            type: Input
        }], type: [{
            type: Input
        }], value: [{
            type: Input,
            args: [{ required: true }]
        }], height: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NgbProgressbar, { className: "NgbProgressbar", filePath: "progressbar\\progressbar.ts", lineNumber: 41 }); })();
/**
 * A directive that allow to stack progress bars.
 *
 * @since 16.0.0
 */
export class NgbProgressbarStacked {
    static { this.ɵfac = function NgbProgressbarStacked_Factory(t) { return new (t || NgbProgressbarStacked)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: NgbProgressbarStacked, selectors: [["ngb-progressbar-stacked"]], hostAttrs: [1, "progress-stacked"], standalone: true, features: [i0.ɵɵStandaloneFeature], ngContentSelectors: _c0, decls: 1, vars: 0, template: function NgbProgressbarStacked_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef();
            i0.ɵɵprojection(0);
        } }, encapsulation: 2, changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(NgbProgressbarStacked, [{
        type: Component,
        args: [{
                selector: 'ngb-progressbar-stacked',
                standalone: true,
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                host: {
                    class: 'progress-stacked',
                },
                template: `<ng-content></ng-content>`,
            }]
    }], null, null); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(NgbProgressbarStacked, { className: "NgbProgressbarStacked", filePath: "progressbar\\progressbar.ts", lineNumber: 144 }); })();
//# sourceMappingURL=data:application/json;base64, 