"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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.UIMLInput = void 0;
var ui_input_1 = require("./ui-input");
var aurelia_framework_1 = require("aurelia-framework");
var config_1 = require("../../config");
var ml_input_helper_1 = require("./helpers/ml-input-helper");
var UIMLInput = exports.UIMLInput = (function (_super) {
    __extends(UIMLInput, _super);
    function UIMLInput(element, config, bindingEngine) {
        var _this_1 = _super.call(this, element, config, bindingEngine) || this;
        _this_1.config = config;
        var _this = _this_1;
        _this_1.mlInputHelper = new ml_input_helper_1.MLInputHelper(_this_1, function () { return _this.valueChanged(); });
        _this_1.mlInputHelper.changeSelectedLangage();
        return _this_1;
    }
    UIMLInput.prototype.onClear = function () {
        this.mlInputHelper.onClear();
    };
    UIMLInput.prototype.updateLanguageCode = function (code) {
        this.selectedLanguageCode = code;
    };
    UIMLInput.prototype.selectedLanguageCodeChanged = function (newValue, oldValue) {
        this.mlInputHelper.selectedLanguageCodeChanged(newValue, oldValue);
    };
    UIMLInput.prototype.bind = function () {
        _super.prototype.bind.call(this);
        this.inputElement.allowClear = this.allowClear;
        if (this.selectedLanguageCode != null) {
            this.mlInputHelper.setSelectedLanguage();
        }
        this.valueChanged();
    };
    UIMLInput.prototype.valueChanged = function () {
        this.mlInputHelper.rebindSubscribers();
    };
    Object.defineProperty(UIMLInput.prototype, "isTranslatable", {
        get: function () {
            return this.mlInputHelper.isTranslatable();
        },
        enumerable: false,
        configurable: true
    });
    UIMLInput.prototype.detached = function () {
        this.mlInputHelper.disposeSubscribers();
    };
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", Array)
    ], UIMLInput.prototype, "languages", void 0);
    __decorate([
        (0, aurelia_framework_1.bindable)(),
        __metadata("design:type", String)
    ], UIMLInput.prototype, "selectedLanguageCode", void 0);
    __decorate([
        (0, aurelia_framework_1.computedFrom)("value"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIMLInput.prototype, "isTranslatable", null);
    UIMLInput = __decorate([
        (0, aurelia_framework_1.customElement)("ui-ml-input"),
        aurelia_framework_1.containerless,
        __metadata("design:paramtypes", [Element, config_1.Config, aurelia_framework_1.BindingEngine])
    ], UIMLInput);
    return UIMLInput;
}(ui_input_1.UIInput));

//# sourceMappingURL=ui-ml-input.js.map
