"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultExpandComponent = exports.HostsTableEmptyState = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_core_1 = require("@patternfly/react-core");
const connected_icon_1 = require("@patternfly/react-icons/dist/js/icons/connected-icon");
const clusterConfiguration_1 = require("../clusterConfiguration");
const AITable_1 = tslib_1.__importDefault(require("../../../common/components/hosts/AITable"));
const HostRowDetail_1 = require("./HostRowDetail");
const EmptyState_1 = tslib_1.__importDefault(require("../ui/uiState/EmptyState"));
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const getHostId = (host) => host.id;
const HostsTableEmptyState = ({ setDiscoveryHintModalOpen, isSNO = false, }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (React.createElement(EmptyState_1.default, { icon: connected_icon_1.ConnectedIcon, title: t('ai:Waiting for host...', { count: +isSNO }), content: t('ai:Hosts may take a few minutes to appear here after booting.'), primaryAction: React.createElement(react_core_1.Spinner, { size: "xl" }), secondaryActions: setDiscoveryHintModalOpen && [
            React.createElement(clusterConfiguration_1.HostsNotShowingLink, { key: "hosts-not-showing", isSNO: isSNO, setDiscoveryHintModalOpen: setDiscoveryHintModalOpen }),
        ] }));
};
exports.HostsTableEmptyState = HostsTableEmptyState;
const DefaultExpandComponent = ({ obj }) => (React.createElement(HostRowDetail_1.HostDetail, { key: obj.id, host: obj }));
exports.DefaultExpandComponent = DefaultExpandComponent;
const HostsTable = (_a) => {
    var { hosts, skipDisabled, alreadySorted } = _a, rest = tslib_1.__rest(_a, ["hosts", "skipDisabled", "alreadySorted"]);
    const data = React.useMemo(() => {
        const filteredHosts = (hosts || []).filter((host) => !skipDisabled || host.status !== 'disabled');
        return alreadySorted
            ? filteredHosts
            : filteredHosts.sort((a, b) => a.createdAt && b.createdAt && a.createdAt < b.createdAt ? -1 : 1);
    }, [hosts, skipDisabled, alreadySorted]);
    return (React.createElement(AITable_1.default, Object.assign({ getDataId: getHostId, data: data, alreadySorted: alreadySorted }, rest)));
};
exports.default = HostsTable;
//# sourceMappingURL=HostsTable.js.map