var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:true});exports.getEngineRunner=exports.getEngineByPlatform=void 0;
var _logger=require("../systemTools/logger");
var _common=require("../common");



var _engineRn=_interopRequireDefault(require("./engine-rn"));
var _engineRnWeb=_interopRequireDefault(require("./engine-rn-web"));
var _engineRnElectron=_interopRequireDefault(require("./engine-rn-electron"));
var _engineRnNext=_interopRequireDefault(require("./engine-rn-next"));
var _engineRnElectronNext=_interopRequireDefault(require("./engine-rn-electron-next"));

var ENGINES={
'engine-rn':_engineRn.default,
'engine-rn-web':_engineRnWeb.default,
'engine-rn-electron':_engineRnElectron.default,
'engine-rn-next':_engineRnNext.default,
'engine-rn-electron-next':_engineRnElectronNext.default};



var getEngineByPlatform=function getEngineByPlatform(c,platform,ignoreMissingError){
var selectedEngineKey;
if(c.buildConfig&&!!platform){var _c$files$rnv$engines$,_c$files$rnv$engines$2;
selectedEngineKey=(0,_common.getConfigProp)(c,platform,'engine');
var selectedEngine=(_c$files$rnv$engines$=c.files.rnv.engines.config)==null?void 0:(_c$files$rnv$engines$2=_c$files$rnv$engines$.engines)==null?void 0:_c$files$rnv$engines$2[selectedEngineKey];
if(!selectedEngine&&!ignoreMissingError){
(0,_logger.logError)("Engine: "+selectedEngineKey+" does not exists or is not registered");
(0,_logger.logRaw)(new Error());
}
return selectedEngine;
}
return null;
};exports.getEngineByPlatform=getEngineByPlatform;


var getEngineRunner=function getEngineRunner(c){
var selectedEngine=getEngineByPlatform(c,c.platform);
var engine=ENGINES[selectedEngine==null?void 0:selectedEngine.id];
if(!engine){
(0,_logger.logError)("Cound not find active engine with id "+(selectedEngine==null?void 0:selectedEngine.id)+". Available engines:\n"+
Object.keys(ENGINES).join(', '));
}
return engine;
};exports.getEngineRunner=getEngineRunner;
//# sourceMappingURL=index.js.map