Files
FrenoCorp/node_modules/rpc-websockets/dist/index.browser-bundle.js
Michael Freno 7c684a42cc FRE-600: Fix code review blockers
- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-25 00:08:01 -04:00

5 lines
42 KiB
JavaScript

var RPCWebSocket=(function(exports){'use strict';var Pr=Object.create;var pt=Object.defineProperty;var Lr=Object.getOwnPropertyDescriptor;var Nr=Object.getOwnPropertyNames,ht=Object.getOwnPropertySymbols,Wr=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty,Dt=Object.prototype.propertyIsEnumerable;var bt=(a,s,u)=>s in a?pt(a,s,{enumerable:true,configurable:true,writable:true,value:u}):a[s]=u,ot=(a,s)=>{for(var u in s||(s={}))xt.call(s,u)&&bt(a,u,s[u]);if(ht)for(var u of ht(s))Dt.call(s,u)&&bt(a,u,s[u]);return a};var lt=(a,s)=>{var u={};for(var l in a)xt.call(a,l)&&s.indexOf(l)<0&&(u[l]=a[l]);if(a!=null&&ht)for(var l of ht(a))s.indexOf(l)<0&&Dt.call(a,l)&&(u[l]=a[l]);return u};var rt=(a,s)=>()=>(a&&(s=a(a=0)),s);var Mr=(a,s)=>()=>(s||a((s={exports:{}}).exports,s),s.exports),Or=(a,s)=>{for(var u in s)pt(a,u,{get:s[u],enumerable:true});},Fr=(a,s,u,l)=>{if(s&&typeof s=="object"||typeof s=="function")for(let p of Nr(s))!xt.call(a,p)&&p!==u&&pt(a,p,{get:()=>s[p],enumerable:!(l=Lr(s,p))||l.enumerable});return a};var $r=(a,s,u)=>(u=a!=null?Pr(Wr(a)):{},Fr(pt(u,"default",{value:a,enumerable:true}),a));var R=(a,s,u)=>bt(a,typeof s!="symbol"?s+"":s,u);var A=rt(()=>{});var j={};Or(j,{_debugEnd:()=>Ce,_debugProcess:()=>Te,_events:()=>Ke,_eventsCount:()=>Xe,_exiting:()=>pe,_fatalExceptions:()=>ke,_getActiveHandles:()=>ye,_getActiveRequests:()=>de,_kill:()=>we,_linkedBinding:()=>ae,_maxListeners:()=>He,_preload_modules:()=>je,_rawDebug:()=>ce,_startProfilerIdleNotifier:()=>Re,_stopProfilerIdleNotifier:()=>Pe,_tickCallback:()=>Ue,abort:()=>Me,addListener:()=>Je,allowedNodeEnvironmentFlags:()=>be,arch:()=>Kt,argv:()=>Qt,argv0:()=>De,assert:()=>xe,binding:()=>ee,browser:()=>se,chdir:()=>ie,config:()=>le,cpuUsage:()=>yt,cwd:()=>ne,debugPort:()=>qe,default:()=>ir,dlopen:()=>fe,domain:()=>he,emit:()=>tr,emitWarning:()=>te,env:()=>Jt,execArgv:()=>Vt,execPath:()=>$e,exit:()=>Ie,features:()=>Ae,hasUncaughtExceptionCaptureCallback:()=>Se,hrtime:()=>dt,kill:()=>Be,listeners:()=>nr,memoryUsage:()=>Ee,moduleLoadList:()=>ue,nextTick:()=>Yt,off:()=>Ve,on:()=>X,once:()=>Qe,openStdin:()=>_e,pid:()=>Oe,platform:()=>Xt,ppid:()=>Fe,prependListener:()=>er,prependOnceListener:()=>rr,reallyExit:()=>me,release:()=>oe,removeAllListeners:()=>Ze,removeListener:()=>ze,resourceUsage:()=>ge,setSourceMapsEnabled:()=>Ye,setUncaughtExceptionCaptureCallback:()=>ve,stderr:()=>Ne,stdin:()=>We,stdout:()=>Le,title:()=>Ht,umask:()=>re,uptime:()=>Ge,version:()=>zt,versions:()=>Zt});function vt(a){throw new Error("Node.js process "+a+" is not supported by JSPM core outside of Node.js")}function qr(){!nt||!V||(nt=false,V.length?K=V.concat(K):ft=-1,K.length&&jt());}function jt(){if(!nt){var a=setTimeout(qr,0);nt=true;for(var s=K.length;s;){for(V=K,K=[];++ft<s;)V&&V[ft].run();ft=-1,s=K.length;}V=null,nt=false,clearTimeout(a);}}function Yt(a){var s=new Array(arguments.length-1);if(arguments.length>1)for(var u=1;u<arguments.length;u++)s[u-1]=arguments[u];K.push(new Gt(a,s)),K.length===1&&!nt&&setTimeout(jt,0);}function Gt(a,s){this.fun=a,this.array=s;}function N(){}function ae(a){vt("_linkedBinding");}function fe(a){vt("dlopen");}function de(){return []}function ye(){return []}function xe(a,s){if(!a)throw new Error(s||"assertion error")}function Se(){return false}function Ge(){return Q.now()/1e3}function dt(a){var s=Math.floor((Date.now()-Q.now())*.001),u=Q.now()*.001,l=Math.floor(u)+s,p=Math.floor(u%1*1e9);return a&&(l=l-a[0],p=p-a[1],p<0&&(l--,p+=kt)),[l,p]}function X(){return ir}function nr(a){return []}var K,nt,V,ft,Ht,Kt,Xt,Jt,Qt,Vt,zt,Zt,te,ee,re,ne,ie,oe,se,ce,ue,he,pe,le,me,we,yt,ge,Ee,Be,Ie,_e,be,Ae,ke,ve,Ue,Te,Ce,Re,Pe,Le,Ne,We,Me,Oe,Fe,$e,qe,De,je,Ye,Q,At,kt,He,Ke,Xe,Je,Qe,Ve,ze,Ze,tr,er,rr,ir,or=rt(()=>{A();v();k();K=[],nt=false,ft=-1;Gt.prototype.run=function(){this.fun.apply(null,this.array);};Ht="browser",Kt="x64",Xt="browser",Jt={PATH:"/usr/bin",LANG:typeof navigator!="undefined"?navigator.language+".UTF-8":void 0,PWD:"/",HOME:"/home",TMP:"/tmp"},Qt=["/usr/bin/node"],Vt=[],zt="v16.8.0",Zt={},te=function(a,s){console.warn((s?s+": ":"")+a);},ee=function(a){vt("binding");},re=function(a){return 0},ne=function(){return "/"},ie=function(a){},oe={name:"node",sourceUrl:"",headersUrl:"",libUrl:""};se=true,ce=N,ue=[];he={},pe=false,le={};me=N,we=N,yt=function(){return {}},ge=yt,Ee=yt,Be=N,Ie=N,_e=N,be={};Ae={inspector:false,debug:false,uv:false,ipv6:false,tls_alpn:false,tls_sni:false,tls_ocsp:false,tls:false,cached_builtins:true},ke=N,ve=N;Ue=N,Te=N,Ce=N,Re=N,Pe=N,Le=void 0,Ne=void 0,We=void 0,Me=N,Oe=2,Fe=1,$e="/bin/usr/node",qe=9229,De="node",je=[],Ye=N,Q={now:typeof performance!="undefined"?performance.now.bind(performance):void 0,timing:typeof performance!="undefined"?performance.timing:void 0};Q.now===void 0&&(At=Date.now(),Q.timing&&Q.timing.navigationStart&&(At=Q.timing.navigationStart),Q.now=()=>Date.now()-At);kt=1e9;dt.bigint=function(a){var s=dt(a);return typeof BigInt=="undefined"?s[0]*kt+s[1]:BigInt(s[0]*kt)+BigInt(s[1])};He=10,Ke={},Xe=0;Je=X,Qe=X,Ve=X,ze=X,Ze=X,tr=N,er=X,rr=X;ir={version:zt,versions:Zt,arch:Kt,platform:Xt,browser:se,release:oe,_rawDebug:ce,moduleLoadList:ue,binding:ee,_linkedBinding:ae,_events:Ke,_eventsCount:Xe,_maxListeners:He,on:X,addListener:Je,once:Qe,off:Ve,removeListener:ze,removeAllListeners:Ze,emit:tr,prependListener:er,prependOnceListener:rr,listeners:nr,domain:he,_exiting:pe,config:le,dlopen:fe,uptime:Ge,_getActiveRequests:de,_getActiveHandles:ye,reallyExit:me,_kill:we,cpuUsage:yt,resourceUsage:ge,memoryUsage:Ee,kill:Be,exit:Ie,openStdin:_e,allowedNodeEnvironmentFlags:be,assert:xe,features:Ae,_fatalExceptions:ke,setUncaughtExceptionCaptureCallback:ve,hasUncaughtExceptionCaptureCallback:Se,emitWarning:te,nextTick:Yt,_tickCallback:Ue,_debugProcess:Te,_debugEnd:Ce,_startProfilerIdleNotifier:Re,_stopProfilerIdleNotifier:Pe,stdout:Le,stdin:We,stderr:Ne,abort:Me,umask:re,chdir:ie,cwd:ne,env:Jt,title:Ht,argv:Qt,execArgv:Vt,pid:Oe,ppid:Fe,execPath:$e,debugPort:qe,hrtime:dt,argv0:De,_preload_modules:je,setSourceMapsEnabled:Ye};});var k=rt(()=>{or();});function Dr(){if(sr)return st;sr=true,st.byteLength=w,st.toByteArray=I,st.fromByteArray=L;for(var a=[],s=[],u=typeof Uint8Array!="undefined"?Uint8Array:Array,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",p=0,f=l.length;p<f;++p)a[p]=l[p],s[l.charCodeAt(p)]=p;s[45]=62,s[95]=63;function i(y){var E=y.length;if(E%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var b=y.indexOf("=");b===-1&&(b=E);var C=b===E?0:4-b%4;return [b,C]}function w(y){var E=i(y),b=E[0],C=E[1];return (b+C)*3/4-C}function d(y,E,b){return (E+b)*3/4-b}function I(y){var E,b=i(y),C=b[0],F=b[1],T=new u(d(y,C,F)),$=0,D=F>0?C-4:C,M;for(M=0;M<D;M+=4)E=s[y.charCodeAt(M)]<<18|s[y.charCodeAt(M+1)]<<12|s[y.charCodeAt(M+2)]<<6|s[y.charCodeAt(M+3)],T[$++]=E>>16&255,T[$++]=E>>8&255,T[$++]=E&255;return F===2&&(E=s[y.charCodeAt(M)]<<2|s[y.charCodeAt(M+1)]>>4,T[$++]=E&255),F===1&&(E=s[y.charCodeAt(M)]<<10|s[y.charCodeAt(M+1)]<<4|s[y.charCodeAt(M+2)]>>2,T[$++]=E>>8&255,T[$++]=E&255),T}function B(y){return a[y>>18&63]+a[y>>12&63]+a[y>>6&63]+a[y&63]}function m(y,E,b){for(var C,F=[],T=E;T<b;T+=3)C=(y[T]<<16&16711680)+(y[T+1]<<8&65280)+(y[T+2]&255),F.push(B(C));return F.join("")}function L(y){for(var E,b=y.length,C=b%3,F=[],T=16383,$=0,D=b-C;$<D;$+=T)F.push(m(y,$,$+T>D?D:$+T));return C===1?(E=y[b-1],F.push(a[E>>2]+a[E<<4&63]+"==")):C===2&&(E=(y[b-2]<<8)+y[b-1],F.push(a[E>>10]+a[E>>4&63]+a[E<<2&63]+"=")),F.join("")}return st}function jr(){if(cr)return mt;cr=true;return mt.read=function(a,s,u,l,p){var f,i,w=p*8-l-1,d=(1<<w)-1,I=d>>1,B=-7,m=u?p-1:0,L=u?-1:1,y=a[s+m];for(m+=L,f=y&(1<<-B)-1,y>>=-B,B+=w;B>0;f=f*256+a[s+m],m+=L,B-=8);for(i=f&(1<<-B)-1,f>>=-B,B+=l;B>0;i=i*256+a[s+m],m+=L,B-=8);if(f===0)f=1-I;else {if(f===d)return i?NaN:(y?-1:1)*(1/0);i=i+Math.pow(2,l),f=f-I;}return (y?-1:1)*i*Math.pow(2,f-l)},mt.write=function(a,s,u,l,p,f){var i,w,d,I=f*8-p-1,B=(1<<I)-1,m=B>>1,L=p===23?Math.pow(2,-24)-Math.pow(2,-77):0,y=l?0:f-1,E=l?1:-1,b=s<0||s===0&&1/s<0?1:0;for(s=Math.abs(s),isNaN(s)||s===1/0?(w=isNaN(s)?1:0,i=B):(i=Math.floor(Math.log(s)/Math.LN2),s*(d=Math.pow(2,-i))<1&&(i--,d*=2),i+m>=1?s+=L/d:s+=L*Math.pow(2,1-m),s*d>=2&&(i++,d/=2),i+m>=B?(w=0,i=B):i+m>=1?(w=(s*d-1)*Math.pow(2,p),i=i+m):(w=s*Math.pow(2,m-1)*Math.pow(2,p),i=0));p>=8;a[u+y]=w&255,y+=E,w/=256,p-=8);for(i=i<<p|w,I+=p;I>0;a[u+y]=i&255,y+=E,i/=256,I-=8);a[u+y-E]|=b*128;},mt}function ar(){if(ur)return z;ur=true;let a=Dr(),s=jr(),u=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;z.Buffer=i,z.SlowBuffer=F,z.INSPECT_MAX_BYTES=50;let l=2147483647;z.kMaxLength=l,i.TYPED_ARRAY_SUPPORT=p(),!i.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function p(){try{let r=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(r,t),r.foo()===42}catch(r){return false}}Object.defineProperty(i.prototype,"parent",{enumerable:true,get:function(){if(i.isBuffer(this))return this.buffer}}),Object.defineProperty(i.prototype,"offset",{enumerable:true,get:function(){if(i.isBuffer(this))return this.byteOffset}});function f(r){if(r>l)throw new RangeError('The value "'+r+'" is invalid for option "size"');let t=new Uint8Array(r);return Object.setPrototypeOf(t,i.prototype),t}function i(r,t,e){if(typeof r=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return B(r)}return w(r,t,e)}i.poolSize=8192;function w(r,t,e){if(typeof r=="string")return m(r,t);if(ArrayBuffer.isView(r))return y(r);if(r==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r);if(G(r,ArrayBuffer)||r&&G(r.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(G(r,SharedArrayBuffer)||r&&G(r.buffer,SharedArrayBuffer)))return E(r,t,e);if(typeof r=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=r.valueOf&&r.valueOf();if(n!=null&&n!==r)return i.from(n,t,e);let o=b(r);if(o)return o;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof r[Symbol.toPrimitive]=="function")return i.from(r[Symbol.toPrimitive]("string"),t,e);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof r)}i.from=function(r,t,e){return w(r,t,e)},Object.setPrototypeOf(i.prototype,Uint8Array.prototype),Object.setPrototypeOf(i,Uint8Array);function d(r){if(typeof r!="number")throw new TypeError('"size" argument must be of type number');if(r<0)throw new RangeError('The value "'+r+'" is invalid for option "size"')}function I(r,t,e){return d(r),r<=0?f(r):t!==void 0?typeof e=="string"?f(r).fill(t,e):f(r).fill(t):f(r)}i.alloc=function(r,t,e){return I(r,t,e)};function B(r){return d(r),f(r<0?0:C(r)|0)}i.allocUnsafe=function(r){return B(r)},i.allocUnsafeSlow=function(r){return B(r)};function m(r,t){if((typeof t!="string"||t==="")&&(t="utf8"),!i.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let e=T(r,t)|0,n=f(e),o=n.write(r,t);return o!==e&&(n=n.slice(0,o)),n}function L(r){let t=r.length<0?0:C(r.length)|0,e=f(t);for(let n=0;n<t;n+=1)e[n]=r[n]&255;return e}function y(r){if(G(r,Uint8Array)){let t=new Uint8Array(r);return E(t.buffer,t.byteOffset,t.byteLength)}return L(r)}function E(r,t,e){if(t<0||r.byteLength<t)throw new RangeError('"offset" is outside of buffer bounds');if(r.byteLength<t+(e||0))throw new RangeError('"length" is outside of buffer bounds');let n;return t===void 0&&e===void 0?n=new Uint8Array(r):e===void 0?n=new Uint8Array(r,t):n=new Uint8Array(r,t,e),Object.setPrototypeOf(n,i.prototype),n}function b(r){if(i.isBuffer(r)){let t=C(r.length)|0,e=f(t);return e.length===0||r.copy(e,0,0,t),e}if(r.length!==void 0)return typeof r.length!="number"||_t(r.length)?f(0):L(r);if(r.type==="Buffer"&&Array.isArray(r.data))return L(r.data)}function C(r){if(r>=l)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+l.toString(16)+" bytes");return r|0}function F(r){return +r!=r&&(r=0),i.alloc(+r)}i.isBuffer=function(t){return t!=null&&t._isBuffer===true&&t!==i.prototype},i.compare=function(t,e){if(G(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),G(e,Uint8Array)&&(e=i.from(e,e.offset,e.byteLength)),!i.isBuffer(t)||!i.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let n=t.length,o=e.length;for(let c=0,h=Math.min(n,o);c<h;++c)if(t[c]!==e[c]){n=t[c],o=e[c];break}return n<o?-1:o<n?1:0},i.isEncoding=function(t){switch(String(t).toLowerCase()){case "hex":case "utf8":case "utf-8":case "ascii":case "latin1":case "binary":case "base64":case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return true;default:return false}},i.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return i.alloc(0);let n;if(e===void 0)for(e=0,n=0;n<t.length;++n)e+=t[n].length;let o=i.allocUnsafe(e),c=0;for(n=0;n<t.length;++n){let h=t[n];if(G(h,Uint8Array))c+h.length>o.length?(i.isBuffer(h)||(h=i.from(h)),h.copy(o,c)):Uint8Array.prototype.set.call(o,h,c);else if(i.isBuffer(h))h.copy(o,c);else throw new TypeError('"list" argument must be an Array of Buffers');c+=h.length;}return o};function T(r,t){if(i.isBuffer(r))return r.length;if(ArrayBuffer.isView(r)||G(r,ArrayBuffer))return r.byteLength;if(typeof r!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof r);let e=r.length,n=arguments.length>2&&arguments[2]===true;if(!n&&e===0)return 0;let o=false;for(;;)switch(t){case "ascii":case "latin1":case "binary":return e;case "utf8":case "utf-8":return It(r).length;case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return e*2;case "hex":return e>>>1;case "base64":return qt(r).length;default:if(o)return n?-1:It(r).length;t=(""+t).toLowerCase(),o=true;}}i.byteLength=T;function $(r,t,e){let n=false;if((t===void 0||t<0)&&(t=0),t>this.length||((e===void 0||e>this.length)&&(e=this.length),e<=0)||(e>>>=0,t>>>=0,e<=t))return "";for(r||(r="utf8");;)switch(r){case "hex":return xr(this,t,e);case "utf8":case "utf-8":return Rt(this,t,e);case "ascii":return _r(this,t,e);case "latin1":case "binary":return br(this,t,e);case "base64":return Br(this,t,e);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return Ar(this,t,e);default:if(n)throw new TypeError("Unknown encoding: "+r);r=(r+"").toLowerCase(),n=true;}}i.prototype._isBuffer=true;function D(r,t,e){let n=r[t];r[t]=r[e],r[e]=n;}i.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let e=0;e<t;e+=2)D(this,e,e+1);return this},i.prototype.swap32=function(){let t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let e=0;e<t;e+=4)D(this,e,e+3),D(this,e+1,e+2);return this},i.prototype.swap64=function(){let t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let e=0;e<t;e+=8)D(this,e,e+7),D(this,e+1,e+6),D(this,e+2,e+5),D(this,e+3,e+4);return this},i.prototype.toString=function(){let t=this.length;return t===0?"":arguments.length===0?Rt(this,0,t):$.apply(this,arguments)},i.prototype.toLocaleString=i.prototype.toString,i.prototype.equals=function(t){if(!i.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t?true:i.compare(this,t)===0},i.prototype.inspect=function(){let t="",e=z.INSPECT_MAX_BYTES;return t=this.toString("hex",0,e).replace(/(.{2})/g,"$1 ").trim(),this.length>e&&(t+=" ... "),"<Buffer "+t+">"},u&&(i.prototype[u]=i.prototype.inspect),i.prototype.compare=function(t,e,n,o,c){if(G(t,Uint8Array)&&(t=i.from(t,t.offset,t.byteLength)),!i.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(e===void 0&&(e=0),n===void 0&&(n=t?t.length:0),o===void 0&&(o=0),c===void 0&&(c=this.length),e<0||n>t.length||o<0||c>this.length)throw new RangeError("out of range index");if(o>=c&&e>=n)return 0;if(o>=c)return -1;if(e>=n)return 1;if(e>>>=0,n>>>=0,o>>>=0,c>>>=0,this===t)return 0;let h=c-o,g=n-e,S=Math.min(h,g),x=this.slice(o,c),U=t.slice(e,n);for(let _=0;_<S;++_)if(x[_]!==U[_]){h=x[_],g=U[_];break}return h<g?-1:g<h?1:0};function M(r,t,e,n,o){if(r.length===0)return -1;if(typeof e=="string"?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,_t(e)&&(e=o?0:r.length-1),e<0&&(e=r.length+e),e>=r.length){if(o)return -1;e=r.length-1;}else if(e<0)if(o)e=0;else return -1;if(typeof t=="string"&&(t=i.from(t,n)),i.isBuffer(t))return t.length===0?-1:Ct(r,t,e,n,o);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?o?Uint8Array.prototype.indexOf.call(r,t,e):Uint8Array.prototype.lastIndexOf.call(r,t,e):Ct(r,[t],e,n,o);throw new TypeError("val must be string, number or Buffer")}function Ct(r,t,e,n,o){let c=1,h=r.length,g=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(r.length<2||t.length<2)return -1;c=2,h/=2,g/=2,e/=2;}function S(U,_){return c===1?U[_]:U.readUInt16BE(_*c)}let x;if(o){let U=-1;for(x=e;x<h;x++)if(S(r,x)===S(t,U===-1?0:x-U)){if(U===-1&&(U=x),x-U+1===g)return U*c}else U!==-1&&(x-=x-U),U=-1;}else for(e+g>h&&(e=h-g),x=e;x>=0;x--){let U=true;for(let _=0;_<g;_++)if(S(r,x+_)!==S(t,_)){U=false;break}if(U)return x}return -1}i.prototype.includes=function(t,e,n){return this.indexOf(t,e,n)!==-1},i.prototype.indexOf=function(t,e,n){return M(this,t,e,n,true)},i.prototype.lastIndexOf=function(t,e,n){return M(this,t,e,n,false)};function yr(r,t,e,n){e=Number(e)||0;let o=r.length-e;n?(n=Number(n),n>o&&(n=o)):n=o;let c=t.length;n>c/2&&(n=c/2);let h;for(h=0;h<n;++h){let g=parseInt(t.substr(h*2,2),16);if(_t(g))return h;r[e+h]=g;}return h}function mr(r,t,e,n){return at(It(t,r.length-e),r,e,n)}function wr(r,t,e,n){return at(Ur(t),r,e,n)}function gr(r,t,e,n){return at(qt(t),r,e,n)}function Er(r,t,e,n){return at(Tr(t,r.length-e),r,e,n)}i.prototype.write=function(t,e,n,o){if(e===void 0)o="utf8",n=this.length,e=0;else if(n===void 0&&typeof e=="string")o=e,n=this.length,e=0;else if(isFinite(e))e=e>>>0,isFinite(n)?(n=n>>>0,o===void 0&&(o="utf8")):(o=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let c=this.length-e;if((n===void 0||n>c)&&(n=c),t.length>0&&(n<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");o||(o="utf8");let h=false;for(;;)switch(o){case "hex":return yr(this,t,e,n);case "utf8":case "utf-8":return mr(this,t,e,n);case "ascii":case "latin1":case "binary":return wr(this,t,e,n);case "base64":return gr(this,t,e,n);case "ucs2":case "ucs-2":case "utf16le":case "utf-16le":return Er(this,t,e,n);default:if(h)throw new TypeError("Unknown encoding: "+o);o=(""+o).toLowerCase(),h=true;}},i.prototype.toJSON=function(){return {type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function Br(r,t,e){return t===0&&e===r.length?a.fromByteArray(r):a.fromByteArray(r.slice(t,e))}function Rt(r,t,e){e=Math.min(r.length,e);let n=[],o=t;for(;o<e;){let c=r[o],h=null,g=c>239?4:c>223?3:c>191?2:1;if(o+g<=e){let S,x,U,_;switch(g){case 1:c<128&&(h=c);break;case 2:S=r[o+1],(S&192)===128&&(_=(c&31)<<6|S&63,_>127&&(h=_));break;case 3:S=r[o+1],x=r[o+2],(S&192)===128&&(x&192)===128&&(_=(c&15)<<12|(S&63)<<6|x&63,_>2047&&(_<55296||_>57343)&&(h=_));break;case 4:S=r[o+1],x=r[o+2],U=r[o+3],(S&192)===128&&(x&192)===128&&(U&192)===128&&(_=(c&15)<<18|(S&63)<<12|(x&63)<<6|U&63,_>65535&&_<1114112&&(h=_));}}h===null?(h=65533,g=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|h&1023),n.push(h),o+=g;}return Ir(n)}let Pt=4096;function Ir(r){let t=r.length;if(t<=Pt)return String.fromCharCode.apply(String,r);let e="",n=0;for(;n<t;)e+=String.fromCharCode.apply(String,r.slice(n,n+=Pt));return e}function _r(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]&127);return n}function br(r,t,e){let n="";e=Math.min(r.length,e);for(let o=t;o<e;++o)n+=String.fromCharCode(r[o]);return n}function xr(r,t,e){let n=r.length;(!t||t<0)&&(t=0),(!e||e<0||e>n)&&(e=n);let o="";for(let c=t;c<e;++c)o+=Cr[r[c]];return o}function Ar(r,t,e){let n=r.slice(t,e),o="";for(let c=0;c<n.length-1;c+=2)o+=String.fromCharCode(n[c]+n[c+1]*256);return o}i.prototype.slice=function(t,e){let n=this.length;t=~~t,e=e===void 0?n:~~e,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),e<0?(e+=n,e<0&&(e=0)):e>n&&(e=n),e<t&&(e=t);let o=this.subarray(t,e);return Object.setPrototypeOf(o,i.prototype),o};function P(r,t,e){if(r%1!==0||r<0)throw new RangeError("offset is not uint");if(r+t>e)throw new RangeError("Trying to access beyond buffer length")}i.prototype.readUintLE=i.prototype.readUIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t],c=1,h=0;for(;++h<e&&(c*=256);)o+=this[t+h]*c;return o},i.prototype.readUintBE=i.prototype.readUIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t+--e],c=1;for(;e>0&&(c*=256);)o+=this[t+--e]*c;return o},i.prototype.readUint8=i.prototype.readUInt8=function(t,e){return t=t>>>0,e||P(t,1,this.length),this[t]},i.prototype.readUint16LE=i.prototype.readUInt16LE=function(t,e){return t=t>>>0,e||P(t,2,this.length),this[t]|this[t+1]<<8},i.prototype.readUint16BE=i.prototype.readUInt16BE=function(t,e){return t=t>>>0,e||P(t,2,this.length),this[t]<<8|this[t+1]},i.prototype.readUint32LE=i.prototype.readUInt32LE=function(t,e){return t=t>>>0,e||P(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216},i.prototype.readUint32BE=i.prototype.readUInt32BE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])},i.prototype.readBigUInt64LE=J(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&it(t,this.length-8);let o=e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,c=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(o)+(BigInt(c)<<BigInt(32))}),i.prototype.readBigUInt64BE=J(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&it(t,this.length-8);let o=e*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],c=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return (BigInt(o)<<BigInt(32))+BigInt(c)}),i.prototype.readIntLE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=this[t],c=1,h=0;for(;++h<e&&(c*=256);)o+=this[t+h]*c;return c*=128,o>=c&&(o-=Math.pow(2,8*e)),o},i.prototype.readIntBE=function(t,e,n){t=t>>>0,e=e>>>0,n||P(t,e,this.length);let o=e,c=1,h=this[t+--o];for(;o>0&&(c*=256);)h+=this[t+--o]*c;return c*=128,h>=c&&(h-=Math.pow(2,8*e)),h},i.prototype.readInt8=function(t,e){return t=t>>>0,e||P(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]},i.prototype.readInt16LE=function(t,e){t=t>>>0,e||P(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n},i.prototype.readInt16BE=function(t,e){t=t>>>0,e||P(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n},i.prototype.readInt32LE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},i.prototype.readInt32BE=function(t,e){return t=t>>>0,e||P(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},i.prototype.readBigInt64LE=J(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&it(t,this.length-8);let o=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return (BigInt(o)<<BigInt(32))+BigInt(e+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24)}),i.prototype.readBigInt64BE=J(function(t){t=t>>>0,et(t,"offset");let e=this[t],n=this[t+7];(e===void 0||n===void 0)&&it(t,this.length-8);let o=(e<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return (BigInt(o)<<BigInt(32))+BigInt(this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n)}),i.prototype.readFloatLE=function(t,e){return t=t>>>0,e||P(t,4,this.length),s.read(this,t,true,23,4)},i.prototype.readFloatBE=function(t,e){return t=t>>>0,e||P(t,4,this.length),s.read(this,t,false,23,4)},i.prototype.readDoubleLE=function(t,e){return t=t>>>0,e||P(t,8,this.length),s.read(this,t,true,52,8)},i.prototype.readDoubleBE=function(t,e){return t=t>>>0,e||P(t,8,this.length),s.read(this,t,false,52,8)};function q(r,t,e,n,o,c){if(!i.isBuffer(r))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>o||t<c)throw new RangeError('"value" argument is out of bounds');if(e+n>r.length)throw new RangeError("Index out of range")}i.prototype.writeUintLE=i.prototype.writeUIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let g=Math.pow(2,8*n)-1;q(this,t,e,n,g,0);}let c=1,h=0;for(this[e]=t&255;++h<n&&(c*=256);)this[e+h]=t/c&255;return e+n},i.prototype.writeUintBE=i.prototype.writeUIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,n=n>>>0,!o){let g=Math.pow(2,8*n)-1;q(this,t,e,n,g,0);}let c=n-1,h=1;for(this[e+c]=t&255;--c>=0&&(h*=256);)this[e+c]=t/h&255;return e+n},i.prototype.writeUint8=i.prototype.writeUInt8=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,1,255,0),this[e]=t&255,e+1},i.prototype.writeUint16LE=i.prototype.writeUInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,65535,0),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeUint16BE=i.prototype.writeUInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeUint32LE=i.prototype.writeUInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=t&255,e+4},i.prototype.writeUint32BE=i.prototype.writeUInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4};function Lt(r,t,e,n,o){$t(t,n,o,r,e,7);let c=Number(t&BigInt(4294967295));r[e++]=c,c=c>>8,r[e++]=c,c=c>>8,r[e++]=c,c=c>>8,r[e++]=c;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,h=h>>8,r[e++]=h,e}function Nt(r,t,e,n,o){$t(t,n,o,r,e,7);let c=Number(t&BigInt(4294967295));r[e+7]=c,c=c>>8,r[e+6]=c,c=c>>8,r[e+5]=c,c=c>>8,r[e+4]=c;let h=Number(t>>BigInt(32)&BigInt(4294967295));return r[e+3]=h,h=h>>8,r[e+2]=h,h=h>>8,r[e+1]=h,h=h>>8,r[e]=h,e+8}i.prototype.writeBigUInt64LE=J(function(t,e=0){return Lt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeBigUInt64BE=J(function(t,e=0){return Nt(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))}),i.prototype.writeIntLE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let S=Math.pow(2,8*n-1);q(this,t,e,n,S-1,-S);}let c=0,h=1,g=0;for(this[e]=t&255;++c<n&&(h*=256);)t<0&&g===0&&this[e+c-1]!==0&&(g=1),this[e+c]=(t/h>>0)-g&255;return e+n},i.prototype.writeIntBE=function(t,e,n,o){if(t=+t,e=e>>>0,!o){let S=Math.pow(2,8*n-1);q(this,t,e,n,S-1,-S);}let c=n-1,h=1,g=0;for(this[e+c]=t&255;--c>=0&&(h*=256);)t<0&&g===0&&this[e+c+1]!==0&&(g=1),this[e+c]=(t/h>>0)-g&255;return e+n},i.prototype.writeInt8=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=t&255,e+1},i.prototype.writeInt16LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,32767,-32768),this[e]=t&255,this[e+1]=t>>>8,e+2},i.prototype.writeInt16BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=t&255,e+2},i.prototype.writeInt32LE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,2147483647,-2147483648),this[e]=t&255,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},i.prototype.writeInt32BE=function(t,e,n){return t=+t,e=e>>>0,n||q(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=t&255,e+4},i.prototype.writeBigInt64LE=J(function(t,e=0){return Lt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),i.prototype.writeBigInt64BE=J(function(t,e=0){return Nt(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Wt(r,t,e,n,o,c){if(e+n>r.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Mt(r,t,e,n,o){return t=+t,e=e>>>0,o||Wt(r,t,e,4),s.write(r,t,e,n,23,4),e+4}i.prototype.writeFloatLE=function(t,e,n){return Mt(this,t,e,true,n)},i.prototype.writeFloatBE=function(t,e,n){return Mt(this,t,e,false,n)};function Ot(r,t,e,n,o){return t=+t,e=e>>>0,o||Wt(r,t,e,8),s.write(r,t,e,n,52,8),e+8}i.prototype.writeDoubleLE=function(t,e,n){return Ot(this,t,e,true,n)},i.prototype.writeDoubleBE=function(t,e,n){return Ot(this,t,e,false,n)},i.prototype.copy=function(t,e,n,o){if(!i.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!o&&o!==0&&(o=this.length),e>=t.length&&(e=t.length),e||(e=0),o>0&&o<n&&(o=n),o===n||t.length===0||this.length===0)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("sourceEnd out of bounds");o>this.length&&(o=this.length),t.length-e<o-n&&(o=t.length-e+n);let c=o-n;return this===t&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(e,n,o):Uint8Array.prototype.set.call(t,this.subarray(n,o),e),c},i.prototype.fill=function(t,e,n,o){if(typeof t=="string"){if(typeof e=="string"?(o=e,e=0,n=this.length):typeof n=="string"&&(o=n,n=this.length),o!==void 0&&typeof o!="string")throw new TypeError("encoding must be a string");if(typeof o=="string"&&!i.isEncoding(o))throw new TypeError("Unknown encoding: "+o);if(t.length===1){let h=t.charCodeAt(0);(o==="utf8"&&h<128||o==="latin1")&&(t=h);}}else typeof t=="number"?t=t&255:typeof t=="boolean"&&(t=Number(t));if(e<0||this.length<e||this.length<n)throw new RangeError("Out of range index");if(n<=e)return this;e=e>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let c;if(typeof t=="number")for(c=e;c<n;++c)this[c]=t;else {let h=i.isBuffer(t)?t:i.from(t,o),g=h.length;if(g===0)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(c=0;c<n-e;++c)this[c+e]=h[c%g];}return this};let tt={};function Bt(r,t,e){tt[r]=class extends e{constructor(){super(),Object.defineProperty(this,"message",{value:t.apply(this,arguments),writable:true,configurable:true}),this.name=`${this.name} [${r}]`,this.stack,delete this.name;}get code(){return r}set code(o){Object.defineProperty(this,"code",{configurable:true,enumerable:true,value:o,writable:true});}toString(){return `${this.name} [${r}]: ${this.message}`}};}Bt("ERR_BUFFER_OUT_OF_BOUNDS",function(r){return r?`${r} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),Bt("ERR_INVALID_ARG_TYPE",function(r,t){return `The "${r}" argument must be of type number. Received type ${typeof t}`},TypeError),Bt("ERR_OUT_OF_RANGE",function(r,t,e){let n=`The value of "${r}" is out of range.`,o=e;return Number.isInteger(e)&&Math.abs(e)>2**32?o=Ft(String(e)):typeof e=="bigint"&&(o=String(e),(e>BigInt(2)**BigInt(32)||e<-(BigInt(2)**BigInt(32)))&&(o=Ft(o)),o+="n"),n+=` It must be ${t}. Received ${o}`,n},RangeError);function Ft(r){let t="",e=r.length,n=r[0]==="-"?1:0;for(;e>=n+4;e-=3)t=`_${r.slice(e-3,e)}${t}`;return `${r.slice(0,e)}${t}`}function kr(r,t,e){et(t,"offset"),(r[t]===void 0||r[t+e]===void 0)&&it(t,r.length-(e+1));}function $t(r,t,e,n,o,c){if(r>e||r<t){let h=typeof t=="bigint"?"n":"",g;throw t===0||t===BigInt(0)?g=`>= 0${h} and < 2${h} ** ${(c+1)*8}${h}`:g=`>= -(2${h} ** ${(c+1)*8-1}${h}) and < 2 ** ${(c+1)*8-1}${h}`,new tt.ERR_OUT_OF_RANGE("value",g,r)}kr(n,o,c);}function et(r,t){if(typeof r!="number")throw new tt.ERR_INVALID_ARG_TYPE(t,"number",r)}function it(r,t,e){throw Math.floor(r)!==r?(et(r,e),new tt.ERR_OUT_OF_RANGE("offset","an integer",r)):t<0?new tt.ERR_BUFFER_OUT_OF_BOUNDS:new tt.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${t}`,r)}let vr=/[^+/0-9A-Za-z-_]/g;function Sr(r){if(r=r.split("=")[0],r=r.trim().replace(vr,""),r.length<2)return "";for(;r.length%4!==0;)r=r+"=";return r}function It(r,t){t=t||1/0;let e,n=r.length,o=null,c=[];for(let h=0;h<n;++h){if(e=r.charCodeAt(h),e>55295&&e<57344){if(!o){if(e>56319){(t-=3)>-1&&c.push(239,191,189);continue}else if(h+1===n){(t-=3)>-1&&c.push(239,191,189);continue}o=e;continue}if(e<56320){(t-=3)>-1&&c.push(239,191,189),o=e;continue}e=(o-55296<<10|e-56320)+65536;}else o&&(t-=3)>-1&&c.push(239,191,189);if(o=null,e<128){if((t-=1)<0)break;c.push(e);}else if(e<2048){if((t-=2)<0)break;c.push(e>>6|192,e&63|128);}else if(e<65536){if((t-=3)<0)break;c.push(e>>12|224,e>>6&63|128,e&63|128);}else if(e<1114112){if((t-=4)<0)break;c.push(e>>18|240,e>>12&63|128,e>>6&63|128,e&63|128);}else throw new Error("Invalid code point")}return c}function Ur(r){let t=[];for(let e=0;e<r.length;++e)t.push(r.charCodeAt(e)&255);return t}function Tr(r,t){let e,n,o,c=[];for(let h=0;h<r.length&&!((t-=2)<0);++h)e=r.charCodeAt(h),n=e>>8,o=e%256,c.push(o),c.push(n);return c}function qt(r){return a.toByteArray(Sr(r))}function at(r,t,e,n){let o;for(o=0;o<n&&!(o+e>=t.length||o>=r.length);++o)t[o+e]=r[o];return o}function G(r,t){return r instanceof t||r!=null&&r.constructor!=null&&r.constructor.name!=null&&r.constructor.name===t.name}function _t(r){return r!==r}let Cr=(function(){let r="0123456789abcdef",t=new Array(256);for(let e=0;e<16;++e){let n=e*16;for(let o=0;o<16;++o)t[n+o]=r[e]+r[o];}return t})();function J(r){return typeof BigInt=="undefined"?Rr:r}function Rr(){throw new Error("BigInt not supported")}return z}var st,sr,mt,cr,z,ur,hr=rt(()=>{A();v();k();st={},sr=false;mt={},cr=false;z={},ur=false;});var Z,Y,pr=rt(()=>{A();v();k();hr();Z=ar();Z.Buffer;Z.SlowBuffer;Z.INSPECT_MAX_BYTES;Z.kMaxLength;Y=Z.Buffer,Z.INSPECT_MAX_BYTES,Z.kMaxLength;});var v=rt(()=>{pr();});var fr=Mr((fn,St)=>{A();v();k();var Yr=Object.prototype.hasOwnProperty,O="~";function ct(){}Object.create&&(ct.prototype=Object.create(null),new ct().__proto__||(O=false));function Gr(a,s,u){this.fn=a,this.context=s,this.once=u||false;}function lr(a,s,u,l,p){if(typeof u!="function")throw new TypeError("The listener must be a function");var f=new Gr(u,l||a,p),i=O?O+s:s;return a._events[i]?a._events[i].fn?a._events[i]=[a._events[i],f]:a._events[i].push(f):(a._events[i]=f,a._eventsCount++),a}function wt(a,s){--a._eventsCount===0?a._events=new ct:delete a._events[s];}function W(){this._events=new ct,this._eventsCount=0;}W.prototype.eventNames=function(){var s=[],u,l;if(this._eventsCount===0)return s;for(l in u=this._events)Yr.call(u,l)&&s.push(O?l.slice(1):l);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(u)):s};W.prototype.listeners=function(s){var u=O?O+s:s,l=this._events[u];if(!l)return [];if(l.fn)return [l.fn];for(var p=0,f=l.length,i=new Array(f);p<f;p++)i[p]=l[p].fn;return i};W.prototype.listenerCount=function(s){var u=O?O+s:s,l=this._events[u];return l?l.fn?1:l.length:0};W.prototype.emit=function(s,u,l,p,f,i){var w=O?O+s:s;if(!this._events[w])return false;var d=this._events[w],I=arguments.length,B,m;if(d.fn){switch(d.once&&this.removeListener(s,d.fn,void 0,true),I){case 1:return d.fn.call(d.context),true;case 2:return d.fn.call(d.context,u),true;case 3:return d.fn.call(d.context,u,l),true;case 4:return d.fn.call(d.context,u,l,p),true;case 5:return d.fn.call(d.context,u,l,p,f),true;case 6:return d.fn.call(d.context,u,l,p,f,i),true}for(m=1,B=new Array(I-1);m<I;m++)B[m-1]=arguments[m];d.fn.apply(d.context,B);}else {var L=d.length,y;for(m=0;m<L;m++)switch(d[m].once&&this.removeListener(s,d[m].fn,void 0,true),I){case 1:d[m].fn.call(d[m].context);break;case 2:d[m].fn.call(d[m].context,u);break;case 3:d[m].fn.call(d[m].context,u,l);break;case 4:d[m].fn.call(d[m].context,u,l,p);break;default:if(!B)for(y=1,B=new Array(I-1);y<I;y++)B[y-1]=arguments[y];d[m].fn.apply(d[m].context,B);}}return true};W.prototype.on=function(s,u,l){return lr(this,s,u,l,false)};W.prototype.once=function(s,u,l){return lr(this,s,u,l,true)};W.prototype.removeListener=function(s,u,l,p){var f=O?O+s:s;if(!this._events[f])return this;if(!u)return wt(this,f),this;var i=this._events[f];if(i.fn)i.fn===u&&(!p||i.once)&&(!l||i.context===l)&&wt(this,f);else {for(var w=0,d=[],I=i.length;w<I;w++)(i[w].fn!==u||p&&!i[w].once||l&&i[w].context!==l)&&d.push(i[w]);d.length?this._events[f]=d.length===1?d[0]:d:wt(this,f);}return this};W.prototype.removeAllListeners=function(s){var u;return s?(u=O?O+s:s,this._events[u]&&wt(this,u)):(this._events=new ct,this._eventsCount=0),this};W.prototype.off=W.prototype.removeListener;W.prototype.addListener=W.prototype.on;W.prefixed=O;W.EventEmitter=W;typeof St!="undefined"&&(St.exports=W);});A();v();k();A();v();k();A();v();k();A();v();k();var ut=$r(fr());var Ut=class extends ut.default{constructor(u,l){super();R(this,"socket");this.socket=new window.WebSocket(u,l.protocols),this.socket.onopen=()=>this.emit("open"),this.socket.onmessage=p=>this.emit("message",p.data),this.socket.onerror=p=>this.emit("error",p),this.socket.onclose=p=>{this.emit("close",p.code,p.reason);};}send(u,l,p){let f=p||l;try{this.socket.send(u),f();}catch(i){f(i);}}close(u,l){this.socket.close(u,l);}addEventListener(u,l,p){this.socket.addEventListener(u,l,p);}};function dr(a,s){return new Ut(a,s)}A();v();k();A();v();k();var gt=class{encode(s){return JSON.stringify(s)}decode(s){return JSON.parse(s)}};var Et=class extends ut.default{constructor(u,l="ws://localhost:8080",m={},I,B){var L=m,{autoconnect:p=true,reconnect:f=true,reconnect_interval:i=1e3,max_reconnects:w=5}=L,d=lt(L,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);super();R(this,"address");R(this,"rpc_id");R(this,"queue");R(this,"options");R(this,"autoconnect");R(this,"ready");R(this,"reconnect");R(this,"reconnect_timer_id");R(this,"reconnect_interval");R(this,"max_reconnects");R(this,"rest_options");R(this,"current_reconnects");R(this,"generate_request_id");R(this,"socket");R(this,"webSocketFactory");R(this,"dataPack");this.webSocketFactory=u,this.queue={},this.rpc_id=0,this.address=l,this.autoconnect=p,this.ready=false,this.reconnect=f,this.reconnect_timer_id=void 0,this.reconnect_interval=i,this.max_reconnects=w,this.rest_options=d,this.current_reconnects=0,this.generate_request_id=I||(()=>typeof this.rpc_id=="number"?++this.rpc_id:Number(this.rpc_id)+1),B?this.dataPack=B:this.dataPack=new gt,this.autoconnect&&this._connect(this.address,ot({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options));}connect(){this.socket||this._connect(this.address,ot({autoconnect:this.autoconnect,reconnect:this.reconnect,reconnect_interval:this.reconnect_interval,max_reconnects:this.max_reconnects},this.rest_options));}call(u,l,p,f){return !f&&typeof p=="object"&&(f=p,p=null),new Promise((i,w)=>{if(!this.ready)return w(new Error("socket not ready"));let d=this.generate_request_id(u,l),I={jsonrpc:"2.0",method:u,params:l||void 0,id:d};this.socket.send(this.dataPack.encode(I),f,B=>{if(B)return w(B);this.queue[d]={promise:[i,w]},p&&(this.queue[d].timeout=setTimeout(()=>{delete this.queue[d],w(new Error("reply timeout"));},p));});})}async login(u){let l=await this.call("rpc.login",u);if(!l)throw new Error("authentication failed");return l}async listMethods(){return await this.call("__listMethods")}notify(u,l){return new Promise((p,f)=>{if(!this.ready)return f(new Error("socket not ready"));let i={jsonrpc:"2.0",method:u,params:l};this.socket.send(this.dataPack.encode(i),w=>{if(w)return f(w);p();});})}async subscribe(u){typeof u=="string"&&(u=[u]);let l=await this.call("rpc.on",u);if(typeof u=="string"&&l[u]!=="ok")throw new Error("Failed subscribing to an event '"+u+"' with: "+l[u]);return l}async unsubscribe(u){typeof u=="string"&&(u=[u]);let l=await this.call("rpc.off",u);if(typeof u=="string"&&l[u]!=="ok")throw new Error("Failed unsubscribing from an event with: "+l);return l}close(u,l){this.socket&&this.socket.close(u||1e3,l);}setAutoReconnect(u){this.reconnect=u;}setReconnectInterval(u){this.reconnect_interval=u;}setMaxReconnects(u){this.max_reconnects=u;}getCurrentReconnects(){return this.current_reconnects}getMaxReconnects(){return this.max_reconnects}isReconnecting(){return this.reconnect_timer_id!==void 0}willReconnect(){return this.reconnect&&(this.max_reconnects===0||this.current_reconnects<this.max_reconnects)}_connect(u,l){clearTimeout(this.reconnect_timer_id),this.socket=this.webSocketFactory(u,l),this.socket.addEventListener("open",()=>{this.ready=true,this.emit("open"),this.current_reconnects=0;}),this.socket.addEventListener("message",({data:p})=>{p instanceof ArrayBuffer&&(p=Y.from(p).toString());try{p=this.dataPack.decode(p);}catch(f){return}if(p.notification&&this.listeners(p.notification).length){if(!Object.keys(p.params).length)return this.emit(p.notification);let f=[p.notification];if(p.params.constructor===Object)f.push(p.params);else for(let i=0;i<p.params.length;i++)f.push(p.params[i]);return Promise.resolve().then(()=>{this.emit.apply(this,f);})}if(!this.queue[p.id])return p.method?Promise.resolve().then(()=>{this.emit(p.method,p==null?void 0:p.params);}):void 0;"error"in p=="result"in p&&this.queue[p.id].promise[1](new Error('Server response malformed. Response must include either "result" or "error", but not both.')),this.queue[p.id].timeout&&clearTimeout(this.queue[p.id].timeout),p.error?this.queue[p.id].promise[1](p.error):this.queue[p.id].promise[0](p.result),delete this.queue[p.id];}),this.socket.addEventListener("error",p=>this.emit("error",p)),this.socket.addEventListener("close",({code:p,reason:f})=>{this.ready&&setTimeout(()=>this.emit("close",p,f),0),this.ready=false,this.socket=void 0,p!==1e3&&(this.current_reconnects++,this.reconnect&&(this.max_reconnects>this.current_reconnects||this.max_reconnects===0)?this.reconnect_timer_id=setTimeout(()=>this._connect(u,l),this.reconnect_interval):this.reconnect&&this.max_reconnects>0&&this.current_reconnects>=this.max_reconnects&&setTimeout(()=>this.emit("max_reconnects_reached",p,f),1));});}};A();v();k();var Tt=class extends Et{constructor(s="ws://localhost:8080",d={},w){var I=d,{autoconnect:u=true,reconnect:l=true,reconnect_interval:p=1e3,max_reconnects:f=5}=I,i=lt(I,["autoconnect","reconnect","reconnect_interval","max_reconnects"]);super(dr,s,ot({autoconnect:u,reconnect:l,reconnect_interval:p,max_reconnects:f},i),w);}};/*! Bundled license information:
@jspm/core/nodelibs/browser/chunk-DtuTasat.js:
(*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
*/exports.Client=Tt;return exports;})({});