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

export interface RegexTesterOptions {
  flags: string;
}

export const regexTesterPlugin: PlimiPlugin<RegexTesterOptions> = {
  manifest: {
    id: "dev-regex",
    name: "Regex Tester",
    description: "Test regular expressions against text and see matches highlighted.",
    category: "developer",
    version: "1.0.0",
    tags: ["regex", "regexp", "test", "match"],
    input: {
      type: "group",
      fields: [
        {
          key: "pattern",
          label: "Regex Pattern",
          type: "text",
          multiline: false,
          placeholder: "Enter regex pattern here (e.g. [A-Z]\\w+)...",
          example: "[A-Z]\\w+",
        },
        {
          key: "text",
          label: "Test Text",
          type: "text",
          placeholder: "Enter test text here...",
          example: "Hello World, This Is A Test.",
        },
      ],
    },
    output: { type: "json" },
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "text",
        key: "flags",
        label: "Regex Flags",
        defaultValue: "gi",
        placeholder: "e.g. gi, g, i, gm",
      },
    ],
  },

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

  run: runRegexTester,
};
