"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 ui_1 = require("../ui");
const DiscoveryInstructions_1 = tslib_1.__importDefault(require("./DiscoveryInstructions"));
const DiscoveryImageConfigForm_1 = require("./DiscoveryImageConfigForm");
const use_translation_wrapper_1 = require("../../hooks/use-translation-wrapper");
const external_link_alt_icon_1 = require("@patternfly/react-icons/dist/js/icons/external-link-alt-icon");
const config_1 = require("../../config");
const DownloadIso = ({ fileName = 'discovery.iso', downloadUrl, onClose, onReset, hasDHCP, isSNO = false, docVersion, updateTagsForCiscoIntersight, ciscoUrl, }) => {
    const wgetCommand = `wget -O ${fileName} '${downloadUrl || ''}'`;
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const openCiscoIntersightHostsLink = (downloadUrl) => {
        updateTagsForCiscoIntersight ? updateTagsForCiscoIntersight() : '';
        window.open((0, config_1.getCiscoIntersightLink)(downloadUrl, ciscoUrl), '_blank', 'noopener');
    };
    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:Discovery ISO is ready to be downloaded') },
                        react_1.default.createElement(react_1.default.Fragment, null,
                            "\u00A0",
                            react_1.default.createElement(DiscoveryInstructions_1.default, { isSNO: isSNO })))),
                hasDHCP === false && (react_1.default.createElement(react_core_1.StackItem, null,
                    react_1.default.createElement(DiscoveryImageConfigForm_1.StaticIPInfo, { docVersion: docVersion }))),
                react_1.default.createElement(react_core_1.StackItem, null,
                    react_1.default.createElement(react_core_1.Button, { variant: "link", icon: react_1.default.createElement(external_link_alt_icon_1.ExternalLinkAltIcon, null), iconPosition: "right", isInline: true, onClick: () => openCiscoIntersightHostsLink(downloadUrl) }, t('ai:Add hosts from Cisco Intersight'))),
                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:Discovery ISO 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 ISO:'), 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.StackItem, null,
                    react_1.default.createElement(react_core_1.Alert, { variant: "info", isInline: true, title: `${t('ai:Never share your downloaded ISO with anyone else.')} ${t('ai:Forwarding it could put your credentials and personal data at risk.')}` })))),
        react_1.default.createElement(react_core_1.ModalFooter, null,
            react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.primary, "data-testid": "download-iso-btn", isDisabled: !downloadUrl, component: 'a', target: "_blank", href: downloadUrl, download: true, rel: "noopener noreferrer" }, t('ai:Download Discovery ISO')),
            react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.secondary, onClick: onClose, "data-testid": "close-iso-btn" }, t('ai:Close')),
            onReset && (react_1.default.createElement(react_core_1.Button, { variant: react_core_1.ButtonVariant.link, onClick: onReset, "data-testid": "edit-iso-btn" }, t('ai:Edit ISO configuration'))))));
};
exports.default = DownloadIso;
//# sourceMappingURL=DownloadIso.js.map