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

export interface NumberBaseOptions {
  fromBase: "2" | "8" | "10" | "16";
  toBase: "2" | "8" | "10" | "16";
}

export const numberBasePlugin: PlimiPlugin<NumberBaseOptions> = {
  manifest: {
    id: "dev-numbase",
    name: "Number Base Converter",
    description: "Convert numbers between binary, octal, decimal, and hexadecimal.",
    category: "developer",
    version: "1.0.0",
    tags: ["number", "binary", "hex", "decimal", "octal", "base"],
    input: { type: "text", placeholder: "Enter a number...", multiline: false },
    output: { type: "json" },
    example: "255",
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "fromBase",
        label: "From Base",
        defaultValue: "10",
        options: [
          { label: "Binary (2)", value: "2" },
          { label: "Octal (8)", value: "8" },
          { label: "Decimal (10)", value: "10" },
          { label: "Hexadecimal (16)", value: "16" },
        ],
      },
      {
        type: "select",
        key: "toBase",
        label: "To Base",
        defaultValue: "16",
        options: [
          { label: "Binary (2)", value: "2" },
          { label: "Octal (8)", value: "8" },
          { label: "Decimal (10)", value: "10" },
          { label: "Hexadecimal (16)", value: "16" },
        ],
      },
    ],
  },

  capabilities: {
    cancelable: false,
    worker: false,
  },

  run: runNumberBase,
};
