import{v as c,ad as l,ae as i,af as m,aN as d}from"./index-CzUo07dn.js";const f=t=>{const a="/1.0/images?recursion=1"+(t?`&project=${t}`:"&all-projects=1");return new Promise((s,e)=>{fetch(a).then(c).then(r=>s(r.metadata)).catch(e)})},u=(t,a)=>new Promise((s,e)=>{fetch(`/1.0/images/${t.fingerprint}?project=${a}`,{method:"DELETE"}).then(c).then(s).catch(e)}),P=(t,a,s)=>{const e=[];return new Promise(r=>{Promise.allSettled(t.map(h=>u({fingerprint:h},a).then(n=>{s.set(n.metadata.id,()=>l(e),g=>i(e,g),()=>m(e,t.length,r))}).catch(n=>{i(e,n instanceof Error?n.message:""),m(e,t.length,r)})))})},I=(t,a,s)=>new Promise((e,r)=>{fetch(`/1.0/images/aliases?project=${s}`,{method:"POST",body:JSON.stringify({target:t,name:a})}).then(c).then(e).catch(r)}),j=(t,a)=>new Promise((s,e)=>{fetch(`/1.0/images?project=${a.project}`,{method:"POST",body:t}).then(c).then(s).catch(e)}),w=(t,a,s,e)=>new Promise((r,h)=>{d.post(`/1.0/images?project=${e}`,t,{headers:{"X-Incus-public":JSON.stringify(a)},onUploadProgress:o=>{s({percentage:o.progress?Math.floor(o.progress*100):0,loaded:o.loaded,total:o.total})}}).then(o=>o.data).then(r).catch(h)});export{P as a,j as b,I as c,u as d,f,w as u};
