const l=async(a,n,{mimeType:s}={})=>{const c="showSaveFilePicker"in window&&(()=>{try{return window.self===window.top}catch{return!1}})(),o=/firefox/i.test(navigator.userAgent);if(c&&!o)try{const i=await(await showSaveFilePicker({suggestedName:n})).createWritable();await i.write(a),await i.close();return}catch(t){if((t==null?void 0:t.name)!=="AbortError")console.warn("showSaveFilePicker failed; falling back to download:",t);else return}const r=URL.createObjectURL(a),e=document.createElement("a");e.href=r,e.download=n||"download",e.rel="noopener",e.style.position="fixed",e.style.top="-1000px",e.style.left="-1000px",document.body.append(e),e.click(),setTimeout(()=>{URL.revokeObjectURL(r),e.remove()},1500)},w=async(a,n,s="application/octet-stream")=>{try{const o=await(await fetch(a)).blob();return l(o,n,{mimeType:s})}catch{const c=a.split(",")[1]||"",o=atob(c),r=new Uint8Array(o.length);for(let t=0;t