zen-code 4.10.2 → 5.0.1
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/dist/app.js +149 -239
- package/dist/{chunk-pzb224c5.js → chunk-0p3df51n.js} +2 -2
- package/dist/{chunk-tjg2e8v3.js → chunk-0pzpg2ra.js} +2 -2
- package/dist/{chunk-wmyc17aa.js → chunk-142wmdx8.js} +1 -1
- package/dist/chunk-1t3rabge.js +1 -0
- package/dist/chunk-2gd8vzrf.js +2 -0
- package/dist/{chunk-vrnj0659.js → chunk-2z45fjmt.js} +51 -51
- package/dist/chunk-3gn0c0j2.js +2 -0
- package/dist/chunk-3nhw50tg.js +1 -0
- package/dist/{chunk-g974hxbz.js → chunk-4260bzp9.js} +1 -1
- package/dist/{chunk-5c3bpcpm.js → chunk-4vh3dxeg.js} +1 -1
- package/dist/{chunk-hnnwbfqk.js → chunk-5e2s5jvw.js} +2 -2
- package/dist/{chunk-s5cqejr6.js → chunk-5kcxxes1.js} +1 -1
- package/dist/chunk-6t0qzren.js +2 -0
- package/dist/chunk-74k5n8f5.js +2 -0
- package/dist/chunk-780j97nd.js +1 -0
- package/dist/chunk-78t2g3ht.js +1 -0
- package/dist/chunk-7d48d71t.js +228 -0
- package/dist/chunk-96b00ygr.js +1 -0
- package/dist/chunk-9kbktaf8.js +89 -0
- package/dist/chunk-a4rvf135.js +1 -0
- package/dist/chunk-ahsvdb98.js +1 -0
- package/dist/{chunk-k4q8j7pg.js → chunk-an34z8wv.js} +1 -1
- package/dist/chunk-arm90pny.js +1 -0
- package/dist/{chunk-40ht9pe1.js → chunk-avqzptcg.js} +2 -2
- package/dist/{chunk-s1tbdcs8.js → chunk-b0yk07x5.js} +1 -1
- package/dist/{chunk-nqh1pptf.js → chunk-be8n8w26.js} +1 -1
- package/dist/{chunk-c7kd2qrp.js → chunk-bqkrynm6.js} +112 -111
- package/dist/chunk-bv28r5cf.js +1 -0
- package/dist/{chunk-mmx0k2yq.js → chunk-c59eqb10.js} +1 -1
- package/dist/{chunk-t6440ajd.js → chunk-cbr2vrpt.js} +2 -2
- package/dist/{chunk-fzh0v6r0.js → chunk-csn4vg3d.js} +2 -2
- package/dist/chunk-df36fv24.js +1 -0
- package/dist/chunk-e3jv1c1w.js +1 -0
- package/dist/{chunk-vbb3m0vz.js → chunk-e6m161vn.js} +1 -1
- package/dist/{chunk-vfxjbdz4.js → chunk-eqetcfer.js} +1 -1
- package/dist/{chunk-8f19qk9r.js → chunk-eze2fzrq.js} +1 -1
- package/dist/{chunk-nmzx5nmt.js → chunk-femf7e4d.js} +1 -1
- package/dist/{chunk-gt8c6dne.js → chunk-fvg6pct8.js} +1 -1
- package/dist/chunk-g2n6hnjp.js +5 -0
- package/dist/{chunk-e8kxa5vj.js → chunk-ge071wp4.js} +2 -2
- package/dist/chunk-h9w6y105.js +1 -0
- package/dist/chunk-hzxg9kx6.js +1 -0
- package/dist/{chunk-g2zskge5.js → chunk-j2qd9mfs.js} +2 -2
- package/dist/chunk-j40cj742.js +2 -0
- package/dist/chunk-jbqqb1ht.js +2 -0
- package/dist/chunk-jz0kw4yt.js +2 -0
- package/dist/chunk-kknfcsyy.js +1 -0
- package/dist/{chunk-zg54h6gy.js → chunk-kvnw06wg.js} +1 -1
- package/dist/chunk-kyb15dg8.js +2 -0
- package/dist/chunk-mq4m1w4w.js +15 -0
- package/dist/chunk-mqcbjght.js +1 -0
- package/dist/{chunk-pe8mzxwn.js → chunk-mqm8wnc8.js} +11 -11
- package/dist/chunk-n7bpjcb0.js +1 -0
- package/dist/chunk-ncaqgas1.js +160 -0
- package/dist/{chunk-f0m4532p.js → chunk-nh11afw0.js} +5 -5
- package/dist/{chunk-spx7nn8t.js → chunk-nwmvyez4.js} +2 -2
- package/dist/chunk-nzyvqxt4.js +1 -0
- package/dist/{chunk-nsw5168d.js → chunk-p6c1xbd5.js} +2 -2
- package/dist/chunk-p75m7q2h.js +1 -0
- package/dist/{chunk-spa69h7p.js → chunk-pffdbhs6.js} +2 -2
- package/dist/chunk-phw7yp5t.js +1 -0
- package/dist/{chunk-8tbtavry.js → chunk-q0452p0f.js} +2 -2
- package/dist/chunk-r133z8tq.js +8 -0
- package/dist/{chunk-qxebn3jw.js → chunk-rqymdmqg.js} +3 -3
- package/dist/chunk-rr7h6wdp.js +7 -0
- package/dist/{chunk-gfhmzpy7.js → chunk-s04zfe57.js} +2 -3
- package/dist/chunk-twhnh3dc.js +1 -0
- package/dist/chunk-tws3wcnm.js +2 -0
- package/dist/chunk-txnezkkt.js +1 -0
- package/dist/{chunk-tjvhqr94.js → chunk-vttq7sqg.js} +1 -1
- package/dist/chunk-vvs5da2x.js +281 -0
- package/dist/{chunk-n9rpnke9.js → chunk-vwj4n000.js} +1 -1
- package/dist/{chunk-4wnmk2tj.js → chunk-w4tbr5h7.js} +3 -3
- package/dist/{chunk-n7s6my89.js → chunk-wts8db9p.js} +32 -32
- package/dist/{chunk-y8qhrx11.js → chunk-x17jyjan.js} +1 -1
- package/dist/chunk-x7x7esvz.js +8 -0
- package/dist/chunk-xprg4hxp.js +17 -0
- package/dist/chunk-xrfpz1vw.js +2 -0
- package/dist/{chunk-hve2a279.js → chunk-xtr6s7kh.js} +2 -2
- package/dist/{chunk-bzgznka5.js → chunk-y807k0kw.js} +1 -1
- package/dist/chunk-ycp2e43r.js +1 -0
- package/dist/chunk-yfv1xeeh.js +2 -0
- package/dist/chunk-zxpb45tb.js +1 -0
- package/dist/cli.js +1 -1
- package/dist/nonInteractive.js +80 -80
- package/dist/zen-core.js +261 -0
- package/dist/zen-keyboard.js +1 -1
- package/package.json +5 -3
- package/dist/chunk-0ddrb30y.js +0 -1
- package/dist/chunk-215an3fz.js +0 -1
- package/dist/chunk-4z0w0ng1.js +0 -2
- package/dist/chunk-57bj89e2.js +0 -1
- package/dist/chunk-5a5mepqj.js +0 -1
- package/dist/chunk-7kw7ss8d.js +0 -1
- package/dist/chunk-86m0rmtc.js +0 -1
- package/dist/chunk-9rayxazs.js +0 -8
- package/dist/chunk-a9gpb2tx.js +0 -2
- package/dist/chunk-a9tw6d68.js +0 -1
- package/dist/chunk-anbtppz1.js +0 -294
- package/dist/chunk-bca8tkkr.js +0 -1
- package/dist/chunk-bdqds8vh.js +0 -1
- package/dist/chunk-dvbb3dd1.js +0 -233
- package/dist/chunk-ehmmd8qc.js +0 -1
- package/dist/chunk-ejfa95sm.js +0 -1
- package/dist/chunk-f7cps5x1.js +0 -1
- package/dist/chunk-fbemqjck.js +0 -2
- package/dist/chunk-feeqtzv5.js +0 -1
- package/dist/chunk-g9911ymn.js +0 -1
- package/dist/chunk-h8fdexm4.js +0 -2
- package/dist/chunk-hp2jzn9x.js +0 -166
- package/dist/chunk-js4qp900.js +0 -2
- package/dist/chunk-m21hvv91.js +0 -2
- package/dist/chunk-mnnyjmgw.js +0 -224
- package/dist/chunk-mw7x6xqp.js +0 -1
- package/dist/chunk-nk62q95g.js +0 -93
- package/dist/chunk-pg1ppq4y.js +0 -1
- package/dist/chunk-q1cxrg0x.js +0 -2
- package/dist/chunk-swc7se71.js +0 -2
- package/dist/chunk-swyc15ym.js +0 -1
- package/dist/chunk-t2s3s6af.js +0 -1
- package/dist/chunk-vdmq9d9x.js +0 -4
- package/dist/chunk-wt3p1w1g.js +0 -1
- package/dist/chunk-y5ry5c7v.js +0 -1
- package/dist/chunk-yy8p9zph.js +0 -2
- package/dist/chunk-z61m3anh.js +0 -1
- package/dist/chunk-zr90qp47.js +0 -1
- package/dist/chunk-zsa62xr0.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Gl as J}from"./chunk-y807k0kw.js";import"./chunk-x17jyjan.js";function X(y){let w=y.stack;if(!w)return{};let q=w.match(/at\s+(?:.*?\s+)?\(?(.+?):(\d+):(\d+)\)?/);if(q)return{file:q[1],line:parseInt(q[2],10),column:parseInt(q[3],10)};return{}}function Y(y,w){let q=y.toLowerCase();if(q.includes("tool")||q.includes("read")||q.includes("write")||q.includes("glob")||q.includes("grep"))return"Tool";if(q.includes("terminal")||q.includes("bash")||q.includes("command")||q.includes("spawn"))return"Terminal";if(q.includes("agent")||q.includes("llm")||q.includes("model"))return"Agent";if(q.includes("config")||q.includes("network")||q.includes("fetch"))return"System";if(w?.stack){let B=w.stack.toLowerCase();if(B.includes("tool")||B.includes("filesystem"))return"Tool";if(B.includes("terminal")||B.includes("bash"))return"Terminal";if(B.includes("agent")||B.includes("graph"))return"Agent"}return"Unknown"}function D(y,w,q,B){let V=q||Y(w,B),H=B?X(B):{};J.addError({level:y,source:V,message:w,file:H.file,line:H.line,column:H.column,stack:B?.stack})}var{error:K,warn:P}=console;function Z(...y){K.apply(console,y);try{let w=y.map((B)=>{if(typeof B==="string")return B;if(B instanceof Error)return B.message;try{return JSON.stringify(B)}catch{return String(B)}}).join(" "),q=y.find((B)=>B instanceof Error);D("error",w,void 0,q)}catch{}}function _(...y){P.apply(console,y);try{let w=y.map((q)=>{if(typeof q==="string")return q;if(q instanceof Error)return q.message;try{return JSON.stringify(q)}catch{return String(q)}}).join(" ");D("warning",w,void 0)}catch{}}function Q(y){let w,q;if(y instanceof Error)w=y.message,q=y;else if(typeof y==="string")w=y;else try{w=JSON.stringify(y)}catch{w=String(y)}D("error",`[UnhandledRejection] ${w}`,"System",q)}function T(y){let w=y instanceof Error?y:Error(String(y));D("error",`[UncaughtException] ${w.message}`,"System",w)}var G=!1;function A(){if(G)return;console.error=Z,console.warn=_,process.on("unhandledRejection",Q),process.on("uncaughtException",T),G=!0}function F(){if(!G)return;console.error=K,console.warn=P,process.off("unhandledRejection",Q),process.off("uncaughtException",T),G=!1}function L(y,w){let q=typeof w==="string"?w:w.message,B=typeof w==="string"?void 0:w;D("error",`[${y}] ${q}`,"Tool",B)}function f(y,w){let q=typeof w==="string"?w:w.message,B=typeof w==="string"?void 0:w;D("error",`[Terminal] ${y}: ${q}`,"Terminal",B)}function v(y,w){let q=typeof w==="string"?w:w.message,B=typeof w==="string"?void 0:w;D("error",`[Agent:${y}] ${q}`,"Agent",B)}export{F as stopErrorInterceptor,L as logToolError,f as logTerminalError,v as logAgentError,A as initErrorInterceptor};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{rk as We}from"./chunk-p6c1xbd5.js";import{El as Oh,Fl as Mh,yl as ou}from"./chunk-xtr6s7kh.js";import{Rl as Vh,Sl as Ch,Tl as L,Wl as _}from"./chunk-x17jyjan.js";var wu=L((qu)=>{(function(){var u=function(e,h,r){var f,q;q="";while(e.length>0)if(f=e.match(h),f)q+=e.slice(0,f.index),q+=r(f),e=e.slice(f.index+f[0].length);else q+=e,e="";return q};qu.split=function(e){var h,r;if(e==null)e="";if(r=[],h="",u(e,/\s*(?:([^\s\\\'\"]+)|'((?:[^\'\\]|\\.)*)'|"((?:[^\"\\]|\\.)*)"|(\\.?)|(\S))(\s|$)?/,function(f){var q,w,E,M,O,V,F;if(M=f[0],F=f[1],V=f[2],q=f[3],w=f[4],E=f[5],O=f[6],E!=null)throw Error("Unmatched quote");if(h+=F||(V||q||w).replace(/\\(?=.)/,""),O!=null)return r.push(h),h=""}),h)r.push(h);return r},qu.escape=function(e){if(e==null)e="";if(e==null)return"''";return e.replace(/([^A-Za-z0-9_\-.,:\/@\n])/g,"\\$1").replace(/\n/g,`'
|
|
2
2
|
'`)}}).call(qu)});var yu=L((Th,Eu)=>{var _u=_("fs"),k;function nu(){try{return _u.statSync("/.dockerenv"),!0}catch(u){return!1}}function tu(){try{return _u.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch(u){return!1}}Eu.exports=()=>{if(k===void 0)k=nu()||tu();return k}});var Mu=L((zh,b)=>{var su=_("os"),pu=_("fs"),Cu=yu(),Ou=()=>{if(process.platform!=="linux")return!1;if(su.release().toLowerCase().includes("microsoft")){if(Cu())return!1;return!0}try{return pu.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft")?!Cu():!1}catch(u){return!1}};if(process.env.__IS_WSL_TEST__)b.exports=Ou;else b.exports=Ou()});var K=L((Me,y)=>{var ue=wu(),g=_("child_process"),a=ou(),ee=Mu(),he=_("path"),fe=_("url"),X=_("os"),l=_("fs"),re=_("net");function ju(u){return JSON.parse(JSON.stringify(u))}Me.clone=ju;var qe=function(u){if(typeof u==="string")return u.replace(/(["$`\\])/g,"\\$1");else return u},we=function(u,e){return u.indexOf(e)!==-1},Lu={u:"urgency",urgency:"urgency",t:"expire-time",time:"expire-time",timeout:"expire-time",e:"expire-time",expire:"expire-time","expire-time":"expire-time",i:"icon",icon:"icon",c:"category",category:"category",subtitle:"category",h:"hint",hint:"hint",a:"app-name","app-name":"app-name"};Me.command=function(u,e,h){if(u=ue.escape(u),process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (command):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.exec(u+" "+e.join(" "),function(r,f,q){if(r)return h(r);h(q,f)})};Me.fileCommand=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommand):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.execFile(u,e,function(r,f,q){if(r)return h(r,f);h(q,f)})};Me.fileCommandJson=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (fileCommandJson):"),console.info("[notifier path]",u),console.info("[notifier options]",e.join(" "));return g.execFile(u,e,function(r,f,q){if(r)return h(r,f);if(!f)return h(r,{});try{let w=JSON.parse(f);h(!q?null:q,w)}catch(w){h(w,f)}})};Me.immediateFileCommand=function(u,e,h){if(process.env.DEBUG&&process.env.DEBUG.indexOf("notifier")!==-1)console.info("node-notifier debug info (notifier):"),console.info("[notifier path]",u);_e(u,function(r,f){if(!f)return h(Error("Notifier ("+u+") not found on system."));g.execFile(u,e),h()})};function _e(u,e){return l.stat(u,function(h,r){if(!h)return e(h,r.isFile());if(he.extname(u))return e(h,!1);return l.stat(u+".exe",function(f,q){if(f)return e(f,!1);e(f,q.isFile())})})}var m=function(u){if(u.appIcon)u.icon=u.appIcon,delete u.appIcon;return u},N=function(u){if(u.text)u.message=u.text,delete u.text;return u},Yu=function(u){if(u.i)u.icon=u.i,delete u.i;return u};Me.mapToNotifySend=function(u){if(u=m(u),u=N(u),u.timeout===!1)delete u.timeout;if(u.wait===!0)u["expire-time"]=5;for(let e in u){if(e==="message"||e==="title")continue;if(u.hasOwnProperty(e)&&Lu[e]!==e)u[Lu[e]]=u[e],delete u[e]}if(typeof u["expire-time"]>"u")u["expire-time"]=1e4;else if(typeof u["expire-time"]==="number")u["expire-time"]=u["expire-time"]*1000;return u};Me.mapToGrowl=function(u){if(u=m(u),u=Yu(u),u=N(u),u.icon&&!Buffer.isBuffer(u.icon))try{u.icon=l.readFileSync(u.icon)}catch(e){}return u};Me.mapToMac=function(u){if(u=Yu(u),u=N(u),u.icon)u.appIcon=u.icon,delete u.icon;if(u.sound===!0)u.sound="Bottle";if(u.sound===!1)delete u.sound;if(u.sound&&u.sound.indexOf("Notification.")===0)u.sound="Bottle";if(u.wait===!0){if(!u.timeout)u.timeout=5;delete u.wait}if(!u.wait&&!u.timeout)if(u.timeout===!1)delete u.timeout;else u.timeout=10;return u.json=!0,u};function i(u){return Object.prototype.toString.call(u)==="[object Array]"}Me.isArray=i;function Ee(){}Me.actionJackerDecorator=function(u,e,h,r){if(e=ju(e),h=h||Ee,typeof h!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof h);return function(f,q){let w=q,E={};if(w&&typeof w==="object")E=w,w=w.activationType;if(w){if(w=w.toLowerCase().trim(),w.match(/^activate|clicked$/))w="activate";if(w.match(/^timedout$/))w="timeout"}if(h.apply(u,[f,w,E]),!r||!w)return;let M=r(w);if(!M)return;u.emit(M,u,e,E)}};Me.constructArgumentList=function(u,e){let h=[];e=e||{};let r=e.initial||[],f=e.keyExtra||"",q=e.allowedArguments||[],w=e.noEscape!==void 0,E=e.allowedArguments!==void 0,M=!!e.explicitTrue,O=!!e.keepNewlines,V=e.wrapper===void 0?'"':e.wrapper,F=function U($){if(i($))return Ju($.map(U).join(","));if(!w)$=qe($);if(typeof $==="string"&&!O)$=Ju($);return V+$+V};r.forEach(function(U){h.push(F(U))});for(let U in u)if(u.hasOwnProperty(U)&&(!E||we(q,U)))if(M&&u[U]===!0)h.push("-"+f+U);else if(M&&u[U]===!1)continue;else h.push("-"+f+U,F(u[U]));return h};function Ju(u){let e=process.platform==="win32"?"\\r\\n":"\\n";return u.replace(/\r?\n/g,e)}var ye=["t","m","b","tb","p","id","s","silent","appID","pid","pipeName","close","install"],Ce="Notification.",Uu="Notification.Default";Me.mapToWin8=function(u){if(u=m(u),u=N(u),u.icon){if(/^file:\/+/.test(u.icon))u.p=new fe.URL(u.icon).pathname.replace(/^\/(\w:\/)/,"$1").replace(/\//g,"\\");else u.p=u.icon;delete u.icon}if(u.message)u.m=u.message.replace(/\x1b/g,""),delete u.message;if(u.title)u.t=u.title,delete u.title;if(u.appName)u.appID=u.appName,delete u.appName;if(typeof u.remove<"u")u.close=u.remove,delete u.remove;if(u.quiet||u.silent)u.silent=u.quiet||u.silent,delete u.quiet;if(typeof u.sound<"u")u.s=u.sound,delete u.sound;if(u.s===!1)u.silent=!0,delete u.s;if(u.s&&u.silent)delete u.s;if(u.s===!0)u.s=Uu;if(u.s&&u.s.indexOf(Ce)!==0)u.s=Uu;if(u.actions&&i(u.actions))u.b=u.actions.join(";"),delete u.actions;for(let e in u)if(u.hasOwnProperty(e)&&ye.indexOf(e)===-1)delete u[e];return u};Me.mapToNotifu=function(u){if(u=m(u),u=N(u),u.icon)u.i=u.icon,delete u.icon;if(u.message)u.m=u.message,delete u.message;if(u.title)u.p=u.title,delete u.title;if(u.time)u.d=u.time,delete u.time;if(u.q!==!1)u.q=!0;else delete u.q;if(u.quiet===!1)delete u.q,delete u.quiet;if(u.sound)delete u.q,delete u.sound;if(u.t)u.d=u.t,delete u.t;if(u.type)u.t=Oe(u.type),delete u.type;return u};Me.isMac=function(){return X.type()==="Darwin"};Me.isMountainLion=function(){return X.type()==="Darwin"&&a.satisfies(n(X.release()),">=12.0.0")};Me.isWin8=function(){return X.type()==="Windows_NT"&&a.satisfies(n(X.release()),">=6.2.9200")};Me.isWSL=function(){return ee};Me.isLessThanWin8=function(){return X.type()==="Windows_NT"&&a.satisfies(n(X.release()),"<6.2.9200")};function n(u){if(u.split(".").length===2)u+=".0";return u}function Oe(u){if(typeof u==="string"||u instanceof String){if(u.toLowerCase()==="info")return"info";if(u.toLowerCase()==="warn")return"warn";if(u.toLowerCase()==="error")return"error"}return"info"}Me.createNamedPipe=(u)=>{let e=Buffer.alloc(1024);return new Promise((h)=>{u.instance=re.createServer((r)=>{r.on("data",(f)=>{e.write(f.toString())}),r.on("end",()=>{u.instance.close()})}),u.instance.listen(u.namedPipe,()=>{h(e)})})}});var Hu=L((Bh,Zu)=>{var $u=_("os"),Te=We(),Q=K(),Ku=_("events").EventEmitter,ze=_("util"),v;Zu.exports=A;function A(u){if(u=Q.clone(u||{}),!(this instanceof A))return new A(u);this.options=u,Ku.call(this)}ze.inherits(A,Ku);function Be(){}function ce(u,e){if(u=Q.clone(u||{}),e=e||Be,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof e);if(typeof u==="string")u={title:"node-notifier",message:u};if(!u.message)return e(Error("Message is required.")),this;if($u.type()!=="Linux"&&!$u.type().match(/BSD$/))return e(Error("Only supported on Linux and *BSD systems")),this;if(v===!1)return e(Error("notify-send must be installed on the system.")),this;if(v||!!this.options.suppressOsdCheck)return Xu(u,e),this;try{v=!!Te.sync("notify-send"),Xu(u,e)}catch(h){return v=!1,e(h)}return this}Object.defineProperty(A.prototype,"notify",{get:function(){if(!this._notify)this._notify=ce.bind(this);return this._notify}});var De=["urgency","expire-time","icon","category","hint","app-name"];function Xu(u,e){u=Q.mapToNotifySend(u),u.title=u.title||"Node Notification:";let h=[u.title,u.message];delete u.title,delete u.message;let r=Q.constructArgumentList(u,{initial:h,keyExtra:"-",allowedArguments:De});Q.command("notify-send",r,e)}});var t=L((ch,Ru)=>{var ge=_("net");Ru.exports=function(u,e){if(typeof e>"u")e=u,u={};let h=u.port||23053,r=u.host||"localhost",f=ge.connect(h,r);f.setTimeout(100),f.once("connect",function(){f.end(),e(null,!0)}),f.once("error",function(){f.end(),e(null,!1)})}});var Nu=L((Dh,Fu)=>{var me=_("net"),ve=_("crypto"),Vu=_("util").format,xe=_("fs"),J=`\r
|
|
3
|
-
`;function Z(u,e){e=e||{},this.type=u,this.host=e.host||"localhost",this.port=e.port||23053,this.request="GNTP/1.0 "+u+" NONE"+J,this.resources=[],this.attempts=0,this.maxAttempts=5}Z.prototype.parseResp=function(u){var e={},h,r;return u=u.slice(0,u.indexOf(J+J)).split(J),h=u[0],r=u.slice(1),e.state=h.match(/-(OK|ERROR|CALLBACK)/)[0].slice(1),r.forEach(function(f){f=f.split(": "),e[f[0]]=f[1]}),e};Z.prototype.retry=function(){var u=this,e=arguments;setTimeout(function(){u.send.apply(u,e)},750)};Z.prototype.addResource=function(u){var e=ve.createHash("md5").update(u).digest("hex"),h="Identifier: "+e+J+"Length: "+u.length+J+J;return this.resources.push({header:h,file:u}),"x-growl-resource://"+e};Z.prototype.add=function(u,e){if(e===void 0)return;if(/-Icon/.test(u)&&!/^https?:\/\//.test(e)){if(/\.(png|gif|jpe?g)$/.test(e))e=this.addResource(xe.readFileSync(e));else if(e instanceof Buffer)e=this.addResource(e)}this.request+=u+": "+e+J};Z.prototype.newline=function(){this.request+=J};Z.prototype.send=function(u){var e=this,h=me.connect(this.port,this.host),r="";u=u||function(){},this.attempts+=1,h.on("connect",function(){h.write(e.request),e.resources.forEach(function(f){h.write(f.header),h.write(f.file),h.write(J+J)})}),h.on("data",function(f){if(r+=f.toString(),r.slice(r.length-4)!==J+J)return;if(r=e.parseResp(r),r.state==="ERROR"||r.state==="CALLBACK")h.end();else r=""}),h.on("end",function(){if(["200","401","402"].indexOf(r["Error-Code"])>=0)if(e.attempts<=e.maxAttempts)e.retry(u);else{var f='GNTP request to "%s:%d" failed with error code %s (%s)';u(Error(Vu(f,e.host,e.port,r["Error-Code"],r["Error-Description"])))}else u(void 0,r)}),h.on("error",function(){u(Error(Vu('Error while sending GNTP request to "%s:%d"',e.host,e.port))),h.destroy()})};Fu.exports=Z});var Su=L((gh,Au)=>{var Qu=Nu();function S(){this.appname="Growly",this.notifications=void 0,this.labels=void 0,this.count=0,this.registered=!1,this.host=void 0,this.port=void 0}S.prototype.getLabels=function(){return this.notifications.map(function(u){return u.label})};S.prototype.setHost=function(u,e){this.host=u,this.port=e};S.prototype.register=function(u,e,h,r){var f;if(typeof e==="object")h=e,e=void 0;if(h===void 0||!h.length)h=[{label:"default",dispname:"Default Notification",enabled:!0}];if(typeof arguments[arguments.length-1]==="function")r=arguments[arguments.length-1];else r=function(){};this.appname=u,this.notifications=h,this.labels=this.getLabels(),this.registered=!0,f=new Qu("REGISTER",{host:this.host,port:this.port}),f.add("Application-Name",u),f.add("Application-Icon",e),f.add("Notifications-Count",h.length),f.newline(),h.forEach(function(q){if(q.enabled===void 0)q.enabled=!0;f.add("Notification-Name",q.label),f.add("Notification-Display-Name",q.dispname),f.add("Notification-Enabled",q.enabled?"True":"False"),f.add("Notification-Icon",q.icon),f.newline()}),f.send(r)};S.prototype.notify=function(u,e,h){var r=this,f;if(!this.registered){this.register(this.appname,function(q){if(q)console.log(q);r.notify.call(r,u,e,h)});return}if(e=e||{},typeof e==="function")h=e,e={};f=new Qu("NOTIFY",{host:this.host,port:this.port}),f.add("Application-Name",this.appname),f.add("Notification-Name",e.label||this.labels[0]),f.add("Notification-ID",++this.count),f.add("Notification-Title",e.title),f.add("Notification-Text",u),f.add("Notification-Sticky",e.sticky?"True":"False"),f.add("Notification-Priority",e.priority),f.add("Notification-Icon",e.icon),f.add("Notification-Coalescing-ID",e.coalescingId||void 0),f.add("Notification-Callback-Context",h?"context":void 0),f.add("Notification-Callback-Context-Type",h?"string":void 0),f.add("Notification-Callback-Target",void 0),f.newline(),f.send(function(q,w){if(h&&q)h(q);else if(h&&w.state==="CALLBACK")h(void 0,w["Notification-Callback-Result"].toLowerCase())})};Au.exports=new S});var P=L((mh,Wu)=>{var Pe=t(),x=K(),G=Su(),Iu=_("events").EventEmitter,de=_("util");Wu.exports=I;var Gu;function I(u){if(u=x.clone(u||{}),!(this instanceof I))return new I(u);G.appname=u.name||"Node",this.options=u,Iu.call(this)}de.inherits(I,Iu);function ke(u,e){if(G.setHost(this.options.host,this.options.port),u=x.clone(u||{}),typeof u==="string")u={title:"node-notifier",message:u};if(e=x.actionJackerDecorator(this,u,e,function(h){if(h==="click")return"click";if(h==="timedout")return"timeout";return!1}),u=x.mapToGrowl(u),!u.message)return e(Error("Message is required.")),this;if(u.title=u.title||"Node Notification:",Gu||!!u.wait){let h=u.wait?e:be;if(G.notify(u.message,u,h),!u.wait)e();return this}return Pe(G,function(h,r){if(Gu=r,!r)return e(Error("Couldn't connect to growl (might be used as a fallback). Make sure it is running"));G.notify(u.message,u),e()}),this}Object.defineProperty(I.prototype,"notify",{get:function(){if(!this._notify)this._notify=ke.bind(this);return this._notify}});function be(){}});var cu=L((vh,Bu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",H=K(),le=P(),ae=_("path"),ie=ae.join(__dirname,"../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier"),zu=_("events").EventEmitter,ne=_("util"),te="You need Mac OS X 10.8 or above to use NotificationCenter, or use Growl fallback with constructor option {withFallback: true}.";Bu.exports=W;function W(u){if(u=H.clone(u||{}),!(this instanceof W))return new W(u);this.options=u,zu.call(this)}ne.inherits(W,zu);var Tu=null;function se(){}function pe(u,e){let h,r=oe();if(u=H.clone(u||{}),Tu=r,typeof u==="string")u={title:"node-notifier",message:u};if(e=e||se,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let f=H.actionJackerDecorator(this,u,e,function(w){if(Tu!==r)return!1;if(w==="activate")return"click";if(w==="timeout")return"timeout";if(w==="replied")return"replied";return!1});if(u=H.mapToMac(u),!u.message&&!u.group&&!u.list&&!u.remove)return e(Error("Message, group, remove or list property is required.")),this;let q=H.constructArgumentList(u);if(H.isMountainLion())return H.fileCommandJson(this.options.customPath||ie,q,f),this;if(h||!!this.options.withFallback)return h=h||new le(this.options),h.notify(u,e);return e(Error(te)),this}Object.defineProperty(W.prototype,"notify",{get:function(){if(!this._notify)this._notify=pe.bind(this);return this._notify}});function oe(){return{_ref:"val"}}});var s=L((xh,vu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",uh=_("path"),eh=uh.resolve(__dirname,"../vendor/notifu/notifu"),hh=t(),Y=K(),fh=p(),Du=P(),rh=_("os"),mu=_("events").EventEmitter,qh=_("util"),d;vu.exports=T;function T(u){if(u=Y.clone(u||{}),!(this instanceof T))return new T(u);this.options=u,mu.call(this)}qh.inherits(T,mu);function wh(){}function _h(u,e){let h,r=this.options;if(u=Y.clone(u||{}),e=e||wh,typeof u==="string")u={title:"node-notifier",message:u};let f=Y.actionJackerDecorator(this,u,e,function(q){if(q==="activate")return"click";if(q==="timeout")return"timeout";return!1});if(!!this.options.withFallback&&Y.isWin8())return h=h||new fh(r),h.notify(u,e);if(!!this.options.withFallback&&(!Y.isLessThanWin8()||d===!0))return h=h||new Du(r),h.notify(u,e);if(!this.options.withFallback||d===!1)return gu(u,r,f),this;return hh(r,function(q,w){if(d=w,d)return h=h||new Du(r),h.notify(u,e);gu(u,r,f)}),this}Object.defineProperty(T.prototype,"notify",{get:function(){if(!this._notify)this._notify=_h.bind(this);return this._notify}});var Eh=["t","d","p","m","i","e","q","w","xp"];function gu(u,e,h){let r=rh.arch()==="x64";u=u||{},u=Y.mapToNotifu(u),u.p=u.p||"Node Notification:";let f=eh+(r?"64":"")+".exe",q=e.customPath||f;if(!u.m)return h(Error("Message is required.")),this;let w=Y.constructArgumentList(u,{wrapper:"",noEscape:!0,explicitTrue:!0,allowedArguments:Eh});if(u.wait)return Y.fileCommand(q,w,function(E,M){let O=yh(E.code);if(O==="error")return h(E,M);return h(null,O)});Y.immediateFileCommand(q,w,h)}function yh(u){switch(u){case 2:return"timeout";case 3:case 6:case 7:return"activate";case 4:return"close";default:return"error"}}});var p=L((Ph,Pu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",Lh=_("path"),Jh=Lh.resolve(__dirname,"../vendor/snoreToast/snoretoast"),j=K(),Uh=s(),jh=_("os"),{v4:Yh}=(Mh(),Ch(Oh)),xu=_("events").EventEmitter,$h=_("util"),o;Pu.exports=z;function z(u){if(u=j.clone(u||{}),!(this instanceof z))return new z(u);this.options=u,xu.call(this)}$h.inherits(z,xu);function Xh(){}function Kh(u){if(!u)return{};return u.split(";").reduce((e,h)=>{let r=h.split("=");if(r&&r.length===2)e[r[0]]=r[1];return e},{})}function Zh(){return`${j.isWSL()?"/tmp/":"\\\\.\\pipe\\"}notifierPipe-${Yh()}`}function Hh(u,e){u=j.clone(u||{}),e=e||Xh;let h=jh.arch()==="x64",r,f={namedPipe:Zh()};if(typeof u==="string")u={title:"node-notifier",message:u};if(typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let q=(E,M)=>{let O=Kh(r&&r.toString("utf16le"));if(O.action==="buttonClicked"&&O.button)O.activationType=O.button;else if(O.action)O.activationType=O.action;if(E&&E.code===-1)M(E,O);M(null,O),f.instance&&f.instance.close()},w=(E)=>q(E,j.actionJackerDecorator(this,u,e,(M)=>M==="activate"?"click":M||!1));if(u.title=u.title||"Node Notification:",typeof u.message>"u"&&typeof u.close>"u")return e(Error("Message or ID to close is required.")),this;if(!j.isWin8()&&!j.isWSL()&&!!this.options.withFallback)return o=o||new Uh(this.options),o.notify(u,e);return j.createNamedPipe(f).then((E)=>{r=E,u.pipeName=f.namedPipe;let M=u.customPath||this.options.customPath||Jh+"-x"+(h?"64":"86")+".exe";u=j.mapToWin8(u);let O=j.constructArgumentList(u,{explicitTrue:!0,wrapper:"",keepNewlines:!0,noEscape:!0});j.fileCommand(M,O,w)}),this}Object.defineProperty(z.prototype,"notify",{get:function(){if(!this._notify)this._notify=Hh.bind(this);return this._notify}})});var bu=L((dh,C)=>{var du=_("os"),ku=K(),B=Hu(),uu=cu(),c=p(),eu=P(),hu=s(),R={withFallback:!0},Rh=ku.isWSL()?"WSL":du.type();switch(Rh){case"Linux":C.exports=new B(R),C.exports.Notification=B;break;case"Darwin":C.exports=new uu(R),C.exports.Notification=uu;break;case"Windows_NT":if(ku.isLessThanWin8())C.exports=new hu(R),C.exports.Notification=hu;else C.exports=new c(R),C.exports.Notification=c;break;case"WSL":C.exports=new c(R),C.exports.Notification=c;break;default:if(du.type().match(/BSD$/))C.exports=new B(R),C.exports.Notification=B;else C.exports=new eu(R),C.exports.Notification=eu}C.exports.NotifySend=B;C.exports.NotificationCenter=uu;C.exports.WindowsToaster=c;C.exports.WindowsBalloon=hu;C.exports.Growl=eu});import ru from"node:path";import lu from"node:os";import D from"node:fs";function au(u){let e=u.replace(/^~/,lu.homedir()),h=ru.resolve(e),r=ru.dirname(h);if(!D.existsSync(r))D.mkdirSync(r,{recursive:!0});return h}function iu(u,e){if(!D.existsSync(u)){process.env.DATABASE_INIT="true";return}let h=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,r=e??h??314572800,q=D.statSync(u).size,w=q/1048576;if(q>r){let E=r/1048576;console.trace(`⚠️ Database file is large: ${w.toFixed(2)}MB (limit: ${E.toFixed(2)}MB)`),console.trace(` Path: ${u}`),console.trace(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function Ah(u){let e=au(u);return process.env.SQLITE_DATABASE_URI=e,iu(e),e}var fu=Vh(bu(),1);function kh(u){if(typeof u==="string")fu.default.notify({title:"Notification",message:u});else fu.default.notify({title:u.title||"Notification",message:u.message,icon:u.icon,sound:u.sound??!0})}var lh={path:process.cwd()};export{Ah as te,kh as ue,lh as ve};
|
|
3
|
+
`;function Z(u,e){e=e||{},this.type=u,this.host=e.host||"localhost",this.port=e.port||23053,this.request="GNTP/1.0 "+u+" NONE"+J,this.resources=[],this.attempts=0,this.maxAttempts=5}Z.prototype.parseResp=function(u){var e={},h,r;return u=u.slice(0,u.indexOf(J+J)).split(J),h=u[0],r=u.slice(1),e.state=h.match(/-(OK|ERROR|CALLBACK)/)[0].slice(1),r.forEach(function(f){f=f.split(": "),e[f[0]]=f[1]}),e};Z.prototype.retry=function(){var u=this,e=arguments;setTimeout(function(){u.send.apply(u,e)},750)};Z.prototype.addResource=function(u){var e=ve.createHash("md5").update(u).digest("hex"),h="Identifier: "+e+J+"Length: "+u.length+J+J;return this.resources.push({header:h,file:u}),"x-growl-resource://"+e};Z.prototype.add=function(u,e){if(e===void 0)return;if(/-Icon/.test(u)&&!/^https?:\/\//.test(e)){if(/\.(png|gif|jpe?g)$/.test(e))e=this.addResource(xe.readFileSync(e));else if(e instanceof Buffer)e=this.addResource(e)}this.request+=u+": "+e+J};Z.prototype.newline=function(){this.request+=J};Z.prototype.send=function(u){var e=this,h=me.connect(this.port,this.host),r="";u=u||function(){},this.attempts+=1,h.on("connect",function(){h.write(e.request),e.resources.forEach(function(f){h.write(f.header),h.write(f.file),h.write(J+J)})}),h.on("data",function(f){if(r+=f.toString(),r.slice(r.length-4)!==J+J)return;if(r=e.parseResp(r),r.state==="ERROR"||r.state==="CALLBACK")h.end();else r=""}),h.on("end",function(){if(["200","401","402"].indexOf(r["Error-Code"])>=0)if(e.attempts<=e.maxAttempts)e.retry(u);else{var f='GNTP request to "%s:%d" failed with error code %s (%s)';u(Error(Vu(f,e.host,e.port,r["Error-Code"],r["Error-Description"])))}else u(void 0,r)}),h.on("error",function(){u(Error(Vu('Error while sending GNTP request to "%s:%d"',e.host,e.port))),h.destroy()})};Fu.exports=Z});var Su=L((gh,Au)=>{var Qu=Nu();function S(){this.appname="Growly",this.notifications=void 0,this.labels=void 0,this.count=0,this.registered=!1,this.host=void 0,this.port=void 0}S.prototype.getLabels=function(){return this.notifications.map(function(u){return u.label})};S.prototype.setHost=function(u,e){this.host=u,this.port=e};S.prototype.register=function(u,e,h,r){var f;if(typeof e==="object")h=e,e=void 0;if(h===void 0||!h.length)h=[{label:"default",dispname:"Default Notification",enabled:!0}];if(typeof arguments[arguments.length-1]==="function")r=arguments[arguments.length-1];else r=function(){};this.appname=u,this.notifications=h,this.labels=this.getLabels(),this.registered=!0,f=new Qu("REGISTER",{host:this.host,port:this.port}),f.add("Application-Name",u),f.add("Application-Icon",e),f.add("Notifications-Count",h.length),f.newline(),h.forEach(function(q){if(q.enabled===void 0)q.enabled=!0;f.add("Notification-Name",q.label),f.add("Notification-Display-Name",q.dispname),f.add("Notification-Enabled",q.enabled?"True":"False"),f.add("Notification-Icon",q.icon),f.newline()}),f.send(r)};S.prototype.notify=function(u,e,h){var r=this,f;if(!this.registered){this.register(this.appname,function(q){if(q)console.log(q);r.notify.call(r,u,e,h)});return}if(e=e||{},typeof e==="function")h=e,e={};f=new Qu("NOTIFY",{host:this.host,port:this.port}),f.add("Application-Name",this.appname),f.add("Notification-Name",e.label||this.labels[0]),f.add("Notification-ID",++this.count),f.add("Notification-Title",e.title),f.add("Notification-Text",u),f.add("Notification-Sticky",e.sticky?"True":"False"),f.add("Notification-Priority",e.priority),f.add("Notification-Icon",e.icon),f.add("Notification-Coalescing-ID",e.coalescingId||void 0),f.add("Notification-Callback-Context",h?"context":void 0),f.add("Notification-Callback-Context-Type",h?"string":void 0),f.add("Notification-Callback-Target",void 0),f.newline(),f.send(function(q,w){if(h&&q)h(q);else if(h&&w.state==="CALLBACK")h(void 0,w["Notification-Callback-Result"].toLowerCase())})};Au.exports=new S});var P=L((mh,Wu)=>{var Pe=t(),x=K(),G=Su(),Iu=_("events").EventEmitter,de=_("util");Wu.exports=I;var Gu;function I(u){if(u=x.clone(u||{}),!(this instanceof I))return new I(u);G.appname=u.name||"Node",this.options=u,Iu.call(this)}de.inherits(I,Iu);function ke(u,e){if(G.setHost(this.options.host,this.options.port),u=x.clone(u||{}),typeof u==="string")u={title:"node-notifier",message:u};if(e=x.actionJackerDecorator(this,u,e,function(h){if(h==="click")return"click";if(h==="timedout")return"timeout";return!1}),u=x.mapToGrowl(u),!u.message)return e(Error("Message is required.")),this;if(u.title=u.title||"Node Notification:",Gu||!!u.wait){let h=u.wait?e:be;if(G.notify(u.message,u,h),!u.wait)e();return this}return Pe(G,function(h,r){if(Gu=r,!r)return e(Error("Couldn't connect to growl (might be used as a fallback). Make sure it is running"));G.notify(u.message,u),e()}),this}Object.defineProperty(I.prototype,"notify",{get:function(){if(!this._notify)this._notify=ke.bind(this);return this._notify}});function be(){}});var cu=L((vh,Bu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",H=K(),le=P(),ae=_("path"),ie=ae.join(__dirname,"../vendor/mac.noindex/terminal-notifier.app/Contents/MacOS/terminal-notifier"),zu=_("events").EventEmitter,ne=_("util"),te="You need Mac OS X 10.8 or above to use NotificationCenter, or use Growl fallback with constructor option {withFallback: true}.";Bu.exports=W;function W(u){if(u=H.clone(u||{}),!(this instanceof W))return new W(u);this.options=u,zu.call(this)}ne.inherits(W,zu);var Tu=null;function se(){}function pe(u,e){let h,r=oe();if(u=H.clone(u||{}),Tu=r,typeof u==="string")u={title:"node-notifier",message:u};if(e=e||se,typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let f=H.actionJackerDecorator(this,u,e,function(w){if(Tu!==r)return!1;if(w==="activate")return"click";if(w==="timeout")return"timeout";if(w==="replied")return"replied";return!1});if(u=H.mapToMac(u),!u.message&&!u.group&&!u.list&&!u.remove)return e(Error("Message, group, remove or list property is required.")),this;let q=H.constructArgumentList(u);if(H.isMountainLion())return H.fileCommandJson(this.options.customPath||ie,q,f),this;if(h||!!this.options.withFallback)return h=h||new le(this.options),h.notify(u,e);return e(Error(te)),this}Object.defineProperty(W.prototype,"notify",{get:function(){if(!this._notify)this._notify=pe.bind(this);return this._notify}});function oe(){return{_ref:"val"}}});var s=L((xh,vu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",uh=_("path"),eh=uh.resolve(__dirname,"../vendor/notifu/notifu"),hh=t(),Y=K(),fh=p(),Du=P(),rh=_("os"),mu=_("events").EventEmitter,qh=_("util"),d;vu.exports=T;function T(u){if(u=Y.clone(u||{}),!(this instanceof T))return new T(u);this.options=u,mu.call(this)}qh.inherits(T,mu);function wh(){}function _h(u,e){let h,r=this.options;if(u=Y.clone(u||{}),e=e||wh,typeof u==="string")u={title:"node-notifier",message:u};let f=Y.actionJackerDecorator(this,u,e,function(q){if(q==="activate")return"click";if(q==="timeout")return"timeout";return!1});if(!!this.options.withFallback&&Y.isWin8())return h=h||new fh(r),h.notify(u,e);if(!!this.options.withFallback&&(!Y.isLessThanWin8()||d===!0))return h=h||new Du(r),h.notify(u,e);if(!this.options.withFallback||d===!1)return gu(u,r,f),this;return hh(r,function(q,w){if(d=w,d)return h=h||new Du(r),h.notify(u,e);gu(u,r,f)}),this}Object.defineProperty(T.prototype,"notify",{get:function(){if(!this._notify)this._notify=_h.bind(this);return this._notify}});var Eh=["t","d","p","m","i","e","q","w","xp"];function gu(u,e,h){let r=rh.arch()==="x64";u=u||{},u=Y.mapToNotifu(u),u.p=u.p||"Node Notification:";let f=eh+(r?"64":"")+".exe",q=e.customPath||f;if(!u.m)return h(Error("Message is required.")),this;let w=Y.constructArgumentList(u,{wrapper:"",noEscape:!0,explicitTrue:!0,allowedArguments:Eh});if(u.wait)return Y.fileCommand(q,w,function(E,M){let O=yh(E.code);if(O==="error")return h(E,M);return h(null,O)});Y.immediateFileCommand(q,w,h)}function yh(u){switch(u){case 2:return"timeout";case 3:case 6:case 7:return"activate";case 4:return"close";default:return"error"}}});var p=L((Ph,Pu)=>{var __dirname="/Users/konghayao/code/ai/code-graph/node_modules/.bun/node-notifier@10.0.1/node_modules/node-notifier/notifiers",Lh=_("path"),Jh=Lh.resolve(__dirname,"../vendor/snoreToast/snoretoast"),j=K(),Uh=s(),jh=_("os"),{v4:Yh}=(Mh(),Ch(Oh)),xu=_("events").EventEmitter,$h=_("util"),o;Pu.exports=z;function z(u){if(u=j.clone(u||{}),!(this instanceof z))return new z(u);this.options=u,xu.call(this)}$h.inherits(z,xu);function Xh(){}function Kh(u){if(!u)return{};return u.split(";").reduce((e,h)=>{let r=h.split("=");if(r&&r.length===2)e[r[0]]=r[1];return e},{})}function Zh(){return`${j.isWSL()?"/tmp/":"\\\\.\\pipe\\"}notifierPipe-${Yh()}`}function Hh(u,e){u=j.clone(u||{}),e=e||Xh;let h=jh.arch()==="x64",r,f={namedPipe:Zh()};if(typeof u==="string")u={title:"node-notifier",message:u};if(typeof e!=="function")throw TypeError("The second argument must be a function callback. You have passed "+typeof fn);let q=(E,M)=>{let O=Kh(r&&r.toString("utf16le"));if(O.action==="buttonClicked"&&O.button)O.activationType=O.button;else if(O.action)O.activationType=O.action;if(E&&E.code===-1)M(E,O);M(null,O),f.instance&&f.instance.close()},w=(E)=>q(E,j.actionJackerDecorator(this,u,e,(M)=>M==="activate"?"click":M||!1));if(u.title=u.title||"Node Notification:",typeof u.message>"u"&&typeof u.close>"u")return e(Error("Message or ID to close is required.")),this;if(!j.isWin8()&&!j.isWSL()&&!!this.options.withFallback)return o=o||new Uh(this.options),o.notify(u,e);return j.createNamedPipe(f).then((E)=>{r=E,u.pipeName=f.namedPipe;let M=u.customPath||this.options.customPath||Jh+"-x"+(h?"64":"86")+".exe";u=j.mapToWin8(u);let O=j.constructArgumentList(u,{explicitTrue:!0,wrapper:"",keepNewlines:!0,noEscape:!0});j.fileCommand(M,O,w)}),this}Object.defineProperty(z.prototype,"notify",{get:function(){if(!this._notify)this._notify=Hh.bind(this);return this._notify}})});var bu=L((dh,C)=>{var du=_("os"),ku=K(),B=Hu(),uu=cu(),c=p(),eu=P(),hu=s(),R={withFallback:!0},Rh=ku.isWSL()?"WSL":du.type();switch(Rh){case"Linux":C.exports=new B(R),C.exports.Notification=B;break;case"Darwin":C.exports=new uu(R),C.exports.Notification=uu;break;case"Windows_NT":if(ku.isLessThanWin8())C.exports=new hu(R),C.exports.Notification=hu;else C.exports=new c(R),C.exports.Notification=c;break;case"WSL":C.exports=new c(R),C.exports.Notification=c;break;default:if(du.type().match(/BSD$/))C.exports=new B(R),C.exports.Notification=B;else C.exports=new eu(R),C.exports.Notification=eu}C.exports.NotifySend=B;C.exports.NotificationCenter=uu;C.exports.WindowsToaster=c;C.exports.WindowsBalloon=hu;C.exports.Growl=eu});import ru from"node:path";import lu from"node:os";import D from"node:fs";function au(u){let e=u.replace(/^~/,lu.homedir()),h=ru.resolve(e),r=ru.dirname(h);if(!D.existsSync(r))D.mkdirSync(r,{recursive:!0});return h}function iu(u,e){if(!D.existsSync(u)){process.env.DATABASE_INIT="true";return}let h=process.env.SQLITE_MAX_SIZE_MB?parseInt(process.env.SQLITE_MAX_SIZE_MB,10)*1024*1024:void 0,r=e??h??314572800,q=D.statSync(u).size,w=q/1048576;if(q>r){let E=r/1048576;console.trace(`⚠️ Database file is large: ${w.toFixed(2)}MB (limit: ${E.toFixed(2)}MB)`),console.trace(` Path: ${u}`),console.trace(" Set SQLITE_MAX_SIZE_MB to adjust limit")}}function Ah(u){let e=au(u);return process.env.SQLITE_DATABASE_URI=e,iu(e),e}var fu=Vh(bu(),1);function kh(u){if(typeof u==="string")fu.default.notify({title:"Notification",message:u});else fu.default.notify({title:u.title||"Notification",message:u.message,icon:u.icon,sound:u.sound??!0})}var lh={path:process.cwd()};export{Ah as R,kh as S,lh as T};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Dl as W8,Fl as E1,Il as o5}from"./chunk-y8qhrx11.js";var Y4=E1((sY,X6)=>{var J6=["nodebuffer","arraybuffer","fragments"],K6=typeof Blob<"u";if(K6)J6.push("blob");X6.exports={BINARY_TYPES:J6,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K6,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var _3=E1((oY,$7)=>{var{EMPTY_BUFFER:qI}=Y4(),gJ=Buffer[Symbol.species];function UI(G,H){if(G.length===0)return qI;if(G.length===1)return G[0];let R=Buffer.allocUnsafe(H),P=0;for(let D=0;D<G.length;D++){let M=G[D];R.set(M,P),P+=M.length}if(P<H)return new gJ(R.buffer,R.byteOffset,P);return R}function Z6(G,H,R,P,D){for(let M=0;M<D;M++)R[P+M]=G[M]^H[M&3]}function $6(G,H){for(let R=0;R<G.length;R++)G[R]^=H[R&3]}function LI(G){if(G.length===G.buffer.byteLength)return G.buffer;return G.buffer.slice(G.byteOffset,G.byteOffset+G.length)}function hJ(G){if(hJ.readOnly=!0,Buffer.isBuffer(G))return G;let H;if(G instanceof ArrayBuffer)H=new gJ(G);else if(ArrayBuffer.isView(G))H=new gJ(G.buffer,G.byteOffset,G.byteLength);else H=Buffer.from(G),hJ.readOnly=!1;return H}$7.exports={concat:UI,mask:Z6,toArrayBuffer:LI,toBuffer:hJ,unmask:$6};if(!process.env.WS_NO_BUFFER_UTIL)try{let G=(()=>{throw new Error("Cannot require module "+"bufferutil");})();$7.exports.mask=function(H,R,P,D,M){if(M<48)Z6(H,R,P,D,M);else G.mask(H,R,P,D,M)},$7.exports.unmask=function(H,R){if(H.length<32)$6(H,R);else G.unmask(H,R)}}catch(G){}});var z6=E1((tY,I6)=>{var Q6=Symbol("kDone"),mJ=Symbol("kRun");class G6{constructor(G){this[Q6]=()=>{this.pending--,this[mJ]()},this.concurrency=G||1/0,this.jobs=[],this.pending=0}add(G){this.jobs.push(G),this[mJ]()}[mJ](){if(this.pending===this.concurrency)return;if(this.jobs.length){let G=this.jobs.shift();this.pending++,G(this[Q6])}}}I6.exports=G6});var N3=E1((eY,H6)=>{var H3=o5("zlib"),j6=_3(),WI=z6(),{kStatusCode:Y6}=Y4(),EI=Buffer[Symbol.species],yI=Buffer.from([0,0,255,255]),G7=Symbol("permessage-deflate"),V4=Symbol("total-length"),T8=Symbol("callback"),U4=Symbol("buffers"),x8=Symbol("error"),Q7;class V6{constructor(G,H,R){if(this._maxPayload=R|0,this._options=G||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!H,this._deflate=null,this._inflate=null,this.params=null,!Q7){let P=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Q7=new WI(P)}}static get extensionName(){return"permessage-deflate"}offer(){let G={};if(this._options.serverNoContextTakeover)G.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)G.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)G.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)G.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)G.client_max_window_bits=!0;return G}accept(G){return G=this.normalizeParams(G),this.params=this._isServer?this.acceptAsServer(G):this.acceptAsClient(G),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let G=this._deflate[T8];if(this._deflate.close(),this._deflate=null,G)G(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(G){let H=this._options,R=G.find((P)=>{if(H.serverNoContextTakeover===!1&&P.server_no_context_takeover||P.server_max_window_bits&&(H.serverMaxWindowBits===!1||typeof H.serverMaxWindowBits==="number"&&H.serverMaxWindowBits>P.server_max_window_bits)||typeof H.clientMaxWindowBits==="number"&&!P.client_max_window_bits)return!1;return!0});if(!R)throw Error("None of the extension offers can be accepted");if(H.serverNoContextTakeover)R.server_no_context_takeover=!0;if(H.clientNoContextTakeover)R.client_no_context_takeover=!0;if(typeof H.serverMaxWindowBits==="number")R.server_max_window_bits=H.serverMaxWindowBits;if(typeof H.clientMaxWindowBits==="number")R.client_max_window_bits=H.clientMaxWindowBits;else if(R.client_max_window_bits===!0||H.clientMaxWindowBits===!1)delete R.client_max_window_bits;return R}acceptAsClient(G){let H=G[0];if(this._options.clientNoContextTakeover===!1&&H.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!H.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")H.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&H.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return H}normalizeParams(G){return G.forEach((H)=>{Object.keys(H).forEach((R)=>{let P=H[R];if(P.length>1)throw Error(`Parameter "${R}" must have only a single value`);if(P=P[0],R==="client_max_window_bits"){if(P!==!0){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else if(R==="server_max_window_bits"){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(R==="client_no_context_takeover"||R==="server_no_context_takeover"){if(P!==!0)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else throw Error(`Unknown parameter "${R}"`);H[R]=P})}),G}decompress(G,H,R){Q7.add((P)=>{this._decompress(G,H,(D,M)=>{P(),R(D,M)})})}compress(G,H,R){Q7.add((P)=>{this._compress(G,H,(D,M)=>{P(),R(D,M)})})}_decompress(G,H,R){let P=this._isServer?"client":"server";if(!this._inflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._inflate=H3.createInflateRaw({...this._options.zlibInflateOptions,windowBits:M}),this._inflate[G7]=this,this._inflate[V4]=0,this._inflate[U4]=[],this._inflate.on("error",vI),this._inflate.on("data",_6)}if(this._inflate[T8]=R,this._inflate.write(G),H)this._inflate.write(yI);this._inflate.flush(()=>{let D=this._inflate[x8];if(D){this._inflate.close(),this._inflate=null,R(D);return}let M=j6.concat(this._inflate[U4],this._inflate[V4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[V4]=0,this._inflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._inflate.reset();R(null,M)})}_compress(G,H,R){let P=this._isServer?"server":"client";if(!this._deflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._deflate=H3.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:M}),this._deflate[V4]=0,this._deflate[U4]=[],this._deflate.on("data",SI)}this._deflate[T8]=R,this._deflate.write(G),this._deflate.flush(H3.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let D=j6.concat(this._deflate[U4],this._deflate[V4]);if(H)D=new EI(D.buffer,D.byteOffset,D.length-4);if(this._deflate[T8]=null,this._deflate[V4]=0,this._deflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._deflate.reset();R(null,D)})}}H6.exports=V6;function SI(G){this[U4].push(G),this[V4]+=G.length}function _6(G){if(this[V4]+=G.length,this[G7]._maxPayload<1||this[V4]<=this[G7]._maxPayload){this[U4].push(G);return}this[x8]=RangeError("Max payload size exceeded"),this[x8].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[x8][Y6]=1009,this.removeListener("data",_6),this.reset()}function vI(G){if(this[G7]._inflate=null,this[x8]){this[T8](this[x8]);return}G[Y6]=1007,this[T8](G)}});var B8=E1((JV,I7)=>{var{isUtf8:N6}=o5("buffer"),{hasBlob:wI}=Y4(),gI=[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 hI(G){return G>=1000&&G<=1014&&G!==1004&&G!==1005&&G!==1006||G>=3000&&G<=4999}function fJ(G){let H=G.length,R=0;while(R<H)if((G[R]&128)===0)R++;else if((G[R]&224)===192){if(R+1===H||(G[R+1]&192)!==128||(G[R]&254)===192)return!1;R+=2}else if((G[R]&240)===224){if(R+2>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||G[R]===224&&(G[R+1]&224)===128||G[R]===237&&(G[R+1]&224)===160)return!1;R+=3}else if((G[R]&248)===240){if(R+3>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||(G[R+3]&192)!==128||G[R]===240&&(G[R+1]&240)===128||G[R]===244&&G[R+1]>143||G[R]>244)return!1;R+=4}else return!1;return!0}function mI(G){return wI&&typeof G==="object"&&typeof G.arrayBuffer==="function"&&typeof G.type==="string"&&typeof G.stream==="function"&&(G[Symbol.toStringTag]==="Blob"||G[Symbol.toStringTag]==="File")}I7.exports={isBlob:mI,isValidStatusCode:hI,isValidUTF8:fJ,tokenChars:gI};if(N6)I7.exports.isValidUTF8=function(G){return G.length<24?fJ(G):N6(G)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let G=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();I7.exports.isValidUTF8=function(H){return H.length<32?fJ(H):G(H)}}catch(G){}});var lJ=E1((KV,O6)=>{var{Writable:fI}=o5("stream"),R6=N3(),{BINARY_TYPES:uI,EMPTY_BUFFER:A6,kStatusCode:lI,kWebSocket:pI}=Y4(),{concat:uJ,toArrayBuffer:kI,unmask:bI}=_3(),{isValidStatusCode:iI,isValidUTF8:F6}=B8(),z7=Buffer[Symbol.species];class D6 extends fI{constructor(G={}){super();this._allowSynchronousEvents=G.allowSynchronousEvents!==void 0?G.allowSynchronousEvents:!0,this._binaryType=G.binaryType||uI[0],this._extensions=G.extensions||{},this._isServer=!!G.isServer,this._maxPayload=G.maxPayload|0,this._skipUTF8Validation=!!G.skipUTF8Validation,this[pI]=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=0}_write(G,H,R){if(this._opcode===8&&this._state==0)return R();this._bufferedBytes+=G.length,this._buffers.push(G),this.startLoop(R)}consume(G){if(this._bufferedBytes-=G,G===this._buffers[0].length)return this._buffers.shift();if(G<this._buffers[0].length){let R=this._buffers[0];return this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G),new z7(R.buffer,R.byteOffset,G)}let H=Buffer.allocUnsafe(G);do{let R=this._buffers[0],P=H.length-G;if(G>=R.length)H.set(this._buffers.shift(),P);else H.set(new Uint8Array(R.buffer,R.byteOffset,G),P),this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G);G-=R.length}while(G>0);return H}startLoop(G){this._loop=!0;do switch(this._state){case 0:this.getInfo(G);break;case 1:this.getPayloadLength16(G);break;case 2:this.getPayloadLength64(G);break;case 3:this.getMask();break;case 4:this.getData(G);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)G()}getInfo(G){if(this._bufferedBytes<2){this._loop=!1;return}let H=this.consume(2);if((H[0]&48)!==0){let P=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");G(P);return}let R=(H[0]&64)===64;if(R&&!this._extensions[R6.extensionName]){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._fin=(H[0]&128)===128,this._opcode=H[0]&15,this._payloadLength=H[1]&127,this._opcode===0){if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(!this._fragmented){let P=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._compressed=R}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let P=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");G(P);return}if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let P=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");G(P);return}}else{let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(H[1]&128)===128,this._isServer){if(!this._masked){let P=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");G(P);return}}else if(this._masked){let P=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");G(P);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(G)}getPayloadLength16(G){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(G)}getPayloadLength64(G){if(this._bufferedBytes<8){this._loop=!1;return}let H=this.consume(8),R=H.readUInt32BE(0);if(R>Math.pow(2,21)-1){let P=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");G(P);return}this._payloadLength=R*Math.pow(2,32)+H.readUInt32BE(4),this.haveLength(G)}haveLength(G){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let H=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(H);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(G){let H=A6;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(H=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)bI(H,this._mask)}if(this._opcode>7){this.controlMessage(H,G);return}if(this._compressed){this._state=5,this.decompress(H,G);return}if(H.length)this._messageLength=this._totalPayloadLength,this._fragments.push(H);this.dataMessage(G)}decompress(G,H){this._extensions[R6.extensionName].decompress(G,this._fin,(P,D)=>{if(P)return H(P);if(D.length){if(this._messageLength+=D.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let M=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");H(M);return}this._fragments.push(D)}if(this.dataMessage(H),this._state===0)this.startLoop(H)})}dataMessage(G){if(!this._fin){this._state=0;return}let H=this._messageLength,R=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let P;if(this._binaryType==="nodebuffer")P=uJ(R,H);else if(this._binaryType==="arraybuffer")P=kI(uJ(R,H));else if(this._binaryType==="blob")P=new Blob(R);else P=R;if(this._allowSynchronousEvents)this.emit("message",P,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!0),this._state=0,this.startLoop(G)})}else{let P=uJ(R,H);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(D);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",P,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!1),this._state=0,this.startLoop(G)})}}controlMessage(G,H){if(this._opcode===8){if(G.length===0)this._loop=!1,this.emit("conclude",1005,A6),this.end();else{let R=G.readUInt16BE(0);if(!iI(R)){let D=this.createError(RangeError,`invalid status code ${R}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");H(D);return}let P=new z7(G.buffer,G.byteOffset+2,G.length-2);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");H(D);return}this._loop=!1,this.emit("conclude",R,P),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",G),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",G),this._state=0,this.startLoop(H)})}createError(G,H,R,P,D){this._loop=!1,this._errored=!0;let M=new G(R?`Invalid WebSocket frame: ${H}`:H);return Error.captureStackTrace(M,this.createError),M.code=D,M[lI]=P,M}}O6.exports=D6});var kJ=E1((ZV,T6)=>{var{Duplex:XV}=o5("stream"),{randomFillSync:dI}=o5("crypto"),M6=N3(),{EMPTY_BUFFER:cI,kWebSocket:nI,NOOP:rI}=Y4(),{isBlob:C8,isValidStatusCode:aI}=B8(),{mask:P6,toBuffer:n4}=_3(),k1=Symbol("kByteLength"),sI=Buffer.alloc(4),r4,q8=8192,c1=0,oI=1,tI=2;class L4{constructor(G,H,R){if(this._extensions=H||{},R)this._generateMask=R,this._maskBuffer=Buffer.alloc(4);this._socket=G,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=c1,this.onerror=rI,this[nI]=void 0}static frame(G,H){let R,P=!1,D=2,M=!1;if(H.mask){if(R=H.maskBuffer||sI,H.generateMask)H.generateMask(R);else{if(q8===8192){if(r4===void 0)r4=Buffer.alloc(8192);dI(r4,0,8192),q8=0}R[0]=r4[q8++],R[1]=r4[q8++],R[2]=r4[q8++],R[3]=r4[q8++]}M=(R[0]|R[1]|R[2]|R[3])===0,D=6}let p;if(typeof G==="string")if((!H.mask||M)&&H[k1]!==void 0)p=H[k1];else G=Buffer.from(G),p=G.length;else p=G.length,P=H.mask&&H.readOnly&&!M;let f=p;if(p>=65536)D+=8,f=127;else if(p>125)D+=2,f=126;let u=Buffer.allocUnsafe(P?p+D:D);if(u[0]=H.fin?H.opcode|128:H.opcode,H.rsv1)u[0]|=64;if(u[1]=f,f===126)u.writeUInt16BE(p,2);else if(f===127)u[2]=u[3]=0,u.writeUIntBE(p,4,6);if(!H.mask)return[u,G];if(u[1]|=128,u[D-4]=R[0],u[D-3]=R[1],u[D-2]=R[2],u[D-1]=R[3],M)return[u,G];if(P)return P6(G,R,u,D,p),[u];return P6(G,R,G,0,p),[u,G]}close(G,H,R,P){let D;if(G===void 0)D=cI;else if(typeof G!=="number"||!aI(G))throw TypeError("First argument must be a valid error code number");else if(H===void 0||!H.length)D=Buffer.allocUnsafe(2),D.writeUInt16BE(G,0);else{let p=Buffer.byteLength(H);if(p>123)throw RangeError("The message must not be greater than 123 bytes");if(D=Buffer.allocUnsafe(2+p),D.writeUInt16BE(G,0),typeof H==="string")D.write(H,2);else D.set(H,2)}let M={[k1]:D.length,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==c1)this.enqueue([this.dispatch,D,!1,M,P]);else this.sendFrame(L4.frame(D,M),P)}ping(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:9,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}pong(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:10,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}send(G,H,R){let P=this._extensions[M6.extensionName],D=H.binary?2:1,M=H.compress,p,f;if(typeof G==="string")p=Buffer.byteLength(G),f=!1;else if(C8(G))p=G.size,f=!1;else G=n4(G),p=G.length,f=n4.readOnly;if(this._firstFragment){if(this._firstFragment=!1,M&&P&&P.params[P._isServer?"server_no_context_takeover":"client_no_context_takeover"])M=p>=P._threshold;this._compress=M}else M=!1,D=0;if(H.fin)this._firstFragment=!0;let u={[k1]:p,fin:H.fin,generateMask:this._generateMask,mask:H.mask,maskBuffer:this._maskBuffer,opcode:D,readOnly:f,rsv1:M};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,this._compress,u,R]);else this.getBlobData(G,this._compress,u,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,this._compress,u,R]);else this.dispatch(G,this._compress,u,R)}getBlobData(G,H,R,P){this._bufferedBytes+=R[k1],this._state=tI,G.arrayBuffer().then((D)=>{if(this._socket.destroyed){let p=Error("The socket was closed while the blob was being read");process.nextTick(pJ,this,p,P);return}this._bufferedBytes-=R[k1];let M=n4(D);if(!H)this._state=c1,this.sendFrame(L4.frame(M,R),P),this.dequeue();else this.dispatch(M,H,R,P)}).catch((D)=>{process.nextTick(eI,this,D,P)})}dispatch(G,H,R,P){if(!H){this.sendFrame(L4.frame(G,R),P);return}let D=this._extensions[M6.extensionName];this._bufferedBytes+=R[k1],this._state=oI,D.compress(G,R.fin,(M,p)=>{if(this._socket.destroyed){let f=Error("The socket was closed while data was being compressed");pJ(this,f,P);return}this._bufferedBytes-=R[k1],this._state=c1,R.readOnly=!1,this.sendFrame(L4.frame(p,R),P),this.dequeue()})}dequeue(){while(this._state===c1&&this._queue.length){let G=this._queue.shift();this._bufferedBytes-=G[3][k1],Reflect.apply(G[0],this,G.slice(1))}}enqueue(G){this._bufferedBytes+=G[3][k1],this._queue.push(G)}sendFrame(G,H){if(G.length===2)this._socket.cork(),this._socket.write(G[0]),this._socket.write(G[1],H),this._socket.uncork();else this._socket.write(G[0],H)}}T6.exports=L4;function pJ(G,H,R){if(typeof R==="function")R(H);for(let P=0;P<G._queue.length;P++){let D=G._queue[P],M=D[D.length-1];if(typeof M==="function")M(H)}}function eI(G,H,R){pJ(G,H,R),G.onerror(H)}});var y6=E1(($V,E6)=>{var{kForOnEventAttribute:R3,kListener:bJ}=Y4(),x6=Symbol("kCode"),B6=Symbol("kData"),C6=Symbol("kError"),q6=Symbol("kMessage"),U6=Symbol("kReason"),U8=Symbol("kTarget"),L6=Symbol("kType"),W6=Symbol("kWasClean");class W4{constructor(G){this[U8]=null,this[L6]=G}get target(){return this[U8]}get type(){return this[L6]}}Object.defineProperty(W4.prototype,"target",{enumerable:!0});Object.defineProperty(W4.prototype,"type",{enumerable:!0});class L8 extends W4{constructor(G,H={}){super(G);this[x6]=H.code===void 0?0:H.code,this[U6]=H.reason===void 0?"":H.reason,this[W6]=H.wasClean===void 0?!1:H.wasClean}get code(){return this[x6]}get reason(){return this[U6]}get wasClean(){return this[W6]}}Object.defineProperty(L8.prototype,"code",{enumerable:!0});Object.defineProperty(L8.prototype,"reason",{enumerable:!0});Object.defineProperty(L8.prototype,"wasClean",{enumerable:!0});class A3 extends W4{constructor(G,H={}){super(G);this[C6]=H.error===void 0?null:H.error,this[q6]=H.message===void 0?"":H.message}get error(){return this[C6]}get message(){return this[q6]}}Object.defineProperty(A3.prototype,"error",{enumerable:!0});Object.defineProperty(A3.prototype,"message",{enumerable:!0});class Y7 extends W4{constructor(G,H={}){super(G);this[B6]=H.data===void 0?null:H.data}get data(){return this[B6]}}Object.defineProperty(Y7.prototype,"data",{enumerable:!0});var Jz={addEventListener(G,H,R={}){for(let D of this.listeners(G))if(!R[R3]&&D[bJ]===H&&!D[R3])return;let P;if(G==="message")P=function(M,p){let f=new Y7("message",{data:p?M:M.toString()});f[U8]=this,j7(H,this,f)};else if(G==="close")P=function(M,p){let f=new L8("close",{code:M,reason:p.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[U8]=this,j7(H,this,f)};else if(G==="error")P=function(M){let p=new A3("error",{error:M,message:M.message});p[U8]=this,j7(H,this,p)};else if(G==="open")P=function(){let M=new W4("open");M[U8]=this,j7(H,this,M)};else return;if(P[R3]=!!R[R3],P[bJ]=H,R.once)this.once(G,P);else this.on(G,P)},removeEventListener(G,H){for(let R of this.listeners(G))if(R[bJ]===H&&!R[R3]){this.removeListener(G,R);break}}};E6.exports={CloseEvent:L8,ErrorEvent:A3,Event:W4,EventTarget:Jz,MessageEvent:Y7};function j7(G,H,R){if(typeof G==="object"&&G.handleEvent)G.handleEvent.call(G,R);else G.call(H,R)}});var iJ=E1((QV,S6)=>{var{tokenChars:F3}=B8();function X4(G,H,R){if(G[H]===void 0)G[H]=[R];else G[H].push(R)}function Kz(G){let H=Object.create(null),R=Object.create(null),P=!1,D=!1,M=!1,p,f,u=-1,V0=-1,R0=-1,Z0=0;for(;Z0<G.length;Z0++)if(V0=G.charCodeAt(Z0),p===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(Z0!==0&&(V0===32||V0===9)){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(V0===44)X4(H,h,R),R=Object.create(null);else p=h;u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(f===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(V0===32||V0===9){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;if(X4(R,G.slice(u,R0),!0),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;u=R0=-1}else if(V0===61&&u!==-1&&R0===-1)f=G.slice(u,Z0),u=R0=-1;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(D){if(F3[V0]!==1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1)u=Z0;else if(!P)P=!0;D=!1}else if(M)if(F3[V0]===1){if(u===-1)u=Z0}else if(V0===34&&u!==-1)M=!1,R0=Z0;else if(V0===92)D=!0;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(V0===34&&G.charCodeAt(Z0-1)===61)M=!0;else if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(u!==-1&&(V0===32||V0===9)){if(R0===-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(P)h=h.replace(/\\/g,""),P=!1;if(X4(R,f,h),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;f=void 0,u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1||M||V0===32||V0===9)throw SyntaxError("Unexpected end of input");if(R0===-1)R0=Z0;let U=G.slice(u,R0);if(p===void 0)X4(H,U,R);else{if(f===void 0)X4(R,U,!0);else if(P)X4(R,f,U.replace(/\\/g,""));else X4(R,f,U);X4(H,p,R)}return H}function Xz(G){return Object.keys(G).map((H)=>{let R=G[H];if(!Array.isArray(R))R=[R];return R.map((P)=>{return[H].concat(Object.keys(P).map((D)=>{let M=P[D];if(!Array.isArray(M))M=[M];return M.map((p)=>p===!0?D:`${D}=${p}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}S6.exports={format:Xz,parse:Kz}});var N7=E1((zV,i6)=>{var Zz=o5("events"),$z=o5("https"),Qz=o5("http"),g6=o5("net"),Gz=o5("tls"),{randomBytes:Iz,createHash:zz}=o5("crypto"),{Duplex:GV,Readable:IV}=o5("stream"),{URL:dJ}=o5("url"),E4=N3(),jz=lJ(),Yz=kJ(),{isBlob:Vz}=B8(),{BINARY_TYPES:v6,CLOSE_TIMEOUT:_z,EMPTY_BUFFER:V7,GUID:Hz,kForOnEventAttribute:cJ,kListener:Nz,kStatusCode:Rz,kWebSocket:Y1,NOOP:h6}=Y4(),{EventTarget:{addEventListener:Az,removeEventListener:Fz}}=y6(),{format:Dz,parse:Oz}=iJ(),{toBuffer:Mz}=_3(),m6=Symbol("kAborted"),nJ=[8,13],_4=["CONNECTING","OPEN","CLOSING","CLOSED"],Pz=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends Zz{constructor(G,H,R){super();if(this._binaryType=v6[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=V7,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,G!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,H===void 0)H=[];else if(!Array.isArray(H))if(typeof H==="object"&&H!==null)R=H,H=[];else H=[H];f6(this,G,H,R)}else this._autoPong=R.autoPong,this._closeTimeout=R.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(G){if(!v6.includes(G))return;if(this._binaryType=G,this._receiver)this._receiver._binaryType=G}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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(G,H,R){let P=new jz({allowSynchronousEvents:R.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:R.maxPayload,skipUTF8Validation:R.skipUTF8Validation}),D=new Yz(G,this._extensions,R.generateMask);if(this._receiver=P,this._sender=D,this._socket=G,P[Y1]=this,D[Y1]=this,G[Y1]=this,P.on("conclude",Bz),P.on("drain",Cz),P.on("error",qz),P.on("message",Uz),P.on("ping",Lz),P.on("pong",Wz),D.onerror=Ez,G.setTimeout)G.setTimeout(0);if(G.setNoDelay)G.setNoDelay();if(H.length>0)G.unshift(H);G.on("close",p6),G.on("data",H7),G.on("end",k6),G.on("error",b6),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[E4.extensionName])this._extensions[E4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(G,H){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=a0.CLOSING,this._sender.close(G,H,!this._isServer,(R)=>{if(R)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),l6(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.ping(G||V7,H,R)}pong(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.pong(G||V7,H,R)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof H==="function")R=H,H={};if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}let P={binary:typeof G!=="string",mask:!this._isServer,compress:!0,fin:!0,...H};if(!this._extensions[E4.extensionName])P.compress=!1;this._sender.send(G||V7,P,R)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((G)=>{Object.defineProperty(a0.prototype,G,{enumerable:!0})});["open","error","close","message"].forEach((G)=>{Object.defineProperty(a0.prototype,`on${G}`,{enumerable:!0,get(){for(let H of this.listeners(G))if(H[cJ])return H[Nz];return null},set(H){for(let R of this.listeners(G))if(R[cJ]){this.removeListener(G,R);break}if(typeof H!=="function")return;this.addEventListener(G,H,{[cJ]:!0})}})});a0.prototype.addEventListener=Az;a0.prototype.removeEventListener=Fz;i6.exports=a0;function f6(G,H,R,P){let D={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_z,protocolVersion:nJ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...P,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(G._autoPong=D.autoPong,G._closeTimeout=D.closeTimeout,!nJ.includes(D.protocolVersion))throw RangeError(`Unsupported protocol version: ${D.protocolVersion} (supported versions: ${nJ.join(", ")})`);let M;if(H instanceof dJ)M=H;else try{M=new dJ(H)}catch(y){throw SyntaxError(`Invalid URL: ${H}`)}if(M.protocol==="http:")M.protocol="ws:";else if(M.protocol==="https:")M.protocol="wss:";G._url=M.href;let p=M.protocol==="wss:",f=M.protocol==="ws+unix:",u;if(M.protocol!=="ws:"&&!p&&!f)u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(f&&!M.pathname)u="The URL's pathname is empty";else if(M.hash)u="The URL contains a fragment identifier";if(u){let y=SyntaxError(u);if(G._redirects===0)throw y;else{_7(G,y);return}}let V0=p?443:80,R0=Iz(16).toString("base64"),Z0=p?$z.request:Qz.request,U=new Set,h;if(D.createConnection=D.createConnection||(p?xz:Tz),D.defaultPort=D.defaultPort||V0,D.port=M.port||V0,D.host=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,D.headers={...D.headers,"Sec-WebSocket-Version":D.protocolVersion,"Sec-WebSocket-Key":R0,Connection:"Upgrade",Upgrade:"websocket"},D.path=M.pathname+M.search,D.timeout=D.handshakeTimeout,D.perMessageDeflate)h=new E4(D.perMessageDeflate!==!0?D.perMessageDeflate:{},!1,D.maxPayload),D.headers["Sec-WebSocket-Extensions"]=Dz({[E4.extensionName]:h.offer()});if(R.length){for(let y of R){if(typeof y!=="string"||!Pz.test(y)||U.has(y))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(y)}D.headers["Sec-WebSocket-Protocol"]=R.join(",")}if(D.origin)if(D.protocolVersion<13)D.headers["Sec-WebSocket-Origin"]=D.origin;else D.headers.Origin=D.origin;if(M.username||M.password)D.auth=`${M.username}:${M.password}`;if(f){let y=D.path.split(":");D.socketPath=y[0],D.path=y[1]}let g;if(D.followRedirects){if(G._redirects===0){G._originalIpc=f,G._originalSecure=p,G._originalHostOrSocketPath=f?D.socketPath:M.host;let y=P&&P.headers;if(P={...P,headers:{}},y)for(let[r,F0]of Object.entries(y))P.headers[r.toLowerCase()]=F0}else if(G.listenerCount("redirect")===0){let y=f?G._originalIpc?D.socketPath===G._originalHostOrSocketPath:!1:G._originalIpc?!1:M.host===G._originalHostOrSocketPath;if(!y||G._originalSecure&&!p){if(delete D.headers.authorization,delete D.headers.cookie,!y)delete D.headers.host;D.auth=void 0}}if(D.auth&&!P.headers.authorization)P.headers.authorization="Basic "+Buffer.from(D.auth).toString("base64");if(g=G._req=Z0(D),G._redirects)G.emit("redirect",G.url,g)}else g=G._req=Z0(D);if(D.timeout)g.on("timeout",()=>{v1(G,g,"Opening handshake has timed out")});if(g.on("error",(y)=>{if(g===null||g[m6])return;g=G._req=null,_7(G,y)}),g.on("response",(y)=>{let r=y.headers.location,F0=y.statusCode;if(r&&D.followRedirects&&F0>=300&&F0<400){if(++G._redirects>D.maxRedirects){v1(G,g,"Maximum redirects exceeded");return}g.abort();let v0;try{v0=new dJ(r,H)}catch($0){let A0=SyntaxError(`Invalid URL: ${r}`);_7(G,A0);return}f6(G,v0,R,P)}else if(!G.emit("unexpected-response",g,y))v1(G,g,`Unexpected server response: ${y.statusCode}`)}),g.on("upgrade",(y,r,F0)=>{if(G.emit("upgrade",y),G.readyState!==a0.CONNECTING)return;g=G._req=null;let v0=y.headers.upgrade;if(v0===void 0||v0.toLowerCase()!=="websocket"){v1(G,r,"Invalid Upgrade header");return}let $0=zz("sha1").update(R0+Hz).digest("base64");if(y.headers["sec-websocket-accept"]!==$0){v1(G,r,"Invalid Sec-WebSocket-Accept header");return}let A0=y.headers["sec-websocket-protocol"],Q0;if(A0!==void 0){if(!U.size)Q0="Server sent a subprotocol but none was requested";else if(!U.has(A0))Q0="Server sent an invalid subprotocol"}else if(U.size)Q0="Server sent no subprotocol";if(Q0){v1(G,r,Q0);return}if(A0)G._protocol=A0;let H0=y.headers["sec-websocket-extensions"];if(H0!==void 0){if(!h){v1(G,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let I0;try{I0=Oz(H0)}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}let L0=Object.keys(I0);if(L0.length!==1||L0[0]!==E4.extensionName){v1(G,r,"Server indicated an extension that was not requested");return}try{h.accept(I0[E4.extensionName])}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}G._extensions[E4.extensionName]=h}G.setSocket(r,F0,{allowSynchronousEvents:D.allowSynchronousEvents,generateMask:D.generateMask,maxPayload:D.maxPayload,skipUTF8Validation:D.skipUTF8Validation})}),D.finishRequest)D.finishRequest(g,G);else g.end()}function _7(G,H){G._readyState=a0.CLOSING,G._errorEmitted=!0,G.emit("error",H),G.emitClose()}function Tz(G){return G.path=G.socketPath,g6.connect(G)}function xz(G){if(G.path=void 0,!G.servername&&G.servername!=="")G.servername=g6.isIP(G.host)?"":G.host;return Gz.connect(G)}function v1(G,H,R){G._readyState=a0.CLOSING;let P=Error(R);if(Error.captureStackTrace(P,v1),H.setHeader){if(H[m6]=!0,H.abort(),H.socket&&!H.socket.destroyed)H.socket.destroy();process.nextTick(_7,G,P)}else H.destroy(P),H.once("error",G.emit.bind(G,"error")),H.once("close",G.emitClose.bind(G))}function rJ(G,H,R){if(H){let P=Vz(H)?H.size:Mz(H).length;if(G._socket)G._sender._bufferedBytes+=P;else G._bufferedAmount+=P}if(R){let P=Error(`WebSocket is not open: readyState ${G.readyState} (${_4[G.readyState]})`);process.nextTick(R,P)}}function Bz(G,H){let R=this[Y1];if(R._closeFrameReceived=!0,R._closeMessage=H,R._closeCode=G,R._socket[Y1]===void 0)return;if(R._socket.removeListener("data",H7),process.nextTick(u6,R._socket),G===1005)R.close();else R.close(G,H)}function Cz(){let G=this[Y1];if(!G.isPaused)G._socket.resume()}function qz(G){let H=this[Y1];if(H._socket[Y1]!==void 0)H._socket.removeListener("data",H7),process.nextTick(u6,H._socket),H.close(G[Rz]);if(!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function w6(){this[Y1].emitClose()}function Uz(G,H){this[Y1].emit("message",G,H)}function Lz(G){let H=this[Y1];if(H._autoPong)H.pong(G,!this._isServer,h6);H.emit("ping",G)}function Wz(G){this[Y1].emit("pong",G)}function u6(G){G.resume()}function Ez(G){let H=this[Y1];if(H.readyState===a0.CLOSED)return;if(H.readyState===a0.OPEN)H._readyState=a0.CLOSING,l6(H);if(this._socket.end(),!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function l6(G){G._closeTimer=setTimeout(G._socket.destroy.bind(G._socket),G._closeTimeout)}function p6(){let G=this[Y1];if(this.removeListener("close",p6),this.removeListener("data",H7),this.removeListener("end",k6),G._readyState=a0.CLOSING,!this._readableState.endEmitted&&!G._closeFrameReceived&&!G._receiver._writableState.errorEmitted&&this._readableState.length!==0){let H=this.read(this._readableState.length);G._receiver.write(H)}if(G._receiver.end(),this[Y1]=void 0,clearTimeout(G._closeTimer),G._receiver._writableState.finished||G._receiver._writableState.errorEmitted)G.emitClose();else G._receiver.on("error",w6),G._receiver.on("finish",w6)}function H7(G){if(!this[Y1]._receiver.write(G))this.pause()}function k6(){let G=this[Y1];G._readyState=a0.CLOSING,G._receiver.end(),this.end()}function b6(){let G=this[Y1];if(this.removeListener("error",b6),this.on("error",h6),G)G._readyState=a0.CLOSING,this.destroy()}});var r6=E1((YV,n6)=>{var jV=N7(),{Duplex:yz}=o5("stream");function d6(G){G.emit("close")}function Sz(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function c6(G){if(this.removeListener("error",c6),this.destroy(),this.listenerCount("error")===0)this.emit("error",G)}function vz(G,H){let R=!0,P=new yz({...H,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return G.on("message",function(M,p){let f=!p&&P._readableState.objectMode?M.toString():M;if(!P.push(f))G.pause()}),G.once("error",function(M){if(P.destroyed)return;R=!1,P.destroy(M)}),G.once("close",function(){if(P.destroyed)return;P.push(null)}),P._destroy=function(D,M){if(G.readyState===G.CLOSED){M(D),process.nextTick(d6,P);return}let p=!1;if(G.once("error",function(u){p=!0,M(u)}),G.once("close",function(){if(!p)M(D);process.nextTick(d6,P)}),R)G.terminate()},P._final=function(D){if(G.readyState===G.CONNECTING){G.once("open",function(){P._final(D)});return}if(G._socket===null)return;if(G._socket._writableState.finished){if(D(),P._readableState.endEmitted)P.destroy()}else G._socket.once("finish",function(){D()}),G.close()},P._read=function(){if(G.isPaused)G.resume()},P._write=function(D,M,p){if(G.readyState===G.CONNECTING){G.once("open",function(){P._write(D,M,p)});return}G.send(D,p)},P.on("end",Sz),P.on("error",c6),P}n6.exports=vz});var s6=E1((VV,a6)=>{var{tokenChars:wz}=B8();function gz(G){let H=new Set,R=-1,P=-1,D=0;for(D;D<G.length;D++){let p=G.charCodeAt(D);if(P===-1&&wz[p]===1){if(R===-1)R=D}else if(D!==0&&(p===32||p===9)){if(P===-1&&R!==-1)P=D}else if(p===44){if(R===-1)throw SyntaxError(`Unexpected character at index ${D}`);if(P===-1)P=D;let f=G.slice(R,P);if(H.has(f))throw SyntaxError(`The "${f}" subprotocol is duplicated`);H.add(f),R=P=-1}else throw SyntaxError(`Unexpected character at index ${D}`)}if(R===-1||P!==-1)throw SyntaxError("Unexpected end of input");let M=G.slice(R,D);if(H.has(M))throw SyntaxError(`The "${M}" subprotocol is duplicated`);return H.add(M),H}a6.exports={parse:gz}});var K$=E1((HV,J$)=>{var hz=o5("events"),R7=o5("http"),{Duplex:_V}=o5("stream"),{createHash:mz}=o5("crypto"),o6=iJ(),a4=N3(),fz=s6(),uz=N7(),{CLOSE_TIMEOUT:lz,GUID:pz,kWebSocket:kz}=Y4(),bz=/^[+/0-9A-Za-z]{22}==$/;class e6 extends hz{constructor(G,H){super();if(G={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lz,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uz,...G},G.port==null&&!G.server&&!G.noServer||G.port!=null&&(G.server||G.noServer)||G.server&&G.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(G.port!=null)this._server=R7.createServer((R,P)=>{let D=R7.STATUS_CODES[426];P.writeHead(426,{"Content-Length":D.length,"Content-Type":"text/plain"}),P.end(D)}),this._server.listen(G.port,G.host,G.backlog,H);else if(G.server)this._server=G.server;if(this._server){let R=this.emit.bind(this,"connection");this._removeListeners=iz(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(P,D,M)=>{this.handleUpgrade(P,D,M,R)}})}if(G.perMessageDeflate===!0)G.perMessageDeflate={};if(G.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=G,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(G){if(this._state===2){if(G)this.once("close",()=>{G(Error("The server is not running"))});process.nextTick(D3,this);return}if(G)this.once("close",G);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(D3,this);else this._shouldEmitClose=!0;else process.nextTick(D3,this)}else{let H=this._server;this._removeListeners(),this._removeListeners=this._server=null,H.close(()=>{D3(this)})}}shouldHandle(G){if(this.options.path){let H=G.url.indexOf("?");if((H!==-1?G.url.slice(0,H):G.url)!==this.options.path)return!1}return!0}handleUpgrade(G,H,R,P){H.on("error",t6);let D=G.headers["sec-websocket-key"],M=G.headers.upgrade,p=+G.headers["sec-websocket-version"];if(G.method!=="GET"){s4(this,G,H,405,"Invalid HTTP method");return}if(M===void 0||M.toLowerCase()!=="websocket"){s4(this,G,H,400,"Invalid Upgrade header");return}if(D===void 0||!bz.test(D)){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Key header");return}if(p!==13&&p!==8){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(G)){O3(H,400);return}let f=G.headers["sec-websocket-protocol"],u=new Set;if(f!==void 0)try{u=fz.parse(f)}catch(Z0){s4(this,G,H,400,"Invalid Sec-WebSocket-Protocol header");return}let V0=G.headers["sec-websocket-extensions"],R0={};if(this.options.perMessageDeflate&&V0!==void 0){let Z0=new a4(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=o6.parse(V0);if(U[a4.extensionName])Z0.accept(U[a4.extensionName]),R0[a4.extensionName]=Z0}catch(U){s4(this,G,H,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Z0={origin:G.headers[`${p===8?"sec-websocket-origin":"origin"}`],secure:!!(G.socket.authorized||G.socket.encrypted),req:G};if(this.options.verifyClient.length===2){this.options.verifyClient(Z0,(U,h,g,y)=>{if(!U)return O3(H,h||401,g,y);this.completeUpgrade(R0,D,u,G,H,R,P)});return}if(!this.options.verifyClient(Z0))return O3(H,401)}this.completeUpgrade(R0,D,u,G,H,R,P)}completeUpgrade(G,H,R,P,D,M,p){if(!D.readable||!D.writable)return D.destroy();if(D[kz])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return O3(D,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mz("sha1").update(H+pz).digest("base64")}`],V0=new this.options.WebSocket(null,void 0,this.options);if(R.size){let R0=this.options.handleProtocols?this.options.handleProtocols(R,P):R.values().next().value;if(R0)u.push(`Sec-WebSocket-Protocol: ${R0}`),V0._protocol=R0}if(G[a4.extensionName]){let R0=G[a4.extensionName].params,Z0=o6.format({[a4.extensionName]:[R0]});u.push(`Sec-WebSocket-Extensions: ${Z0}`),V0._extensions=G}if(this.emit("headers",u,P),D.write(u.concat(`\r
|
|
1
|
+
import{Rl as W8,Tl as E1,Wl as o5}from"./chunk-x17jyjan.js";var Y4=E1((sY,X6)=>{var J6=["nodebuffer","arraybuffer","fragments"],K6=typeof Blob<"u";if(K6)J6.push("blob");X6.exports={BINARY_TYPES:J6,CLOSE_TIMEOUT:30000,EMPTY_BUFFER:Buffer.alloc(0),GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",hasBlob:K6,kForOnEventAttribute:Symbol("kIsForOnEventAttribute"),kListener:Symbol("kListener"),kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),NOOP:()=>{}}});var _3=E1((oY,$7)=>{var{EMPTY_BUFFER:qI}=Y4(),gJ=Buffer[Symbol.species];function UI(G,H){if(G.length===0)return qI;if(G.length===1)return G[0];let R=Buffer.allocUnsafe(H),P=0;for(let D=0;D<G.length;D++){let M=G[D];R.set(M,P),P+=M.length}if(P<H)return new gJ(R.buffer,R.byteOffset,P);return R}function Z6(G,H,R,P,D){for(let M=0;M<D;M++)R[P+M]=G[M]^H[M&3]}function $6(G,H){for(let R=0;R<G.length;R++)G[R]^=H[R&3]}function LI(G){if(G.length===G.buffer.byteLength)return G.buffer;return G.buffer.slice(G.byteOffset,G.byteOffset+G.length)}function hJ(G){if(hJ.readOnly=!0,Buffer.isBuffer(G))return G;let H;if(G instanceof ArrayBuffer)H=new gJ(G);else if(ArrayBuffer.isView(G))H=new gJ(G.buffer,G.byteOffset,G.byteLength);else H=Buffer.from(G),hJ.readOnly=!1;return H}$7.exports={concat:UI,mask:Z6,toArrayBuffer:LI,toBuffer:hJ,unmask:$6};if(!process.env.WS_NO_BUFFER_UTIL)try{let G=(()=>{throw new Error("Cannot require module "+"bufferutil");})();$7.exports.mask=function(H,R,P,D,M){if(M<48)Z6(H,R,P,D,M);else G.mask(H,R,P,D,M)},$7.exports.unmask=function(H,R){if(H.length<32)$6(H,R);else G.unmask(H,R)}}catch(G){}});var z6=E1((tY,I6)=>{var Q6=Symbol("kDone"),mJ=Symbol("kRun");class G6{constructor(G){this[Q6]=()=>{this.pending--,this[mJ]()},this.concurrency=G||1/0,this.jobs=[],this.pending=0}add(G){this.jobs.push(G),this[mJ]()}[mJ](){if(this.pending===this.concurrency)return;if(this.jobs.length){let G=this.jobs.shift();this.pending++,G(this[Q6])}}}I6.exports=G6});var N3=E1((eY,H6)=>{var H3=o5("zlib"),j6=_3(),WI=z6(),{kStatusCode:Y6}=Y4(),EI=Buffer[Symbol.species],yI=Buffer.from([0,0,255,255]),G7=Symbol("permessage-deflate"),V4=Symbol("total-length"),T8=Symbol("callback"),U4=Symbol("buffers"),x8=Symbol("error"),Q7;class V6{constructor(G,H,R){if(this._maxPayload=R|0,this._options=G||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!H,this._deflate=null,this._inflate=null,this.params=null,!Q7){let P=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Q7=new WI(P)}}static get extensionName(){return"permessage-deflate"}offer(){let G={};if(this._options.serverNoContextTakeover)G.server_no_context_takeover=!0;if(this._options.clientNoContextTakeover)G.client_no_context_takeover=!0;if(this._options.serverMaxWindowBits)G.server_max_window_bits=this._options.serverMaxWindowBits;if(this._options.clientMaxWindowBits)G.client_max_window_bits=this._options.clientMaxWindowBits;else if(this._options.clientMaxWindowBits==null)G.client_max_window_bits=!0;return G}accept(G){return G=this.normalizeParams(G),this.params=this._isServer?this.acceptAsServer(G):this.acceptAsClient(G),this.params}cleanup(){if(this._inflate)this._inflate.close(),this._inflate=null;if(this._deflate){let G=this._deflate[T8];if(this._deflate.close(),this._deflate=null,G)G(Error("The deflate stream was closed while data was being processed"))}}acceptAsServer(G){let H=this._options,R=G.find((P)=>{if(H.serverNoContextTakeover===!1&&P.server_no_context_takeover||P.server_max_window_bits&&(H.serverMaxWindowBits===!1||typeof H.serverMaxWindowBits==="number"&&H.serverMaxWindowBits>P.server_max_window_bits)||typeof H.clientMaxWindowBits==="number"&&!P.client_max_window_bits)return!1;return!0});if(!R)throw Error("None of the extension offers can be accepted");if(H.serverNoContextTakeover)R.server_no_context_takeover=!0;if(H.clientNoContextTakeover)R.client_no_context_takeover=!0;if(typeof H.serverMaxWindowBits==="number")R.server_max_window_bits=H.serverMaxWindowBits;if(typeof H.clientMaxWindowBits==="number")R.client_max_window_bits=H.clientMaxWindowBits;else if(R.client_max_window_bits===!0||H.clientMaxWindowBits===!1)delete R.client_max_window_bits;return R}acceptAsClient(G){let H=G[0];if(this._options.clientNoContextTakeover===!1&&H.client_no_context_takeover)throw Error('Unexpected parameter "client_no_context_takeover"');if(!H.client_max_window_bits){if(typeof this._options.clientMaxWindowBits==="number")H.client_max_window_bits=this._options.clientMaxWindowBits}else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits==="number"&&H.client_max_window_bits>this._options.clientMaxWindowBits)throw Error('Unexpected or invalid parameter "client_max_window_bits"');return H}normalizeParams(G){return G.forEach((H)=>{Object.keys(H).forEach((R)=>{let P=H[R];if(P.length>1)throw Error(`Parameter "${R}" must have only a single value`);if(P=P[0],R==="client_max_window_bits"){if(P!==!0){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(!this._isServer)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else if(R==="server_max_window_bits"){let D=+P;if(!Number.isInteger(D)||D<8||D>15)throw TypeError(`Invalid value for parameter "${R}": ${P}`);P=D}else if(R==="client_no_context_takeover"||R==="server_no_context_takeover"){if(P!==!0)throw TypeError(`Invalid value for parameter "${R}": ${P}`)}else throw Error(`Unknown parameter "${R}"`);H[R]=P})}),G}decompress(G,H,R){Q7.add((P)=>{this._decompress(G,H,(D,M)=>{P(),R(D,M)})})}compress(G,H,R){Q7.add((P)=>{this._compress(G,H,(D,M)=>{P(),R(D,M)})})}_decompress(G,H,R){let P=this._isServer?"client":"server";if(!this._inflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._inflate=H3.createInflateRaw({...this._options.zlibInflateOptions,windowBits:M}),this._inflate[G7]=this,this._inflate[V4]=0,this._inflate[U4]=[],this._inflate.on("error",vI),this._inflate.on("data",_6)}if(this._inflate[T8]=R,this._inflate.write(G),H)this._inflate.write(yI);this._inflate.flush(()=>{let D=this._inflate[x8];if(D){this._inflate.close(),this._inflate=null,R(D);return}let M=j6.concat(this._inflate[U4],this._inflate[V4]);if(this._inflate._readableState.endEmitted)this._inflate.close(),this._inflate=null;else if(this._inflate[V4]=0,this._inflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._inflate.reset();R(null,M)})}_compress(G,H,R){let P=this._isServer?"server":"client";if(!this._deflate){let D=`${P}_max_window_bits`,M=typeof this.params[D]!=="number"?H3.Z_DEFAULT_WINDOWBITS:this.params[D];this._deflate=H3.createDeflateRaw({...this._options.zlibDeflateOptions,windowBits:M}),this._deflate[V4]=0,this._deflate[U4]=[],this._deflate.on("data",SI)}this._deflate[T8]=R,this._deflate.write(G),this._deflate.flush(H3.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let D=j6.concat(this._deflate[U4],this._deflate[V4]);if(H)D=new EI(D.buffer,D.byteOffset,D.length-4);if(this._deflate[T8]=null,this._deflate[V4]=0,this._deflate[U4]=[],H&&this.params[`${P}_no_context_takeover`])this._deflate.reset();R(null,D)})}}H6.exports=V6;function SI(G){this[U4].push(G),this[V4]+=G.length}function _6(G){if(this[V4]+=G.length,this[G7]._maxPayload<1||this[V4]<=this[G7]._maxPayload){this[U4].push(G);return}this[x8]=RangeError("Max payload size exceeded"),this[x8].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[x8][Y6]=1009,this.removeListener("data",_6),this.reset()}function vI(G){if(this[G7]._inflate=null,this[x8]){this[T8](this[x8]);return}G[Y6]=1007,this[T8](G)}});var B8=E1((JV,I7)=>{var{isUtf8:N6}=o5("buffer"),{hasBlob:wI}=Y4(),gI=[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 hI(G){return G>=1000&&G<=1014&&G!==1004&&G!==1005&&G!==1006||G>=3000&&G<=4999}function fJ(G){let H=G.length,R=0;while(R<H)if((G[R]&128)===0)R++;else if((G[R]&224)===192){if(R+1===H||(G[R+1]&192)!==128||(G[R]&254)===192)return!1;R+=2}else if((G[R]&240)===224){if(R+2>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||G[R]===224&&(G[R+1]&224)===128||G[R]===237&&(G[R+1]&224)===160)return!1;R+=3}else if((G[R]&248)===240){if(R+3>=H||(G[R+1]&192)!==128||(G[R+2]&192)!==128||(G[R+3]&192)!==128||G[R]===240&&(G[R+1]&240)===128||G[R]===244&&G[R+1]>143||G[R]>244)return!1;R+=4}else return!1;return!0}function mI(G){return wI&&typeof G==="object"&&typeof G.arrayBuffer==="function"&&typeof G.type==="string"&&typeof G.stream==="function"&&(G[Symbol.toStringTag]==="Blob"||G[Symbol.toStringTag]==="File")}I7.exports={isBlob:mI,isValidStatusCode:hI,isValidUTF8:fJ,tokenChars:gI};if(N6)I7.exports.isValidUTF8=function(G){return G.length<24?fJ(G):N6(G)};else if(!process.env.WS_NO_UTF_8_VALIDATE)try{let G=(()=>{throw new Error("Cannot require module "+"utf-8-validate");})();I7.exports.isValidUTF8=function(H){return H.length<32?fJ(H):G(H)}}catch(G){}});var lJ=E1((KV,O6)=>{var{Writable:fI}=o5("stream"),R6=N3(),{BINARY_TYPES:uI,EMPTY_BUFFER:A6,kStatusCode:lI,kWebSocket:pI}=Y4(),{concat:uJ,toArrayBuffer:kI,unmask:bI}=_3(),{isValidStatusCode:iI,isValidUTF8:F6}=B8(),z7=Buffer[Symbol.species];class D6 extends fI{constructor(G={}){super();this._allowSynchronousEvents=G.allowSynchronousEvents!==void 0?G.allowSynchronousEvents:!0,this._binaryType=G.binaryType||uI[0],this._extensions=G.extensions||{},this._isServer=!!G.isServer,this._maxPayload=G.maxPayload|0,this._skipUTF8Validation=!!G.skipUTF8Validation,this[pI]=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=0}_write(G,H,R){if(this._opcode===8&&this._state==0)return R();this._bufferedBytes+=G.length,this._buffers.push(G),this.startLoop(R)}consume(G){if(this._bufferedBytes-=G,G===this._buffers[0].length)return this._buffers.shift();if(G<this._buffers[0].length){let R=this._buffers[0];return this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G),new z7(R.buffer,R.byteOffset,G)}let H=Buffer.allocUnsafe(G);do{let R=this._buffers[0],P=H.length-G;if(G>=R.length)H.set(this._buffers.shift(),P);else H.set(new Uint8Array(R.buffer,R.byteOffset,G),P),this._buffers[0]=new z7(R.buffer,R.byteOffset+G,R.length-G);G-=R.length}while(G>0);return H}startLoop(G){this._loop=!0;do switch(this._state){case 0:this.getInfo(G);break;case 1:this.getPayloadLength16(G);break;case 2:this.getPayloadLength64(G);break;case 3:this.getMask();break;case 4:this.getData(G);break;case 5:case 6:this._loop=!1;return}while(this._loop);if(!this._errored)G()}getInfo(G){if(this._bufferedBytes<2){this._loop=!1;return}let H=this.consume(2);if((H[0]&48)!==0){let P=this.createError(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");G(P);return}let R=(H[0]&64)===64;if(R&&!this._extensions[R6.extensionName]){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._fin=(H[0]&128)===128,this._opcode=H[0]&15,this._payloadLength=H[1]&127,this._opcode===0){if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(!this._fragmented){let P=this.createError(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._opcode=this._fragmented}else if(this._opcode===1||this._opcode===2){if(this._fragmented){let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}this._compressed=R}else if(this._opcode>7&&this._opcode<11){if(!this._fin){let P=this.createError(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");G(P);return}if(R){let P=this.createError(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");G(P);return}if(this._payloadLength>125||this._opcode===8&&this._payloadLength===1){let P=this.createError(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");G(P);return}}else{let P=this.createError(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");G(P);return}if(!this._fin&&!this._fragmented)this._fragmented=this._opcode;if(this._masked=(H[1]&128)===128,this._isServer){if(!this._masked){let P=this.createError(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK");G(P);return}}else if(this._masked){let P=this.createError(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");G(P);return}if(this._payloadLength===126)this._state=1;else if(this._payloadLength===127)this._state=2;else this.haveLength(G)}getPayloadLength16(G){if(this._bufferedBytes<2){this._loop=!1;return}this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength(G)}getPayloadLength64(G){if(this._bufferedBytes<8){this._loop=!1;return}let H=this.consume(8),R=H.readUInt32BE(0);if(R>Math.pow(2,21)-1){let P=this.createError(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH");G(P);return}this._payloadLength=R*Math.pow(2,32)+H.readUInt32BE(4),this.haveLength(G)}haveLength(G){if(this._payloadLength&&this._opcode<8){if(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0){let H=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");G(H);return}}if(this._masked)this._state=3;else this._state=4}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=4}getData(G){let H=A6;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}if(H=this.consume(this._payloadLength),this._masked&&(this._mask[0]|this._mask[1]|this._mask[2]|this._mask[3])!==0)bI(H,this._mask)}if(this._opcode>7){this.controlMessage(H,G);return}if(this._compressed){this._state=5,this.decompress(H,G);return}if(H.length)this._messageLength=this._totalPayloadLength,this._fragments.push(H);this.dataMessage(G)}decompress(G,H){this._extensions[R6.extensionName].decompress(G,this._fin,(P,D)=>{if(P)return H(P);if(D.length){if(this._messageLength+=D.length,this._messageLength>this._maxPayload&&this._maxPayload>0){let M=this.createError(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");H(M);return}this._fragments.push(D)}if(this.dataMessage(H),this._state===0)this.startLoop(H)})}dataMessage(G){if(!this._fin){this._state=0;return}let H=this._messageLength,R=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let P;if(this._binaryType==="nodebuffer")P=uJ(R,H);else if(this._binaryType==="arraybuffer")P=kI(uJ(R,H));else if(this._binaryType==="blob")P=new Blob(R);else P=R;if(this._allowSynchronousEvents)this.emit("message",P,!0),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!0),this._state=0,this.startLoop(G)})}else{let P=uJ(R,H);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");G(D);return}if(this._state===5||this._allowSynchronousEvents)this.emit("message",P,!1),this._state=0;else this._state=6,setImmediate(()=>{this.emit("message",P,!1),this._state=0,this.startLoop(G)})}}controlMessage(G,H){if(this._opcode===8){if(G.length===0)this._loop=!1,this.emit("conclude",1005,A6),this.end();else{let R=G.readUInt16BE(0);if(!iI(R)){let D=this.createError(RangeError,`invalid status code ${R}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");H(D);return}let P=new z7(G.buffer,G.byteOffset+2,G.length-2);if(!this._skipUTF8Validation&&!F6(P)){let D=this.createError(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");H(D);return}this._loop=!1,this.emit("conclude",R,P),this.end()}this._state=0;return}if(this._allowSynchronousEvents)this.emit(this._opcode===9?"ping":"pong",G),this._state=0;else this._state=6,setImmediate(()=>{this.emit(this._opcode===9?"ping":"pong",G),this._state=0,this.startLoop(H)})}createError(G,H,R,P,D){this._loop=!1,this._errored=!0;let M=new G(R?`Invalid WebSocket frame: ${H}`:H);return Error.captureStackTrace(M,this.createError),M.code=D,M[lI]=P,M}}O6.exports=D6});var kJ=E1((ZV,T6)=>{var{Duplex:XV}=o5("stream"),{randomFillSync:dI}=o5("crypto"),M6=N3(),{EMPTY_BUFFER:cI,kWebSocket:nI,NOOP:rI}=Y4(),{isBlob:C8,isValidStatusCode:aI}=B8(),{mask:P6,toBuffer:n4}=_3(),k1=Symbol("kByteLength"),sI=Buffer.alloc(4),r4,q8=8192,c1=0,oI=1,tI=2;class L4{constructor(G,H,R){if(this._extensions=H||{},R)this._generateMask=R,this._maskBuffer=Buffer.alloc(4);this._socket=G,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._queue=[],this._state=c1,this.onerror=rI,this[nI]=void 0}static frame(G,H){let R,P=!1,D=2,M=!1;if(H.mask){if(R=H.maskBuffer||sI,H.generateMask)H.generateMask(R);else{if(q8===8192){if(r4===void 0)r4=Buffer.alloc(8192);dI(r4,0,8192),q8=0}R[0]=r4[q8++],R[1]=r4[q8++],R[2]=r4[q8++],R[3]=r4[q8++]}M=(R[0]|R[1]|R[2]|R[3])===0,D=6}let p;if(typeof G==="string")if((!H.mask||M)&&H[k1]!==void 0)p=H[k1];else G=Buffer.from(G),p=G.length;else p=G.length,P=H.mask&&H.readOnly&&!M;let f=p;if(p>=65536)D+=8,f=127;else if(p>125)D+=2,f=126;let u=Buffer.allocUnsafe(P?p+D:D);if(u[0]=H.fin?H.opcode|128:H.opcode,H.rsv1)u[0]|=64;if(u[1]=f,f===126)u.writeUInt16BE(p,2);else if(f===127)u[2]=u[3]=0,u.writeUIntBE(p,4,6);if(!H.mask)return[u,G];if(u[1]|=128,u[D-4]=R[0],u[D-3]=R[1],u[D-2]=R[2],u[D-1]=R[3],M)return[u,G];if(P)return P6(G,R,u,D,p),[u];return P6(G,R,G,0,p),[u,G]}close(G,H,R,P){let D;if(G===void 0)D=cI;else if(typeof G!=="number"||!aI(G))throw TypeError("First argument must be a valid error code number");else if(H===void 0||!H.length)D=Buffer.allocUnsafe(2),D.writeUInt16BE(G,0);else{let p=Buffer.byteLength(H);if(p>123)throw RangeError("The message must not be greater than 123 bytes");if(D=Buffer.allocUnsafe(2+p),D.writeUInt16BE(G,0),typeof H==="string")D.write(H,2);else D.set(H,2)}let M={[k1]:D.length,fin:!0,generateMask:this._generateMask,mask:R,maskBuffer:this._maskBuffer,opcode:8,readOnly:!1,rsv1:!1};if(this._state!==c1)this.enqueue([this.dispatch,D,!1,M,P]);else this.sendFrame(L4.frame(D,M),P)}ping(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:9,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}pong(G,H,R){let P,D;if(typeof G==="string")P=Buffer.byteLength(G),D=!1;else if(C8(G))P=G.size,D=!1;else G=n4(G),P=G.length,D=n4.readOnly;if(P>125)throw RangeError("The data size must not be greater than 125 bytes");let M={[k1]:P,fin:!0,generateMask:this._generateMask,mask:H,maskBuffer:this._maskBuffer,opcode:10,readOnly:D,rsv1:!1};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,!1,M,R]);else this.getBlobData(G,!1,M,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,!1,M,R]);else this.sendFrame(L4.frame(G,M),R)}send(G,H,R){let P=this._extensions[M6.extensionName],D=H.binary?2:1,M=H.compress,p,f;if(typeof G==="string")p=Buffer.byteLength(G),f=!1;else if(C8(G))p=G.size,f=!1;else G=n4(G),p=G.length,f=n4.readOnly;if(this._firstFragment){if(this._firstFragment=!1,M&&P&&P.params[P._isServer?"server_no_context_takeover":"client_no_context_takeover"])M=p>=P._threshold;this._compress=M}else M=!1,D=0;if(H.fin)this._firstFragment=!0;let u={[k1]:p,fin:H.fin,generateMask:this._generateMask,mask:H.mask,maskBuffer:this._maskBuffer,opcode:D,readOnly:f,rsv1:M};if(C8(G))if(this._state!==c1)this.enqueue([this.getBlobData,G,this._compress,u,R]);else this.getBlobData(G,this._compress,u,R);else if(this._state!==c1)this.enqueue([this.dispatch,G,this._compress,u,R]);else this.dispatch(G,this._compress,u,R)}getBlobData(G,H,R,P){this._bufferedBytes+=R[k1],this._state=tI,G.arrayBuffer().then((D)=>{if(this._socket.destroyed){let p=Error("The socket was closed while the blob was being read");process.nextTick(pJ,this,p,P);return}this._bufferedBytes-=R[k1];let M=n4(D);if(!H)this._state=c1,this.sendFrame(L4.frame(M,R),P),this.dequeue();else this.dispatch(M,H,R,P)}).catch((D)=>{process.nextTick(eI,this,D,P)})}dispatch(G,H,R,P){if(!H){this.sendFrame(L4.frame(G,R),P);return}let D=this._extensions[M6.extensionName];this._bufferedBytes+=R[k1],this._state=oI,D.compress(G,R.fin,(M,p)=>{if(this._socket.destroyed){let f=Error("The socket was closed while data was being compressed");pJ(this,f,P);return}this._bufferedBytes-=R[k1],this._state=c1,R.readOnly=!1,this.sendFrame(L4.frame(p,R),P),this.dequeue()})}dequeue(){while(this._state===c1&&this._queue.length){let G=this._queue.shift();this._bufferedBytes-=G[3][k1],Reflect.apply(G[0],this,G.slice(1))}}enqueue(G){this._bufferedBytes+=G[3][k1],this._queue.push(G)}sendFrame(G,H){if(G.length===2)this._socket.cork(),this._socket.write(G[0]),this._socket.write(G[1],H),this._socket.uncork();else this._socket.write(G[0],H)}}T6.exports=L4;function pJ(G,H,R){if(typeof R==="function")R(H);for(let P=0;P<G._queue.length;P++){let D=G._queue[P],M=D[D.length-1];if(typeof M==="function")M(H)}}function eI(G,H,R){pJ(G,H,R),G.onerror(H)}});var y6=E1(($V,E6)=>{var{kForOnEventAttribute:R3,kListener:bJ}=Y4(),x6=Symbol("kCode"),B6=Symbol("kData"),C6=Symbol("kError"),q6=Symbol("kMessage"),U6=Symbol("kReason"),U8=Symbol("kTarget"),L6=Symbol("kType"),W6=Symbol("kWasClean");class W4{constructor(G){this[U8]=null,this[L6]=G}get target(){return this[U8]}get type(){return this[L6]}}Object.defineProperty(W4.prototype,"target",{enumerable:!0});Object.defineProperty(W4.prototype,"type",{enumerable:!0});class L8 extends W4{constructor(G,H={}){super(G);this[x6]=H.code===void 0?0:H.code,this[U6]=H.reason===void 0?"":H.reason,this[W6]=H.wasClean===void 0?!1:H.wasClean}get code(){return this[x6]}get reason(){return this[U6]}get wasClean(){return this[W6]}}Object.defineProperty(L8.prototype,"code",{enumerable:!0});Object.defineProperty(L8.prototype,"reason",{enumerable:!0});Object.defineProperty(L8.prototype,"wasClean",{enumerable:!0});class A3 extends W4{constructor(G,H={}){super(G);this[C6]=H.error===void 0?null:H.error,this[q6]=H.message===void 0?"":H.message}get error(){return this[C6]}get message(){return this[q6]}}Object.defineProperty(A3.prototype,"error",{enumerable:!0});Object.defineProperty(A3.prototype,"message",{enumerable:!0});class Y7 extends W4{constructor(G,H={}){super(G);this[B6]=H.data===void 0?null:H.data}get data(){return this[B6]}}Object.defineProperty(Y7.prototype,"data",{enumerable:!0});var Jz={addEventListener(G,H,R={}){for(let D of this.listeners(G))if(!R[R3]&&D[bJ]===H&&!D[R3])return;let P;if(G==="message")P=function(M,p){let f=new Y7("message",{data:p?M:M.toString()});f[U8]=this,j7(H,this,f)};else if(G==="close")P=function(M,p){let f=new L8("close",{code:M,reason:p.toString(),wasClean:this._closeFrameReceived&&this._closeFrameSent});f[U8]=this,j7(H,this,f)};else if(G==="error")P=function(M){let p=new A3("error",{error:M,message:M.message});p[U8]=this,j7(H,this,p)};else if(G==="open")P=function(){let M=new W4("open");M[U8]=this,j7(H,this,M)};else return;if(P[R3]=!!R[R3],P[bJ]=H,R.once)this.once(G,P);else this.on(G,P)},removeEventListener(G,H){for(let R of this.listeners(G))if(R[bJ]===H&&!R[R3]){this.removeListener(G,R);break}}};E6.exports={CloseEvent:L8,ErrorEvent:A3,Event:W4,EventTarget:Jz,MessageEvent:Y7};function j7(G,H,R){if(typeof G==="object"&&G.handleEvent)G.handleEvent.call(G,R);else G.call(H,R)}});var iJ=E1((QV,S6)=>{var{tokenChars:F3}=B8();function X4(G,H,R){if(G[H]===void 0)G[H]=[R];else G[H].push(R)}function Kz(G){let H=Object.create(null),R=Object.create(null),P=!1,D=!1,M=!1,p,f,u=-1,V0=-1,R0=-1,Z0=0;for(;Z0<G.length;Z0++)if(V0=G.charCodeAt(Z0),p===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(Z0!==0&&(V0===32||V0===9)){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(V0===44)X4(H,h,R),R=Object.create(null);else p=h;u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(f===void 0)if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(V0===32||V0===9){if(R0===-1&&u!==-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;if(X4(R,G.slice(u,R0),!0),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;u=R0=-1}else if(V0===61&&u!==-1&&R0===-1)f=G.slice(u,Z0),u=R0=-1;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(D){if(F3[V0]!==1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1)u=Z0;else if(!P)P=!0;D=!1}else if(M)if(F3[V0]===1){if(u===-1)u=Z0}else if(V0===34&&u!==-1)M=!1,R0=Z0;else if(V0===92)D=!0;else throw SyntaxError(`Unexpected character at index ${Z0}`);else if(V0===34&&G.charCodeAt(Z0-1)===61)M=!0;else if(R0===-1&&F3[V0]===1){if(u===-1)u=Z0}else if(u!==-1&&(V0===32||V0===9)){if(R0===-1)R0=Z0}else if(V0===59||V0===44){if(u===-1)throw SyntaxError(`Unexpected character at index ${Z0}`);if(R0===-1)R0=Z0;let h=G.slice(u,R0);if(P)h=h.replace(/\\/g,""),P=!1;if(X4(R,f,h),V0===44)X4(H,p,R),R=Object.create(null),p=void 0;f=void 0,u=R0=-1}else throw SyntaxError(`Unexpected character at index ${Z0}`);if(u===-1||M||V0===32||V0===9)throw SyntaxError("Unexpected end of input");if(R0===-1)R0=Z0;let U=G.slice(u,R0);if(p===void 0)X4(H,U,R);else{if(f===void 0)X4(R,U,!0);else if(P)X4(R,f,U.replace(/\\/g,""));else X4(R,f,U);X4(H,p,R)}return H}function Xz(G){return Object.keys(G).map((H)=>{let R=G[H];if(!Array.isArray(R))R=[R];return R.map((P)=>{return[H].concat(Object.keys(P).map((D)=>{let M=P[D];if(!Array.isArray(M))M=[M];return M.map((p)=>p===!0?D:`${D}=${p}`).join("; ")})).join("; ")}).join(", ")}).join(", ")}S6.exports={format:Xz,parse:Kz}});var N7=E1((zV,i6)=>{var Zz=o5("events"),$z=o5("https"),Qz=o5("http"),g6=o5("net"),Gz=o5("tls"),{randomBytes:Iz,createHash:zz}=o5("crypto"),{Duplex:GV,Readable:IV}=o5("stream"),{URL:dJ}=o5("url"),E4=N3(),jz=lJ(),Yz=kJ(),{isBlob:Vz}=B8(),{BINARY_TYPES:v6,CLOSE_TIMEOUT:_z,EMPTY_BUFFER:V7,GUID:Hz,kForOnEventAttribute:cJ,kListener:Nz,kStatusCode:Rz,kWebSocket:Y1,NOOP:h6}=Y4(),{EventTarget:{addEventListener:Az,removeEventListener:Fz}}=y6(),{format:Dz,parse:Oz}=iJ(),{toBuffer:Mz}=_3(),m6=Symbol("kAborted"),nJ=[8,13],_4=["CONNECTING","OPEN","CLOSING","CLOSED"],Pz=/^[!#$%&'*+\-.0-9A-Z^_`|a-z~]+$/;class a0 extends Zz{constructor(G,H,R){super();if(this._binaryType=v6[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage=V7,this._closeTimer=null,this._errorEmitted=!1,this._extensions={},this._paused=!1,this._protocol="",this._readyState=a0.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,G!==null){if(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,H===void 0)H=[];else if(!Array.isArray(H))if(typeof H==="object"&&H!==null)R=H,H=[];else H=[H];f6(this,G,H,R)}else this._autoPong=R.autoPong,this._closeTimeout=R.closeTimeout,this._isServer=!0}get binaryType(){return this._binaryType}set binaryType(G){if(!v6.includes(G))return;if(this._binaryType=G,this._receiver)this._receiver._binaryType=G}get bufferedAmount(){if(!this._socket)return this._bufferedAmount;return this._socket._writableState.length+this._sender._bufferedBytes}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(G,H,R){let P=new jz({allowSynchronousEvents:R.allowSynchronousEvents,binaryType:this.binaryType,extensions:this._extensions,isServer:this._isServer,maxPayload:R.maxPayload,skipUTF8Validation:R.skipUTF8Validation}),D=new Yz(G,this._extensions,R.generateMask);if(this._receiver=P,this._sender=D,this._socket=G,P[Y1]=this,D[Y1]=this,G[Y1]=this,P.on("conclude",Bz),P.on("drain",Cz),P.on("error",qz),P.on("message",Uz),P.on("ping",Lz),P.on("pong",Wz),D.onerror=Ez,G.setTimeout)G.setTimeout(0);if(G.setNoDelay)G.setNoDelay();if(H.length>0)G.unshift(H);G.on("close",p6),G.on("data",H7),G.on("end",k6),G.on("error",b6),this._readyState=a0.OPEN,this.emit("open")}emitClose(){if(!this._socket){this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}if(this._extensions[E4.extensionName])this._extensions[E4.extensionName].cleanup();this._receiver.removeAllListeners(),this._readyState=a0.CLOSED,this.emit("close",this._closeCode,this._closeMessage)}close(G,H){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this.readyState===a0.CLOSING){if(this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted))this._socket.end();return}this._readyState=a0.CLOSING,this._sender.close(G,H,!this._isServer,(R)=>{if(R)return;if(this._closeFrameSent=!0,this._closeFrameReceived||this._receiver._writableState.errorEmitted)this._socket.end()}),l6(this)}pause(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;this._paused=!0,this._socket.pause()}ping(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.ping(G||V7,H,R)}pong(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof G==="function")R=G,G=H=void 0;else if(typeof H==="function")R=H,H=void 0;if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}if(H===void 0)H=!this._isServer;this._sender.pong(G||V7,H,R)}resume(){if(this.readyState===a0.CONNECTING||this.readyState===a0.CLOSED)return;if(this._paused=!1,!this._receiver._writableState.needDrain)this._socket.resume()}send(G,H,R){if(this.readyState===a0.CONNECTING)throw Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof H==="function")R=H,H={};if(typeof G==="number")G=G.toString();if(this.readyState!==a0.OPEN){rJ(this,G,R);return}let P={binary:typeof G!=="string",mask:!this._isServer,compress:!0,fin:!0,...H};if(!this._extensions[E4.extensionName])P.compress=!1;this._sender.send(G||V7,P,R)}terminate(){if(this.readyState===a0.CLOSED)return;if(this.readyState===a0.CONNECTING){v1(this,this._req,"WebSocket was closed before the connection was established");return}if(this._socket)this._readyState=a0.CLOSING,this._socket.destroy()}}Object.defineProperty(a0,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0.prototype,"CONNECTING",{enumerable:!0,value:_4.indexOf("CONNECTING")});Object.defineProperty(a0,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0.prototype,"OPEN",{enumerable:!0,value:_4.indexOf("OPEN")});Object.defineProperty(a0,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0.prototype,"CLOSING",{enumerable:!0,value:_4.indexOf("CLOSING")});Object.defineProperty(a0,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});Object.defineProperty(a0.prototype,"CLOSED",{enumerable:!0,value:_4.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","isPaused","protocol","readyState","url"].forEach((G)=>{Object.defineProperty(a0.prototype,G,{enumerable:!0})});["open","error","close","message"].forEach((G)=>{Object.defineProperty(a0.prototype,`on${G}`,{enumerable:!0,get(){for(let H of this.listeners(G))if(H[cJ])return H[Nz];return null},set(H){for(let R of this.listeners(G))if(R[cJ]){this.removeListener(G,R);break}if(typeof H!=="function")return;this.addEventListener(G,H,{[cJ]:!0})}})});a0.prototype.addEventListener=Az;a0.prototype.removeEventListener=Fz;i6.exports=a0;function f6(G,H,R,P){let D={allowSynchronousEvents:!0,autoPong:!0,closeTimeout:_z,protocolVersion:nJ[1],maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10,...P,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:"GET",host:void 0,path:void 0,port:void 0};if(G._autoPong=D.autoPong,G._closeTimeout=D.closeTimeout,!nJ.includes(D.protocolVersion))throw RangeError(`Unsupported protocol version: ${D.protocolVersion} (supported versions: ${nJ.join(", ")})`);let M;if(H instanceof dJ)M=H;else try{M=new dJ(H)}catch(y){throw SyntaxError(`Invalid URL: ${H}`)}if(M.protocol==="http:")M.protocol="ws:";else if(M.protocol==="https:")M.protocol="wss:";G._url=M.href;let p=M.protocol==="wss:",f=M.protocol==="ws+unix:",u;if(M.protocol!=="ws:"&&!p&&!f)u=`The URL's protocol must be one of "ws:", "wss:", "http:", "https:", or "ws+unix:"`;else if(f&&!M.pathname)u="The URL's pathname is empty";else if(M.hash)u="The URL contains a fragment identifier";if(u){let y=SyntaxError(u);if(G._redirects===0)throw y;else{_7(G,y);return}}let V0=p?443:80,R0=Iz(16).toString("base64"),Z0=p?$z.request:Qz.request,U=new Set,h;if(D.createConnection=D.createConnection||(p?xz:Tz),D.defaultPort=D.defaultPort||V0,D.port=M.port||V0,D.host=M.hostname.startsWith("[")?M.hostname.slice(1,-1):M.hostname,D.headers={...D.headers,"Sec-WebSocket-Version":D.protocolVersion,"Sec-WebSocket-Key":R0,Connection:"Upgrade",Upgrade:"websocket"},D.path=M.pathname+M.search,D.timeout=D.handshakeTimeout,D.perMessageDeflate)h=new E4(D.perMessageDeflate!==!0?D.perMessageDeflate:{},!1,D.maxPayload),D.headers["Sec-WebSocket-Extensions"]=Dz({[E4.extensionName]:h.offer()});if(R.length){for(let y of R){if(typeof y!=="string"||!Pz.test(y)||U.has(y))throw SyntaxError("An invalid or duplicated subprotocol was specified");U.add(y)}D.headers["Sec-WebSocket-Protocol"]=R.join(",")}if(D.origin)if(D.protocolVersion<13)D.headers["Sec-WebSocket-Origin"]=D.origin;else D.headers.Origin=D.origin;if(M.username||M.password)D.auth=`${M.username}:${M.password}`;if(f){let y=D.path.split(":");D.socketPath=y[0],D.path=y[1]}let g;if(D.followRedirects){if(G._redirects===0){G._originalIpc=f,G._originalSecure=p,G._originalHostOrSocketPath=f?D.socketPath:M.host;let y=P&&P.headers;if(P={...P,headers:{}},y)for(let[r,F0]of Object.entries(y))P.headers[r.toLowerCase()]=F0}else if(G.listenerCount("redirect")===0){let y=f?G._originalIpc?D.socketPath===G._originalHostOrSocketPath:!1:G._originalIpc?!1:M.host===G._originalHostOrSocketPath;if(!y||G._originalSecure&&!p){if(delete D.headers.authorization,delete D.headers.cookie,!y)delete D.headers.host;D.auth=void 0}}if(D.auth&&!P.headers.authorization)P.headers.authorization="Basic "+Buffer.from(D.auth).toString("base64");if(g=G._req=Z0(D),G._redirects)G.emit("redirect",G.url,g)}else g=G._req=Z0(D);if(D.timeout)g.on("timeout",()=>{v1(G,g,"Opening handshake has timed out")});if(g.on("error",(y)=>{if(g===null||g[m6])return;g=G._req=null,_7(G,y)}),g.on("response",(y)=>{let r=y.headers.location,F0=y.statusCode;if(r&&D.followRedirects&&F0>=300&&F0<400){if(++G._redirects>D.maxRedirects){v1(G,g,"Maximum redirects exceeded");return}g.abort();let v0;try{v0=new dJ(r,H)}catch($0){let A0=SyntaxError(`Invalid URL: ${r}`);_7(G,A0);return}f6(G,v0,R,P)}else if(!G.emit("unexpected-response",g,y))v1(G,g,`Unexpected server response: ${y.statusCode}`)}),g.on("upgrade",(y,r,F0)=>{if(G.emit("upgrade",y),G.readyState!==a0.CONNECTING)return;g=G._req=null;let v0=y.headers.upgrade;if(v0===void 0||v0.toLowerCase()!=="websocket"){v1(G,r,"Invalid Upgrade header");return}let $0=zz("sha1").update(R0+Hz).digest("base64");if(y.headers["sec-websocket-accept"]!==$0){v1(G,r,"Invalid Sec-WebSocket-Accept header");return}let A0=y.headers["sec-websocket-protocol"],Q0;if(A0!==void 0){if(!U.size)Q0="Server sent a subprotocol but none was requested";else if(!U.has(A0))Q0="Server sent an invalid subprotocol"}else if(U.size)Q0="Server sent no subprotocol";if(Q0){v1(G,r,Q0);return}if(A0)G._protocol=A0;let H0=y.headers["sec-websocket-extensions"];if(H0!==void 0){if(!h){v1(G,r,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let I0;try{I0=Oz(H0)}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}let L0=Object.keys(I0);if(L0.length!==1||L0[0]!==E4.extensionName){v1(G,r,"Server indicated an extension that was not requested");return}try{h.accept(I0[E4.extensionName])}catch(F5){v1(G,r,"Invalid Sec-WebSocket-Extensions header");return}G._extensions[E4.extensionName]=h}G.setSocket(r,F0,{allowSynchronousEvents:D.allowSynchronousEvents,generateMask:D.generateMask,maxPayload:D.maxPayload,skipUTF8Validation:D.skipUTF8Validation})}),D.finishRequest)D.finishRequest(g,G);else g.end()}function _7(G,H){G._readyState=a0.CLOSING,G._errorEmitted=!0,G.emit("error",H),G.emitClose()}function Tz(G){return G.path=G.socketPath,g6.connect(G)}function xz(G){if(G.path=void 0,!G.servername&&G.servername!=="")G.servername=g6.isIP(G.host)?"":G.host;return Gz.connect(G)}function v1(G,H,R){G._readyState=a0.CLOSING;let P=Error(R);if(Error.captureStackTrace(P,v1),H.setHeader){if(H[m6]=!0,H.abort(),H.socket&&!H.socket.destroyed)H.socket.destroy();process.nextTick(_7,G,P)}else H.destroy(P),H.once("error",G.emit.bind(G,"error")),H.once("close",G.emitClose.bind(G))}function rJ(G,H,R){if(H){let P=Vz(H)?H.size:Mz(H).length;if(G._socket)G._sender._bufferedBytes+=P;else G._bufferedAmount+=P}if(R){let P=Error(`WebSocket is not open: readyState ${G.readyState} (${_4[G.readyState]})`);process.nextTick(R,P)}}function Bz(G,H){let R=this[Y1];if(R._closeFrameReceived=!0,R._closeMessage=H,R._closeCode=G,R._socket[Y1]===void 0)return;if(R._socket.removeListener("data",H7),process.nextTick(u6,R._socket),G===1005)R.close();else R.close(G,H)}function Cz(){let G=this[Y1];if(!G.isPaused)G._socket.resume()}function qz(G){let H=this[Y1];if(H._socket[Y1]!==void 0)H._socket.removeListener("data",H7),process.nextTick(u6,H._socket),H.close(G[Rz]);if(!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function w6(){this[Y1].emitClose()}function Uz(G,H){this[Y1].emit("message",G,H)}function Lz(G){let H=this[Y1];if(H._autoPong)H.pong(G,!this._isServer,h6);H.emit("ping",G)}function Wz(G){this[Y1].emit("pong",G)}function u6(G){G.resume()}function Ez(G){let H=this[Y1];if(H.readyState===a0.CLOSED)return;if(H.readyState===a0.OPEN)H._readyState=a0.CLOSING,l6(H);if(this._socket.end(),!H._errorEmitted)H._errorEmitted=!0,H.emit("error",G)}function l6(G){G._closeTimer=setTimeout(G._socket.destroy.bind(G._socket),G._closeTimeout)}function p6(){let G=this[Y1];if(this.removeListener("close",p6),this.removeListener("data",H7),this.removeListener("end",k6),G._readyState=a0.CLOSING,!this._readableState.endEmitted&&!G._closeFrameReceived&&!G._receiver._writableState.errorEmitted&&this._readableState.length!==0){let H=this.read(this._readableState.length);G._receiver.write(H)}if(G._receiver.end(),this[Y1]=void 0,clearTimeout(G._closeTimer),G._receiver._writableState.finished||G._receiver._writableState.errorEmitted)G.emitClose();else G._receiver.on("error",w6),G._receiver.on("finish",w6)}function H7(G){if(!this[Y1]._receiver.write(G))this.pause()}function k6(){let G=this[Y1];G._readyState=a0.CLOSING,G._receiver.end(),this.end()}function b6(){let G=this[Y1];if(this.removeListener("error",b6),this.on("error",h6),G)G._readyState=a0.CLOSING,this.destroy()}});var r6=E1((YV,n6)=>{var jV=N7(),{Duplex:yz}=o5("stream");function d6(G){G.emit("close")}function Sz(){if(!this.destroyed&&this._writableState.finished)this.destroy()}function c6(G){if(this.removeListener("error",c6),this.destroy(),this.listenerCount("error")===0)this.emit("error",G)}function vz(G,H){let R=!0,P=new yz({...H,autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1});return G.on("message",function(M,p){let f=!p&&P._readableState.objectMode?M.toString():M;if(!P.push(f))G.pause()}),G.once("error",function(M){if(P.destroyed)return;R=!1,P.destroy(M)}),G.once("close",function(){if(P.destroyed)return;P.push(null)}),P._destroy=function(D,M){if(G.readyState===G.CLOSED){M(D),process.nextTick(d6,P);return}let p=!1;if(G.once("error",function(u){p=!0,M(u)}),G.once("close",function(){if(!p)M(D);process.nextTick(d6,P)}),R)G.terminate()},P._final=function(D){if(G.readyState===G.CONNECTING){G.once("open",function(){P._final(D)});return}if(G._socket===null)return;if(G._socket._writableState.finished){if(D(),P._readableState.endEmitted)P.destroy()}else G._socket.once("finish",function(){D()}),G.close()},P._read=function(){if(G.isPaused)G.resume()},P._write=function(D,M,p){if(G.readyState===G.CONNECTING){G.once("open",function(){P._write(D,M,p)});return}G.send(D,p)},P.on("end",Sz),P.on("error",c6),P}n6.exports=vz});var s6=E1((VV,a6)=>{var{tokenChars:wz}=B8();function gz(G){let H=new Set,R=-1,P=-1,D=0;for(D;D<G.length;D++){let p=G.charCodeAt(D);if(P===-1&&wz[p]===1){if(R===-1)R=D}else if(D!==0&&(p===32||p===9)){if(P===-1&&R!==-1)P=D}else if(p===44){if(R===-1)throw SyntaxError(`Unexpected character at index ${D}`);if(P===-1)P=D;let f=G.slice(R,P);if(H.has(f))throw SyntaxError(`The "${f}" subprotocol is duplicated`);H.add(f),R=P=-1}else throw SyntaxError(`Unexpected character at index ${D}`)}if(R===-1||P!==-1)throw SyntaxError("Unexpected end of input");let M=G.slice(R,D);if(H.has(M))throw SyntaxError(`The "${M}" subprotocol is duplicated`);return H.add(M),H}a6.exports={parse:gz}});var K$=E1((HV,J$)=>{var hz=o5("events"),R7=o5("http"),{Duplex:_V}=o5("stream"),{createHash:mz}=o5("crypto"),o6=iJ(),a4=N3(),fz=s6(),uz=N7(),{CLOSE_TIMEOUT:lz,GUID:pz,kWebSocket:kz}=Y4(),bz=/^[+/0-9A-Za-z]{22}==$/;class e6 extends hz{constructor(G,H){super();if(G={allowSynchronousEvents:!0,autoPong:!0,maxPayload:104857600,skipUTF8Validation:!1,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,closeTimeout:lz,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null,WebSocket:uz,...G},G.port==null&&!G.server&&!G.noServer||G.port!=null&&(G.server||G.noServer)||G.server&&G.noServer)throw TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(G.port!=null)this._server=R7.createServer((R,P)=>{let D=R7.STATUS_CODES[426];P.writeHead(426,{"Content-Length":D.length,"Content-Type":"text/plain"}),P.end(D)}),this._server.listen(G.port,G.host,G.backlog,H);else if(G.server)this._server=G.server;if(this._server){let R=this.emit.bind(this,"connection");this._removeListeners=iz(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(P,D,M)=>{this.handleUpgrade(P,D,M,R)}})}if(G.perMessageDeflate===!0)G.perMessageDeflate={};if(G.clientTracking)this.clients=new Set,this._shouldEmitClose=!1;this.options=G,this._state=0}address(){if(this.options.noServer)throw Error('The server is operating in "noServer" mode');if(!this._server)return null;return this._server.address()}close(G){if(this._state===2){if(G)this.once("close",()=>{G(Error("The server is not running"))});process.nextTick(D3,this);return}if(G)this.once("close",G);if(this._state===1)return;if(this._state=1,this.options.noServer||this.options.server){if(this._server)this._removeListeners(),this._removeListeners=this._server=null;if(this.clients)if(!this.clients.size)process.nextTick(D3,this);else this._shouldEmitClose=!0;else process.nextTick(D3,this)}else{let H=this._server;this._removeListeners(),this._removeListeners=this._server=null,H.close(()=>{D3(this)})}}shouldHandle(G){if(this.options.path){let H=G.url.indexOf("?");if((H!==-1?G.url.slice(0,H):G.url)!==this.options.path)return!1}return!0}handleUpgrade(G,H,R,P){H.on("error",t6);let D=G.headers["sec-websocket-key"],M=G.headers.upgrade,p=+G.headers["sec-websocket-version"];if(G.method!=="GET"){s4(this,G,H,405,"Invalid HTTP method");return}if(M===void 0||M.toLowerCase()!=="websocket"){s4(this,G,H,400,"Invalid Upgrade header");return}if(D===void 0||!bz.test(D)){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Key header");return}if(p!==13&&p!==8){s4(this,G,H,400,"Missing or invalid Sec-WebSocket-Version header",{"Sec-WebSocket-Version":"13, 8"});return}if(!this.shouldHandle(G)){O3(H,400);return}let f=G.headers["sec-websocket-protocol"],u=new Set;if(f!==void 0)try{u=fz.parse(f)}catch(Z0){s4(this,G,H,400,"Invalid Sec-WebSocket-Protocol header");return}let V0=G.headers["sec-websocket-extensions"],R0={};if(this.options.perMessageDeflate&&V0!==void 0){let Z0=new a4(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let U=o6.parse(V0);if(U[a4.extensionName])Z0.accept(U[a4.extensionName]),R0[a4.extensionName]=Z0}catch(U){s4(this,G,H,400,"Invalid or unacceptable Sec-WebSocket-Extensions header");return}}if(this.options.verifyClient){let Z0={origin:G.headers[`${p===8?"sec-websocket-origin":"origin"}`],secure:!!(G.socket.authorized||G.socket.encrypted),req:G};if(this.options.verifyClient.length===2){this.options.verifyClient(Z0,(U,h,g,y)=>{if(!U)return O3(H,h||401,g,y);this.completeUpgrade(R0,D,u,G,H,R,P)});return}if(!this.options.verifyClient(Z0))return O3(H,401)}this.completeUpgrade(R0,D,u,G,H,R,P)}completeUpgrade(G,H,R,P,D,M,p){if(!D.readable||!D.writable)return D.destroy();if(D[kz])throw Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>0)return O3(D,503);let u=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${mz("sha1").update(H+pz).digest("base64")}`],V0=new this.options.WebSocket(null,void 0,this.options);if(R.size){let R0=this.options.handleProtocols?this.options.handleProtocols(R,P):R.values().next().value;if(R0)u.push(`Sec-WebSocket-Protocol: ${R0}`),V0._protocol=R0}if(G[a4.extensionName]){let R0=G[a4.extensionName].params,Z0=o6.format({[a4.extensionName]:[R0]});u.push(`Sec-WebSocket-Extensions: ${Z0}`),V0._extensions=G}if(this.emit("headers",u,P),D.write(u.concat(`\r
|
|
2
2
|
`).join(`\r
|
|
3
3
|
`)),D.removeListener("error",t6),V0.setSocket(D,M,{allowSynchronousEvents:this.options.allowSynchronousEvents,maxPayload:this.options.maxPayload,skipUTF8Validation:this.options.skipUTF8Validation}),this.clients)this.clients.add(V0),V0.on("close",()=>{if(this.clients.delete(V0),this._shouldEmitClose&&!this.clients.size)process.nextTick(D3,this)});p(V0,P)}}J$.exports=e6;function iz(G,H){for(let R of Object.keys(H))G.on(R,H[R]);return function(){for(let P of Object.keys(H))G.removeListener(P,H[P])}}function D3(G){G._state=2,G.emit("close")}function t6(){this.destroy()}function O3(G,H,R,P){R=R||R7.STATUS_CODES[H],P={Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(R),...P},G.once("finish",G.destroy),G.end(`HTTP/1.1 ${H} ${R7.STATUS_CODES[H]}\r
|
|
4
4
|
`+Object.keys(P).map((D)=>`${D}: ${P[D]}`).join(`\r
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{Qf as u,Rf as p}from"./chunk-mqm8wnc8.js";import{Ag as n,Cg as o,Dg as d,Eg as r,sg as l,ug as S,xg as i,zg as s}from"./chunk-ncaqgas1.js";import{Mg as g}from"./chunk-0p3df51n.js";import{Dj as h,Wh as c}from"./chunk-9kbktaf8.js";import{Dl as N,Fl as WY}from"./chunk-xtr6s7kh.js";import{Wl as L}from"./chunk-x17jyjan.js";WY();var PY=(Y)=>{let Z=Y.goto!=null&&!Array.isArray(Y.goto)?[Y.goto]:Y.goto;return new p({goto:Z?.map(($)=>{if(typeof $!=="string")return new u($.node,$.input);return $}),update:Y.update??void 0,resume:Y.resume})},I="[...]",QY="[Circular]",G=[],x=[];function zY(){return{depthLimit:Number.MAX_SAFE_INTEGER,edgesLimit:Number.MAX_SAFE_INTEGER}}function OY(Y,Z,$,J){if(typeof J>"u")J=zY();f(Y,"",0,[],void 0,0,J);var H;try{if(x.length===0)H=JSON.stringify(Y,Z,$);else H=JSON.stringify(Y,KY(Z),$)}catch(U){return JSON.stringify("[unable to serialize, circular reference is too complex to analyze]")}finally{while(G.length!==0){var X=G.pop();if(X.length===4)Object.defineProperty(X[0],X[1],X[3]);else X[0][X[1]]=X[2]}}return H}function w(Y,Z,$,J){var H=Object.getOwnPropertyDescriptor(J,$);if(H.get!==void 0)if(H.configurable)Object.defineProperty(J,$,{value:Y}),G.push([J,$,Z,H]);else x.push([Z,$,Y]);else J[$]=Y,G.push([J,$,Z])}function f(Y,Z,$,J,H,X,U){X+=1;var W;if(typeof Y==="object"&&Y!==null){for(W=0;W<J.length;W++)if(J[W]===Y){w(QY,Y,Z,H);return}if(typeof U.depthLimit<"u"&&X>U.depthLimit){w(I,Y,Z,H);return}if(typeof U.edgesLimit<"u"&&$+1>U.edgesLimit){w(I,Y,Z,H);return}if(J.push(Y),Array.isArray(Y))for(W=0;W<Y.length;W++)f(Y[W],W,W,J,Y,X,U);else{var P=Object.keys(Y);for(W=0;W<P.length;W++){var z=P[W];f(Y[z],z,W,J,Y,X,U)}}J.pop()}}function KY(Y){return Y=typeof Y<"u"?Y:function(Z,$){return $},function(Z,$){if(x.length>0)for(var J=0;J<x.length;J++){var H=x[J];if(H[1]===Z&&H[0]===$){$=H[2],x.splice(J,1);break}}return Y.call(this,Z,$)}}function VY(Y){return Y!==null&&Y.lc===1&&Y.type==="constructor"&&Array.isArray(Y.id)}async function q(Y){if(Y&&typeof Y==="object")if(Array.isArray(Y))return await Promise.all(Y.map(($)=>q($)));else{let Z={};for(let[$,J]of Object.entries(Y))Z[$]=await q(J);if(Z.lc===2&&Z.type==="undefined")return;else if(Z.lc===2&&Z.type==="constructor"&&Array.isArray(Z.id))try{let $=Z.id[Z.id.length-1],J;switch($){case"Set":J=Set;break;case"Map":J=Map;break;case"RegExp":J=RegExp;break;case"Error":J=Error;break;default:return Z}if(Z.method)return J[Z.method](...Z.args||[]);else return new J(...Z.args||[])}catch($){return Z}else if(VY(Z))return i(JSON.stringify(Z));return Z}return Y}function M(Y,Z,$,J){return{lc:2,type:"constructor",id:[Y.name],method:Z??null,args:$??[],kwargs:J??{}}}function FY(Y){if(Y===void 0)return{lc:2,type:"undefined"};else if(Y instanceof Set||Y instanceof Map)return M(Y.constructor,void 0,[Array.from(Y)]);else if(Y instanceof RegExp)return M(RegExp,void 0,[Y.source,Y.flags]);else if(Y instanceof Error)return M(Y.constructor,void 0,[Y.message]);else if(Y?.lg_name==="Send")return{node:Y.node,args:Y.args};else return Y}class t{_dumps(Y){return new TextEncoder().encode(OY(Y,($,J)=>{return FY(J)}))}async dumpsTyped(Y){if(Y instanceof Uint8Array)return["bytes",Y];else return["json",this._dumps(Y)]}async _loads(Y){let Z=JSON.parse(Y);return q(Z)}async loadsTyped(Y,Z){if(Y==="bytes")return typeof Z==="string"?new TextEncoder().encode(Z):Z;else if(Y==="json")return this._loads(typeof Z==="string"?Z:new TextDecoder().decode(Z));else throw Error(`Unknown serialization type: ${Y}`)}}class a extends g.default{constructor(Y,Z=!0,$=300){super();this.id=Y,this.compressMessages=Z,this.ttl=$}serializer=new t;async encodeData(Y){let[Z,$]=await this.serializer.dumpsTyped(Y);return $}async decodeData(Y){return await this.serializer.loadsTyped("json",Y)}}class e{queues=new Map;defaultCompressMessages;queueConstructor;constructor(Y,Z={}){this.defaultCompressMessages=Z.defaultCompressMessages??!0,this.queueConstructor=Y}createQueue(Y,Z=300){return this.queues.set(Y,new this.queueConstructor(Y,this.defaultCompressMessages,Z)),this.queues.get(Y)}async getQueue(Y){let Z=this.queues.get(Y);if(!Z)if(await this.queueConstructor?.isQueueExist?.(Y))return this.createQueue(Y);else throw Error(`Queue with id '${Y}' does not exist`);return Z}async cancelQueue(Y){await this.removeQueue(Y)}async pushToQueue(Y,Z){await(await this.getQueue(Y)).push(Z)}async getQueueData(Y){let Z=this.queues.get(Y);if(!Z)throw Error(`Queue with id '${Y}' does not exist`);return await Z.getAll()}async clearQueue(Y){let Z=this.queues.get(Y);if(Z){let $=Z.clear();if($ instanceof Promise)await $}}async removeQueue(Y){let Z=this.queues.get(Y);if(!Z)return!1;try{await Z.cancel()}catch($){console.error("Error cancelling queue:",$)}try{let $=Z.clear();if($ instanceof Promise)await $}catch($){console.error("Error clearing queue:",$)}if(typeof Z.destroy==="function")try{await Z.destroy()}catch($){console.error("Error destroying queue:",$)}return this.queues.delete(Y)}getAllQueueIds(){return Array.from(this.queues.keys())}async getAllQueuesData(){let Y={};for(let[Z,$]of this.queues)Y[Z]=await $.getAll();return Y}clearAllQueues(){for(let Y of this.queues.values())Y.clear()}async copyQueue(Y,Z,$){let H=await(await this.getQueue(Y)).copyToQueue(Z,$);return this.queues.set(Z,H),H}}var E={};async function wY(Y,Z){E[Y]=Z}async function YY(Y,Z,$){if(!E[Y])throw Error(`Graph "${Y}" not found`);let J=typeof E[Y]==="function"?await E[Y](Z??{configurable:{}}):E[Y];if(typeof $?.checkpointer<"u")J.checkpointer=$?.checkpointer??D.globalCheckPointer;else J.checkpointer=D.globalCheckPointer;return J.store=$?.store??void 0,J}class b{db;adapter;constructor(Y){this.db=Y.db,this.adapter=Y}async setup(){await this.adapter.createTables(this.db),await this.adapter.createIndexes(this.db)}async create(Y){let Z=Y?.threadId||N(),$=new Date,J=Y?.metadata||{},H={};if(Y?.ifExists==="raise"){if(await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",Z).executeTakeFirst())throw Error(`Thread with ID ${Z} already exists.`)}if(Y?.ifExists==="do_nothing"&&Y?.threadId){let X=await this.db.selectFrom("threads").selectAll().where("thread_id","=",Z).executeTakeFirst();if(X)return{thread_id:X.thread_id,created_at:this.adapter.dbToDate(X.created_at).toISOString(),updated_at:this.adapter.dbToDate(X.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(X.updated_at).toISOString(),metadata:this.adapter.dbToJson(X.metadata),status:X.status,values:X.values?this.adapter.dbToJson(X.values):null,interrupts:this.adapter.dbToJson(X.interrupts),title:X.title}}return await this.db.insertInto("threads").values({thread_id:Z,created_at:this.adapter.dateToDb($),updated_at:this.adapter.dateToDb($),metadata:this.adapter.jsonToDb(J),status:"idle",values:null,interrupts:this.adapter.jsonToDb(H)}).execute(),{thread_id:Z,created_at:$.toISOString(),updated_at:$.toISOString(),state_updated_at:$.toISOString(),metadata:J,status:"idle",values:null,interrupts:H,title:null}}async search(Y){let Z=this.db.selectFrom("threads"),$;if(Y?.select)$=new Set(Y.select);else if(Y?.withoutDetails)$=new Set(["thread_id","created_at","updated_at","metadata","status","title"]);else $=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);let J=[];if($.has("thread_id"))J.push("thread_id");if($.has("created_at"))J.push("created_at");if($.has("updated_at"))J.push("updated_at");if($.has("metadata"))J.push("metadata");if($.has("status"))J.push("status");if($.has("values"))J.push("values");if($.has("interrupts"))J.push("interrupts");if($.has("title"))J.push("title");if(J.length>0)Z=Z.select(J);else Z=Z.selectAll();if(Y?.ids&&Y.ids.length>0)Z=Z.where("thread_id","in",Y.ids);if(Y?.status)Z=Z.where("status","=",Y.status);if(Y?.metadata)for(let[X,U]of Object.entries(Y.metadata))Z=Z.where(this.adapter.buildJsonQuery(this.db,"metadata",X,U));if(Y?.values)Z=Z.where((X)=>{return X("values","=",this.adapter.jsonToDb(Y.values))});if(Y?.sortBy){let X=Y.sortOrder==="desc"?"desc":"asc";Z=Z.orderBy(Y.sortBy,X)}if(Y?.limit!==void 0){if(Z=Z.limit(Y.limit),Y?.offset!==void 0)Z=Z.offset(Y.offset)}return(await Z.execute()).map((X)=>{let U={thread_id:X.thread_id};if($.has("created_at"))U.created_at=this.adapter.dbToDate(X.created_at).toISOString();if($.has("updated_at"))U.updated_at=this.adapter.dbToDate(X.updated_at).toISOString();if($.has("metadata"))U.metadata=this.adapter.dbToJson(X.metadata);if($.has("status"))U.status=X.status;if($.has("values"))U.values=X.values?this.adapter.dbToJson(X.values):null;if($.has("interrupts"))U.interrupts=this.adapter.dbToJson(X.interrupts);if($.has("title"))U.title=X.title;return U})}async get(Y){let Z=await this.db.selectFrom("threads").selectAll().where("thread_id","=",Y).executeTakeFirst();if(!Z)throw Error(`Thread with ID ${Y} not found.`);return{thread_id:Z.thread_id,created_at:this.adapter.dbToDate(Z.created_at).toISOString(),updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),state_updated_at:this.adapter.dbToDate(Z.updated_at).toISOString(),metadata:this.adapter.dbToJson(Z.metadata),status:Z.status,values:Z.values?this.adapter.dbToJson(Z.values):null,interrupts:this.adapter.dbToJson(Z.interrupts),title:Z.title}}async set(Y,Z){if(!await this.db.selectFrom("threads").select("thread_id").where("thread_id","=",Y).executeTakeFirst())throw Error(`Thread with ID ${Y} not found.`);let J={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0)J.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.status!==void 0)J.status=Z.status;if(Z.values!==void 0)J.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)J.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)J.title=Z.title;await this.db.updateTable("threads").set(J).where("thread_id","=",Y).execute()}async delete(Y){if((await this.db.deleteFrom("threads").where("thread_id","=",Y).executeTakeFirst()).numDeletedRows===0n)throw Error(`Thread with ID ${Y} not found.`)}async updateState(Y,Z){let $=await this.get(Y);if($.status==="busy")throw Error(`Thread with ID ${Y} is busy, can't update state.`);let J=$.metadata?.graph_id;if(!J)return await this.set(Y,{values:Z.values??null}),{configurable:{thread_id:Y}};let H={configurable:{thread_id:Y,graph_id:J}},X=await YY(J,H),U=await X.updateState(H,Z.values),W=await X.getState(H);return await this.set(Y,{values:JSON.parse(C(W.values))}),U}async createRun(Y,Z,$){let J=N(),H=new Date,X=$?.metadata??{};return await this.db.insertInto("runs").values({run_id:J,thread_id:Y,assistant_id:Z,created_at:this.adapter.dateToDb(H),updated_at:this.adapter.dateToDb(H),status:"pending",metadata:this.adapter.jsonToDb(X),multitask_strategy:"reject"}).execute(),{run_id:J,thread_id:Y,assistant_id:Z,created_at:H.toISOString(),updated_at:H.toISOString(),status:"pending",metadata:X,multitask_strategy:"reject"}}async listRuns(Y,Z){let $=this.db.selectFrom("runs").selectAll().where("thread_id","=",Y).orderBy("created_at","desc");if(Z?.status)$=$.where("status","=",Z.status);if(Z?.limit!==void 0){if($=$.limit(Z.limit),Z?.offset!==void 0)$=$.offset(Z.offset)}return(await $.execute()).map((H)=>({run_id:H.run_id,thread_id:H.thread_id,assistant_id:H.assistant_id,created_at:this.adapter.dbToDate(H.created_at).toISOString(),updated_at:this.adapter.dbToDate(H.updated_at).toISOString(),status:H.status,metadata:this.adapter.dbToJson(H.metadata),multitask_strategy:H.multitask_strategy}))}async updateRun(Y,Z){if(!await this.db.selectFrom("runs").select("run_id").where("run_id","=",Y).executeTakeFirst())throw Error(`Run with ID ${Y} not found.`);let J={updated_at:this.adapter.dateToDb(new Date)};if(Z.status!==void 0)J.status=Z.status;if(Z.metadata!==void 0)J.metadata=this.adapter.jsonToDb(Z.metadata);if(Z.multitask_strategy!==void 0)J.multitask_strategy=Z.multitask_strategy;await this.db.updateTable("runs").set(J).where("run_id","=",Y).execute()}async count(Y){return(await this.search(Y)).length}async patch(Y,Z){let $=await this.db.selectFrom("threads").selectAll().where("thread_id","=",Y).executeTakeFirst();if(!$)throw Error(`Thread with ID ${Y} not found.`);let J={updated_at:this.adapter.dateToDb(new Date)};if(Z.metadata!==void 0){let H=this.adapter.dbToJson($.metadata)||{};J.metadata=this.adapter.jsonToDb({...H,...Z.metadata})}if(Z.status!==void 0)J.status=Z.status;if(Z.values!==void 0)J.values=Z.values?this.adapter.jsonToDb(Z.values):null;if(Z.interrupts!==void 0)J.interrupts=this.adapter.jsonToDb(Z.interrupts);if(Z.title!==void 0)J.title=Z.title;return await this.db.updateTable("threads").set(J).where("thread_id","=",Y).execute(),await this.get(Y)}async getState(Y,Z){let $=await this.get(Y);if(Z?.checkpointId){let H=await this.db.selectFrom("checkpoints").selectAll().where("checkpoint_id","=",Z.checkpointId).where("thread_id","=",Y).executeTakeFirst();if(!H)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${Y}`);return{values:this.adapter.dbToJson(H.values),next:this.adapter.dbToJson(H.next),metadata:this.adapter.dbToJson(H.metadata),checkpoint:{id:H.checkpoint_id,thread_id:Y,parent_checkpoint_id:null,checkpoint_ns:"",metadata:this.adapter.dbToJson(H.metadata),created_at:this.adapter.dbToDate(H.created_at).toISOString()},created_at:this.adapter.dbToDate(H.created_at).toISOString(),parent_checkpoint:null,tasks:[]}}return{values:$.values||{},next:[],metadata:$.metadata,checkpoint:null,created_at:$.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory(Y,Z){let J=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",Y).orderBy("created_at","asc").execute(),H=J.map((X)=>({values:this.adapter.dbToJson(X.values),next:this.adapter.dbToJson(X.next),metadata:this.adapter.dbToJson(X.metadata),checkpoint:{thread_id:Y,checkpoint_ns:"",checkpoint_id:X.checkpoint_id,checkpoint_map:null},created_at:this.adapter.dbToDate(X.created_at).toISOString(),parent_checkpoint:null,tasks:[]}));if(Z?.before){let X=J.findIndex((U)=>U.checkpoint_id===Z.before);if(X!==-1)H=H.slice(X+1)}if(Z?.limit)H=H.slice(0,Z.limit);return H}async copy(Y){let Z=await this.get(Y),$=N(),J=new Date;await this.db.insertInto("threads").values({thread_id:$,created_at:this.adapter.dateToDb(J),updated_at:this.adapter.dateToDb(J),metadata:this.adapter.jsonToDb(Z.metadata),status:Z.status,values:Z.values?this.adapter.jsonToDb(Z.values):null,interrupts:this.adapter.jsonToDb(Z.interrupts),title:Z.title}).execute();let H=await this.db.selectFrom("checkpoints").selectAll().where("thread_id","=",Y).orderBy("created_at","asc").execute();for(let X of H)await this.db.insertInto("checkpoints").values({checkpoint_id:N(),thread_id:$,values:X.values,next:X.next,config:X.config,created_at:X.created_at,metadata:X.metadata}).execute();return{...Z,thread_id:$,created_at:J.toISOString(),updated_at:J.toISOString()}}async saveCheckpoint(Y,Z,$,J,H){await this.db.insertInto("checkpoints").values({checkpoint_id:N(),thread_id:Y,values:this.adapter.jsonToDb(Z),next:this.adapter.jsonToDb($),config:this.adapter.jsonToDb(J),created_at:this.adapter.dateToDb(new Date),metadata:this.adapter.jsonToDb(H||{})}).execute()}async setTitleIfNull(Y,Z){return(await this.db.updateTable("threads").set({title:Z,updated_at:this.adapter.dateToDb(new Date)}).where("thread_id","=",Y).where("title","is",null).executeTakeFirst()).numUpdatedRows>0n}}function DY(Y){let[Z,$]=Y.split("::");return{threadId:Z,checkpointNs:$??""}}function T(Y,Z,$){return`${Y}::${Z}::${$}`}function m(Y){if(Y===null||typeof Y!=="object")return JSON.stringify(Y);if(Array.isArray(Y))return JSON.stringify(Y.map((J)=>m(J)));let Z={},$=Object.keys(Y).sort();for(let J of $)Z[J]=Y[J];return JSON.stringify(Z,(J,H)=>{if(H!==null&&typeof H==="object"&&!Array.isArray(H)){let X={},U=Object.keys(H).sort();for(let W of U)X[W]=H[W];return X}return H})}class ZY extends n{storage={};writes={};constructor(Y){super(Y)}async get(Y){return(await this.getTuple(Y))?.checkpoint}async _migratePendingSends(Y,Z,$,J){let H=Y,X=T(Z,$,J),U=await Promise.all(Object.values(this.writes[X]??{}).filter(([W,P])=>P===S).map(async([W,P,z])=>await this.serde.loadsTyped("json",z)));H.channel_values??={},H.channel_values[S]=U,H.channel_versions??={},H.channel_versions[S]=Object.keys(H.channel_versions).length>0?o(...Object.values(H.channel_versions)):this.getNextVersion(void 0)}async _loadPendingWrites(Y,Z,$){let J=T(Y,Z,$),H=this.writes[J]??{};if(Object.keys(H).length===0)return[];return await Promise.all(Object.values(H).map(async([X,U,W])=>{return[X,U,await this.serde.loadsTyped("json",W)]}))}_cleanupOldWrites(Y,Z,$){let J=T(Y,Z,$);delete this.writes[J]}_checkMetadataFilterMatch(Y,Z){for(let[$,J]of Object.entries(Z)){let H=Y?.[$];if(J===null){if(!($ in(Y||{}))||H!==null)return!1}else if(typeof J==="object"&&!Array.isArray(J)){if(typeof H!=="object"||H===null)return!1;if(m(J)!==m(H))return!1}else if(H!==J)return!1}return!0}async getTuple(Y){let Z=Y.configurable?.thread_id,$=Y.configurable?.checkpoint_ns??"",J=r(Y);if(Z===void 0)return;let H=this.storage[Z]?.[$];if(H===void 0)return;let{checkpoint:X,metadata:U,checkpoint_id:W,parent_checkpoint_id:P}=H;if(J&&W!==J)return;let z=await this.serde.loadsTyped("json",X);if(z.v<4&&P!==void 0)await this._migratePendingSends(z,Z,$,P);let Q=await this._loadPendingWrites(Z,$,W),K=await this.serde.loadsTyped("json",U),F={config:{configurable:{thread_id:Z,checkpoint_ns:$,checkpoint_id:W}},checkpoint:z,metadata:K,pendingWrites:Q};if(P!==void 0)F.parentConfig={configurable:{thread_id:Z,checkpoint_ns:$,checkpoint_id:P}};return F}async*list(Y,Z){let{before:$,limit:J,filter:H}=Z??{},X=Y.configurable?.thread_id?[Y.configurable.thread_id]:Object.keys(this.storage),U=Y.configurable?.checkpoint_ns,W=Y.configurable?.checkpoint_id,P=[];for(let Q of X){let K=this.storage[Q];if(K===void 0)continue;for(let F of Object.keys(K)){if(U!==void 0&&F!==U)continue;let A=K[F];if(A===void 0)continue;let{checkpoint_id:V}=A;if(W&&V!==W)continue;if($?.configurable?.checkpoint_id&&V>=$.configurable.checkpoint_id)continue;let B=await this.serde.loadsTyped("json",A.metadata);if(H&&!this._checkMetadataFilterMatch(B,H))continue;P.push({threadId:Q,checkpointNs:F,namespaceData:A})}}P.sort((Q,K)=>K.namespaceData.checkpoint_ts-Q.namespaceData.checkpoint_ts);let z=0;for(let{threadId:Q,checkpointNs:K,namespaceData:F}of P){if(J!==void 0&&z>=J)return;let{checkpoint:A,metadata:V,checkpoint_id:B,parent_checkpoint_id:_}=F,O=await this.serde.loadsTyped("json",A);if(O.v<4&&_!==void 0)await this._migratePendingSends(O,Q,K,_);let j=await this._loadPendingWrites(Q,K,B),UY=await this.serde.loadsTyped("json",V),y={config:{configurable:{thread_id:Q,checkpoint_ns:K,checkpoint_id:B}},checkpoint:O,metadata:UY,pendingWrites:j};if(_!==void 0)y.parentConfig={configurable:{thread_id:Q,checkpoint_ns:K,checkpoint_id:_}};z++,yield y}}async put(Y,Z,$,J){let H=s(Z),X=Y.configurable?.thread_id,U=Y.configurable?.checkpoint_ns??"",W=Y.configurable?.checkpoint_id;if(X===void 0)throw Error("thread_id is required");let P=Z.id||l(0);if(!this.storage[X])this.storage[X]={};let z=this.storage[X][U];if(z!==void 0&&z.checkpoint_id!==P)this._cleanupOldWrites(X,U,z.checkpoint_id);let[[,Q],[,K]]=await Promise.all([this.serde.dumpsTyped(H),this.serde.dumpsTyped($)]);return this.storage[X][U]={checkpoint:Q,metadata:K,checkpoint_id:P,parent_checkpoint_id:W,checkpoint_ts:Date.now()},{configurable:{thread_id:X,checkpoint_ns:U,checkpoint_id:P}}}async putWrites(Y,Z,$){let J=Y.configurable?.thread_id,H=Y.configurable?.checkpoint_ns??"",X=Y.configurable?.checkpoint_id;if(!J||!X)throw Error("thread_id and checkpoint_id are required");let U=T(J,H,X),W=this.writes[U];if(this.writes[U]===void 0)this.writes[U]={};await Promise.all(Z.map(async([P,z],Q)=>{let[,K]=await this.serde.dumpsTyped(z),F=[$,d[P]||Q],A=`${F[0]},${F[1]}`;if(F[1]>=0&&W&&A in W)return;this.writes[U][A]=[$,P,K]}))}async deleteThread(Y){delete this.storage[Y];for(let Z of Object.keys(this.writes)){let{threadId:$}=DY(Z.split("::").slice(0,2).join("::"));if($===Y)delete this.writes[Z]}}}class R{event;data;id;constructor(Y,Z){this.event=Y,this.data=Z}}class $Y extends R{constructor(){super("__system_cancel__","user cancel this run")}}class JY extends R{constructor(){super("__stream_end__","stream end")}}class v extends R{constructor(Y){super("__stream_error__",{error:Y.name,message:Y.message})}}class k extends a{data=[];activeGenerators=new Set;isDestroyed=!1;async push(Y){if(this.isDestroyed)return;let Z=this.compressMessages?await this.encodeData(Y):Y;process.env.LG_TEMP_MESSAGE!=="true"&&this.data.push(Z),this.emit("dataChange",Z)}onDataChange(Y){if(this.isDestroyed)return()=>{};return this.on("dataChange",async(Z)=>{if(this.isDestroyed)return;Y(this.compressMessages?await this.decodeData(Z):Z)}),()=>this.off("dataChange",Y)}async*onDataReceive(){if(this.isDestroyed)return;let Y=new AbortController;this.activeGenerators.add(Y);let Z=[],$=null,J=!1,H=!1,X=null,U=async(z)=>{if(H||Y.signal.aborted)return;try{let Q=this.compressMessages?await this.decodeData(z):z;if(Z.push(Q),Q.event==="__stream_end__"||Q.event==="__stream_error__"||Q.event==="__stream_cancel__"){if(X)clearTimeout(X),X=null;if(X=setTimeout(()=>{if(J=!0,$)$(),$=null},300),Q.event==="__stream_cancel__")Y.abort("stream cancelled")}if($)$(),$=null}catch(Q){if(console.error("Error in handleData:",Q),$)$(),$=null}};this.on("dataChange",U);let W=()=>{if(J=!0,$)$(),$=null};Y.signal.addEventListener("abort",W);let P=()=>{if(H)return;if(H=!0,X)clearTimeout(X),X=null;try{this.off("dataChange",U)}catch(z){}try{Y.signal.removeEventListener("abort",W)}catch(z){}if($)$(),$=null;Z.length=0,this.activeGenerators.delete(Y)};try{if(Y.signal.aborted||this.isDestroyed)return;while(!J&&!Y.signal.aborted&&!this.isDestroyed)if(Z.length>0){for(let z of Z)yield z;Z.length=0}else await new Promise((z)=>{$=z})}finally{P()}}async getAll(){if(this.isDestroyed)return[];return this.compressMessages?await Promise.all(this.data.map((Y)=>this.decodeData(Y))):[...this.data]}clear(){this.data.length=0}cancelSignal=new AbortController;async cancel(){for(let Y of this.activeGenerators)try{Y.abort("user cancel this run")}catch(Z){}if(this.activeGenerators.clear(),!this.cancelSignal.signal.aborted)this.cancelSignal.abort("user cancel this run");if(!this.isDestroyed)await this.push(new $Y)}async copyToQueue(Y,Z){let $=this.data.slice(),J=new k(Y,this.compressMessages,Z??this.ttl);return J.data=$,J}async destroy(){if(this.isDestroyed)return;this.isDestroyed=!0,await this.cancel(),this.clear(),this.removeAllListeners(),this.activeGenerators.clear()}}class XY{threads=[];checkpoints=new Map;async setup(){return}async create(Y){let Z=Y?.threadId||N();if(Y?.ifExists==="raise"&&this.threads.some((J)=>J.thread_id===Z))throw Error(`Thread with ID ${Z} already exists.`);let $={thread_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),state_updated_at:new Date().toISOString(),metadata:Y?.metadata||{},status:"idle",values:null,interrupts:{},title:null};return this.checkpoints.set(Z,[]),this.threads.push($),$}async search(Y){let Z=[...this.threads];if(Y?.ids&&Y.ids.length>0)Z=Z.filter((X)=>Y.ids.includes(X.thread_id));if(Y?.status)Z=Z.filter((X)=>X.status===Y.status);if(Y?.metadata){for(let X in Y.metadata)if(Object.prototype.hasOwnProperty.call(Y.metadata,X))Z=Z.filter((U)=>U.metadata&&U.metadata[X]===Y.metadata?.[X])}if(Y?.values)Z=Z.filter((X)=>{if(!X.values)return!1;return this.deepEqual(X.values,Y.values)});if(Y?.sortBy)Z.sort((X,U)=>{let W,P;switch(Y.sortBy){case"thread_id":W=X.thread_id,P=U.thread_id;break;case"created_at":W=new Date(X.created_at).getTime(),P=new Date(U.created_at).getTime();break;case"updated_at":W=new Date(X.updated_at).getTime(),P=new Date(U.updated_at).getTime();break;case"status":W=X.status,P=U.status;break;default:return 0}if(Y.sortOrder==="desc")return P>W?1:P<W?-1:0;else return W>P?1:W<P?-1:0});let $=Y?.offset||0,J=Y?.limit||Z.length;return Z.slice($,$+J).map((X)=>{let U={thread_id:X.thread_id},W;if(Y?.select)W=new Set(Y.select);else if(Y?.withoutDetails)W=new Set(["thread_id","created_at","updated_at","metadata","status"]);else W=new Set(["thread_id","created_at","updated_at","metadata","status","values","interrupts","title"]);if(W.has("thread_id"))U.thread_id=X.thread_id;if(W.has("created_at"))U.created_at=X.created_at;if(W.has("updated_at"))U.updated_at=X.updated_at;if(W.has("metadata"))U.metadata=X.metadata;if(W.has("status"))U.status=X.status;if(W.has("values"))U.values=X.values;if(W.has("interrupts"))U.interrupts=X.interrupts;if(W.has("title"))U.title=X.title;return U})}deepEqual(Y,Z){if(Y===Z)return!0;if(typeof Y!==typeof Z)return!1;if(typeof Y!=="object"||Y===null||Z===null)return!1;let $=Object.keys(Y),J=Object.keys(Z);if($.length!==J.length)return!1;for(let H of $){if(!J.includes(H))return!1;if(!this.deepEqual(Y[H],Z[H]))return!1}return!0}async get(Y){let Z=this.threads.find(($)=>$.thread_id===Y);if(!Z)throw Error(`Thread with ID ${Y} not found.`);return Z}async set(Y,Z){let $=this.threads.findIndex((J)=>J.thread_id===Y);if($===-1)throw Error(`Thread with ID ${Y} not found.`);this.threads[$]={...this.threads[$],...Z}}async delete(Y){let Z=this.threads.length;if(this.threads=this.threads.filter(($)=>$.thread_id!==Y),this.checkpoints.delete(Y),this.threads.length===Z)throw Error(`Thread with ID ${Y} not found.`)}async updateState(Y,Z){let $=this.threads.findIndex((H)=>H.thread_id===Y);if($===-1)throw Error(`Thread with ID ${Y} not found.`);let J=this.threads[$];if(J.status==="busy")throw Error(`Thread with ID ${Y} is busy, can't update state.`);if(this.threads[$]={...J,values:Z.values,updated_at:new Date().toISOString()},J.metadata?.graph_id){let H=J.metadata?.graph_id,X={configurable:{thread_id:Y,graph_id:H}};try{let U=await YY(H,X),W=await U.updateState(X,Z.values),P=await U.getState(X);return await this.set(Y,{values:JSON.parse(C(P.values))}),W}catch(U){console.warn("Failed to update graph state:",U)}}return{configurable:{thread_id:Y}}}runs=[];async createRun(Y,Z,$){let H={run_id:N(),thread_id:Y,assistant_id:Z,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),status:"pending",metadata:$?.metadata??{},multitask_strategy:"reject"};return this.runs.push(H),H}async listRuns(Y,Z){let $=[...this.runs];if(Z?.status)$=$.filter((J)=>J.status===Z.status);if(Z?.limit)$=$.slice(Z.offset||0,(Z.offset||0)+Z.limit);return $}async updateRun(Y,Z){let $=this.runs.findIndex((J)=>J.run_id===Y);if($===-1)throw Error(`Run with ID ${Y} not found.`);this.runs[$]={...this.runs[$],...Z}}async count(Y){return(await this.search(Y)).length}async patch(Y,Z){let $=this.threads.findIndex((H)=>H.thread_id===Y);if($===-1)throw Error(`Thread with ID ${Y} not found.`);let J={...this.threads[$],...Z,updated_at:new Date().toISOString(),metadata:Z.metadata?{...this.threads[$].metadata,...Z.metadata}:this.threads[$].metadata};return this.threads[$]=J,J}async getState(Y,Z){let $=await this.get(Y);if(Z?.checkpointId){let X=(this.checkpoints.get(Y)||[]).find((U)=>U.checkpoint_id===Z.checkpointId);if(!X)throw Error(`Checkpoint with ID ${Z.checkpointId} not found for thread ${Y}`);return{values:X.values,next:X.next,metadata:X.metadata,checkpoint:{id:X.checkpoint_id,thread_id:Y,parent_checkpoint_id:null,checkpoint_ns:"",metadata:X.metadata,created_at:X.created_at},created_at:X.created_at,parent_checkpoint:null,tasks:[]}}return{values:$.values||{},next:[],metadata:$.metadata,checkpoint:null,created_at:$.created_at,parent_checkpoint:null,tasks:[]}}async getStateHistory(Y,Z){let $=this.checkpoints.get(Y)||[],J=$.map((H)=>({values:H.values,next:H.next,metadata:H.metadata,checkpoint:{checkpoint_id:H.checkpoint_id,thread_id:Y,checkpoint_ns:"",checkpoint_map:void 0},created_at:H.created_at,parent_checkpoint:null,tasks:[]}));if(Z?.before){let H=$.findIndex((X)=>X.checkpoint_id===Z.before);if(H!==-1)J=J.slice(H+1)}if(Z?.limit)J=J.slice(0,Z.limit);return J}async copy(Y){let Z=await this.get(Y),$=N(),J={...Z,thread_id:$,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};this.threads.push(J);let X=(this.checkpoints.get(Y)||[]).map((U)=>({...U,checkpoint_id:N(),thread_id:$}));return this.checkpoints.set($,X),J}async saveCheckpoint(Y,Z,$,J,H){let X=this.checkpoints.get(Y)||[],U={checkpoint_id:N(),thread_id:Y,values:Z,next:$,config:J,created_at:new Date().toISOString(),metadata:H};X.push(U),this.checkpoints.set(Y,X)}async setTitleIfNull(Y,Z){let $=this.threads.findIndex((J)=>J.thread_id===Y);if($===-1)throw Error(`Thread with ID ${Y} not found.`);if(this.threads[$].title===null)return this.threads[$]={...this.threads[$],title:Z,updated_at:new Date().toISOString()},!0;return!1}}var AY=async()=>{if(process.env.REDIS_URL&&(process.env.CHECKPOINT_TYPE==="redis"||process.env.CHECKPOINT_TYPE==="shallow/redis")){if(process.env.CHECKPOINT_TYPE==="redis"){console.debug("LG | Using redis as checkpoint");let{RedisSaver:Y}=await import("./chunk-96b00ygr.js");return await Y.fromUrl(process.env.REDIS_URL,{defaultTTL:60,refreshOnRead:!0})}if(process.env.CHECKPOINT_TYPE==="shallow/redis"){console.debug("LG | Using shallow redis as checkpoint");let{ShallowRedisSaver:Y}=await import("./chunk-3nhw50tg.js");return await Y.fromUrl(process.env.REDIS_URL)}}if(process.env.DATABASE_URL&&HY(process.env.DATABASE_URL)==="postgres"){console.debug("LG | Using postgres as checkpoint");let{createPGCheckpoint:Y}=await import("./chunk-be8n8w26.js");return Y()}if(process.env.SQLITE_DATABASE_URI){if(process.env.CHECKPOINT_TYPE==="sqlite"){console.debug("LG | Using sqlite (full) as checkpoint");let{SqliteSaver:$}=await import("./chunk-avqzptcg.js");return await $.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}console.debug("LG | Using shallow sqlite as checkpoint (default)");let{SqliteShallowSaver:Y}=await import("./chunk-j2qd9mfs.js");return await Y.fromConnStringAsync(process.env.SQLITE_DATABASE_URI)}return console.log("LG | You are using memory as checkpoint!"),console.log("\x1B[33m%s\x1B[0m","LG | set SQLITE_DATABASE_URI=./.langgraph_api/langgraph.db to your .env file to use \x1B[1mSQLite\x1B[0m for dev!"),console.log("\x1B[33m%s\x1B[0m","LG | set DATABASE_URL=postgresql://user:pass@localhost:5432/db to your .env file to use \x1B[1mPostgreSQL\x1B[0m for prod!"),new ZY},BY=async()=>{let Y;if(process.env.REDIS_URL){console.debug("LG | Using redis as stream queue");let{RedisStreamQueue:Z}=await import("./chunk-4260bzp9.js");Y=Z}else Y=k;return new e(Y)};function HY(Y){let Z=Y.toLowerCase();if(Z.startsWith("http://")||Z.startsWith("https://"))return"remote";return"postgres"}var NY=async(Y)=>{if(process.env.DATABASE_URL){if(HY(process.env.DATABASE_URL)==="remote"){console.debug("LG | Using Remote PostgreSQL ThreadsManager");let{RemoteKyselyThreadsManager:$}=await import("./chunk-vttq7sqg.js"),J=new $(process.env.DATABASE_URL);if(process.env.DATABASE_INIT==="true")await J.setup();return J}else if(Y.checkpointer){console.debug("LG | Using PostgreSQL ThreadsManager");let{PostgresAdapter:$}=await import("./chunk-142wmdx8.js"),J=Y.checkpointer.pool,H=new b(new $(J));if(process.env.DATABASE_INIT==="true")await H.setup();return H}}if(process.env.SQLITE_DATABASE_URI&&Y.checkpointer){console.debug("LG | Using SQLite ThreadsManager");let{SQLiteAdapter:Z}=await import("./chunk-eze2fzrq.js"),$=Y.checkpointer.db,J=new b(new Z($));return await J.setup(),J}return new XY};function RY(Y){if(typeof Y==="string")return Y;if(Array.isArray(Y))return Y.find(($)=>$.type==="text")?.text||"";if(Y?.text)return Y.text;return""}var LY=(Y,Z)=>{let $=Y?.messages;if(!$||!Array.isArray($)||$.length===0)return null;let J=$[0];if(!J)return null;let H=RY(J.content);if(!H)return null;let X=H.trim().replace(/\n/g," ");if(!X)return null;let U=15,W=X.slice(0,U);return W.length<X.length?`${W}...`:W};class D{static globalMessageQueue=null;static globalCheckPointer=null;static globalThreadsManager=null;static isInitialized=null;static _titleGenerator=LY;static setTitleGenerator(Y){D._titleGenerator=Y}static getTitleGenerator(){return D._titleGenerator}static async initGlobal(){if(D.isInitialized)return D.isInitialized;return D.isInitialized=(async()=>{let[Y,Z]=await Promise.all([BY(),AY()]);console.debug("LG | checkpointer created");let $=await NY({checkpointer:Z});console.debug("LG | threads manager created"),console.debug("LG | global init done"),D.globalMessageQueue=Y,D.globalCheckPointer=Z,D.globalThreadsManager=$})(),D.isInitialized}}async function _Y(Y,Z,$,J,H){let U=J.config?.configurable?.graph_id;if(!U||typeof U!=="string")throw Error("Invalid or missing graph_id");let W=await H.getGraph(U,J.config,{checkpointer:J.temporary?null:void 0}),P=Array.isArray(J.streamMode)?J.streamMode:J.streamMode?[J.streamMode]:[],z=new Set(["values",...P.filter((V)=>V!=="events"&&V!=="messages-tuple")]);if(P.includes("messages-tuple"))z.add("messages");if(P.includes("messages"))z.add("values");await $.push(new R("metadata",{run_id:Z.run_id,attempt:H.attempt,graph_id:U}));let Q={...J.config?.metadata,run_attempt:H.attempt},K=null,F=null,A=null;try{K=new Set,F=new Map,A=await W.stream(J.command!=null?PY(J.command):J.input??null,{interruptAfter:J.interruptAfter,interruptBefore:J.interruptBefore,tags:J.config?.tags,configurable:J.config?.configurable,recursionLimit:J.config?.recursionLimit,subgraphs:J.streamSubgraphs,metadata:Q,runId:Z.run_id,streamMode:[...z],signal:$.cancelSignal.signal});for await(let V of A){let B=[];if(V.length===3)B=V.splice(0,1);let _=(O)=>{if(B.length===0)return O;if(B.length===1&&B[0]?.length===0)return O;return`${O}|${B.join("|")}`};if(V[0]==="values"){let O=V[1];if(_("values")==="values")if(await $.push(new R(_("values"),O)),O?.__interrupt__)await Y.set(Z.thread_id,{status:"interrupted",interrupts:O?JSON.parse(C(O)):""});else await Y.set(Z.thread_id,{values:O?JSON.parse(C(O)):""})}else if(V[0]==="messages"){let O=V[1][0],j=V[1][1];if(O.id&&!K.has(O.id))await $.push(new R("messages/metadata",{[O.id]:j})),K.add(O.id);if(c.isInstance(O)&&O.id){if(F.set(O.id,[...F.get(O.id)??[],O]),await $.push(new R("messages/partial",[F.get(O.id).reduce(h)])),O.content===""&&!O.tool_calls?.length)F.delete(O.id)}else await $.push(new R("messages/partial",[O]))}else if(V[0]==="updates"){let O=V[1];await $.push(new R(_("updates"),O))}}}catch(V){if(!(V instanceof Error&&V.message?.includes("cancel"))){console.error("streamStateWithQueue error:",V);try{await $.push(new v(V))}catch(B){}}throw V}finally{try{await $.push(new JY)}catch(V){}if(K)K.clear(),K=null;if(F)F.clear(),F=null;A=null}}var C=(Y,Z=0)=>{return JSON.stringify(Y,function($,J){let H=this[$];if(H!=null&&typeof H==="object"&&"toDict"in H&&typeof H.toDict==="function"){let{type:X,data:U}=H.toDict();return{...U,type:X}}return J},Z)};async function*MY(Y,Z,$,J){Z=await Z;let{run_id:H,thread_id:X}=Z,U=null,W=null,P=null,z=!1;try{await Y.set(X,{status:"busy"}),await Y.updateRun(Z.run_id,{status:"running"}),W=D.globalMessageQueue.createQueue(H),U=W.onDataReceive(),P=_Y(Y,Z,W,$,J).catch((Q)=>{if(z)return;if(Q.message!=="user cancel this run")console.error("Queue task error:",Q);D.globalMessageQueue.pushToQueue(H,new v(Q))});for await(let Q of U)yield Q;await Y.updateRun(Z.run_id,{status:"success"})}catch(Q){console.error("Stream error:",Q),await Y.updateRun(Z.run_id,{status:"error"}),await Y.set(X,{status:"error"})}finally{if(z=!0,U){try{await U.return(void 0)}catch(K){}U=null}if(W&&!W.cancelSignal.signal.aborted)try{W.cancelSignal.abort("Stream consumer disconnected")}catch(K){}if(P){try{await Promise.race([P,new Promise((K)=>setTimeout(K,1000))])}catch(K){}P=null}if((await Y.get(X)).status==="interrupted")await D.globalMessageQueue.copyQueue(H,X,30000);else await Y.set(X,{status:"idle",interrupts:{}});await D.globalMessageQueue.removeQueue(H),W=null}}
|
|
2
|
+
export{a as pa,E as qa,wY as ra,YY as sa,$Y as ta,D as ua,C as va,MY as wa};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{vk as a}from"./chunk-eqetcfer.js";import"./chunk-x17jyjan.js";export{a as FileSystemPluginStore};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{uk as a}from"./chunk-nwmvyez4.js";import"./chunk-ge071wp4.js";import"./chunk-x17jyjan.js";export{a as FileSystemSkillStore};
|