import { queryNodes } from './queryNodes.js';
import { ErrorCode } from '../../../constants.js';
import { invokeUIMethodEndpoint } from '../../endpoints.js';
import { __InvokeUIMethod } from '../elementAPIs/pureElementPAPIs.js';
export function registerInvokeUIMethodHandler(rpc, lynxViewInstance) {
    rpc.registerHandler(invokeUIMethodEndpoint, (type, identifier, component_id, method, params, root_unique_id) => {
        let code = ErrorCode.UNKNOWN;
        let data = undefined;
        queryNodes(lynxViewInstance, type, identifier, component_id, true, root_unique_id, (element) => {
            __InvokeUIMethod(element, method, params, (res) => {
                code = res.code;
                data = res.data;
            });
        }, (error) => {
            code = error;
        });
        return { code, data };
    });
}
//# sourceMappingURL=registerInvokeUIMethodHandler.js.map