"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.canNextFromReviewStep = exports.canNextFromNetworkingStep = exports.canNextFromHostDiscoveryStep = exports.canNextFromHostSelectionStep = exports.allClusterWizardSoftValidationIds = exports.wizardStepsValidationsMap = void 0;
const validationsInfoUtils_1 = require("../../../common/components/clusterWizard/validationsInfoUtils");
const clusterDetailsStepValidationsMap = {
    cluster: {
        groups: [],
        validationIds: ['pull-secret-set', 'dns-domain-defined'],
    },
    host: {
        allowedStatuses: [],
        groups: [],
        validationIds: [],
    },
    softValidationIds: [],
};
const hostDiscoveryStepValidationsMap = {
    cluster: {
        groups: [],
        validationIds: [
            'sufficient-masters-count',
            'odf-requirements-satisfied',
            'lso-requirements-satisfied',
            'cnv-requirements-satisfied',
        ],
    },
    host: {
        allowedStatuses: ['known', 'known-unbound', 'disabled'],
        groups: ['hardware'],
        validationIds: [
            'connected',
            'odf-requirements-satisfied',
            'lso-requirements-satisfied',
            'cnv-requirements-satisfied',
        ],
    },
    softValidationIds: [],
};
const networkingStepValidationsMap = {
    cluster: {
        groups: ['network'],
        validationIds: [],
    },
    host: {
        allowedStatuses: ['known', 'disabled'],
        groups: ['network'],
        validationIds: [],
    },
    // TODO(jtomasek): container-images-available validation is currently not running on the backend, it stays in pending.
    // marking it as soft validation is the easy way to prevent it from blocking the progress.
    // Alternatively we would have to whitelist network validations instead of using group
    // TODO(mlibra): remove that container-images-available from soft validations and let backend drive it via disabling it.
    //   Depends on: https://issues.redhat.com/browse/MGMT-5265
    softValidationIds: [
        'ntp-synced',
        'container-images-available',
        'custom-manifests-requirements-satisfied',
    ],
    getPageURL: (host, validationID) => {
        if (validationID === 'ntp-synced') {
            return {
                url: `multicloud/infrastructure/environments/details/${host.infraEnvId || ''}`,
                name: 'infrastructure environment',
            };
        }
        return undefined;
    },
};
const reviewStepValidationsMap = {
    cluster: {
        groups: [],
        validationIds: ['all-hosts-are-ready-to-install'],
    },
    host: {
        allowedStatuses: ['known', 'disabled'],
        groups: [],
        validationIds: [],
    },
    softValidationIds: [],
};
exports.wizardStepsValidationsMap = {
    'cluster-details': clusterDetailsStepValidationsMap,
    'hosts-discovery': hostDiscoveryStepValidationsMap,
    'hosts-selection': hostDiscoveryStepValidationsMap,
    networking: networkingStepValidationsMap,
    'custom-manifests': networkingStepValidationsMap,
    review: reviewStepValidationsMap,
};
exports.allClusterWizardSoftValidationIds = (0, validationsInfoUtils_1.getAllClusterWizardSoftValidationIds)(exports.wizardStepsValidationsMap);
const canNextFromClusterDeploymentWizardStep = (agentClusterInstall, agents, wizardStepId) => {
    var _a, _b, _c;
    const clusterStatus = (_b = (_a = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.status) === null || _a === void 0 ? void 0 : _a.debugInfo) === null || _b === void 0 ? void 0 : _b.state;
    const validationsInfo = (_c = agentClusterInstall === null || agentClusterInstall === void 0 ? void 0 : agentClusterInstall.status) === null || _c === void 0 ? void 0 : _c.validationsInfo;
    const hosts = agents.reduce((result, agent) => {
        var _a, _b, _c;
        const status = (_b = (_a = agent.status) === null || _a === void 0 ? void 0 : _a.debugInfo) === null || _b === void 0 ? void 0 : _b.state;
        if (status) {
            result.push({ status, validationsInfo: (_c = agent.status) === null || _c === void 0 ? void 0 : _c.validationsInfo });
        }
        return result;
    }, []);
    if (!clusterStatus) {
        return false;
    }
    return ((0, validationsInfoUtils_1.getWizardStepClusterStatus)(wizardStepId, exports.wizardStepsValidationsMap, { status: clusterStatus, validationsInfo: validationsInfo || {} }, hosts) === 'ready');
};
const canNextFromHostSelectionStep = (agentClusterInstall, agents) => canNextFromClusterDeploymentWizardStep(agentClusterInstall, agents, 'hosts-selection');
exports.canNextFromHostSelectionStep = canNextFromHostSelectionStep;
const canNextFromHostDiscoveryStep = (agentClusterInstall, agents) => canNextFromClusterDeploymentWizardStep(agentClusterInstall, agents, 'hosts-discovery');
exports.canNextFromHostDiscoveryStep = canNextFromHostDiscoveryStep;
const canNextFromNetworkingStep = (agentClusterInstall, agents) => canNextFromClusterDeploymentWizardStep(agentClusterInstall, agents, 'networking');
exports.canNextFromNetworkingStep = canNextFromNetworkingStep;
const canNextFromReviewStep = (agentClusterInstall, agents) => canNextFromClusterDeploymentWizardStep(agentClusterInstall, agents, 'review');
exports.canNextFromReviewStep = canNextFromReviewStep;
//# sourceMappingURL=wizardTransition.js.map