import { default as CortexElement } from '../../../../base/src/cortex-element.ts';
import * as signalR from '@microsoft/signalr';
/**
 * @summary The `cx-hub-connection` component is used to establish a connection to a SignalR hub.
 * https://learn.microsoft.com/en-us/javascript/api/%40microsoft/signalr/hubconnection?view=signalr-js-latest
 *
 * @event {{ args: any[] }} cx-invoked.[method_name] - Emitted when the method with such name is invoked on the server.
 * E.g: `cx-invoked.receiveMessage` will fire when `receiveMessage` method is invoked on the server.
 * @event {{ error: Error | undefined }} cx-hub-connection-reconnecting - Emitted when SignalR enters reconnecting state.
 * @event {{ connectionId: string | undefined }} cx-hub-connection-reconnected - Emitted when SignalR successfully reconnects.
 * @event {{ error: Error | undefined }} cx-hub-connection-disconnected - Emitted when SignalR closes the connection.
 */
export default class CxHubConnection extends CortexElement {
    private connection;
    /**
     * In case the connection is re-established, we need to re-register the event listeners.
     * This set stores the names of the method names that are being watched.
     */
    private readonly watchedMethods;
    /** The url of the HubConnection to the server. */
    baseUrl: string;
    /** Default interval at which to ping the server in milliseconds. */
    keepAliveIntervalInMilliseconds: number;
    /** Default server timeout in milliseconds. */
    serverTimeoutInMilliseconds: number;
    /** A boolean value that determines whether the negotiation step should be skipped when connecting to the server. */
    skipNegotiation: boolean;
    /** Enables SignalR automatic reconnect policy when set to true. */
    withAutomaticReconnect: boolean;
    /**
     * Optional reconnect delays in milliseconds passed to SignalR's overloaded
     * `withAutomaticReconnect(retryDelays)` API.
     */
    automaticReconnectRetryDelays?: number[];
    /**
     * Optional retry policy passed to SignalR's overloaded
     * `withAutomaticReconnect(retryPolicy)` API.
     */
    automaticReconnectRetryPolicy?: signalR.IRetryPolicy;
    /** The transport type for the connection. */
    transport: signalR.HttpTransportType;
    /**
     * Controls when the connection starts.
     */
    connectMode: 'manual' | 'auto';
    connectedCallback(): void;
    private readonly emitEvent;
    private registerConnectionLifecycleListeners;
    private registerEventListeners;
    onBaseUrlChanged(): void;
    private configureAutomaticReconnect;
    /** Starts the connection.
     * @returns A Promise that resolves when the connection is successfully started, or rejects with an error.
     */
    start(): Promise<void>;
    /** Stops the connection.
     * @returns A Promise that resolves when the connection is successfully stopped, or rejects with an error.
     */
    stop(): Promise<void>;
    /**
     * Invokes a hub method on the server using the specified method name and arguments.
     * @param methodName The name of the server method to invoke.
     * @param args The arguments to pass to the server method.
     * @returns A Promise that resolves with the result of the server method (if any), or rejects with an error.
     */
    invoke(methodName: string, ...args: any[]): Promise<any>;
}
declare global {
    interface HTMLElementTagNameMap {
        'cx-hub-connection': CxHubConnection;
    }
}
