import{r as e,a as t}from"./p-823ca21f.js";import{c as n}from"./p-b68038b5.js";var r=n((function(e){((t,n)=>{e.exports=n()})("streamSaver",(()=>{const e=typeof window==="object"?window:this;if(!e.HTMLElement)console.warn("streamsaver is meant to run on browsers main thread");let t=null;let n=false;const r=e=>{try{e()}catch(e){}};const a=e.WebStreamsPolyfill||{};const s=e.isSecureContext;let i=/constructor/i.test(e.HTMLElement)||!!e.safari||!!e.WebKitPoint;const o=s||"MozAppearance"in document.documentElement.style?"iframe":"navigate";const l={createWriteStream:u,WritableStream:e.WritableStream||a.WritableStream,supported:true,version:{full:"2.0.5",major:2,minor:0,dot:5},mitm:"https://jimmywarting.github.io/StreamSaver.js/mitm.html?version=2.0.0"};function c(e){if(!e)throw new Error("meh");const t=document.createElement("iframe");t.hidden=true;t.src=e;t.loaded=false;t.name="iframe";t.isIframe=true;t.postMessage=(...e)=>t.contentWindow.postMessage(...e);t.addEventListener("load",(()=>{t.loaded=true}),{once:true});document.body.appendChild(t);return t}function f(t){const n="width=200,height=100";const r=document.createDocumentFragment();const a={frame:e.open(t,"popup",n),loaded:false,isIframe:false,isPopup:true,remove(){a.frame.close()},addEventListener(...e){r.addEventListener(...e)},dispatchEvent(...e){r.dispatchEvent(...e)},removeEventListener(...e){r.removeEventListener(...e)},postMessage(...e){a.frame.postMessage(...e)}};const s=t=>{if(t.source===a.frame){a.loaded=true;e.removeEventListener("message",s);a.dispatchEvent(new Event("load"))}};e.addEventListener("message",s);return a}try{new Response(new ReadableStream);if(s&&!("serviceWorker"in navigator)){i=true}}catch(e){i=true}r((()=>{const{readable:e}=new TransformStream;const t=new MessageChannel;t.port1.postMessage(e,[e]);t.port1.close();t.port2.close();n=true;Object.defineProperty(l,"TransformStream",{configurable:false,writable:false,value:TransformStream})}));function m(){if(!t){t=s?c(l.mitm):f(l.mitm)}}function u(e,r,a){let s={size:null,pathname:null,writableStrategy:undefined,readableStrategy:undefined};let f=0;let u=null;let d=null;let h=null;if(Number.isFinite(r)){[a,r]=[r,a];console.warn("[StreamSaver] Deprecated pass an object as 2nd argument when creating a write stream");s.size=a;s.writableStrategy=r}else if(r&&r.highWaterMark){console.warn("[StreamSaver] Deprecated pass an object as 2nd argument when creating a write stream");s.size=a;s.writableStrategy=r}else{s=r||{}}if(!i){m();d=new MessageChannel;e=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A");const r={transferringReadable:n,pathname:s.pathname||Math.random().toString().slice(-6)+"/"+e,headers:{"Content-Type":"application/octet-stream; charset=utf-8","Content-Disposition":"attachment; filename*=UTF-8''"+e}};if(s.size){r.headers["Content-Length"]=s.size}const a=[r,"*",[d.port2]];if(n){const e=o==="iframe"?undefined:{transform(e,t){if(!(e instanceof Uint8Array)){throw new TypeError("Can only write Uint8Arrays")}f+=e.length;t.enqueue(e);if(u){location.href=u;u=null}},flush(){if(u){location.href=u}}};h=new l.TransformStream(e,s.writableStrategy,s.readableStrategy);const t=h.readable;d.port1.postMessage({readableStream:t},[t])}d.port1.onmessage=e=>{if(e.data.download){if(o==="navigate"){t.remove();t=null;if(f){location.href=e.data.download}else{u=e.data.download}}else{if(t.isPopup){t.remove();t=null;if(o==="iframe"){c(l.mitm)}}c(e.data.download)}}else if(e.data.abort){p=[];d.port1.postMessage("abort");d.port1.onmessage=null;d.port1.close();d.port2.close();d=null}};if(t.loaded){t.postMessage(...a)}else{t.addEventListener("load",(()=>{t.postMessage(...a)}),{once:true})}}let p=[];return!i&&h&&h.writable||new l.WritableStream({write(e){if(!(e instanceof Uint8Array)){throw new TypeError("Can only write Uint8Arrays")}if(i){p.push(e);return}d.port1.postMessage(e);f+=e.length;if(u){location.href=u;u=null}},close(){if(i){const t=new Blob(p,{type:"application/octet-stream; charset=utf-8"});const n=document.createElement("a");n.href=URL.createObjectURL(t);n.download=e;n.click()}else{d.port1.postMessage("end")}},abort(){p=[];d.port1.postMessage("abort");d.port1.onmessage=null;d.port1.close();d.port2.close();d=null}},s.writableStrategy)}return l}))}));let a=class{constructor(t){e(this,t);this.textEncoder=new TextEncoder}async abort(){const e=this.writer;if(e){this.writer=undefined;return e.abort()}}async start(e,n){await this.abort();e=e||this.filename;const a=n??this.filesize;r.mitm=`${t("../gc-core-streamsaver/lib/mitm.html")}?version=${r.version.full}`;this.writer=r.createWriteStream(e,{size:a}).getWriter()}async stop(){const e=this.writer;if(e){this.writer=undefined;return e.close()}}async write(e){if(this.writer){if(typeof e==="string"){return this.writer.write(this.textEncoder.encode(e))}if(e instanceof Uint8Array){return this.writer.write(e)}}}};export{a as gc_core_streamsaver};
//# sourceMappingURL=p-81d2e126.entry.js.map