"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ojSelector = exports.OjSelector = void 0;
const __1 = require("../../");
const OjSelector_1 = require("./OjSelector");
Object.defineProperty(exports, "OjSelector", { enumerable: true, get: function () { return OjSelector_1.OjSelector; } });
/**
 * Retrieve an instance of [OjSelector](../classes/elements.OjSelector.html).
 * @example
 * ```javascript
 * import { ojSelector } from '@oracle/oraclejet-webdriver/elements';
 * const el = await ojSelector(driver, By.id('my-oj-selector'));
 * ```
 * @param driver A WebDriver/WebElement instance from where the element will be
 * searched. If WebDriver is passed, the element will be searched globally in the
 * document. If WebElement is passed, the search will be relative to this element.
 * @param by The locator with which to find the element
 */
async function ojSelector(driver, by) {
    const webEl = await driver.findElement(by);
    // Check that the element is of type OjSelector
    if (!(webEl instanceof OjSelector_1.OjSelector)) {
        const tagName = await webEl.getTagName();
        let supplemental = '';
        if (webEl.constructor.name === 'OjSelector') {
            supplemental = 'You likely have multiple installations of this package.';
        }
        throw Error(`ojSelector(${by}) created ${webEl.constructor.name} for <${tagName}>, but expected ${OjSelector_1.OjSelector.name}. ${supplemental}`);
    }
    return webEl;
}
exports.ojSelector = ojSelector;
(0, __1.register)('oj-selector', OjSelector_1.OjSelector);
//# sourceMappingURL=index.js.map