"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UICircularProgress = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var aurelia_typed_observable_plugin_1 = require("aurelia-typed-observable-plugin");
var UICircularProgress = exports.UICircularProgress = (function () {
    function UICircularProgress(taskQueue) {
        this.taskQueue = taskQueue;
        this.value = 0;
    }
    UICircularProgress.prototype.attached = function () {
        var _this = this;
        this.taskQueue.queueMicroTask(function () {
            _this.radius = _this.circle.r.baseVal.value;
            _this.circumference = _this.radius * 2 * Math.PI;
            _this.circle.style.strokeDasharray = "".concat(_this.circumference, " ").concat(_this.circumference);
            _this.circle.style.strokeDashoffset = "".concat(_this.circumference);
        });
    };
    UICircularProgress.prototype.valueChanged = function (newVal, oldVal) {
        this.setProgress(this.value);
    };
    UICircularProgress.prototype.setProgress = function (percent) {
        var _this = this;
        this.taskQueue.queueMicroTask(function () {
            var offset = _this.circumference - percent / 100 * _this.circumference;
            _this.circle.style.strokeDashoffset = offset.toString();
        });
    };
    __decorate([
        aurelia_typed_observable_plugin_1.bindable,
        __metadata("design:type", Number)
    ], UICircularProgress.prototype, "value", void 0);
    UICircularProgress = __decorate([
        (0, aurelia_framework_1.customElement)("ui-circular-progress"),
        aurelia_framework_1.autoinject,
        __metadata("design:paramtypes", [aurelia_framework_1.TaskQueue])
    ], UICircularProgress);
    return UICircularProgress;
}());

//# sourceMappingURL=ui-circular-progress.js.map
