/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/lavamoat@11.1.1/src/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const path=require("node:path"),fs=require("node:fs"),{loadPolicy:loadPolicy,loadPolicyAndApplyOverrides:loadPolicyAndApplyOverrides,jsonStringifySortedPolicy:jsonStringifySortedPolicy}=require("lavamoat-core"),{loadCanonicalNameMap:loadCanonicalNameMap}=require("@lavamoat/aa"),{parseForPolicy:parseForPolicy}=require("./parseForPolicy"),{createKernel:createKernel}=require("./kernel"),defaults=require("./defaults");async function runLava(e){(e=Object.assign({},defaults,e)).projectRoot=path.resolve(e.projectRoot),e.entryPath=path.resolve(e.projectRoot,e.entryPath),e.policyPath=path.resolve(e.projectRoot,e.policyPath),e.policyOverridePath=path.resolve(e.projectRoot,e.policyOverridePath),e.policyDebugPath=path.resolve(e.projectRoot,e.policyDebugPath);const{entryPath:o,writeAutoPolicy:a,writeAutoPolicyDebug:t,writeAutoPolicyAndRun:r,policyPath:i,policyDebugPath:l,policyOverridePath:c,projectRoot:n,scuttleGlobalThis:d,debugMode:y,statsMode:p}=e,s=!a&&!t||r;if(a||t||r){const e=Boolean(t),a=await loadPolicy({debugMode:y,policyPath:c});console.warn(`LavaMoat generating policy from entry "${o}"...`);const r=await parseForPolicy({projectRoot:n,entryId:o,policyOverride:a,includeDebugInfo:e});e&&(fs.mkdirSync(path.dirname(l),{recursive:!0}),fs.writeFileSync(l,jsonStringifySortedPolicy(r)),console.warn(`LavaMoat wrote policy debug to "${l}"`)),delete r.debugInfo,fs.mkdirSync(path.dirname(i),{recursive:!0}),fs.writeFileSync(i,jsonStringifySortedPolicy(r)),console.warn(`LavaMoat wrote policy to "${i}"`)}if(s){const e=await loadPolicyAndApplyOverrides({debugMode:y,policyPath:i,policyOverridePath:c}),a=await loadCanonicalNameMap({rootDir:n,includeDevDeps:!0});return createKernel({projectRoot:n,lavamoatPolicy:e,canonicalNameMap:a,scuttleGlobalThis:d,debugMode:y,statsMode:p}).internalRequire(o)}}module.exports={runLava:runLava};
//# sourceMappingURL=/sm/843c601438690efdb7b0d00bb092112e3bdbfe9451167f20b00d7ca5493053b3.map