import { WEBHOOK_EVENT_OPTIONS, WEBHOOK_EVENT_VALUES } from "@/lib/developers/catalog";
import type { AutomationActionType, WebhookEventType } from "@/types";

export const AUTOMATION_TRIGGER_OPTIONS: Array<{
  value: WebhookEventType;
  label: string;
}> = WEBHOOK_EVENT_OPTIONS;

export const AUTOMATION_TRIGGER_VALUES = WEBHOOK_EVENT_VALUES;

export const AUTOMATION_ACTION_OPTIONS: Array<{
  value: AutomationActionType;
  label: string;
  description: string;
}> = [
  {
    value: "send_slack",
    label: "Send to Slack",
    description: "Post the matching event into one connected Slack channel.",
  },
  {
    value: "send_telegram",
    label: "Send to Telegram",
    description: "Send the matching event into one connected Telegram chat.",
  },
  {
    value: "send_google_sheets",
    label: "Append to Google Sheets",
    description: "Forward the matching event to one connected Sheets webhook.",
  },
  {
    value: "send_notion",
    label: "Send to Notion",
    description: "Create a structured Notion page from the matching event.",
  },
  {
    value: "create_gmail_draft",
    label: "Create Gmail draft",
    description: "Create a draft email in one connected Gmail inbox from the matching event.",
  },
  {
    value: "create_task",
    label: "Create follow-up task",
    description: "Create a new task in this workspace when the rule matches.",
  },
  {
    value: "create_note",
    label: "Create note",
    description: "Create a structured note in this workspace when the rule matches.",
  },
  {
    value: "ai_create_task",
    label: "AI task",
    description: "Ask Mindavio AI to generate a follow-up task description and create it here.",
  },
  {
    value: "ai_create_note",
    label: "AI note",
    description: "Ask Mindavio AI to generate a summary note and save it in this workspace.",
  },
];

const ACTION_LABELS = new Map(
  AUTOMATION_ACTION_OPTIONS.map((option) => [option.value, option.label])
);

export function getAutomationActionLabel(actionType: AutomationActionType) {
  return ACTION_LABELS.get(actionType) || actionType;
}
