import { Options } from 'fast-glob';

declare function scanAndReplaceAll(): Promise<void>;

interface I18nConfig {
    locale: string;
    fallbackLocale?: string;
    outputDir: string;
    tempDir?: string;
    include: string[];
    exclude?: string[];
    keyGeneration?: {
        maxChineseLength?: number;
        hashLength?: number;
        maxRetryCount?: number;
        reuseExistingKey?: boolean;
        duplicateKeySuffix?: 'hash';
        keyPrefix?: string;
        separator?: string;
        pinyinOptions?: {
            toneType?: 'none' | 'symbol' | 'num';
            type?: 'string' | 'array';
        };
    };
    output?: {
        prettyJson?: boolean;
        localeFileName?: string;
    };
    logging?: {
        enabled?: boolean;
        level?: 'minimal' | 'normal' | 'verbose';
    };
    replacement?: {
        functionName?: string;
        quoteType?: 'single' | 'double';
        autoImport?: {
            enabled?: boolean;
            insertPosition?: 'top' | 'afterImports';
            imports?: {
                [filePattern: string]: {
                    importStatement: string;
                };
            };
        };
    };
    translation?: {
        enabled?: boolean;
        provider?: 'baidu' | 'custom';
        defaultSourceLang?: string;
        defaultTargetLang?: string;
        concurrency?: number;
        retryTimes?: number;
        retryDelay?: number;
        batchDelay?: number;
        baidu?: {
            appid?: string;
            key?: string;
        };
        custom?: {
            endpoint?: string;
            apiKey?: string;
        };
    };
    [key: string]: unknown;
}

declare function loadConfig(customConfigPath?: string): I18nConfig;
declare class ConfigManagerClass {
    private config;
    init(config: I18nConfig): void;
    get(): I18nConfig;
}
declare const ConfigManager: ConfigManagerClass;

declare function initI18nCache(): Promise<void>;
declare function createI18nKey(text: string): string;
declare function flushI18nCache(): Promise<void>;

/**
 * 读取文件内容
 */
declare function readFile(filePath: string, encoding?: BufferEncoding): Promise<string>;
/**
 * 写入文件内容
 */
declare function writeFile(filePath: string, data: string | Buffer): Promise<void>;
/**
 * 写入文件内容，支持 tempDir 配置
 * @param filePath 原始文件路径
 * @param data 文件内容
 * @param tempDir 临时目录，如果配置则写入到临时目录，否则写入原始位置
 */
declare function writeFileWithTempDir(filePath: string, data: string | Buffer, tempDir?: string): Promise<void>;
/**
 * 创建目录
 */
declare function ensureDir(dirPath: string): Promise<void>;
/**
 * 遍历目录下所有文件，支持glob模式和过滤参数
 */
declare function findFiles(pattern: string | string[], options?: Options): Promise<string[]>;
/**
 * 根据 include/exclude 参数筛选目标文件，所有路径以 CLI 执行目录为根目录
 * @param include 需要包含的文件模式（glob数组或字符串）
 * @param exclude 需要排除的文件模式（glob数组或字符串）
 */
declare function findTargetFiles(include: string[], exclude?: string[]): Promise<string[]>;
/**
 * 检查文件是否存在
 * @param filePath 文件路径
 */
declare function fileExists(filePath: string): boolean;
/**
 * 同步读取 JSON 文件内容
 * @param filePath JSON 文件路径
 */
declare function readJsonSync(filePath: string): unknown;
/**
 * 异步读取 JSON 文件内容
 * @param filePath JSON 文件路径
 * @param defaultValue 文件不存在时的默认值
 */
declare function readJson<T = unknown>(filePath: string, defaultValue?: T): Promise<T>;
/**
 * 异步写入 JSON 文件内容
 * @param filePath JSON 文件路径
 * @param data 要写入的数据
 * @param pretty 是否格式化输出，默认为 true
 */
declare function writeJson(filePath: string, data: unknown, pretty?: boolean): Promise<void>;

export { ConfigManager, createI18nKey, ensureDir, fileExists, findFiles, findTargetFiles, flushI18nCache, initI18nCache, loadConfig, readFile, readJson, readJsonSync, scanAndReplaceAll, writeFile, writeFileWithTempDir, writeJson };
