"use strict";var t=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(u,r){function o(t){try{a(i.next(t))}catch(t){r(t)}}function s(t){try{a(i.throw(t))}catch(t){r(t)}}function a(t){var e;t.done?u(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(o,s)}a((i=i.apply(t,e||[])).next())}))},e=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.InstallInfo=exports.auditRequest=exports.getUUID=exports.installCostAudit=exports.installResultAudit=exports.commandAudit=void 0;const n=e(require("node-fetch")),i=require("../registry"),u=require("uuid"),r=e(require("fs-extra")),o=e(require("os")),s=require("../../common/Constants"),a=require("../../common/ohpm.config"),l=e(require("../../log"));function c(){try{const t=`${o.default.homedir}/${s.Constants.PmDir}/ufile`;r.default.existsSync(t)||r.default.createFileSync(t);let e=r.default.readFileSync(t,"utf-8");return null!=e&&e.length||(e=(0,u.v4)().replace(/-/g,""),r.default.writeFileSync(t,e)),e}catch(t){return void l.default.debug("",`getUUID failed. err: ${t}`)}}exports.commandAudit=function(t){return{command:{uuid:c(),command:t}}},exports.installResultAudit=function(t){return{installResult:{uuid:c(),installResult:t}}},exports.installCostAudit=function(t,e){return{installCost:{uuid:c(),totalCost:t,packageNum:e}}},exports.getUUID=c,exports.auditRequest=function(e,u){return t(this,void 0,void 0,(function*(){(function(t){return!!Object.keys(t).find((e=>void 0===t[e].uuid))})(e)||(u=u||(0,i.getAuditRegistry)())&&(yield(0,n.default)(u.concat("audit"),{headers:{version:"v1","user-agent":(0,i.getUserAgent)(),"Content-Type":"application/json; charset=UTF-8"},body:JSON.stringify(e),method:"POST",agent:(0,i.getProxyAgent)(u),timeout:a.PmConfig.auditTimeOut}))}))},exports.InstallInfo={packageNum:0,cost:0};