var D=Object.defineProperty;var f=(o,t)=>D(o,"name",{value:t,configurable:!0});import{E as d}from"../packem_shared/Table-3pFgIUZ2-DABgc6rj.js";import{p as n}from"./bin.js";import{s as b}from"../packem_shared/scan-progress-lZdk5KJ-.js";import{s as y,D as h}from"../packem_shared/osv-bloom-0Vu8YRhg.js";var v=Object.defineProperty,a=f((o,t)=>v(o,"name",{value:t,configurable:!0}),"s");const w=a(o=>o?.security?.audit?.advisories?.bloom??{},"readBloomConfig"),p=a(o=>o>=1e3?`${(o/1e3).toFixed(1)}s`:`${Math.round(o)}ms`,"formatDuration"),$=a(o=>o<1024?`${o} B`:o<1024*1024?`${(o/1024).toFixed(1)} KB`:`${(o/(1024*1024)).toFixed(1)} MB`,"formatBytes"),B=a(async({options:o,visConfig:t,workspaceRoot:c})=>{if(!c)throw new Error("Could not determine workspace root. Run this command inside a workspace.");const l=o.format==="json",m=w(t),u=o.source??m.source??h,s=b([{id:"bloom",label:"Sync osv-bloom prefilter"}],{live:!l});let e,r;try{s.start("bloom");const i=Date.now();e=await y({allowedHosts:m.allowedHosts,cacheDir:o.cacheDir,force:!!o.force,source:u,workspaceRoot:c}),e.upToDate?s.finish("bloom","ok",`up to date · ${p(Date.now()-i)}`):s.finish("bloom","ok",`${e.manifest.entryCount.toLocaleString()} entries · ${$(e.bytesOnDisk)} · ${p(e.durationMs)}`)}catch(i){r=i instanceof Error?i.message:String(i),s.finish("bloom","error",r)}finally{s.stop()}l?process.stdout.write(`${JSON.stringify({bytesOnDisk:e?.bytesOnDisk??0,cacheDir:e?.cacheDir??null,durationMs:e?.durationMs??0,error:r??null,manifest:e?.manifest??null,source:u,upToDate:e?.upToDate??!1},void 0,2)}
`):e&&(n.info(d(`Cache: ${e.cacheDir}`)),n.info(d(`Built: ${e.manifest.builtAtRfc3339}`)),r||n.success(e.upToDate?"osv-bloom prefilter up to date.":"osv-bloom prefilter synced.")),r&&(process.exitCode=1)},"execute"),x=B;export{x as advisoriesBloomSyncExecute};
