"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkVersions = checkVersions;
const oj_module_proxy_1 = require("./oj-module-proxy");
/**
 * Check the running JET UI version against this oraclejet-webdriver package
 * version. It's expected that the JET UI is already fully loaded so that
 * "oj.version" and "oj.revision" will resolve.
 * If a mismatch is found, a console warning will be logged with the mismatched
 * values.
 * @param driver WebDriver instance
 * @private
 */
async function checkVersions(driver) {
    const pjson = require('../package.json');
    const version = pjson.version;
    const revision = pjson.config.revision;
    const jet = await (0, oj_module_proxy_1.executeWithModules)(driver, ['Core'], [], (core) => ({ version: core.version, revision: core.revision }));
    if (
    // Check if not local build (running from JET repo)
    !revision.match(/^#@@oj\.revision@@#$|^local:/) &&
        // or version mismatch
        (version !== jet.version || revision !== jet.revision)) {
        const mismatch = `version mismatch: oraclejet ${JSON.stringify(jet)}, oraclejet-webdriver ${JSON.stringify({ version, revision })}`;
        console.warn(`
  Your oraclejet UI version/revision does not match oraclejet-webdriver
  ${mismatch}
      `);
        throw Error(mismatch);
    }
}
//# sourceMappingURL=version-check.js.map