var f=Object.defineProperty;var R=(u,p)=>f(u,"name",{value:p,configurable:!0});import{M as d,l as o,B as $}from"./readFileSync-DseCu8sg-DEq4Fn3a.js";import{E as h}from"../packem_chunks/config.js";import{A as x}from"../packem_chunks/bin.js";var S=Object.defineProperty,b=R((u,p)=>S(u,"name",{value:p,configurable:!0}),"k");const U=b((u,p,A,m=[])=>{const i=[];if(A===void 0)return i.push("minimumReleaseAge not set in vis.config; skipping native sync."),i;const r=Number.isFinite(A)?Math.max(0,Math.round(A)):0;switch(u){case"bun":{const n=d(p,"bunfig.toml");let e=o(n)?$(n):"";const a=r*60,t=`minimumReleaseAge = ${String(a)}`,s=m.length>0?`minimumReleaseAgeExcludes = [${m.map(c=>`"${c.replaceAll(String.raw`"`,String.raw`\"`)}"`).join(", ")}]`:void 0,g=/^\[install\][ \t]*\n/m.exec(e);if(g?.index===void 0){const c=s?`${t}
${s}`:t;e=`${e.trimEnd()?`${e.trimEnd()}

`:""}[install]
${c}
`}else{const c=g.index+g[0].length,E=e.slice(c),y=/^\[/m.exec(E),k=y?.index===void 0?e.length:c+y.index;let l=e.slice(c,k);l=/^[ \t]*minimumReleaseAge[ \t]*=/m.test(l)?l.replace(/^[ \t]*minimumReleaseAge[ \t]*=.*$/m,t):`${t}
${l}`,s&&(l=/^[ \t]*minimumReleaseAgeExcludes[ \t]*=/m.test(l)?l.replace(/^[ \t]*minimumReleaseAgeExcludes[ \t]*=.*$/m,s):`${s}
${l}`),e=`${e.slice(0,c)}${l}${e.slice(k)}`}h(n,e.endsWith(`
`)?e:`${e}
`),i.push(`Updated bunfig.toml [install] minimumReleaseAge = ${String(a)} (${String(r)} minutes)`),s&&i.push(`Updated bunfig.toml [install] minimumReleaseAgeExcludes (${String(m.length)} entries)`);break}case"npm":{const n=d(p,".npmrc");let e=o(n)?$(n):"";const a=r===0?0:Math.max(1,Math.ceil(r/1440)),t=`min-release-age=${String(a)}`;e=/^\s*min-release-age\s*=/m.test(e)?e.replace(/^\s*min-release-age\s*=.*$/m,t):`${e.trimEnd()}
${t}
`,h(n,e.endsWith(`
`)?e:`${e}
`),i.push(`Updated .npmrc min-release-age=${String(a)} (rounded up from ${String(r)} minutes; npm's unit is days)`),m.length>0&&i.push("npm has no native per-package exclude list; skipped excludes sync.");break}case"pnpm":{const n=d(p,"pnpm-workspace.yaml");if(!o(n)){i.push("pnpm-workspace.yaml not found. Cannot sync minimumReleaseAge.");break}let e=$(n);e.endsWith(`
`)||(e+=`
`);const a=`minimumReleaseAge: ${String(r)}
`;if(e=/^minimumReleaseAge[ \t]*:.*$/m.test(e)?e.replace(/^minimumReleaseAge[ \t]*:.*$/m,a.trimEnd()):`${e.trimEnd()}

${a}`,m.length>0){const t=`minimumReleaseAgeExclude:
${m.map(g=>`  - ${x(g)}`).join(`
`)}
`,s=/^minimumReleaseAgeExclude:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;e=s.test(e)?e.replace(s,t):`${e.trimEnd()}

${t}`}h(n,e),i.push(`Updated pnpm-workspace.yaml minimumReleaseAge: ${String(r)} minutes`),m.length>0&&i.push(`Updated pnpm-workspace.yaml minimumReleaseAgeExclude (${String(m.length)} entries)`);break}case"yarn":{const n=d(p,".yarnrc.yml");if(!o(n)){i.push("yarn classic lacks npmMinimalAgeGate; .yarnrc.yml not found, skipping.");break}let e=$(n);const a=`npmMinimalAgeGate: ${String(r)}`;if(e.endsWith(`
`)||(e+=`
`),e=/^npmMinimalAgeGate[ \t]*:.*$/m.test(e)?e.replace(/^npmMinimalAgeGate[ \t]*:.*$/m,a):`${e.trimEnd()}

${a}
`,m.length>0){const t=`npmPreapprovedPackages:
${m.map(g=>`  - ${x(g)}`).join(`
`)}
`,s=/^npmPreapprovedPackages:[ \t]*\n(?:[ \t]{2}[^\n]*\n)*/m;e=s.test(e)?e.replace(s,t):`${e.trimEnd()}

${t}`}h(n,e),i.push(`Updated .yarnrc.yml npmMinimalAgeGate: ${String(r)} (minutes; bare integer dodges yarn duration-string bug)`),m.length>0&&i.push(`Updated .yarnrc.yml npmPreapprovedPackages (${String(m.length)} entries)`);break}}return i},"syncMinimumReleaseAgeToNativeConfig");export{U as E};
