import React, { useEffect } from "react";
import { Title } from "../../hooks/useTitle";
import { DownloadItem } from "./DownloadItem";
import useDownloadItems from "../../hooks/useDownloadItems";
import { ButtonIcon } from "../common/ButtonIcon";
import { FEAGlobals } from "../../../common/Globals";
import "../../assets/css/download.css";
/**
 * UI for the Download Manager containing a list and data for downloads initiated across all windows.
 */
export const DownloadManager = (props) => {
    const { downloadItems, initDownloadItems, removeDownloadItem } = useDownloadItems();
    const launchPreferences = () => {
        FEAGlobals.FSBL.Clients.RouterClient.transmit("FinsembleUserPreferencesChannel", {
            preferencesTab: "General",
        });
        FEAGlobals.FSBL.Clients.LauncherClient.showWindow({
            componentType: "UserPreferences",
        }, {
            monitor: "mine",
            left: "center",
            top: "center",
        });
    };
    useEffect(() => {
        FEAGlobals.fin.desktop.System.getDownloadList((downloadList) => {
            initDownloadItems(downloadList);
        });
    }, []);
    return (React.createElement("div", null,
        React.createElement(Title, { title: "Download Manager" }),
        React.createElement("div", { className: "download-wrapper" },
            React.createElement("div", { className: "download-row" },
                React.createElement("div", { className: "download-header" },
                    React.createElement("div", { className: "download-title" }, "Downloads"),
                    React.createElement("div", { className: "download-settings" },
                        React.createElement(ButtonIcon, { text: "Settings", className: "download-settings-button", icon: "gear", onClick: launchPreferences })))),
            (downloadItems === null || downloadItems === void 0 ? void 0 : downloadItems.length) > 0 ? (React.createElement("div", null, downloadItems.map((downloadItem) => (React.createElement(DownloadItem, { key: `download-item-${downloadItem.id}`, downloadItem: downloadItem, remove: removeDownloadItem, ...props }))))) : (React.createElement("div", { className: "no-downloads" }, "No Downloads to Display")))));
};
//# sourceMappingURL=DownloadManager.js.map