/**
 * Google Gemini API Client
 *
 * Handles communication with Google Gemini API for translation
 * Supports dynamic config refresh when database settings change
 */
import { Tone, GeminiTranslationResponse, BulkStringItem, BulkTranslateResponse } from '../types';
import { StructuredFields } from '../utils/structuredFields';
export interface GeminiTokenUsage {
    inputTokens: number;
    outputTokens: number;
    totalTokens: number;
}
export declare function getGeminiTokenUsage(usageMetadata: unknown): GeminiTokenUsage;
declare class GeminiClient {
    private client;
    private model;
    private readonly timeout;
    private currentConfig;
    constructor();
    /**
     * Initialize or reinitialize the Gemini client with current config
     */
    private initializeClient;
    /**
     * Refresh the client configuration from database
     * Called automatically when config changes are detected
     */
    refreshConfig(): void;
    /**
     * Get current configuration (for debugging/monitoring)
     */
    getCurrentConfig(): {
        hasKey: boolean;
    } | null;
    /**
     * Extract and preserve HTML tags from content
     * Returns content with placeholders and mapping of tags
     */
    private extractHtmlTags;
    /**
     * Restore HTML tags from placeholders
     */
    private restoreHtmlTags;
    private assertStructuredPlaceholdersPreserved;
    private getToneInstruction;
    /**
     * Get language name from ISO code for better prompting
     */
    private getLanguageName;
    private withTimeout;
    /**
     * Translate content using Google Gemini API
     *
     * @param content Content to translate
     * @param sourceLang Source language (ISO 639-1 code)
     * @param targetLang Target language (ISO 639-1 code)
     * @param tone Translation tone/style
     * @returns Translation response with translated content, tokens used, and processing time
     * @throws Error if translation fails
     */
    private isRetryableError;
    translate(content: string, sourceLang: string, targetLang: string, tone?: Tone): Promise<GeminiTranslationResponse>;
    /**
     * Translate multiple strings in a single Gemini API call (token-efficient bulk mode).
     *
     * Extracts HTML tags from each string before building the JSON prompt,
     * then restores them in the response. On JSON parse failure the entire batch
     * is marked as failed so the caller can fall back gracefully.
     *
     * @param strings  Array of { id, content } pairs — id is echoed back unchanged
     * @param sourceLang Source language ISO 639-1 code
     * @param targetLang Target language ISO 639-1 code
     * @param tone Translation tone
     * @returns Array of results in the same order as the input
     */
    translateBulk(strings: BulkStringItem[], sourceLang: string, targetLang: string, tone?: Tone): Promise<BulkTranslateResponse>;
    /**
     * Translate structured post fields (title, excerpt, content) in a single Gemini call.
     *
     * Fields are HTML-tag-extracted individually before building a JSON prompt,
     * then HTML tags are restored per-field from the JSON response.
     */
    translateStructured(fields: StructuredFields, sourceLang: string, targetLang: string, tone?: Tone): Promise<{
        fields: StructuredFields;
        translatedFields: StructuredFields;
        translated_title?: string;
        translated_excerpt?: string;
        translated_content?: string;
        tokens_used: number;
        input_tokens: number;
        output_tokens: number;
        processing_time_ms: number;
        model_used: string;
    }>;
    /**
     * Check health of Gemini service
     * Tests API key validity with a minimal request
     *
     * @returns true if service is healthy, false otherwise
     */
    healthCheck(): Promise<boolean>;
}
export declare const geminiClient: GeminiClient;
export {};
//# sourceMappingURL=geminiClient.d.ts.map