"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.UICheckbox = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var ui_internal_1 = require("../../utils/ui-internal");
var UICheckbox = exports.UICheckbox = (function () {
    function UICheckbox(element, taskQueue) {
        this.element = element;
        this.taskQueue = taskQueue;
        this.disabled = false;
        this.onChange = function () { };
        this.isDisabled = false;
    }
    UICheckbox.prototype.disable = function (b) {
        this.isDisabled = b;
    };
    UICheckbox.prototype.bind = function () {
        if (this.checked === "true") {
            this.checked = true;
        }
    };
    UICheckbox.prototype.checkChanged = function ($event) {
        var _this = this;
        $event.preventDefault();
        $event.stopPropagation();
        if (!this.disabled) {
            this.checked = !this.checked;
            this.taskQueue.queueMicroTask(function () { return _this.onChange({ checked: _this.checked }); });
        }
        this.element.dispatchEvent(ui_internal_1.UIInternal.createEvent("change", this));
    };
    __decorate([
        (0, aurelia_framework_1.bindable)({ defaultBindingMode: aurelia_framework_1.bindingMode.twoWay }),
        __metadata("design:type", Object)
    ], UICheckbox.prototype, "checked", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Object)
    ], UICheckbox.prototype, "model", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Function)
    ], UICheckbox.prototype, "matcher", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Boolean)
    ], UICheckbox.prototype, "disabled", void 0);
    __decorate([
        aurelia_framework_1.bindable,
        __metadata("design:type", Function)
    ], UICheckbox.prototype, "onChange", void 0);
    UICheckbox = __decorate([
        (0, aurelia_framework_1.customElement)("ui-checkbox"),
        __metadata("design:paramtypes", [Element, aurelia_framework_1.TaskQueue])
    ], UICheckbox);
    return UICheckbox;
}());

//# sourceMappingURL=ui-checkbox.js.map
