import { ChannelSchema, ChannelType } from "@/types/notification";

export const channelSchemas: ChannelSchema[] = [
  {
    type: "telegram",
    name: "Telegram Bot",
    description: "Telegram Bot API with media support",
    fields: [
      {
        name: "bot_token",
        type: "text",
        label: "Bot Token",
        placeholder: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
        required: true,
        description: "Get from @BotFather",
      },
      {
        name: "chat_id",
        type: "text",
        label: "Chat ID",
        placeholder: "@your_channel or user_id",
        required: true,
        description: "Channel username or user ID",
      },
      {
        name: "parse_mode",
        type: "select",
        label: "Parse Mode",
        required: false,
        description: "Message formatting mode",
        options: [
          { value: "", label: "None" },
          { value: "Markdown", label: "Markdown" },
          { value: "MarkdownV2", label: "MarkdownV2" },
          { value: "HTML", label: "HTML" },
        ],
      },
    ],
  },
  {
    type: "discord",
    name: "Discord Webhook",
    description: "Discord webhook notifications with rich embeds",
    fields: [
      {
        name: "webhook_url",
        type: "url",
        label: "Webhook URL",
        placeholder: "https://discord.com/api/webhooks/...",
        required: true,
        description: "Discord webhook URL",
      },
      {
        name: "username",
        type: "text",
        label: "Username",
        placeholder: "VoceChat Bot",
        required: false,
        description: "Override webhook username",
      },
      {
        name: "avatar_url",
        type: "url",
        label: "Avatar URL",
        placeholder: "https://example.com/avatar.png",
        required: false,
        description: "Override webhook avatar",
      },
    ],
  },
  {
    type: "feishu",
    name: "Feishu Bot",
    description: "Feishu (Lark) webhook notifications",
    fields: [
      {
        name: "webhook_url",
        type: "url",
        label: "Webhook URL",
        placeholder: "https://open.feishu.cn/open-apis/bot/v2/hook/...",
        required: true,
        description: "Feishu webhook URL",
      },
      {
        name: "sign_secret",
        type: "text",
        label: "Sign Secret",
        placeholder: "Optional signing secret",
        required: false,
        description: "For signature verification",
      },
    ],
  },
  {
    type: "dingtalk",
    name: "DingTalk Bot",
    description: "DingTalk webhook notifications",
    fields: [
      {
        name: "webhook_url",
        type: "url",
        label: "Webhook URL",
        placeholder: "https://oapi.dingtalk.com/robot/send?access_token=...",
        required: true,
        description: "DingTalk webhook URL",
      },
      {
        name: "sign_secret",
        type: "text",
        label: "Sign Secret",
        placeholder: "Optional signing secret",
        required: false,
        description: "For signature verification",
      },
    ],
  },
  {
    type: "wecombot",
    name: "WeCom Bot",
    description: "WeCom (WeChat Work) webhook notifications",
    fields: [
      {
        name: "webhook_url",
        type: "url",
        label: "Webhook URL",
        placeholder: "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=...",
        required: true,
        description: "WeCom webhook URL",
      },
    ],
  },
  {
    type: "bark",
    name: "Bark",
    description: "Bark iOS notification service",
    fields: [
      {
        name: "server_url",
        type: "url",
        label: "Server URL",
        placeholder: "https://api.day.app",
        required: true,
        description: "Bark server URL",
      },
      {
        name: "device_key",
        type: "text",
        label: "Device Key",
        placeholder: "Your device key",
        required: true,
        description: "Device key from Bark app",
      },
      {
        name: "sound",
        type: "text",
        label: "Sound",
        placeholder: "default",
        required: false,
        description: "Notification sound name",
      },
    ],
  },
  {
    type: "gotify",
    name: "Gotify",
    description: "Gotify self-hosted notification server",
    fields: [
      {
        name: "server_url",
        type: "url",
        label: "Server URL",
        placeholder: "https://gotify.example.com",
        required: true,
        description: "Gotify server URL",
      },
      {
        name: "app_token",
        type: "text",
        label: "App Token",
        placeholder: "Application token",
        required: true,
        description: "Application token from Gotify",
      },
      {
        name: "priority",
        type: "number",
        label: "Priority",
        placeholder: "5",
        required: false,
        description: "Message priority (0-10)",
      },
    ],
  },
  {
    type: "serverchan",
    name: "Server Chan",
    description: "Server Chan notification service",
    fields: [
      {
        name: "send_key",
        type: "text",
        label: "SendKey",
        placeholder: "Your SendKey",
        required: true,
        description: "SendKey from Server Chan",
      },
    ],
  },
  {
    type: "pushdeer",
    name: "PushDeer",
    description: "PushDeer notification service",
    fields: [
      {
        name: "server_url",
        type: "url",
        label: "Server URL",
        placeholder: "https://api2.pushdeer.com",
        required: true,
        description: "PushDeer server URL",
      },
      {
        name: "push_key",
        type: "text",
        label: "Push Key",
        placeholder: "Your push key",
        required: true,
        description: "Push key from PushDeer",
      },
    ],
  },
  {
    type: "matrix",
    name: "Matrix",
    description: "Matrix protocol notifications",
    fields: [
      {
        name: "homeserver_url",
        type: "url",
        label: "Homeserver URL",
        placeholder: "https://matrix.org",
        required: true,
        description: "Matrix homeserver URL",
      },
      {
        name: "access_token",
        type: "text",
        label: "Access Token",
        placeholder: "Your access token",
        required: true,
        description: "Matrix access token",
      },
      {
        name: "room_id",
        type: "text",
        label: "Room ID",
        placeholder: "!roomid:matrix.org",
        required: true,
        description: "Matrix room ID",
      },
    ],
  },
  {
    type: "custom_json",
    name: "Custom JSON Webhook",
    description: "Custom HTTP webhook with JSON payload",
    fields: [
      {
        name: "webhook_url",
        type: "url",
        label: "Webhook URL",
        placeholder: "https://example.com/webhook",
        required: true,
        description: "HTTP endpoint URL",
      },
      {
        name: "method",
        type: "select",
        label: "HTTP Method",
        required: true,
        description: "HTTP request method",
        options: [
          { value: "POST", label: "POST" },
          { value: "PUT", label: "PUT" },
          { value: "PATCH", label: "PATCH" },
        ],
      },
      {
        name: "headers",
        type: "textarea",
        label: "Custom Headers",
        placeholder: '{"Authorization": "Bearer token"}',
        required: false,
        description: "JSON object with custom headers",
      },
      {
        name: "body_template",
        type: "textarea",
        label: "Body Template",
        placeholder: '{"message": "{{content}}", "user": "{{sender}}"}',
        required: false,
        description: "JSON template with placeholders",
      },
    ],
  },
];

export function getChannelSchema(type: ChannelType): ChannelSchema | undefined {
  return channelSchemas.find((s) => s.type === type);
}
