import { Observable } from 'rxjs';
import * as i0 from "@angular/core";
export type EventName = 'RESOURCE_CREATED' | 'RESOURCE_UPDATED' | 'RESOURCE_DELETED';
/**
 * Service for handling real-time server-sent events.
 *
 * ### Benefits
 *
 * - **Real-Time Interaction**: Enables live updates without user actions or polling.
 * - **Scalable and Flexible**: The system is flexible and easily expandable to handle new events.
 * - **Consistency**: Ensures synchronization between server and client states for a consistent user experience.
 * - **Authorization**: It uses the user's authentication (QdAuth) to secure the connection against the backend out-of-the-box. This requires a proper QdAuth setup. You can disable this feature when starting the connection.
 *
 * ### Usage
 *
 * ```ts
 * // Start the connection to the events
 * pushEventsService.connect('http://service-endpint/events');
 * // or start without authentication in case you don't need:
 * pushEventsService.connect('http://service-endpint/events', { disableAuthentication: true });
 *
 * // Subscribe to the event (Side Effect)
 * const subscription = pushEventsService.observe('RESOURCE_UPDATED').subscribe(event => handleEvent(event));
 *
 * // Unsubscribe to prevent memory leaks
 * subscription.unsubscribe();
 *
 * // Disconnect the connection
 * pushEventsService.disconnect();
 * ```
 */
export declare class QdPushEventsService {
    private readonly authenticationService;
    private _eventSource;
    private _eventSubscriptionSubjects;
    private _listeners;
    private _heartbeatTimeout;
    private _reconnectDelayTime;
    private _heartbeatReconnectDelayTime;
    private _accessTokenSub?;
    private _options;
    private _isUnauthorized;
    constructor(authenticationService: any);
    /**
     * Establishes an EventSource connection to the given URL.
     * Automatically reconnects if heartbeat fails or is delayed.
     * Subscribers are retained across reconnections.
     *
     * @param url The backend URL for the event stream.
     * @param options Options for the connection
     */
    connect(url: string, options?: {
        disableAuthentication: boolean;
    }): void;
    /**
     * Closes the EventSource connection and clears all listeners.
     * Subscribers are preserved for reconnection.
     */
    disconnect(): void;
    /**
     * Returns an Observable for the specified event name.
     * If not connected, returns `NEVER` and logs an error.
     * Automatically adds a listener for the event if needed.
     *
     * @param eventName The event type ('RESOURCE_CREATED', 'RESOURCE_UPDATED', 'RESOURCE_DELETED').
     * @returns Observable<MessageEvent> The event stream.
     */
    observe(eventName: EventName): Observable<MessageEvent>;
    /**
     * Removes all listeners and clears all subscriptions.
     * The EventSource connection remains open.
     */
    unobserveAll(): void;
    /**
     * Checks if the EventSource is connected or in the process of connecting.
     */
    isConnectedOrConnecting(): boolean;
    private reconnect;
    private addEventListenerForEventName;
    private addEventListenersForExistingSubscriptions;
    private addEventListenerToEventSource;
    private removeAllEventListenersFromEventSource;
    private logWarn;
    private logError;
    private connectEventSource;
    static ɵfac: i0.ɵɵFactoryDeclaration<QdPushEventsService, [{ optional: true; }]>;
    static ɵprov: i0.ɵɵInjectableDeclaration<QdPushEventsService>;
}
//# sourceMappingURL=push-events.service.d.ts.map