"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRowsDataFromFilters = exports.findValue = void 0;
var findAttributeSelectorItem = function (fieldName, attributesGroup) {
    var attrGroup;
    var _loop_1 = function (attributesGroupItem) {
        var findAttribute = function (fieldName, attributesSelectorItems) {
            for (var _i = 0, attributesSelectorItems_1 = attributesSelectorItems; _i < attributesSelectorItems_1.length; _i++) {
                var attributeGroup = attributesSelectorItems_1[_i];
                if (fieldName === attributeGroup.fieldName) {
                    attrGroup = attributeGroup;
                    return;
                }
                if ('children' in attributeGroup) {
                    findAttribute(fieldName, attributeGroup.children);
                }
            }
        };
        findAttribute(fieldName, attributesGroupItem.attributes);
        if (attrGroup) {
            return "break";
        }
    };
    for (var _i = 0, attributesGroup_1 = attributesGroup; _i < attributesGroup_1.length; _i++) {
        var attributesGroupItem = attributesGroup_1[_i];
        var state_1 = _loop_1(attributesGroupItem);
        if (state_1 === "break")
            break;
    }
    return attrGroup;
};
var findValue = function (options, filter) {
    return options ? options.find(function (option) { return option.value === filter; }) : null;
};
exports.findValue = findValue;
var getRowsDataFromFilters = function (filters, attributesGroupArr) {
    return filters.map(function (filter, index) {
        return {
            attribute: filter.fieldName ? findAttributeSelectorItem(filter.fieldName, attributesGroupArr) : undefined,
            filter: filter.filter,
            operator: filter.operator,
            id: index,
            values: filter.values
        };
    });
};
exports.getRowsDataFromFilters = getRowsDataFromFilters;
