import { groupToMap } from '@antv/util';
/** @ignore */
export function group(data, fields, appendConditions) {
    if (appendConditions === void 0) { appendConditions = {}; }
    if (!fields) {
        return [data];
    }
    var groups = groupToMap(data, fields);
    var array = [];
    if (fields.length === 1 && appendConditions[fields[0]]) {
        var values = appendConditions[fields[0]];
        for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
            var value = values_1[_i];
            var arr = groups["_" + value];
            if (arr) {
                // 可能存在用户设置 values ，但是数据中没有对应的字段，则这时候 arr 就为 null
                array.push(arr);
            }
        }
    }
    else {
        for (var k in groups) {
            if (groups.hasOwnProperty(k)) {
                var eachGroup = groups[k];
                array.push(eachGroup);
            }
        }
    }
    return array;
}
//# sourceMappingURL=group-data.js.map