@linzumi/cli 1.0.307 → 1.0.308
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 +23 -34
- package/dist/cloud-supervisor.mjs +1 -1
- package/dist/hosted-coding-account-worker.js +1 -1
- package/dist/index.js +349 -349
- package/dist/mcp-server.mjs +41 -41
- package/dist/remote-codex-harness-worker.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -54,39 +54,28 @@ the work side runs locally. This npm package is the local half.
|
|
|
54
54
|
|
|
55
55
|
## What's new in this release
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
This also keeps every fix from 1.0.306 and earlier: the recovery-restart
|
|
80
|
-
repair (the supervisor starts the replacement instead of draining forever),
|
|
81
|
-
Stop on a thread whose finished turn still holds its agent process, bounded
|
|
82
|
-
Stop retirement, replay of a finished answer whose acknowledgment was lost,
|
|
83
|
-
the permission-request tools, the "Still restoring" and "Needs attention" rows
|
|
84
|
-
(with Retry), steering-aware recovery, and the earlier reconnect, startup and
|
|
85
|
-
journal-cleanup improvements. Update Commander to use these changes;
|
|
86
|
-
publishing the package does not restart an already running Commander. As with
|
|
87
|
-
1.0.306, the recovery-restart repair runs only once the supervisor process
|
|
88
|
-
itself runs 1.0.306 or later, so a supervisor still on older code needs
|
|
89
|
-
`connect --supervise` relaunched from a current CLI, for example
|
|
57
|
+
- Files your coding agent generates in a Linzumi task worktree (the
|
|
58
|
+
`~/.linzumi/worktrees/<repository>/<task>` checkouts) can now be uploaded
|
|
59
|
+
and attached. Before, those uploads were refused when Commander was started
|
|
60
|
+
from the original checkout. A linked checkout is accepted only when Git
|
|
61
|
+
itself registers it as a worktree of the same repository as the folder
|
|
62
|
+
Commander trusts; a directory's name alone grants nothing. Files in the
|
|
63
|
+
trusted folder and in Downloads work as before, and unrelated repositories,
|
|
64
|
+
unregistered paths, hidden path segments below an accepted folder, symlink
|
|
65
|
+
escapes and non-regular files are still refused.
|
|
66
|
+
|
|
67
|
+
This also keeps everything from 1.0.307 and earlier: the assistant tools for
|
|
68
|
+
sending messages as you, listing valid job-start options with typed start
|
|
69
|
+
refusals, the canonical job archive, and project management (those need a
|
|
70
|
+
Linzumi server that includes #12020 or later); the recovery-restart repair;
|
|
71
|
+
Stop on a thread whose finished turn still holds its agent process; bounded
|
|
72
|
+
Stop retirement; replay of a finished answer whose acknowledgment was lost;
|
|
73
|
+
the permission-request tools; the "Still restoring" and "Needs attention"
|
|
74
|
+
rows; and the earlier reconnect, startup and journal-cleanup improvements.
|
|
75
|
+
Update Commander to use these changes; publishing the package does not restart
|
|
76
|
+
an already running Commander. The recovery-restart repair still requires the
|
|
77
|
+
supervisor process itself to run 1.0.306 or later, so a supervisor on older
|
|
78
|
+
code needs `connect --supervise` relaunched from a current CLI, for example
|
|
90
79
|
`npx -y @linzumi/cli@latest connect --supervise --workspace your-workspace`.
|
|
91
80
|
|
|
92
81
|
## Manual Runner Setup
|
|
@@ -96,7 +85,7 @@ Install the CLI or run it with `npx`:
|
|
|
96
85
|
```bash
|
|
97
86
|
npm install -g @linzumi/cli@latest
|
|
98
87
|
npx -y @linzumi/cli@latest connect --supervise --workspace your-workspace
|
|
99
|
-
npx -y @linzumi/cli@1.0.
|
|
88
|
+
npx -y @linzumi/cli@1.0.308 --version
|
|
100
89
|
linzumi --version
|
|
101
90
|
```
|
|
102
91
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire as __linzumiBundleCreateRequire } from 'node:module';
|
|
2
2
|
const require = __linzumiBundleCreateRequire(import.meta.url);
|
|
3
3
|
var E2=Object.create;var L_=Object.defineProperty;var C2=Object.getOwnPropertyDescriptor;var x2=Object.getOwnPropertyNames;var O2=Object.getPrototypeOf,R2=Object.prototype.hasOwnProperty;var ot=(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 N=(e,t)=>()=>(e&&(t=e(e=0)),t);var yt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),P2=(e,t)=>{for(var n in t)L_(e,n,{get:t[n],enumerable:!0})},I2=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of x2(t))!R2.call(e,i)&&i!==n&&L_(e,i,{get:()=>t[i],enumerable:!(r=C2(t,i))||r.enumerable});return e};var Qr=(e,t,n)=>(n=e!=null?E2(O2(e)):{},I2(t||!e||!e.__esModule?L_(n,"default",{value:e,enumerable:!0}):n,e));var N_=N(()=>{});function gt(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 Xa(e){if(e!=null)return gt(e)}function Ge(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 qe=N(()=>{});function io(e,t){if(e!==void 0)return t(Ge(e))}function an(e,t,n){return e!==void 0?n(Ge(e)):t}function et(e,t){if(e!==void 0)return gt(t(Ge(e)))}function Et(e,t){if(e!==void 0)return t(Ge(e))}function $e(e,t){return e!==void 0?Ge(e):t}var ke=N(()=>{N_();qe()});var af=N(()=>{});function Pt(e,t,n){return e.reduce(n,t)}var at=N(()=>{af();qe()});function Xr(e){if(e.RE_EXN_ID==="JsExn")return gt(e._1)}var sf,D2,ei,JWe,WWe,Ii=N(()=>{qe();sf=(e=>t=>t&&typeof t[e]=="string"?t[e]:void 0),D2=sf("stack"),ei=sf("message"),JWe=sf("name"),WWe=sf("fileName")});var es=N(()=>{});var xE=yt((VWe,CE)=>{var ao=ot("constants"),$2=process.cwd,df=null,L2=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return df||(df=$2.call(process)),df};try{process.cwd()}catch{}typeof process.chdir=="function"&&(F_=process.chdir,process.chdir=function(e){df=null,F_.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,F_));var F_;CE.exports=N2;function N2(e){ao.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=r(e.chmod),e.fchmod=r(e.fchmod),e.lchmod=r(e.lchmod),e.chownSync=a(e.chownSync),e.fchownSync=a(e.fchownSync),e.lchownSync=a(e.lchownSync),e.chmodSync=i(e.chmodSync),e.fchmodSync=i(e.fchmodSync),e.lchmodSync=i(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,m){m&&process.nextTick(m)},e.lchownSync=function(){}),L2==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:(function(u){function c(p,m,y){var h=Date.now(),b=0;u(p,m,function g(S){if(S&&(S.code==="EACCES"||S.code==="EPERM"||S.code==="EBUSY")&&Date.now()-h<6e4){setTimeout(function(){e.stat(m,function(v,T){v&&v.code==="ENOENT"?u(p,m,g):y(S)})},b),b<100&&(b+=10);return}y&&y(S)})}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.rename)),e.read=typeof e.read!="function"?e.read:(function(u){function c(p,m,y,h,b,g){var S;if(g&&typeof g=="function"){var v=0;S=function(T,E,x){if(T&&T.code==="EAGAIN"&&v<10)return v++,u.call(e,p,m,y,h,b,S);g.apply(this,arguments)}}return u.call(e,p,m,y,h,b,S)}return Object.setPrototypeOf&&Object.setPrototypeOf(c,u),c})(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:(function(u){return function(c,p,m,y,h){for(var b=0;;)try{return u.call(e,c,p,m,y,h)}catch(g){if(g.code==="EAGAIN"&&b<10){b++;continue}throw g}}})(e.readSync);function t(u){u.lchmod=function(c,p,m){u.open(c,ao.O_WRONLY|ao.O_SYMLINK,p,function(y,h){if(y){m&&m(y);return}u.fchmod(h,p,function(b){u.close(h,function(g){m&&m(b||g)})})})},u.lchmodSync=function(c,p){var m=u.openSync(c,ao.O_WRONLY|ao.O_SYMLINK,p),y=!0,h;try{h=u.fchmodSync(m,p),y=!1}finally{if(y)try{u.closeSync(m)}catch{}else u.closeSync(m)}return h}}function n(u){ao.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(c,p,m,y){u.open(c,ao.O_SYMLINK,function(h,b){if(h){y&&y(h);return}u.futimes(b,p,m,function(g){u.close(b,function(S){y&&y(g||S)})})})},u.lutimesSync=function(c,p,m){var y=u.openSync(c,ao.O_SYMLINK),h,b=!0;try{h=u.futimesSync(y,p,m),b=!1}finally{if(b)try{u.closeSync(y)}catch{}else u.closeSync(y)}return h}):u.futimes&&(u.lutimes=function(c,p,m,y){y&&process.nextTick(y)},u.lutimesSync=function(){})}function r(u){return u&&function(c,p,m){return u.call(e,c,p,function(y){l(y)&&(y=null),m&&m.apply(this,arguments)})}}function i(u){return u&&function(c,p){try{return u.call(e,c,p)}catch(m){if(!l(m))throw m}}}function o(u){return u&&function(c,p,m,y){return u.call(e,c,p,m,function(h){l(h)&&(h=null),y&&y.apply(this,arguments)})}}function a(u){return u&&function(c,p,m){try{return u.call(e,c,p,m)}catch(y){if(!l(y))throw y}}}function s(u){return u&&function(c,p,m){typeof p=="function"&&(m=p,p=null);function y(h,b){b&&(b.uid<0&&(b.uid+=4294967296),b.gid<0&&(b.gid+=4294967296)),m&&m.apply(this,arguments)}return p?u.call(e,c,p,y):u.call(e,c,y)}}function d(u){return u&&function(c,p){var m=p?u.call(e,c,p):u.call(e,c);return m&&(m.uid<0&&(m.uid+=4294967296),m.gid<0&&(m.gid+=4294967296)),m}}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 PE=yt((ZWe,RE)=>{var OE=ot("stream").Stream;RE.exports=j2;function j2(e){return{ReadStream:t,WriteStream:n};function t(r,i){if(!(this instanceof t))return new t(r,i);OE.call(this);var o=this;this.path=r,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,i=i||{};for(var a=Object.keys(i),s=0,d=a.length;s<d;s++){var l=a[s];this[l]=i[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(r,i){if(!(this instanceof n))return new n(r,i);OE.call(this),this.path=r,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,i=i||{};for(var o=Object.keys(i),a=0,s=o.length;a<s;a++){var d=o[a];this[d]=i[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 ME=yt((YWe,IE)=>{"use strict";IE.exports=G2;var F2=Object.getPrototypeOf||function(e){return e.__proto__};function G2(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:F2(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n))}),t}});var B_=yt((QWe,U_)=>{var Lt=ot("fs"),q2=xE(),U2=PE(),B2=ME(),lf=ot("util"),pn,cf;typeof Symbol=="function"&&typeof Symbol.for=="function"?(pn=Symbol.for("graceful-fs.queue"),cf=Symbol.for("graceful-fs.previous")):(pn="___graceful-fs.queue",cf="___graceful-fs.previous");function z2(){}function LE(e,t){Object.defineProperty(e,pn,{get:function(){return t}})}var Vo=z2;lf.debuglog?Vo=lf.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(Vo=function(){var e=lf.format.apply(lf,arguments);e="GFS4: "+e.split(/\n/).join(`
|
|
4
|
-
GFS4: `),console.error(e)});Lt[pn]||(DE=global[pn]||[],LE(Lt,DE),Lt.close=(function(e){function t(n,r){return e.call(Lt,n,function(i){i||$E(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(t,cf,{value:e}),t})(Lt.close),Lt.closeSync=(function(e){function t(n){e.apply(Lt,arguments),$E()}return Object.defineProperty(t,cf,{value:e}),t})(Lt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Vo(Lt[pn]),ot("assert").equal(Lt[pn].length,0)}));var DE;global[pn]||LE(global,Lt[pn]);U_.exports=G_(B2(Lt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Lt.__patched&&(U_.exports=G_(Lt),Lt.__patched=!0);function G_(e){q2(e),e.gracefulify=G_,e.createReadStream=E,e.createWriteStream=x;var t=e.readFile;e.readFile=n;function n(A,C,O){return typeof C=="function"&&(O=C,C=null),I(A,C,O);function I(P,M,q,ee){return t(P,M,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?ts([I,[P,M,q],Q,ee||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return r(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return o(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(A,C,O,I){return typeof O=="function"&&(I=O,O=0),P(A,C,O,I);function P(M,q,ee,Q,te){return s(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(A,C,O){typeof C=="function"&&(O=C,C=null);var I=u.test(process.version)?function(q,ee,Q,te){return l(q,P(q,ee,Q,te))}:function(q,ee,Q,te){return l(q,ee,P(q,ee,Q,te))};return I(A,C,O);function P(M,q,ee,Q){return function(te,Y){te&&(te.code==="EMFILE"||te.code==="ENFILE")?ts([I,[M,q,ee],te,Q||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof ee=="function"&&ee.call(this,te,Y))}}}if(process.version.substr(0,4)==="v0.8"){var p=U2(e);g=p.ReadStream,v=p.WriteStream}var m=e.ReadStream;m&&(g.prototype=Object.create(m.prototype),g.prototype.open=S);var y=e.WriteStream;y&&(v.prototype=Object.create(y.prototype),v.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return g},set:function(A){g=A},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(A){v=A},enumerable:!0,configurable:!0});var h=g;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(A){h=A},enumerable:!0,configurable:!0});var b=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(A){b=A},enumerable:!0,configurable:!0});function g(A,C){return this instanceof g?(m.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function S(){var A=this;w(A.path,A.flags,A.mode,function(C,O){C?(A.autoClose&&A.destroy(),A.emit("error",C)):(A.fd=O,A.emit("open",O),A.read())})}function v(A,C){return this instanceof v?(y.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function T(){var A=this;w(A.path,A.flags,A.mode,function(C,O){C?(A.destroy(),A.emit("error",C)):(A.fd=O,A.emit("open",O))})}function E(A,C){return new e.ReadStream(A,C)}function x(A,C){return new e.WriteStream(A,C)}var _=e.open;e.open=w;function w(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return _(M,q,ee,function(Y,j){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return e}function ts(e){Vo("ENQUEUE",e[0].name,e[1]),Lt[pn].push(e),q_()}var uf;function $E(){for(var e=Date.now(),t=0;t<Lt[pn].length;++t)Lt[pn][t].length>2&&(Lt[pn][t][3]=e,Lt[pn][t][4]=e);q_()}function q_(){if(clearTimeout(uf),uf=void 0,Lt[pn].length!==0){var e=Lt[pn].shift(),t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)Vo("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-i>=6e4){Vo("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,d=Math.max(o-i,1),l=Math.min(d*1.2,100);s>=l?(Vo("RETRY",t.name,n),t.apply(null,n.concat([i]))):Lt[pn].push(e)}uf===void 0&&(uf=setTimeout(q_,0))}}});var jE=yt((XWe,NE)=>{function ar(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))}NE.exports=ar;ar.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ar.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};ar.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 r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0};ar.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)};ar.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ar.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ar.prototype.start=ar.prototype.try;ar.prototype.errors=function(){return this._errors};ar.prototype.attempts=function(){return this._attempts};ar.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=i,n=a)}return t}});var FE=yt(Zo=>{var K2=jE();Zo.operation=function(e){var t=Zo.timeouts(e);return new K2(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Zo.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 r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(o,a){return o-a}),r};Zo.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};Zo.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var r in e)typeof e[r]=="function"&&n.push(r)}for(var i=0;i<n.length;i++){var o=n[i],a=e[o];e[o]=function(d){var l=Zo.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 qE=yt((t4e,GE)=>{GE.exports=FE()});var UE=yt((n4e,ff)=>{ff.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ff.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ff.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var JE=yt((r4e,is)=>{var It=global.process,Yo=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"};Yo(It)?(BE=ot("assert"),ns=UE(),zE=/^win/i.test(It.platform),ll=ot("events"),typeof ll!="function"&&(ll=ll.EventEmitter),It.__signal_exit_emitter__?sn=It.__signal_exit_emitter__:(sn=It.__signal_exit_emitter__=new ll,sn.count=0,sn.emitted={}),sn.infinite||(sn.setMaxListeners(1/0),sn.infinite=!0),is.exports=function(e,t){if(!Yo(global.process))return function(){};BE.equal(typeof e,"function","a callback must be provided for exit handler"),rs===!1&&z_();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){sn.removeListener(n,e),sn.listeners("exit").length===0&&sn.listeners("afterexit").length===0&&pf()};return sn.on(n,e),r},pf=function(){!rs||!Yo(global.process)||(rs=!1,ns.forEach(function(t){try{It.removeListener(t,mf[t])}catch{}}),It.emit=hf,It.reallyExit=K_,sn.count-=1)},is.exports.unload=pf,Qo=function(t,n,r){sn.emitted[t]||(sn.emitted[t]=!0,sn.emit(t,n,r))},mf={},ns.forEach(function(e){mf[e]=function(){if(Yo(global.process)){var n=It.listeners(e);n.length===sn.count&&(pf(),Qo("exit",null,e),Qo("afterexit",null,e),zE&&e==="SIGHUP"&&(e="SIGINT"),It.kill(It.pid,e))}}}),is.exports.signals=function(){return ns},rs=!1,z_=function(){rs||!Yo(global.process)||(rs=!0,sn.count+=1,ns=ns.filter(function(t){try{return It.on(t,mf[t]),!0}catch{return!1}}),It.emit=HE,It.reallyExit=KE)},is.exports.load=z_,K_=It.reallyExit,KE=function(t){Yo(global.process)&&(It.exitCode=t||0,Qo("exit",It.exitCode,null),Qo("afterexit",It.exitCode,null),K_.call(It,It.exitCode))},hf=It.emit,HE=function(t,n){if(t==="exit"&&Yo(global.process)){n!==void 0&&(It.exitCode=n);var r=hf.apply(this,arguments);return Qo("exit",It.exitCode,null),Qo("afterexit",It.exitCode,null),r}else return hf.apply(this,arguments)}):is.exports=function(){return function(){}};var BE,ns,zE,ll,sn,pf,Qo,mf,rs,z_,K_,KE,hf,HE});var QE=yt((i4e,ul)=>{"use strict";var H2=ot("path"),W_=B_(),J2=qE(),W2=JE(),Mi={};function os(e,t){return t.lockfilePath||`${e}.lock`}function V_(e,t,n){if(!t.realpath)return n(null,H2.resolve(e));t.fs.realpath(e,n)}function H_(e,t,n){t.fs.mkdir(os(e,t),r=>{if(!r)return n();if(r.code!=="EEXIST")return n(r);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(os(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?H_(e,{...t,stale:0},n):n(i);if(!VE(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));ZE(e,t,a=>{if(a)return n(a);H_(e,{...t,stale:0},n)})})})}function VE(e,t){return e.mtime.getTime()<Date.now()-t.stale}function ZE(e,t,n){t.fs.rmdir(os(e,t),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function J_(e,t){let n=Mi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(os(e,t),r,r,i=>{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 WE(e,n,o)}if(i)return i.code==="ENOENT"?WE(e,n,Object.assign(i,{code:"ECOMPROMISED"})):(n.updateError=i,n.updateDelay=1e3,J_(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,J_(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function WE(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Mi[e]===t&&delete Mi[e],t.options.onCompromised(n)}function V2(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:W_,onCompromised:r=>{throw r},...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),V_(e,t,(r,i)=>{if(r)return n(r);let o=J2.operation(t.retries);o.attempt(()=>{H_(i,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=Mi[i]={options:t,lastUpdate:Date.now()};J_(i,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));YE(i,{...t,realpath:!1},d)})})})})}function YE(e,t,n){t={fs:W_,realpath:!0,...t},V_(e,t,(r,i)=>{if(r)return n(r);let o=Mi[i];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 Mi[i],ZE(i,t,n)})}function Z2(e,t,n){t={stale:1e4,realpath:!0,fs:W_,...t},t.stale=Math.max(t.stale||0,2e3),V_(e,t,(r,i)=>{if(r)return n(r);t.fs.stat(os(i,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!VE(a,t)))})}function Y2(){return Mi}W2(()=>{for(let e in Mi){let t=Mi[e].options;try{t.fs.rmdirSync(os(e,t))}catch{}}});ul.exports.lock=V2;ul.exports.unlock=YE;ul.exports.check=Z2;ul.exports.getLocks=Y2});var eC=yt((o4e,XE)=>{"use strict";var Q2=B_();function X2(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(r=>{n[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),n}function eK(e){return(...t)=>new Promise((n,r)=>{t.push((i,o)=>{i?r(i):n(o)}),e(...t)})}function tK(e){return(...t)=>{let n,r;if(t.push((i,o)=>{n=i,r=o}),e(...t),n)throw n;return r}}function nK(e){if(e={...e},e.fs=X2(e.fs||Q2),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}XE.exports={toPromise:eK,toSync:tK,toSyncOptions:nK}});var nC=yt((a4e,so)=>{"use strict";var as=QE(),{toPromise:_f,toSync:yf,toSyncOptions:Z_}=eC();async function tC(e,t){let n=await _f(as.lock)(e,t);return _f(n)}function rK(e,t){let n=yf(as.lock)(e,Z_(t));return yf(n)}function iK(e,t){return _f(as.unlock)(e,t)}function oK(e,t){return yf(as.unlock)(e,Z_(t))}function aK(e,t){return _f(as.check)(e,t)}function sK(e,t){return yf(as.check)(e,Z_(t))}so.exports=tC;so.exports.lock=tC;so.exports.unlock=iK;so.exports.lockSync=rK;so.exports.unlockSync=oK;so.exports.check=aK;so.exports.checkSync=sK});var rC=N(()=>{});var ss=N(()=>{});var Xo=N(()=>{});var Je=N(()=>{rC();ss();Xo()});function lK(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function We(e){return lK(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Q_(e){let t=Y_[e];if(t!==void 0){let n=t+1|0;return Y_[e]=n,e+("/"+n)}return Y_[e]=1,e}var Y_,st=N(()=>{Y_={}});import*as oC from"node:child_process";function Kt(e){let t=Xr(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Ge(t);return{code:Xa(n.code),message:$e(ei(n),"unknown error")}}function aC(e,t,n,r){try{return{TAG:"Ok",_0:oC.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:r})}}catch(i){let o=We(i);return{TAG:"Error",_0:Kt(o)}}}var uK,Ke=N(()=>{Ii();ke();es();uK=Qr(nC(),1);Je();qe();st()});function dC(e){let t=aC(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=sC.exec(t._0);if(n!=null)return Et(n.slice(1)[0],r=>r)}function lC(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 sC,uC=N(()=>{at();Ke();ke();Je();sC=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function fK(e,t){let n=lC(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 cC(e,t){return fK(dC(e),t)}var fC=N(()=>{ke();uC()});var pC,X_=N(()=>{fC();pC=cC});var hC,mC=N(()=>{hC={name:"@linzumi/cli",version:"1.0.307",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/build-*-oracle.mjs","native/darwin/linzumi-terminal-pty-helper","native/darwin/terminal-pty-helper.manifest.json"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","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","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.159.2",blessed:"^0.1.81","ghostty-web":"0.4.0","proper-lockfile":"3.2.0","stream-json":"1.9.1",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 ey,bf=N(()=>{"use strict";mC();ey=hC.dependencies["@openai/codex"]});async function _C(e,t,n){let r;try{e(),r=!0}catch{r=!1}let i;try{await t(),i=!0}catch{i=!1}return r&&i?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function yC(e,t){let n=e.quotaWindow,r=e.credits;if(n===void 0&&r===void 0)return{status:"unavailable",reason:"empty_response"};let i=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:i[0],windowMinutes:i[1],resetsAtMs:i[2],capturedAtMs:t,credits:r}}}var gC=N(()=>{});var bC,vC,SC=N(()=>{gC();bC=_C,vC=yC});function pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ty(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 Wt=N(()=>{"use strict"});var vf=N(()=>{"use strict";Wt()});function AC(e){let t=ti(e.rateLimits)??ti(e.rate_limits)??ti(e.limits)??e,n=[t,...Object.values(t).flatMap(b=>{let g=ti(b);return g===void 0?[]:[g]})],r=n.reduce((b,g)=>{let S=nt(g.usedPercent)??nt(g.used_percent);return S===void 0?b:b===void 0?S:Math.max(b,S)},void 0),o=n.some(b=>nt(b.remaining)===0||nt(b.remainingRequests)===0||nt(b.remaining_requests)===0||nt(b.remainingTokens)===0||nt(b.remaining_tokens)===0||nt(b.retryAfterSeconds)!==void 0||nt(b.retry_after_seconds)!==void 0)?"rejected":r!==void 0&&r>=80?"allowed_warning":"allowed",a=ti(t.primary),s=nt(a?.usedPercent),d=nt(a?.windowDurationMins),l=nt(a?.resetsAt),u=ti(t.credits),c=kC(u?.hasCredits),p=kC(u?.unlimited),m=u?.balance,y=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof m=="string"?m:null},h=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:yK(e)??"seen (no details)",status:o,utilizationPercent:r,...h===void 0?{}:{quotaWindow:h},...y===void 0?{}:{credits:y}}}function yK(e){let t=ti(e.rateLimits)??ti(e.rate_limits)??ti(e.limits)??e,n=wC(t,void 0),r=Object.entries(t).flatMap(([o,a])=>{let s=ti(a);return s===void 0?[]:[wC(s,o)]}),i=[n,...r].filter(o=>o!==void 0);return i.length===0?void 0:i.join(" | ")}function wC(e,t){let n=Ar(e.limitName)??Ar(e.limit_name)??Ar(e.name)??Ar(e.type)??t,r=Ar(e.planType)??Ar(e.plan_type)??Ar(e.plan),i=nt(e.remaining)??nt(e.remainingRequests)??nt(e.remaining_requests)??nt(e.remainingTokens)??nt(e.remaining_tokens),o=nt(e.limit)??nt(e.requestLimit)??nt(e.request_limit)??nt(e.limitRequests)??nt(e.limit_requests)??nt(e.tokenLimit)??nt(e.token_limit)??nt(e.limitTokens)??nt(e.limit_tokens),a=Ar(e.resetAt)??Ar(e.reset_at)??Ar(e.resetsAt)??Ar(e.resets_at)??TC(e.resetsAt)??TC(e.resets_at)??Sf(e.resetAfterSeconds)??Sf(e.reset_after_seconds)??Sf(e.retryAfterSeconds)??Sf(e.retry_after_seconds),s=nt(e.usedPercent)??nt(e.used_percent),d=nt(e.windowDurationMins)??nt(e.window_duration_mins),l=[n,r].filter(m=>m!==void 0).join(" "),u=l===""?void 0:l,p=[i===void 0?void 0:o===void 0?`${i} remaining`:`${i}/${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(m=>m!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Sf(e){let t=nt(e);return t===void 0?void 0:`${t}s`}function TC(e){let t=nt(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function ti(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Ar(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function kC(e){return typeof e=="boolean"?e:void 0}function nt(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 EC=N(()=>{"use strict";vf();Wt()});var Di=yt((T4e,OC)=>{"use strict";var CC=["nodebuffer","arraybuffer","fragments"],xC=typeof Blob<"u";xC&&CC.push("blob");OC.exports={BINARY_TYPES:CC,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:xC,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ml=yt((k4e,wf)=>{"use strict";var{EMPTY_BUFFER:gK}=Di(),ny=Buffer[Symbol.species];function bK(e,t){if(e.length===0)return gK;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let i=0;i<e.length;i++){let o=e[i];n.set(o,r),r+=o.length}return r<t?new ny(n.buffer,n.byteOffset,r):n}function RC(e,t,n,r,i){for(let o=0;o<i;o++)n[r+o]=e[o]^t[o&3]}function PC(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function vK(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function ry(e){if(ry.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new ny(e):ArrayBuffer.isView(e)?t=new ny(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),ry.readOnly=!1),t}wf.exports={concat:bK,mask:RC,toArrayBuffer:vK,toBuffer:ry,unmask:PC};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=ot("bufferutil");wf.exports.mask=function(t,n,r,i,o){o<48?RC(t,n,r,i,o):e.mask(t,n,r,i,o)},wf.exports.unmask=function(t,n){t.length<32?PC(t,n):e.unmask(t,n)}}catch{}});var DC=yt((A4e,MC)=>{"use strict";var IC=Symbol("kDone"),iy=Symbol("kRun"),oy=class{constructor(t){this[IC]=()=>{this.pending--,this[iy]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[iy]()}[iy](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[IC])}}};MC.exports=oy});var _l=yt((E4e,jC)=>{"use strict";var hl=ot("zlib"),$C=ml(),SK=DC(),{kStatusCode:LC}=Di(),wK=Buffer[Symbol.species],TK=Buffer.from([0,0,255,255]),kf=Symbol("permessage-deflate"),$i=Symbol("total-length"),ls=Symbol("callback"),lo=Symbol("buffers"),us=Symbol("error"),Tf,ay=class{constructor(t,n,r){if(this._maxPayload=r|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,!Tf){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Tf=new SK(i)}}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[ls];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,r=t.find(i=>!(n.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>i.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}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(r=>{let i=n[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=i})}),t}decompress(t,n,r){Tf.add(i=>{this._decompress(t,n,(o,a)=>{i(),r(o,a)})})}compress(t,n,r){Tf.add(i=>{this._compress(t,n,(o,a)=>{i(),r(o,a)})})}_decompress(t,n,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?hl.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=hl.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[kf]=this,this._inflate[$i]=0,this._inflate[lo]=[],this._inflate.on("error",AK),this._inflate.on("data",NC)}this._inflate[ls]=r,this._inflate.write(t),n&&this._inflate.write(TK),this._inflate.flush(()=>{let o=this._inflate[us];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=$C.concat(this._inflate[lo],this._inflate[$i]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$i]=0,this._inflate[lo]=[],n&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,a)})}_compress(t,n,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?hl.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=hl.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[$i]=0,this._deflate[lo]=[],this._deflate.on("data",kK)}this._deflate[ls]=r,this._deflate.write(t),this._deflate.flush(hl.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=$C.concat(this._deflate[lo],this._deflate[$i]);n&&(o=new wK(o.buffer,o.byteOffset,o.length-4)),this._deflate[ls]=null,this._deflate[$i]=0,this._deflate[lo]=[],n&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};jC.exports=ay;function kK(e){this[lo].push(e),this[$i]+=e.length}function NC(e){if(this[$i]+=e.length,this[kf]._maxPayload<1||this[$i]<=this[kf]._maxPayload){this[lo].push(e);return}this[us]=new RangeError("Max payload size exceeded"),this[us].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[us][LC]=1009,this.removeListener("data",NC),this.reset()}function AK(e){if(this[kf]._inflate=null,this[us]){this[ls](this[us]);return}e[LC]=1007,this[ls](e)}});var cs=yt((C4e,Af)=>{"use strict";var{isUtf8:FC}=ot("buffer"),{hasBlob:EK}=Di(),CK=[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 xK(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function sy(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 OK(e){return EK&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Af.exports={isBlob:OK,isValidStatusCode:xK,isValidUTF8:sy,tokenChars:CK};if(FC)Af.exports.isValidUTF8=function(e){return e.length<24?sy(e):FC(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=ot("utf-8-validate");Af.exports.isValidUTF8=function(t){return t.length<32?sy(t):e(t)}}catch{}});var fy=yt((x4e,HC)=>{"use strict";var{Writable:RK}=ot("stream"),GC=_l(),{BINARY_TYPES:PK,EMPTY_BUFFER:qC,kStatusCode:IK,kWebSocket:MK}=Di(),{concat:dy,toArrayBuffer:DK,unmask:$K}=ml(),{isValidStatusCode:LK,isValidUTF8:UC}=cs(),Ef=Buffer[Symbol.species],sr=0,BC=1,zC=2,KC=3,ly=4,uy=5,Cf=6,cy=class extends RK{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||PK[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[MK]=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=sr}_write(t,n,r){if(this._opcode===8&&this._state==sr)return r();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Ef(r.buffer,r.byteOffset+t,r.length-t),new Ef(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],i=n.length-t;t>=r.length?n.set(this._buffers.shift(),i):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),i),this._buffers[0]=new Ef(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case sr:this.getInfo(t);break;case BC:this.getPayloadLength16(t);break;case zC:this.getPayloadLength64(t);break;case KC:this.getMask();break;case ly:this.getData(t);break;case uy:case Cf: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 i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let r=(n[0]&64)===64;if(r&&!this._extensions[GC.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=BC:this._payloadLength===127?this._state=zC: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),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=r*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=KC:this._state=ly}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ly}getData(t){let n=qC;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&&$K(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=uy,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[GC.extensionName].decompress(t,this._fin,(i,o)=>{if(i)return n(i);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===sr&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=sr;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=dy(r,n):this._binaryType==="arraybuffer"?i=DK(dy(r,n)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit("message",i,!0),this._state=sr,this.startLoop(t)}))}else{let i=dy(r,n);if(!this._skipUTF8Validation&&!UC(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===uy||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit("message",i,!1),this._state=sr,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,qC),this.end();else{let r=t.readUInt16BE(0);if(!LK(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let i=new Ef(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!UC(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=sr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=sr,this.startLoop(n)}))}createError(t,n,r,i,o){this._loop=!1,this._errored=!0;let a=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[IK]=i,a}};HC.exports=cy});var hy=yt((R4e,VC)=>{"use strict";var{Duplex:O4e}=ot("stream"),{randomFillSync:NK}=ot("crypto"),JC=_l(),{EMPTY_BUFFER:jK,kWebSocket:FK,NOOP:GK}=Di(),{isBlob:fs,isValidStatusCode:qK}=cs(),{mask:WC,toBuffer:ta}=ml(),dr=Symbol("kByteLength"),UK=Buffer.alloc(4),xf=8*1024,na,ps=xf,Er=0,BK=1,zK=2,py=class e{constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Er,this.onerror=GK,this[FK]=void 0}static frame(t,n){let r,i=!1,o=2,a=!1;n.mask&&(r=n.maskBuffer||UK,n.generateMask?n.generateMask(r):(ps===xf&&(na===void 0&&(na=Buffer.alloc(xf)),NK(na,0,xf),ps=0),r[0]=na[ps++],r[1]=na[ps++],r[2]=na[ps++],r[3]=na[ps++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[dr]!==void 0?s=n[dr]:(t=Buffer.from(t),s=t.length):(s=t.length,i=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(i?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]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],a?[l,t]:i?(WC(t,r,l,o,s),[l]):(WC(t,r,t,0,s),[l,t])):[l,t]}close(t,n,r,i){let o;if(t===void 0)o=jK;else{if(typeof t!="number"||!qK(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={[dr]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Er?this.enqueue([this.dispatch,o,!1,a,i]):this.sendFrame(e.frame(o,a),i)}ping(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):fs(t)?(i=t.size,o=!1):(t=ta(t),i=t.length,o=ta.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[dr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Er?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}pong(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):fs(t)?(i=t.size,o=!1):(t=ta(t),i=t.length,o=ta.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[dr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Er?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}send(t,n,r){let i=this._extensions[JC.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):fs(t)?(s=t.size,d=!1):(t=ta(t),s=t.length,d=ta.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=i._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[dr]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==Er?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,i){this._bufferedBytes+=r[dr],this._state=zK,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(my,this,s,i);return}this._bufferedBytes-=r[dr];let a=ta(o);n?this.dispatch(a,n,r,i):(this._state=Er,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(KK,this,o,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let o=this._extensions[JC.extensionName];this._bufferedBytes+=r[dr],this._state=BK,o.compress(t,r.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");my(this,d,i);return}this._bufferedBytes-=r[dr],this._state=Er,r.readOnly=!1,this.sendFrame(e.frame(s,r),i),this.dequeue()})}dequeue(){for(;this._state===Er&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][dr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][dr],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)}};VC.exports=py;function my(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],o=i[i.length-1];typeof o=="function"&&o(t)}}function KK(e,t,n){my(e,t,n),e.onerror(t)}});var i0=yt((P4e,r0)=>{"use strict";var{kForOnEventAttribute:yl,kListener:_y}=Di(),ZC=Symbol("kCode"),YC=Symbol("kData"),QC=Symbol("kError"),XC=Symbol("kMessage"),e0=Symbol("kReason"),ms=Symbol("kTarget"),t0=Symbol("kType"),n0=Symbol("kWasClean"),Li=class{constructor(t){this[ms]=null,this[t0]=t}get target(){return this[ms]}get type(){return this[t0]}};Object.defineProperty(Li.prototype,"target",{enumerable:!0});Object.defineProperty(Li.prototype,"type",{enumerable:!0});var ra=class extends Li{constructor(t,n={}){super(t),this[ZC]=n.code===void 0?0:n.code,this[e0]=n.reason===void 0?"":n.reason,this[n0]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[ZC]}get reason(){return this[e0]}get wasClean(){return this[n0]}};Object.defineProperty(ra.prototype,"code",{enumerable:!0});Object.defineProperty(ra.prototype,"reason",{enumerable:!0});Object.defineProperty(ra.prototype,"wasClean",{enumerable:!0});var hs=class extends Li{constructor(t,n={}){super(t),this[QC]=n.error===void 0?null:n.error,this[XC]=n.message===void 0?"":n.message}get error(){return this[QC]}get message(){return this[XC]}};Object.defineProperty(hs.prototype,"error",{enumerable:!0});Object.defineProperty(hs.prototype,"message",{enumerable:!0});var gl=class extends Li{constructor(t,n={}){super(t),this[YC]=n.data===void 0?null:n.data}get data(){return this[YC]}};Object.defineProperty(gl.prototype,"data",{enumerable:!0});var HK={addEventListener(e,t,n={}){for(let i of this.listeners(e))if(!n[yl]&&i[_y]===t&&!i[yl])return;let r;if(e==="message")r=function(o,a){let s=new gl("message",{data:a?o:o.toString()});s[ms]=this,Of(t,this,s)};else if(e==="close")r=function(o,a){let s=new ra("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[ms]=this,Of(t,this,s)};else if(e==="error")r=function(o){let a=new hs("error",{error:o,message:o.message});a[ms]=this,Of(t,this,a)};else if(e==="open")r=function(){let o=new Li("open");o[ms]=this,Of(t,this,o)};else return;r[yl]=!!n[yl],r[_y]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[_y]===t&&!n[yl]){this.removeListener(e,n);break}}};r0.exports={CloseEvent:ra,ErrorEvent:hs,Event:Li,EventTarget:HK,MessageEvent:gl};function Of(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var yy=yt((I4e,o0)=>{"use strict";var{tokenChars:bl}=cs();function ni(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function JK(e){let t=Object.create(null),n=Object.create(null),r=!1,i=!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&&bl[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 m=e.slice(d,u);l===44?(ni(t,m,n),n=Object.create(null)):a=m,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&bl[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),ni(n,e.slice(d,u),!0),l===44&&(ni(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(i){if(bl[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:r||(r=!0),i=!1}else if(o)if(bl[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)i=!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&&bl[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 m=e.slice(d,u);r&&(m=m.replace(/\\/g,""),r=!1),ni(n,s,m),l===44&&(ni(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?ni(t,p,n):(s===void 0?ni(n,p,!0):r?ni(n,s,p.replace(/\\/g,"")):ni(n,s,p),ni(t,a,n)),t}function WK(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}o0.exports={format:WK,parse:JK}});var Mf=yt(($4e,y0)=>{"use strict";var VK=ot("events"),ZK=ot("https"),YK=ot("http"),d0=ot("net"),QK=ot("tls"),{randomBytes:XK,createHash:eH}=ot("crypto"),{Duplex:M4e,Readable:D4e}=ot("stream"),{URL:gy}=ot("url"),uo=_l(),tH=fy(),nH=hy(),{isBlob:rH}=cs(),{BINARY_TYPES:a0,EMPTY_BUFFER:Rf,GUID:iH,kForOnEventAttribute:by,kListener:oH,kStatusCode:aH,kWebSocket:dn,NOOP:l0}=Di(),{EventTarget:{addEventListener:sH,removeEventListener:dH}}=i0(),{format:lH,parse:uH}=yy(),{toBuffer:cH}=ml(),fH=30*1e3,u0=Symbol("kAborted"),vy=[8,13],Ni=["CONNECTING","OPEN","CLOSING","CLOSED"],pH=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Mt=class e extends VK{constructor(t,n,r){super(),this._binaryType=a0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Rf,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?(r=n,n=[]):n=[n]),c0(this,t,n,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){a0.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,r){let i=new tH({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new nH(t,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=t,i[dn]=this,o[dn]=this,t[dn]=this,i.on("conclude",_H),i.on("drain",yH),i.on("error",gH),i.on("message",bH),i.on("ping",vH),i.on("pong",SH),o.onerror=wH,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",m0),t.on("data",If),t.on("end",h0),t.on("error",_0),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[uo.extensionName]&&this._extensions[uo.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){Jn(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,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),p0(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||Rf,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||Rf,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[uo.extensionName]||(i.compress=!1),this._sender.send(t||Rf,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Jn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Mt,"CONNECTING",{enumerable:!0,value:Ni.indexOf("CONNECTING")});Object.defineProperty(Mt.prototype,"CONNECTING",{enumerable:!0,value:Ni.indexOf("CONNECTING")});Object.defineProperty(Mt,"OPEN",{enumerable:!0,value:Ni.indexOf("OPEN")});Object.defineProperty(Mt.prototype,"OPEN",{enumerable:!0,value:Ni.indexOf("OPEN")});Object.defineProperty(Mt,"CLOSING",{enumerable:!0,value:Ni.indexOf("CLOSING")});Object.defineProperty(Mt.prototype,"CLOSING",{enumerable:!0,value:Ni.indexOf("CLOSING")});Object.defineProperty(Mt,"CLOSED",{enumerable:!0,value:Ni.indexOf("CLOSED")});Object.defineProperty(Mt.prototype,"CLOSED",{enumerable:!0,value:Ni.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Mt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Mt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[by])return t[oH];return null},set(t){for(let n of this.listeners(e))if(n[by]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[by]:!0})}})});Mt.prototype.addEventListener=sH;Mt.prototype.removeEventListener=dH;y0.exports=Mt;function c0(e,t,n,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:vy[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!vy.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${vy.join(", ")})`);let o;if(t instanceof gy)o=t;else try{o=new gy(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 h=new SyntaxError(d);if(e._redirects===0)throw h;Pf(e,h);return}let l=a?443:80,u=XK(16).toString("base64"),c=a?ZK.request:YK.request,p=new Set,m;if(i.createConnection=i.createConnection||(a?hH:mH),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new uo(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=lH({[uo.extensionName]:m.offer()})),n.length){for(let h of n){if(typeof h!="string"||!pH.test(h)||p.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(h)}i.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),s){let h=i.path.split(":");i.socketPath=h[0],i.path=h[1]}let y;if(i.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?i.socketPath:o.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[b,g]of Object.entries(h))r.headers[b.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=s?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,h||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),y=e._req=c(i),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=c(i);i.timeout&&y.on("timeout",()=>{Jn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[u0]||(y=e._req=null,Pf(e,h))}),y.on("response",h=>{let b=h.headers.location,g=h.statusCode;if(b&&i.followRedirects&&g>=300&&g<400){if(++e._redirects>i.maxRedirects){Jn(e,y,"Maximum redirects exceeded");return}y.abort();let S;try{S=new gy(b,t)}catch{let T=new SyntaxError(`Invalid URL: ${b}`);Pf(e,T);return}c0(e,S,n,r)}else e.emit("unexpected-response",y,h)||Jn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,b,g)=>{if(e.emit("upgrade",h),e.readyState!==Mt.CONNECTING)return;y=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Jn(e,b,"Invalid Upgrade header");return}let v=eH("sha1").update(u+iH).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Jn(e,b,"Invalid Sec-WebSocket-Accept header");return}let T=h.headers["sec-websocket-protocol"],E;if(T!==void 0?p.size?p.has(T)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":p.size&&(E="Server sent no subprotocol"),E){Jn(e,b,E);return}T&&(e._protocol=T);let x=h.headers["sec-websocket-extensions"];if(x!==void 0){if(!m){Jn(e,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let _;try{_=uH(x)}catch{Jn(e,b,"Invalid Sec-WebSocket-Extensions header");return}let w=Object.keys(_);if(w.length!==1||w[0]!==uo.extensionName){Jn(e,b,"Server indicated an extension that was not requested");return}try{m.accept(_[uo.extensionName])}catch{Jn(e,b,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[uo.extensionName]=m}e.setSocket(b,g,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(y,e):y.end()}function Pf(e,t){e._readyState=Mt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function mH(e){return e.path=e.socketPath,d0.connect(e)}function hH(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=d0.isIP(e.host)?"":e.host),QK.connect(e)}function Jn(e,t,n){e._readyState=Mt.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Jn),t.setHeader?(t[u0]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Pf,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Sy(e,t,n){if(t){let r=rH(t)?t.size:cH(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${Ni[e.readyState]})`);process.nextTick(n,r)}}function _H(e,t){let n=this[dn];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dn]!==void 0&&(n._socket.removeListener("data",If),process.nextTick(f0,n._socket),e===1005?n.close():n.close(e,t))}function yH(){let e=this[dn];e.isPaused||e._socket.resume()}function gH(e){let t=this[dn];t._socket[dn]!==void 0&&(t._socket.removeListener("data",If),process.nextTick(f0,t._socket),t.close(e[aH])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function s0(){this[dn].emitClose()}function bH(e,t){this[dn].emit("message",e,t)}function vH(e){let t=this[dn];t._autoPong&&t.pong(e,!this._isServer,l0),t.emit("ping",e)}function SH(e){this[dn].emit("pong",e)}function f0(e){e.resume()}function wH(e){let t=this[dn];t.readyState!==Mt.CLOSED&&(t.readyState===Mt.OPEN&&(t._readyState=Mt.CLOSING,p0(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function p0(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),fH)}function m0(){let e=this[dn];this.removeListener("close",m0),this.removeListener("data",If),this.removeListener("end",h0),e._readyState=Mt.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[dn]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",s0),e._receiver.on("finish",s0))}function If(e){this[dn]._receiver.write(e)||this.pause()}function h0(){let e=this[dn];e._readyState=Mt.CLOSING,e._receiver.end(),this.end()}function _0(){let e=this[dn];this.removeListener("error",_0),this.on("error",l0),e&&(e._readyState=Mt.CLOSING,this.destroy())}});var S0=yt((N4e,v0)=>{"use strict";var L4e=Mf(),{Duplex:TH}=ot("stream");function g0(e){e.emit("close")}function kH(){!this.destroyed&&this._writableState.finished&&this.destroy()}function b0(e){this.removeListener("error",b0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function AH(e,t){let n=!0,r=new TH({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&r._readableState.objectMode?o.toString():o;r.push(s)||e.pause()}),e.once("error",function(o){r.destroyed||(n=!1,r.destroy(o))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(e.readyState===e.CLOSED){o(i),process.nextTick(g0,r);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(i),process.nextTick(g0,r)}),n&&e.terminate()},r._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(i)});return}e._socket!==null&&(e._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){i()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(i,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(i,o,a)});return}e.send(i,a)},r.on("end",kH),r.on("error",b0),r}v0.exports=AH});var T0=yt((j4e,w0)=>{"use strict";var{tokenChars:EH}=cs();function CH(e){let t=new Set,n=-1,r=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(r===-1&&EH[a]===1)n===-1&&(n=i);else if(i!==0&&(a===32||a===9))r===-1&&n!==-1&&(r=i);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,i);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}w0.exports={parse:CH}});var R0=yt((G4e,O0)=>{"use strict";var xH=ot("events"),Df=ot("http"),{Duplex:F4e}=ot("stream"),{createHash:OH}=ot("crypto"),k0=yy(),ia=_l(),RH=T0(),PH=Mf(),{GUID:IH,kWebSocket:MH}=Di(),DH=/^[+/0-9A-Za-z]{22}==$/,A0=0,E0=1,x0=2,wy=class extends xH{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:PH,...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=Df.createServer((r,i)=>{let o=Df.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=$H(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,a)=>{this.handleUpgrade(i,o,a,r)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=A0}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===x0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(vl,this);return}if(t&&this.once("close",t),this._state!==E0)if(this._state=E0,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(vl,this):process.nextTick(vl,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{vl(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,r,i){n.on("error",C0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){oa(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){oa(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!DH.test(o)){oa(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){oa(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Sl(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=RH.parse(d)}catch{oa(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 ia(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=k0.parse(u);m[ia.extensionName]&&(p.accept(m[ia.extensionName]),c[ia.extensionName]=p)}catch{oa(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,(m,y,h,b)=>{if(!m)return Sl(n,y||401,h,b);this.completeUpgrade(c,o,l,t,n,r,i)});return}if(!this.options.verifyClient(p))return Sl(n,401)}this.completeUpgrade(c,o,l,t,n,r,i)}completeUpgrade(t,n,r,i,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[MH])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>A0)return Sl(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${OH("sha1").update(n+IH).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[ia.extensionName]){let c=t[ia.extensionName].params,p=k0.format({[ia.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,i),o.write(l.concat(`\r
|
|
4
|
+
GFS4: `),console.error(e)});Lt[pn]||(DE=global[pn]||[],LE(Lt,DE),Lt.close=(function(e){function t(n,r){return e.call(Lt,n,function(i){i||$E(),typeof r=="function"&&r.apply(this,arguments)})}return Object.defineProperty(t,cf,{value:e}),t})(Lt.close),Lt.closeSync=(function(e){function t(n){e.apply(Lt,arguments),$E()}return Object.defineProperty(t,cf,{value:e}),t})(Lt.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Vo(Lt[pn]),ot("assert").equal(Lt[pn].length,0)}));var DE;global[pn]||LE(global,Lt[pn]);U_.exports=G_(B2(Lt));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!Lt.__patched&&(U_.exports=G_(Lt),Lt.__patched=!0);function G_(e){q2(e),e.gracefulify=G_,e.createReadStream=E,e.createWriteStream=x;var t=e.readFile;e.readFile=n;function n(A,C,O){return typeof C=="function"&&(O=C,C=null),I(A,C,O);function I(P,M,q,ee){return t(P,M,function(Q){Q&&(Q.code==="EMFILE"||Q.code==="ENFILE")?ts([I,[P,M,q],Q,ee||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var r=e.writeFile;e.writeFile=i;function i(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return r(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var o=e.appendFile;o&&(e.appendFile=a);function a(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return o(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var s=e.copyFile;s&&(e.copyFile=d);function d(A,C,O,I){return typeof O=="function"&&(I=O,O=0),P(A,C,O,I);function P(M,q,ee,Q,te){return s(M,q,ee,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}var l=e.readdir;e.readdir=c;var u=/^v[0-5]\./;function c(A,C,O){typeof C=="function"&&(O=C,C=null);var I=u.test(process.version)?function(q,ee,Q,te){return l(q,P(q,ee,Q,te))}:function(q,ee,Q,te){return l(q,ee,P(q,ee,Q,te))};return I(A,C,O);function P(M,q,ee,Q){return function(te,Y){te&&(te.code==="EMFILE"||te.code==="ENFILE")?ts([I,[M,q,ee],te,Q||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof ee=="function"&&ee.call(this,te,Y))}}}if(process.version.substr(0,4)==="v0.8"){var p=U2(e);g=p.ReadStream,v=p.WriteStream}var m=e.ReadStream;m&&(g.prototype=Object.create(m.prototype),g.prototype.open=S);var y=e.WriteStream;y&&(v.prototype=Object.create(y.prototype),v.prototype.open=T),Object.defineProperty(e,"ReadStream",{get:function(){return g},set:function(A){g=A},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return v},set:function(A){v=A},enumerable:!0,configurable:!0});var h=g;Object.defineProperty(e,"FileReadStream",{get:function(){return h},set:function(A){h=A},enumerable:!0,configurable:!0});var b=v;Object.defineProperty(e,"FileWriteStream",{get:function(){return b},set:function(A){b=A},enumerable:!0,configurable:!0});function g(A,C){return this instanceof g?(m.apply(this,arguments),this):g.apply(Object.create(g.prototype),arguments)}function S(){var A=this;w(A.path,A.flags,A.mode,function(C,O){C?(A.autoClose&&A.destroy(),A.emit("error",C)):(A.fd=O,A.emit("open",O),A.read())})}function v(A,C){return this instanceof v?(y.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function T(){var A=this;w(A.path,A.flags,A.mode,function(C,O){C?(A.destroy(),A.emit("error",C)):(A.fd=O,A.emit("open",O))})}function E(A,C){return new e.ReadStream(A,C)}function x(A,C){return new e.WriteStream(A,C)}var _=e.open;e.open=w;function w(A,C,O,I){return typeof O=="function"&&(I=O,O=null),P(A,C,O,I);function P(M,q,ee,Q,te){return _(M,q,ee,function(Y,j){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?ts([P,[M,q,ee,Q],Y,te||Date.now(),Date.now()]):typeof Q=="function"&&Q.apply(this,arguments)})}}return e}function ts(e){Vo("ENQUEUE",e[0].name,e[1]),Lt[pn].push(e),q_()}var uf;function $E(){for(var e=Date.now(),t=0;t<Lt[pn].length;++t)Lt[pn][t].length>2&&(Lt[pn][t][3]=e,Lt[pn][t][4]=e);q_()}function q_(){if(clearTimeout(uf),uf=void 0,Lt[pn].length!==0){var e=Lt[pn].shift(),t=e[0],n=e[1],r=e[2],i=e[3],o=e[4];if(i===void 0)Vo("RETRY",t.name,n),t.apply(null,n);else if(Date.now()-i>=6e4){Vo("TIMEOUT",t.name,n);var a=n.pop();typeof a=="function"&&a.call(null,r)}else{var s=Date.now()-o,d=Math.max(o-i,1),l=Math.min(d*1.2,100);s>=l?(Vo("RETRY",t.name,n),t.apply(null,n.concat([i]))):Lt[pn].push(e)}uf===void 0&&(uf=setTimeout(q_,0))}}});var jE=yt((XWe,NE)=>{function ar(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))}NE.exports=ar;ar.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts};ar.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null};ar.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 r=this,i=setTimeout(function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout(function(){r._operationTimeoutCb(r._attempts)},r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)},n);return this._options.unref&&i.unref(),!0};ar.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)};ar.prototype.try=function(e){console.log("Using RetryOperation.try() is deprecated"),this.attempt(e)};ar.prototype.start=function(e){console.log("Using RetryOperation.start() is deprecated"),this.attempt(e)};ar.prototype.start=ar.prototype.try;ar.prototype.errors=function(){return this._errors};ar.prototype.attempts=function(){return this._attempts};ar.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],o=i.message,a=(e[o]||0)+1;e[o]=a,a>=n&&(t=i,n=a)}return t}});var FE=yt(Zo=>{var K2=jE();Zo.operation=function(e){var t=Zo.timeouts(e);return new K2(t,{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})};Zo.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 r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort(function(o,a){return o-a}),r};Zo.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*Math.pow(t.factor,e));return r=Math.min(r,t.maxTimeout),r};Zo.wrap=function(e,t,n){if(t instanceof Array&&(n=t,t=null),!n){n=[];for(var r in e)typeof e[r]=="function"&&n.push(r)}for(var i=0;i<n.length;i++){var o=n[i],a=e[o];e[o]=function(d){var l=Zo.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 qE=yt((t4e,GE)=>{GE.exports=FE()});var UE=yt((n4e,ff)=>{ff.exports=["SIGABRT","SIGALRM","SIGHUP","SIGINT","SIGTERM"];process.platform!=="win32"&&ff.exports.push("SIGVTALRM","SIGXCPU","SIGXFSZ","SIGUSR2","SIGTRAP","SIGSYS","SIGQUIT","SIGIOT");process.platform==="linux"&&ff.exports.push("SIGIO","SIGPOLL","SIGPWR","SIGSTKFLT","SIGUNUSED")});var JE=yt((r4e,is)=>{var It=global.process,Yo=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"};Yo(It)?(BE=ot("assert"),ns=UE(),zE=/^win/i.test(It.platform),ll=ot("events"),typeof ll!="function"&&(ll=ll.EventEmitter),It.__signal_exit_emitter__?sn=It.__signal_exit_emitter__:(sn=It.__signal_exit_emitter__=new ll,sn.count=0,sn.emitted={}),sn.infinite||(sn.setMaxListeners(1/0),sn.infinite=!0),is.exports=function(e,t){if(!Yo(global.process))return function(){};BE.equal(typeof e,"function","a callback must be provided for exit handler"),rs===!1&&z_();var n="exit";t&&t.alwaysLast&&(n="afterexit");var r=function(){sn.removeListener(n,e),sn.listeners("exit").length===0&&sn.listeners("afterexit").length===0&&pf()};return sn.on(n,e),r},pf=function(){!rs||!Yo(global.process)||(rs=!1,ns.forEach(function(t){try{It.removeListener(t,mf[t])}catch{}}),It.emit=hf,It.reallyExit=K_,sn.count-=1)},is.exports.unload=pf,Qo=function(t,n,r){sn.emitted[t]||(sn.emitted[t]=!0,sn.emit(t,n,r))},mf={},ns.forEach(function(e){mf[e]=function(){if(Yo(global.process)){var n=It.listeners(e);n.length===sn.count&&(pf(),Qo("exit",null,e),Qo("afterexit",null,e),zE&&e==="SIGHUP"&&(e="SIGINT"),It.kill(It.pid,e))}}}),is.exports.signals=function(){return ns},rs=!1,z_=function(){rs||!Yo(global.process)||(rs=!0,sn.count+=1,ns=ns.filter(function(t){try{return It.on(t,mf[t]),!0}catch{return!1}}),It.emit=HE,It.reallyExit=KE)},is.exports.load=z_,K_=It.reallyExit,KE=function(t){Yo(global.process)&&(It.exitCode=t||0,Qo("exit",It.exitCode,null),Qo("afterexit",It.exitCode,null),K_.call(It,It.exitCode))},hf=It.emit,HE=function(t,n){if(t==="exit"&&Yo(global.process)){n!==void 0&&(It.exitCode=n);var r=hf.apply(this,arguments);return Qo("exit",It.exitCode,null),Qo("afterexit",It.exitCode,null),r}else return hf.apply(this,arguments)}):is.exports=function(){return function(){}};var BE,ns,zE,ll,sn,pf,Qo,mf,rs,z_,K_,KE,hf,HE});var QE=yt((i4e,ul)=>{"use strict";var H2=ot("path"),W_=B_(),J2=qE(),W2=JE(),Mi={};function os(e,t){return t.lockfilePath||`${e}.lock`}function V_(e,t,n){if(!t.realpath)return n(null,H2.resolve(e));t.fs.realpath(e,n)}function H_(e,t,n){t.fs.mkdir(os(e,t),r=>{if(!r)return n();if(r.code!=="EEXIST")return n(r);if(t.stale<=0)return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));t.fs.stat(os(e,t),(i,o)=>{if(i)return i.code==="ENOENT"?H_(e,{...t,stale:0},n):n(i);if(!VE(o,t))return n(Object.assign(new Error("Lock file is already being hold"),{code:"ELOCKED",file:e}));ZE(e,t,a=>{if(a)return n(a);H_(e,{...t,stale:0},n)})})})}function VE(e,t){return e.mtime.getTime()<Date.now()-t.stale}function ZE(e,t,n){t.fs.rmdir(os(e,t),r=>{if(r&&r.code!=="ENOENT")return n(r);n()})}function J_(e,t){let n=Mi[e];n.updateTimeout||(n.updateDelay=n.updateDelay||t.update,n.updateTimeout=setTimeout(()=>{let r=Date.now()/1e3;n.updateTimeout=null,t.fs.utimes(os(e,t),r,r,i=>{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 WE(e,n,o)}if(i)return i.code==="ENOENT"?WE(e,n,Object.assign(i,{code:"ECOMPROMISED"})):(n.updateError=i,n.updateDelay=1e3,J_(e,t));n.lastUpdate=Date.now(),n.updateError=null,n.updateDelay=null,J_(e,t)}})},n.updateDelay),n.updateTimeout.unref&&n.updateTimeout.unref())}function WE(e,t,n){t.released=!0,t.updateTimeout&&clearTimeout(t.updateTimeout),Mi[e]===t&&delete Mi[e],t.options.onCompromised(n)}function V2(e,t,n){t={stale:1e4,update:null,realpath:!0,retries:0,fs:W_,onCompromised:r=>{throw r},...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),V_(e,t,(r,i)=>{if(r)return n(r);let o=J2.operation(t.retries);o.attempt(()=>{H_(i,t,a=>{if(o.retry(a))return;if(a)return n(o.mainError());let s=Mi[i]={options:t,lastUpdate:Date.now()};J_(i,t),n(null,d=>{if(s.released)return d&&d(Object.assign(new Error("Lock is already released"),{code:"ERELEASED"}));YE(i,{...t,realpath:!1},d)})})})})}function YE(e,t,n){t={fs:W_,realpath:!0,...t},V_(e,t,(r,i)=>{if(r)return n(r);let o=Mi[i];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 Mi[i],ZE(i,t,n)})}function Z2(e,t,n){t={stale:1e4,realpath:!0,fs:W_,...t},t.stale=Math.max(t.stale||0,2e3),V_(e,t,(r,i)=>{if(r)return n(r);t.fs.stat(os(i,t),(o,a)=>o?o.code==="ENOENT"?n(null,!1):n(o):n(null,!VE(a,t)))})}function Y2(){return Mi}W2(()=>{for(let e in Mi){let t=Mi[e].options;try{t.fs.rmdirSync(os(e,t))}catch{}}});ul.exports.lock=V2;ul.exports.unlock=YE;ul.exports.check=Z2;ul.exports.getLocks=Y2});var eC=yt((o4e,XE)=>{"use strict";var Q2=B_();function X2(e){let t=["mkdir","realpath","stat","rmdir","utimes"],n={...e};return t.forEach(r=>{n[r]=(...i)=>{let o=i.pop(),a;try{a=e[`${r}Sync`](...i)}catch(s){return o(s)}o(null,a)}}),n}function eK(e){return(...t)=>new Promise((n,r)=>{t.push((i,o)=>{i?r(i):n(o)}),e(...t)})}function tK(e){return(...t)=>{let n,r;if(t.push((i,o)=>{n=i,r=o}),e(...t),n)throw n;return r}}function nK(e){if(e={...e},e.fs=X2(e.fs||Q2),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}XE.exports={toPromise:eK,toSync:tK,toSyncOptions:nK}});var nC=yt((a4e,so)=>{"use strict";var as=QE(),{toPromise:_f,toSync:yf,toSyncOptions:Z_}=eC();async function tC(e,t){let n=await _f(as.lock)(e,t);return _f(n)}function rK(e,t){let n=yf(as.lock)(e,Z_(t));return yf(n)}function iK(e,t){return _f(as.unlock)(e,t)}function oK(e,t){return yf(as.unlock)(e,Z_(t))}function aK(e,t){return _f(as.check)(e,t)}function sK(e,t){return yf(as.check)(e,Z_(t))}so.exports=tC;so.exports.lock=tC;so.exports.unlock=iK;so.exports.lockSync=rK;so.exports.unlockSync=oK;so.exports.check=aK;so.exports.checkSync=sK});var rC=N(()=>{});var ss=N(()=>{});var Xo=N(()=>{});var Je=N(()=>{rC();ss();Xo()});function lK(e){return e==null?!1:typeof e.RE_EXN_ID=="string"}function We(e){return lK(e)?e:{RE_EXN_ID:"JsExn",_1:e}}function Q_(e){let t=Y_[e];if(t!==void 0){let n=t+1|0;return Y_[e]=n,e+("/"+n)}return Y_[e]=1,e}var Y_,st=N(()=>{Y_={}});import*as oC from"node:child_process";function Kt(e){let t=Xr(e);if(t===void 0)return{code:void 0,message:"unknown error"};let n=Ge(t);return{code:Xa(n.code),message:$e(ei(n),"unknown error")}}function aC(e,t,n,r){try{return{TAG:"Ok",_0:oC.execFileSync(e,t,{encoding:"utf8",timeout:n,maxBuffer:r})}}catch(i){let o=We(i);return{TAG:"Error",_0:Kt(o)}}}var uK,Ke=N(()=>{Ii();ke();es();uK=Qr(nC(),1);Je();qe();st()});function dC(e){let t=aC(e,["--version"],1e4,1048576);if(t.TAG!=="Ok")return;let n=sC.exec(t._0);if(n!=null)return Et(n.slice(1)[0],r=>r)}function lC(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 sC,uC=N(()=>{at();Ke();ke();Je();sC=new RegExp("(\\d+\\.\\d+\\.\\d+)")});function fK(e,t){let n=lC(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 cC(e,t){return fK(dC(e),t)}var fC=N(()=>{ke();uC()});var pC,X_=N(()=>{fC();pC=cC});var hC,mC=N(()=>{hC={name:"@linzumi/cli",version:"1.0.308",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/build-*-oracle.mjs","native/darwin/linzumi-terminal-pty-helper","native/darwin/terminal-pty-helper.manifest.json"],scripts:{build:"rescript build ../linzumi-cli-rescript && node scripts/build.mjs","bump-version":"node scripts/bump-cli-version.mjs",test:"pnpm --dir ../linzumi-cli-rescript test && npm run test:operational",typecheck:"rescript build ../linzumi-cli-rescript && tsgo --noEmit -p tsconfig.source.json",prepack:"rescript build -q ../linzumi-cli-rescript && node scripts/build.mjs","pack:dry-run":"npm pack --dry-run","test:operational":"vitest run --config vitest.config.mjs","vendor:codex-app-server-protocol":"tsx scripts/vendor-codex-app-server-protocol.ts","test:startup":"npm run build && node --test --test-concurrency=1 ../linzumi-cli-rescript/src/parity/CommanderStartupRefusalConformance.res.mjs","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","test:agent-source":"LINZUMI_CI_QUARANTINE=0 pnpm exec vitest run --config vitest.config.mjs test/channelSession.test.ts test/kandanQueue.test.ts -t '(retains three busy accepted source snapshots without fusing or interrupting|keeps different accepted agent sources distinct through interrupt pickup)' && pnpm --dir ../linzumi-cli-rescript build && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/AgentOpenaiModelProviderConformance.res.mjs && pnpm --dir ../linzumi-cli-rescript exec node --import tsx src/parity/WorkerMintCredentialConformance.res.mjs","codex:history-table":"node scripts/codex_history_table.mjs","vendor:codex-app-server-protocol:check":"tsx scripts/vendor-codex-app-server-protocol.ts --check"},keywords:["linzumi","kandan","codex","local-runner"],license:"MIT",publishConfig:{access:"public"},dependencies:{"@anthropic-ai/claude-agent-sdk":"0.3.283","@inquirer/prompts":"^7.8.6","@modelcontextprotocol/sdk":"^1.29.0","@openai/codex":"0.159.2",blessed:"^0.1.81","ghostty-web":"0.4.0","proper-lockfile":"3.2.0","stream-json":"1.9.1",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 ey,bf=N(()=>{"use strict";mC();ey=hC.dependencies["@openai/codex"]});async function _C(e,t,n){let r;try{e(),r=!0}catch{r=!1}let i;try{await t(),i=!0}catch{i=!1}return r&&i?{TAG:"Ok",_0:void 0}:(n("hosted_auth_quota_cleanup_failed reason=owned_process_not_confirmed_reaped"),{TAG:"Error",_0:"cleanup_failed"})}function yC(e,t){let n=e.quotaWindow,r=e.credits;if(n===void 0&&r===void 0)return{status:"unavailable",reason:"empty_response"};let i=n!==void 0?[n.usedPercent,n.windowMinutes,n.resetsAtMs]:[void 0,void 0,void 0];return{status:"captured",quotaWindow:{usedPercent:i[0],windowMinutes:i[1],resetsAtMs:i[2],capturedAtMs:t,credits:r}}}var gC=N(()=>{});var bC,vC,SC=N(()=>{gC();bC=_C,vC=yC});function pt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ty(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 Wt=N(()=>{"use strict"});var vf=N(()=>{"use strict";Wt()});function AC(e){let t=ti(e.rateLimits)??ti(e.rate_limits)??ti(e.limits)??e,n=[t,...Object.values(t).flatMap(b=>{let g=ti(b);return g===void 0?[]:[g]})],r=n.reduce((b,g)=>{let S=nt(g.usedPercent)??nt(g.used_percent);return S===void 0?b:b===void 0?S:Math.max(b,S)},void 0),o=n.some(b=>nt(b.remaining)===0||nt(b.remainingRequests)===0||nt(b.remaining_requests)===0||nt(b.remainingTokens)===0||nt(b.remaining_tokens)===0||nt(b.retryAfterSeconds)!==void 0||nt(b.retry_after_seconds)!==void 0)?"rejected":r!==void 0&&r>=80?"allowed_warning":"allowed",a=ti(t.primary),s=nt(a?.usedPercent),d=nt(a?.windowDurationMins),l=nt(a?.resetsAt),u=ti(t.credits),c=kC(u?.hasCredits),p=kC(u?.unlimited),m=u?.balance,y=c===void 0||p===void 0?void 0:{hasCredits:c,unlimited:p,balance:typeof m=="string"?m:null},h=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:yK(e)??"seen (no details)",status:o,utilizationPercent:r,...h===void 0?{}:{quotaWindow:h},...y===void 0?{}:{credits:y}}}function yK(e){let t=ti(e.rateLimits)??ti(e.rate_limits)??ti(e.limits)??e,n=wC(t,void 0),r=Object.entries(t).flatMap(([o,a])=>{let s=ti(a);return s===void 0?[]:[wC(s,o)]}),i=[n,...r].filter(o=>o!==void 0);return i.length===0?void 0:i.join(" | ")}function wC(e,t){let n=Ar(e.limitName)??Ar(e.limit_name)??Ar(e.name)??Ar(e.type)??t,r=Ar(e.planType)??Ar(e.plan_type)??Ar(e.plan),i=nt(e.remaining)??nt(e.remainingRequests)??nt(e.remaining_requests)??nt(e.remainingTokens)??nt(e.remaining_tokens),o=nt(e.limit)??nt(e.requestLimit)??nt(e.request_limit)??nt(e.limitRequests)??nt(e.limit_requests)??nt(e.tokenLimit)??nt(e.token_limit)??nt(e.limitTokens)??nt(e.limit_tokens),a=Ar(e.resetAt)??Ar(e.reset_at)??Ar(e.resetsAt)??Ar(e.resets_at)??TC(e.resetsAt)??TC(e.resets_at)??Sf(e.resetAfterSeconds)??Sf(e.reset_after_seconds)??Sf(e.retryAfterSeconds)??Sf(e.retry_after_seconds),s=nt(e.usedPercent)??nt(e.used_percent),d=nt(e.windowDurationMins)??nt(e.window_duration_mins),l=[n,r].filter(m=>m!==void 0).join(" "),u=l===""?void 0:l,p=[i===void 0?void 0:o===void 0?`${i} remaining`:`${i}/${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(m=>m!==void 0);return p.length===0?u===void 0?void 0:`${u} seen (no details)`:u===void 0?p.join(" "):`${u} ${p.join(" ")}`}function Sf(e){let t=nt(e);return t===void 0?void 0:`${t}s`}function TC(e){let t=nt(e);return t===void 0?void 0:new Date(t*1e3).toISOString()}function ti(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function Ar(e){return typeof e=="string"&&e.trim()!==""?e:void 0}function kC(e){return typeof e=="boolean"?e:void 0}function nt(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 EC=N(()=>{"use strict";vf();Wt()});var Di=yt((T4e,OC)=>{"use strict";var CC=["nodebuffer","arraybuffer","fragments"],xC=typeof Blob<"u";xC&&CC.push("blob");OC.exports={BINARY_TYPES:CC,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:xC,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var ml=yt((k4e,wf)=>{"use strict";var{EMPTY_BUFFER:gK}=Di(),ny=Buffer[Symbol.species];function bK(e,t){if(e.length===0)return gK;if(e.length===1)return e[0];let n=Buffer.allocUnsafe(t),r=0;for(let i=0;i<e.length;i++){let o=e[i];n.set(o,r),r+=o.length}return r<t?new ny(n.buffer,n.byteOffset,r):n}function RC(e,t,n,r,i){for(let o=0;o<i;o++)n[r+o]=e[o]^t[o&3]}function PC(e,t){for(let n=0;n<e.length;n++)e[n]^=t[n&3]}function vK(e){return e.length===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.length)}function ry(e){if(ry.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=new ny(e):ArrayBuffer.isView(e)?t=new ny(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),ry.readOnly=!1),t}wf.exports={concat:bK,mask:RC,toArrayBuffer:vK,toBuffer:ry,unmask:PC};if(!process.env.WS_NO_BUFFER_UTIL)try{let e=ot("bufferutil");wf.exports.mask=function(t,n,r,i,o){o<48?RC(t,n,r,i,o):e.mask(t,n,r,i,o)},wf.exports.unmask=function(t,n){t.length<32?PC(t,n):e.unmask(t,n)}}catch{}});var DC=yt((A4e,MC)=>{"use strict";var IC=Symbol("kDone"),iy=Symbol("kRun"),oy=class{constructor(t){this[IC]=()=>{this.pending--,this[iy]()},this.concurrency=t||1/0,this.jobs=[],this.pending=0}add(t){this.jobs.push(t),this[iy]()}[iy](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[IC])}}};MC.exports=oy});var _l=yt((E4e,jC)=>{"use strict";var hl=ot("zlib"),$C=ml(),SK=DC(),{kStatusCode:LC}=Di(),wK=Buffer[Symbol.species],TK=Buffer.from([0,0,255,255]),kf=Symbol("permessage-deflate"),$i=Symbol("total-length"),ls=Symbol("callback"),lo=Symbol("buffers"),us=Symbol("error"),Tf,ay=class{constructor(t,n,r){if(this._maxPayload=r|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,!Tf){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Tf=new SK(i)}}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[ls];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,r=t.find(i=>!(n.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(n.serverMaxWindowBits===!1||typeof n.serverMaxWindowBits=="number"&&n.serverMaxWindowBits>i.server_max_window_bits)||typeof n.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!r)throw new Error("None of the extension offers can be accepted");return n.serverNoContextTakeover&&(r.server_no_context_takeover=!0),n.clientNoContextTakeover&&(r.client_no_context_takeover=!0),typeof n.serverMaxWindowBits=="number"&&(r.server_max_window_bits=n.serverMaxWindowBits),typeof n.clientMaxWindowBits=="number"?r.client_max_window_bits=n.clientMaxWindowBits:(r.client_max_window_bits===!0||n.clientMaxWindowBits===!1)&&delete r.client_max_window_bits,r}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(r=>{let i=n[r];if(i.length>1)throw new Error(`Parameter "${r}" must have only a single value`);if(i=i[0],r==="client_max_window_bits"){if(i!==!0){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else if(r==="server_max_window_bits"){let o=+i;if(!Number.isInteger(o)||o<8||o>15)throw new TypeError(`Invalid value for parameter "${r}": ${i}`);i=o}else if(r==="client_no_context_takeover"||r==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${r}": ${i}`)}else throw new Error(`Unknown parameter "${r}"`);n[r]=i})}),t}decompress(t,n,r){Tf.add(i=>{this._decompress(t,n,(o,a)=>{i(),r(o,a)})})}compress(t,n,r){Tf.add(i=>{this._compress(t,n,(o,a)=>{i(),r(o,a)})})}_decompress(t,n,r){let i=this._isServer?"client":"server";if(!this._inflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?hl.Z_DEFAULT_WINDOWBITS:this.params[o];this._inflate=hl.createInflateRaw({...this._options.zlibInflateOptions,windowBits:a}),this._inflate[kf]=this,this._inflate[$i]=0,this._inflate[lo]=[],this._inflate.on("error",AK),this._inflate.on("data",NC)}this._inflate[ls]=r,this._inflate.write(t),n&&this._inflate.write(TK),this._inflate.flush(()=>{let o=this._inflate[us];if(o){this._inflate.close(),this._inflate=null,r(o);return}let a=$C.concat(this._inflate[lo],this._inflate[$i]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[$i]=0,this._inflate[lo]=[],n&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),r(null,a)})}_compress(t,n,r){let i=this._isServer?"server":"client";if(!this._deflate){let o=`${i}_max_window_bits`,a=typeof this.params[o]!="number"?hl.Z_DEFAULT_WINDOWBITS:this.params[o];this._deflate=hl.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:a}),this._deflate[$i]=0,this._deflate[lo]=[],this._deflate.on("data",kK)}this._deflate[ls]=r,this._deflate.write(t),this._deflate.flush(hl.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let o=$C.concat(this._deflate[lo],this._deflate[$i]);n&&(o=new wK(o.buffer,o.byteOffset,o.length-4)),this._deflate[ls]=null,this._deflate[$i]=0,this._deflate[lo]=[],n&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),r(null,o)})}};jC.exports=ay;function kK(e){this[lo].push(e),this[$i]+=e.length}function NC(e){if(this[$i]+=e.length,this[kf]._maxPayload<1||this[$i]<=this[kf]._maxPayload){this[lo].push(e);return}this[us]=new RangeError("Max payload size exceeded"),this[us].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[us][LC]=1009,this.removeListener("data",NC),this.reset()}function AK(e){if(this[kf]._inflate=null,this[us]){this[ls](this[us]);return}e[LC]=1007,this[ls](e)}});var cs=yt((C4e,Af)=>{"use strict";var{isUtf8:FC}=ot("buffer"),{hasBlob:EK}=Di(),CK=[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 xK(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function sy(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 OK(e){return EK&&typeof e=="object"&&typeof e.arrayBuffer=="function"&&typeof e.type=="string"&&typeof e.stream=="function"&&(e[Symbol.toStringTag]==="Blob"||e[Symbol.toStringTag]==="File")}Af.exports={isBlob:OK,isValidStatusCode:xK,isValidUTF8:sy,tokenChars:CK};if(FC)Af.exports.isValidUTF8=function(e){return e.length<24?sy(e):FC(e)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let e=ot("utf-8-validate");Af.exports.isValidUTF8=function(t){return t.length<32?sy(t):e(t)}}catch{}});var fy=yt((x4e,HC)=>{"use strict";var{Writable:RK}=ot("stream"),GC=_l(),{BINARY_TYPES:PK,EMPTY_BUFFER:qC,kStatusCode:IK,kWebSocket:MK}=Di(),{concat:dy,toArrayBuffer:DK,unmask:$K}=ml(),{isValidStatusCode:LK,isValidUTF8:UC}=cs(),Ef=Buffer[Symbol.species],sr=0,BC=1,zC=2,KC=3,ly=4,uy=5,Cf=6,cy=class extends RK{constructor(t={}){super(),this._allowSynchronousEvents=t.allowSynchronousEvents!==void 0?t.allowSynchronousEvents:!0,this._binaryType=t.binaryType||PK[0],this._extensions=t.extensions||{},this._isServer=!!t.isServer,this._maxPayload=t.maxPayload|0,this._skipUTF8Validation=!!t.skipUTF8Validation,this[MK]=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=sr}_write(t,n,r){if(this._opcode===8&&this._state==sr)return r();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(r)}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let r=this._buffers[0];return this._buffers[0]=new Ef(r.buffer,r.byteOffset+t,r.length-t),new Ef(r.buffer,r.byteOffset,t)}let n=Buffer.allocUnsafe(t);do{let r=this._buffers[0],i=n.length-t;t>=r.length?n.set(this._buffers.shift(),i):(n.set(new Uint8Array(r.buffer,r.byteOffset,t),i),this._buffers[0]=new Ef(r.buffer,r.byteOffset+t,r.length-t)),t-=r.length}while(t>0);return n}startLoop(t){this._loop=!0;do switch(this._state){case sr:this.getInfo(t);break;case BC:this.getPayloadLength16(t);break;case zC:this.getPayloadLength64(t);break;case KC:this.getMask();break;case ly:this.getData(t);break;case uy:case Cf: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 i=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");t(i);return}let r=(n[0]&64)===64;if(r&&!this._extensions[GC.extensionName]){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._fin=(n[0]&128)===128,this._opcode=n[0]&15,this._payloadLength=n[1]&127,this._opcode===0){if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(!this._fragmented){let i=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}this._compressed=r}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let i=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");t(i);return}if(r){let i=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");t(i);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let i=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");t(i);return}}else{let i=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");t(i);return}if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(n[1]&128)===128,this._isServer){if(!this._masked){let i=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");t(i);return}}else if(this._masked){let i=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");t(i);return}this._payloadLength===126?this._state=BC:this._payloadLength===127?this._state=zC: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),r=n.readUInt32BE(0);if(r>Math.pow(2,21)-1){let i=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");t(i);return}this._payloadLength=r*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=KC:this._state=ly}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=ly}getData(t){let n=qC;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&&$K(n,this._mask)}if(this._opcode>7){this.controlMessage(n,t);return}if(this._compressed){this._state=uy,this.decompress(n,t);return}n.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(n)),this.dataMessage(t)}decompress(t,n){this._extensions[GC.extensionName].decompress(t,this._fin,(i,o)=>{if(i)return n(i);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===sr&&this.startLoop(n)})}dataMessage(t){if(!this._fin){this._state=sr;return}let n=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let i;this._binaryType==="nodebuffer"?i=dy(r,n):this._binaryType==="arraybuffer"?i=DK(dy(r,n)):this._binaryType==="blob"?i=new Blob(r):i=r,this._allowSynchronousEvents?(this.emit("message",i,!0),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit("message",i,!0),this._state=sr,this.startLoop(t)}))}else{let i=dy(r,n);if(!this._skipUTF8Validation&&!UC(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");t(o);return}this._state===uy||this._allowSynchronousEvents?(this.emit("message",i,!1),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit("message",i,!1),this._state=sr,this.startLoop(t)}))}}controlMessage(t,n){if(this._opcode===8){if(t.length===0)this._loop=!1,this.emit("conclude",1005,qC),this.end();else{let r=t.readUInt16BE(0);if(!LK(r)){let o=this.createError(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");n(o);return}let i=new Ef(t.buffer,t.byteOffset+2,t.length-2);if(!this._skipUTF8Validation&&!UC(i)){let o=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");n(o);return}this._loop=!1,this.emit("conclude",r,i),this.end()}this._state=sr;return}this._allowSynchronousEvents?(this.emit(this._opcode===9?"ping":"pong",t),this._state=sr):(this._state=Cf,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",t),this._state=sr,this.startLoop(n)}))}createError(t,n,r,i,o){this._loop=!1,this._errored=!0;let a=new t(r?`Invalid WebSocket frame: ${n}`:n);return Error.captureStackTrace(a,this.createError),a.code=o,a[IK]=i,a}};HC.exports=cy});var hy=yt((R4e,VC)=>{"use strict";var{Duplex:O4e}=ot("stream"),{randomFillSync:NK}=ot("crypto"),JC=_l(),{EMPTY_BUFFER:jK,kWebSocket:FK,NOOP:GK}=Di(),{isBlob:fs,isValidStatusCode:qK}=cs(),{mask:WC,toBuffer:ta}=ml(),dr=Symbol("kByteLength"),UK=Buffer.alloc(4),xf=8*1024,na,ps=xf,Er=0,BK=1,zK=2,py=class e{constructor(t,n,r){this._extensions=n||{},r&&(this._generateMask=r,this._maskBuffer=Buffer.alloc(4)),this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=Er,this.onerror=GK,this[FK]=void 0}static frame(t,n){let r,i=!1,o=2,a=!1;n.mask&&(r=n.maskBuffer||UK,n.generateMask?n.generateMask(r):(ps===xf&&(na===void 0&&(na=Buffer.alloc(xf)),NK(na,0,xf),ps=0),r[0]=na[ps++],r[1]=na[ps++],r[2]=na[ps++],r[3]=na[ps++]),a=(r[0]|r[1]|r[2]|r[3])===0,o=6);let s;typeof t=="string"?(!n.mask||a)&&n[dr]!==void 0?s=n[dr]:(t=Buffer.from(t),s=t.length):(s=t.length,i=n.mask&&n.readOnly&&!a);let d=s;s>=65536?(o+=8,d=127):s>125&&(o+=2,d=126);let l=Buffer.allocUnsafe(i?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]=r[0],l[o-3]=r[1],l[o-2]=r[2],l[o-1]=r[3],a?[l,t]:i?(WC(t,r,l,o,s),[l]):(WC(t,r,t,0,s),[l,t])):[l,t]}close(t,n,r,i){let o;if(t===void 0)o=jK;else{if(typeof t!="number"||!qK(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={[dr]:o.length,fin:!0,generateMask:this._generateMask,mask:r,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};this._state!==Er?this.enqueue([this.dispatch,o,!1,a,i]):this.sendFrame(e.frame(o,a),i)}ping(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):fs(t)?(i=t.size,o=!1):(t=ta(t),i=t.length,o=ta.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[dr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:9,readOnly:o,rsv1:!1};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Er?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}pong(t,n,r){let i,o;if(typeof t=="string"?(i=Buffer.byteLength(t),o=!1):fs(t)?(i=t.size,o=!1):(t=ta(t),i=t.length,o=ta.readOnly),i>125)throw new RangeError("The data size must not be greater than 125 bytes");let a={[dr]:i,fin:!0,generateMask:this._generateMask,mask:n,maskBuffer:this._maskBuffer,opcode:10,readOnly:o,rsv1:!1};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,!1,a,r]):this.getBlobData(t,!1,a,r):this._state!==Er?this.enqueue([this.dispatch,t,!1,a,r]):this.sendFrame(e.frame(t,a),r)}send(t,n,r){let i=this._extensions[JC.extensionName],o=n.binary?2:1,a=n.compress,s,d;typeof t=="string"?(s=Buffer.byteLength(t),d=!1):fs(t)?(s=t.size,d=!1):(t=ta(t),s=t.length,d=ta.readOnly),this._firstFragment?(this._firstFragment=!1,a&&i&&i.params[i._isServer?"server_no_context_takeover":"client_no_context_takeover"]&&(a=s>=i._threshold),this._compress=a):(a=!1,o=0),n.fin&&(this._firstFragment=!0);let l={[dr]:s,fin:n.fin,generateMask:this._generateMask,mask:n.mask,maskBuffer:this._maskBuffer,opcode:o,readOnly:d,rsv1:a};fs(t)?this._state!==Er?this.enqueue([this.getBlobData,t,this._compress,l,r]):this.getBlobData(t,this._compress,l,r):this._state!==Er?this.enqueue([this.dispatch,t,this._compress,l,r]):this.dispatch(t,this._compress,l,r)}getBlobData(t,n,r,i){this._bufferedBytes+=r[dr],this._state=zK,t.arrayBuffer().then(o=>{if(this._socket.destroyed){let s=new Error("The socket was closed while the blob was being read");process.nextTick(my,this,s,i);return}this._bufferedBytes-=r[dr];let a=ta(o);n?this.dispatch(a,n,r,i):(this._state=Er,this.sendFrame(e.frame(a,r),i),this.dequeue())}).catch(o=>{process.nextTick(KK,this,o,i)})}dispatch(t,n,r,i){if(!n){this.sendFrame(e.frame(t,r),i);return}let o=this._extensions[JC.extensionName];this._bufferedBytes+=r[dr],this._state=BK,o.compress(t,r.fin,(a,s)=>{if(this._socket.destroyed){let d=new Error("The socket was closed while data was being compressed");my(this,d,i);return}this._bufferedBytes-=r[dr],this._state=Er,r.readOnly=!1,this.sendFrame(e.frame(s,r),i),this.dequeue()})}dequeue(){for(;this._state===Er&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[3][dr],Reflect.apply(t[0],this,t.slice(1))}}enqueue(t){this._bufferedBytes+=t[3][dr],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)}};VC.exports=py;function my(e,t,n){typeof n=="function"&&n(t);for(let r=0;r<e._queue.length;r++){let i=e._queue[r],o=i[i.length-1];typeof o=="function"&&o(t)}}function KK(e,t,n){my(e,t,n),e.onerror(t)}});var i0=yt((P4e,r0)=>{"use strict";var{kForOnEventAttribute:yl,kListener:_y}=Di(),ZC=Symbol("kCode"),YC=Symbol("kData"),QC=Symbol("kError"),XC=Symbol("kMessage"),e0=Symbol("kReason"),ms=Symbol("kTarget"),t0=Symbol("kType"),n0=Symbol("kWasClean"),Li=class{constructor(t){this[ms]=null,this[t0]=t}get target(){return this[ms]}get type(){return this[t0]}};Object.defineProperty(Li.prototype,"target",{enumerable:!0});Object.defineProperty(Li.prototype,"type",{enumerable:!0});var ra=class extends Li{constructor(t,n={}){super(t),this[ZC]=n.code===void 0?0:n.code,this[e0]=n.reason===void 0?"":n.reason,this[n0]=n.wasClean===void 0?!1:n.wasClean}get code(){return this[ZC]}get reason(){return this[e0]}get wasClean(){return this[n0]}};Object.defineProperty(ra.prototype,"code",{enumerable:!0});Object.defineProperty(ra.prototype,"reason",{enumerable:!0});Object.defineProperty(ra.prototype,"wasClean",{enumerable:!0});var hs=class extends Li{constructor(t,n={}){super(t),this[QC]=n.error===void 0?null:n.error,this[XC]=n.message===void 0?"":n.message}get error(){return this[QC]}get message(){return this[XC]}};Object.defineProperty(hs.prototype,"error",{enumerable:!0});Object.defineProperty(hs.prototype,"message",{enumerable:!0});var gl=class extends Li{constructor(t,n={}){super(t),this[YC]=n.data===void 0?null:n.data}get data(){return this[YC]}};Object.defineProperty(gl.prototype,"data",{enumerable:!0});var HK={addEventListener(e,t,n={}){for(let i of this.listeners(e))if(!n[yl]&&i[_y]===t&&!i[yl])return;let r;if(e==="message")r=function(o,a){let s=new gl("message",{data:a?o:o.toString()});s[ms]=this,Of(t,this,s)};else if(e==="close")r=function(o,a){let s=new ra("close",{code:o,reason:a.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});s[ms]=this,Of(t,this,s)};else if(e==="error")r=function(o){let a=new hs("error",{error:o,message:o.message});a[ms]=this,Of(t,this,a)};else if(e==="open")r=function(){let o=new Li("open");o[ms]=this,Of(t,this,o)};else return;r[yl]=!!n[yl],r[_y]=t,n.once?this.once(e,r):this.on(e,r)},removeEventListener(e,t){for(let n of this.listeners(e))if(n[_y]===t&&!n[yl]){this.removeListener(e,n);break}}};r0.exports={CloseEvent:ra,ErrorEvent:hs,Event:Li,EventTarget:HK,MessageEvent:gl};function Of(e,t,n){typeof e=="object"&&e.handleEvent?e.handleEvent.call(e,n):e.call(t,n)}});var yy=yt((I4e,o0)=>{"use strict";var{tokenChars:bl}=cs();function ni(e,t,n){e[t]===void 0?e[t]=[n]:e[t].push(n)}function JK(e){let t=Object.create(null),n=Object.create(null),r=!1,i=!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&&bl[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 m=e.slice(d,u);l===44?(ni(t,m,n),n=Object.create(null)):a=m,d=u=-1}else throw new SyntaxError(`Unexpected character at index ${c}`);else if(s===void 0)if(u===-1&&bl[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),ni(n,e.slice(d,u),!0),l===44&&(ni(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(i){if(bl[l]!==1)throw new SyntaxError(`Unexpected character at index ${c}`);d===-1?d=c:r||(r=!0),i=!1}else if(o)if(bl[l]===1)d===-1&&(d=c);else if(l===34&&d!==-1)o=!1,u=c;else if(l===92)i=!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&&bl[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 m=e.slice(d,u);r&&(m=m.replace(/\\/g,""),r=!1),ni(n,s,m),l===44&&(ni(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?ni(t,p,n):(s===void 0?ni(n,p,!0):r?ni(n,s,p.replace(/\\/g,"")):ni(n,s,p),ni(t,a,n)),t}function WK(e){return Object.keys(e).map(t=>{let n=e[t];return Array.isArray(n)||(n=[n]),n.map(r=>[t].concat(Object.keys(r).map(i=>{let o=r[i];return Array.isArray(o)||(o=[o]),o.map(a=>a===!0?i:`${i}=${a}`).join("; ")})).join("; ")).join(", ")}).join(", ")}o0.exports={format:WK,parse:JK}});var Mf=yt(($4e,y0)=>{"use strict";var VK=ot("events"),ZK=ot("https"),YK=ot("http"),d0=ot("net"),QK=ot("tls"),{randomBytes:XK,createHash:eH}=ot("crypto"),{Duplex:M4e,Readable:D4e}=ot("stream"),{URL:gy}=ot("url"),uo=_l(),tH=fy(),nH=hy(),{isBlob:rH}=cs(),{BINARY_TYPES:a0,EMPTY_BUFFER:Rf,GUID:iH,kForOnEventAttribute:by,kListener:oH,kStatusCode:aH,kWebSocket:dn,NOOP:l0}=Di(),{EventTarget:{addEventListener:sH,removeEventListener:dH}}=i0(),{format:lH,parse:uH}=yy(),{toBuffer:cH}=ml(),fH=30*1e3,u0=Symbol("kAborted"),vy=[8,13],Ni=["CONNECTING","OPEN","CLOSING","CLOSED"],pH=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/,Mt=class e extends VK{constructor(t,n,r){super(),this._binaryType=a0[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=Rf,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?(r=n,n=[]):n=[n]),c0(this,t,n,r)):(this._autoPong=r.autoPong,this._isServer=!0)}get binaryType(){return this._binaryType}set binaryType(t){a0.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,r){let i=new tH({allowSynchronousEvents:r.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:r.maxPayload,skipUTF8Validation:r.skipUTF8Validation}),o=new nH(t,this._extensions,r.generateMask);this._receiver=i,this._sender=o,this._socket=t,i[dn]=this,o[dn]=this,t[dn]=this,i.on("conclude",_H),i.on("drain",yH),i.on("error",gH),i.on("message",bH),i.on("ping",vH),i.on("pong",SH),o.onerror=wH,t.setTimeout&&t.setTimeout(0),t.setNoDelay&&t.setNoDelay(),n.length>0&&t.unshift(n),t.on("close",m0),t.on("data",If),t.on("end",h0),t.on("error",_0),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[uo.extensionName]&&this._extensions[uo.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){Jn(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,r=>{r||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end())}),p0(this)}}pause(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!0,this._socket.pause())}ping(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.ping(t||Rf,n,r)}pong(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(r=t,t=n=void 0):typeof n=="function"&&(r=n,n=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}n===void 0&&(n=!this._isServer),this._sender.pong(t||Rf,n,r)}resume(){this.readyState===e.CONNECTING||this.readyState===e.CLOSED||(this._paused=!1,this._receiver._writableState.needDrain||this._socket.resume())}send(t,n,r){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof n=="function"&&(r=n,n={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){Sy(this,t,r);return}let i={binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0,...n};this._extensions[uo.extensionName]||(i.compress=!1),this._sender.send(t||Rf,i,r)}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){Jn(this,this._req,"WebSocket was closed before the connection was established");return}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy())}}};Object.defineProperty(Mt,"CONNECTING",{enumerable:!0,value:Ni.indexOf("CONNECTING")});Object.defineProperty(Mt.prototype,"CONNECTING",{enumerable:!0,value:Ni.indexOf("CONNECTING")});Object.defineProperty(Mt,"OPEN",{enumerable:!0,value:Ni.indexOf("OPEN")});Object.defineProperty(Mt.prototype,"OPEN",{enumerable:!0,value:Ni.indexOf("OPEN")});Object.defineProperty(Mt,"CLOSING",{enumerable:!0,value:Ni.indexOf("CLOSING")});Object.defineProperty(Mt.prototype,"CLOSING",{enumerable:!0,value:Ni.indexOf("CLOSING")});Object.defineProperty(Mt,"CLOSED",{enumerable:!0,value:Ni.indexOf("CLOSED")});Object.defineProperty(Mt.prototype,"CLOSED",{enumerable:!0,value:Ni.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach(e=>{Object.defineProperty(Mt.prototype,e,{enumerable:!0})});["open","error","close","message"].forEach(e=>{Object.defineProperty(Mt.prototype,`on${e}`,{enumerable:!0,get(){for(let t of this.listeners(e))if(t[by])return t[oH];return null},set(t){for(let n of this.listeners(e))if(n[by]){this.removeListener(e,n);break}typeof t=="function"&&this.addEventListener(e,t,{[by]:!0})}})});Mt.prototype.addEventListener=sH;Mt.prototype.removeEventListener=dH;y0.exports=Mt;function c0(e,t,n,r){let i={allowSynchronousEvents:!0,autoPong:!0,protocolVersion:vy[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...r,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(e._autoPong=i.autoPong,!vy.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${vy.join(", ")})`);let o;if(t instanceof gy)o=t;else try{o=new gy(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 h=new SyntaxError(d);if(e._redirects===0)throw h;Pf(e,h);return}let l=a?443:80,u=XK(16).toString("base64"),c=a?ZK.request:YK.request,p=new Set,m;if(i.createConnection=i.createConnection||(a?hH:mH),i.defaultPort=i.defaultPort||l,i.port=o.port||l,i.host=o.hostname.startsWith("[")?o.hostname.slice(1,-1):o.hostname,i.headers={...i.headers,"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":u,Connection:"Upgrade",Upgrade:"websocket"},i.path=o.pathname+o.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(m=new uo(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=lH({[uo.extensionName]:m.offer()})),n.length){for(let h of n){if(typeof h!="string"||!pH.test(h)||p.has(h))throw new SyntaxError("An invalid or duplicated subprotocol was specified");p.add(h)}i.headers["Sec-WebSocket-Protocol"]=n.join(",")}if(i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(o.username||o.password)&&(i.auth=`${o.username}:${o.password}`),s){let h=i.path.split(":");i.socketPath=h[0],i.path=h[1]}let y;if(i.followRedirects){if(e._redirects===0){e._originalIpc=s,e._originalSecure=a,e._originalHostOrSocketPath=s?i.socketPath:o.host;let h=r&&r.headers;if(r={...r,headers:{}},h)for(let[b,g]of Object.entries(h))r.headers[b.toLowerCase()]=g}else if(e.listenerCount("redirect")===0){let h=s?e._originalIpc?i.socketPath===e._originalHostOrSocketPath:!1:e._originalIpc?!1:o.host===e._originalHostOrSocketPath;(!h||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,h||delete i.headers.host,i.auth=void 0)}i.auth&&!r.headers.authorization&&(r.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64")),y=e._req=c(i),e._redirects&&e.emit("redirect",e.url,y)}else y=e._req=c(i);i.timeout&&y.on("timeout",()=>{Jn(e,y,"Opening handshake has timed out")}),y.on("error",h=>{y===null||y[u0]||(y=e._req=null,Pf(e,h))}),y.on("response",h=>{let b=h.headers.location,g=h.statusCode;if(b&&i.followRedirects&&g>=300&&g<400){if(++e._redirects>i.maxRedirects){Jn(e,y,"Maximum redirects exceeded");return}y.abort();let S;try{S=new gy(b,t)}catch{let T=new SyntaxError(`Invalid URL: ${b}`);Pf(e,T);return}c0(e,S,n,r)}else e.emit("unexpected-response",y,h)||Jn(e,y,`Unexpected server response: ${h.statusCode}`)}),y.on("upgrade",(h,b,g)=>{if(e.emit("upgrade",h),e.readyState!==Mt.CONNECTING)return;y=e._req=null;let S=h.headers.upgrade;if(S===void 0||S.toLowerCase()!=="websocket"){Jn(e,b,"Invalid Upgrade header");return}let v=eH("sha1").update(u+iH).digest("base64");if(h.headers["sec-websocket-accept"]!==v){Jn(e,b,"Invalid Sec-WebSocket-Accept header");return}let T=h.headers["sec-websocket-protocol"],E;if(T!==void 0?p.size?p.has(T)||(E="Server sent an invalid subprotocol"):E="Server sent a subprotocol but none was requested":p.size&&(E="Server sent no subprotocol"),E){Jn(e,b,E);return}T&&(e._protocol=T);let x=h.headers["sec-websocket-extensions"];if(x!==void 0){if(!m){Jn(e,b,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let _;try{_=uH(x)}catch{Jn(e,b,"Invalid Sec-WebSocket-Extensions header");return}let w=Object.keys(_);if(w.length!==1||w[0]!==uo.extensionName){Jn(e,b,"Server indicated an extension that was not requested");return}try{m.accept(_[uo.extensionName])}catch{Jn(e,b,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[uo.extensionName]=m}e.setSocket(b,g,{allowSynchronousEvents:i.allowSynchronousEvents,generateMask:i.generateMask,maxPayload:i.maxPayload,skipUTF8Validation:i.skipUTF8Validation})}),i.finishRequest?i.finishRequest(y,e):y.end()}function Pf(e,t){e._readyState=Mt.CLOSING,e._errorEmitted=!0,e.emit("error",t),e.emitClose()}function mH(e){return e.path=e.socketPath,d0.connect(e)}function hH(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=d0.isIP(e.host)?"":e.host),QK.connect(e)}function Jn(e,t,n){e._readyState=Mt.CLOSING;let r=new Error(n);Error.captureStackTrace(r,Jn),t.setHeader?(t[u0]=!0,t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),process.nextTick(Pf,e,r)):(t.destroy(r),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)))}function Sy(e,t,n){if(t){let r=rH(t)?t.size:cH(t).length;e._socket?e._sender._bufferedBytes+=r:e._bufferedAmount+=r}if(n){let r=new Error(`WebSocket is not open: readyState ${e.readyState} (${Ni[e.readyState]})`);process.nextTick(n,r)}}function _H(e,t){let n=this[dn];n._closeFrameReceived=!0,n._closeMessage=t,n._closeCode=e,n._socket[dn]!==void 0&&(n._socket.removeListener("data",If),process.nextTick(f0,n._socket),e===1005?n.close():n.close(e,t))}function yH(){let e=this[dn];e.isPaused||e._socket.resume()}function gH(e){let t=this[dn];t._socket[dn]!==void 0&&(t._socket.removeListener("data",If),process.nextTick(f0,t._socket),t.close(e[aH])),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e))}function s0(){this[dn].emitClose()}function bH(e,t){this[dn].emit("message",e,t)}function vH(e){let t=this[dn];t._autoPong&&t.pong(e,!this._isServer,l0),t.emit("ping",e)}function SH(e){this[dn].emit("pong",e)}function f0(e){e.resume()}function wH(e){let t=this[dn];t.readyState!==Mt.CLOSED&&(t.readyState===Mt.OPEN&&(t._readyState=Mt.CLOSING,p0(t)),this._socket.end(),t._errorEmitted||(t._errorEmitted=!0,t.emit("error",e)))}function p0(e){e._closeTimer=setTimeout(e._socket.destroy.bind(e._socket),fH)}function m0(){let e=this[dn];this.removeListener("close",m0),this.removeListener("data",If),this.removeListener("end",h0),e._readyState=Mt.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[dn]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",s0),e._receiver.on("finish",s0))}function If(e){this[dn]._receiver.write(e)||this.pause()}function h0(){let e=this[dn];e._readyState=Mt.CLOSING,e._receiver.end(),this.end()}function _0(){let e=this[dn];this.removeListener("error",_0),this.on("error",l0),e&&(e._readyState=Mt.CLOSING,this.destroy())}});var S0=yt((N4e,v0)=>{"use strict";var L4e=Mf(),{Duplex:TH}=ot("stream");function g0(e){e.emit("close")}function kH(){!this.destroyed&&this._writableState.finished&&this.destroy()}function b0(e){this.removeListener("error",b0),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e)}function AH(e,t){let n=!0,r=new TH({...t,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return e.on("message",function(o,a){let s=!a&&r._readableState.objectMode?o.toString():o;r.push(s)||e.pause()}),e.once("error",function(o){r.destroyed||(n=!1,r.destroy(o))}),e.once("close",function(){r.destroyed||r.push(null)}),r._destroy=function(i,o){if(e.readyState===e.CLOSED){o(i),process.nextTick(g0,r);return}let a=!1;e.once("error",function(d){a=!0,o(d)}),e.once("close",function(){a||o(i),process.nextTick(g0,r)}),n&&e.terminate()},r._final=function(i){if(e.readyState===e.CONNECTING){e.once("open",function(){r._final(i)});return}e._socket!==null&&(e._socket._writableState.finished?(i(),r._readableState.endEmitted&&r.destroy()):(e._socket.once("finish",function(){i()}),e.close()))},r._read=function(){e.isPaused&&e.resume()},r._write=function(i,o,a){if(e.readyState===e.CONNECTING){e.once("open",function(){r._write(i,o,a)});return}e.send(i,a)},r.on("end",kH),r.on("error",b0),r}v0.exports=AH});var T0=yt((j4e,w0)=>{"use strict";var{tokenChars:EH}=cs();function CH(e){let t=new Set,n=-1,r=-1,i=0;for(i;i<e.length;i++){let a=e.charCodeAt(i);if(r===-1&&EH[a]===1)n===-1&&(n=i);else if(i!==0&&(a===32||a===9))r===-1&&n!==-1&&(r=i);else if(a===44){if(n===-1)throw new SyntaxError(`Unexpected character at index ${i}`);r===-1&&(r=i);let s=e.slice(n,r);if(t.has(s))throw new SyntaxError(`The "${s}" subprotocol is duplicated`);t.add(s),n=r=-1}else throw new SyntaxError(`Unexpected character at index ${i}`)}if(n===-1||r!==-1)throw new SyntaxError("Unexpected end of input");let o=e.slice(n,i);if(t.has(o))throw new SyntaxError(`The "${o}" subprotocol is duplicated`);return t.add(o),t}w0.exports={parse:CH}});var R0=yt((G4e,O0)=>{"use strict";var xH=ot("events"),Df=ot("http"),{Duplex:F4e}=ot("stream"),{createHash:OH}=ot("crypto"),k0=yy(),ia=_l(),RH=T0(),PH=Mf(),{GUID:IH,kWebSocket:MH}=Di(),DH=/^[+/0-9A-Za-z]{22}==$/,A0=0,E0=1,x0=2,wy=class extends xH{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:PH,...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=Df.createServer((r,i)=>{let o=Df.STATUS_CODES[426];i.writeHead(426,{"Content-Length":o.length,"Content-Type":"text/plain"}),i.end(o)}),this._server.listen(t.port,t.host,t.backlog,n)):t.server&&(this._server=t.server),this._server){let r=this.emit.bind(this,"connection");this._removeListeners=$H(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,o,a)=>{this.handleUpgrade(i,o,a,r)}})}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set,this._shouldEmitClose=!1),this.options=t,this._state=A0}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===x0){t&&this.once("close",()=>{t(new Error("The server is not running"))}),process.nextTick(vl,this);return}if(t&&this.once("close",t),this._state!==E0)if(this._state=E0,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(vl,this):process.nextTick(vl,this);else{let n=this._server;this._removeListeners(),this._removeListeners=this._server=null,n.close(()=>{vl(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,r,i){n.on("error",C0);let o=t.headers["sec-websocket-key"],a=t.headers.upgrade,s=+t.headers["sec-websocket-version"];if(t.method!=="GET"){oa(this,t,n,405,"Invalid HTTP method");return}if(a===void 0||a.toLowerCase()!=="websocket"){oa(this,t,n,400,"Invalid Upgrade header");return}if(o===void 0||!DH.test(o)){oa(this,t,n,400,"Missing or invalid Sec-WebSocket-Key header");return}if(s!==13&&s!==8){oa(this,t,n,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(t)){Sl(n,400);return}let d=t.headers["sec-websocket-protocol"],l=new Set;if(d!==void 0)try{l=RH.parse(d)}catch{oa(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 ia(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let m=k0.parse(u);m[ia.extensionName]&&(p.accept(m[ia.extensionName]),c[ia.extensionName]=p)}catch{oa(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,(m,y,h,b)=>{if(!m)return Sl(n,y||401,h,b);this.completeUpgrade(c,o,l,t,n,r,i)});return}if(!this.options.verifyClient(p))return Sl(n,401)}this.completeUpgrade(c,o,l,t,n,r,i)}completeUpgrade(t,n,r,i,o,a,s){if(!o.readable||!o.writable)return o.destroy();if(o[MH])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>A0)return Sl(o,503);let l=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${OH("sha1").update(n+IH).digest("base64")}`],u=new this.options.WebSocket(null,void 0,this.options);if(r.size){let c=this.options.handleProtocols?this.options.handleProtocols(r,i):r.values().next().value;c&&(l.push(`Sec-WebSocket-Protocol: ${c}`),u._protocol=c)}if(t[ia.extensionName]){let c=t[ia.extensionName].params,p=k0.format({[ia.extensionName]:[c]});l.push(`Sec-WebSocket-Extensions: ${p}`),u._extensions=t}this.emit("headers",l,i),o.write(l.concat(`\r
|
|
5
5
|
`).join(`\r
|
|
6
6
|
`)),o.removeListener("error",C0),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(vl,this)})),s(u,i)}};O0.exports=wy;function $H(e,t){for(let n of Object.keys(t))e.on(n,t[n]);return function(){for(let r of Object.keys(t))e.removeListener(r,t[r])}}function vl(e){e._state=x0,e.emit("close")}function C0(){this.destroy()}function Sl(e,t,n,r){n=n||Df.STATUS_CODES[t],r={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(n),...r},e.once("finish",e.destroy),e.end(`HTTP/1.1 ${t} ${Df.STATUS_CODES[t]}\r
|
|
7
7
|
`+Object.keys(r).map(i=>`${i}: ${r[i]}`).join(`\r
|