var D=Object.defineProperty;var y=(o,t)=>D(o,"name",{value:t,configurable:!0});import{l as w,M as u,B as d}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{S as h}from"./lockfile-CedmXr44.js";import{V as S,u as b}from"../packem_chunks/bin.js";var j=Object.defineProperty,l=y((o,t)=>j(o,"name",{value:t,configurable:!0}),"f");const L={bun:{file:"bun.lock",type:"bun"},npm:{aliases:["npm-shrinkwrap.json"],file:"package-lock.json",type:"npm"},pnpm:{file:"pnpm-lock.yaml",type:"pnpm"},yarn:{file:"yarn.lock",type:"yarn"}},O=l(o=>{const t=L[o];return t?[...t.aliases??[],t.file].map(e=>({file:e,type:t.type})):[]},"lockfileCandidates"),m=l((o,t)=>{const e=O(t);if(e.length!==0)return e.find(r=>w(u(o,r.file)))??e[e.length-1]},"resolveLockfile"),g=l(o=>{try{return JSON.parse(d(o))}catch{return}},"readPackageJsonShape"),v=l(o=>{const t=[],e=g(u(o,"package.json"));e&&t.push(e);const r=S(o);let c;if(r?c=r:e?.workspaces&&(Array.isArray(e.workspaces)?c=e.workspaces:e.workspaces.packages&&(c=e.workspaces.packages)),!c)return t;const a=b(o,c);for(const s of a){const n=g(u(o,s,"package.json"));n&&t.push(n)}return t},"collectWorkspacePackageJsons"),P=l((o,t)=>{const e=new Set,r=[],c=new Map;for(const s of t){const n=c.get(s.name);n?n.push(s):c.set(s.name,[s])}const a=l(s=>{if(s)for(const n of Object.keys(s))e.has(n)||(e.add(n),r.push(n))},"enqueueRoots");for(const s of v(o))a(s.dependencies),a(s.peerDependencies),a(s.optionalDependencies);for(;r.length>0;){const s=r.shift(),n=c.get(s);if(n){for(const i of n)for(const p of[i.dependencies,i.peerDependencies,i.optionalDependencies])if(p)for(const f of Object.keys(p))e.has(f)||(e.add(f),r.push(f))}}return e},"computeProdReachable"),C=l((o,t,e={})=>{const r=m(o,t);if(!r)return[];let c;try{c=d(u(o,r.file))}catch{return[]}const a=h(c,r.type);if(a.length===0)return[];const s=e.includeDev??!0?void 0:P(o,a),n=new Set,i=[];for(const p of a){if(s&&!s.has(p.name))continue;const f=`${p.name}@${p.version}`;n.has(f)||(n.add(f),i.push({isDev:!1,name:p.name,version:p.version}))}return i},"lockedPackages"),E=l((o,t)=>{const e=m(o,t);if(!e)return[];let r;try{r=d(u(o,e.file))}catch{return[]}const c=h(r,e.type);if(c.length===0)return[];const a=new Map;for(const n of c)a.has(n.name)||a.set(n.name,new Set),a.get(n.name).add(n.version);const s=[];for(const[n,i]of a)i.size<=1||s.push({name:n,versions:[...i]});return s.sort((n,i)=>n.name.localeCompare(i.name))},"findDuplicateDependencies"),G=l((o,t)=>{const e=m(o,t);if(!e)return;let r;try{r=d(u(o,e.file))}catch{return}const c=h(r,e.type);if(c.length===0)return;const a=[],s=new Set;for(const n of v(o))for(const i of[n.dependencies,n.devDependencies,n.peerDependencies,n.optionalDependencies])if(i)for(const[p,f]of Object.entries(i)){const k=`${p}@${f}`;s.has(k)||(s.add(k),a.push({name:p,version:f}))}return{entries:c,roots:a}},"loadLockfileGraph");export{L,G as a,E as f,C as l,m as r};
