import React from "react";
import { Add, ArrowUp, Settings } from "@carbon/react/icons";
import { AppTeaserCards } from "./app-teaser-cards";
import { getReadableAppName } from "../../utils/camunda";
import { operatePreviewBase64, optimizePreviBase64, tasklistPreviewBase64, } from "../../assets/appTeaserPreviews";
export const teaserApps = ["tasklist", "operate", "optimize"];
const base64Src = (src) => `data:image/jpeg;base64,${src}`;
export const C3AppTeaser = ({ appName: app, hasTrialExpired, hasSleepingCluster, canUpgradePlan, canCreateCluster, onClickCta, pricing, }) => {
    const appName = app ? getReadableAppName(app) : "";
    const variants = {
        upgrade: {
            title: `Upgrade your plan${appName ? ` to use ${appName}` : ""}`,
            subtitle: `Your plan has expired, which means you won't be able to 
			create a cluster or access the following apps and features.`,
            ctaText: "Upgrade plan",
            ctaIcon: ArrowUp,
            disabledMessage: "Contact your admin to upgrade",
        },
        manageClusters: {
            title: `Resume your cluster${appName ? ` to use ${appName}` : ""}`,
            subtitle: `The applications displayed below require an active 
			cluster to run.`,
            ctaText: "Manage clusters",
            ctaIcon: Settings,
            disabledMessage: "Contact your admin to unpause your cluster",
        },
        createClusters: {
            title: `Create a cluster${appName ? ` to use ${appName}` : ""}`,
            subtitle: `The apps displayed below require a cluster to run. 
			Begin by creating your cluster.`,
            ctaText: "Create Cluster",
            ctaIcon: Add,
            disabledMessage: "Contact your admin to create a cluster",
        },
    };
    const variant = hasTrialExpired
        ? variants.upgrade
        : hasSleepingCluster
            ? variants.manageClusters
            : variants.createClusters;
    return (React.createElement(AppTeaserCards, { title: variant.title, subtitle: React.createElement(React.Fragment, null, variant.subtitle), subtext: hasTrialExpired && pricing
            ? `Plans starting at ${pricing.currency || ""}${pricing.amount || ""}${pricing.interval ? `/${pricing.interval}` : ""}`
            : "", cta: {
            action: onClickCta,
            text: variant.ctaText,
            renderIcon: variant.ctaIcon,
            disabled: hasTrialExpired ? !canUpgradePlan : !canCreateCluster,
            disabledMessage: variant.disabledMessage,
        }, cards: [
            {
                description: "Assign and execute tasks that require human interaction via easy-to-use Camunda Forms builder or your own apps with the API.",
                title: "Tasklist",
                id: "tasklist",
                img: {
                    altText: "tasklist teaser",
                    path: base64Src(tasklistPreviewBase64),
                },
            },
            {
                description: "Visualize, monitor, and troubleshoot your processes in real-time. Automate your process management and focus on growing your business.",
                title: "Operate",
                id: "operate",
                img: {
                    altText: "operate teaser",
                    path: base64Src(operatePreviewBase64),
                },
            },
            {
                description: "Advanced analytics and reporting capabilites help you track metrics, identify bottlenecks, and optimize workflows in real-time",
                title: "Optimize",
                id: "optimize",
                img: {
                    altText: "optimize teaser",
                    path: base64Src(optimizePreviBase64),
                },
            },
        ] }));
};
