module.exports=[5840,a=>{"use strict";var b=a.i(20695);a.i(47299),a.i(43698),a.i(27028),a.i(81111),a.i(51615),a.i(12057),a.i(63049),a.i(57764),a.i(61095),a.i(2157),a.i(50227);var c=Object.defineProperty,d=(a,b)=>c(a,"name",{value:b,configurable:!0});let e=0,f={START_BOUNDARY:e++,HEADER_FIELD_START:e++,HEADER_FIELD:e++,HEADER_VALUE_START:e++,HEADER_VALUE:e++,HEADER_VALUE_ALMOST_DONE:e++,HEADERS_ALMOST_DONE:e++,PART_DATA_START:e++,PART_DATA:e++,END:e++},g=1,h=2,i=d(a=>32|a,"lower"),j=d(()=>{},"noop"),k=class{constructor(a){this.index=0,this.flags=0,this.onHeaderEnd=j,this.onHeaderField=j,this.onHeadersEnd=j,this.onHeaderValue=j,this.onPartBegin=j,this.onPartData=j,this.onPartEnd=j,this.boundaryChars={};const b=new Uint8Array((a=`\r
--`+a).length);for(let c=0;c<a.length;c++)b[c]=a.charCodeAt(c),this.boundaryChars[b[c]]=!0;this.boundary=b,this.lookbehind=new Uint8Array(this.boundary.length+8),this.state=f.START_BOUNDARY}write(a){let b,c,e=0,j=a.length,k=this.index,{lookbehind:l,boundary:m,boundaryChars:n,index:o,state:p,flags:q}=this,r=this.boundary.length,s=r-1,t=a.length,u=d(a=>{this[a+"Mark"]=e},"mark"),v=d(a=>{delete this[a+"Mark"]},"clear"),w=d((a,b,c,d)=>{(void 0===b||b!==c)&&this[a](d&&d.subarray(b,c))},"callback"),x=d((b,c)=>{let d=b+"Mark";d in this&&(c?(w(b,this[d],e,a),delete this[d]):(w(b,this[d],a.length,a),this[d]=0))},"dataCallback");for(e=0;e<j;e++)switch(b=a[e],p){case f.START_BOUNDARY:if(o===m.length-2){if(45===b)q|=h;else if(13!==b)return;o++;break}if(o-1==m.length-2){if(q&h&&45===b)p=f.END,q=0;else{if(q&h||10!==b)return;o=0,w("onPartBegin"),p=f.HEADER_FIELD_START}break}b!==m[o+2]&&(o=-2),b===m[o+2]&&o++;break;case f.HEADER_FIELD_START:p=f.HEADER_FIELD,u("onHeaderField"),o=0;case f.HEADER_FIELD:if(13===b){v("onHeaderField"),p=f.HEADERS_ALMOST_DONE;break}if(o++,45===b)break;if(58===b){if(1===o)return;x("onHeaderField",!0),p=f.HEADER_VALUE_START;break}if((c=i(b))<97||c>122)return;break;case f.HEADER_VALUE_START:if(32===b)break;u("onHeaderValue"),p=f.HEADER_VALUE;case f.HEADER_VALUE:13===b&&(x("onHeaderValue",!0),w("onHeaderEnd"),p=f.HEADER_VALUE_ALMOST_DONE);break;case f.HEADER_VALUE_ALMOST_DONE:if(10!==b)return;p=f.HEADER_FIELD_START;break;case f.HEADERS_ALMOST_DONE:if(10!==b)return;w("onHeadersEnd"),p=f.PART_DATA_START;break;case f.PART_DATA_START:p=f.PART_DATA,u("onPartData");case f.PART_DATA:if(k=o,0===o){for(e+=s;e<t&&!(a[e]in n);)e+=r;e-=s,b=a[e]}if(o<m.length)m[o]===b?(0===o&&x("onPartData",!0),o++):o=0;else if(o===m.length)o++,13===b?q|=g:45===b?q|=h:o=0;else if(o-1===m.length)if(q&g){if(o=0,10===b){q&=~g,w("onPartEnd"),w("onPartBegin"),p=f.HEADER_FIELD_START;break}}else q&h&&45===b?(w("onPartEnd"),p=f.END,q=0):o=0;o>0?l[o-1]=b:k>0&&(w("onPartData",0,k,new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),k=0,u("onPartData"),e--);break;case f.END:break;default:throw Error(`Unexpected state entered: ${p}`)}x("onHeaderField"),x("onHeaderValue"),x("onPartData"),this.index=o,this.state=p,this.flags=q}end(){if(this.state===f.HEADER_FIELD_START&&0===this.index||this.state===f.PART_DATA&&this.index===this.boundary.length)this.onPartEnd();else if(this.state!==f.END)throw Error("MultipartParser.end(): stream ended unexpectedly")}};function l(a){let b=a.match(/\bfilename=("(.*?)"|([^()<>@,;:\\"/[\]?={}\s\t]+))($|;\s)/i);if(!b)return;let c=b[2]||b[3]||"",d=c.slice(c.lastIndexOf("\\")+1);return(d=d.replace(/%22/g,'"')).replace(/&#(\d{4});/g,(a,b)=>String.fromCharCode(b))}async function m(a,c){let e,f,g,h,i,j;if(!/multipart/i.test(c))throw TypeError("Failed to fetch");let m=c.match(/boundary=(?:"([^"]+)"|([^;]+))/i);if(!m)throw TypeError("no or bad content-type header, no multipart boundary");let n=new k(m[1]||m[2]),o=[],p=new b.FormData,q=d(a=>{g+=u.decode(a,{stream:!0})},"onPartData"),r=d(a=>{o.push(a)},"appendToFile"),s=d(()=>{let a=new b.File(o,j,{type:i});p.append(h,a)},"appendFileToFormData"),t=d(()=>{p.append(h,g)},"appendEntryToFormData"),u=new TextDecoder("utf-8");for await(let b of(u.decode(),n.onPartBegin=function(){n.onPartData=q,n.onPartEnd=t,e="",f="",g="",h="",i="",j=null,o.length=0},n.onHeaderField=function(a){e+=u.decode(a,{stream:!0})},n.onHeaderValue=function(a){f+=u.decode(a,{stream:!0})},n.onHeaderEnd=function(){if(f+=u.decode(),"content-disposition"===(e=e.toLowerCase())){let a=f.match(/\bname=("([^"]*)"|([^()<>@,;:\\"/[\]?={}\s\t]+))/i);a&&(h=a[2]||a[3]||""),(j=l(f))&&(n.onPartData=r,n.onPartEnd=s)}else"content-type"===e&&(i=f);f="",e=""},a))n.write(b);return n.end(),p}d(k,"MultipartParser"),d(l,"_fileName"),d(m,"toFormData"),a.s(["toFormData",()=>m])}];

//# sourceMappingURL=node_modules_node-fetch-native_dist_chunks_multipart-parser_mjs_b20147c1._.js.map