"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const react_1 = tslib_1.__importDefault(require("react"));
const file_saver_1 = require("file-saver");
const react_core_1 = require("@patternfly/react-core");
const ui_1 = require("../ui");
const DiscoveryIpxeInstructions_1 = tslib_1.__importDefault(require("./DiscoveryIpxeInstructions"));
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const DownloadIpxeScript = ({ fileName = 'ipxe-script.txt', downloadUrl, onClose, onReset, }) => {
    const wgetCommand = `wget -O ${fileName} '${downloadUrl || ''}'`;
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (react_1.default.createElement(react_1.default.Fragment, null,
        react_1.default.createElement(react_core_1.ModalBody, null,
            react_1.default.createElement(react_core_1.Stack, { hasGutter: true },
                react_1.default.createElement(react_core_1.StackItem, null,
                    react_1.default.createElement(react_core_1.Alert, { isInline: true, variant: "success", title: t('ai:iPXE script file is ready to be downloaded') },
                        react_1.default.createElement(react_1.default.Fragment, null,
                            "\u00A0",
                            react_1.default.createElement(DiscoveryIpxeInstructions_1.default, null)))),
                react_1.default.createElement(react_core_1.StackItem, null,
                    react_1.default.createElement(ui_1.DetailList, null,
                        react_1.default.createElement(ui_1.DetailItem, { title: t('ai:iPXE script file URL'), value: react_1.default.createElement(react_core_1.ClipboardCopy, { isReadOnly: true, onCopy: (event) => (0, react_core_1.clipboardCopyFunc)(event, downloadUrl) }, downloadUrl) }),
                        react_1.default.createElement(ui_1.DetailItem, { title: t('ai:Command to download the iPXE script file'), value: react_1.default.createElement(react_core_1.ClipboardCopy, { isReadOnly: true, onCopy: (event) => (0, react_core_1.clipboardCopyFunc)(event, wgetCommand) }, wgetCommand) }))))),
        react_1.default.createElement(react_core_1.ModalFooter, null,
            react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.primary, onClick: () => downloadUrl && (0, file_saver_1.saveAs)(downloadUrl), "data-testid": "download-ipxe-btn", isDisabled: !downloadUrl }, t('ai:Download script file')),
            onReset && (react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.secondary, onClick: onReset, "data-testid": "close-ipxe-btn" }, t('ai:Back'))),
            react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.link, onClick: onClose, "data-testid": "edit-ipxe-btn" }, t('ai:Cancel')))));
};
exports.default = DownloadIpxeScript;
//# sourceMappingURL=DownloadIpxeScript.js.map