import { EventEmitter } from '@angular/core';
import { HashMap } from '../../utils';
var TreeListDefault = (function () {
    function TreeListDefault() {
        this.update = new EventEmitter();
        this.groups = new HashMap();
        this.groupsParents = new HashMap();
        this.elements = new HashMap();
        this.groupsFilter = function (a) { return a.id; };
        this.groupParentsFilter = function (a) { return a.parent; };
        this.elementsFilter = function (a) { return a.parent; };
    }
    TreeListDefault.prototype.setGroups = function (groups) {
        var _this = this;
        this.groups.clear();
        groups.forEach(function (group) {
            var key = _this.groupsFilter(group);
            _this.groups.put(key, group);
            var keyP = _this.groupParentsFilter(group);
            if (!_this.groupsParents.containsKey(keyP)) {
                _this.groupsParents.put(keyP, new Array());
            }
            _this.groupsParents.get(keyP).push(key);
        });
        this.update.emit(true);
    };
    TreeListDefault.prototype.setElements = function (elements) {
        var _this = this;
        this.elements.clear();
        elements.forEach(function (element) {
            var key = _this.elementsFilter(element);
            if (!_this.elements.containsKey(key)) {
                _this.elements.put(key, new Array());
            }
            _this.elements.get(key).push(element);
        });
        this.update.emit(true);
    };
    TreeListDefault.prototype.setGroupsFilter = function (groupsFilter) {
        this.groupsFilter = groupsFilter;
    };
    TreeListDefault.prototype.setGroupParentsFilter = function (groupParentsFilter) {
        this.groupParentsFilter = groupParentsFilter;
    };
    TreeListDefault.prototype.setElementsFilter = function (elementsFilter) {
        this.elementsFilter = elementsFilter;
    };
    TreeListDefault.prototype.build = function (key) {
        if (key === undefined || key === null) {
            key = '';
        }
        return [
            [this.groups.getOrDefault(key, '')],
            this.groupsParents.getOrDefault(key, new Array()),
            this.elements.getOrDefault(key, new Array())
        ];
    };
    return TreeListDefault;
}());
export { TreeListDefault };
//# sourceMappingURL=tree-list.class.js.map