"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const formik_1 = require("formik");
const react_core_1 = require("@patternfly/react-core");
const agents_1 = require("../helpers/agents");
const hostSelection_1 = require("./hostSelection");
const SwitchField_1 = tslib_1.__importDefault(require("../../../common/components/ui/formik/SwitchField"));
const ClusterScaleUpAutoHostsSelection_1 = tslib_1.__importDefault(require("./ClusterScaleUpAutoHostsSelection"));
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const RadioField_1 = tslib_1.__importDefault(require("../../../common/components/ui/formik/RadioField"));
const ScaleUpForm = ({ agents, onEditHost, onEditRole, onSetInstallationDiskId, isNutanix, }) => {
    const { values } = (0, formik_1.useFormikContext)();
    const { autoSelectHosts } = values;
    const availableAgents = react_1.default.useMemo(() => (0, agents_1.getAgentsForSelection)(agents).filter((agent) => {
        var _a, _b, _c, _d, _e, _f, _g, _h, _j;
        return !(((_b = (_a = agent.spec) === null || _a === void 0 ? void 0 : _a.clusterDeploymentName) === null || _b === void 0 ? void 0 : _b.name) || ((_d = (_c = agent.spec) === null || _c === void 0 ? void 0 : _c.clusterDeploymentName) === null || _d === void 0 ? void 0 : _d.namespace)) &&
            (isNutanix
                ? ((_g = (_f = (_e = agent.status) === null || _e === void 0 ? void 0 : _e.inventory) === null || _f === void 0 ? void 0 : _f.systemVendor) === null || _g === void 0 ? void 0 : _g.manufacturer) === 'Nutanix'
                : ((_j = (_h = agent.status) === null || _h === void 0 ? void 0 : _h.inventory.cpu) === null || _j === void 0 ? void 0 : _j.architecture) === values.cpuArchitecture);
    }), [agents, values.cpuArchitecture, isNutanix]);
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement(react_core_1.Form, null,
        react_1.default.createElement(SwitchField_1.default, { name: "autoSelectHosts", label: t('ai:Auto-select hosts') }),
        !isNutanix && (react_1.default.createElement(react_core_1.FormGroup, { fieldId: "cpuArchitecture", label: t('ai:CPU architecture') },
            react_1.default.createElement(react_core_1.Flex, { justifyContent: { default: 'justifyContentFlexStart' } },
                react_1.default.createElement(react_core_1.FlexItem, null,
                    react_1.default.createElement(RadioField_1.default, { name: "cpuArchitecture", id: "x86_64", value: "x86_64", label: t('ai:x86_64') })),
                react_1.default.createElement(react_core_1.FlexItem, null,
                    react_1.default.createElement(RadioField_1.default, { name: "cpuArchitecture", id: "arm64", value: "arm64", label: react_1.default.createElement(react_1.default.Fragment, null,
                            t('ai:arm64'),
                            "\u00A0") }))))),
        autoSelectHosts && react_1.default.createElement(ClusterScaleUpAutoHostsSelection_1.default, { availableAgents: availableAgents }),
        !autoSelectHosts && (react_1.default.createElement(hostSelection_1.ClusterDeploymentHostsSelectionAdvanced, { availableAgents: availableAgents, onEditHost: onEditHost, onEditRole: onEditRole, onSetInstallationDiskId: onSetInstallationDiskId }))));
};
exports.default = ScaleUpForm;
//# sourceMappingURL=ScaleUpForm.js.map