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);
};
import { bindable, BindingEngine, computedFrom, containerless, customElement } from "aurelia-framework";
import { Config } from "../../config";
import { UITextarea } from './ui-textarea';
import { observable } from "aurelia-typed-observable-plugin";
import { MLInputHelper } from "./helpers/ml-input-helper";
export var UIMLTextarea = (function (_super) {
    __extends(UIMLTextarea, _super);
    function UIMLTextarea(element, config, bindingEngine) {
        var _this_1 = _super.call(this, element, bindingEngine) || this;
        _this_1.config = config;
        _this_1.isValueObservable = false;
        _this_1.mlInputHelper = new MLInputHelper(_this_1);
        _this_1.mlInputHelper.changeSelectedLangage();
        return _this_1;
    }
    UIMLTextarea.prototype.onClear = function () {
        this.mlInputHelper.onClear();
    };
    UIMLTextarea.prototype.updateLanguageCode = function (code) {
        this.selectedLanguageCode = code;
    };
    UIMLTextarea.prototype.selectedLanguageCodeChanged = function (newValue, oldValue) {
        this.mlInputHelper.selectedLanguageCodeChanged(newValue, oldValue);
    };
    UIMLTextarea.prototype.bind = function () {
        this.uITextArea.allowClear = this.allowClear;
        this.uITextArea.isValueObservable = false;
        if (this.selectedLanguageCode != null) {
            this.mlInputHelper.setSelectedLanguage();
        }
        var _this = this;
        this.mlInputHelper.rebindSubscribers(function () {
            setTimeout(function () {
                _this.textareaAutoResize();
            }, 50);
        });
        _super.prototype.bind.call(this);
    };
    Object.defineProperty(UIMLTextarea.prototype, "isTranslatable", {
        get: function () {
            return this.mlInputHelper.isTranslatable();
        },
        enumerable: false,
        configurable: true
    });
    UIMLTextarea.prototype.detached = function () {
        this.mlInputHelper.disposeSubscribers();
        _super.prototype.detached.call(this);
    };
    UIMLTextarea.prototype.attached = function () {
        this.inputEl = this.uITextArea.inputEl;
        _super.prototype.attached.call(this);
    };
    UIMLTextarea.prototype.selectedLanguageChanged = function () {
        var _this_1 = this;
        setTimeout(function () {
            _this_1.textareaAutoResize();
        }, 50);
    };
    __decorate([
        bindable(),
        __metadata("design:type", Array)
    ], UIMLTextarea.prototype, "languages", void 0);
    __decorate([
        observable,
        __metadata("design:type", Object)
    ], UIMLTextarea.prototype, "selectedLanguage", void 0);
    __decorate([
        bindable(),
        __metadata("design:type", String)
    ], UIMLTextarea.prototype, "selectedLanguageCode", void 0);
    __decorate([
        computedFrom("value"),
        __metadata("design:type", Object),
        __metadata("design:paramtypes", [])
    ], UIMLTextarea.prototype, "isTranslatable", null);
    UIMLTextarea = __decorate([
        customElement("ui-ml-textarea"),
        containerless,
        __metadata("design:paramtypes", [Element, Config, BindingEngine])
    ], UIMLTextarea);
    return UIMLTextarea;
}(UITextarea));

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