"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EServiceEnviroment=void 0,exports.initServices=initServices;const vsbase_1=require("../common/vsbase"),nativeModule_1=require("../nativeModule/common/nativeModule"),createService_1=require("../root/common/createService"),appDirService_1=require("../app/common/appDirService");var EServiceEnviroment;let _env;function getRootFactory(){let e;if(_env===EServiceEnviroment.SERVER)e=require("../root/server/root").Root;else if(_env===EServiceEnviroment.ELECTRON)e=require("../root/electron/root").Root;else if(_env===EServiceEnviroment.NW)e=require("../root/nw/root").Root;else{if(_env!==EServiceEnviroment.NODE)throw new Error("[Builder Services] Not Define Env");e=require("../root/node/root").Root}return e}!function(e){e.ELECTRON="ELECTRON",e.SERVER="SERVER",e.NW="NW",e.NODE="NODE"}(EServiceEnviroment||(exports.EServiceEnviroment=EServiceEnviroment={}));let _Root=null;function getServiceFactory(){return function(e){var r;let o;return _Root||(_Root=getRootFactory()),null===(r=_Root.iis)||void 0===r||r.invokeFunction(r=>{o=r.get(e)}),o}}async function initServices(e,r,o){let t,i;o&&(0,vsbase_1.setGetVsBaseBundle)(o),_env=e,e===EServiceEnviroment.SERVER?(i=require("../root/server/root").Root,t=require("../root/server/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.ELECTRON?(i=require("../root/electron/root").Root,t=require("../root/electron/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.NW?(i=require("../root/nw/root").Root,t=require("../root/nw/rootService").getSingletonServiceDescriptors):e===EServiceEnviroment.NODE&&(i=require("../root/node/root").Root,t=require("../root/node/rootService").getSingletonServiceDescriptors);const n=(0,createService_1.createService)(t());i.initIisWithServices(n.instantiationService),i.iis.invokeFunction(async e=>{"NativeModule"in r&&(e.get(nativeModule_1.INativeModuleService).setWXMLParsePath(r.NativeModule.WXMLParsePath),e.get(nativeModule_1.INativeModuleService).setWXSSParsePath(r.NativeModule.WXSSParsePath),e.get(nativeModule_1.INativeModuleService).setGlassEaselLazyModulePath(r.NativeModule.GlassEaselLazyModulePath),e.get(appDirService_1.IAppDirService).init(r.AppDirService))})}exports.default=getServiceFactory();