"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractPuppeteerSelector = void 0;
const firstArg = (args) => args[0];
const firstArgIfString = (args) => {
    if (typeof args[0] === 'string') {
        return args[0];
    }
    return undefined;
};
const commonSelectorMapping = {
    $: firstArg,
    $$: firstArg,
    $$eval: firstArg,
    $eval: firstArg,
    focus: firstArg,
    hover: firstArg,
    click: firstArg,
    type: firstArg,
    tap: firstArg,
    select: firstArg,
};
const selectorMapping = {
    Page: {
        ...commonSelectorMapping,
        waitFor: firstArgIfString,
        waitForSelector: firstArg,
    },
    ElementHandle: {
        ...commonSelectorMapping,
    },
    Keyboard: {},
    Mouse: {},
    Frame: {
        ...commonSelectorMapping,
        waitFor: firstArgIfString,
        waitForSelector: firstArg,
    },
};
function extractPuppeteerSelector(puppeteerObject, fnName, args) {
    var _a, _b;
    const type = puppeteerObject.constructor.name;
    return (_b = (_a = selectorMapping[type]) === null || _a === void 0 ? void 0 : _a[fnName]) === null || _b === void 0 ? void 0 : _b.call(_a, args);
}
exports.extractPuppeteerSelector = extractPuppeteerSelector;
