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 __());
    };
})();
import { Config } from '../../../index';
import { Container } from 'aurelia-framework';
import BaseFilter from '../base-filter';
import { StringFilterHelper } from './string-filter-helper';
var StringFilter = (function (_super) {
    __extends(StringFilter, _super);
    function StringFilter() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    StringFilter.prototype.init = function (params) {
        var _this = this;
        var _a, _b;
        this.filterHelper = new StringFilterHelper((_a = params.searchMinLength) !== null && _a !== void 0 ? _a : 0, (_b = params.isMultiple) !== null && _b !== void 0 ? _b : true, function () { return _this.textDisplayedChanged(); });
        this.filterChangedCallback = params.filterChangedCallback;
        this.config = Container.instance.get(Config);
        _super.prototype.init.call(this, params);
    };
    StringFilter.prototype.isFilterActive = function () {
        return this.filterHelper.isFilterActive();
    };
    StringFilter.prototype.setupContentGui = function () {
        return "<div class=\"floating-filter__body__search\">\n              <ui-input type=\"text\" value.bind=\"filterHelper.textDisplayed & debounce:500\" t=\"[placeholder]common:grid.searchShort\" autofocus.one-time=\"true\" allow-clear.one-time=\"true\">\n                <ui-input-addon icon=\"digi-search\"></ui-input-addon>\n              </ui-input>\n              <div class=\"ui-check__wrapper\" if.bind=\"showEmptyFieldsCheckbox\">\n                <ui-checkbox checked.bind=\"filterHelper.displayEmptyFields\">${ 'grid.displayEmptyFields' | t }</ui-checkbox>\n              </div>\n            </div>";
    };
    StringFilter.prototype.resetFilter = function () {
        this.filterHelper.resetFilter();
    };
    StringFilter.prototype.removeFilterValue = function () {
        this.resetFilter();
    };
    StringFilter.prototype.textDisplayedChanged = function () {
        var instance = this.params.api.getFilterInstance(this.params.colDef.field);
        instance.setModel({ filterType: 'text', type: 'contains', filter: this.filterHelper.text, isMultiple: this.filterHelper.isMultiple, displayEmptyFields: this.filterHelper.displayEmptyFields });
    };
    StringFilter.prototype.getModel = function () {
        return this.isFilterActive() ?
            { filterType: 'text', type: 'contains', filter: this.filterHelper.text, isMultiple: this.filterHelper.isMultiple, displayEmptyFields: this.filterHelper.displayEmptyFields }
            : null;
    };
    StringFilter.prototype.setModel = function (model) {
        if (model == null) {
            this.filterHelper.text = null;
            this.filterHelper.isMultiple = true;
        }
        else if (model.filterType == 'text') {
            this.filterHelper.text = model.filter;
            this.filterHelper.isMultiple = model.isMultiple;
        }
        this.filterHelper.textDisplayed = this.filterHelper.text;
        this.filterChangedCallback();
    };
    StringFilter.prototype.getValue = function () {
        return this.filterHelper.getValue();
    };
    StringFilter.prototype.getModelAsString = function () {
        return this.filterHelper.getModelAsString();
    };
    StringFilter.prototype.setupContentGuiSideFilter = function () {
        return this.filterHelper.setupContentGuiSideFilter();
    };
    StringFilter.prototype.applyObservers = function () {
        this.dispose();
        this.disposables.push(this.bindingEngine.propertyObserver(this.filterHelper, 'displayEmptyFields').subscribe(this.textDisplayedChanged.bind(this)));
    };
    return StringFilter;
}(BaseFilter));
export { StringFilter };

//# sourceMappingURL=string-filter.js.map
