Object.defineProperty(exports, "__esModule", { value: true });
const babelPlugin_1 = require("./babelPlugin");
const handleEvalScript_1 = require("./handleEvalScript");
const getBabelOptions_1 = require("./getBabelOptions");
var Babel = window["Babel"];
delete window["__core-js_shared__"]; // Added by babel standalone, but breaks some lodash tests
let evalFn;
window["__fromJSEvalSetEvalFn"] = function (fn) {
    evalFn = fn;
};
function getEvalFn() {
    let ret;
    if (evalFn) {
        ret = evalFn;
        evalFn = null;
    }
    else {
        ret = eval;
    }
    return ret;
}
window["fromJSEval"] = function (code) {
    return window["__callExpression"]([[eval, null], [undefined, null], [[code]]], {}, null);
};
window["__fromJSEval"] = function (code) {
    function compile(code, url, done) {
        const babelResult = Babel.transform(code, getBabelOptions_1.default(babelPlugin_1.default, {}, url));
        babelResult.locs = getBabelOptions_1.getAndResetLocs();
        done(babelResult);
    }
    let returnValue;
    // handle eval script is sync because compile is sync!
    handleEvalScript_1.default(code, compile, {}, evalScript => {
        returnValue = {
            evalScript,
            returnValue: getEvalFn().call(this, evalScript.instrumentedCode)
        };
    });
    return returnValue;
};
//# sourceMappingURL=compileInBrowser.js.map