"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractPuppeteerText = void 0;
const secondArg = (args) => args[1];
const firstArg = (args) => args[0];
const returnValue = (_, returnValue) => typeof returnValue === 'string' ? returnValue : undefined;
const textMapping = {
    Page: {
        type: secondArg,
        evaluate: returnValue,
        goto: firstArg,
        $eval: returnValue,
    },
    ElementHandle: {
        type: firstArg,
        getProperty: firstArg,
    },
    Keyboard: {
        press: firstArg,
        type: firstArg,
    },
    Mouse: {
        move: JSON.stringify,
        click: JSON.stringify,
        down: JSON.stringify,
        up: JSON.stringify,
    },
    Frame: {
        focus: firstArg,
        type: secondArg,
    },
};
function extractPuppeteerText(puppeteerObject, fnName, args, returnValue) {
    var _a, _b;
    const type = puppeteerObject.constructor.name;
    return (_b = (_a = textMapping[type]) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, args, returnValue);
}
exports.extractPuppeteerText = extractPuppeteerText;
