@linzumi/cli 1.0.269 → 1.0.270
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/impl-res/cloud-supervisor.mjs +1 -1
- package/dist/impl-res/index.js +282 -282
- package/dist/impl-ts/cloud-supervisor.mjs +1 -1
- package/dist/impl-ts/index.js +502 -502
- package/dist/impl-ts/mcp-server.mjs +3 -3
- package/dist/mcp-server.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
2
|
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var zF=Object.create;var Hm=Object.defineProperty;var JF=Object.getOwnPropertyDescriptor;var KF=Object.getOwnPropertyNames;var BF=Object.getPrototypeOf,WF=Object.prototype.hasOwnProperty;var We=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var F=(e,t)=>()=>(e&&(t=e(e=0)),t);var tt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),HF=(e,t)=>{for(var n in t)Hm(e,n,{get:t[n],enumerable:!0})},VF=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of KF(t))!WF.call(e,r)&&r!==n&&Hm(e,r,{get:()=>t[r],enumerable:!(i=JF(t,r))||i.enumerable});return e};var oa=(e,t,n)=>(n=e!=null?zF(BF(e)):{},VF(t||!e||!e.__esModule?Hm(n,"default",{value:e,enumerable:!0}):n,e));var Vm=F(()=>{});function qt(e){return e===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:e!==null&&e.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:e.BS_PRIVATE_NESTED_SOME_NONE+1|0}:e}function Iu(e){if(e!=null)return qt(e)}function He(e){if(e===null||e.BS_PRIVATE_NESTED_SOME_NONE===void 0)return e;let t=e.BS_PRIVATE_NESTED_SOME_NONE;if(t!==0)return{BS_PRIVATE_NESTED_SOME_NONE:t-1|0}}var nt=F(()=>{});function aa(e,t){if(e!==void 0)return t(He(e))}function xt(e,t){if(e!==void 0)return qt(t(He(e)))}function Mn(e,t){if(e!==void 0)return t(He(e))}function Ve(e,t){return e!==void 0?He(e):t}var Ne=F(()=>{Vm();nt()});var Ou=F(()=>{});function sn(e,t,n){return e.reduce(n,t)}var At=F(()=>{Ou();nt()});function ri(e){if(e.RE_EXN_ID==="JsExn")return qt(e._1)}var Ru,QF,Fr,jue,que,ii=F(()=>{nt();Ru=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),QF=Ru("stack"),Fr=Ru("message"),jue=Ru("name"),que=Ru("fileName")});var $u=F(()=>{});var nk=tt((Nue,tk)=>{var Ci=We("constants"),YF=process.cwd,Mu=null,XF=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Mu||(Mu=YF.call(process)),Mu};try{process.cwd()}catch{}typeof process.chdir=="function"&&(Ym=process.chdir,process.chdir=function(e){Mu=null,Ym.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,Ym));var Ym;tk.exports=eD;function eD(e){Ci.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&t(e),e.lutimes||n(e),e.chown=o(e.chown),e.fchown=o(e.fchown),e.lchown=o(e.lchown),e.chmod=i(e.chmod),e.fchmod=i(e.fchmod),e.lchmod=i(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=r(e.chmodSync),e.fchmodSync=r(e.fchmodSync),e.lchmodSync=r(e.lchmodSync),e.stat=s(e.stat),e.fstat=s(e.fstat),e.lstat=s(e.lstat),e.statSync=d(e.statSync),e.fstatSync=d(e.fstatSync),e.lstatSync=d(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(u,c,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(u,c,p,f){f&&process.nextTick(f)},e.lchownSync=function(){}),XF==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function c(p,f,h){var g=Date.now(),_=0;u(p,f,function y(b){if(b&&(b.code==="EACCES"||b.code==="EPERM"||b.code==="EBUSY")&&Date.now()-g<6e4){setTimeout(function(){e.stat(f,function(v,w){v&&v.code==="ENOENT"?u(p,f,y):h(b)})},_),_<100&&(_+=10);return}h&&h(b)})}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function c(p,f,h,g,_,y){var b;if(y&&typeof y=="function"){var v=0;b=function(w,A,C){if(w&&w.code==="EAGAIN"&&v<10)return v++,u.call(e,p,f,h,g,_,b);y.apply(this,arguments)}}return u.call(e,p,f,h,g,_,b)}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(c,p,f,h,g){for(var _=0;;)try{return u.call(e,c,p,f,h,g)}catch(y){if(y.code==="EAGAIN"&&_<10){_++;continue}throw y}}})(e.readSync);function t(u){u.lchmod=function(c,p,f){u.open(c,Ci.O_WRONLY|Ci.O_SYMLINK,p,function(h,g){if(h){f&&f(h);return}u.fchmod(g,p,function(_){u.close(g,function(y){f&&f(_||y)})})})},u.lchmodSync=function(c,p){var f=u.openSync(c,Ci.O_WRONLY|Ci.O_SYMLINK,p),h=!0,g;try{g=u.fchmodSync(f,p),h=!1}finally{if(h)try{u.closeSync(f)}catch{}else u.closeSync(f)}return g}}function n(u){Ci.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(c,p,f,h){u.open(c,Ci.O_SYMLINK,function(g,_){if(g){h&&h(g);return}u.futimes(_,p,f,function(y){u.close(_,function(b){h&&h(y||b)})})})},u.lutimesSync=function(c,p,f){var h=u.openSync(c,Ci.O_SYMLINK),g,_=!0;try{g=u.futimesSync(h,p,f),_=!1}finally{if(_)try{u.closeSync(h)}catch{}else u.closeSync(h)}return g}):u.futimes&&(u.lutimes=function(c,p,f,h){h&&process.nextTick(h)},u.lutimesSync=function(){})}function i(u){return u&&function(c,p,f){return u.call(e,c,p,function(h){l(h)&&(h=null),f&&f.apply(this,arguments)})}}function r(u){return u&&function(c,p){try{return u.call(e,c,p)}catch(f){if(!l(f))throw f}}}function o(u){return u&&function(c,p,f,h){return u.call(e,c,p,f,function(g){l(g)&&(g=null),h&&h.apply(this,arguments)})}}function a(u){return u&&function(c,p,f){try{return u.call(e,c,p,f)}catch(h){if(!l(h))throw h}}}function s(u){return u&&function(c,p,f){typeof p=="function"&&(f=p,p=null);function h(g,_){_&&(_.uid<0&&(_.uid+=4294967296),_.gid<0&&(_.gid+=4294967296)),f&&f.apply(this,arguments)}return p?u.call(e,c,p,h):u.call(e,c,h)}}function d(u){return u&&function(c,p){var f=p?u.call(e,c,p):u.call(e,c);return f&&(f.uid<0&&(f.uid+=4294967296),f.gid<0&&(f.gid+=4294967296)),f}}function l(u){if(!u||u.code==="ENOSYS")return!0;var c=!process.getuid||process.getuid()!==0;return!!(c&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var ok=tt((Fue,ik)=>{var rk=We("stream").Stream;ik.exports=tD;function tD(e){return{ReadStream:t,WriteStream:n};function t(i,r){if(!(this instanceof t))return new t(i,r);rk.call(this);var o=this;this.path=i,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,r=r||{};for(var a=Object.keys(r),s=0,d=a.length;s<d;s++){var l=a[s];this[l]=r[l]}if(this.encoding&&this.setEncoding(this.encoding),this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.end===void 0)this.end=1/0;else if(typeof this.end!="number")throw TypeError("end must be a Number");if(this.start>this.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){o._read()});return}e.open(this.path,this.flags,this.mode,function(u,c){if(u){o.emit("error",u),o.readable=!1;return}o.fd=c,o.emit("open",c),o._read()})}function n(i,r){if(!(this instanceof n))return new n(i,r);rk.call(this),this.path=i,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,r=r||{};for(var o=Object.keys(r),a=0,s=o.length;a<s;a++){var d=o[a];this[d]=r[d]}if(this.start!==void 0){if(typeof this.start!="number")throw TypeError("start must be a Number");if(this.start<0)throw new Error("start must be >= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var sk=tt((Due,ak)=>{"use strict";ak.exports=rD;var nD=Object.getPrototypeOf||function(e){return e.__proto__};function rD(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:nD(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var nh=tt((Lue,th)=>{var St=We("fs"),iD=nk(),oD=ok(),aD=sk(),ju=We("util"),Qt,Nu;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Qt=Symbol.for("graceful-fs.queue"),Nu=Symbol.for("graceful-fs.previous")):(Qt="___graceful-fs.queue",Nu="___graceful-fs.previous");function sD(){}function uk(e,t){Object.defineProperty(e,Qt,{get:function(){return t}})}var ao=sD;ju.debuglog?ao=ju.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(ao=function(){var e=ju.format.apply(ju,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
4
|
-
GFS4: `),console.error(e)});St[Qt]||(dk=global[Qt]||[],uk(St,dk),St.close=(function(e){function t(n,i){return e.call(St,n,function(r){r||lk(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Nu,{value:e}),t})(St.close),St.closeSync=(function(e){function t(n){e.apply(St,arguments),lk()}return Object.defineProperty(t,Nu,{value:e}),t})(St.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ao(St[Qt]),We("assert").equal(St[Qt].length,0)}));var dk;global[Qt]||uk(global,St[Qt]);th.exports=Xm(aD(St));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!St.__patched&&(th.exports=Xm(St),St.__patched=!0);function Xm(e){iD(e),e.gracefulify=Xm,e.createReadStream=A,e.createWriteStream=C;var t=e.readFile;e.readFile=n;function n(T,E,P){return typeof E=="function"&&(P=E,E=null),R(T,E,P);function R(O,M,J,Z){return t(O,M,function(z){z&&(z.code==="EMFILE"||z.code==="ENFILE")?sa([R,[O,M,J],z,Z||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var i=e.writeFile;e.writeFile=r;function r(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return i(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return o(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(T,E,P,R){return typeof P=="function"&&(R=P,P=0),O(T,E,P,R);function O(M,J,Z,z,X){return s(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(T,E,P){typeof E=="function"&&(P=E,E=null);var R=u.test(process.version)?function(J,Z,z,X){return l(J,O(J,Z,z,X))}:function(J,Z,z,X){return l(J,Z,O(J,Z,z,X))};return R(T,E,P);function O(M,J,Z,z){return function(X,ee){X&&(X.code==="EMFILE"||X.code==="ENFILE")?sa([R,[M,J,Z],X,z||Date.now(),Date.now()]):(ee&&ee.sort&&ee.sort(),typeof Z=="function"&&Z.call(this,X,ee))}}}if(process.version.substr(0,4)==="v0.8"){var p=oD(e);y=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=b);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(e,"FileReadStream",{get:function(){return g},set:function(T){g=T},enumerable:!0,configurable:!0});var _=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(T){_=T},enumerable:!0,configurable:!0});function y(T,E){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function b(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.autoClose&&T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P),T.read())})}function v(T,E){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function w(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P))})}function A(T,E){return new e.ReadStream(T,E)}function C(T,E){return new e.WriteStream(T,E)}var S=e.open;e.open=k;function k(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return S(M,J,Z,function(ee,B){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}return e}function sa(e){ao("ENQUEUE",e[0].name,e[1]),St[Qt].push(e),eh()}var qu;function lk(){for(var e=Date.now(),t=0;t<St[Qt].length;++t)St[Qt][t].length>2&&(St[Qt][t][3]=e,St[Qt][t][4]=e);eh()}function eh(){if(clearTimeout(qu),qu=void 0,St[Qt].length!==0){var e=St[Qt].shift(),t=e[0],n=e[1],i=e[2],r=e[3],o=e[4];if(r===void 0)ao("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){ao("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,i)}else{var s=Date.now()-o,d=Math.max(o-r,1),l=Math.min(d*1.2,100);s>=l?(ao("RETRY",t.name,n),t.apply(null,n.concat([r]))):St[Qt].push(e)}qu===void 0&&(qu=setTimeout(eh,0))}}});var fk=tt((Uue,ck)=>{function Vn(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}ck.exports=Vn;Vn.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Vn.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Vn.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var i=this,r=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n);return this._options.unref&&r.unref(),!0};Vn.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Vn.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Vn.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Vn.prototype.start=Vn.prototype.try;Vn.prototype.errors=function(){return this._errors};Vn.prototype.attempts=function(){return this._attempts};Vn.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],o=r.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=r,n=a)}return t}});var pk=tt(so=>{var dD=fk();so.operation=function(e){var t=so.timeouts(e);return new dD(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};so.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],r=0;r<t.retries;r++)i.push(this.createTimeout(r,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(r,t)),i.sort(function(o,a){return o-a}),i};so.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout),i};so.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var i in e)typeof e[i]=="function"&&n.push(i)}for(var r=0;r<n.length;r++){var o=n[r],a=e[o];e[o]=function(d){var l=so.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var hk=tt((zue,mk)=>{mk.exports=pk()});var gk=tt((Jue,Fu)=>{Fu.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Fu.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Sk=tt((Kue,ua)=>{var ft=global.process,lo=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};lo(ft)?(yk=We("assert"),da=gk(),_k=/^win/i.test(ft.platform),Vs=We("events"),typeof Vs!="function"&&(Vs=Vs.EventEmitter),ft.__signal_exit_emitter__?zt=ft.__signal_exit_emitter__:(zt=ft.__signal_exit_emitter__=new Vs,zt.count=0,zt.emitted={}),zt.infinite||(zt.setMaxListeners(1/0),zt.infinite=!0),ua.exports=function(e,t){if(!lo(global.process))return function(){};yk.equal(typeof e,"function","a callback must be provided for exit handler"),la===!1&&rh();var n="exit";t&&t.alwaysLast&&(n="afterexit");var i=function(){zt.removeListener(n,e),zt.listeners("exit").length===0&&zt.listeners("afterexit").length===0&&Du()};return zt.on(n,e),i},Du=function(){!la||!lo(global.process)||(la=!1,da.forEach(function(t){try{ft.removeListener(t,Lu[t])}catch{}}),ft.emit=Uu,ft.reallyExit=ih,zt.count-=1)},ua.exports.unload=Du,uo=function(t,n,i){zt.emitted[t]||(zt.emitted[t]=!0,zt.emit(t,n,i))},Lu={},da.forEach(function(e){Lu[e]=function(){if(lo(global.process)){var n=ft.listeners(e);n.length===zt.count&&(Du(),uo("exit",null,e),uo("afterexit",null,e),_k&&e==="SIGHUP"&&(e="SIGINT"),ft.kill(ft.pid,e))}}}),ua.exports.signals=function(){return da},la=!1,rh=function(){la||!lo(global.process)||(la=!0,zt.count+=1,da=da.filter(function(t){try{return ft.on(t,Lu[t]),!0}catch{return!1}}),ft.emit=vk,ft.reallyExit=bk)},ua.exports.load=rh,ih=ft.reallyExit,bk=function(t){lo(global.process)&&(ft.exitCode=t||0,uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),ih.call(ft,ft.exitCode))},Uu=ft.emit,vk=function(t,n){if(t==="exit"&&lo(global.process)){n!==void 0&&(ft.exitCode=n);var i=Uu.apply(this,arguments);return uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),i}else return Uu.apply(this,arguments)}):ua.exports=function(){return function(){}};var yk,da,_k,Vs,zt,Du,uo,Lu,la,rh,ih,bk,Uu,vk});var Ck=tt((Bue,Zs)=>{"use strict";var lD=We("path"),sh=nh(),uD=hk(),cD=Sk(),oi={};function ca(e,t){return t.lockfilePath||`${e}.lock`}function dh(e,t,n){if(!t.realpath)return n(null,lD.resolve(e));t.fs.realpath(e,n)}function oh(e,t,n){t.fs.mkdir(ca(e,t),i=>{if(!i)return n();if(i.code!=="EEXIST")return n(i);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(ca(e,t),(r,o)=>{if(r)return r.code==="ENOENT"?oh(e,{...t,stale:0},n):n(r);if(!kk(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));xk(e,t,a=>{if(a)return n(a);oh(e,{...t,stale:0},n)})})})}function kk(e,t){return e.mtime.getTime()<Date.now()-t.stale}function xk(e,t,n){t.fs.rmdir(ca(e,t),i=>{if(i&&i.code!=="ENOENT")return n(i);n()})}function ah(e,t){let n=oi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let i=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(ca(e,t),i,i,r=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return wk(e,n,o)}if(r)return r.code==="ENOENT"?wk(e,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateError=r,n.updateDelay=1e3,ah(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,ah(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function wk(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),oi[e]===t&&delete oi[e],t.options.onCompromised(n)}function fD(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:sh,onCompromised:i=>{throw i},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),dh(e,t,(i,r)=>{if(i)return n(i);let o=uD.operation(t.retries);o.attempt(()=>{oh(r,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=oi[r]={options:t,lastUpdate:Date.now()};ah(r,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Tk(r,{...t,realpath:!1},d)})})})})}function Tk(e,t,n){t={fs:sh,realpath:!0,...t},dh(e,t,(i,r)=>{if(i)return n(i);let o=oi[r];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete oi[r],xk(r,t,n)})}function pD(e,t,n){t={stale:1e4,realpath:!0,fs:sh,...t},t.stale=Math.max(t.stale||0,2e3),dh(e,t,(i,r)=>{if(i)return n(i);t.fs.stat(ca(r,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!kk(a,t)))})}function mD(){return oi}cD(()=>{for(let e in oi){let t=oi[e].options;try{t.fs.rmdirSync(ca(e,t))}catch{}}});Zs.exports.lock=fD;Zs.exports.unlock=Tk;Zs.exports.check=pD;Zs.exports.getLocks=mD});var Ek=tt((Wue,Ak)=>{"use strict";var hD=nh();function gD(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(i=>{n[i]=(...r)=>{let o=r.pop(),a;try{a=e[`${i}Sync`](...r)}catch(s){return o(s)}o(null,a)}}),n}function yD(e){return(...t)=>new Promise((n,i)=>{t.push((r,o)=>{r?i(r):n(o)}),e(...t)})}function _D(e){return(...t)=>{let n,i;if(t.push((r,o)=>{n=r,i=o}),e(...t),n)throw n;return i}}function bD(e){if(e={...e},e.fs=gD(e.fs||hD),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Ak.exports={toPromise:yD,toSync:_D,toSyncOptions:bD}});var Ik=tt((Hue,Ai)=>{"use strict";var fa=Ck(),{toPromise:Gu,toSync:zu,toSyncOptions:lh}=Ek();async function Pk(e,t){let n=await Gu(fa.lock)(e,t);return Gu(n)}function vD(e,t){let n=zu(fa.lock)(e,lh(t));return zu(n)}function SD(e,t){return Gu(fa.unlock)(e,t)}function wD(e,t){return zu(fa.unlock)(e,lh(t))}function kD(e,t){return Gu(fa.check)(e,t)}function xD(e,t){return zu(fa.check)(e,lh(t))}Ai.exports=Pk;Ai.exports.lock=Pk;Ai.exports.unlock=SD;Ai.exports.lockSync=vD;Ai.exports.unlockSync=wD;Ai.exports.check=kD;Ai.exports.checkSync=xD});var Ok=F(()=>{});var Rk=F(()=>{});var Ju=F(()=>{});var Yt=F(()=>{Ok();Rk();Ju()});function AD(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Jt(e){return AD(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function fh(e){let t=ch[e];if(t!==void 0){let n=t+1|0;return ch[e]=n,e+("/"+n)}return ch[e]=1,e}var ch,Xt=F(()=>{ch={}});import*as jk from"node:child_process";function pa(e){let t=ri(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=He(t);return{code:Iu(n.code),message:Ve(Fr(n),"unknown error")}}function qk(e,t,n,i){try{return{TAG:"Ok",_0:jk.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:i})}}catch(r){let o=Jt(r);return{TAG:"Error",_0:pa(o)}}}var ED,Kt=F(()=>{ii();Ne();$u();ED=oa(Ik(),1);Yt();nt();Xt()});function Fk(e){let t=qk(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=Nk.exec(t._0);if(n!=null)return Mn(n.slice(1)[0],i=>i)}function Dk(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var Nk,Lk=F(()=>{At();Kt();Ne();Yt();Nk=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function ID(e,t){let n=Dk(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function Uk(e,t){return ID(Fk(e),t)}var Gk=F(()=>{Ne();Lk()});var zk,ph=F(()=>{Gk();zk=Uk});var Kk,Jk=F(()=>{Kk={name:"@linzumi/cli",version:"1.0.269",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts"],scripts:{"test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts test/llmProxySessionCredential.test.ts test/runnerBridge.test.ts test/threadCodexWorkerIpc.test.ts -t '(?:^| )(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup|does not install an old mint after its credential is (replaced|stopped)|worker agent capability requires an exact true ready flag|starts an explicitly server-keyed OpenAI agent worker without local OpenAI credentials|applies the accepted OpenAI follow-up model on an existing worker|refuses explicit OpenAI worker creation with (passthrough|missing-token|blank-origin) binding|refuses a private agent turn without an owned relay before Codex|explicitly capable worker receives a private request through ordinary IPC|old worker receives no private agent source descriptor)$'",build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","test:actual-commander-parity":"pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs","bump-version":"node scripts/bump-cli-version.mjs","codex:history-table":"node scripts/codex_history_table.mjs",test:"npm run test:startup && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","record:agent-fixtures":"tsx scripts/record-agent-replay-fixtures.ts","normalize:agent-fixture":"tsx scripts/normalize-agent-replay-fixture.ts","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","replay:agent-fixture":"tsx scripts/replay-agent-fixture.ts","replay:agent-backend":"tsx scripts/replay-agent-backend.ts","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check","replay:agent-backend-browser":"tsx scripts/replay-agent-backend-browser.ts","promote:gstack-claude-smoke-fixture":"tsx scripts/promote-gstack-claude-smoke-fixture.ts","diagnose:claude-probe":"tsx scripts/diagnose-claude-probe.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.199","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.153.2",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var mh,Wu=F(()=>{"use strict";Jk();mh=Kk.dependencies["@openai/codex"]});async function Bk(e,t,n){let i;try{e(),i=!0}catch{i=!1}let r;try{await t(),r=!0}catch{r=!1}return i&&r?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function Wk(e,t){let n=e.quotaWindow,i=e.credits;if(n===void 0&&i===void 0)return{status:"unavailable",reason:"empty_response"};let r=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:r[0],windowMinutes:r[1],resetsAtMs:r[2],capturedAtMs:t,credits:i}}}var Hk=F(()=>{});var Vk,Zk,Qk=F(()=>{Hk();Vk=Bk,Zk=Wk});function Ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hh(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Et=F(()=>{"use strict"});var Hu=F(()=>{"use strict";Et()});function tx(e){let t=Dr(e.rateLimits)??Dr(e.rate_limits)??Dr(e.limits)??e,n=[t,...Object.values(t).flatMap(_=>{let y=Dr(_);return y===void 0?[]:[y]})],i=n.reduce((_,y)=>{let b=Fe(y.usedPercent)??Fe(y.used_percent);return b===void 0?_:_===void 0?b:Math.max(_,b)},void 0),o=n.some(_=>Fe(_.remaining)===0||Fe(_.remainingRequests)===0||Fe(_.remaining_requests)===0||Fe(_.remainingTokens)===0||Fe(_.remaining_tokens)===0||Fe(_.retryAfterSeconds)!==void 0||Fe(_.retry_after_seconds)!==void 0)?"rejected":i!==void 0&&i>=80?"allowed_warning":"allowed",a=Dr(t.primary),s=Fe(a?.usedPercent),d=Fe(a?.windowDurationMins),l=Fe(a?.resetsAt),u=Dr(t.credits),c=ex(u?.hasCredits),p=ex(u?.unlimited),f=u?.balance,h=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof f=="string"?f:null},g=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:jD(e)??"seen (no details)",status:o,utilizationPercent:i,...g===void 0?{}:{quotaWindow:g},...h===void 0?{}:{credits:h}}}function jD(e){let t=Dr(e.rateLimits)??Dr(e.rate_limits)??Dr(e.limits)??e,n=Yk(t,void 0),i=Object.entries(t).flatMap(([o,a])=>{let s=Dr(a);return s===void 0?[]:[Yk(s,o)]}),r=[n,...i].filter(o=>o!==void 0);return r.length===0?void 0:r.join(" | ")}function Yk(e,t){let n=gr(e.limitName)??gr(e.limit_name)??gr(e.name)??gr(e.type)??t,i=gr(e.planType)??gr(e.plan_type)??gr(e.plan),r=Fe(e.remaining)??Fe(e.remainingRequests)??Fe(e.remaining_requests)??Fe(e.remainingTokens)??Fe(e.remaining_tokens),o=Fe(e.limit)??Fe(e.requestLimit)??Fe(e.request_limit)??Fe(e.limitRequests)??Fe(e.limit_requests)??Fe(e.tokenLimit)??Fe(e.token_limit)??Fe(e.limitTokens)??Fe(e.limit_tokens),a=gr(e.resetAt)??gr(e.reset_at)??gr(e.resetsAt)??gr(e.resets_at)??Xk(e.resetsAt)??Xk(e.resets_at)??Vu(e.resetAfterSeconds)??Vu(e.reset_after_seconds)??Vu(e.retryAfterSeconds)??Vu(e.retry_after_seconds),s=Fe(e.usedPercent)??Fe(e.used_percent),d=Fe(e.windowDurationMins)??Fe(e.window_duration_mins),l=[n,i].filter(f=>f!==void 0).join(" "),u=l===""?void 0:l,p=[r===void 0?void 0:o===void 0?`${r} remaining`:`${r}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(f=>f!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Vu(e){let t=Fe(e);return t===void 0?void 0:`${t}s`}function Xk(e){let t=Fe(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function Dr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function gr(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function ex(e){return typeof e=="boolean"?e:void 0}function Fe(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var nx=F(()=>{"use strict";Hu();Et()});var ai=tt((fce,ox)=>{"use strict";var rx=["nodebuffer","arraybuffer","fragments"],ix=typeof Blob<"u";ix&&rx.push("blob");ox.exports={BINARY_TYPES:rx,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ix,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Qs=tt((pce,Zu)=>{"use strict";var{EMPTY_BUFFER:qD}=ai(),gh=Buffer[Symbol.species];function ND(e,t){if(e.length===0)return qD;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),i=0;for(let r=0;r<e.length;r++){let o=e[r];n.set(o,i),i+=o.length}return i<t?new gh(n.buffer,n.byteOffset,i):n}function ax(e,t,n,i,r){for(let o=0;o<r;o++)n[i+o]=e[o]^t[o&3]}function sx(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function FD(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function yh(e){if(yh.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new gh(e):ArrayBuffer.isView(e)?t=new gh(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),yh.readOnly=!1),t}Zu.exports={concat:ND,mask:ax,toArrayBuffer:FD,toBuffer:yh,unmask:sx};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=We("bufferutil");Zu.exports.mask=function(t,n,i,r,o){o<48?ax(t,n,i,r,o):e.mask(t,n,i,r,o)},Zu.exports.unmask=function(t,n){t.length<32?sx(t,n):e.unmask(t,n)}}catch{}});var ux=tt((mce,lx)=>{"use strict";var dx=Symbol("kDone"),_h=Symbol("kRun"),bh=class{constructor(t){this[dx]=()=>{this.pending--,this[_h]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[_h]()}[_h](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[dx])}}};lx.exports=bh});var Xs=tt((hce,mx)=>{"use strict";var Ys=We("zlib"),cx=Qs(),DD=ux(),{kStatusCode:fx}=ai(),LD=Buffer[Symbol.species],UD=Buffer.from([0,0,255,255]),Yu=Symbol("permessage-deflate"),si=Symbol("total-length"),ha=Symbol("callback"),Ei=Symbol("buffers"),ga=Symbol("error"),Qu,vh=class{constructor(t,n,i){if(this._maxPayload=i|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Qu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Qu=new DD(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[ha];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,i=t.find(r=>!(n.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>r.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(i=>{let r=n[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);n[i]=r})}),t}decompress(t,n,i){Qu.add(r=>{this._decompress(t,n,(o,a)=>{r(),i(o,a)})})}compress(t,n,i){Qu.add(r=>{this._compress(t,n,(o,a)=>{r(),i(o,a)})})}_decompress(t,n,i){let r=this._isServer?"client":"server";if(!this._inflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Ys.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Ys.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Yu]=this,this._inflate[si]=0,this._inflate[Ei]=[],this._inflate.on("error",zD),this._inflate.on("data",px)}this._inflate[ha]=i,this._inflate.write(t),n&&this._inflate.write(UD),this._inflate.flush(()=>{let o=this._inflate[ga];if(o){this._inflate.close(),this._inflate=null,i(o);return}let a=cx.concat(this._inflate[Ei],this._inflate[si]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[si]=0,this._inflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,a)})}_compress(t,n,i){let r=this._isServer?"server":"client";if(!this._deflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Ys.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Ys.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[si]=0,this._deflate[Ei]=[],this._deflate.on("data",GD)}this._deflate[ha]=i,this._deflate.write(t),this._deflate.flush(Ys.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=cx.concat(this._deflate[Ei],this._deflate[si]);n&&(o=new LD(o.buffer,o.byteOffset,o.length-4)),this._deflate[ha]=null,this._deflate[si]=0,this._deflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,o)})}};mx.exports=vh;function GD(e){this[Ei].push(e),this[si]+=e.length}function px(e){if(this[si]+=e.length,this[Yu]._maxPayload<1||this[si]<=this[Yu]._maxPayload){this[Ei].push(e);return}this[ga]=new RangeError("Max payload size exceeded"),this[ga].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ga][fx]=1009,this.removeListener("data",px),this.reset()}function zD(e){if(this[Yu]._inflate=null,this[ga]){this[ha](this[ga]);return}e[fx]=1007,this[ha](e)}});var ya=tt((gce,Xu)=>{"use strict";var{isUtf8:hx}=We("buffer"),{hasBlob:JD}=ai(),KD=[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 BD(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Sh(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function WD(e){return JD&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Xu.exports={isBlob:WD,isValidStatusCode:BD,isValidUTF8:Sh,tokenChars:KD};if(hx)Xu.exports.isValidUTF8=function(e){return e.length<24?Sh(e):hx(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=We("utf-8-validate");Xu.exports.isValidUTF8=function(t){return t.length<32?Sh(t):e(t)}}catch{}});var Ch=tt((yce,wx)=>{"use strict";var{Writable:HD}=We("stream"),gx=Xs(),{BINARY_TYPES:VD,EMPTY_BUFFER:yx,kStatusCode:ZD,kWebSocket:QD}=ai(),{concat:wh,toArrayBuffer:YD,unmask:XD}=Qs(),{isValidStatusCode:eL,isValidUTF8:_x}=ya(),ec=Buffer[Symbol.species],Zn=0,bx=1,vx=2,Sx=3,kh=4,xh=5,tc=6,Th=class extends HD{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||VD[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[QD]=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=Zn}_write(t,n,i){if(this._opcode===8&&this._state==Zn)return i();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(i)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t),new ec(i.buffer,i.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let i=this._buffers[0],r=n.length-t;t>=i.length?n.set(this._buffers.shift(),r):(n.set(new Uint8Array(i.buffer,i.byteOffset,t),r),this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t)),t-=i.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Zn:this.getInfo(t);break;case bx:this.getPayloadLength16(t);break;case vx:this.getPayloadLength64(t);break;case Sx:this.getMask();break;case kh:this.getData(t);break;case xh:case tc:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(r);return}let i=(n[0]&64)===64;if(i&&!this._extensions[gx.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(r);return}this._payloadLength===126?this._state=bx:this._payloadLength===127?this._state=vx: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 n=this.consume(8),i=n.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(r);return}this._payloadLength=i*Math.pow(2,32)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=Sx:this._state=kh}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=kh}getData(t){let n=yx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&XD(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=xh,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[gx.extensionName].decompress(t,this._fin,(r,o)=>{if(r)return n(r);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===Zn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Zn;return}let n=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=wh(i,n):this._binaryType==="arraybuffer"?r=YD(wh(i,n)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!0),this._state=Zn,this.startLoop(t)}))}else{let r=wh(i,n);if(!this._skipUTF8Validation&&!_x(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===xh||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!1),this._state=Zn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,yx),this.end();else{let i=t.readUInt16BE(0);if(!eL(i)){let o=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let r=new ec(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!_x(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=Zn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn,this.startLoop(n)}))}createError(t,n,i,r,o){this._loop=!1,this._errored=!0;let a=new t(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[ZD]=r,a}};wx.exports=Th});var Ph=tt((bce,Tx)=>{"use strict";var{Duplex:_ce}=We("stream"),{randomFillSync:tL}=We("crypto"),kx=Xs(),{EMPTY_BUFFER:nL,kWebSocket:rL,NOOP:iL}=ai(),{isBlob:_a,isValidStatusCode:oL}=ya(),{mask:xx,toBuffer:co}=Qs(),Qn=Symbol("kByteLength"),aL=Buffer.alloc(4),nc=8*1024,fo,ba=nc,yr=0,sL=1,dL=2,Ah=class e{constructor(t,n,i){this._extensions=n||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=yr,this.onerror=iL,this[rL]=void 0}static frame(t,n){let i,r=!1,o=2,a=!1;n.mask&&(i=n.maskBuffer||aL,n.generateMask?n.generateMask(i):(ba===nc&&(fo===void 0&&(fo=Buffer.alloc(nc)),tL(fo,0,nc),ba=0),i[0]=fo[ba++],i[1]=fo[ba++],i[2]=fo[ba++],i[3]=fo[ba++]),a=(i[0]|i[1]|i[2]|i[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[Qn]!==void 0?s=n[Qn]:(t=Buffer.from(t),s=t.length):(s=t.length,r=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(r?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=i[0],l[o-3]=i[1],l[o-2]=i[2],l[o-1]=i[3],a?[l,t]:r?(xx(t,i,l,o,s),[l]):(xx(t,i,t,0,s),[l,t])):[l,t]}close(t,n,i,r){let o;if(t===void 0)o=nL;else{if(typeof t!="number"||!oL(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[Qn]:o.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yr?this.enqueue([this.dispatch,o,!1,a,r]):this.sendFrame(e.frame(o,a),r)}ping(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}pong(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}send(t,n,i){let r=this._extensions[kx.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):_a(t)?(s=t.size,d=!1):(t=co(t),s=t.length,d=co.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=r._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[Qn]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,this._compress,l,i]):this.getBlobData(t,this._compress,l,i):this._state!==yr?this.enqueue([this.dispatch,t,this._compress,l,i]):this.dispatch(t,this._compress,l,i)}getBlobData(t,n,i,r){this._bufferedBytes+=i[Qn],this._state=dL,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(Eh,this,s,r);return}this._bufferedBytes-=i[Qn];let a=co(o);n?this.dispatch(a,n,i,r):(this._state=yr,this.sendFrame(e.frame(a,i),r),this.dequeue())}).catch(o=>{process.nextTick(lL,this,o,r)})}dispatch(t,n,i,r){if(!n){this.sendFrame(e.frame(t,i),r);return}let o=this._extensions[kx.extensionName];this._bufferedBytes+=i[Qn],this._state=sL,o.compress(t,i.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Eh(this,d,r);return}this._bufferedBytes-=i[Qn],this._state=yr,i.readOnly=!1,this.sendFrame(e.frame(s,i),r),this.dequeue()})}dequeue(){for(;this._state===yr&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Qn],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Qn],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};Tx.exports=Ah;function Eh(e,t,n){typeof n=="function"&&n(t);for(let i=0;i<e._queue.length;i++){let r=e._queue[i],o=r[r.length-1];typeof o=="function"&&o(t)}}function lL(e,t,n){Eh(e,t,n),e.onerror(t)}});var Mx=tt((vce,$x)=>{"use strict";var{kForOnEventAttribute:ed,kListener:Ih}=ai(),Cx=Symbol("kCode"),Ax=Symbol("kData"),Ex=Symbol("kError"),Px=Symbol("kMessage"),Ix=Symbol("kReason"),va=Symbol("kTarget"),Ox=Symbol("kType"),Rx=Symbol("kWasClean"),di=class{constructor(t){this[va]=null,this[Ox]=t}get target(){return this[va]}get type(){return this[Ox]}};Object.defineProperty(di.prototype,"target",{enumerable:!0});Object.defineProperty(di.prototype,"type",{enumerable:!0});var po=class extends di{constructor(t,n={}){super(t),this[Cx]=n.code===void 0?0:n.code,this[Ix]=n.reason===void 0?"":n.reason,this[Rx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[Cx]}get reason(){return this[Ix]}get wasClean(){return this[Rx]}};Object.defineProperty(po.prototype,"code",{enumerable:!0});Object.defineProperty(po.prototype,"reason",{enumerable:!0});Object.defineProperty(po.prototype,"wasClean",{enumerable:!0});var Sa=class extends di{constructor(t,n={}){super(t),this[Ex]=n.error===void 0?null:n.error,this[Px]=n.message===void 0?"":n.message}get error(){return this[Ex]}get message(){return this[Px]}};Object.defineProperty(Sa.prototype,"error",{enumerable:!0});Object.defineProperty(Sa.prototype,"message",{enumerable:!0});var td=class extends di{constructor(t,n={}){super(t),this[Ax]=n.data===void 0?null:n.data}get data(){return this[Ax]}};Object.defineProperty(td.prototype,"data",{enumerable:!0});var uL={addEventListener(e,t,n={}){for(let r of this.listeners(e))if(!n[ed]&&r[Ih]===t&&!r[ed])return;let i;if(e==="message")i=function(o,a){let s=new td("message",{data:a?o:o.toString()});s[va]=this,rc(t,this,s)};else if(e==="close")i=function(o,a){let s=new po("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[va]=this,rc(t,this,s)};else if(e==="error")i=function(o){let a=new Sa("error",{error:o,message:o.message});a[va]=this,rc(t,this,a)};else if(e==="open")i=function(){let o=new di("open");o[va]=this,rc(t,this,o)};else return;i[ed]=!!n[ed],i[Ih]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Ih]===t&&!n[ed]){this.removeListener(e,n);break}}};$x.exports={CloseEvent:po,ErrorEvent:Sa,Event:di,EventTarget:uL,MessageEvent:td};function rc(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var Oh=tt((Sce,jx)=>{"use strict";var{tokenChars:nd}=ya();function Lr(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function cL(e){let t=Object.create(null),n=Object.create(null),i=!1,r=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);l===44?(Lr(t,f,n),n=Object.create(null)):a=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),Lr(n,e.slice(d,u),!0),l===44&&(Lr(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(r){if(nd[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:i||(i=!0),r=!1}else if(o)if(nd[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);i&&(f=f.replace(/\\/g,""),i=!1),Lr(n,s,f),l===44&&(Lr(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?Lr(t,p,n):(s===void 0?Lr(n,p,!0):i?Lr(n,s,p.replace(/\\/g,"")):Lr(n,s,p),Lr(t,a,n)),t}function fL(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(i=>[t].concat(Object.keys(i).map(r=>{let o=i[r];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?r:`${r}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jx.exports={format:fL,parse:cL}});var sc=tt((xce,Wx)=>{"use strict";var pL=We("events"),mL=We("https"),hL=We("http"),Fx=We("net"),gL=We("tls"),{randomBytes:yL,createHash:_L}=We("crypto"),{Duplex:wce,Readable:kce}=We("stream"),{URL:Rh}=We("url"),Pi=Xs(),bL=Ch(),vL=Ph(),{isBlob:SL}=ya(),{BINARY_TYPES:qx,EMPTY_BUFFER:ic,GUID:wL,kForOnEventAttribute:$h,kListener:kL,kStatusCode:xL,kWebSocket:Bt,NOOP:Dx}=ai(),{EventTarget:{addEventListener:TL,removeEventListener:CL}}=Mx(),{format:AL,parse:EL}=Oh(),{toBuffer:PL}=Qs(),IL=30*1e3,Lx=Symbol("kAborted"),Mh=[8,13],li=["CONNECTING","OPEN","CLOSING","CLOSED"],OL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pt=class e extends pL{constructor(t,n,i){super(),this._binaryType=qx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ic,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,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),Ux(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){qx.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,n,i){let r=new bL({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),o=new vL(t,this._extensions,i.generateMask);this._receiver=r,this._sender=o,this._socket=t,r[Bt]=this,o[Bt]=this,t[Bt]=this,r.on("conclude",ML),r.on("drain",jL),r.on("error",qL),r.on("message",NL),r.on("ping",FL),r.on("pong",DL),o.onerror=LL,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Jx),t.on("data",ac),t.on("end",Kx),t.on("error",Bx),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[Pi.extensionName]&&this._extensions[Pi.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(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,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),zx(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||ic,n,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||ic,n,i)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}let r={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[Pi.extensionName]||(r.compress=!1),this._sender.send(t||ic,r,i)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(pt,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt.prototype,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt.prototype,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt.prototype,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});Object.defineProperty(pt.prototype,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(pt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(pt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[$h])return t[kL];return null},set(t){for(let n of this.listeners(e))if(n[$h]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[$h]:!0})}})});pt.prototype.addEventListener=TL;pt.prototype.removeEventListener=CL;Wx.exports=pt;function Ux(e,t,n,i){let r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Mh[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,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=r.autoPong,!Mh.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${Mh.join(", ")})`);let o;if(t instanceof Rh)o=t;else try{o=new Rh(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let g=new SyntaxError(d);if(e._redirects===0)throw g;oc(e,g);return}let l=a?443:80,u=yL(16).toString("base64"),c=a?mL.request:hL.request,p=new Set,f;if(r.createConnection=r.createConnection||(a?$L:RL),r.defaultPort=r.defaultPort||l,r.port=o.port||l,r.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=o.pathname+o.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(f=new Pi(r.perMessageDeflate!==!0?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=AL({[Pi.extensionName]:f.offer()})),n.length){for(let g of n){if(typeof g!="string"||!OL.test(g)||p.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(g)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(o.username||o.password)&&(r.auth=`${o.username}:${o.password}`),s){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let h;if(r.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?r.socketPath:o.host;let g=i&&i.headers;if(i={...i,headers:{}},g)for(let[_,y]of Object.entries(g))i.headers[_.toLowerCase()]=y}else if(e.listenerCount("redirect")===0){let g=s?e._originalIpc?r.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!g||e._originalSecure&&!a)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),h=e._req=c(r),e._redirects&&e.emit("redirect",e.url,h)}else h=e._req=c(r);r.timeout&&h.on("timeout",()=>{qn(e,h,"Opening handshake has timed out")}),h.on("error",g=>{h===null||h[Lx]||(h=e._req=null,oc(e,g))}),h.on("response",g=>{let _=g.headers.location,y=g.statusCode;if(_&&r.followRedirects&&y>=300&&y<400){if(++e._redirects>r.maxRedirects){qn(e,h,"Maximum redirects exceeded");return}h.abort();let b;try{b=new Rh(_,t)}catch{let w=new SyntaxError(`Invalid URL: ${_}`);oc(e,w);return}Ux(e,b,n,i)}else e.emit("unexpected-response",h,g)||qn(e,h,`Unexpected server response: ${g.statusCode}`)}),h.on("upgrade",(g,_,y)=>{if(e.emit("upgrade",g),e.readyState!==pt.CONNECTING)return;h=e._req=null;let b=g.headers.upgrade;if(b===void 0||b.toLowerCase()!=="websocket"){qn(e,_,"Invalid Upgrade header");return}let v=_L("sha1").update(u+wL).digest("base64");if(g.headers["sec-websocket-accept"]!==v){qn(e,_,"Invalid Sec-WebSocket-Accept header");return}let w=g.headers["sec-websocket-protocol"],A;if(w!==void 0?p.size?p.has(w)||(A="Server sent an invalid subprotocol"):A="Server sent a subprotocol but none was requested":p.size&&(A="Server sent no subprotocol"),A){qn(e,_,A);return}w&&(e._protocol=w);let C=g.headers["sec-websocket-extensions"];if(C!==void 0){if(!f){qn(e,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let S;try{S=EL(C)}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(S);if(k.length!==1||k[0]!==Pi.extensionName){qn(e,_,"Server indicated an extension that was not requested");return}try{f.accept(S[Pi.extensionName])}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Pi.extensionName]=f}e.setSocket(_,y,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(h,e):h.end()}function oc(e,t){e._readyState=pt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function RL(e){return e.path=e.socketPath,Fx.connect(e)}function $L(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Fx.isIP(e.host)?"":e.host),gL.connect(e)}function qn(e,t,n){e._readyState=pt.CLOSING;let i=new Error(n);Error.captureStackTrace(i,qn),t.setHeader?(t[Lx]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(oc,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function jh(e,t,n){if(t){let i=SL(t)?t.size:PL(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${e.readyState} (${li[e.readyState]})`);process.nextTick(n,i)}}function ML(e,t){let n=this[Bt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[Bt]!==void 0&&(n._socket.removeListener("data",ac),process.nextTick(Gx,n._socket),e===1005?n.close():n.close(e,t))}function jL(){let e=this[Bt];e.isPaused||e._socket.resume()}function qL(e){let t=this[Bt];t._socket[Bt]!==void 0&&(t._socket.removeListener("data",ac),process.nextTick(Gx,t._socket),t.close(e[xL])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function Nx(){this[Bt].emitClose()}function NL(e,t){this[Bt].emit("message",e,t)}function FL(e){let t=this[Bt];t._autoPong&&t.pong(e,!this._isServer,Dx),t.emit("ping",e)}function DL(e){this[Bt].emit("pong",e)}function Gx(e){e.resume()}function LL(e){let t=this[Bt];t.readyState!==pt.CLOSED&&(t.readyState===pt.OPEN&&(t._readyState=pt.CLOSING,zx(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function zx(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),IL)}function Jx(){let e=this[Bt];this.removeListener("close",Jx),this.removeListener("data",ac),this.removeListener("end",Kx),e._readyState=pt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Bt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Nx),e._receiver.on("finish",Nx))}function ac(e){this[Bt]._receiver.write(e)||this.pause()}function Kx(){let e=this[Bt];e._readyState=pt.CLOSING,e._receiver.end(),this.end()}function Bx(){let e=this[Bt];this.removeListener("error",Bx),this.on("error",Dx),e&&(e._readyState=pt.CLOSING,this.destroy())}});var Qx=tt((Cce,Zx)=>{"use strict";var Tce=sc(),{Duplex:UL}=We("stream");function Hx(e){e.emit("close")}function GL(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Vx(e){this.removeListener("error",Vx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function zL(e,t){let n=!0,i=new UL({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&i._readableState.objectMode?o.toString():o;i.push(s)||e.pause()}),e.once("error",function(o){i.destroyed||(n=!1,i.destroy(o))}),e.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,o){if(e.readyState===e.CLOSED){o(r),process.nextTick(Hx,i);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(r),process.nextTick(Hx,i)}),n&&e.terminate()},i._final=function(r){if(e.readyState===e.CONNECTING){e.once("open",function(){i._final(r)});return}e._socket!==null&&(e._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",function(){r()}),e.close()))},i._read=function(){e.isPaused&&e.resume()},i._write=function(r,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){i._write(r,o,a)});return}e.send(r,a)},i.on("end",GL),i.on("error",Vx),i}Zx.exports=zL});var Xx=tt((Ace,Yx)=>{"use strict";var{tokenChars:JL}=ya();function KL(e){let t=new Set,n=-1,i=-1,r=0;for(r;r<e.length;r++){let a=e.charCodeAt(r);if(i===-1&&JL[a]===1)n===-1&&(n=r);else if(r!==0&&(a===32||a===9))i===-1&&n!==-1&&(i=r);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}Yx.exports={parse:KL}});var a0=tt((Pce,o0)=>{"use strict";var BL=We("events"),dc=We("http"),{Duplex:Ece}=We("stream"),{createHash:WL}=We("crypto"),e0=Oh(),mo=Xs(),HL=Xx(),VL=sc(),{GUID:ZL,kWebSocket:QL}=ai(),YL=/^[+/0-9A-Za-z]{22}==$/,t0=0,n0=1,i0=2,qh=class extends BL{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:VL,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=dc.createServer((i,r)=>{let o=dc.STATUS_CODES[426];r.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),r.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=XL(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,o,a)=>{this.handleUpgrade(r,o,a,i)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=t0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===i0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(rd,this);return}if(t&&this.once("close",t),this._state!==n0)if(this._state=n0,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(rd,this):process.nextTick(rd,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{rd(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,i,r){n.on("error",r0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ho(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ho(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!YL.test(o)){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){id(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=HL.parse(d)}catch{ho(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new mo(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=e0.parse(u);f[mo.extensionName]&&(p.accept(f[mo.extensionName]),c[mo.extensionName]=p)}catch{ho(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(f,h,g,_)=>{if(!f)return id(n,h||401,g,_);this.completeUpgrade(c,o,l,t,n,i,r)});return}if(!this.options.verifyClient(p))return id(n,401)}this.completeUpgrade(c,o,l,t,n,i,r)}completeUpgrade(t,n,i,r,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[QL])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>t0)return id(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${WL("sha1").update(n+ZL).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(i.size){let c=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[mo.extensionName]){let c=t[mo.extensionName].params,p=e0.format({[mo.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,r),o.write(l.concat(`\r
|
|
4
|
+
GFS4: `),console.error(e)});St[Qt]||(dk=global[Qt]||[],uk(St,dk),St.close=(function(e){function t(n,i){return e.call(St,n,function(r){r||lk(),typeof i=="function"&&i.apply(this,arguments)})}return Object.defineProperty(t,Nu,{value:e}),t})(St.close),St.closeSync=(function(e){function t(n){e.apply(St,arguments),lk()}return Object.defineProperty(t,Nu,{value:e}),t})(St.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){ao(St[Qt]),We("assert").equal(St[Qt].length,0)}));var dk;global[Qt]||uk(global,St[Qt]);th.exports=Xm(aD(St));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!St.__patched&&(th.exports=Xm(St),St.__patched=!0);function Xm(e){iD(e),e.gracefulify=Xm,e.createReadStream=A,e.createWriteStream=C;var t=e.readFile;e.readFile=n;function n(T,E,P){return typeof E=="function"&&(P=E,E=null),R(T,E,P);function R(O,M,J,Z){return t(O,M,function(z){z&&(z.code==="EMFILE"||z.code==="ENFILE")?sa([R,[O,M,J],z,Z||Date.now(),Date.now()]):typeof J=="function"&&J.apply(this,arguments)})}}var i=e.writeFile;e.writeFile=r;function r(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return i(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return o(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(T,E,P,R){return typeof P=="function"&&(R=P,P=0),O(T,E,P,R);function O(M,J,Z,z,X){return s(M,J,Z,function(ee){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(T,E,P){typeof E=="function"&&(P=E,E=null);var R=u.test(process.version)?function(J,Z,z,X){return l(J,O(J,Z,z,X))}:function(J,Z,z,X){return l(J,Z,O(J,Z,z,X))};return R(T,E,P);function O(M,J,Z,z){return function(X,ee){X&&(X.code==="EMFILE"||X.code==="ENFILE")?sa([R,[M,J,Z],X,z||Date.now(),Date.now()]):(ee&&ee.sort&&ee.sort(),typeof Z=="function"&&Z.call(this,X,ee))}}}if(process.version.substr(0,4)==="v0.8"){var p=oD(e);y=p.ReadStream,v=p.WriteStream}var f=e.ReadStream;f&&(y.prototype=Object.create(f.prototype),y.prototype.open=b);var h=e.WriteStream;h&&(v.prototype=Object.create(h.prototype),v.prototype.open=w),Object.defineProperty(e,"ReadStream",{get:function(){return y},set:function(T){y=T},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(T){v=T},enumerable:!0,configurable:!0});var g=y;Object.defineProperty(e,"FileReadStream",{get:function(){return g},set:function(T){g=T},enumerable:!0,configurable:!0});var _=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return _},set:function(T){_=T},enumerable:!0,configurable:!0});function y(T,E){return this instanceof y?(f.apply(this,arguments),this):y.apply(Object.create(y.prototype),arguments)}function b(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.autoClose&&T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P),T.read())})}function v(T,E){return this instanceof v?(h.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function w(){var T=this;k(T.path,T.flags,T.mode,function(E,P){E?(T.destroy(),T.emit("error",E)):(T.fd=P,T.emit("open",P))})}function A(T,E){return new e.ReadStream(T,E)}function C(T,E){return new e.WriteStream(T,E)}var S=e.open;e.open=k;function k(T,E,P,R){return typeof P=="function"&&(R=P,P=null),O(T,E,P,R);function O(M,J,Z,z,X){return S(M,J,Z,function(ee,B){ee&&(ee.code==="EMFILE"||ee.code==="ENFILE")?sa([O,[M,J,Z,z],ee,X||Date.now(),Date.now()]):typeof z=="function"&&z.apply(this,arguments)})}}return e}function sa(e){ao("ENQUEUE",e[0].name,e[1]),St[Qt].push(e),eh()}var qu;function lk(){for(var e=Date.now(),t=0;t<St[Qt].length;++t)St[Qt][t].length>2&&(St[Qt][t][3]=e,St[Qt][t][4]=e);eh()}function eh(){if(clearTimeout(qu),qu=void 0,St[Qt].length!==0){var e=St[Qt].shift(),t=e[0],n=e[1],i=e[2],r=e[3],o=e[4];if(r===void 0)ao("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-r>=6e4){ao("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,i)}else{var s=Date.now()-o,d=Math.max(o-r,1),l=Math.min(d*1.2,100);s>=l?(ao("RETRY",t.name,n),t.apply(null,n.concat([r]))):St[Qt].push(e)}qu===void 0&&(qu=setTimeout(eh,0))}}});var fk=tt((Uue,ck)=>{function Vn(e,t){typeof t=="boolean"&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}ck.exports=Vn;Vn.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};Vn.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};Vn.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(new Error("RetryOperation timeout occurred")),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var i=this,r=setTimeout(function(){i._attempts++,i._operationTimeoutCb&&(i._timeout=setTimeout(function(){i._operationTimeoutCb(i._attempts)},i._operationTimeout),i._options.unref&&i._timeout.unref()),i._fn(i._attempts)},n);return this._options.unref&&r.unref(),!0};Vn.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){n._operationTimeoutCb()},n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)};Vn.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};Vn.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};Vn.prototype.start=Vn.prototype.try;Vn.prototype.errors=function(){return this._errors};Vn.prototype.attempts=function(){return this._attempts};Vn.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,i=0;i<this._errors.length;i++){var r=this._errors[i],o=r.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=r,n=a)}return t}});var pk=tt(so=>{var dD=fk();so.operation=function(e){var t=so.timeouts(e);return new dD(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};so.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw new Error("minTimeout is greater than maxTimeout");for(var i=[],r=0;r<t.retries;r++)i.push(this.createTimeout(r,t));return e&&e.forever&&!i.length&&i.push(this.createTimeout(r,t)),i.sort(function(o,a){return o-a}),i};so.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,i=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return i=Math.min(i,t.maxTimeout),i};so.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var i in e)typeof e[i]=="function"&&n.push(i)}for(var r=0;r<n.length;r++){var o=n[r],a=e[o];e[o]=function(d){var l=so.operation(t),u=Array.prototype.slice.call(arguments,1),c=u.pop();u.push(function(p){l.retry(p)||(p&&(arguments[0]=l.mainError()),c.apply(this,arguments))}),l.attempt(function(){d.apply(e,u)})}.bind(e,a),e[o].options=t}}});var hk=tt((zue,mk)=>{mk.exports=pk()});var gk=tt((Jue,Fu)=>{Fu.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&Fu.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&Fu.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var Sk=tt((Kue,ua)=>{var ft=global.process,lo=function(e){return e&&typeof e=="object"&&typeof e.removeListener=="function"&&typeof e.emit=="function"&&typeof e.reallyExit=="function"&&typeof e.listeners=="function"&&typeof e.kill=="function"&&typeof e.pid=="number"&&typeof e.on=="function"};lo(ft)?(yk=We("assert"),da=gk(),_k=/^win/i.test(ft.platform),Vs=We("events"),typeof Vs!="function"&&(Vs=Vs.EventEmitter),ft.__signal_exit_emitter__?zt=ft.__signal_exit_emitter__:(zt=ft.__signal_exit_emitter__=new Vs,zt.count=0,zt.emitted={}),zt.infinite||(zt.setMaxListeners(1/0),zt.infinite=!0),ua.exports=function(e,t){if(!lo(global.process))return function(){};yk.equal(typeof e,"function","a callback must be provided for exit handler"),la===!1&&rh();var n="exit";t&&t.alwaysLast&&(n="afterexit");var i=function(){zt.removeListener(n,e),zt.listeners("exit").length===0&&zt.listeners("afterexit").length===0&&Du()};return zt.on(n,e),i},Du=function(){!la||!lo(global.process)||(la=!1,da.forEach(function(t){try{ft.removeListener(t,Lu[t])}catch{}}),ft.emit=Uu,ft.reallyExit=ih,zt.count-=1)},ua.exports.unload=Du,uo=function(t,n,i){zt.emitted[t]||(zt.emitted[t]=!0,zt.emit(t,n,i))},Lu={},da.forEach(function(e){Lu[e]=function(){if(lo(global.process)){var n=ft.listeners(e);n.length===zt.count&&(Du(),uo("exit",null,e),uo("afterexit",null,e),_k&&e==="SIGHUP"&&(e="SIGINT"),ft.kill(ft.pid,e))}}}),ua.exports.signals=function(){return da},la=!1,rh=function(){la||!lo(global.process)||(la=!0,zt.count+=1,da=da.filter(function(t){try{return ft.on(t,Lu[t]),!0}catch{return!1}}),ft.emit=vk,ft.reallyExit=bk)},ua.exports.load=rh,ih=ft.reallyExit,bk=function(t){lo(global.process)&&(ft.exitCode=t||0,uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),ih.call(ft,ft.exitCode))},Uu=ft.emit,vk=function(t,n){if(t==="exit"&&lo(global.process)){n!==void 0&&(ft.exitCode=n);var i=Uu.apply(this,arguments);return uo("exit",ft.exitCode,null),uo("afterexit",ft.exitCode,null),i}else return Uu.apply(this,arguments)}):ua.exports=function(){return function(){}};var yk,da,_k,Vs,zt,Du,uo,Lu,la,rh,ih,bk,Uu,vk});var Ck=tt((Bue,Zs)=>{"use strict";var lD=We("path"),sh=nh(),uD=hk(),cD=Sk(),oi={};function ca(e,t){return t.lockfilePath||`${e}.lock`}function dh(e,t,n){if(!t.realpath)return n(null,lD.resolve(e));t.fs.realpath(e,n)}function oh(e,t,n){t.fs.mkdir(ca(e,t),i=>{if(!i)return n();if(i.code!=="EEXIST")return n(i);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(ca(e,t),(r,o)=>{if(r)return r.code==="ENOENT"?oh(e,{...t,stale:0},n):n(r);if(!kk(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));xk(e,t,a=>{if(a)return n(a);oh(e,{...t,stale:0},n)})})})}function kk(e,t){return e.mtime.getTime()<Date.now()-t.stale}function xk(e,t,n){t.fs.rmdir(ca(e,t),i=>{if(i&&i.code!=="ENOENT")return n(i);n()})}function ah(e,t){let n=oi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let i=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(ca(e,t),i,i,r=>{if(!n.released){if(n.lastUpdate<=Date.now()-t.stale&&n.lastUpdate>Date.now()-t.stale*2){let o=Object.assign(new Error(n.updateError||"Unable to update lock within the stale threshold"),{code:"ECOMPROMISED"});return wk(e,n,o)}if(r)return r.code==="ENOENT"?wk(e,n,Object.assign(r,{code:"ECOMPROMISED"})):(n.updateError=r,n.updateDelay=1e3,ah(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,ah(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function wk(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),oi[e]===t&&delete oi[e],t.options.onCompromised(n)}function fD(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:sh,onCompromised:i=>{throw i},...t},t.retries=t.retries||0,t.retries=typeof t.retries=="number"?{retries:t.retries}:t.retries,t.stale=Math.max(t.stale||0,2e3),t.update=t.update==null?t.stale/2:t.update||0,t.update=Math.max(Math.min(t.update,t.stale/2),1e3),dh(e,t,(i,r)=>{if(i)return n(i);let o=uD.operation(t.retries);o.attempt(()=>{oh(r,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=oi[r]={options:t,lastUpdate:Date.now()};ah(r,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));Tk(r,{...t,realpath:!1},d)})})})})}function Tk(e,t,n){t={fs:sh,realpath:!0,...t},dh(e,t,(i,r)=>{if(i)return n(i);let o=oi[r];if(!o)return n(Object.assign(new Error("Lock is not acquired/owned by you"),{code:"ENOTACQUIRED"}));o.updateTimeout&&clearTimeout(o.updateTimeout),o.released=!0,delete oi[r],xk(r,t,n)})}function pD(e,t,n){t={stale:1e4,realpath:!0,fs:sh,...t},t.stale=Math.max(t.stale||0,2e3),dh(e,t,(i,r)=>{if(i)return n(i);t.fs.stat(ca(r,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!kk(a,t)))})}function mD(){return oi}cD(()=>{for(let e in oi){let t=oi[e].options;try{t.fs.rmdirSync(ca(e,t))}catch{}}});Zs.exports.lock=fD;Zs.exports.unlock=Tk;Zs.exports.check=pD;Zs.exports.getLocks=mD});var Ek=tt((Wue,Ak)=>{"use strict";var hD=nh();function gD(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(i=>{n[i]=(...r)=>{let o=r.pop(),a;try{a=e[`${i}Sync`](...r)}catch(s){return o(s)}o(null,a)}}),n}function yD(e){return(...t)=>new Promise((n,i)=>{t.push((r,o)=>{r?i(r):n(o)}),e(...t)})}function _D(e){return(...t)=>{let n,i;if(t.push((r,o)=>{n=r,i=o}),e(...t),n)throw n;return i}}function bD(e){if(e={...e},e.fs=gD(e.fs||hD),typeof e.retries=="number"&&e.retries>0||e.retries&&typeof e.retries.retries=="number"&&e.retries.retries>0)throw Object.assign(new Error("Cannot use retries with the sync api"),{code:"ESYNC"});return e}Ak.exports={toPromise:yD,toSync:_D,toSyncOptions:bD}});var Ik=tt((Hue,Ai)=>{"use strict";var fa=Ck(),{toPromise:Gu,toSync:zu,toSyncOptions:lh}=Ek();async function Pk(e,t){let n=await Gu(fa.lock)(e,t);return Gu(n)}function vD(e,t){let n=zu(fa.lock)(e,lh(t));return zu(n)}function SD(e,t){return Gu(fa.unlock)(e,t)}function wD(e,t){return zu(fa.unlock)(e,lh(t))}function kD(e,t){return Gu(fa.check)(e,t)}function xD(e,t){return zu(fa.check)(e,lh(t))}Ai.exports=Pk;Ai.exports.lock=Pk;Ai.exports.unlock=SD;Ai.exports.lockSync=vD;Ai.exports.unlockSync=wD;Ai.exports.check=kD;Ai.exports.checkSync=xD});var Ok=F(()=>{});var Rk=F(()=>{});var Ju=F(()=>{});var Yt=F(()=>{Ok();Rk();Ju()});function AD(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function Jt(e){return AD(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function fh(e){let t=ch[e];if(t!==void 0){let n=t+1|0;return ch[e]=n,e+("/"+n)}return ch[e]=1,e}var ch,Xt=F(()=>{ch={}});import*as jk from"node:child_process";function pa(e){let t=ri(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=He(t);return{code:Iu(n.code),message:Ve(Fr(n),"unknown error")}}function qk(e,t,n,i){try{return{TAG:"Ok",_0:jk.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:i})}}catch(r){let o=Jt(r);return{TAG:"Error",_0:pa(o)}}}var ED,Kt=F(()=>{ii();Ne();$u();ED=oa(Ik(),1);Yt();nt();Xt()});function Fk(e){let t=qk(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=Nk.exec(t._0);if(n!=null)return Mn(n.slice(1)[0],i=>i)}function Dk(e,t){return e!==void 0&&t!==void 0?e===t?{TAG:"Match",version:e}:{TAG:"Mismatch",pathVersion:e,pinnedVersion:t}:{TAG:"Unverified",pathVersion:e,pinnedVersion:t}}var Nk,Lk=F(()=>{At();Kt();Ne();Yt();Nk=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function ID(e,t){let n=Dk(e,t);switch(n.TAG){case"Match":return{TAG:"Ok",_0:n.version};case"Mismatch":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=mismatch observed="+n.pathVersion+" expected="+n.pinnedVersion};case"Unverified":return{TAG:"Error",_0:"hosted_codex_runtime_refused reason=unverified observed=unverified expected="+t}}}function Uk(e,t){return ID(Fk(e),t)}var Gk=F(()=>{Ne();Lk()});var zk,ph=F(()=>{Gk();zk=Uk});var Kk,Jk=F(()=>{Kk={name:"@linzumi/cli",version:"1.0.270",description:"Linzumi CLI \u2014 point a Codex agent at the real code on your laptop, with your team watching and steering from shared threads.",type:"module",bin:{linzumi:"bin/linzumi.js"},files:["README.md","bin","dist","scripts"],scripts:{"test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts test/llmProxySessionCredential.test.ts test/runnerBridge.test.ts test/threadCodexWorkerIpc.test.ts -t '(?:^| )(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup|does not install an old mint after its credential is (replaced|stopped)|worker agent capability requires an exact true ready flag|starts an explicitly server-keyed OpenAI agent worker without local OpenAI credentials|applies the accepted OpenAI follow-up model on an existing worker|refuses explicit OpenAI worker creation with (passthrough|missing-token|blank-origin) binding|refuses a private agent turn without an owned relay before Codex|explicitly capable worker receives a private request through ordinary IPC|old worker receives no private agent source descriptor)$'",build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","test:actual-commander-parity":"pnpm --dir ../linzumi-cli-rescript build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/ActualCommanderParityConformance.res.mjs","bump-version":"node scripts/bump-cli-version.mjs","codex:history-table":"node scripts/codex_history_table.mjs",test:"npm run test:startup && node --import tsx --test ../linzumi-cli-rescript/src/parity/McpToolCallBoundaryTest.res.mjs && rescript build ../../kandan/server_v2/web/replay_harness && vitest run --config vitest.config.mjs",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json","typecheck:all":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.json","typecheck:watch":"rescript build ../linzumi-cli-rescript && tsgo --noEmit -w -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","record:agent-fixtures":"tsx scripts/record-agent-replay-fixtures.ts","normalize:agent-fixture":"tsx scripts/normalize-agent-replay-fixture.ts","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","replay:agent-fixture":"tsx scripts/replay-agent-fixture.ts","replay:agent-backend":"tsx scripts/replay-agent-backend.ts","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check","replay:agent-backend-browser":"tsx scripts/replay-agent-backend-browser.ts","promote:gstack-claude-smoke-fixture":"tsx scripts/promote-gstack-claude-smoke-fixture.ts","diagnose:claude-probe":"tsx scripts/diagnose-claude-probe.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.199","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.153.2",blessed:"^0.1.81","proper-lockfile":"3.2.0",undici:"^6.25.0",ws:"^8.18.0",zod:"^3.25.76"},engines:{node:">=20"},readmeFilename:"README.md",devDependencies:{"@types/blessed":"^0.1.27","@types/node":"^22.18.6","@types/proper-lockfile":"4.1.4","@typescript/native-preview":"7.0.0-dev.20260703.1",esbuild:"^0.27.2","fast-check":"^3.23.2",rescript:"12.3.0",tsx:"^4.21.0",typescript:"^5.9.3",vitest:"^1.6.1"}}});var mh,Wu=F(()=>{"use strict";Jk();mh=Kk.dependencies["@openai/codex"]});async function Bk(e,t,n){let i;try{e(),i=!0}catch{i=!1}let r;try{await t(),r=!0}catch{r=!1}return i&&r?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function Wk(e,t){let n=e.quotaWindow,i=e.credits;if(n===void 0&&i===void 0)return{status:"unavailable",reason:"empty_response"};let r=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:r[0],windowMinutes:r[1],resetsAtMs:r[2],capturedAtMs:t,credits:i}}}var Hk=F(()=>{});var Vk,Zk,Qk=F(()=>{Hk();Vk=Bk,Zk=Wk});function Ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function hh(e){let t=[["threadId",e.threadId],["turnId",e.turnId],["itemId",e.itemId],["processId",e.processId],["requestId",e.requestId]].filter(n=>n[1]!==void 0);return Object.fromEntries(t)}var Et=F(()=>{"use strict"});var Hu=F(()=>{"use strict";Et()});function tx(e){let t=Dr(e.rateLimits)??Dr(e.rate_limits)??Dr(e.limits)??e,n=[t,...Object.values(t).flatMap(_=>{let y=Dr(_);return y===void 0?[]:[y]})],i=n.reduce((_,y)=>{let b=Fe(y.usedPercent)??Fe(y.used_percent);return b===void 0?_:_===void 0?b:Math.max(_,b)},void 0),o=n.some(_=>Fe(_.remaining)===0||Fe(_.remainingRequests)===0||Fe(_.remaining_requests)===0||Fe(_.remainingTokens)===0||Fe(_.remaining_tokens)===0||Fe(_.retryAfterSeconds)!==void 0||Fe(_.retry_after_seconds)!==void 0)?"rejected":i!==void 0&&i>=80?"allowed_warning":"allowed",a=Dr(t.primary),s=Fe(a?.usedPercent),d=Fe(a?.windowDurationMins),l=Fe(a?.resetsAt),u=Dr(t.credits),c=ex(u?.hasCredits),p=ex(u?.unlimited),f=u?.balance,h=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof f=="string"?f:null},g=s===void 0&&d===void 0&&l===void 0?void 0:{...s===void 0?{}:{usedPercent:s},...d===void 0?{}:{windowMinutes:d},...l===void 0?{}:{resetsAtMs:l*1e3}};return{summary:jD(e)??"seen (no details)",status:o,utilizationPercent:i,...g===void 0?{}:{quotaWindow:g},...h===void 0?{}:{credits:h}}}function jD(e){let t=Dr(e.rateLimits)??Dr(e.rate_limits)??Dr(e.limits)??e,n=Yk(t,void 0),i=Object.entries(t).flatMap(([o,a])=>{let s=Dr(a);return s===void 0?[]:[Yk(s,o)]}),r=[n,...i].filter(o=>o!==void 0);return r.length===0?void 0:r.join(" | ")}function Yk(e,t){let n=gr(e.limitName)??gr(e.limit_name)??gr(e.name)??gr(e.type)??t,i=gr(e.planType)??gr(e.plan_type)??gr(e.plan),r=Fe(e.remaining)??Fe(e.remainingRequests)??Fe(e.remaining_requests)??Fe(e.remainingTokens)??Fe(e.remaining_tokens),o=Fe(e.limit)??Fe(e.requestLimit)??Fe(e.request_limit)??Fe(e.limitRequests)??Fe(e.limit_requests)??Fe(e.tokenLimit)??Fe(e.token_limit)??Fe(e.limitTokens)??Fe(e.limit_tokens),a=gr(e.resetAt)??gr(e.reset_at)??gr(e.resetsAt)??gr(e.resets_at)??Xk(e.resetsAt)??Xk(e.resets_at)??Vu(e.resetAfterSeconds)??Vu(e.reset_after_seconds)??Vu(e.retryAfterSeconds)??Vu(e.retry_after_seconds),s=Fe(e.usedPercent)??Fe(e.used_percent),d=Fe(e.windowDurationMins)??Fe(e.window_duration_mins),l=[n,i].filter(f=>f!==void 0).join(" "),u=l===""?void 0:l,p=[r===void 0?void 0:o===void 0?`${r} remaining`:`${r}/${o} remaining`,s===void 0?void 0:`${s}% used`,d===void 0?void 0:`${d}m window`,a===void 0?void 0:`reset ${a}`].filter(f=>f!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Vu(e){let t=Fe(e);return t===void 0?void 0:`${t}s`}function Xk(e){let t=Fe(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function Dr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function gr(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function ex(e){return typeof e=="boolean"?e:void 0}function Fe(e){if(typeof e=="number"&&Number.isSafeInteger(e))return e;if(typeof e!="string")return;let t=Number.parseInt(e,10);return Number.isSafeInteger(t)&&t.toString()===e.trim()?t:void 0}var nx=F(()=>{"use strict";Hu();Et()});var ai=tt((fce,ox)=>{"use strict";var rx=["nodebuffer","arraybuffer","fragments"],ix=typeof Blob<"u";ix&&rx.push("blob");ox.exports={BINARY_TYPES:rx,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:ix,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var Qs=tt((pce,Zu)=>{"use strict";var{EMPTY_BUFFER:qD}=ai(),gh=Buffer[Symbol.species];function ND(e,t){if(e.length===0)return qD;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),i=0;for(let r=0;r<e.length;r++){let o=e[r];n.set(o,i),i+=o.length}return i<t?new gh(n.buffer,n.byteOffset,i):n}function ax(e,t,n,i,r){for(let o=0;o<r;o++)n[i+o]=e[o]^t[o&3]}function sx(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function FD(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function yh(e){if(yh.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new gh(e):ArrayBuffer.isView(e)?t=new gh(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),yh.readOnly=!1),t}Zu.exports={concat:ND,mask:ax,toArrayBuffer:FD,toBuffer:yh,unmask:sx};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=We("bufferutil");Zu.exports.mask=function(t,n,i,r,o){o<48?ax(t,n,i,r,o):e.mask(t,n,i,r,o)},Zu.exports.unmask=function(t,n){t.length<32?sx(t,n):e.unmask(t,n)}}catch{}});var ux=tt((mce,lx)=>{"use strict";var dx=Symbol("kDone"),_h=Symbol("kRun"),bh=class{constructor(t){this[dx]=()=>{this.pending--,this[_h]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[_h]()}[_h](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[dx])}}};lx.exports=bh});var Xs=tt((hce,mx)=>{"use strict";var Ys=We("zlib"),cx=Qs(),DD=ux(),{kStatusCode:fx}=ai(),LD=Buffer[Symbol.species],UD=Buffer.from([0,0,255,255]),Yu=Symbol("permessage-deflate"),si=Symbol("total-length"),ha=Symbol("callback"),Ei=Symbol("buffers"),ga=Symbol("error"),Qu,vh=class{constructor(t,n,i){if(this._maxPayload=i|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!n,this._deflate=null,this._inflate=null,this.params=null,!Qu){let r=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Qu=new DD(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[ha];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(t){let n=this._options,i=t.find(r=>!(n.serverNoContextTakeover===!1&&r.server_no_context_takeover||r.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>r.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!r.client_max_window_bits));if(!i)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(i.server_no_context_takeover=!0),n.clientNoContextTakeover&&(i.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(i.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?i.client_max_window_bits=n.clientMaxWindowBits:(i.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete i.client_max_window_bits,i}acceptAsClient(t){let n=t[0];if(this._options.clientNoContextTakeover===!1&&n.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!n.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(n.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&n.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return n}normalizeParams(t){return t.forEach(n=>{Object.keys(n).forEach(i=>{let r=n[i];if(r.length>1)throw new Error(`Parameter "${i}" must have only a single value`);if(r=r[0],i==="client_max_window_bits"){if(r!==!0){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else if(i==="server_max_window_bits"){let o=+r;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${i}": ${r}`);r=o}else if(i==="client_no_context_takeover"||i==="server_no_context_takeover"){if(r!==!0)throw new TypeError(`Invalid value for parameter "${i}": ${r}`)}else throw new Error(`Unknown parameter "${i}"`);n[i]=r})}),t}decompress(t,n,i){Qu.add(r=>{this._decompress(t,n,(o,a)=>{r(),i(o,a)})})}compress(t,n,i){Qu.add(r=>{this._compress(t,n,(o,a)=>{r(),i(o,a)})})}_decompress(t,n,i){let r=this._isServer?"client":"server";if(!this._inflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Ys.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=Ys.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[Yu]=this,this._inflate[si]=0,this._inflate[Ei]=[],this._inflate.on("error",zD),this._inflate.on("data",px)}this._inflate[ha]=i,this._inflate.write(t),n&&this._inflate.write(UD),this._inflate.flush(()=>{let o=this._inflate[ga];if(o){this._inflate.close(),this._inflate=null,i(o);return}let a=cx.concat(this._inflate[Ei],this._inflate[si]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[si]=0,this._inflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._inflate.reset()),i(null,a)})}_compress(t,n,i){let r=this._isServer?"server":"client";if(!this._deflate){let o=`${r}_max_window_bits`,a=typeof this.params[o]!="number"?Ys.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=Ys.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[si]=0,this._deflate[Ei]=[],this._deflate.on("data",GD)}this._deflate[ha]=i,this._deflate.write(t),this._deflate.flush(Ys.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=cx.concat(this._deflate[Ei],this._deflate[si]);n&&(o=new LD(o.buffer,o.byteOffset,o.length-4)),this._deflate[ha]=null,this._deflate[si]=0,this._deflate[Ei]=[],n&&this.params[`${r}_no_context_takeover`]&&this._deflate.reset(),i(null,o)})}};mx.exports=vh;function GD(e){this[Ei].push(e),this[si]+=e.length}function px(e){if(this[si]+=e.length,this[Yu]._maxPayload<1||this[si]<=this[Yu]._maxPayload){this[Ei].push(e);return}this[ga]=new RangeError("Max payload size exceeded"),this[ga].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[ga][fx]=1009,this.removeListener("data",px),this.reset()}function zD(e){if(this[Yu]._inflate=null,this[ga]){this[ha](this[ga]);return}e[fx]=1007,this[ha](e)}});var ya=tt((gce,Xu)=>{"use strict";var{isUtf8:hx}=We("buffer"),{hasBlob:JD}=ai(),KD=[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 BD(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function Sh(e){let t=e.length,n=0;for(;n<t;)if((e[n]&128)===0)n++;else if((e[n]&224)===192){if(n+1===t||(e[n+1]&192)!==128||(e[n]&254)===192)return!1;n+=2}else if((e[n]&240)===224){if(n+2>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||e[n]===224&&(e[n+1]&224)===128||e[n]===237&&(e[n+1]&224)===160)return!1;n+=3}else if((e[n]&248)===240){if(n+3>=t||(e[n+1]&192)!==128||(e[n+2]&192)!==128||(e[n+3]&192)!==128||e[n]===240&&(e[n+1]&240)===128||e[n]===244&&e[n+1]>143||e[n]>244)return!1;n+=4}else return!1;return!0}function WD(e){return JD&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Xu.exports={isBlob:WD,isValidStatusCode:BD,isValidUTF8:Sh,tokenChars:KD};if(hx)Xu.exports.isValidUTF8=function(e){return e.length<24?Sh(e):hx(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=We("utf-8-validate");Xu.exports.isValidUTF8=function(t){return t.length<32?Sh(t):e(t)}}catch{}});var Ch=tt((yce,wx)=>{"use strict";var{Writable:HD}=We("stream"),gx=Xs(),{BINARY_TYPES:VD,EMPTY_BUFFER:yx,kStatusCode:ZD,kWebSocket:QD}=ai(),{concat:wh,toArrayBuffer:YD,unmask:XD}=Qs(),{isValidStatusCode:eL,isValidUTF8:_x}=ya(),ec=Buffer[Symbol.species],Zn=0,bx=1,vx=2,Sx=3,kh=4,xh=5,tc=6,Th=class extends HD{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||VD[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[QD]=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=Zn}_write(t,n,i){if(this._opcode===8&&this._state==Zn)return i();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(i)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let i=this._buffers[0];return this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t),new ec(i.buffer,i.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let i=this._buffers[0],r=n.length-t;t>=i.length?n.set(this._buffers.shift(),r):(n.set(new Uint8Array(i.buffer,i.byteOffset,t),r),this._buffers[0]=new ec(i.buffer,i.byteOffset+t,i.length-t)),t-=i.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case Zn:this.getInfo(t);break;case bx:this.getPayloadLength16(t);break;case vx:this.getPayloadLength64(t);break;case Sx:this.getMask();break;case kh:this.getData(t);break;case xh:case tc:this._loop=!1;return}while(this._loop);this._errored||t()}getInfo(t){if(this._bufferedBytes<2){this._loop=!1;return}let n=this.consume(2);if((n[0]&48)!==0){let r=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(r);return}let i=(n[0]&64)===64;if(i&&!this._extensions[gx.extensionName]){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(!this._fragmented){let r=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}this._compressed=i}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let r=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(r);return}if(i){let r=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(r);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let r=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(r);return}}else{let r=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(r);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let r=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(r);return}}else if(this._masked){let r=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(r);return}this._payloadLength===126?this._state=bx:this._payloadLength===127?this._state=vx: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 n=this.consume(8),i=n.readUInt32BE(0);if(i>Math.pow(2,21)-1){let r=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(r);return}this._payloadLength=i*Math.pow(2,32)+n.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 n=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");t(n);return}this._masked?this._state=Sx:this._state=kh}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=kh}getData(t){let n=yx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}n=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0&&XD(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=xh,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[gx.extensionName].decompress(t,this._fin,(r,o)=>{if(r)return n(r);if(o.length){if(this._messageLength+=o.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let a=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");n(a);return}this._fragments.push(o)}this.dataMessage(n),this._state===Zn&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=Zn;return}let n=this._messageLength,i=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let r;this._binaryType==="nodebuffer"?r=wh(i,n):this._binaryType==="arraybuffer"?r=YD(wh(i,n)):this._binaryType==="blob"?r=new Blob(i):r=i,this._allowSynchronousEvents?(this.emit("message",r,!0),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!0),this._state=Zn,this.startLoop(t)}))}else{let r=wh(i,n);if(!this._skipUTF8Validation&&!_x(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===xh||this._allowSynchronousEvents?(this.emit("message",r,!1),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit("message",r,!1),this._state=Zn,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,yx),this.end();else{let i=t.readUInt16BE(0);if(!eL(i)){let o=this.createError(RangeError,`invalid status code ${i}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let r=new ec(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!_x(r)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",i,r),this.end()}this._state=Zn;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn):(this._state=tc,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=Zn,this.startLoop(n)}))}createError(t,n,i,r,o){this._loop=!1,this._errored=!0;let a=new t(i?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[ZD]=r,a}};wx.exports=Th});var Ph=tt((bce,Tx)=>{"use strict";var{Duplex:_ce}=We("stream"),{randomFillSync:tL}=We("crypto"),kx=Xs(),{EMPTY_BUFFER:nL,kWebSocket:rL,NOOP:iL}=ai(),{isBlob:_a,isValidStatusCode:oL}=ya(),{mask:xx,toBuffer:co}=Qs(),Qn=Symbol("kByteLength"),aL=Buffer.alloc(4),nc=8*1024,fo,ba=nc,yr=0,sL=1,dL=2,Ah=class e{constructor(t,n,i){this._extensions=n||{},i&&(this._generateMask=i,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=yr,this.onerror=iL,this[rL]=void 0}static frame(t,n){let i,r=!1,o=2,a=!1;n.mask&&(i=n.maskBuffer||aL,n.generateMask?n.generateMask(i):(ba===nc&&(fo===void 0&&(fo=Buffer.alloc(nc)),tL(fo,0,nc),ba=0),i[0]=fo[ba++],i[1]=fo[ba++],i[2]=fo[ba++],i[3]=fo[ba++]),a=(i[0]|i[1]|i[2]|i[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[Qn]!==void 0?s=n[Qn]:(t=Buffer.from(t),s=t.length):(s=t.length,r=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(r?s+o:o);return l[0]=n.fin?n.opcode|128:n.opcode,n.rsv1&&(l[0]|=64),l[1]=d,d===126?l.writeUInt16BE(s,2):d===127&&(l[2]=l[3]=0,l.writeUIntBE(s,4,6)),n.mask?(l[1]|=128,l[o-4]=i[0],l[o-3]=i[1],l[o-2]=i[2],l[o-1]=i[3],a?[l,t]:r?(xx(t,i,l,o,s),[l]):(xx(t,i,t,0,s),[l,t])):[l,t]}close(t,n,i,r){let o;if(t===void 0)o=nL;else{if(typeof t!="number"||!oL(t))throw new TypeError("First argument must be a valid error code number");if(n===void 0||!n.length)o=Buffer.allocUnsafe(2),o.writeUInt16BE(t,0);else{let s=Buffer.byteLength(n);if(s>123)throw new RangeError("The message must not be greater than 123 bytes");o=Buffer.allocUnsafe(2+s),o.writeUInt16BE(t,0),typeof n=="string"?o.write(n,2):o.set(n,2)}}let a={[Qn]:o.length,fin:!0,generateMask:this._generateMask,mask:i,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==yr?this.enqueue([this.dispatch,o,!1,a,r]):this.sendFrame(e.frame(o,a),r)}ping(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}pong(t,n,i){let r,o;if(typeof t=="string"?(r=Buffer.byteLength(t),o=!1):_a(t)?(r=t.size,o=!1):(t=co(t),r=t.length,o=co.readOnly),r>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[Qn]:r,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,!1,a,i]):this.getBlobData(t,!1,a,i):this._state!==yr?this.enqueue([this.dispatch,t,!1,a,i]):this.sendFrame(e.frame(t,a),i)}send(t,n,i){let r=this._extensions[kx.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):_a(t)?(s=t.size,d=!1):(t=co(t),s=t.length,d=co.readOnly),this._firstFragment?(this._firstFragment=!1,a&&r&&r.params[r._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=r._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[Qn]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};_a(t)?this._state!==yr?this.enqueue([this.getBlobData,t,this._compress,l,i]):this.getBlobData(t,this._compress,l,i):this._state!==yr?this.enqueue([this.dispatch,t,this._compress,l,i]):this.dispatch(t,this._compress,l,i)}getBlobData(t,n,i,r){this._bufferedBytes+=i[Qn],this._state=dL,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(Eh,this,s,r);return}this._bufferedBytes-=i[Qn];let a=co(o);n?this.dispatch(a,n,i,r):(this._state=yr,this.sendFrame(e.frame(a,i),r),this.dequeue())}).catch(o=>{process.nextTick(lL,this,o,r)})}dispatch(t,n,i,r){if(!n){this.sendFrame(e.frame(t,i),r);return}let o=this._extensions[kx.extensionName];this._bufferedBytes+=i[Qn],this._state=sL,o.compress(t,i.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");Eh(this,d,r);return}this._bufferedBytes-=i[Qn],this._state=yr,i.readOnly=!1,this.sendFrame(e.frame(s,i),r),this.dequeue()})}dequeue(){for(;this._state===yr&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][Qn],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][Qn],this._queue.push(t)}sendFrame(t,n){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],n),this._socket.uncork()):this._socket.write(t[0],n)}};Tx.exports=Ah;function Eh(e,t,n){typeof n=="function"&&n(t);for(let i=0;i<e._queue.length;i++){let r=e._queue[i],o=r[r.length-1];typeof o=="function"&&o(t)}}function lL(e,t,n){Eh(e,t,n),e.onerror(t)}});var Mx=tt((vce,$x)=>{"use strict";var{kForOnEventAttribute:ed,kListener:Ih}=ai(),Cx=Symbol("kCode"),Ax=Symbol("kData"),Ex=Symbol("kError"),Px=Symbol("kMessage"),Ix=Symbol("kReason"),va=Symbol("kTarget"),Ox=Symbol("kType"),Rx=Symbol("kWasClean"),di=class{constructor(t){this[va]=null,this[Ox]=t}get target(){return this[va]}get type(){return this[Ox]}};Object.defineProperty(di.prototype,"target",{enumerable:!0});Object.defineProperty(di.prototype,"type",{enumerable:!0});var po=class extends di{constructor(t,n={}){super(t),this[Cx]=n.code===void 0?0:n.code,this[Ix]=n.reason===void 0?"":n.reason,this[Rx]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[Cx]}get reason(){return this[Ix]}get wasClean(){return this[Rx]}};Object.defineProperty(po.prototype,"code",{enumerable:!0});Object.defineProperty(po.prototype,"reason",{enumerable:!0});Object.defineProperty(po.prototype,"wasClean",{enumerable:!0});var Sa=class extends di{constructor(t,n={}){super(t),this[Ex]=n.error===void 0?null:n.error,this[Px]=n.message===void 0?"":n.message}get error(){return this[Ex]}get message(){return this[Px]}};Object.defineProperty(Sa.prototype,"error",{enumerable:!0});Object.defineProperty(Sa.prototype,"message",{enumerable:!0});var td=class extends di{constructor(t,n={}){super(t),this[Ax]=n.data===void 0?null:n.data}get data(){return this[Ax]}};Object.defineProperty(td.prototype,"data",{enumerable:!0});var uL={addEventListener(e,t,n={}){for(let r of this.listeners(e))if(!n[ed]&&r[Ih]===t&&!r[ed])return;let i;if(e==="message")i=function(o,a){let s=new td("message",{data:a?o:o.toString()});s[va]=this,rc(t,this,s)};else if(e==="close")i=function(o,a){let s=new po("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[va]=this,rc(t,this,s)};else if(e==="error")i=function(o){let a=new Sa("error",{error:o,message:o.message});a[va]=this,rc(t,this,a)};else if(e==="open")i=function(){let o=new di("open");o[va]=this,rc(t,this,o)};else return;i[ed]=!!n[ed],i[Ih]=t,n.once?this.once(e,i):this.on(e,i)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[Ih]===t&&!n[ed]){this.removeListener(e,n);break}}};$x.exports={CloseEvent:po,ErrorEvent:Sa,Event:di,EventTarget:uL,MessageEvent:td};function rc(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var Oh=tt((Sce,jx)=>{"use strict";var{tokenChars:nd}=ya();function Lr(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function cL(e){let t=Object.create(null),n=Object.create(null),i=!1,r=!1,o=!1,a,s,d=-1,l=-1,u=-1,c=0;for(;c<e.length;c++)if(l=e.charCodeAt(c),a===void 0)if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(c!==0&&(l===32||l===9))u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);l===44?(Lr(t,f,n),n=Object.create(null)):a=f,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(l===32||l===9)u===-1&&d!==-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c),Lr(n,e.slice(d,u),!0),l===44&&(Lr(t,a,n),n=Object.create(null),a=void 0),d=u=-1}else if(l===61&&d!==-1&&u===-1)s=e.slice(d,c),d=u=-1;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(r){if(nd[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:i||(i=!0),r=!1}else if(o)if(nd[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)r=!0;else throw new SyntaxError(`Unexpected character at index ${c}`);else if(l===34&&e.charCodeAt(c-1)===61)o=!0;else if(u===-1&&nd[l]===1)d===-1&&(d=c);else if(d!==-1&&(l===32||l===9))u===-1&&(u=c);else if(l===59||l===44){if(d===-1)throw new SyntaxError(`Unexpected character at index ${c}`);u===-1&&(u=c);let f=e.slice(d,u);i&&(f=f.replace(/\\/g,""),i=!1),Lr(n,s,f),l===44&&(Lr(t,a,n),n=Object.create(null),a=void 0),s=void 0,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);if(d===-1||o||l===32||l===9)throw new SyntaxError("Unexpected end of input");u===-1&&(u=c);let p=e.slice(d,u);return a===void 0?Lr(t,p,n):(s===void 0?Lr(n,p,!0):i?Lr(n,s,p.replace(/\\/g,"")):Lr(n,s,p),Lr(t,a,n)),t}function fL(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(i=>[t].concat(Object.keys(i).map(r=>{let o=i[r];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?r:`${r}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}jx.exports={format:fL,parse:cL}});var sc=tt((xce,Wx)=>{"use strict";var pL=We("events"),mL=We("https"),hL=We("http"),Fx=We("net"),gL=We("tls"),{randomBytes:yL,createHash:_L}=We("crypto"),{Duplex:wce,Readable:kce}=We("stream"),{URL:Rh}=We("url"),Pi=Xs(),bL=Ch(),vL=Ph(),{isBlob:SL}=ya(),{BINARY_TYPES:qx,EMPTY_BUFFER:ic,GUID:wL,kForOnEventAttribute:$h,kListener:kL,kStatusCode:xL,kWebSocket:Bt,NOOP:Dx}=ai(),{EventTarget:{addEventListener:TL,removeEventListener:CL}}=Mx(),{format:AL,parse:EL}=Oh(),{toBuffer:PL}=Qs(),IL=30*1e3,Lx=Symbol("kAborted"),Mh=[8,13],li=["CONNECTING","OPEN","CLOSING","CLOSED"],OL=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,pt=class e extends pL{constructor(t,n,i){super(),this._binaryType=qx[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=ic,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,n===void 0?n=[]:Array.isArray(n)||(typeof n=="object"&&n!==null?(i=n,n=[]):n=[n]),Ux(this,t,n,i)):(this._autoPong=i.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){qx.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,n,i){let r=new bL({allowSynchronousEvents:i.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation}),o=new vL(t,this._extensions,i.generateMask);this._receiver=r,this._sender=o,this._socket=t,r[Bt]=this,o[Bt]=this,t[Bt]=this,r.on("conclude",ML),r.on("drain",jL),r.on("error",qL),r.on("message",NL),r.on("ping",FL),r.on("pong",DL),o.onerror=LL,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",Jx),t.on("data",ac),t.on("end",Kx),t.on("error",Bx),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[Pi.extensionName]&&this._extensions[Pi.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(t,n){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(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,n,!this._isServer,i=>{i||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),zx(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||ic,n,i)}pong(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(i=t,t=n=void 0):typeof n=="function"&&(i=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||ic,n,i)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,i){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(i=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){jh(this,t,i);return}let r={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[Pi.extensionName]||(r.compress=!1),this._sender.send(t||ic,r,i)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){qn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(pt,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt.prototype,"CONNECTING",{enumerable:!0,value:li.indexOf("CONNECTING")});Object.defineProperty(pt,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt.prototype,"OPEN",{enumerable:!0,value:li.indexOf("OPEN")});Object.defineProperty(pt,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt.prototype,"CLOSING",{enumerable:!0,value:li.indexOf("CLOSING")});Object.defineProperty(pt,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});Object.defineProperty(pt.prototype,"CLOSED",{enumerable:!0,value:li.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(pt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(pt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[$h])return t[kL];return null},set(t){for(let n of this.listeners(e))if(n[$h]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[$h]:!0})}})});pt.prototype.addEventListener=TL;pt.prototype.removeEventListener=CL;Wx.exports=pt;function Ux(e,t,n,i){let r={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:Mh[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...i,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=r.autoPong,!Mh.includes(r.protocolVersion))throw new RangeError(`Unsupported protocol version: ${r.protocolVersion} (supported versions: ${Mh.join(", ")})`);let o;if(t instanceof Rh)o=t;else try{o=new Rh(t)}catch{throw new SyntaxError(`Invalid URL: ${t}`)}o.protocol==="http:"?o.protocol="ws:":o.protocol==="https:"&&(o.protocol="wss:"),e._url=o.href;let a=o.protocol==="wss:",s=o.protocol==="ws+unix:",d;if(o.protocol!=="ws:"&&!a&&!s?d=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`:s&&!o.pathname?d="The URL's pathname is empty":o.hash&&(d="The URL contains a fragment identifier"),d){let g=new SyntaxError(d);if(e._redirects===0)throw g;oc(e,g);return}let l=a?443:80,u=yL(16).toString("base64"),c=a?mL.request:hL.request,p=new Set,f;if(r.createConnection=r.createConnection||(a?$L:RL),r.defaultPort=r.defaultPort||l,r.port=o.port||l,r.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,r.headers={...r.headers,"Sec-WebSocket-Version":r.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},r.path=o.pathname+o.search,r.timeout=r.handshakeTimeout,r.perMessageDeflate&&(f=new Pi(r.perMessageDeflate!==!0?r.perMessageDeflate:{},!1,r.maxPayload),r.headers["Sec-WebSocket-Extensions"]=AL({[Pi.extensionName]:f.offer()})),n.length){for(let g of n){if(typeof g!="string"||!OL.test(g)||p.has(g))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(g)}r.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(r.origin&&(r.protocolVersion<13?r.headers["Sec-WebSocket-Origin"]=r.origin:r.headers.Origin=r.origin),(o.username||o.password)&&(r.auth=`${o.username}:${o.password}`),s){let g=r.path.split(":");r.socketPath=g[0],r.path=g[1]}let h;if(r.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?r.socketPath:o.host;let g=i&&i.headers;if(i={...i,headers:{}},g)for(let[_,y]of Object.entries(g))i.headers[_.toLowerCase()]=y}else if(e.listenerCount("redirect")===0){let g=s?e._originalIpc?r.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!g||e._originalSecure&&!a)&&(delete r.headers.authorization,delete r.headers.cookie,g||delete r.headers.host,r.auth=void 0)}r.auth&&!i.headers.authorization&&(i.headers.authorization="Basic "+Buffer.from(r.auth).toString("base64")),h=e._req=c(r),e._redirects&&e.emit("redirect",e.url,h)}else h=e._req=c(r);r.timeout&&h.on("timeout",()=>{qn(e,h,"Opening handshake has timed out")}),h.on("error",g=>{h===null||h[Lx]||(h=e._req=null,oc(e,g))}),h.on("response",g=>{let _=g.headers.location,y=g.statusCode;if(_&&r.followRedirects&&y>=300&&y<400){if(++e._redirects>r.maxRedirects){qn(e,h,"Maximum redirects exceeded");return}h.abort();let b;try{b=new Rh(_,t)}catch{let w=new SyntaxError(`Invalid URL: ${_}`);oc(e,w);return}Ux(e,b,n,i)}else e.emit("unexpected-response",h,g)||qn(e,h,`Unexpected server response: ${g.statusCode}`)}),h.on("upgrade",(g,_,y)=>{if(e.emit("upgrade",g),e.readyState!==pt.CONNECTING)return;h=e._req=null;let b=g.headers.upgrade;if(b===void 0||b.toLowerCase()!=="websocket"){qn(e,_,"Invalid Upgrade header");return}let v=_L("sha1").update(u+wL).digest("base64");if(g.headers["sec-websocket-accept"]!==v){qn(e,_,"Invalid Sec-WebSocket-Accept header");return}let w=g.headers["sec-websocket-protocol"],A;if(w!==void 0?p.size?p.has(w)||(A="Server sent an invalid subprotocol"):A="Server sent a subprotocol but none was requested":p.size&&(A="Server sent no subprotocol"),A){qn(e,_,A);return}w&&(e._protocol=w);let C=g.headers["sec-websocket-extensions"];if(C!==void 0){if(!f){qn(e,_,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let S;try{S=EL(C)}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}let k=Object.keys(S);if(k.length!==1||k[0]!==Pi.extensionName){qn(e,_,"Server indicated an extension that was not requested");return}try{f.accept(S[Pi.extensionName])}catch{qn(e,_,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Pi.extensionName]=f}e.setSocket(_,y,{allowSynchronousEvents:r.allowSynchronousEvents,generateMask:r.generateMask,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation})}),r.finishRequest?r.finishRequest(h,e):h.end()}function oc(e,t){e._readyState=pt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function RL(e){return e.path=e.socketPath,Fx.connect(e)}function $L(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Fx.isIP(e.host)?"":e.host),gL.connect(e)}function qn(e,t,n){e._readyState=pt.CLOSING;let i=new Error(n);Error.captureStackTrace(i,qn),t.setHeader?(t[Lx]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(oc,e,i)):(t.destroy(i),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function jh(e,t,n){if(t){let i=SL(t)?t.size:PL(t).length;e._socket?e._sender._bufferedBytes+=i:e._bufferedAmount+=i}if(n){let i=new Error(`WebSocket is not open: readyState ${e.readyState} (${li[e.readyState]})`);process.nextTick(n,i)}}function ML(e,t){let n=this[Bt];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[Bt]!==void 0&&(n._socket.removeListener("data",ac),process.nextTick(Gx,n._socket),e===1005?n.close():n.close(e,t))}function jL(){let e=this[Bt];e.isPaused||e._socket.resume()}function qL(e){let t=this[Bt];t._socket[Bt]!==void 0&&(t._socket.removeListener("data",ac),process.nextTick(Gx,t._socket),t.close(e[xL])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function Nx(){this[Bt].emitClose()}function NL(e,t){this[Bt].emit("message",e,t)}function FL(e){let t=this[Bt];t._autoPong&&t.pong(e,!this._isServer,Dx),t.emit("ping",e)}function DL(e){this[Bt].emit("pong",e)}function Gx(e){e.resume()}function LL(e){let t=this[Bt];t.readyState!==pt.CLOSED&&(t.readyState===pt.OPEN&&(t._readyState=pt.CLOSING,zx(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function zx(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),IL)}function Jx(){let e=this[Bt];this.removeListener("close",Jx),this.removeListener("data",ac),this.removeListener("end",Kx),e._readyState=pt.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Bt]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Nx),e._receiver.on("finish",Nx))}function ac(e){this[Bt]._receiver.write(e)||this.pause()}function Kx(){let e=this[Bt];e._readyState=pt.CLOSING,e._receiver.end(),this.end()}function Bx(){let e=this[Bt];this.removeListener("error",Bx),this.on("error",Dx),e&&(e._readyState=pt.CLOSING,this.destroy())}});var Qx=tt((Cce,Zx)=>{"use strict";var Tce=sc(),{Duplex:UL}=We("stream");function Hx(e){e.emit("close")}function GL(){!this.destroyed&&this._writableState.finished&&this.destroy()}function Vx(e){this.removeListener("error",Vx),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function zL(e,t){let n=!0,i=new UL({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&i._readableState.objectMode?o.toString():o;i.push(s)||e.pause()}),e.once("error",function(o){i.destroyed||(n=!1,i.destroy(o))}),e.once("close",function(){i.destroyed||i.push(null)}),i._destroy=function(r,o){if(e.readyState===e.CLOSED){o(r),process.nextTick(Hx,i);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(r),process.nextTick(Hx,i)}),n&&e.terminate()},i._final=function(r){if(e.readyState===e.CONNECTING){e.once("open",function(){i._final(r)});return}e._socket!==null&&(e._socket._writableState.finished?(r(),i._readableState.endEmitted&&i.destroy()):(e._socket.once("finish",function(){r()}),e.close()))},i._read=function(){e.isPaused&&e.resume()},i._write=function(r,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){i._write(r,o,a)});return}e.send(r,a)},i.on("end",GL),i.on("error",Vx),i}Zx.exports=zL});var Xx=tt((Ace,Yx)=>{"use strict";var{tokenChars:JL}=ya();function KL(e){let t=new Set,n=-1,i=-1,r=0;for(r;r<e.length;r++){let a=e.charCodeAt(r);if(i===-1&&JL[a]===1)n===-1&&(n=r);else if(r!==0&&(a===32||a===9))i===-1&&n!==-1&&(i=r);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${r}`);i===-1&&(i=r);let s=e.slice(n,i);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=i=-1}else throw new SyntaxError(`Unexpected character at index ${r}`)}if(n===-1||i!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,r);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}Yx.exports={parse:KL}});var a0=tt((Pce,o0)=>{"use strict";var BL=We("events"),dc=We("http"),{Duplex:Ece}=We("stream"),{createHash:WL}=We("crypto"),e0=Oh(),mo=Xs(),HL=Xx(),VL=sc(),{GUID:ZL,kWebSocket:QL}=ai(),YL=/^[+/0-9A-Za-z]{22}==$/,t0=0,n0=1,i0=2,qh=class extends BL{constructor(t,n){if(super(),t={allowSynchronousEvents:!0,autoPong:!0,maxPayload:100*1024*1024,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:VL,...t},t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=dc.createServer((i,r)=>{let o=dc.STATUS_CODES[426];r.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),r.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let i=this.emit.bind(this,"connection");this._removeListeners=XL(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(r,o,a)=>{this.handleUpgrade(r,o,a,i)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=t0}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(this._state===i0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(rd,this);return}if(t&&this.once("close",t),this._state!==n0)if(this._state=n0,this.options.noServer||this.options.server)this._server&&(this._removeListeners(),this._removeListeners=this._server=null),this.clients?this.clients.size?this._shouldEmitClose=!0:process.nextTick(rd,this):process.nextTick(rd,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{rd(this)})}}shouldHandle(t){if(this.options.path){let n=t.url.indexOf("?");if((n!==-1?t.url.slice(0,n):t.url)!==this.options.path)return!1}return!0}handleUpgrade(t,n,i,r){n.on("error",r0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){ho(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){ho(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!YL.test(o)){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){ho(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){id(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=HL.parse(d)}catch{ho(this,t,n,400,"Invalid Sec-WebSocket-Protocol header");return}let u=t.headers["sec-websocket-extensions"],c={};if(this.options.perMessageDeflate&&u!==void 0){let p=new mo(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let f=e0.parse(u);f[mo.extensionName]&&(p.accept(f[mo.extensionName]),c[mo.extensionName]=p)}catch{ho(this,t,n,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let p={origin:t.headers[`${s===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(p,(f,h,g,_)=>{if(!f)return id(n,h||401,g,_);this.completeUpgrade(c,o,l,t,n,i,r)});return}if(!this.options.verifyClient(p))return id(n,401)}this.completeUpgrade(c,o,l,t,n,i,r)}completeUpgrade(t,n,i,r,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[QL])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>t0)return id(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${WL("sha1").update(n+ZL).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(i.size){let c=this.options.handleProtocols?this.options.handleProtocols(i,r):i.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[mo.extensionName]){let c=t[mo.extensionName].params,p=e0.format({[mo.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,r),o.write(l.concat(`\r
|
|
5
5
|
`).join(`\r
|
|
6
6
|
`)),o.removeListener("error",r0),u.setSocket(o,a,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients&&(this.clients.add(u),u.on("close",()=>{this.clients.delete(u),this._shouldEmitClose&&!this.clients.size&&process.nextTick(rd,this)})),s(u,r)}};o0.exports=qh;function XL(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let i of Object.keys(t))e.removeListener(i,t[i])}}function rd(e){e._state=i0,e.emit("close")}function r0(){this.destroy()}function id(e,t,n,i){n=n||dc.STATUS_CODES[t],i={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...i},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${dc.STATUS_CODES[t]}\r
|
|
7
7
|
`+Object.keys(i).map(r=>`${r}: ${i[r]}`).join(`\r
|