import { TranslationConfig, TranslationResult } from '../types'; export declare class TranslationWidget { private config; private translationService?; private currentLanguage; private widget; private elements; private autoDetectLanguage; private isTranslated; private userLanguage; private isTranslating; private observer; private translationScheduled; private scheduleTimeout; private showUI; private lastTranslated; private static instance; private currentTranslationPromise; private lastRequestedLanguage; private translationRequestId; /** * @param publicKey - The public api key for the translation widget * @param config - The configuration for the translation widget */ constructor(publicKey: string, config?: Partial); /** * Initializes the translation widget */ private initialize; /** * Gets the value of a URL parameter * @param name - The name of the URL parameter * @returns The value of the URL parameter */ private getUrlParameter; /** * Sets up the content observer */ private setupContentObserver; /** * Observes the body for changes */ private observeBody; /** * Handles the URL change */ private onUrlChange; /** * Sets up the URL observer */ private setupURLObserver; /** * Creates the widget */ private createWidget; /** * Gets the current language label * @returns The current language label */ private getCurrentLanguageLabel; /** * Creates the widget HTML * @param currentLanguageLabel - The current language label * @returns The widget HTML */ private createWidgetHTML; /** * Creates the language options * @returns The language options */ private createLanguageOptions; /** * Updates the trigger text * @param newText - The new text */ private updateTriggerText; /** * Gets the text to translate * @param node - The node to translate * @param parent - The parent element * @param targetLang - The target language * @returns The text to translate */ private getTextToTranslate; /** * Calculates the font size * @param text - The text to calculate the font size for * @param originalFontSize - The original font size * @param originalText - The original text * @returns The font size */ private calculateFontSize; /** * Updates the loading state * @param isLoading - Whether the widget is loading */ private updateLoadingState; /** * Main function to translate the page * * Handles the translation of the page for multiple languages * * 1. Increments the request ID for each new translation * 2. Waits for the current translation to complete * 3. If the target language is the default page language, resets the translations * 4. Creates a new promise for each translation and awaits it * * @param targetLang - The target language */ private translatePage; /** * Reset to default Page language * @returns */ resetToDefaultLanguage(): void; private _translatePage; /** * Updates the visibility of the reset button */ private updateResetButtonVisibility; /** * Resets the translations */ private resetTranslations; /** * Adjusts the dropdown position */ private adjustDropdownPosition; /** * Sets up the event listeners */ private setupEventListeners; private scheduleTranslation; /** * Public method to translate the page to a specific language * @param langCode The language code to translate to * @returns Promise that resolves when translation is complete */ translateTo(langCode: string, onComplete?: (result: TranslationResult) => void, onError?: (error: Error) => void): Promise; /** * Get the current instance of TranslationWidget * @returns The current TranslationWidget instance or null if not initialized */ static getInstance(): TranslationWidget | null; private getLanguageSVG; /** * Safely sets HTML content for translated text, handling nested HTML structures * @param element - The element to update * @param translatedText - The translated text that may contain HTML */ private setTranslatedContent; } declare global { interface Window { resetTranslation: (defaultLang: string, onComplete?: (result: Pick) => void, onError?: (error: Error) => void) => void; translate: (langCode: string, onComplete?: (result: TranslationResult) => void, onError?: (error: Error) => void) => Promise; clearCache: (lang_code: string[], onComplete?: () => void, onError?: (error: Error) => void) => void; } }