"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidFlashingCellRules = void 0;
const Utilities_1 = require("../../Components/EntityRulesEditor/Utilities");
const isValidFlashingCellRules = (flashingCell, api, context) => {
    var _a, _b;
    if (!((_b = (_a = flashingCell.Rule) === null || _a === void 0 ? void 0 : _a.Predicates) === null || _b === void 0 ? void 0 : _b.length) && !flashingCell.Rule.BooleanExpression) {
        return 'No Rule defined for Flashing Cell';
    }
    const isRuleValid = (0, Utilities_1.isAdaptableRuleValid)(flashingCell, api, context);
    if (typeof isRuleValid === 'string') {
        return isRuleValid;
    }
    // boolean expressions may also be saved as named queries
    if (context.namedQuery != false) {
        const isValidName = api.namedQueryApi.isValidNamedQuery(context.namedQuery);
        if (!isValidName.valid) {
            return isValidName.message;
        }
    }
    return true;
};
exports.isValidFlashingCellRules = isValidFlashingCellRules;
