import type { PlimiPlugin } from "../../core/plugins/plugin-types";
import { runBase64 } from "./run";

export interface Base64Options {
  mode: "encode" | "decode";
}

export const base64Plugin: PlimiPlugin<Base64Options> = {
  manifest: {
    id: "base64",
    name: "Base64 Encoder / Decoder",
    description: "Encode or decode Base64 text locally.",
    category: "developer",
    version: "1.0.0",
    tags: ["base64", "encode", "decode"],
    input: { type: "text" },
    output: { type: "text" },
    example: "Hello, Plimi!",
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "mode",
        label: "Mode",
        defaultValue: "encode",
        options: [
          { label: "Encode", value: "encode" },
          { label: "Decode", value: "decode" },
        ],
      },
    ],
  },

  capabilities: {
    cancelable: false,
    worker: false, // Runs synchronously since it's very fast for normal text
  },

  run: runBase64,
};
