"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getPredicateValues = getPredicateValues;
const get_with_default_1 = require("../objects/get-with-default");
const util_1 = require("../util");
const expandPredicates_1 = require("./_internal/expandPredicates");
/**
 * Get all the values for a predicate in a query
 * @param predicateProp The predicate property to get the values for
 * @param query The query to get the values from
 * @returns An array of all the values for the predicate
 */
function getPredicateValues(predicateProp, query, props = ["any", "all"]) {
    // ensure the query is expanded (meaning that the predicates are IMatchOptions)
    const expanded = (0, expandPredicates_1.expandPredicates)(query);
    return (
    // iterate over the filters
    expanded.filters
        // get all the predicates from all the filters and flatten...
        .reduce((acc, filter) => [...acc, ...filter.predicates], [])
        // get the `.any` and `.all` values for the prop
        .reduce((acc, predicate) => {
        // iterate the props and add them to the accumulator
        props.forEach((prop) => {
            acc = [
                ...acc,
                ...(0, get_with_default_1.getWithDefault)(predicate, `${predicateProp}.${prop}`, []),
            ];
        });
        return acc;
    }, [])
        // drop dupes
        .filter(util_1.unique));
}
//# sourceMappingURL=getPredicateValues.js.map