/*
 * @license
 * Copyright Endlessjs. All Rights Reserved.
 * Licensed under the MIT License. See License.txt in the project root for license information.
 */
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 (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        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 { Directive, HostListener, Input } from '@angular/core';
import { Subject } from 'rxjs';
import { debounceTime, takeWhile } from 'rxjs/operators';
var ElFilterDirective = /** @class */ (function () {
    function ElFilterDirective() {
    }
    ElFilterDirective.prototype.filter = function (filterRequest) {
        this.filterable.filter(filterRequest);
    };
    __decorate([
        Input('elFilter'),
        __metadata("design:type", Object)
    ], ElFilterDirective.prototype, "filterable", void 0);
    ElFilterDirective = __decorate([
        Directive({ selector: '[elFilter]' })
    ], ElFilterDirective);
    return ElFilterDirective;
}());
export { ElFilterDirective };
/**
 * Helper directive to trigger data source's filter method when user types in input
 */
var ElFilterInputDirective = /** @class */ (function (_super) {
    __extends(ElFilterInputDirective, _super);
    function ElFilterInputDirective() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        _this.search$ = new Subject();
        _this.alive = true;
        /**
         * Debounce time before triggering filter method. Set in milliseconds.
         * Default 200.
         */
        _this.debounceTime = 200;
        return _this;
    }
    ElFilterInputDirective_1 = ElFilterInputDirective;
    ElFilterInputDirective.prototype.ngOnInit = function () {
        var _this = this;
        this.search$
            .pipe(takeWhile(function () { return _this.alive; }), debounceTime(this.debounceTime))
            .subscribe(function (query) {
            _super.prototype.filter.call(_this, query);
        });
    };
    ElFilterInputDirective.prototype.ngOnDestroy = function () {
        this.alive = false;
        this.search$.complete();
    };
    ElFilterInputDirective.prototype.filter = function (event) {
        this.search$.next(event.target.value);
    };
    var ElFilterInputDirective_1;
    __decorate([
        Input('elFilterInput'),
        __metadata("design:type", Object)
    ], ElFilterInputDirective.prototype, "filterable", void 0);
    __decorate([
        Input(),
        __metadata("design:type", Number)
    ], ElFilterInputDirective.prototype, "debounceTime", void 0);
    __decorate([
        HostListener('input', ['$event']),
        __metadata("design:type", Function),
        __metadata("design:paramtypes", [Object]),
        __metadata("design:returntype", void 0)
    ], ElFilterInputDirective.prototype, "filter", null);
    ElFilterInputDirective = ElFilterInputDirective_1 = __decorate([
        Directive({
            selector: '[elFilterInput]',
            providers: [{ provide: ElFilterDirective, useExisting: ElFilterInputDirective_1 }],
        })
    ], ElFilterInputDirective);
    return ElFilterInputDirective;
}(ElFilterDirective));
export { ElFilterInputDirective };
//# sourceMappingURL=tree-grid-filter.js.map