/**
 * List of built-in activities
 */
import {
    faChartBar,
    faColumns,
    faComments,
    faDatabase,
    faDownload,
    faFile,
    faFileContract,
    faFolder,
    faHdd,
    faLaptop,
    faList,
    faPlay,
    faSitemap,
    faTable,
    faUpload,
    faWrench,
} from "@fortawesome/free-solid-svg-icons";

import type { Activity } from "@/stores/activityStoreTypes";
import type { EventData } from "@/stores/eventStore";

export const defaultActivities = [
    {
        anonymous: true,
        description: "Opens a data dialog, allowing uploads from URL, pasted content or disk.",
        icon: faUpload,
        id: "upload",
        mutable: false,
        optional: false,
        panel: false,
        title: "Upload",
        to: null,
        tooltip: "Download from URL or upload files from disk",
        visible: true,
    },
    {
        anonymous: true,
        description: "Opens the new beta upload interface with experimental features.",
        icon: faUpload,
        id: "beta-upload",
        mutable: false,
        optional: true,
        panel: true,
        title: "Beta Upload",
        to: null,
        tooltip: "Try the new experimental upload interface",
        visible: false,
    },
    {
        anonymous: true,
        description: "Displays the tool panel to search and access all available tools.",
        icon: faWrench,
        id: "tools",
        mutable: false,
        optional: false,
        panel: true,
        title: "Tools",
        to: null,
        tooltip: "Search and run tools",
        visible: true,
    },
    {
        anonymous: true,
        description: "Displays the list of all histories.",
        icon: faHdd,
        id: "histories",
        mutable: false,
        optional: true,
        panel: false,
        title: "Histories",
        tooltip: "Show all histories",
        to: "/histories/list",
        visible: true,
    },
    {
        anonymous: false,
        description: "Displays all of your datasets across all histories.",
        icon: faFolder,
        id: "datasets",
        mutable: false,
        optional: true,
        panel: false,
        title: "Datasets",
        tooltip: "Show all datasets",
        to: "/datasets/list",
        visible: true,
    },
    {
        anonymous: false,
        description: "Display Data Libraries with datasets available to all users.",
        icon: faDatabase,
        id: "libraries",
        mutable: false,
        optional: true,
        panel: false,
        title: "Libraries",
        tooltip: "Access data libraries",
        to: "/libraries",
        visible: true,
    },
    {
        anonymous: true,
        description: "Displays the list of available visualizations.",
        icon: faChartBar,
        id: "visualizations",
        mutable: false,
        optional: true,
        panel: true,
        title: "Visualization",
        to: null,
        tooltip: "Visualize datasets",
        visible: true,
    },
    {
        anonymous: false,
        description: "AI-powered assistant to help with Galaxy tasks and troubleshooting.",
        icon: faComments,
        id: "chatgxy",
        mutable: false,
        optional: true,
        panel: true,
        title: "ChatGXY",
        to: "/chatgxy",
        tooltip: "Chat with Galaxy AI Assistant",
        visible: true,
        windowTitle: "ChatGXY",
    },
    {
        anonymous: true,
        description: "Displays a panel to search and access workflows.",
        icon: faSitemap,
        id: "workflows",
        mutable: false,
        optional: true,
        panel: false,
        title: "Workflows",
        to: "/workflows/list",
        tooltip: "Search and run workflows",
        visible: true,
    },
    {
        anonymous: false,
        description: "Displays all workflow runs.",
        icon: faList,
        id: "invocation",
        mutable: false,
        optional: true,
        panel: true,
        title: "Workflow Invocations",
        tooltip: "Show all workflow runs",
        to: null,
        visible: true,
    },
    {
        anonymous: false,
        description: "Displays currently running interactive tools (ITs), if these are enabled by the administrator.",
        icon: faLaptop,
        id: "interactivetools",
        mutable: false,
        optional: true,
        panel: true,
        title: "Interactive Tools",
        tooltip: "Show Active and available Interactive tools",
        to: "/interactivetool_entry_points/list",
        visible: true,
    },
    {
        anonymous: false,
        description: "Displays the history selector panel and opens History Multiview in the center panel.",
        icon: faColumns,
        id: "multiview",
        mutable: false,
        optional: true,
        panel: true,
        title: "History Multiview",
        tooltip: "Select histories to show in History Multiview",
        to: "/histories/view_multiple",
        visible: true,
    },
    {
        anonymous: true,
        description: "Display and create new pages.",
        icon: faFileContract,
        id: "pages",
        mutable: false,
        optional: true,
        panel: false,
        title: "Pages",
        tooltip: "Show all pages",
        to: "/pages/list",
        visible: true,
    },
    {
        anonymous: true,
        description: "Rule-based advanced import of datasets or collections.",
        icon: faTable,
        id: "rules",
        mutable: false,
        optional: true,
        panel: false,
        title: "Rule-based Data Import",
        tooltip: "Launch rule-based advanced import of datasets or collections",
        to: "/rules",
        visible: false,
    },
    {
        anonymous: false,
        description: "Displays tools defined by you.",
        icon: faWrench,
        id: "user-defined-tools",
        mutable: false,
        optional: true,
        panel: true,
        title: "Custom Tools",
        to: null,
        tooltip: "Search and run user-defined tools",
        visible: true,
    },
    {
        anonymous: false,
        description: "Manage your recent downloads.",
        icon: faDownload,
        id: "recent-downloads",
        mutable: false,
        optional: true,
        panel: false,
        title: "Recent Exports",
        to: "/downloads",
        tooltip: "Access your recent exports and downloads to check their status or download them again.",
        visible: true,
    },
] as const;

export function convertDropData(data: EventData): Activity | null {
    if (data.history_content_type === "dataset") {
        return {
            anonymous: true,
            description: "Displays this dataset.",
            icon: faFile,
            id: `dataset-${data.id}`,
            mutable: true,
            optional: true,
            panel: false,
            title: data.name as string,
            tooltip: "View your dataset",
            to: `/datasets/${data.id}/preview`,
            visible: true,
        };
    }
    if (data.model_class === "StoredWorkflow") {
        return {
            anonymous: false,
            description: data.description as string,
            icon: faPlay,
            id: `workflow-${data.id}`,
            mutable: true,
            optional: true,
            panel: false,
            title: data.name as string,
            tooltip: data.name as string,
            to: `/workflows/run?id=${data.id}`,
            visible: true,
        };
    }
    return null;
}
