import iconNodes from "lucide-static/icon-nodes.json" with { type: "json" };
import z from "zod";
import { createToolFactory, ToolCategory } from "../tools2/types.js";
let availableIcons = null;
function getAvailableIcons() {
    if (availableIcons !== null) {
        return availableIcons;
    }
    // Convert PascalCase icon names to kebab-case
    availableIcons = Object.keys(iconNodes).map((name) => name.replace(/([A-Z])/g, (_match, letter, index) => index === 0 ? letter.toLowerCase() : `-${letter.toLowerCase()}`));
    return availableIcons;
}
function findSimilarIcons(searchTerm) {
    const term = searchTerm.toLowerCase().replace(/[-_]/g, "");
    const icons = getAvailableIcons();
    if (icons.includes(searchTerm)) {
        return [searchTerm];
    }
    const suggestions = icons.filter((icon) => {
        const iconName = icon.toLowerCase().replace(/[-_]/g, "");
        return iconName.includes(term) || term.includes(iconName);
    });
    return [...new Set(suggestions)].slice(0, 5);
}
export const buildValidateIconsToolFactory = createToolFactory("build_getValidIcons", () => {
    return {
        category: ToolCategory.GENERAL,
        description: `
      Validate Lucide icon names and get suggestions for invalid ones.

      Icon naming conventions:
      - Use kebab-case (e.g., 'alert-circle', not 'AlertCircle')
      - No prefixes like 'Icon' or 'Lucide' (e.g., 'user', not 'IconUser')
      - No suffixes like 'X' for variations (e.g., 'flag', not 'FlagX')
      - Common icons: home, user, settings, search, menu, x, plus, trash, edit
    `,
        inputSchema: z.object({
            iconNames: z
                .array(z.string())
                .describe("Array of icon names to validate (e.g., ['flag', 'user', 'invalid-icon'])"),
        }),
        execute: async ({ iconNames }) => {
            const availableIcons = getAvailableIcons();
            return iconNames
                .filter((iconName) => !availableIcons.includes(iconName))
                .map((iconName) => ({
                name: iconName,
                suggestions: findSimilarIcons(iconName).slice(0, 5),
            }));
        },
        readOnly: true,
        getSummary: (input, output) => {
            const total = input.iconNames?.length ?? 0;
            const invalid = Array.isArray(output) ? output.length : 0;
            const valid = total - invalid;
            return {
                output: `${valid}/${total} valid`,
            };
        },
    };
});
//# sourceMappingURL=build-validate-icons.js.map