import type { ISDKPartialOptions } from './krispai/krispsdk';
import type { Tracer } from './tracer';
/**
 * Options to pass to the NoiseCancellation instance.
 */
export type NoiseCancellationOptions = {
    /**
     * The base path to load the models from.
     * You can override this if you want to host the models yourself.
     * @default `https://unpkg.com/@stream-io/audio-filters-web@${packageVersion}/src/krispai/models`.
     */
    basePath?: string;
    /**
     * When Krisp SDK detects buffer overflow, it will disable the filter and
     * wait for this timeout before enabling it again.
     * Defaults to 15000 ms.
     */
    restoreTimeoutMs?: number;
    /**
     * The number of attempts to restore the filter after a buffer overflow.
     * Defaults to 3.
     */
    restoreAttempts?: number;
    /**
     * Optional Krisp SDK parameters.
     */
    krispSDKParams?: ISDKPartialOptions['params'];
};
/**
 * An interface for the NoiseCancellation implementation.
 * Provided for easier unit testing.
 */
export interface INoiseCancellation {
    isSupported: () => boolean | Promise<boolean>;
    init: (options?: {
        tracer?: Tracer;
    }) => Promise<void>;
    isEnabled: () => Promise<boolean>;
    canAutoEnable?: () => Promise<boolean>;
    enable: () => Promise<void>;
    disable: () => Promise<void>;
    dispose: () => Promise<void>;
    resume: () => void;
    setSuppressionLevel: (level: number) => void;
    toFilter: () => (mediaStream: MediaStream) => {
        output: MediaStream;
    };
    on: <E extends keyof Events, T = Events[E]>(event: E, callback: T) => () => void;
    off: <E extends keyof Events, T = Events[E]>(event: E, callback: T) => void;
}
/**
 * A list of events one can subscribe to.
 */
export type Events = {
    /**
     * Fires when Noise Cancellation state changes.
     *
     * @param enabled true when enabled, false otherwise.
     */
    change: (enabled: boolean) => void;
};
/**
 * A wrapper around the Krisp.AI SDK.
 */
export declare class NoiseCancellation implements INoiseCancellation {
    private sdk?;
    private filterNode?;
    private audioContext?;
    private restoreTimeoutId?;
    private tracer?;
    private readonly initializing;
    private readonly resolveInitialized;
    private readonly basePath;
    private readonly restoreTimeoutMs;
    private readonly restoreAttempts;
    private readonly krispSDKParams?;
    private readonly listeners;
    /**
     * Constructs a new instance.
     */
    constructor({ basePath, restoreTimeoutMs, restoreAttempts, krispSDKParams, }?: NoiseCancellationOptions);
    /**
     * Checks if the noise cancellation is supported on this platform.
     * Make sure you call this method before trying to enable the noise cancellation.
     */
    isSupported: () => false | Promise<boolean>;
    /**
     * Initializes the KrispAI SDK.
     *
     * Will throw in case the noise cancellation is not supported on this platform
     * or if the SDK is already initialized.
     */
    init: (options?: {
        tracer?: Tracer;
    }) => Promise<void>;
    /**
     * Checks if the noise cancellation is enabled.
     */
    isEnabled: () => Promise<boolean>;
    /**
     * Enables the noise cancellation.
     */
    enable: () => Promise<void>;
    /**
     * Disables the noise cancellation.
     */
    disable: () => Promise<void>;
    /**
     * Disposes the instance and releases all resources.
     */
    dispose: () => Promise<void>;
    /**
     * Sets the noise suppression level (0-100).
     *
     * @param level 0 for no suppression, 100 for maximum suppression.
     */
    setSuppressionLevel: (level: number) => void;
    /**
     * A utility method convenient for our Microphone filters API.
     */
    toFilter: () => (mediaStream: MediaStream) => {
        output: MediaStream;
    };
    resume: () => void;
    /**
     * Registers the given callback to the event type;
     *
     * @param event the event to listen.
     * @param callback the callback to call.
     */
    on: <E extends keyof Events, T = Events[E]>(event: E, callback: T) => () => void;
    /**
     * Unregisters the given callback for the event type.
     *
     * @param event the event.
     * @param callback the callback to unregister.
     */
    off: <E extends keyof Events, T = Events[E]>(event: E, callback: T) => void;
    /**
     * Dispatches a new event payload for the given event type.
     *
     * @param event the event.
     * @param payload the payload.
     */
    private dispatch;
    /**
     * Handles the buffer overflow event.
     * Disables the filter and waits for the restore timeout before enabling it again.
     *
     * Based on: https://sdk-docs.krisp.ai/docs/getting-started-js#system-overload-handling
     */
    private handleBufferOverflow;
}
