import { Workflow } from "../workflow-types";
import {
  assertWorkflowTemplateCompatibility,
  type WorkflowTemplateDefinition,
} from "./template-definition";
import { TEMPLATE_OWNER } from "./template-owner";
import {
  MONGODB_QA_AGENT_TEMPLATE,
  MONGODB_QA_AGENT_WORKFLOW,
} from "./mongodb-qa-agent";
import { PYTHON_AGENT_TEMPLATE, PYTHON_AGENT_WORKFLOW } from "./python-agent";
import {
  TELEGRAM_HELLO_TEMPLATE,
  TELEGRAM_HELLO_WORKFLOW,
} from "./telegram-hello";
import {
  TELEGRAM_HEARTBEAT_TEMPLATE,
  TELEGRAM_HEARTBEAT_WORKFLOW,
} from "./telegram-heartbeat";
import {
  TELEGRAM_AGENT_TEMPLATE,
  TELEGRAM_AGENT_WORKFLOW,
} from "./telegram-agent";
import {
  DISCORD_PRIVATE_LISTENER_TEMPLATE,
  DISCORD_PRIVATE_LISTENER_WORKFLOW,
} from "./discord-private-listener";
import {
  PRIVATE_BOT_SHARED_LISTENER_TEMPLATE,
  PRIVATE_BOT_SHARED_LISTENER_WORKFLOW,
} from "./private-bot-shared-listener";
import {
  QQ_PRIVATE_LISTENER_TEMPLATE,
  QQ_PRIVATE_LISTENER_WORKFLOW,
} from "./qq-private-listener";
import {
  TELEGRAM_PRIVATE_LISTENER_TEMPLATE,
  TELEGRAM_PRIVATE_LISTENER_WORKFLOW,
} from "./telegram-private-listener";
import {
  WECOM_LARK_SHARED_LISTENER_TEMPLATE,
  WECOM_LARK_SHARED_LISTENER_WORKFLOW,
} from "./wecom-lark-shared-listener";
import {
  WECHAT_PRIVATE_LISTENER_TEMPLATE,
  WECHAT_PRIVATE_LISTENER_WORKFLOW,
} from "./wechat-private-listener";
import { DEEP_AGENT_TEMPLATE, DEEP_AGENT_WORKFLOW } from "./deep-agent";
import {
  CHATKIT_WIDGETS_TEMPLATE,
  CHATKIT_WIDGETS_WORKFLOW,
} from "./chatkit-widgets";

export const SAMPLE_WORKFLOWS: Workflow[] = [
  PYTHON_AGENT_WORKFLOW,
  TELEGRAM_HELLO_WORKFLOW,
  TELEGRAM_HEARTBEAT_WORKFLOW,
  TELEGRAM_AGENT_WORKFLOW,
  DISCORD_PRIVATE_LISTENER_WORKFLOW,
  QQ_PRIVATE_LISTENER_WORKFLOW,
  PRIVATE_BOT_SHARED_LISTENER_WORKFLOW,
  TELEGRAM_PRIVATE_LISTENER_WORKFLOW,
  WECOM_LARK_SHARED_LISTENER_WORKFLOW,
  WECHAT_PRIVATE_LISTENER_WORKFLOW,
  MONGODB_QA_AGENT_WORKFLOW,
  DEEP_AGENT_WORKFLOW,
  CHATKIT_WIDGETS_WORKFLOW,
];

export const WORKFLOW_TEMPLATE_DEFINITIONS: WorkflowTemplateDefinition[] = [
  PYTHON_AGENT_TEMPLATE,
  TELEGRAM_HELLO_TEMPLATE,
  TELEGRAM_HEARTBEAT_TEMPLATE,
  TELEGRAM_AGENT_TEMPLATE,
  DISCORD_PRIVATE_LISTENER_TEMPLATE,
  QQ_PRIVATE_LISTENER_TEMPLATE,
  PRIVATE_BOT_SHARED_LISTENER_TEMPLATE,
  TELEGRAM_PRIVATE_LISTENER_TEMPLATE,
  WECOM_LARK_SHARED_LISTENER_TEMPLATE,
  WECHAT_PRIVATE_LISTENER_TEMPLATE,
  MONGODB_QA_AGENT_TEMPLATE,
  DEEP_AGENT_TEMPLATE,
  CHATKIT_WIDGETS_TEMPLATE,
];

const TEMPLATE_BY_ID = new Map(
  WORKFLOW_TEMPLATE_DEFINITIONS.map((definition) => [
    definition.workflow.id,
    definition,
  ]),
);

export const getWorkflowTemplateDefinition = (
  templateId: string,
): WorkflowTemplateDefinition | undefined => {
  return TEMPLATE_BY_ID.get(templateId);
};

export {
  assertWorkflowTemplateCompatibility,
  TEMPLATE_OWNER,
  MONGODB_QA_AGENT_TEMPLATE,
  MONGODB_QA_AGENT_WORKFLOW,
  PYTHON_AGENT_TEMPLATE,
  PYTHON_AGENT_WORKFLOW,
  DISCORD_PRIVATE_LISTENER_TEMPLATE,
  DISCORD_PRIVATE_LISTENER_WORKFLOW,
  PRIVATE_BOT_SHARED_LISTENER_TEMPLATE,
  PRIVATE_BOT_SHARED_LISTENER_WORKFLOW,
  WECOM_LARK_SHARED_LISTENER_TEMPLATE,
  WECOM_LARK_SHARED_LISTENER_WORKFLOW,
  TELEGRAM_AGENT_TEMPLATE,
  TELEGRAM_AGENT_WORKFLOW,
  QQ_PRIVATE_LISTENER_TEMPLATE,
  QQ_PRIVATE_LISTENER_WORKFLOW,
  TELEGRAM_PRIVATE_LISTENER_TEMPLATE,
  TELEGRAM_PRIVATE_LISTENER_WORKFLOW,
  TELEGRAM_HEARTBEAT_TEMPLATE,
  TELEGRAM_HEARTBEAT_WORKFLOW,
  TELEGRAM_HELLO_TEMPLATE,
  TELEGRAM_HELLO_WORKFLOW,
  WECHAT_PRIVATE_LISTENER_TEMPLATE,
  WECHAT_PRIVATE_LISTENER_WORKFLOW,
  DEEP_AGENT_TEMPLATE,
  DEEP_AGENT_WORKFLOW,
  CHATKIT_WIDGETS_TEMPLATE,
  CHATKIT_WIDGETS_WORKFLOW,
};
