"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.explainPredicate = explainPredicate;
const expandPredicate_1 = require("./expandPredicate");
const explainHelpers_1 = require("./explainHelpers");
/**
 * Geneate an explanation if a specific result passes the predicate's criteria
 * This will delegate to more specific functions based on the predicate's key
 * @param predicate
 * @param result
 * @param requestOptions
 * @returns
 */
async function explainPredicate(predicate, result, requestOptions) {
    // const predicateResult: IPredicateExplanation = {
    //   predicate: cloneObject(predicate),
    //   included: false,
    //   reasons: [],
    // };
    // get the key from the predicate
    const key = Object.keys(predicate)[0];
    // default to match options...
    let fn = explainHelpers_1.explainMatchOptionPredicate;
    // However, some keys are treated differently
    if (expandPredicate_1.PREDICATE_NON_MATCH_OPTIONS_PROPS.includes(key)) {
        if (expandPredicate_1.PREDICATE_DATE_PROPS.includes(key)) {
            // handle as date
            fn = explainHelpers_1.explainDatePredicate;
        }
        else {
            // handle as prop we just copy forward
            fn = explainHelpers_1.explainPropPredicate;
        }
    }
    // return the result
    return fn(predicate, result, requestOptions);
}
//# sourceMappingURL=explainPredicate.js.map