// @bun
import{y as Q}from"./chunk-ks3qn9ry.js";import{B as X,F as Y}from"./chunk-hggcmr0j.js";function K(w){let z=w.split("/").pop()||"";if(["deps.yaml","dependencies.yaml","pkgx.yaml",".deps.yaml"].includes(z))return!0;let j=z.replace(/\.(yaml|yml)$/,"");return["deps","dependencies","pkgx",".deps"].includes(j)}async function W(w,z){try{if(!K(w))return null;let q=await Q(w),j=[];if(q&&typeof q==="object"){if(q.allDependencies&&Array.isArray(q.allDependencies)){for(let A of q.allDependencies)if(A.name&&A.constraint)j.push({name:A.name,currentVersion:A.constraint,type:"dependencies",file:w})}}let H=w.split("/").pop()||"";return{path:w,type:H,content:z,dependencies:j}}catch(q){return console.warn(`Failed to parse dependency file ${w}:`,q),null}}async function Z(w,z,q){try{if(!K(w))return z;let j=z;for(let H of q){let A=H.name.replace(/\s*\(dev\)$/,"").replace(/\s*\(peer\)$/,"").replace(/\s*\(optional\)$/,""),I=new RegExp(`(\\s*${A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*:\\s*)([^\\n\\r]*)`,"g"),J=j.match(I);if(J){let L=J[0].match(/:[ \t]*([^\\nr]+)/);if(L){let O=L[1].trim().match(/^(\D*)/),S=O?O[1]:"",T=/^[\^~>=<]/.test(H.newVersion)?H.newVersion:`${S}${H.newVersion}`;j=j.replace(I,`$1${T}`)}}}return j}catch(j){return console.warn(`Failed to update dependency file ${w}:`,j),z}}async function b(w){let z=[],q=new Map;for(let j of w)if(K(j.file)){if(!q.has(j.file))q.set(j.file,[]);q.get(j.file).push(j)}for(let[j,H]of q)try{let A=await import("fs");if(A.existsSync(j)){let I=A.readFileSync(j,"utf-8"),J=await Z(j,I,H);z.push({path:j,content:J,type:"update"})}}catch(A){console.warn(`Failed to generate updates for dependency file ${j}:`,A)}return z}export{Z as updateDependencyFile,W as parseDependencyFile,K as isDependencyFile,b as generateDependencyFileUpdates};
export{K as w,W as x};
