"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAgentClusterInstallOfAgent = exports.getIsTNACluster = exports.getIsSNOCluster = void 0;
const agents_1 = require("./agents");
const getIsSNOCluster = (agentClusterInstall) => { var _a, _b; return ((_b = (_a = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.spec) === null || _a === void 0 ? void 0 : _a.provisionRequirements) === null || _b === void 0 ? void 0 : _b.controlPlaneAgents) === 1; };
exports.getIsSNOCluster = getIsSNOCluster;
const getIsTNACluster = (agentClusterInstall) => {
    var _a;
    return ((_a = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.spec) === null || _a === void 0 ? void 0 : _a.provisionRequirements.arbiterAgents) === 1 &&
        agentClusterInstall.spec.provisionRequirements.controlPlaneAgents === 2;
};
exports.getIsTNACluster = getIsTNACluster;
const getAgentClusterInstallOfAgent = (agentClusterInstalls, agent) => {
    if (!agent) {
        return undefined;
    }
    const cdName = (0, agents_1.getClusterNameOfAgent)(agent);
    if (!cdName) {
        return undefined;
    }
    return agentClusterInstalls.find((aci) => {
        var _a, _b;
        const ownerReference = (_b = (_a = aci.metadata) === null || _a === void 0 ? void 0 : _a.ownerReferences) === null || _b === void 0 ? void 0 : _b.find((or) => or.kind === 'ClusterDeployment' && or.name === cdName);
        return !!ownerReference;
    });
};
exports.getAgentClusterInstallOfAgent = getAgentClusterInstallOfAgent;
//# sourceMappingURL=agentClusterInstall.js.map