var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire810d;e.register("6KsJx",function(t,n){Object.defineProperty(t.exports,"toFormData",{get:()=>D,set:void 0,enumerable:!0,configurable:!0});var a=e("j9HqM"),r=e("1RVNT");let i=0,o={START_BOUNDARY:i++,HEADER_FIELD_START:i++,HEADER_FIELD:i++,HEADER_VALUE_START:i++,HEADER_VALUE:i++,HEADER_VALUE_ALMOST_DONE:i++,HEADERS_ALMOST_DONE:i++,PART_DATA_START:i++,PART_DATA:i++,END:i++},s=1,A={PART_BOUNDARY:s,LAST_BOUNDARY:s*=2},d=e=>32|e,E=()=>{};class l{constructor(e){this.index=0,this.flags=0,this.onHeaderEnd=E,this.onHeaderField=E,this.onHeadersEnd=E,this.onHeaderValue=E,this.onPartBegin=E,this.onPartData=E,this.onPartEnd=E,this.boundaryChars={},e="\r\n--"+e;let t=new Uint8Array(e.length);for(let n=0;n{this[e+"Mark"]=a;},c=e=>{delete this[e+"Mark"];},b=(e,t,n,a)=>{(void 0===t||t!==n)&&this[e](a&&a.subarray(t,n));},H=(t,n)=>{let r=t+"Mark";r in this&&(n?(b(t,this[r],a,e),delete this[r]):(b(t,this[r],e.length,e),this[r]=0));};for(a=0;a122)return;break;case o.HEADER_VALUE_START:if(32===t)break;u("onHeaderValue"),h=o.HEADER_VALUE;case o.HEADER_VALUE:13===t&&(H("onHeaderValue",!0),b("onHeaderEnd"),h=o.HEADER_VALUE_ALMOST_DONE);break;case o.HEADER_VALUE_ALMOST_DONE:if(10!==t)return;h=o.HEADER_FIELD_START;break;case o.HEADERS_ALMOST_DONE:if(10!==t)return;b("onHeadersEnd"),h=o.PART_DATA_START;break;case o.PART_DATA_START:h=o.PART_DATA,u("onPartData");case o.PART_DATA:if(i=D,0===D){for(a+=R;a<_&&!(e[a]in l);)a+=f;a-=R,t=e[a];}if(D0)s[D-1]=t;else if(i>0){let e=new Uint8Array(s.buffer,s.byteOffset,s.byteLength);b("onPartData",0,i,e),i=0,u("onPartData"),a--;}break;case o.END:break;default:throw Error(`Unexpected state entered: ${h}`);}H("onHeaderField"),H("onHeaderValue"),H("onPartData"),this.index=D,this.state=h,this.flags=T;}end(){if(this.state===o.HEADER_FIELD_START&&0===this.index||this.state===o.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==o.END)throw Error("MultipartParser.end(): stream ended unexpectedly");}}async function D(e,t){let n,i,o,s,A,d;if(!/multipart/i.test(t))throw TypeError("Failed to fetch");let E=t.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!E)throw TypeError("no or bad content-type header, no multipart boundary");let D=new l(E[1]||E[2]),h=[],T=new r.FormData(),f=e=>{o+=c.decode(e,{stream:!0});},R=e=>{h.push(e);},_=()=>{let e=new a.File(h,d,{type:A});T.append(s,e);},u=()=>{T.append(s,o);},c=new TextDecoder("utf-8");for await(let t of(c.decode(),D.onPartBegin=function(){D.onPartData=f,D.onPartEnd=u,n="",i="",o="",s="",A="",d=null,h.length=0;},D.onHeaderField=function(e){n+=c.decode(e,{stream:!0});},D.onHeaderValue=function(e){i+=c.decode(e,{stream:!0});},D.onHeaderEnd=function(){if(i+=c.decode(),"content-disposition"===(n=n.toLowerCase())){let e=i.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);e&&(s=e[2]||e[3]||""),(d=function(e){let t=e.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!t)return;let n=t[2]||t[3]||"",a=n.slice(n.lastIndexOf("\\")+1);return(a=a.replace(/%22/g,'"')).replace(/&#(\d{4});/g,(e,t)=>String.fromCharCode(t));}(i))&&(D.onPartData=R,D.onPartEnd=_);}else"content-type"===n&&(A=i);i="",n="";},e))D.write(t);return D.end(),T;}}); //# sourceMappingURL=multipart-parser.30e64fd9.js.map