"use strict";
var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    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);
};
var core_1 = require("@angular/core");
var typescript_angular_utilities_1 = require("typescript-angular-utilities");
var SearchUtility = typescript_angular_utilities_1.services.search.SearchUtility;
var filter_1 = require("../filter");
var SearchFilter = (function (_super) {
    __extends(SearchFilter, _super);
    function SearchFilter(searchUtility) {
        var _this = _super.call(this) || this;
        _this.predicate = function (item, searchText) {
            if (!searchText || searchText.length < _this.minSearchLength) {
                return true;
            }
            if (_this.tokenized) {
                return _this.searchUtility.tokenizedSearch(item, searchText, _this.caseSensitive);
            }
            return _this.searchUtility.search(item, searchText, _this.caseSensitive);
        };
        _this.searchUtility = searchUtility;
        _this.type = 'search';
        _this.minSearchLength = 1;
        _this.caseSensitive = false;
        _this.tokenized = false;
        return _this;
    }
    Object.defineProperty(SearchFilter.prototype, "searchText$", {
        get: function () {
            return this.value$.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    SearchFilter.prototype.setSearch = function (search) {
        this.value$.next(search);
    };
    return SearchFilter;
}(filter_1.Filter));
SearchFilter = __decorate([
    core_1.Injectable(),
    __metadata("design:paramtypes", [SearchUtility])
], SearchFilter);
exports.SearchFilter = SearchFilter;
//# sourceMapp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