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

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