"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const common_1 = require("../../../common");
const hooks_1 = require("../../hooks");
const utils_1 = require("../../../common/utils");
const parseRAM = (ramMib) => (0, utils_1.fileSize)(ramMib * 1024 * 1024, 2, 'iec');
const HostRequirementsContent = ({ clusterId, isSingleNode, isAddingHosts, }) => {
    var _a, _b, _c, _d;
    const { preflightRequirements, error, isLoading } = (0, hooks_1.useClusterPreflightRequirements)(clusterId);
    if (isLoading) {
        return react_1.default.createElement(common_1.LoadingState, { content: "Loading hardware requirements ..." });
    }
    if (error) {
        return react_1.default.createElement(common_1.ErrorState, null);
    }
    const masterQuantitativeData = (_b = (_a = preflightRequirements === null || preflightRequirements === void 0 ? void 0 : preflightRequirements.ocp) === null || _a === void 0 ? void 0 : _a.master) === null || _b === void 0 ? void 0 : _b.quantitative;
    const masterCpuCores = (masterQuantitativeData === null || masterQuantitativeData === void 0 ? void 0 : masterQuantitativeData.cpuCores) || 4;
    const masterRam = parseRAM((masterQuantitativeData === null || masterQuantitativeData === void 0 ? void 0 : masterQuantitativeData.ramMib) || 16 * 1024);
    const masterDiskSizeGb = (masterQuantitativeData === null || masterQuantitativeData === void 0 ? void 0 : masterQuantitativeData.diskSizeGb) || 100;
    const contentForControlPlaneNodes = `${masterCpuCores} CPU cores, ${masterRam} RAM, and ${masterDiskSizeGb} GB disk size.`;
    const workerQuantitativeData = (_d = (_c = preflightRequirements === null || preflightRequirements === void 0 ? void 0 : preflightRequirements.ocp) === null || _c === void 0 ? void 0 : _c.worker) === null || _d === void 0 ? void 0 : _d.quantitative;
    const workerCpuCores = (workerQuantitativeData === null || workerQuantitativeData === void 0 ? void 0 : workerQuantitativeData.cpuCores) || 2;
    const workerRam = parseRAM((workerQuantitativeData === null || workerQuantitativeData === void 0 ? void 0 : workerQuantitativeData.ramMib) || 16 * 1024);
    const workerDiskSizeGb = (workerQuantitativeData === null || workerQuantitativeData === void 0 ? void 0 : workerQuantitativeData.diskSizeGb) || 100;
    const contentForWorkerNodes = `${workerCpuCores} CPU cores, ${workerRam} RAM, and ${workerDiskSizeGb} GB disk size.`;
    if (isAddingHosts) {
        return (react_1.default.createElement(react_core_1.Content, { component: 'p' }, `Worker hosts must have at least ${contentForWorkerNodes}`));
    }
    let content;
    if (isSingleNode) {
        content = (react_1.default.createElement(react_core_1.List, null,
            react_1.default.createElement(react_core_1.ListItem, null, `One host is required with at least ${contentForControlPlaneNodes}`),
            react_1.default.createElement(react_core_1.ListItem, null, "Operators might require additional resources.")));
    }
    else {
        content = (react_1.default.createElement(react_core_1.List, null,
            react_1.default.createElement(react_core_1.ListItem, null, `Control plane nodes: At least ${contentForControlPlaneNodes}`),
            react_1.default.createElement(react_core_1.ListItem, null, `Workers: At least ${contentForWorkerNodes}`),
            react_1.default.createElement(react_core_1.ListItem, null,
                "Also note that each host's disk write speed should meet the minimum requirements to run OpenShift.",
                react_1.default.createElement("br", null),
                react_1.default.createElement(common_1.ExternalLink, { href: common_1.DISK_WRITE_SPEED_LINK }, "Learn more")),
            react_1.default.createElement(react_core_1.ListItem, null, "Operators might require additional resources.")));
    }
    return content;
};
exports.default = HostRequirementsContent;
//# sourceMappingURL=HostRequirementsContent.js.map