"use strict";var e=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(n,a){function s(e){try{h(i.next(e))}catch(e){a(e)}}function o(e){try{h(i.throw(e))}catch(e){a(e)}}function h(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(s,o)}h((i=i.apply(e,t||[])).next())}))},t=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DependencyMapFile=void 0;const r=require("../../util"),i=require("../../common/message"),n=require("../../util/isFilePathSilentlySync"),a=t(require("../../log")),s=require("./types"),o=require("../../util/FsUtil"),h=t(require("path"));exports.DependencyMapFile=class{constructor(e){this.targetName="",this.rootDependency="",this.dependencyMap={},this.targetPath=e,this.filePath=this.resolveFilePath(h.default.join(e,s.DEPENDENCY_MAP_JSON)),a.default.debug("",`Found ${s.DEPENDENCY_MAP_JSON} in ${this.filePath}`)}loadDepMapFile(){return e(this,void 0,void 0,(function*(){const e=yield o.FsUtil.readJSON5(this.filePath);if(!e)return void a.default.warn("",`the content of ${this.filePath} is empty.`);this.targetName=e.targetName?e.targetName.trim():"",this.rootDependency=e.rootDependency?h.default.join(this.targetPath,e.rootDependency):"",this.dependencyMap={};const t=e.dependencyMap;if(t){Object.keys(t).forEach((e=>{let r=t[`${e}`];r&&!h.default.isAbsolute(r)&&(r=h.default.join(this.targetPath,r)),this.dependencyMap[`${e}`]=r||""}))}a.default.debug("",`Load file content of ${s.DEPENDENCY_MAP_JSON} - ${this.filePath} succeed, targetName: ${this.targetName}, dependencyMap: ${JSON.stringify(this.dependencyMap)}.`)}))}hasTargetName(){return!!this.targetName}getTargetName(){return this.targetName}getRootDependencyPath(){return this.rootDependency}needChangeLockFileName(){return!(!this.targetName||this.targetName===s.DEFAULT_TARGET_NAME)}getDependencyMap(){return this.dependencyMap}getModuleNames(){return Object.keys(this.dependencyMap)}getOhPkgJsonPath(e){const t=this.dependencyMap[`${e}`];if(!t)throw new Error((0,i.format)(i.Messages.Target.OhPkgPathEmptyError,{moduleName:e,filePath:this.filePath}));return t}getModuleOhPkgJson(t){return e(this,void 0,void 0,(function*(){return o.FsUtil.readJSON5(this.getOhPkgJsonPath(t))}))}resolveFilePath(e){if(!r.FsBlockingUtil.existsSync(e))throw new Error((0,i.format)(i.Messages.Target.FileUnExistError,{filePath:e}));if(!(0,n.isFilePathSilentlySync)(e))throw new Error((0,i.format)(i.Messages.Target.NotFilePathError,{filePath:e}));return e}};