"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProgressBarTexts = void 0;
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const react_core_1 = require("@patternfly/react-core");
const check_circle_icon_1 = require("@patternfly/react-icons/dist/js/icons/check-circle-icon");
const exclamation_circle_icon_1 = require("@patternfly/react-icons/dist/js/icons/exclamation-circle-icon");
const in_progress_icon_1 = require("@patternfly/react-icons/dist/js/icons/in-progress-icon");
const ClusterProgressItem_1 = tslib_1.__importDefault(require("./ClusterProgressItem"));
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const ProgressBarTexts = ({ hosts, hostRole }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const hostRoleText = hostRole === 'master'
        ? t('ai:Control Plane', { count: hosts.length })
        : t('ai:Worker', { count: hosts.length });
    if (hosts.some((host) => ['cancelled', 'error'].includes(host.status))) {
        const failedHostsCount = hosts.filter((host) => host.status === 'error').length;
        return (react_1.default.createElement(ClusterProgressItem_1.default, { icon: react_1.default.createElement(react_core_1.Icon, { status: "danger" },
                react_1.default.createElement(exclamation_circle_icon_1.ExclamationCircleIcon, null)) },
            react_1.default.createElement(react_1.default.Fragment, null,
                hostRoleText,
                react_1.default.createElement("br", null),
                react_1.default.createElement("small", null,
                    failedHostsCount,
                    "/",
                    hostRole === 'master'
                        ? t('ai:{{count}} control plane node failed', { count: hosts.length })
                        : t('ai:{{count}} worker failed', { count: hosts.length })))));
    }
    const installedHosts = hosts.filter((host) => ['installed', 'added-to-existing-cluster'].includes(host.status));
    const beingInstalledHosts = hosts.filter((host) => [
        'preparing-for-installation',
        'preparing-successful',
        'pending-for-input',
        'installing',
        'installing-in-progress',
        'installing-pending-user-action',
        'resetting-pending-user-action',
        'resetting',
    ].includes(host.status));
    if (beingInstalledHosts.length > 0) {
        return (react_1.default.createElement(ClusterProgressItem_1.default, { icon: react_1.default.createElement(in_progress_icon_1.InProgressIcon, null) },
            react_1.default.createElement(react_1.default.Fragment, null,
                hostRoleText,
                react_1.default.createElement("br", null),
                react_1.default.createElement("small", null, hostRole === 'master'
                    ? t('ai:Installing {{count}} control plane node', {
                        count: beingInstalledHosts.length,
                    })
                    : t('ai:Installing {{count}} worker', { count: beingInstalledHosts.length })))));
    }
    return (react_1.default.createElement(ClusterProgressItem_1.default, { icon: react_1.default.createElement(react_core_1.Icon, { status: "success" },
            react_1.default.createElement(check_circle_icon_1.CheckCircleIcon, null)) },
        react_1.default.createElement(react_1.default.Fragment, null,
            hostRoleText,
            react_1.default.createElement("br", null),
            react_1.default.createElement("small", null, hostRole === 'master'
                ? t('ai:{{count}} control plane node installed', { count: installedHosts.length })
                : t('ai:{{count}} worker installed', { count: installedHosts.length })))));
};
exports.ProgressBarTexts = ProgressBarTexts;
//# sourceMappingURL=ProgressBarTexts.js.map