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