import * as tslib_1 from "tslib";
import { Component, Input, Output, EventEmitter, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core';
/**
 * Progress Bar Component
 */
var ProgressBarComponent = /** @class */ (function () {
    function ProgressBarComponent() {
        /**
         * Emit a event with the current progress value when the progressbar is closed
         */
        this.close = new EventEmitter();
        /** Emit a event when the progressbar is refreshed */
        this.refresh = new EventEmitter();
        /**
         * Current progress bar value
         * @default 0
         */
        this.value = 0;
        /**
         * Progress bar max value
         * @default 100
         */
        this.maxValue = 100;
        /**
         * Whether the progress is successful
         * @default false
         */
        this.isSuccess = false;
        /**
         * Success text when progress bar is done
         * @default 完成
         */
        this.successText = '完成';
        /**
         * Whether the progress is error
         * @default false
         */
        this.isError = false;
        /**
         * Error text when progress bar is error
         * @default false
         */
        this.errorText = '错误';
        /**
         * Whether show progress text
         * @default false
         */
        this.showProgressText = false;
        /**
         * Whether show operation buttons
         * @default false
         */
        this.showOperation = false;
    }
    Object.defineProperty(ProgressBarComponent.prototype, "percent", {
        /**
         * Compute percent
         * @docs-private
         */
        get: function () {
            if (this.value && this.maxValue && this.maxValue !== 0) {
                return Math.floor((this.value / this.maxValue) * 100);
            }
            return 0;
        },
        enumerable: true,
        configurable: true
    });
    /**
     * close progressbar
     * @docs-private
     */
    ProgressBarComponent.prototype.onClose = function () {
        this.close.emit(this.value);
    };
    /**
     * refresh progressbar
     * @docs-private
     */
    ProgressBarComponent.prototype.onRefresh = function () {
        this.refresh.emit(this.value);
    };
    tslib_1.__decorate([
        Output(),
        tslib_1.__metadata("design:type", EventEmitter)
    ], ProgressBarComponent.prototype, "close", void 0);
    tslib_1.__decorate([
        Output(),
        tslib_1.__metadata("design:type", EventEmitter)
    ], ProgressBarComponent.prototype, "refresh", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], ProgressBarComponent.prototype, "value", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Number)
    ], ProgressBarComponent.prototype, "maxValue", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarComponent.prototype, "isSuccess", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], ProgressBarComponent.prototype, "successText", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarComponent.prototype, "isError", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", String)
    ], ProgressBarComponent.prototype, "errorText", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarComponent.prototype, "showProgressText", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Boolean)
    ], ProgressBarComponent.prototype, "showOperation", void 0);
    ProgressBarComponent = tslib_1.__decorate([
        Component({
            selector: 'nb-progress-bar',
            template: "<table class=\"bar-table\"><tr class=\"bar-row\"><td class=\"bar-val-col\"><div class=\"bar-outer\"><div class=\"bar-inner\" [style.width.%]=\"percent\" [class.bar-inner-success]=\"isSuccess\" [class.bar-inner-error]=\"isError\"></div></div></td><td class=\"bar-text-col\" *ngIf=\"showProgressText\"><div class=\"bar-text\"><div *ngIf=\"isSuccess\" class=\"bar-text-success\">{{ successText }}</div><div *ngIf=\"isError\" class=\"bar-text-error\">{{ errorText }}</div><div *ngIf=\"!isSuccess && !isError\">{{ percent }}%</div></div></td><td class=\"bar-operation-col\" *ngIf=\"showOperation\"><div class=\"bar-operations\" [class.bar-operation-success]=\"isSuccess\" [class.bar-operation-error]=\"isError\"><div class=\"bar-operation-delete\" (click)=\"onClose()\"><i class=\"iconfont icon-close\"></i></div><div class=\"bar-operation-refresh\" (click)=\"onRefresh()\"><i class=\"iconfont icon-refresh\"></i></div></div></td></tr></table>",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.OnPush,
            preserveWhitespaces: false,
            host: {
                'class': 'nb-widget nb-progress-bar'
            },
            exportAs: 'nbProgressBar'
        })
    ], ProgressBarComponent);
    return ProgressBarComponent;
}());
export { ProgressBarComponent };
//# sourceMappingURL=progress-bar.js.map