UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

3 lines 118 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var vs=Object.create;var Me=Object.defineProperty;var ms=Object.getOwnPropertyDescriptor;var ys=Object.getOwnPropertyNames;var Ss=Object.getPrototypeOf,Es=Object.prototype.hasOwnProperty;var s=(e,t)=>Me(e,"name",{value:t,configurable:!0});var m=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ws=(e,t)=>{for(var r in t)Me(e,r,{get:t[r],enumerable:!0})},Vr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of ys(t))!Es.call(e,i)&&i!==r&&Me(e,i,{get:()=>t[i],enumerable:!(n=ms(t,i))||n.enumerable});return e};var Vt=(e,t,r)=>(r=e!=null?vs(Ss(e)):{},Vr(t||!e||!e.__esModule?Me(r,"default",{value:e,enumerable:!0}):r,e)),bs=e=>Vr(Me({},"__esModule",{value:!0}),e);var Z=m(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.getExtLoginPath=N.runCommand=N.getEnvValue=N.validDevPlatform=N.isAppStudio=void 0;var Ts=require("../../commonlibs/cross-spawn/index.js");function zr(){let e=process.env.WS_BASE_URL;return e===void 0?!1:e!==""}s(zr,"isAppStudio");N.isAppStudio=zr;function xs(e){if(!zr())throw new Error(`The '${e}' API is supported only in Buisness Application Studio environment.`)}s(xs,"validDevPlatform");N.validDevPlatform=xs;function Os(e){let t=process.env[e];if(t===void 0)throw new Error(`The ${e} environment variable is missing.`);return t}s(Os,"getEnvValue");N.getEnvValue=Os;async function Cs(e,t){return new Promise((r,n)=>{let i=(0,Ts.spawn)(e,t);As(e,i,r,n)})}s(Cs,"runCommand");N.runCommand=Cs;function As(e,t,r,n){let i=[],a=!1;t.stdout.on("data",o=>{i.push(String(o))}),t.stderr.on("data",o=>{i.push(String(o))}),t.on("error",o=>{a||(a=!0,n(o))}),t.on("exit",(o,c)=>{if(a)return;a=!0;let d=i.join("").trim(),u=d.substring(d.lastIndexOf(` `)+1);if(u.startsWith("{")||(u=d),o===0)r(u);else if(c!==null){let h=new Error(`Could not execute ${e}`);h.code=c,n(h)}else{try{u=JSON.parse(u).message||u}catch{}n(new Error(u))}})}s(As,"procEvents");function Ps(e,t){let r=new URL(e);return r.protocol="https",r.pathname=`${t?"remote":"ext"}-login.html`,r.search=`cb=${Math.floor(Math.random()*1e5)}`,r.toString()}s(Ps,"getExtLoginPath");N.getExtLoginPath=Ps});var zt=m(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.isAppStudio=void 0;var Ds=Z();async function Ls(){return(0,Ds.isAppStudio)()}s(Ls,"isAppStudio");it.isAppStudio=Ls});var at=m(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.addJwtHeader=void 0;var Kr=Z(),Rs="H2O_JWT";function Is(e){return(0,Kr.isAppStudio)()||(e["x-approuter-authorization"]=`Bearer ${(0,Kr.getEnvValue)(Rs)}`),e}s(Is,"addJwtHeader");st.addJwtHeader=Is});var ct=m((Jr,ot)=>{(function(e,t,r){typeof ot<"u"&&ot.exports?ot.exports=r():typeof define=="function"&&define.amd?define(r):t[e]=r()})("urljoin",Jr,function(){function e(t){var r=[];if(t.length===0)return"";if(typeof t[0]!="string")throw new TypeError("Url must be a string. Received "+t[0]);if(t[0].match(/^[^/:]+:\/*$/)&&t.length>1){var n=t.shift();t[0]=n+t[0]}t[0].match(/^file:\/\/\//)?t[0]=t[0].replace(/^([^/:]+):\/*/,"$1:///"):t[0]=t[0].replace(/^([^/:]+):\/*/,"$1://");for(var i=0;i<t.length;i++){var a=t[i];if(typeof a!="string")throw new TypeError("Url must be a string. Received "+a);a!==""&&(i>0&&(a=a.replace(/^[\/]+/,"")),i<t.length-1?a=a.replace(/[\/]+$/,""):a=a.replace(/[\/]+$/,"/"),r.push(a))}var o=r.join("/");o=o.replace(/\/(\?|&|#[^!])/g,"$1");var c=o.split("?");return o=c.shift()+(c.length>0?"?":"")+c.join("&"),o}return s(e,"normalize"),function(){var t;return typeof arguments[0]=="object"?t=arguments[0]:t=[].slice.call(arguments),e(t)}})});var $e=m(x=>{"use strict";Object.defineProperty(x,"__esModule",{value:!0});x.getDestinationHeaders=x.responseDestinationToDestinationListInfo=x.flatDestinationToDestinationBaseInfo=x.destinationInfoToAnswerDestination=x.strToBoolean=x.strToProxyType=x.strToAuthenticationType=x.strToTokenServiceUrlType=x.strToDestinationType=x.authenticationTypeToProperties=x.AuthenticationType=x.ENV_H2O_URL=void 0;var Us=at();x.ENV_H2O_URL="H2O_URL";x.AuthenticationType={NoAuthentication:"NoAuthentication",BasicAuthentication:"BasicAuthentication",OAuth2ClientCredentials:"OAuth2ClientCredentials",OAuth2UserTokenExchange:"OAuth2UserTokenExchange"};x.authenticationTypeToProperties={[x.AuthenticationType.OAuth2UserTokenExchange]:e=>e.oauth2UserTokenExchange,[x.AuthenticationType.OAuth2ClientCredentials]:e=>e.oauth2ClientCredentials,[x.AuthenticationType.NoAuthentication]:()=>{},[x.AuthenticationType.BasicAuthentication]:()=>{}};function Xr(e){let r=["HTTP"].find(n=>n===e);if(!r)throw new Error(`unknown ${e} destination type`);return r}s(Xr,"strToDestinationType");x.strToDestinationType=Xr;function Ns(e){let r=["Dedicated","Common"].find(n=>n===e);if(!r)throw new Error(`unknown ${e} token service url type`);return r}s(Ns,"strToTokenServiceUrlType");x.strToTokenServiceUrlType=Ns;function Qr(e){let r=["NoAuthentication","BasicAuthentication","OAuth2ClientCredentials","OAuth2UserTokenExchange"].find(n=>n===e);if(!r)throw new Error(`unknown ${e} authentication type`);return r}s(Qr,"strToAuthenticationType");x.strToAuthenticationType=Qr;function Zr(e){let r=["Internet","OnPremise"].find(n=>n===e);if(!r)throw new Error(`unknown ${e} proxy type`);return r}s(Zr,"strToProxyType");x.strToProxyType=Zr;function ks(e){return e?e.toLocaleLowerCase()==="true":!1}s(ks,"strToBoolean");x.strToBoolean=ks;function Bs(e){return{authentication:Qr(e.Authentication)}}s(Bs,"toCredentials");var lt="sap-client",Kt="product.name",Jt="URL.headers.ApiKey",Yt="applicationID",Yr="HTML5.DynamicDestination",Xt="HTML5.Timeout",Qt="com.sap.catalog.propagate.credential",Zt="x-system-type",er="x-correlation-id",tr="x-system-id";function Fs(e){let t={};return e.WebIDEAdditionalData&&(t.additionalData=e.WebIDEAdditionalData),e.WebIDEUsage&&(t.usage=e.WebIDEUsage),e[Yr]&&(t.html5DynamicDestination=e[Yr]),e[Xt]&&(t.html5Timeout=e[Xt]),e[lt]&&(t.sapClient=e[lt]),e[Kt]&&(t.productName=e[Kt]),e[Jt]&&(t.apiKey=e[Jt]),e[Yt]&&(t.applicationID=e[Yt]),e.apiBusinessHubEnterpriseURL&&(t.apiBusinessHubEnterpriseURL=e.apiBusinessHubEnterpriseURL),e[Qt]&&(t.comSapCatalogPropagateCredential=e[Qt]),e[Zt]&&(t.xSystemType=e[Zt]),e[er]&&(t.xCorrelationId=e[er]),e[tr]&&(t.xSystemId=e[tr]),Object.keys(t).length===0?void 0:t}s(Fs,"extractBASProperties");function Gs(e){var t,r,n,i,a,o,c,d,u,h,g,T,O;let v={Name:e.name,Type:"HTTP",Authentication:e.credentials.authentication,ProxyType:e.proxyType,URL:e.url.toString(),WebIDEEnabled:"true"};if(e.credentials.authentication==="BasicAuthentication"){if(!e.credentials.basicAuthentication)throw new Error("Missing user and password for Basic Authentication");v.User=e.credentials.basicAuthentication.userName,v.Password=e.credentials.basicAuthentication.userPassword}if(["OAuth2ClientCredentials","OAuth2UserTokenExchange"].includes(e.credentials.authentication)){let E=js(e.credentials);v.tokenServiceURL=E.tokenServiceURL,v.tokenServiceURLType=E.tokenServiceURLType,v.clientId=E.clientId,v.clientSecret=E.clientSecret,v.tokenServiceUser=E.tokenServiceUser,v.tokenServicePassword=E.tokenServicePassword}if(e.description&&(v.Description=e.description),!((t=e.basProperties)===null||t===void 0)&&t.additionalData&&(v.WebIDEAdditionalData=e.basProperties.additionalData),!((r=e.basProperties)===null||r===void 0)&&r.usage&&(v.WebIDEUsage=String(e.basProperties.usage)),!((n=e.basProperties)===null||n===void 0)&&n.sapClient){if(e.basProperties.sapClient.length!=3)throw new Error(`${lt} "${e.basProperties.sapClient}" property length must equal 3.`);v[lt]=e.basProperties.sapClient}return!((i=e.basProperties)===null||i===void 0)&&i.productName&&(v[Kt]=e.basProperties.productName),!((a=e.basProperties)===null||a===void 0)&&a.apiKey&&(v[Jt]=e.basProperties.apiKey),!((o=e.basProperties)===null||o===void 0)&&o.applicationID&&(v[Yt]=e.basProperties.applicationID),!((c=e.basProperties)===null||c===void 0)&&c.apiBusinessHubEnterpriseURL&&(v.apiBusinessHubEnterpriseURL=e.basProperties.apiBusinessHubEnterpriseURL),((d=e.basProperties)===null||d===void 0?void 0:d.html5DynamicDestination)!==void 0?v["HTML5.DynamicDestination"]=e.basProperties.html5DynamicDestination:v["HTML5.DynamicDestination"]="true",!((u=e.basProperties)===null||u===void 0)&&u.html5Timeout&&(v[Xt]=e.basProperties.html5Timeout),!((h=e.basProperties)===null||h===void 0)&&h.comSapCatalogPropagateCredential&&(v[Qt]=e.basProperties.comSapCatalogPropagateCredential),!((g=e.basProperties)===null||g===void 0)&&g.xSystemType&&(v[Zt]=e.basProperties.xSystemType),!((T=e.basProperties)===null||T===void 0)&&T.xSystemId&&(v[tr]=e.basProperties.xSystemId),!((O=e.basProperties)===null||O===void 0)&&O.xCorrelationId&&(v[er]=e.basProperties.xCorrelationId),v}s(Gs,"destinationInfoToAnswerDestination");x.destinationInfoToAnswerDestination=Gs;function en(e){let t={name:e.Name,type:Xr(e.Type),credentials:Bs(e),proxyType:Zr(e.ProxyType)};e.Description&&(t.description=e.Description);let r=Fs(e);return r&&(t.basProperties=r),t}s(en,"flatDestinationToDestinationBaseInfo");x.flatDestinationToDestinationBaseInfo=en;function Ms(e){let t=en(e);return Object.assign(Object.assign({},t),{host:e.Host})}s(Ms,"responseDestinationToDestinationListInfo");x.responseDestinationToDestinationListInfo=Ms;function $s(){let e={"Content-Type":"application/json","User-Agent":"Bas"};return(0,Us.addJwtHeader)(e)}s($s,"getDestinationHeaders");x.getDestinationHeaders=$s;function js(e){let t=x.authenticationTypeToProperties[e.authentication](e);if(!t)throw new Error(`Missing credentials for ${e.authentication}`);return t}s(js,"getOAuthProperties")});var nr=m(Ee=>{"use strict";var tn=Ee&&Ee.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Ee,"__esModule",{value:!0});Ee.getDestinations=void 0;var qs=tn(ct()),Ws=tn(require("../../commonlibs/axios/index.js")),Hs=Z(),rr=$e();function Vs(e){if(e==="HTTP")return"HTTP"}s(Vs,"getDestinationType");function zs(e){switch(e){case"NoAuthentication":return"NoAuthentication";case"BasicAuthentication":return"BasicAuthentication";case"OAuth2ClientCredentials":return"OAuth2ClientCredentials";case"OAuth2UserTokenExchange":return"OAuth2UserTokenExchange";default:return}}s(zs,"getAuthenticationType");function Ks(e,t){let r=!0;if(!t)return r;for(let[n,i]of t){r=!1;let a=e[n];if(!a)return r;for(let o=0;o<i.length;++o)if(a===i[o]){r=!0;break}if(!r)return r}return r}s(Ks,"matchFilter");function Js(e,t){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Vs(e.Type)!==void 0&&zs(e.Authentication)!==void 0&&Ks(e,t)}s(Js,"isAllowtoAddDestination");function Ys(e,t){let r=[];return e.forEach(n=>{Js(n,t)&&r.push((0,rr.responseDestinationToDestinationListInfo)(n))}),r}s(Ys,"transformToDestinations");async function Xs(e){let t=(0,qs.default)((0,Hs.getEnvValue)(rr.ENV_H2O_URL),"/api/listDestinations"),r;try{let n={url:t,headers:(0,rr.getDestinationHeaders)()};r=await Ws.default.request(n)}catch(n){throw new Error(`Couldn't retrieve the destination from the (${t}) URL because of the following error: ${n.message}. Error code=${n.response.status}`)}if(!Array.isArray(r.data))throw new Error(`The response data (${r.data}) is not an array format`);return Ys(r.data,e)}s(Xs,"getDestinations");Ee.getDestinations=Xs});var sn=m(we=>{"use strict";var nn=we&&we.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(we,"__esModule",{value:!0});we.createDestination=void 0;var Qs=nn(ct()),Zs=nn(require("../../commonlibs/axios/index.js")),ea=Z(),ta=at(),rn=$e();async function ra(e){let t=(0,rn.destinationInfoToAnswerDestination)(e),r=(0,Qs.default)((0,ea.getEnvValue)(rn.ENV_H2O_URL),"/api/createDestination");try{let n={"Content-Type":"application/json","User-Agent":"Bas"},i={method:"post",url:r,headers:(0,ta.addJwtHeader)(n),data:t};await Zs.default.request(i)}catch(n){throw new Error(`Couldn't create the destination from the (${r}) URL because of the following error: ${n.message}. Error code=${n.response.status}`)}}s(ra,"createDestination");we.createDestination=ra});var ee=m((nf,cn)=>{"use strict";var an=["nodebuffer","arraybuffer","fragments"],on=typeof Blob<"u";on&&an.push("blob");cn.exports={BINARY_TYPES:an,CLOSE_TIMEOUT:3e4,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:on,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:s(()=>{},"NOOP")}});var je=m((af,ut)=>{"use strict";var{EMPTY_BUFFER:na}=ee(),ir=Buffer[Symbol.species];function ia(e,t){if(e.length===0)return na;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let i=0;i<e.length;i++){let a=e[i];r.set(a,n),n+=a.length}return n<t?new ir(r.buffer,r.byteOffset,n):r}s(ia,"concat");function ln(e,t,r,n,i){for(let a=0;a<i;a++)r[n+a]=e[a]^t[a&3]}s(ln,"_mask");function un(e,t){for(let r=0;r<e.length;r++)e[r]^=t[r&3]}s(un,"_unmask");function sa(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}s(sa,"toArrayBuffer");function sr(e){if(sr.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new ir(e):ArrayBuffer.isView(e)?t=new ir(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),sr.readOnly=!1),t}s(sr,"toBuffer");ut.exports={concat:ia,mask:ln,toArrayBuffer:sa,toBuffer:sr,unmask:un};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=require("bufferutil");ut.exports.mask=function(t,r,n,i,a){a<48?ln(t,r,n,i,a):e.mask(t,r,n,i,a)},ut.exports.unmask=function(t,r){t.length<32?un(t,r):e.unmask(t,r)}}catch{}});var hn=m((cf,dn)=>{"use strict";var fn=Symbol("kDone"),ar=Symbol("kRun"),or=class{static{s(this,"Limiter")}constructor(t){this[fn]=()=>{this.pending--,this[ar]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[ar]()}[ar](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[fn])}}};dn.exports=or});var xe=m((uf,vn)=>{"use strict";var qe=require("zlib"),pn=je(),aa=hn(),{kStatusCode:_n}=ee(),oa=Buffer[Symbol.species],ca=Buffer.from([0,0,255,255]),dt=Symbol("permessage-deflate"),te=Symbol("total-length"),be=Symbol("callback"),ie=Symbol("buffers"),Te=Symbol("error"),ft,cr=class{static{s(this,"PerMessageDeflate")}constructor(t){if(this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._maxPayload=this._options.maxPayload|0,this._isServer=!!this._options.isServer,this._deflate=null,this._inflate=null,this.params=null,!ft){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;ft=new aa(r)}}static get extensionName(){return"permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[be];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let r=this._options,n=t.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let i=r[n];if(i.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(i=i[0],n==="client_max_window_bits"){if(i!==!0){let a=+i;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=a}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else if(n==="server_max_window_bits"){let a=+i;if(!Number.isInteger(a)||a<8||a>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=a}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=i})}),t}decompress(t,r,n){ft.add(i=>{this._decompress(t,r,(a,o)=>{i(),n(a,o)})})}compress(t,r,n){ft.add(i=>{this._compress(t,r,(a,o)=>{i(),n(a,o)})})}_decompress(t,r,n){let i=this._isServer?"client":"server";if(!this._inflate){let a=`${i}_max_window_bits`,o=typeof this.params[a]!="number"?qe.Z_DEFAULT_WINDOWBITS:this.params[a];this._inflate=qe.createInflateRaw({...this._options.zlibInflateOptions,windowBits:o}),this._inflate[dt]=this,this._inflate[te]=0,this._inflate[ie]=[],this._inflate.on("error",ua),this._inflate.on("data",gn)}this._inflate[be]=n,this._inflate.write(t),r&&this._inflate.write(ca),this._inflate.flush(()=>{let a=this._inflate[Te];if(a){this._inflate.close(),this._inflate=null,n(a);return}let o=pn.concat(this._inflate[ie],this._inflate[te]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[te]=0,this._inflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,o)})}_compress(t,r,n){let i=this._isServer?"server":"client";if(!this._deflate){let a=`${i}_max_window_bits`,o=typeof this.params[a]!="number"?qe.Z_DEFAULT_WINDOWBITS:this.params[a];this._deflate=qe.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:o}),this._deflate[te]=0,this._deflate[ie]=[],this._deflate.on("data",la)}this._deflate[be]=n,this._deflate.write(t),this._deflate.flush(qe.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let a=pn.concat(this._deflate[ie],this._deflate[te]);r&&(a=new oa(a.buffer,a.byteOffset,a.length-4)),this._deflate[be]=null,this._deflate[te]=0,this._deflate[ie]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,a)})}};vn.exports=cr;function la(e){this[ie].push(e),this[te]+=e.length}s(la,"deflateOnData");function gn(e){if(this[te]+=e.length,this[dt]._maxPayload<1||this[te]<=this[dt]._maxPayload){this[ie].push(e);return}this[Te]=new RangeError("Max payload size exceeded"),this[Te].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Te][_n]=1009,this.removeListener("data",gn),this.reset()}s(gn,"inflateOnData");function ua(e){if(this[dt]._inflate=null,this[Te]){this[be](this[Te]);return}e[_n]=1007,this[be](e)}s(ua,"inflateOnError")});var Oe=m((df,ht)=>{"use strict";var{isUtf8:mn}=require("buffer"),{hasBlob:fa}=ee(),da=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function ha(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}s(ha,"isValidStatusCode");function lr(e){let t=e.length,r=0;for(;r<t;)if((e[r]&128)===0)r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return!1;r+=2}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return!1;r+=3}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return!1;r+=4}else return!1;return!0}s(lr,"_isValidUTF8");function pa(e){return fa&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}s(pa,"isBlob");ht.exports={isBlob:pa,isValidStatusCode:ha,isValidUTF8:lr,tokenChars:da};if(mn)ht.exports.isValidUTF8=function(e){return e.length<24?lr(e):mn(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=require("utf-8-validate");ht.exports.isValidUTF8=function(t){return t.length<32?lr(t):e(t)}}catch{}});var pr=m((pf,xn)=>{"use strict";var{Writable:_a}=require("stream"),yn=xe(),{BINARY_TYPES:ga,EMPTY_BUFFER:Sn,kStatusCode:va,kWebSocket:ma}=ee(),{concat:ur,toArrayBuffer:ya,unmask:Sa}=je(),{isValidStatusCode:Ea,isValidUTF8:En}=Oe(),pt=Buffer[Symbol.species],k=0,wn=1,bn=2,Tn=3,fr=4,dr=5,_t=6,hr=class extends _a{static{s(this,"Receiver")}constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||ga[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxBufferedChunks=t.maxBufferedChunks|0,this._maxFragments=t.maxFragments|0,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[ma]=void 0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._errored=!1,this._loop=!1,this._state=k}_write(t,r,n){if(this._opcode===8&&this._state==k)return n();if(this._maxBufferedChunks>0&&this._buffers.length>=this._maxBufferedChunks){n(this.createError(RangeError,"Too many buffered chunks",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS"));return}this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=new pt(n.buffer,n.byteOffset+t,n.length-t),new pt(n.buffer,n.byteOffset,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],i=r.length-t;t>=n.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),i),this._buffers[0]=new pt(n.buffer,n.byteOffset+t,n.length-t)),t-=n.length}while(t>0);return r}startLoop(t){this._loop=!0;do switch(this._state){case k:this.getInfo(t);break;case wn:this.getPayloadLength16(t);break;case bn:this.getPayloadLength64(t);break;case Tn:this.getMask();break;case fr:this.getData(t);break;case dr:case _t:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let r=this.consume(2);if((r[0]&48)!==0){let i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let n=(r[0]&64)===64;if(n&&!this._extensions[yn.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(r[0]&128)===128,this._opcode=r[0]&15,this._payloadLength=r[1]&127,this._opcode===0){if(n){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=n}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(n){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(r[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=wn:this._payloadLength===127?this._state=bn:this.haveLength(t)}getPayloadLength16(t){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(t)}getPayloadLength64(t){if(this._bufferedBytes<8){this._loop=!1;return}let r=this.consume(8),n=r.readUInt32BE(0);if(n>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=n*Math.pow(2,32)+r.readUInt32BE(4),this.haveLength(t)}haveLength(t){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0)){let r=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(r);return}this._masked?this._state=Tn:this._state=fr}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=fr}getData(t){let r=Sn;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&Sa(r,this._mask)}if(this._opcode>7){this.controlMessage(r,t);return}if(this._compressed){this._state=dr,this.decompress(r,t);return}if(r.length){if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let n=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");t(n);return}this._messageLength=this._totalPayloadLength,this._fragments.push(r)}this.dataMessage(t)}decompress(t,r){this._extensions[yn.extensionName].decompress(t,this._fin,(i,a)=>{if(i)return r(i);if(a.length){if(this._messageLength+=a.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let o=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");r(o);return}if(this._maxFragments>0&&this._fragments.length>=this._maxFragments){let o=this.createError(RangeError,"Too many message fragments",!1,1008,"WS_ERR_TOO_MANY_BUFFERED_PARTS");r(o);return}this._fragments.push(a)}this.dataMessage(r),this._state===k&&this.startLoop(r)})}dataMessage(t){if(!this._fin){this._state=k;return}let r=this._messageLength,n=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=ur(n,r):this._binaryType==="arraybuffer"?i=ya(ur(n,r)):this._binaryType==="blob"?i=new Blob(n):i=n,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=k):(this._state=_t,setImmediate(()=>{this.emit("message",i,!0),this._state=k,this.startLoop(t)}))}else{let i=ur(n,r);if(!this._skipUTF8Validation&&!En(i)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(a);return}this._state===dr||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=k):(this._state=_t,setImmediate(()=>{this.emit("message",i,!1),this._state=k,this.startLoop(t)}))}}controlMessage(t,r){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,Sn),this.end();else{let n=t.readUInt16BE(0);if(!Ea(n)){let a=this.createError(RangeError,`invalid status code ${n}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");r(a);return}let i=new pt(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!En(i)){let a=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");r(a);return}this._loop=!1,this.emit("conclude",n,i),this.end()}this._state=k;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=k):(this._state=_t,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=k,this.startLoop(r)}))}createError(t,r,n,i,a){this._loop=!1,this._errored=!0;let o=new t(n?`Invalid WebSocket frame: ${r}`:r);return Error.captureStackTrace(o,this.createError),o.code=a,o[va]=i,o}};xn.exports=hr});var vr=m((vf,An)=>{"use strict";var{Duplex:gf}=require("stream"),{randomFillSync:wa}=require("crypto"),{types:{isUint8Array:ba}}=require("util"),On=xe(),{EMPTY_BUFFER:Ta,kWebSocket:xa,NOOP:Oa}=ee(),{isBlob:Ce,isValidStatusCode:Ca}=Oe(),{mask:Cn,toBuffer:le}=je(),B=Symbol("kByteLength"),Aa=Buffer.alloc(4),gt=8*1024,ue,Ae=gt,M=0,Pa=1,Da=2,_r=class e{static{s(this,"Sender")}constructor(t,r,n){this._extensions=r||{},n&&(this._generateMask=n,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=M,this.onerror=Oa,this[xa]=void 0}static frame(t,r){let n,i=!1,a=2,o=!1;r.mask&&(n=r.maskBuffer||Aa,r.generateMask?r.generateMask(n):(Ae===gt&&(ue===void 0&&(ue=Buffer.alloc(gt)),wa(ue,0,gt),Ae=0),n[0]=ue[Ae++],n[1]=ue[Ae++],n[2]=ue[Ae++],n[3]=ue[Ae++]),o=(n[0]|n[1]|n[2]|n[3])===0,a=6);let c;typeof t=="string"?(!r.mask||o)&&r[B]!==void 0?c=r[B]:(t=Buffer.from(t),c=t.length):(c=t.length,i=r.mask&&r.readOnly&&!o);let d=c;c>=65536?(a+=8,d=127):c>125&&(a+=2,d=126);let u=Buffer.allocUnsafe(i?c+a:a);return u[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(u[0]|=64),u[1]=d,d===126?u.writeUInt16BE(c,2):d===127&&(u[2]=u[3]=0,u.writeUIntBE(c,4,6)),r.mask?(u[1]|=128,u[a-4]=n[0],u[a-3]=n[1],u[a-2]=n[2],u[a-1]=n[3],o?[u,t]:i?(Cn(t,n,u,a,c),[u]):(Cn(t,n,t,0,c),[u,t])):[u,t]}close(t,r,n,i){let a;if(t===void 0)a=Ta;else{if(typeof t!="number"||!Ca(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||!r.length)a=Buffer.allocUnsafe(2),a.writeUInt16BE(t,0);else{let c=Buffer.byteLength(r);if(c>123)throw new RangeError("The message must not be greater than 123 bytes");if(a=Buffer.allocUnsafe(2+c),a.writeUInt16BE(t,0),typeof r=="string")a.write(r,2);else if(ba(r))a.set(r,2);else throw new TypeError("Second argument must be a string or a Uint8Array")}}let o={[B]:a.length,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==M?this.enqueue([this.dispatch,a,!1,o,i]):this.sendFrame(e.frame(a,o),i)}ping(t,r,n){let i,a;if(typeof t=="string"?(i=Buffer.byteLength(t),a=!1):Ce(t)?(i=t.size,a=!1):(t=le(t),i=t.length,a=le.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[B]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:9,readOnly:a,rsv1:!1};Ce(t)?this._state!==M?this.enqueue([this.getBlobData,t,!1,o,n]):this.getBlobData(t,!1,o,n):this._state!==M?this.enqueue([this.dispatch,t,!1,o,n]):this.sendFrame(e.frame(t,o),n)}pong(t,r,n){let i,a;if(typeof t=="string"?(i=Buffer.byteLength(t),a=!1):Ce(t)?(i=t.size,a=!1):(t=le(t),i=t.length,a=le.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let o={[B]:i,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:10,readOnly:a,rsv1:!1};Ce(t)?this._state!==M?this.enqueue([this.getBlobData,t,!1,o,n]):this.getBlobData(t,!1,o,n):this._state!==M?this.enqueue([this.dispatch,t,!1,o,n]):this.sendFrame(e.frame(t,o),n)}send(t,r,n){let i=this._extensions[On.extensionName],a=r.binary?2:1,o=r.compress,c,d;typeof t=="string"?(c=Buffer.byteLength(t),d=!1):Ce(t)?(c=t.size,d=!1):(t=le(t),c=t.length,d=le.readOnly),this._firstFragment?(this._firstFragment=!1,o&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(o=c>=i._threshold),this._compress=o):(o=!1,a=0),r.fin&&(this._firstFragment=!0);let u={[B]:c,fin:r.fin,generateMask:this._generateMask,mask:r.mask,maskBuffer:this._maskBuffer,opcode:a,readOnly:d,rsv1:o};Ce(t)?this._state!==M?this.enqueue([this.getBlobData,t,this._compress,u,n]):this.getBlobData(t,this._compress,u,n):this._state!==M?this.enqueue([this.dispatch,t,this._compress,u,n]):this.dispatch(t,this._compress,u,n)}getBlobData(t,r,n,i){this._bufferedBytes+=n[B],this._state=Da,t.arrayBuffer().then(a=>{if(this._socket.destroyed){let c=new Error("The socket was closed while the blob was being read");process.nextTick(gr,this,c,i);return}this._bufferedBytes-=n[B];let o=le(a);r?this.dispatch(o,r,n,i):(this._state=M,this.sendFrame(e.frame(o,n),i),this.dequeue())}).catch(a=>{process.nextTick(La,this,a,i)})}dispatch(t,r,n,i){if(!r){this.sendFrame(e.frame(t,n),i);return}let a=this._extensions[On.extensionName];this._bufferedBytes+=n[B],this._state=Pa,a.compress(t,n.fin,(o,c)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");gr(this,d,i);return}this._bufferedBytes-=n[B],this._state=M,n.readOnly=!1,this.sendFrame(e.frame(c,n),i),this.dequeue()})}dequeue(){for(;this._state===M&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][B],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][B],this._queue.push(t)}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r)}};An.exports=_r;function gr(e,t,r){typeof r=="function"&&r(t);for(let n=0;n<e._queue.length;n++){let i=e._queue[n],a=i[i.length-1];typeof a=="function"&&a(t)}}s(gr,"callCallbacks");function La(e,t,r){gr(e,t,r),e.onerror(t)}s(La,"onError")});var Bn=m((yf,kn)=>{"use strict";var{kForOnEventAttribute:We,kListener:mr}=ee(),Pn=Symbol("kCode"),Dn=Symbol("kData"),Ln=Symbol("kError"),Rn=Symbol("kMessage"),In=Symbol("kReason"),Pe=Symbol("kTarget"),Un=Symbol("kType"),Nn=Symbol("kWasClean"),re=class{static{s(this,"Event")}constructor(t){this[Pe]=null,this[Un]=t}get target(){return this[Pe]}get type(){return this[Un]}};Object.defineProperty(re.prototype,"target",{enumerable:!0});Object.defineProperty(re.prototype,"type",{enumerable:!0});var fe=class extends re{static{s(this,"CloseEvent")}constructor(t,r={}){super(t),this[Pn]=r.code===void 0?0:r.code,this[In]=r.reason===void 0?"":r.reason,this[Nn]=r.wasClean===void 0?!1:r.wasClean}get code(){return this[Pn]}get reason(){return this[In]}get wasClean(){return this[Nn]}};Object.defineProperty(fe.prototype,"code",{enumerable:!0});Object.defineProperty(fe.prototype,"reason",{enumerable:!0});Object.defineProperty(fe.prototype,"wasClean",{enumerable:!0});var De=class extends re{static{s(this,"ErrorEvent")}constructor(t,r={}){super(t),this[Ln]=r.error===void 0?null:r.error,this[Rn]=r.message===void 0?"":r.message}get error(){return this[Ln]}get message(){return this[Rn]}};Object.defineProperty(De.prototype,"error",{enumerable:!0});Object.defineProperty(De.prototype,"message",{enumerable:!0});var He=class extends re{static{s(this,"MessageEvent")}constructor(t,r={}){super(t),this[Dn]=r.data===void 0?null:r.data}get data(){return this[Dn]}};Object.defineProperty(He.prototype,"data",{enumerable:!0});var Ra={addEventListener(e,t,r={}){for(let i of this.listeners(e))if(!r[We]&&i[mr]===t&&!i[We])return;let n;if(e==="message")n=s(function(a,o){let c=new He("message",{data:o?a:a.toString()});c[Pe]=this,vt(t,this,c)},"onMessage");else if(e==="close")n=s(function(a,o){let c=new fe("close",{code:a,reason:o.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});c[Pe]=this,vt(t,this,c)},"onClose");else if(e==="error")n=s(function(a){let o=new De("error",{error:a,message:a.message});o[Pe]=this,vt(t,this,o)},"onError");else if(e==="open")n=s(function(){let a=new re("open");a[Pe]=this,vt(t,this,a)},"onOpen");else return;n[We]=!!r[We],n[mr]=t,r.once?this.once(e,n):this.on(e,n)},removeEventListener(e,t){for(let r of this.listeners(e))if(r[mr]===t&&!r[We]){this.removeListener(e,r);break}}};kn.exports={CloseEvent:fe,ErrorEvent:De,Event:re,EventTarget:Ra,MessageEvent:He};function vt(e,t,r){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,r):e.call(t,r)}s(vt,"callListener")});var mt=m((Ef,Fn)=>{"use strict";var{tokenChars:Ve}=Oe();function H(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r)}s(H,"push");function Ia(e){let t=Object.create(null),r=Object.create(null),n=!1,i=!1,a=!1,o,c,d=-1,u=-1,h=-1,g=0;for(;g<e.length;g++)if(u=e.charCodeAt(g),o===void 0)if(h===-1&&Ve[u]===1)d===-1&&(d=g);else if(g!==0&&(u===32||u===9))h===-1&&d!==-1&&(h=g);else if(u===59||u===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${g}`);h===-1&&(h=g);let O=e.slice(d,h);u===44?(H(t,O,r),r=Object.create(null)):o=O,d=h=-1}else throw new SyntaxError(`Unexpected character at index ${g}`);else if(c===void 0)if(h===-1&&Ve[u]===1)d===-1&&(d=g);else if(u===32||u===9)h===-1&&d!==-1&&(h=g);else if(u===59||u===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${g}`);h===-1&&(h=g),H(r,e.slice(d,h),!0),u===44&&(H(t,o,r),r=Object.create(null),o=void 0),d=h=-1}else if(u===61&&d!==-1&&h===-1)c=e.slice(d,g),d=h=-1;else throw new SyntaxError(`Unexpected character at index ${g}`);else if(i){if(Ve[u]!==1)throw new SyntaxError(`Unexpected character at index ${g}`);d===-1?d=g:n||(n=!0),i=!1}else if(a)if(Ve[u]===1)d===-1&&(d=g);else if(u===34&&d!==-1)a=!1,h=g;else if(u===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${g}`);else if(u===34&&e.charCodeAt(g-1)===61)a=!0;else if(h===-1&&Ve[u]===1)d===-1&&(d=g);else if(d!==-1&&(u===32||u===9))h===-1&&(h=g);else if(u===59||u===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${g}`);h===-1&&(h=g);let O=e.slice(d,h);n&&(O=O.replace(/\\/g,""),n=!1),H(r,c,O),u===44&&(H(t,o,r),r=Object.create(null),o=void 0),c=void 0,d=h=-1}else throw new SyntaxError(`Unexpected character at index ${g}`);if(d===-1||a||u===32||u===9)throw new SyntaxError("Unexpected end of input");h===-1&&(h=g);let T=e.slice(d,h);return o===void 0?H(t,T,r):(c===void 0?H(r,T,!0):n?H(r,c,T.replace(/\\/g,"")):H(r,c,T),H(t,o,r)),t}s(Ia,"parse");function Ua(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(i=>{let a=n[i];return Array.isArray(a)||(a=[a]),a.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}s(Ua,"format");Fn.exports={format:Ua,parse:Ia}});var wt=m((xf,Yn)=>{"use strict";var Na=require("events"),ka=require("https"),Ba=require("http"),$n=require("net"),Fa=require("tls"),{randomBytes:Ga,createHash:Ma}=require("crypto"),{Duplex:bf,Readable:Tf}=require("stream"),{URL:yr}=require("url"),se=xe(),$a=pr(),ja=vr(),{isBlob:qa}=Oe(),{BINARY_TYPES:Gn,CLOSE_TIMEOUT:Wa,EMPTY_BUFFER:yt,GUID:Ha,kForOnEventAttribute:Sr,kListener:Va,kStatusCode:za,kWebSocket:R,NOOP:jn}=ee(),{EventTarget:{addEventListener:Ka,removeEventListener:Ja}}=Bn(),{format:Ya,parse:Xa}=mt(),{toBuffer:Qa}=je(),qn=Symbol("kAborted"),Er=[8,13],ne=["CONNECTING","OPEN","CLOSING","CLOSED"],Za=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,A=class e extends Na{static{s(this,"WebSocket")}constructor(t,r,n){super(),this._binaryType=Gn[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=yt,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,r===void 0?r=[]:Array.isArray(r)||(typeof r=="object"&&r!==null?(n=r,r=[]):r=[r]),Wn(this,t,r,n)):(this._autoPong=n.autoPong,this._closeTimeout=n.closeTimeout,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){Gn.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t))}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get isPaused(){return this._paused}get onclose(){return null}get onerror(){return null}get onopen(){return null}get onmessage(){return null}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,r,n){let i=new $a({allowSynchronousEvents:n.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxBufferedChunks:n.maxBufferedChunks,maxFragments:n.maxFragments,maxPayload:n.maxPayload,skipUTF8Validation:n.skipUTF8Validation}),a=new ja(t,this._extensions,n.generateMask);this._receiver=i,this._sender=a,this._socket=t,i[R]=this,a[R]=this,t[R]=this,i.on("conclude",ro),i.on("drain",no),i.on("error",io),i.on("message",so),i.on("ping",ao),i.on("pong",oo),a.onerror=co,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",zn),t.on("data",Et),t.on("end",Kn),t.on("error",Jn),this._readyState=e.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[se.extensionName]&&this._extensions[se.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){U(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),Vn(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){wr(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||yt,r,n)}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){wr(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||yt,r,n)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){wr(this,t,n);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...r};this._extensions[se.extensionName]||(i.compress=!1),this._sender.send(t||yt,i,n)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){U(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(A,"CONNECTING",{enumerable:!0,value:ne.indexOf("CONNECTING")});Object.defineProperty(A.prototype,"CONNECTING",{enumerable:!0,value:ne.indexOf("CONNECTING")});Object.defineProperty(A,"OPEN",{enumerable:!0,value:ne.indexOf("OPEN")});Object.defineProperty(A.prototype,"OPEN",{enumerable:!0,value:ne.indexOf("OPEN")});Object.defineProperty(A,"CLOSING",{enumerable:!0,value:ne.indexOf("CLOSING")});Object.defineProperty(A.prototype,"CLOSING",{enumerable:!0,value:ne.indexOf("CLOSING")});Object.defineProperty(A,"CLOSED",{enumerable:!0,value:ne.indexOf("CLOSED")});Object.defineProperty(A.prototype,"CLOSED",{enumerable:!0,value:ne.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(A.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(A.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[Sr])return t[Va];return null},set(t){for(let r of this.listeners(e))if(r[Sr]){this.removeListener(e,r);break}typeof t=="function"&&this.addEventListener(e,t,{[Sr]:!0})}})});A.prototype.addEventListener=Ka;A.prototype.removeEventListener=Ja;Yn.exports=A;function Wn(e,t,r,n){let i={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:Wa,protocolVersion:Er[1],maxBufferedChunks:1048576,maxFragments:131072,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...n,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,e._closeTimeout=i.closeTimeout,!Er.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${Er.join(", ")})`);let a;if(t instanceof yr)a=t;else try{a=new yr(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}a.protocol==="http:"?a.protocol="ws:":a.protocol==="https:"&&(a.protocol="wss:"),e._url=a.href;let o=a.protocol==="wss:",c=a.protocol==="ws+unix:",d;if(a.protocol!=="ws:"&&!o&&!c?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:c&&!a.pathname?d="The URL's pathname is empty":a.hash&&(d="The URL contains a fragment identifier"),d){let E=new SyntaxError(d);if(e._redirects===0)throw E;St(e,E);return}let u=o?443:80,h=Ga(16).toString("base64"),g=o?ka.request:Ba.request,T=new Set,O;if(i.createConnection=i.createConnection||(o?to:eo),i.defaultPort=i.defaultPort||u,i.port=a.port||u,i.host=a.hostname.startsWith("[")?a.hostname.slice(1,-1):a.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.path=a.pathname+a.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(O=new se({...i.perMessageDeflate,isServer:!1,maxPayload:i.maxPayload}),i.headers["Sec-WebSocket-Extensions"]=Ya({[se.extensionName]:O.offer()})),r.length){for(let E of r){if(typeof E!="string"||!Za.test(E)||T.has(E))throw new SyntaxError("An invalid or duplicated subprotocol was specified");T.add(E)}i.headers["Sec-WebSocket-Protocol"]=r.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(a.username||a.password)&&(i.auth=`${a.username}:${a.password}`),c){let E=i.path.split(":");i.socketPath=E[0],i.path=E[1]}let v;if(i.followRedirects){if(e._redirects===0){e._originalIpc=c,e._originalSecure=o,e._originalHostOrSocketPath=c?i.socketPath:a.host;let E=n&&n.headers;if(n={...n,headers:{}},E)for(let[D,W]of Object.entries(E))n.headers[D.toLowerCase()]=W}else if(e.listenerCount("redirect")===0){let E=c?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:a.host===e._originalHostOrSocketPath;(!E||e._originalSecure&&!o)&&(delete i.headers.authorization,delete i.headers.cookie,E||delete i.headers.host,i.auth=void 0)}i.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),v=e._req=g(i),e._redirects&&e.emit("redirect",e.url,v)}else v=e._req=g(i);i.timeout&&v.on("timeout",()=>{U(e,v,"Opening handshake has timed out")}),v.on("error",E=>{v===null||v[qn]||(v=e._req=null,St(e,E))}),v.on("response",E=>{let D=E.headers.location,W=E.statusCode;if(D&&i.followRedirects&&W>=300&&W<400){if(++e._redirects>i.maxRedirects){U(e,v,"Maximum redirects exceeded");return}v.abort();let Fe;try{Fe=new yr(D,t)}catch{let Se=new SyntaxError(`Invalid URL: ${D}`);St(e,Se);return}Wn(e,Fe,r,n)}else e.emit("unexpected-response",v,E)||U(e,v,`Unexpected server response: ${E.statusCode}`)}),v.on("upgrade",(E,D,W)=>{if(e.emit("upgrade",E),e.readyState!==A.CONNECTING)return;v=e._req=null;let Fe=E.headers.upgrade;if(Fe===void 0||Fe.toLowerCase()!=="websocket"){U(e,D,"Invalid Upgrade header");return}let qr=Ma("sha1").update(h+Ha).digest("base64");if(E.headers["sec-websocket-accept"]!==qr){U(e,D,"Invalid Sec-WebSocket-Accept header");return}let Se=E.headers["sec-websocket-protocol"],Ge;if(Se!==void 0?T.size?T.has(Se)||(Ge="Server sent an invalid subprotocol"):Ge="Server sent a subprotocol but none was requested":T.size&&(Ge="Server sent no subprotocol"),Ge){U(e,D,Ge);return}Se&&(e._protocol=Se);let Wr=E.headers["sec-websocket-extensions"];if(Wr!==void 0){if(!O){U(e,D,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let Wt;try{Wt=Xa(Wr)}catch{U(e,D,"Invalid Sec-WebSocket-Extensions header");return}let Hr=Object.keys(Wt);if(Hr.length!==1||Hr[0]!==se.extensionName){U(e,D,"Server indicated an extension that was not requested");return}try{O.accept(Wt[se.extensionName])}catch{U(e,D,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[se.extensionName]=O}e.setSocket(D,W,{allowSynchronousEvents:i.allowSynchrono