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

export interface VariablesConverterOptions {
  toFormat: "auto" | "constant" | "dot" | "camel" | "pascal" | "snake" | "kebab";
}

export const variablesConverterPlugin: PlimiPlugin<VariablesConverterOptions> = {
  manifest: {
    id: "dev-varconvert",
    name: "Variables Converter",
    description: "Convert variable names between camelCase, PascalCase, snake_case, constant_case (A_B_C), dot.notation (a.b.c), and kebab-case.",
    category: "developer",
    version: "1.0.0",
    tags: ["variable", "casing", "convert", "camelcase", "snakecase", "naming"],
    input: {
      type: "text",
      placeholder: "e.g. user.profile.name or USER_PROFILE_NAME...",
      multiline: false,
    },
    output: { type: "json" },
    example: "user.profile.name",
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "toFormat",
        label: "Primary Format",
        defaultValue: "auto",
        options: [
          { label: "Auto (Detect)", value: "auto" },
          { label: "Constant Case (A_B_C)", value: "constant" },
          { label: "Dot Notation (a.b.c)", value: "dot" },
          { label: "Camel Case (aBC)", value: "camel" },
          { label: "Pascal Case (ABC)", value: "pascal" },
          { label: "Snake Case (a_b_c)", value: "snake" },
          { label: "Kebab Case (a-b-c)", value: "kebab" },
        ],
      },
    ],
  },

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

  run: runVariablesConverter,
};
