import { EventEmitter } from 'node:events';
import type { StringRecord } from '@appium/types';
/**
 * Handles messages from the Web Inspector and dispatches them as events.
 * Extends EventEmitter to provide event-based message handling.
 */
export default class RpcMessageHandler extends EventEmitter {
    /**
     * Handles a message from the Web Inspector by parsing the selector
     * and emitting appropriate events.
     *
     * @param plist - The plist message from the Web Inspector containing
     *                __selector and __argument properties.
     */
    handleMessage(plist: StringRecord): Promise<void>;
    /**
     * Parses the data key from a plist message.
     * The data key is a JSON string that needs to be parsed.
     *
     * @param plist - The plist message containing the data key.
     * @returns The parsed DataMessage object.
     * @throws Error if the data key cannot be parsed.
     */
    private parseDataKey;
    /**
     * Dispatches a data message by emitting events.
     * If msgId is provided, emits a message-specific event.
     * Otherwise, emits method-based events with appropriate argument mapping.
     *
     * @param msgId - If not empty, emits an event with this ID: <msgId, error, result>.
     *                If empty, emits method-based events: <name, error, ...args>.
     * @param method - The method name from the data message.
     * @param params - The parameters from the data message.
     * @param result - The result from the data message.
     * @param error - Any error that occurred during message processing.
     */
    private dispatchDataMessage;
    /**
     * Handles a data message from the Web Inspector by parsing it and
     * dispatching appropriate events based on the message type.
     *
     * @param plist - The plist message from the Web Inspector.
     */
    private handleDataMessage;
}
//# sourceMappingURL=rpc-message-handler.d.ts.map