"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFailingResourceConditions = exports.getFailingAgentConditions = exports.REQUIRED_AGENT_CONDITION_TYPES = void 0;
exports.REQUIRED_AGENT_CONDITION_TYPES = ['SpecSynced', 'Connected', 'Validated'];
const getFailingAgentConditions = (agents = []) => {
    const agentsAlerts = {};
    const ofType = exports.REQUIRED_AGENT_CONDITION_TYPES;
    agents.forEach((a) => {
        var _a, _b, _c;
        const failingConds = (_b = (_a = a.status) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.filter((condition) => ofType.includes(condition.type) && condition.status === 'False');
        if (failingConds === null || failingConds === void 0 ? void 0 : failingConds.length) {
            agentsAlerts[((_c = a.metadata) === null || _c === void 0 ? void 0 : _c.name) || 'unknownname'] = failingConds;
        }
    });
    return agentsAlerts;
};
exports.getFailingAgentConditions = getFailingAgentConditions;
const getFailingResourceConditions = (resource = {}, 
// ofType === unknown matches ALL condition types
ofType) => {
    var _a, _b;
    return ((_b = (_a = resource.status) === null || _a === void 0 ? void 0 : _a.conditions) === null || _b === void 0 ? void 0 : _b.filter((c) => (!ofType || (ofType === null || ofType === void 0 ? void 0 : ofType.includes(c.type))) && c.status === 'False')) || [];
};
exports.getFailingResourceConditions = getFailingResourceConditions;
//# sourceMappingURL=conditions.js.map