import { DictionaryAPI } from "@intlayer/backend";
import { IntlayerConfig } from "@intlayer/types";

//#region src/IntlayerEventListener.d.ts
type IntlayerMessageEvent = MessageEvent;
/**
 * IntlayerEventListener class to listen for dictionary changes via SSE (Server-Sent Events).
 *
 * Usage example:
 *
 *   import { buildIntlayerDictionary } from './transpiler/declaration_file_to_dictionary/intlayer_dictionary';
 *   import { IntlayerEventListener } from '@intlayer/api';
 *
 *   export const checkDictionaryChanges = async () => {
 *     // Instantiate the listener
 *     const eventListener = new IntlayerEventListener();
 *
 *     // Set up your callbacks
 *     eventListener.onDictionaryChange = async (dictionary) => {
 *       await buildIntlayerDictionary(dictionary);
 *     };
 *
 *     // Initialize the listener
 *     await eventListener.initialize();
 *
 *     // Optionally, clean up later when you’re done
 *     // eventListener.cleanup();
 *   };
 */
declare class IntlayerEventListener {
  private intlayerConfig;
  private appLogger;
  private eventSource;
  private reconnectAttempts;
  private maxReconnectAttempts;
  private reconnectDelay;
  private isManuallyDisconnected;
  private reconnectTimeout;
  /**
   * Callback triggered when a Dictionary is ADDED.
   */
  onDictionaryAdded?: (dictionary: DictionaryAPI) => any;
  /**
   * Callback triggered when a Dictionary is UPDATED.
   */
  onDictionaryChange?: (dictionary: DictionaryAPI) => any;
  /**
   * Callback triggered when a Dictionary is DELETED.
   */
  onDictionaryDeleted?: (dictionary: DictionaryAPI) => any;
  /**
   * Callback triggered when connection is established or re-established.
   */
  onConnectionOpen?: () => any;
  /**
   * Callback triggered when connection encounters an error.
   */
  onConnectionError?: (error: Event) => any;
  constructor(intlayerConfig?: IntlayerConfig);
  /**
   * Initializes the EventSource connection using the given intlayerConfig
   * (or the default config if none was provided).
   */
  initialize(): Promise<void>;
  /**
   * Establishes the EventSource connection with automatic reconnection support.
   */
  private connect;
  /**
   * Cleans up (closes) the EventSource connection.
   */
  cleanup(): void;
  /**
   * Schedules a reconnection attempt with exponential backoff.
   */
  private scheduleReconnect;
  /**
   * Handles incoming SSE messages, parses the event data,
   * and invokes the appropriate callback.
   */
  private handleMessage;
  /**
   * Handles any SSE errors and attempts reconnection if appropriate.
   */
  private handleError;
}
//#endregion
export { IntlayerEventListener, IntlayerMessageEvent };
//# sourceMappingURL=IntlayerEventListener.d.ts.map