"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 lodash_1 = require("lodash");
var filterGroup_service_1 = require("../filterGroup.service");
var ModeFilterGroup = (function (_super) {
    __extends(ModeFilterGroup, _super);
    function ModeFilterGroup(settings, transformService) {
        var _this = _super.call(this, settings) || this;
        _this.transformService = transformService;
        _this.getValue = settings.getValue;
        settings.options = lodash_1.map(settings.options, _this.buildModeOption.bind(_this));
        _this.initOptions();
        return _this;
    }
    ModeFilterGroup.prototype.serialize = function () {
        return this.value$.asObservable().map(function (activeOption) {
            if (activeOption.displayAll) {
                return null;
            }
            return activeOption.value;
        });
    };
    ModeFilterGroup.prototype.buildModeOption = function (option) {
        var _this = this;
        var modeOption = option;
        modeOption.predicate = function (item) {
            if (modeOption.displayAll) {
                return true;
            }
            return _this.transformService.getValue(item, _this.getValue) === modeOption.value;
        };
        return modeOption;
    };
    return ModeFilterGroup;
}(filterGroup_service_1.FilterGroup));
exports.ModeFilterGroup = ModeFilterGroup;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9kZUZpbHRlckdyb3VwLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJtb2RlRmlsdGVyR3JvdXAuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7QUFDQSxpQ0FBNkI7QUFLN0IsOERBQWtGO0FBeUJsRjtJQUFnRCxtQ0FBc0I7SUFLckUseUJBQVksUUFBdUMsRUFDL0MsZ0JBQStDO1FBRG5ELFlBRUMsa0JBQVcsUUFBUSxDQUFDLFNBTXBCO1FBTEEsS0FBSSxDQUFDLGdCQUFnQixHQUFHLGdCQUFnQixDQUFDO1FBRXpDLEtBQUksQ0FBQyxRQUFRLEdBQUcsUUFBUSxDQUFDLFFB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