import{cO as T2,cA as b2}from"./B565zvD7.js";const T={};var P={},u1={exports:{}},w1,O1;function y2(){if(O1)return w1;O1=1;var p={};w1=p;function e(d){return d<0?-1:1}function l(d){return d%1===.5&&(d&1)===0?Math.floor(d):Math.round(d)}function i(d,t){t.unsigned||--d;const s=t.unsigned?0:-Math.pow(2,d),v=Math.pow(2,d)-1,r=t.moduloBitLength?Math.pow(2,t.moduloBitLength):Math.pow(2,d),N=t.moduloBitLength?Math.pow(2,t.moduloBitLength-1):Math.pow(2,d-1);return function(c,w){w||(w={});let u=+c;if(w.enforceRange){if(!Number.isFinite(u))throw new TypeError("Argument is not a finite number");if(u=e(u)*Math.floor(Math.abs(u)),uv)throw new TypeError("Argument is not in byte range");return u}if(!isNaN(u)&&w.clamp)return u=l(u),uv&&(u=v),u;if(!Number.isFinite(u)||u===0)return 0;if(u=e(u)*Math.floor(Math.abs(u)),u=u%r,!t.unsigned&&u>=N)return u-r;if(t.unsigned){if(u<0)u+=r;else if(u===-0)return 0}return u}}return p.void=function(){},p.boolean=function(d){return!!d},p.byte=i(8,{unsigned:!1}),p.octet=i(8,{unsigned:!0}),p.short=i(16,{unsigned:!1}),p["unsigned short"]=i(16,{unsigned:!0}),p.long=i(32,{unsigned:!1}),p["unsigned long"]=i(32,{unsigned:!0}),p["long long"]=i(32,{unsigned:!1,moduloBitLength:64}),p["unsigned long long"]=i(32,{unsigned:!0,moduloBitLength:64}),p.double=function(d){const t=+d;if(!Number.isFinite(t))throw new TypeError("Argument is not a finite floating-point value");return t},p["unrestricted double"]=function(d){const t=+d;if(isNaN(t))throw new TypeError("Argument is NaN");return t},p.float=p.double,p["unrestricted float"]=p["unrestricted double"],p.DOMString=function(d,t){return t||(t={}),t.treatNullAsEmptyString&&d===null?"":String(d)},p.ByteString=function(d,t){const s=String(d);let v;for(let r=0;(v=s.codePointAt(r))!==void 0;++r)if(v>255)throw new TypeError("Argument is not a valid bytestring");return s},p.USVString=function(d){const t=String(d),s=t.length,v=[];for(let r=0;r57343)v.push(String.fromCodePoint(N));else if(56320<=N&&N<=57343)v.push(String.fromCodePoint(65533));else if(r===s-1)v.push(String.fromCodePoint(65533));else{const c=t.charCodeAt(r+1);if(56320<=c&&c<=57343){const w=N&1023,u=c&1023;v.push(String.fromCodePoint(65536+1024*w+u)),++r}else v.push(String.fromCodePoint(65533))}}return v.join("")},p.Date=function(d,t){if(!(d instanceof Date))throw new TypeError("Argument is not a Date object");if(!isNaN(d))return d},p.RegExp=function(d,t){return d instanceof RegExp||(d=new RegExp(d)),d},w1}var h1={exports:{}},U1;function A2(){return U1||(U1=1,function(p){p.exports.mixin=function(l,i){const d=Object.getOwnPropertyNames(i);for(let t=0;t= 0x80 (not a basic code point)","invalid-input":"Invalid input"},_1=U-A1,I=Math.floor,N1=String.fromCharCode;function W(p){throw new RangeError(P2[p])}function R2(p,e){const l=[];let i=p.length;for(;i--;)l[i]=e(p[i]);return l}function K1(p,e){const l=p.split("@");let i="";l.length>1&&(i=l[0]+"@",p=l[1]),p=p.replace(x2,".");const d=p.split("."),t=R2(d,e).join(".");return i+t}function E1(p){const e=[];let l=0;const i=p.length;for(;l=55296&&d<=56319&&lString.fromCodePoint(...p),L2=function(p){return p>=48&&p<58?26+(p-48):p>=65&&p<91?p-65:p>=97&&p<123?p-97:U},I1=function(p,e){return p+22+75*(p<26)-((e!=0)<<5)},Q1=function(p,e,l){let i=0;for(p=l?I(p/C2):p>>1,p+=I(p/e);p>_1*m1>>1;i+=U)p=I(p/_1);return I(i+(_1+1)*p/(p+E2))},C1=function(p){const e=[],l=p.length;let i=0,d=Z1,t=W1,s=p.lastIndexOf(J1);s<0&&(s=0);for(let v=0;v=128&&W("not-basic"),e.push(p.charCodeAt(v));for(let v=s>0?s+1:0;v=l&&W("invalid-input");const u=L2(p.charCodeAt(v++));u>=U&&W("invalid-input"),u>I((X-i)/c)&&W("overflow"),i+=u*c;const S=w<=t?A1:w>=t+m1?m1:w-t;if(uI(X/f)&&W("overflow"),c*=f}const N=e.length+1;t=Q1(i-r,N,r==0),I(i/N)>X-d&&W("overflow"),d+=I(i/N),i%=N,e.splice(i++,0,d)}return String.fromCodePoint(...e)},B1=function(p){const e=[];p=E1(p);const l=p.length;let i=Z1,d=0,t=W1;for(const r of p)r<128&&e.push(N1(r));const s=e.length;let v=s;for(s&&e.push(J1);v=i&&cI((X-d)/N)&&W("overflow"),d+=(r-i)*N,i=r;for(const c of p)if(cX&&W("overflow"),c===i){let w=d;for(let u=U;;u+=U){const S=u<=t?A1:u>=t+m1?m1:u-t;if(w=w)return _;_[0][0]>w?S=f-1:u=f+1}return null}var t=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;function s(w){return w.replace(t,"_").length}function v(w,u,S){for(var f=!1,_="",D=s(w),y=0;y253||y.length===0)&&(_.error=!0);for(var A=0;A63||D.length===0){_.error=!0;break}}return _.error?null:D.join(".")},d1.toUnicode=function(w,u){var S=c(w,u,l.NONTRANSITIONAL);return{domain:S.string,error:S.error}},d1.PROCESSING_OPTIONS=l,d1}var k1;function k(){return k1||(k1=1,function(p){const e=e2,l=z2(),i={ftp:21,file:null,gopher:70,http:80,https:443,ws:80,wss:443},d=Symbol("failure");function t(a){return e.ucs2.decode(a).length}function s(a,m){const o=a[m];return isNaN(o)?void 0:String.fromCodePoint(o)}function v(a){return a>=48&&a<=57}function r(a){return a>=65&&a<=90||a>=97&&a<=122}function N(a){return r(a)||v(a)}function c(a){return v(a)||a>=65&&a<=70||a>=97&&a<=102}function w(a){return a==="."||a.toLowerCase()==="%2e"}function u(a){return a=a.toLowerCase(),a===".."||a==="%2e."||a===".%2e"||a==="%2e%2e"}function S(a,m){return r(a)&&(m===58||m===124)}function f(a){return a.length===2&&r(a.codePointAt(0))&&(a[1]===":"||a[1]==="|")}function _(a){return a.length===2&&r(a.codePointAt(0))&&a[1]===":"}function D(a){return a.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/)!==-1}function y(a){return a.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/)!==-1}function A(a){return i[a]!==void 0}function g(a){return A(a.scheme)}function z(a){return i[a]}function x(a){let m=a.toString(16).toUpperCase();return m.length===1&&(m="0"+m),"%"+m}function M(a){const m=new Buffer(a);let o="";for(let n=0;n126}const s2=new Set([32,34,35,60,62,63,96,123,125]);function x1(a){return s1(a)||s2.has(a)}const r2=new Set([47,58,59,61,64,91,92,93,94,124]);function o1(a){return x1(a)||r2.has(a)}function Z(a,m){const o=String.fromCodePoint(a);return m(a)?M(o):o}function o2(a){let m=10;return a.length>=2&&a.charAt(0)==="0"&&a.charAt(1).toLowerCase()==="x"?(a=a.substring(2),m=16):a.length>=2&&a.charAt(0)==="0"&&(a=a.substring(1),m=8),a===""?0:(m===10?/[^0-9]/:m===16?/[^0-9A-Fa-f]/:/[^0-7]/).test(a)?d:parseInt(a,m)}function n2(a){const m=a.split(".");if(m[m.length-1]===""&&m.length>1&&m.pop(),m.length>4)return a;const o=[];for(const V of m){if(V==="")return a;const C=o2(V);if(C===d)return a;o.push(C)}for(let V=0;V255)return d;if(o[o.length-1]>=Math.pow(256,5-o.length))return d;let n=o.pop(),h=0;for(const V of o)n+=V*Math.pow(256,3-h),++h;return n}function v2(a){let m="",o=a;for(let n=1;n<=4;++n)m=String(o%256)+m,n!==4&&(m="."+m),o=Math.floor(o/256);return m}function u2(a){const m=[0,0,0,0,0,0,0,0];let o=0,n=null,h=0;if(a=e.ucs2.decode(a),a[h]===58){if(a[h+1]!==58)return d;h+=2,++o,n=o}for(;h6))return d;let H=0;for(;a[h]!==void 0;){let O=null;if(H>0)if(a[h]===46&&H<4)++h;else return d;if(!v(a[h]))return d;for(;v(a[h]);){const L1=parseInt(s(a,h));if(O===null)O=L1;else{if(O===0)return d;O=O*10+L1}if(O>255)return d;++h}m[o]=m[o]*256+O,++H,(H===2||H===4)&&++o}if(H!==4)return d;break}else if(a[h]===58){if(++h,a[h]===void 0)return d}else if(a[h]!==void 0)return d;m[o]=V,++o}if(n!==null){let V=o-n;for(o=7;o!==0&&V>0;){const C=m[n+V-1];m[n+V-1]=m[o],m[o]=C,--o,--V}}else if(n===null&&o!==8)return d;return m}function w2(a){let m="";const n=f2(a).idx;let h=!1;for(let V=0;V<=7;++V)if(!(h&&a[V]===0)){if(h&&(h=!1),n===V){m+=V===0?"::":":",h=!0;continue}m+=a[V].toString(16),V!==7&&(m+=":")}return m}function n1(a,m){if(a[0]==="[")return a[a.length-1]!=="]"?d:u2(a.substring(1,a.length-1));if(!m)return h2(a);const o=e1(a),n=l.toASCII(o,!1,l.PROCESSING_OPTIONS.NONTRANSITIONAL,!1);if(n===null||D(n))return d;const h=n2(n);return typeof h=="number"||h===d?h:n}function h2(a){if(y(a))return d;let m="";const o=e.ucs2.decode(a);for(let n=0;no&&(m=n,o=h),n=null,h=0):(n===null&&(n=V),++h);return h>o&&(m=n,o=h),{idx:m,len:o}}function v1(a){return typeof a=="number"?v2(a):a instanceof Array?"["+w2(a)+"]":a}function c2(a){return a.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g,"")}function _2(a){return a.replace(/\u0009|\u000A|\u000D/g,"")}function P1(a){const m=a.path;m.length!==0&&(a.scheme==="file"&&m.length===1&&D2(m[0])||m.pop())}function R1(a){return a.username!==""||a.password!==""}function N2(a){return a.host===null||a.host===""||a.cannotBeABaseURL||a.scheme==="file"}function D2(a){return/^[A-Za-z]:$/.test(a)}function b(a,m,o,n,h){if(this.pointer=0,this.input=a,this.base=m||null,this.encodingOverride=o||"utf-8",this.stateOverride=h,this.url=n,this.failure=!1,this.parseError=!1,!this.url){this.url={scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,cannotBeABaseURL:!1};const C=c2(this.input);C!==this.input&&(this.parseError=!0),this.input=C}const V=_2(this.input);for(V!==this.input&&(this.parseError=!0),this.input=V,this.state=h||"scheme start",this.buffer="",this.atFlag=!1,this.arrFlag=!1,this.passwordTokenSeenFlag=!1,this.input=e.ucs2.decode(this.input);this.pointer<=this.input.length;++this.pointer){const C=this.input[this.pointer],H=isNaN(C)?void 0:String.fromCodePoint(C),O=this["parse "+this.state](C,H);if(O){if(O===d){this.failure=!0;break}}else break}}b.prototype["parse scheme start"]=function(m,o){if(r(m))this.buffer+=o.toLowerCase(),this.state="scheme";else if(!this.stateOverride)this.state="no scheme",--this.pointer;else return this.parseError=!0,d;return!0},b.prototype["parse scheme"]=function(m,o){if(N(m)||m===43||m===45||m===46)this.buffer+=o.toLowerCase();else if(m===58){if(this.stateOverride&&(g(this.url)&&!A(this.buffer)||!g(this.url)&&A(this.buffer)||(R1(this.url)||this.url.port!==null)&&this.buffer==="file"||this.url.scheme==="file"&&(this.url.host===""||this.url.host===null))||(this.url.scheme=this.buffer,this.buffer="",this.stateOverride))return!1;this.url.scheme==="file"?((this.input[this.pointer+1]!==47||this.input[this.pointer+2]!==47)&&(this.parseError=!0),this.state="file"):g(this.url)&&this.base!==null&&this.base.scheme===this.url.scheme?this.state="special relative or authority":g(this.url)?this.state="special authority slashes":this.input[this.pointer+1]===47?(this.state="path or authority",++this.pointer):(this.url.cannotBeABaseURL=!0,this.url.path.push(""),this.state="cannot-be-a-base-URL path")}else if(!this.stateOverride)this.buffer="",this.state="no scheme",this.pointer=-1;else return this.parseError=!0,d;return!0},b.prototype["parse no scheme"]=function(m){return this.base===null||this.base.cannotBeABaseURL&&m!==35?d:(this.base.cannotBeABaseURL&&m===35?(this.url.scheme=this.base.scheme,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.url.cannotBeABaseURL=!0,this.state="fragment"):this.base.scheme==="file"?(this.state="file",--this.pointer):(this.state="relative",--this.pointer),!0)},b.prototype["parse special relative or authority"]=function(m){return m===47&&this.input[this.pointer+1]===47?(this.state="special authority ignore slashes",++this.pointer):(this.parseError=!0,this.state="relative",--this.pointer),!0},b.prototype["parse path or authority"]=function(m){return m===47?this.state="authority":(this.state="path",--this.pointer),!0},b.prototype["parse relative"]=function(m){return this.url.scheme=this.base.scheme,isNaN(m)?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query=this.base.query):m===47?this.state="relative slash":m===63?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query="",this.state="query"):m===35?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.state="fragment"):g(this.url)&&m===92?(this.parseError=!0,this.state="relative slash"):(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(0,this.base.path.length-1),this.state="path",--this.pointer),!0},b.prototype["parse relative slash"]=function(m){return g(this.url)&&(m===47||m===92)?(m===92&&(this.parseError=!0),this.state="special authority ignore slashes"):m===47?this.state="authority":(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.state="path",--this.pointer),!0},b.prototype["parse special authority slashes"]=function(m){return m===47&&this.input[this.pointer+1]===47?(this.state="special authority ignore slashes",++this.pointer):(this.parseError=!0,this.state="special authority ignore slashes",--this.pointer),!0},b.prototype["parse special authority ignore slashes"]=function(m){return m!==47&&m!==92?(this.state="authority",--this.pointer):this.parseError=!0,!0},b.prototype["parse authority"]=function(m,o){if(m===64){this.parseError=!0,this.atFlag&&(this.buffer="%40"+this.buffer),this.atFlag=!0;const n=t(this.buffer);for(let h=0;hMath.pow(2,16)-1)return this.parseError=!0,d;this.url.port=n===z(this.url.scheme)?null:n,this.buffer=""}if(this.stateOverride)return!1;this.state="path start",--this.pointer}else return this.parseError=!0,d;return!0};const V2=new Set([47,92,63,35]);b.prototype["parse file"]=function(m){return this.url.scheme="file",m===47||m===92?(m===92&&(this.parseError=!0),this.state="file slash"):this.base!==null&&this.base.scheme==="file"?isNaN(m)?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query=this.base.query):m===63?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query="",this.state="query"):m===35?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.state="fragment"):(this.input.length-this.pointer-1===0||!S(m,this.input[this.pointer+1])||this.input.length-this.pointer-1>=2&&!V2.has(this.input[this.pointer+2])?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),P1(this.url)):this.parseError=!0,this.state="path",--this.pointer):(this.state="path",--this.pointer),!0},b.prototype["parse file slash"]=function(m){return m===47||m===92?(m===92&&(this.parseError=!0),this.state="file host"):(this.base!==null&&this.base.scheme==="file"&&(_(this.base.path[0])?this.url.path.push(this.base.path[0]):this.url.host=this.base.host),this.state="path",--this.pointer),!0},b.prototype["parse file host"]=function(m,o){if(isNaN(m)||m===47||m===92||m===63||m===35)if(--this.pointer,!this.stateOverride&&f(this.buffer))this.parseError=!0,this.state="path";else if(this.buffer===""){if(this.url.host="",this.stateOverride)return!1;this.state="path start"}else{let n=n1(this.buffer,g(this.url));if(n===d)return d;if(n==="localhost"&&(n=""),this.url.host=n,this.stateOverride)return!1;this.buffer="",this.state="path start"}else this.buffer+=o;return!0},b.prototype["parse path start"]=function(m){return g(this.url)?(m===92&&(this.parseError=!0),this.state="path",m!==47&&m!==92&&--this.pointer):!this.stateOverride&&m===63?(this.url.query="",this.state="query"):!this.stateOverride&&m===35?(this.url.fragment="",this.state="fragment"):m!==void 0&&(this.state="path",m!==47&&--this.pointer),!0},b.prototype["parse path"]=function(m){if(isNaN(m)||m===47||g(this.url)&&m===92||!this.stateOverride&&(m===63||m===35)){if(g(this.url)&&m===92&&(this.parseError=!0),u(this.buffer)?(P1(this.url),m!==47&&!(g(this.url)&&m===92)&&this.url.path.push("")):w(this.buffer)&&m!==47&&!(g(this.url)&&m===92)?this.url.path.push(""):w(this.buffer)||(this.url.scheme==="file"&&this.url.path.length===0&&f(this.buffer)&&(this.url.host!==""&&this.url.host!==null&&(this.parseError=!0,this.url.host=""),this.buffer=this.buffer[0]+":"),this.url.path.push(this.buffer)),this.buffer="",this.url.scheme==="file"&&(m===void 0||m===63||m===35))for(;this.url.path.length>1&&this.url.path[0]==="";)this.parseError=!0,this.url.path.shift();m===63&&(this.url.query="",this.state="query"),m===35&&(this.url.fragment="",this.state="fragment")}else m===37&&(!c(this.input[this.pointer+1])||!c(this.input[this.pointer+2]))&&(this.parseError=!0),this.buffer+=Z(m,x1);return!0},b.prototype["parse cannot-be-a-base-URL path"]=function(m){return m===63?(this.url.query="",this.state="query"):m===35?(this.url.fragment="",this.state="fragment"):(!isNaN(m)&&m!==37&&(this.parseError=!0),m===37&&(!c(this.input[this.pointer+1])||!c(this.input[this.pointer+2]))&&(this.parseError=!0),isNaN(m)||(this.url.path[0]=this.url.path[0]+Z(m,s1))),!0},b.prototype["parse query"]=function(m,o){if(isNaN(m)||!this.stateOverride&&m===35){(!g(this.url)||this.url.scheme==="ws"||this.url.scheme==="wss")&&(this.encodingOverride="utf-8");const n=new Buffer(this.buffer);for(let h=0;h126||n[h]===34||n[h]===35||n[h]===60||n[h]===62?this.url.query+=x(n[h]):this.url.query+=String.fromCodePoint(n[h]);this.buffer="",m===35&&(this.url.fragment="",this.state="fragment")}else m===37&&(!c(this.input[this.pointer+1])||!c(this.input[this.pointer+2]))&&(this.parseError=!0),this.buffer+=o;return!0},b.prototype["parse fragment"]=function(m){return isNaN(m)||(m===0?this.parseError=!0:(m===37&&(!c(this.input[this.pointer+1])||!c(this.input[this.pointer+2]))&&(this.parseError=!0),this.url.fragment+=Z(m,s1))),!0};function S2(a,m){let o=a.scheme+":";if(a.host!==null?(o+="//",(a.username!==""||a.password!=="")&&(o+=a.username,a.password!==""&&(o+=":"+a.password),o+="@"),o+=v1(a.host),a.port!==null&&(o+=":"+a.port)):a.host===null&&a.scheme==="file"&&(o+="//"),a.cannotBeABaseURL)o+=a.path[0];else for(const n of a.path)o+="/"+n;return a.query!==null&&(o+="?"+a.query),!m&&a.fragment!==null&&(o+="#"+a.fragment),o}function g2(a){let m=a.scheme+"://";return m+=v1(a.host),a.port!==null&&(m+=":"+a.port),m}p.exports.serializeURL=S2,p.exports.serializeURLOrigin=function(a){switch(a.scheme){case"blob":try{return p.exports.serializeURLOrigin(p.exports.parseURL(a.path[0]))}catch{return"null"}case"ftp":case"gopher":case"http":case"https":case"ws":case"wss":return g2({scheme:a.scheme,host:a.host,port:a.port});case"file":return"file://";default:return"null"}},p.exports.basicURLParse=function(a,m){m===void 0&&(m={});const o=new b(a,m.baseURL,m.encodingOverride,m.url,m.stateOverride);return o.failure?"failure":o.url},p.exports.setTheUsername=function(a,m){a.username="";const o=e.ucs2.decode(m);for(let n=0;n1&&arguments[1]!==void 0?arguments[1]:{},i=l.size;let d=i===void 0?0:i;var t=l.timeout;let s=t===void 0?0:t;p==null?p=null:a2(p)?p=Buffer.from(p.toString()):t1(p)||Buffer.isBuffer(p)||(Object.prototype.toString.call(p)==="[object ArrayBuffer]"?p=Buffer.from(p):ArrayBuffer.isView(p)?p=Buffer.from(p.buffer,p.byteOffset,p.byteLength):p instanceof T||(p=Buffer.from(String(p)))),this[$]={body:p,disturbed:!1,error:null},this.size=d,this.timeout=s,p instanceof T&&p.on("error",function(v){const r=v.name==="AbortError"?v:new F(`Invalid response body while trying to fetch ${e.url}: ${v.message}`,"system",v);e[$].error=r})}B.prototype={get body(){return this[$].body},get bodyUsed(){return this[$].disturbed},arrayBuffer(){return Y.call(this).then(function(p){return p.buffer.slice(p.byteOffset,p.byteOffset+p.byteLength)})},blob(){let p=this.headers&&this.headers.get("content-type")||"";return Y.call(this).then(function(e){return Object.assign(new p1([],{type:p.toLowerCase()}),{[q]:e})})},json(){var p=this;return Y.call(this).then(function(e){try{return JSON.parse(e.toString())}catch(l){return B.Promise.reject(new F(`invalid json response body at ${p.url} reason: ${l.message}`,"invalid-json"))}})},text(){return Y.call(this).then(function(p){return p.toString()})},buffer(){return Y.call(this)},textConverted(){var p=this;return Y.call(this).then(function(e){return H2(e,p.headers)})}};Object.defineProperties(B.prototype,{body:{enumerable:!0},bodyUsed:{enumerable:!0},arrayBuffer:{enumerable:!0},blob:{enumerable:!0},json:{enumerable:!0},text:{enumerable:!0}});B.mixIn=function(p){for(const e of Object.getOwnPropertyNames(B.prototype))if(!(e in p)){const l=Object.getOwnPropertyDescriptor(B.prototype,e);Object.defineProperty(p,e,l)}};function Y(){var p=this;if(this[$].disturbed)return B.Promise.reject(new TypeError(`body used already for: ${this.url}`));if(this[$].disturbed=!0,this[$].error)return B.Promise.reject(this[$].error);let e=this.body;if(e===null)return B.Promise.resolve(Buffer.alloc(0));if(t1(e)&&(e=e.stream()),Buffer.isBuffer(e))return B.Promise.resolve(e);if(!(e instanceof T))return B.Promise.resolve(Buffer.alloc(0));let l=[],i=0,d=!1;return new B.Promise(function(t,s){let v;p.timeout&&(v=setTimeout(function(){d=!0,s(new F(`Response timeout while trying to fetch ${p.url} (over ${p.timeout}ms)`,"body-timeout"))},p.timeout)),e.on("error",function(r){r.name==="AbortError"?(d=!0,s(r)):s(new F(`Invalid response body while trying to fetch ${p.url}: ${r.message}`,"system",r))}),e.on("data",function(r){if(!(d||r===null)){if(p.size&&i+r.length>p.size){d=!0,s(new F(`content size at ${p.url} over limit: ${p.size}`,"max-size"));return}i+=r.length,l.push(r)}}),e.on("end",function(){if(!d){clearTimeout(v);try{t(Buffer.concat(l,i))}catch(r){s(new F(`Could not create Buffer from response body for ${p.url}: ${r.message}`,"system",r))}}})})}function H2(p,e){throw new Error("The package `encoding` must be installed to use the textConverted() function")}function a2(p){return typeof p!="object"||typeof p.append!="function"||typeof p.delete!="function"||typeof p.get!="function"||typeof p.getAll!="function"||typeof p.has!="function"||typeof p.set!="function"?!1:p.constructor.name==="URLSearchParams"||Object.prototype.toString.call(p)==="[object URLSearchParams]"||typeof p.sort=="function"}function t1(p){return typeof p=="object"&&typeof p.arrayBuffer=="function"&&typeof p.type=="string"&&typeof p.stream=="function"&&typeof p.constructor=="function"&&typeof p.constructor.name=="string"&&/^(Blob|File)$/.test(p.constructor.name)&&/^(Blob|File)$/.test(p[Symbol.toStringTag])}function m2(p){let e,l,i=p.body;if(p.bodyUsed)throw new Error("cannot clone body after it is used");return i instanceof T&&typeof i.getBoundary!="function"&&(e=new M1,l=new M1,i.pipe(e),i.pipe(l),p[$].body=e,i=l),i}function l2(p){return p===null?null:typeof p=="string"?"text/plain;charset=UTF-8":a2(p)?"application/x-www-form-urlencoded;charset=UTF-8":t1(p)?p.type||null:Buffer.isBuffer(p)||Object.prototype.toString.call(p)==="[object ArrayBuffer]"||ArrayBuffer.isView(p)?null:typeof p.getBoundary=="function"?`multipart/form-data;boundary=${p.getBoundary()}`:p instanceof T?null:"text/plain;charset=UTF-8"}function i2(p){const e=p.body;return e===null?0:t1(e)?e.size:Buffer.isBuffer(e)?e.length:e&&typeof e.getLengthSync=="function"&&(e._lengthRetrievers&&e._lengthRetrievers.length==0||e.hasKnownLength&&e.hasKnownLength())?e.getLengthSync():null}function G2(p,e){const l=e.body;l===null?p.end():t1(l)?l.stream().pipe(p):Buffer.isBuffer(l)?(p.write(l),p.end()):l.pipe(p)}B.Promise=global.Promise;const t2=/[^\^_`a-zA-Z\-0-9!#$%&'*+.|~]/,T1=/[^\t\x20-\x7e\x80-\xff]/;function a1(p){if(p=`${p}`,t2.test(p)||p==="")throw new TypeError(`${p} is not a legal HTTP header name`)}function H1(p){if(p=`${p}`,T1.test(p))throw new TypeError(`${p} is not a legal HTTP header value`)}function Q(p,e){e=e.toLowerCase();for(const l in p)if(l.toLowerCase()===e)return l}const E=Symbol("map");class L{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0;if(this[E]=Object.create(null),e instanceof L){const l=e.raw(),i=Object.keys(l);for(const d of i)for(const t of l[d])this.append(d,t);return}if(e!=null)if(typeof e=="object"){const l=e[Symbol.iterator];if(l!=null){if(typeof l!="function")throw new TypeError("Header pairs must be iterable");const i=[];for(const d of e){if(typeof d!="object"||typeof d[Symbol.iterator]!="function")throw new TypeError("Each header pair must be iterable");i.push(Array.from(d))}for(const d of i){if(d.length!==2)throw new TypeError("Each header pair must be a name/value tuple");this.append(d[0],d[1])}}else for(const i of Object.keys(e)){const d=e[i];this.append(i,d)}}else throw new TypeError("Provided initializer must be an object")}get(e){e=`${e}`,a1(e);const l=Q(this[E],e);return l===void 0?null:this[E][l].join(", ")}forEach(e){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,i=b1(this),d=0;for(;d1&&arguments[1]!==void 0?arguments[1]:"key+value";return Object.keys(p[E]).sort().map(e==="key"?function(i){return i.toLowerCase()}:e==="value"?function(i){return p[E][i].join(", ")}:function(i){return[i.toLowerCase(),p[E][i].join(", ")]})}const y1=Symbol("internal");function V1(p,e){const l=Object.create(F1);return l[y1]={target:p,kind:e,index:0},l}const F1=Object.setPrototypeOf({next(){if(!this||Object.getPrototypeOf(this)!==F1)throw new TypeError("Value of `this` is not a HeadersIterator");var p=this[y1];const e=p.target,l=p.kind,i=p.index,d=b1(e,l),t=d.length;return i>=t?{value:void 0,done:!0}:(this[y1].index=i+1,{value:d[i],done:!1})}},Object.getPrototypeOf(Object.getPrototypeOf([][Symbol.iterator]())));Object.defineProperty(F1,Symbol.toStringTag,{value:"HeadersIterator",writable:!1,enumerable:!1,configurable:!0});function W2(p){const e=Object.assign({__proto__:null},p[E]),l=Q(p[E],"Host");return l!==void 0&&(e[l]=e[l][0]),e}function Z2(p){const e=new L;for(const l of Object.keys(p))if(!t2.test(l))if(Array.isArray(p[l]))for(const i of p[l])T1.test(i)||(e[E][l]===void 0?e[E][l]=[i]:e[E][l].push(i));else T1.test(p[l])||(e[E][l]=[p[l]]);return e}const G=Symbol("Response internals"),J2=T.STATUS_CODES;class R{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};B.call(this,e,l);const i=l.status||200,d=new L(l.headers);if(e!=null&&!d.has("Content-Type")){const t=l2(e);t&&d.append("Content-Type",t)}this[G]={url:l.url,status:i,statusText:l.statusText||J2[i],headers:d,counter:l.counter}}get url(){return this[G].url||""}get status(){return this[G].status}get ok(){return this[G].status>=200&&this[G].status<300}get redirected(){return this[G].counter>0}get statusText(){return this[G].statusText}get headers(){return this[G].headers}clone(){return new R(m2(this),{url:this.url,status:this.status,statusText:this.statusText,headers:this.headers,ok:this.ok,redirected:this.redirected})}}B.mixIn(R.prototype);Object.defineProperties(R.prototype,{url:{enumerable:!0},status:{enumerable:!0},ok:{enumerable:!0},redirected:{enumerable:!0},statusText:{enumerable:!0},headers:{enumerable:!0},clone:{enumerable:!0}});Object.defineProperty(R.prototype,Symbol.toStringTag,{value:"Response",writable:!1,enumerable:!1,configurable:!0});const j=Symbol("Request internals"),K2=T.URL||d2.URL,Y2=T.parse,Q2=T.format;function S1(p){return/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(p)&&(p=new K2(p).toString()),Y2(p)}const X2="destroy"in T.Readable.prototype;function r1(p){return typeof p=="object"&&typeof p[j]=="object"}function pp(p){const e=p&&typeof p=="object"&&Object.getPrototypeOf(p);return!!(e&&e.constructor.name==="AbortSignal")}class K{constructor(e){let l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i;r1(e)?i=S1(e.url):(e&&e.href?i=S1(e.href):i=S1(`${e}`),e={});let d=l.method||e.method||"GET";if(d=d.toUpperCase(),(l.body!=null||r1(e)&&e.body!==null)&&(d==="GET"||d==="HEAD"))throw new TypeError("Request with GET/HEAD method cannot have body");let t=l.body!=null?l.body:r1(e)&&e.body!==null?m2(e):null;B.call(this,t,{timeout:l.timeout||e.timeout||0,size:l.size||e.size||0});const s=new L(l.headers||e.headers||{});if(t!=null&&!s.has("Content-Type")){const r=l2(t);r&&s.append("Content-Type",r)}let v=r1(e)?e.signal:null;if("signal"in l&&(v=l.signal),v!=null&&!pp(v))throw new TypeError("Expected signal to be an instanceof AbortSignal");this[j]={method:d,redirect:l.redirect||e.redirect||"follow",headers:s,parsedURL:i,signal:v},this.follow=l.follow!==void 0?l.follow:e.follow!==void 0?e.follow:20,this.compress=l.compress!==void 0?l.compress:e.compress!==void 0?e.compress:!0,this.counter=l.counter||e.counter||0,this.agent=l.agent||e.agent}get method(){return this[j].method}get url(){return Q2(this[j].parsedURL)}get headers(){return this[j].headers}get redirect(){return this[j].redirect}get signal(){return this[j].signal}clone(){return new K(this)}}B.mixIn(K.prototype);Object.defineProperty(K.prototype,Symbol.toStringTag,{value:"Request",writable:!1,enumerable:!1,configurable:!0});Object.defineProperties(K.prototype,{method:{enumerable:!0},url:{enumerable:!0},headers:{enumerable:!0},redirect:{enumerable:!0},clone:{enumerable:!0},signal:{enumerable:!0}});function ep(p){const e=p[j].parsedURL,l=new L(p[j].headers);if(l.has("Accept")||l.set("Accept","*/*"),!e.protocol||!e.hostname)throw new TypeError("Only absolute URLs are supported");if(!/^https?:$/.test(e.protocol))throw new TypeError("Only HTTP(S) protocols are supported");if(p.signal&&p.body instanceof T.Readable&&!X2)throw new Error("Cancellation of streamed requests with AbortSignal is not supported in node < 8");let i=null;if(p.body==null&&/^(POST|PUT)$/i.test(p.method)&&(i="0"),p.body!=null){const t=i2(p);typeof t=="number"&&(i=String(t))}i&&l.set("Content-Length",i),l.has("User-Agent")||l.set("User-Agent","node-fetch/1.0 (+https://github.com/bitinn/node-fetch)"),p.compress&&!l.has("Accept-Encoding")&&l.set("Accept-Encoding","gzip,deflate");let d=p.agent;return typeof d=="function"&&(d=d(e)),!l.has("Connection")&&!d&&l.set("Connection","close"),Object.assign({},e,{method:p.method,headers:W2(l),agent:d})}function l1(p){Error.call(this,p),this.type="aborted",this.message=p,Error.captureStackTrace(this,this.constructor)}l1.prototype=Object.create(Error.prototype);l1.prototype.constructor=l1;l1.prototype.name="AbortError";const i1=T.URL||d2.URL,G1=T.PassThrough,dp=function(e,l){const i=new i1(l).hostname,d=new i1(e).hostname;return i===d||i[i.length-d.length-1]==="."&&i.endsWith(d)},ap=function(e,l){const i=new i1(l).protocol,d=new i1(e).protocol;return i===d};function J(p,e){if(!J.Promise)throw new Error("native promise missing, set fetch.Promise to your favorite alternative");return B.Promise=J.Promise,new J.Promise(function(l,i){const d=new K(p,e),t=ep(d),s=(t.protocol==="https:",T).request,v=d.signal;let r=null;const N=function(){let _=new l1("The user aborted a request.");i(_),d.body&&d.body instanceof T.Readable&&g1(d.body,_),!(!r||!r.body)&&r.body.emit("error",_)};if(v&&v.aborted){N();return}const c=function(){N(),S()},w=s(t);let u;v&&v.addEventListener("abort",c);function S(){w.abort(),v&&v.removeEventListener("abort",c),clearTimeout(u)}d.timeout&&w.once("socket",function(f){u=setTimeout(function(){i(new F(`network timeout at: ${d.url}`,"request-timeout")),S()},d.timeout)}),w.on("error",function(f){i(new F(`request to ${d.url} failed, reason: ${f.message}`,"system",f)),r&&r.body&&g1(r.body,f),S()}),mp(w,function(f){v&&v.aborted||r&&r.body&&g1(r.body,f)}),parseInt(process.version.substring(1))<14&&w.on("socket",function(f){f.addListener("close",function(_){const D=f.listenerCount("data")>0;if(r&&D&&!_&&!(v&&v.aborted)){const y=new Error("Premature close");y.code="ERR_STREAM_PREMATURE_CLOSE",r.body.emit("error",y)}})}),w.on("response",function(f){clearTimeout(u);const _=Z2(f.headers);if(J.isRedirect(f.statusCode)){const z=_.get("Location");let x=null;try{x=z===null?null:new i1(z,d.url).toString()}catch{if(d.redirect!=="manual"){i(new F(`uri requested responds with an invalid redirect URL: ${z}`,"invalid-redirect")),S();return}}switch(d.redirect){case"error":i(new F(`uri requested responds with a redirect, redirect mode is set to error: ${d.url}`,"no-redirect")),S();return;case"manual":if(x!==null)try{_.set("Location",x)}catch(e1){i(e1)}break;case"follow":if(x===null)break;if(d.counter>=d.follow){i(new F(`maximum redirect reached at: ${d.url}`,"max-redirect")),S();return}const M={headers:new L(d.headers),follow:d.follow,counter:d.counter+1,agent:d.agent,compress:d.compress,method:d.method,body:d.body,signal:d.signal,timeout:d.timeout,size:d.size};if(!dp(d.url,x)||!ap(d.url,x))for(const e1 of["authorization","www-authenticate","cookie","cookie2"])M.headers.delete(e1);if(f.statusCode!==303&&d.body&&i2(d)===null){i(new F("Cannot follow redirect with body being a readable stream","unsupported-redirect")),S();return}(f.statusCode===303||(f.statusCode===301||f.statusCode===302)&&d.method==="POST")&&(M.method="GET",M.body=void 0,M.headers.delete("content-length")),l(J(new K(x,M))),S();return}}f.once("end",function(){v&&v.removeEventListener("abort",c)});let D=f.pipe(new G1);const y={url:d.url,status:f.statusCode,statusText:f.statusMessage,headers:_,size:d.size,timeout:d.timeout,counter:d.counter},A=_.get("Content-Encoding");if(!d.compress||d.method==="HEAD"||A===null||f.statusCode===204||f.statusCode===304){r=new R(D,y),l(r);return}const g={flush:T.Z_SYNC_FLUSH,finishFlush:T.Z_SYNC_FLUSH};if(A=="gzip"||A=="x-gzip"){D=D.pipe(T.createGunzip(g)),r=new R(D,y),l(r);return}if(A=="deflate"||A=="x-deflate"){const z=f.pipe(new G1);z.once("data",function(x){(x[0]&15)===8?D=D.pipe(T.createInflate()):D=D.pipe(T.createInflateRaw()),r=new R(D,y),l(r)}),z.on("end",function(){r||(r=new R(D,y),l(r))});return}if(A=="br"&&typeof T.createBrotliDecompress=="function"){D=D.pipe(T.createBrotliDecompress()),r=new R(D,y),l(r);return}r=new R(D,y),l(r)}),G2(w,d)})}function mp(p,e){let l;p.on("socket",function(i){l=i}),p.on("response",function(i){const d=i.headers;d["transfer-encoding"]==="chunked"&&!d["content-length"]&&i.once("close",function(t){if(l&&l.listenerCount("data")>0&&!t){const v=new Error("Premature close");v.code="ERR_STREAM_PREMATURE_CLOSE",e(v)}})})}function g1(p,e){p.destroy?p.destroy(e):(p.emit("error",e),p.end())}J.isRedirect=function(p){return p===301||p===302||p===303||p===307||p===308};J.Promise=global.Promise;export{F as FetchError,L as Headers,K as Request,R as Response,J as default};