var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
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);
};
import { autoinject, bindingMode, customElement, bindable } from 'aurelia-framework';
export var UITagListCheck = (function () {
    function UITagListCheck() {
        this.isEditable = true;
        this.showLabel = true;
    }
    UITagListCheck.prototype.toggleTag = function (tag) {
        if (this.isEditable) {
            if (tag)
                tag.selected = !tag.selected;
            this.model = __assign({}, this.model);
        }
    };
    UITagListCheck.prototype.toggleModel = function (model) {
        var _a;
        if (this.isEditable && ((_a = model === null || model === void 0 ? void 0 : model.tags) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            model.selected = !model.selected;
            model.tags.forEach(function (tag) {
                tag.selected = model.selected;
            });
            this.model = __assign({}, model);
        }
    };
    UITagListCheck.prototype.attached = function () {
        this.initConfig();
    };
    UITagListCheck.prototype.modelChanged = function () {
        if (this.model == null || this.model.label == null || this.model.label.length == 0) {
            this.showLabel = false;
        }
        else {
            this.showLabel = true;
        }
    };
    UITagListCheck.prototype.initConfig = function () {
        if (this.config == null) {
            this.config = {};
        }
        if (this.config.onBackgroundColor == null) {
            this.config.onBackgroundColor = 'red';
        }
        if (this.config.onTextColor == null) {
            this.config.onTextColor = 'white';
        }
        if (this.config.offBackgroundColor == null) {
            this.config.offBackgroundColor = 'green';
        }
        if (this.config.offTextColor == null) {
            this.config.offTextColor = 'white';
        }
        if (this.config.size == null) {
            this.config.size = 'md';
        }
    };
    __decorate([
        bindable({ defaultBindingMode: bindingMode.twoWay }),
        __metadata("design:type", UITagListCheckModel)
    ], UITagListCheck.prototype, "model", void 0);
    __decorate([
        bindable({ defaultBindingMode: bindingMode.oneTime }),
        __metadata("design:type", UITagListCheckConfig)
    ], UITagListCheck.prototype, "config", void 0);
    __decorate([
        bindable({ defaultBindingMode: bindingMode.oneTime }),
        __metadata("design:type", Boolean)
    ], UITagListCheck.prototype, "isEditable", void 0);
    UITagListCheck = __decorate([
        autoinject,
        customElement("ui-tag-list-check")
    ], UITagListCheck);
    return UITagListCheck;
}());
var UITagListCheckConfig = (function () {
    function UITagListCheckConfig() {
    }
    return UITagListCheckConfig;
}());
export { UITagListCheckConfig };
var UITagListCheckModel = (function () {
    function UITagListCheckModel() {
    }
    return UITagListCheckModel;
}());
export { UITagListCheckModel };
var UITagListCheckTag = (function () {
    function UITagListCheckTag() {
    }
    return UITagListCheckTag;
}());
export { UITagListCheckTag };

//# sourceMappingURL=ui-tag-list-check.js.map
