var y=async(e,t=[{}],n=null,r=!1,o=null)=>{Array.isArray(t)||(t=[t]),t[0].fileName=t[0].fileName||"Untitled";const c=[];let i=null;if(e instanceof Blob&&e.type?i=e.type:e.headers&&e.headers.get("content-type")&&(i=e.headers.get("content-type")),t.forEach((a,p)=>{c[p]={description:a.description||"",accept:{}},a.mimeTypes?(p===0&&i&&a.mimeTypes.push(i),a.mimeTypes.map(d=>{c[p].accept[d]=a.extensions||[]})):i&&(c[p].accept[i]=a.extensions||[])}),n)try{await n.getFile()}catch(a){if(n=null,r)throw a}const l=n||await window.showSaveFilePicker({suggestedName:t[0].fileName,id:t[0].id,startIn:t[0].startIn,types:c,excludeAcceptAllOption:t[0].excludeAcceptAllOption||!1});!n&&o&&o();const s=await l.createWritable();return"stream"in e?(await e.stream().pipeTo(s),l):"body"in e?(await e.body.pipeTo(s),l):(await s.write(await e),await s.close(),l)};export{y as default};
