@plasmohq/bms
Version:
Browser Market Submission
3 lines • 703 kB
JavaScript
var RS=Object.create;var fa=Object.defineProperty;var BS=Object.getOwnPropertyDescriptor;var kS=Object.getOwnPropertyNames;var xS=Object.getPrototypeOf,NS=Object.prototype.hasOwnProperty;var ne=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),PS=(t,e)=>{for(var r in e)fa(t,r,{get:e[r],enumerable:!0})},lp=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of kS(e))!NS.call(t,i)&&i!==r&&fa(t,i,{get:()=>e[i],enumerable:!(n=BS(e,i))||n.enumerable});return t};var Me=(t,e,r)=>(r=t!=null?RS(xS(t)):{},lp(e||!t||!t.__esModule?fa(r,"default",{value:t,enumerable:!0}):r,t)),OS=t=>lp(fa({},"__esModule",{value:!0}),t);var By=ne((el,tl)=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});function B_(t){return t.encrypted}var Zu=(t,e)=>{let r;typeof e=="function"?r={connect:e}:r=e;let n=typeof r.connect=="function",i=typeof r.secureConnect=="function",s=typeof r.close=="function",a=()=>{n&&r.connect(),B_(t)&&i&&(t.authorized?r.secureConnect():t.authorizationError||t.once("secureConnect",r.secureConnect)),s&&t.once("close",r.close)};t.writable&&!t.connecting?a():t.connecting?t.once("connect",a):t.destroyed&&s&&r.close(t._hadError)};el.default=Zu;tl.exports=Zu;tl.exports.default=Zu});var ul=ne((lO,Jy)=>{"use strict";var Z_=new Set([200,203,204,206,300,301,308,404,405,410,414,501]),eT=new Set([200,203,204,300,301,302,303,307,308,404,405,410,414,501]),tT=new Set([500,502,503,504]),rT={date:!0,connection:!0,"keep-alive":!0,"proxy-authenticate":!0,"proxy-authorization":!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0},nT={"content-length":!0,"content-encoding":!0,"transfer-encoding":!0,"content-range":!0};function zn(t){let e=parseInt(t,10);return isFinite(e)?e:0}function iT(t){return t?tT.has(t.status):!0}function cl(t){let e={};if(!t)return e;let r=t.trim().split(/,/);for(let n of r){let[i,s]=n.split(/=/,2);e[i.trim()]=s===void 0?!0:s.trim().replace(/^"|"$/g,"")}return e}function sT(t){let e=[];for(let r in t){let n=t[r];e.push(n===!0?r:r+"="+n)}if(e.length)return e.join(", ")}Jy.exports=class{constructor(e,r,{shared:n,cacheHeuristic:i,immutableMinTimeToLive:s,ignoreCargoCult:a,_fromObject:c}={}){if(c){this._fromObject(c);return}if(!r||!r.headers)throw Error("Response headers missing");this._assertRequestHasHeaders(e),this._responseTime=this.now(),this._isShared=n!==!1,this._cacheHeuristic=i!==void 0?i:.1,this._immutableMinTtl=s!==void 0?s:24*3600*1e3,this._status="status"in r?r.status:200,this._resHeaders=r.headers,this._rescc=cl(r.headers["cache-control"]),this._method="method"in e?e.method:"GET",this._url=e.url,this._host=e.headers.host,this._noAuthorization=!e.headers.authorization,this._reqHeaders=r.headers.vary?e.headers:null,this._reqcc=cl(e.headers["cache-control"]),a&&"pre-check"in this._rescc&&"post-check"in this._rescc&&(delete this._rescc["pre-check"],delete this._rescc["post-check"],delete this._rescc["no-cache"],delete this._rescc["no-store"],delete this._rescc["must-revalidate"],this._resHeaders=Object.assign({},this._resHeaders,{"cache-control":sT(this._rescc)}),delete this._resHeaders.expires,delete this._resHeaders.pragma),r.headers["cache-control"]==null&&/no-cache/.test(r.headers.pragma)&&(this._rescc["no-cache"]=!0)}now(){return Date.now()}storable(){return!!(!this._reqcc["no-store"]&&(this._method==="GET"||this._method==="HEAD"||this._method==="POST"&&this._hasExplicitExpiration())&&eT.has(this._status)&&!this._rescc["no-store"]&&(!this._isShared||!this._rescc.private)&&(!this._isShared||this._noAuthorization||this._allowsStoringAuthenticated())&&(this._resHeaders.expires||this._rescc["max-age"]||this._isShared&&this._rescc["s-maxage"]||this._rescc.public||Z_.has(this._status)))}_hasExplicitExpiration(){return this._isShared&&this._rescc["s-maxage"]||this._rescc["max-age"]||this._resHeaders.expires}_assertRequestHasHeaders(e){if(!e||!e.headers)throw Error("Request headers missing")}satisfiesWithoutRevalidation(e){this._assertRequestHasHeaders(e);let r=cl(e.headers["cache-control"]);return r["no-cache"]||/no-cache/.test(e.headers.pragma)||r["max-age"]&&this.age()>r["max-age"]||r["min-fresh"]&&this.timeToLive()<1e3*r["min-fresh"]||this.stale()&&!(r["max-stale"]&&!this._rescc["must-revalidate"]&&(r["max-stale"]===!0||r["max-stale"]>this.age()-this.maxAge()))?!1:this._requestMatches(e,!1)}_requestMatches(e,r){return(!this._url||this._url===e.url)&&this._host===e.headers.host&&(!e.method||this._method===e.method||r&&e.method==="HEAD")&&this._varyMatches(e)}_allowsStoringAuthenticated(){return this._rescc["must-revalidate"]||this._rescc.public||this._rescc["s-maxage"]}_varyMatches(e){if(!this._resHeaders.vary)return!0;if(this._resHeaders.vary==="*")return!1;let r=this._resHeaders.vary.trim().toLowerCase().split(/\s*,\s*/);for(let n of r)if(e.headers[n]!==this._reqHeaders[n])return!1;return!0}_copyWithoutHopByHopHeaders(e){let r={};for(let n in e)rT[n]||(r[n]=e[n]);if(e.connection){let n=e.connection.trim().split(/\s*,\s*/);for(let i of n)delete r[i]}if(r.warning){let n=r.warning.split(/,/).filter(i=>!/^\s*1[0-9][0-9]/.test(i));n.length?r.warning=n.join(",").trim():delete r.warning}return r}responseHeaders(){let e=this._copyWithoutHopByHopHeaders(this._resHeaders),r=this.age();return r>3600*24&&!this._hasExplicitExpiration()&&this.maxAge()>3600*24&&(e.warning=(e.warning?`${e.warning}, `:"")+'113 - "rfc7234 5.5.4"'),e.age=`${Math.round(r)}`,e.date=new Date(this.now()).toUTCString(),e}date(){let e=Date.parse(this._resHeaders.date);return isFinite(e)?e:this._responseTime}age(){let e=this._ageValue(),r=(this.now()-this._responseTime)/1e3;return e+r}_ageValue(){return zn(this._resHeaders.age)}maxAge(){if(!this.storable()||this._rescc["no-cache"]||this._isShared&&this._resHeaders["set-cookie"]&&!this._rescc.public&&!this._rescc.immutable||this._resHeaders.vary==="*")return 0;if(this._isShared){if(this._rescc["proxy-revalidate"])return 0;if(this._rescc["s-maxage"])return zn(this._rescc["s-maxage"])}if(this._rescc["max-age"])return zn(this._rescc["max-age"]);let e=this._rescc.immutable?this._immutableMinTtl:0,r=this.date();if(this._resHeaders.expires){let n=Date.parse(this._resHeaders.expires);return Number.isNaN(n)||n<r?0:Math.max(e,(n-r)/1e3)}if(this._resHeaders["last-modified"]){let n=Date.parse(this._resHeaders["last-modified"]);if(isFinite(n)&&r>n)return Math.max(e,(r-n)/1e3*this._cacheHeuristic)}return e}timeToLive(){let e=this.maxAge()-this.age(),r=e+zn(this._rescc["stale-if-error"]),n=e+zn(this._rescc["stale-while-revalidate"]);return Math.max(0,e,r,n)*1e3}stale(){return this.maxAge()<=this.age()}_useStaleIfError(){return this.maxAge()+zn(this._rescc["stale-if-error"])>this.age()}useStaleWhileRevalidate(){return this.maxAge()+zn(this._rescc["stale-while-revalidate"])>this.age()}static fromObject(e){return new this(void 0,void 0,{_fromObject:e})}_fromObject(e){if(this._responseTime)throw Error("Reinitialized");if(!e||e.v!==1)throw Error("Invalid serialization");this._responseTime=e.t,this._isShared=e.sh,this._cacheHeuristic=e.ch,this._immutableMinTtl=e.imm!==void 0?e.imm:24*3600*1e3,this._status=e.st,this._resHeaders=e.resh,this._rescc=e.rescc,this._method=e.m,this._url=e.u,this._host=e.h,this._noAuthorization=e.a,this._reqHeaders=e.reqh,this._reqcc=e.reqcc}toObject(){return{v:1,t:this._responseTime,sh:this._isShared,ch:this._cacheHeuristic,imm:this._immutableMinTtl,st:this._status,resh:this._resHeaders,rescc:this._rescc,m:this._method,u:this._url,h:this._host,a:this._noAuthorization,reqh:this._reqHeaders,reqcc:this._reqcc}}revalidationHeaders(e){this._assertRequestHasHeaders(e);let r=this._copyWithoutHopByHopHeaders(e.headers);if(delete r["if-range"],!this._requestMatches(e,!0)||!this.storable())return delete r["if-none-match"],delete r["if-modified-since"],r;if(this._resHeaders.etag&&(r["if-none-match"]=r["if-none-match"]?`${r["if-none-match"]}, ${this._resHeaders.etag}`:this._resHeaders.etag),r["accept-ranges"]||r["if-match"]||r["if-unmodified-since"]||this._method&&this._method!="GET"){if(delete r["if-modified-since"],r["if-none-match"]){let i=r["if-none-match"].split(/,/).filter(s=>!/^\s*W\//.test(s));i.length?r["if-none-match"]=i.join(",").trim():delete r["if-none-match"]}}else this._resHeaders["last-modified"]&&!r["if-modified-since"]&&(r["if-modified-since"]=this._resHeaders["last-modified"]);return r}revalidatedPolicy(e,r){if(this._assertRequestHasHeaders(e),this._useStaleIfError()&&iT(r))return{modified:!1,matches:!1,policy:this};if(!r||!r.headers)throw Error("Response headers missing");let n=!1;if(r.status!==void 0&&r.status!=304?n=!1:r.headers.etag&&!/^\s*W\//.test(r.headers.etag)?n=this._resHeaders.etag&&this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag:this._resHeaders.etag&&r.headers.etag?n=this._resHeaders.etag.replace(/^\s*W\//,"")===r.headers.etag.replace(/^\s*W\//,""):this._resHeaders["last-modified"]?n=this._resHeaders["last-modified"]===r.headers["last-modified"]:!this._resHeaders.etag&&!this._resHeaders["last-modified"]&&!r.headers.etag&&!r.headers["last-modified"]&&(n=!0),!n)return{policy:new this.constructor(e,r),modified:r.status!=304,matches:!1};let i={};for(let a in this._resHeaders)i[a]=a in r.headers&&!nT[a]?r.headers[a]:this._resHeaders[a];let s=Object.assign({},r,{status:this._status,method:this._method,headers:i});return{policy:new this.constructor(e,s,{shared:this._isShared,cacheHeuristic:this._cacheHeuristic,immutableMinTimeToLive:this._immutableMinTtl}),modified:!1,matches:!0}}}});var fl=ne(ll=>{ll.stringify=function t(e){if(typeof e>"u")return e;if(e&&Buffer.isBuffer(e))return JSON.stringify(":base64:"+e.toString("base64"));if(e&&e.toJSON&&(e=e.toJSON()),e&&typeof e=="object"){var r="",n=Array.isArray(e);r=n?"[":"{";var i=!0;for(var s in e){var a=typeof e[s]=="function"||!n&&typeof e[s]>"u";Object.hasOwnProperty.call(e,s)&&!a&&(i||(r+=","),i=!1,n?e[s]==null?r+="null":r+=t(e[s]):e[s]!==void 0&&(r+=t(s)+":"+t(e[s])))}return r+=n?"]":"}",r}else return typeof e=="string"?JSON.stringify(/^:/.test(e)?":"+e:e):typeof e>"u"?"null":JSON.stringify(e)};ll.parse=function(t){return JSON.parse(t,function(e,r){return typeof r=="string"?/^:base64:/.test(r)?Buffer.from(r.substring(8),"base64"):/^:/.test(r)?r.substring(1):r:r})}});var nm=ne((yO,rm)=>{"use strict";var oT=require("events"),em=fl(),aT=t=>{let e={redis:"@keyv/redis",rediss:"@keyv/redis",mongodb:"@keyv/mongo",mongo:"@keyv/mongo",sqlite:"@keyv/sqlite",postgresql:"@keyv/postgres",postgres:"@keyv/postgres",mysql:"@keyv/mysql",etcd:"@keyv/etcd",offline:"@keyv/offline",tiered:"@keyv/tiered"};if(t.adapter||t.uri){let r=t.adapter||/^[^:+]*/.exec(t.uri)[0];return new(require(e[r]))(t)}return new Map},tm=["sqlite","postgres","mysql","mongo","redis","tiered"],hl=class extends oT{constructor(e,{emitErrors:r=!0,...n}={}){if(super(),this.opts={namespace:"keyv",serialize:em.stringify,deserialize:em.parse,...typeof e=="string"?{uri:e}:e,...n},!this.opts.store){let s={...this.opts};this.opts.store=aT(s)}if(this.opts.compression){let s=this.opts.compression;this.opts.serialize=s.serialize.bind(s),this.opts.deserialize=s.deserialize.bind(s)}typeof this.opts.store.on=="function"&&r&&this.opts.store.on("error",s=>this.emit("error",s)),this.opts.store.namespace=this.opts.namespace;let i=s=>async function*(){for await(let[a,c]of typeof s=="function"?s(this.opts.store.namespace):s){let u=await this.opts.deserialize(c);if(!(this.opts.store.namespace&&!a.includes(this.opts.store.namespace))){if(typeof u.expires=="number"&&Date.now()>u.expires){this.delete(a);continue}yield[this._getKeyUnprefix(a),u.value]}}};typeof this.opts.store[Symbol.iterator]=="function"&&this.opts.store instanceof Map?this.iterator=i(this.opts.store):typeof this.opts.store.iterator=="function"&&this.opts.store.opts&&this._checkIterableAdaptar()&&(this.iterator=i(this.opts.store.iterator.bind(this.opts.store)))}_checkIterableAdaptar(){return tm.includes(this.opts.store.opts.dialect)||tm.findIndex(e=>this.opts.store.opts.url.includes(e))>=0}_getKeyPrefix(e){return`${this.opts.namespace}:${e}`}_getKeyPrefixArray(e){return e.map(r=>`${this.opts.namespace}:${r}`)}_getKeyUnprefix(e){return e.split(":").splice(1).join(":")}get(e,r){let{store:n}=this.opts,i=Array.isArray(e),s=i?this._getKeyPrefixArray(e):this._getKeyPrefix(e);if(i&&n.getMany===void 0){let a=[];for(let c of s)a.push(Promise.resolve().then(()=>n.get(c)).then(u=>typeof u=="string"?this.opts.deserialize(u):this.opts.compression?this.opts.deserialize(u):u).then(u=>{if(u!=null)return typeof u.expires=="number"&&Date.now()>u.expires?this.delete(c).then(()=>{}):r&&r.raw?u:u.value}));return Promise.allSettled(a).then(c=>{let u=[];for(let o of c)u.push(o.value);return u})}return Promise.resolve().then(()=>i?n.getMany(s):n.get(s)).then(a=>typeof a=="string"?this.opts.deserialize(a):this.opts.compression?this.opts.deserialize(a):a).then(a=>{if(a!=null)return i?a.map((c,u)=>{if(typeof c=="string"&&(c=this.opts.deserialize(c)),c!=null){if(typeof c.expires=="number"&&Date.now()>c.expires){this.delete(e[u]).then(()=>{});return}return r&&r.raw?c:c.value}}):typeof a.expires=="number"&&Date.now()>a.expires?this.delete(e).then(()=>{}):r&&r.raw?a:a.value})}set(e,r,n){let i=this._getKeyPrefix(e);typeof n>"u"&&(n=this.opts.ttl),n===0&&(n=void 0);let{store:s}=this.opts;return Promise.resolve().then(()=>{let a=typeof n=="number"?Date.now()+n:null;return typeof r=="symbol"&&this.emit("error","symbol cannot be serialized"),r={value:r,expires:a},this.opts.serialize(r)}).then(a=>s.set(i,a,n)).then(()=>!0)}delete(e){let{store:r}=this.opts;if(Array.isArray(e)){let i=this._getKeyPrefixArray(e);if(r.deleteMany===void 0){let s=[];for(let a of i)s.push(r.delete(a));return Promise.allSettled(s).then(a=>a.every(c=>c.value===!0))}return Promise.resolve().then(()=>r.deleteMany(i))}let n=this._getKeyPrefix(e);return Promise.resolve().then(()=>r.delete(n))}clear(){let{store:e}=this.opts;return Promise.resolve().then(()=>e.clear())}has(e){let r=this._getKeyPrefix(e),{store:n}=this.opts;return Promise.resolve().then(async()=>typeof n.has=="function"?n.has(r):await n.get(r)!==void 0)}disconnect(){let{store:e}=this.opts;if(typeof e.disconnect=="function")return e.disconnect()}};rm.exports=hl});var um=ne((TO,cm)=>{"use strict";var hT=["aborted","complete","headers","httpVersion","httpVersionMinor","httpVersionMajor","method","rawHeaders","rawTrailers","setTimeout","socket","statusCode","statusMessage","trailers","url"];cm.exports=(t,e)=>{if(e._readableState.autoDestroy)throw new Error("The second stream must have the `autoDestroy` option set to `false`");let r=new Set(Object.keys(t).concat(hT)),n={};for(let i of r)i in e||(n[i]={get(){let s=t[i];return typeof s=="function"?s.bind(t):s},set(s){t[i]=s},enumerable:!0,configurable:!1});return Object.defineProperties(e,n),t.once("aborted",()=>{e.destroy(),e.emit("aborted")}),t.once("close",()=>{t.complete&&e.readable?e.once("end",()=>{e.emit("close")}):e.emit("close")}),e}});var ml=ne((AO,lm)=>{"use strict";var{Transform:dT,PassThrough:pT}=require("stream"),yl=require("zlib"),yT=um();lm.exports=t=>{let e=(t.headers["content-encoding"]||"").toLowerCase();if(!["gzip","deflate","br"].includes(e))return t;let r=e==="br";if(r&&typeof yl.createBrotliDecompress!="function")return t.destroy(new Error("Brotli is not supported on Node.js < 12")),t;let n=!0,i=new dT({transform(c,u,o){n=!1,o(null,c)},flush(c){c()}}),s=new pT({autoDestroy:!1,destroy(c,u){t.destroy(),u(c)}}),a=r?yl.createBrotliDecompress():yl.createUnzip();return a.once("error",c=>{if(n&&!t.readable){s.end();return}s.destroy(c)}),yT(t,s),t.pipe(i).pipe(a).pipe(s),s}});var Ps=ne((HO,Nm)=>{"use strict";var Al=class{constructor(e={}){if(!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=e.maxSize,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(e,r){if(this.cache.set(e,r),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function")for(let[n,i]of this.oldCache.entries())this.onEviction(n,i);this.oldCache=this.cache,this.cache=new Map}}get(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e)){let r=this.oldCache.get(e);return this.oldCache.delete(e),this._set(e,r),r}}set(e,r){return this.cache.has(e)?this.cache.set(e,r):this._set(e,r),this}has(e){return this.cache.has(e)||this.oldCache.has(e)}peek(e){if(this.cache.has(e))return this.cache.get(e);if(this.oldCache.has(e))return this.oldCache.get(e)}delete(e){let r=this.cache.delete(e);return r&&this._size--,this.oldCache.delete(e)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(let[e]of this)yield e}*values(){for(let[,e]of this)yield e}*[Symbol.iterator](){for(let e of this.cache)yield e;for(let e of this.oldCache){let[r]=e;this.cache.has(r)||(yield e)}}get size(){let e=0;for(let r of this.oldCache.keys())this.cache.has(r)||e++;return Math.min(this._size+e,this.maxSize)}};Nm.exports=Al});var Il=ne(($O,Pm)=>{"use strict";Pm.exports=t=>{if(t.listenerCount("error")!==0)return t;t.__destroy=t._destroy,t._destroy=(...r)=>{let n=r.pop();t.__destroy(...r,async i=>{await Promise.resolve(),n(i)})};let e=r=>{Promise.resolve().then(()=>{t.emit("error",r)})};return t.once("error",e),Promise.resolve().then(()=>{t.off("error",e)}),t}});var Wn=ne((zO,jm)=>{"use strict";var{URL:Om}=require("url"),xT=require("events"),NT=require("tls"),PT=require("http2"),OT=Ps(),LT=Il(),Kt=Symbol("currentStreamCount"),Lm=Symbol("request"),Gt=Symbol("cachedOriginSet"),Cn=Symbol("gracefullyClosing"),ka=Symbol("length"),Um=["createConnection","maxDeflateDynamicTableSize","maxSettings","maxSessionMemory","maxHeaderListPairs","maxOutstandingPings","maxReservedRemoteStreams","maxSendHeaderBlockLength","paddingStrategy","peerMaxConcurrentStreams","settings","family","localAddress","rejectUnauthorized","pskCallback","minDHSize","path","socket","ca","cert","sigalgs","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","privateKeyEngine","privateKeyIdentifier","maxVersion","minVersion","pfx","secureOptions","secureProtocol","sessionIdContext","ticketKeys"],UT=(t,e,r)=>{let n=0,i=t.length;for(;n<i;){let s=n+i>>>1;r(t[s],e)?n=s+1:i=s}return n},DT=(t,e)=>t.remoteSettings.maxConcurrentStreams>e.remoteSettings.maxConcurrentStreams,Rl=(t,e)=>{for(let r=0;r<t.length;r++){let n=t[r];n[Gt].length>0&&n[Gt].length<e[Gt].length&&n[Gt].every(i=>e[Gt].includes(i))&&n[Kt]+e[Kt]<=e.remoteSettings.maxConcurrentStreams&&qm(n)}},Dm=(t,e)=>{for(let r=0;r<t.length;r++){let n=t[r];if(e[Gt].length>0&&e[Gt].length<n[Gt].length&&e[Gt].every(i=>n[Gt].includes(i))&&e[Kt]+n[Kt]<=n.remoteSettings.maxConcurrentStreams)return qm(e),!0}return!1},qm=t=>{t[Cn]=!0,t[Kt]===0&&t.close()},Ni=class t extends xT{constructor({timeout:e=0,maxSessions:r=Number.POSITIVE_INFINITY,maxEmptySessions:n=10,maxCachedTlsSessions:i=100}={}){super(),this.sessions={},this.queue={},this.timeout=e,this.maxSessions=r,this.maxEmptySessions=n,this._emptySessionCount=0,this._sessionCount=0,this.settings={enablePush:!1,initialWindowSize:1024*1024*32},this.tlsSessionCache=new OT({maxSize:i})}get protocol(){return"https:"}normalizeOptions(e){let r="";for(let n=0;n<Um.length;n++){let i=Um[n];r+=":",e&&e[i]!==void 0&&(r+=e[i])}return r}_processQueue(){if(this._sessionCount>=this.maxSessions){this.closeEmptySessions(this.maxSessions-this._sessionCount+1);return}for(let e in this.queue)for(let r in this.queue[e]){let n=this.queue[e][r];n.completed||(n.completed=!0,n())}}_isBetterSession(e,r){return e>r}_accept(e,r,n,i){let s=0;for(;s<r.length&&e[Kt]<e.remoteSettings.maxConcurrentStreams;)r[s].resolve(e),s++;r.splice(0,s),r.length>0&&(this.getSession(n,i,r),r.length=0)}getSession(e,r,n){return new Promise((i,s)=>{Array.isArray(n)&&n.length>0?(n=[...n],i()):n=[{resolve:i,reject:s}];try{if(typeof e=="string")e=new Om(e);else if(!(e instanceof Om))throw new TypeError("The `origin` argument needs to be a string or an URL object");if(r){let{servername:y}=r,{hostname:h}=e;if(y&&h!==y)throw new Error(`Origin ${h} differs from servername ${y}`)}}catch(y){for(let h=0;h<n.length;h++)n[h].reject(y);return}let a=this.normalizeOptions(r),c=e.origin;if(a in this.sessions){let y=this.sessions[a],h=-1,g=-1,R;for(let v=0;v<y.length;v++){let l=y[v],T=l.remoteSettings.maxConcurrentStreams;if(T<h)break;if(!l[Gt].includes(c))continue;let S=l[Kt];S>=T||l[Cn]||l.destroyed||(R||(h=T),this._isBetterSession(S,g)&&(R=l,g=S))}if(R){this._accept(R,n,c,r);return}}if(a in this.queue){if(c in this.queue[a]){this.queue[a][c].listeners.push(...n);return}}else this.queue[a]={[ka]:0};let u=()=>{a in this.queue&&this.queue[a][c]===o&&(delete this.queue[a][c],--this.queue[a][ka]===0&&delete this.queue[a])},o=async()=>{this._sessionCount++;let y=`${c}:${a}`,h=!1,g;try{let R={...r};R.settings===void 0&&(R.settings=this.settings),R.session===void 0&&(R.session=this.tlsSessionCache.get(y)),g=await(R.createConnection||this.createConnection).call(this,e,R),R.createConnection=()=>g;let l=PT.connect(e,R);l[Kt]=0,l[Cn]=!1;let T=()=>{let{socket:d}=l,E;return d.servername===!1?(d.servername=d.remoteAddress,E=l.originSet,d.servername=!1):E=l.originSet,E},S=()=>l[Kt]<l.remoteSettings.maxConcurrentStreams;l.socket.once("session",d=>{this.tlsSessionCache.set(y,d)}),l.once("error",d=>{for(let E=0;E<n.length;E++)n[E].reject(d);this.tlsSessionCache.delete(y)}),l.setTimeout(this.timeout,()=>{l.destroy()}),l.once("close",()=>{if(this._sessionCount--,h){this._emptySessionCount--;let d=this.sessions[a];d.length===1?delete this.sessions[a]:d.splice(d.indexOf(l),1)}else{u();let d=new Error("Session closed without receiving a SETTINGS frame");d.code="HTTP2WRAPPER_NOSETTINGS";for(let E=0;E<n.length;E++)n[E].reject(d)}this._processQueue()});let B=()=>{let d=this.queue[a];if(!d)return;let E=l[Gt];for(let I=0;I<E.length;I++){let k=E[I];if(k in d){let{listeners:U,completed:_}=d[k],m=0;for(;m<U.length&&S();)U[m].resolve(l),m++;if(d[k].listeners.splice(0,m),d[k].listeners.length===0&&!_&&(delete d[k],--d[ka]===0)){delete this.queue[a];break}if(!S())break}}};l.on("origin",()=>{l[Gt]=T()||[],l[Cn]=!1,Dm(this.sessions[a],l),!(l[Cn]||!S())&&(B(),S()&&Rl(this.sessions[a],l))}),l.once("remoteSettings",()=>{if(o.destroyed){let d=new Error("Agent has been destroyed");for(let E=0;E<n.length;E++)n[E].reject(d);l.destroy();return}if(l.setLocalWindowSize&&l.setLocalWindowSize(1024*1024*4),l[Gt]=T()||[],l.socket.encrypted){let d=l[Gt][0];if(d!==c){let E=new Error(`Requested origin ${c} does not match server ${d}`);for(let I=0;I<n.length;I++)n[I].reject(E);l.destroy();return}}u();{let d=this.sessions;if(a in d){let E=d[a];E.splice(UT(E,l,DT),0,l)}else d[a]=[l]}h=!0,this._emptySessionCount++,this.emit("session",l),this._accept(l,n,c,r),l[Kt]===0&&this._emptySessionCount>this.maxEmptySessions&&this.closeEmptySessions(this._emptySessionCount-this.maxEmptySessions),l.on("remoteSettings",()=>{S()&&(B(),S()&&Rl(this.sessions[a],l))})}),l[Lm]=l.request,l.request=(d,E)=>{if(l[Cn])throw new Error("The session is gracefully closing. No new streams are allowed.");let I=l[Lm](d,E);return l.ref(),l[Kt]++===0&&this._emptySessionCount--,I.once("close",()=>{if(--l[Kt]===0&&(this._emptySessionCount++,l.unref(),this._emptySessionCount>this.maxEmptySessions||l[Cn])){l.close();return}l.destroyed||l.closed||S()&&!Dm(this.sessions[a],l)&&(Rl(this.sessions[a],l),B(),l[Kt]===0&&this._processQueue())}),I}}catch(R){u(),this._sessionCount--;for(let v=0;v<n.length;v++)n[v].reject(R)}};o.listeners=n,o.completed=!1,o.destroyed=!1,this.queue[a][c]=o,this.queue[a][ka]++,this._processQueue()})}request(e,r,n,i){return new Promise((s,a)=>{this.getSession(e,r,[{reject:a,resolve:c=>{try{let u=c.request(n,i);LT(u),s(u)}catch(u){a(u)}}}])})}async createConnection(e,r){return t.connect(e,r)}static connect(e,r){r.ALPNProtocols=["h2"];let n=e.port||443,i=e.hostname;typeof r.servername>"u"&&(r.servername=i);let s=NT.connect(n,i,r);return r.socket&&(s._peername={family:void 0,address:void 0,port:n}),s}closeEmptySessions(e=Number.POSITIVE_INFINITY){let r=0,{sessions:n}=this;for(let i in n){let s=n[i];for(let a=0;a<s.length;a++){let c=s[a];if(c[Kt]===0&&(r++,c.close(),r>=e))return r}}return r}destroy(e){let{sessions:r,queue:n}=this;for(let i in r){let s=r[i];for(let a=0;a<s.length;a++)s[a].destroy(e)}for(let i in n){let s=n[i];for(let a in s)s[a].destroyed=!0}this.queue={},this.tlsSessionCache.clear()}get emptySessionCount(){return this._emptySessionCount}get pendingSessionCount(){return this._sessionCount-this._emptySessionCount}get sessionCount(){return this._sessionCount}};Ni.kCurrentStreamCount=Kt;Ni.kGracefullyClosing=Cn;jm.exports={Agent:Ni,globalAgent:new Ni}});var kl=ne((KO,Fm)=>{"use strict";var{Readable:qT}=require("stream"),Bl=class extends qT{constructor(e,r){super({emitClose:!1,autoDestroy:!0,highWaterMark:r}),this.statusCode=null,this.statusMessage="",this.httpVersion="2.0",this.httpVersionMajor=2,this.httpVersionMinor=0,this.headers={},this.trailers={},this.req=null,this.aborted=!1,this.complete=!1,this.upgrade=null,this.rawHeaders=[],this.rawTrailers=[],this.socket=e,this._dumped=!1}get connection(){return this.socket}set connection(e){this.socket=e}_destroy(e,r){this.readableEnded||(this.aborted=!0),r(),this.req._request.destroy(e)}setTimeout(e,r){return this.req.setTimeout(e,r),this}_dump(){this._dumped||(this._dumped=!0,this.removeAllListeners("data"),this.resume())}_read(){this.req&&this.req._request.resume()}};Fm.exports=Bl});var Vm=ne((GO,Mm)=>{"use strict";Mm.exports=(t,e,r)=>{for(let n of r)t.on(n,(...i)=>e.emit(n,...i))}});var Os=ne((QO,Hm)=>{"use strict";var Qn=(t,e,r)=>{Hm.exports[e]=class extends t{constructor(...i){super(typeof r=="string"?r:r(i)),this.name=`${super.name} [${e}]`,this.code=e}}};Qn(TypeError,"ERR_INVALID_ARG_TYPE",t=>{let e=t[0].includes(".")?"property":"argument",r=t[1],n=Array.isArray(r);return n&&(r=`${r.slice(0,-1).join(", ")} or ${r.slice(-1)}`),`The "${t[0]}" ${e} must be ${n?"one of":"of"} type ${r}. Received ${typeof t[2]}`});Qn(TypeError,"ERR_INVALID_PROTOCOL",t=>`Protocol "${t[0]}" not supported. Expected "${t[1]}"`);Qn(Error,"ERR_HTTP_HEADERS_SENT",t=>`Cannot ${t[0]} headers after they are sent to the client`);Qn(TypeError,"ERR_INVALID_HTTP_TOKEN",t=>`${t[0]} must be a valid HTTP token [${t[1]}]`);Qn(TypeError,"ERR_HTTP_INVALID_HEADER_VALUE",t=>`Invalid value "${t[0]} for header "${t[1]}"`);Qn(TypeError,"ERR_INVALID_CHAR",t=>`Invalid character in ${t[0]} [${t[1]}]`);Qn(Error,"ERR_HTTP2_NO_SOCKET_MANIPULATION","HTTP/2 sockets should not be directly manipulated (e.g. read and written)")});var zm=ne((YO,$m)=>{"use strict";$m.exports=t=>{switch(t){case":method":case":scheme":case":authority":case":path":return!0;default:return!1}}});var xl=ne((XO,Km)=>{"use strict";var{ERR_INVALID_HTTP_TOKEN:jT}=Os(),FT=zm(),MT=/^[\^`\-\w!#$%&*+.|~]+$/;Km.exports=t=>{if(typeof t!="string"||!MT.test(t)&&!FT(t))throw new jT("Header name",t)}});var Nl=ne((JO,Gm)=>{"use strict";var{ERR_HTTP_INVALID_HEADER_VALUE:VT,ERR_INVALID_CHAR:HT}=Os(),$T=/[^\t\u0020-\u007E\u0080-\u00FF]/;Gm.exports=(t,e)=>{if(typeof e>"u")throw new VT(e,t);if($T.test(e))throw new HT("header content",t)}});var Ym=ne((ZO,Qm)=>{"use strict";var{ERR_HTTP2_NO_SOCKET_MANIPULATION:Wm}=Os(),zT={has(t,e){let r=t.session===void 0?t:t.session.socket;return e in t||e in r},get(t,e){switch(e){case"on":case"once":case"end":case"emit":case"destroy":return t[e].bind(t);case"writable":case"destroyed":return t[e];case"readable":return t.destroyed?!1:t.readable;case"setTimeout":{let{session:r}=t;return r!==void 0?r.setTimeout.bind(r):t.setTimeout.bind(t)}case"write":case"read":case"pause":case"resume":throw new Wm;default:{let r=t.session===void 0?t:t.session.socket,n=r[e];return typeof n=="function"?n.bind(r):n}}},getPrototypeOf(t){return t.session!==void 0?Reflect.getPrototypeOf(t.session.socket):Reflect.getPrototypeOf(t)},set(t,e,r){switch(e){case"writable":case"readable":case"destroyed":case"on":case"once":case"end":case"emit":case"destroy":return t[e]=r,!0;case"setTimeout":{let{session:n}=t;return n===void 0?t.setTimeout=r:n.setTimeout=r,!0}case"write":case"read":case"pause":case"resume":throw new Wm;default:{let n=t.session===void 0?t:t.session.socket;return n[e]=r,!0}}}};Qm.exports=zT});var Ul=ne((eL,rg)=>{"use strict";var{URL:Pl,urlToHttpOptions:Xm}=require("url"),KT=require("http2"),{Writable:GT}=require("stream"),{Agent:WT,globalAgent:QT}=Wn(),YT=kl(),XT=Vm(),{ERR_INVALID_ARG_TYPE:xa,ERR_INVALID_PROTOCOL:JT,ERR_HTTP_HEADERS_SENT:Jm}=Os(),ZT=xl(),eA=Nl(),tA=Ym(),{HTTP2_HEADER_STATUS:Zm,HTTP2_HEADER_METHOD:eg,HTTP2_HEADER_PATH:tg,HTTP2_HEADER_AUTHORITY:Ls,HTTP2_METHOD_CONNECT:rA}=KT.constants,jt=Symbol("headers"),Pi=Symbol("origin"),Us=Symbol("session"),Ol=Symbol("options"),Na=Symbol("flushedHeaders"),Oi=Symbol("jobs"),Ds=Symbol("pendingAgentPromise"),Ll=class extends GT{constructor(e,r,n){if(super({autoDestroy:!1,emitClose:!1}),typeof e=="string"?e=Xm(new Pl(e)):e instanceof Pl?e=Xm(e):e={...e},typeof r=="function"||r===void 0?(n=r,r=e):r=Object.assign(e,r),r.h2session){if(this[Us]=r.h2session,this[Us].destroyed)throw new Error("The session has been closed already");this.protocol=this[Us].socket.encrypted?"https:":"http:"}else if(r.agent===!1)this.agent=new WT({maxEmptySessions:0});else if(typeof r.agent>"u"||r.agent===null)this.agent=QT;else if(typeof r.agent.request=="function")this.agent=r.agent;else throw new xa("options.agent",["http2wrapper.Agent-like Object","undefined","false"],r.agent);if(this.agent&&(this.protocol=this.agent.protocol),r.protocol&&r.protocol!==this.protocol)throw new JT(r.protocol,this.protocol);r.port||(r.port=r.defaultPort||this.agent&&this.agent.defaultPort||443),r.host=r.hostname||r.host||"localhost",delete r.hostname;let{timeout:i}=r;r.timeout=void 0,this[jt]=Object.create(null),this[Oi]=[],this[Ds]=void 0,this.socket=null,this.connection=null,this.method=r.method||"GET",this.method==="CONNECT"&&(r.path==="/"||r.path===void 0)||(this.path=r.path),this.res=null,this.aborted=!1,this.reusedSocket=!1;let{headers:s}=r;if(s)for(let c in s)this.setHeader(c,s[c]);r.auth&&!("authorization"in this[jt])&&(this[jt].authorization="Basic "+Buffer.from(r.auth).toString("base64")),r.session=r.tlsSession,r.path=r.socketPath,this[Ol]=r,this[Pi]=new Pl(`${this.protocol}//${r.servername||r.host}:${r.port}`);let a=r._reuseSocket;a&&(r.createConnection=(...c)=>a.destroyed?this.agent.createConnection(...c):a,this.agent.getSession(this[Pi],this[Ol]).catch(()=>{})),i&&this.setTimeout(i),n&&this.once("response",n),this[Na]=!1}get method(){return this[jt][eg]}set method(e){e&&(this[jt][eg]=e.toUpperCase())}get path(){let e=this.method==="CONNECT"?Ls:tg;return this[jt][e]}set path(e){if(e){let r=this.method==="CONNECT"?Ls:tg;this[jt][r]=e}}get host(){return this[Pi].hostname}set host(e){}get _mustNotHaveABody(){return this.method==="GET"||this.method==="HEAD"||this.method==="DELETE"}_write(e,r,n){if(this._mustNotHaveABody){n(new Error("The GET, HEAD and DELETE methods must NOT have a body"));return}this.flushHeaders();let i=()=>this._request.write(e,r,n);this._request?i():this[Oi].push(i)}_final(e){this.flushHeaders();let r=()=>{if(this._mustNotHaveABody||this.method==="CONNECT"){e();return}this._request.end(e)};this._request?r():this[Oi].push(r)}abort(){this.res&&this.res.complete||(this.aborted||process.nextTick(()=>this.emit("abort")),this.aborted=!0,this.destroy())}async _destroy(e,r){this.res&&this.res._dump(),this._request?this._request.destroy():process.nextTick(()=>{this.emit("close")});try{await this[Ds]}catch(n){this.aborted&&(e=n)}r(e)}async flushHeaders(){if(this[Na]||this.destroyed)return;this[Na]=!0;let e=this.method===rA,r=n=>{if(this._request=n,this.destroyed){n.destroy();return}e||XT(n,this,["timeout","continue"]),n.once("error",s=>{this.destroy(s)}),n.once("aborted",()=>{let{res:s}=this;s?(s.aborted=!0,s.emit("aborted"),s.destroy()):this.destroy(new Error("The server aborted the HTTP/2 stream"))});let i=(s,a,c)=>{let u=new YT(this.socket,n.readableHighWaterMark);this.res=u,u.url=`${this[Pi].origin}${this.path}`,u.req=this,u.statusCode=s[Zm],u.headers=s,u.rawHeaders=c,u.once("end",()=>{u.complete=!0,u.socket=null,u.connection=null}),e?(u.upgrade=!0,this.emit("connect",u,n,Buffer.alloc(0))?this.emit("close"):n.destroy()):(n.on("data",o=>{!u._dumped&&!u.push(o)&&n.pause()}),n.once("end",()=>{this.aborted||u.push(null)}),this.emit("response",u)||u._dump())};n.once("response",i),n.once("headers",s=>this.emit("information",{statusCode:s[Zm]})),n.once("trailers",(s,a,c)=>{let{res:u}=this;if(u===null){i(s,a,c);return}u.trailers=s,u.rawTrailers=c}),n.once("close",()=>{let{aborted:s,res:a}=this;if(a){s&&(a.aborted=!0,a.emit("aborted"),a.destroy());let c=()=>{a.emit("close"),this.destroy(),this.emit("close")};a.readable?a.once("end",c):c();return}if(!this.destroyed){this.destroy(new Error("The HTTP/2 stream has been early terminated")),this.emit("close");return}this.destroy(),this.emit("close")}),this.socket=new Proxy(n,tA);for(let s of this[Oi])s();this[Oi].length=0,this.emit("socket",this.socket)};if(!(Ls in this[jt])&&!e&&(this[jt][Ls]=this[Pi].host),this[Us])try{r(this[Us].request(this[jt]))}catch(n){this.destroy(n)}else{this.reusedSocket=!0;try{let n=this.agent.request(this[Pi],this[Ol],this[jt]);this[Ds]=n,r(await n),this[Ds]=!1}catch(n){this[Ds]=!1,this.destroy(n)}}}get connection(){return this.socket}set connection(e){this.socket=e}getHeaderNames(){return Object.keys(this[jt])}hasHeader(e){if(typeof e!="string")throw new xa("name","string",e);return!!this[jt][e.toLowerCase()]}getHeader(e){if(typeof e!="string")throw new xa("name","string",e);return this[jt][e.toLowerCase()]}get headersSent(){return this[Na]}removeHeader(e){if(typeof e!="string")throw new xa("name","string",e);if(this.headersSent)throw new Jm("remove");delete this[jt][e.toLowerCase()]}setHeader(e,r){if(this.headersSent)throw new Jm("set");ZT(e),eA(e,r);let n=e.toLowerCase();if(n==="connection"){if(r.toLowerCase()==="keep-alive")return;throw new Error(`Invalid 'connection' header: ${r}`)}n==="host"&&this.method==="CONNECT"?this[jt][Ls]=r:this[jt][n]=r}setNoDelay(){}setSocketKeepAlive(){}setTimeout(e,r){let n=()=>this._request.setTimeout(e,r);return this._request?n():this[Oi].push(n),this}get maxHeadersCount(){if(!this.destroyed&&this._request)return this._request.session.localSettings.maxHeaderListSize}set maxHeadersCount(e){}};rg.exports=Ll});var Dl=ne((tL,ng)=>{"use strict";var nA=require("tls");ng.exports=(t={},e=nA.connect)=>new Promise((r,n)=>{let i=!1,s,a=async()=>{await u,s.off("timeout",c),s.off("error",n),t.resolveSocket?(r({alpnProtocol:s.alpnProtocol,socket:s,timeout:i}),i&&(await Promise.resolve(),s.emit("timeout"))):(s.destroy(),r({alpnProtocol:s.alpnProtocol,timeout:i}))},c=async()=>{i=!0,a()},u=(async()=>{try{s=await e(t,a),s.on("error",n),s.once("timeout",c)}catch(o){n(o)}})()})});var sg=ne((rL,ig)=>{"use strict";var{isIP:iA}=require("net"),sA=require("assert"),oA=t=>{if(t[0]==="["){let r=t.indexOf("]");return sA(r!==-1),t.slice(1,r)}let e=t.indexOf(":");return e===-1?t:t.slice(0,e)};ig.exports=t=>{let e=oA(t);return iA(e)?"":e}});var dg=ne((nL,qs)=>{"use strict";var{URL:og,urlToHttpOptions:ag}=require("url"),cg=require("http"),ql=require("https"),aA=Dl(),cA=Ps(),{Agent:uA,globalAgent:lA}=Wn(),fA=Ul(),hA=sg(),ug=Il(),lg=new cA({maxSize:100}),dA=new Map,pA=(t,e,r)=>{e._httpMessage={shouldKeepAlive:!0};let n=()=>{t.emit("free",e,r)};e.on("free",n);let i=()=>{t.removeSocket(e,r)};e.on("close",i);let s=()=>{let{freeSockets:c}=t;for(let u of Object.values(c))if(u.includes(e)){e.destroy();return}};e.on("timeout",s);let a=()=>{t.removeSocket(e,r),e.off("close",i),e.off("free",n),e.off("timeout",s),e.off("agentRemove",a)};e.on("agentRemove",a),t.emit("free",e,r)},fg=(t,e=new Map,r=void 0)=>async n=>{let i=`${n.host}:${n.port}:${n.ALPNProtocols.sort()}`;if(!t.has(i)){if(e.has(i))return{alpnProtocol:(await e.get(i)).alpnProtocol};let{path:s}=n;n.path=n.socketPath;let a=aA(n,r);e.set(i,a);try{let c=await a;return t.set(i,c.alpnProtocol),e.delete(i),n.path=s,c}catch(c){throw e.delete(i),n.path=s,c}}return{alpnProtocol:t.get(i)}},hg=fg(lg,dA);qs.exports=async(t,e,r)=>{if(typeof t=="string"?t=ag(new og(t)):t instanceof og?t=ag(t):t={...t},typeof e=="function"||e===void 0?(r=e,e=t):e=Object.assign(t,e),e.ALPNProtocols=e.ALPNProtocols||["h2","http/1.1"],!Array.isArray(e.ALPNProtocols)||e.ALPNProtocols.length===0)throw new Error("The `ALPNProtocols` option must be an Array with at least one entry");e.protocol=e.protocol||"https:";let n=e.protocol==="https:";e.host=e.hostname||e.host||"localhost",e.session=e.tlsSession,e.servername=e.servername||hA(e.headers&&e.headers.host||e.host),e.port=e.port||(n?443:80),e._defaultAgent=n?ql.globalAgent:cg.globalAgent;let i=e.resolveProtocol||hg,{agent:s}=e;if(s!==void 0&&s!==!1&&s.constructor.name!=="Object")throw new Error("The `options.agent` can be only an object `http`, `https` or `http2` properties");if(n){e.resolveSocket=!0;let{socket:a,alpnProtocol:c,timeout:u}=await i(e);if(u){a&&a.destroy();let y=new Error(`Timed out resolving ALPN: ${e.timeout} ms`);throw y.code="ETIMEDOUT",y.ms=e.timeout,y}a&&e.createConnection&&(a.destroy(),a=void 0),delete e.resolveSocket;let o=c==="h2";if(s&&(s=o?s.http2:s.https,e.agent=s),s===void 0&&(s=o?lA:ql.globalAgent),a)if(s===!1)a.destroy();else{let y=(o?uA:ql.Agent).prototype.createConnection;s.createConnection===y?o?e._reuseSocket=a:pA(s,a,e):a.destroy()}if(o)return ug(new fA(e,r))}else s&&(e.agent=s.http);return e.headers&&(e.headers={...e.headers},e.headers[":authority"]&&(e.headers.host||(e.headers.host=e.headers[":authority"]),delete e.headers[":authority"]),delete e.headers[":method"],delete e.headers[":scheme"],delete e.headers[":path"]),ug(cg.request(e,r))};qs.exports.protocolCache=lg;qs.exports.resolveProtocol=hg;qs.exports.createResolveProtocol=fg});var jl=ne((iL,pg)=>{"use strict";var yA=require("stream"),mA=require("tls"),gA=new mA.TLSSocket(new yA.PassThrough)._handle._parentWrap.constructor;pg.exports=gA});var Ml=ne((sL,yg)=>{"use strict";var Fl=class extends Error{constructor(e,r=""){super(`The proxy server rejected the request with status code ${e} (${r||"empty status message"})`),this.statusCode=e,this.statusMessage=r}};yg.exports=Fl});var gg=ne((oL,mg)=>{"use strict";var bA=(t,e,r)=>{if(!r.some(i=>typeof i==="string"?typeof e===i:e instanceof i)){let i=r.map(s=>typeof s=="string"?s:s.name);throw new TypeError(`Expected '${t}' to be a type of ${i.join(" or ")}, got ${typeof e}`)}};mg.exports=bA});var Vl=ne((aL,vg)=>{"use strict";var{URL:bg}=require("url"),Pa=gg();vg.exports=(t,e)=>{Pa("proxyOptions",e,["object"]),Pa("proxyOptions.headers",e.headers,["object","undefined"]),Pa("proxyOptions.raw",e.raw,["boolean","undefined"]),Pa("proxyOptions.url",e.url,[bg,"string"]);let r=new bg(e.url);t.proxyOptions={raw:!0,...e,headers:{...e.headers},url:r}}});var Oa=ne((cL,Eg)=>{"use strict";Eg.exports=t=>{let{username:e,password:r}=t.proxyOptions.url;if(e||r){let n=`${e}:${r}`,i=`Basic ${Buffer.from(n).toString("base64")}`;return{"proxy-authorization":i,authorization:i}}return{}}});var Tg=ne((uL,_g)=>{"use strict";var vA=require("tls"),EA=require("http"),wg=require("https"),wA=jl(),{globalAgent:SA}=Wn(),CA=Ml(),Sg=Vl(),_A=Oa(),Cg=(t,e,r)=>{(async()=>{try{let{proxyOptions:n}=t,{url:i,headers:s,raw:a}=n,c=await SA.request(i,n,{..._A(t),...s,":method":"CONNECT",":authority":`${e.host}:${e.port}`});c.once("error",r),c.once("response",u=>{let o=u[":status"];if(o!==200){r(new CA(o,""));return}let y=t instanceof wg.Agent;if(a&&y){e.socket=c;let g=vA.connect(e);g.once("close",()=>{c.destroy()}),r(null,g);return}let h=new wA(c);h.encrypted=!1,h._handle.getpeername=g=>{g.family=void 0,g.address=void 0,g.port=void 0},r(null,h)})}catch(n){r(n)}})()},Hl=class extends EA.Agent{constructor(e){super(e),Sg(this,e.proxyOptions)}createConnection(e,r){Cg(this,e,r)}},$l=class extends wg.Agent{constructor(e){super(e),Sg(this,e.proxyOptions)}createConnection(e,r){Cg(this,e,r)}};_g.exports={HttpOverHttp2:Hl,HttpsOverHttp2:$l}});var Kl=ne((lL,Ag)=>{"use strict";var{Agent:TA}=Wn(),AA=jl(),IA=Ml(),RA=Vl(),zl=class extends TA{constructor(e){super(e),RA(this,e.proxyOptions)}async createConnection(e,r){let n=`${e.hostname}:${e.port||443}`,[i,s,a]=await this._getProxyStream(n);if(s!==200)throw new IA(s,a);if(this.proxyOptions.raw)r.socket=i;else{let c=new AA(i);return c.encrypted=!1,c._handle.getpeername=u=>{u.family=void 0,u.address=void 0,u.port=void 0},c}return super.createConnection(e,r)}};Ag.exports=zl});var Rg=ne((fL,Ig)=>{"use strict";var{globalAgent:BA}=Wn(),kA=Kl(),xA=Oa(),NA=t=>new Promise((e,r)=>{t.once("error",r),t.once("response",n=>{t.off("error",r),e(n[":status"])})}),Gl=class extends kA{async _getProxyStream(e){let{proxyOptions:r}=this,n={...xA(this),...r.headers,":method":"CONNECT",":authority":e},i=await BA.request(r.url,r,n),s=await NA(i);return[i,s,""]}};Ig.exports=Gl});var kg=ne((hL,Bg)=>{"use strict";var PA=require("http"),OA=require("https"),LA=Kl(),UA=Oa(),DA=t=>new Promise((e,r)=>{let n=(i,s,a)=>{s.unshift(a),t.off("error",r),e([s,i.statusCode,i.statusMessage])};t.once("error",r),t.once("connect",n)}),La=class extends LA{async _getProxyStream(e){let{proxyOptions:r}=this,{url:n,headers:i}=this.proxyOptions,a=(n.protocol==="https:"?OA:PA).request({...r,hostname:n.hostname,port:n.port,path:e,headers:{...UA(this),...i,host:e},method:"CONNECT"}).end();return DA(a)}};Bg.exports={Http2OverHttp:La,Http2OverHttps:La}});var Ng=ne((dL,xg)=>{"use strict";var qA=require("http2"),{Agent:jA,globalAgent:FA}=Wn(),Wl=Ul(),MA=kl(),VA=dg(),{HttpOverHttp2:HA,HttpsOverHttp2:$A}=Tg(),zA=Rg(),{Http2OverHttp:KA,Http2OverHttps:GA}=kg(),WA=xl(),QA=Nl(),YA=(t,e,r)=>new Wl(t,e,r),XA=(t,e,r)=>{let n=new Wl(t,e,r);return n.end(),n};xg.exports={...qA,ClientRequest:Wl,IncomingMessage:MA,Agent:jA,globalAgent:FA,request:YA,get:XA,auto:VA,proxies:{HttpOverHttp2:HA,HttpsOverHttp2:$A,Http2OverHttp2:zA,Http2OverHttp:KA,Http2OverHttps:GA},validateHeaderName:WA,validateHeaderValue:QA}});var Mi=ne((Tf,v0)=>{var ec=require("buffer"),Kr=ec.Buffer;function b0(t,e){for(var r in t)e[r]=t[r]}Kr.from&&Kr.alloc&&Kr.allocUnsafe&&Kr.allocUnsafeSlow?v0.exports=ec:(b0(ec,Tf),Tf.Buffer=ri);function ri(t,e,r){return Kr(t,e,r)}ri.prototype=Object.create(Kr.prototype);b0(Kr,ri);ri.from=function(t,e,r){if(typeof t=="number")throw new TypeError("Argument must not be a number");return Kr(t,e,r)};ri.alloc=function(t,e,r){if(typeof t!="number")throw new TypeError("Argument must be a number");var n=Kr(t);return e!==void 0?typeof r=="string"?n.fill(e,r):n.fill(e):n.fill(0),n};ri.allocUnsafe=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return Kr(t)};ri.allocUnsafeSlow=function(t){if(typeof t!="number")throw new TypeError("Argument must be a number");return ec.SlowBuffer(t)}});var Af=ne((YU,E0)=>{var tc=Mi().Buffer,l3=require("stream"),f3=require("util");function rc(t){if(this.buffer=null,this.writable=!0,this.readable=!0,!t)return this.buffer=tc.alloc(0),this;if(typeof t.pipe=="function")return this.buffer=tc.alloc(0),t.pipe(this),this;if(t.length||typeof t=="object")return this.buffer=t,this.writable=!1,process.nextTick(function(){this.emit("end",t),this.readable=!1,this.emit("close")}.bind(this)),this;throw new TypeError("Unexpected data type ("+typeof t+")")}f3.inherits(rc,l3);rc.prototype.write=function(e){this.buffer=tc.concat([this.buffer,tc.from(e)]),this.emit("data",e)};rc.prototype.end=function(e){e&&this.write(e),this.emit("end",e),this.emit("close"),this.writable=!1,this.readable=!1};E0.exports=rc});var S0=ne((XU,w0)=>{"use strict";var Ws=require("buffer").Buffer,If=require("buffer").SlowBuffer;w0.exports=nc;function nc(t,e){if(!Ws.isBuffer(t)||!Ws.isBuffer(e)||t.length!==e.length)return!1;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return r===0}nc.install=function(){Ws.prototype.equal=If.prototype.equal=function(e){return nc(this,e)}};var h3=Ws.prototype.equal,d3=If.prototype.equal;nc.restore=function(){Ws.prototype.equal=h3,If.prototype.equal=d3}});var _0=ne((JU,C0)=>{"use strict";function Rf(t){var e=(t/8|0)+(t%8===0?0:1);return e}var p3={ES256:Rf(256),ES384:Rf(384),ES512:Rf(521)};function y3(t){var e=p3[t];if(e)return e;throw new Error('Unknown algorithm "'+t+'"')}C0.exports=y3});var x0=ne((ZU,k0)=>{"use strict";var ic=Mi().Buffer,A0=_0(),sc=128,I0=0,m3=32,g3=16,b3=2,R0=g3|m3|I0<<6,oc=b3|I0<<6;function v3(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function B0(t){if(ic.isBuffer(t))return t;if(typeof t=="string")return ic.from(t,"base64");throw new TypeError("ECDSA signature must be a Base64 string or a Buffer")}function E3(t,e){t=B0(t);var r=A0(e),n=r+1,i=t.length,s=0;if(t[s++]!==R0)throw new Error('Could not find expected "seq"');var a=t[s++];if(a===(sc|1)&&(a=t[s++]),i-s<a)throw new Error('"seq" specified length of "'+a+'", only "'+(i-s)+'" remaining');if(t[s++]!==oc)throw new Error('Could not find expected "int" for "r"');var c=t[s++];if(i-s-2<c)throw new Error('"r" specified length of "'+c+'", only "'+(i-s-2)+'" available');if(n<c)throw new Error('"r" specified length of "'+c+'", max of "'+n+'" is acceptable');var u=s;if(s+=c,t[s++]!==oc)throw new Error('Could not find expected "int" for "s"');var o=t[s++];if(i-s!==o)throw new Error('"s" specified length of "'+o+'", expected "'+(i-s)+'"');if(n<o)throw new Error('"s" specified length of "'+o+'", max of "'+n+'" is acceptable');var y=s;if(s+=o,s!==i)throw new Error('Expected to consume entire buffer, but "'+(i-s)+'" bytes remain');var h=r-c,g=r-o,R=ic.allocUnsafe(h+c+g+o);for(s=0;s<h;++s)R[s]=0;t.copy(R,s,u+Math.max(-h,0),u+c),s=r;for(var v=s;s<v+g;++s)R[s]=0;return t.copy(R,s,y+Math.max(-g,0),y+o),R=R.toString("base64"),R=v3(R),R}function T0(t,e,r){for(var n=0;e+n<r&&t[e+n]===0;)++n;var i=t[e+n]>=sc;return i&&--n,n}function w3(t,e){t=B0(t);var r=A0(e),n=t.length;if(n!==r*2)throw new TypeError('"'+e+'" signatures must be "'+r*2+'" bytes, saw "'+n+'"');var i=T0(t,0,r),s=T0(t,r,t.length),a=r-i,c=r-s,u=2+a+1+1+c,o=u<sc,y=ic.allocUnsafe((o?2:3)+u),h=0;return y[h++]=R0,o?y[h++]=u:(y[h++]=sc|1,y[h++]=u&255),y[h++]=oc,y[h++]=a,i<0?(y[h++]=0,h+=t.copy(y,h,0,r)):h+=t.copy(y,h,i,r),y[h++]=oc,y[h++]=c,s<0?(y[h++]=0,t.copy(y,h,r)):t.copy(y,h,r+s),y}k0.exports={derToJose:E3,joseToDer:w3}});var xf=ne((e7,F0)=>{var S3=S0(),Hi=Mi().Buffer,Gr=require("crypto"),P0=x0(),N0=require("util"),C3=`"%s" is not a valid algorithm.
Supported algorithms are:
"HS256", "HS384", "HS512", "RS256", "RS384", "RS512", "PS256", "PS384", "PS512", "ES256", "ES384", "ES512" and "none".`,Qs="secret must be a string or buffer",Vi="key must be a string or a buffer",_3="key must be a string, a buffer or an object",Bf=typeof Gr.createPublicKey=="function";Bf&&(Vi+=" or a KeyObject",Qs+="or a KeyObject");function O0(t){if(!Hi.isBuffer(t)&&typeof t!="string"&&(!Bf||typeof t!="object"||typeof t.type!="string"||typeof t.asymmetricKeyType!="string"||typeof t.export!="function"))throw xr(Vi)}function L0(t){if(!Hi.isBuffer(t)&&typeof t!="string"&&typeof t!="object")throw xr(_3)}function T3(t){if(!Hi.isBuffer(t)){if(typeof t=="string")return t;if(!Bf||typeof t!="object"||t.type!=="secret"||typeof t.export!="function")throw xr(Qs)}}function kf(t){return t.replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function U0(t){t=t.toString();var e=4-t.length%4;if(e!==4)for(var r=0;r<e;++r)t+="=";return t.replace(/\-/g,"+").replace(/_/g,"/")}function xr(t){var e=[].slice.call(arguments,1),r=N0.format.bind(N0,t).apply(null,e);return new TypeError(r)}function A3(t){return Hi.isBuffer(t)||typeof t=="string"}function Ys(t){return A3(t)||(t=JSON.stringify(t)),t}function D0(t){return function(r,n){T3(n),r=Ys(r);var i=Gr.createHmac("sha"+t,n),s=(i.update(r),i.digest("base64"));return kf(s)}}function I3(t){return function(r,n,i){var s=D0(t)(r,i);return S3(Hi.from(n),Hi.from(s))}}function q0(t){return function(r,n){L0(n),r=Ys(r);var i=Gr.createSign("RSA-SHA"+t),s=(i.update(r),i.sign(n,"base64"));return kf(s)}}function j0(t){return function(r,n,i){O0(i),r=Ys(r),n=U0(n);var s=Gr.createVerify("RSA-SHA"+t);return s.update(r),s.verify(i,n,"base64")}}function R3(t){return function(r,n){L0(n),r=Ys(r);var i=Gr.createSign("RSA-SHA"+t),s=(i.update(r),i.sign({key:n,padding:Gr.constants.RSA_PKCS1_PSS_PADDING,saltLength:Gr.constants.RSA_PSS_SALTLEN_DIGEST},"base64"));return kf(s)}}function B3(t){return function(r,n,i){O0(i),r=Ys(r),n=U0(n);var s=Gr.createVerify("RSA-SHA"+t);return s.update(r),s.verify({key:i,padding:Gr.constants.RSA_PKCS1_PSS_PADDING,saltLength:Gr.constants.RSA_PSS_SALTLEN_DIGEST},n,"base64")}}function k3(t){var e=q0(t);return function(){var n=e.apply(null,arguments);return n=P0.derToJose(n,"ES"+t),n}}function x3(t){var e=j0(t);return function(n,i,s){i=P0.joseToDer(i,"ES"+t).toString("base64");var a=e(n,i,s);return a}}function N3(){return function(){return""}}function P3(){return function(e,r){return r===""}}F0.exports=function(e){var r={hs:D0,rs:q0,ps:R3,es:k3,none:N3},n={hs:I3,rs:j0,ps:B3,es:x3,none:P3},i=e.match(/^(RS|PS|ES|HS)(256|384|512)$|^(none)$/i);if(!i)throw xr(C3,e);var s=(i[1]||i[3]).toLowerCase(),a=i[2];return{sign:r[s](a),verify:n[s](a)}}});var Nf=ne((t7,M0)=>{var O3=require("buffer").Buffer;M0.exports=function(e){return typeof e=="string"?e:typeof e=="number"||O3.isBuffer(e)?e.toString():JSON.stringify(e)}});var G0=ne((r7,K0)=>{var L3=Mi().Buffer,V0=Af(),U3=xf(),D3=require("stream"),H0=Nf(),Pf=require("util");function $0(t,e){return L3.from(t,e).toString("base64").replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_")}function q3(t,e,r){r=r||"utf8";var n=$0(H0(t),"binary"),i=$0(H0(e),r);return Pf.format("%s.%s",n,i)}function z0(t){var e=t.header,r=t.payload,n=t.secret||t.privateKey,i=t.encoding,s=U3(e.alg),a=q3(e,r,i),c=s.sign(a,n);return Pf.format("%s.%s",a,c)}function ac(t){var e=t.secret||t.privateKey||t.key,r=new V0(e);this.readable=!0,this.header=t.header,this.encoding=t.encoding,this.secret=this.privateKey=this.key=r,this.payload=new V0(t.payload),this.secret.once(